#
luxiaotao1123
2024-04-24 cba0269f489f008b64f9b3a58022ba96bfd4f205
#
3个文件已修改
73 ■■■■ 已修改文件
src/assets/data/shelf.js 54 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/shelf.jsx 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/warehouse.jsx 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
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]} />
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>