Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

dispose interior-window InstancedMesh on rebuild to free instanceMatrix VRAM

[._.]/ Adam Eivyf5ed6ca6dc2b
diff --git a/client/src/components/city/BuildingWindows.jsx b/client/src/components/city/BuildingWindows.jsx
index 9a3d6f45ab..65fba8bbd7 100644
--- a/client/src/components/city/BuildingWindows.jsx
+++ b/client/src/components/city/BuildingWindows.jsx
@@ -195,7 +195,10 @@ export default function BuildingWindows({
}, [mesh, dimMul]);
// R3F only auto-disposes objects it created via JSX; these are built
- // imperatively, so free their GPU buffers on replace/unmount ourselves.
+ // imperatively, so free their GPU buffers on replace/unmount ourselves. The
+ // mesh is recreated whenever the material is rebuilt (theme/brightness change),
+ // so its instanceMatrix buffer must be freed too — <primitive> won't.
+ useEffect(() => (mesh ? () => mesh.dispose() : undefined), [mesh]);
useEffect(() => (built ? () => built.geo.dispose() : undefined), [built]);
useEffect(() => (material ? () => material.dispose() : undefined), [material]);