fix: a pb with octree

This commit is contained in:
Tom Boullay
2026-05-11 16:43:02 +02:00
parent 6f5137229d
commit ff21b80d57
3 changed files with 28 additions and 8 deletions
+4 -1
View File
@@ -8,6 +8,7 @@ export function useOctreeGraphNode(
graphNodeRef: RefObject<Object3D | null>,
onOctreeReady: OctreeReadyHandler,
rebuildKey: string | number = 0,
enabled = true,
): void {
const octreeBuilt = useRef(false);
@@ -16,6 +17,8 @@ export function useOctreeGraphNode(
}, [rebuildKey]);
useEffect(() => {
if (!enabled) return;
const graphNode = graphNodeRef.current;
if (octreeBuilt.current || !graphNode) return;
octreeBuilt.current = true;
@@ -25,5 +28,5 @@ export function useOctreeGraphNode(
const octree = new Octree();
octree.fromGraphNode(graphNode);
onOctreeReady(octree);
}, [graphNodeRef, onOctreeReady, rebuildKey]);
}, [enabled, graphNodeRef, onOctreeReady, rebuildKey]);
}