huweili-cesium 1.2.71 → 1.2.73
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/geometry.js +68 -0
- package/js/labelDiv.js +2 -2
- package/package.json +1 -1
package/js/geometry.js
CHANGED
|
@@ -214,6 +214,73 @@ export function geometryConfig() {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
/**
|
|
218
|
+
* 让圆锥顶点固定,朝向指定经纬度目标旋转
|
|
219
|
+
* @param {Object} options 配置参数
|
|
220
|
+
* @param {string} options.id 圆锥体ID
|
|
221
|
+
* @param {number[]} options.positions 固定顶点位置 [lng, lat, height]
|
|
222
|
+
* @param {number} options.targetLng 目标经度
|
|
223
|
+
* @param {number} options.targetLat 目标纬度
|
|
224
|
+
* @param {number} [options.targetHeight=0] 目标高度
|
|
225
|
+
* @param {string} options.mapId 地图实例ID
|
|
226
|
+
* @returns {boolean} 更新成功返回true,否则返回false
|
|
227
|
+
*/
|
|
228
|
+
const updateConeLookAtTarget = (options) => {
|
|
229
|
+
const { id, positions, targetLng, targetLat, targetHeight = 0, mapId } = options
|
|
230
|
+
const map = mapStore.getMap(mapId)
|
|
231
|
+
if (!map) {
|
|
232
|
+
console.error('地图实例不存在')
|
|
233
|
+
return false
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const primitive = mapStore.getGraphicMap(id, mapId)
|
|
237
|
+
if (!primitive) {
|
|
238
|
+
console.error(`id: ${id} 圆锥体不存在`)
|
|
239
|
+
return false
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (!positions || positions.length < 2) {
|
|
243
|
+
console.error('圆锥顶点位置 positions 无效')
|
|
244
|
+
return false
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const [lng, lat, height = 0] = positions
|
|
248
|
+
const vertexPos = Cesium.Cartesian3.fromDegrees(lng, lat, height)
|
|
249
|
+
const targetPos = Cesium.Cartesian3.fromDegrees(Number(targetLng), Number(targetLat), Number(targetHeight))
|
|
250
|
+
|
|
251
|
+
if (!Number.isFinite(targetPos.x) || !Number.isFinite(targetPos.y) || !Number.isFinite(targetPos.z)) {
|
|
252
|
+
console.error('目标经纬度无效')
|
|
253
|
+
return false
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
try {
|
|
257
|
+
const transform = Cesium.Transforms.eastNorthUpToFixedFrame(vertexPos)
|
|
258
|
+
const inverseTransform = Cesium.Matrix4.inverseTransformation(transform, new Cesium.Matrix4())
|
|
259
|
+
const localTarget = Cesium.Matrix4.multiplyByPoint(inverseTransform, targetPos, new Cesium.Cartesian3())
|
|
260
|
+
|
|
261
|
+
const heading = Math.atan2(localTarget.x, localTarget.y)
|
|
262
|
+
const horizontalDistance = Math.sqrt(localTarget.x * localTarget.x + localTarget.y * localTarget.y)
|
|
263
|
+
const pitch = Math.atan2(localTarget.z, horizontalDistance)
|
|
264
|
+
const hpr = new Cesium.HeadingPitchRoll(heading, pitch, 0)
|
|
265
|
+
|
|
266
|
+
const modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(vertexPos, hpr)
|
|
267
|
+
const trans = Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(0, 0, -(primitive._originalOptions?.length || 0) / 2))
|
|
268
|
+
Cesium.Matrix4.multiply(modelMatrix, trans, modelMatrix)
|
|
269
|
+
|
|
270
|
+
primitive.modelMatrix = modelMatrix
|
|
271
|
+
primitive._originalOptions = primitive._originalOptions || {}
|
|
272
|
+
primitive._originalOptions.positions = positions
|
|
273
|
+
primitive._originalOptions.targetLng = targetLng
|
|
274
|
+
primitive._originalOptions.targetLat = targetLat
|
|
275
|
+
primitive._originalOptions.targetHeight = targetHeight
|
|
276
|
+
mapStore.setGraphicMap(id, primitive, mapId)
|
|
277
|
+
return true
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.error('更新圆锥朝向目标失败:', error)
|
|
280
|
+
return false
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
217
284
|
/**
|
|
218
285
|
* 创建四棱锥波效果
|
|
219
286
|
* @param {string} options.id - 效果唯一标识符
|
|
@@ -495,6 +562,7 @@ export function geometryConfig() {
|
|
|
495
562
|
conicalWave,
|
|
496
563
|
updateConeLengthOrPosition,
|
|
497
564
|
updateConePose,
|
|
565
|
+
updateConeLookAtTarget,
|
|
498
566
|
rectangularPyramidWave,
|
|
499
567
|
updateRectangularPyramidWavePose,
|
|
500
568
|
updateRectangularPyramidPoseFast,
|
package/js/labelDiv.js
CHANGED
|
@@ -191,7 +191,7 @@ export function labelDiv() {
|
|
|
191
191
|
detailDiv.innerHTML = `
|
|
192
192
|
<div class="drone-detail-header">
|
|
193
193
|
<span class="drone-badge"></span>
|
|
194
|
-
<span class="drone-detail-title"
|
|
194
|
+
<span class="drone-detail-title">${labelItem.uavName}</span>
|
|
195
195
|
<button class="drone-detail-close"></button>
|
|
196
196
|
</div>
|
|
197
197
|
<div class="drone-detail-body" id="drone-info-${labelItem.id}">
|
|
@@ -210,7 +210,7 @@ export function labelDiv() {
|
|
|
210
210
|
<div><span class="pilot-title">高度:</span><span class="alt">-</span>km</div>
|
|
211
211
|
<div><span class="pilot-title">速度:</span><span class="speed">-</span>km/h</div>
|
|
212
212
|
<div><span class="pilot-title">距离:</span><span class="distance">200m</span></div>
|
|
213
|
-
${!isUnknown ? '<div><span class="pilot-title">频段:</span><span class="band">2.4GHz</span></div>' : ''}
|
|
213
|
+
${!isUnknown ? '<div><span class="pilot-title">频段:</span><span class="band">2.4GHz、5.8GHz</span></div>' : ''}
|
|
214
214
|
</div>
|
|
215
215
|
${!isUnknown ? `
|
|
216
216
|
<div class="drone-detail-divider"></div>
|