From 496c8b0305fa7345aae514fd06d1d5f4d23ec5f7 Mon Sep 17 00:00:00 2001 From: SreeNath14 <153710861+SreeNath14@users.noreply.github.com> Date: Wed, 16 Apr 2025 16:08:47 +0530 Subject: [PATCH] new comit --- .../simulation/process/processAnimator.tsx | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/src/modules/simulation/process/processAnimator.tsx b/app/src/modules/simulation/process/processAnimator.tsx index 981846b..408cd37 100644 --- a/app/src/modules/simulation/process/processAnimator.tsx +++ b/app/src/modules/simulation/process/processAnimator.tsx @@ -55,7 +55,6 @@ const ProcessAnimator: React.FC = ({ const groupRef = useRef(null); const tempStackedObjectsRef = useRef>({}); const [previouslyConnected, setPreviouslyConnected] = useState({}); - const currentSpawnedObjectRef = useRef(null); const { animationStates, @@ -124,6 +123,8 @@ const ProcessAnimator: React.FC = ({ }); }, [animationStates, MaterialRef, agvRef]); + // In processAnimator.tsx - only the relevant spawn logic part that needs fixes + // Add this function to ProcessAnimator component const isConnectedToActiveArmBot = useCallback( (processId: any) => { @@ -163,6 +164,8 @@ const ProcessAnimator: React.FC = ({ // Track connection state changes if (wasConnected !== isConnected) { + + // Update connection tracking (in a separate useEffect to avoid issues with setState in render) setTimeout(() => { setPreviouslyConnected((prev: any) => ({ ...prev, @@ -173,10 +176,11 @@ const ProcessAnimator: React.FC = ({ // If just disconnected, reset the spawn timer to allow new spawns if (wasConnected && !isConnected) { + newStates[process.id] = { ...processState, - nextSpawnTime: currentTime + 0.1, - hasSpawnedZeroIntervalObject: false, + nextSpawnTime: currentTime + 0.1, // Start spawning soon after disconnect + hasSpawnedZeroIntervalObject: false, // Reset for zero interval spawns }; } @@ -195,6 +199,7 @@ const ProcessAnimator: React.FC = ({ const spawnPoint = findSpawnPoint(process); if (!spawnPoint || !spawnPoint.actions) { + return; } @@ -210,6 +215,8 @@ const ProcessAnimator: React.FC = ({ ? spawnAction.spawnInterval : parseFloat(spawnAction.spawnInterval || "0") || 0; + + // Check if this is a zero interval spawn and we already spawned an object if ( spawnInterval === 0 && @@ -224,6 +231,7 @@ const ProcessAnimator: React.FC = ({ ); if (currentTime >= processState.nextSpawnTime) { + const objectId = `obj-${process.id}-${processState.objectIdCounter}`; const newObject = createSpawnedObject( process, @@ -269,8 +277,6 @@ const ProcessAnimator: React.FC = ({ // Second useFrame for animation logic useFrame((_, delta) => { - let currentProcessObject: any = null; - // Animation logic frame const currentTime = clockRef.current.getElapsedTime() - elapsedBeforePauseRef.current; @@ -297,7 +303,6 @@ const ProcessAnimator: React.FC = ({ [id]: { ...obj, state: { - visible: true, ...obj.state, isAnimating: false, // Stop animation isDelaying: false, // Clear delays @@ -321,6 +326,7 @@ const ProcessAnimator: React.FC = ({ currentTime - processState.processDelayStartTime >= effectiveDelayTime ) { + newStates[process.id] = { ...processState, isProcessDelaying: false, @@ -356,6 +362,7 @@ const ProcessAnimator: React.FC = ({ []; if (path.length < 2) { + return; } @@ -370,6 +377,7 @@ const ProcessAnimator: React.FC = ({ const currentRef = gltf?.scene ? obj.ref.current : obj.ref.current; if (!currentRef) { + return; } @@ -397,6 +405,7 @@ const ProcessAnimator: React.FC = ({ stateRef.currentDelayDuration / speedRef.current; if (currentTime - stateRef.delayStartTime >= effectiveDelayTime) { + stateRef.isDelaying = false; stateRef.delayComplete = true; stateRef.isAnimating = true; @@ -564,9 +573,7 @@ const ProcessAnimator: React.FC = ({ // Log if no animation is occurring when it should if (!animationOccurring && !isConnected) { - console.log( - `Warning: No animation occurring for process ${process.id} despite not being connected` - ); + } newStates[process.id] = {