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",
|
||||
"postprocessing": "^6.36.4",
|
||||
"prompt-sync": "^4.2.0",
|
||||
"r3f-perf": "^7.2.3",
|
||||
"react": "^18.3.1",
|
||||
"react-chartjs-2": "^5.3.0",
|
||||
"react-dom": "^18.3.1",
|
||||
@@ -3371,6 +3372,15 @@
|
||||
"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": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.0.0.tgz",
|
||||
@@ -7073,6 +7083,23 @@
|
||||
"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": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz",
|
||||
@@ -17894,6 +17921,64 @@
|
||||
"integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==",
|
||||
"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": {
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"mqtt": "^5.10.4",
|
||||
"postprocessing": "^6.36.4",
|
||||
"prompt-sync": "^4.2.0",
|
||||
"r3f-perf": "^7.2.3",
|
||||
"react": "^18.3.1",
|
||||
"react-chartjs-2": "^5.3.0",
|
||||
"react-dom": "^18.3.1",
|
||||
|
||||
@@ -3,44 +3,44 @@ import InputWithDropDown from "../../../../../ui/inputs/InputWithDropDown";
|
||||
import LabledDropdown from "../../../../../ui/inputs/LabledDropdown";
|
||||
|
||||
interface StorageActionProps {
|
||||
type: "store" | "spawn" | "default";
|
||||
value: string;
|
||||
maxCapacity: string;
|
||||
spawnedCount: string;
|
||||
min: number;
|
||||
max?: number;
|
||||
defaultValue: string;
|
||||
maxCapacityDefault: string;
|
||||
spawnedCountCefault: string;
|
||||
currentMaterialType: string;
|
||||
handleCapacityChange: (value: string) => void;
|
||||
handleSpawnCountChange: (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 (
|
||||
<>
|
||||
{type === 'store' &&
|
||||
<InputWithDropDown
|
||||
key={'Storage Capacity'}
|
||||
label="Storage Capacity"
|
||||
value={value}
|
||||
value={maxCapacity}
|
||||
min={min}
|
||||
step={1}
|
||||
max={max}
|
||||
defaultValue={defaultValue}
|
||||
defaultValue={maxCapacityDefault}
|
||||
activeOption="unit"
|
||||
onClick={() => { }}
|
||||
onChange={handleCapacityChange}
|
||||
/>
|
||||
}
|
||||
{type === 'spawn' &&
|
||||
<>
|
||||
<InputWithDropDown
|
||||
label="Spawn Capacity"
|
||||
value={value}
|
||||
key={"Spawn Count"}
|
||||
label="Spawn Count"
|
||||
value={spawnedCount}
|
||||
min={min}
|
||||
step={1}
|
||||
max={max}
|
||||
defaultValue={defaultValue}
|
||||
defaultValue={spawnedCountCefault}
|
||||
activeOption="unit"
|
||||
onClick={() => { }}
|
||||
onChange={handleCapacityChange}
|
||||
onChange={handleSpawnCountChange}
|
||||
/>
|
||||
<LabledDropdown
|
||||
label={"Material Type"}
|
||||
@@ -49,8 +49,6 @@ const StorageAction: React.FC<StorageActionProps> = ({ type, value, min, max, de
|
||||
onSelect={handleMaterialTypeChange}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,10 +14,13 @@ import { useSceneContext } from "../../../../../../modules/scene/sceneContext";
|
||||
|
||||
function StorageMechanics() {
|
||||
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 { selectedEventData } = useSelectedEventData();
|
||||
const { productStore } = useSceneContext();
|
||||
const { getPointByUuid, updateAction } = productStore();
|
||||
const { getPointByUuid, updateAction, updateEvent, getEventByModelUuid } = productStore();
|
||||
const { selectedProductStore } = useProductContext();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
const { setSelectedAction, clearSelectedAction } = useSelectedAction();
|
||||
@@ -52,6 +55,24 @@ function StorageMechanics() {
|
||||
setSelectedPointData(point);
|
||||
const uiOption = point.action.actionType === "retrieve" ? "spawn" : point.action.actionType;
|
||||
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);
|
||||
}
|
||||
} 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) => {
|
||||
if (!selectedEventData || !selectedPointData) return;
|
||||
const newCapacity = parseInt(value);
|
||||
|
||||
const event = updateAction(selectedProduct.productUuid, selectedPointData.action.actionUuid, {
|
||||
storageCapacity: newCapacity,
|
||||
const newCapacity = parseInt(value);
|
||||
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) {
|
||||
updateBackend(
|
||||
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) => {
|
||||
if (!selectedEventData || !selectedPointData) return;
|
||||
|
||||
const event = updateAction(selectedProduct.productUuid, selectedPointData.action.actionUuid, {
|
||||
const event = updateEvent(selectedProduct.productUuid, selectedEventData.data.modelUuid, {
|
||||
materialType: value,
|
||||
});
|
||||
|
||||
@@ -161,16 +199,6 @@ function StorageMechanics() {
|
||||
[selectedPointData]
|
||||
);
|
||||
|
||||
const currentCapacity = useMemo(() =>
|
||||
selectedPointData ? selectedPointData.action.storageCapacity.toString() : "0",
|
||||
[selectedPointData]
|
||||
);
|
||||
|
||||
const currentMaterialType = useMemo(() =>
|
||||
selectedPointData?.action.materialType || "Default material",
|
||||
[selectedPointData]
|
||||
);
|
||||
|
||||
const availableActions = {
|
||||
defaultOption: "store",
|
||||
options: ["store", "spawn"],
|
||||
@@ -184,6 +212,20 @@ function StorageMechanics() {
|
||||
return (
|
||||
<>
|
||||
{selectedEventData && (
|
||||
<>
|
||||
<section>
|
||||
<StorageAction
|
||||
maxCapacity={currentCapacity}
|
||||
spawnedCount={spawnedCount}
|
||||
maxCapacityDefault="0"
|
||||
spawnedCountCefault="0"
|
||||
min={0}
|
||||
currentMaterialType={spawnedMaterial}
|
||||
handleCapacityChange={handleCapacityChange}
|
||||
handleSpawnCountChange={handleSpawnCountChange}
|
||||
handleMaterialTypeChange={handleMaterialTypeChange}
|
||||
/>
|
||||
</section>
|
||||
<section>
|
||||
<ActionsList
|
||||
selectedPointData={selectedPointData}
|
||||
@@ -201,21 +243,13 @@ function StorageMechanics() {
|
||||
options={availableActions.options}
|
||||
onSelect={handleActionTypeChange}
|
||||
/>
|
||||
<StorageAction
|
||||
type={activeOption}
|
||||
value={currentCapacity}
|
||||
defaultValue="0"
|
||||
min={0}
|
||||
currentMaterialType={currentMaterialType}
|
||||
handleCapacityChange={handleCapacityChange}
|
||||
handleMaterialTypeChange={handleMaterialTypeChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<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],
|
||||
state: "idle",
|
||||
type: "storageUnit",
|
||||
storageCapacity: 10,
|
||||
storageCount: 10,
|
||||
materialType: "Default material",
|
||||
subType: item.eventData.subType || '',
|
||||
point: {
|
||||
uuid: item.eventData.point?.uuid || THREE.MathUtils.generateUUID(),
|
||||
@@ -241,7 +244,6 @@ function AssetsGroup({ plane }: { readonly plane: RefMesh }) {
|
||||
actionUuid: THREE.MathUtils.generateUUID(),
|
||||
actionName: "Action 1",
|
||||
actionType: "store",
|
||||
storageCapacity: 10,
|
||||
triggers: []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,6 +345,9 @@ async function handleModelLoad(
|
||||
rotation: newFloorItem.rotation,
|
||||
state: "idle",
|
||||
type: "storageUnit",
|
||||
storageCapacity: 10,
|
||||
storageCount: 10,
|
||||
materialType: "Default material",
|
||||
subType: selectedItem.subType || '',
|
||||
point: {
|
||||
uuid: THREE.MathUtils.generateUUID(),
|
||||
@@ -354,7 +357,6 @@ async function handleModelLoad(
|
||||
actionUuid: THREE.MathUtils.generateUUID(),
|
||||
actionName: "Action 1",
|
||||
actionType: "store",
|
||||
storageCapacity: 10,
|
||||
triggers: [],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -375,6 +375,9 @@ const CopyPasteControls3D = ({
|
||||
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
||||
state: "idle",
|
||||
type: "storageUnit",
|
||||
storageCapacity: 10,
|
||||
storageCount: 10,
|
||||
materialType: "Default material",
|
||||
subType: pastedAsset.userData.eventData.subType || '',
|
||||
point: {
|
||||
uuid: THREE.MathUtils.generateUUID(),
|
||||
@@ -384,7 +387,6 @@ const CopyPasteControls3D = ({
|
||||
actionUuid: THREE.MathUtils.generateUUID(),
|
||||
actionName: "Action 1",
|
||||
actionType: "store",
|
||||
storageCapacity: 10,
|
||||
triggers: []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,6 +445,9 @@ const DuplicationControls3D = ({
|
||||
rotation: [newFloorItem.rotation.x, newFloorItem.rotation.y, newFloorItem.rotation.z],
|
||||
state: "idle",
|
||||
type: "storageUnit",
|
||||
storageCapacity: 10,
|
||||
storageCount: 10,
|
||||
materialType: "Default material",
|
||||
subType: duplicatedAsset.userData.eventData.subType || '',
|
||||
point: {
|
||||
uuid: THREE.MathUtils.generateUUID(),
|
||||
@@ -454,7 +457,6 @@ const DuplicationControls3D = ({
|
||||
actionUuid: THREE.MathUtils.generateUUID(),
|
||||
actionName: "Action 1",
|
||||
actionType: "store",
|
||||
storageCapacity: 10,
|
||||
triggers: []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Stats } from "@react-three/drei";
|
||||
import { detectModifierKeys } from "../../../utils/shortcutkeys/detectModifierKeys";
|
||||
|
||||
import { Perf } from 'r3f-perf';
|
||||
|
||||
export default function StatsHelper() {
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
@@ -18,5 +19,5 @@ export default function StatsHelper() {
|
||||
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 { useLoadingProgress, useSocketStore } from "../../store/builder/store";
|
||||
import { Color, SRGBColorSpace } from "three";
|
||||
import StatsHelper from "./helpers/StatsHelper";
|
||||
|
||||
export default function Scene({ layout }: { readonly layout: "Main Layout" | "Comparison Layout"; }) {
|
||||
const map = useMemo(() => [
|
||||
@@ -72,7 +71,6 @@ export default function Scene({ layout }: { readonly layout: "Main Layout" | "Co
|
||||
<Builder />
|
||||
<Simulation />
|
||||
<Visualization />
|
||||
<StatsHelper />
|
||||
</Canvas>
|
||||
</KeyboardControls>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import Sun from '../environment/sky'
|
||||
import Shadows from '../environment/shadow'
|
||||
import PostProcessing from '../postProcessing/postProcessing'
|
||||
import StatsHelper from '../helpers/StatsHelper';
|
||||
import Controls from '../controls/controls';
|
||||
import { AdaptiveDpr, AdaptiveEvents, Environment } from '@react-three/drei'
|
||||
|
||||
import background from "../../../assets/textures/hdr/mudroadpuresky2k.hdr";
|
||||
// import { Perf } from 'r3f-perf';
|
||||
|
||||
function Setup() {
|
||||
return (
|
||||
@@ -18,12 +18,12 @@ function Setup() {
|
||||
|
||||
<PostProcessing />
|
||||
|
||||
{/* <Perf position="bottom-left" className="scene-performance-stats"/> */}
|
||||
|
||||
{/* <MovingClouds /> */}
|
||||
|
||||
<Environment files={background} environmentIntensity={1.5} />
|
||||
|
||||
<StatsHelper />
|
||||
|
||||
<AdaptiveEvents />
|
||||
|
||||
<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.currentLoad,
|
||||
model.modelUuid,
|
||||
model.point.action.storageCapacity,
|
||||
model.storageCapacity,
|
||||
(action as HumanAction)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,15 +136,14 @@ function Products() {
|
||||
if (event.type === 'storageUnit') {
|
||||
addStorageUnit(selectedProduct.productUuid, event);
|
||||
|
||||
if (event.point.action.actionType === 'retrieve') {
|
||||
const storageAction = event.point.action;
|
||||
const materials = Array.from({ length: storageAction.storageCapacity }, () => ({
|
||||
materialType: storageAction.materialType || 'Default material',
|
||||
if (event.storageCount > 0) {
|
||||
const materials = Array.from({ length: event.storageCount }, () => ({
|
||||
materialType: event.materialType || 'Default material',
|
||||
materialId: THREE.MathUtils.generateUUID()
|
||||
}));
|
||||
|
||||
setCurrentMaterials(event.modelUuid, materials);
|
||||
updateCurrentLoad(event.modelUuid, storageAction.storageCapacity);
|
||||
updateCurrentLoad(event.modelUuid, event.storageCount);
|
||||
} else {
|
||||
setCurrentMaterials(event.modelUuid, []);
|
||||
updateCurrentLoad(event.modelUuid, 0);
|
||||
|
||||
@@ -575,7 +575,7 @@ export function useTriggerHandler() {
|
||||
|
||||
if (action && storageUnit) {
|
||||
|
||||
if (storageUnit.currentLoad < storageUnit.point.action.storageCapacity) {
|
||||
if (storageUnit.currentLoad < storageUnit.storageCapacity) {
|
||||
|
||||
// Handle current action from vehicle
|
||||
handleAction(action, materialId);
|
||||
@@ -1135,7 +1135,7 @@ export function useTriggerHandler() {
|
||||
|
||||
if (action && storageUnit) {
|
||||
|
||||
if (storageUnit.currentLoad < storageUnit.point.action.storageCapacity) {
|
||||
if (storageUnit.currentLoad < storageUnit.storageCapacity) {
|
||||
|
||||
// Handle current action from vehicle
|
||||
handleAction(action, materialId);
|
||||
@@ -1782,7 +1782,7 @@ export function useTriggerHandler() {
|
||||
|
||||
if (action && storageUnit) {
|
||||
|
||||
if (storageUnit.currentLoad < storageUnit.point.action.storageCapacity) {
|
||||
if (storageUnit.currentLoad < storageUnit.storageCapacity) {
|
||||
|
||||
// Handle current action from vehicle
|
||||
handleAction(action, materialId);
|
||||
|
||||
@@ -31,7 +31,7 @@ const StorageContentUi: React.FC<StorageContentUiProps> = ({ storageUnit }) => {
|
||||
status={storageUnit.state}
|
||||
count={storageUnit.currentLoad}
|
||||
enableStatue={false}
|
||||
totalCapacity={storageUnit.point.action.storageCapacity}
|
||||
totalCapacity={storageUnit.storageCapacity}
|
||||
/>
|
||||
</Html>
|
||||
);
|
||||
|
||||
@@ -394,7 +394,7 @@ function VehicleInstance({ agvDetail }: Readonly<{ agvDetail: VehicleStatus }>)
|
||||
agvDetail.currentLoad,
|
||||
agvDetail.point.action.unLoadDuration,
|
||||
model.modelUuid,
|
||||
model.point.action.storageCapacity,
|
||||
model.storageCapacity,
|
||||
agvDetail.point.action
|
||||
);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ export const createStorageUnitStore = () => {
|
||||
|
||||
getFullStorageUnits: () => {
|
||||
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;
|
||||
actionName: string;
|
||||
actionType: "store" | "retrieve";
|
||||
materialType?: string;
|
||||
storageCapacity: number;
|
||||
triggers: TriggerSchema[];
|
||||
}
|
||||
|
||||
@@ -207,6 +205,9 @@ interface MachineEventSchema extends AssetEventSchema {
|
||||
interface StorageEventSchema extends AssetEventSchema {
|
||||
type: "storageUnit";
|
||||
subType: string;
|
||||
storageCapacity: number;
|
||||
storageCount: number;
|
||||
materialType: string;
|
||||
point: StoragePointSchema;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user