#
luxiaotao1123
2024-04-23 ac3a17007eba343238d4b8916e46d64c58b0db9c
#
4个文件已修改
476 ■■■■■ 已修改文件
src/assets/data/agv.js 432 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/agv.jsx 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/box.jsx 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/config/setting.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/data/agv.js
@@ -7,7 +7,32 @@
            height: 0,
            loaderTheta: 0,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: false
        }
    ],
@@ -19,7 +44,32 @@
            height: 0,
            loaderTheta: 0,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: false
        }
    ],
@@ -31,7 +81,32 @@
            height: 0,
            loaderTheta: 0,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: false
        }
    ],
@@ -43,7 +118,32 @@
            height: 100,
            loaderTheta: 0,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: false
        }
    ],
@@ -55,7 +155,32 @@
            height: 150,
            loaderTheta: 0,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: false
        }
    ],
@@ -67,7 +192,32 @@
            height: 200,
            loaderTheta: 0,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: false
        }
    ],
@@ -79,7 +229,32 @@
            height: 100,
            loaderTheta: 0,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: false
        }
    ],
@@ -91,7 +266,32 @@
            height: 100,
            loaderTheta: 0,
            forkLength: 40,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: false
        }
    ],
@@ -103,7 +303,32 @@
            height: 100,
            loaderTheta: 0,
            forkLength: 40,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: true
        }
    ],
@@ -115,7 +340,32 @@
            height: 100,
            loaderTheta: 0,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: true
        }
    ],
@@ -127,7 +377,32 @@
            height: 0,
            loaderTheta: 0,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: true
        }
    ],
@@ -139,7 +414,32 @@
            height: 0,
            loaderTheta: 270,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: true
        }
    ],
@@ -151,7 +451,32 @@
            height: 0,
            loaderTheta: 270,
            forkLength: 40,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: false
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: true
        }
    ],
@@ -163,7 +488,32 @@
            height: 0,
            loaderTheta: 270,
            forkLength: 40,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: true
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: false
        }
    ],
@@ -175,7 +525,32 @@
            height: 0,
            loaderTheta: 270,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: true
                },
                {
                    no: 2,
                    hasBox: false
                },
                {
                    no: 3,
                    hasBox: false
                },
                {
                    no: 4,
                    hasBox: false
                },
                {
                    no: 5,
                    hasBox: false
                },
                {
                    no: 6,
                    hasBox: false
                },
            ],
            hasBox: false
        }
    ],
@@ -187,7 +562,32 @@
            height: 0,
            loaderTheta: 0,
            forkLength: 0,
            trayList: [],
            trayList: [
                {
                    no: 1,
                    hasBox: true
                },
                {
                    no: 2,
                    hasBox: true
                },
                {
                    no: 3,
                    hasBox: true
                },
                {
                    no: 4,
                    hasBox: true
                },
                {
                    no: 5,
                    hasBox: true
                },
                {
                    no: 6,
                    hasBox: true
                },
            ],
            hasBox: false
        }
    ],
src/components/agv.jsx
@@ -20,6 +20,7 @@
        if (!props || Object.keys(props).length === 0) {
            return;
        }
        // group position
        const pos = {
            x: position?.[0],
@@ -67,9 +68,7 @@
        // loader theta
        if (integrateTheta !== loaderTheta) {
            console.log(integrateTheta, loaderTheta);
            const minTheta = Common.minDiffTheta(integrateTheta, loaderTheta);
            console.log(minTheta);
            new TWEEN.Tween({ value: integrateTheta })
                .to({ value: minTheta }, INTERVAL_TIME)
                .easing(TWEEN.Easing.Linear.None)
@@ -144,6 +143,14 @@
                        {hasBox && <Box position={[0, 24, 0]} />}
                    </group>
                </group>
                <group>
                    {trayList?.[0]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 25, 0]} />}
                    {trayList?.[1]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 48, 0]} />}
                    {trayList?.[2]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 71, 0]} />}
                    {trayList?.[3]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 94, 0]} />}
                    {trayList?.[4]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 117, 0]} />}
                    {trayList?.[5]?.hasBox && <Box rotationY={Math.PI / 2} position={[-43, 140, 0]} />}
                </group>
            </group>
        </>
    )
src/components/box.jsx
@@ -2,37 +2,18 @@
import { useFrame } from '@react-three/fiber';
import { useFBX, useAnimations } from '@react-three/drei';
import * as THREE from 'three';
const setShadow = (obj) => {
    obj.castShadow = true;
    obj.receiveShadow = true;
    if (obj.children) {
        obj.children.forEach((child) => {
            setShadow(child);
        });
    }
};
const setColor = (obj) => {
    if (obj.material) {
        obj.material.color.set(0x4680BF);
    }
    if (obj.children) {
        obj.children.forEach((child) => {
            setColor(child);
        });
    }
};
import { MODEL_BOX_SCALE } from '@/config/setting'
import * as Common from '../utils/common';
const Box = (props) => {
    const { position = [0, 300, 0] } = props;
    const { position = [0, 300, 0], rotationY = 0 } = props;
    const boxModel = useMemo(() => {
        const fbx = useFBX('/models/box/box.fbx');
        if (!fbx.castShadow) {
            setShadow(fbx);
            Common.setShadow(fbx);
        }
        fbx.scale.set(MODEL_BOX_SCALE, MODEL_BOX_SCALE, MODEL_BOX_SCALE);
        return fbx.clone();
    }, [])
@@ -42,7 +23,7 @@
    return (
        <>
            <group rotation={[0, 0, 0]} scale={0.5} position={position}>
            <group rotation-y={rotationY} scale={0.5} position={position}>
                <primitive object={boxModel} castShadow />
            </group>
        </>
src/config/setting.js
@@ -9,3 +9,5 @@
export const INTERVAL_TIME = 500;
export const MODEL_AGV_SCALE = .5;
export const MODEL_BOX_SCALE = 1;