3.9 KiB
3.9 KiB
Current Architecture
This document describes the code that exists today in the repository.
Runtime Structure
src/main.tsxmounts React and wraps the app inBrowserRouter.src/App.tsxdeclares the top-level routes:/mounts the playable 3D scene, debug perf overlay, and HTML overlays./editormounts the map editor page.
src/world/World.tsxcomposes the active scene, including:- environment and lighting
- 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/world/GameMap.tsxloads map nodes frompublic/map.json, resolves available models, and builds the collision octree.src/world/debug/TestScene.tsxprovides a debug-oriented interaction and physics scene.src/world/player/PlayerComponent.tsxmounts the camera and controller.src/world/player/PlayerController.tsxowns pointer lock movement, jump handling, and interaction input.
Interaction Model
src/stateManager/InteractionManager.tsis the current interaction state source.src/components/3d/InteractableObject.tsxhandles focus detection through distance and raycasting.src/components/3d/TriggerObject.tsximplements trigger-style interactions.src/components/3d/GrabbableObject.tsximplements hold-and-release interactions.src/hooks/useInteraction.tsexposes the interaction snapshot to React UI.src/components/ui/InteractPrompt.tsxshows theEprompt for trigger interactions.
Audio
src/stateManager/AudioManager.tscurrently provides pooled one-shot sound playback.- Trigger interactions may play audio directly through
AudioManager.
Debug System
- Debug mode is enabled with
?debug. src/utils/debug/Debug.tsowns thelil-guiinstance and debug controls.src/hooks/debug/useCameraMode.tsandsrc/hooks/debug/useSceneMode.tssubscribe to debug state.src/utils/debug/DebugPerf.tsxlazily mountsr3f-perfin debug mode.src/utils/debug/scene/DebugHelpers.tsxmounts debug helpers.src/utils/debug/scene/DebugCameraControls.tsxmounts the free debug camera.
Editor System
src/pages/editor/EditorPage.tsxis the route-level editor page for/editor.src/features/editor/components/EditorControls.tsxrenders the HTML editor control panel.src/features/editor/scene/EditorScene.tsxcomposes the editor canvas scene, camera controls, lights, shortcuts, and map rendering.src/features/editor/scene/EditorMap.tsxrenders map nodes, fallback cubes, selection highlighting, and transform controls.src/features/editor/controls/FlyController.tsxprovides player-style editor navigation.src/features/editor/hooks/useEditorSceneData.tsloads scene data and handles folder upload fallback.src/features/editor/hooks/useEditorHistory.tsowns editor undo and redo state.src/utils/editor/loadEditorScene.tshandles editor-only folder upload parsing.src/utils/loadMapSceneData.tsis shared by the game scene and editor to loadpublic/map.jsonand resolve model URLs.src/types/editor.tscontains the sharedMapNode,SceneData, andTransformModetypes.
Map Data
public/map.jsonis expected to be aMapNode[].- Each map node
namemaps topublic/models/{name}/model.gltf. - The editor renders a fallback cube for missing models.
- The game scene filters out nodes whose model cannot be resolved.
Current Limitations
- The repository is still a prototype, not the full intended game runtime.
src/world/debug/TestScene.tsxis still part of the active scene composition.- There is no central gameplay orchestrator such as
GameManageryet. - Missions, zones, cinematics, and dialogue systems are not implemented.
- The player uses octree collision and simple movement rules, not a complete gameplay physics stack.
- Editor save-to-server is implemented as a Vite dev-server plugin, not a production backend API.