From b1187b68aea9d6435cae53a8155bca0040e3f7de Mon Sep 17 00:00:00 2001 From: Tom Boullay Date: Thu, 30 Apr 2026 11:49:18 +0200 Subject: [PATCH] refactor: split hooks types and utils by domain --- docs/technical/architecture.md | 6 +++--- docs/technical/editor.md | 4 ++-- docs/technical/hand-tracking.md | 4 ++-- .../debug/scene/DebugCameraControls.tsx | 2 +- src/components/editor/EditorControls.tsx | 2 +- src/components/editor/scene/EditorMap.tsx | 2 +- src/components/editor/scene/EditorScene.tsx | 2 +- .../{repairGame => }/RepairCaseModel.tsx | 4 ++-- .../{repairGame => }/RepairCaseObject.tsx | 6 +++--- .../{repairGame => }/RepairGameZone.tsx | 6 +++--- .../{repairGame => }/RepairModuleSlot.tsx | 8 ++++---- .../three/interaction/GrabbableObject.tsx | 17 ++++++++--------- .../three/interaction/InteractableObject.tsx | 4 ++-- .../three/interaction/TriggerObject.tsx | 2 +- src/components/three/models/AnimatedModel.tsx | 2 +- src/components/three/models/ExplodableModel.tsx | 6 +++--- src/components/three/models/SimpleModel.tsx | 2 +- src/components/ui/Crosshair.tsx | 2 +- src/components/ui/HandTrackingOverlay.tsx | 4 ++-- src/components/ui/HandTrackingVisualizer.tsx | 2 +- src/components/ui/InteractPrompt.tsx | 2 +- src/data/debug/testSceneConfig.ts | 2 +- src/data/docs/docsTranslations.ts | 2 +- .../repairCaseConfig.ts | 0 .../repairGameConfig.ts | 2 +- .../repairGameModelCatalog.ts | 0 src/data/interaction/triggerConfig.ts | 2 +- src/data/player/playerConfig.ts | 2 +- .../{ => animation}/useCharacterAnimation.ts | 0 src/hooks/debug/useCameraMode.ts | 2 +- src/hooks/debug/useSceneMode.ts | 2 +- src/hooks/editor/useEditorHistory.ts | 2 +- src/hooks/editor/useEditorSceneData.ts | 4 ++-- src/hooks/{ => gameplay}/useModelSelection.ts | 2 +- .../useHandTrackingSnapshot.ts | 2 +- .../{ => handTracking}/useRemoteHandTracking.ts | 2 +- src/hooks/{ => interaction}/useInteraction.ts | 2 +- src/hooks/{ => three}/useOctreeGraphNode.ts | 2 +- src/managers/AudioManager.ts | 2 +- src/managers/InteractionManager.ts | 2 +- src/pages/editor/page.tsx | 2 +- src/pages/page.tsx | 2 +- .../gameplay}/HandTrackingProvider.tsx | 6 +++--- src/router.tsx | 2 +- .../DocsRouteComponents.tsx => DocsRoute.tsx} | 0 src/types/{ => debug}/debug.ts | 0 src/types/{ => editor}/editor.ts | 2 +- src/types/{ => handTracking}/handTracking.ts | 0 src/types/{ => interaction}/interaction.ts | 0 src/types/{ => logger}/logger.ts | 0 src/types/{ => three}/three-addons.d.ts | 0 src/types/{ => three}/three.ts | 0 src/utils/{ => core}/EventEmitter.ts | 0 src/utils/{ => core}/Sizes.ts | 0 src/utils/{ => core}/Time.ts | 0 src/utils/{ => core}/logger.ts | 2 +- src/utils/debug/Debug.ts | 2 +- src/utils/editor/loadEditorScene.ts | 4 ++-- src/utils/{ => map}/loadMapSceneData.ts | 4 ++-- src/utils/{ => map}/mapNodeValidation.ts | 2 +- src/utils/{ => three}/ExplodedModel.ts | 0 src/world/GameMap.tsx | 8 ++++---- src/world/debug/TestMap.tsx | 4 ++-- src/world/player/Player.tsx | 2 +- src/world/player/PlayerController.tsx | 2 +- 65 files changed, 83 insertions(+), 84 deletions(-) rename src/components/three/gameplay/{repairGame => }/RepairCaseModel.tsx (97%) rename src/components/three/gameplay/{repairGame => }/RepairCaseObject.tsx (83%) rename src/components/three/gameplay/{repairGame => }/RepairGameZone.tsx (89%) rename src/components/three/gameplay/{repairGame => }/RepairModuleSlot.tsx (89%) rename src/data/{repairGame => gameplay}/repairCaseConfig.ts (100%) rename src/data/{repairGame => gameplay}/repairGameConfig.ts (88%) rename src/data/{repairGame => gameplay}/repairGameModelCatalog.ts (100%) rename src/hooks/{ => animation}/useCharacterAnimation.ts (100%) rename src/hooks/{ => gameplay}/useModelSelection.ts (95%) rename src/hooks/{ => handTracking}/useHandTrackingSnapshot.ts (84%) rename src/hooks/{ => handTracking}/useRemoteHandTracking.ts (99%) rename src/hooks/{ => interaction}/useInteraction.ts (81%) rename src/hooks/{ => three}/useOctreeGraphNode.ts (92%) rename src/{components/ui => providers/gameplay}/HandTrackingProvider.tsx (75%) rename src/routes/{docs/DocsRouteComponents.tsx => DocsRoute.tsx} (100%) rename src/types/{ => debug}/debug.ts (100%) rename src/types/{ => editor}/editor.ts (83%) rename src/types/{ => handTracking}/handTracking.ts (100%) rename src/types/{ => interaction}/interaction.ts (100%) rename src/types/{ => logger}/logger.ts (100%) rename src/types/{ => three}/three-addons.d.ts (100%) rename src/types/{ => three}/three.ts (100%) rename src/utils/{ => core}/EventEmitter.ts (100%) rename src/utils/{ => core}/Sizes.ts (100%) rename src/utils/{ => core}/Time.ts (100%) rename src/utils/{ => core}/logger.ts (98%) rename src/utils/{ => map}/loadMapSceneData.ts (91%) rename src/utils/{ => map}/mapNodeValidation.ts (93%) rename src/utils/{ => three}/ExplodedModel.ts (100%) diff --git a/docs/technical/architecture.md b/docs/technical/architecture.md index 87ad7c5..1464c8d 100644 --- a/docs/technical/architecture.md +++ b/docs/technical/architecture.md @@ -25,7 +25,7 @@ This document describes the code that exists today in the repository. - `src/components/three/interaction/InteractableObject.tsx` handles focus detection through distance and raycasting. - `src/components/three/interaction/TriggerObject.tsx` implements trigger-style interactions. - `src/components/three/interaction/GrabbableObject.tsx` implements hold-and-release interactions. -- `src/hooks/useInteraction.ts` exposes the interaction snapshot to React UI. +- `src/hooks/interaction/useInteraction.ts` exposes the interaction snapshot to React UI. - `src/components/ui/InteractPrompt.tsx` shows the `E` prompt for trigger interactions. ## Audio @@ -59,8 +59,8 @@ This document describes the code that exists today in the repository. - `src/hooks/editor/useEditorSceneData.ts` loads scene data and handles folder upload fallback. - `src/hooks/editor/useEditorHistory.ts` owns editor undo and redo state. - `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. +- `src/utils/map/loadMapSceneData.ts` is shared by the game scene and editor to load `public/map.json` and resolve model URLs. +- `src/types/editor/editor.ts` contains the shared `MapNode`, `SceneData`, and `TransformMode` types. ## Map Data diff --git a/docs/technical/editor.md b/docs/technical/editor.md index c927047..c232513 100644 --- a/docs/technical/editor.md +++ b/docs/technical/editor.md @@ -57,13 +57,13 @@ src/ `src/controls/editor/FlyController.tsx` provides editor movement controls for player-style navigation. -`src/utils/loadMapSceneData.ts` is shared by the game map and editor. It loads `/map.json` and resolves available `public/models/{name}/model.glb` files first, then falls back to `public/models/{name}/model.gltf`. +`src/utils/map/loadMapSceneData.ts` is shared by the game map and editor. It loads `/map.json` and resolves available `public/models/{name}/model.glb` files first, then falls back to `public/models/{name}/model.gltf`. `src/utils/editor/loadEditorScene.ts` contains editor-only upload handling for user-selected folders. ## Data Format -The shared editor type lives in `src/types/editor.ts`. +The shared editor type lives in `src/types/editor/editor.ts`. ```ts interface MapNode { diff --git a/docs/technical/hand-tracking.md b/docs/technical/hand-tracking.md index 38072d4..9a9db9e 100644 --- a/docs/technical/hand-tracking.md +++ b/docs/technical/hand-tracking.md @@ -10,7 +10,7 @@ The feature is currently scoped to the debug physics scene and is not yet a prod ## Runtime Flow -1. The browser captures webcam frames in `src/hooks/useRemoteHandTracking.ts`. +1. The browser captures webcam frames in `src/hooks/handTracking/useRemoteHandTracking.ts`. 2. Frames are sent to the local Python backend over WebSocket. 3. The backend runs MediaPipe hand landmark detection. 4. The backend returns hand data including landmarks, handedness, score, center point, and `isFist`. @@ -46,7 +46,7 @@ The backend sends normalized hand coordinates and landmarks. The frontend treats ## Frontend Data Shape -The shared types live in `src/types/handTracking.ts`. +The shared types live in `src/types/handTracking/handTracking.ts`. ```ts interface HandTrackingHand { diff --git a/src/components/debug/scene/DebugCameraControls.tsx b/src/components/debug/scene/DebugCameraControls.tsx index 11acdb0..8a83c21 100644 --- a/src/components/debug/scene/DebugCameraControls.tsx +++ b/src/components/debug/scene/DebugCameraControls.tsx @@ -8,7 +8,7 @@ import { PLAYER_EYE_HEIGHT, PLAYER_SPAWN_POSITION_GAME, } from "@/data/player/playerConfig"; -import type { Vector3Tuple } from "@/types/three"; +import type { Vector3Tuple } from "@/types/three/three"; const DEBUG_CAMERA_TARGET: Vector3Tuple = [ PLAYER_SPAWN_POSITION_GAME[0], diff --git a/src/components/editor/EditorControls.tsx b/src/components/editor/EditorControls.tsx index e68cd70..143d666 100644 --- a/src/components/editor/EditorControls.tsx +++ b/src/components/editor/EditorControls.tsx @@ -12,7 +12,7 @@ import { Save, Undo2, } from "lucide-react"; -import type { MapNode, TransformMode } from "@/types/editor"; +import type { MapNode, TransformMode } from "@/types/editor/editor"; interface EditorControlsProps { transformMode: TransformMode; diff --git a/src/components/editor/scene/EditorMap.tsx b/src/components/editor/scene/EditorMap.tsx index 8b94718..c63f36c 100644 --- a/src/components/editor/scene/EditorMap.tsx +++ b/src/components/editor/scene/EditorMap.tsx @@ -3,7 +3,7 @@ import { Grid, TransformControls, useGLTF } from "@react-three/drei"; import type { ThreeEvent } from "@react-three/fiber"; import * as THREE from "three"; -import type { SceneData, MapNode, TransformMode } from "@/types/editor"; +import type { SceneData, MapNode, TransformMode } from "@/types/editor/editor"; interface EditorMapProps { sceneData: SceneData; diff --git a/src/components/editor/scene/EditorScene.tsx b/src/components/editor/scene/EditorScene.tsx index 000b681..0e1ec58 100644 --- a/src/components/editor/scene/EditorScene.tsx +++ b/src/components/editor/scene/EditorScene.tsx @@ -2,7 +2,7 @@ import { useEffect } from "react"; import { OrbitControls } from "@react-three/drei"; import { EditorMap } from "@/components/editor/scene/EditorMap"; import { FlyController } from "@/controls/editor/FlyController"; -import type { MapNode, TransformMode, SceneData } from "@/types/editor"; +import type { MapNode, TransformMode, SceneData } from "@/types/editor/editor"; interface EditorSceneProps { sceneData: SceneData; diff --git a/src/components/three/gameplay/repairGame/RepairCaseModel.tsx b/src/components/three/gameplay/RepairCaseModel.tsx similarity index 97% rename from src/components/three/gameplay/repairGame/RepairCaseModel.tsx rename to src/components/three/gameplay/RepairCaseModel.tsx index 7a405bf..65d6c52 100644 --- a/src/components/three/gameplay/repairGame/RepairCaseModel.tsx +++ b/src/components/three/gameplay/RepairCaseModel.tsx @@ -14,8 +14,8 @@ import { REPAIR_CASE_OPEN_ROTATION_OFFSET_DEGREES, REPAIR_CASE_ROTATION_AMPLITUDE_DEGREES, REPAIR_CASE_ROTATION_RESET_SPEED, -} from "@/data/repairGame/repairCaseConfig"; -import type { Vector3Tuple } from "@/types/three"; +} from "@/data/gameplay/repairCaseConfig"; +import type { Vector3Tuple } from "@/types/three/three"; interface RepairCaseModelProps { modelPath: string; diff --git a/src/components/three/gameplay/repairGame/RepairCaseObject.tsx b/src/components/three/gameplay/RepairCaseObject.tsx similarity index 83% rename from src/components/three/gameplay/repairGame/RepairCaseObject.tsx rename to src/components/three/gameplay/RepairCaseObject.tsx index a877e08..1371f3c 100644 --- a/src/components/three/gameplay/repairGame/RepairCaseObject.tsx +++ b/src/components/three/gameplay/RepairCaseObject.tsx @@ -1,12 +1,12 @@ import { TriggerObject } from "@/components/three/interaction/TriggerObject"; -import { RepairCaseModel } from "@/components/three/gameplay/repairGame/RepairCaseModel"; +import { RepairCaseModel } from "@/components/three/gameplay/RepairCaseModel"; import { REPAIR_CASE_CLOSE_SOUND_PATH, REPAIR_CASE_MODEL_PATH, REPAIR_CASE_OPEN_SOUND_PATH, -} from "@/data/repairGame/repairCaseConfig"; +} from "@/data/gameplay/repairCaseConfig"; import { AudioManager } from "@/managers/AudioManager"; -import type { Vector3Tuple } from "@/types/three"; +import type { Vector3Tuple } from "@/types/three/three"; interface RepairCaseObjectProps { position: Vector3Tuple; diff --git a/src/components/three/gameplay/repairGame/RepairGameZone.tsx b/src/components/three/gameplay/RepairGameZone.tsx similarity index 89% rename from src/components/three/gameplay/repairGame/RepairGameZone.tsx rename to src/components/three/gameplay/RepairGameZone.tsx index e6397a9..31dfeb5 100644 --- a/src/components/three/gameplay/repairGame/RepairGameZone.tsx +++ b/src/components/three/gameplay/RepairGameZone.tsx @@ -1,13 +1,13 @@ import { useState } from "react"; import { Text } from "@react-three/drei"; -import { RepairCaseObject } from "@/components/three/gameplay/repairGame/RepairCaseObject"; -import { RepairModuleSlot } from "@/components/three/gameplay/repairGame/RepairModuleSlot"; +import { RepairCaseObject } from "@/components/three/gameplay/RepairCaseObject"; +import { RepairModuleSlot } from "@/components/three/gameplay/RepairModuleSlot"; import { REPAIR_GAME_MODULE_SLOTS, REPAIR_GAME_ZONE_LABEL, REPAIR_GAME_ZONE_ORIGIN, REPAIR_GAME_ZONE_RADIUS, -} from "@/data/repairGame/repairGameConfig"; +} from "@/data/gameplay/repairGameConfig"; export function RepairGameZone(): React.JSX.Element { const [caseOpen, setCaseOpen] = useState(false); diff --git a/src/components/three/gameplay/repairGame/RepairModuleSlot.tsx b/src/components/three/gameplay/RepairModuleSlot.tsx similarity index 89% rename from src/components/three/gameplay/repairGame/RepairModuleSlot.tsx rename to src/components/three/gameplay/RepairModuleSlot.tsx index 0d1f80a..630fdca 100644 --- a/src/components/three/gameplay/repairGame/RepairModuleSlot.tsx +++ b/src/components/three/gameplay/RepairModuleSlot.tsx @@ -2,10 +2,10 @@ import { Html } from "@react-three/drei"; import { useCallback, useState } from "react"; import { TriggerObject } from "@/components/three/interaction/TriggerObject"; import { ExplodableModel } from "@/components/three/models/ExplodableModel"; -import { REPAIR_GAME_MODEL_CATALOG } from "@/data/repairGame/repairGameModelCatalog"; -import type { ModelCatalogItem } from "@/data/repairGame/repairGameModelCatalog"; -import { useModelSelection } from "@/hooks/useModelSelection"; -import type { Vector3Tuple } from "@/types/three"; +import { REPAIR_GAME_MODEL_CATALOG } from "@/data/gameplay/repairGameModelCatalog"; +import type { ModelCatalogItem } from "@/data/gameplay/repairGameModelCatalog"; +import { useModelSelection } from "@/hooks/gameplay/useModelSelection"; +import type { Vector3Tuple } from "@/types/three/three"; interface RepairModuleSlotProps { position: Vector3Tuple; diff --git a/src/components/three/interaction/GrabbableObject.tsx b/src/components/three/interaction/GrabbableObject.tsx index 5b5b67b..3a1bc4c 100644 --- a/src/components/three/interaction/GrabbableObject.tsx +++ b/src/components/three/interaction/GrabbableObject.tsx @@ -22,13 +22,13 @@ import { } from "@/data/interaction/grabConfig"; import { INTERACTION_RADIUS } from "@/data/interaction/interactionConfig"; import { useDebugFolder } from "@/hooks/debug/useDebugFolder"; -import { useHandTrackingSnapshot } from "@/hooks/useHandTrackingSnapshot"; +import { useHandTrackingSnapshot } from "@/hooks/handTracking/useHandTrackingSnapshot"; import { InteractionManager } from "@/managers/InteractionManager"; import type { HandTrackingHand, HandTrackingLandmark, -} from "@/types/handTracking"; -import type { ColliderShape, Vector3Tuple } from "@/types/three"; +} from "@/types/handTracking/handTracking"; +import type { ColliderShape, Vector3Tuple } from "@/types/three/three"; interface GrabbableObjectProps { position: Vector3Tuple; @@ -38,7 +38,6 @@ interface GrabbableObjectProps { handControlled?: boolean; } -// Shared params let one debug folder drive every instance. const grabDebugParams = { stiffness: GRAB_STIFFNESS_DEFAULT, throwBoost: GRAB_THROW_BOOST_DEFAULT, @@ -74,10 +73,10 @@ function getHandCenterPoint(hand: HandTrackingHand): HandTrackingLandmark { return { x: hand.x, y: hand.y, z: hand.z }; } - let minX = landmarks[0].x; - let maxX = landmarks[0].x; - let minY = landmarks[0].y; - let maxY = landmarks[0].y; + let minX = landmarks[0]!.x; + let maxX = landmarks[0]!.x; + let minY = landmarks[0]!.y; + let maxY = landmarks[0]!.y; landmarks.forEach((landmark) => { minX = Math.min(minX, landmark.x); @@ -112,7 +111,7 @@ function getHandHit( _handRaycaster.far = INTERACTION_RADIUS; const hits = _handRaycaster.intersectObject(group, true); - if (hits.length > 0) return hits[0]; + if (hits?.length > 0) return hits[0] ?? null; } return null; diff --git a/src/components/three/interaction/InteractableObject.tsx b/src/components/three/interaction/InteractableObject.tsx index 4385d01..501eb9d 100644 --- a/src/components/three/interaction/InteractableObject.tsx +++ b/src/components/three/interaction/InteractableObject.tsx @@ -13,8 +13,8 @@ import { Debug } from "@/utils/debug/Debug"; import { useDebugFolder } from "@/hooks/debug/useDebugFolder"; import { InteractionManager } from "@/managers/InteractionManager"; import { INTERACTION_RADIUS } from "@/data/interaction/interactionConfig"; -import type { Vector3Tuple } from "@/types/three"; -import type { InteractableHandle } from "@/types/interaction"; +import type { InteractableHandle } from "@/types/interaction/interaction"; +import type { Vector3Tuple } from "@/types/three/three"; interface InteractableObjectBaseProps { label: string; diff --git a/src/components/three/interaction/TriggerObject.tsx b/src/components/three/interaction/TriggerObject.tsx index cd2ea29..cc609fc 100644 --- a/src/components/three/interaction/TriggerObject.tsx +++ b/src/components/three/interaction/TriggerObject.tsx @@ -9,7 +9,7 @@ import { TRIGGER_DEFAULT_SPAWN_OFFSET, } from "@/data/interaction/triggerConfig"; import { AudioManager } from "@/managers/AudioManager"; -import type { ColliderShape, Vector3Tuple } from "@/types/three"; +import type { ColliderShape, Vector3Tuple } from "@/types/three/three"; interface SpawnedModel { id: number; diff --git a/src/components/three/models/AnimatedModel.tsx b/src/components/three/models/AnimatedModel.tsx index 2770223..0f7e98c 100644 --- a/src/components/three/models/AnimatedModel.tsx +++ b/src/components/three/models/AnimatedModel.tsx @@ -6,7 +6,7 @@ import { AnimatedModelContext, type AnimatedModelContextValue, } from "@/components/three/models/useAnimatedModel"; -import type { Vector3Tuple } from "@/types/three"; +import type { Vector3Tuple } from "@/types/three/three"; export interface AnimatedModelConfig { modelPath: string; diff --git a/src/components/three/models/ExplodableModel.tsx b/src/components/three/models/ExplodableModel.tsx index daa1d68..7c2d77a 100644 --- a/src/components/three/models/ExplodableModel.tsx +++ b/src/components/three/models/ExplodableModel.tsx @@ -2,8 +2,8 @@ import type { ReactNode } from "react"; import { Component, useEffect, useMemo } from "react"; import { useFrame } from "@react-three/fiber"; import { useGLTF } from "@react-three/drei"; -import { ExplodedModel } from "@/utils/ExplodedModel"; -import type { Vector3Tuple } from "@/types/three"; +import { ExplodedModel } from "@/utils/three/ExplodedModel"; +import type { Vector3Tuple } from "@/types/three/three"; interface ModelErrorBoundaryProps { children: ReactNode; @@ -52,7 +52,7 @@ export function ExplodableModel( return ( } + fallback={} > diff --git a/src/components/three/models/SimpleModel.tsx b/src/components/three/models/SimpleModel.tsx index 4d07416..e536619 100644 --- a/src/components/three/models/SimpleModel.tsx +++ b/src/components/three/models/SimpleModel.tsx @@ -1,6 +1,6 @@ import { useMemo } from "react"; import { useGLTF } from "@react-three/drei"; -import type { Vector3Tuple } from "@/types/three"; +import type { Vector3Tuple } from "@/types/three/three"; export interface SimpleModelConfig { modelPath: string; diff --git a/src/components/ui/Crosshair.tsx b/src/components/ui/Crosshair.tsx index dae485e..bc032fe 100644 --- a/src/components/ui/Crosshair.tsx +++ b/src/components/ui/Crosshair.tsx @@ -1,5 +1,5 @@ import { useCameraMode } from "@/hooks/debug/useCameraMode"; -import { useInteraction } from "@/hooks/useInteraction"; +import { useInteraction } from "@/hooks/interaction/useInteraction"; export function Crosshair(): React.JSX.Element | null { const cameraMode = useCameraMode(); diff --git a/src/components/ui/HandTrackingOverlay.tsx b/src/components/ui/HandTrackingOverlay.tsx index 4a415a9..50bb879 100644 --- a/src/components/ui/HandTrackingOverlay.tsx +++ b/src/components/ui/HandTrackingOverlay.tsx @@ -1,5 +1,5 @@ -import { useHandTrackingSnapshot } from "@/hooks/useHandTrackingSnapshot"; -import type { HandTrackingStatus } from "@/types/handTracking"; +import { useHandTrackingSnapshot } from "@/hooks/handTracking/useHandTrackingSnapshot"; +import type { HandTrackingStatus } from "@/types/handTracking/handTracking"; const STATUS_LABELS: Record = { idle: "Idle", diff --git a/src/components/ui/HandTrackingVisualizer.tsx b/src/components/ui/HandTrackingVisualizer.tsx index bd70691..6ce2f47 100644 --- a/src/components/ui/HandTrackingVisualizer.tsx +++ b/src/components/ui/HandTrackingVisualizer.tsx @@ -1,4 +1,4 @@ -import { useHandTrackingSnapshot } from "@/hooks/useHandTrackingSnapshot"; +import { useHandTrackingSnapshot } from "@/hooks/handTracking/useHandTrackingSnapshot"; const HAND_CONNECTIONS: Array<[number, number]> = [ [0, 1], diff --git a/src/components/ui/InteractPrompt.tsx b/src/components/ui/InteractPrompt.tsx index 70b09db..56d21db 100644 --- a/src/components/ui/InteractPrompt.tsx +++ b/src/components/ui/InteractPrompt.tsx @@ -1,6 +1,6 @@ import { INTERACT_KEY } from "@/data/input/keybindings"; import { useCameraMode } from "@/hooks/debug/useCameraMode"; -import { useInteraction } from "@/hooks/useInteraction"; +import { useInteraction } from "@/hooks/interaction/useInteraction"; export function InteractPrompt(): React.JSX.Element | null { const cameraMode = useCameraMode(); diff --git a/src/data/debug/testSceneConfig.ts b/src/data/debug/testSceneConfig.ts index 545db0b..568967b 100644 --- a/src/data/debug/testSceneConfig.ts +++ b/src/data/debug/testSceneConfig.ts @@ -1,4 +1,4 @@ -import type { Vector3Tuple } from "@/types/three"; +import type { Vector3Tuple } from "@/types/three/three"; export const TEST_SCENE_FLOOR_POSITION: Vector3Tuple = [0, -0.5, 0]; export const TEST_SCENE_FLOOR_SIZE: Vector3Tuple = [200, 1, 200]; diff --git a/src/data/docs/docsTranslations.ts b/src/data/docs/docsTranslations.ts index 18385c7..8a01bd3 100644 --- a/src/data/docs/docsTranslations.ts +++ b/src/data/docs/docsTranslations.ts @@ -109,7 +109,7 @@ Ce document décrit le code réellement présent aujourd'hui dans le dépôt. - \`src/components/three/interaction/InteractableObject.tsx\` gère la détection de focus par distance et raycasting. - \`src/components/three/interaction/TriggerObject.tsx\` implémente les interactions de type trigger. - \`src/components/three/interaction/GrabbableObject.tsx\` implémente les interactions saisir / relâcher. -- \`src/hooks/useInteraction.ts\` expose un snapshot d'interaction à l'UI React. +- \`src/hooks/interaction/useInteraction.ts\` expose un snapshot d'interaction à l'UI React. - \`src/components/ui/InteractPrompt.tsx\` affiche le prompt \`E\` pour les interactions trigger. ## Audio diff --git a/src/data/repairGame/repairCaseConfig.ts b/src/data/gameplay/repairCaseConfig.ts similarity index 100% rename from src/data/repairGame/repairCaseConfig.ts rename to src/data/gameplay/repairCaseConfig.ts diff --git a/src/data/repairGame/repairGameConfig.ts b/src/data/gameplay/repairGameConfig.ts similarity index 88% rename from src/data/repairGame/repairGameConfig.ts rename to src/data/gameplay/repairGameConfig.ts index f92d896..6fd67af 100644 --- a/src/data/repairGame/repairGameConfig.ts +++ b/src/data/gameplay/repairGameConfig.ts @@ -1,4 +1,4 @@ -import type { Vector3Tuple } from "@/types/three"; +import type { Vector3Tuple } from "@/types/three/three"; export const REPAIR_GAME_ZONE_ORIGIN: Vector3Tuple = [10, 0.4, -8]; export const REPAIR_GAME_ZONE_RADIUS = 4.2; diff --git a/src/data/repairGame/repairGameModelCatalog.ts b/src/data/gameplay/repairGameModelCatalog.ts similarity index 100% rename from src/data/repairGame/repairGameModelCatalog.ts rename to src/data/gameplay/repairGameModelCatalog.ts diff --git a/src/data/interaction/triggerConfig.ts b/src/data/interaction/triggerConfig.ts index 46bf396..d9120f0 100644 --- a/src/data/interaction/triggerConfig.ts +++ b/src/data/interaction/triggerConfig.ts @@ -1,4 +1,4 @@ -import type { Vector3Tuple } from "@/types/three"; +import type { Vector3Tuple } from "@/types/three/three"; export const TRIGGER_DEFAULT_COLLIDERS = "ball"; export const TRIGGER_DEFAULT_LABEL = "Interagir"; diff --git a/src/data/player/playerConfig.ts b/src/data/player/playerConfig.ts index a8b60ea..699ee49 100644 --- a/src/data/player/playerConfig.ts +++ b/src/data/player/playerConfig.ts @@ -1,4 +1,4 @@ -import type { Vector3Tuple } from "@/types/three"; +import type { Vector3Tuple } from "@/types/three/three"; export const PLAYER_EYE_HEIGHT = 1.75; export const PLAYER_CAPSULE_RADIUS = 0.35; diff --git a/src/hooks/useCharacterAnimation.ts b/src/hooks/animation/useCharacterAnimation.ts similarity index 100% rename from src/hooks/useCharacterAnimation.ts rename to src/hooks/animation/useCharacterAnimation.ts diff --git a/src/hooks/debug/useCameraMode.ts b/src/hooks/debug/useCameraMode.ts index 90976f6..73cfa93 100644 --- a/src/hooks/debug/useCameraMode.ts +++ b/src/hooks/debug/useCameraMode.ts @@ -1,4 +1,4 @@ -import type { CameraMode } from "@/types/debug"; +import type { CameraMode } from "@/types/debug/debug"; import { useDebugStore } from "@/hooks/debug/useDebugStore"; export function useCameraMode(): CameraMode { diff --git a/src/hooks/debug/useSceneMode.ts b/src/hooks/debug/useSceneMode.ts index 5d14254..4af9129 100644 --- a/src/hooks/debug/useSceneMode.ts +++ b/src/hooks/debug/useSceneMode.ts @@ -1,4 +1,4 @@ -import type { SceneMode } from "@/types/debug"; +import type { SceneMode } from "@/types/debug/debug"; import { useDebugStore } from "@/hooks/debug/useDebugStore"; export function useSceneMode(): SceneMode { diff --git a/src/hooks/editor/useEditorHistory.ts b/src/hooks/editor/useEditorHistory.ts index 275bcad..4d27554 100644 --- a/src/hooks/editor/useEditorHistory.ts +++ b/src/hooks/editor/useEditorHistory.ts @@ -1,5 +1,5 @@ import { useCallback, useRef, useState } from "react"; -import type { MapNode, SceneData } from "@/types/editor"; +import type { MapNode, SceneData } from "@/types/editor/editor"; interface ObjectTransform { uuid: string; diff --git a/src/hooks/editor/useEditorSceneData.ts b/src/hooks/editor/useEditorSceneData.ts index ffdab7b..29b9c42 100644 --- a/src/hooks/editor/useEditorSceneData.ts +++ b/src/hooks/editor/useEditorSceneData.ts @@ -1,7 +1,7 @@ import { useCallback, useEffect, useState } from "react"; import { createSceneDataFromFiles } from "@/utils/editor/loadEditorScene"; -import { loadMapSceneData } from "@/utils/loadMapSceneData"; -import type { SceneData } from "@/types/editor"; +import { loadMapSceneData } from "@/utils/map/loadMapSceneData"; +import type { SceneData } from "@/types/editor/editor"; interface UseEditorSceneDataResult { hasMapJson: boolean; diff --git a/src/hooks/useModelSelection.ts b/src/hooks/gameplay/useModelSelection.ts similarity index 95% rename from src/hooks/useModelSelection.ts rename to src/hooks/gameplay/useModelSelection.ts index 52665b6..c1f4f64 100644 --- a/src/hooks/useModelSelection.ts +++ b/src/hooks/gameplay/useModelSelection.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from "react"; -import type { ModelCatalogItem } from "@/data/repairGame/repairGameModelCatalog"; +import type { ModelCatalogItem } from "@/data/gameplay/repairGameModelCatalog"; interface UseModelSelectionResult { isOpen: boolean; diff --git a/src/hooks/useHandTrackingSnapshot.ts b/src/hooks/handTracking/useHandTrackingSnapshot.ts similarity index 84% rename from src/hooks/useHandTrackingSnapshot.ts rename to src/hooks/handTracking/useHandTrackingSnapshot.ts index d3d18cf..4360cc8 100644 --- a/src/hooks/useHandTrackingSnapshot.ts +++ b/src/hooks/handTracking/useHandTrackingSnapshot.ts @@ -1,5 +1,5 @@ import { createContext, useContext } from "react"; -import type { HandTrackingSnapshot } from "@/types/handTracking"; +import type { HandTrackingSnapshot } from "@/types/handTracking/handTracking"; export const HAND_TRACKING_IDLE_SNAPSHOT: HandTrackingSnapshot = { hands: [], diff --git a/src/hooks/useRemoteHandTracking.ts b/src/hooks/handTracking/useRemoteHandTracking.ts similarity index 99% rename from src/hooks/useRemoteHandTracking.ts rename to src/hooks/handTracking/useRemoteHandTracking.ts index d568104..7081b40 100644 --- a/src/hooks/useRemoteHandTracking.ts +++ b/src/hooks/handTracking/useRemoteHandTracking.ts @@ -12,7 +12,7 @@ import type { HandTrackingFrameMessage, HandTrackingServerMessage, HandTrackingSnapshot, -} from "@/types/handTracking"; +} from "@/types/handTracking/handTracking"; interface UseRemoteHandTrackingOptions { enabled: boolean; diff --git a/src/hooks/useInteraction.ts b/src/hooks/interaction/useInteraction.ts similarity index 81% rename from src/hooks/useInteraction.ts rename to src/hooks/interaction/useInteraction.ts index 34a2a86..13d2534 100644 --- a/src/hooks/useInteraction.ts +++ b/src/hooks/interaction/useInteraction.ts @@ -1,6 +1,6 @@ import { useSyncExternalStore } from "react"; import { InteractionManager } from "@/managers/InteractionManager"; -import type { InteractionSnapshot } from "@/types/interaction"; +import type { InteractionSnapshot } from "@/types/interaction/interaction"; const manager = InteractionManager.getInstance(); diff --git a/src/hooks/useOctreeGraphNode.ts b/src/hooks/three/useOctreeGraphNode.ts similarity index 92% rename from src/hooks/useOctreeGraphNode.ts rename to src/hooks/three/useOctreeGraphNode.ts index 3a4f3a3..4706fd0 100644 --- a/src/hooks/useOctreeGraphNode.ts +++ b/src/hooks/three/useOctreeGraphNode.ts @@ -2,7 +2,7 @@ import { useEffect, useRef } from "react"; import type { RefObject } from "react"; import type { Object3D } from "three"; import { Octree } from "three/addons/math/Octree.js"; -import type { OctreeReadyHandler } from "@/types/three"; +import type { OctreeReadyHandler } from "@/types/three/three"; export function useOctreeGraphNode( graphNodeRef: RefObject, diff --git a/src/managers/AudioManager.ts b/src/managers/AudioManager.ts index bbd3741..6c2a534 100644 --- a/src/managers/AudioManager.ts +++ b/src/managers/AudioManager.ts @@ -1,4 +1,4 @@ -import { logger } from "@/utils/logger"; +import { logger } from "@/utils/core/logger"; interface PlaySoundOptions { playbackRate?: number; diff --git a/src/managers/InteractionManager.ts b/src/managers/InteractionManager.ts index 83697f0..1b27e89 100644 --- a/src/managers/InteractionManager.ts +++ b/src/managers/InteractionManager.ts @@ -2,7 +2,7 @@ import type { GrabInteractableHandle, InteractableHandle, InteractionSnapshot, -} from "@/types/interaction"; +} from "@/types/interaction/interaction"; export class InteractionManager { private static _instance: InteractionManager | null = null; diff --git a/src/pages/editor/page.tsx b/src/pages/editor/page.tsx index c60e93b..fac7e24 100644 --- a/src/pages/editor/page.tsx +++ b/src/pages/editor/page.tsx @@ -4,7 +4,7 @@ import { EditorControls } from "@/components/editor/EditorControls"; import { EditorScene } from "@/components/editor/scene/EditorScene"; import { useEditorHistory } from "@/hooks/editor/useEditorHistory"; import { useEditorSceneData } from "@/hooks/editor/useEditorSceneData"; -import type { MapNode, SceneData, TransformMode } from "@/types/editor"; +import type { MapNode, SceneData, TransformMode } from "@/types/editor/editor"; const SAVE_ERROR_MESSAGE = "Erreur lors de l'enregistrement"; diff --git a/src/pages/page.tsx b/src/pages/page.tsx index 12c6688..21b2f5c 100644 --- a/src/pages/page.tsx +++ b/src/pages/page.tsx @@ -2,7 +2,7 @@ import { Suspense } from "react"; import { Canvas } from "@react-three/fiber"; import { Crosshair } from "@/components/ui/Crosshair"; import { HandTrackingOverlay } from "@/components/ui/HandTrackingOverlay"; -import { HandTrackingProvider } from "@/components/ui/HandTrackingProvider"; +import { HandTrackingProvider } from "@/providers/gameplay/HandTrackingProvider"; import { HandTrackingVisualizer } from "@/components/ui/HandTrackingVisualizer"; import { InteractPrompt } from "@/components/ui/InteractPrompt"; import { DebugPerf } from "@/components/debug/DebugPerf"; diff --git a/src/components/ui/HandTrackingProvider.tsx b/src/providers/gameplay/HandTrackingProvider.tsx similarity index 75% rename from src/components/ui/HandTrackingProvider.tsx rename to src/providers/gameplay/HandTrackingProvider.tsx index f404c24..b5541ec 100644 --- a/src/components/ui/HandTrackingProvider.tsx +++ b/src/providers/gameplay/HandTrackingProvider.tsx @@ -1,11 +1,11 @@ import type { ReactNode } from "react"; import { useSceneMode } from "@/hooks/debug/useSceneMode"; -import { useInteraction } from "@/hooks/useInteraction"; +import { useInteraction } from "@/hooks/interaction/useInteraction"; import { HAND_TRACKING_IDLE_SNAPSHOT, HandTrackingContext, -} from "@/hooks/useHandTrackingSnapshot"; -import { useRemoteHandTracking } from "@/hooks/useRemoteHandTracking"; +} from "@/hooks/handTracking/useHandTrackingSnapshot"; +import { useRemoteHandTracking } from "@/hooks/handTracking/useRemoteHandTracking"; export function HandTrackingProvider({ children, diff --git a/src/router.tsx b/src/router.tsx index 3da6a6c..1c3c09b 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -17,7 +17,7 @@ import { DocsReadmeRoute, DocsTargetArchitectureRoute, DocsTechnicalEditorRoute, -} from "@/routes/docs/DocsRouteComponents"; +} from "@/routes/DocsRoute"; const rootRoute = createRootRoute({ component: Outlet, diff --git a/src/routes/docs/DocsRouteComponents.tsx b/src/routes/DocsRoute.tsx similarity index 100% rename from src/routes/docs/DocsRouteComponents.tsx rename to src/routes/DocsRoute.tsx diff --git a/src/types/debug.ts b/src/types/debug/debug.ts similarity index 100% rename from src/types/debug.ts rename to src/types/debug/debug.ts diff --git a/src/types/editor.ts b/src/types/editor/editor.ts similarity index 83% rename from src/types/editor.ts rename to src/types/editor/editor.ts index 73306c4..5f86c18 100644 --- a/src/types/editor.ts +++ b/src/types/editor/editor.ts @@ -1,4 +1,4 @@ -import type { Vector3Tuple } from "./three"; +import type { Vector3Tuple } from "@/types/three/three"; export interface MapNode { name: string; diff --git a/src/types/handTracking.ts b/src/types/handTracking/handTracking.ts similarity index 100% rename from src/types/handTracking.ts rename to src/types/handTracking/handTracking.ts diff --git a/src/types/interaction.ts b/src/types/interaction/interaction.ts similarity index 100% rename from src/types/interaction.ts rename to src/types/interaction/interaction.ts diff --git a/src/types/logger.ts b/src/types/logger/logger.ts similarity index 100% rename from src/types/logger.ts rename to src/types/logger/logger.ts diff --git a/src/types/three-addons.d.ts b/src/types/three/three-addons.d.ts similarity index 100% rename from src/types/three-addons.d.ts rename to src/types/three/three-addons.d.ts diff --git a/src/types/three.ts b/src/types/three/three.ts similarity index 100% rename from src/types/three.ts rename to src/types/three/three.ts diff --git a/src/utils/EventEmitter.ts b/src/utils/core/EventEmitter.ts similarity index 100% rename from src/utils/EventEmitter.ts rename to src/utils/core/EventEmitter.ts diff --git a/src/utils/Sizes.ts b/src/utils/core/Sizes.ts similarity index 100% rename from src/utils/Sizes.ts rename to src/utils/core/Sizes.ts diff --git a/src/utils/Time.ts b/src/utils/core/Time.ts similarity index 100% rename from src/utils/Time.ts rename to src/utils/core/Time.ts diff --git a/src/utils/logger.ts b/src/utils/core/logger.ts similarity index 98% rename from src/utils/logger.ts rename to src/utils/core/logger.ts index b1629de..a89ee8a 100644 --- a/src/utils/logger.ts +++ b/src/utils/core/logger.ts @@ -3,7 +3,7 @@ import type { LogEntry, LogLevel, LoggerConfig, -} from "@/types/logger"; +} from "@/types/logger/logger"; import { isDebugEnabled } from "@/utils/debug/isDebugEnabled"; const LEVEL_PRIORITY: Record = { diff --git a/src/utils/debug/Debug.ts b/src/utils/debug/Debug.ts index 9f6e121..5fb5b3c 100644 --- a/src/utils/debug/Debug.ts +++ b/src/utils/debug/Debug.ts @@ -1,5 +1,5 @@ import GUI from "lil-gui"; -import type { CameraMode, SceneMode } from "@/types/debug"; +import type { CameraMode, SceneMode } from "@/types/debug/debug"; import { isDebugEnabled } from "@/utils/debug/isDebugEnabled"; const DEBUG_CONTROLS_STORAGE_KEY = "la-fabrik-debug-controls"; diff --git a/src/utils/editor/loadEditorScene.ts b/src/utils/editor/loadEditorScene.ts index e22b36f..8be736d 100644 --- a/src/utils/editor/loadEditorScene.ts +++ b/src/utils/editor/loadEditorScene.ts @@ -1,5 +1,5 @@ -import type { SceneData } from "@/types/editor"; -import { parseMapNodes } from "@/utils/mapNodeValidation"; +import type { SceneData } from "@/types/editor/editor"; +import { parseMapNodes } from "@/utils/map/mapNodeValidation"; const MAP_JSON_PATH = "/map.json"; diff --git a/src/utils/loadMapSceneData.ts b/src/utils/map/loadMapSceneData.ts similarity index 91% rename from src/utils/loadMapSceneData.ts rename to src/utils/map/loadMapSceneData.ts index da2464b..0040c74 100644 --- a/src/utils/loadMapSceneData.ts +++ b/src/utils/map/loadMapSceneData.ts @@ -1,5 +1,5 @@ -import type { MapNode, SceneData } from "@/types/editor"; -import { parseMapNodes } from "@/utils/mapNodeValidation"; +import type { MapNode, SceneData } from "@/types/editor/editor"; +import { parseMapNodes } from "@/utils/map/mapNodeValidation"; const MAP_JSON_PATH = "/map.json"; const MODEL_FILE_NAMES = ["model.glb", "model.gltf"]; diff --git a/src/utils/mapNodeValidation.ts b/src/utils/map/mapNodeValidation.ts similarity index 93% rename from src/utils/mapNodeValidation.ts rename to src/utils/map/mapNodeValidation.ts index cbe8973..b137242 100644 --- a/src/utils/mapNodeValidation.ts +++ b/src/utils/map/mapNodeValidation.ts @@ -1,4 +1,4 @@ -import type { MapNode } from "../types/editor"; +import type { MapNode } from "@/types/editor/editor"; function isVector3Tuple(value: unknown): value is [number, number, number] { return ( diff --git a/src/utils/ExplodedModel.ts b/src/utils/three/ExplodedModel.ts similarity index 100% rename from src/utils/ExplodedModel.ts rename to src/utils/three/ExplodedModel.ts diff --git a/src/world/GameMap.tsx b/src/world/GameMap.tsx index 1abcf85..415ca8c 100644 --- a/src/world/GameMap.tsx +++ b/src/world/GameMap.tsx @@ -2,10 +2,10 @@ import type { ReactNode } from "react"; import { Component, useEffect, useMemo, useRef, useState } from "react"; import { useGLTF } from "@react-three/drei"; import * as THREE from "three"; -import { useOctreeGraphNode } from "@/hooks/useOctreeGraphNode"; -import { loadMapSceneData } from "@/utils/loadMapSceneData"; -import type { OctreeReadyHandler } from "@/types/three"; -import type { MapNode } from "@/types/editor"; +import { useOctreeGraphNode } from "@/hooks/three/useOctreeGraphNode"; +import { loadMapSceneData } from "@/utils/map/loadMapSceneData"; +import type { MapNode } from "@/types/editor/editor"; +import type { OctreeReadyHandler } from "@/types/three/three"; interface LoadedMapNode { node: MapNode; diff --git a/src/world/debug/TestMap.tsx b/src/world/debug/TestMap.tsx index 8e87a42..1a11d53 100644 --- a/src/world/debug/TestMap.tsx +++ b/src/world/debug/TestMap.tsx @@ -21,8 +21,8 @@ import { TEST_SCENE_TRIGGER_SEGMENTS, TEST_SCENE_TRIGGER_SOUND_PATH, } from "@/data/debug/testSceneConfig"; -import { useOctreeGraphNode } from "@/hooks/useOctreeGraphNode"; -import type { OctreeReadyHandler } from "@/types/three"; +import { useOctreeGraphNode } from "@/hooks/three/useOctreeGraphNode"; +import type { OctreeReadyHandler } from "@/types/three/three"; interface TestMapProps { onOctreeReady: OctreeReadyHandler; diff --git a/src/world/player/Player.tsx b/src/world/player/Player.tsx index 8fdc489..d30ac2a 100644 --- a/src/world/player/Player.tsx +++ b/src/world/player/Player.tsx @@ -1,7 +1,7 @@ import { useEffect } from "react"; import { useThree } from "@react-three/fiber"; import type { Octree } from "three/addons/math/Octree.js"; -import type { Vector3Tuple } from "@/types/three"; +import type { Vector3Tuple } from "@/types/three/three"; import { PlayerCamera } from "@/world/player/PlayerCamera"; import { PlayerController } from "@/world/player/PlayerController"; diff --git a/src/world/player/PlayerController.tsx b/src/world/player/PlayerController.tsx index b9b714b..6467d84 100644 --- a/src/world/player/PlayerController.tsx +++ b/src/world/player/PlayerController.tsx @@ -24,7 +24,7 @@ import { PLAYER_XZ_DAMPING_FACTOR, } from "@/data/player/playerConfig"; import { InteractionManager } from "@/managers/InteractionManager"; -import type { Vector3Tuple } from "@/types/three"; +import type { Vector3Tuple } from "@/types/three/three"; type Keys = { forward: boolean;