@pirireis/webglobeplugins 0.15.16-alpha → 0.15.18-alpha
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/Math/methods.js +2 -2
- package/package.json +1 -1
- package/point-tracks/plugin.js +18 -13
- package/programs/line-on-globe/linestrip/linestrip.js +0 -1
- package/programs/totems/globe-changes.js +52 -0
- package/range-tools-on-terrain/bearing-line/adapters.js +8 -5
- package/range-tools-on-terrain/bearing-line/plugin.js +6 -4
- package/range-tools-on-terrain/circle-line-chain/adapters.js +2 -0
- package/range-tools-on-terrain/circle-line-chain/plugin.js +24 -4
- package/range-tools-on-terrain/range-ring/adapters.js +59 -7
- package/range-tools-on-terrain/range-ring/plugin.js +23 -3
- package/semiplugins/lightweight/line-plugin.js +8 -4
- package/semiplugins/lightweight/piece-of-pie-plugin.js +4 -2
- package/semiplugins/shape-on-terrain/arc-plugin.js +34 -10
- package/semiplugins/shape-on-terrain/circle-plugin.js +46 -21
- package/semiplugins/shape-on-terrain/padding-1-degree.js +357 -190
- package/util/account/single-attribute-buffer-management/buffer-manager.js +12 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator copy.js +161 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +91 -5
- package/util/account/single-attribute-buffer-management/chunked-buffer-manager.js +75 -0
- package/util/account/single-attribute-buffer-management/chunked-buffer-orchestrator.js +195 -0
- package/util/account/single-attribute-buffer-management/object-store.js +7 -0
- package/util/check/typecheck.js +12 -0
- package/util/geometry/index.js +2 -1
package/Math/methods.js
CHANGED
|
@@ -73,13 +73,13 @@ export const pixelXYLenghtToUnitVectorWithHeight = (pixelXYHeight) => {
|
|
|
73
73
|
const radius = WORLD_RADIUS_3D + pixelXYHeight[2];
|
|
74
74
|
return [...radianToCartesian3d([long, lat]), radius];
|
|
75
75
|
};
|
|
76
|
-
export const globe3Dcoordinates = (globe, height = 0
|
|
76
|
+
export const globe3Dcoordinates = (globe, longlats, height = 0, msl = false, { paddingCount = 0, paddingValue = NaN }) => {
|
|
77
77
|
const len = longlats.length / 2;
|
|
78
78
|
const result = new Float32Array(len * 3 + paddingCount * 3).fill(paddingValue);
|
|
79
79
|
for (let i = 0; i < len; i++) {
|
|
80
80
|
const long = longlats[i * 2];
|
|
81
81
|
const lat = longlats[i * 2 + 1];
|
|
82
|
-
const xyz = globe.api_GetCartesian3DPoint(long, lat, height,
|
|
82
|
+
const xyz = globe.api_GetCartesian3DPoint(long, lat, height, msl);
|
|
83
83
|
result.set(xyz, i * 3);
|
|
84
84
|
}
|
|
85
85
|
return result;
|
package/package.json
CHANGED
package/point-tracks/plugin.js
CHANGED
|
@@ -167,8 +167,8 @@ class PointTracksPlugin {
|
|
|
167
167
|
* @param {string} trackID
|
|
168
168
|
*/
|
|
169
169
|
deleteTrack(trackID) {
|
|
170
|
-
const
|
|
171
|
-
const points = Array.from(
|
|
170
|
+
const pointList = this._tracksToPointsMap.get(trackID);
|
|
171
|
+
const points = Array.from(pointList);
|
|
172
172
|
const { _bufferOrchestrator, _bufferManagersMap } = this;
|
|
173
173
|
_bufferOrchestrator.deleteBulk(points.map((pointID) => keyMethod(trackID, pointID)), _bufferManagersMap);
|
|
174
174
|
this._tracksToPointsMap.delete(trackID);
|
|
@@ -206,8 +206,8 @@ class PointTracksPlugin {
|
|
|
206
206
|
console.warn(`Track with ID ${trackID} does not exist.`);
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
|
-
const
|
|
210
|
-
const points = Array.from(
|
|
209
|
+
const pointList = this._tracksToPointsMap.get(trackID);
|
|
210
|
+
const points = Array.from(pointList);
|
|
211
211
|
const { _bufferOrchestrator, _bufferManagersMap } = this;
|
|
212
212
|
_bufferOrchestrator.updateBulk(points.map((pointID) => {
|
|
213
213
|
return {
|
|
@@ -270,12 +270,13 @@ class PointTracksPlugin {
|
|
|
270
270
|
const trackID = track.trackID;
|
|
271
271
|
const points = track.points;
|
|
272
272
|
if (!this._tracksToPointsMap.has(trackID)) {
|
|
273
|
-
this._tracksToPointsMap.set(trackID,
|
|
273
|
+
this._tracksToPointsMap.set(trackID, []); // TODO: alternative to Set?
|
|
274
|
+
// this._tracksToPointsMap.set(trackID, new Set()); // TODO: alternative to Set?
|
|
274
275
|
}
|
|
275
|
-
const
|
|
276
|
+
const pointList = this._tracksToPointsMap.get(trackID);
|
|
276
277
|
for (let p = 0; p < points.length; p++) {
|
|
277
278
|
const pointID = points[p].ID;
|
|
278
|
-
|
|
279
|
+
pointList.push(pointID);
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
282
|
}
|
|
@@ -286,9 +287,14 @@ class PointTracksPlugin {
|
|
|
286
287
|
}
|
|
287
288
|
_deletePointsFromTracksMap(trackID, pointIDs) {
|
|
288
289
|
const trackSet = this._tracksToPointsMap.get(trackID);
|
|
289
|
-
|
|
290
|
-
|
|
290
|
+
const pointList = new Set(pointIDs);
|
|
291
|
+
const newList = [];
|
|
292
|
+
for (const pointID of trackSet) {
|
|
293
|
+
if (!pointList.has(pointID)) {
|
|
294
|
+
newList.push(pointID);
|
|
295
|
+
}
|
|
291
296
|
}
|
|
297
|
+
this._tracksToPointsMap.set(trackID, newList);
|
|
292
298
|
}
|
|
293
299
|
_selfSelect() {
|
|
294
300
|
const { globe } = this;
|
|
@@ -311,12 +317,11 @@ class PointTracksPlugin {
|
|
|
311
317
|
const indexes = [];
|
|
312
318
|
const foundTracks = [];
|
|
313
319
|
for (const trackID of trackIDs) {
|
|
314
|
-
const
|
|
315
|
-
if (!
|
|
320
|
+
const pointList = this._tracksToPointsMap.get(trackID);
|
|
321
|
+
if (!pointList)
|
|
316
322
|
continue;
|
|
317
323
|
foundTracks.push(trackID);
|
|
318
|
-
const
|
|
319
|
-
for (const pointID of points) {
|
|
324
|
+
for (const pointID of pointList) {
|
|
320
325
|
const key = keyMethod(trackID, pointID);
|
|
321
326
|
const index = this._bufferOrchestrator.offsetMap.get(key);
|
|
322
327
|
indexes.push(index);
|
|
@@ -3,7 +3,6 @@ import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../../to
|
|
|
3
3
|
import { cartesian3DToGLPosition, mercatorXYToGLPosition, } from "../../../util/shaderfunctions/geometrytransformations";
|
|
4
4
|
import { noRegisterGlobeProgramCache } from "../../programcache";
|
|
5
5
|
import { attributeLoader } from "../../../util/gl-util/buffer/attribute-loader";
|
|
6
|
-
import "../../../util/gl-util/buffer/attribute-loader";
|
|
7
6
|
import { UniformBlockManager } from "../../../util/gl-util/uniform-block/manager";
|
|
8
7
|
import { drawArrays } from "../../../util/gl-util/draw-options/methods";
|
|
9
8
|
const ESCAPE_VALUE = -1;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export class GlobeChangeObserver {
|
|
2
|
+
globe;
|
|
3
|
+
lastLOD = -1;
|
|
4
|
+
lastGeometry;
|
|
5
|
+
lastWorldWH = { width: 0, height: 0 };
|
|
6
|
+
lastLook = {
|
|
7
|
+
CenterLong: 0,
|
|
8
|
+
CenterLat: 0,
|
|
9
|
+
Distance: 0,
|
|
10
|
+
Tilt: 0,
|
|
11
|
+
NorthAng: 0
|
|
12
|
+
};
|
|
13
|
+
lastElevationCoefficient = NaN;
|
|
14
|
+
changes = {
|
|
15
|
+
geometryChanged: false,
|
|
16
|
+
lookChanged: false,
|
|
17
|
+
lodChanged: false,
|
|
18
|
+
worldWHChanged: false,
|
|
19
|
+
elevationCoefficientChanged: false
|
|
20
|
+
};
|
|
21
|
+
constructor(globe) {
|
|
22
|
+
this.globe = globe;
|
|
23
|
+
this.lastGeometry = globe.api_GetCurrentGeometry();
|
|
24
|
+
this.lastLook = globe.api_GetCurrentLookInfo();
|
|
25
|
+
this.lastLOD = globe.api_GetCurrentLODWithDecimal();
|
|
26
|
+
this.lastWorldWH = globe.api_GetCurrentWorldWH();
|
|
27
|
+
this.lastElevationCoefficient = globe.api_GetZScale();
|
|
28
|
+
}
|
|
29
|
+
checkChanges() {
|
|
30
|
+
const currentGeometry = this.globe.api_GetCurrentGeometry();
|
|
31
|
+
const currentLook = this.globe.api_GetCurrentLookInfo();
|
|
32
|
+
const currentLOD = this.globe.api_GetCurrentLODWithDecimal();
|
|
33
|
+
const currentWorldWH = this.globe.api_GetCurrentWorldWH();
|
|
34
|
+
this.changes.geometryChanged = (this.lastGeometry !== currentGeometry);
|
|
35
|
+
this.changes.lookChanged = (this.lastLook.CenterLong !== currentLook.CenterLong ||
|
|
36
|
+
this.lastLook.CenterLat !== currentLook.CenterLat ||
|
|
37
|
+
this.lastLook.Distance !== currentLook.Distance ||
|
|
38
|
+
this.lastLook.Tilt !== currentLook.Tilt ||
|
|
39
|
+
this.lastLook.NorthAng !== currentLook.NorthAng);
|
|
40
|
+
this.changes.lodChanged = (this.lastLOD !== currentLOD);
|
|
41
|
+
this.changes.worldWHChanged = (this.lastWorldWH.width !== currentWorldWH.width ||
|
|
42
|
+
this.lastWorldWH.height !== currentWorldWH.height);
|
|
43
|
+
// Update last known states
|
|
44
|
+
this.lastGeometry = currentGeometry;
|
|
45
|
+
this.lastLook = currentLook;
|
|
46
|
+
this.lastLOD = currentLOD;
|
|
47
|
+
this.lastWorldWH = currentWorldWH;
|
|
48
|
+
}
|
|
49
|
+
getChanges() {
|
|
50
|
+
return this.changes;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -18,7 +18,7 @@ export const flatLinesInputAdapter = (bearingLine) => {
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
export const flatLinesBearingInputAdapter = (bearingLine) => {
|
|
21
|
-
const { long, lat, rgba, key, bearingLat = 0, bearingLong = 0 } = bearingLine;
|
|
21
|
+
const { long, lat, rgba, key, bearingLat = 0, bearingLong = 0, msl } = bearingLine;
|
|
22
22
|
return {
|
|
23
23
|
key: key,
|
|
24
24
|
start: [long, lat],
|
|
@@ -27,7 +27,7 @@ export const flatLinesBearingInputAdapter = (bearingLine) => {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
export const bearingLineToCircleInputAdapter = (globe) => (bearingLine) => {
|
|
30
|
-
const { long, lat, endLong, endLat, rgba, altitude = 0 } = bearingLine;
|
|
30
|
+
const { long, lat, endLong, endLat, rgba, altitude = 0, msl = null } = bearingLine;
|
|
31
31
|
if (bearingLine.radius === undefined || bearingLine.radius === null) {
|
|
32
32
|
const radius = globe.Math.GetDist2D(long, lat, endLong, endLat);
|
|
33
33
|
bearingLine.radius = radius;
|
|
@@ -38,20 +38,22 @@ export const bearingLineToCircleInputAdapter = (globe) => (bearingLine) => {
|
|
|
38
38
|
radius: bearingLine.radius,
|
|
39
39
|
height: altitude,
|
|
40
40
|
color: rgba,
|
|
41
|
+
msl
|
|
41
42
|
};
|
|
42
43
|
};
|
|
43
44
|
export const bearingLineToArcInputAdapter = (bearingLine) => {
|
|
44
|
-
const { long, lat, endLong, endLat, rgba, altitude = 0 } = bearingLine;
|
|
45
|
+
const { long, lat, endLong, endLat, rgba, altitude = 0, msl } = bearingLine;
|
|
45
46
|
return {
|
|
46
47
|
key: bearingLine.key,
|
|
47
48
|
start: [long, lat],
|
|
48
49
|
end: [endLong, endLat],
|
|
49
50
|
height: altitude,
|
|
50
51
|
color: rgba,
|
|
52
|
+
msl: msl
|
|
51
53
|
};
|
|
52
54
|
};
|
|
53
55
|
export const bearingLineToBearingArcInputAdapter = (globe, bearingLine) => {
|
|
54
|
-
const { long, lat, bearingAngle, rgba, altitude = 0, key } = bearingLine;
|
|
56
|
+
const { long, lat, bearingAngle, rgba, altitude = 0, key, msl } = bearingLine;
|
|
55
57
|
if (bearingLine.radius === undefined || bearingLine.radius === null) {
|
|
56
58
|
throw new Error("Bearing line radius is not defined. Please calculate it before converting to ArcInput.");
|
|
57
59
|
}
|
|
@@ -64,6 +66,7 @@ export const bearingLineToBearingArcInputAdapter = (globe, bearingLine) => {
|
|
|
64
66
|
end: [endLong, endLat],
|
|
65
67
|
height: altitude,
|
|
66
68
|
color: rgba,
|
|
69
|
+
msl,
|
|
67
70
|
};
|
|
68
71
|
};
|
|
69
72
|
export const bearingLineToPieceOfPieInputAdapter = (globe, item) => {
|
|
@@ -71,7 +74,7 @@ export const bearingLineToPieceOfPieInputAdapter = (globe, item) => {
|
|
|
71
74
|
const long = radian(item.long);
|
|
72
75
|
const endLat = radian(item.endLat);
|
|
73
76
|
const endLong = radian(item.endLong);
|
|
74
|
-
const altitude = (item.altitude ?? 0)
|
|
77
|
+
const altitude = (item.altitude ?? 0);
|
|
75
78
|
const radius = item.radius ? item.radius * 0.2 : 10;
|
|
76
79
|
// @ts-ignore
|
|
77
80
|
const { long: bearingLong, lat: bearingLat } = globe.Math.FindPointByPolar(item.long, item.lat, item.radius, item.bearingAngle);
|
|
@@ -37,6 +37,7 @@ export class BearingLinePlugin {
|
|
|
37
37
|
defaultColor: [1, 1, 1, 0.5],
|
|
38
38
|
defaultHeightFromGroundIn3D: 30.0,
|
|
39
39
|
variativeColorsOn: false,
|
|
40
|
+
isMSL: false
|
|
40
41
|
},
|
|
41
42
|
arcOnTerrainOptions: {
|
|
42
43
|
defaultHeightFromGroundIn3D: 30.0,
|
|
@@ -44,6 +45,7 @@ export class BearingLinePlugin {
|
|
|
44
45
|
defaultColor: [1, 1, 1, 0.5],
|
|
45
46
|
globeViewOn: true,
|
|
46
47
|
flatViewOn: false,
|
|
48
|
+
isMSL: false
|
|
47
49
|
},
|
|
48
50
|
lineOptions: {
|
|
49
51
|
flatViewOn: true,
|
|
@@ -411,11 +413,11 @@ export class BearingLinePlugin {
|
|
|
411
413
|
throw new Error("Circle and Arc plugins are not initialized.");
|
|
412
414
|
}
|
|
413
415
|
if (this.drawOptions.drawVRM) {
|
|
414
|
-
this.circlePlugin.setPluginOpacity(this._opacities.circle ?? this._opacities.general);
|
|
416
|
+
this.circlePlugin.setPluginOpacity(this._opacities.circle ?? this._opacities.general, false);
|
|
415
417
|
this.circlePlugin.draw3D();
|
|
416
418
|
}
|
|
417
419
|
if (this.drawOptions.drawBearingLine) {
|
|
418
|
-
this.arcPluginBL.setPluginOpacity(this._opacities.
|
|
420
|
+
this.arcPluginBL.setPluginOpacity(this._opacities.bearing ?? this._opacities.general, false);
|
|
419
421
|
this.arcPluginBL.draw3D();
|
|
420
422
|
}
|
|
421
423
|
if (this.drawOptions.drawAngleRing) {
|
|
@@ -423,12 +425,12 @@ export class BearingLinePlugin {
|
|
|
423
425
|
const tiltAngle = this.globe.api_GetCurrentLookInfo().Tilt;
|
|
424
426
|
const opacity = pieceOfPieOpacityAdaptor(currentLOD, tiltAngle) * (this._opacities.general ?? 1);
|
|
425
427
|
if (opacity > 0) {
|
|
426
|
-
this.pieceOfPiePlugin.setPluginOpacity(opacity);
|
|
428
|
+
this.pieceOfPiePlugin.setPluginOpacity(opacity, false);
|
|
427
429
|
this.pieceOfPiePlugin.draw3D();
|
|
428
430
|
}
|
|
429
431
|
}
|
|
430
432
|
const currentGeometry = this.globe.api_GetCurrentGeometry();
|
|
431
|
-
this.arcPlugin.setPluginOpacity(this._opacities.arc ?? this._opacities.general);
|
|
433
|
+
this.arcPlugin.setPluginOpacity(this._opacities.arc ?? this._opacities.general, false);
|
|
432
434
|
this.arcPlugin.draw3D();
|
|
433
435
|
if (currentGeometry === 1) {
|
|
434
436
|
this.linePlugin.draw3D();
|
|
@@ -22,6 +22,7 @@ export const circleDataAdaptor = (globe, chain) => {
|
|
|
22
22
|
radius,
|
|
23
23
|
height: chainProperties.altitude ?? 0,
|
|
24
24
|
color: color,
|
|
25
|
+
msl: chainProperties.msl ?? null
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
return circleInputs;
|
|
@@ -45,6 +46,7 @@ export function arcDataAdaptor(chain) {
|
|
|
45
46
|
end: [nextLong, nextLat],
|
|
46
47
|
height: chainProperties.altitude ?? 0,
|
|
47
48
|
color: color,
|
|
49
|
+
msl: chainProperties.msl ?? null
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
return arcInputs;
|
|
@@ -27,6 +27,7 @@ export class CircleLineChainPlugin {
|
|
|
27
27
|
variativeColorsOn: false,
|
|
28
28
|
defaultColor: [1, 1, 1, 1],
|
|
29
29
|
defaultHeightFromGroundIn3D: 30,
|
|
30
|
+
isMSL: false
|
|
30
31
|
},
|
|
31
32
|
arcOnTerrainOptions: {
|
|
32
33
|
flatViewOn: true,
|
|
@@ -35,7 +36,8 @@ export class CircleLineChainPlugin {
|
|
|
35
36
|
defaultColor: [1, 1, 1, 1],
|
|
36
37
|
defaultHeightFromGroundIn3D: 0,
|
|
37
38
|
vertexCount: 32,
|
|
38
|
-
cameraAttractionIsOn: true // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
39
|
+
cameraAttractionIsOn: true, // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
40
|
+
isMSL: false, // If true, no elevation of terrain
|
|
39
41
|
},
|
|
40
42
|
lineOptions: {
|
|
41
43
|
flatViewOn: true,
|
|
@@ -164,6 +166,15 @@ export class CircleLineChainPlugin {
|
|
|
164
166
|
// set Opacities of plugins
|
|
165
167
|
this.globe?.DrawRender();
|
|
166
168
|
}
|
|
169
|
+
setElevationMode(mode) {
|
|
170
|
+
if (this._freed) {
|
|
171
|
+
console.warn("CircleLineChainPlugin is freed, cannot set elevation mode.");
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this.arcPlugin?.setElevationMode(mode);
|
|
175
|
+
this.circlePlugin?.setElevationMode(mode);
|
|
176
|
+
this.globe?.DrawRender();
|
|
177
|
+
}
|
|
167
178
|
deleteChains(chainKeys) {
|
|
168
179
|
if (this._freed) {
|
|
169
180
|
console.warn("CircleLineChainPlugin is freed, cannot delete chains.");
|
|
@@ -287,6 +298,15 @@ export class CircleLineChainPlugin {
|
|
|
287
298
|
this.globe?.DrawRender();
|
|
288
299
|
}
|
|
289
300
|
setDefaultSemiPluginColor(semiPluginName, color) {
|
|
301
|
+
if (semiPluginName === "ALL") {
|
|
302
|
+
this._semiPluginOptions.circleOnTerrainOptions.defaultColor = color;
|
|
303
|
+
this._semiPluginOptions.arcOnTerrainOptions.defaultColor = color;
|
|
304
|
+
this._semiPluginOptions.lineOptions.defaultColor = color;
|
|
305
|
+
this.circlePlugin?.setDefaultColor(color);
|
|
306
|
+
this.arcPlugin?.setDefaultColor(color);
|
|
307
|
+
this.linePlugin?.setDefaultColor(color);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
290
310
|
switch (semiPluginName) {
|
|
291
311
|
case "circleOnTerrain":
|
|
292
312
|
this._semiPluginOptions.circleOnTerrainOptions.defaultColor = color;
|
|
@@ -383,7 +403,7 @@ export class CircleLineChainPlugin {
|
|
|
383
403
|
}
|
|
384
404
|
const circleOpacity = getOpacity(this._opacities, "circle");
|
|
385
405
|
if (this._drawCircleOn && circleOpacity !== 0) {
|
|
386
|
-
this.circlePlugin?.setPluginOpacity(circleOpacity);
|
|
406
|
+
this.circlePlugin?.setPluginOpacity(circleOpacity, false);
|
|
387
407
|
this.circlePlugin?.draw3D();
|
|
388
408
|
}
|
|
389
409
|
const currentGeometry = globe.api_GetCurrentGeometry();
|
|
@@ -392,12 +412,12 @@ export class CircleLineChainPlugin {
|
|
|
392
412
|
// globe view
|
|
393
413
|
const lineOpacity = getOpacity(this._opacities, "globeArc");
|
|
394
414
|
if (lineOpacity !== 0) {
|
|
395
|
-
this.linePlugin?.setPluginOpacity(lineOpacity);
|
|
415
|
+
this.linePlugin?.setPluginOpacity(lineOpacity, false);
|
|
396
416
|
this.linePlugin?.draw3D();
|
|
397
417
|
}
|
|
398
418
|
const arcOpacity = getOpacity(this._opacities, "globeArcFitsTerrain");
|
|
399
419
|
if (arcOpacity !== 0) {
|
|
400
|
-
this.arcPlugin?.setPluginOpacity(arcOpacity);
|
|
420
|
+
this.arcPlugin?.setPluginOpacity(arcOpacity, false);
|
|
401
421
|
this.arcPlugin?.draw3D();
|
|
402
422
|
}
|
|
403
423
|
break;
|
|
@@ -7,19 +7,71 @@
|
|
|
7
7
|
// altitude: rangeRing.altitude,
|
|
8
8
|
// };
|
|
9
9
|
// }
|
|
10
|
+
const keyAdapter = (centerID, rangeID) => {
|
|
11
|
+
return `${centerID}-${rangeID}`;
|
|
12
|
+
};
|
|
13
|
+
export const allKeysAdapter = (rangeRing) => {
|
|
14
|
+
const result = new Array(rangeRing.rings.length);
|
|
15
|
+
for (let i = 0; i < rangeRing.rings.length; i++) {
|
|
16
|
+
result[i] = keyAdapter(rangeRing.centerID, rangeRing.rings[i].ringID);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
10
20
|
export const rangeRingToCircleInputAdapter = (rangeRing) => {
|
|
21
|
+
const centerID = rangeRing.centerID;
|
|
11
22
|
return rangeRing.rings.map(ring => ({
|
|
12
|
-
key: ring.
|
|
23
|
+
key: keyAdapter(centerID, ring.ringID),
|
|
13
24
|
center: [rangeRing.long, rangeRing.lat],
|
|
14
25
|
radius: ring.radius,
|
|
15
26
|
color: rangeRing.rgba,
|
|
16
27
|
altitude: rangeRing.altitude,
|
|
17
28
|
}));
|
|
18
29
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
export const allArcKeysAdapter = (rangeRing) => {
|
|
31
|
+
const arcEachRing = Math.ceil(360 / rangeRing.stepAngle);
|
|
32
|
+
const result = new Array(arcEachRing * rangeRing.rings.length);
|
|
33
|
+
for (let i = 0; i < rangeRing.rings.length; i++)
|
|
34
|
+
for (let j = 0; j < arcEachRing; j++)
|
|
35
|
+
result[i * arcEachRing + j] = keyAdapter(rangeRing.centerID, rangeRing.rings[i].ringID) + `-${j}`;
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
export const rangeRingToArcInputAdapter = (globe, rangeRingInput) => {
|
|
39
|
+
const { long, lat, stepAngle, altitude = 0, rgba, rings } = rangeRingInput;
|
|
40
|
+
const arcEachRing = Math.ceil(360 / stepAngle);
|
|
41
|
+
const result = new Array(rings.length * arcEachRing);
|
|
42
|
+
for (let i = 0; i < rings.length; i++) {
|
|
43
|
+
const ring = rings[i];
|
|
44
|
+
for (let j = 0; j < arcEachRing; j++) {
|
|
45
|
+
const angle = Math.min(stepAngle * j, 360);
|
|
46
|
+
const startLongLat = globe.Math.FindPointByPolar(long, lat, ring.radius, angle);
|
|
47
|
+
const endLongLat = globe.Math.FindPointByPolar(long, lat, ring.radius - ring.padding, angle);
|
|
48
|
+
result[i * arcEachRing + j] = {
|
|
49
|
+
key: keyAdapter(rangeRingInput.centerID, ring.ringID) + `-${j}`,
|
|
50
|
+
start: [startLongLat.long, startLongLat.lat],
|
|
51
|
+
end: [endLongLat.long, endLongLat.lat],
|
|
52
|
+
color: rgba,
|
|
53
|
+
height: altitude,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
export const padding1DegreeInputAdapter = (bearingLine) => {
|
|
60
|
+
const { long, lat, rgba, altitude = 0, rings } = bearingLine;
|
|
61
|
+
const result = new Array(rings.length);
|
|
62
|
+
for (let i = 0; i < rings.length; i++) {
|
|
63
|
+
const ring = rings[i];
|
|
64
|
+
result[i] = {
|
|
65
|
+
key: keyAdapter(bearingLine.centerID, ring.ringID),
|
|
66
|
+
center: [long, lat],
|
|
67
|
+
outerRadius: ring.radius,
|
|
68
|
+
colorsRatios: [{
|
|
69
|
+
color: rgba,
|
|
70
|
+
ratio: 360,
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
heightFromGroundIn3D: altitude,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
25
77
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CircleOnTerrainPlugin } from "../../semiplugins/shape-on-terrain/circle-plugin";
|
|
2
2
|
import { ArcOnTerrainPlugin } from "../../semiplugins/shape-on-terrain/arc-plugin";
|
|
3
|
-
import { LinePlugin } from "../../semiplugins/lightweight/line-plugin";
|
|
4
3
|
// @ts-ignore
|
|
5
4
|
export class RangeRingPlugin {
|
|
6
5
|
id;
|
|
@@ -8,15 +7,36 @@ export class RangeRingPlugin {
|
|
|
8
7
|
gl = null;
|
|
9
8
|
circlePlugin;
|
|
10
9
|
arcPlugin;
|
|
11
|
-
|
|
10
|
+
paddingPlugin = null; // TODO: implement padding plugin
|
|
12
11
|
_memory = new Map();
|
|
12
|
+
_semiPluginOptions = {
|
|
13
|
+
circleOnTerrainOptions: {
|
|
14
|
+
variativeColorsOn: false,
|
|
15
|
+
defaultColor: [1, 1, 1, 1],
|
|
16
|
+
defaultHeightFromGroundIn3D: 30,
|
|
17
|
+
},
|
|
18
|
+
arcOnTerrainOptions: {
|
|
19
|
+
flatViewOn: true,
|
|
20
|
+
globeViewOn: true,
|
|
21
|
+
variativeColorsOn: false,
|
|
22
|
+
defaultColor: [1, 1, 1, 1],
|
|
23
|
+
defaultHeightFromGroundIn3D: 0,
|
|
24
|
+
vertexCount: 32,
|
|
25
|
+
cameraAttractionIsOn: true // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
26
|
+
},
|
|
27
|
+
paddingOptions: {
|
|
28
|
+
variativeColorsOn: false,
|
|
29
|
+
defaultColor: [1, 1, 1, 1],
|
|
30
|
+
defaultHeightFromGroundIn3D: 0,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
13
33
|
constructor(id) {
|
|
14
34
|
this.id = id;
|
|
15
35
|
this.circlePlugin = new CircleOnTerrainPlugin(this.id + "-circle");
|
|
16
36
|
this.arcPlugin = new ArcOnTerrainPlugin(this.id + "-arc", {
|
|
17
37
|
vertexCount: 5,
|
|
18
38
|
});
|
|
19
|
-
this.
|
|
39
|
+
this.paddingPlugin = null; // TODO: initialize padding plugin if needed
|
|
20
40
|
}
|
|
21
41
|
insertBulk(items) {
|
|
22
42
|
}
|
|
@@ -66,10 +66,12 @@ export class LinePlugin {
|
|
|
66
66
|
_bufferOrchestrator.deleteBulk(keys);
|
|
67
67
|
this.globe?.DrawRender();
|
|
68
68
|
}
|
|
69
|
-
setPluginOpacity(opacity) {
|
|
69
|
+
setPluginOpacity(opacity, drawRender = false) {
|
|
70
70
|
constraintFloat(opacity, 0, 1);
|
|
71
71
|
this._options.opacity = opacity;
|
|
72
|
-
|
|
72
|
+
if (drawRender) {
|
|
73
|
+
this.globe?.DrawRender();
|
|
74
|
+
}
|
|
73
75
|
}
|
|
74
76
|
setPluginDashedLineRatio(ratio) {
|
|
75
77
|
constraintFloat(ratio, 0, 1);
|
|
@@ -82,14 +84,16 @@ export class LinePlugin {
|
|
|
82
84
|
this._options.defaultColor[3] = opacity; // Update the default color's alpha channel
|
|
83
85
|
this.globe?.DrawRender();
|
|
84
86
|
}
|
|
85
|
-
setDefaultColor(color) {
|
|
87
|
+
setDefaultColor(color, drawRender = false) {
|
|
86
88
|
if (!this.globe || !this.gl) {
|
|
87
89
|
console.warn("Globe or WebGL context is not initialized.");
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
92
|
this._options.defaultColor = color;
|
|
91
93
|
this._uboHandler?.updateSingle("u_color", new Float32Array(color));
|
|
92
|
-
|
|
94
|
+
if (drawRender) {
|
|
95
|
+
this.globe.DrawRender();
|
|
96
|
+
}
|
|
93
97
|
}
|
|
94
98
|
// GLOBE INTERACTION METHODS
|
|
95
99
|
draw3D() {
|
|
@@ -41,10 +41,12 @@ export class PieceOfPiePlugin {
|
|
|
41
41
|
this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersMap);
|
|
42
42
|
this.globe?.DrawRender();
|
|
43
43
|
}
|
|
44
|
-
setPluginOpacity(opacity) {
|
|
44
|
+
setPluginOpacity(opacity, drawRender = true) {
|
|
45
45
|
opacityCheck(opacity);
|
|
46
46
|
this._uboHandler?.updateSingle("u_opacity", new Float32Array([opacity]));
|
|
47
|
-
|
|
47
|
+
if (drawRender) {
|
|
48
|
+
this.globe?.DrawRender();
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
setDrawMode(drawMode) {
|
|
50
52
|
if (drawMode !== "TRIANGLE_FAN" && drawMode !== "LINE_STRIP" && drawMode !== "BOTH") {
|
|
@@ -39,7 +39,7 @@ export class ArcOnTerrainPlugin {
|
|
|
39
39
|
defaultHeightFromGroundIn3D = 30.0, // Default height from ground in
|
|
40
40
|
vertexCount = 70, // Number of vertices per arc
|
|
41
41
|
cameraAttractionIsOn = true, // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
42
|
-
bufferType = "STREAM_DRAW" } = {}) {
|
|
42
|
+
bufferType = "STREAM_DRAW", isMSL = false } = {}) {
|
|
43
43
|
this.id = id;
|
|
44
44
|
this._arcMap = new Map();
|
|
45
45
|
this._options = {
|
|
@@ -50,7 +50,8 @@ export class ArcOnTerrainPlugin {
|
|
|
50
50
|
defaultHeightFromGroundIn3D: defaultHeightFromGroundIn3D ? defaultHeightFromGroundIn3D : 30.0,
|
|
51
51
|
vertexCount: vertexCount ? vertexCount : 70,
|
|
52
52
|
cameraAttractionIsOn: cameraAttractionIsOn ? true : false,
|
|
53
|
-
bufferType: bufferType ? bufferType : "STREAM_DRAW"
|
|
53
|
+
bufferType: bufferType ? bufferType : "STREAM_DRAW",
|
|
54
|
+
isMSL: isMSL ? true : false
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
insertBulk(arcs) {
|
|
@@ -104,22 +105,40 @@ export class ArcOnTerrainPlugin {
|
|
|
104
105
|
_bufferOrchestrator.updateBulk([{ key: key, color: color }], bufferManagerMap, ["color"]);
|
|
105
106
|
this.globe.DrawRender();
|
|
106
107
|
}
|
|
107
|
-
setPluginOpacity(opacity) {
|
|
108
|
+
setPluginOpacity(opacity, drawRender = false) {
|
|
108
109
|
if (!this.globe || !this.gl) {
|
|
109
110
|
console.warn("Globe or WebGL context is not initialized.");
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
113
|
opacityCheck(opacity);
|
|
113
114
|
this._opacity = opacity;
|
|
114
|
-
|
|
115
|
+
if (drawRender) {
|
|
116
|
+
this.globe.DrawRender();
|
|
117
|
+
}
|
|
115
118
|
}
|
|
116
|
-
setDefaultColor(color) {
|
|
119
|
+
setDefaultColor(color, drawRender = false) {
|
|
117
120
|
if (!this.globe || !this.gl) {
|
|
118
121
|
console.warn("Globe or WebGL context is not initialized.");
|
|
119
122
|
return;
|
|
120
123
|
}
|
|
121
124
|
this._options.defaultColor = color;
|
|
122
125
|
this._arcUBOHandler?.updateSingle("u_color", new Float32Array(color));
|
|
126
|
+
if (drawRender) {
|
|
127
|
+
this.globe.DrawRender();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
setElevationMode(mode) {
|
|
131
|
+
switch (mode) {
|
|
132
|
+
case "msl":
|
|
133
|
+
this._options.isMSL = true;
|
|
134
|
+
break;
|
|
135
|
+
case "agl":
|
|
136
|
+
this._options.isMSL = false;
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
throw new Error(`Unknown elevation mode: ${mode}`);
|
|
140
|
+
}
|
|
141
|
+
this._buildArcs(); // can be async
|
|
123
142
|
this.globe.DrawRender();
|
|
124
143
|
}
|
|
125
144
|
setCameraAttraction(isOn) {
|
|
@@ -151,7 +170,9 @@ export class ArcOnTerrainPlugin {
|
|
|
151
170
|
}
|
|
152
171
|
const globe = this.globe;
|
|
153
172
|
this._staticDynamicStrategy?.updateState();
|
|
154
|
-
|
|
173
|
+
if (globe.api_IsScreenMoving()) {
|
|
174
|
+
this._buildArcs(); // can be async
|
|
175
|
+
}
|
|
155
176
|
const { gl, program, _bufferOrchestrator, _vao, _arcUBOHandler, } = this;
|
|
156
177
|
if (!gl || !program || !_bufferOrchestrator || !_vao || !_arcUBOHandler) {
|
|
157
178
|
console.warn("WebGL context, program, or buffer orchestrator is not initialized.");
|
|
@@ -193,7 +214,8 @@ export class ArcOnTerrainPlugin {
|
|
|
193
214
|
key: "staticArcs",
|
|
194
215
|
longLatArr: longLatArr,
|
|
195
216
|
height: null,
|
|
196
|
-
color: this._options.defaultColor
|
|
217
|
+
color: this._options.defaultColor,
|
|
218
|
+
msl: null
|
|
197
219
|
}];
|
|
198
220
|
if (keys.length == 0) {
|
|
199
221
|
for (const [key, [arcInstance, arcInput]] of _arcMap) {
|
|
@@ -207,6 +229,7 @@ export class ArcOnTerrainPlugin {
|
|
|
207
229
|
data[0].key = key;
|
|
208
230
|
data[0].height = arcInput.height ?? this._options.defaultHeightFromGroundIn3D;
|
|
209
231
|
data[0].color = arcInput.color ?? this._options.defaultColor;
|
|
232
|
+
data[0].msl = arcInput.msl ?? null;
|
|
210
233
|
if (calledFromInsert) {
|
|
211
234
|
this._bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
212
235
|
}
|
|
@@ -232,6 +255,7 @@ export class ArcOnTerrainPlugin {
|
|
|
232
255
|
data[0].key = key;
|
|
233
256
|
data[0].height = arcInput.height ?? this._options.defaultHeightFromGroundIn3D;
|
|
234
257
|
data[0].color = arcInput.color ?? this._options.defaultColor;
|
|
258
|
+
data[0].msl = arcInput.msl ?? null;
|
|
235
259
|
if (calledFromInsert) {
|
|
236
260
|
this._bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
237
261
|
}
|
|
@@ -288,7 +312,7 @@ export class ArcOnTerrainPlugin {
|
|
|
288
312
|
key: key,
|
|
289
313
|
longLatArr: longLatArr,
|
|
290
314
|
height: arcInput.height ?? this._options.defaultHeightFromGroundIn3D,
|
|
291
|
-
|
|
315
|
+
msl: arcInput.msl ?? null
|
|
292
316
|
});
|
|
293
317
|
}
|
|
294
318
|
// this._bufferOrchestrator.resetWithCapacity(bufferManagerMap, result.length);
|
|
@@ -312,8 +336,8 @@ export class ArcOnTerrainPlugin {
|
|
|
312
336
|
this.bufferManagerMap.set("position3d", {
|
|
313
337
|
bufferManager: new BufferManager(gl, 3 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
314
338
|
adaptor: (item) => {
|
|
315
|
-
const { longLatArr, height = this._options.defaultHeightFromGroundIn3D } = item;
|
|
316
|
-
const result = globe3Dcoordinates(globe,
|
|
339
|
+
const { longLatArr, height = this._options.defaultHeightFromGroundIn3D, msl = this._options.isMSL } = item;
|
|
340
|
+
const result = globe3Dcoordinates(globe, longLatArr, height, msl, { paddingCount: 1 });
|
|
317
341
|
return result;
|
|
318
342
|
}
|
|
319
343
|
});
|