diff --git a/app/src/modules/simulation/human/instances/animator/manufacturerAnimator.tsx b/app/src/modules/simulation/human/instances/animator/manufacturerAnimator.tsx index d7b0147..0524726 100644 --- a/app/src/modules/simulation/human/instances/animator/manufacturerAnimator.tsx +++ b/app/src/modules/simulation/human/instances/animator/manufacturerAnimator.tsx @@ -15,7 +15,7 @@ interface ManufacturerAnimatorProps { function ManufacturerAnimator({ path, handleCallBack, human, reset }: Readonly) { const { humanStore, assetStore, productStore } = useSceneContext(); const { getActionByUuid, selectedProduct } = productStore(); - const { getHumanById } = humanStore(); + const { getHumanById, incrementDistanceTraveled } = humanStore(); const { setCurrentAnimation } = assetStore(); const { isPaused } = usePauseButtonStore(); const { isPlaying } = usePlayButtonStore(); @@ -108,7 +108,15 @@ function ManufacturerAnimator({ path, handleCallBack, human, reset }: Readonly 0) { + incrementDistanceTraveled(human.modelUuid, actualStep); + } + const t = (progressRef.current - accumulatedDistance) / segmentDistance; const position = start.clone().lerp(end, t); object.position.copy(position); diff --git a/app/src/modules/simulation/human/instances/animator/operatorAnimator.tsx b/app/src/modules/simulation/human/instances/animator/operatorAnimator.tsx index e2a7ab3..c5d7891 100644 --- a/app/src/modules/simulation/human/instances/animator/operatorAnimator.tsx +++ b/app/src/modules/simulation/human/instances/animator/operatorAnimator.tsx @@ -15,7 +15,7 @@ interface WorkerAnimatorProps { function OperatorAnimator({ path, handleCallBack, human, reset }: Readonly) { const { humanStore, assetStore, productStore } = useSceneContext(); const { getActionByUuid, selectedProduct } = productStore(); - const { getHumanById } = humanStore(); + const { getHumanById, incrementDistanceTraveled } = humanStore(); const { setCurrentAnimation } = assetStore(); const { isPaused } = usePauseButtonStore(); const { isPlaying } = usePlayButtonStore(); @@ -116,7 +116,15 @@ function OperatorAnimator({ path, handleCallBack, human, reset }: Readonly 0) { + incrementDistanceTraveled(human.modelUuid, actualStep); + } + const t = (progressRef.current - accumulatedDistance) / segmentDistance; const position = start.clone().lerp(end, t); object.position.copy(position); diff --git a/app/src/modules/simulation/human/instances/animator/workerAnimator.tsx b/app/src/modules/simulation/human/instances/animator/workerAnimator.tsx index d076445..25a3fbb 100644 --- a/app/src/modules/simulation/human/instances/animator/workerAnimator.tsx +++ b/app/src/modules/simulation/human/instances/animator/workerAnimator.tsx @@ -16,7 +16,7 @@ interface WorkerAnimatorProps { function WorkerAnimator({ path, handleCallBack, human, reset, startUnloadingProcess }: Readonly) { const { humanStore, assetStore, productStore } = useSceneContext(); const { getActionByUuid, selectedProduct } = productStore(); - const { getHumanById } = humanStore(); + const { getHumanById, incrementDistanceTraveled } = humanStore(); const { setCurrentAnimation } = assetStore(); const { isPaused } = usePauseButtonStore(); const { isPlaying } = usePlayButtonStore(); @@ -118,7 +118,15 @@ function WorkerAnimator({ path, handleCallBack, human, reset, startUnloadingProc const isAligned = angle < 0.01; if (isAligned) { - progressRef.current = Math.min(progressRef.current + delta * (speed * human.speed), totalDistance); + const distanceStep = delta * (speed * human.speed); + const previousProgress = progressRef.current; + progressRef.current = Math.min(progressRef.current + distanceStep, totalDistance); + const actualStep = progressRef.current - previousProgress; + + if (actualStep > 0) { + incrementDistanceTraveled(human.modelUuid, actualStep); + } + const t = (progressRef.current - accumulatedDistance) / segmentDistance; const position = start.clone().lerp(end, t); object.position.copy(position);