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

---
 src/assets/data/shelf.js |   18 +++++++-----------
 src/components/shelf.jsx |   29 ++++++++++++++---------------
 2 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/src/assets/data/shelf.js b/src/assets/data/shelf.js
index 3b944b5..a187cf2 100644
--- a/src/assets/data/shelf.js
+++ b/src/assets/data/shelf.js
@@ -1,18 +1,14 @@
 const shelfData = [
   {
-    x: 200,
-    y: -1000,
-    width: 200,
-    height: 2000,
-    tunnelNumber: 'T1',
+    no: '1-1-1',
+    position: [0, 0, 0],
+    rotationY: Math.PI / 2,
   },
   {
-    x: 200,
-    y: -50,
-    width: 1300,
-    height: 100,
-    tunnelNumber: 'T2',
-  },
+    no: '2-1-1',
+    position: [100, 0, 0],
+    rotationY: Math.PI / 2,
+  }
 ];
 
 export default shelfData;
diff --git a/src/components/shelf.jsx b/src/components/shelf.jsx
index c084e7c..b9cd11d 100644
--- a/src/components/shelf.jsx
+++ b/src/components/shelf.jsx
@@ -1,28 +1,27 @@
-import { useState, useMemo, useRef, useEffect } from 'react';
+import { useMemo } from 'react';
 import { useGLTF } from '@react-three/drei';
-import { MODEL_SHELF_SCALE } from '@/config/setting';
-import * as Common from '../utils/common';
+import * as THREE from 'three';
+import { MODEL_SHELF_SCALE } from '@/config/setting'
 
 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();
-    }, [])
+    const { scene } = useGLTF('/models/shelf/row.glb');
+    console.log(scene);
 
-    useEffect(() => {
-
-    }, []);
+    // 鍦╱seMemo鍐呴儴鍏嬮殕妯″瀷锛屼互閬垮厤褰卞搷鍒板師濮嬫ā鍨�
+    const model = useMemo(() => scene.clone(), [scene]);
 
     return (
         <>
             <group rotation-y={rotationY} position={position}>
-                <primitive object={model} castShadow />
+                {/* 鍦╬rimitives鍐呰缃ā鍨嬬殑姣斾緥鍜岄槾褰卞睘鎬� */}
+                <primitive
+                    object={model}
+                    castShadow
+                    receiveShadow
+                    scale={[MODEL_SHELF_SCALE, MODEL_SHELF_SCALE, MODEL_SHELF_SCALE]}
+                />
             </group>
         </>
     )

--
Gitblit v1.9.1