refacto : cleaning the codebasebase again

This commit is contained in:
2026-04-19 16:50:11 +02:00
parent f9c4495610
commit dcbc1c73f5
26 changed files with 127 additions and 5726 deletions
+2 -9
View File
@@ -1,13 +1,6 @@
import { useSyncExternalStore } from "react";
import type { CameraMode } from "@/types/debug";
import { Debug } from "@/utils/debug/Debug";
import { useDebugStore } from "@/hooks/debug/useDebugStore";
export function useCameraMode(): CameraMode {
const debug = Debug.getInstance();
return useSyncExternalStore(
(listener) => debug.subscribe(listener),
() => debug.getCameraMode(),
() => debug.getCameraMode(),
);
return useDebugStore((debug) => debug.getCameraMode());
}
+12
View File
@@ -0,0 +1,12 @@
import { useSyncExternalStore } from "react";
import { Debug } from "@/utils/debug/Debug";
export function useDebugStore<T>(selector: (debug: Debug) => T): T {
const debug = Debug.getInstance();
return useSyncExternalStore(
(listener) => debug.subscribe(listener),
() => selector(debug),
() => selector(debug),
);
}
+2 -9
View File
@@ -1,13 +1,6 @@
import { useSyncExternalStore } from "react";
import type { SceneMode } from "@/types/debug";
import { Debug } from "@/utils/debug/Debug";
import { useDebugStore } from "@/hooks/debug/useDebugStore";
export function useSceneMode(): SceneMode {
const debug = Debug.getInstance();
return useSyncExternalStore(
(listener) => debug.subscribe(listener),
() => debug.getSceneMode(),
() => debug.getSceneMode(),
);
return useDebugStore((debug) => debug.getSceneMode());
}
+2 -12
View File
@@ -1,8 +1,6 @@
import { useSyncExternalStore } from "react";
import {
InteractionManager,
type InteractionSnapshot,
} from "@/stateManager/InteractionManager";
import { InteractionManager } from "@/stateManager/InteractionManager";
import type { InteractionSnapshot } from "@/types/interaction";
const manager = InteractionManager.getInstance();
@@ -12,11 +10,3 @@ export function useInteraction(): InteractionSnapshot {
manager.getState.bind(manager),
);
}
export function useInteractionSelector<T>(
selector: (state: InteractionSnapshot) => T,
): T {
return useSyncExternalStore(manager.subscribe.bind(manager), () =>
selector(manager.getState()),
);
}
+24
View File
@@ -0,0 +1,24 @@
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/3d";
export function useOctreeGraphNode(
graphNodeRef: RefObject<Object3D | null>,
onOctreeReady: OctreeReadyHandler,
): void {
const octreeBuilt = useRef(false);
useEffect(() => {
const graphNode = graphNodeRef.current;
if (octreeBuilt.current || !graphNode) return;
octreeBuilt.current = true;
graphNode.updateMatrixWorld(true);
const octree = new Octree();
octree.fromGraphNode(graphNode);
onOctreeReady(octree);
}, [graphNodeRef, onOctreeReady]);
}