浏览代码

Merge branch 'master' of http://182.92.126.35:3000/hrx/mky-vent-base

bobo04052021@163.com 3 天之前
父节点
当前提交
7f36c1d8ab

+ 0 - 1
src/utils/http/axios/index.ts

@@ -110,7 +110,6 @@ const transform: AxiosTransform = {
   // 请求之前处理config
   beforeRequestHook: (config, options) => {
     const { apiUrl, joinPrefix, joinParamsToUrl, formatDate, joinTime = true, urlPrefix } = options;
-    debugger;
     if (!config.url.startsWith('http')) {
       if (joinPrefix) {
         config.url = `${urlPrefix}${config.url}`;

+ 18 - 15
src/views/vent/monitorManager/fireDoorMonitor/fireDoor.threejs.fire.redGate.ts

@@ -65,7 +65,7 @@ class FireDoor {
       return;
     }
     if (this.mixers && this.fmClock.running) {
-      this.mixers.update(2);
+      this.mixers.update(1);
     }
   }
 
@@ -80,12 +80,15 @@ class FireDoor {
   initAnimation() {
     const fireGroup = this.group.children[0]?.getObjectByName('fireDoor-redGate');
     if (fireGroup) {
+      // const doorGroup = new THREE.Object3D();
+      // doorGroup.add(fireGroup.children[0].getObjectByName('men_1'));
+      // doorGroup.add(fireGroup.children[0].getObjectByName('men2'));
       const tracks = fireGroup.animations[0].tracks;
 
       this.mixers = new THREE.AnimationMixer(fireGroup);
 
-      const door = new THREE.AnimationClip('door', 100, tracks);
-      const frontClipAction = this.mixers.clipAction(door, fireGroup);
+      const door = new THREE.AnimationClip('door', 2, tracks);
+      const frontClipAction = this.mixers.clipAction(door, fireGroup.children[0]);
       frontClipAction.clampWhenFinished = true;
       frontClipAction.loop = THREE.LoopOnce;
       this.clipActionArr.door = frontClipAction;
@@ -93,7 +96,7 @@ class FireDoor {
   }
 
   // 播放动画
-  play(handlerState, timeScale = 0.01) {
+  play(handlerState, timeScale = 0.1) {
     let handler = () => {};
     if (this.clipActionArr.door) {
       switch (handlerState) {
@@ -101,27 +104,20 @@ class FireDoor {
           handler = () => {
             this.clipActionArr.door.paused = true;
             this.clipActionArr.door.reset();
-            this.clipActionArr.door.time = 1.7;
-            this.clipActionArr.door.timeScale = -timeScale;
-            // this.clipActionArr.door.clampWhenFinished = true;
+            this.clipActionArr.door.time = 0.1;
+            this.clipActionArr.door.timeScale = timeScale;
             this.clipActionArr.door.play();
             this.fmClock.start();
-
-            // 显示打开前门文字
-            if (this.damperOpenMesh) this.damperOpenMesh.visible = true;
           };
           break;
         case 2: // 关闭门
           handler = () => {
             this.clipActionArr.door.paused = true;
             this.clipActionArr.door.reset(); //
-            this.clipActionArr.door.time = 0;
-            this.clipActionArr.door.timeScale = timeScale;
-            // this.clipActionArr.door.clampWhenFinished = true;
+            this.clipActionArr.door.time = 1.1;
+            this.clipActionArr.door.timeScale = -timeScale;
             this.clipActionArr.door.play();
             this.fmClock.start();
-
-            if (this.damperOpenMesh) this.damperOpenMesh.visible = false;
           };
           break;
         default:
@@ -130,6 +126,13 @@ class FireDoor {
     }
   }
 
+  resetAnimate() {
+    this.clipActionArr.door.reset();
+    this.clipActionArr.door.time = 0.1;
+    this.clipActionArr.door.stop();
+    this.fmClock.stop();
+  }
+
   mountedThree() {
     this.group = new THREE.Object3D();
     this.group.name = this.modelName;

+ 7 - 0
src/views/vent/monitorManager/fireDoorMonitor/fireDoor.threejs.fire.ts

@@ -130,6 +130,13 @@ class FireDoor {
     }
   }
 
+  resetAnimate() {
+    this.clipActionArr.door.reset();
+    this.clipActionArr.door.time = 0.1;
+    this.clipActionArr.door.stop();
+    this.fmClock.stop();
+  }
+
   mountedThree() {
     this.group = new THREE.Object3D();
     this.group.name = this.modelName;

+ 7 - 0
src/views/vent/monitorManager/fireDoorMonitor/fireDoor.threejs.fireF.ts

@@ -129,6 +129,13 @@ class FireDoorF {
     }
   }
 
+  resetAnimate() {
+    this.clipActionArr.door.reset();
+    this.clipActionArr.door.time = 0.1;
+    this.clipActionArr.door.stop();
+    this.fmClock.stop();
+  }
+
   mountedThree() {
     this.group = new THREE.Object3D();
     this.group.name = this.modelName;

+ 8 - 0
src/views/vent/monitorManager/fireDoorMonitor/fireDoor.threejs.ssl.ts

@@ -91,6 +91,14 @@ class FireDoor {
       this.clipActionArr.door = frontClipAction;
     }
   }
+  resetAnimate() {
+    if (this.clipActionArr.door) {
+      this.clipActionArr.door.reset();
+      this.clipActionArr.door.time = 0.1;
+      this.clipActionArr.door.stop();
+      this.fmClock.stop();
+    }
+  }
 
   // 播放动画
   play(handlerState, timeScale = 0.01) {

+ 33 - 93
src/views/vent/monitorManager/fireDoorMonitor/fireDoor.threejs.ts

@@ -75,7 +75,22 @@ export const play = (handlerState, flag?) => {
 
 // 切换风门类型
 export const setModelType = (type) => {
+  // 重置动画
+  if (fhmType === 'fireDoor' && fireDoor) {
+    fireDoor.resetAnimate();
+  }
+  if (fhmType === 'fireDoorF' && fireDoorF) {
+    fireDoorF.resetAnimate();
+  }
+  if (fhmType === 'fireDoorSsl' && fireDoorSsl) {
+    fireDoorSsl.resetAnimate();
+  }
+  if (fhmType === 'fireDoorRed' && fireDoorRed) {
+    fireDoorRed.resetAnimate();
+  }
+
   fhmType = type;
+
   const fhmConfigurations = {
     fireDoor: {
       render: fireDoor ? () => fireDoor.render() : null,
@@ -98,95 +113,29 @@ export const setModelType = (type) => {
     fireDoorRed: {
       render: fireDoorRed ? () => fireDoorRed.render() : null,
       group: fireDoorRed ? fireDoorRed.group : null,
-      newP: { x: 66.257, y: 57.539, z: 94.313 },
-      newT: { x: -2.28, y: -0.91, z: -5.68 },
+      newP: { x: 66.14, y: 52.98, z: 112.23 },
+      newT: { x: 6.049, y: 7.907, z: -25.566 },
     },
   };
+
+  if (type == 'fireDoor' || type == 'fireDoorF') {
+    model.orbitControls.maxPolarAngle = Math.PI / 2;
+    model.orbitControls.minPolarAngle = Math.PI / 3;
+    model.orbitControls.minDistance = 600;
+    model.orbitControls.maxDistance = 900;
+    model.orbitControls.update();
+  } else if (type == 'fireDoorRed' || type == 'fireDoorSsl') {
+    model.orbitControls.maxPolarAngle = Math.PI;
+    model.orbitControls.minPolarAngle = 0;
+    model.orbitControls.enableRotate = true;
+    model.orbitControls.minDistance = 0;
+    model.orbitControls.maxDistance = Infinity;
+    model.orbitControls.update();
+  }
+
   const config = fhmConfigurations[fhmType];
   const oldCameraPosition = { x: -1000, y: 100, z: 500 };
   return new Promise((resolve) => {
-    // 暂停风门1动画
-    // if (fhmType === 'fireDoor' && fireDoor && fireDoor.group) {
-    //   if (fireDoor.clipActionArr.door) {
-    //     fireDoor.clipActionArr.door.reset();
-    //     fireDoor.clipActionArr.door.time = 0.5;
-    //     fireDoor.clipActionArr.door.stop();
-    //   }
-
-    //   if (fireDoor.damperOpenMesh) fireDoor.damperOpenMesh.visible = false;
-    //   if (fireDoor.damperClosedMesh) fireDoor.damperClosedMesh.visible = true;
-    //   model.scene.remove(group);
-    //   model.startAnimation = fireDoor.render.bind(fireDoor);
-    //   group = fireDoor.group;
-    //   group.rotation.y = 0;
-    //   const oldCameraPosition = { x: -1000, y: 100, z: 500 };
-    //   setTimeout(async () => {
-    //     resolve(null);
-    //     model.scene.add(fireDoor.group);
-    //     await animateCamera(
-    //       oldCameraPosition,
-    //       { x: 0, y: 0, z: 0 },
-    //       { x: -654.2006991449887, y: 103.16181473511944, z: -30.348656073478562 },
-    //       { x: -7.380506513422206, y: 56.36967052459397, z: -29.230675020846963 },
-    //       model,
-    //       0.8
-    //     );
-    //   }, 300);
-    // } else if (fhmType === 'fireDoorF' && fireDoorF && fireDoorF.group) {
-    //   if (fireDoorF.clipActionArr.door) {
-    //     fireDoorF.clipActionArr.door.reset();
-    //     fireDoorF.clipActionArr.door.time = 0;
-    //     fireDoorF.clipActionArr.door.stop();
-    //   }
-    //   model.scene.remove(group);
-    //   model.startAnimation = fireDoorF.render.bind(fireDoorF);
-    //   group = fireDoorF.group;
-    //   group.rotation.y = 0;
-    //   const oldCameraPosition = { x: -1000, y: 100, z: 500 };
-    //   setTimeout(async () => {
-    //     resolve(null);
-    //     model.scene.add(fireDoorF.group);
-    //     await animateCamera(
-    //       oldCameraPosition,
-    //       { x: 0, y: 0, z: 0 },
-    //       { x: -655.0169729333649, y: 47.24181078408825, z: -9.781926649842067 },
-    //       { x: -7.380506513422206, y: 47.24181078408821, z: -37.9244016972381 },
-    //       model,
-    //       0.8
-    //     );
-    //   }, 300);
-    // } else if (fhmType === 'fireDoorSsl' && fireDoorSsl && fireDoorSsl.group) {
-    //   // if (fireDoorSsl.clipActionArr.door) {
-    //   //   fireDoorSsl.clipActionArr.door.reset();
-    //   //   fireDoorSsl.clipActionArr.door.time = 0;
-    //   //   fireDoorSsl.clipActionArr.door.stop();
-    //   // }
-    //   // model.scene.remove(group);
-    //   // model.startAnimation = fireDoorSsl.render.bind(fireDoorSsl);
-    //   group = fireDoorSsl.group;
-    //   group.rotation.y = 0;
-    //   const oldCameraPosition = { x: -1000, y: 100, z: 500 };
-    //   setTimeout(async () => {
-    //     resolve(null);
-    //     model.scene.add(fireDoorSsl.group);
-    //     await animateCamera(
-    //       oldCameraPosition,
-    //       { x: 0, y: 0, z: 0 },
-    //       {
-    //         x: 342.74781900192056,
-    //         y: 183.50210411099545,
-    //         z: 451.0806333923029,
-    //       },
-    //       {
-    //         x: 72.33938301176254,
-    //         y: -35.03891296652319,
-    //         z: -37.91742549963208,
-    //       },
-    //       model,
-    //       0.8
-    //     );
-    //   }, 300);
-    // }
     if (config && config.group) {
       model.startAnimation = config.render;
       group = config.group;
@@ -214,14 +163,6 @@ export const initCameraCanvas = async (playerVal1) => {
     return await fireDoorRed.initCamera.call(fireDoorRed, playerVal1);
   }
 };
-const setControls = () => {
-  if (model && model.orbitControls) {
-    model.orbitControls.maxPolarAngle = Math.PI / 2;
-    model.orbitControls.minPolarAngle = Math.PI / 3;
-    model.orbitControls.minDistance = 600;
-    model.orbitControls.maxDistance = 900;
-  }
-};
 
 const loadModel = (code): Promise<any> => {
   if (code === 'fireDoor') return import('./fireDoor.threejs.fire').then((r) => r.default);
@@ -271,7 +212,6 @@ export const mountedThree = () => {
       fireDoorRed.mountedThree();
     }
     resolve(null);
-    setControls();
     model.animate();
     startAnimation();
   });

+ 11 - 8
src/views/vent/monitorManager/fireDoorMonitor/index.vue

@@ -315,16 +315,17 @@
     selectRowIndex.value = index;
     const baseData: any = deviceBaseList.value.find((baseData: any) => baseData.id === selectRow.deviceID);
     Object.assign(selectData, initData, selectRow, baseData);
-    doorDeviceState = 1; //记录设备状态,为了与下一次监测数据做比较
+    doorDeviceState = 0; //记录设备状态,为了与下一次监测数据做比较
+    isdoorOpenRunning = false; //开关门动作是否在进行
     let type = 'fireDoorRed';
-    // if (selectData.modelType == 'bd_qt') {
-    //   type = 'fireDoor';
-    // } else if (selectData.modelType == 'bd_kj') {
-    //   type = 'fireDoorF';
-    // }
+    if (selectData.modelType == 'bd_qt') {
+      type = 'fireDoor';
+    } else if (selectData.modelType == 'bd_kj') {
+      type = 'fireDoorF';
+    }
     await setModelType(type);
     loading.value = false;
-    isdoorOpenRunning = true; //开关门动作是否在进行
+
     await getCamera(selectRow.deviceID, playerRef.value);
   }
 
@@ -408,7 +409,7 @@
   let isdoorOpenRunning = false; //开关门动作是否在进行
   // let isMidCloseRunning = false; //中间门动作是否在进行
   // 0 关闭 1 正在打开 2 打开 3正在关闭
-  let doorDeviceState = 1; //记录设备状态,为了与下一次监测数据做比较
+  let doorDeviceState = 0; //记录设备状态,为了与下一次监测数据做比较
   function monitorAnimation(selectData) {
     const timeScale = 0.005;
     // 打开
@@ -417,6 +418,7 @@
       if (doorDeviceState != 1) {
         // import.meta.env.VITE_GLOB_IS_SIMULATE ? play(1, timeScale) : play(1);
         play(1, timeScale);
+        debugger;
         doorDeviceState = 1;
         doorIsOpen.value = true;
       }
@@ -427,6 +429,7 @@
       if (doorDeviceState != 0) {
         // import.meta.env.VITE_GLOB_IS_SIMULATE ? play(1, timeScale) : play(1);
         play(2, timeScale);
+        debugger;
         doorDeviceState = 0;
         doorIsOpen.value = false;
       }