refactor: Improve error handling and variable naming in Assets and IKAnimationController components

This commit is contained in:
Jerald-Golden-B 2025-04-16 18:05:23 +05:30
parent ee319c28e4
commit 64885f246e
2 changed files with 15 additions and 10 deletions

View File

@ -73,7 +73,7 @@ const Assets: React.FC = () => {
try { try {
const filt = await fetchAssets(); const filt = await fetchAssets();
setFiltereredAssets(filt); setFiltereredAssets(filt);
} catch {} } catch { }
}; };
filteredAssets(); filteredAssets();
}, [categoryAssets]); }, [categoryAssets]);
@ -135,7 +135,7 @@ const Assets: React.FC = () => {
const res = await getCategoryAsset(asset); const res = await getCategoryAsset(asset);
setCategoryAssets(res); setCategoryAssets(res);
setFiltereredAssets(res); setFiltereredAssets(res);
} catch (error) {} } catch (error) { }
} }
}; };
return ( return (
@ -234,6 +234,7 @@ const Assets: React.FC = () => {
src={categoryInfo?.categoryImage || ""} src={categoryInfo?.categoryImage || ""}
alt={category} alt={category}
className="category-image" className="category-image"
draggable={false}
/> />
<div className="category-name">{category}</div> <div className="category-name">{category}</div>
</div> </div>

View File

@ -4,6 +4,8 @@ import * as THREE from "three";
import { usePlayButtonStore, useResetButtonStore } from "../../../store/usePlayButtonStore"; import { usePlayButtonStore, useResetButtonStore } from "../../../store/usePlayButtonStore";
import { useSimulationStates } from "../../../store/store"; import { useSimulationStates } from "../../../store/store";
import MaterialInstances from "./MaterialInstances"; import MaterialInstances from "./MaterialInstances";
import { Line } from "react-chartjs-2";
import { QuadraticBezierLine } from "@react-three/drei";
interface StaticMachineState { interface StaticMachineState {
@ -124,7 +126,7 @@ const IKAnimationController = ({
]); ]);
}; };
const processCurves = useMemo(() => { const processedCurves = useMemo(() => {
if (!isPlaying) return []; if (!isPlaying) return [];
return processes.map(process => { return processes.map(process => {
@ -172,8 +174,8 @@ const IKAnimationController = ({
const activeProcess = useMemo(() => { const activeProcess = useMemo(() => {
if (!selectedTrigger) return null; if (!selectedTrigger) return null;
return processCurves.find(p => p?.triggerId === selectedTrigger); return processedCurves.find(p => p?.triggerId === selectedTrigger);
}, [processCurves, selectedTrigger]); }, [processedCurves, selectedTrigger]);
// Initial movement to rest position // Initial movement to rest position
useFrame((_, delta) => { useFrame((_, delta) => {
@ -364,11 +366,13 @@ const IKAnimationController = ({
} }
return ( return (
<MaterialInstances <>
statusRef={statusRef} <MaterialInstances
ikSolver={ikSolver} statusRef={statusRef}
targetBoneName={targetBoneName} ikSolver={ikSolver}
/> targetBoneName={targetBoneName}
/>
</>
); );
}; };