From 6854f52b238d2078f564ed851e356898e8208ee7 Mon Sep 17 00:00:00 2001 From: Tom Boullay Date: Mon, 11 May 2026 16:43:02 +0200 Subject: [PATCH] fix: a pb with octree --- src/hooks/three/useOctreeGraphNode.ts | 5 ++++- src/world/GameMap.tsx | 8 ++++++-- src/world/World.tsx | 23 ++++++++++++++++++----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/hooks/three/useOctreeGraphNode.ts b/src/hooks/three/useOctreeGraphNode.ts index 4706fd0..5f6598b 100644 --- a/src/hooks/three/useOctreeGraphNode.ts +++ b/src/hooks/three/useOctreeGraphNode.ts @@ -8,6 +8,7 @@ export function useOctreeGraphNode( graphNodeRef: RefObject, 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]); } diff --git a/src/world/GameMap.tsx b/src/world/GameMap.tsx index f5a4097..41021f6 100644 --- a/src/world/GameMap.tsx +++ b/src/world/GameMap.tsx @@ -62,13 +62,17 @@ class ModelErrorBoundary extends Component< interface GameMapProps { onOctreeReady: OctreeReadyHandler; + buildOctree?: boolean; } -export function GameMap({ onOctreeReady }: GameMapProps): React.JSX.Element { +export function GameMap({ + onOctreeReady, + buildOctree = true, +}: GameMapProps): React.JSX.Element { const [mapNodes, setMapNodes] = useState([]); const groupRef = useRef(null); - useOctreeGraphNode(groupRef, onOctreeReady, mapNodes.length); + useOctreeGraphNode(groupRef, onOctreeReady, mapNodes.length, buildOctree); useEffect(() => { const loadMap = async () => { diff --git a/src/world/World.tsx b/src/world/World.tsx index 454915e..65862f5 100644 --- a/src/world/World.tsx +++ b/src/world/World.tsx @@ -19,10 +19,21 @@ import { GameStageContent } from "@/world/GameStageContent"; import { Player } from "@/world/player/Player"; import { TestMap } from "@/world/debug/TestMap"; +function hasBootFlag(name: string): boolean { + if (typeof window === "undefined") return false; + return new URLSearchParams(window.location.search).has(name); +} + export function World(): React.JSX.Element { const cameraMode = useCameraMode(); const sceneMode = useSceneMode(); const [octree, setOctree] = useState(null); + const noCinematics = hasBootFlag("noCinematics"); + const noDialogues = hasBootFlag("noDialogues"); + const noMap = hasBootFlag("noMap"); + const noMusic = hasBootFlag("noMusic"); + const noOctree = hasBootFlag("noOctree"); + const noPlayer = hasBootFlag("noPlayer"); const playerSpawnPosition = sceneMode === "game" ? PLAYER_SPAWN_POSITION_GAME @@ -43,17 +54,19 @@ export function World(): React.JSX.Element { {sceneMode === "game" ? ( <> - - - - + {noMusic ? null : } + {noCinematics ? null : } + {noDialogues ? null : } + {noMap ? null : ( + + )} ) : ( )} - {cameraMode !== "debug" ? ( + {cameraMode !== "debug" && !noPlayer ? ( ) : null}