huweili-cesium 1.2.13 → 1.2.14

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.
@@ -77,6 +77,27 @@ export function measureDistance() {
77
77
  }
78
78
  }
79
79
 
80
+ const createGroundPolylinePositions = (startPosition, endPosition, segmentCount = 32) => {
81
+ if (!startPosition || !endPosition) return []
82
+
83
+ const start = Cesium.Cartographic.fromCartesian(startPosition)
84
+ const end = Cesium.Cartographic.fromCartesian(endPosition)
85
+ const positions = []
86
+
87
+ for (let i = 0; i <= segmentCount; i += 1) {
88
+ const t = i / segmentCount
89
+ positions.push(
90
+ Cesium.Cartesian3.fromRadians(
91
+ Cesium.Math.lerp(start.longitude, end.longitude, t),
92
+ Cesium.Math.lerp(start.latitude, end.latitude, t),
93
+ 0
94
+ )
95
+ )
96
+ }
97
+
98
+ return positions
99
+ }
100
+
80
101
  const getGroundDistance = (startPosition, endPosition) => {
81
102
  if (!startPosition || !endPosition) return 0
82
103
  return Cesium.Cartesian3.distance(startPosition, endPosition)
@@ -114,6 +135,13 @@ export function measureDistance() {
114
135
  const color = Cesium.Color.fromCssColorString(options.color || '#00ffff')
115
136
  const width = options.width ?? 3
116
137
  const clampToGround = options.clampToGround ?? true
138
+ const lineMaterial =
139
+ options.lineMaterial ||
140
+ new Cesium.PolylineGlowMaterialProperty({
141
+ color: Cesium.Color.fromAlpha(color, options.opacity ?? 0.95),
142
+ glowPower: options.glowPower ?? 0.12,
143
+ taperPower: options.taperPower ?? 0
144
+ })
117
145
 
118
146
  let startPosition = null
119
147
  let endPosition = null
@@ -139,7 +167,7 @@ export function measureDistance() {
139
167
  if (!startPosition) return []
140
168
  const targetPosition = endPosition || floatingPosition
141
169
  if (!targetPosition) return [startPosition]
142
- return [startPosition, targetPosition]
170
+ return createGroundPolylinePositions(startPosition, targetPosition, options.segmentCount ?? 48)
143
171
  }
144
172
 
145
173
  const getCurrentDistance = () => getGroundDistance(startPosition, endPosition || floatingPosition)
@@ -203,8 +231,11 @@ export function measureDistance() {
203
231
  polyline: {
204
232
  positions: new Cesium.CallbackProperty(() => getLinePositions(), false),
205
233
  width,
206
- material: color,
207
- clampToGround
234
+ material: lineMaterial,
235
+ clampToGround,
236
+ arcType: Cesium.ArcType.GEODESIC,
237
+ granularity: options.granularity ?? Cesium.Math.toRadians(0.2),
238
+ depthFailMaterial: options.depthFailMaterial || new Cesium.ColorMaterialProperty(Cesium.Color.fromAlpha(color, 0.7))
208
239
  }
209
240
  })
210
241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huweili-cesium",
3
- "version": "1.2.13",
3
+ "version": "1.2.14",
4
4
  "description": "基于 Cesium 的地图工具库(无人机态势、轨迹、围栏、工具栏等)",
5
5
  "type": "module",
6
6
  "main": "./index.js",