"updated arm logic"
This commit is contained in:
@@ -8,8 +8,7 @@ import crate from "../../../assets/gltf-glb/crate_box.glb";
|
||||
import { useProcessAnimation } from "./useProcessAnimations";
|
||||
import ProcessObject from "./processObject";
|
||||
import { ProcessData } from "./types";
|
||||
import { useSimulationStates } from "../../../store/store";
|
||||
import { retrieveGLTF } from "../../../utils/indexDB/idbUtils";
|
||||
|
||||
|
||||
interface ProcessContainerProps {
|
||||
processes: ProcessData[];
|
||||
@@ -44,19 +43,23 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
||||
checkAndCountTriggers,
|
||||
} = useProcessAnimation(processes, setProcesses, agvRef);
|
||||
|
||||
const baseMaterials = useMemo(() => ({
|
||||
Box: new THREE.MeshStandardMaterial({ color: 0x8b4513 }),
|
||||
Crate: new THREE.MeshStandardMaterial({ color: 0x00ff00 }),
|
||||
Default: new THREE.MeshStandardMaterial(),
|
||||
}), []);
|
||||
const baseMaterials = useMemo(
|
||||
() => ({
|
||||
Box: new THREE.MeshStandardMaterial({ color: 0x8b4513 }),
|
||||
Crate: new THREE.MeshStandardMaterial({ color: 0x00ff00 }),
|
||||
Default: new THREE.MeshStandardMaterial(),
|
||||
}),
|
||||
[]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
// Update material references for all spawned objects
|
||||
Object.entries(animationStates).forEach(([processId, processState]) => {
|
||||
Object.keys(processState.spawnedObjects).forEach((objectId) => {
|
||||
const entry = { processId, objectId, };
|
||||
const entry = { processId, objectId };
|
||||
|
||||
const materialType = processState.spawnedObjects[objectId]?.currentMaterialType;
|
||||
const materialType =
|
||||
processState.spawnedObjects[objectId]?.currentMaterialType;
|
||||
|
||||
if (!materialType) {
|
||||
return;
|
||||
@@ -65,13 +68,17 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
||||
const matRefArray = MaterialRef.current;
|
||||
|
||||
// Find existing material group
|
||||
const existing = matRefArray.find((entryGroup: { material: string; objects: any[] }) =>
|
||||
entryGroup.material === materialType
|
||||
const existing = matRefArray.find(
|
||||
(entryGroup: { material: string; objects: any[] }) =>
|
||||
entryGroup.material === materialType
|
||||
);
|
||||
|
||||
if (existing) {
|
||||
// Check if this processId + objectId already exists
|
||||
const alreadyExists = existing.objects.some((o: any) => o.processId === entry.processId && o.objectId === entry.objectId);
|
||||
const alreadyExists = existing.objects.some(
|
||||
(o: any) =>
|
||||
o.processId === entry.processId && o.objectId === entry.objectId
|
||||
);
|
||||
|
||||
if (!alreadyExists) {
|
||||
existing.objects.push(entry);
|
||||
@@ -91,7 +98,8 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
||||
|
||||
useFrame(() => {
|
||||
// Spawn logic frame
|
||||
const currentTime = clockRef.current.getElapsedTime() - elapsedBeforePauseRef.current;
|
||||
const currentTime =
|
||||
clockRef.current.getElapsedTime() - elapsedBeforePauseRef.current;
|
||||
|
||||
setAnimationStates((prev) => {
|
||||
const newStates = { ...prev };
|
||||
@@ -119,7 +127,10 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
||||
: parseFloat(spawnAction.spawnInterval as string) || 0;
|
||||
|
||||
// Check if this is a zero interval spawn and we already spawned an object
|
||||
if (spawnInterval === 0 && processState.hasSpawnedZeroIntervalObject === true) {
|
||||
if (
|
||||
spawnInterval === 0 &&
|
||||
processState.hasSpawnedZeroIntervalObject === true
|
||||
) {
|
||||
return; // Don't spawn more objects for zero interval
|
||||
}
|
||||
|
||||
@@ -324,10 +335,13 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
||||
|
||||
if (isLastPoint) {
|
||||
const isAgvPicking = agvRef.current.some(
|
||||
(agv: any) => agv.processId === process.id && agv.status === "picking"
|
||||
(agv: any) =>
|
||||
agv.processId === process.id && agv.status === "picking"
|
||||
);
|
||||
|
||||
const shouldHide = !currentPointData?.actions || !hasNonInheritActions(currentPointData.actions);
|
||||
const shouldHide =
|
||||
!currentPointData?.actions ||
|
||||
!hasNonInheritActions(currentPointData.actions);
|
||||
|
||||
if (shouldHide) {
|
||||
if (isAgvPicking) {
|
||||
@@ -358,7 +372,8 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
||||
|
||||
if (tempStackedObjectsRef.current[objectId]) {
|
||||
const isAgvPicking = agvRef.current.some(
|
||||
(agv: any) => agv.processId === process.id && agv.status === "picking"
|
||||
(agv: any) =>
|
||||
agv.processId === process.id && agv.status === "picking"
|
||||
);
|
||||
|
||||
if (isAgvPicking) {
|
||||
@@ -377,7 +392,8 @@ const ProcessAnimator: React.FC<ProcessContainerProps> = ({
|
||||
|
||||
if (!isLastPoint) {
|
||||
const nextPoint = path[nextPointIdx];
|
||||
const distance = path[stateRef.currentIndex].distanceTo(nextPoint);
|
||||
const distance =
|
||||
path[stateRef.currentIndex].distanceTo(nextPoint);
|
||||
const effectiveSpeed = stateRef.speed * speedRef.current;
|
||||
const movement = effectiveSpeed * delta;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user