refactor: Simplify eventData structure in controls and remove console logs from simulation
This commit is contained in:
@@ -245,9 +245,6 @@ function processEventData(item: Types.EventData, setSimulationStates: any) {
|
|||||||
},
|
},
|
||||||
position: item.position
|
position: item.position
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(staticMachine);
|
|
||||||
|
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
|
|||||||
@@ -224,11 +224,11 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
|||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
eventData: backendEventData,
|
eventData: { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed },
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newEventData: any = backendEventData;
|
const newEventData: any = { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed };
|
||||||
newEventData.modeluuid = newFloorItem.modeluuid;
|
newEventData.modeluuid = newFloorItem.modeluuid;
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
@@ -277,7 +277,6 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
|||||||
const backendEventData = {
|
const backendEventData = {
|
||||||
type: 'Vehicle',
|
type: 'Vehicle',
|
||||||
points: createVehiclePoint(),
|
points: createVehiclePoint(),
|
||||||
speed: (eventData as Types.VehicleEventsSchema)?.points.speed
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// API
|
// API
|
||||||
@@ -305,11 +304,11 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
|||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
eventData: backendEventData,
|
eventData: { type: backendEventData.type, points: backendEventData.points },
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newEventData: any = backendEventData;
|
const newEventData: any = { type: backendEventData.type, points: backendEventData.points };
|
||||||
newEventData.modeluuid = newFloorItem.modeluuid;
|
newEventData.modeluuid = newFloorItem.modeluuid;
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|||||||
@@ -206,11 +206,11 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
|||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
eventData: backendEventData,
|
eventData: { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed },
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newEventData: any = backendEventData;
|
const newEventData: any = { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed };
|
||||||
newEventData.modeluuid = newFloorItem.modeluuid;
|
newEventData.modeluuid = newFloorItem.modeluuid;
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
@@ -221,8 +221,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
|||||||
newEventData as Types.ConveyorEventsSchema
|
newEventData as Types.ConveyorEventsSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
console.log('data: ', data);
|
socket.emit("v2:model-asset:add", data);
|
||||||
// socket.emit("v2:model-asset:add", data);
|
|
||||||
|
|
||||||
} else if (eventData.type === 'Vehicle' && eventData) {
|
} else if (eventData.type === 'Vehicle' && eventData) {
|
||||||
const createVehiclePoint = () => {
|
const createVehiclePoint = () => {
|
||||||
@@ -287,11 +286,11 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
|||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
eventData: backendEventData,
|
eventData: { type: backendEventData.type, points: backendEventData.points },
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newEventData: any = backendEventData;
|
const newEventData: any = { type: backendEventData.type, points: backendEventData.points };
|
||||||
newEventData.modeluuid = newFloorItem.modeluuid;
|
newEventData.modeluuid = newFloorItem.modeluuid;
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
// obj.userData.modelId,
|
// obj.userData.modelId,
|
||||||
// false,
|
// false,
|
||||||
// true,
|
// true,
|
||||||
// backendEventData
|
// { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed }
|
||||||
// );
|
// );
|
||||||
|
|
||||||
//SOCKET
|
//SOCKET
|
||||||
@@ -219,11 +219,11 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
eventData: backendEventData,
|
eventData: { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed },
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newEventData: any = backendEventData;
|
const newEventData: any = { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed };
|
||||||
newEventData.modeluuid = newFloorItem.modeluuid;
|
newEventData.modeluuid = newFloorItem.modeluuid;
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
@@ -257,7 +257,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
|
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
|
||||||
// false,
|
// false,
|
||||||
// true,
|
// true,
|
||||||
// backendEventData
|
// { type: backendEventData.type, points: backendEventData.points }
|
||||||
// );
|
// );
|
||||||
|
|
||||||
//SOCKET
|
//SOCKET
|
||||||
@@ -271,11 +271,11 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
eventData: backendEventData,
|
eventData: { type: backendEventData.type, points: backendEventData.points },
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newEventData: any = backendEventData;
|
const newEventData: any = { type: backendEventData.type, points: backendEventData.points };
|
||||||
newEventData.modeluuid = newFloorItem.modeluuid;
|
newEventData.modeluuid = newFloorItem.modeluuid;
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
|
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
|
||||||
// false,
|
// false,
|
||||||
// true,
|
// true,
|
||||||
// backendEventData
|
// { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed }
|
||||||
// );
|
// );
|
||||||
|
|
||||||
//SOCKET
|
//SOCKET
|
||||||
@@ -223,11 +223,11 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
eventData: backendEventData,
|
eventData: { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed },
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newEventData: any = backendEventData;
|
const newEventData: any = { type: backendEventData.type, points: backendEventData.points, speed: backendEventData.speed };
|
||||||
newEventData.modeluuid = newFloorItem.modeluuid;
|
newEventData.modeluuid = newFloorItem.modeluuid;
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
@@ -262,7 +262,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
|
// { "x": obj.rotation.x, "y": obj.rotation.y, "z": obj.rotation.z },
|
||||||
// false,
|
// false,
|
||||||
// true,
|
// true,
|
||||||
// backendEventData
|
// { type: backendEventData.type, points: backendEventData.points }
|
||||||
// );
|
// );
|
||||||
|
|
||||||
//SOCKET
|
//SOCKET
|
||||||
@@ -276,11 +276,11 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
eventData: backendEventData,
|
eventData: { type: backendEventData.type, points: backendEventData.points },
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newEventData: any = backendEventData;
|
const newEventData: any = { type: backendEventData.type, points: backendEventData.points };
|
||||||
newEventData.modeluuid = newFloorItem.modeluuid;
|
newEventData.modeluuid = newFloorItem.modeluuid;
|
||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
@@ -298,7 +298,6 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('hii');
|
|
||||||
|
|
||||||
//REST
|
//REST
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function Simulation() {
|
|||||||
const [processes, setProcesses] = useState([]);
|
const [processes, setProcesses] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('simulationStates: ', simulationStates);
|
// console.log('simulationStates: ', simulationStates);
|
||||||
}, [simulationStates]);
|
}, [simulationStates]);
|
||||||
|
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user