瀏覽代碼

风机加载

sunzehao 3 月之前
父節點
當前提交
00fd43497a
共有 2 個文件被更改,包括 48 次插入2 次删除
  1. 13 0
      src/views/cesium.vue
  2. 35 2
      src/views/cesiumComponents/topographicMap.vue

+ 13 - 0
src/views/cesium.vue

@@ -55,6 +55,14 @@
           >{{ rainLayer ? "关闭" : "显示" }}温度图</el-button
         >
       </div>
+      <div class="item">
+        <el-button
+          size="small"
+          type="primary"
+          @click="switchTopographicMap"
+          >风机</el-button
+        >
+      </div>
       <el-tooltip
         class="box-item"
         effect="dark"
@@ -922,6 +930,11 @@ export default {
         path: "/temperatureLayer",
       });
     },
+    switchTopographicMap() {
+      this.$router.push({
+        path: "/topographicMap",
+      });
+    },
   },
 };
 </script>

+ 35 - 2
src/views/cesiumComponents/topographicMap.vue

@@ -7,7 +7,12 @@
 <script>
 import * as Cesium from "../../Cesium";
 import "../../Cesium/Widgets/widgets.css";
+import nxGeoJson from "../../assets/geoJson/nxgeo.json";
 export default {
+    data() {
+        return {
+        }
+    },
     mounted() {
         this.initCesium();
     },
@@ -54,20 +59,48 @@ export default {
                 requestVertexNormals: true,
             });
             viewer.camera.flyTo({
-                destination: Cesium.Cartesian3.fromDegrees(106.231729, 38.485199, 1000),
+                destination: Cesium.Cartesian3.fromDegrees(106.53, 37.66, 2000),
                 orientation: {
                     heading: 4.399419347553678,
-                    pitch: 0.1699544300063054,
+                    pitch: 0.0699544300063054,
                     roll: 6.28315827512673,
                 },
                 duration: 3,
             });
 
+            // 添加一些3D模型
+            this.addModel(
+                viewer,
+                "./static/model/fjSolo/model.glb",
+                "风机",
+                106.43,
+                37.64
+            );
+
             setTimeout(() => {
                 this.addLigh(viewer);
             }, 3000);
             
         },
+        addModel(viewer, uri, name, lon, lat) {
+            const hpRoll = new Cesium.HeadingPitchRoll(90.0, 0.0, 0.0);
+            const position = Cesium.Cartesian3.fromDegrees(lon, lat);
+            const orientation = Cesium.Transforms.headingPitchRollQuaternion(
+                position,
+                hpRoll
+            );
+            viewer.entities.add({
+                name, // 模型名称
+                position, // 模型位置
+                orientation, // 模型朝向
+                model: {
+                uri,
+                scale: 0.5,
+                // 模型贴地
+                heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
+                },
+            });
+        },
         async addLigh(viewer) {
             const fragmentShader = `
                 uniform sampler2D colorTexture;