simulation #47
@@ -219,7 +219,7 @@ async function handleModelLoad(
|
|||||||
eventData.position = newFloorItem.position;
|
eventData.position = newFloorItem.position;
|
||||||
eventData.rotation = [model.rotation.x, model.rotation.y, model.rotation.z];
|
eventData.rotation = [model.rotation.x, model.rotation.y, model.rotation.z];
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
eventData as Types.ConveyorEventsSchema
|
eventData as Types.ConveyorEventsSchema
|
||||||
]);
|
]);
|
||||||
@@ -235,7 +235,7 @@ async function handleModelLoad(
|
|||||||
points: {
|
points: {
|
||||||
uuid: pointUUID,
|
uuid: pointUUID,
|
||||||
position: res.points.position as [number, number, number],
|
position: res.points.position as [number, number, number],
|
||||||
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: {}, hitCount: 1, end: {}, buffer: 0 },
|
||||||
connections: { source: { modelUUID: model.uuid, pointUUID: pointUUID }, targets: [] },
|
connections: { source: { modelUUID: model.uuid, pointUUID: pointUUID }, targets: [] },
|
||||||
speed: 2,
|
speed: 2,
|
||||||
}
|
}
|
||||||
@@ -281,13 +281,50 @@ async function handleModelLoad(
|
|||||||
return updatedItems;
|
return updatedItems;
|
||||||
});
|
});
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
eventData as Types.VehicleEventsSchema
|
eventData as Types.VehicleEventsSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
socket.emit("v2:model-asset:add", data);
|
socket.emit("v2:model-asset:add", data);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// API
|
||||||
|
|
||||||
|
// await setFloorItemApi(
|
||||||
|
// organization,
|
||||||
|
// newFloorItem.modeluuid,
|
||||||
|
// newFloorItem.modelname,
|
||||||
|
// newFloorItem.modelfileID,
|
||||||
|
// newFloorItem.position,
|
||||||
|
// { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
|
||||||
|
// false,
|
||||||
|
// true,
|
||||||
|
// );
|
||||||
|
|
||||||
|
// SOCKET
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
organization,
|
||||||
|
modeluuid: newFloorItem.modeluuid,
|
||||||
|
modelname: newFloorItem.modelname,
|
||||||
|
modelfileID: newFloorItem.modelfileID,
|
||||||
|
position: newFloorItem.position,
|
||||||
|
rotation: { x: model.rotation.x, y: model.rotation.y, z: model.rotation.z },
|
||||||
|
isLocked: false,
|
||||||
|
isVisible: true,
|
||||||
|
socketId: socket.id
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
setFloorItems((prevItems) => {
|
||||||
|
const updatedItems = [...(prevItems || []), newFloorItem];
|
||||||
|
localStorage.setItem("FloorItems", JSON.stringify(updatedItems));
|
||||||
|
return updatedItems;
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.emit("v2:model-asset:add", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
gsap.to(model.position, { y: newFloorItem.position[1], duration: 1.5, ease: "power2.out" });
|
gsap.to(model.position, { y: newFloorItem.position[1], duration: 1.5, ease: "power2.out" });
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ async function DeleteFloorItems(
|
|||||||
}
|
}
|
||||||
setFloorItems(updatedItems);
|
setFloorItems(updatedItems);
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).filter(event => event.modeluuid !== removedItem.modeluuid);
|
const updatedEvents = (prevEvents || []).filter(event => event.modeluuid !== removedItem.modeluuid);
|
||||||
return updatedEvents;
|
return updatedEvents;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { getFloorAssets } from '../../../services/factoryBuilder/assest/floorAss
|
|||||||
async function loadInitialFloorItems(
|
async function loadInitialFloorItems(
|
||||||
itemsGroup: Types.RefGroup,
|
itemsGroup: Types.RefGroup,
|
||||||
setFloorItems: Types.setFloorItemSetState,
|
setFloorItems: Types.setFloorItemSetState,
|
||||||
setSimulationStates: (paths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => void
|
setSimulationStates: (paths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => void
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!itemsGroup.current) return;
|
if (!itemsGroup.current) return;
|
||||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
|
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_MARKETPLACE_URL}`;
|
||||||
@@ -137,7 +137,7 @@ async function loadInitialFloorItems(
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (item.eventData) {
|
if (item.eventData || item.modelfileID === '67e3db95c2e8f37134526fb2') {
|
||||||
processEventData(item, setSimulationStates);
|
processEventData(item, setSimulationStates);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ function processLoadedModel(
|
|||||||
item: Types.EventData,
|
item: Types.EventData,
|
||||||
itemsGroup: Types.RefGroup,
|
itemsGroup: Types.RefGroup,
|
||||||
setFloorItems: Types.setFloorItemSetState,
|
setFloorItems: Types.setFloorItemSetState,
|
||||||
setSimulationStates: (paths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => void
|
setSimulationStates: (paths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => void
|
||||||
) {
|
) {
|
||||||
const model = gltf;
|
const model = gltf;
|
||||||
model.uuid = item.modeluuid;
|
model.uuid = item.modeluuid;
|
||||||
@@ -192,7 +192,7 @@ function processLoadedModel(
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (item.eventData) {
|
if (item.eventData || item.modelfileID === '67e3db95c2e8f37134526fb2') {
|
||||||
processEventData(item, setSimulationStates);
|
processEventData(item, setSimulationStates);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ function processEventData(item: Types.EventData, setSimulationStates: any) {
|
|||||||
data.position = item.position;
|
data.position = item.position;
|
||||||
data.rotation = [item.rotation.x, item.rotation.y, item.rotation.z];
|
data.rotation = [item.rotation.x, item.rotation.y, item.rotation.z];
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
data as Types.ConveyorEventsSchema
|
data as Types.ConveyorEventsSchema
|
||||||
]);
|
]);
|
||||||
@@ -222,11 +222,37 @@ function processEventData(item: Types.EventData, setSimulationStates: any) {
|
|||||||
data.modelName = item.modelname;
|
data.modelName = item.modelname;
|
||||||
data.position = item.position;
|
data.position = item.position;
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
data as Types.VehicleEventsSchema
|
data as Types.VehicleEventsSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
} else if (item.modelfileID === '67e3db95c2e8f37134526fb2') {
|
||||||
|
|
||||||
|
const pointUUID = THREE.MathUtils.generateUUID();
|
||||||
|
const pointPosition = new THREE.Vector3(0, 1.75, 0);
|
||||||
|
|
||||||
|
const staticMachine: Types.StaticMachineEventsSchema = {
|
||||||
|
modeluuid: item.modeluuid,
|
||||||
|
modelName: item.modelname,
|
||||||
|
type: "StaticMachine",
|
||||||
|
points: {
|
||||||
|
uuid: pointUUID,
|
||||||
|
position: [pointPosition.x, pointPosition.y, pointPosition.z],
|
||||||
|
actions: { uuid: THREE.MathUtils.generateUUID(), name: 'Action 1', buffer: 'Inherit', material: 'Inherit', isUsed: false },
|
||||||
|
triggers: { uuid: THREE.MathUtils.generateUUID(), name: 'Trigger 1', type: 'OnComplete' },
|
||||||
|
connections: { source: { modelUUID: item.modeluuid, pointUUID: pointUUID }, targets: [] },
|
||||||
|
},
|
||||||
|
position: item.position
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(staticMachine);
|
||||||
|
|
||||||
|
|
||||||
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
||||||
|
...(prevEvents || []),
|
||||||
|
staticMachine as Types.StaticMachineEventsSchema
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
|||||||
return updatedItems;
|
return updatedItems;
|
||||||
});
|
});
|
||||||
|
|
||||||
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
||||||
|
|
||||||
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";
|
||||||
@@ -234,7 +234,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
|||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
newEventData as Types.ConveyorEventsSchema
|
newEventData as Types.ConveyorEventsSchema
|
||||||
]);
|
]);
|
||||||
@@ -314,7 +314,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
|||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
newEventData as Types.VehicleEventsSchema
|
newEventData as Types.VehicleEventsSchema
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
|||||||
return updatedItems;
|
return updatedItems;
|
||||||
});
|
});
|
||||||
|
|
||||||
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
||||||
|
|
||||||
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";
|
||||||
@@ -216,7 +216,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
|||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
newEventData as Types.ConveyorEventsSchema
|
newEventData as Types.ConveyorEventsSchema
|
||||||
]);
|
]);
|
||||||
@@ -295,7 +295,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
|||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => [
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => [
|
||||||
...(prevEvents || []),
|
...(prevEvents || []),
|
||||||
newEventData as Types.VehicleEventsSchema
|
newEventData as Types.VehicleEventsSchema
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
return updatedItems;
|
return updatedItems;
|
||||||
});
|
});
|
||||||
|
|
||||||
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
||||||
|
|
||||||
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";
|
||||||
@@ -229,7 +229,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).map(event =>
|
const updatedEvents = (prevEvents || []).map(event =>
|
||||||
event.modeluuid === newFloorItem.modeluuid
|
event.modeluuid === newFloorItem.modeluuid
|
||||||
? { ...event, ...newEventData }
|
? { ...event, ...newEventData }
|
||||||
@@ -280,7 +280,7 @@ function MoveControls({ movedObjects, setMovedObjects, itemsGroupRef, copiedObje
|
|||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).map(event =>
|
const updatedEvents = (prevEvents || []).map(event =>
|
||||||
event.modeluuid === newFloorItem.modeluuid
|
event.modeluuid === newFloorItem.modeluuid
|
||||||
? { ...event, ...newEventData }
|
? { ...event, ...newEventData }
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
return updatedItems;
|
return updatedItems;
|
||||||
});
|
});
|
||||||
|
|
||||||
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
let eventData: Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema | undefined = simulationStates.find((events) => events.modeluuid === obj.userData.modeluuid);
|
||||||
|
|
||||||
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";
|
||||||
@@ -233,7 +233,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
newEventData.rotation = [obj.rotation.x, obj.rotation.y, obj.rotation.z];
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).map(event =>
|
const updatedEvents = (prevEvents || []).map(event =>
|
||||||
event.modeluuid === newFloorItem.modeluuid
|
event.modeluuid === newFloorItem.modeluuid
|
||||||
? { ...event, ...newEventData }
|
? { ...event, ...newEventData }
|
||||||
@@ -285,7 +285,7 @@ function RotateControls({ rotatedObjects, setRotatedObjects, movedObjects, setMo
|
|||||||
newEventData.modelName = newFloorItem.modelname;
|
newEventData.modelName = newFloorItem.modelname;
|
||||||
newEventData.position = newFloorItem.position;
|
newEventData.position = newFloorItem.position;
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).map(event =>
|
const updatedEvents = (prevEvents || []).map(event =>
|
||||||
event.modeluuid === newFloorItem.modeluuid
|
event.modeluuid === newFloorItem.modeluuid
|
||||||
? { ...event, ...newEventData }
|
? { ...event, ...newEventData }
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ const SelectionControls: React.FC = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
setSimulationStates((prevEvents: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => {
|
||||||
const updatedEvents = (prevEvents || []).filter(event => event.modeluuid !== selectedMesh.uuid);
|
const updatedEvents = (prevEvents || []).filter(event => event.modeluuid !== selectedMesh.uuid);
|
||||||
return updatedEvents;
|
return updatedEvents;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ function Behaviour() {
|
|||||||
const { floorItems } = useFloorItems();
|
const { floorItems } = useFloorItems();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const newPaths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[] = [];
|
const newPaths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[] = [];
|
||||||
|
|
||||||
// floorItems.forEach((item: Types.FloorItemType) => {
|
// floorItems.forEach((item: Types.FloorItemType) => {
|
||||||
// if (item.modelfileID === "672a090f80d91ac979f4d0bd") {
|
// if (item.modelfileID === "672a090f80d91ac979f4d0bd") {
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ function PathConnector({ pathsGroupRef }: { pathsGroupRef: React.MutableRefObjec
|
|||||||
updateBackend(updatedPathDetails);
|
updateBackend(updatedPathDetails);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateBackend = async (updatedPaths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]) => {
|
const updateBackend = async (updatedPaths: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]) => {
|
||||||
if (updatedPaths.length === 0) return;
|
if (updatedPaths.length === 0) return;
|
||||||
const email = localStorage.getItem("email");
|
const email = localStorage.getItem("email");
|
||||||
const organization = email ? email.split("@")[1].split(".")[0] : "";
|
const organization = email ? email.split("@")[1].split(".")[0] : "";
|
||||||
|
|||||||
@@ -17,11 +17,7 @@ import { useSubModuleStore } from "../../../store/useModuleStore";
|
|||||||
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
import { usePlayButtonStore } from "../../../store/usePlayButtonStore";
|
||||||
import { setEventApi } from "../../../services/factoryBuilder/assest/floorAsset/setEventsApt";
|
import { setEventApi } from "../../../services/factoryBuilder/assest/floorAsset/setEventsApt";
|
||||||
|
|
||||||
function PathCreation({
|
function PathCreation({ pathsGroupRef, }: { pathsGroupRef: React.MutableRefObject<THREE.Group>; }) {
|
||||||
pathsGroupRef,
|
|
||||||
}: {
|
|
||||||
pathsGroupRef: React.MutableRefObject<THREE.Group>;
|
|
||||||
}) {
|
|
||||||
const { isPlaying } = usePlayButtonStore();
|
const { isPlaying } = usePlayButtonStore();
|
||||||
const { renderDistance } = useRenderDistance();
|
const { renderDistance } = useRenderDistance();
|
||||||
const { setSubModule } = useSubModuleStore();
|
const { setSubModule } = useSubModuleStore();
|
||||||
@@ -30,10 +26,10 @@ function PathCreation({
|
|||||||
const { editingPoint, setEditingPoint } = useEditingPoint();
|
const { editingPoint, setEditingPoint } = useEditingPoint();
|
||||||
const { previewPosition, setPreviewPosition } = usePreviewPosition();
|
const { previewPosition, setPreviewPosition } = usePreviewPosition();
|
||||||
const { raycaster, camera, pointer, gl } = useThree();
|
const { raycaster, camera, pointer, gl } = useThree();
|
||||||
const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
|
|
||||||
const { setSelectedPath } = useSelectedPath();
|
const { setSelectedPath } = useSelectedPath();
|
||||||
const { simulationStates, setSimulationStates } = useSimulationStates();
|
const { simulationStates, setSimulationStates } = useSimulationStates();
|
||||||
const { isConnecting } = useIsConnecting();
|
const { isConnecting } = useIsConnecting();
|
||||||
|
const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
|
||||||
|
|
||||||
const groupRefs = useRef<{ [key: string]: THREE.Group }>({});
|
const groupRefs = useRef<{ [key: string]: THREE.Group }>({});
|
||||||
const sphereRefs = useRef<{ [key: string]: THREE.Mesh }>({});
|
const sphereRefs = useRef<{ [key: string]: THREE.Mesh }>({});
|
||||||
@@ -99,11 +95,7 @@ function PathCreation({
|
|||||||
}) as Types.ConveyorEventsSchema[];
|
}) as Types.ConveyorEventsSchema[];
|
||||||
|
|
||||||
const updatedPath = updatedPaths.find(
|
const updatedPath = updatedPaths.find(
|
||||||
(path) =>
|
(path) => path.type === "Conveyor" && path.points.some((point) => point.uuid === selectedActionSphere.points.uuid)
|
||||||
path.type === "Conveyor" &&
|
|
||||||
path.points.some(
|
|
||||||
(point) => point.uuid === selectedActionSphere.points.uuid
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// console.log("Updated Path:", updatedPath);
|
// console.log("Updated Path:", updatedPath);
|
||||||
@@ -178,29 +170,18 @@ function PathCreation({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlePointUpdate = (
|
const handlePointUpdate = (pointType: "start" | "end", x: number, z: number) => {
|
||||||
pointType: "start" | "end",
|
|
||||||
x: number,
|
|
||||||
z: number
|
|
||||||
) => {
|
|
||||||
if (!selectedActionSphere?.points?.uuid) return;
|
if (!selectedActionSphere?.points?.uuid) return;
|
||||||
const updatedPaths = simulationStates.map((path) => {
|
const updatedPaths = simulationStates.map((path) => {
|
||||||
|
|
||||||
if (
|
if (path.type === "Vehicle" && path.points.uuid === selectedActionSphere.points.uuid) {
|
||||||
path.type === "Vehicle" &&
|
|
||||||
path.points.uuid === selectedActionSphere.points.uuid
|
|
||||||
) {
|
|
||||||
return {
|
return {
|
||||||
...path,
|
...path,
|
||||||
points: {
|
points: {
|
||||||
...path.points,
|
...path.points,
|
||||||
actions: {
|
actions: {
|
||||||
...path.points.actions,
|
...path.points.actions,
|
||||||
[pointType]: {
|
[pointType]: { ...path.points.actions[pointType], x: x, y: z, },
|
||||||
...path.points.actions[pointType],
|
|
||||||
x: x,
|
|
||||||
y: z,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -208,11 +189,7 @@ function PathCreation({
|
|||||||
return path;
|
return path;
|
||||||
});
|
});
|
||||||
|
|
||||||
const updatedPath = updatedPaths.find(
|
const updatedPath = updatedPaths.find((path): path is Types.VehicleEventsSchema => path.type === "Vehicle" && path.points.uuid === selectedActionSphere.points.uuid);
|
||||||
(path): path is Types.VehicleEventsSchema =>
|
|
||||||
path.type === "Vehicle" &&
|
|
||||||
path.points.uuid === selectedActionSphere.points.uuid
|
|
||||||
);
|
|
||||||
updateBackend(updatedPath);
|
updateBackend(updatedPath);
|
||||||
|
|
||||||
setSimulationStates(updatedPaths);
|
setSimulationStates(updatedPaths);
|
||||||
@@ -228,7 +205,7 @@ function PathCreation({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<group
|
<group
|
||||||
name={`${path.modeluuid}-event-path`}
|
name={`${path.modeluuid}-${path.type}-path`}
|
||||||
key={path.modeluuid}
|
key={path.modeluuid}
|
||||||
ref={(el) => (groupRefs.current[path.modeluuid] = el!)}
|
ref={(el) => (groupRefs.current[path.modeluuid] = el!)}
|
||||||
position={path.position}
|
position={path.position}
|
||||||
@@ -276,51 +253,28 @@ function PathCreation({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<meshStandardMaterial
|
<meshStandardMaterial
|
||||||
color={
|
color={index === 0 ? "orange" : index === path.points.length - 1 ? "blue" : "green"}
|
||||||
index === 0
|
|
||||||
? "orange"
|
|
||||||
: index === path.points.length - 1
|
|
||||||
? "blue"
|
|
||||||
: "green"
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Sphere>
|
</Sphere>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{points.slice(0, -1).map((point, index) => {
|
{points.slice(0, -1).map((point, index) => {
|
||||||
const nextPoint = points[index + 1];
|
const nextPoint = points[index + 1];
|
||||||
const segmentCurve = new THREE.CatmullRomCurve3([
|
const segmentCurve = new THREE.CatmullRomCurve3([point, nextPoint,]);
|
||||||
point,
|
const tubeGeometry = new THREE.TubeGeometry(segmentCurve, 20, 0.1, 16, false);
|
||||||
nextPoint,
|
|
||||||
]);
|
|
||||||
const tubeGeometry = new THREE.TubeGeometry(
|
|
||||||
segmentCurve,
|
|
||||||
20,
|
|
||||||
0.1,
|
|
||||||
16,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<mesh
|
<mesh name="event-connection-tube" key={`tube-${index}`} geometry={tubeGeometry}>
|
||||||
name="event-connection-tube"
|
<meshStandardMaterial transparent opacity={0.9} color="red" />
|
||||||
key={`tube-${index}`}
|
|
||||||
geometry={tubeGeometry}
|
|
||||||
>
|
|
||||||
<meshStandardMaterial
|
|
||||||
transparent
|
|
||||||
opacity={0.9}
|
|
||||||
color="red"
|
|
||||||
/>
|
|
||||||
</mesh>
|
</mesh>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</group>
|
</group>
|
||||||
);
|
);
|
||||||
} else if (path.type === "Vehicle") {
|
} else if (path.type === "Vehicle" || path.type === "StaticMachine") {
|
||||||
return (
|
return (
|
||||||
<group
|
<group
|
||||||
name={`${path.modeluuid}-vehicle-path`}
|
name={`${path.modeluuid}-${path.type}-path`}
|
||||||
key={path.modeluuid}
|
key={path.modeluuid}
|
||||||
ref={(el) => (groupRefs.current[path.modeluuid] = el!)}
|
ref={(el) => (groupRefs.current[path.modeluuid] = el!)}
|
||||||
position={path.position}
|
position={path.position}
|
||||||
|
|||||||
@@ -433,6 +433,7 @@ export interface PathPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface SimulationPath {
|
export interface SimulationPath {
|
||||||
|
type: string;
|
||||||
modeluuid: string;
|
modeluuid: string;
|
||||||
points: PathPoint[];
|
points: PathPoint[];
|
||||||
pathPosition: [number, number, number];
|
pathPosition: [number, number, number];
|
||||||
@@ -464,6 +465,7 @@ function convertToSimulationPath(
|
|||||||
|
|
||||||
if (path.type === "Conveyor") {
|
if (path.type === "Conveyor") {
|
||||||
return {
|
return {
|
||||||
|
type: path.type,
|
||||||
modeluuid,
|
modeluuid,
|
||||||
points: path.points.map((point) => ({
|
points: path.points.map((point) => ({
|
||||||
uuid: point.uuid,
|
uuid: point.uuid,
|
||||||
@@ -483,6 +485,7 @@ function convertToSimulationPath(
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
|
type: path.type,
|
||||||
modeluuid,
|
modeluuid,
|
||||||
points: [
|
points: [
|
||||||
{
|
{
|
||||||
@@ -614,6 +617,7 @@ export function useProcessCreation() {
|
|||||||
const [processes, setProcesses] = useState<Process[]>([]);
|
const [processes, setProcesses] = useState<Process[]>([]);
|
||||||
|
|
||||||
const hasSpawnAction = useCallback((path: SimulationPath): boolean => {
|
const hasSpawnAction = useCallback((path: SimulationPath): boolean => {
|
||||||
|
if (path.type !== "Conveyor") return false;
|
||||||
return path.points.some((point) =>
|
return path.points.some((point) =>
|
||||||
point.actions.some((action) => action.type.toLowerCase() === "spawn")
|
point.actions.some((action) => action.type.toLowerCase() === "spawn")
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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(() => {
|
||||||
|
|||||||
@@ -341,12 +341,12 @@ export const useSelectedPath = create<any>((set: any) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
interface SimulationPathsStore {
|
interface SimulationPathsStore {
|
||||||
simulationStates: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[];
|
simulationStates: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[];
|
||||||
setSimulationStates: (
|
setSimulationStates: (
|
||||||
paths:
|
paths:
|
||||||
| (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]
|
| (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]
|
||||||
| ((prev: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[]
|
| ((prev: (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[]
|
||||||
) => (Types.ConveyorEventsSchema | Types.VehicleEventsSchema)[])
|
) => (Types.ConveyorEventsSchema | Types.VehicleEventsSchema | Types.StaticMachineEventsSchema)[])
|
||||||
) => void;
|
) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
app/src/types/world/worldTypes.d.ts
vendored
14
app/src/types/world/worldTypes.d.ts
vendored
@@ -317,6 +317,20 @@ interface VehicleEventsSchema {
|
|||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface StaticMachineEventsSchema {
|
||||||
|
modeluuid: string;
|
||||||
|
modelName: string;
|
||||||
|
type: 'StaticMachine';
|
||||||
|
points: {
|
||||||
|
uuid: string;
|
||||||
|
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 }[] };
|
||||||
|
};
|
||||||
|
position: [number, number, number];
|
||||||
|
}
|
||||||
|
|
||||||
export type EventData = {
|
export type EventData = {
|
||||||
modeluuid: string;
|
modeluuid: string;
|
||||||
modelname: string;
|
modelname: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user