huweili-cesium 1.2.14 → 1.2.15
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/measureDistance.js +3 -34
- package/package.json +1 -1
package/js/measureDistance.js
CHANGED
|
@@ -77,27 +77,6 @@ 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
|
-
|
|
101
80
|
const getGroundDistance = (startPosition, endPosition) => {
|
|
102
81
|
if (!startPosition || !endPosition) return 0
|
|
103
82
|
return Cesium.Cartesian3.distance(startPosition, endPosition)
|
|
@@ -135,13 +114,6 @@ export function measureDistance() {
|
|
|
135
114
|
const color = Cesium.Color.fromCssColorString(options.color || '#00ffff')
|
|
136
115
|
const width = options.width ?? 3
|
|
137
116
|
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
|
-
})
|
|
145
117
|
|
|
146
118
|
let startPosition = null
|
|
147
119
|
let endPosition = null
|
|
@@ -167,7 +139,7 @@ export function measureDistance() {
|
|
|
167
139
|
if (!startPosition) return []
|
|
168
140
|
const targetPosition = endPosition || floatingPosition
|
|
169
141
|
if (!targetPosition) return [startPosition]
|
|
170
|
-
return
|
|
142
|
+
return [startPosition, targetPosition]
|
|
171
143
|
}
|
|
172
144
|
|
|
173
145
|
const getCurrentDistance = () => getGroundDistance(startPosition, endPosition || floatingPosition)
|
|
@@ -231,11 +203,8 @@ export function measureDistance() {
|
|
|
231
203
|
polyline: {
|
|
232
204
|
positions: new Cesium.CallbackProperty(() => getLinePositions(), false),
|
|
233
205
|
width,
|
|
234
|
-
material:
|
|
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))
|
|
206
|
+
material: color,
|
|
207
|
+
clampToGround
|
|
239
208
|
}
|
|
240
209
|
})
|
|
241
210
|
}
|