refactor: Update connection identifiers from pathUUID to modelUUID across simulation components

This commit is contained in:
Jerald-Golden-B 2025-04-05 15:15:01 +05:30
parent 1cc877aee1
commit b89589d8ea
10 changed files with 162 additions and 86 deletions

View File

@ -171,7 +171,7 @@ async function handleModelLoad(
}], }],
triggers: [], triggers: [],
connections: { connections: {
source: { pathUUID: model.uuid, pointUUID: pointUUIDs[index] }, source: { modelUUID: model.uuid, pointUUID: pointUUIDs[index] },
targets: [] targets: []
} }
})), })),

View File

@ -183,7 +183,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
: [defaultAction], : [defaultAction],
triggers: (eventData as Types.ConveyorEventsSchema)?.points[index].triggers, triggers: (eventData as Types.ConveyorEventsSchema)?.points[index].triggers,
connections: { connections: {
source: { pathUUID: obj.uuid, pointUUID }, source: { modelUUID: obj.uuid, pointUUID },
targets: [] targets: []
} }
}; };

View File

@ -165,7 +165,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
: [defaultAction], : [defaultAction],
triggers: (eventData as Types.ConveyorEventsSchema)?.points[index].triggers, triggers: (eventData as Types.ConveyorEventsSchema)?.points[index].triggers,
connections: { connections: {
source: { pathUUID: obj.uuid, pointUUID }, source: { modelUUID: newFloorItem.modeluuid, pointUUID },
targets: [] targets: []
} }
}; };
@ -221,7 +221,8 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
newEventData as Types.ConveyorEventsSchema 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) { } else if (eventData.type === 'Vehicle' && eventData) {
const createVehiclePoint = () => { const createVehiclePoint = () => {

View File

@ -185,7 +185,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
const email = localStorage.getItem("email"); const email = localStorage.getItem("email");
const organization = email ? email.split("@")[1].split(".")[0] : "default"; const organization = email ? email.split("@")[1].split(".")[0] : "default";
if (eventData) { if (eventData && eventData.type !== 'StaticMachine') {
if (eventData.type === 'Conveyor' && eventData) { if (eventData.type === 'Conveyor' && eventData) {
const backendEventData = { const backendEventData = {

View File

@ -189,7 +189,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
const email = localStorage.getItem("email"); const email = localStorage.getItem("email");
const organization = email ? email.split("@")[1].split(".")[0] : "default"; const organization = email ? email.split("@")[1].split(".")[0] : "default";
if (eventData) { if (eventData && eventData.type !== 'StaticMachine') {
if (eventData.type === 'Conveyor' && eventData) { if (eventData.type === 'Conveyor' && eventData) {
const backendEventData = { const backendEventData = {
@ -298,7 +298,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
} }
} else { } else {
console.log('hii');
//REST //REST

View File

@ -31,7 +31,7 @@ function Behaviour() {
// rotation: [0, 0, 0], // rotation: [0, 0, 0],
// actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: true }], // actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: true }],
// triggers: [], // triggers: [],
// connections: { source: { pathUUID: item.modeluuid, pointUUID: point1UUID }, targets: [] }, // connections: { source: { modelUUID: item.modeluuid, pointUUID: point1UUID }, targets: [] },
// }, // },
// { // {
// uuid: middlePointUUID, // uuid: middlePointUUID,
@ -39,7 +39,7 @@ function Behaviour() {
// rotation: [0, 0, 0], // rotation: [0, 0, 0],
// actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: true }], // actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: true }],
// triggers: [], // triggers: [],
// connections: { source: { pathUUID: item.modeluuid, pointUUID: middlePointUUID }, targets: [] }, // connections: { source: { modelUUID: item.modeluuid, pointUUID: middlePointUUID }, targets: [] },
// }, // },
// { // {
// uuid: point2UUID, // uuid: point2UUID,
@ -47,7 +47,7 @@ function Behaviour() {
// rotation: [0, 0, 0], // rotation: [0, 0, 0],
// actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: true }], // actions: [{ uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Inherit', material: 'Inherit', delay: 'Inherit', spawnInterval: 'Inherit', isUsed: true }],
// triggers: [], // triggers: [],
// connections: { source: { pathUUID: item.modeluuid, pointUUID: point2UUID }, targets: [] }, // connections: { source: { modelUUID: item.modeluuid, pointUUID: point2UUID }, targets: [] },
// }, // },
// ], // ],
// position: [...item.position], // position: [...item.position],
@ -68,7 +68,7 @@ function Behaviour() {
// uuid: pointUUID, // uuid: pointUUID,
// position: [pointPosition.x, pointPosition.y, pointPosition.z], // position: [pointPosition.x, pointPosition.y, pointPosition.z],
// actions: { uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', type: 'Start', start: {}, hitCount: 1, end: {}, buffer: 0 }, // 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, // speed: 2,
// }, // },
// position: [...item.position], // position: [...item.position],

View File

@ -17,7 +17,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
const { socket } = useSocketStore(); const { socket } = useSocketStore();
const [firstSelected, setFirstSelected] = useState<{ const [firstSelected, setFirstSelected] = useState<{
pathUUID: string; modelUUID: string;
sphereUUID: string; sphereUUID: string;
position: THREE.Vector3; position: THREE.Vector3;
isCorner: boolean; isCorner: boolean;
@ -26,26 +26,26 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
const [helperlineColor, setHelperLineColor] = useState<string>('red'); const [helperlineColor, setHelperLineColor] = useState<string>('red');
const updatePathConnections = ( const updatePathConnections = (
fromPathUUID: string, fromModelUUID: string,
fromPointUUID: string, fromPointUUID: string,
toPathUUID: string, toModelUUID: string,
toPointUUID: string toPointUUID: string
) => { ) => {
const updatedPaths = simulationStates.map(path => { const updatedPaths = simulationStates.map(path => {
if (path.type === 'Conveyor') { if (path.type === 'Conveyor') {
if (path.modeluuid === fromPathUUID) { if (path.modeluuid === fromModelUUID) {
return { return {
...path, ...path,
points: path.points.map(point => { points: path.points.map(point => {
if (point.uuid === fromPointUUID) { if (point.uuid === fromPointUUID) {
const newTarget = { const newTarget = {
pathUUID: toPathUUID, modelUUID: toModelUUID,
pointUUID: toPointUUID pointUUID: toPointUUID
}; };
const existingTargets = point.connections.targets || []; const existingTargets = point.connections.targets || [];
if (!existingTargets.some(target => if (!existingTargets.some(target =>
target.pathUUID === newTarget.pathUUID && target.modelUUID === newTarget.modelUUID &&
target.pointUUID === newTarget.pointUUID target.pointUUID === newTarget.pointUUID
)) { )) {
return { return {
@ -61,19 +61,19 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
}) })
}; };
} }
else if (path.modeluuid === toPathUUID) { else if (path.modeluuid === toModelUUID) {
return { return {
...path, ...path,
points: path.points.map(point => { points: path.points.map(point => {
if (point.uuid === toPointUUID) { if (point.uuid === toPointUUID) {
const reverseTarget = { const reverseTarget = {
pathUUID: fromPathUUID, modelUUID: fromModelUUID,
pointUUID: fromPointUUID pointUUID: fromPointUUID
}; };
const existingTargets = point.connections.targets || []; const existingTargets = point.connections.targets || [];
if (!existingTargets.some(target => if (!existingTargets.some(target =>
target.pathUUID === reverseTarget.pathUUID && target.modelUUID === reverseTarget.modelUUID &&
target.pointUUID === reverseTarget.pointUUID target.pointUUID === reverseTarget.pointUUID
)) { )) {
return { 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') { else if (path.type === 'Vehicle') {
// Handle outgoing connections from Vehicle // Handle outgoing connections from Vehicle
if (path.modeluuid === fromPathUUID && path.points.uuid === fromPointUUID) { if (path.modeluuid === fromModelUUID && path.points.uuid === fromPointUUID) {
const newTarget = { const newTarget = {
pathUUID: toPathUUID, modelUUID: toModelUUID,
pointUUID: toPointUUID pointUUID: toPointUUID
}; };
const existingTargets = path.points.connections.targets || []; const existingTargets = path.points.connections.targets || [];
// Check if target is a Conveyor // 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') { if (toPath?.type !== 'Conveyor') {
console.log("Vehicle can only connect to Conveyors"); console.log("Vehicle can only connect to Conveyors");
return path; return path;
@ -114,7 +113,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
} }
if (!existingTargets.some(target => if (!existingTargets.some(target =>
target.pathUUID === newTarget.pathUUID && target.modelUUID === newTarget.modelUUID &&
target.pointUUID === newTarget.pointUUID target.pointUUID === newTarget.pointUUID
)) { )) {
return { return {
@ -130,15 +129,15 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
} }
} }
// Handle incoming connections to Vehicle // 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 = { const reverseTarget = {
pathUUID: fromPathUUID, modelUUID: fromModelUUID,
pointUUID: fromPointUUID pointUUID: fromPointUUID
}; };
const existingTargets = path.points.connections.targets || []; const existingTargets = path.points.connections.targets || [];
// Check if source is a Conveyor // 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') { if (fromPath?.type !== 'Conveyor') {
console.log("Vehicle can only connect to Conveyors"); console.log("Vehicle can only connect to Conveyors");
return path; return path;
@ -151,7 +150,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
} }
if (!existingTargets.some(target => if (!existingTargets.some(target =>
target.pathUUID === reverseTarget.pathUUID && target.modelUUID === reverseTarget.modelUUID &&
target.pointUUID === reverseTarget.pointUUID target.pointUUID === reverseTarget.pointUUID
)) { )) {
return { return {
@ -168,13 +167,89 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
} }
return path; 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; return path;
}); });
setSimulationStates(updatedPaths); setSimulationStates(updatedPaths);
const updatedPathDetails = updatedPaths.filter(path => const updatedPathDetails = updatedPaths.filter(path =>
path.modeluuid === fromPathUUID || path.modeluuid === toPathUUID path.modeluuid === fromModelUUID || path.modeluuid === toModelUUID
); );
updateBackend(updatedPathDetails); updateBackend(updatedPathDetails);
@ -223,8 +298,8 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
} }
const handleAddConnection = (fromPathUUID: string, fromUUID: string, toPathUUID: string, toUUID: string) => { const handleAddConnection = (fromModelUUID: string, fromUUID: string, toModelUUID: string, toUUID: string) => {
updatePathConnections(fromPathUUID, fromUUID, toPathUUID, toUUID); updatePathConnections(fromModelUUID, fromUUID, toModelUUID, toUUID);
setFirstSelected(null); setFirstSelected(null);
setCurrentLine(null); setCurrentLine(null);
setIsConnecting(false); setIsConnecting(false);
@ -261,7 +336,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
const intersected = intersects[0].object; const intersected = intersects[0].object;
if (intersected.name.includes("events-sphere")) { if (intersected.name.includes("events-sphere")) {
const pathUUID = intersected.userData.path.modeluuid; const modelUUID = intersected.userData.path.modeluuid;
const sphereUUID = intersected.uuid; const sphereUUID = intersected.uuid;
const worldPosition = new THREE.Vector3(); const worldPosition = new THREE.Vector3();
intersected.getWorldPosition(worldPosition); intersected.getWorldPosition(worldPosition);
@ -277,9 +352,9 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
isStartOrEnd = sphereUUID === intersected.userData.path.points.uuid; isStartOrEnd = sphereUUID === intersected.userData.path.points.uuid;
} }
if (pathUUID) { if (modelUUID) {
const firstPath = simulationStates.find(p => p.modeluuid === firstSelected?.pathUUID); const firstPath = simulationStates.find(p => p.modeluuid === firstSelected?.modelUUID);
const secondPath = simulationStates.find(p => p.modeluuid === pathUUID); const secondPath = simulationStates.find(p => p.modeluuid === modelUUID);
// Prevent vehicle-to-vehicle connections // Prevent vehicle-to-vehicle connections
if (firstPath && secondPath && firstPath.type === 'Vehicle' && secondPath.type === 'Vehicle') { 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 // Check if this specific connection already exists
const isDuplicateConnection = firstSelected const isDuplicateConnection = firstSelected
? simulationStates.some(path => { ? simulationStates.some(path => {
if (path.modeluuid === firstSelected.pathUUID) { if (path.modeluuid === firstSelected.modelUUID) {
if (path.type === 'Conveyor') { if (path.type === 'Conveyor') {
const point = path.points.find(p => p.uuid === firstSelected.sphereUUID); const point = path.points.find(p => p.uuid === firstSelected.sphereUUID);
return point?.connections.targets.some(t => return point?.connections.targets.some(t =>
t.pathUUID === pathUUID && t.pointUUID === sphereUUID t.modelUUID === modelUUID && t.pointUUID === sphereUUID
); );
} else if (path.type === 'Vehicle') { } else if (path.type === 'Vehicle') {
return path.points.connections.targets.some(t => 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 // Prevent same-path connections
if (firstSelected.pathUUID === pathUUID) { if (firstSelected.modelUUID === modelUUID) {
console.log("Cannot connect spheres on the same path."); console.log("Cannot connect spheres on the same path.");
return; return;
} }
@ -370,15 +445,15 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
// All checks passed - make the connection // All checks passed - make the connection
handleAddConnection( handleAddConnection(
firstSelected.pathUUID, firstSelected.modelUUID,
firstSelected.sphereUUID, firstSelected.sphereUUID,
pathUUID, modelUUID,
sphereUUID sphereUUID
); );
} else { } else {
// First selection - just store it // First selection - just store it
setFirstSelected({ setFirstSelected({
pathUUID, modelUUID,
sphereUUID, sphereUUID,
position: worldPosition, position: worldPosition,
isCorner: isStartOrEnd isCorner: isStartOrEnd
@ -426,7 +501,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
); );
let point: THREE.Vector3 | null = null; 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; let isInvalidConnection = false;
if (intersects.length > 0) { if (intersects.length > 0) {
@ -446,10 +521,10 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
const spherePosition = new THREE.Vector3(); const spherePosition = new THREE.Vector3();
sphere.getWorldPosition(spherePosition); sphere.getWorldPosition(spherePosition);
const pathData = sphere.userData.path; const pathData = sphere.userData.path;
const pathUUID = pathData.modeluuid; const modelUUID = pathData.modeluuid;
const firstPath = simulationStates.find(p => p.modeluuid === firstSelected.pathUUID); const firstPath = simulationStates.find(p => p.modeluuid === firstSelected.modelUUID);
const secondPath = simulationStates.find(p => p.modeluuid === pathUUID); const secondPath = simulationStates.find(p => p.modeluuid === modelUUID);
const isVehicleToVehicle = firstPath?.type === 'Vehicle' && secondPath?.type === 'Vehicle'; const isVehicleToVehicle = firstPath?.type === 'Vehicle' && secondPath?.type === 'Vehicle';
// Inside the useFrame hook, where we check for snapped spheres: // 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) // Check for duplicate connection (regardless of path type)
const isDuplicateConnection = simulationStates.some(path => { const isDuplicateConnection = simulationStates.some(path => {
if (path.modeluuid === firstSelected.pathUUID) { if (path.modeluuid === firstSelected.modelUUID) {
if (path.type === 'Conveyor') { if (path.type === 'Conveyor') {
const point = path.points.find(p => p.uuid === firstSelected.sphereUUID); const point = path.points.find(p => p.uuid === firstSelected.sphereUUID);
return point?.connections.targets.some(t => return point?.connections.targets.some(t =>
t.pathUUID === pathUUID && t.pointUUID === sphereUUID t.modelUUID === modelUUID && t.pointUUID === sphereUUID
); );
} else if (path.type === 'Vehicle') { } else if (path.type === 'Vehicle') {
return path.points.connections.targets.some(t => 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 && !isVehicleAtMaxConnections &&
!isVehicleConnectingToNonConveyor && !isVehicleConnectingToNonConveyor &&
firstSelected.sphereUUID !== sphereUUID && firstSelected.sphereUUID !== sphereUUID &&
firstSelected.pathUUID !== pathUUID && firstSelected.modelUUID !== modelUUID &&
(firstSelected.isCorner || isConnectable) && (firstSelected.isCorner || isConnectable) &&
!(firstPath?.type === 'Conveyor' && !(firstPath?.type === 'Conveyor' &&
pathData.type === 'Conveyor' && pathData.type === 'Conveyor' &&
@ -515,7 +590,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
snappedSphere = { snappedSphere = {
sphereUUID, sphereUUID,
position: spherePosition, position: spherePosition,
pathUUID, modelUUID,
isCorner: isConnectable isCorner: isConnectable
}; };
} else { } else {
@ -563,7 +638,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
if (path.type === 'Conveyor') { if (path.type === 'Conveyor') {
return path.points.flatMap(point => return path.points.flatMap(point =>
point.connections.targets.map((target, index) => { 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; if (targetPath?.type === 'Vehicle') return null;
const fromSphere = pathsGroupRef.current?.getObjectByProperty('uuid', point.uuid); const fromSphere = pathsGroupRef.current?.getObjectByProperty('uuid', point.uuid);

View File

@ -29,8 +29,8 @@ interface ProcessPoint {
rotation: number[]; rotation: number[];
actions: PointAction[]; actions: PointAction[];
connections: { connections: {
source: { pathUUID: string; pointUUID: string }; source: { modelUUID: string; pointUUID: string };
targets: { pathUUID: string; pointUUID: string }[]; targets: { modelUUID: string; pointUUID: string }[];
}; };
} }

View File

@ -29,7 +29,7 @@
// position: [number, number, number]; // position: [number, number, number];
// actions: PointAction[]; // actions: PointAction[];
// connections: { // connections: {
// targets: Array<{ pathUUID: string }>; // targets: Array<{ modelUUID: string }>;
// }; // };
// } // }
@ -72,7 +72,7 @@
// actions: point.actions.map(normalizeAction), // Preserve exact actions // actions: point.actions.map(normalizeAction), // Preserve exact actions
// connections: { // connections: {
// targets: point.connections.targets.map((target) => ({ // targets: point.connections.targets.map((target) => ({
// pathUUID: target.pathUUID, // modelUUID: target.modelUUID,
// })), // })),
// }, // },
// })), // })),
@ -94,7 +94,7 @@
// : [normalizeAction(path.point.actions)], // : [normalizeAction(path.point.actions)],
// connections: { // connections: {
// targets: path.point.connections.targets.map((target) => ({ // 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) // // Check if current last connects to next last (requires reversal)
// const connectsToLast = currentLastPoint.connections.targets.some( // const connectsToLast = currentLastPoint.connections.targets.some(
// (target) => // (target) =>
// target.pathUUID === nextPath.modeluuid && // target.modelUUID === nextPath.modeluuid &&
// nextLastPoint.connections.targets.some( // 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) // // Check if current last connects to next first (no reversal needed)
// const connectsToFirst = currentLastPoint.connections.targets.some( // const connectsToFirst = currentLastPoint.connections.targets.some(
// (target) => // (target) =>
// target.pathUUID === nextPath.modeluuid && // target.modelUUID === nextPath.modeluuid &&
// nextFirstPoint.connections.targets.some( // nextFirstPoint.connections.targets.some(
// (t) => t.pathUUID === currentPath.modeluuid // (t) => t.modelUUID === currentPath.modeluuid
// ) // )
// ); // );
@ -249,10 +249,10 @@
// // Process outgoing connections // // Process outgoing connections
// for (const point of currentPath.points) { // for (const point of currentPath.points) {
// for (const target of point.connections.targets) { // for (const target of point.connections.targets) {
// if (!visited.has(target.pathUUID)) { // if (!visited.has(target.modelUUID)) {
// const targetPath = pathMap.get(target.pathUUID); // const targetPath = pathMap.get(target.modelUUID);
// if (targetPath) { // if (targetPath) {
// visited.add(target.pathUUID); // visited.add(target.modelUUID);
// queue.push(targetPath); // queue.push(targetPath);
// } // }
// } // }
@ -264,7 +264,7 @@
// if (!visited.has(uuid)) { // if (!visited.has(uuid)) {
// const hasConnectionToCurrent = path.points.some((point) => // const hasConnectionToCurrent = path.points.some((point) =>
// point.connections.targets.some( // point.connections.targets.some(
// (t) => t.pathUUID === currentPath.modeluuid // (t) => t.modelUUID === currentPath.modeluuid
// ) // )
// ); // );
// if (hasConnectionToCurrent) { // if (hasConnectionToCurrent) {
@ -335,7 +335,7 @@
// ), // ),
// connections: path.points // connections: path.points
// .flatMap((p: PathPoint) => // .flatMap((p: PathPoint) =>
// p.connections.targets.map((t: { pathUUID: string }) => t.pathUUID) // p.connections.targets.map((t: { modelUUID: string }) => t.modelUUID)
// ) // )
// .join(","), // .join(","),
// })); // }));
@ -428,7 +428,7 @@ export interface PathPoint {
position: [number, number, number]; position: [number, number, number];
actions: PointAction[]; actions: PointAction[];
connections: { connections: {
targets: Array<{ pathUUID: string }>; targets: Array<{ modelUUID: string }>;
}; };
} }
@ -473,7 +473,7 @@ function convertToSimulationPath(
actions: point.actions.map(normalizeAction), // Preserve exact actions actions: point.actions.map(normalizeAction), // Preserve exact actions
connections: { connections: {
targets: point.connections.targets.map((target) => ({ targets: point.connections.targets.map((target) => ({
pathUUID: target.pathUUID, modelUUID: target.modelUUID,
})), })),
}, },
})), })),
@ -496,7 +496,7 @@ function convertToSimulationPath(
: [normalizeAction(path.points.actions)], : [normalizeAction(path.points.actions)],
connections: { connections: {
targets: path.points.connections.targets.map((target) => ({ 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) // Check if current last connects to next last (requires reversal)
const connectsToLast = currentLastPoint.connections.targets.some( const connectsToLast = currentLastPoint.connections.targets.some(
(target) => (target) =>
target.pathUUID === nextPath.modeluuid && target.modelUUID === nextPath.modeluuid &&
nextLastPoint.connections.targets.some( 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) // Check if current last connects to next first (no reversal needed)
const connectsToFirst = currentLastPoint.connections.targets.some( const connectsToFirst = currentLastPoint.connections.targets.some(
(target) => (target) =>
target.pathUUID === nextPath.modeluuid && target.modelUUID === nextPath.modeluuid &&
nextFirstPoint.connections.targets.some( nextFirstPoint.connections.targets.some(
(t) => t.pathUUID === currentPath.modeluuid (t) => t.modelUUID === currentPath.modeluuid
) )
); );
@ -678,10 +678,10 @@ export function useProcessCreation() {
// Process outgoing connections // Process outgoing connections
for (const point of currentPath.points) { for (const point of currentPath.points) {
for (const target of point.connections.targets) { for (const target of point.connections.targets) {
if (!visited.has(target.pathUUID)) { if (!visited.has(target.modelUUID)) {
const targetPath = pathMap.get(target.pathUUID); const targetPath = pathMap.get(target.modelUUID);
if (targetPath) { if (targetPath) {
visited.add(target.pathUUID); visited.add(target.modelUUID);
queue.push(targetPath); queue.push(targetPath);
} }
} }
@ -693,7 +693,7 @@ export function useProcessCreation() {
if (!visited.has(uuid)) { if (!visited.has(uuid)) {
const hasConnectionToCurrent = path.points.some((point) => const hasConnectionToCurrent = path.points.some((point) =>
point.connections.targets.some( point.connections.targets.some(
(t) => t.pathUUID === currentPath.modeluuid (t) => t.modelUUID === currentPath.modeluuid
) )
); );
if (hasConnectionToCurrent) { if (hasConnectionToCurrent) {
@ -768,7 +768,7 @@ const ProcessCreator: React.FC<ProcessCreatorProps> = React.memo(
.join(","), .join(","),
connections: path.points connections: path.points
.flatMap((p: PathPoint) => .flatMap((p: PathPoint) =>
p.connections.targets.map((t: { pathUUID: string }) => t.pathUUID) p.connections.targets.map((t: { modelUUID: string }) => t.modelUUID)
) )
.join(","), .join(","),
})); }));

View File

@ -271,10 +271,10 @@ export type RefCSM = React.MutableRefObject<CSM>;
export type RefCSMHelper = React.MutableRefObject<CSMHelper>; export type RefCSMHelper = React.MutableRefObject<CSMHelper>;
interface PathConnection { interface PathConnection {
fromPathUUID: string; fromModelUUID: string;
fromUUID: string; fromUUID: string;
toConnections: { toConnections: {
toPathUUID: string; toModelUUID: string;
toUUID: string; toUUID: string;
}[]; }[];
} }
@ -296,7 +296,7 @@ interface ConveyorEventsSchema {
rotation: [number, number, number]; rotation: [number, number, number];
actions: { uuid: string; name: string; type: string; material: string; delay: number | string; spawnInterval: number | string; isUsed: boolean }[] | []; 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 }[] | []; 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]; position: [number, number, number];
rotation: [number, number, number]; rotation: [number, number, number];
@ -311,7 +311,7 @@ interface VehicleEventsSchema {
uuid: string; uuid: string;
position: [number, number, number]; 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 }; 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; speed: number;
}; };
position: [number, number, number]; position: [number, number, number];
@ -326,7 +326,7 @@ interface StaticMachineEventsSchema {
position: [number, number, number]; position: [number, number, number];
actions: { uuid: string; name: string; buffer: number | string; material: string; isUsed: boolean }; actions: { uuid: string; name: string; buffer: number | string; material: string; isUsed: boolean };
triggers: { uuid: string; name: string; type: string }; 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]; position: [number, number, number];
} }
@ -347,7 +347,7 @@ export type EventData = {
rotation: [number, number, number]; rotation: [number, number, number];
actions: { uuid: string; name: string; type: string; material: string; delay: number | string; spawnInterval: number | string; isUsed: boolean }[] | []; 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 }[] | []; 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; speed: number | string;
} | { } | {
@ -356,7 +356,7 @@ export type EventData = {
uuid: string; uuid: string;
position: [number, number, number]; 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 }; 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; speed: number;
}; };
}; };