From ac3a17007eba343238d4b8916e46d64c58b0db9c Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 23 四月 2024 14:17:12 +0800
Subject: [PATCH] #
---
src/assets/data/agv.js | 432 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
src/components/box.jsx | 31 ---
src/config/setting.js | 2
src/components/agv.jsx | 11 +
4 files changed, 433 insertions(+), 43 deletions(-)
diff --git a/src/assets/data/agv.js b/src/assets/data/agv.js
index 76c06ed..49bc8a5 100644
--- a/src/assets/data/agv.js
+++ b/src/assets/data/agv.js
@@ -7,7 +7,32 @@
height: 0,
loaderTheta: 0,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: false
}
],
@@ -19,7 +44,32 @@
height: 0,
loaderTheta: 0,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: false
}
],
@@ -31,7 +81,32 @@
height: 0,
loaderTheta: 0,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: false
}
],
@@ -43,7 +118,32 @@
height: 100,
loaderTheta: 0,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: false
}
],
@@ -55,7 +155,32 @@
height: 150,
loaderTheta: 0,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: false
}
],
@@ -67,7 +192,32 @@
height: 200,
loaderTheta: 0,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: false
}
],
@@ -79,7 +229,32 @@
height: 100,
loaderTheta: 0,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: false
}
],
@@ -91,7 +266,32 @@
height: 100,
loaderTheta: 0,
forkLength: 40,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: false
}
],
@@ -103,7 +303,32 @@
height: 100,
loaderTheta: 0,
forkLength: 40,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: true
}
],
@@ -115,7 +340,32 @@
height: 100,
loaderTheta: 0,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: true
}
],
@@ -127,7 +377,32 @@
height: 0,
loaderTheta: 0,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: true
}
],
@@ -139,7 +414,32 @@
height: 0,
loaderTheta: 270,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: true
}
],
@@ -151,7 +451,32 @@
height: 0,
loaderTheta: 270,
forkLength: 40,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: false
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: true
}
],
@@ -163,7 +488,32 @@
height: 0,
loaderTheta: 270,
forkLength: 40,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: true
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: false
}
],
@@ -175,7 +525,32 @@
height: 0,
loaderTheta: 270,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: true
+ },
+ {
+ no: 2,
+ hasBox: false
+ },
+ {
+ no: 3,
+ hasBox: false
+ },
+ {
+ no: 4,
+ hasBox: false
+ },
+ {
+ no: 5,
+ hasBox: false
+ },
+ {
+ no: 6,
+ hasBox: false
+ },
+ ],
hasBox: false
}
],
@@ -187,7 +562,32 @@
height: 0,
loaderTheta: 0,
forkLength: 0,
- trayList: [],
+ trayList: [
+ {
+ no: 1,
+ hasBox: true
+ },
+ {
+ no: 2,
+ hasBox: true
+ },
+ {
+ no: 3,
+ hasBox: true
+ },
+ {
+ no: 4,
+ hasBox: true
+ },
+ {
+ no: 5,
+ hasBox: true
+ },
+ {
+ no: 6,
+ hasBox: true
+ },
+ ],
hasBox: false
}
],
diff --git a/src/components/agv.jsx b/src/components/agv.jsx
index 31e88be..bb7e222 100644
--- a/src/components/agv.jsx
+++ b/src/components/agv.jsx
@@ -20,6 +20,7 @@
if (!props || Object.keys(props).length === 0) {
return;
}
+
// group position
const pos = {
x: position?.[0],
@@ -67,9 +68,7 @@
// loader theta
if (integrateTheta !== loaderTheta) {
- console.log(integrateTheta, loaderTheta);
const minTheta = Common.minDiffTheta(integrateTheta, loaderTheta);
- console.log(minTheta);
new TWEEN.Tween({ value: integrateTheta })
.to({ value: minTheta }, INTERVAL_TIME)
.easing(TWEEN.Easing.Linear.None)
@@ -144,6 +143,14 @@
{hasBox && <Box position={[0, 24, 0]} />}
</group>
</group>
+ <group>
+ {trayList?.[0]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 25, 0]} />}
+ {trayList?.[1]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 48, 0]} />}
+ {trayList?.[2]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 71, 0]} />}
+ {trayList?.[3]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 94, 0]} />}
+ {trayList?.[4]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 117, 0]} />}
+ {trayList?.[5]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 140, 0]} />}
+ </group>
</group>
</>
)
diff --git a/src/components/box.jsx b/src/components/box.jsx
index 5ca3bba..69b0481 100644
--- a/src/components/box.jsx
+++ b/src/components/box.jsx
@@ -2,37 +2,18 @@
import { useFrame } from '@react-three/fiber';
import { useFBX, useAnimations } from '@react-three/drei';
import * as THREE from 'three';
-
-const setShadow = (obj) => {
- obj.castShadow = true;
- obj.receiveShadow = true;
-
- if (obj.children) {
- obj.children.forEach((child) => {
- setShadow(child);
- });
- }
-};
-
-const setColor = (obj) => {
- if (obj.material) {
- obj.material.color.set(0x4680BF);
- }
- if (obj.children) {
- obj.children.forEach((child) => {
- setColor(child);
- });
- }
-};
+import { MODEL_BOX_SCALE } from '@/config/setting'
+import * as Common from '../utils/common';
const Box = (props) => {
- const { position = [0, 300, 0] } = props;
+ const { position = [0, 300, 0], rotationY = 0 } = props;
const boxModel = useMemo(() => {
const fbx = useFBX('/models/box/box.fbx');
if (!fbx.castShadow) {
- setShadow(fbx);
+ Common.setShadow(fbx);
}
+ fbx.scale.set(MODEL_BOX_SCALE, MODEL_BOX_SCALE, MODEL_BOX_SCALE);
return fbx.clone();
}, [])
@@ -42,7 +23,7 @@
return (
<>
- <group rotation={[0, 0, 0]} scale={0.5} position={position}>
+ <group rotation-y={rotationY} scale={0.5} position={position}>
<primitive object={boxModel} castShadow />
</group>
</>
diff --git a/src/config/setting.js b/src/config/setting.js
index c3424c8..94e6d7a 100644
--- a/src/config/setting.js
+++ b/src/config/setting.js
@@ -9,3 +9,5 @@
export const INTERVAL_TIME = 500;
export const MODEL_AGV_SCALE = .5;
+
+export const MODEL_BOX_SCALE = 1;
\ No newline at end of file
--
Gitblit v1.9.1