From 53bcb7e5dffa071d2c6593f5db7f0b6e4e2f8dfe Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Wed, 18 Oct 2023 16:17:02 +0800
Subject: [PATCH] 隐藏重复定时和连续执行

---
 src/hooks/use-cesium-tsa.ts |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/src/hooks/use-cesium-tsa.ts b/src/hooks/use-cesium-tsa.ts
index 7b03f6d..d70dfcf 100644
--- a/src/hooks/use-cesium-tsa.ts
+++ b/src/hooks/use-cesium-tsa.ts
@@ -27,6 +27,9 @@
   billboard?: billboardSetting
   label?: labelSetting
   id?: string
+  heading?: number
+  pitch?: number
+  roll?: number
 }
 // 定义全局的viewer变量防止重复生成
 // eslint-disable-next-line no-var
@@ -140,8 +143,9 @@
   // 添加标记点
   const addPoint = (pointOption: pointOption) => {
     if (!pointOption.longitude && !pointOption.latitude) return
+    const position = Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude)
     viewer?.entities.add({
-      position: Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude),
+      position,
       billboard: pointOption.billboard,
       point: pointOption.point,
       label: pointOption.label,
@@ -157,7 +161,21 @@
       viewer?.entities.remove(pointEntity)
     }
   }
-
+  // 通过点ID获取实体
+  function getEntityById (id:string) {
+    const pointEntity = viewer?.entities.getById(id)
+    return pointEntity
+  }
+  // 更新图片实体位置
+  function updateEntityPosition (longitude:number, latitude:number, id:string, params?:any) {
+    const entity = getEntityById(id) as Cesium.Entity
+    const position = Cesium.Cartesian3.fromDegrees(longitude, latitude)
+    const heading = Cesium.Math.toRadians(-params.heading)
+    if (Cesium.defined(entity)) {
+      entity.position = position
+      entity.billboard.rotation = heading
+    }
+  }
   // 飞行 flyto
   const flyTo = (pointOption: pointOption, time: number = 4) => {
     if (!pointOption.longitude && !pointOption.latitude) return
@@ -220,7 +238,6 @@
   // 切换不同背景图层
   const patternMap = () => {
     const imageryLayers = viewer?.scene.imageryLayers
-    console.log(imageryLayers, 'imageryLayers')
     // 切换为标准图层
     if (store.state.common.mapSetting.mode === 0) {
       const tdtImg_c = imageryLayers?._layers.find(v => v.imageryProvider._layer === 'tdtImg_c')
@@ -230,7 +247,6 @@
     } else {
       const tdtStand_c = imageryLayers?._layers.find(v => v.imageryProvider.credit.html === 'stand_tc')
       const tdtStand_zj = imageryLayers?._layers.find(v => v.imageryProvider.credit.html === 'stand_zj')
-      console.log(tdtStand_c, tdtStand_zj, '===========================')
       viewer?.imageryLayers.remove(tdtStand_c)
       viewer?.imageryLayers.remove(tdtStand_zj)
     }
@@ -258,6 +274,8 @@
     zoonIn,
     zoonOut,
     roadPattern,
-    patternMap
+    patternMap,
+    getEntityById,
+    updateEntityPosition
   }
 }

--
Gitblit v1.9.3