无人机管理后台前端(已迁走)
罗广辉
2025-10-11 02409bfbe15f22fc3b5dccadabfd860a660a49d9
src/utils/cesium/publicCesium.js
@@ -94,7 +94,7 @@
         terrain = false,
         layerMode = 0,
         contour = true,
         flyToContour = true,
         flyToContour = false,
         multiple = 1.4,
         dockOptions = {},
@@ -149,6 +149,8 @@
               requestWaterMask: true, // 启用水体遮罩效果
            }).then(terrainProvider => {
               this.viewer.terrainProvider = terrainProvider
               options?.terrainInit?.()
            })
         } catch (error) {
            console.error('地形加载失败:', error)
@@ -193,11 +195,12 @@
         gl = null
         this.viewer?.destroy() // 销毁Viewer实例
         this.viewer = null
         var cesiumContainer = document.getElementById(this.viewerDom)
         if (cesiumContainer && removeDom) {
            cesiumContainer.remove() // 移除与地图相关的DOM元素
            this.viewerDom = null
         }
         // var cesiumContainer = document.getElementById(this.viewerDom)
         // if (cesiumContainer && removeDom) {
         //    cesiumContainer.remove() // 移除与地图相关的DOM元素
         //    this.viewerDom = null
         // }
         this.viewerDom = null
      }
   }
@@ -209,7 +212,7 @@
   async switchContour (open) {
      if (open) {
         await this.boundary?.openContour()
      } else {
         this.boundary?.closeContour()
      }
@@ -221,6 +224,7 @@
   // 飞行 flyto
   flyTo (pointOption, time = 4, height = 3000, orientation = {}, complete = () => { }) {
      console.log(pointOption, )
      if (!pointOption.longitude && !pointOption.latitude) return
      const destination = Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude, height)
      const duration = time
@@ -752,7 +756,7 @@
         Cesium.Cartesian3.subtract(a, this.viewer?.camera.position, a),
         Cesium.Cartesian3.normalize(r, r),
         Cesium.Cartesian3.normalize(a, a)) : (r = c.direction,
         a = h.direction)
            a = h.direction)
      let d = Cesium.Cartesian3.dot(r, a)
         , p = 0
      return d < 1 && (p = Math.acos(d)),
@@ -781,7 +785,7 @@
            , r = Cesium.Math.acosClamped(-e)
         a > 0 && a > r && (a = r - Cesium.Math.EPSILON4),
            r = Cesium.Math.acosClamped(e),
         a < 0 && -a > r && (a = -r + Cesium.Math.EPSILON4)
            a < 0 && -a > r && (a = -r + Cesium.Math.EPSILON4)
      }
      return a
   }