schema change
This commit is contained in:
85
app/package-lock.json
generated
85
app/package-lock.json
generated
@@ -38,6 +38,7 @@
|
|||||||
"mqtt": "^5.10.4",
|
"mqtt": "^5.10.4",
|
||||||
"postprocessing": "^6.36.4",
|
"postprocessing": "^6.36.4",
|
||||||
"prompt-sync": "^4.2.0",
|
"prompt-sync": "^4.2.0",
|
||||||
|
"r3f-perf": "^7.2.3",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-chartjs-2": "^5.3.0",
|
"react-chartjs-2": "^5.3.0",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
@@ -3371,6 +3372,15 @@
|
|||||||
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-icons": {
|
||||||
|
"version": "1.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-icons/-/react-icons-1.3.2.tgz",
|
||||||
|
"integrity": "sha512-fyQIhGDhzfc9pK2kH6Pl9c4BDJGfMkPqkyIgYDthyNYoNg3wVhoJMMh19WS4Up/1KMPFVpNsT2q3WmXn2N1m6g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16.x || ^17.x || ^18.x || ^19.0.0 || ^19.0.0-rc"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/react-id": {
|
"node_modules/@radix-ui/react-id": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.0.0.tgz",
|
||||||
@@ -7073,6 +7083,23 @@
|
|||||||
"react": ">= 16.8.0"
|
"react": ">= 16.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@utsubo/events": {
|
||||||
|
"version": "0.1.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@utsubo/events/-/events-0.1.7.tgz",
|
||||||
|
"integrity": "sha512-WB/GEj/0h27Bz8rJ0+CBtNz5mLT79ne1OjB7PUM4n0qLBqEDwm6yBzZC3j6tasHjlBPJDYZiBVIA1glaMlgZ5g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"eventemitter3": "^4.0.7"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.8.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"react": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@webassemblyjs/ast": {
|
"node_modules/@webassemblyjs/ast": {
|
||||||
"version": "1.14.1",
|
"version": "1.14.1",
|
||||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz",
|
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz",
|
||||||
@@ -17894,6 +17921,64 @@
|
|||||||
"integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==",
|
"integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/r3f-perf": {
|
||||||
|
"version": "7.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/r3f-perf/-/r3f-perf-7.2.3.tgz",
|
||||||
|
"integrity": "sha512-4+P/N/bnO9D8nzdm3suL/NjPZK/HHdjwpvajhi8j7eB41i2ECN6lX9RXiKSpHzpsDi2ui1tBj6q7/sz5opoqXw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@radix-ui/react-icons": "^1.3.0",
|
||||||
|
"@react-three/drei": "^9.103.0",
|
||||||
|
"@stitches/react": "^1.2.8",
|
||||||
|
"@utsubo/events": "^0.1.7",
|
||||||
|
"zustand": "~4.5.2"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@react-three/fiber": ">=8.0",
|
||||||
|
"react": ">=18.0",
|
||||||
|
"react-dom": ">=18.0",
|
||||||
|
"three": ">=0.133"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@react-three/fiber": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"dom": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"react-dom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/r3f-perf/node_modules/zustand": {
|
||||||
|
"version": "4.5.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/zustand/-/zustand-4.5.7.tgz",
|
||||||
|
"integrity": "sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"use-sync-external-store": "^1.2.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.7.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": ">=16.8",
|
||||||
|
"immer": ">=9.0.6",
|
||||||
|
"react": ">=16.8"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"immer": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"react": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/raf": {
|
"node_modules/raf": {
|
||||||
"version": "3.4.1",
|
"version": "3.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"mqtt": "^5.10.4",
|
"mqtt": "^5.10.4",
|
||||||
"postprocessing": "^6.36.4",
|
"postprocessing": "^6.36.4",
|
||||||
"prompt-sync": "^4.2.0",
|
"prompt-sync": "^4.2.0",
|
||||||
|
"r3f-perf": "^7.2.3",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-chartjs-2": "^5.3.0",
|
"react-chartjs-2": "^5.3.0",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
|
|||||||
@@ -3,53 +3,51 @@ import InputWithDropDown from "../../../../../ui/inputs/InputWithDropDown";
|
|||||||
import LabledDropdown from "../../../../../ui/inputs/LabledDropdown";
|
import LabledDropdown from "../../../../../ui/inputs/LabledDropdown";
|
||||||
|
|
||||||
interface StorageActionProps {
|
interface StorageActionProps {
|
||||||
type: "store" | "spawn" | "default";
|
maxCapacity: string;
|
||||||
value: string;
|
spawnedCount: string;
|
||||||
min: number;
|
min: number;
|
||||||
max?: number;
|
max?: number;
|
||||||
defaultValue: string;
|
maxCapacityDefault: string;
|
||||||
|
spawnedCountCefault: string;
|
||||||
currentMaterialType: string;
|
currentMaterialType: string;
|
||||||
handleCapacityChange: (value: string) => void;
|
handleCapacityChange: (value: string) => void;
|
||||||
|
handleSpawnCountChange: (value: string) => void;
|
||||||
handleMaterialTypeChange: (value: string) => void;
|
handleMaterialTypeChange: (value: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StorageAction: React.FC<StorageActionProps> = ({ type, value, min, max, defaultValue, currentMaterialType, handleCapacityChange, handleMaterialTypeChange }) => {
|
const StorageAction: React.FC<StorageActionProps> = ({ maxCapacity, spawnedCount, min, max, maxCapacityDefault, spawnedCountCefault, currentMaterialType, handleCapacityChange, handleSpawnCountChange, handleMaterialTypeChange }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{type === 'store' &&
|
<InputWithDropDown
|
||||||
<InputWithDropDown
|
key={'Storage Capacity'}
|
||||||
label="Storage Capacity"
|
label="Storage Capacity"
|
||||||
value={value}
|
value={maxCapacity}
|
||||||
min={min}
|
min={min}
|
||||||
step={1}
|
step={1}
|
||||||
max={max}
|
max={max}
|
||||||
defaultValue={defaultValue}
|
defaultValue={maxCapacityDefault}
|
||||||
activeOption="unit"
|
activeOption="unit"
|
||||||
onClick={() => { }}
|
onClick={() => { }}
|
||||||
onChange={handleCapacityChange}
|
onChange={handleCapacityChange}
|
||||||
/>
|
/>
|
||||||
}
|
<InputWithDropDown
|
||||||
{type === 'spawn' &&
|
key={"Spawn Count"}
|
||||||
<>
|
label="Spawn Count"
|
||||||
<InputWithDropDown
|
value={spawnedCount}
|
||||||
label="Spawn Capacity"
|
min={min}
|
||||||
value={value}
|
step={1}
|
||||||
min={min}
|
max={max}
|
||||||
step={1}
|
defaultValue={spawnedCountCefault}
|
||||||
max={max}
|
activeOption="unit"
|
||||||
defaultValue={defaultValue}
|
onClick={() => { }}
|
||||||
activeOption="unit"
|
onChange={handleSpawnCountChange}
|
||||||
onClick={() => { }}
|
/>
|
||||||
onChange={handleCapacityChange}
|
<LabledDropdown
|
||||||
/>
|
label={"Material Type"}
|
||||||
<LabledDropdown
|
defaultOption={currentMaterialType}
|
||||||
label={"Material Type"}
|
options={["Default material", "Material 1", "Material 2", "Material 3"]}
|
||||||
defaultOption={currentMaterialType}
|
onSelect={handleMaterialTypeChange}
|
||||||
options={["Default material", "Material 1", "Material 2", "Material 3"]}
|
/>
|
||||||
onSelect={handleMaterialTypeChange}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,10 +14,13 @@ import { useSceneContext } from "../../../../../../modules/scene/sceneContext";
|
|||||||
|
|
||||||
function StorageMechanics() {
|
function StorageMechanics() {
|
||||||
const [activeOption, setActiveOption] = useState<"default" | "store" | "spawn">("default");
|
const [activeOption, setActiveOption] = useState<"default" | "store" | "spawn">("default");
|
||||||
|
const [currentCapacity, setCurrentCapacity] = useState("1");
|
||||||
|
const [spawnedCount, setSpawnedCount] = useState("0");
|
||||||
|
const [spawnedMaterial, setSpawnedMaterial] = useState("Default material");
|
||||||
const [selectedPointData, setSelectedPointData] = useState<StoragePointSchema | undefined>();
|
const [selectedPointData, setSelectedPointData] = useState<StoragePointSchema | undefined>();
|
||||||
const { selectedEventData } = useSelectedEventData();
|
const { selectedEventData } = useSelectedEventData();
|
||||||
const { productStore } = useSceneContext();
|
const { productStore } = useSceneContext();
|
||||||
const { getPointByUuid, updateAction } = productStore();
|
const { getPointByUuid, updateAction, updateEvent, getEventByModelUuid } = productStore();
|
||||||
const { selectedProductStore } = useProductContext();
|
const { selectedProductStore } = useProductContext();
|
||||||
const { selectedProduct } = selectedProductStore();
|
const { selectedProduct } = selectedProductStore();
|
||||||
const { setSelectedAction, clearSelectedAction } = useSelectedAction();
|
const { setSelectedAction, clearSelectedAction } = useSelectedAction();
|
||||||
@@ -52,6 +55,24 @@ function StorageMechanics() {
|
|||||||
setSelectedPointData(point);
|
setSelectedPointData(point);
|
||||||
const uiOption = point.action.actionType === "retrieve" ? "spawn" : point.action.actionType;
|
const uiOption = point.action.actionType === "retrieve" ? "spawn" : point.action.actionType;
|
||||||
setActiveOption(uiOption as "store" | "spawn");
|
setActiveOption(uiOption as "store" | "spawn");
|
||||||
|
setCurrentCapacity(
|
||||||
|
(getEventByModelUuid(
|
||||||
|
selectedProduct.productUuid,
|
||||||
|
selectedEventData.data.modelUuid
|
||||||
|
) as StorageEventSchema | undefined)?.storageCapacity?.toString() || "1"
|
||||||
|
);
|
||||||
|
setSpawnedCount(
|
||||||
|
(getEventByModelUuid(
|
||||||
|
selectedProduct.productUuid,
|
||||||
|
selectedEventData.data.modelUuid
|
||||||
|
) as StorageEventSchema | undefined)?.storageCount?.toString() || "0"
|
||||||
|
)
|
||||||
|
setSpawnedMaterial(
|
||||||
|
(getEventByModelUuid(
|
||||||
|
selectedProduct.productUuid,
|
||||||
|
selectedEventData.data.modelUuid
|
||||||
|
) as StorageEventSchema | undefined)?.materialType?.toString() || "Default material"
|
||||||
|
)
|
||||||
setSelectedAction(point.action.actionUuid, point.action.actionName);
|
setSelectedAction(point.action.actionUuid, point.action.actionName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -95,29 +116,55 @@ function StorageMechanics() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRenameAction = (newName: string) => {
|
|
||||||
if (!selectedPointData) return;
|
|
||||||
const event = updateAction(selectedProduct.productUuid, selectedPointData.action.actionUuid, { actionName: newName });
|
|
||||||
|
|
||||||
if (event) {
|
|
||||||
updateBackend(
|
|
||||||
selectedProduct.productName,
|
|
||||||
selectedProduct.productUuid,
|
|
||||||
projectId || '',
|
|
||||||
event
|
|
||||||
);
|
|
||||||
updateSelectedPointData();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCapacityChange = (value: string) => {
|
const handleCapacityChange = (value: string) => {
|
||||||
if (!selectedEventData || !selectedPointData) return;
|
if (!selectedEventData || !selectedPointData) return;
|
||||||
const newCapacity = parseInt(value);
|
|
||||||
|
|
||||||
const event = updateAction(selectedProduct.productUuid, selectedPointData.action.actionUuid, {
|
const newCapacity = parseInt(value);
|
||||||
storageCapacity: newCapacity,
|
let updatedEvent: EventsSchema | undefined;
|
||||||
|
|
||||||
|
updatedEvent = updateEvent(
|
||||||
|
selectedProduct.productUuid,
|
||||||
|
selectedEventData.data.modelUuid,
|
||||||
|
{ storageCapacity: newCapacity }
|
||||||
|
);
|
||||||
|
|
||||||
|
const currentCount = parseInt(spawnedCount);
|
||||||
|
if (currentCount > newCapacity) {
|
||||||
|
updatedEvent = updateEvent(
|
||||||
|
selectedProduct.productUuid,
|
||||||
|
selectedEventData.data.modelUuid,
|
||||||
|
{ storageCount: newCapacity }
|
||||||
|
);
|
||||||
|
setSpawnedCount(newCapacity.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentCapacity(value);
|
||||||
|
|
||||||
|
if (updatedEvent) {
|
||||||
|
updateBackend(
|
||||||
|
selectedProduct.productName,
|
||||||
|
selectedProduct.productUuid,
|
||||||
|
projectId || '',
|
||||||
|
updatedEvent
|
||||||
|
);
|
||||||
|
updateSelectedPointData();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSpawnCountChange = (value: string) => {
|
||||||
|
if (!selectedEventData || !selectedPointData) return;
|
||||||
|
|
||||||
|
const newCount = parseInt(value);
|
||||||
|
const maxCapacity = parseInt(currentCapacity);
|
||||||
|
|
||||||
|
if (newCount > maxCapacity) return;
|
||||||
|
|
||||||
|
const event = updateEvent(selectedProduct.productUuid, selectedEventData.data.modelUuid, {
|
||||||
|
storageCount: newCount,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setSpawnedCount(value);
|
||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
updateBackend(
|
updateBackend(
|
||||||
selectedProduct.productName,
|
selectedProduct.productName,
|
||||||
@@ -129,19 +176,10 @@ function StorageMechanics() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const createNewMaterial = (materialType: string): { materialType: string; materialId: string } | null => {
|
|
||||||
if (!selectedEventData || !selectedPointData) return null;
|
|
||||||
const materialId = THREE.MathUtils.generateUUID();
|
|
||||||
return {
|
|
||||||
materialType,
|
|
||||||
materialId
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleMaterialTypeChange = (value: string) => {
|
const handleMaterialTypeChange = (value: string) => {
|
||||||
if (!selectedEventData || !selectedPointData) return;
|
if (!selectedEventData || !selectedPointData) return;
|
||||||
|
|
||||||
const event = updateAction(selectedProduct.productUuid, selectedPointData.action.actionUuid, {
|
const event = updateEvent(selectedProduct.productUuid, selectedEventData.data.modelUuid, {
|
||||||
materialType: value,
|
materialType: value,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -161,16 +199,6 @@ function StorageMechanics() {
|
|||||||
[selectedPointData]
|
[selectedPointData]
|
||||||
);
|
);
|
||||||
|
|
||||||
const currentCapacity = useMemo(() =>
|
|
||||||
selectedPointData ? selectedPointData.action.storageCapacity.toString() : "0",
|
|
||||||
[selectedPointData]
|
|
||||||
);
|
|
||||||
|
|
||||||
const currentMaterialType = useMemo(() =>
|
|
||||||
selectedPointData?.action.materialType || "Default material",
|
|
||||||
[selectedPointData]
|
|
||||||
);
|
|
||||||
|
|
||||||
const availableActions = {
|
const availableActions = {
|
||||||
defaultOption: "store",
|
defaultOption: "store",
|
||||||
options: ["store", "spawn"],
|
options: ["store", "spawn"],
|
||||||
@@ -184,38 +212,44 @@ function StorageMechanics() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{selectedEventData && (
|
{selectedEventData && (
|
||||||
<section>
|
<>
|
||||||
<ActionsList
|
<section>
|
||||||
selectedPointData={selectedPointData}
|
<StorageAction
|
||||||
/>
|
maxCapacity={currentCapacity}
|
||||||
<div className="selected-actions-details">
|
spawnedCount={spawnedCount}
|
||||||
<div className="selected-actions-header">
|
maxCapacityDefault="0"
|
||||||
<RenameInput
|
spawnedCountCefault="0"
|
||||||
value={currentActionName}
|
min={0}
|
||||||
canEdit={false}
|
currentMaterialType={spawnedMaterial}
|
||||||
/>
|
handleCapacityChange={handleCapacityChange}
|
||||||
|
handleSpawnCountChange={handleSpawnCountChange}
|
||||||
|
handleMaterialTypeChange={handleMaterialTypeChange}
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<ActionsList
|
||||||
|
selectedPointData={selectedPointData}
|
||||||
|
/>
|
||||||
|
<div className="selected-actions-details">
|
||||||
|
<div className="selected-actions-header">
|
||||||
|
<RenameInput
|
||||||
|
value={currentActionName}
|
||||||
|
canEdit={false}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="selected-actions-list">
|
||||||
|
<LabledDropdown
|
||||||
|
defaultOption={activeOption}
|
||||||
|
options={availableActions.options}
|
||||||
|
onSelect={handleActionTypeChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="selected-actions-list">
|
<div className="tirgger">
|
||||||
<LabledDropdown
|
<Trigger selectedPointData={selectedPointData as any} type={'StorageUnit'} />
|
||||||
defaultOption={activeOption}
|
|
||||||
options={availableActions.options}
|
|
||||||
onSelect={handleActionTypeChange}
|
|
||||||
/>
|
|
||||||
<StorageAction
|
|
||||||
type={activeOption}
|
|
||||||
value={currentCapacity}
|
|
||||||
defaultValue="0"
|
|
||||||
min={0}
|
|
||||||
currentMaterialType={currentMaterialType}
|
|
||||||
handleCapacityChange={handleCapacityChange}
|
|
||||||
handleMaterialTypeChange={handleMaterialTypeChange}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
<div className="tirgger">
|
</>
|
||||||
<Trigger selectedPointData={selectedPointData as any} type={'StorageUnit'} />
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -232,6 +232,9 @@ function AssetsGroup({ plane }: { readonly plane: RefMesh }) {
|
|||||||
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
rotation: [item.rotation.x, item.rotation.y, item.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
type: "storageUnit",
|
type: "storageUnit",
|
||||||
|
storageCapacity: 10,
|
||||||
|
storageCount: 10,
|
||||||
|
materialType: "Default material",
|
||||||
subType: item.eventData.subType || '',
|
subType: item.eventData.subType || '',
|
||||||
point: {
|
point: {
|
||||||
uuid: item.eventData.point?.uuid || THREE.MathUtils.generateUUID(),
|
uuid: item.eventData.point?.uuid || THREE.MathUtils.generateUUID(),
|
||||||
@@ -241,7 +244,6 @@ function AssetsGroup({ plane }: { readonly plane: RefMesh }) {
|
|||||||
actionUuid: THREE.MathUtils.generateUUID(),
|
actionUuid: THREE.MathUtils.generateUUID(),
|
||||||
actionName: "Action 1",
|
actionName: "Action 1",
|
||||||
actionType: "store",
|
actionType: "store",
|
||||||
storageCapacity: 10,
|
|
||||||
triggers: []
|
triggers: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -345,6 +345,9 @@ async function handleModelLoad(
|
|||||||
rotation: newFloorItem.rotation,
|
rotation: newFloorItem.rotation,
|
||||||
state: "idle",
|
state: "idle",
|
||||||
type: "storageUnit",
|
type: "storageUnit",
|
||||||
|
storageCapacity: 10,
|
||||||
|
storageCount: 10,
|
||||||
|
materialType: "Default material",
|
||||||
subType: selectedItem.subType || '',
|
subType: selectedItem.subType || '',
|
||||||
point: {
|
point: {
|
||||||
uuid: THREE.MathUtils.generateUUID(),
|
uuid: THREE.MathUtils.generateUUID(),
|
||||||
@@ -354,7 +357,6 @@ async function handleModelLoad(
|
|||||||
actionUuid: THREE.MathUtils.generateUUID(),
|
actionUuid: THREE.MathUtils.generateUUID(),
|
||||||
actionName: "Action 1",
|
actionName: "Action 1",
|
||||||
actionType: "store",
|
actionType: "store",
|
||||||
storageCapacity: 10,
|
|
||||||
triggers: [],
|
triggers: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -375,6 +375,9 @@ const CopyPasteControls3D = ({
|
|||||||
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
type: "storageUnit",
|
type: "storageUnit",
|
||||||
|
storageCapacity: 10,
|
||||||
|
storageCount: 10,
|
||||||
|
materialType: "Default material",
|
||||||
subType: pastedAsset.userData.eventData.subType || '',
|
subType: pastedAsset.userData.eventData.subType || '',
|
||||||
point: {
|
point: {
|
||||||
uuid: THREE.MathUtils.generateUUID(),
|
uuid: THREE.MathUtils.generateUUID(),
|
||||||
@@ -384,7 +387,6 @@ const CopyPasteControls3D = ({
|
|||||||
actionUuid: THREE.MathUtils.generateUUID(),
|
actionUuid: THREE.MathUtils.generateUUID(),
|
||||||
actionName: "Action 1",
|
actionName: "Action 1",
|
||||||
actionType: "store",
|
actionType: "store",
|
||||||
storageCapacity: 10,
|
|
||||||
triggers: []
|
triggers: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -445,6 +445,9 @@ const DuplicationControls3D = ({
|
|||||||
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
||||||
state: "idle",
|
state: "idle",
|
||||||
type: "storageUnit",
|
type: "storageUnit",
|
||||||
|
storageCapacity: 10,
|
||||||
|
storageCount: 10,
|
||||||
|
materialType: "Default material",
|
||||||
subType: duplicatedAsset.userData.eventData.subType || '',
|
subType: duplicatedAsset.userData.eventData.subType || '',
|
||||||
point: {
|
point: {
|
||||||
uuid: THREE.MathUtils.generateUUID(),
|
uuid: THREE.MathUtils.generateUUID(),
|
||||||
@@ -454,7 +457,6 @@ const DuplicationControls3D = ({
|
|||||||
actionUuid: THREE.MathUtils.generateUUID(),
|
actionUuid: THREE.MathUtils.generateUUID(),
|
||||||
actionName: "Action 1",
|
actionName: "Action 1",
|
||||||
actionType: "store",
|
actionType: "store",
|
||||||
storageCapacity: 10,
|
|
||||||
triggers: []
|
triggers: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Stats } from "@react-three/drei";
|
|
||||||
import { detectModifierKeys } from "../../../utils/shortcutkeys/detectModifierKeys";
|
import { detectModifierKeys } from "../../../utils/shortcutkeys/detectModifierKeys";
|
||||||
|
|
||||||
|
import { Perf } from 'r3f-perf';
|
||||||
|
|
||||||
export default function StatsHelper() {
|
export default function StatsHelper() {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
|
|
||||||
@@ -18,5 +19,5 @@ export default function StatsHelper() {
|
|||||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return visible ? <Stats className="stats" /> : null;
|
return visible ? <Perf position="bottom-left" className="scene-performance-stats"/> : null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import { getAllProjects } from "../../services/dashboard/getAllProjects";
|
|||||||
import { getUserData } from "../../functions/getUserData";
|
import { getUserData } from "../../functions/getUserData";
|
||||||
import { useLoadingProgress, useSocketStore } from "../../store/builder/store";
|
import { useLoadingProgress, useSocketStore } from "../../store/builder/store";
|
||||||
import { Color, SRGBColorSpace } from "three";
|
import { Color, SRGBColorSpace } from "three";
|
||||||
import StatsHelper from "./helpers/StatsHelper";
|
|
||||||
|
|
||||||
export default function Scene({ layout }: { readonly layout: "Main Layout" | "Comparison Layout"; }) {
|
export default function Scene({ layout }: { readonly layout: "Main Layout" | "Comparison Layout"; }) {
|
||||||
const map = useMemo(() => [
|
const map = useMemo(() => [
|
||||||
@@ -72,7 +71,6 @@ export default function Scene({ layout }: { readonly layout: "Main Layout" | "Co
|
|||||||
<Builder />
|
<Builder />
|
||||||
<Simulation />
|
<Simulation />
|
||||||
<Visualization />
|
<Visualization />
|
||||||
<StatsHelper />
|
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</KeyboardControls>
|
</KeyboardControls>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import Sun from '../environment/sky'
|
import Sun from '../environment/sky'
|
||||||
import Shadows from '../environment/shadow'
|
import Shadows from '../environment/shadow'
|
||||||
import PostProcessing from '../postProcessing/postProcessing'
|
import PostProcessing from '../postProcessing/postProcessing'
|
||||||
|
import StatsHelper from '../helpers/StatsHelper';
|
||||||
import Controls from '../controls/controls';
|
import Controls from '../controls/controls';
|
||||||
import { AdaptiveDpr, AdaptiveEvents, Environment } from '@react-three/drei'
|
import { AdaptiveDpr, AdaptiveEvents, Environment } from '@react-three/drei'
|
||||||
|
|
||||||
import background from "../../../assets/textures/hdr/mudroadpuresky2k.hdr";
|
import background from "../../../assets/textures/hdr/mudroadpuresky2k.hdr";
|
||||||
// import { Perf } from 'r3f-perf';
|
|
||||||
|
|
||||||
function Setup() {
|
function Setup() {
|
||||||
return (
|
return (
|
||||||
@@ -18,12 +18,12 @@ function Setup() {
|
|||||||
|
|
||||||
<PostProcessing />
|
<PostProcessing />
|
||||||
|
|
||||||
{/* <Perf position="bottom-left" className="scene-performance-stats"/> */}
|
|
||||||
|
|
||||||
{/* <MovingClouds /> */}
|
{/* <MovingClouds /> */}
|
||||||
|
|
||||||
<Environment files={background} environmentIntensity={1.5} />
|
<Environment files={background} environmentIntensity={1.5} />
|
||||||
|
|
||||||
|
<StatsHelper />
|
||||||
|
|
||||||
<AdaptiveEvents />
|
<AdaptiveEvents />
|
||||||
|
|
||||||
<AdaptiveDpr pixelated />
|
<AdaptiveDpr pixelated />
|
||||||
|
|||||||
47
app/src/modules/scene/tools/autoRotate.tsx
Normal file
47
app/src/modules/scene/tools/autoRotate.tsx
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { useEffect, useRef, useState } from 'react'
|
||||||
|
import { useThree, useFrame } from '@react-three/fiber'
|
||||||
|
import type CameraControlsImpl from 'camera-controls'
|
||||||
|
|
||||||
|
export default function AutoRotate() {
|
||||||
|
const { gl, controls } = useThree()
|
||||||
|
const [isIdle, setIsIdle] = useState(false)
|
||||||
|
const idleTimeout = useRef<NodeJS.Timeout | null>(null)
|
||||||
|
const lastInteractionTime = useRef(Date.now())
|
||||||
|
|
||||||
|
const cameraControls = controls as CameraControlsImpl | null
|
||||||
|
|
||||||
|
const resetIdleTimer = () => {
|
||||||
|
lastInteractionTime.current = Date.now()
|
||||||
|
if (isIdle) setIsIdle(false)
|
||||||
|
if (idleTimeout.current) clearTimeout(idleTimeout.current)
|
||||||
|
idleTimeout.current = setTimeout(() => {
|
||||||
|
setIsIdle(true)
|
||||||
|
}, 30_000)
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const dom = gl.domElement
|
||||||
|
const listener = () => resetIdleTimer()
|
||||||
|
|
||||||
|
dom.addEventListener('pointerdown', listener)
|
||||||
|
dom.addEventListener('wheel', listener)
|
||||||
|
window.addEventListener('keydown', listener)
|
||||||
|
|
||||||
|
resetIdleTimer()
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
dom.removeEventListener('pointerdown', listener)
|
||||||
|
dom.removeEventListener('wheel', listener)
|
||||||
|
window.removeEventListener('keydown', listener)
|
||||||
|
}
|
||||||
|
}, [gl])
|
||||||
|
|
||||||
|
useFrame((_, delta) => {
|
||||||
|
if (isIdle && cameraControls) {
|
||||||
|
cameraControls.rotate(delta * 0.1, 0, true)
|
||||||
|
cameraControls.update(delta)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -238,7 +238,7 @@ function WorkerInstance({ human }: { human: HumanStatus }) {
|
|||||||
human.modelUuid,
|
human.modelUuid,
|
||||||
human.currentLoad,
|
human.currentLoad,
|
||||||
model.modelUuid,
|
model.modelUuid,
|
||||||
model.point.action.storageCapacity,
|
model.storageCapacity,
|
||||||
(action as HumanAction)
|
(action as HumanAction)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,15 +136,14 @@ function Products() {
|
|||||||
if (event.type === 'storageUnit') {
|
if (event.type === 'storageUnit') {
|
||||||
addStorageUnit(selectedProduct.productUuid, event);
|
addStorageUnit(selectedProduct.productUuid, event);
|
||||||
|
|
||||||
if (event.point.action.actionType === 'retrieve') {
|
if (event.storageCount > 0) {
|
||||||
const storageAction = event.point.action;
|
const materials = Array.from({ length: event.storageCount }, () => ({
|
||||||
const materials = Array.from({ length: storageAction.storageCapacity }, () => ({
|
materialType: event.materialType || 'Default material',
|
||||||
materialType: storageAction.materialType || 'Default material',
|
|
||||||
materialId: THREE.MathUtils.generateUUID()
|
materialId: THREE.MathUtils.generateUUID()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setCurrentMaterials(event.modelUuid, materials);
|
setCurrentMaterials(event.modelUuid, materials);
|
||||||
updateCurrentLoad(event.modelUuid, storageAction.storageCapacity);
|
updateCurrentLoad(event.modelUuid, event.storageCount);
|
||||||
} else {
|
} else {
|
||||||
setCurrentMaterials(event.modelUuid, []);
|
setCurrentMaterials(event.modelUuid, []);
|
||||||
updateCurrentLoad(event.modelUuid, 0);
|
updateCurrentLoad(event.modelUuid, 0);
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ export function useTriggerHandler() {
|
|||||||
|
|
||||||
if (action && storageUnit) {
|
if (action && storageUnit) {
|
||||||
|
|
||||||
if (storageUnit.currentLoad < storageUnit.point.action.storageCapacity) {
|
if (storageUnit.currentLoad < storageUnit.storageCapacity) {
|
||||||
|
|
||||||
// Handle current action from vehicle
|
// Handle current action from vehicle
|
||||||
handleAction(action, materialId);
|
handleAction(action, materialId);
|
||||||
@@ -1135,7 +1135,7 @@ export function useTriggerHandler() {
|
|||||||
|
|
||||||
if (action && storageUnit) {
|
if (action && storageUnit) {
|
||||||
|
|
||||||
if (storageUnit.currentLoad < storageUnit.point.action.storageCapacity) {
|
if (storageUnit.currentLoad < storageUnit.storageCapacity) {
|
||||||
|
|
||||||
// Handle current action from vehicle
|
// Handle current action from vehicle
|
||||||
handleAction(action, materialId);
|
handleAction(action, materialId);
|
||||||
@@ -1782,7 +1782,7 @@ export function useTriggerHandler() {
|
|||||||
|
|
||||||
if (action && storageUnit) {
|
if (action && storageUnit) {
|
||||||
|
|
||||||
if (storageUnit.currentLoad < storageUnit.point.action.storageCapacity) {
|
if (storageUnit.currentLoad < storageUnit.storageCapacity) {
|
||||||
|
|
||||||
// Handle current action from vehicle
|
// Handle current action from vehicle
|
||||||
handleAction(action, materialId);
|
handleAction(action, materialId);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const StorageContentUi: React.FC<StorageContentUiProps> = ({ storageUnit }) => {
|
|||||||
status={storageUnit.state}
|
status={storageUnit.state}
|
||||||
count={storageUnit.currentLoad}
|
count={storageUnit.currentLoad}
|
||||||
enableStatue={false}
|
enableStatue={false}
|
||||||
totalCapacity={storageUnit.point.action.storageCapacity}
|
totalCapacity={storageUnit.storageCapacity}
|
||||||
/>
|
/>
|
||||||
</Html>
|
</Html>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ function VehicleInstance({ agvDetail }: Readonly<{ agvDetail: VehicleStatus }>)
|
|||||||
agvDetail.currentLoad,
|
agvDetail.currentLoad,
|
||||||
agvDetail.point.action.unLoadDuration,
|
agvDetail.point.action.unLoadDuration,
|
||||||
model.modelUuid,
|
model.modelUuid,
|
||||||
model.point.action.storageCapacity,
|
model.storageCapacity,
|
||||||
agvDetail.point.action
|
agvDetail.point.action
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ export const createStorageUnitStore = () => {
|
|||||||
|
|
||||||
getFullStorageUnits: () => {
|
getFullStorageUnits: () => {
|
||||||
return get().storageUnits.filter(
|
return get().storageUnits.filter(
|
||||||
s => s.currentLoad >= s.point.action.storageCapacity
|
s => s.currentLoad >= s.storageCapacity
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
5
app/src/types/simulationTypes.d.ts
vendored
5
app/src/types/simulationTypes.d.ts
vendored
@@ -90,8 +90,6 @@ interface StorageAction {
|
|||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "store" | "retrieve";
|
actionType: "store" | "retrieve";
|
||||||
materialType?: string;
|
|
||||||
storageCapacity: number;
|
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,6 +205,9 @@ interface MachineEventSchema extends AssetEventSchema {
|
|||||||
interface StorageEventSchema extends AssetEventSchema {
|
interface StorageEventSchema extends AssetEventSchema {
|
||||||
type: "storageUnit";
|
type: "storageUnit";
|
||||||
subType: string;
|
subType: string;
|
||||||
|
storageCapacity: number;
|
||||||
|
storageCount: number;
|
||||||
|
materialType: string;
|
||||||
point: StoragePointSchema;
|
point: StoragePointSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user