Sfoglia il codice sorgente

Merge branch 'jay' of zengminguo/D-MAP into master

zengminguo 6 mesi fa
parent
commit
590cde1880
2 ha cambiato i file con 91 aggiunte e 174 eliminazioni
  1. 91 173
      src/uwb-sample.js
  2. 0 1
      src/views/ordinaryPage/index.vue

+ 91 - 173
src/uwb-sample.js

@@ -159,6 +159,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
           // sprite.scale.set(100, 100, 1);
           mesh.position.set(x, y + 10, z);
           mesh.rotation.set(-Math.PI / 2, 0, 0);
+          // mesh.scale.set(0.2, 0.2, 0.2)
 
           if (sdkInstance) {
             if (benchIdList.indexOf(Number(bench_id)) >= 0) {
@@ -192,7 +193,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
             let ang_y = 0.0;
             let ang_z = 0.0;
             let benchType = item.bench_type;
-  
+
             if (true) {
               x = JSON.parse(JSON.stringify(item.fix_pos_x));
               y = JSON.parse(JSON.stringify(item.fix_pos_y));
@@ -201,7 +202,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
               ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
               ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
             }
-  
+
             let card_id = item.card_id;
             let bench_id = item.bench_id;
             let bench_img = item.bench_img;
@@ -222,12 +223,12 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
                 benchImg: bench_img,
               };
               childMeshTmp.userData = customData;
-  
+
               if (benchIdList.indexOf(Number(bench_id)) >= 0) {
                 if (!window.benchMeshMap[bench_id]) {
                   window.benchMeshMap[bench_id] = childMeshTmp;
                   sdkInstance.sceneRenderer.scene.add(childMeshTmp)
-  
+
                 } else {
                   let deleteChildMesh = window.benchMeshMap[bench_id];
                   sdkInstance.sceneRenderer.scene.remove(deleteChildMesh)
@@ -236,7 +237,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
                   deleteChildMesh = null; // 置空指向该3D模型的变量
                   window.benchMeshMap[bench_id] = childMeshTmp;
                   sdkInstance.sceneRenderer.scene.add(childMeshTmp);
-  
+
                 }
               }
             }
@@ -399,7 +400,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
               ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
               ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
             }
-            
+
             let card_id = item.card_id;
             let bench_id = item.bench_id;
             let show_remote_button = item.show_remote_button;
@@ -611,7 +612,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
             let ang_y = 0.0;
             let ang_z = 0.0;
             let benchType = item.bench_type;
-  
+
             if (true) {
               x = JSON.parse(JSON.stringify(item.fix_pos_x));
               y = JSON.parse(JSON.stringify(item.fix_pos_y));
@@ -620,7 +621,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
               ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
               ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
             }
-  
+
             let card_id = item.card_id;
             let bench_id = item.bench_id;
             let bench_img = item.bench_img;
@@ -642,13 +643,12 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
                 benchImg: bench_img,
               };
               childMeshTmp.userData = customData;
-  
+
               if (benchIdList.indexOf(Number(bench_id)) >= 0) {
                 if (!window.benchMeshMap[bench_id]) {
                   window.benchMeshMap[bench_id] = childMeshTmp;
                   sdkInstance.sceneRenderer.scene.add(childMeshTmp)
-                }
-                else {
+                } else {
                   let deleteChildMesh = window.benchMeshMap[bench_id];
                   sdkInstance.sceneRenderer.scene.remove(deleteChildMesh)
                   deleteChildMesh.geometry.dispose(); // 清理几何体
@@ -832,7 +832,14 @@ function getsqlDataRealTime() {
       //   let bench_id = item.bench_id;
       //   let show_remote_button = item.show_remote_button;
 
-      //   if (item.use_fix_pos == 1) {
+      //   if (item.use_fix_pos == 0) {
+      //     x = JSON.parse(JSON.stringify(item.x));
+      //     y = JSON.parse(JSON.stringify(item.fix_pos_y));
+      //     z = JSON.parse(JSON.stringify(item.z));
+      //     ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
+      //     ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
+      //     ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
+      //   } else if (item.use_fix_pos == 1) {
       //     x = JSON.parse(JSON.stringify(item.fix_pos_x));
       //     y = JSON.parse(JSON.stringify(item.fix_pos_y));
       //     z = JSON.parse(JSON.stringify(item.fix_pos_z));
@@ -893,26 +900,28 @@ function getsqlDataRealTime() {
 
       //   }
 
-      //   // if (window.benchMeshMap[item.bench_id] && window.benchMeshWaterMap[item.bench_id]) {
-      //   //   window.benchMeshMap[item.bench_id].position.set(x, y, z);
-      //   //   // window.benchMeshWaterMap[item.bench_id].position.set(x, y + 10, z);
-      //   //   // if (item.use_fix_pos == 0) {
-      //   //   //   window.benchMeshMap[item.bench_id].position.set(x - 14.7, JSON.parse(JSON.stringify(item.fix_pos_y)), y - 14);
-      //   //   //   window.benchMeshWaterMap[item.bench_id].position.set(x - 14.7, JSON.parse(JSON.stringify(item.fix_pos_y)) + 10, y - 14);
-      //   //   // }
-      //   //   var localPosition = new THREE.Vector3(window.benchMeshMap[item.bench_id].position.x, window.benchMeshMap[item.bench_id].position.y, window.benchMeshMap[item.bench_id].position.z);
-      //   //   var worldPosition = window.uwbInstance.convertLocalToWorld(localPosition);
-      //   //   var pos = window.sdkInstance.getScreenPosition(worldPosition);
-      //   //   window.benchPosList.forEach(function (element) {
-      //   //     if (element.benchId == item.bench_id) {
-      //   //       element.x = pos.x
-      //   //       element.y = pos.y
-      //   //       element.benchType = item.bench_type
-      //   //       element.benchId = item.bench_id
-      //   //       element.benchImg = item.bench_img
-      //   //     }
-      //   //   })
-      //   // }
+      //   if (window.benchMeshMap[item.bench_id] && window.benchMeshWaterMap[item.bench_id]) {
+
+      //     if (item.use_fix_pos == 0) {
+      //       window.benchMeshMap[item.bench_id].position.set(x - 14.7, y, z - 14);
+      //       window.benchMeshWaterMap[item.bench_id].position.set(x - 14.7, y + 10, z - 14);
+      //     } else {
+      //       window.benchMeshMap[item.bench_id].position.set(x, y, z);
+      //       window.benchMeshWaterMap[item.bench_id].position.set(x, y + 10, z);
+      //     }
+      //     var localPosition = new THREE.Vector3(window.benchMeshMap[item.bench_id].position.x, window.benchMeshMap[item.bench_id].position.y, window.benchMeshMap[item.bench_id].position.z);
+      //     var worldPosition = window.uwbInstance.convertLocalToWorld(localPosition);
+      //     var pos = window.sdkInstance.getScreenPosition(worldPosition);
+      //     window.benchPosList.forEach(function (element) {
+      //       if (element.benchId == item.bench_id) {
+      //         element.x = pos.x
+      //         element.y = pos.y
+      //         element.benchType = item.bench_type
+      //         element.benchId = item.bench_id
+      //         element.benchImg = item.bench_img
+      //       }
+      //     })
+      //   }
       // }
       // window.showBenchPos(window.benchPosList);
     });
@@ -922,11 +931,11 @@ function getsqlDataRealTime() {
 }
 // 刷新水滴
 function waterRefresh(result) {
-  console.log("刷新水滴")
+  // console.log("刷新水滴")
   let benchList = window.store ? window.store.getters['benchList/getBenchList'] : [];
   let statusList = benchList.map(b => b.status).join();
   if (statusList == oldStatus) { // 水滴无变化,只需移动原模型位置
-    console.log("水滴状态无变化")
+    // console.log("水滴状态无变化")
     for (var item of result) {
       let x = item.x;
       let y = item.y;
@@ -940,9 +949,9 @@ function waterRefresh(result) {
       let show_remote_button = item.show_remote_button;
 
       if (item.use_fix_pos == 0) {
-        x = JSON.parse(JSON.stringify(item.x));
+        x = JSON.parse(JSON.stringify(item.x)) - 12.4; // 页面原点x和实际原点(8号基站位置)x偏移量为 12.4m
         y = JSON.parse(JSON.stringify(item.fix_pos_y));
-        z = JSON.parse(JSON.stringify(item.z));
+        z = 6.8 - JSON.parse(JSON.stringify(item.z)); // 页面原点y和实际原点(8号基站位置)y偏移量为 6.8m
         ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
         ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
         ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
@@ -954,62 +963,15 @@ function waterRefresh(result) {
         ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
         ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
       }
-      // else if (item.use_fix_pos == 2) {
-      //   var distance = 10000.0;
-      //   var xSubTmp = x;
-      //   var ySubTmp = y;
-      //   var zSubTmp = z;
-      //   x = x - 14.7;
-      //   z = y - 14
-      //   var ang_xSubTmp = ang_x;
-      //   var ang_ySubTmp = ang_y;
-      //   var ang_zSubTmp = ang_z;
-      //   if (window.benchDBList) {
-      //     var iCount = 0;
-      //     for (var itemSub of window.benchDBList) {
-      //       iCount++;
-      //       var xSub = itemSub.x;
-      //       var ySub = itemSub.y;
-      //       var zSub = itemSub.z;
-      //       var ang_xSub = 0.0;
-      //       var ang_ySub = 0.0;
-      //       var ang_zSub = 0.0;
-      //       xSub = itemSub.fix_pos_x;
-      //       ySub = itemSub.fix_pos_y;
-      //       zSub = itemSub.fix_pos_z;
-      //       ang_xSub = itemSub.fix_angle_x;
-      //       ang_ySub = itemSub.fix_angle_y;
-      //       ang_zSub = itemSub.fix_angle_z;
-      //       var disTmp = Math.sqrt(Math.pow(x - xSub, 2) + Math.pow(z - zSub, 2))
-      //       if (disTmp < distance) {
-      //         distance = disTmp;
-      //         xSubTmp = xSub;
-      //         ySubTmp = ySub;
-      //         zSubTmp = zSub;
-      //         ang_xSubTmp = ang_xSub;
-      //         ang_ySubTmp = ang_ySub;
-      //         ang_zSubTmp = ang_zSub;
-      //       }
-      //     }
-      //   }
-      //   x = xSubTmp;
-      //   y = ySubTmp;
-      //   z = zSubTmp;
-      //   ang_x = ang_xSubTmp;
-      //   ang_y = ang_ySubTmp;
-      //   ang_z = ang_zSubTmp;
-  
-      //   x = JSON.parse(JSON.stringify(xSubTmp));
-      //   y = JSON.parse(JSON.stringify(ySubTmp));
-      //   z = JSON.parse(JSON.stringify(zSubTmp));
-      //   ang_x = JSON.parse(JSON.stringify(ang_xSubTmp));
-      //   ang_y = JSON.parse(JSON.stringify(ang_ySubTmp));
-      //   ang_z = JSON.parse(JSON.stringify(ang_zSubTmp));
-      // }
-      
-      
+
       // let num = Math.floor((Math.random() * 10) + 1)
 
+      // 查看对应的像素点
+      // var localPosition = new THREE.Vector3(x, y, z);
+      // var worldPosition = window.uwbInstance.convertLocalToWorld(localPosition);
+      // var pos = window.sdkInstance.getScreenPosition(worldPosition);
+      // console.log("转换的像素点位", pos)
+
       let benchIdList = benchList.map(m => m.id);
       if (benchIdList.indexOf(Number(bench_id)) >= 0) {
         // console.log('移动原水滴模型位置', bench_id)
@@ -1024,11 +986,11 @@ function waterRefresh(result) {
         //   type: 'water'
         // };
         // meshChild.userData = customData;
-        meshChild.position.set(x, y+10, z);
+        meshChild.position.set(x, y + 10, z);
       }
     }
   } else { // 水滴变化,需移除原模型后重新添加新模型
-    console.log("水滴状态变化")
+    // console.log("水滴状态变化")
     oldStatus = statusList;
     for (var item of result) {
       let x = item.x;
@@ -1043,9 +1005,9 @@ function waterRefresh(result) {
       let show_remote_button = item.show_remote_button;
 
       if (item.use_fix_pos == 0) {
-        x = JSON.parse(JSON.stringify(item.x));
+        x = JSON.parse(JSON.stringify(item.x)) - 12.4; // 页面原点x和实际原点(8号基站位置)x偏移量为 12.4m
         y = JSON.parse(JSON.stringify(item.fix_pos_y));
-        z = JSON.parse(JSON.stringify(item.z));
+        z = 6.8 - JSON.parse(JSON.stringify(item.z)); // 页面原点y和实际原点(8号基站位置)y偏移量为 6.8m
         ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
         ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
         ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
@@ -1057,65 +1019,25 @@ function waterRefresh(result) {
         ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
         ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
       }
-      // else if (item.use_fix_pos == 2) {
-      //   var distance = 10000.0;
-      //   var xSubTmp = x;
-      //   var ySubTmp = y;
-      //   var zSubTmp = z;
-      //   x = x - 14.7;
-      //   z = y - 14
-      //   var ang_xSubTmp = ang_x;
-      //   var ang_ySubTmp = ang_y;
-      //   var ang_zSubTmp = ang_z;
-      //   if (window.benchDBList) {
-      //     var iCount = 0;
-      //     for (var itemSub of window.benchDBList) {
-      //       iCount++;
-      //       var xSub = itemSub.x;
-      //       var ySub = itemSub.y;
-      //       var zSub = itemSub.z;
-      //       var ang_xSub = 0.0;
-      //       var ang_ySub = 0.0;
-      //       var ang_zSub = 0.0;
-      //       xSub = itemSub.fix_pos_x;
-      //       ySub = itemSub.fix_pos_y;
-      //       zSub = itemSub.fix_pos_z;
-      //       ang_xSub = itemSub.fix_angle_x;
-      //       ang_ySub = itemSub.fix_angle_y;
-      //       ang_zSub = itemSub.fix_angle_z;
-      //       var disTmp = Math.sqrt(Math.pow(x - xSub, 2) + Math.pow(z - zSub, 2))
-      //       if (disTmp < distance) {
-      //         distance = disTmp;
-      //         xSubTmp = xSub;
-      //         ySubTmp = ySub;
-      //         zSubTmp = zSub;
-      //         ang_xSubTmp = ang_xSub;
-      //         ang_ySubTmp = ang_ySub;
-      //         ang_zSubTmp = ang_zSub;
-      //       }
-      //     }
-      //   }
-      //   x = xSubTmp;
-      //   y = ySubTmp;
-      //   z = zSubTmp;
-      //   ang_x = ang_xSubTmp;
-      //   ang_y = ang_ySubTmp;
-      //   ang_z = ang_zSubTmp;
-  
-      //   x = JSON.parse(JSON.stringify(xSubTmp));
-      //   y = JSON.parse(JSON.stringify(ySubTmp));
-      //   z = JSON.parse(JSON.stringify(zSubTmp));
-      //   ang_x = JSON.parse(JSON.stringify(ang_xSubTmp));
-      //   ang_y = JSON.parse(JSON.stringify(ang_ySubTmp));
-      //   ang_z = JSON.parse(JSON.stringify(ang_zSubTmp));
-      // }
 
       // 移除已加载的水滴
       if (window.benchMeshWaterMap[bench_id]) {
-        window.sdkInstance.sceneRenderer.scene.remove(window.benchMeshWaterMap[bench_id]);
+        // window.sdkInstance.sceneRenderer.scene.remove(window.benchMeshWaterMap[bench_id]);
+        let deleteChildMesh = window.benchMeshWaterMap[bench_id];
+        window.sdkInstance.sceneRenderer.scene.remove(deleteChildMesh)
+
+        deleteChildMesh.geometry.dispose(); // 清理几何体
+        deleteChildMesh.material.dispose(); // 清理材质
+        deleteChildMesh = null; // 置空指向该3D模型的变量
+        // window.benchMeshWaterMap[bench_id] = childMeshTmp;
+        // window.sdkInstance.sceneRenderer.scene.add(childMeshTmp);
       }
 
       let currentBench = benchList.find(b => b.id == bench_id);
+
+      // 创建几何体
+      const geometry = new THREE.PlaneGeometry(1.2, 1.2);
+      // 创建材质
       let texture = null;
       if (currentBench) {
         switch (currentBench.status) {
@@ -1135,9 +1057,6 @@ function waterRefresh(result) {
       } else {
         texture = textureOffline;
       }
-
-      // 创建水滴模型
-      const geometry = new THREE.PlaneGeometry(1.2, 1.2);
       let uniformsA = {
         amplitude: { value: 1.0 },
         color: { value: new THREE.Color(0xff2200) },
@@ -1160,6 +1079,7 @@ function waterRefresh(result) {
         side: THREE.DoubleSide,
         transparent: true
       });
+      // 创建水滴
       const mesh = new THREE.Mesh(geometry, shaderMaterial);
 
       var customData = {
@@ -1182,16 +1102,16 @@ function waterRefresh(result) {
 }
 // 刷新台架
 function benchRefresh(result) {
-  console.log("刷新台架")
+  // console.log("刷新台架")
   let benchList = window.store ? window.store.getters['benchList/getBenchList'] : [];
   let benchIdList = benchList.map(m => m.id);
   let newBenchIds = benchIdList.join();
   if (newBenchIds == oldBenchIds) { // 台架无变化,只需移动原模型位置
-    console.log("台架id无变动")
+    // console.log("台架id无变动")
     // if (window.benchMeshMap[item.bench_id]) {
     // }
   } else { // 台架变化,需移除原模型后重新添加新模型
-    console.log("台架id变动")
+    // console.log("台架id变动")
     oldBenchIds = newBenchIds;
   }
 }
@@ -1223,12 +1143,12 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
   let sdkInstance = null;
   window.renderHeight = modelHeight;
   window.renderWidth = modelWidth;
-  var geometry = new THREE.ConeGeometry(radius, height, segments);
-  var material1 = new THREE.MeshBasicMaterial({
-    color: color,
-    opacity: 0.2,
-    transparent: true,
-  });
+  // var geometry = new THREE.ConeGeometry(radius, height, segments);
+  // var material1 = new THREE.MeshBasicMaterial({
+  //   color: color,
+  //   opacity: 0.2,
+  //   transparent: true,
+  // });
 
   fetchAndCombine().then(([err, data]) => {
     if (err) {
@@ -1325,7 +1245,6 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
           g_gltf_downloaded = true;
         }
 
-
         if (g_fbxLoader == null) {
           // g_fbxLoader = new THREE.GLTFLoader();
           // g_fbxLoader.load("../models/mesh2.gltf", function (fbx) {
@@ -1365,7 +1284,6 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
           getsqlData(sdkInstance, uwbInstance, false);
         }
 
-
         // 创建物体add
         // 模型加载完成,进入模型页面,添加摆放的物体
         let canvas = document.getElementsByTagName('canvas')[0];
@@ -1456,20 +1374,20 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
             for (let z = 0; z < intersects.length; z++) {
               let m = intersects[z];
               if (m && m.object && (m.object.userData.type == 'water')) {
-                //window.store.dispatch('benchList/setMouseOverBench', {
-                //  bench_id: m.object.userData.benchId,
-                //  pageX: event.x,
-                //  pageY: event.y,
-                //  status: true
-                //})
+                // window.store.dispatch('benchList/setMouseOverBench', {
+                //   bench_id: m.object.userData.benchId,
+                //   pageX: event.x,
+                //   pageY: event.y,
+                //   status: true
+                // })
                 break;
               } else {
-                //window.store.dispatch('benchList/setMouseOverBench', {
-                //  bench_id: m.object.userData.benchId,
-                //  pageX: event.x,
-                //  pageY: event.y,
-                //  status: false
-                //})
+                // window.store.dispatch('benchList/setMouseOverBench', {
+                //   bench_id: m.object.userData.benchId,
+                //   pageX: event.x,
+                //   pageY: event.y,
+                //   status: false
+                // })
               }
             }
             bool = false;

+ 0 - 1
src/views/ordinaryPage/index.vue

@@ -954,7 +954,6 @@ export default {
 
     // 调用定时器方法,返回定时器id,用于按条件清空
     that.timerId = that.myInterval((count) => {
-      console.log("刷新", Date.now())
       this.$store.dispatch("benchList/fetchBenchList").then(() => {
         // this.refreshBenchStatus();
         // if (!this.waterdotrefresh) {