refactor: organize three components by domain

This commit is contained in:
Tom Boullay
2026-04-30 11:35:53 +02:00
parent 37eded8d7e
commit 9ac5844182
30 changed files with 465 additions and 327 deletions
+7 -7
View File
@@ -1,5 +1,4 @@
/* eslint-disable react-hooks/immutability */
import { useRef, useEffect, useState, useCallback } from "react";
import { useRef, useEffect, useState, useCallback, useMemo } from "react";
import { useGLTF, useAnimations } from "@react-three/drei";
import type { AnimationAction, AnimationMixer } from "three";
import * as THREE from "three";
@@ -36,6 +35,7 @@ export function useCharacterAnimation(
const groupRef = useRef<THREE.Group | null>(null);
const { scene, animations } = useGLTF(modelPath);
const model = useMemo(() => scene.clone(true), [scene]);
const { actions, names, mixer } = useAnimations(animations, groupRef);
const [currentAnimation, setCurrentAnimation] = useState(initialAnimation);
@@ -78,11 +78,11 @@ export function useCharacterAnimation(
const setAnimationSpeed = useCallback(
(speed: number) => {
if (mixer) {
mixer.timeScale = speed;
}
Object.values(actions).forEach((action) => {
action?.setEffectiveTimeScale(speed);
});
},
[mixer],
[actions],
);
useEffect(() => {
@@ -93,7 +93,7 @@ export function useCharacterAnimation(
}, [actions, initialAnimation]);
return {
scene,
scene: model,
actions,
names,
mixer,
+1 -1
View File
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useState } from "react";
import type { ModelCatalogItem } from "@/data/mainFeature/modelCatalog";
import type { ModelCatalogItem } from "@/data/repairGame/repairGameModelCatalog";
interface UseModelSelectionResult {
isOpen: boolean;