#
luxiaotao1123
2024-05-08 19d6c1cbe579409b4fdf77530300b29aa63518d7
src/components/agv.jsx
@@ -14,14 +14,16 @@
} from '../config/setting'
const Agv = (props) => {
    const { agvNo, position, theta, loaderTheta, trayList, hasBox } = props;
    const height = props.height * 0.06;
    const { agvNo, position, trayList, hasBox } = props;
    const theta = -props.theta;
    const height = props.height * 0.04;
    const forkLength = props.forkLength * 0.1;
    const loaderTheta = Number(props.loaderTheta?.toFixed(1));
    const [groupPos, setGroupPos] = useState({ x: 0, y: 0, z: 0 });
    const [groupTheta, setGroupTheta] = useState(0);
    const [loaderHeight, setLoaderHeight] = useState(0);
    const [integrateTheta, setIntegrateTheta] = useState(0);
    const [loaderAngle, setLoaderAngle] = useState(0);
    const [forkDis, setForkDis] = useState(0);
    const [realTrayList, setRealTrayList] = useState([]);
@@ -36,7 +38,7 @@
            y: position?.[1] * REAL_COMPARE_MAP_SCALE,
            z: position?.[0] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_Z,
        }
        if (!Common.deepEqual(groupPos, pos) && props.position) {
        if (!Common.deepEqual(groupPos, pos) && props.position !== null) {
            new TWEEN.Tween(groupPos)
                .to(pos, INTERVAL_TIME)
                .easing(TWEEN.Easing.Linear.None)
@@ -49,10 +51,10 @@
        }
        // group theta
        if (groupTheta !== theta && props.theta) {
            const minTheta = Common.minDiffTheta(groupTheta, theta);
        if (groupTheta !== theta && props.theta !== null) {
            const targetTheta = Common.normalizeAngle(theta - groupTheta) + groupTheta;
            new TWEEN.Tween({ value: groupTheta })
                .to({ value: minTheta }, INTERVAL_TIME)
                .to({ value: targetTheta }, INTERVAL_TIME)
                .easing(TWEEN.Easing.Linear.None)
                .onUpdate((e) => {
                    setGroupTheta(e.value)
@@ -63,7 +65,7 @@
        }
        // loader height
        if (loaderHeight !== height && props.height) {
        if (loaderHeight !== height && props.height !== null) {
            new TWEEN.Tween({ value: loaderHeight })
                .to({ value: height }, INTERVAL_TIME)
                .easing(TWEEN.Easing.Linear.None)
@@ -77,21 +79,23 @@
        // loader theta
        const loaderAbsoluteAngle = (theta + loaderTheta) % 360;
        if (integrateTheta !== loaderAbsoluteAngle && props.loaderTheta) {
            const minTheta = Common.minDiffTheta(integrateTheta, loaderAbsoluteAngle);
            new TWEEN.Tween({ value: integrateTheta })
                .to({ value: minTheta }, INTERVAL_TIME)
        if (loaderAngle !== loaderAbsoluteAngle && props.loaderTheta !== null) {
            const targetTheta = Common.normalizeAngle(loaderAbsoluteAngle - loaderAngle) + loaderAngle;
            new TWEEN.Tween({ value: loaderAngle })
                .to({ value: targetTheta }, INTERVAL_TIME)
                .easing(TWEEN.Easing.Linear.None)
                .onUpdate((e) => {
                    setIntegrateTheta(e.value)
                    setLoaderAngle(e.value)
                })
                .onComplete((e) => {
                    setIntegrateTheta(e.value)
                    setLoaderAngle(e.value)
                }).start();
        }
        // fork lenght
        if (forkDis !== forkLength && props.forkLength) {
        // console.log("forkDis", forkDis);
        // console.log("forkLength", forkLength);
        if (forkDis !== forkLength && props.forkLength !== null) {
            new TWEEN.Tween({ value: forkDis })
                .to({ value: forkLength }, INTERVAL_TIME)
                .easing(TWEEN.Easing.Linear.None)
@@ -149,7 +153,7 @@
                <primitive object={bodyModel} castShadow />
                <group
                    position-y={loaderHeight}
                    rotation-y={Common.rotationParseNum(integrateTheta)}
                    rotation-y={Common.rotationParseNum(loaderAngle)}
                >
                    <primitive object={loaderModel} castShadow position={[0, 20, 0]} />
                    <group position-z={forkDis}>