diff --git a/docs/technical/architecture.md b/docs/technical/architecture.md index bce96e2..b10ff54 100644 --- a/docs/technical/architecture.md +++ b/docs/technical/architecture.md @@ -13,7 +13,7 @@ This document describes the code that exists today in the repository. - debug helpers and debug camera mode - either the map scene or the debug physics test scene - the player rig when the active camera mode is `player` -- `src/components/game/GameMap.tsx` loads map nodes from `public/map.json`, resolves available models, and builds the collision octree. +- `src/world/GameMap.tsx` loads map nodes from `public/map.json`, resolves available models, and builds the collision octree. - `src/world/debug/TestScene.tsx` provides a debug-oriented interaction and physics scene. - `src/world/player/PlayerComponent.tsx` mounts the camera and controller. - `src/world/player/PlayerController.tsx` owns pointer lock movement, jump handling, and interaction input. @@ -50,7 +50,7 @@ This document describes the code that exists today in the repository. - `src/features/editor/controls/FlyController.tsx` provides player-style editor navigation. - `src/features/editor/hooks/useEditorSceneData.ts` loads scene data and handles folder upload fallback. - `src/features/editor/hooks/useEditorHistory.ts` owns editor undo and redo state. -- `src/features/editor/utils/loadEditorScene.ts` handles editor-only folder upload parsing. +- `src/utils/editor/loadEditorScene.ts` handles editor-only folder upload parsing. - `src/utils/loadMapSceneData.ts` is shared by the game scene and editor to load `public/map.json` and resolve model URLs. - `src/types/editor.ts` contains the shared `MapNode`, `SceneData`, and `TransformMode` types. diff --git a/docs/technical/editor.md b/docs/technical/editor.md index 46b6d68..35e9761 100644 --- a/docs/technical/editor.md +++ b/docs/technical/editor.md @@ -32,11 +32,11 @@ src/ │ ├── scene/ │ │ ├── EditorMap.tsx │ │ └── EditorScene.tsx -│ └── utils/ -│ └── loadEditorScene.ts ├── types/ │ └── editor.ts └── utils/ + ├── editor/ + │ └── loadEditorScene.ts └── loadMapSceneData.ts ``` @@ -58,7 +58,7 @@ src/ `src/utils/loadMapSceneData.ts` is shared by the game map and editor. It loads `/map.json` and resolves available `public/models/{name}/model.gltf` files. -`src/features/editor/utils/loadEditorScene.ts` contains editor-only upload handling for user-selected folders. +`src/utils/editor/loadEditorScene.ts` contains editor-only upload handling for user-selected folders. ## Data Format diff --git a/src/features/editor/hooks/useEditorSceneData.ts b/src/features/editor/hooks/useEditorSceneData.ts index aab1b63..ffdab7b 100644 --- a/src/features/editor/hooks/useEditorSceneData.ts +++ b/src/features/editor/hooks/useEditorSceneData.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from "react"; -import { createSceneDataFromFiles } from "@/features/editor/utils/loadEditorScene"; +import { createSceneDataFromFiles } from "@/utils/editor/loadEditorScene"; import { loadMapSceneData } from "@/utils/loadMapSceneData"; import type { SceneData } from "@/types/editor"; diff --git a/src/features/editor/utils/loadEditorScene.ts b/src/utils/editor/loadEditorScene.ts similarity index 100% rename from src/features/editor/utils/loadEditorScene.ts rename to src/utils/editor/loadEditorScene.ts diff --git a/src/components/game/GameMap.tsx b/src/world/GameMap.tsx similarity index 100% rename from src/components/game/GameMap.tsx rename to src/world/GameMap.tsx diff --git a/src/world/Map.tsx b/src/world/Map.tsx deleted file mode 100644 index 17a7d8f..0000000 --- a/src/world/Map.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { useEffect, useRef } from "react"; -import { useThree } from "@react-three/fiber"; -import { useGLTF } from "@react-three/drei"; -import * as THREE from "three"; -import { MAP_DEBUG_BOX_HELPER_COLOR } from "@/data/debugConfig"; -import { useOctreeGraphNode } from "@/hooks/useOctreeGraphNode"; -import type { OctreeReadyHandler } from "@/types/3d"; -import { Debug } from "@/utils/debug/Debug"; - -const MAP_PATH = "/models/map/model.gltf"; - -interface MapProps { - onOctreeReady: OctreeReadyHandler; -} - -export function Map({ onOctreeReady }: MapProps): React.JSX.Element { - const { scene: gltfScene } = useGLTF(MAP_PATH); - const groupRef = useRef(null); - const boxHelpersRef = useRef([]); - const { scene } = useThree(); - - useOctreeGraphNode(groupRef, onOctreeReady); - - useEffect(() => { - const debug = Debug.getInstance(); - if (!debug.active || !groupRef.current) return; - - const helpers: THREE.BoxHelper[] = []; - - groupRef.current.traverse((child) => { - if (!(child instanceof THREE.Mesh)) return; - const helper = new THREE.BoxHelper(child, MAP_DEBUG_BOX_HELPER_COLOR); - scene.add(helper); - helpers.push(helper); - }); - - boxHelpersRef.current = helpers; - - return () => { - helpers.forEach((h) => { - scene.remove(h); - h.dispose(); - }); - boxHelpersRef.current = []; - }; - }, [scene]); - - return ( - - - - ); -} - -useGLTF.preload(MAP_PATH); diff --git a/src/world/World.tsx b/src/world/World.tsx index b7a68ef..3798050 100644 --- a/src/world/World.tsx +++ b/src/world/World.tsx @@ -10,7 +10,7 @@ import { DebugCameraControls } from "@/utils/debug/scene/DebugCameraControls"; import { DebugHelpers } from "@/utils/debug/scene/DebugHelpers"; import { Environment } from "@/world/Environment"; import { Lighting } from "@/world/Lighting"; -import { GameMap } from "@/components/game/GameMap"; +import { GameMap } from "@/world/GameMap"; import { PlayerComponent } from "@/world/player/PlayerComponent"; import { TestScene } from "@/world/debug/TestScene";