Browse Source

model move

xyh 1 year ago
parent
commit
900071b21f
2 changed files with 35 additions and 12 deletions
  1. 18 12
      src/views/simulation/index.vue
  2. 17 0
      vue.config.js

+ 18 - 12
src/views/simulation/index.vue

@@ -117,7 +117,7 @@ export default {
   mounted() {
     this.cesiumInit();
     // this.pointMove();
-    this.startWebSocket();
+    // this.startWebSocket();
   },
   beforeDestroy() {
     // 在组件销毁前,关闭WebSocket连接
@@ -777,10 +777,10 @@ export default {
       //   .get("/api", this.jsonData).then(res=>{
       //     console.log('res :>> ', res);
       //   })
-      // await axios
-      //   .post("/api/traj", this.jsonData).then(res=>{
-      //     console.log('res :>> ', res);
-      //   })
+      await axios
+        .post("/api/traj", this.jsonData).then(res=>{
+          console.log('res :>> ', res);
+        })
 
     },
     // 根据时间参数请求模型位置并更新 2D
@@ -793,11 +793,11 @@ export default {
       await axios
         .post("/api/pos", {simulation_time: newTimeString+'.000'}).then(res=>{
           console.log('res :>> ', res);
-          let data = res.data[1]
+          let data = res.data[1].data
           //依次更新每个模型位置
           for(let i=0;i<this.nameIdList.length;i++){
             if(data[this.nameIdList[i].name]!=null&&data[this.nameIdList[i].name]!=undefined){
-              this.modelEntityMoveByIDAndLocation(this.viewer2D,this.nameIdList[i].id,data[this.nameIdList[i].name].x,id,data[this.nameIdList[i].name].y,id,data[this.nameIdList[i].name].z)
+              this.modelEntityMoveByIDAndLocation(this.viewer2D,this.nameIdList[i].id,data[this.nameIdList[i].name].x,data[this.nameIdList[i].name].y,data[this.nameIdList[i].name].z)
             }
           }
           //更新模型位置
@@ -814,12 +814,16 @@ export default {
       const newTimeString = `${jsDate.getFullYear()}-${(jsDate.getMonth() + 1).toString().padStart(2, '0')}-${jsDate.getDate().toString().padStart(2, '0')} ${jsDate.getHours().toString().padStart(2, '0')}:${jsDate.getMinutes().toString().padStart(2, '0')}:${jsDate.getSeconds().toString().padStart(2, '0')}`;
       await axios
         .post("/api/pos", {simulation_time: newTimeString+'.000'}).then(res=>{
-          console.log('res :>> ', res);
-          let data = res.data[1]
+          let data = res.data[1].data
+        
           //依次更新每个模型位置
           for(let i=0;i<this.nameIdList.length;i++){
-            if(data[this.nameIdList[i].name]!=null&&data[this.nameIdList[i].name]!=undefined){
-              this.modelEntityMoveByIDAndLocation(this.viewer3D,this.nameIdList[i].id,data[this.nameIdList[i].name].x,id,data[this.nameIdList[i].name].y,id,data[this.nameIdList[i].name].z)
+            console.log('this.nameIdList[i].name :>> ', this.nameIdList[i].name);
+            console.log('data :>> ', data);
+            console.log('data[this.nameIdList[i].name] :>> ', data[this.nameIdList[i].name]);
+            if(this.nameIdList[i].name in data){
+              console.log(' 开始移动'+this.nameIdList[i].name);
+              this.modelEntityMoveByIDAndLocation(this.viewer3D,this.nameIdList[i].id,data[this.nameIdList[i].name].x,data[this.nameIdList[i].name].y,data[this.nameIdList[i].name].z)
             }
           }
            //更新模型位置
@@ -829,7 +833,9 @@ export default {
     },
      // 根据模型实体Id和终点位置进行移动
      modelEntityMoveByIDAndLocation(viewer,id,x,y,z) {
-      
+        x = parseFloat(x)*1000
+        y = parseFloat(y)*1000
+        z = parseFloat(z)*1000
         let entity = viewer.entities.getById(id)
         //终点位置
         let position = new this.Cesium.Cartesian3(x, y, z);

+ 17 - 0
vue.config.js

@@ -43,6 +43,22 @@ module.exports = {
         amd: {
             toUrlUndefined: true
         },
+        output: {
+            sourcePrefix: ' '
+          }
+         },
+        devServer: {
+          proxy: {
+            '/socket.io':{
+              target: 'http://192.168.1.6:1234', // target host
+              changeOrigin: true, // needed for virtual hosted sites
+              logLevel: 'debug'
+            },
+            '/sockjs-node': {
+              target: 'http://192.168.1.6:1234',
+              ws: true,
+              changeOrigin: true
+            },
         '/api': {
           target: 'http://localhost:80',
           ws: true,
@@ -51,6 +67,7 @@ module.exports = {
           //   "^/geoserver":""
           // } 
         }
+    }
     },
 
     chainWebpack: config => {