Add storage event handling and extend actionType in simulation types
This commit is contained in:
parent
82d3a696d1
commit
75aa0c3d26
|
@ -290,7 +290,27 @@ function processLoadedModel(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
addEvent(roboticArmEvent);
|
addEvent(roboticArmEvent);
|
||||||
|
} else if (item.eventData.type === 'Storage') {
|
||||||
|
const storageEvent: StorageEventSchema = {
|
||||||
|
modelUuid: item.modelUuid,
|
||||||
|
modelName: item.modelName,
|
||||||
|
position: item.position,
|
||||||
|
rotation: [item.rotation.x, item.rotation.y, item.rotation.z], state: "idle",
|
||||||
|
type: "storageUnit",
|
||||||
|
point: {
|
||||||
|
uuid: item.eventData.point?.uuid || THREE.MathUtils.generateUUID(),
|
||||||
|
position: [item.eventData.point?.position[0] || 0, item.eventData.point?.position[1] || 0, item.eventData.point?.position[2] || 0],
|
||||||
|
rotation: [item.eventData.point?.rotation[0] || 0, item.eventData.point?.rotation[1] || 0, item.eventData.point?.rotation[2] || 0],
|
||||||
|
action: {
|
||||||
|
actionUuid: THREE.MathUtils.generateUUID(),
|
||||||
|
actionName: "Action 1",
|
||||||
|
actionType: "store",
|
||||||
|
storageCapacity: 10,
|
||||||
|
triggers: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
addEvent(storageEvent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setFloorItems((prevItems) => [
|
setFloorItems((prevItems) => [
|
||||||
|
|
|
@ -342,6 +342,33 @@ async function handleModelLoad(
|
||||||
position: machineEvent.point.position,
|
position: machineEvent.point.position,
|
||||||
rotation: machineEvent.point.rotation
|
rotation: machineEvent.point.rotation
|
||||||
};
|
};
|
||||||
|
} else if (selectedItem.type === "Storage") {
|
||||||
|
const storageEvent: StorageEventSchema = {
|
||||||
|
modelUuid: newFloorItem.modelUuid,
|
||||||
|
modelName: newFloorItem.modelName,
|
||||||
|
position: newFloorItem.position,
|
||||||
|
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
||||||
|
state: "idle",
|
||||||
|
type: "storageUnit",
|
||||||
|
point: {
|
||||||
|
uuid: THREE.MathUtils.generateUUID(),
|
||||||
|
position: [data.points[0].x, data.points[0].y, data.points[0].z],
|
||||||
|
rotation: [0, 0, 0],
|
||||||
|
action: {
|
||||||
|
actionUuid: THREE.MathUtils.generateUUID(),
|
||||||
|
actionName: "Action 1",
|
||||||
|
actionType: "store",
|
||||||
|
storageCapacity: 10,
|
||||||
|
triggers: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addEvent(storageEvent);
|
||||||
|
eventData.point = {
|
||||||
|
uuid: storageEvent.point.uuid,
|
||||||
|
position: storageEvent.point.position,
|
||||||
|
rotation: storageEvent.point.rotation
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const completeData = {
|
const completeData = {
|
||||||
|
|
|
@ -150,6 +150,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
||||||
};
|
};
|
||||||
|
|
||||||
let updatedEventData = null;
|
let updatedEventData = null;
|
||||||
|
console.log('obj.userData: ', obj.userData);
|
||||||
if (obj.userData.eventData) {
|
if (obj.userData.eventData) {
|
||||||
updatedEventData = JSON.parse(JSON.stringify(obj.userData.eventData));
|
updatedEventData = JSON.parse(JSON.stringify(obj.userData.eventData));
|
||||||
updatedEventData.modelUuid = newFloorItem.modelUuid;
|
updatedEventData.modelUuid = newFloorItem.modelUuid;
|
||||||
|
@ -287,11 +288,9 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.userData.eventData = eventData;
|
|
||||||
|
|
||||||
newFloorItem.eventData = eventData;
|
newFloorItem.eventData = eventData;
|
||||||
|
|
||||||
|
|
||||||
setFloorItems((prevItems: Types.FloorItems) => {
|
setFloorItems((prevItems: Types.FloorItems) => {
|
||||||
const updatedItems = [...(prevItems || []), newFloorItem];
|
const updatedItems = [...(prevItems || []), newFloorItem];
|
||||||
localStorage.setItem("FloorItems", JSON.stringify(updatedItems));
|
localStorage.setItem("FloorItems", JSON.stringify(updatedItems));
|
||||||
|
@ -335,6 +334,7 @@ const CopyPasteControls = ({ itemsGroupRef, copiedObjects, setCopiedObjects, pas
|
||||||
name: newFloorItem.modelName,
|
name: newFloorItem.modelName,
|
||||||
modelId: newFloorItem.modelfileID,
|
modelId: newFloorItem.modelfileID,
|
||||||
modelUuid: newFloorItem.modelUuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
|
eventData: JSON.parse(JSON.stringify(eventData))
|
||||||
};
|
};
|
||||||
|
|
||||||
itemsGroupRef.current.add(obj);
|
itemsGroupRef.current.add(obj);
|
||||||
|
|
|
@ -265,11 +265,8 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.userData.eventData = eventData;
|
|
||||||
|
|
||||||
newFloorItem.eventData = eventData;
|
newFloorItem.eventData = eventData;
|
||||||
|
|
||||||
|
|
||||||
setFloorItems((prevItems: Types.FloorItems) => {
|
setFloorItems((prevItems: Types.FloorItems) => {
|
||||||
const updatedItems = [...(prevItems || []), newFloorItem];
|
const updatedItems = [...(prevItems || []), newFloorItem];
|
||||||
localStorage.setItem("FloorItems", JSON.stringify(updatedItems));
|
localStorage.setItem("FloorItems", JSON.stringify(updatedItems));
|
||||||
|
@ -313,6 +310,7 @@ const DuplicationControls = ({ itemsGroupRef, duplicatedObjects, setDuplicatedOb
|
||||||
name: newFloorItem.modelName,
|
name: newFloorItem.modelName,
|
||||||
modelId: newFloorItem.modelfileID,
|
modelId: newFloorItem.modelfileID,
|
||||||
modelUuid: newFloorItem.modelUuid,
|
modelUuid: newFloorItem.modelUuid,
|
||||||
|
eventData: JSON.parse(JSON.stringify(eventData))
|
||||||
};
|
};
|
||||||
|
|
||||||
itemsGroupRef.current.add(obj);
|
itemsGroupRef.current.add(obj);
|
||||||
|
|
|
@ -124,7 +124,7 @@ interface MachineAction {
|
||||||
interface StorageAction {
|
interface StorageAction {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "store";
|
actionType: "store" | "spawn";
|
||||||
storageCapacity: number;
|
storageCapacity: number;
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue