Forráskód Böngészése

模型预览只有gis需要加载香港地图

Alfyn 2 hete
szülő
commit
2ac0e45a16
1 módosított fájl, 47 hozzáadás és 41 törlés
  1. 47 41
      src/views/modelView/IndexPage.vue

+ 47 - 41
src/views/modelView/IndexPage.vue

@@ -9,12 +9,12 @@
 
 <script>
 import { notification } from 'ant-design-vue'
-import { getDateDiff,loadModelScript } from '@/utils/util.js'
-import OperationMenu from "./modules/OperationMenu.vue";
+import { getDateDiff, loadModelScript } from '@/utils/util.js'
+import OperationMenu from './modules/OperationMenu.vue'
 import { savePreviewImage } from '@/api/model'
 export default {
   name: 'indexPage',
-  components:{ 
+  components: {
     OperationMenu,
   },
   data() {
@@ -26,35 +26,35 @@ export default {
       modelList: null,
       addNum: 0,
       loadingCompleted: false,
-      imgObj: null
+      imgObj: null,
     }
   },
-  watch:{
-    imgObj(value){
-      if(value){
+  watch: {
+    imgObj(value) {
+      if (value) {
         savePreviewImage({
           base64: value.url,
-          bim_file_id: value.lightweightName
+          bim_file_id: value.lightweightName,
         })
       }
-    }
+    },
   },
   async mounted() {
-    await  this.loadModelScript()
+    await this.loadModelScript()
     if (this.query.id) {
-        let data = localStorage.getItem(this.query.id)
-        let list = JSON.parse(data)
-        if ('data' in list[0]) {
-          // 合模
-          this.modelList = list[0].data
-        } else {
-          //单模型
-          this.modelList = list
-        }
-        this.$store.commit('SET_VIEWSINGLEMODEL', this.modelList)
-        this.$store.commit('SET_MAINMODELMSG', this.modelList[0])
-        this.InitScene()
+      let data = localStorage.getItem(this.query.id)
+      let list = JSON.parse(data)
+      if ('data' in list[0]) {
+        // 合模
+        this.modelList = list[0].data
+      } else {
+        //单模型
+        this.modelList = list
       }
+      this.$store.commit('SET_VIEWSINGLEMODEL', this.modelList)
+      this.$store.commit('SET_MAINMODELMSG', this.modelList[0])
+      this.InitScene()
+    }
   },
   beforeDestroy() {
     notification.destroy()
@@ -77,7 +77,7 @@ export default {
           break
       }
       this.$store.commit('SET_DEFAULTS', copyDefaults)
-      
+
       window.api = new window.API(this.$store.state.model.defaults) //api对象后面调用接口要全程使用,控制好作用域
       window.api.Public.setTopRenderState(true)
       window.api.Public.setSceneRenderState(false) //实时渲染
@@ -166,14 +166,14 @@ export default {
         )
       }
     },
-    previewImage(lightweightName){
+    previewImage(lightweightName) {
       let that = this
       window.api.Camera.saveScreenShot((base64image) => {
         that.imgObj = {
-          url : base64image,
-          lightweightName : lightweightName
+          url: base64image,
+          lightweightName: lightweightName,
         }
-      });
+      })
     },
     loadHKMap() {
       //设置gis地图
@@ -185,26 +185,32 @@ export default {
           maximumLevel: 19,
         }
       )
-      //加载建筑模型
-      window.api.Model.mergeModel(
-        'https://data1.map.gov.hk/api/3d-data/3dtiles/f2/tileset.json?key=3967f8f365694e0798af3e7678509421',
-        'hkBuilding',
-        (res) => {
-          console.log('模型开始加载 回调')
-        },
-        (res) => {},
-        {
-          flyto: true,
-          maxspaceerror: 0.3,
-        }
-      )
+      if (
+        this.modelList.filter((item) => {
+          return item.modelType === 'gis'
+        }).length
+      ) {
+        // 加载建筑模型
+        window.api.Model.mergeModel(
+          'https://data1.map.gov.hk/api/3d-data/3dtiles/f2/tileset.json?key=3967f8f365694e0798af3e7678509421',
+          'hkBuilding',
+          (res) => {
+            console.log('模型开始加载 回调')
+          },
+          (res) => {},
+          {
+            flyto: true,
+            maxspaceerror: 0.3,
+          }
+        )
+      }
     },
   },
 }
 </script>
 
 <style lang="less" scoped>
-.content{
+.content {
   height: 100%;
 }
 #cesiumContainer {