deepsea 8 months ago
parent
commit
e8b6951311
1 changed files with 14 additions and 2 deletions
  1. 14 2
      src/uwb-sample.js

+ 14 - 2
src/uwb-sample.js

@@ -17,6 +17,7 @@ window.benchListInterval = null;
 window.otherInterval = null;
 var fbxLoader1Loaded = false;
 var fbxLoader2Loaded = false;
+var oldStatus = '';
 
 let textureLoader = new THREE.TextureLoader();
 let textureReady = textureLoader.load('../images/location_ready.png');
@@ -135,6 +136,12 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
           let show_remote_button = item.show_remote_button;
           // 添加水滴
           let benchList = window.store ? window.store.getters['benchList/getBenchList'] : [];
+
+          let statusList = benchList.map(b => b.status).join();
+          if (statusList == oldStatus) {
+            return;
+          }
+
           let benchIdList = window.store.getters['benchList/getBenchList'].map(m => m.id);
           let currentBench = benchList.find(b => b.id == bench_id);
           let texture = null;
@@ -332,7 +339,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
 
               console.log('添加模型和水滴1111')
               if (benchIdList.indexOf(Number(bench_id)) > 0) {
-                if (window.benchMeshMap[bench_id]) {
+                if (!window.benchMeshMap[bench_id]) {
                   window.benchMeshMap[bench_id] = childMeshTmp;
                   sdkInstance.sceneRenderer.scene.add(childMeshTmp)
                 }
@@ -459,7 +466,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
               };
               childMeshTmp.userData = customData;
 
-              if (window.benchMeshMap[bench_id]) {
+              if (!window.benchMeshMap[bench_id]) {
                 window.benchMeshMap[bench_id] = childMeshTmp;
                 sdkInstance.sceneRenderer.scene.add(childMeshTmp)
               }
@@ -793,6 +800,11 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
             let benchIdList = window.store.getters['benchList/getBenchList'].map(m => m.id);
             if (benchIdList.length > 0) {
               // clearInterval(benchListInterval)
+              let statusList = benchIdList.map(b => b.status).join();
+              if (statusList == oldStatus) {
+                return;
+              }
+              oldStatus = statusList;
               getsqlData(sdkInstance, uwbInstance, false)
             }
           }, 6 * 1000);