completed init movement for human

This commit is contained in:
2025-07-03 18:01:11 +05:30
parent 1e715cee50
commit 7cf82629e9
16 changed files with 302 additions and 567 deletions

View File

@@ -7,7 +7,7 @@ import { useTriggerHandler } from '../../../triggers/triggerHandler/useTriggerHa
import { useSceneContext } from '../../../../scene/sceneContext';
import { useProductContext } from '../../../products/productContext';
import HumanAnimator from './animator/humanAnimator';
import HumanAnimator from '../animator/humanAnimator';
function HumanInstance({ human }: { human: HumanStatus }) {
const { navMesh } = useNavMesh();
@@ -66,12 +66,10 @@ function HumanInstance({ human }: { human: HumanStatus }) {
console.error("Failed to compute path");
return [];
}
},
[navMesh]
);
}, [navMesh]);
function humanStatus(modelId: string, status: string) {
// console.log(`${modelId} , ${status}`);
console.log(`${modelId} , ${status}`);
}
function reset() {
@@ -96,6 +94,25 @@ function HumanInstance({ human }: { human: HumanStatus }) {
useEffect(() => {
if (isPlaying) {
if (!human.point.action.pickUpPoint || !human.point.action.dropPoint) return;
if (!human.isActive && human.state === 'idle' && currentPhase === 'init') {
const toPickupPath = computePath(
new THREE.Vector3(human?.position[0], human?.position[1], human?.position[2]),
new THREE.Vector3(
human?.point?.action?.pickUpPoint?.position?.[0] ?? 0,
human?.point?.action?.pickUpPoint?.position?.[1] ?? 0,
human?.point?.action?.pickUpPoint?.position?.[2] ?? 0
)
);
setPath(toPickupPath);
setCurrentPhase('init-pickup');
setHumanState(human.modelUuid, 'running');
setHumanPicking(human.modelUuid, false);
setHumanActive(human.modelUuid, true);
humanStatus(human.modelUuid, 'Started from init, heading to pickup');
return;
}
}
else {
@@ -104,10 +121,28 @@ function HumanInstance({ human }: { human: HumanStatus }) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [human, currentPhase, path, isPlaying]);
function handleCallBack() {
if (currentPhase === 'init-pickup') {
setCurrentPhase('picking');
} else if (currentPhase === 'pickup-drop') {
} else if (currentPhase === 'drop-pickup') {
}
}
function startUnloadingProcess() {
}
return (
<>
<HumanAnimator />
<HumanAnimator
path={path}
handleCallBack={handleCallBack}
currentPhase={currentPhase}
human={human}
reset={reset}
startUnloadingProcess={startUnloadingProcess}
/>
</>
)