diff --git a/app/src/modules/builder/agv/agv.tsx b/app/src/modules/builder/agv/agv.tsx index c2e7783..0a2d14e 100644 --- a/app/src/modules/builder/agv/agv.tsx +++ b/app/src/modules/builder/agv/agv.tsx @@ -79,8 +79,9 @@ const Agv: React.FC = ({ return ( <> {pathPoints.map((pair, i) => ( - + + {toPickupPath.length > 0 && ( { + console.log('processedCurves: ', processedCurves); + }, [processedCurves]) + const activeCurve = useMemo(() => { if (isPlaying && processedCurves) return processedCurves.find((c) => c?.trigger === selectedTrigger); @@ -337,7 +342,19 @@ const IKAnimationController = ({ ikSolver.update(); }); - return null; + return ( + <> + {armBot.status === 'moving' && activeCurve && + + } + + ); }; export default IKAnimationController; \ No newline at end of file diff --git a/app/src/modules/simulation/armbot/MaterialInstances.tsx b/app/src/modules/simulation/armbot/MaterialInstances.tsx new file mode 100644 index 0000000..778ae30 --- /dev/null +++ b/app/src/modules/simulation/armbot/MaterialInstances.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import * as THREE from 'three'; +import { Box } from '@react-three/drei'; + +type MaterialInstancesProps = { + groupRef: React.RefObject; + activeCurve: any; + progress: number; + ikSolver: any; + targetBoneName: string; +}; + +function MaterialInstances({ + groupRef, + activeCurve, + progress, + ikSolver, + targetBoneName +}: MaterialInstancesProps) { + const { endToRestRange, startToEndRange } = activeCurve; + + // Show the box from when we reach the start point until we leave the end point + const shouldShow = (progress >= startToEndRange[0] && progress < startToEndRange[1] && progress >= endToRestRange[0]); + + if (!shouldShow || !ikSolver) return null; + + const targetBone = ikSolver.mesh.skeleton.bones.find( + (b: any) => b.name === targetBoneName + ); + if (!targetBone) return null; + + const worldPos = new THREE.Vector3(); + targetBone.getWorldPosition(worldPos); + + return ( + + + + ); +} + +export default MaterialInstances; \ No newline at end of file diff --git a/app/src/modules/simulation/process/processAnimator.tsx b/app/src/modules/simulation/process/processAnimator.tsx index f6cda0b..a32b34b 100644 --- a/app/src/modules/simulation/process/processAnimator.tsx +++ b/app/src/modules/simulation/process/processAnimator.tsx @@ -169,9 +169,6 @@ const ProcessAnimator: React.FC = ({ const spawnPoint = findSpawnPoint(process); if (!spawnPoint || !spawnPoint.actions) { - console.log( - `Process ${process.id} has no valid spawn point or actions` - ); return; } @@ -255,10 +252,6 @@ const ProcessAnimator: React.FC = ({ // Check connection status with debugging const isConnected = isConnectedToActiveArmBot(process.id); - console.log( - `Process ${process.id} animation - connected:`, - isConnected - ); if (isConnected) { // Stop all animations when connected to active arm bot @@ -293,9 +286,6 @@ const ProcessAnimator: React.FC = ({ currentTime - processState.processDelayStartTime >= effectiveDelayTime ) { - console.log( - `Process ${process.id} delay completed, resuming animation` - ); newStates[process.id] = { ...processState, isProcessDelaying: false, @@ -331,9 +321,6 @@ const ProcessAnimator: React.FC = ({ []; if (path.length < 2) { - console.log( - `Process ${process.id} has insufficient path points: ${path.length}` - ); return; } @@ -348,9 +335,6 @@ const ProcessAnimator: React.FC = ({ const currentRef = gltf?.scene ? obj.ref.current : obj.ref.current; if (!currentRef) { - console.log( - `No reference for object ${objectId}, skipping animation` - ); return; } @@ -378,9 +362,6 @@ const ProcessAnimator: React.FC = ({ stateRef.currentDelayDuration / speedRef.current; if (currentTime - stateRef.delayStartTime >= effectiveDelayTime) { - console.log( - `Delay complete for object ${objectId}, resuming animation` - ); stateRef.isDelaying = false; stateRef.delayComplete = true; stateRef.isAnimating = true; @@ -408,9 +389,6 @@ const ProcessAnimator: React.FC = ({ // Skip non-animating objects if (!stateRef.isAnimating) { - console.log( - `Object ${objectId} not animating, skipping animation updates` - ); return; } @@ -454,9 +432,6 @@ const ProcessAnimator: React.FC = ({ if (shouldHide) { if (isAgvPicking) { - console.log( - `AGV picking at last point for object ${objectId}, hiding object` - ); updatedObjects[objectId] = { ...obj, visible: false, @@ -517,14 +492,8 @@ const ProcessAnimator: React.FC = ({ if (stateRef.delayComplete && stateRef.progress < 0.01) { stateRef.progress = 0.05; stateRef.delayComplete = false; - console.log( - `Boosting progress for object ${objectId} after delay` - ); } else { stateRef.progress += movement / distance; - console.log( - `Object ${objectId} progress: ${stateRef.progress.toFixed(3)}` - ); } // Handle point transition @@ -564,9 +533,9 @@ 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` - ); + // console.log( + // `Warning: No animation occurring for process ${process.id} despite not being connected` + // ); } newStates[process.id] = { diff --git a/app/src/modules/simulation/process/useProcessAnimations.tsx b/app/src/modules/simulation/process/useProcessAnimations.tsx index 9f08cf3..a46fe3c 100644 --- a/app/src/modules/simulation/process/useProcessAnimations.tsx +++ b/app/src/modules/simulation/process/useProcessAnimations.tsx @@ -510,6 +510,14 @@ export const useProcessAnimation = ( if (activeVehicles.length === 0) { onHitTriggers.forEach((trigger: Trigger) => { + const triggerKey = `${point.uuid}-${trigger.uuid}`; + + newTriggerCounts[triggerKey] = (newTriggerCounts[triggerKey] || 0) + 1; + + shouldLog = true; + + newTriggerLogs.push({ timestamp: currentTime, pointId: point.uuid, objectId, triggerId: trigger.uuid, }); + const connections = point.connections?.targets || []; connections.forEach((connection) => { @@ -529,7 +537,7 @@ export const useProcessAnimation = ( let processTotalHits = Object.values(newTriggerCounts).reduce((a, b) => a + b, 0); - // Handle logic for vehicles and ArmBots when a trigger is hit + // Handle logic for vehicles when a trigger is hit if (shouldLog) { vehiclePaths.forEach((vehiclePath) => { if (vehiclePath.points?.length > 0) {