human movement improvement

This commit is contained in:
2025-08-22 16:12:59 +05:30
parent 88b09c44d2
commit aa55f2ba9e

View File

@@ -14,7 +14,7 @@ function WorkerInstance({ human }: { human: HumanStatus }) {
const { navMesh } = useNavMesh(); const { navMesh } = useNavMesh();
const { isPlaying } = usePlayButtonStore(); const { isPlaying } = usePlayButtonStore();
const { scene } = useThree(); const { scene } = useThree();
const { assetStore, materialStore, armBotStore, conveyorStore, machineStore, vehicleStore, humanStore, storageUnitStore, productStore } = useSceneContext(); const { assetStore, materialStore, armBotStore, conveyorStore, machineStore, vehicleStore, humanStore, storageUnitStore, productStore, humanEventManagerRef } = useSceneContext();
const { removeMaterial, setEndTime, setIsVisible } = materialStore(); const { removeMaterial, setEndTime, setIsVisible } = materialStore();
const { getStorageUnitById } = storageUnitStore(); const { getStorageUnitById } = storageUnitStore();
const { getArmBotById } = armBotStore(); const { getArmBotById } = armBotStore();
@@ -129,23 +129,47 @@ function WorkerInstance({ human }: { human: HumanStatus }) {
humanStatus(human.modelUuid, 'Started from pickup point, heading to drop point'); humanStatus(human.modelUuid, 'Started from pickup point, heading to drop point');
} }
} else if (human.currentMaterials.length > 0 && human.currentLoad > 0 && humanAsset?.animationState?.current !== 'pickup') { } else if (human.currentMaterials.length > 0 && human.currentLoad > 0 && humanAsset?.animationState?.current !== 'pickup') {
setTimeout(()=>{ setTimeout(() => {
if (human.currentMaterials[0]?.materialId) { if (human.currentMaterials[0]?.materialId) {
setIsVisible(human.currentMaterials[0]?.materialId, false); setIsVisible(human.currentMaterials[0]?.materialId, false);
} }
humanStatus(human.modelUuid, 'Started to pickup in pickup point'); humanStatus(human.modelUuid, 'Started to pickup in pickup point');
setCurrentAnimation(human.modelUuid, 'pickup', true, false, false); setCurrentAnimation(human.modelUuid, 'pickup', true, false, false);
},1) }, 1)
} }
} else if (!human.isActive && human.state === 'idle' && human.currentPhase === 'dropping' && human.currentLoad === 0) { } else if (!human.isActive && human.state === 'idle' && human.currentPhase === 'dropping' && human.currentLoad === 0) {
if (action.pickUpPoint && action.dropPoint) { if (action.pickUpPoint && action.dropPoint) {
const dropToPickup = computePath(action.dropPoint.position || [0, 0, 0], action.pickUpPoint.position || [0, 0, 0]); // const dropToPickup = computePath(action.dropPoint.position || [0, 0, 0], action.pickUpPoint.position || [0, 0, 0]);
setPath(dropToPickup); // setPath(dropToPickup);
setCurrentPhase(human.modelUuid, 'init'); // setCurrentPhase(human.modelUuid, 'drop-pickup');
setHumanState(human.modelUuid, 'running'); // setHumanState(human.modelUuid, 'running');
setHumanActive(human.modelUuid, true); // setHumanActive(human.modelUuid, true);
setCurrentAnimation(human.modelUuid, 'walking', true, true, true); // setCurrentAnimation(human.modelUuid, 'walking', true, true, true);
humanStatus(human.modelUuid, 'Started from dropping point, heading to pickup point'); if (humanEventManagerRef.current) {
let state = humanEventManagerRef.current.humanStates.find(h => h.humanId === human.modelUuid);
if (state) {
const existingAction = state.actionQueue.find(a => a.actionUuid === action.actionUuid);
if (existingAction) {
const currentCount = existingAction.count ?? 0;
if (existingAction.actionType === 'worker') {
if (currentCount < existingAction.maxLoadCount) {
const dropToPickup = computePath(action.dropPoint.position || [0, 0, 0], action.pickUpPoint.position || [0, 0, 0]);
setPath(dropToPickup);
setCurrentPhase(human.modelUuid, 'drop-pickup');
setHumanState(human.modelUuid, 'running');
setHumanActive(human.modelUuid, true);
setCurrentAnimation(human.modelUuid, 'walking', true, true, true);
} else {
setCurrentPhase(human.modelUuid, 'picking');
setHumanState(human.modelUuid, 'idle');
setHumanActive(human.modelUuid, false);
setCurrentAnimation(human.modelUuid, 'idle', true, true, true);
humanStatus(human.modelUuid, 'Started from dropping point, heading to pickup point');
}
}
}
}
}
} }
} }
} else { } else {