@pirireis/webglobeplugins 0.15.1-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 +76 -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 +65 -47
- package/semiplugins/lightweight/piece-of-pie-plugin.js +50 -25
- package/semiplugins/shape-on-terrain/arc-plugin.js +197 -100
- package/semiplugins/shape-on-terrain/circle-plugin.js +209 -90
- 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/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
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
newItemCount++;
|
|
61
89
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const _arc = arc.create(_start, _end);
|
|
65
|
-
this._arcMap.set(key, [_arc, arcInput]); // height is null for now
|
|
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,44 +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;
|
|
113
|
-
|
|
175
|
+
if (drawRender) {
|
|
176
|
+
this.globe.DrawRender();
|
|
177
|
+
}
|
|
114
178
|
}
|
|
115
|
-
setDefaultColor(color) {
|
|
179
|
+
setDefaultColor(color, drawRender = false) {
|
|
116
180
|
if (!this.globe || !this.gl) {
|
|
117
181
|
console.warn("Globe or WebGL context is not initialized.");
|
|
118
182
|
return;
|
|
119
183
|
}
|
|
120
184
|
this._options.defaultColor = color;
|
|
121
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
|
|
122
202
|
this.globe.DrawRender();
|
|
123
203
|
}
|
|
124
204
|
setCameraAttraction(isOn) {
|
|
@@ -132,11 +212,18 @@ export class ArcOnTerrainPlugin {
|
|
|
132
212
|
init(globe, gl) {
|
|
133
213
|
this.globe = globe;
|
|
134
214
|
this.gl = gl;
|
|
215
|
+
this._frameCounterTrigger = new FrameCounterTrigger(globe, 15, 1000, (globeChanges) => {
|
|
216
|
+
if (this._freed)
|
|
217
|
+
return;
|
|
218
|
+
this.__buildDynamicArcs();
|
|
219
|
+
});
|
|
135
220
|
this.program = LineStripProgramCache.get(globe);
|
|
136
|
-
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
|
|
137
224
|
this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
|
|
138
|
-
this.
|
|
139
|
-
this.
|
|
225
|
+
this._fillbufferManagersMap();
|
|
226
|
+
this.bufferOrchestrator = new BufferOrchestrator();
|
|
140
227
|
this._arcUBOHandler = this.program.createUBO();
|
|
141
228
|
this._arcUBOHandler.update(new Map([
|
|
142
229
|
["u_color", new Float32Array(this._options.defaultColor)],
|
|
@@ -148,39 +235,49 @@ export class ArcOnTerrainPlugin {
|
|
|
148
235
|
console.warn("Globe or WebGL context is not initialized.");
|
|
149
236
|
return;
|
|
150
237
|
}
|
|
238
|
+
const globe = this.globe;
|
|
151
239
|
this._staticDynamicStrategy?.updateState();
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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) {
|
|
155
246
|
console.warn("WebGL context, program, or buffer orchestrator is not initialized.");
|
|
156
247
|
return;
|
|
157
248
|
}
|
|
158
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;
|
|
159
253
|
const drawOptions = {
|
|
160
254
|
drawRange: {
|
|
161
255
|
first: 0,
|
|
162
|
-
count:
|
|
256
|
+
count: bufferOrchestrator.length * (this._options.vertexCount + 1)
|
|
163
257
|
},
|
|
164
258
|
indexes: null
|
|
165
259
|
};
|
|
166
260
|
program.draw(_vao, drawOptions, this._opacity, _arcUBOHandler);
|
|
167
261
|
gl.enable(gl.DEPTH_TEST);
|
|
168
262
|
}
|
|
169
|
-
_buildArcs() {
|
|
263
|
+
_buildArcs(subSetIDs = null) {
|
|
170
264
|
const state = this._staticDynamicStrategy?.getState();
|
|
171
|
-
if (state === StaticDynamicState.
|
|
172
|
-
this.
|
|
265
|
+
if (state === StaticDynamicState.DYNAMIC) {
|
|
266
|
+
this.__buildDynamicArcs(subSetIDs);
|
|
173
267
|
}
|
|
174
|
-
else if (state === StaticDynamicState.
|
|
175
|
-
this.
|
|
268
|
+
else if (subSetIDs || state === StaticDynamicState.TO_STATIC) {
|
|
269
|
+
this.__buildStaticArcs(subSetIDs);
|
|
176
270
|
}
|
|
177
271
|
}
|
|
178
|
-
__buildStaticArcs(
|
|
179
|
-
const { globe, _arcMap, _cameraUniformBlock,
|
|
180
|
-
if (!globe || !_cameraUniformBlock || !
|
|
272
|
+
__buildStaticArcs(subSetIDs = null) {
|
|
273
|
+
const { globe, _arcMap, _cameraUniformBlock, bufferManagersMap, bufferOrchestrator } = this;
|
|
274
|
+
if (!globe || !_cameraUniformBlock || !bufferManagersMap || !bufferOrchestrator) {
|
|
181
275
|
console.warn("Globe or camera uniform block is not initialized.");
|
|
182
276
|
return;
|
|
183
277
|
}
|
|
278
|
+
const bufferKey = [this.globe.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"];
|
|
279
|
+
if (!this.bufferManagersMap?.has(bufferKey[0]))
|
|
280
|
+
return;
|
|
184
281
|
const longLat = [0, 0];
|
|
185
282
|
const _attractionStrength = 0;
|
|
186
283
|
const longLatArr = new Float32Array(2 * this._options.vertexCount);
|
|
@@ -188,60 +285,43 @@ export class ArcOnTerrainPlugin {
|
|
|
188
285
|
key: "staticArcs",
|
|
189
286
|
longLatArr: longLatArr,
|
|
190
287
|
height: null,
|
|
191
|
-
color: this._options.defaultColor
|
|
288
|
+
color: this._options.defaultColor,
|
|
289
|
+
msl: null
|
|
192
290
|
}];
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const generatedPoints = evenlySpacedArcPoints(_0arc.p0, _0arc.normal, _0arc.coverAngle, this._options.vertexCount);
|
|
197
|
-
for (let i = 0; i < generatedPoints.length; i++) {
|
|
198
|
-
const point = generatedPoints[i];
|
|
199
|
-
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
200
|
-
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
201
|
-
}
|
|
202
|
-
data[0].key = key;
|
|
203
|
-
data[0].height = arcInput.height ?? this._options.defaultHeightFromGroundIn3D;
|
|
204
|
-
data[0].color = arcInput.color ?? this._options.defaultColor;
|
|
205
|
-
if (calledFromInsert) {
|
|
206
|
-
this._bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
this._bufferOrchestrator.updateBulk(data, bufferManagerMap, this._coordinaateBufferKeysForUpdate);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
291
|
+
let keys;
|
|
292
|
+
if (subSetIDs === null) {
|
|
293
|
+
keys = _arcMap.keys();
|
|
212
294
|
}
|
|
213
295
|
else {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
225
|
-
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
226
|
-
}
|
|
227
|
-
data[0].key = key;
|
|
228
|
-
data[0].height = arcInput.height ?? this._options.defaultHeightFromGroundIn3D;
|
|
229
|
-
data[0].color = arcInput.color ?? this._options.defaultColor;
|
|
230
|
-
if (calledFromInsert) {
|
|
231
|
-
this._bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
this._bufferOrchestrator.updateBulk(data, bufferManagerMap, this._coordinaateBufferKeysForUpdate);
|
|
235
|
-
}
|
|
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);
|
|
236
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);
|
|
237
312
|
}
|
|
238
313
|
}
|
|
239
|
-
|
|
240
|
-
const { globe, _arcMap, _cameraUniformBlock,
|
|
241
|
-
if (!globe || !_cameraUniformBlock || !
|
|
314
|
+
__buildDynamicArcs(subSetIDs = null) {
|
|
315
|
+
const { globe, _arcMap, _cameraUniformBlock, bufferManagersMap } = this;
|
|
316
|
+
if (!globe || !_cameraUniformBlock || !bufferManagersMap) {
|
|
242
317
|
console.warn("Globe or camera uniform block is not initialized.");
|
|
243
318
|
return;
|
|
244
319
|
}
|
|
320
|
+
const bufferKey = [
|
|
321
|
+
this.globe.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"
|
|
322
|
+
];
|
|
323
|
+
if (!this.bufferManagersMap?.has(bufferKey[0]))
|
|
324
|
+
return;
|
|
245
325
|
const { cameraAttractionIsOn } = this._options;
|
|
246
326
|
const lookAtPosition = _cameraUniformBlock.getLookAtVector();
|
|
247
327
|
const cameraPosition = _cameraUniformBlock.getCameraVector();
|
|
@@ -259,7 +339,15 @@ export class ArcOnTerrainPlugin {
|
|
|
259
339
|
})();
|
|
260
340
|
const result = [];
|
|
261
341
|
const longLat = [0, 0];
|
|
262
|
-
|
|
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);
|
|
263
351
|
arc.copy(_0arc, arcInstance);
|
|
264
352
|
const isOnArc = arc.closestPoint(_attractionPoint, _0arc, cameraPosition);
|
|
265
353
|
if (!isOnArc) {
|
|
@@ -283,13 +371,13 @@ export class ArcOnTerrainPlugin {
|
|
|
283
371
|
key: key,
|
|
284
372
|
longLatArr: longLatArr,
|
|
285
373
|
height: arcInput.height ?? this._options.defaultHeightFromGroundIn3D,
|
|
286
|
-
|
|
374
|
+
msl: arcInput.msl ?? null
|
|
287
375
|
});
|
|
288
376
|
}
|
|
289
|
-
// this.
|
|
290
|
-
this.
|
|
377
|
+
// this.bufferOrchestrator.resetWithCapacity(bufferManagersMap, result.length);
|
|
378
|
+
this.bufferOrchestrator.insertBulk(result, bufferManagersMap, bufferKey);
|
|
291
379
|
}
|
|
292
|
-
|
|
380
|
+
_fillbufferManagersMap() {
|
|
293
381
|
const { gl, globe } = this;
|
|
294
382
|
if (!gl || !globe) {
|
|
295
383
|
console.warn("WebGL context or globe is not initialized.");
|
|
@@ -297,19 +385,19 @@ export class ArcOnTerrainPlugin {
|
|
|
297
385
|
}
|
|
298
386
|
const g2D = globe2Dcoordinates(globe);
|
|
299
387
|
const { flatViewOn, globeViewOn, variativeColorsOn } = this._options;
|
|
300
|
-
this.
|
|
388
|
+
this.bufferManagersMap = new Map();
|
|
301
389
|
if (globeViewOn) {
|
|
302
|
-
this.
|
|
390
|
+
this.bufferManagersMap.set("position3d", {
|
|
303
391
|
bufferManager: new BufferManager(gl, 3 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
304
392
|
adaptor: (item) => {
|
|
305
|
-
const { longLatArr, height = this._options.defaultHeightFromGroundIn3D } = item;
|
|
306
|
-
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 });
|
|
307
395
|
return result;
|
|
308
396
|
}
|
|
309
397
|
});
|
|
310
398
|
}
|
|
311
399
|
if (flatViewOn) {
|
|
312
|
-
this.
|
|
400
|
+
this.bufferManagersMap.set("position2d", {
|
|
313
401
|
bufferManager: new BufferManager(gl, 2 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
314
402
|
adaptor: (item) => {
|
|
315
403
|
const { longLatArr } = item;
|
|
@@ -318,8 +406,8 @@ export class ArcOnTerrainPlugin {
|
|
|
318
406
|
});
|
|
319
407
|
}
|
|
320
408
|
if (this._options.variativeColorsOn) {
|
|
321
|
-
const _colorArray = new Float32Array(4 * (this._options.vertexCount + 1));
|
|
322
|
-
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", {
|
|
323
411
|
bufferManager: new BufferManager(gl, 4 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
324
412
|
adaptor: (item) => {
|
|
325
413
|
// Calculate color based on radius
|
|
@@ -344,7 +432,7 @@ export class ArcOnTerrainPlugin {
|
|
|
344
432
|
return null;
|
|
345
433
|
this._coordinaateBufferKeysForUpdate.push(key);
|
|
346
434
|
// @ts-ignore
|
|
347
|
-
const bufferManager = this.
|
|
435
|
+
const bufferManager = this.bufferManagersMap.get(key).bufferManager;
|
|
348
436
|
// @ts-ignore
|
|
349
437
|
return createBufferAndReadInfo(bufferManager.buffer);
|
|
350
438
|
});
|
|
@@ -354,6 +442,15 @@ export class ArcOnTerrainPlugin {
|
|
|
354
442
|
bufferObjects[2] // color
|
|
355
443
|
);
|
|
356
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
|
+
}
|
|
357
454
|
free() {
|
|
358
455
|
if (this._freed) {
|
|
359
456
|
console.warn("Plugin already freed");
|
|
@@ -364,7 +461,7 @@ export class ArcOnTerrainPlugin {
|
|
|
364
461
|
return;
|
|
365
462
|
}
|
|
366
463
|
this._arcUBOHandler?.free();
|
|
367
|
-
this.
|
|
464
|
+
this.bufferManagersMap?.forEach((manager) => {
|
|
368
465
|
manager.bufferManager.free();
|
|
369
466
|
});
|
|
370
467
|
CameraUniformBlockTotemCache.release(this.globe);
|