debug: add logging for scene loading flow

This commit is contained in:
Tom Boullay
2026-05-14 00:16:28 +02:00
parent 3b4c9c2529
commit d02cf29a1d
3 changed files with 24 additions and 0 deletions
+10
View File
@@ -3,6 +3,7 @@ import type { RefObject } from "react";
import type { Object3D } from "three";
import { Octree } from "three/addons/math/Octree.js";
import type { OctreeReadyHandler } from "@/types/three/three";
import { logger } from "@/utils/core/Logger";
export function useOctreeGraphNode(
graphNodeRef: RefObject<Object3D | null>,
@@ -17,16 +18,25 @@ export function useOctreeGraphNode(
}, [rebuildKey]);
useEffect(() => {
logger.debug("useOctreeGraphNode", "Check", {
enabled,
octreeBuilt: octreeBuilt.current,
hasGraphNode: !!graphNodeRef.current,
rebuildKey,
});
if (!enabled) return;
const graphNode = graphNodeRef.current;
if (!enabled || octreeBuilt.current || !graphNode) return;
octreeBuilt.current = true;
logger.info("useOctreeGraphNode", "Building octree from graph node");
graphNode.updateMatrixWorld(true);
const octree = new Octree();
octree.fromGraphNode(graphNode);
logger.info("useOctreeGraphNode", "Octree built, calling onOctreeReady");
onOctreeReady(octree);
}, [enabled, graphNodeRef, onOctreeReady, rebuildKey]);
}