huweili-cesium 1.2.67 → 1.2.69
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.
- package/js/movePath.js +1 -14
- package/js/movePoint.js +25 -15
- package/package.json +1 -1
package/js/movePath.js
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import * as Cesium from 'cesium'
|
|
12
12
|
import { useMapStore } from './stores/mapStore.js'
|
|
13
|
-
import { DroneConfig } from './config/index.js'
|
|
14
13
|
|
|
15
14
|
const scratchCutoffTime = new Cesium.JulianDate()
|
|
16
15
|
|
|
@@ -48,20 +47,8 @@ export function movePathConfig() {
|
|
|
48
47
|
|
|
49
48
|
const positions = trailData.positions
|
|
50
49
|
const renderPositions = trailData.renderPositions || (trailData.renderPositions = positions.map(point => point.position).filter(Boolean))
|
|
51
|
-
const lastPoint = positions[positions.length - 1]
|
|
52
|
-
const lastPosition = lastPoint?.position
|
|
53
|
-
const minTrailDistanceSquared = trailData.minTrailDistanceSquared || (trailData.minTrailDistanceSquared = DroneConfig.minTrailDistance * DroneConfig.minTrailDistance)
|
|
54
50
|
|
|
55
|
-
//
|
|
56
|
-
if (lastPoint && lastPosition) {
|
|
57
|
-
const distanceSquared = Cesium.Cartesian3.distanceSquared(lastPosition, newPosition)
|
|
58
|
-
const elapsedSeconds = Cesium.JulianDate.secondsDifference(currentTime, lastPoint.timestamp)
|
|
59
|
-
if (distanceSquared < minTrailDistanceSquared || elapsedSeconds < DroneConfig.minTrailIntervalSeconds) {
|
|
60
|
-
return trailData
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 添加新的轨迹点,包含位置和时间戳
|
|
51
|
+
// 轨迹必须和无人机同频更新:收到一次位置就立刻追加一次,不做距离/时间节流。
|
|
65
52
|
const clonedPosition = Cesium.Cartesian3.clone(newPosition)
|
|
66
53
|
positions.push({ position: clonedPosition, timestamp: Cesium.JulianDate.clone(currentTime) })
|
|
67
54
|
renderPositions.push(clonedPosition)
|
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,
|