Browse Source

Merge branch 'master' of http://43.143.235.246:9080/fireLHB/firemap

xyh 1 year ago
parent
commit
79d917e016
3 changed files with 97 additions and 80 deletions
  1. 44 10
      src/views/simulation/index.vue
  2. 1 1
      src/views/situation/index.vue
  3. 52 69
      vue.config.js

+ 44 - 10
src/views/simulation/index.vue

@@ -79,7 +79,7 @@ export default {
       selectedMarker: null,
       // 以前的标记点坐标
       oldPosition: null,
-      activeName: null,
+      activeName: 'fouth',
       currentLab: {
         index: -1,
         isActive: false
@@ -673,7 +673,6 @@ export default {
         name: name
       })
       this.id++;
-      console.log('this.viewer3D.entities :>> ', this.viewer3D.entities);
     },
     // 从鼠标点击事件获取坐标
     getCoordinatesFromEvent(event) {
@@ -761,7 +760,7 @@ export default {
         const currentTime = clock.currentTime; // 获取当前时间轴的时间
         const elapsedTime = this.Cesium.JulianDate.secondsDifference(
           currentTime,
-          this.viewer2D.clock.startTime
+          this.viewer3D.clock.startTime
         ); // 获取从起始时间到当前时间的秒数
         if (parseInt(elapsedTime) % stepTime === 0 && elapsedTime!=0) {
           console.log('elapsedTime :>> ', elapsedTime);
@@ -778,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
@@ -794,17 +793,52 @@ export default {
       await axios
         .post("/api/pos", {simulation_time: newTimeString+'.000'}).then(res=>{
           console.log('res :>> ', res);
+          let data = res.data[1]
+          //依次更新每个模型位置
+          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,"1654426964397658112",res.data[1].data.W1.x,res.data[1].data.W1.y,res.data[1].data.W1.z)
         })
+        
     },
      // 根据时间参数请求模型位置并更新 3D
-     requestDataAndUpdateModel3D(startTime, elapsedTime) {
+     async requestDataAndUpdateModel3D(startTime, elapsedTime) {
       const jsDate = new Date(startTime);
       // 增加 elapsedTime 秒
       jsDate.setSeconds(jsDate.getSeconds() + elapsedTime);
       // 转换为需求字符串格式
       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]
+          //依次更新每个模型位置
+          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)
+            }
+          }
+           //更新模型位置
+          //  this.modelEntityMoveByIDAndLocation(this.viewer3D,viewer,"1654426964397658112",res.data[1].data.W1.x,res.data[1].data.W1.y,res.data[1].data.W1.z)  
+        })
+        
+    },
+     // 根据模型实体Id和终点位置进行移动
+     modelEntityMoveByIDAndLocation(viewer,id,x,y,z) {
+      
+        let entity = viewer.entities.getById(id)
+        //终点位置
+        let position = new this.Cesium.Cartesian3(x, y, z);
+        //设置方向,根据实体的位置来配置方向
+        entity.orientation = new this.Cesium.VelocityOrientationProperty(entity.position);
+        //设置查看器,让模型动起来
+        entity.position.setValue(position)
+
+     }
   }
 };
 </script>

+ 1 - 1
src/views/situation/index.vue

@@ -98,7 +98,7 @@ export default {
       selectedMarker: null,
       // 以前的标记点坐标
       oldPosition: null,
-      activeName: null,
+      activeName: 'fouth',
       currentLab: {
         index: -1,
         isActive: false

+ 52 - 69
vue.config.js

@@ -1,62 +1,47 @@
 const CopyWebpackPlugin = require('copy-webpack-plugin')
-const webpack = require('webpack') 
+const webpack = require('webpack')
 const cesiumSource = 'node_modules/cesium/Source'
 const cesiumWorkers = '../Build/Cesium/Workers'
 const path = require("path");
+
 function resolve(dir) {
-  return path.join(__dirname, dir);
+    return path.join(__dirname, dir);
 }
 module.exports = {
-    publicPath: './',  // 基本路径
+    publicPath: './', // 基本路径
     outputDir: 'dist', // 构建时的输出目录
     assetsDir: 'static', // 放置静态资源的目录
     indexPath: 'index.html', // html 的输出路径
     filenameHashing: true, // 文件名哈希值
     lintOnSave: false, // 是否在保存的时候使用 `eslint-loader` 进行检查。
-  
+
     // 组件是如何被渲染到页面中的? (ast:抽象语法树;vDom:虚拟DOM)
     // template ---> ast ---> render ---> vDom ---> 真实的Dom ---> 页面
     // runtime-only:将template在打包的时候,就已经编译为render函数
     // runtime-compiler:在运行的时候才去编译template
     runtimeCompiler: false,
-  
+
     transpileDependencies: [], // babel-loader 默认会跳过 node_modules 依赖。
     productionSourceMap: false, // 是否为生产环境构建生成 source map
-  
+
     configureWebpack: {
-      plugins: [
-        new CopyWebpackPlugin([{ from: path.join(cesiumSource, cesiumWorkers), to: 'Workers' }]),
-        new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Assets'), to: 'Assets' }]),
-        new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Widgets'), to: 'Widgets' }]),
-        new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'ThirdParty/Workers'), to: 'ThirdParty/Workers' }]),
-   
-        new webpack.DefinePlugin({
-          CESIUM_BASE_URL: JSON.stringify('./')
-        })
-      ],
-      module: {
-        unknownContextCritical: false,
-        unknownContextRegExp: /\/cesium\/cesium\/Source\/Core\/buildModuleUrl\.js/
-      },
-      // 配置cesium----开始
-      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'
+        plugins: [
+            new CopyWebpackPlugin([{ from: path.join(cesiumSource, cesiumWorkers), to: 'Workers' }]),
+            new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Assets'), to: 'Assets' }]),
+            new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'Widgets'), to: 'Widgets' }]),
+            new CopyWebpackPlugin([{ from: path.join(cesiumSource, 'ThirdParty/Workers'), to: 'ThirdParty/Workers' }]),
+
+            new webpack.DefinePlugin({
+                CESIUM_BASE_URL: JSON.stringify('./')
+            })
+        ],
+        module: {
+            unknownContextCritical: false,
+            unknownContextRegExp: /\/cesium\/cesium\/Source\/Core\/buildModuleUrl\.js/
         },
-        '/sockjs-node': {
-          target: 'http://192.168.1.6:1234',
-          ws: true,
-          changeOrigin: true
+        // 配置cesium----开始
+        amd: {
+            toUrlUndefined: true
         },
         '/api': {
           target: 'http://localhost:80',
@@ -66,38 +51,36 @@ module.exports = {
           //   "^/geoserver":""
           // } 
         }
-          
-      }
     },
 
     chainWebpack: config => {
-      config.resolve.alias
-        .set("@", resolve("src"))
-        .set("assets", resolve("src/assets"))
-        .set("components", resolve("src/components"))
-        .set("public", resolve("public"))
-        .set("cesium",path.resolve(__dirname, cesiumSource))
-    // set svg-sprite-loader
-    config.module
-      .rule('svg')
-      .exclude.add(resolve('src/assets'))  // 存放 svg 目录的目录
-      .end()
-    config.module
-      .rule('assets')
-      .test(/\.svg$/)
-      .include.add(resolve('src/assets'))  // 存放 svg 目录的目录
-      .end()
-      .use('svg-sprite-loader')
-      .loader('svg-sprite-loader')
-      .options({
-        symbolId: 'icon-[name]'
-      })
-      .end()
-    config.module
-      .rule('glb')
-      .test(/\.glb$/)
-      .use('url-loader')
-      .loader('url-loader')
-      .end();
+        config.resolve.alias
+            .set("@", resolve("src"))
+            .set("assets", resolve("src/assets"))
+            .set("components", resolve("src/components"))
+            .set("public", resolve("public"))
+            .set("cesium", path.resolve(__dirname, cesiumSource))
+            // set svg-sprite-loader
+        config.module
+            .rule('svg')
+            .exclude.add(resolve('src/assets')) // 存放 svg 目录的目录
+            .end()
+        config.module
+            .rule('assets')
+            .test(/\.svg$/)
+            .include.add(resolve('src/assets')) // 存放 svg 目录的目录
+            .end()
+            .use('svg-sprite-loader')
+            .loader('svg-sprite-loader')
+            .options({
+                symbolId: 'icon-[name]'
+            })
+            .end()
+        config.module
+            .rule('glb')
+            .test(/\.glb$/)
+            .use('url-loader')
+            .loader('url-loader')
+            .end();
     }
-  }
+}