#
luxiaotao1123
2024-10-23 3af87f4424fda51760188233983cd8d4a4586c50
zy-acs-flow/src/map/insight/agv/AgvMain.jsx
@@ -19,23 +19,36 @@
import ConfirmButton from '../../../page/components/ConfirmButton';
import { grey } from '@mui/material/colors';
let three;
const AgvMain = (props) => {
    const { curAgvNo, curAgvInfo: info, fetchAgvInfo } = props;
    const theme = useTheme();
    const translate = useTranslate();
    const dataProvider = useDataProvider();
    const redirect = useRedirect();
    const notify = useNotification();
    const containerRef = useRef();
    const [loading, setLoading] = useState(true);
    const threeRef = useRef(null);
const startThree = (dom) => {
    three = new AgvThree(dom);
    three.startup();
        if (threeRef.current) {
            threeRef.current.destroy();
        }
        threeRef.current = new AgvThree(dom);
        threeRef.current.startup();
}
const endThree = () => {
    if (three) {
        three.destroy();
        three = null;
        if (threeRef.current) {
            threeRef.current.destroy();
            threeRef.current = null;
    }
}
const renderThree = (curAgvNo) => {
    if (curAgvNo && three) {
        three.generateMesh((loader, addObject) => {
        if (curAgvNo && threeRef.current) {
            threeRef.current.generateMesh((loader, addObject) => {
            const loadModel = (path) => {
                return new Promise((resolve, reject) => {
                    loader.load(path, (mesh) => {
@@ -69,7 +82,7 @@
                addObject(agvGroup);
                three?.rePerspective(350, 450);
                    threeRef.current?.rePerspective(350, 450);
            }).catch((error) => {
                console.error(error);
@@ -78,19 +91,8 @@
    }
}
const AgvMain = (props) => {
    const { curAgvNo, curAgvInfo: info, fetchAgvInfo } = props;
    const theme = useTheme();
    const translate = useTranslate();
    const dataProvider = useDataProvider();
    const redirect = useRedirect();
    const notify = useNotification();
    const containerRef = useRef();
    const [loading, setLoading] = useState(true);
    useEffect(() => {
        if (info) {
            endThree();
            setLoading(true);
            setTimeout(() => {
                startThree(containerRef.current);