fix runtime map loading lifecycle

This commit is contained in:
2026-04-28 14:42:49 +02:00
parent 8c6af0ed6d
commit 7e99d455b4
7 changed files with 65 additions and 44 deletions
+6 -1
View File
@@ -7,9 +7,14 @@ import type { OctreeReadyHandler } from "@/types/3d";
export function useOctreeGraphNode(
graphNodeRef: RefObject<Object3D | null>,
onOctreeReady: OctreeReadyHandler,
rebuildKey: string | number = 0,
): void {
const octreeBuilt = useRef(false);
useEffect(() => {
octreeBuilt.current = false;
}, [rebuildKey]);
useEffect(() => {
const graphNode = graphNodeRef.current;
if (octreeBuilt.current || !graphNode) return;
@@ -20,5 +25,5 @@ export function useOctreeGraphNode(
const octree = new Octree();
octree.fromGraphNode(graphNode);
onOctreeReady(octree);
}, [graphNodeRef, onOctreeReady]);
}, [graphNodeRef, onOctreeReady, rebuildKey]);
}