From 794d8a8a7de3bcfad9d6f813a0372bf46a3956eb Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 23 四月 2024 15:25:39 +0800
Subject: [PATCH] #

---
 src/components/box.jsx      |    2 
 src/config/setting.js       |    4 +
 public/models/shelf/row.glb |    0 
 src/assets/data/shelf.js    |   18 +++++++++
 src/core/warehouse.jsx      |   16 ++++++--
 src/components/shelf.jsx    |   31 +++++++++++++++
 6 files changed, 65 insertions(+), 6 deletions(-)

diff --git a/public/models/shlef/row.glb b/public/models/shelf/row.glb
similarity index 100%
rename from public/models/shlef/row.glb
rename to public/models/shelf/row.glb
Binary files differ
diff --git a/src/assets/data/shelf.js b/src/assets/data/shelf.js
new file mode 100644
index 0000000..3b944b5
--- /dev/null
+++ b/src/assets/data/shelf.js
@@ -0,0 +1,18 @@
+const shelfData = [
+  {
+    x: 200,
+    y: -1000,
+    width: 200,
+    height: 2000,
+    tunnelNumber: 'T1',
+  },
+  {
+    x: 200,
+    y: -50,
+    width: 1300,
+    height: 100,
+    tunnelNumber: 'T2',
+  },
+];
+
+export default shelfData;
diff --git a/src/components/box.jsx b/src/components/box.jsx
index 69b0481..425e6d5 100644
--- a/src/components/box.jsx
+++ b/src/components/box.jsx
@@ -23,7 +23,7 @@
 
     return (
         <>
-            <group rotation-y={rotationY} scale={0.5} position={position}>
+            <group rotation-y={rotationY} position={position}>
                 <primitive object={boxModel} castShadow />
             </group>
         </>
diff --git a/src/components/shelf.jsx b/src/components/shelf.jsx
new file mode 100644
index 0000000..c084e7c
--- /dev/null
+++ b/src/components/shelf.jsx
@@ -0,0 +1,31 @@
+import { useState, useMemo, useRef, useEffect } from 'react';
+import { useGLTF } from '@react-three/drei';
+import { MODEL_SHELF_SCALE } from '@/config/setting';
+import * as Common from '../utils/common';
+
+const Shelf = (props) => {
+    const { position = [0, 300, 0], rotationY = 0 } = props;
+
+    const model = useMemo(() => {
+        const fbx = useGLTF('/models/shelf/row.glb');
+        if (!fbx.castShadow) {
+            Common.setShadow(fbx);
+        }
+        fbx.scale.set(MODEL_SHELF_SCALE, MODEL_SHELF_SCALE, MODEL_SHELF_SCALE);
+        return fbx.clone();
+    }, [])
+
+    useEffect(() => {
+
+    }, []);
+
+    return (
+        <>
+            <group rotation-y={rotationY} position={position}>
+                <primitive object={model} castShadow />
+            </group>
+        </>
+    )
+}
+
+export default Shelf;
\ No newline at end of file
diff --git a/src/config/setting.js b/src/config/setting.js
index 94e6d7a..b37e7f6 100644
--- a/src/config/setting.js
+++ b/src/config/setting.js
@@ -10,4 +10,6 @@
 
 export const MODEL_AGV_SCALE = .5;
 
-export const MODEL_BOX_SCALE = 1;
\ No newline at end of file
+export const MODEL_BOX_SCALE = .5;
+
+export const MODEL_SHELF_SCALE = 1;
\ No newline at end of file
diff --git a/src/core/warehouse.jsx b/src/core/warehouse.jsx
index 89a95c8..3e5524c 100644
--- a/src/core/warehouse.jsx
+++ b/src/core/warehouse.jsx
@@ -1,10 +1,13 @@
 import { useState, useEffect, useRef, useMemo } from 'react';
 import { useFrame } from '@react-three/fiber';
 import * as THREE from 'three';
-import Agv from '../components/agv';
-import Box from '../components/box';
-import tunnelData from '../assets/data/tunnel';
 import Tunnel from '../components/tunnel';
+import Shelf from '../components/shelf';
+import Box from '../components/box';
+import Agv from '../components/agv';
+
+import tunnelData from '@/assets/data/tunnel';
+import shelfData from '@/assets/data/shelf';
 import agvRealDataList from '@/assets/data/agv';
 import { INTERVAL_TIME } from '@/config/setting'
 
@@ -34,7 +37,11 @@
     }, [])
 
     const tunnelEl = useMemo(() => {
-        return tunnelData.map((tunnel, index) => <Tunnel key={index} {...tunnel} />)
+        return tunnelData.map((data, index) => <Tunnel key={index} {...data} />)
+    }, []);
+
+    const shelfEl = useMemo(() => {
+        return shelfData.map((data, index) => <Shelf key={index} {...data} />)
     }, []);
 
     const agvEl = useMemo(() => {
@@ -53,6 +60,7 @@
         <>
             <group>
                 {tunnelEl}
+                {shelfEl}
                 {agvEl}
                 {boxEl}
             </group>

--
Gitblit v1.9.1