From 073cd20230a7c4d8b7c771ce227e3101813638fc Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 22 四月 2024 15:49:17 +0800
Subject: [PATCH] #
---
src/utils/common.js | 23 +++++++
src/assets/data/agv.js | 74 ++++++++++++++++++++++++
src/core/warehouse.jsx | 13 +++
src/components/agv.jsx | 11 ++-
4 files changed, 116 insertions(+), 5 deletions(-)
diff --git a/src/assets/data/agv.js b/src/assets/data/agv.js
index e69de29..e0f7d60 100644
--- a/src/assets/data/agv.js
+++ b/src/assets/data/agv.js
@@ -0,0 +1,74 @@
+export default [
+ [
+ {
+ no: 1,
+ position: [0, 0, 0],
+ theta: 0,
+ height: 100,
+ loaderTheta: 180,
+ forkLength: 0,
+ trayList: [],
+ hasBox: false
+ }
+ ],
+ [
+ {
+ no: 1,
+ position: [100, 0, 0],
+ theta: 0,
+ height: 100,
+ loaderTheta: 180,
+ forkLength: 0,
+ trayList: [],
+ hasBox: false
+ }
+ ],
+ [
+ {
+ no: 1,
+ position: [100, 0, 0],
+ theta: 90,
+ height: 100,
+ loaderTheta: 180,
+ forkLength: 0,
+ trayList: [],
+ hasBox: false
+ }
+ ],
+ [
+ {
+ no: 1,
+ position: [100, 0, 200],
+ theta: 90,
+ height: 100,
+ loaderTheta: 180,
+ forkLength: 0,
+ trayList: [],
+ hasBox: false
+ }
+ ],
+ [
+ {
+ no: 1,
+ position: [100, 0, 300],
+ theta: 90,
+ height: 100,
+ loaderTheta: 180,
+ forkLength: 0,
+ trayList: [],
+ hasBox: false
+ }
+ ],
+ [
+ {
+ no: 1,
+ position: [100, 0, 300],
+ theta: 90,
+ height: 100,
+ loaderTheta: 180,
+ forkLength: 0,
+ trayList: [],
+ hasBox: false
+ }
+ ],
+]
\ No newline at end of file
diff --git a/src/components/agv.jsx b/src/components/agv.jsx
index 2f256ad..2bce4f7 100644
--- a/src/components/agv.jsx
+++ b/src/components/agv.jsx
@@ -3,6 +3,7 @@
import { useFBX, useAnimations } from '@react-three/drei';
import * as THREE from 'three';
import Box from './box';
+import * as Common from '../utils/common'
const setShadow = (obj) => {
obj.castShadow = true;
@@ -27,7 +28,12 @@
};
const Agv = (props) => {
- const { } = props;
+ const { position, theta } = props;
+
+ useEffect(() => {
+ console.log(position);
+ console.log(theta);
+ }, [props]);
const bodyModel = useMemo(() => {
const fbx = useFBX('/models/agv/body.fbx');
@@ -54,12 +60,11 @@
}, [])
useEffect(() => {
-
}, []);
return (
<>
- <group rotation={[0, 0, 0]} scale={0.5} position={[0, 0, 0]}>
+ <group rotation-y={Common.rotationParseNum(theta)} scale={0.5} position={position}>
<primitive object={bodyModel} castShadow />
<primitive object={loaderModel} castShadow position={[0, 100, 0]} />
<primitive object={forkModel} castShadow position={[0, 120, 0]} />
diff --git a/src/core/warehouse.jsx b/src/core/warehouse.jsx
index b65db59..c4ce962 100644
--- a/src/core/warehouse.jsx
+++ b/src/core/warehouse.jsx
@@ -5,6 +5,9 @@
import Box from '../components/box';
import tunnelData from '../assets/data/tunnel';
import Tunnel from '../components/tunnel';
+import agvRealDataList from '@/assets/data/agv'
+
+let index = 0;
const Warehouse = (props) => {
@@ -18,6 +21,13 @@
useEffect(() => {
+ setInterval(() => {
+ const agvRealData = agvRealDataList[index];
+ if (agvRealData) {
+ setAgvData(agvRealData);
+ }
+ index++;
+ }, 2000)
}, [])
const tunnelEl = useMemo(() => {
@@ -29,8 +39,7 @@
const boxEl = boxData.map((data, idx) => <Box key={idx} {...data} />)
useFrame((state, delta) => {
- // setAgvData();
- // setBoxData();
+
})
return (
diff --git a/src/utils/common.js b/src/utils/common.js
new file mode 100644
index 0000000..b1041f5
--- /dev/null
+++ b/src/utils/common.js
@@ -0,0 +1,23 @@
+import * as THREE from 'three';
+
+export const isNullOfUndefined = (param) => {
+ if (null === param || undefined === param) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+export const rotationToNum = (rotation) => {
+ let res = rotation * 180 / Math.PI;
+ if (res < 0) {
+ res += 360;
+ } else if (res > 360) {
+ res -= 360;
+ }
+ return res;
+}
+
+export const rotationParseNum = (num) => {
+ return num * Math.PI / 180;
+}
\ No newline at end of file
--
Gitblit v1.9.1