<!-- 实现具体3d逻辑使用 -->
<script setup lang="ts">
import CourseChapter3dMain from '@/components/student/CourseChapter3dMain.vue';
import { threeWorld } from "@/stores/threeWorld.ts";
import { courseChapter3dShow } from "@/stores/courseChapter3dShow.ts";
import { HighlightLayerEvent } from "@/components/student/event/HighlightLayerEvent.ts";
import { DragAndDropEvent } from "@/components/student/event/DragAndDropEvent.ts";
import { TypeViewEvent } from "@/components/student/event/TypeViewEvent.ts";
import { RenderEvent } from "@/components/student/event/RenderEvent.ts";
import { ref, watch } from "vue";

const props = defineProps({

    config : {
        type: Object
    },
    // 获取当前学生任务ID缺陷列表
    studentTaskIdList : {
        type: Object
    },

});

// 定义发射给父组件的方法
const emits = defineEmits([
    // 上一步是否显示
    'tipsBtnsUpOpen',
    // 下一步是否显示
    'tipsBtnsDownOpen',
]);

// setInterval(function() {
//     console.log(
//         "3d场景参数", props.config
//     );
// }, 1000);

// 处理哪些物体显示高光效果
let objHighlightLayerEvent = new HighlightLayerEvent();
// 处理指定物体拖拽逻辑
let objDragAndDropEvent = new DragAndDropEvent();
// 根据配置的流程切换对应的3d界面逻辑
let objTypeViewEvent = new TypeViewEvent();
// 3d渲染帧事件处理
let objRenderEvent = new RenderEvent();

// // 【开发的时候】3d场景,iframe地址
// let threeWorldUrl = "3dMain/index.html#/main?id=zidingyi";

// babylon 对象
let BABYLON : any = null;

// let commonconfig = "http://localhost:5173/3dMain/model2/";
// let commonmodel = "http://localhost:5173/3dMain/model2/";

// let threeWorldUrl = "3dMain/index.html#/main?id=zidingyi_lu_cun&user=zidingyi"
// + '&commonconfig=' + commonconfig
// + '&commonmodel=' + commonmodel;

// // 【发布的时候】3d场景,iframe地址
// // 配置文件地址
// // let commonconfig = "https://www.3dyzt.com/eduTrain/3dMain/model/";
// let commonconfig = "https://www.3dyzt.com/ShiZhengGuanWangZhiNengJianCeYuWeiHu/user_web/3dMain/model2/";// 正式
// // let commonconfig = "https://www.3dyzt.com/eduTrain/3dMain/model3/";// 临时测试
// // 模型地址
// // let commonmodel = "https://www.3dyzt.com/eduTrain/3dMain/model/";
// let commonmodel = "https://www.3dyzt.com/ShiZhengGuanWangZhiNengJianCeYuWeiHu/user_web/3dMain/model2/";// 正式
// // let commonmodel = "https://www.3dyzt.com/eduTrain/3dMain/model3/";// 临时测试


// // 发布后的地址
// let threeWorldUrl = "https://www.3dyzt.com/main/index.html#/main?id=zidingyi&user=zidingyi&commonconfig=" + commonconfig + "&commonmodel=" + commonmodel;

let threeWorldHost = import.meta.env.VITE_APP_THREE_WORLD_URL;

// let commonconfig = threeWorldHost + "3dMain/model2/";
// let commonmodel = threeWorldHost + "3dMain/model2/";

let commonconfig = threeWorldHost + "3dMain/model_cctv/";
let commonmodel = threeWorldHost + "3dMain/model_cctv/";

let threeWorldUrl = "3dMain/index.html#/main?id=zidingyi_lu_cun&user=zidingyi"
+ '&commonconfig=' + commonconfig
+ '&commonmodel=' + commonmodel;

/**
 * 上一步是否显示
 * open     true - 显示， false - 隐藏
 */
const tipsBtnsUpOpenEvent = (open : Boolean) => {
    emits('tipsBtnsUpOpen', open);
}

/**
 * 下一步是否显示
 * open     true - 显示， false - 隐藏
 */
const tipsBtnsDownOpenEvent = (open : Boolean) => {
    emits('tipsBtnsDownOpen', open);
    
}

// 记录当前的流程
let thisFlowPath : any = null;
// 记录最后一次播放完成的状态
let thisFlowPathEnd : any = null;

/**
 * 监听发送参数变化，流程完成的时候
 */
watch(
    () => courseChapter3dShow().show.showEndViewBool,
    (newVal, oldVal) => {

        // console.log(
        //     newVal, oldVal,
        //     props.config
        // );
        
        // 如果没有加载完成，则不触发后面的逻辑
        if (courseChapter3dShow().show.showEndViewBool == false) {
            return;
        }

        if (thisFlowPathEnd != thisFlowPath) {

            thisFlowPathEnd = thisFlowPath;

            // 启动播放声音
            objTypeViewEvent.musicConfigPlay(
                thisFlowPath, "end"
            );

        }

    }
);


/**
 * 监听发送参数变化，来控制切换3d的逻辑
 */
watch(
    () => props.config,
    (newVal, oldVal) => {

        // console.log(
        //     newVal, oldVal,
        //     props.config
        // );
        
        // 如果没有加载完成，则不触发后面的逻辑
        if (threeWorld().loadSuccess == false) {
            return;
        }

        typeEvent(props.config?.threeDimensionalConfig);

    }
);

/**
 * 监听弹出提示隐藏后来触发不同的逻辑
 */
watch(
    () => courseChapter3dShow().show.showToastViewBool,
    (newVal, oldVal) => {

        if (courseChapter3dShow().show.showToastViewBool == true) {
            return;
        }
        
        console.log(
            " () => courseChapter3dShow().show.showToastState 2222222222 ",
            courseChapter3dShow().show.showToastState
        );

        switch (courseChapter3dShow().show.showToastState) {
            case '立即穿戴':
                objTypeViewEvent.workRoleClothingUpdate("yes", false);
                break;

            case '去摆放':
                console.log(
                    "去摆放触发了 animationSecurityZoneStart(安全桩001|西区实训基地-烘|BaseLayer)",
                    courseChapter3dShow().show.showToastViewBool
                );

                objTypeViewEvent.animationSecurityZoneStart("安全桩001|西区实训基地-烘|BaseLayer");
                break;

            case '将抬升支架降至最低':

                // @ts-ignore
                threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("相机上升");
                // @ts-ignore
                threeWorld().obj.newIframe.roleShow(false);

                // @ts-ignore
                threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
                    "主机升降", 'start', 1, null, null, false, null, function(state : any, objAnimation : any) {

                        if (state == "播放完成") {
                            
                        }
                        
                    }
                );

                break;

            case '镜头旋转至正上方':

                // @ts-ignore
                threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("镜头归位");
                // @ts-ignore
                threeWorld().obj.newIframe.roleShow(false);

                // @ts-ignore
                threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
                    "相机", 'start', 1, 0, 60, false, null, function(state : any, objAnimation : any) {

                        if (state == "播放完成") {
                            
                        }
                        
                    }
                );

                break;

            case '摆放线缆盘线缆盘方向与爬行器爬行的方向一致':

                // @ts-ignore
                threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("连接电缆");
                // @ts-ignore
                threeWorld().obj.newIframe.roleShow(false);

                // @ts-ignore
                threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
                    "电缆拔出", 'start', 1, null, null, false, null, function(state : any, objAnimation : any) {

                        if (state == "播放完成") {
                            
                        }
                        
                    }
                );
                
                break;

            case '镜头归位':

                // @ts-ignore
                threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("镜头归位");
                // @ts-ignore
                threeWorld().obj.newIframe.roleShow(false);

                // @ts-ignore
                threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
                    "相机", 'start', 1, 60, 240, false, null, function(state : any, objAnimation : any) {

                        if (state == "播放完成") {
                            
                        }
                        
                    }
                );

                break;

            case '调节行驶方向正确放置过线滑轮':


                // @ts-ignore
                threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("相机上升");
                // @ts-ignore
                threeWorld().obj.newIframe.roleShow(false);

                // @ts-ignore
                threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
                    "轮子滚动", 'start', 1, null, null, false, null, function(state : any, objAnimation : any) {

                        if (state == "播放完成") {
                            
                        }
                        
                    }
                );

                break;
            
        }
        
    }
);

/**
 * 监听发送参数变化
 * 控制主光强度
 */
watch(
    () => courseChapter3dShow().show.lightMain,
    (newVal, oldVal) => {
        
        // 如果没有加载完成，则不触发后面的逻辑
        if (threeWorld().loadSuccess == false) {
            return;
        }

        // 最大强度值
        // let intensityMax = 99999 * 2;
        // let intensityMax = 200 * 2;
        // let intensityMax = 100 * 2;
        let intensityMax = 100;
        let newIntensity = courseChapter3dShow().show.lightMain / 100 * intensityMax;
        objTypeViewEvent.spotLightCameraUpdateConfig(newIntensity);

        
    }
);

/**
 * 监听发送参数变化
 * 控制辅光强度
 */
watch(
    () => courseChapter3dShow().show.lightAssist,
    (newVal, oldVal) => {
        
        // 如果没有加载完成，则不触发后面的逻辑
        if (threeWorld().loadSuccess == false) {
            return;
        }

        // 最大强度值
        // let intensityMax = 999 * 1;
        // let intensityMax = 800 * 1;
        // let intensityMax = 10;
        let intensityMax = 8;
        let newIntensity = courseChapter3dShow().show.lightAssist / 100 * intensityMax;
        objTypeViewEvent.pointLightCameraUpdateConfig(newIntensity);
        
    }
);

/**
 * 回调加载百分比
 */
const callbackLoadPercentageEvent = (json: { loadPercentage: any; }) => {
    // console.log("回调加载百分比", json)
    const loadPercentage = parseFloat(json["loadPercentage"]);
    // 加载小于百分比
    if (loadPercentage < 100) {

        // ##############################【这里只做控制】隐藏其他按钮界面等
        threeWorld().loadSuccess = false;
        goPlayCallbackEventMain();
        return
    }
}

/**
 * 回调加载完成
 */
const callbackLoadEndEvent = (json : { 'roleChoiceOpenBool' : true }) => {
    // console.log("回调加载完成", json)

    // 此时是显示角色的界面
    if (json["roleChoiceOpenBool"] === true) {
        // ############################## 隐藏其他按钮界面等
        threeWorld().loadSuccess = false;
        
        return;
    }

    // ############################## 这个时候，是真正的进入3d画面了，才显示其他按钮界面等
    threeWorld().loadSuccess = true;
    // @ts-ignore
    BABYLON = threeWorld().obj.newIframe.objIframe.BABYLON;

    objHighlightLayerEventInit();
    objDragAndDropEventInit();
    objTypeViewEventInit();
    objRenderEventInit();

    threeEvent();
    animationAllFpsToZero();
    pipelineProblemsJsonInitEvent();
    birthPointInit();
    carMoveSpeedInitEvent();

    // @ts-ignore 设置鼠标右键平移
    threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CameraArray.find().jsonCamera.panningSensibility = 8;
    // @ts-ignore
    threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CameraArray.find().activeCameraConfigUpdate();
    
    try {
        
        // 更新角色的固定皮肤
        // @ts-ignore
        let roleCode = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().roleCode;
        // @ts-ignore
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().roleCodeAllConfig[roleCode]["skinUpdate"] = "exhibition_html_1709861931375_";

    } catch (e) {

    }

    // @ts-ignore
    threeWorld().obj.newIframe.roleShow(true);
    // @ts-ignore 解决角色有时候出现不了的问题
    threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.EventMoveRole.find().roleRotationYMove(180);

    setTimeout(function() {

        initScene();

        getRndArrayDemoEvent();

        workRoleTexture();

    }, 3000);
    
}

/**
 * 回调距离范围内
 */
const callbackDistanceYesEvent = (json : any) => {
    // console.log("回调距离范围内", json);
}

/**
 * 回调距离范围外
 */
const callbackDistanceNoEvent = (json : any) => {
    // console.log("回调距离范围外", json);
}

/**
 * 回调视角切换完成
 */
const callbackCameraVisualAngleJsonToLookEvent = (json : any) => {
    // console.log("视角触发完成", json);
}

/**
 * 记录出生点
 */
const birthPointInit = () => {

    courseChapter3dShow().show.birthPoint = {};
    // @ts-ignore
    for (let i = 0; i < threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonBirthplace.find().list.length; i++) {
        // @ts-ignore
        let json = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonBirthplace.find().list[i];
        // console.log(
        //     "json", json
        // );

        // @ts-ignore
        courseChapter3dShow().show.birthPoint[json.name] = json;

    }

    // console.log(
    //     "courseChapter3dShow().show.birthPoint = {};",
    //     courseChapter3dShow().show.birthPoint
    // );
    
}

/**
 * 记录3d里配置的移动速度
 */
const carMoveSpeedInitEvent = () => {

    // // @ts-ignore
    // let objRoleConfig = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().roleCodeAllConfig[
    //     // @ts-ignore
    //     threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().roleCode
    // ];

    // @ts-ignore
    let roleConfig = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().roleConfig;
    
    courseChapter3dShow().show.carMoveSpeed = parseFloat("" + roleConfig.speedMove);

    // console.log(
    //     "roleConfig",
    //     roleConfig,
    //     "courseChapter3dShow().show.carMoveSpeed",
    //     courseChapter3dShow().show.carMoveSpeed
    // );
    
}

/**
 * 初始化 处理高光效果的对象
 */
const objHighlightLayerEventInit = () => {
    
    // @ts-ignore
    objHighlightLayerEvent.BABYLON = threeWorld().obj.newIframe.objIframe.BABYLON;
    // @ts-ignore
    objHighlightLayerEvent.ChengGuangYuanJing = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing;
    // @ts-ignore
    objHighlightLayerEvent.objIframe = threeWorld().obj.newIframe.objIframe;

    // 设置回调方法
    objHighlightLayerEvent.tipsBtnsUpOpenEventCallback = function(open : Boolean) {
        tipsBtnsUpOpenEvent(open);
    }

    objHighlightLayerEvent.tipsBtnsDownOpenEventCallback = function(open : Boolean) {
        tipsBtnsDownOpenEvent(open);
    }
    
}

/**
 * 初始化 处理指定物体拖拽逻辑
 */
const objDragAndDropEventInit = () => {
    
    // @ts-ignore
    objDragAndDropEvent.BABYLON = threeWorld().obj.newIframe.objIframe.BABYLON;
    // @ts-ignore
    objDragAndDropEvent.ChengGuangYuanJing = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing;
    // @ts-ignore
    objDragAndDropEvent.objIframe = threeWorld().obj.newIframe.objIframe;

    objDragAndDropEvent.objHighlightLayerEvent = objHighlightLayerEvent;

    // 设置回调方法
    objDragAndDropEvent.tipsBtnsUpOpenEventCallback = function(open : Boolean) {
        tipsBtnsUpOpenEvent(open);
    }

    objDragAndDropEvent.tipsBtnsDownOpenEventCallback = function(open : Boolean) {
        tipsBtnsDownOpenEvent(open);
    }
    
}

/**
 * 初始化 根据配置的流程切换对应的3d界面逻辑
 */
const objTypeViewEventInit = () => {
    
    // @ts-ignore 记录该对象，全局使用
    courseChapter3dShow().show.objTypeViewEvent = objTypeViewEvent;

    // @ts-ignore
    objTypeViewEvent.BABYLON = threeWorld().obj.newIframe.objIframe.BABYLON;
    // @ts-ignore
    objTypeViewEvent.ChengGuangYuanJing = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing;
    // @ts-ignore
    objTypeViewEvent.objIframe = threeWorld().obj.newIframe.objIframe;

    objTypeViewEvent.objHighlightLayerEvent = objHighlightLayerEvent;

    // 设置回调方法
    objTypeViewEvent.tipsBtnsUpOpenEventCallback = function(open : Boolean) {
        tipsBtnsUpOpenEvent(open);
    }

    objTypeViewEvent.tipsBtnsDownOpenEventCallback = function(open : Boolean) {
        tipsBtnsDownOpenEvent(open);
    }
    
    objTypeViewEvent.musicConfig = {

        "请走到工作区域" : {

            // 进入流程播放如何完成任务的声音
            // "start" : new URL("./../../assets/music/demo.mp3", import.meta.url).href,
            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startgongzuoquyu.mp3", import.meta.url).href,
            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startgongzuoquyu.mp3", import.meta.url).href,
            // 完成任务播放的声音
            // "end" : new URL("./../../assets/music/demo2.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endgongzuoquyu.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endgongzuoquyu.mp3", import.meta.url).href,
        },
        "请点击人物进行穿搭衣服" : {
            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startgongzuofu.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endgongzuofu.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startgongzuofu.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endgongzuofu.mp3", import.meta.url).href,

        },
        "将四个安全桩放置到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startanquanzhuang.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endanquanzhuang.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startanquanzhuang.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endanquanzhuang.mp3", import.meta.url).href,

        },
        "将盒子拆开把设备拿出来" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startxiangzi.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endxiangzi.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startxiangzi.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endxiangzi.mp3", import.meta.url).href,

        },
        "将盒子拆开把设备放置在安全的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startxiangzi.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endxiangzi.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startxiangzi.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endxiangzi.mp3", import.meta.url).href,

        },

        "将检测机器人6寸轮子安装到正确位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startsixlunzi.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endsixlunzi.mp3.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startsixlunzi.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endsixlunzi.mp3", import.meta.url).href,

        },
        "将检测机器人的轮子安装到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/starttenlunzi.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/enttenlunzi.mp3.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/starttenlunzi.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/enttenlunzi.mp3", import.meta.url).href,

        },

        "将检测机器人6寸右侧轮子安装到正确位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio_1/startSixChunLunZiYouChe.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio_1/endSixChunLunZiYouChe.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startSixChunLunZiYouChe.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endSixChunLunZiYouChe.mp3", import.meta.url).href,

        },
        "将检测机器人6寸左侧轮子安装到正确位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio_1/startSixChunLunZiZuoChe.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio_1/endSixChunLunZiZuoChe.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startSixChunLunZiZuoChe.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endSixChunLunZiZuoChe.mp3", import.meta.url).href,

        },
        "将检测机器人10寸右侧轮子安装到正确位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio_1/startTenChunLunZiYouChe.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio_1/endTenChunLunZiYouChe.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startTenChunLunZiYouChe.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endTenChunLunZiYouChe.mp3", import.meta.url).href,

        },
        "将检测机器人10寸左侧轮子安装到正确位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio_1/startTenChunLunZiZuoChe.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio_1/endTenChunLunZiZuoChe.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startTenChunLunZiZuoChe.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endTenChunLunZiZuoChe.mp3", import.meta.url).href,

        },
        
        "将检测机器人的防撞杆安装到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startfangzhuanggan.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endfangzhuanggan.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startfangzhuanggan.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endfangzhuanggan.mp3", import.meta.url).href,

        },
        "将检测机器人的防撞杆锁安装到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startfangzhuanggansuo.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endfangzhuanggansuo.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startfangzhuanggansuo.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endfangzhuanggansuo.mp3", import.meta.url).href,

        },
        "将检测机器人的镜头架安装到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startxiangji.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endxiangji.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startxiangji.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endxiangji.mp3", import.meta.url).href,

        },
        "将检测机器人的相机安装到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startxiangji.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endxiangji.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startxiangji.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endxiangji.mp3", import.meta.url).href,

        },
        "将绕线车的电源线安装到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startdianyuanxian.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/enddianyuanxian.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startdianyuanxian.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/enddianyuanxian.mp3", import.meta.url).href,

        },
        "将绕线车的纠偏轮安装到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startjiupianlun.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endjiupianlun.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startjiupianlun.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endjiupianlun.mp3", import.meta.url).href,

        },
        "将绕线车的锂电池安装到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startlidianchi.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endlidianchi.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startlidianchi.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endlidianchi.mp3", import.meta.url).href,

        },
        "将绕线车的电脑主机放置到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startdiannaozhuji.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/enddiannaozhuji.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startdiannaozhuji.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/enddiannaozhuji.mp3", import.meta.url).href,

        },
        "将绕线车的手柄安装到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startCaoZuoShouBin.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endCaoZuoShouBin.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startCaoZuoShouBin.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endCaoZuoShouBin.mp3", import.meta.url).href,

        },
        "将绕线车的电缆安装到正确的位置" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startDianLan.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endDianLan.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startDianLan.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endDianLan.mp3", import.meta.url).href,

        },
        "抬升支架降至最低" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startZhiJia.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endZhiJia.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startZhiJia.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endZhiJia.mp3", import.meta.url).href,

        },
        "镜头旋转至正上方" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startXiangJiShang.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endXiangJiShang.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startXiangJiShang.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endXiangJiShang.mp3", import.meta.url).href,

        },
        "镜头归位" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startXiangJiGuiWei.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endXiangJiGuiWei.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startXiangJiGuiWei.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endXiangJiGuiWei.mp3", import.meta.url).href,

        },
        "调节行驶方向正确放置过线滑轮" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startXingShiFangXiang.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endXingShiFangXiang.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startXingShiFangXiang.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endXingShiFangXiang.mp3", import.meta.url).href,

        },
        "打开井盖" : {

            // "start" : new URL("./../../assets/music/threeWorld/tts_audio/startJingGai.mp3", import.meta.url).href,
            // "end" : new URL("./../../assets/music/threeWorld/tts_audio/endJingGai.mp3", import.meta.url).href,

            "start" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/startJingGai.mp3", import.meta.url).href,
            "end" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/endJingGai.mp3", import.meta.url).href,

        },
        "车辆超速" : {
            // "carSpeeding" : new URL("./../../assets/music/threeWorld/tts_audio_1/chaoSuTiXing.mp3", import.meta.url).href,
            "carSpeeding" : new URL("./../../assets/music/threeWorld/tts_audio_04_09/chaoSuTiXing.mp3", import.meta.url).href,
        },

        "爬行器" : {
            "introduce" : new URL("./../../assets/music/audio/paXingQi.mp3", import.meta.url).href,
        },

        "爬行器_LED前灯" : {
            "introduce" : new URL("./../../assets/music/audio/paXingQiLedQianDeng.mp3", import.meta.url).href,
        },

        "爬行器_防撞杆" : {
            "introduce" : new URL("./../../assets/music/audio/paXingQiFangZhuangGan.mp3", import.meta.url).href,
        },

        "爬行器_后置相机" : {
            "introduce" : new URL("./../../assets/music/audio/paXingQiHouZhiXiangJi.mp3", import.meta.url).href,
        },

        "爬行器_检测车身" : {
            "introduce" : new URL("./../../assets/music/audio/paXingQiJianCheCheShen.mp3", import.meta.url).href,
        },

        "爬行器_连接线缆" : {
            "introduce" : new URL("./../../assets/music/audio/paXingQiLianJieXianLan.mp3", import.meta.url).href,
        },

        "爬行器_轮子" : {
            "introduce" : new URL("./../../assets/music/audio/paXingQiLunZi.mp3", import.meta.url).href,
        },

        "爬行器_前置相机" : {
            "introduce" : new URL("./../../assets/music/audio/paXingQiQianZhiXiangJi.mp3", import.meta.url).href,
        },

        "爬行器_升降支架" : {
            "introduce" : new URL("./../../assets/music/audio/paXingQiShengJiangZhiJia.mp3", import.meta.url).href,
        },

        "线缆卷盘" : {
            "introduce" : new URL("./../../assets/music/audio/xianLanJuanPan.mp3", import.meta.url).href,
        },

        "线缆卷盘_电源连线" : {
            "introduce" : new URL("./../../assets/music/audio/xianLanJuanPanDianYuanLianXian.mp3", import.meta.url).href,
        },

        "线缆卷盘_控制手柄" : {
            "introduce" : new URL("./../../assets/music/audio/xianLanJuanPanKongZhiShouBing.mp3", import.meta.url).href,
        },

        "线缆卷盘_控制终端" : {
            "introduce" : new URL("./../../assets/music/audio/xianLanJuanPanKongZhiZhongDuan.mp3", import.meta.url).href,
        },

        "线缆卷盘_锂电池" : {
            "introduce" : new URL("./../../assets/music/audio/xianLanJuanPanLiDianChi.mp3", import.meta.url).href,
        },

        "线缆卷盘_连接线缆" : {
            "introduce" : new URL("./../../assets/music/audio/xianLanJuanPanLianJieXianLan.mp3", import.meta.url).href,
        },
        
    }
    
}

/**
 * 初始化 3d渲染帧事件处理
 */
const objRenderEventInit = () => {
    
    // @ts-ignore
    objRenderEvent.BABYLON = threeWorld().obj.newIframe.objIframe.BABYLON;
    // @ts-ignore
    objRenderEvent.ChengGuangYuanJing = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing;
    // @ts-ignore
    objRenderEvent.objIframe = threeWorld().obj.newIframe.objIframe;

    // 设置回调方法
    objRenderEvent.tipsBtnsUpOpenEventCallback = function(open : Boolean) {
        tipsBtnsUpOpenEvent(open);
    }

    objRenderEvent.tipsBtnsDownOpenEventCallback = function(open : Boolean) {
        tipsBtnsDownOpenEvent(open);
    }
    
}


setInterval(function() {

    // 如果没有加载完成，则不触发后面的逻辑
    if (threeWorld().loadSuccess == false) {
        return;
    }

    // 更新时间
    var cur = new Date(); // 创建当前日期对象 cur
    var years = cur.getFullYear(); // 从日期对象cur中取得年数
    var months = cur.getMonth() + 1; // 取得月数
    var days = cur.getDate(); // 取得天数
    var hours = cur.getHours(); // 取得小时数
    var minutes = cur.getMinutes(); // 取得分钟数

    courseChapter3dShow().show.showCarEyeYears = years;
    courseChapter3dShow().show.showCarEyeMonths = months;
    courseChapter3dShow().show.showCarEyeDays = days;
    courseChapter3dShow().show.showCarEyeHours = hours;
    courseChapter3dShow().show.showCarEyeMinutes = minutes;
    
}, 1000);


/**
 * 监听是否点击 进入活动，或者是点击屏幕进入3d场景回调
 */
const goPlayCallbackEventMain = () => {

    if (
        // @ts-ignore
        threeWorld().obj.newIframe.objIframe.window["goPlayCallbackEvent"] != null
        // @ts-ignore
        && threeWorld().obj.newIframe.objIframe.window["goPlayCallbackEvent"] != undefined
    ) {
        return;
    }

    // @ts-ignore
    threeWorld().obj.newIframe.objIframe.window["goPlayCallbackEvent"] = function(res : any) {

        // console.log(
        //     " ========== 监听是否点击 进入活动，或者是点击屏幕进入3d场景 ========== ",
        //     res
        // );

        setTimeout(function() {
            initScene();
        }, 200);

    }

}

/**
 * 记录点击的时候最后的时间戳
 * 用于后续，点击放开后，是否触发增加点击的值的逻辑
 */
let clickTime = ref(0);

/**
 * 控制多少毫秒触发一次逻辑
 */
let threeEventRenderTime = 0;

/**
 * 控制多少毫秒触发一次逻辑
 */
let threeEventRenderTimeTwo = 0;

/**
 * 控制多少毫秒触发一次逻辑
 */
let threeEventRenderTimeThree = 0;

/**
 * 符合条件下，判断鼠标移动到执行的物体后，更换样式
 * 控制多少毫秒执行一次，不要过于频繁，影响性能
 */
const moveUpdateMouseStyle = () => {

    if (courseChapter3dShow().show.pickResultMoveBool == true) {
        courseChapter3dShow().show.showTxtViewBool = false;
        return;
    }

    // 当前的步骤状态
    let statue = props.config?.threeDimensionalConfig;
    
    if (
        statue == "将四个安全桩放置到正确的位置"
        || statue == "将检测机器人6寸轮子安装到正确位置"
        || statue == "将检测机器人的轮子安装到正确的位置"

        || statue == "将检测机器人6寸右侧轮子安装到正确位置"
        || statue == "将检测机器人6寸左侧轮子安装到正确位置"
        || statue == "将检测机器人10寸右侧轮子安装到正确位置"
        || statue == "将检测机器人10寸左侧轮子安装到正确位置"

        || statue == "将检测机器人的防撞杆安装到正确的位置"
        || statue == "将检测机器人的防撞杆锁安装到正确的位置"
        || statue == "将检测机器人的镜头架安装到正确的位置"
        || statue == "将检测机器人的相机安装到正确的位置"
        || statue == "将绕线车的电源线安装到正确的位置"
        || statue == "将绕线车的纠偏轮安装到正确的位置"
        || statue == "将绕线车的锂电池安装到正确的位置"
        || statue == "将绕线车的电脑主机放置到正确的位置"
        || statue == "将绕线车的手柄安装到正确的位置"

        || statue == "将绕线车的电缆安装到正确的位置"
        || statue == "抬升支架降至最低"
        || statue == "镜头旋转至正上方"
        || statue == "镜头归位"
        || statue == "打开井盖"

    ) {

        // @ts-ignore
        let objScene = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene;

        // 获取选择的对象， 通过测试  scene.pick() 方法是非常消耗性能的
        let pickResultMove = objScene.pick(
            objScene.pointerX,
            objScene.pointerY
        );

        // console.log(
        //     " 鼠标移动的坐标位置 moveUpdateMouseStyle = () => { ",
        //     objScene.pointerX,
        //     objScene.pointerY
        // );

        if (pickResultMove.hit) {
            
            let objMesh = pickResultMove.pickedMesh;
            let thisClickPosition = pickResultMove.pickedPoint;

            // console.log(
            //     "符合条件判断是否更新鼠标样式",
            //     objMesh.id,
            //     thisClickPosition
            // );
            
            // 符合手势的列表
            let meshList = [

                "model_1709892139359安全桩001",
                "model_1709892139359安全桩004",
                "model_1709892139359安全桩003",
                "model_1709892139359安全桩002",

                "exhibition_html_1710385814466_10”后轮左_primitive0",
                "exhibition_html_1710385814466_10”后轮左_primitive1",
                "exhibition_html_1710385814466_10”后轮左_primitive2",

                "exhibition_html_1710385814466_10”前轮左_primitive0",
                "exhibition_html_1710385814466_10”前轮左_primitive1",
                "exhibition_html_1710385814466_10”前轮左_primitive2",

                "exhibition_html_1710385814466_10”后轮右_primitive0",
                "exhibition_html_1710385814466_10”后轮右_primitive1",
                "exhibition_html_1710385814466_10”后轮右_primitive2",

                "exhibition_html_1710385814466_10”前轮右_primitive0",
                "exhibition_html_1710385814466_10”前轮右_primitive1",
                "exhibition_html_1710385814466_10”前轮右_primitive2",

                "exhibition_html_1710385814466_6”后轮左_primitive0",
                "exhibition_html_1710385814466_6”后轮左_primitive1",
                "exhibition_html_1710385814466_6”中轮左_primitive0",
                "exhibition_html_1710385814466_6”中轮左_primitive1",
                "exhibition_html_1710385814466_6”前轮左_primitive0",
                "exhibition_html_1710385814466_6”前轮左_primitive0",
                "exhibition_html_1710385814466_6”后轮右_primitive0",
                "exhibition_html_1710385814466_6”后轮右_primitive0",
                "exhibition_html_1710385814466_6”中轮右_primitive0",
                "exhibition_html_1710385814466_6”中轮右_primitive1",
                "exhibition_html_1710385814466_6”前轮右_primitive0",
                "exhibition_html_1710385814466_6”前轮右_primitive1",

                "exhibition_html_1710385814466_防撞杆_primitive0",
                "exhibition_html_1710385814466_防撞杆_primitive1",

                "exhibition_html_1710385814466_防撞杆锁_primitive0",
                "exhibition_html_1710385814466_防撞杆锁_primitive1",

                "exhibition_html_1710385814466_镜头架_primitive0",
                "exhibition_html_1710385814466_镜头架_primitive1",
                "exhibition_html_1710385814466_镜头架_primitive2",
                "exhibition_html_1710385814466_镜头架_primitive3",

                "exhibition_html_1710385814466_相机_primitive0",
                "exhibition_html_1710385814466_相机_primitive1",
                "exhibition_html_1710385814466_相机_primitive2",
                "exhibition_html_1710385814466_相机_primitive3",

                "exhibition_html_1757573408562_绕线车-电源线",

                "exhibition_html_1710385814466_绕线车-纠偏轮_primitive0",
                "exhibition_html_1710385814466_绕线车-纠偏轮_primitive1",

                "exhibition_html_1710385814466_锂电池_primitive0",
                "exhibition_html_1710385814466_锂电池_primitive1",
                "exhibition_html_1710385814466_锂电池_primitive2",

                "exhibition_html_1710385814466_电脑屏幕_primitive0",
                "exhibition_html_1710385814466_电脑屏幕_primitive1",
                "exhibition_html_1710385814466_电脑屏幕_primitive2",

                "exhibition_html_1710385814466_电脑主机_primitive0",
                "exhibition_html_1710385814466_电脑主机_primitive1",
                "exhibition_html_1710385814466_电脑主机_primitive2",
                "exhibition_html_1710385814466_电脑主机_primitive3",

                "exhibition_html_1710385814466_手柄_primitive0",
                "exhibition_html_1710385814466_手柄_primitive1",
                "exhibition_html_1710385814466_手柄_primitive2",
                "exhibition_html_1710385814466_手柄_primitive3",

                "exhibition_html_1710385814466_电缆01_primitive0",
                "exhibition_html_1710385814466_电缆01_primitive1",
                "exhibition_html_1710385814466_绕线车-电缆",

                "model_1712911455459井盖002",

                "exhibition_html_1710385814466_上机_primitive0",
                "exhibition_html_1710385814466_上机_primitive1",
                "exhibition_html_1710385814466_上机_primitive2",
                "exhibition_html_1710385814466_上机_primitive3",
                "exhibition_html_1710385814466_上机_primitive4",
                "exhibition_html_1710385814466_上机_primitive5",

            ];

            for (let i = 0; i < meshList.length; i++) {

                let thisMeshList = meshList[i];
                if (thisMeshList == objMesh.id) {

                    objDragAndDropEvent.iframeCanvasStyle("pointer");

                    if (
                        // @ts-ignore
                        threeWorld().obj.meshEvent[objMesh.id] != null
                        // @ts-ignore
                        && threeWorld().obj.meshEvent[objMesh.id] != undefined
                    ) {

                        // @ts-ignore
                        let thisMeshEvent = threeWorld().obj.meshEvent[objMesh.id];

                        courseChapter3dShow().show.showTxtViewBool = true;
                        courseChapter3dShow().show.showTxtContent = thisMeshEvent.txt;
                        courseChapter3dShow().show.showTxtViewX = objScene.pointerX + 20;
                        courseChapter3dShow().show.showTxtViewY = objScene.pointerY - 20;
                        
                    }

                    return;
                }

            }

            objDragAndDropEvent.iframeCanvasStyle("normal");
            courseChapter3dShow().show.showTxtViewBool = false;

        }
        
    }
    
}





/**
 * 设置3d事件
 */
const threeEvent = () => {
    
    // @ts-ignore
    let objScene = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene;

    /**
     * 可以被追加事件的API【 可以不断追加进来 】
     */
    // @ts-ignore
    threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.onPointerObservable.add(
        (pointerInfo : any) => {

            // console.log(
            //     "  ============================== 鼠标事件触发了 ============================== ",
            //     pointerInfo.pickInfo,
            //     pointerInfo.pickInfo.hit
            // );

        // 当前的步骤状态
        let statue = props.config?.threeDimensionalConfig;

        if (courseChapter3dShow().show.pickResultMoveBool == true) {

            courseChapter3dShow().show.showDirectionViewBool = false;
            courseChapter3dShow().show.showClickRotationViewBool = false;

            // 获取选择的对象， 通过测试  scene.pick() 方法是非常消耗性能的
            let pickResultMove = objScene.pick(
                objScene.pointerX,
                objScene.pointerY
            );

            if (pickResultMove.hit) {

                // console.log(
                //     "鼠标移动触发逻辑",
                //     "pickResultMove", pickResultMove
                // );

                objDragAndDropEvent.threeWorldPointerMove(pickResultMove, statue);
                objDragAndDropEvent.dragAndDropMove(pickResultMove, statue);
                
                
            }
            
        }
        
        // 如果点击到3d世界里的物体的时候
        if (pointerInfo.pickInfo.hit) {
            
            var pickResult = pointerInfo.pickInfo;
            // console.log(
            //     " threeEvent = () => { 鼠标事件 》》》》》》》》》》 ", pickResult
            // );

            // // 获取点击对象的方向【 一定要加上 true，否则载入的获取模型的方向，会有问题 】
            // var getNormal = pickResult.getNormal(true);
            // console.log({
            //     '事件' : 'lickType 鼠标事件点击到物体了',
            //     '被点击到的物体' : pickResult,
            //     '坐标' : pickResult.pickedPoint,
            //     '被点击的物体的名字' : pickResult.pickedMesh.name,
            //     '被点击物体的材质' : pickResult.pickedMesh.material,
            //     '获取点击对象的方向' : getNormal,
            //     '得到点击物体的所有点位集合[ 物体都是通过很多点为链接而形成的,可以通过这个方法知道物体的最大尺寸,或者最小尺寸等 ]' : pickResult.pickedMesh._geometry._positions,
            //     '得到被点击物体的绝对坐标,后续该坐标例如取中心点垂直就很有用处【3d模型如果错位，说明是3d建模把模型给合并导致的，需要跟对方沟通，让模型单独】' : pickResult.pickedMesh._absolutePosition
            // });

            switch (pointerInfo.type) {

                case BABYLON.PointerEventTypes.POINTERDOWN:
                    // console.log("clickType 鼠标按下");

                    courseChapter3dShow().show.showDirectionViewBool = false;
                    courseChapter3dShow().show.showClickRotationViewBool = false;

                    clickTime.value = new Date().getTime();
                    objDragAndDropEvent.dragAndDropClick( pickResult, statue );
                    
                    break;
                case BABYLON.PointerEventTypes.POINTERUP:
                    // console.log("clickType 鼠标弹起");

                    let thisTime = new Date().getTime();
                    // 距离点击的时间
                    let distanceTime = thisTime - clickTime.value;

                    // console.log(
                    //     "distanceTime", distanceTime
                    // );

                    objDragAndDropEvent.dragAndDropPointerup(pickResult, statue);

                    /**
                     * 低于200毫秒，则为触发增加值的逻辑
                     * 否则，就是用户平时旋转3d场景的逻辑
                     */
                    if (distanceTime <= 200) {

                        // console.log(
                        //     " 鼠标点击弹起了 threeEvent = () => { ", pickResult.pickedMesh
                        // );

                        objDragAndDropEvent.threeWorldPointerupEvent(pickResult, statue);

                        // // 这里的拖拽逻辑，暂时取消
                        // gizmoManagerEvent(pickResult.pickedMesh);

                        objTypeViewEvent.wearingClothes(pickResult.pickedMesh, statue);
                        objTypeViewEvent.openBox(pickResult.pickedMesh, statue);
                        objTypeViewEvent.openCable(pickResult.pickedMesh, statue);
                        objTypeViewEvent.openSupport(pickResult.pickedMesh, statue);
                        objTypeViewEvent.openShotUp(pickResult.pickedMesh, statue);
                        objTypeViewEvent.openShotRet(pickResult.pickedMesh, statue);
                        objTypeViewEvent.openManholeCover(pickResult.pickedMesh, statue);
                        
                    }
                    
                    break;
                case BABYLON.PointerEventTypes.POINTERMOVE:
                    // console.log("clickType 鼠标移动中");
                    
                    break;
                case BABYLON.PointerEventTypes.POINTERWHEEL:
                    // console.log("clickType 鼠标滚轮滚动中");
                    break;
                case BABYLON.PointerEventTypes.POINTERPICK:
                    // console.log("clickType 鼠标指针选中事件");
                    break;
                case BABYLON.PointerEventTypes.POINTERTAP:
                    // console.log("clickType 当对象被触摸并在没有拖动的情况下释放时，触发指针触发事件。");
                    break;
                case BABYLON.PointerEventTypes.POINTERDOUBLETAP:
                    // console.log("clickType 鼠标双击");
                    
                    break;
            }

        }
        
    });
    
    // @ts-ignore 添加帧事件
    threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.onBeforeRenderObservable.add(function() {

        // 当前的步骤状态
        let statue = props.config?.threeDimensionalConfig;

        let thisTime = new Date().getTime();
        if (thisTime - threeEventRenderTime >= 1000) {

            threeEventRenderTime = thisTime;
            objRenderEvent.updateCarDb();
            objTypeViewEvent.arcRotateCameraCarPushEvent();
            carStatusEvent();
            objRenderEvent.workEvent(statue);
            
        }

        if (thisTime - threeEventRenderTimeTwo >= 3000) {

            threeEventRenderTimeTwo = thisTime;
            // 自动降挡
            objRenderEvent.carMoveLvEvent('moderate');

        }

        if (thisTime - threeEventRenderTimeThree >= 300) {

            threeEventRenderTimeThree = thisTime;
            moveUpdateMouseStyle();
            
        }
        
        carCameraAlphaAndBetaNew();
        objTypeViewEvent.arcRotateCameraCarEvent();
        objTypeViewEvent.spotLightCameraEvent();
        objDragAndDropEvent.cameraVisualAngleUpdate();
        objHighlightLayerEvent.updateSize();

        // console.log(
        //     " 每帧在执行 threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.onBeforeRenderObservable.add(function() { "
        // );
        
    });
    
}

// 是否因为，移动后停止了
let moveToStop = true;

// 控制播放超速声音的时间戳，不需要太频繁播放声音
let speedingMusicPlayTime = 0;

/**
 * 通过车的不同状态，控制前进还是倒退的逻辑
 */
const carStatusEvent = () => {

    // console.log(

    //     "carStatusEvent = () => {",
    //     courseChapter3dShow().show.carStatus,
    //     courseChapter3dShow().show.carMoveLv,
    //     courseChapter3dShow().show.carMoveSpeed,

    // );


    // 超速提示
    courseChapter3dShow().show.showCarEyeViewBoolSpeeding = courseChapter3dShow().show.carMoveLv >= 8 ? true : false;

    var thisTime = new Date().getTime();
    
    if (
        // 如果超速
        courseChapter3dShow().show.showCarEyeViewBoolSpeeding == true
        && (thisTime - speedingMusicPlayTime) >= 3500
    ) {
        
        speedingMusicPlayTime = thisTime;
        objTypeViewEvent.musicConfigPlay(
            "车辆超速", "carSpeeding"
        );
        
    }


    // 得到最顶部距离的值
    let showCarEyeDistanceMax = (pipelineProblemsArrayEventList.length - 2 - distanceXBoolSum) * 29.94;
    showCarEyeDistanceMax -= (29.94 / 2);

    // 由于多出了个出生点与坐标点的距离差
    showCarEyeDistanceMax += courseChapter3dShow().show.lineDistance;
    
    // console.log(
    //     " 得到最顶部距离的值 showCarEyeDistanceMax ",
    //     showCarEyeDistanceMax
    // );

    // console.log(
    //     "距离判断是否到最顶位置",
    //     // pipelineProblemsArrayEventList.length,
    //     // showCarEyeDistanceMax,
    //     // courseChapter3dShow().show.showCarEyeDistance,
    //     // courseChapter3dShow().show.birthPointRecord,
    //     // courseChapter3dShow().show.carPointRecord,

    //     // courseChapter3dShow().show.birthPointRecord.x,
    //     // courseChapter3dShow().show.carPointRecord.x,
    // );

    if (
        // 前视
        courseChapter3dShow().show.lookAfterOrFront == "front"
        // && courseChapter3dShow().show.showCarEyeDistance >= 476
        && courseChapter3dShow().show.showCarEyeDistance >= showCarEyeDistanceMax
    ) {
        courseChapter3dShow().show.showCarEyeViewBoolSpeeding2 = true;
    } else if (
        // 后视
        courseChapter3dShow().show.lookAfterOrFront == "after"
        // && courseChapter3dShow().show.showCarEyeDistance <= 7.3
        && courseChapter3dShow().show.showCarEyeDistance <= 1
    ) {
        courseChapter3dShow().show.showCarEyeViewBoolSpeeding2 = true;
    } else {
        courseChapter3dShow().show.showCarEyeViewBoolSpeeding2 = false;
    }

    // 如果是停止移动了
    if (courseChapter3dShow().show.carStatus == "stopMove") {

        // 此时说明要停止移动了
        if (moveToStop == false) {

            // 触发键盘的停止逻辑

            // @ts-ignore 
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.EventMoveRole.find().moveState = 0;
            // @ts-ignore 
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolW = false;
            // @ts-ignore 
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolA = false;
            // @ts-ignore 
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolS = false;
            // @ts-ignore 
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolD = false;

            // @ts-ignore 恢复初始的移动速度
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().speed = courseChapter3dShow().show.carMoveSpeed;
            
            moveToStop = true;

        }

        return;
    }

    moveToStop = false;

    // 根据不同的挡位，控制合理的移动速度
    let speed = courseChapter3dShow().show.carMoveSpeed
    * (courseChapter3dShow().show.carMoveLv / courseChapter3dShow().show.carMoveSpeedMultipleMax * 1);
    
    // // @ts-ignore 更新目标角色的参数
    // threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().modelRoleCreateOrUpdate(
    //     // @ts-ignore 
    //     threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().roleCode,
    //     {
    //         "addMoveSpeed" : courseChapter3dShow().show.carMoveSpeed - speed,
    //         "addMoveSpeedSecond" : 3,
    //         "addMoveSpeedSecondTimeUpdate" : new Date().getTime()
    //     }
    // );

    // @ts-ignore
    threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().speed = speed;
    
    // 前进
    if (courseChapter3dShow().show.carStatus == "forwardMove") {

        // @ts-ignore 
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.EventMoveRole.find().moveState = 1;
        // @ts-ignore 
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolW = true;
        // @ts-ignore 
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolA = false;
        // @ts-ignore 
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolS = false;
        // @ts-ignore 
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolD = false;
    }

    // 后退
    if (courseChapter3dShow().show.carStatus == "retreatMove") {

        // @ts-ignore 
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.EventMoveRole.find().moveState = 1;
        // @ts-ignore 
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolS = true;
        // @ts-ignore 
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolA = false;
        // @ts-ignore 
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolW = false;
        // @ts-ignore 
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonEvent.find().boolD = false;

    }

    // console.log(
    //     " carStatusEvent = () => { 移动速度 ",
    //     speed
    // );
    
}

/**
 * 通过每帧的方式来控制变化的
 * courseChapter3dShow().show.carCameraAlphaNew
 * courseChapter3dShow().show.carCameraBetaNew
 * …… 左右旋转，上下旋转，镜头放大缩小
 * 等逻辑
 * 跟 车机器人相关的逻辑
 * 
 */
const carCameraAlphaAndBetaNew = () => {
    
    // 可旋转角度
    let mathPiMax = Math.PI / 2;
    let mathPiMax2 = Math.PI / 10;

    // fov每次变化参数
    let fovUpdate = 0.2;

    // fov最大值
    let fovMax = 1.6;
    // fov最小值
    let fovMin = 0.4;

    // 帧数
    let fps = 75;
    // 完成秒数
    let secondFps = fps * 1.5;
    let secondFps2 = fps * 1.5;
    let secondFps3 = fps * 3;

    // y轴支架每次变化的参数
    let yUpdate = 1 / 2;
    // let yUpdate = 1;

    // y轴支架最大值
    let yMax = 1.5;
    // y轴支架最小值
    let yMin = 0;

    // 车速
    // let carMoveLvProportionMax = 100 * 50;
    let carMoveLvProportionMax = 100;

    // 车相机左右旋转
    if (courseChapter3dShow().show.carCameraAlpha != courseChapter3dShow().show.carCameraAlphaNew) {

        let distance = courseChapter3dShow().show.carCameraAlpha - courseChapter3dShow().show.carCameraAlphaNew;
        if (distance > 0) {
            courseChapter3dShow().show.carCameraAlphaNew += mathPiMax / secondFps3;
            if (courseChapter3dShow().show.carCameraAlphaNew >= courseChapter3dShow().show.carCameraAlpha) {
                courseChapter3dShow().show.carCameraAlphaNew = courseChapter3dShow().show.carCameraAlpha;
            }

        } else {
            courseChapter3dShow().show.carCameraAlphaNew -= mathPiMax / secondFps3;
            if (courseChapter3dShow().show.carCameraAlphaNew <= courseChapter3dShow().show.carCameraAlpha) {
                courseChapter3dShow().show.carCameraAlphaNew = courseChapter3dShow().show.carCameraAlpha;
            }
        }
        
        if (courseChapter3dShow().show.carCameraAlphaNew >= mathPiMax) {
            courseChapter3dShow().show.carCameraAlphaNew = mathPiMax;
        }

        if (courseChapter3dShow().show.carCameraAlphaNew <= -mathPiMax) {
            courseChapter3dShow().show.carCameraAlphaNew = -mathPiMax;
        }

    }

    // 车相机上下旋转
    if (courseChapter3dShow().show.carCameraBeta != courseChapter3dShow().show.carCameraBetaNew) {

        let distance = courseChapter3dShow().show.carCameraBeta - courseChapter3dShow().show.carCameraBetaNew;
        if (distance > 0) {
            courseChapter3dShow().show.carCameraBetaNew += mathPiMax / secondFps3;
            if (courseChapter3dShow().show.carCameraBetaNew >= courseChapter3dShow().show.carCameraBeta) {
                courseChapter3dShow().show.carCameraBetaNew = courseChapter3dShow().show.carCameraBeta;
            }

        } else {
            courseChapter3dShow().show.carCameraBetaNew -= mathPiMax / secondFps3;
            if (courseChapter3dShow().show.carCameraBetaNew <= courseChapter3dShow().show.carCameraBeta) {
                courseChapter3dShow().show.carCameraBetaNew = courseChapter3dShow().show.carCameraBeta;
            }
        }
        
        if (courseChapter3dShow().show.carCameraBetaNew >= mathPiMax) {
            courseChapter3dShow().show.carCameraBetaNew = mathPiMax;
        }

        if (courseChapter3dShow().show.carCameraBetaNew <= -mathPiMax) {
            courseChapter3dShow().show.carCameraBetaNew = -mathPiMax;
        }

    }

    // 车左右转弯
    if (courseChapter3dShow().show.carCameraAlphaWheel != courseChapter3dShow().show.carCameraAlphaWheelNew) {

        let distance = courseChapter3dShow().show.carCameraAlphaWheel - courseChapter3dShow().show.carCameraAlphaWheelNew;
        if (distance > 0) {
            courseChapter3dShow().show.carCameraAlphaWheelNew += mathPiMax2 / secondFps2;
            if (courseChapter3dShow().show.carCameraAlphaWheelNew >= courseChapter3dShow().show.carCameraAlphaWheel) {
                courseChapter3dShow().show.carCameraAlphaWheelNew = courseChapter3dShow().show.carCameraAlphaWheel;
            }

        } else {
            courseChapter3dShow().show.carCameraAlphaWheelNew -= mathPiMax2 / secondFps2;
            if (courseChapter3dShow().show.carCameraAlphaWheelNew <= courseChapter3dShow().show.carCameraAlphaWheel) {
                courseChapter3dShow().show.carCameraAlphaWheelNew = courseChapter3dShow().show.carCameraAlphaWheel;
            }
        }

        if (courseChapter3dShow().show.carCameraAlphaWheelNew >= mathPiMax2) {
            courseChapter3dShow().show.carCameraAlphaWheelNew = mathPiMax2;
        }

        if (courseChapter3dShow().show.carCameraAlphaWheelNew <= -mathPiMax2) {
            courseChapter3dShow().show.carCameraAlphaWheelNew = -mathPiMax2;
        }

    }

    // 车相机是否放大
    if (courseChapter3dShow().show.carCameraFov != courseChapter3dShow().show.carCameraFovNew) {

        let distance = courseChapter3dShow().show.carCameraFov - courseChapter3dShow().show.carCameraFovNew;
        if (distance > 0) {
            courseChapter3dShow().show.carCameraFovNew += fovUpdate / secondFps;
            if (courseChapter3dShow().show.carCameraFovNew >= courseChapter3dShow().show.carCameraFov) {
                courseChapter3dShow().show.carCameraFovNew = courseChapter3dShow().show.carCameraFov;
            }

        } else {
            courseChapter3dShow().show.carCameraFovNew -= fovUpdate / secondFps;
            if (courseChapter3dShow().show.carCameraFovNew <= courseChapter3dShow().show.carCameraFov) {
                courseChapter3dShow().show.carCameraFovNew = courseChapter3dShow().show.carCameraFov;
            }
        }

        if (courseChapter3dShow().show.carCameraFovNew >= fovMax) {
            courseChapter3dShow().show.carCameraFovNew = fovMax;
        }

        if (courseChapter3dShow().show.carCameraFovNew <= fovMin) {
            courseChapter3dShow().show.carCameraFovNew = fovMin;
        }

    }

    // 支架上升还是下降
    if (courseChapter3dShow().show.carCameraPositionY != courseChapter3dShow().show.carCameraPositionYNew) {

        let distance = courseChapter3dShow().show.carCameraPositionY - courseChapter3dShow().show.carCameraPositionYNew;
        if (distance > 0) {

            courseChapter3dShow().show.carCameraPositionYNew += yUpdate / secondFps;
            if (courseChapter3dShow().show.carCameraPositionYNew >= courseChapter3dShow().show.carCameraPositionY) {
                courseChapter3dShow().show.carCameraPositionYNew = courseChapter3dShow().show.carCameraPositionY;
            }

        } else {

            courseChapter3dShow().show.carCameraPositionYNew -= yUpdate / secondFps;
            if (courseChapter3dShow().show.carCameraPositionYNew <= courseChapter3dShow().show.carCameraPositionY) {
                courseChapter3dShow().show.carCameraPositionYNew = courseChapter3dShow().show.carCameraPositionY;
            }

        }

        if (courseChapter3dShow().show.carCameraPositionYNew >= yMax) {
            courseChapter3dShow().show.carCameraPositionYNew = yMax;
        }

        if (courseChapter3dShow().show.carCameraPositionYNew <= yMin) {
            courseChapter3dShow().show.carCameraPositionYNew = yMin;
        }

    }

    // 车速变动百分比
    if (courseChapter3dShow().show.carMoveLvProportion != courseChapter3dShow().show.carMoveLvProportionNew) {

        let distance = courseChapter3dShow().show.carMoveLvProportion - courseChapter3dShow().show.carMoveLvProportionNew;
        if (distance > 0) {

            courseChapter3dShow().show.carMoveLvProportionNew += carMoveLvProportionMax / secondFps;
            if (courseChapter3dShow().show.carMoveLvProportionNew >= courseChapter3dShow().show.carMoveLvProportion) {
                courseChapter3dShow().show.carMoveLvProportionNew = courseChapter3dShow().show.carMoveLvProportion;
            }

        } else {

            courseChapter3dShow().show.carMoveLvProportionNew -= carMoveLvProportionMax / secondFps;
            if (courseChapter3dShow().show.carMoveLvProportionNew <= courseChapter3dShow().show.carMoveLvProportion) {
                courseChapter3dShow().show.carMoveLvProportionNew = courseChapter3dShow().show.carMoveLvProportion;
            }

        }

        // if (courseChapter3dShow().show.carMoveLvProportionNew >= 100) {
        //     courseChapter3dShow().show.carMoveLvProportionNew = 100;
        // }

        // if (courseChapter3dShow().show.carMoveLvProportionNew <= 0) {
        //     courseChapter3dShow().show.carMoveLvProportionNew = 0;
        // }

        if (courseChapter3dShow().show.carMoveLvProportionNew >= 96) {
            courseChapter3dShow().show.carMoveLvProportionNew = 96;
        }

        if (courseChapter3dShow().show.carMoveLvProportionNew <= 3) {
            courseChapter3dShow().show.carMoveLvProportionNew = 3;
            courseChapter3dShow().show.bottomSpeedImgTopSptWidth = '0rem';
        } else {
            // courseChapter3dShow().show.bottomSpeedImgTopSptWidth = '2.6rem';
            courseChapter3dShow().show.bottomSpeedImgTopSptWidth = '2rem';
        }

        // 最大的例子所在位置
        let topRemMax = 6;
        // let topRemMax = 8;

        if (courseChapter3dShow().show.carMoveLvProportionNew <= 50) {

            courseChapter3dShow().show.carMoveLvProportionTopNew = -(topRemMax * courseChapter3dShow().show.carMoveLvProportionNew / 100);
            
        } else {

            courseChapter3dShow().show.carMoveLvProportionTopNew = -(topRemMax * ( 100 - courseChapter3dShow().show.carMoveLvProportionNew) / 100);

        }
        

    }
    
}

/**
 * 3d加载完成优先切换到默认的视角
 */
const initScene = () => {

    // console.log(
    //     "initScene = () => {",
    //     threeWorld().obj.newIframe,
    //     threeWorld().obj.newIframe.getCameraVisualAngleGetList()
    // );
    
    // @ts-ignore
    threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("检测车");
    // @ts-ignore
    threeWorld().obj.newIframe.roleShow(false);

    // 清空3d背景
    // @ts-ignore
    threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.clearColor = {
        "r" : 0, "g" : 0, "b" : 0, "a" : 0
    };

    groundNoRemove();

    typeEvent(props.config?.threeDimensionalConfig);

    // 触发自动点击逻辑
    // @ts-ignore
    threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().screenClickNumEvent();

    // 默认装的盒子是可以看到的
    objTypeViewEvent.boxLook(true);

}

/**
 * 将所有设置为地面的，改为不设置为地面
 */
const groundNoRemove = () => {

    // // 临时测试用的，后续正式，在注释掉
    // return;

    // console.log(
    //     "groundNoRemove = () => {",
    //     threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.ModelObjEdit.find().meshListIdToJson
    // );

    // @ts-ignore
    for (const key in threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.ModelObjEdit.find().meshListIdToJson) {
        
        if (
            // @ts-ignore
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.ModelObjEdit.find().meshListIdToJson[key]['isGround'] == true
        ) {
            // 通过更新材质的参数，来更新
            // @ts-ignore
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.ModelObjEdit.find().objOneMeshListIdToJsonUpdate(
                key,
                {
                    
                    "isGround" : false,
                }
            );
        }
        
    }

    // @ts-ignore
    for (let i = 0; i < threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.meshes.length; i++) {
        // @ts-ignore
        let objMesh = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.meshes[i];
        // console.log(
        //     "myIsGround",
        //     objMesh["myIsGround"]
        // );
        // if (objMesh["myIsGround"] == true) {
        //     delete objMesh["myIsGround"];
        // }

        delete objMesh["myIsGround"];
    }

    // @ts-ignore
    threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.Role.find().isGroundList = {};

    // @ts-ignore
    threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.ModelObjEdit.find().myIsGroundConfigNum = 0;

}

/**
 * 停止所有动画
 */
const animationAllFpsToZero = () => {

    objTypeViewEvent.animationAllTypeUpdate("stopAll");

};

/**
 * 根据不同的类型，切换对应的3d逻辑
 */
const typeEvent = (type : any) => {

    console.log(
        "根据不同的类型，切换对应的3d逻辑",
        type
    );

    courseChapter3dShow().show.viewType = type;
    
    thisFlowPath = type;

    objDragAndDropEvent.txtBool = false;
    courseChapter3dShow().show.showDirectionViewBool = false;

    // @ts-ignore
    if (threeWorld().obj.showCongratulationsTxtJson[type] != null && threeWorld().obj.showCongratulationsTxtJson[type] != undefined) {
        
        // @ts-ignore
        let showCongratulationsTxtJson = threeWorld().obj.showCongratulationsTxtJson[type];
        courseChapter3dShow().show.showCongratulationsTxt = showCongratulationsTxtJson.txt;

        courseChapter3dShow().show.showEndTxt = showCongratulationsTxtJson.txtEnd;

        if (
            showCongratulationsTxtJson.showDirectionX != null && showCongratulationsTxtJson.showDirectionX != undefined
            && showCongratulationsTxtJson.showDirectionY != null && showCongratulationsTxtJson.showDirectionY != undefined
        ) {

            let tips = props.config?.tips;
            if (tips != null && tips != undefined) {

                // 由于新增了切换视角逻辑，延迟弹出
                setTimeout(function() {
                    
                    // @ts-ignore
                    courseChapter3dShow().show.showDirectionEvent(
                        tips,
                        null,
                        showCongratulationsTxtJson.showDirectionX,
                        showCongratulationsTxtJson.showDirectionY,
                        function() {}
                    );
                    
                }, 1500);
            }
            
        }

        
    } else {
        courseChapter3dShow().show.showCongratulationsTxt = "";
    }

    setTimeout(function() {
        // 启动播放声音
        objTypeViewEvent.musicConfigPlay(
            type, "start"
        );
    }, 1500);

    // 控制物体的显示和隐藏以及高亮
    objHighlightLayerEvent.statueMeshLookOrHighlight(type);

    // 重置为空数组
    objDragAndDropEvent.highlightLayerMeshListClick = [];

    objDragAndDropEvent.retVisibility(0, "restore", {});
    objDragAndDropEvent.retVisibility(1, "restore", {});

    switch(type) {

        // 操作帮助
        case 'operationHelp':
            objTypeViewEvent.operationHelpEvent();
            break;
            
        // 设备拆解
        case 'equipmentDisassembly':
            objTypeViewEvent.equipmentDisassemblyEvent();
            // 切换动画
            objTypeViewEvent.animationAllTypeUpdate("stopAll");
            break;

        // 爬行器模块
        case 'crawlerModule':
            objTypeViewEvent.crawlerModuleEvent();
            // 切换动画
            objTypeViewEvent.animationAllTypeUpdate("stopAll");
            objDragAndDropEvent.txtBool = true;
            break;
        
        // 线缆卷盘
        case 'cableReel':
            objTypeViewEvent.cableReelEvent();
            // 切换动画
            objTypeViewEvent.animationAllTypeUpdate("stopAll");
            objDragAndDropEvent.txtBool = true;
            break;

        // 检测实训注意事项
        case 'precautionsForTestingTraining':
            objTypeViewEvent.precautionsForTestingTrainingEvent(props.config?.durationStudyMin);
            // 切换动画
            objTypeViewEvent.animationAllTypeUpdate("stopAll");
            break;

        // 设备下井实验视频
        case 'equipmentDownHoleExperimentVideo':
            objTypeViewEvent.equipmentDownHoleExperimentVideoEvent();
            // 切换动画
            objTypeViewEvent.animationAllTypeUpdate("stopAll");
            break;
            
        case '请走到工作区域':

            objTypeViewEvent.work_1();
            // 切换动画
            objTypeViewEvent.animationAllTypeUpdate("beforeUnboxing");
            
            break;
            
        case '请点击人物进行穿搭衣服':
            objTypeViewEvent.work_2();
            // 切换动画
            objTypeViewEvent.animationAllTypeUpdate("beforeUnboxing");
            break;
            
        case '将四个安全桩放置到正确的位置':
            objTypeViewEvent.work_3();
            // 切换动画
            objTypeViewEvent.animationAllTypeUpdate("beforeUnboxing");
            break;
            
        case '将盒子拆开把设备拿出来':
            objTypeViewEvent.work_4();
            break;
            
        case '将盒子拆开把设备放置在安全的位置':
            objTypeViewEvent.work_5();
            break;

        // 已经不会用到的逻辑了
        case '将检测机器人6寸轮子安装到正确位置':
            objTypeViewEvent.work_6_0();
            break;
            
        // 已经不会用到的逻辑了
        case '将检测机器人的轮子安装到正确的位置':
            objTypeViewEvent.work_6();
            break;

        case '将检测机器人6寸右侧轮子安装到正确位置':
            objTypeViewEvent.work_6_right();
            break;

        case '将检测机器人6寸左侧轮子安装到正确位置':
            objTypeViewEvent.work_6_left();
            break;

        case '将检测机器人10寸右侧轮子安装到正确位置':
            objTypeViewEvent.work_10_right();
            break;

        case '将检测机器人10寸左侧轮子安装到正确位置':
            objTypeViewEvent.work_10_left();
            break;
            
        case '将检测机器人的防撞杆安装到正确的位置':
            objTypeViewEvent.work_7();
            break;
            
        case '将检测机器人的防撞杆锁安装到正确的位置':
            objTypeViewEvent.work_8();
            break;
            
        case '将检测机器人的镜头架安装到正确的位置':
            objTypeViewEvent.work_9();
            break;
            
        case '将检测机器人的相机安装到正确的位置':
            objTypeViewEvent.work_10();
            break;
            
        case '将绕线车的电源线安装到正确的位置':
            objTypeViewEvent.work_11();
            break;
            
        case '将绕线车的纠偏轮安装到正确的位置':
            objTypeViewEvent.work_12();
            break;
            
        case '将绕线车的锂电池安装到正确的位置':
            objTypeViewEvent.work_13();
            break;
            
        case '将绕线车的电脑主机放置到正确的位置':
            objTypeViewEvent.work_14();
            break;
            
        case '将绕线车的手柄安装到正确的位置':
            objTypeViewEvent.work_15();
            break;
            
        case '将绕线车的电缆安装到正确的位置':
            objTypeViewEvent.work_16();
            break;
            
        case '抬升支架降至最低':
            objTypeViewEvent.work_17();
            break;
            
        case '镜头旋转至正上方':
            objTypeViewEvent.work_18();
            break;
            
        case '镜头归位':
            objTypeViewEvent.work_19();
            break;
            
        case '调节行驶方向正确放置过线滑轮':
            objTypeViewEvent.work_20();
            break;
            
        case '打开井盖':
            objTypeViewEvent.work_21();
            break;
            
        case '下井视频':
            objTypeViewEvent.work_22();
            break;

        case '设备回收视频':
            objTypeViewEvent.work_23();
            break;
            
        // 作业前准备工作1
        case 'preparationWorkBeforeHomework1':
            objTypeViewEvent.preparationWorkBeforeHomework1Event();
            break;

        // 作业前准备工作2
        case 'preparationWorkBeforeHomework2':
            objTypeViewEvent.preparationWorkBeforeHomework2Event();
            break;

        // 作业前准备工作3
        case 'preparationWorkBeforeHomework3':
            objTypeViewEvent.preparationWorkBeforeHomework3Event();
            break;

        // 作业前准备工作4
        case 'preparationWorkBeforeHomework4':
            objTypeViewEvent.preparationWorkBeforeHomework4Event();
            break;

        // 设备连接工作1
        case 'deviceConnectionWork1':
            objTypeViewEvent.deviceConnectionWork1Event();
            break;

        // 设备连接工作2
        case 'deviceConnectionWork2':
            objTypeViewEvent.deviceConnectionWork2Event();
            break;

        // 设备调试工作
        case 'equipmentDebuggingWork':
            objTypeViewEvent.equipmentDebuggingWorkEvent();
            break;

        // 录制准备视频
        case 'recordPreparationVideo':
            objTypeViewEvent.recordPreparationVideoEvent();
            break;

        // 设备下井工作1
        case 'equipmentDownHoleWork1':
            objTypeViewEvent.equipmentDownHoleWork1Event();
            break;

        // 设备下井工作2
        case 'equipmentDownHoleWork2':
            objTypeViewEvent.equipmentDownHoleWork2Event();
            break;

        // 设备下井工作3
        case 'equipmentDownHoleWork3':
            objTypeViewEvent.equipmentDownHoleWork3Event();
            break;

        // 设备下井工作4
        case 'equipmentDownHoleWork4':
            objTypeViewEvent.equipmentDownHoleWork4Event();
            break;

        // 设备下井工作5
        case 'equipmentDownHoleWork5':
            objTypeViewEvent.equipmentDownHoleWork5Event();
            break;

        // 设备下井工作6
        case 'equipmentDownHoleWork6':
            objTypeViewEvent.equipmentDownHoleWork6Event();
            break;

        // 设备下井工作7
        case 'equipmentDownHoleWork7':
            objTypeViewEvent.equipmentDownHoleWork7Event();
            break;

        // 下井检测
        case 'downHoleInspection':
            objTypeViewEvent.downHoleInspectionEvent();
            break;

        // 设备归位工作
        case 'equipmentRepositioningWork':
            objTypeViewEvent.equipmentRepositioningWorkEvent();
            break;

        default:
            objTypeViewEvent.viewHide();
            break;
            
    }

    let tips = props.config?.tips;
    if (tips != null && tips != undefined) {
        courseChapter3dShow().show.showTitleTxt = tips;
    }


}

// let wearYes = new URL("./../../assets/3dMain/body.webp", import.meta.url).href;
let wearYes = new URL("./../../assets/3dMain/04_M_Construction_d_2.webp", import.meta.url).href;
let wearNo = new URL("./../../assets/3dMain/04_M_Construction_d_1.webp", import.meta.url).href;

let wearTextureNo:any = null;
let wearTextureYes:any = null;

// 优先记录好工作人员进行替换的贴图对象
const workRoleTexture = () => {
    
    let list = [
        "exhibition_html_1709861931375_M_SML_Construction_01_primitive0",
        // "exhibition_html_1709861931375_M_SML_Construction_01_primitive1",
        // "exhibition_html_1709861931375_M_SML_Construction_01_primitive2",
        // "exhibition_html_1709861931375_M_SML_Construction_01_primitive3",
    ];

    for (let i = 0; i < list.length; i++) {

        let objMeshId = list[i];
        // @ts-ignore
        let objMesh = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.getMeshById(objMeshId);
        if (objMesh != null && objMesh != undefined && objMesh.material != null && objMesh.material != undefined) {

            // console.log(
            //     "objMesh.material",
            //     objMesh.material
            // );

            if (wearTextureNo == null) {

                if (objMesh.material.albedoTexture != null && objMesh.material.albedoTexture != undefined) {
                    wearTextureNo = objMesh.material.albedoTexture.clone();
                }

            }

        }
        
    }

    wearTextureYes = new BABYLON.Texture(
        wearYes, 
        // @ts-ignore
        threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene,
        null, false
    );

    objTypeViewEvent.wearTextureNo = wearTextureNo;
    objTypeViewEvent.wearTextureYes = wearTextureYes;
    
}

/**
 * 设备连接工作，右侧菜单点击回调
 */
courseChapter3dShow().show.showToolMenuRightClickCallback = function(res : any) {
    
    console.log(
        "设备连接工作，右侧菜单点击回调", res
    );

    switch (res.name) {

        case "旋转镜头":

            // @ts-ignore
            threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("镜头归位");
            // @ts-ignore
            threeWorld().obj.newIframe.roleShow(false);

            // @ts-ignore
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
                "镜头架", 'start', 1,  null, null, false, null, function(state : any, objAnimation : any) {

                    if (state == "播放完成") {
                        
                    }
                    
                }
            );

            // @ts-ignore
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
                "相机", 'start', 1,  null, null, false, null, function(state : any, objAnimation : any) {

                    if (state == "播放完成") {
                        
                    }
                    
                }
            );


            break;

        case "移动电源":

            // @ts-ignore
            threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("电池");
            // @ts-ignore
            threeWorld().obj.newIframe.roleShow(false);

            // @ts-ignore
            threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().animationGroupsEventCallback(
                "电池", 'start', 1,  null, null, false, null, function(state : any, objAnimation : any) {

                    if (state == "播放完成") {
                        
                    }
                    
                }
            );
            
            break;

        case "主机终端":

            // @ts-ignore
            threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("检测车组电脑");
            // @ts-ignore
            threeWorld().obj.newIframe.roleShow(false);
            
            break;

        case "手柄":

            // @ts-ignore
            threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("手柄");
            // @ts-ignore
            threeWorld().obj.newIframe.roleShow(false);

            break;

        case "绕线车":

            // @ts-ignore
            threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("绕线车");
            // @ts-ignore
            threeWorld().obj.newIframe.roleShow(false);

            break;

        case "爬行器":

            // @ts-ignore
            threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("检测车组");
            // @ts-ignore
            threeWorld().obj.newIframe.roleShow(false);

            break;

    }
    
}

// 管道问题点类型对应布展的物体名字， 每个管段 相差 x = 29.94 的距离，起始坐标 x = -260 [ 端头1 -289.94 ] , y = -13 , z = -30
let pipelineProblemsJson : any = {

    "管道问题点-支管段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-异物穿入段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-脱节段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-树根段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-起伏段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-破裂段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-密封圈脱落段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-漏水段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-结诟段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-腐蚀段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-浮渣段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-错位段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-残墙段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-障碍物段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-变形段" : {
        "exhibitionCode" : "",
    },
    "管道问题点-端头1" : {
        "exhibitionCode" : "",
    },
    "管道问题点-端头2" : {
        "exhibitionCode" : "",
    },

    "管道问题点-标准管段1" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段2" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段3" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段4" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段5" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段6" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段7" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段8" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段9" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段10" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段11" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段12" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段13" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段14" : {
        "exhibitionCode" : "",
    },
    "管道问题点-标准管段15" : {
        "exhibitionCode" : "",
    },
};

/**
 * 记录管道问题点对应的布展的物体
 */
const pipelineProblemsJsonInitEvent = () => {
    
    // @ts-ignore
    for (let key in threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().exhibitionJson) {

        // @ts-ignore
        let thisExhibitionJson = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().exhibitionJson[key];
        let specialCode = thisExhibitionJson.specialCode;
        let codeId = thisExhibitionJson.codeId;

        if (pipelineProblemsJson[specialCode] != null && pipelineProblemsJson[specialCode] != undefined) {
            pipelineProblemsJson[specialCode]["exhibitionCode"] = codeId;
        }

        // console.log(
        //     "thisExhibitionJson", thisExhibitionJson,
        //     "specialCode", specialCode,
        //     "codeId", codeId
        // );
        
    }

    // console.log(
    //     "pipelineProblemsJson", pipelineProblemsJson
    // );

}

/**
 * 取随机数
 * min  最小值
 * max  最大值
 */
const rnd = (min : any, max : any) => {
    return Math.floor(Math.random() * (max - min + 1) + min);
}

/**
 * 根据数组demo，来控制管道问题点的排序逻辑
 */
let pipelineProblemsArrayDemo : any = [
    // { "name" : "管道问题点-标准管段" },
];

/**
 * 随机数组demo
 */
const getRndArray = () => {

    // 获取可随机定义的数组
    let array = [];
    for (let key in pipelineProblemsJson) {
        array.push({
            "name" : key,
        });
    }

    // 返回得到的随机数组结果
    let arrayNew : any = [];

    // 随机多少个管道问题点
    let runSum = 12;
    for (var i = 0; i < runSum; i++) {

        let rndIndex = rnd(1, array.length) - 1;
        arrayNew.push(array[rndIndex]);

        // 删除数组下标
        array.splice(rndIndex, 1);

    }

    return arrayNew;

}

/**
 * 随机个数组案例,来控制管道问题点的排序逻辑
 */
const getRndArrayDemoEvent = () => {

    // let array = getRndArray();
    
    let array : any = [];

    // 记录当前新增的【 管道问题点-标准管段 】数量
    let addStandardSum = 1;

    /**
     * 临时记录已经出现过的管段
     * 如果已经重复，则不添加
     */
    let addOldNameJson : any = {};
    
    // 固定有个最开始封闭的管道
    array.push({
        "name" : "管道问题点-端头1"
    });

    // // 固定有个最开始封闭的管道
    // array.push({
    //     "name" : "管道问题点-标准管段1"
    // });

    // if (
    //     props.studentTaskIdList != null
    //     && props.studentTaskIdList != undefined
    //     && typeof props.studentTaskIdList == 'object'
    // ) {

    //     for (var i = 0; i < props.studentTaskIdList.length; i++) {

    //         let thisStudentTaskIdList = props.studentTaskIdList[i];

    //         console.log(
    //             "thisStudentTaskIdList",
    //             thisStudentTaskIdList
    //         );
            
    //         let addJson = {
    //             "name" : thisStudentTaskIdList?.pipDefect?.name
    //         }
            
    //         if (addJson["name"] == null || addJson["name"] == undefined || addJson["name"] == '') {
    //             addJson["name"] = '管道问题点-标准管段' + addStandardSum;
    //             addStandardSum += 1;
    //         }

    //         // // // 调试用的，过滤掉一些，来知道哪些管段有问题
    //         // // // if (addJson.name == "管道问题点-变形段") {
    //         // if (addJson.name !== "管道问题点-变形段") {
    //         //     continue;
    //         // }

    //         if (
    //             addOldNameJson[addJson["name"]] == null && addOldNameJson[addJson["name"]] == undefined
    //         ) {
    //             addOldNameJson[addJson["name"]] = addJson["name"];
    //             array.push(addJson);
    //         }
            
    //     }

    // }

    // // 本次要继续随机生成的标准管段数量
    // let standardCreateSum = 15 - (array.length - 2);
    // if (standardCreateSum >= 1) {

    //     for (var i = 0; i < standardCreateSum; i++) {

    //         let addJson = {
    //             "name" : '管道问题点-标准管段' + addStandardSum
    //         }
    //         addStandardSum += 1;

    //         // 随机数
    //         let rndIndex = rnd(2, array.length - 2);
    //         array.splice(rndIndex, 0, addJson);

    //     }

    // }
    
    // console.log(
    //     "const getRndArrayDemoEvent = () => {",
    //     array,
    //     standardCreateSum
    // );


    // ########## 现在修改为根据后端返回的数组下标的点位，进行排序，不在进行随机生成标准管段

    // 优先记录对应数组下标的管段json
    let addIndexJson : any = {};

    if (
        props.studentTaskIdList != null
        && props.studentTaskIdList != undefined
        && typeof props.studentTaskIdList == 'object'
    ) {

        for (var i = 0; i < props.studentTaskIdList.length; i++) {

            let thisStudentTaskIdList = props.studentTaskIdList[i];
            let pipIndex = thisStudentTaskIdList.pipIndex;
            let name = thisStudentTaskIdList?.pipDefect?.name;
            // console.log(
            //     "thisStudentTaskIdList",
            //     thisStudentTaskIdList
            // );
            
            let addJson = {
                "name" : name
            }
            
            if (addJson["name"] == null || addJson["name"] == undefined || addJson["name"] == '') {
                addJson["name"] = '管道问题点-标准管段' + addStandardSum;
                addStandardSum += 1;
            }
            
            if (
                addOldNameJson[addJson["name"]] == null && addOldNameJson[addJson["name"]] == undefined
            ) {
                addOldNameJson[addJson["name"]] = addJson["name"];
                addIndexJson[pipIndex] = addJson;
            }
            
        }

    }
    
    // 总共是15个管段，15个管段内，根据 addIndexJson 数组下标，替换问题管段
    for (var i = 1; i <= 15; i++) {

        // 如果存在问题管段数据
        if (addIndexJson[i] != null && addIndexJson[i] != undefined) {

            array.push(addIndexJson[i]);

        } else {

            var addJson = {
                "name" : '管道问题点-标准管段' + addStandardSum,
            };

            // 增加为标准管段
            array.push(addJson);
            addStandardSum += 1;

        }

    }


    // 固定有个最尾巴封闭的管道
    array.push({
        "name" : "管道问题点-端头2"
    });

    console.log(
        " 【管道问题点】 const getRndArrayDemoEvent = () => {",
        array,
        pipelineProblemsJson
    );
    
    pipelineProblemsArrayEvent(array);
    
}

/**
 * 优先将所有的管道移动到看不到的地方
 */
const pipelineProblemsJsonMoveEvent = () => {

    for (let key in pipelineProblemsJson) {

        let objPipelineProblemsJson = pipelineProblemsJson[key];
        let exhibitionCode = objPipelineProblemsJson.exhibitionCode;

        // @ts-ignore
        let objMesh = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.getMeshById(exhibitionCode);
        if (objMesh != null && objMesh != undefined) {
            
            let thisMesh = objMesh;

            // 确认当前可进行移动的主物体
            if (objMesh._parentContainer != null && objMesh._parentContainer != undefined) {
                let _parentContainer = objMesh._parentContainer;
                
                if (_parentContainer.meshes != null && _parentContainer.meshes != undefined) {
                    thisMesh = _parentContainer.meshes[0];
                }
                
            }
            
            thisMesh.position.x = 1000;

        }
        
    }

}


/**
 * 记录 pipelineProblemsArrayEvent 方法，本次安装的管道列表数据
 */
let pipelineProblemsArrayEventList : any = [];

 /**
 * 由于一些管段会出现错位的问题，所以要进行，坐标偏移特殊处理
 * 出现的次数
 */
let distanceXBoolSum = 0;
    
/**
 * 根据数组，来控制管道问题点的排序逻辑
 * array        数组
 */
const pipelineProblemsArrayEvent = (array : any) => {

    pipelineProblemsJsonMoveEvent();

    pipelineProblemsArrayEventList = array;

    // console.log(
    //     "pipelineProblemsArrayEvent = (array : any) => {",
    //     "pipelineProblemsArrayEventList",
    //     pipelineProblemsArrayEventList
    // );
    
    // 每个管段 相差 x = 29.94 的距离，起始坐标 x = -260 [ 端头1 -289.94 ] , y = -13 , z = -30
    // let startX = -260;
    // let startX = -289.94;
    let startX = -319.88;
    let distanceX = 29.94;

    /**
     * 由于一些管段会出现错位的问题，所以要进行，坐标偏移特殊处理
     * 出现的次数
     */
    distanceXBoolSum = 0;
    
    // 开始根据数组的排序，来移动对应的管道到合适的位置
    for (let i = 0; i < array.length; i++) {
        
        let thisArray = array[i];
        let name = thisArray.name;
        
        if (pipelineProblemsJson[name] != null && pipelineProblemsJson[name] != undefined) {

            let objPipelineProblemsJson = pipelineProblemsJson[name];
            let exhibitionCode = objPipelineProblemsJson.exhibitionCode;

            // @ts-ignore
            let objMesh = threeWorld().obj.newIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene.getMeshById(exhibitionCode);
            
            if (objMesh != null && objMesh != undefined) {
                
                let thisMesh = objMesh;
                
                // 确认当前可进行移动的主物体
                if (objMesh._parentContainer != null && objMesh._parentContainer != undefined) {
                    let _parentContainer = objMesh._parentContainer;
                    
                    if (_parentContainer.meshes != null && _parentContainer.meshes != undefined) {
                        thisMesh = _parentContainer.meshes[0];
                    }
                    
                }

                let newX = startX + distanceX * i;

                // // 一些管段特殊处理
                // if (name == "管道问题点-变形段") {
                //     // distanceXBoolSum += 1;
                //     console.log(
                //         name,
                //         thisMesh.id
                //     );
                // }

                // 触发整体偏移逻辑
                newX = newX - (distanceX * distanceXBoolSum);

                thisMesh.position.x = newX;
                
            }

        }
        
    }
    
}

</script>

<template>

    <!-- 3d课程配置：{{ props.config }} -->

    <img v-if="courseChapter3dShow().show.threeWorldMask == true" class="threeWorldMask" src="../../assets/student/mask.webp" />

    <CourseChapter3dMain
    :iframeId="'newIframe'"
    :url="threeWorldUrl"
    @callbackLoadPercentage="callbackLoadPercentageEvent"
    @callbackLoadEnd="callbackLoadEndEvent"
    @callbackDistanceYes="callbackDistanceYesEvent"
    @callbackDistanceNo="callbackDistanceNoEvent"
    @callbackCameraVisualAngleJsonToLook="callbackCameraVisualAngleJsonToLookEvent"
    ></CourseChapter3dMain>

</template>

<style scoped>

    .threeWorldMask {
        position: fixed;
        z-index: 1;
        width: 100%;
        height: 100%;
        top: 0px;
        left: 0px;
        pointer-events: none;
    }

</style>