#
luxiaotao1123
2024-04-22 073cd20230a7c4d8b7c771ce227e3101813638fc
#
1个文件已添加
3个文件已修改
121 ■■■■■ 已修改文件
src/assets/data/agv.js 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/agv.jsx 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/warehouse.jsx 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/common.js 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/data/agv.js
@@ -0,0 +1,74 @@
export default [
    [
        {
            no: 1,
            position: [0, 0, 0],
            theta: 0,
            height: 100,
            loaderTheta: 180,
            forkLength: 0,
            trayList: [],
            hasBox: false
        }
    ],
    [
        {
            no: 1,
            position: [100, 0, 0],
            theta: 0,
            height: 100,
            loaderTheta: 180,
            forkLength: 0,
            trayList: [],
            hasBox: false
        }
    ],
    [
        {
            no: 1,
            position: [100, 0, 0],
            theta: 90,
            height: 100,
            loaderTheta: 180,
            forkLength: 0,
            trayList: [],
            hasBox: false
        }
    ],
    [
        {
            no: 1,
            position: [100, 0, 200],
            theta: 90,
            height: 100,
            loaderTheta: 180,
            forkLength: 0,
            trayList: [],
            hasBox: false
        }
    ],
    [
        {
            no: 1,
            position: [100, 0, 300],
            theta: 90,
            height: 100,
            loaderTheta: 180,
            forkLength: 0,
            trayList: [],
            hasBox: false
        }
    ],
    [
        {
            no: 1,
            position: [100, 0, 300],
            theta: 90,
            height: 100,
            loaderTheta: 180,
            forkLength: 0,
            trayList: [],
            hasBox: false
        }
    ],
]
src/components/agv.jsx
@@ -3,6 +3,7 @@
import { useFBX, useAnimations } from '@react-three/drei';
import * as THREE from 'three';
import Box from './box';
import * as Common from '../utils/common'
const setShadow = (obj) => {
    obj.castShadow = true;
@@ -27,7 +28,12 @@
};
const Agv = (props) => {
    const { } = props;
    const { position, theta } = props;
    useEffect(() => {
        console.log(position);
        console.log(theta);
    }, [props]);
    const bodyModel = useMemo(() => {
        const fbx = useFBX('/models/agv/body.fbx');
@@ -54,12 +60,11 @@
    }, [])
    useEffect(() => {
    }, []);
    return (
        <>
            <group rotation={[0, 0, 0]} scale={0.5} position={[0, 0, 0]}>
            <group rotation-y={Common.rotationParseNum(theta)} scale={0.5} position={position}>
                <primitive object={bodyModel} castShadow />
                <primitive object={loaderModel} castShadow position={[0, 100, 0]} />
                <primitive object={forkModel} castShadow position={[0, 120, 0]} />
src/core/warehouse.jsx
@@ -5,6 +5,9 @@
import Box from '../components/box';
import tunnelData from '../assets/data/tunnel';
import Tunnel from '../components/tunnel';
import agvRealDataList from '@/assets/data/agv'
let index = 0;
const Warehouse = (props) => {
@@ -18,6 +21,13 @@
    useEffect(() => {
        setInterval(() => {
            const agvRealData = agvRealDataList[index];
            if (agvRealData) {
                setAgvData(agvRealData);
            }
            index++;
        }, 2000)
    }, [])
    const tunnelEl = useMemo(() => {
@@ -29,8 +39,7 @@
    const boxEl = boxData.map((data, idx) => <Box key={idx} {...data} />)
    useFrame((state, delta) => {
        // setAgvData();
        // setBoxData();
    })
    return (
src/utils/common.js
New file
@@ -0,0 +1,23 @@
import * as THREE from 'three';
export const isNullOfUndefined = (param) => {
    if (null === param || undefined === param) {
        return true;
    } else {
        return false;
    }
}
export const rotationToNum = (rotation) => {
    let res = rotation * 180 / Math.PI;
    if (res < 0) {
        res += 360;
    } else if (res > 360) {
        res -= 360;
    }
    return res;
}
export const rotationParseNum = (num) => {
    return num * Math.PI / 180;
}