huweili-cesium 1.2.67 → 1.2.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/js/movePoint.js +25 -15
  2. package/package.json +1 -1
package/js/movePoint.js CHANGED
@@ -21,6 +21,7 @@ import { groundLinkConfig } from './groundLink'
21
21
 
22
22
  const MIN_DRONE_MOVE_DISTANCE = 0.1
23
23
  const MIN_DRONE_MOVE_DISTANCE_SQUARED = MIN_DRONE_MOVE_DISTANCE * MIN_DRONE_MOVE_DISTANCE
24
+ const DEFAULT_FAR_FUTURE_SECONDS = 3600
24
25
 
25
26
  export function movePointConfig(baseUrl) {
26
27
  // 获取地图store实例
@@ -239,12 +240,6 @@ export function movePointConfig(baseUrl) {
239
240
  return modelEntity
240
241
  }
241
242
 
242
- // 初始化复用对象,避免上百个无人机高频移动时反复创建临时对象
243
- modelEntity.scratchPosition ||= new Cesium.Cartesian3()
244
- modelEntity.scratchTargetPosition ||= new Cesium.Cartesian3()
245
- modelEntity.scratchFlightEndTime ||= new Cesium.JulianDate()
246
- modelEntity.scratchFarFutureTime ||= new Cesium.JulianDate()
247
-
248
243
  // 如果存在实体,确保实体属性实时同步
249
244
  const info = modelEntity.info || (modelEntity.info = {})
250
245
  info.pointId = pointId
@@ -259,23 +254,38 @@ export function movePointConfig(baseUrl) {
259
254
  info.distance = options.distance || ''
260
255
  info.receiveTime = options.receiveTime || ''
261
256
 
262
- // ========== 终止当前所有飞行状态 ==========
263
- // 本方案不再做平滑插值和断流续航:来一个新经纬度,无人机和拖尾就同步落到该经纬度。
257
+ // 约定:收到一次无人机数据,就立刻把无人机定位到这个点,同时拖尾追加同一个点。
258
+ // 不再做平滑插值,避免无人机和轨迹之间出现滞后。
259
+ const targetPosition = Cesium.Cartesian3.fromDegrees(lng, lat, height)
260
+
261
+ // 终止旧飞行监听,避免历史插值逻辑继续影响当前定位。
264
262
  if (modelEntity.flightEndListener) {
265
263
  map.clock.onTick.removeEventListener(modelEntity.flightEndListener)
266
264
  modelEntity.flightEndListener = null
267
265
  }
268
266
 
269
267
  modelEntity.isFlying = false
270
- modelEntity.positionProperty = null
271
- modelEntity.lastMoveDirection = null
272
- modelEntity.lastSpeed = 0
273
-
274
- const targetPosition = Cesium.Cartesian3.fromDegrees(lng, lat, height, modelEntity.currentPosition || new Cesium.Cartesian3())
275
268
  modelEntity.currentPosition = Cesium.Cartesian3.clone(targetPosition, modelEntity.currentPosition || new Cesium.Cartesian3())
269
+ modelEntity.info = modelEntity.info || {}
270
+ modelEntity.info.pointId = pointId
271
+ modelEntity.info.lng = lng
272
+ modelEntity.info.lat = lat
273
+ modelEntity.info.height = height
274
+ modelEntity.info.speed = speed
275
+ modelEntity.info.flyingHandName = options.flyingHandName || ''
276
+ modelEntity.info.flyingHandPhone = options.flyingHandPhone || ''
277
+ modelEntity.info.flyingHandPosition = options.flyingHandPosition || ''
278
+ modelEntity.info.frequencyBand = options.frequencyBand || ''
279
+ modelEntity.info.distance = options.distance || ''
280
+ modelEntity.info.receiveTime = options.receiveTime || ''
281
+
282
+ // 直接使用当前点覆盖实体位置,不再依赖 SampledPositionProperty 做插值。
283
+ if (modelEntity.entity) {
284
+ modelEntity.entity.position = targetPosition
285
+ }
286
+ modelEntity.positionProperty = null
276
287
 
277
- // 无人机实体和拖尾使用同一个目标点同步更新,不保留任何预测点,避免拖尾领先或回头找无人机。
278
- modelEntity.entity.position = modelEntity.currentPosition
288
+ // 拖尾直接追加同一个点。
279
289
  moveDroneTrail({
280
290
  pointId,
281
291
  newPosition: modelEntity.currentPosition,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huweili-cesium",
3
- "version": "1.2.67",
3
+ "version": "1.2.68",
4
4
  "description": "基于 Cesium 的地图工具库(无人机态势、轨迹、围栏、工具栏等)",
5
5
  "type": "module",
6
6
  "main": "./index.js",