@pirireis/webglobeplugins 0.15.0-alpha → 0.15.2-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.js +1 -2
- package/Math/circle-cdf-points.js +1 -170
- package/Math/circle.js +0 -25
- package/Math/methods.js +2 -2
- package/Math/vec3.js +6 -2
- package/altitude-locator/plugin.js +1 -1
- package/bearing-line/plugin.js +3 -2
- package/package.json +1 -1
- package/point-tracks/plugin.js +82 -22
- package/programs/line-on-globe/lines-color-instanced-flat.js +0 -1
- package/programs/line-on-globe/linestrip/linestrip.js +2 -30
- package/programs/point-on-globe/element-globe-surface-glow.js +0 -1
- package/programs/rings/partial-ring/piece-of-pie.js +55 -89
- package/programs/totems/camerauniformblock.js +7 -0
- package/programs/totems/canvas-webglobe-info.js +9 -9
- package/programs/totems/globe-changes.js +59 -0
- package/range-tools-on-terrain/bearing-line/adapters.js +8 -5
- package/range-tools-on-terrain/bearing-line/plugin.js +115 -18
- package/range-tools-on-terrain/circle-line-chain/adapters.js +15 -8
- package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +35 -13
- package/range-tools-on-terrain/circle-line-chain/plugin.js +94 -16
- package/range-tools-on-terrain/range-ring/adapters.js +74 -6
- package/range-tools-on-terrain/range-ring/plugin.js +222 -7
- package/range-tools-on-terrain/range-ring/types.js +9 -1
- package/semiplugins/interface.js +1 -0
- package/semiplugins/lightweight/line-plugin.js +72 -45
- package/semiplugins/lightweight/piece-of-pie-plugin.js +50 -25
- package/semiplugins/shape-on-terrain/arc-plugin.js +204 -98
- package/semiplugins/shape-on-terrain/circle-plugin.js +215 -88
- package/semiplugins/shape-on-terrain/padding-1-degree.js +538 -0
- package/util/account/single-attribute-buffer-management/buffer-manager.js +10 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +145 -8
- package/util/account/single-attribute-buffer-management/buffer-orchestrator1.js +159 -0
- package/util/account/single-attribute-buffer-management/object-store.js +7 -0
- package/util/build-strategy/static-dynamic.js +11 -1
- package/util/check/typecheck.js +12 -0
- package/util/frame-counter-trigger.js +84 -0
- package/util/geometry/index.js +2 -1
- package/util/webglobjectbuilders.js +2 -2
- package/write-text/context-text4.js +140 -0
- package/Math/arc-generate-points copy.js +0 -366
- package/Math/globe-util/horizon-plane.js +0 -112
- package/altitude-locator/draw-subset-obj.js +0 -16
- package/programs/line-on-globe/paddings/paddings.js +0 -1
- package/programs/rings/partial-ring/piece-of-pie copy.js +0 -286
- package/semiplugins/shape-on-terrain/derived/padding-plugin.js +0 -101
- package/semiplugins/shape-on-terrain/one-degree-padding.js +0 -85
|
@@ -7,6 +7,7 @@ import { globe3Dcoordinates, globe2Dcoordinates, RADIANS } from "../../Math/meth
|
|
|
7
7
|
import { generateArcPoints, evenlySpacedArcPoints } from "../../Math/arc-cdf-points";
|
|
8
8
|
import { StaticDynamicState, StaticDynamicStrategy } from "../../util/build-strategy/static-dynamic";
|
|
9
9
|
import { opacityCheck } from "../../util/check/typecheck";
|
|
10
|
+
import { FrameCounterTrigger } from "../../util/frame-counter-trigger";
|
|
10
11
|
import * as vec3 from "../../Math/vec3";
|
|
11
12
|
import * as arc from "../../Math/arc";
|
|
12
13
|
import { CameraUniformBlockTotemCache } from "../../programs/totems/camerauniformblock";
|
|
@@ -17,11 +18,16 @@ const _attractionPoint = [0, 0, 0];
|
|
|
17
18
|
const _start = [0, 0, 0];
|
|
18
19
|
const _end = [0, 0, 0];
|
|
19
20
|
const _0arc = arc.create([1, 0, 0], [0, 1, 0]); // zero arc for intersection tests
|
|
21
|
+
function createArc(start, end) {
|
|
22
|
+
vec3.fromLongLatToUnitVector(_start, [start[0] * RADIANS, start[1] * RADIANS]);
|
|
23
|
+
vec3.fromLongLatToUnitVector(_end, [end[0] * RADIANS, end[1] * RADIANS]);
|
|
24
|
+
return arc.create(_start, _end);
|
|
25
|
+
}
|
|
20
26
|
export class ArcOnTerrainPlugin {
|
|
21
27
|
id;
|
|
22
28
|
program = null;
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
bufferManagersMap = null;
|
|
30
|
+
bufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
|
|
25
31
|
_opacity = 1;
|
|
26
32
|
_arcUBOHandler = null;
|
|
27
33
|
_vao = null;
|
|
@@ -33,13 +39,14 @@ export class ArcOnTerrainPlugin {
|
|
|
33
39
|
_options;
|
|
34
40
|
_coordinaateBufferKeysForUpdate = [];
|
|
35
41
|
_freed = false;
|
|
42
|
+
_frameCounterTrigger = null;
|
|
36
43
|
constructor(id, { globeViewOn = true, // If true, arcs are drawn in 3D globe view
|
|
37
44
|
flatViewOn = true, // If true, arcs are drawn in 2D flat view
|
|
38
45
|
variativeColorsOn = false, defaultColor = [0.1, 0.1, 1, 1], // Default color in RGBA format
|
|
39
46
|
defaultHeightFromGroundIn3D = 30.0, // Default height from ground in
|
|
40
47
|
vertexCount = 70, // Number of vertices per arc
|
|
41
|
-
cameraAttractionIsOn = true // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
42
|
-
|
|
48
|
+
cameraAttractionIsOn = true, // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
49
|
+
bufferType = "STREAM_DRAW", isMSL = false } = {}) {
|
|
43
50
|
this.id = id;
|
|
44
51
|
this._arcMap = new Map();
|
|
45
52
|
this._options = {
|
|
@@ -49,27 +56,74 @@ export class ArcOnTerrainPlugin {
|
|
|
49
56
|
defaultColor: defaultColor ? defaultColor : [0.1, 0.1, 1, 1],
|
|
50
57
|
defaultHeightFromGroundIn3D: defaultHeightFromGroundIn3D ? defaultHeightFromGroundIn3D : 30.0,
|
|
51
58
|
vertexCount: vertexCount ? vertexCount : 70,
|
|
52
|
-
cameraAttractionIsOn: cameraAttractionIsOn ? true : false
|
|
59
|
+
cameraAttractionIsOn: cameraAttractionIsOn ? true : false,
|
|
60
|
+
bufferType: bufferType ? bufferType : "STREAM_DRAW",
|
|
61
|
+
isMSL: isMSL ? true : false
|
|
53
62
|
};
|
|
54
63
|
}
|
|
64
|
+
increaseSpace(amount) {
|
|
65
|
+
if (this._freed) {
|
|
66
|
+
console.warn("Plugin is freed, cannot increase space");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (this.globe === null) {
|
|
70
|
+
console.warn("Globe is not initialized.");
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (typeof amount !== "number" || amount <= 0) {
|
|
74
|
+
console.warn("Invalid amount, must be a positive number");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.bufferOrchestrator.ensureSpace(amount, this.bufferManagersMap);
|
|
78
|
+
}
|
|
55
79
|
insertBulk(arcs) {
|
|
56
80
|
const keys = [];
|
|
81
|
+
let newItemCount = 0;
|
|
57
82
|
for (let arcInput of arcs) {
|
|
58
83
|
const { key, start, end } = arcInput;
|
|
59
84
|
if (this._arcMap.has(key)) {
|
|
60
|
-
this._arcMap.delete(key);
|
|
85
|
+
this._arcMap.delete(key); // Remove old arc
|
|
61
86
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
87
|
+
else {
|
|
88
|
+
newItemCount++;
|
|
89
|
+
}
|
|
90
|
+
const _arc = createArc(start, end);
|
|
91
|
+
this._arcMap.set(key, [_arc, arcInput]); // Always set new color
|
|
66
92
|
keys.push(key);
|
|
67
93
|
}
|
|
68
|
-
this.
|
|
94
|
+
this.bufferOrchestrator.ensureSpace(newItemCount, this.bufferManagersMap);
|
|
95
|
+
this._buildArcs(keys);
|
|
96
|
+
if (this._options.variativeColorsOn) {
|
|
97
|
+
this.__fillColors(keys);
|
|
98
|
+
}
|
|
99
|
+
this.globe.DrawRender();
|
|
100
|
+
}
|
|
101
|
+
updateCoordinates(items) {
|
|
102
|
+
if (this._freed) {
|
|
103
|
+
console.warn("Plugin is freed, cannot update coordinates");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (this.globe === null || this.gl === null) {
|
|
107
|
+
console.warn("Globe or WebGL context is not initialized, cannot update coordinates");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const updateKeys = [];
|
|
111
|
+
for (const { key, start, end } of items) {
|
|
112
|
+
const arcInput = this._arcMap.get(key);
|
|
113
|
+
if (!arcInput) {
|
|
114
|
+
console.warn(`Arc with key ${key} not found in arcMap.`);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const _arc = createArc(start, end);
|
|
118
|
+
arc.copy(arcInput[0], _arc); // Update the arc in the map
|
|
119
|
+
// Update the arc in the buffer
|
|
120
|
+
updateKeys.push(key);
|
|
121
|
+
}
|
|
122
|
+
this._buildArcs(updateKeys);
|
|
69
123
|
this.globe.DrawRender();
|
|
70
124
|
}
|
|
71
125
|
deleteBulk(keys) {
|
|
72
|
-
if (!this.
|
|
126
|
+
if (!this.bufferOrchestrator || !this.bufferManagersMap || !this.globe) {
|
|
73
127
|
console.warn("Buffer orchestrator or buffer manager map is not initialized.");
|
|
74
128
|
return;
|
|
75
129
|
}
|
|
@@ -81,35 +135,70 @@ export class ArcOnTerrainPlugin {
|
|
|
81
135
|
console.warn(`Arc with key ${key} not found in arcMap.`);
|
|
82
136
|
}
|
|
83
137
|
}
|
|
84
|
-
this.
|
|
138
|
+
this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersMap);
|
|
85
139
|
this.globe.DrawRender();
|
|
86
140
|
}
|
|
87
|
-
|
|
141
|
+
updateColors(keyColorCouples, drawRender = true) {
|
|
142
|
+
if (this._freed) {
|
|
143
|
+
console.warn("Plugin is freed, cannot update color");
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
88
146
|
if (this._options.variativeColorsOn === false) {
|
|
89
147
|
console.warn("Variative colors are not enabled in this plugin. Create another instance with variativeColorsOn: true to use this feature.");
|
|
90
148
|
return;
|
|
91
149
|
}
|
|
92
|
-
const {
|
|
93
|
-
if (!
|
|
150
|
+
const { bufferOrchestrator, bufferManagersMap } = this;
|
|
151
|
+
if (!bufferOrchestrator || !bufferManagersMap) {
|
|
94
152
|
console.warn("Buffer orchestrator or buffer manager map is not initialized.");
|
|
95
153
|
return;
|
|
96
154
|
}
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
155
|
+
for (const { key, color } of keyColorCouples) {
|
|
156
|
+
const arcInput = this._arcMap.get(key);
|
|
157
|
+
if (!arcInput) {
|
|
158
|
+
console.warn(`Arc with key ${key} not found in arcMap.`);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
arcInput[1].color = color; // Update the color in the arc map
|
|
162
|
+
bufferOrchestrator.updateBulk([{ key: key, color: color }], bufferManagersMap, ["color"]);
|
|
163
|
+
}
|
|
164
|
+
if (drawRender) {
|
|
165
|
+
this.globe.DrawRender();
|
|
101
166
|
}
|
|
102
|
-
arcInput[1].color = color; // Update the color in the arc map
|
|
103
|
-
_bufferOrchestrator.updateBulk([{ key: key, color: color }], bufferManagerMap, ["color"]);
|
|
104
|
-
this.globe.DrawRender();
|
|
105
167
|
}
|
|
106
|
-
setPluginOpacity(opacity) {
|
|
168
|
+
setPluginOpacity(opacity, drawRender = false) {
|
|
107
169
|
if (!this.globe || !this.gl) {
|
|
108
170
|
console.warn("Globe or WebGL context is not initialized.");
|
|
109
171
|
return;
|
|
110
172
|
}
|
|
111
173
|
opacityCheck(opacity);
|
|
112
174
|
this._opacity = opacity;
|
|
175
|
+
if (drawRender) {
|
|
176
|
+
this.globe.DrawRender();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
setDefaultColor(color, drawRender = false) {
|
|
180
|
+
if (!this.globe || !this.gl) {
|
|
181
|
+
console.warn("Globe or WebGL context is not initialized.");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
this._options.defaultColor = color;
|
|
185
|
+
this._arcUBOHandler?.updateSingle("u_color", new Float32Array(color));
|
|
186
|
+
if (drawRender) {
|
|
187
|
+
this.globe.DrawRender();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
setElevationMode(mode) {
|
|
191
|
+
switch (mode) {
|
|
192
|
+
case "msl":
|
|
193
|
+
this._options.isMSL = true;
|
|
194
|
+
break;
|
|
195
|
+
case "agl":
|
|
196
|
+
this._options.isMSL = false;
|
|
197
|
+
break;
|
|
198
|
+
default:
|
|
199
|
+
throw new Error(`Unknown elevation mode: ${mode}`);
|
|
200
|
+
}
|
|
201
|
+
this._buildArcs(); // can be async
|
|
113
202
|
this.globe.DrawRender();
|
|
114
203
|
}
|
|
115
204
|
setCameraAttraction(isOn) {
|
|
@@ -123,11 +212,18 @@ export class ArcOnTerrainPlugin {
|
|
|
123
212
|
init(globe, gl) {
|
|
124
213
|
this.globe = globe;
|
|
125
214
|
this.gl = gl;
|
|
215
|
+
this._frameCounterTrigger = new FrameCounterTrigger(globe, 15, 1000, (globeChanges) => {
|
|
216
|
+
if (this._freed)
|
|
217
|
+
return;
|
|
218
|
+
this.__buildDynamicArcs();
|
|
219
|
+
});
|
|
126
220
|
this.program = LineStripProgramCache.get(globe);
|
|
127
|
-
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, DYNAMIC_STRATEGY_START_LOD)
|
|
221
|
+
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, DYNAMIC_STRATEGY_START_LOD, () => {
|
|
222
|
+
this.__buildStaticArcs();
|
|
223
|
+
}); // Initialize static-dynamic strategy with a transition level of 8
|
|
128
224
|
this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
|
|
129
|
-
this.
|
|
130
|
-
this.
|
|
225
|
+
this._fillbufferManagersMap();
|
|
226
|
+
this.bufferOrchestrator = new BufferOrchestrator();
|
|
131
227
|
this._arcUBOHandler = this.program.createUBO();
|
|
132
228
|
this._arcUBOHandler.update(new Map([
|
|
133
229
|
["u_color", new Float32Array(this._options.defaultColor)],
|
|
@@ -139,39 +235,49 @@ export class ArcOnTerrainPlugin {
|
|
|
139
235
|
console.warn("Globe or WebGL context is not initialized.");
|
|
140
236
|
return;
|
|
141
237
|
}
|
|
238
|
+
const globe = this.globe;
|
|
142
239
|
this._staticDynamicStrategy?.updateState();
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
240
|
+
// if (globe.api_IsScreenMoving()) {
|
|
241
|
+
// this._buildArcs(); // can be async
|
|
242
|
+
// }
|
|
243
|
+
this._frameCounterTrigger?.trigger();
|
|
244
|
+
const { gl, program, bufferOrchestrator, _vao, _arcUBOHandler, } = this;
|
|
245
|
+
if (!gl || !program || !bufferOrchestrator || !_vao || !_arcUBOHandler) {
|
|
146
246
|
console.warn("WebGL context, program, or buffer orchestrator is not initialized.");
|
|
147
247
|
return;
|
|
148
248
|
}
|
|
149
249
|
gl.disable(gl.DEPTH_TEST);
|
|
250
|
+
const currentGeometry = globe.api_GetCurrentGeometry();
|
|
251
|
+
if ((currentGeometry === 0 && !this._options.globeViewOn) || (currentGeometry === 1 && !this._options.flatViewOn))
|
|
252
|
+
return;
|
|
150
253
|
const drawOptions = {
|
|
151
254
|
drawRange: {
|
|
152
255
|
first: 0,
|
|
153
|
-
count:
|
|
256
|
+
count: bufferOrchestrator.length * (this._options.vertexCount + 1)
|
|
154
257
|
},
|
|
155
258
|
indexes: null
|
|
156
259
|
};
|
|
157
260
|
program.draw(_vao, drawOptions, this._opacity, _arcUBOHandler);
|
|
158
261
|
gl.enable(gl.DEPTH_TEST);
|
|
159
262
|
}
|
|
160
|
-
_buildArcs() {
|
|
263
|
+
_buildArcs(subSetIDs = null) {
|
|
161
264
|
const state = this._staticDynamicStrategy?.getState();
|
|
162
|
-
if (state === StaticDynamicState.
|
|
163
|
-
this.
|
|
265
|
+
if (state === StaticDynamicState.DYNAMIC) {
|
|
266
|
+
this.__buildDynamicArcs(subSetIDs);
|
|
164
267
|
}
|
|
165
|
-
else if (state === StaticDynamicState.
|
|
166
|
-
this.
|
|
268
|
+
else if (subSetIDs || state === StaticDynamicState.TO_STATIC) {
|
|
269
|
+
this.__buildStaticArcs(subSetIDs);
|
|
167
270
|
}
|
|
168
271
|
}
|
|
169
|
-
__buildStaticArcs(
|
|
170
|
-
const { globe, _arcMap, _cameraUniformBlock,
|
|
171
|
-
if (!globe || !_cameraUniformBlock || !
|
|
272
|
+
__buildStaticArcs(subSetIDs = null) {
|
|
273
|
+
const { globe, _arcMap, _cameraUniformBlock, bufferManagersMap, bufferOrchestrator } = this;
|
|
274
|
+
if (!globe || !_cameraUniformBlock || !bufferManagersMap || !bufferOrchestrator) {
|
|
172
275
|
console.warn("Globe or camera uniform block is not initialized.");
|
|
173
276
|
return;
|
|
174
277
|
}
|
|
278
|
+
const bufferKey = [this.globe.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"];
|
|
279
|
+
if (!this.bufferManagersMap?.has(bufferKey[0]))
|
|
280
|
+
return;
|
|
175
281
|
const longLat = [0, 0];
|
|
176
282
|
const _attractionStrength = 0;
|
|
177
283
|
const longLatArr = new Float32Array(2 * this._options.vertexCount);
|
|
@@ -179,60 +285,43 @@ export class ArcOnTerrainPlugin {
|
|
|
179
285
|
key: "staticArcs",
|
|
180
286
|
longLatArr: longLatArr,
|
|
181
287
|
height: null,
|
|
182
|
-
color: this._options.defaultColor
|
|
288
|
+
color: this._options.defaultColor,
|
|
289
|
+
msl: null
|
|
183
290
|
}];
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const generatedPoints = evenlySpacedArcPoints(_0arc.p0, _0arc.normal, _0arc.coverAngle, this._options.vertexCount);
|
|
188
|
-
for (let i = 0; i < generatedPoints.length; i++) {
|
|
189
|
-
const point = generatedPoints[i];
|
|
190
|
-
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
191
|
-
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
192
|
-
}
|
|
193
|
-
data[0].key = key;
|
|
194
|
-
data[0].height = arcInput.height ?? this._options.defaultHeightFromGroundIn3D;
|
|
195
|
-
data[0].color = arcInput.color ?? this._options.defaultColor;
|
|
196
|
-
if (calledFromInsert) {
|
|
197
|
-
this._bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
this._bufferOrchestrator.updateBulk(data, bufferManagerMap, this._coordinaateBufferKeysForUpdate);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
291
|
+
let keys;
|
|
292
|
+
if (subSetIDs === null) {
|
|
293
|
+
keys = _arcMap.keys();
|
|
203
294
|
}
|
|
204
295
|
else {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
216
|
-
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
217
|
-
}
|
|
218
|
-
data[0].key = key;
|
|
219
|
-
data[0].height = arcInput.height ?? this._options.defaultHeightFromGroundIn3D;
|
|
220
|
-
data[0].color = arcInput.color ?? this._options.defaultColor;
|
|
221
|
-
if (calledFromInsert) {
|
|
222
|
-
this._bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
this._bufferOrchestrator.updateBulk(data, bufferManagerMap, this._coordinaateBufferKeysForUpdate);
|
|
226
|
-
}
|
|
296
|
+
keys = subSetIDs;
|
|
297
|
+
}
|
|
298
|
+
for (const key of keys) {
|
|
299
|
+
const [arcInstance, arcInput] = _arcMap.get(key);
|
|
300
|
+
arc.copy(_0arc, arcInstance);
|
|
301
|
+
const generatedPoints = evenlySpacedArcPoints(_0arc.p0, _0arc.normal, _0arc.coverAngle, this._options.vertexCount);
|
|
302
|
+
for (let i = 0; i < generatedPoints.length; i++) {
|
|
303
|
+
const point = generatedPoints[i];
|
|
304
|
+
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
305
|
+
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
227
306
|
}
|
|
307
|
+
data[0].key = key;
|
|
308
|
+
data[0].height = arcInput.height ?? this._options.defaultHeightFromGroundIn3D;
|
|
309
|
+
data[0].color = arcInput.color ?? this._options.defaultColor;
|
|
310
|
+
data[0].msl = arcInput.msl ?? null;
|
|
311
|
+
this.bufferOrchestrator.insertBulk(data, bufferManagersMap, bufferKey);
|
|
228
312
|
}
|
|
229
313
|
}
|
|
230
|
-
|
|
231
|
-
const { globe, _arcMap, _cameraUniformBlock,
|
|
232
|
-
if (!globe || !_cameraUniformBlock || !
|
|
314
|
+
__buildDynamicArcs(subSetIDs = null) {
|
|
315
|
+
const { globe, _arcMap, _cameraUniformBlock, bufferManagersMap } = this;
|
|
316
|
+
if (!globe || !_cameraUniformBlock || !bufferManagersMap) {
|
|
233
317
|
console.warn("Globe or camera uniform block is not initialized.");
|
|
234
318
|
return;
|
|
235
319
|
}
|
|
320
|
+
const bufferKey = [
|
|
321
|
+
this.globe.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"
|
|
322
|
+
];
|
|
323
|
+
if (!this.bufferManagersMap?.has(bufferKey[0]))
|
|
324
|
+
return;
|
|
236
325
|
const { cameraAttractionIsOn } = this._options;
|
|
237
326
|
const lookAtPosition = _cameraUniformBlock.getLookAtVector();
|
|
238
327
|
const cameraPosition = _cameraUniformBlock.getCameraVector();
|
|
@@ -250,7 +339,15 @@ export class ArcOnTerrainPlugin {
|
|
|
250
339
|
})();
|
|
251
340
|
const result = [];
|
|
252
341
|
const longLat = [0, 0];
|
|
253
|
-
|
|
342
|
+
let keys;
|
|
343
|
+
if (subSetIDs === null) {
|
|
344
|
+
keys = _arcMap.keys();
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
keys = subSetIDs;
|
|
348
|
+
}
|
|
349
|
+
for (const key of keys) {
|
|
350
|
+
const [arcInstance, arcInput] = _arcMap.get(key);
|
|
254
351
|
arc.copy(_0arc, arcInstance);
|
|
255
352
|
const isOnArc = arc.closestPoint(_attractionPoint, _0arc, cameraPosition);
|
|
256
353
|
if (!isOnArc) {
|
|
@@ -274,13 +371,13 @@ export class ArcOnTerrainPlugin {
|
|
|
274
371
|
key: key,
|
|
275
372
|
longLatArr: longLatArr,
|
|
276
373
|
height: arcInput.height ?? this._options.defaultHeightFromGroundIn3D,
|
|
277
|
-
|
|
374
|
+
msl: arcInput.msl ?? null
|
|
278
375
|
});
|
|
279
376
|
}
|
|
280
|
-
// this.
|
|
281
|
-
this.
|
|
377
|
+
// this.bufferOrchestrator.resetWithCapacity(bufferManagersMap, result.length);
|
|
378
|
+
this.bufferOrchestrator.insertBulk(result, bufferManagersMap, bufferKey);
|
|
282
379
|
}
|
|
283
|
-
|
|
380
|
+
_fillbufferManagersMap() {
|
|
284
381
|
const { gl, globe } = this;
|
|
285
382
|
if (!gl || !globe) {
|
|
286
383
|
console.warn("WebGL context or globe is not initialized.");
|
|
@@ -288,19 +385,19 @@ export class ArcOnTerrainPlugin {
|
|
|
288
385
|
}
|
|
289
386
|
const g2D = globe2Dcoordinates(globe);
|
|
290
387
|
const { flatViewOn, globeViewOn, variativeColorsOn } = this._options;
|
|
291
|
-
this.
|
|
388
|
+
this.bufferManagersMap = new Map();
|
|
292
389
|
if (globeViewOn) {
|
|
293
|
-
this.
|
|
390
|
+
this.bufferManagersMap.set("position3d", {
|
|
294
391
|
bufferManager: new BufferManager(gl, 3 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
295
392
|
adaptor: (item) => {
|
|
296
|
-
const { longLatArr, height = this._options.defaultHeightFromGroundIn3D } = item;
|
|
297
|
-
const result = globe3Dcoordinates(globe,
|
|
393
|
+
const { longLatArr, height = this._options.defaultHeightFromGroundIn3D, msl = this._options.isMSL } = item;
|
|
394
|
+
const result = globe3Dcoordinates(globe, longLatArr, height, msl, { paddingCount: 1 });
|
|
298
395
|
return result;
|
|
299
396
|
}
|
|
300
397
|
});
|
|
301
398
|
}
|
|
302
399
|
if (flatViewOn) {
|
|
303
|
-
this.
|
|
400
|
+
this.bufferManagersMap.set("position2d", {
|
|
304
401
|
bufferManager: new BufferManager(gl, 2 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
305
402
|
adaptor: (item) => {
|
|
306
403
|
const { longLatArr } = item;
|
|
@@ -309,8 +406,8 @@ export class ArcOnTerrainPlugin {
|
|
|
309
406
|
});
|
|
310
407
|
}
|
|
311
408
|
if (this._options.variativeColorsOn) {
|
|
312
|
-
const _colorArray = new Float32Array(4 * (this._options.vertexCount + 1));
|
|
313
|
-
this.
|
|
409
|
+
const _colorArray = new Float32Array(4 * (this._options.vertexCount + 1)); // TODO: this could cause data races or unexpected overwrites.
|
|
410
|
+
this.bufferManagersMap.set("color", {
|
|
314
411
|
bufferManager: new BufferManager(gl, 4 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
315
412
|
adaptor: (item) => {
|
|
316
413
|
// Calculate color based on radius
|
|
@@ -335,7 +432,7 @@ export class ArcOnTerrainPlugin {
|
|
|
335
432
|
return null;
|
|
336
433
|
this._coordinaateBufferKeysForUpdate.push(key);
|
|
337
434
|
// @ts-ignore
|
|
338
|
-
const bufferManager = this.
|
|
435
|
+
const bufferManager = this.bufferManagersMap.get(key).bufferManager;
|
|
339
436
|
// @ts-ignore
|
|
340
437
|
return createBufferAndReadInfo(bufferManager.buffer);
|
|
341
438
|
});
|
|
@@ -345,6 +442,15 @@ export class ArcOnTerrainPlugin {
|
|
|
345
442
|
bufferObjects[2] // color
|
|
346
443
|
);
|
|
347
444
|
}
|
|
445
|
+
__fillColors(subSetIDs) {
|
|
446
|
+
if (this._options.variativeColorsOn === false)
|
|
447
|
+
return;
|
|
448
|
+
const data = [null];
|
|
449
|
+
for (const id of subSetIDs) {
|
|
450
|
+
data[0] = this._arcMap.get(id)[1];
|
|
451
|
+
this.bufferOrchestrator.insertBulk(data, this.bufferManagersMap, ["color"]);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
348
454
|
free() {
|
|
349
455
|
if (this._freed) {
|
|
350
456
|
console.warn("Plugin already freed");
|
|
@@ -355,7 +461,7 @@ export class ArcOnTerrainPlugin {
|
|
|
355
461
|
return;
|
|
356
462
|
}
|
|
357
463
|
this._arcUBOHandler?.free();
|
|
358
|
-
this.
|
|
464
|
+
this.bufferManagersMap?.forEach((manager) => {
|
|
359
465
|
manager.bufferManager.free();
|
|
360
466
|
});
|
|
361
467
|
CameraUniformBlockTotemCache.release(this.globe);
|