diff --git a/app/src/components/ui/simulation/simulationPlayer.tsx b/app/src/components/ui/simulation/simulationPlayer.tsx
index 9787d00..cc2efb6 100644
--- a/app/src/components/ui/simulation/simulationPlayer.tsx
+++ b/app/src/components/ui/simulation/simulationPlayer.tsx
@@ -38,18 +38,12 @@ const SimulationPlayer: React.FC = () => {
const { isReset, setReset } = useResetButtonStore();
const { subModule } = useSubModuleStore();
- useEffect(() => {
- if (isReset) {
- setTimeout(()=>{
- setReset(false);
- },0)
- }
- }, [isReset])
-
// Button functions
const handleReset = () => {
setReset(true);
+ setIsPaused(false);
setSpeed(1);
+ setPlaySimulation(false); // local state reset
};
const handlePlayStop = () => {
setIsPaused(!isPaused);
@@ -58,6 +52,7 @@ const SimulationPlayer: React.FC = () => {
const handleExit = () => {
setPlaySimulation(false);
setIsPlaying(false);
+ setIsPaused(false);
setActiveTool("cursor");
};
@@ -279,10 +274,11 @@ const SimulationPlayer: React.FC = () => {
{index < intervals.length - 1 && (
= ((index + 1) / totalSegments) * 100
+ className={`line ${
+ progress >= ((index + 1) / totalSegments) * 100
? "filled"
: ""
- }`}
+ }`}
>
)}
diff --git a/app/src/modules/simulation/actions/conveyor/actionHandler/useDefaultHandler.ts b/app/src/modules/simulation/actions/conveyor/actionHandler/useDefaultHandler.ts
new file mode 100644
index 0000000..e69de29
diff --git a/app/src/modules/simulation/actions/conveyor/actionHandler/useSpawnHandler.ts b/app/src/modules/simulation/actions/conveyor/actionHandler/useSpawnHandler.ts
index 20d82bf..8f639e6 100644
--- a/app/src/modules/simulation/actions/conveyor/actionHandler/useSpawnHandler.ts
+++ b/app/src/modules/simulation/actions/conveyor/actionHandler/useSpawnHandler.ts
@@ -4,28 +4,44 @@ import { useFrame } from "@react-three/fiber";
import { useMaterialStore } from "../../../../../store/simulation/useMaterialStore";
import { useProductStore } from "../../../../../store/simulation/useProductStore";
import { useSelectedProduct } from "../../../../../store/simulation/useSimulationStore";
+import { usePlayButtonStore, useAnimationPlaySpeed, usePauseButtonStore, useResetButtonStore } from "../../../../../store/usePlayButtonStore";
-export function useSpawnHandler() {
- const { addMaterial } = useMaterialStore();
- const { getModelUuidByActionUuid, getPointUuidByActionUuid } = useProductStore();
- const { selectedProduct } = useSelectedProduct();
- const lastSpawnTime = useRef(null);
- const startTime = useRef(null);
- const spawnCountRef = useRef(0);
- const spawnParams = useRef<{
+interface SpawnInstance {
+ lastSpawnTime: number | null;
+ startTime: number;
+ spawnCount: number;
+ params: {
material: string;
intervalMs: number;
totalCount: number;
action: ConveyorAction;
- } | null>(null);
+ };
+ pauseStartTime: number;
+ remainingTime: number;
+ isPaused: boolean;
+}
- const clearCurrentSpawn = useCallback(() => {
- lastSpawnTime.current = null;
- startTime.current = null;
- spawnCountRef.current = 0;
- spawnParams.current = null;
+export function useSpawnHandler() {
+ const { addMaterial } = useMaterialStore();
+ const { getModelUuidByActionUuid, getPointUuidByActionUuid } = useProductStore();
+ const { isPlaying } = usePlayButtonStore();
+ const { isPaused } = usePauseButtonStore();
+ const { speed } = useAnimationPlaySpeed();
+ const { isReset } = useResetButtonStore();
+ const { selectedProduct } = useSelectedProduct();
+
+ const activeSpawns = useRef