schema change
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user