人生啊人生 10 hónapja
szülő
commit
469893bb1f

+ 18 - 0
src/components/student/CourseChapter3d.vue

@@ -3,6 +3,8 @@
 import CourseChapter3dMain from '@/components/student/CourseChapter3dMain.vue';
 import { threeWorld } from "@/stores/threeWorld.ts";
 import { courseChapter3dShow } from "@/stores/courseChapter3dShow.ts";
+import { ThreeWorldEvent } from "./ThreeWorldEvent/js/ThreeWorldEvent.ts";
+import { ThreeWorldEventMain } from "./ThreeWorldEvent/js/ThreeWorldEventMain.ts";
 import { ref, watch } from "vue";
 
 const props = defineProps({
@@ -139,6 +141,22 @@ const callbackCameraVisualAngleJsonToLookEvent = (json : any) => {
  */
 const initScene = () => {
     
+    let objNewIframe : any = threeWorld().obj.newIframe;
+    
+    ThreeWorldEventMain.find().initObj(
+        objNewIframe,
+        objNewIframe.objIframe,
+        objNewIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene,
+        objNewIframe.objIframe.BABYLON
+    );
+
+    ThreeWorldEvent.find().initObj(
+        objNewIframe,
+        objNewIframe.objIframe,
+        objNewIframe.objIframe.ChengGuangYuanJing.CommonVal.find().objScene,
+        objNewIframe.objIframe.BABYLON
+    );
+    
     // // @ts-ignore
     // threeWorld().obj.newIframe.cameraVisualAngleGetListNameGpsTo("检测车");
     // // @ts-ignore

+ 12 - 6
src/components/student/ThreeWorldEvent/js/ThreeWorldEvent.ts

@@ -11,29 +11,35 @@ export class ThreeWorldEvent {
     public objScene : any = null;
     // babylon 对象,懂babylon,就可以使用babylon的api去操作
     public BABYLON : any = null;
-
-    // 操作 Cesium 的类
-    public objCesiumMain : any = null;
-
+    
     // 当前鼠标是否按住
     public clickPressBool : any = false;
     // 记录鼠标最后一次点击的时间戳
     public clickTime : any = 0;
+
+    static instance: any;
     
     // 每次 new 出对象则会调用这个构造函数
     constructor() {
         
     }
 
+    // 实现单例模式
+    static find() {
+        if (!ThreeWorldEvent.instance) {
+            ThreeWorldEvent.instance = new ThreeWorldEvent();
+        }
+        return ThreeWorldEvent.instance;
+    }
+
     /**
      * 初始化方法
      * objIframeEdit    已经封装好的,编辑器的类对象,内置可以直接调用的代码
      * objIframe        iframe对象
      * objScene         场景对象
      * BABYLON          babylon.js对象,用于后续调用babylon的代码去创建更新等操作
-     * objCesiumMain    操作 Cesium 的类
      */
-    initObj = (objIframeEdit:any, objIframe:any, objScene:any, BABYLON:any, objCesiumMain:any) => {
+    initObj = (objIframeEdit:any, objIframe:any, objScene:any, BABYLON:any) => {
         
         if (this.objIframe != null && this.objIframe != undefined) {
             return this;

+ 1 - 4
src/components/student/ThreeWorldEvent/js/ThreeWorldEventMain.ts

@@ -12,10 +12,7 @@ export class ThreeWorldEventMain {
     public objScene : any = null;
     // babylon 对象,懂babylon,就可以使用babylon的api去操作
     public BABYLON : any = null;
-
-    // 处理3d世界的各种事件
-    public objThreeWorldEvent : any = null;
-
+    
     static instance: any;
 
     // 每次 new 出对象则会调用这个构造函数