Explorar o código

Merge branch 'master' of http://121.42.8.157:13000/zengminguo/D-MAP

deepsea hai 1 ano
pai
achega
1d4f2deadf
Modificáronse 1 ficheiros con 56 adicións e 27 borrados
  1. 56 27
      src/uwb-sample.js

+ 56 - 27
src/uwb-sample.js

@@ -26,6 +26,7 @@ let textureOffline = textureLoader.load('../images/location_offline.png');
 window.benchMeshMap = {};
 window.benchMeshWaterMap = {};
 window.benchDBList = null
+window.benchPosList = [];
 
 function getsqlData(sdkInstance, uwbInstance, bAddModel) {
   let g_PosArrayResult = null;
@@ -462,28 +463,35 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
             }
           };
           if (!sessionStorage.getItem('3dMode') || sessionStorage.getItem('3dMode') == 0) {
-            otherInterval = setInterval(() => {
-              if (uwbInstance) {
-                clearInterval(otherInterval)
-                var benchPosList = [];
-                for (var item of result) {
-                  var localPosition = new THREE.Vector3(item.fix_pos_x, item.fix_pos_y, item.fix_pos_z);
-                  var worldPosition = uwbInstance.convertLocalToWorld(localPosition);
-                  var pos = sdkInstance.getScreenPosition(worldPosition);
-                  benchPosList.push(
-                    {
-                      x: pos.x,
-                      y: pos.y,
-                      benchType: item.bench_type,
-                      benchId: item.bench_id,
-                      benchImg: item.bench_img,
-                    }
-                  )
+            if(!window.otherInterval)
+            {
+              window.otherInterval = setInterval(() => {
+                if (window.uwbInstance) 
+                {
+                  clearInterval(window.otherInterval)
+                  //var benchPosList = [];
+                  for (var item of result) {
+                    var localPosition = new THREE.Vector3(item.fix_pos_x, item.fix_pos_y, item.fix_pos_z);
+                    var worldPosition = window.uwbInstance.convertLocalToWorld(localPosition);
+                    var pos = window.sdkInstance.getScreenPosition(worldPosition);
+                    window.benchPosList.push(
+                      {
+                        x: pos.x,
+                        y: pos.y,
+                        benchType: item.bench_type,
+                        benchId: item.bench_id,
+                        benchImg: item.bench_img,
+                      }
+                    )
+                  }
+                  console.log('benchPosList',window.benchPosList)
+                  window.showBenchPos(window.benchPosList);
+                  setInterval(()=>{
+                    getsqlDataRealTime();
+                  },60*1000)
                 }
-                window.showBenchPos(benchPosList);
-                setInterval(() => { getsqlDataRealTime(); }, 5 * 60 * 1000)
-              }
-            }, 2000)
+              }, 2 * 1000)
+            }
           }
         })
       }
@@ -494,7 +502,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
 
 function getsqlDataRealTime() {
   if (true) {
-    var sqlstr = "select t3.* ,t4.fix_pos_x, t4.fix_pos_y, t4.fix_pos_z,t4.fix_angle_x, t4.fix_angle_y, t4.fix_angle_z, t4.bench_id, t4.use_fix_pos from (SELECT t1.* FROM his_location_tadiao_result_unity t1 INNER JOIN (SELECT MAX(loc_time) AS max_loc_time FROM his_location_tadiao_result_unity GROUP BY card_id) t2 ON t1.loc_time = t2.max_loc_time) as t3 INNER JOIN dat_bench_extend t4 ON (t4.card_id=t3.card_id)";
+    var sqlstr = "select t3.* ,t4.fix_pos_x, t4.fix_pos_y, t4.fix_pos_z,t4.fix_angle_x, t4.fix_angle_y, t4.fix_angle_z, t4.bench_type, t4.bench_id, t4.bench_img, t4.use_fix_pos from (SELECT t1.* FROM his_location_tadiao_result_unity t1 INNER JOIN (SELECT MAX(loc_time) AS max_loc_time FROM his_location_tadiao_result_unity GROUP BY card_id) t2 ON t1.loc_time = t2.max_loc_time) as t3 INNER JOIN dat_bench_extend t4 ON (t4.card_id=t3.card_id)";
 
     //sqlstr = sqlstr.format(two_seconds_ago, two_seconds_ago)
     console.log(sqlstr);
@@ -509,6 +517,7 @@ function getsqlDataRealTime() {
     // 触发事件进行从服务器获取数据
     window.vm.$socket.emit("REPT", msg, (datas) => {
       let result = datas.data;
+      //var benchPosList = [];
       for (var item of result) {
         let x = item.x;
         let y = item.y;
@@ -578,13 +587,32 @@ function getsqlDataRealTime() {
           ang_z = JSON.parse(JSON.stringify(ang_zSubTmp));
 
         }
-        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);
+        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
+            }
+          })
         }
       }
+      console.log('benchPosList', window.benchPosList)
+      window.showBenchPos(window.benchPosList);
     });
   }
 
@@ -672,6 +700,7 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
 
       sdkInstance.on("endLoading", (mode) => {
         console.log(mode, '-----+++++-----')
+        console.log('endLoading')
         vrBgContainer.style.display = "none";
 
         // 本地坐标系原点位姿