new comit

This commit is contained in:
SreeNath14 2025-04-16 16:08:47 +05:30
parent 0eedbdd58e
commit 496c8b0305
1 changed files with 16 additions and 9 deletions

View File

@ -55,7 +55,6 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
const groupRef = useRef<THREE.Group>(null);
const tempStackedObjectsRef = useRef<Record<string, boolean>>({});
const [previouslyConnected, setPreviouslyConnected] = useState<any>({});
const currentSpawnedObjectRef = useRef<any>(null);
const {
animationStates,
@ -124,6 +123,8 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
});
}, [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<ProcessContainerProps> = ({
// 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<ProcessContainerProps> = ({
// 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<ProcessContainerProps> = ({
const spawnPoint = findSpawnPoint(process);
if (!spawnPoint || !spawnPoint.actions) {
return;
}
@ -210,6 +215,8 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
? 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<ProcessContainerProps> = ({
);
if (currentTime >= processState.nextSpawnTime) {
const objectId = `obj-${process.id}-${processState.objectIdCounter}`;
const newObject = createSpawnedObject(
process,
@ -269,8 +277,6 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
// 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<ProcessContainerProps> = ({
[id]: {
...obj,
state: {
visible: true,
...obj.state,
isAnimating: false, // Stop animation
isDelaying: false, // Clear delays
@ -321,6 +326,7 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
currentTime - processState.processDelayStartTime >=
effectiveDelayTime
) {
newStates[process.id] = {
...processState,
isProcessDelaying: false,
@ -356,6 +362,7 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
[];
if (path.length < 2) {
return;
}
@ -370,6 +377,7 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
const currentRef = gltf?.scene ? obj.ref.current : obj.ref.current;
if (!currentRef) {
return;
}
@ -397,6 +405,7 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
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<ProcessContainerProps> = ({
// 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] = {