#
luxiaotao1123
2024-04-26 9121586a22ea00ec4a3ef873c621dab8840508e4
#
1个文件已修改
34 ■■■■ 已修改文件
src/components/box.jsx 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/box.jsx
@@ -6,10 +6,28 @@
import * as Common from '../utils/common';
import { useStore } from '@/store';
const getShelfRow = (row) => {
    return row;
}
const getShelfBay = (bay) => {
    return bay - (bay - 1) % 3;
}
const getShelfLev = (lev) => {
    return 1;
}
const getShelfNo = (row, bay, lev) => {
    return getShelfRow(row) + '-' + getShelfBay(bay) + '-' + getShelfLev(lev);
}
const Box = (props) => {
    const { position = [0, 300, 0], rotationY = 0 } = props;
    const { row, bay, lev, position = [0, 300, 0], rotationY = 0 } = props;
    const state = useStore();
    const [pos, setPos] = useState([]);
    const boxModel = useMemo(() => {
        const fbx = useFBX('/models/box/box.fbx');
        if (!fbx.castShadow) {
@@ -20,12 +38,20 @@
    }, [])
    useEffect(() => {
        console.log(state.shelfList['1-1-1']);
        if (row && bay && lev) {
            // from shelf
            const shelfNo = getShelfNo(row, bay, lev);
            const shelfPos = state.shelfList[shelfNo];
            setPos(shelfPos);
        } else {
            // from agv
            setPos(position);
        }
    }, [props]);
    return (
        <>
            <group rotation-y={rotationY} position={position}>
            <group rotation-y={rotationY} position={pos}>
                <primitive object={boxModel} castShadow />
            </group>
        </>