From cba0269f489f008b64f9b3a58022ba96bfd4f205 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期三, 24 四月 2024 15:05:55 +0800 Subject: [PATCH] # --- src/assets/data/shelf.js | 54 +++++++++++++++++++-------- src/core/warehouse.jsx | 7 +++ src/components/shelf.jsx | 12 ++++-- 3 files changed, 52 insertions(+), 21 deletions(-) diff --git a/src/assets/data/shelf.js b/src/assets/data/shelf.js index 2ae47ef..4170eb0 100644 --- a/src/assets/data/shelf.js +++ b/src/assets/data/shelf.js @@ -1,25 +1,47 @@ +// row + + +// bay +const realBayPos = [1589, 3540, 5491, 7442, 9393, 11344]; +const mapBayMaxAbs = 500; + +const calBayMapPos = (realPosition, minRealPosition = Math.min(...realBayPos), maxRealPosition = Math.max(...realBayPos), maxMapPosition = mapBayMaxAbs) => { + return ((realPosition - minRealPosition) / (maxRealPosition - minRealPosition)) * (2 * maxMapPosition) - maxMapPosition; +} + +console.log(Math.max(...realBayPos)); + const shelfData = [ { - no: '1-1-1', - position: [0, 0, 0], - rotationY: 0, - }, - { - no: '1-1-1', - position: [100, 0, 0], + no: '3-1-1', + position: [0, 0, calBayMapPos(realBayPos[5])], rotationY: Math.PI / 2, }, { - no: '1-1-1', - position: [100, 0, 100], - rotationY: 0, + no: '3-4-1', + position: [0, 0, calBayMapPos(realBayPos[4])], + rotationY: Math.PI / 2, }, - - // { - // no: '2-1-1', - // position: [100, 0, 0], - // rotationY: Math.PI / 2, - // } + { + no: '3-7-1', + position: [0, 0, calBayMapPos(realBayPos[3])], + rotationY: Math.PI / 2, + }, + { + no: '3-10-1', + position: [0, 0, calBayMapPos(realBayPos[2])], + rotationY: Math.PI / 2, + }, + { + no: '3-13-1', + position: [0, 0, calBayMapPos(realBayPos[1])], + rotationY: Math.PI / 2, + }, + { + no: '3-16-1', + position: [0, 0, calBayMapPos(realBayPos[0])], + rotationY: Math.PI / 2, + }, ]; export default shelfData; diff --git a/src/components/shelf.jsx b/src/components/shelf.jsx index 1626e3c..4c39a50 100644 --- a/src/components/shelf.jsx +++ b/src/components/shelf.jsx @@ -1,11 +1,11 @@ import { useMemo, useState, useEffect } from 'react'; -import { useGLTF } from '@react-three/drei'; +import { useGLTF, useFBX } from '@react-three/drei'; import * as THREE from 'three'; import { MODEL_SHELF_SCALE } from '@/config/setting' import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'; import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'; import Box from './box'; - +import * as Common from '../utils/common'; const Shelf = (props) => { const { position = [0, 300, 0], rotationY = 0 } = props; @@ -17,14 +17,18 @@ return ( <> <group rotation-y={rotationY} position={position}> - <primitive + {/* <primitive castShadow receiveShadow object={nodes.鐗╀欢_1001} material={materials['鏉愯川_1.002']} position={[0, 99, 0]} scale={50000} - /> + /> */} + <mesh position={[0, 100, 0]}> + <boxGeometry args={[150, 200, 30]} /> + <meshStandardMaterial color={'orange'} transparent={true} opacity={.5} /> + </mesh> </group> {/* <Box rotationY={Math.PI / 2} position={[0, 100, -50]} /> <Box rotationY={Math.PI / 2} position={[0, 100, 0]} /> diff --git a/src/core/warehouse.jsx b/src/core/warehouse.jsx index 035b9f3..f1bea49 100644 --- a/src/core/warehouse.jsx +++ b/src/core/warehouse.jsx @@ -28,7 +28,7 @@ const timer = setInterval(() => { const agvRealData = agvRealDataList[index]; if (agvRealData) { - setAgvData(agvRealData); + // setAgvData(agvRealData); } index++; }, INTERVAL_TIME * 1.1); @@ -44,6 +44,10 @@ const shelfEl = useMemo(() => { return shelfData.map((data, index) => <Shelf key={index} {...data} />) + }, []); + + const shelfEl1 = useMemo(() => { + return shelfData.slice(0, 1).map((data, index) => <Shelf key={index} {...data} />) }, []); const agvEl = useMemo(() => { @@ -63,6 +67,7 @@ <group> {tunnelEl} {shelfEl} + {/* {shelfEl1} */} {agvEl} {boxEl} </group> -- Gitblit v1.9.1