57862207 1 year ago
parent
commit
98b536268d
1 changed files with 25 additions and 7 deletions
  1. 25 7
      src/uwb-sample.js

+ 25 - 7
src/uwb-sample.js

@@ -465,13 +465,14 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
             if(!window.otherInterval)
             {
               window.otherInterval = setInterval(() => {
-                if (uwbInstance) {
+                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 = uwbInstance.convertLocalToWorld(localPosition);
-                    var pos = sdkInstance.getScreenPosition(worldPosition);
+                    var worldPosition = window.uwbInstance.convertLocalToWorld(localPosition);
+                    var pos = window.sdkInstance.getScreenPosition(worldPosition);
                     benchPosList.push(
                       {
                         x: pos.x,
@@ -484,9 +485,11 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
                   }
                   console.log('benchPosList',benchPosList)
                   window.showBenchPos(benchPosList);
+                  setInterval(()=>{
+                    getsqlDataRealTime();
+                  },30*1000)
                 }
-                setTimeout(() => { getsqlDataRealTime(); }, 10);
-              }, 60 * 1000)
+              }, 2 * 1000)
             }
           }
         })
@@ -498,7 +501,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);
@@ -513,6 +516,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;
@@ -590,9 +594,22 @@ function getsqlDataRealTime() {
             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(x, y, z);
+          var worldPosition = window.uwbInstance.convertLocalToWorld(window.benchMeshMap[item.bench_id].position);
+          var pos = window.sdkInstance.getScreenPosition(worldPosition);
+          benchPosList.push(
+            {
+              x: pos.x,
+              y: pos.y,
+              benchType: item.bench_type,
+              benchId: item.bench_id,
+              benchImg: item.bench_img,
+            }
+          )
         }
-        
       }
+      console.log('benchPosList', benchPosList)
+      window.showBenchPos(benchPosList);
     });
   }
 
@@ -680,6 +697,7 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
 
       sdkInstance.on("endLoading", (mode) => {
         console.log(mode, '-----+++++-----')
+        console.log('endLoading')
         vrBgContainer.style.display = "none";
 
         // 本地坐标系原点位姿