feat: introduce VehicleAnimator component for animating 3D vehicles along defined paths with play/pause/reset functionality.

This commit is contained in:
2025-12-20 12:38:53 +05:30
parent 036164155f
commit 40854a4bd7

View File

@@ -18,7 +18,7 @@ interface VehicleAnimatorProps {
function VehicleAnimator({ path, handleCallBack, currentPhase, agvUuid, agvDetail, reset, startUnloadingProcess }: Readonly<VehicleAnimatorProps>) {
const { vehicleStore } = useSceneContext();
const { getVehicleById } = vehicleStore();
const { getVehicleById, incrementDistanceTraveled } = vehicleStore();
const { isPaused } = usePauseButtonStore();
const { isPlaying } = usePlayButtonStore();
const { speed } = useAnimationPlaySpeed();
@@ -126,6 +126,7 @@ function VehicleAnimator({ path, handleCallBack, currentPhase, agvUuid, agvDetai
if (isAligned) {
progressRef.current += delta * (speed * agvDetail.speed);
incrementDistanceTraveled(agvUuid, delta * (speed * agvDetail.speed));
const t = (progressRef.current - accumulatedDistance) / segmentDistance;
const position = start.clone().lerp(end, t);
object.position.copy(position);