@pirireis/webglobeplugins 0.15.2-3.alpha → 0.15.3-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/arc-generate-points copy.js +366 -0
- package/Math/arc.js +2 -1
- package/Math/circle-cdf-points.js +170 -1
- package/Math/circle.js +25 -0
- package/Math/globe-util/horizon-plane.js +112 -0
- package/Math/methods.js +2 -2
- package/Math/vec3.js +2 -6
- package/altitude-locator/draw-subset-obj.js +16 -0
- package/altitude-locator/plugin.js +1 -1
- package/bearing-line/plugin.js +2 -3
- package/package.json +1 -1
- package/point-tracks/plugin.js +22 -82
- package/programs/line-on-globe/lines-color-instanced-flat.js +1 -0
- package/programs/line-on-globe/linestrip/linestrip.js +28 -2
- package/programs/line-on-globe/paddings/paddings.js +1 -0
- package/programs/point-on-globe/element-globe-surface-glow.js +1 -0
- package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
- package/programs/totems/camerauniformblock.js +0 -7
- package/programs/totems/canvas-webglobe-info.js +9 -9
- package/range-tools-on-terrain/bearing-line/adapters.js +5 -8
- package/range-tools-on-terrain/bearing-line/plugin.js +20 -95
- package/range-tools-on-terrain/circle-line-chain/adapters.js +8 -15
- package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +12 -16
- package/range-tools-on-terrain/circle-line-chain/plugin.js +11 -67
- package/range-tools-on-terrain/range-ring/adapters.js +6 -74
- package/range-tools-on-terrain/range-ring/plugin.js +7 -222
- package/range-tools-on-terrain/range-ring/types.js +1 -9
- package/semiplugins/lightweight/line-plugin.js +47 -65
- package/semiplugins/lightweight/piece-of-pie-plugin.js +18 -44
- package/semiplugins/shape-on-terrain/arc-plugin.js +100 -197
- package/semiplugins/shape-on-terrain/circle-plugin.js +90 -209
- package/semiplugins/shape-on-terrain/derived/padding-plugin.js +101 -0
- package/semiplugins/shape-on-terrain/one-degree-padding.js +85 -0
- package/util/account/single-attribute-buffer-management/buffer-manager.js +0 -10
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +8 -145
- package/util/account/single-attribute-buffer-management/object-store.js +0 -7
- package/util/build-strategy/static-dynamic.js +1 -11
- package/util/check/typecheck.js +0 -12
- package/util/geometry/index.js +1 -2
- package/programs/totems/globe-changes.js +0 -59
- package/semiplugins/interface.js +0 -1
- package/semiplugins/shape-on-terrain/padding-1-degree.js +0 -538
- package/util/account/single-attribute-buffer-management/buffer-orchestrator1.js +0 -159
- package/util/frame-counter-trigger.js +0 -84
- package/write-text/context-text4.js +0 -140
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* set and get node data
|
|
3
|
+
* node indexes;
|
|
4
|
+
*/
|
|
1
5
|
export class ChainListMap {
|
|
2
6
|
_chainMap;
|
|
3
7
|
_chainSideProperties;
|
|
@@ -75,9 +79,6 @@ export class ChainListMap {
|
|
|
75
79
|
deleteKeys.push(chain[chain.length - 2].__identity__);
|
|
76
80
|
deleteKeys.push(chain[chain.length - 1].__identity__);
|
|
77
81
|
}
|
|
78
|
-
else if (chain.length === 1) {
|
|
79
|
-
deleteKeys.push(lastItem.__identity__);
|
|
80
|
-
}
|
|
81
82
|
}
|
|
82
83
|
else {
|
|
83
84
|
newChain.push(lastItem);
|
|
@@ -94,7 +95,7 @@ export class ChainListMap {
|
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
this._chainMap.delete(chainKey);
|
|
97
|
-
this._chainSideProperties.delete(chainKey);
|
|
98
|
+
this._chainSideProperties.delete(chainKey); // TODO: this might be this way but adding this know can cause side effects
|
|
98
99
|
for (const key of keys)
|
|
99
100
|
this._indexMap.delete(key);
|
|
100
101
|
return keys;
|
|
@@ -110,13 +111,13 @@ export class ChainListMap {
|
|
|
110
111
|
chain[index] = node;
|
|
111
112
|
}
|
|
112
113
|
updateNodesProperties(chainKey, nodes) {
|
|
113
|
-
const chain = this._chainMap.get(chainKey);
|
|
114
|
-
if (!chain)
|
|
115
|
-
return;
|
|
116
114
|
nodes.forEach((node) => {
|
|
117
115
|
const index = this.getIndexOfNode(chainKey, node.key);
|
|
118
116
|
if (index === undefined)
|
|
119
117
|
return;
|
|
118
|
+
const chain = this._chainMap.get(chainKey);
|
|
119
|
+
if (!chain)
|
|
120
|
+
return;
|
|
120
121
|
const chainNode = chain[index];
|
|
121
122
|
if (node.circleProperties) {
|
|
122
123
|
if (typeof chainNode.circleProperties !== 'object')
|
|
@@ -132,12 +133,6 @@ export class ChainListMap {
|
|
|
132
133
|
chainNode.lineProperties[key] = value;
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
|
-
if (node.circleOn !== undefined)
|
|
136
|
-
chainNode.circleOn = node.circleOn;
|
|
137
|
-
if (node.arcOn !== undefined)
|
|
138
|
-
chainNode.arcOn = node.arcOn;
|
|
139
|
-
if (node.lineOn !== undefined)
|
|
140
|
-
chainNode.lineOn = node.lineOn;
|
|
141
136
|
});
|
|
142
137
|
}
|
|
143
138
|
updateCoordsinatesOfNode(node, chainKey) {
|
|
@@ -173,9 +168,10 @@ export class ChainListMap {
|
|
|
173
168
|
memoryProperties[key] = value;
|
|
174
169
|
});
|
|
175
170
|
}
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
|
|
171
|
+
// TODO: bad name clean up, need to check on frontend
|
|
172
|
+
getNodeProperties(chainKey) {
|
|
173
|
+
return this._chainSideProperties.get(chainKey);
|
|
174
|
+
}
|
|
179
175
|
getChainProperties(chainKey) {
|
|
180
176
|
return this._chainSideProperties.get(chainKey);
|
|
181
177
|
}
|
|
@@ -27,7 +27,6 @@ export class CircleLineChainPlugin {
|
|
|
27
27
|
variativeColorsOn: false,
|
|
28
28
|
defaultColor: [1, 1, 1, 1],
|
|
29
29
|
defaultHeightFromGroundIn3D: 30,
|
|
30
|
-
isMSL: false
|
|
31
30
|
},
|
|
32
31
|
arcOnTerrainOptions: {
|
|
33
32
|
flatViewOn: true,
|
|
@@ -36,8 +35,7 @@ export class CircleLineChainPlugin {
|
|
|
36
35
|
defaultColor: [1, 1, 1, 1],
|
|
37
36
|
defaultHeightFromGroundIn3D: 0,
|
|
38
37
|
vertexCount: 32,
|
|
39
|
-
cameraAttractionIsOn: true
|
|
40
|
-
isMSL: false, // If true, no elevation of terrain
|
|
38
|
+
cameraAttractionIsOn: true // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
41
39
|
},
|
|
42
40
|
lineOptions: {
|
|
43
41
|
flatViewOn: true,
|
|
@@ -47,7 +45,7 @@ export class CircleLineChainPlugin {
|
|
|
47
45
|
dashedLineOpacityVariativeOn: false,
|
|
48
46
|
dashedLineRatioVariativeOn: false,
|
|
49
47
|
bufferType: "DYNAMIC_DRAW",
|
|
50
|
-
opacity: 1.0
|
|
48
|
+
opacity: 1.0
|
|
51
49
|
}
|
|
52
50
|
};
|
|
53
51
|
constructor(id, { drawCircleOn, textWritersMap, textDataPreAdaptor, opacities, lineAdaptor, arcAdaptor, circleAdaptor, arcOnTerrainOptions, circleOnTerrainOptions, lineOptions } = {}) {
|
|
@@ -118,17 +116,11 @@ export class CircleLineChainPlugin {
|
|
|
118
116
|
if (this._chainListMap.hasChain(chainKey)) {
|
|
119
117
|
chainsToClean.push(chainKey);
|
|
120
118
|
}
|
|
121
|
-
}
|
|
122
|
-
this._cleanChainsFromSemiPlugins(chainsToClean);
|
|
123
|
-
for (const { chainKey, chainProperties, nodes } of chains) {
|
|
124
|
-
if (!chainKey || !chainProperties || !nodes || nodes.length === 0) {
|
|
125
|
-
console.warn("Invalid chain data, skipping insertion.");
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
119
|
this._chainListMap.setChain(chainKey, nodes);
|
|
129
120
|
this._chainListMap.setChainProperties(chainKey, chainProperties);
|
|
130
121
|
chainKeys.push(chainKey);
|
|
131
122
|
}
|
|
123
|
+
this._cleanChainsFromSemiPlugins(chainsToClean);
|
|
132
124
|
// Reconstruct chains
|
|
133
125
|
this._reconstructChains(chainKeys);
|
|
134
126
|
// Update texts
|
|
@@ -158,23 +150,12 @@ export class CircleLineChainPlugin {
|
|
|
158
150
|
this.globe?.DrawRender();
|
|
159
151
|
}
|
|
160
152
|
setOpacities(opacities) {
|
|
161
|
-
|
|
162
|
-
console.warn("CircleLineChainPlugin is freed, cannot set opacities.");
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
153
|
+
// TODO: Check opacities
|
|
165
154
|
this._opacities = {
|
|
166
155
|
...this._opacities,
|
|
167
156
|
...opacities
|
|
168
157
|
};
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
setElevationMode(mode) {
|
|
172
|
-
if (this._freed) {
|
|
173
|
-
console.warn("CircleLineChainPlugin is freed, cannot set elevation mode.");
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
this.arcPlugin?.setElevationMode(mode);
|
|
177
|
-
this.circlePlugin?.setElevationMode(mode);
|
|
158
|
+
// set Opacities of plugins
|
|
178
159
|
this.globe?.DrawRender();
|
|
179
160
|
}
|
|
180
161
|
deleteChains(chainKeys) {
|
|
@@ -194,7 +175,6 @@ export class CircleLineChainPlugin {
|
|
|
194
175
|
this.circlePlugin?.deleteBulk(keys);
|
|
195
176
|
this._updateTexts(chainKeys, Array.from(this._textWritersMap.keys()));
|
|
196
177
|
}
|
|
197
|
-
this.globe?.DrawRender();
|
|
198
178
|
}
|
|
199
179
|
deleteNodes(keysAndNodes) {
|
|
200
180
|
if (this._freed) {
|
|
@@ -211,44 +191,17 @@ export class CircleLineChainPlugin {
|
|
|
211
191
|
this._updateTexts(chainKeysToReconstruct, Array.from(this._textWritersMap.keys()));
|
|
212
192
|
this.globe?.DrawRender();
|
|
213
193
|
}
|
|
214
|
-
updateNodesProperties(chainKey,
|
|
194
|
+
updateNodesProperties(chainKey, nodesAndPropertyMap, { textWriterIDs = [] } = {}) {
|
|
215
195
|
if (this._freed) {
|
|
216
196
|
console.warn("CircleLineChainPlugin is freed, cannot update nodes properties.");
|
|
217
197
|
return;
|
|
218
198
|
}
|
|
219
|
-
this._chainListMap.updateNodesProperties(chainKey,
|
|
199
|
+
this._chainListMap.updateNodesProperties(chainKey, nodesAndPropertyMap);
|
|
220
200
|
this._cleanChainsFromSemiPlugins([chainKey]);
|
|
221
201
|
this._reconstructChains([chainKey]);
|
|
222
202
|
this._updateTexts([chainKey], textWriterIDs);
|
|
223
203
|
this.globe?.DrawRender();
|
|
224
204
|
}
|
|
225
|
-
updateChainDrawOptionsProperties(chainKey, drawOptions) {
|
|
226
|
-
if (this._freed) {
|
|
227
|
-
console.warn("CircleLineChainPlugin is freed, cannot update chain draw options properties.");
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
const chain = this._chainListMap.getChain(chainKey);
|
|
231
|
-
if (!chain) {
|
|
232
|
-
console.warn(`Chain with key ${chainKey} not found.`);
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
const { nodes } = chain;
|
|
236
|
-
nodes.forEach((node) => {
|
|
237
|
-
if (drawOptions.circleOn !== undefined) {
|
|
238
|
-
node.circleOn = drawOptions.circleOn;
|
|
239
|
-
}
|
|
240
|
-
if (drawOptions.arcOn !== undefined) {
|
|
241
|
-
node.arcOn = drawOptions.arcOn;
|
|
242
|
-
}
|
|
243
|
-
if (drawOptions.line !== undefined) {
|
|
244
|
-
node.lineOn = drawOptions.line;
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
this._cleanChainsFromSemiPlugins([chainKey]);
|
|
248
|
-
this._reconstructChains([chainKey]);
|
|
249
|
-
this._updateTexts([chainKey], Array.from(this._textWritersMap.keys()));
|
|
250
|
-
this.globe?.DrawRender();
|
|
251
|
-
}
|
|
252
205
|
updateCoordinatesBulk(chains, { textWriterIDs = [] } = {}) {
|
|
253
206
|
if (this._freed) {
|
|
254
207
|
console.warn("CircleLineChainPlugin is freed, cannot update coordinates.");
|
|
@@ -300,15 +253,6 @@ export class CircleLineChainPlugin {
|
|
|
300
253
|
this.globe?.DrawRender();
|
|
301
254
|
}
|
|
302
255
|
setDefaultSemiPluginColor(semiPluginName, color) {
|
|
303
|
-
if (semiPluginName === "ALL") {
|
|
304
|
-
this._semiPluginOptions.circleOnTerrainOptions.defaultColor = color;
|
|
305
|
-
this._semiPluginOptions.arcOnTerrainOptions.defaultColor = color;
|
|
306
|
-
this._semiPluginOptions.lineOptions.defaultColor = color;
|
|
307
|
-
this.circlePlugin?.setDefaultColor(color);
|
|
308
|
-
this.arcPlugin?.setDefaultColor(color);
|
|
309
|
-
this.linePlugin?.setDefaultColor(color);
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
256
|
switch (semiPluginName) {
|
|
313
257
|
case "circleOnTerrain":
|
|
314
258
|
this._semiPluginOptions.circleOnTerrainOptions.defaultColor = color;
|
|
@@ -350,10 +294,10 @@ export class CircleLineChainPlugin {
|
|
|
350
294
|
for (const chainKey of chainKeys) {
|
|
351
295
|
// Clean chains from text writers
|
|
352
296
|
const nodeKeys = this._chainListMap.getNodeKeysOfChain(chainKey);
|
|
297
|
+
nodeKeys.pop(); // Remove the last key which is destination of the last circle
|
|
353
298
|
this._textWritersMap.forEach((writer) => {
|
|
354
299
|
writer.deleteTextBulk(nodeKeys);
|
|
355
300
|
});
|
|
356
|
-
nodeKeys.pop(); // Remove the last key which is destination of the last circle
|
|
357
301
|
// Clean chains from semi-plugins
|
|
358
302
|
this.circlePlugin?.deleteBulk(nodeKeys);
|
|
359
303
|
this.linePlugin?.deleteBulk(nodeKeys);
|
|
@@ -405,7 +349,7 @@ export class CircleLineChainPlugin {
|
|
|
405
349
|
}
|
|
406
350
|
const circleOpacity = getOpacity(this._opacities, "circle");
|
|
407
351
|
if (this._drawCircleOn && circleOpacity !== 0) {
|
|
408
|
-
this.circlePlugin?.setPluginOpacity(circleOpacity
|
|
352
|
+
this.circlePlugin?.setPluginOpacity(circleOpacity);
|
|
409
353
|
this.circlePlugin?.draw3D();
|
|
410
354
|
}
|
|
411
355
|
const currentGeometry = globe.api_GetCurrentGeometry();
|
|
@@ -414,12 +358,12 @@ export class CircleLineChainPlugin {
|
|
|
414
358
|
// globe view
|
|
415
359
|
const lineOpacity = getOpacity(this._opacities, "globeArc");
|
|
416
360
|
if (lineOpacity !== 0) {
|
|
417
|
-
this.linePlugin?.setPluginOpacity(lineOpacity
|
|
361
|
+
this.linePlugin?.setPluginOpacity(lineOpacity);
|
|
418
362
|
this.linePlugin?.draw3D();
|
|
419
363
|
}
|
|
420
364
|
const arcOpacity = getOpacity(this._opacities, "globeArcFitsTerrain");
|
|
421
365
|
if (arcOpacity !== 0) {
|
|
422
|
-
this.arcPlugin?.setPluginOpacity(arcOpacity
|
|
366
|
+
this.arcPlugin?.setPluginOpacity(arcOpacity);
|
|
423
367
|
this.arcPlugin?.draw3D();
|
|
424
368
|
}
|
|
425
369
|
break;
|
|
@@ -7,87 +7,19 @@
|
|
|
7
7
|
// altitude: rangeRing.altitude,
|
|
8
8
|
// };
|
|
9
9
|
// }
|
|
10
|
-
export const keyAdapter = (centerID, rangeID) => {
|
|
11
|
-
return `${centerID}-${rangeID}`;
|
|
12
|
-
};
|
|
13
|
-
export const allCircleKeysAdapter = (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
|
-
};
|
|
20
10
|
export const rangeRingToCircleInputAdapter = (rangeRing) => {
|
|
21
|
-
const centerID = rangeRing.centerID;
|
|
22
11
|
return rangeRing.rings.map(ring => ({
|
|
23
|
-
key:
|
|
12
|
+
key: ring.rindID,
|
|
24
13
|
center: [rangeRing.long, rangeRing.lat],
|
|
25
14
|
radius: ring.radius,
|
|
26
15
|
color: rangeRing.rgba,
|
|
27
16
|
altitude: rangeRing.altitude,
|
|
28
17
|
}));
|
|
29
18
|
};
|
|
30
|
-
|
|
31
|
-
|
|
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 function createColorRatios(color, stepAngle, colorFade = 0.4) {
|
|
60
|
-
const angleCount = Math.ceil(360 / stepAngle) * 2;
|
|
61
|
-
let angleLeft = 360;
|
|
62
|
-
const result = new Array(angleCount);
|
|
63
|
-
for (let i = 0; i < angleCount; i++) {
|
|
64
|
-
const currentAngle = Math.min(stepAngle, angleLeft);
|
|
65
|
-
angleLeft -= currentAngle;
|
|
66
|
-
result[i * 2] = {
|
|
67
|
-
color: [0, 0, 0, 0],
|
|
68
|
-
ratio: 1,
|
|
69
|
-
};
|
|
70
|
-
const colorRatio = {
|
|
71
|
-
// color: i % 2 === 0 ? color : [color[0] * colorFade, color[1] * colorFade, color[2] * colorFade, color[3]] as Color,
|
|
72
|
-
color: i % 2 === 0 ? color : [1 - color[0] * colorFade, 1 - color[1] * colorFade, 1 - color[2] * colorFade, color[3]],
|
|
73
|
-
ratio: currentAngle - 1
|
|
74
|
-
};
|
|
75
|
-
result[i * 2 + 1] = colorRatio;
|
|
76
|
-
}
|
|
77
|
-
return result;
|
|
19
|
+
function rangeRingToPaddingsCoordinatesAdapter(globe, center, rangeRing, startAngle, stepAngle) {
|
|
20
|
+
return new Float32Array();
|
|
78
21
|
}
|
|
79
|
-
export const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
for (let i = 0; i < rings.length; i++) {
|
|
83
|
-
const ring = rings[i];
|
|
84
|
-
result[i] = {
|
|
85
|
-
key: keyAdapter(bearingLine.centerID, ring.ringID),
|
|
86
|
-
center: [long, lat],
|
|
87
|
-
radius: ring.radius,
|
|
88
|
-
colorsRatios: createColorRatios(rgba, stepAngle, 0.5),
|
|
89
|
-
heightFromGroundIn3D: altitude,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return result;
|
|
22
|
+
export const rangeRingToArcInputAdapter = (globe, rangeRing) => {
|
|
23
|
+
// TODO;
|
|
24
|
+
return [];
|
|
93
25
|
};
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import { CircleOnTerrainPlugin } from "../../semiplugins/shape-on-terrain/circle-plugin";
|
|
2
2
|
import { ArcOnTerrainPlugin } from "../../semiplugins/shape-on-terrain/arc-plugin";
|
|
3
|
-
import {
|
|
4
|
-
import { padding1DegreeInputAdapter, rangeRingToArcInputAdapter, rangeRingToCircleInputAdapter, allCircleKeysAdapter, allArcKeysAdapter, createColorRatios } from "./adapters";
|
|
5
|
-
export var ENUM_HIDE;
|
|
6
|
-
(function (ENUM_HIDE) {
|
|
7
|
-
ENUM_HIDE[ENUM_HIDE["SHOW"] = 0] = "SHOW";
|
|
8
|
-
ENUM_HIDE[ENUM_HIDE["HIDE"] = 1] = "HIDE";
|
|
9
|
-
ENUM_HIDE[ENUM_HIDE["HIDE_1_DEGREE_PADDINGS"] = 2] = "HIDE_1_DEGREE_PADDINGS";
|
|
10
|
-
})(ENUM_HIDE || (ENUM_HIDE = {}));
|
|
11
|
-
export var ENUM_TEXT_HIDE;
|
|
12
|
-
(function (ENUM_TEXT_HIDE) {
|
|
13
|
-
ENUM_TEXT_HIDE[ENUM_TEXT_HIDE["SHOW"] = 0] = "SHOW";
|
|
14
|
-
ENUM_TEXT_HIDE[ENUM_TEXT_HIDE["HIDE"] = 1] = "HIDE";
|
|
15
|
-
})(ENUM_TEXT_HIDE || (ENUM_TEXT_HIDE = {}));
|
|
3
|
+
import { LinePlugin } from "../../semiplugins/lightweight/line-plugin";
|
|
16
4
|
// @ts-ignore
|
|
17
5
|
export class RangeRingPlugin {
|
|
18
6
|
id;
|
|
@@ -20,227 +8,24 @@ export class RangeRingPlugin {
|
|
|
20
8
|
gl = null;
|
|
21
9
|
circlePlugin;
|
|
22
10
|
arcPlugin;
|
|
23
|
-
|
|
11
|
+
linePlugin;
|
|
24
12
|
_memory = new Map();
|
|
25
|
-
|
|
26
|
-
textWritersMap = new Map();
|
|
27
|
-
_semiPluginOptions = {
|
|
28
|
-
circleOnTerrainOptions: {
|
|
29
|
-
variativeColorsOn: false,
|
|
30
|
-
defaultColor: [1, 1, 1, 1],
|
|
31
|
-
defaultHeightFromGroundIn3D: 30,
|
|
32
|
-
},
|
|
33
|
-
arcOnTerrainOptions: {
|
|
34
|
-
flatViewOn: true,
|
|
35
|
-
globeViewOn: true,
|
|
36
|
-
variativeColorsOn: false,
|
|
37
|
-
defaultColor: [1, 1, 1, 1],
|
|
38
|
-
defaultHeightFromGroundIn3D: 0,
|
|
39
|
-
vertexCount: 32,
|
|
40
|
-
cameraAttractionIsOn: true // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
41
|
-
},
|
|
42
|
-
paddingOptions: {
|
|
43
|
-
variativeColorsOn: false,
|
|
44
|
-
defaultColor: [1, 1, 1, 1],
|
|
45
|
-
defaultHeightFromGroundIn3D: 0,
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
constructor(id, { textDataPreAdaptor = (center) => center, textWritersMap = new Map(), }) {
|
|
13
|
+
constructor(id) {
|
|
49
14
|
this.id = id;
|
|
50
|
-
this.circlePlugin = new CircleOnTerrainPlugin(this.id + "-circle"
|
|
51
|
-
variativeColorsOn: true,
|
|
52
|
-
});
|
|
15
|
+
this.circlePlugin = new CircleOnTerrainPlugin(this.id + "-circle");
|
|
53
16
|
this.arcPlugin = new ArcOnTerrainPlugin(this.id + "-arc", {
|
|
54
|
-
|
|
55
|
-
vertexCount: 20,
|
|
56
|
-
});
|
|
57
|
-
this.paddingPlugin = new Padding1DegreePlugin(this.id + "-padding", {
|
|
58
|
-
variativeColorsOn: true,
|
|
59
|
-
defaultColor: [1, 1, 1, 1],
|
|
60
|
-
defaultHeightFromGroundIn3D: 0,
|
|
17
|
+
vertexCount: 5,
|
|
61
18
|
});
|
|
62
|
-
|
|
63
|
-
this.textWritersMap = textWritersMap;
|
|
64
|
-
}
|
|
19
|
+
this.linePlugin = new LinePlugin(this.id + "-line");
|
|
65
20
|
}
|
|
66
21
|
insertBulk(items) {
|
|
67
|
-
if (this._freed) {
|
|
68
|
-
console.warn("Plugin is freed, cannot insert items");
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (this.globe === null || this.gl === null) {
|
|
72
|
-
console.warn("Globe or WebGL context is not initialized, cannot insert items");
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const visableItems = items.filter(item => item.hide !== ENUM_HIDE.HIDE);
|
|
76
|
-
if (this.paddingPlugin) {
|
|
77
|
-
const paddingInputs = visableItems.map(item => padding1DegreeInputAdapter(item)).flat();
|
|
78
|
-
this.paddingPlugin.insertBulk(paddingInputs);
|
|
79
|
-
}
|
|
80
|
-
const circleInputs = visableItems.filter(item => item.hide === ENUM_HIDE.SHOW).map(rangeRingToCircleInputAdapter).flat();
|
|
81
|
-
this.circlePlugin.insertBulk(circleInputs);
|
|
82
|
-
const arcInputs = visableItems.map((item) => rangeRingToArcInputAdapter(this.globe, item)).flat();
|
|
83
|
-
this.arcPlugin.insertBulk(arcInputs);
|
|
84
|
-
for (const item of items) {
|
|
85
|
-
this._memory.set(item.centerID, item);
|
|
86
|
-
if (item.hide !== ENUM_HIDE.HIDE && item.textHide === ENUM_HIDE.SHOW) {
|
|
87
|
-
this.updateText([item.centerID]);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
removeCenters(centers) {
|
|
92
|
-
if (this._freed) {
|
|
93
|
-
console.warn("Plugin is freed, cannot remove centers");
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (this.globe === null || this.gl === null) {
|
|
97
|
-
console.warn("Globe or WebGL context is not initialized, cannot remove centers");
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
for (let i = 0; i < centers.length; i++) {
|
|
101
|
-
const rangeRingInput = this._memory.get(centers[i]);
|
|
102
|
-
if (!rangeRingInput) {
|
|
103
|
-
console.warn(`No data found for centerID: ${centers[i]}`);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
const circleKeys = allCircleKeysAdapter(rangeRingInput);
|
|
107
|
-
this.circlePlugin.deleteBulk(circleKeys);
|
|
108
|
-
this.paddingPlugin?.deleteBulk(circleKeys);
|
|
109
|
-
const allArcKeys = allArcKeysAdapter(rangeRingInput);
|
|
110
|
-
this.arcPlugin.deleteBulk(allArcKeys);
|
|
111
|
-
this._memory.delete(centers[i]);
|
|
112
|
-
}
|
|
113
|
-
this.globe.DrawRender();
|
|
114
|
-
}
|
|
115
|
-
updateCenters() {
|
|
116
|
-
}
|
|
117
|
-
updateCentersCoordinate(items) {
|
|
118
|
-
if (this._freed) {
|
|
119
|
-
console.warn("Plugin is freed, cannot update centers coordinates");
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (this.globe === null || this.gl === null) {
|
|
123
|
-
console.warn("Globe or WebGL context is not initialized, cannot update centers coordinates");
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const globe = this.globe;
|
|
127
|
-
for (const item of items) {
|
|
128
|
-
const { centerID, long, lat } = item;
|
|
129
|
-
const rangeRingInput = this._memory.get(centerID);
|
|
130
|
-
if (rangeRingInput) {
|
|
131
|
-
rangeRingInput.long = long;
|
|
132
|
-
rangeRingInput.lat = lat;
|
|
133
|
-
const arcData = rangeRingToArcInputAdapter(globe, rangeRingInput);
|
|
134
|
-
this.arcPlugin.updateCoordinates(arcData);
|
|
135
|
-
const circleData = rangeRingToCircleInputAdapter(rangeRingInput);
|
|
136
|
-
this.circlePlugin.updateCoordinates(circleData);
|
|
137
|
-
this.paddingPlugin?.updateCoordinates(circleData);
|
|
138
|
-
this.updateText([centerID]);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
22
|
}
|
|
142
|
-
|
|
143
|
-
if (this._freed) {
|
|
144
|
-
console.warn("Plugin is freed, cannot update centers color");
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (this.globe === null || this.gl === null) {
|
|
148
|
-
console.warn("Globe or WebGL context is not initialized, cannot update centers color");
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
// update Colors from memory map
|
|
152
|
-
for (let item of items) {
|
|
153
|
-
const data = this._memory.get(item.centerID);
|
|
154
|
-
if (!data) {
|
|
155
|
-
console.warn(`No data found for centerID: ${item.centerID}`);
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
data.rgba = item.rgba;
|
|
159
|
-
// update arc Colors
|
|
160
|
-
const arcColors = allArcKeysAdapter(data).map(key => ({ key, color: data.rgba }));
|
|
161
|
-
this.arcPlugin.updateColors(arcColors, false);
|
|
162
|
-
const circleColors = allCircleKeysAdapter(data).map(key => ({ key, color: data.rgba }));
|
|
163
|
-
this.circlePlugin.updateColors(circleColors);
|
|
164
|
-
if (this.paddingPlugin) {
|
|
165
|
-
const colorRatios = createColorRatios(data.rgba, data.stepAngle, 0.5);
|
|
166
|
-
for (const { key } of circleColors) {
|
|
167
|
-
this.paddingPlugin?.updateColorRatios(key, colorRatios, false);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
this.updateText([item.centerID]);
|
|
171
|
-
}
|
|
172
|
-
this.globe.DrawRender();
|
|
173
|
-
}
|
|
174
|
-
updateCentersHide() {
|
|
23
|
+
_build() {
|
|
175
24
|
}
|
|
176
25
|
init(globe, gl) {
|
|
177
26
|
this.globe = globe;
|
|
178
27
|
this.gl = gl;
|
|
179
|
-
this.circlePlugin.init(globe, gl);
|
|
180
|
-
this.arcPlugin.init(globe, gl);
|
|
181
|
-
this.paddingPlugin?.init(globe, gl);
|
|
182
28
|
}
|
|
183
29
|
draw3D() {
|
|
184
|
-
if (this._freed) {
|
|
185
|
-
console.warn("RangeRing Plugin is freed, cannot draw");
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
this.arcPlugin.draw3D();
|
|
189
|
-
this.paddingPlugin?.draw3D();
|
|
190
|
-
this.circlePlugin.draw3D();
|
|
191
|
-
for (const [key, writer] of this.textWritersMap) {
|
|
192
|
-
writer.draw();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
free() {
|
|
196
|
-
if (this._freed) {
|
|
197
|
-
console.warn("RangeRing Plugin is already freed");
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
this._freed = true;
|
|
201
|
-
this.circlePlugin.free();
|
|
202
|
-
this.arcPlugin.free();
|
|
203
|
-
this.paddingPlugin?.free();
|
|
204
|
-
}
|
|
205
|
-
updateText(centerIDs = null) {
|
|
206
|
-
if (this._freed) {
|
|
207
|
-
console.warn("Plugin is freed, cannot update text");
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (this.globe === null || this.gl === null) {
|
|
211
|
-
console.warn("Globe or WebGL context is not initialized, cannot update text");
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
const globe = this.globe;
|
|
215
|
-
const textWritersMap = this.textWritersMap;
|
|
216
|
-
let keys = centerIDs ?? this._memory.keys();
|
|
217
|
-
for (const centerID of keys) {
|
|
218
|
-
const rangeRingData = this._memory.get(centerID);
|
|
219
|
-
if (!rangeRingData)
|
|
220
|
-
continue;
|
|
221
|
-
for (const [key, writer] of textWritersMap) {
|
|
222
|
-
writer.insertText(rangeRingData);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
deleteText(centerIDs) {
|
|
227
|
-
if (this._freed) {
|
|
228
|
-
console.warn("Plugin is freed, cannot delete text");
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
if (this.globe === null || this.gl === null) {
|
|
232
|
-
console.warn("Globe or WebGL context is not initialized, cannot delete text");
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
const globe = this.globe;
|
|
236
|
-
const textWritersMap = this.textWritersMap;
|
|
237
|
-
for (const centerID of centerIDs) {
|
|
238
|
-
const rangeRingData = this._memory.get(centerID);
|
|
239
|
-
if (!rangeRingData)
|
|
240
|
-
continue;
|
|
241
|
-
for (const [key, writer] of textWritersMap) {
|
|
242
|
-
writer.deleteText(rangeRingData);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
30
|
}
|
|
246
31
|
}
|