Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(home): stop the 3D switch reaching for a renderer that does not exist yet

nirholas8521bd8403a9
diff --git a/src/home/scene.js b/src/home/scene.js
index eb74792ce..5c0a060c6 100644
--- a/src/home/scene.js
+++ b/src/home/scene.js
@@ -450,14 +450,22 @@ function setView(view, { remember = true, force = false } = {}) {
if (view === '2d') {
state.renderer = createHomeFallback(el.stage, { onAct: act, onFocusRoom: focusRoom });
state.fpsSince = 0;
+ // The flat house is built synchronously, so the model it already has can
+ // go in right away. The 3D branch deliberately does NOT do this: mount3d
+ // is async (it lazy-imports Three.js) and `state.renderer` is still the
+ // null set above until that import resolves, so reaching for it here
+ // threw "Cannot read properties of null (reading 'setModel')" on every
+ // switch to 3D with a house already loaded. mount3d applies the current
+ // model itself once its renderer exists, which is the only moment that
+ // can work.
+ if (state.model) {
+ state.renderer.setModel(state.model);
+ state.renderer.setStale?.(state.stale);
+ renderEmptyStates(state.model);
+ }
} else {
mount3d();
}
- if (state.model) {
- state.renderer.setModel(state.model);
- state.renderer.setStale?.(state.stale);
- renderEmptyStates(state.model);
- }
renderAge();
}