From c9ec91f64f45e1484231cee06d3efd8510bb0995 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 26 四月 2024 16:16:35 +0800
Subject: [PATCH] #

---
 src/components/box.jsx |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/components/box.jsx b/src/components/box.jsx
index af0d2d7..351575b 100644
--- a/src/components/box.jsx
+++ b/src/components/box.jsx
@@ -2,7 +2,13 @@
 import { useFrame } from '@react-three/fiber';
 import { useFBX, useAnimations } from '@react-three/drei';
 import * as THREE from 'three';
-import { MODEL_BOX_SCALE, SHELF_BAY_GROUP_COUNT } from '@/config/setting'
+import {
+    MODEL_BOX_SCALE,
+    SHELF_BAY_GROUP_COUNT,
+    SHELF_BAY_UNIT_SEPARTE_DISTANCE,
+    SHELF_LEV_UNIT_SEPARTE_DISTANCE,
+    SHELF_HEIGHT_FROM_GROUND
+} from '@/config/setting'
 import * as Common from '../utils/common';
 import { useStore } from '@/store';
 
@@ -43,11 +49,26 @@
             // from shelf
             const shelfNo = getShelfNo(row, bay, lev);
             const shelfPos = state.shelfList[shelfNo];
+            if (!shelfPos) { return }
             const { row: shelfRow, bay: shelfBay, lev: shelfLev } = Common.parseLocNo(shelfNo);
 
-            console.log([shelfPos[0], shelfPos[1] + (bay - shelfBay) * 100, shelfPos[2] + (lev - shelfLev) * 100]);
+            // cal bay position
+            let posZByLev = shelfPos[2];
+            if (bay === shelfBay) {
+                posZByLev = shelfPos[2] + SHELF_BAY_UNIT_SEPARTE_DISTANCE;
+            }
+            if (bay === shelfBay + 1) {
+                posZByLev = shelfPos[2];
+            }
+            if (bay === shelfBay + 2) {
+                posZByLev = shelfPos[2] - SHELF_BAY_UNIT_SEPARTE_DISTANCE;
+            }
 
-            setPos([shelfPos[0], shelfPos[1] + (bay - shelfBay) * 10, shelfPos[2] + (lev - shelfLev) * 100]);
+            setPos([
+                shelfPos[0],
+                shelfPos[1] + SHELF_HEIGHT_FROM_GROUND + (lev - shelfLev) * SHELF_LEV_UNIT_SEPARTE_DISTANCE,
+                posZByLev
+            ]);
             setRotaY(Math.PI / 2);
         } else {
             // from agv

--
Gitblit v1.9.1