|  |  | 
 |  |  | // 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; | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |     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]} /> | 
 
 |  |  | 
 |  |  |         const timer = setInterval(() => { | 
 |  |  |             const agvRealData = agvRealDataList[index]; | 
 |  |  |             if (agvRealData) { | 
 |  |  |                 setAgvData(agvRealData); | 
 |  |  |                 // setAgvData(agvRealData); | 
 |  |  |             } | 
 |  |  |             index++; | 
 |  |  |         }, INTERVAL_TIME * 1.1); | 
 |  |  | 
 |  |  |  | 
 |  |  |     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(() => { | 
 |  |  | 
 |  |  |             <group> | 
 |  |  |                 {tunnelEl} | 
 |  |  |                 {shelfEl} | 
 |  |  |                 {/* {shelfEl1} */} | 
 |  |  |                 {agvEl} | 
 |  |  |                 {boxEl} | 
 |  |  |             </group> |