huweili-cesium 1.2.62 → 1.2.64
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/customToolbarButtons.js +9 -1
- package/js/movePoint.js +40 -41
- package/package.json +1 -1
|
@@ -51,6 +51,10 @@ export function createCustomToolbarButtons() {
|
|
|
51
51
|
button.className = `cesium-button cesium-toolbar-button ${options.className || ''}`
|
|
52
52
|
button.title = options.title
|
|
53
53
|
|
|
54
|
+
if (options.isDefaultVisible) button.dataset.toolbarDefaultVisible = 'true'
|
|
55
|
+
if (options.isMoreToggle) button.dataset.toolbarMoreToggle = 'true'
|
|
56
|
+
if (options.isExpandToggle) button.dataset.toolbarExpandToggle = 'true'
|
|
57
|
+
|
|
54
58
|
if (options.iconSrc) {
|
|
55
59
|
const img = document.createElement('img')
|
|
56
60
|
img.src = options.iconSrc
|
|
@@ -92,7 +96,11 @@ export function createCustomToolbarButtons() {
|
|
|
92
96
|
toolbar.style.minWidth = 'unset'
|
|
93
97
|
toolbar.style.flexWrap = 'nowrap'
|
|
94
98
|
toolbar.style.position = 'absolute'
|
|
95
|
-
toolbar.style.
|
|
99
|
+
toolbar.style.left = ''
|
|
100
|
+
toolbar.style.top = ''
|
|
101
|
+
toolbar.style.right = ''
|
|
102
|
+
toolbar.style.bottom = ''
|
|
103
|
+
toolbar.style.inset = 'initial'
|
|
96
104
|
|
|
97
105
|
return buttons.map(opt => addToolbarButton(viewer, opt)).filter(Boolean)
|
|
98
106
|
}
|
package/js/movePoint.js
CHANGED
|
@@ -288,14 +288,14 @@ export function movePointConfig(baseUrl) {
|
|
|
288
288
|
})
|
|
289
289
|
|
|
290
290
|
// ========== 终止当前所有飞行状态 ==========
|
|
291
|
-
//
|
|
291
|
+
// 新坐标一到,立即打断旧的插值/续航逻辑,优先追最新点位。
|
|
292
292
|
if (modelEntity.flightEndListener) {
|
|
293
293
|
map.clock.onTick.removeEventListener(modelEntity.flightEndListener)
|
|
294
294
|
modelEntity.flightEndListener = null
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
modelEntity.isFlying = false
|
|
298
|
-
// 每次移动都重建采样属性,只保留“当前位置 ->
|
|
298
|
+
// 每次移动都重建采样属性,只保留“当前位置 -> 最新目标点”的快速追踪段。
|
|
299
299
|
modelEntity.positionProperty = new Cesium.SampledPositionProperty()
|
|
300
300
|
modelEntity.positionProperty.forwardExtrapolationType = Cesium.ExtrapolationType.HOLD
|
|
301
301
|
modelEntity.positionProperty.backwardExtrapolationType = Cesium.ExtrapolationType.HOLD
|
|
@@ -307,61 +307,60 @@ export function movePointConfig(baseUrl) {
|
|
|
307
307
|
// ========== 计算新的飞行路径 ==========
|
|
308
308
|
const targetPosition = Cesium.Cartesian3.fromDegrees(lng, lat, height)
|
|
309
309
|
const distanceSquared = Cesium.Cartesian3.distanceSquared(currentRealPosition, targetPosition)
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
return modelEntity
|
|
310
|
+
const distance = Math.sqrt(distanceSquared)
|
|
311
|
+
const cruiseSpeed = Math.max(speed, 0)
|
|
312
|
+
const moveDirection = distanceSquared >= MIN_DRONE_MOVE_DISTANCE_SQUARED
|
|
313
|
+
? Cesium.Cartesian3.normalize(
|
|
314
|
+
Cesium.Cartesian3.subtract(targetPosition, currentRealPosition, modelEntity.scratchTargetPosition),
|
|
315
|
+
new Cesium.Cartesian3()
|
|
316
|
+
)
|
|
317
|
+
: modelEntity.lastMoveDirection
|
|
318
|
+
|
|
319
|
+
if (moveDirection) {
|
|
320
|
+
modelEntity.lastMoveDirection = Cesium.Cartesian3.clone(moveDirection, modelEntity.lastMoveDirection || new Cesium.Cartesian3())
|
|
322
321
|
}
|
|
322
|
+
modelEntity.lastSpeed = cruiseSpeed
|
|
323
323
|
|
|
324
|
-
//
|
|
325
|
-
const
|
|
326
|
-
const flightEndTime = Cesium.JulianDate.addSeconds(currentTime,
|
|
324
|
+
// 新坐标进来时不再按业务速度慢慢飞过去,而是用极短追踪时间快速贴到最新经纬度。
|
|
325
|
+
const fastArriveDuration = distanceSquared < MIN_DRONE_MOVE_DISTANCE_SQUARED ? 0 : 0.05
|
|
326
|
+
const flightEndTime = Cesium.JulianDate.addSeconds(currentTime, fastArriveDuration, modelEntity.scratchFlightEndTime)
|
|
327
327
|
|
|
328
328
|
if (!map.clock.shouldAnimate) {
|
|
329
329
|
map.clock.shouldAnimate = true
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
// 不再为每个无人机改全局 clock.startTime/stopTime,避免多无人机互相抢时钟范围。
|
|
333
332
|
modelEntity.positionProperty.addSample(flightEndTime, targetPosition)
|
|
334
333
|
modelEntity.isFlying = true
|
|
334
|
+
modelEntity.currentPosition = Cesium.Cartesian3.clone(targetPosition, modelEntity.currentPosition)
|
|
335
335
|
|
|
336
336
|
const flightTickListener = (clock) => {
|
|
337
337
|
if (!modelEntity.isFlying) return
|
|
338
338
|
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
?
|
|
342
|
-
:
|
|
343
|
-
|
|
344
|
-
if (
|
|
345
|
-
//
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
339
|
+
const isArriving = Cesium.JulianDate.compare(clock.currentTime, flightEndTime) < 0
|
|
340
|
+
let tickPosition = isArriving
|
|
341
|
+
? modelEntity.positionProperty.getValue(clock.currentTime, modelEntity.scratchPosition)
|
|
342
|
+
: targetPosition
|
|
343
|
+
|
|
344
|
+
if (!isArriving && modelEntity.lastMoveDirection && modelEntity.lastSpeed > 0) {
|
|
345
|
+
// 下一秒坐标迟迟不来时,按上一次航向和速度继续向前慢速插值飞行。
|
|
346
|
+
const extraSeconds = Math.max(0, Cesium.JulianDate.secondsDifference(clock.currentTime, flightEndTime))
|
|
347
|
+
const extraDistance = modelEntity.lastSpeed * extraSeconds
|
|
348
|
+
tickPosition = Cesium.Cartesian3.add(
|
|
349
|
+
targetPosition,
|
|
350
|
+
Cesium.Cartesian3.multiplyByScalar(modelEntity.lastMoveDirection, extraDistance, modelEntity.scratchTargetPosition),
|
|
351
|
+
modelEntity.scratchPosition
|
|
352
|
+
)
|
|
352
353
|
}
|
|
353
354
|
|
|
354
|
-
if (!
|
|
355
|
+
if (!tickPosition) return
|
|
355
356
|
|
|
356
|
-
|
|
357
|
-
modelEntity.
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
clock.onTick.removeEventListener(flightTickListener)
|
|
364
|
-
modelEntity.flightEndListener = null
|
|
357
|
+
// 每帧缓存真实位置,并同步追加轨迹点。
|
|
358
|
+
modelEntity.currentPosition = Cesium.Cartesian3.clone(tickPosition, modelEntity.currentPosition)
|
|
359
|
+
moveDroneTrail({
|
|
360
|
+
pointId,
|
|
361
|
+
newPosition: modelEntity.currentPosition,
|
|
362
|
+
mapId
|
|
363
|
+
})
|
|
365
364
|
}
|
|
366
365
|
|
|
367
366
|
modelEntity.flightEndListener = flightTickListener
|