added global speed for agv

This commit is contained in:
2025-04-11 18:08:53 +05:30
parent 1256f33342
commit 3eecf30541
3 changed files with 12 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import { Line } from "@react-three/drei";
import {
useNavMesh,
@@ -6,7 +6,7 @@ import {
useSimulationStates,
} from "../../../store/store";
import PathNavigator from "./pathNavigator";
import { usePlayButtonStore, useResetButtonStore } from "../../../store/usePlayButtonStore";
import { useAnimationPlaySpeed, usePlayButtonStore, useResetButtonStore } from "../../../store/usePlayButtonStore";
type PathPoints = {
modelUuid: string;
@@ -31,6 +31,10 @@ const Agv: React.FC<ProcessContainerProps> = ({
const { navMesh } = useNavMesh();
const { isPlaying } = usePlayButtonStore();
const { isReset, setReset } = useResetButtonStore();
const { speed } = useAnimationPlaySpeed();
const globalSpeed = useRef(1);
useEffect(() => { globalSpeed.current = speed }, [speed])
useEffect(() => {
if (!isPlaying || isReset) {
@@ -81,6 +85,7 @@ const Agv: React.FC<ProcessContainerProps> = ({
pathPoints={pair.points}
id={pair.modelUuid}
speed={pair.modelSpeed}
globalSpeed={globalSpeed.current}
bufferTime={pair.bufferTime}
hitCount={pair.hitCount}
processes={processes}