From b89589d8eaaec7a24bbe262ddfe588abb9dabe78 Mon Sep 17 00:00:00 2001 From: Jerald-Golden-B Date: Sat, 5 Apr 2025 15:15:01 +0530 Subject: [PATCH] refactor: Update connection identifiers from pathUUID to modelUUID across simulation components --- .../geomentries/assets/addAssetModel.ts | 2 +- .../controls/selection/copyPasteControls.tsx | 2 +- .../selection/duplicationControls.tsx | 5 +- .../scene/controls/selection/moveControls.tsx | 2 +- .../controls/selection/rotateControls.tsx | 4 +- .../simulation/behaviour/behaviour.tsx | 8 +- .../modules/simulation/path/pathConnector.tsx | 159 +++++++++++++----- .../simulation/process/processAnimator.tsx | 4 +- .../simulation/process/processCreator.tsx | 48 +++--- app/src/types/world/worldTypes.d.ts | 14 +- 10 files changed, 162 insertions(+), 86 deletions(-) diff --git a/app/src/modules/builder/geomentries/assets/addAssetModel.ts b/app/src/modules/builder/geomentries/assets/addAssetModel.ts index e6c56ae..9fc6199 100644 --- a/app/src/modules/builder/geomentries/assets/addAssetModel.ts +++ b/app/src/modules/builder/geomentries/assets/addAssetModel.ts @@ -171,7 +171,7 @@ async function handleModelLoad( }], triggers: [], connections: { - source: { pathUUID: model.uuid, pointUUID: pointUUIDs[index] }, + source: { modelUUID: model.uuid, pointUUID: pointUUIDs[index] }, targets: [] } })), diff --git a/app/src/modules/scene/controls/selection/copyPasteControls.tsx b/app/src/modules/scene/controls/selection/copyPasteControls.tsx index 5aecf77..8a8c84c 100644 --- a/app/src/modules/scene/controls/selection/copyPasteControls.tsx +++ b/app/src/modules/scene/controls/selection/copyPasteControls.tsx @@ -183,7 +183,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas : [defaultAction], triggers: (eventData as Types.ConveyorEventsSchema)?.points[index].triggers, connections: { - source: { pathUUID: obj.uuid, pointUUID }, + source: { modelUUID: obj.uuid, pointUUID }, targets: [] } }; diff --git a/app/src/modules/scene/controls/selection/duplicationControls.tsx b/app/src/modules/scene/controls/selection/duplicationControls.tsx index a058a09..96bd9e2 100644 --- a/app/src/modules/scene/controls/selection/duplicationControls.tsx +++ b/app/src/modules/scene/controls/selection/duplicationControls.tsx @@ -165,7 +165,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb : [defaultAction], triggers: (eventData as Types.ConveyorEventsSchema)?.points[index].triggers, connections: { - source: { pathUUID: obj.uuid, pointUUID }, + source: { modelUUID: newFloorItem.modeluuid, pointUUID }, targets: [] } }; @@ -221,7 +221,8 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb newEventData as Types.ConveyorEventsSchema ]); - socket.emit("v2:model-asset:add", data); + console.log('data: ', data); + // socket.emit("v2:model-asset:add", data); } else if (eventData.type === 'Vehicle' && eventData) { const createVehiclePoint = () => { diff --git a/app/src/modules/scene/controls/selection/moveControls.tsx b/app/src/modules/scene/controls/selection/moveControls.tsx index 6055ed0..9871811 100644 --- a/app/src/modules/scene/controls/selection/moveControls.tsx +++ b/app/src/modules/scene/controls/selection/moveControls.tsx @@ -185,7 +185,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje const email = localStorage.getItem("email"); const organization = email ? email.split("@")[1].split(".")[0] : "default"; - if (eventData) { + if (eventData && eventData.type !== 'StaticMachine') { if (eventData.type === 'Conveyor' && eventData) { const backendEventData = { diff --git a/app/src/modules/scene/controls/selection/rotateControls.tsx b/app/src/modules/scene/controls/selection/rotateControls.tsx index 92af77c..04a9cd8 100644 --- a/app/src/modules/scene/controls/selection/rotateControls.tsx +++ b/app/src/modules/scene/controls/selection/rotateControls.tsx @@ -189,7 +189,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo const email = localStorage.getItem("email"); const organization = email ? email.split("@")[1].split(".")[0] : "default"; - if (eventData) { + if (eventData && eventData.type !== 'StaticMachine') { if (eventData.type === 'Conveyor' && eventData) { const backendEventData = { @@ -298,7 +298,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo } } else { - +console.log('hii'); //REST diff --git a/app/src/modules/simulation/behaviour/behaviour.tsx b/app/src/modules/simulation/behaviour/behaviour.tsx index 57ac7cd..0ddc3aa 100644 --- a/app/src/modules/simulation/behaviour/behaviour.tsx +++ b/app/src/modules/simulation/behaviour/behaviour.tsx @@ -31,7 +31,7 @@ function Behaviour() { // rotation: [0, 0, 0], // actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: true }], // triggers: [], - // connections: { source: { pathUUID: item.modeluuid, pointUUID: point1UUID }, targets: [] }, + // connections: { source: { modelUUID: item.modeluuid, pointUUID: point1UUID }, targets: [] }, // }, // { // uuid: middlePointUUID, @@ -39,7 +39,7 @@ function Behaviour() { // rotation: [0, 0, 0], // actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: true }], // triggers: [], - // connections: { source: { pathUUID: item.modeluuid, pointUUID: middlePointUUID }, targets: [] }, + // connections: { source: { modelUUID: item.modeluuid, pointUUID: middlePointUUID }, targets: [] }, // }, // { // uuid: point2UUID, @@ -47,7 +47,7 @@ function Behaviour() { // rotation: [0, 0, 0], // actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: true }], // triggers: [], - // connections: { source: { pathUUID: item.modeluuid, pointUUID: point2UUID }, targets: [] }, + // connections: { source: { modelUUID: item.modeluuid, pointUUID: point2UUID }, targets: [] }, // }, // ], // position: [...item.position], @@ -68,7 +68,7 @@ function Behaviour() { // uuid: pointUUID, // position: [pointPosition.x, pointPosition.y, pointPosition.z], // actions: { uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Start', start: {}, hitCount: 1, end: {}, buffer: 0 }, - // connections: { source: { pathUUID: item.modeluuid, pointUUID: pointUUID }, targets: [] }, + // connections: { source: { modelUUID: item.modeluuid, pointUUID: pointUUID }, targets: [] }, // speed: 2, // }, // position: [...item.position], diff --git a/app/src/modules/simulation/path/pathConnector.tsx b/app/src/modules/simulation/path/pathConnector.tsx index 28d641f..8a295be 100644 --- a/app/src/modules/simulation/path/pathConnector.tsx +++ b/app/src/modules/simulation/path/pathConnector.tsx @@ -17,7 +17,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec const { socket } = useSocketStore(); const [firstSelected, setFirstSelected] = useState<{ - pathUUID: string; + modelUUID: string; sphereUUID: string; position: THREE.Vector3; isCorner: boolean; @@ -26,26 +26,26 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec const [helperlineColor, setHelperLineColor] = useState('red'); const updatePathConnections = ( - fromPathUUID: string, + fromModelUUID: string, fromPointUUID: string, - toPathUUID: string, + toModelUUID: string, toPointUUID: string ) => { const updatedPaths = simulationStates.map(path => { if (path.type === 'Conveyor') { - if (path.modeluuid === fromPathUUID) { + if (path.modeluuid === fromModelUUID) { return { ...path, points: path.points.map(point => { if (point.uuid === fromPointUUID) { const newTarget = { - pathUUID: toPathUUID, + modelUUID: toModelUUID, pointUUID: toPointUUID }; const existingTargets = point.connections.targets || []; if (!existingTargets.some(target => - target.pathUUID === newTarget.pathUUID && + target.modelUUID === newTarget.modelUUID && target.pointUUID === newTarget.pointUUID )) { return { @@ -61,19 +61,19 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec }) }; } - else if (path.modeluuid === toPathUUID) { + else if (path.modeluuid === toModelUUID) { return { ...path, points: path.points.map(point => { if (point.uuid === toPointUUID) { const reverseTarget = { - pathUUID: fromPathUUID, + modelUUID: fromModelUUID, pointUUID: fromPointUUID }; const existingTargets = point.connections.targets || []; if (!existingTargets.some(target => - target.pathUUID === reverseTarget.pathUUID && + target.modelUUID === reverseTarget.modelUUID && target.pointUUID === reverseTarget.pointUUID )) { return { @@ -90,18 +90,17 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec }; } } - // In the updatePathConnections function, modify the Vehicle handling section: else if (path.type === 'Vehicle') { // Handle outgoing connections from Vehicle - if (path.modeluuid === fromPathUUID && path.points.uuid === fromPointUUID) { + if (path.modeluuid === fromModelUUID && path.points.uuid === fromPointUUID) { const newTarget = { - pathUUID: toPathUUID, + modelUUID: toModelUUID, pointUUID: toPointUUID }; const existingTargets = path.points.connections.targets || []; // Check if target is a Conveyor - const toPath = simulationStates.find(p => p.modeluuid === toPathUUID); + const toPath = simulationStates.find(p => p.modeluuid === toModelUUID); if (toPath?.type !== 'Conveyor') { console.log("Vehicle can only connect to Conveyors"); return path; @@ -114,7 +113,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec } if (!existingTargets.some(target => - target.pathUUID === newTarget.pathUUID && + target.modelUUID === newTarget.modelUUID && target.pointUUID === newTarget.pointUUID )) { return { @@ -130,15 +129,15 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec } } // Handle incoming connections to Vehicle - else if (path.modeluuid === toPathUUID && path.points.uuid === toPointUUID) { + else if (path.modeluuid === toModelUUID && path.points.uuid === toPointUUID) { const reverseTarget = { - pathUUID: fromPathUUID, + modelUUID: fromModelUUID, pointUUID: fromPointUUID }; const existingTargets = path.points.connections.targets || []; // Check if source is a Conveyor - const fromPath = simulationStates.find(p => p.modeluuid === fromPathUUID); + const fromPath = simulationStates.find(p => p.modeluuid === fromModelUUID); if (fromPath?.type !== 'Conveyor') { console.log("Vehicle can only connect to Conveyors"); return path; @@ -151,7 +150,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec } if (!existingTargets.some(target => - target.pathUUID === reverseTarget.pathUUID && + target.modelUUID === reverseTarget.modelUUID && target.pointUUID === reverseTarget.pointUUID )) { return { @@ -168,13 +167,89 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec } return path; } + // else if (path.type === 'StaticMachine') { + // if (path.modeluuid === fromModelUUID && path.points.uuid === fromPointUUID) { + // const newTarget = { + // modelUUID: toModelUUID, + // pointUUID: toPointUUID + // }; + // const existingTargets = path.points.connections.targets || []; + + // // Check if target is an ArmBot + // const toPath = simulationStates.find(p => p.modeluuid === toModelUUID); + // if (toPath?.type !== 'ArmBot') { + // console.log("StaticMachine can only connect to ArmBot"); + // return path; + // } + + // // Check if already has a connection + // if (existingTargets.length >= 1) { + // console.log("StaticMachine can have only one connection"); + // return path; + // } + + // if (!existingTargets.some(target => + // target.modelUUID === newTarget.modelUUID && + // target.pointUUID === newTarget.pointUUID + // )) { + // return { + // ...path, + // points: { + // ...path.points, + // connections: { + // ...path.points.connections, + // targets: [...existingTargets, newTarget] + // } + // } + // }; + // } + // } + // // Handle incoming connections to StaticMachine + // else if (path.modeluuid === toModelUUID && path.points.uuid === toPointUUID) { + // const reverseTarget = { + // modelUUID: fromModelUUID, + // pointUUID: fromPointUUID + // }; + // const existingTargets = path.points.connections.targets || []; + + // // Check if source is an ArmBot + // const fromPath = simulationStates.find(p => p.modeluuid === fromModelUUID); + // if (fromPath?.type !== 'ArmBot') { + // console.log("StaticMachine can only connect to ArmBot"); + // return path; + // } + + // // Check if already has a connection + // if (existingTargets.length >= 1) { + // console.log("StaticMachine can have only one connection"); + // return path; + // } + + // if (!existingTargets.some(target => + // target.modelUUID === reverseTarget.modelUUID && + // target.pointUUID === reverseTarget.pointUUID + // )) { + // return { + // ...path, + // points: { + // ...path.points, + // connections: { + // ...path.points.connections, + // targets: [...existingTargets, reverseTarget] + // } + // } + // }; + // } + // } + // return path; + // } return path; }); setSimulationStates(updatedPaths); const updatedPathDetails = updatedPaths.filter(path => - path.modeluuid === fromPathUUID || path.modeluuid === toPathUUID + path.modeluuid === fromModelUUID || path.modeluuid === toModelUUID ); updateBackend(updatedPathDetails); @@ -223,8 +298,8 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec } - const handleAddConnection = (fromPathUUID: string, fromUUID: string, toPathUUID: string, toUUID: string) => { - updatePathConnections(fromPathUUID, fromUUID, toPathUUID, toUUID); + const handleAddConnection = (fromModelUUID: string, fromUUID: string, toModelUUID: string, toUUID: string) => { + updatePathConnections(fromModelUUID, fromUUID, toModelUUID, toUUID); setFirstSelected(null); setCurrentLine(null); setIsConnecting(false); @@ -261,7 +336,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec const intersected = intersects[0].object; if (intersected.name.includes("events-sphere")) { - const pathUUID = intersected.userData.path.modeluuid; + const modelUUID = intersected.userData.path.modeluuid; const sphereUUID = intersected.uuid; const worldPosition = new THREE.Vector3(); intersected.getWorldPosition(worldPosition); @@ -277,9 +352,9 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec isStartOrEnd = sphereUUID === intersected.userData.path.points.uuid; } - if (pathUUID) { - const firstPath = simulationStates.find(p => p.modeluuid === firstSelected?.pathUUID); - const secondPath = simulationStates.find(p => p.modeluuid === pathUUID); + if (modelUUID) { + const firstPath = simulationStates.find(p => p.modeluuid === firstSelected?.modelUUID); + const secondPath = simulationStates.find(p => p.modeluuid === modelUUID); // Prevent vehicle-to-vehicle connections if (firstPath && secondPath && firstPath.type === 'Vehicle' && secondPath.type === 'Vehicle') { @@ -299,15 +374,15 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec // Check if this specific connection already exists const isDuplicateConnection = firstSelected ? simulationStates.some(path => { - if (path.modeluuid === firstSelected.pathUUID) { + if (path.modeluuid === firstSelected.modelUUID) { if (path.type === 'Conveyor') { const point = path.points.find(p => p.uuid === firstSelected.sphereUUID); return point?.connections.targets.some(t => - t.pathUUID === pathUUID && t.pointUUID === sphereUUID + t.modelUUID === modelUUID && t.pointUUID === sphereUUID ); } else if (path.type === 'Vehicle') { return path.points.connections.targets.some(t => - t.pathUUID === pathUUID && t.pointUUID === sphereUUID + t.modelUUID === modelUUID && t.pointUUID === sphereUUID ); } } @@ -357,7 +432,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec } // Prevent same-path connections - if (firstSelected.pathUUID === pathUUID) { + if (firstSelected.modelUUID === modelUUID) { console.log("Cannot connect spheres on the same path."); return; } @@ -370,15 +445,15 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec // All checks passed - make the connection handleAddConnection( - firstSelected.pathUUID, + firstSelected.modelUUID, firstSelected.sphereUUID, - pathUUID, + modelUUID, sphereUUID ); } else { // First selection - just store it setFirstSelected({ - pathUUID, + modelUUID, sphereUUID, position: worldPosition, isCorner: isStartOrEnd @@ -426,7 +501,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec ); let point: THREE.Vector3 | null = null; - let snappedSphere: { sphereUUID: string, position: THREE.Vector3, pathUUID: string, isCorner: boolean } | null = null; + let snappedSphere: { sphereUUID: string, position: THREE.Vector3, modelUUID: string, isCorner: boolean } | null = null; let isInvalidConnection = false; if (intersects.length > 0) { @@ -446,10 +521,10 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec const spherePosition = new THREE.Vector3(); sphere.getWorldPosition(spherePosition); const pathData = sphere.userData.path; - const pathUUID = pathData.modeluuid; + const modelUUID = pathData.modeluuid; - const firstPath = simulationStates.find(p => p.modeluuid === firstSelected.pathUUID); - const secondPath = simulationStates.find(p => p.modeluuid === pathUUID); + const firstPath = simulationStates.find(p => p.modeluuid === firstSelected.modelUUID); + const secondPath = simulationStates.find(p => p.modeluuid === modelUUID); const isVehicleToVehicle = firstPath?.type === 'Vehicle' && secondPath?.type === 'Vehicle'; // Inside the useFrame hook, where we check for snapped spheres: @@ -465,15 +540,15 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec // Check for duplicate connection (regardless of path type) const isDuplicateConnection = simulationStates.some(path => { - if (path.modeluuid === firstSelected.pathUUID) { + if (path.modeluuid === firstSelected.modelUUID) { if (path.type === 'Conveyor') { const point = path.points.find(p => p.uuid === firstSelected.sphereUUID); return point?.connections.targets.some(t => - t.pathUUID === pathUUID && t.pointUUID === sphereUUID + t.modelUUID === modelUUID && t.pointUUID === sphereUUID ); } else if (path.type === 'Vehicle') { return path.points.connections.targets.some(t => - t.pathUUID === pathUUID && t.pointUUID === sphereUUID + t.modelUUID === modelUUID && t.pointUUID === sphereUUID ); } } @@ -506,7 +581,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec !isVehicleAtMaxConnections && !isVehicleConnectingToNonConveyor && firstSelected.sphereUUID !== sphereUUID && - firstSelected.pathUUID !== pathUUID && + firstSelected.modelUUID !== modelUUID && (firstSelected.isCorner || isConnectable) && !(firstPath?.type === 'Conveyor' && pathData.type === 'Conveyor' && @@ -515,7 +590,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec snappedSphere = { sphereUUID, position: spherePosition, - pathUUID, + modelUUID, isCorner: isConnectable }; } else { @@ -563,7 +638,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec if (path.type === 'Conveyor') { return path.points.flatMap(point => point.connections.targets.map((target, index) => { - const targetPath = simulationStates.find(p => p.modeluuid === target.pathUUID); + const targetPath = simulationStates.find(p => p.modeluuid === target.modelUUID); if (targetPath?.type === 'Vehicle') return null; const fromSphere = pathsGroupRef.current?.getObjectByProperty('uuid', point.uuid); diff --git a/app/src/modules/simulation/process/processAnimator.tsx b/app/src/modules/simulation/process/processAnimator.tsx index d82b800..c8cf07f 100644 --- a/app/src/modules/simulation/process/processAnimator.tsx +++ b/app/src/modules/simulation/process/processAnimator.tsx @@ -29,8 +29,8 @@ interface ProcessPoint { rotation: number[]; actions: PointAction[]; connections: { - source: { pathUUID: string; pointUUID: string }; - targets: { pathUUID: string; pointUUID: string }[]; + source: { modelUUID: string; pointUUID: string }; + targets: { modelUUID: string; pointUUID: string }[]; }; } diff --git a/app/src/modules/simulation/process/processCreator.tsx b/app/src/modules/simulation/process/processCreator.tsx index a579719..4403a71 100644 --- a/app/src/modules/simulation/process/processCreator.tsx +++ b/app/src/modules/simulation/process/processCreator.tsx @@ -29,7 +29,7 @@ // position: [number, number, number]; // actions: PointAction[]; // connections: { -// targets: Array<{ pathUUID: string }>; +// targets: Array<{ modelUUID: string }>; // }; // } @@ -72,7 +72,7 @@ // actions: point.actions.map(normalizeAction), // Preserve exact actions // connections: { // targets: point.connections.targets.map((target) => ({ -// pathUUID: target.pathUUID, +// modelUUID: target.modelUUID, // })), // }, // })), @@ -94,7 +94,7 @@ // : [normalizeAction(path.point.actions)], // connections: { // targets: path.point.connections.targets.map((target) => ({ -// pathUUID: target.pathUUID, +// modelUUID: target.modelUUID, // })), // }, // }, @@ -137,18 +137,18 @@ // // Check if current last connects to next last (requires reversal) // const connectsToLast = currentLastPoint.connections.targets.some( // (target) => -// target.pathUUID === nextPath.modeluuid && +// target.modelUUID === nextPath.modeluuid && // nextLastPoint.connections.targets.some( -// (t) => t.pathUUID === currentPath.modeluuid +// (t) => t.modelUUID === currentPath.modeluuid // ) // ); // // Check if current last connects to next first (no reversal needed) // const connectsToFirst = currentLastPoint.connections.targets.some( // (target) => -// target.pathUUID === nextPath.modeluuid && +// target.modelUUID === nextPath.modeluuid && // nextFirstPoint.connections.targets.some( -// (t) => t.pathUUID === currentPath.modeluuid +// (t) => t.modelUUID === currentPath.modeluuid // ) // ); @@ -249,10 +249,10 @@ // // Process outgoing connections // for (const point of currentPath.points) { // for (const target of point.connections.targets) { -// if (!visited.has(target.pathUUID)) { -// const targetPath = pathMap.get(target.pathUUID); +// if (!visited.has(target.modelUUID)) { +// const targetPath = pathMap.get(target.modelUUID); // if (targetPath) { -// visited.add(target.pathUUID); +// visited.add(target.modelUUID); // queue.push(targetPath); // } // } @@ -264,7 +264,7 @@ // if (!visited.has(uuid)) { // const hasConnectionToCurrent = path.points.some((point) => // point.connections.targets.some( -// (t) => t.pathUUID === currentPath.modeluuid +// (t) => t.modelUUID === currentPath.modeluuid // ) // ); // if (hasConnectionToCurrent) { @@ -335,7 +335,7 @@ // ), // connections: path.points // .flatMap((p: PathPoint) => -// p.connections.targets.map((t: { pathUUID: string }) => t.pathUUID) +// p.connections.targets.map((t: { modelUUID: string }) => t.modelUUID) // ) // .join(","), // })); @@ -428,7 +428,7 @@ export interface PathPoint { position: [number, number, number]; actions: PointAction[]; connections: { - targets: Array<{ pathUUID: string }>; + targets: Array<{ modelUUID: string }>; }; } @@ -473,7 +473,7 @@ function convertToSimulationPath( actions: point.actions.map(normalizeAction), // Preserve exact actions connections: { targets: point.connections.targets.map((target) => ({ - pathUUID: target.pathUUID, + modelUUID: target.modelUUID, })), }, })), @@ -496,7 +496,7 @@ function convertToSimulationPath( : [normalizeAction(path.points.actions)], connections: { targets: path.points.connections.targets.map((target) => ({ - pathUUID: target.pathUUID, + modelUUID: target.modelUUID, })), }, }, @@ -539,18 +539,18 @@ function shouldReverseNextPath( // Check if current last connects to next last (requires reversal) const connectsToLast = currentLastPoint.connections.targets.some( (target) => - target.pathUUID === nextPath.modeluuid && + target.modelUUID === nextPath.modeluuid && nextLastPoint.connections.targets.some( - (t) => t.pathUUID === currentPath.modeluuid + (t) => t.modelUUID === currentPath.modeluuid ) ); // Check if current last connects to next first (no reversal needed) const connectsToFirst = currentLastPoint.connections.targets.some( (target) => - target.pathUUID === nextPath.modeluuid && + target.modelUUID === nextPath.modeluuid && nextFirstPoint.connections.targets.some( - (t) => t.pathUUID === currentPath.modeluuid + (t) => t.modelUUID === currentPath.modeluuid ) ); @@ -678,10 +678,10 @@ export function useProcessCreation() { // Process outgoing connections for (const point of currentPath.points) { for (const target of point.connections.targets) { - if (!visited.has(target.pathUUID)) { - const targetPath = pathMap.get(target.pathUUID); + if (!visited.has(target.modelUUID)) { + const targetPath = pathMap.get(target.modelUUID); if (targetPath) { - visited.add(target.pathUUID); + visited.add(target.modelUUID); queue.push(targetPath); } } @@ -693,7 +693,7 @@ export function useProcessCreation() { if (!visited.has(uuid)) { const hasConnectionToCurrent = path.points.some((point) => point.connections.targets.some( - (t) => t.pathUUID === currentPath.modeluuid + (t) => t.modelUUID === currentPath.modeluuid ) ); if (hasConnectionToCurrent) { @@ -768,7 +768,7 @@ const ProcessCreator: React.FC = React.memo( .join(","), connections: path.points .flatMap((p: PathPoint) => - p.connections.targets.map((t: { pathUUID: string }) => t.pathUUID) + p.connections.targets.map((t: { modelUUID: string }) => t.modelUUID) ) .join(","), })); diff --git a/app/src/types/world/worldTypes.d.ts b/app/src/types/world/worldTypes.d.ts index 85bcb9d..9038efe 100644 --- a/app/src/types/world/worldTypes.d.ts +++ b/app/src/types/world/worldTypes.d.ts @@ -271,10 +271,10 @@ export type RefCSM = React.MutableRefObject; export type RefCSMHelper = React.MutableRefObject; interface PathConnection { - fromPathUUID: string; + fromModelUUID: string; fromUUID: string; toConnections: { - toPathUUID: string; + toModelUUID: string; toUUID: string; }[]; } @@ -296,7 +296,7 @@ interface ConveyorEventsSchema { rotation: [number, number, number]; actions: { uuid: string; name: string; type: string; material: string; delay: number | string; spawnInterval: number | string; isUsed: boolean }[] | []; triggers: { uuid: string; name: string; type: string; isUsed: boolean; bufferTime: number }[] | []; - connections: { source: { pathUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] }; + connections: { source: { modelUUID: string; pointUUID: string }; targets: { modelUUID: string; pointUUID: string }[] }; }[]; position: [number, number, number]; rotation: [number, number, number]; @@ -311,7 +311,7 @@ interface VehicleEventsSchema { uuid: string; position: [number, number, number]; actions: { uuid: string; name: string; type: string; start: { x: number, y: number } | {}, hitCount: number, end: { x: number, y: number } | {}, buffer: number }; - connections: { source: { modelUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] }; + connections: { source: { modelUUID: string; pointUUID: string }; targets: { modelUUID: string; pointUUID: string }[] }; speed: number; }; position: [number, number, number]; @@ -326,7 +326,7 @@ interface StaticMachineEventsSchema { position: [number, number, number]; actions: { uuid: string; name: string; buffer: number | string; material: string; isUsed: boolean }; triggers: { uuid: string; name: string; type: string }; - connections: { source: { modelUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] }; + connections: { source: { modelUUID: string; pointUUID: string }; targets: { modelUUID: string; pointUUID: string }[] }; }; position: [number, number, number]; } @@ -347,7 +347,7 @@ export type EventData = { rotation: [number, number, number]; actions: { uuid: string; name: string; type: string; material: string; delay: number | string; spawnInterval: number | string; isUsed: boolean }[] | []; triggers: { uuid: string; name: string; type: string; isUsed: boolean; bufferTime: number }[] | []; - connections: { source: { pathUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] }; + connections: { source: { modelUUID: string; pointUUID: string }; targets: { modelUUID: string; pointUUID: string }[] }; }[]; speed: number | string; } | { @@ -356,7 +356,7 @@ export type EventData = { uuid: string; position: [number, number, number]; actions: { uuid: string; name: string; type: string; start: { x: number, y: number } | {}, hitCount: number, end: { x: number, y: number } | {}, buffer: number }; - connections: { source: { modelUUID: string; pointUUID: string }; targets: { pathUUID: string; pointUUID: string }[] }; + connections: { source: { modelUUID: string; pointUUID: string }; targets: { modelUUID: string; pointUUID: string }[] }; speed: number; }; };