@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
|
@@ -7,7 +7,6 @@ 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";
|
|
11
10
|
import * as vec3 from "../../Math/vec3";
|
|
12
11
|
import * as arc from "../../Math/arc";
|
|
13
12
|
import { CameraUniformBlockTotemCache } from "../../programs/totems/camerauniformblock";
|
|
@@ -18,16 +17,11 @@ const _attractionPoint = [0, 0, 0];
|
|
|
18
17
|
const _start = [0, 0, 0];
|
|
19
18
|
const _end = [0, 0, 0];
|
|
20
19
|
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
|
-
}
|
|
26
20
|
export class ArcOnTerrainPlugin {
|
|
27
21
|
id;
|
|
28
22
|
program = null;
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
bufferManagerMap = null;
|
|
24
|
+
_bufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
|
|
31
25
|
_opacity = 1;
|
|
32
26
|
_arcUBOHandler = null;
|
|
33
27
|
_vao = null;
|
|
@@ -39,14 +33,13 @@ export class ArcOnTerrainPlugin {
|
|
|
39
33
|
_options;
|
|
40
34
|
_coordinaateBufferKeysForUpdate = [];
|
|
41
35
|
_freed = false;
|
|
42
|
-
_frameCounterTrigger = null;
|
|
43
36
|
constructor(id, { globeViewOn = true, // If true, arcs are drawn in 3D globe view
|
|
44
37
|
flatViewOn = true, // If true, arcs are drawn in 2D flat view
|
|
45
38
|
variativeColorsOn = false, defaultColor = [0.1, 0.1, 1, 1], // Default color in RGBA format
|
|
46
39
|
defaultHeightFromGroundIn3D = 30.0, // Default height from ground in
|
|
47
40
|
vertexCount = 70, // Number of vertices per arc
|
|
48
|
-
cameraAttractionIsOn = true
|
|
49
|
-
|
|
41
|
+
cameraAttractionIsOn = true // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
42
|
+
} = {}) {
|
|
50
43
|
this.id = id;
|
|
51
44
|
this._arcMap = new Map();
|
|
52
45
|
this._options = {
|
|
@@ -56,74 +49,27 @@ export class ArcOnTerrainPlugin {
|
|
|
56
49
|
defaultColor: defaultColor ? defaultColor : [0.1, 0.1, 1, 1],
|
|
57
50
|
defaultHeightFromGroundIn3D: defaultHeightFromGroundIn3D ? defaultHeightFromGroundIn3D : 30.0,
|
|
58
51
|
vertexCount: vertexCount ? vertexCount : 70,
|
|
59
|
-
cameraAttractionIsOn: cameraAttractionIsOn ? true : false
|
|
60
|
-
bufferType: bufferType ? bufferType : "STREAM_DRAW",
|
|
61
|
-
isMSL: isMSL ? true : false
|
|
52
|
+
cameraAttractionIsOn: cameraAttractionIsOn ? true : false
|
|
62
53
|
};
|
|
63
54
|
}
|
|
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
|
-
}
|
|
79
55
|
insertBulk(arcs) {
|
|
80
56
|
const keys = [];
|
|
81
|
-
let newItemCount = 0;
|
|
82
57
|
for (let arcInput of arcs) {
|
|
83
58
|
const { key, start, end } = arcInput;
|
|
84
59
|
if (this._arcMap.has(key)) {
|
|
85
|
-
this._arcMap.delete(key);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
newItemCount++;
|
|
60
|
+
this._arcMap.delete(key);
|
|
89
61
|
}
|
|
90
|
-
|
|
91
|
-
|
|
62
|
+
vec3.fromLongLatToUnitVector(_start, [start[0] * RADIANS, start[1] * RADIANS]);
|
|
63
|
+
vec3.fromLongLatToUnitVector(_end, [end[0] * RADIANS, end[1] * RADIANS]);
|
|
64
|
+
const _arc = arc.create(_start, _end);
|
|
65
|
+
this._arcMap.set(key, [_arc, arcInput]); // height is null for now
|
|
92
66
|
keys.push(key);
|
|
93
67
|
}
|
|
94
|
-
this.
|
|
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);
|
|
68
|
+
this.__buildStaticArcs(keys, true);
|
|
123
69
|
this.globe.DrawRender();
|
|
124
70
|
}
|
|
125
71
|
deleteBulk(keys) {
|
|
126
|
-
if (!this.
|
|
72
|
+
if (!this._bufferOrchestrator || !this.bufferManagerMap || !this.globe) {
|
|
127
73
|
console.warn("Buffer orchestrator or buffer manager map is not initialized.");
|
|
128
74
|
return;
|
|
129
75
|
}
|
|
@@ -135,70 +81,44 @@ export class ArcOnTerrainPlugin {
|
|
|
135
81
|
console.warn(`Arc with key ${key} not found in arcMap.`);
|
|
136
82
|
}
|
|
137
83
|
}
|
|
138
|
-
this.
|
|
84
|
+
this._bufferOrchestrator.deleteBulk(keys, this.bufferManagerMap);
|
|
139
85
|
this.globe.DrawRender();
|
|
140
86
|
}
|
|
141
|
-
|
|
142
|
-
if (this._freed) {
|
|
143
|
-
console.warn("Plugin is freed, cannot update color");
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
87
|
+
updateColor(key, color) {
|
|
146
88
|
if (this._options.variativeColorsOn === false) {
|
|
147
89
|
console.warn("Variative colors are not enabled in this plugin. Create another instance with variativeColorsOn: true to use this feature.");
|
|
148
90
|
return;
|
|
149
91
|
}
|
|
150
|
-
const {
|
|
151
|
-
if (!
|
|
92
|
+
const { _bufferOrchestrator, bufferManagerMap } = this;
|
|
93
|
+
if (!_bufferOrchestrator || !bufferManagerMap) {
|
|
152
94
|
console.warn("Buffer orchestrator or buffer manager map is not initialized.");
|
|
153
95
|
return;
|
|
154
96
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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();
|
|
97
|
+
const arcInput = this._arcMap.get(key);
|
|
98
|
+
if (!arcInput) {
|
|
99
|
+
console.warn(`Arc with key ${key} not found in arcMap.`);
|
|
100
|
+
return;
|
|
166
101
|
}
|
|
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();
|
|
167
105
|
}
|
|
168
|
-
setPluginOpacity(opacity
|
|
106
|
+
setPluginOpacity(opacity) {
|
|
169
107
|
if (!this.globe || !this.gl) {
|
|
170
108
|
console.warn("Globe or WebGL context is not initialized.");
|
|
171
109
|
return;
|
|
172
110
|
}
|
|
173
111
|
opacityCheck(opacity);
|
|
174
112
|
this._opacity = opacity;
|
|
175
|
-
|
|
176
|
-
this.globe.DrawRender();
|
|
177
|
-
}
|
|
113
|
+
this.globe.DrawRender();
|
|
178
114
|
}
|
|
179
|
-
setDefaultColor(color
|
|
115
|
+
setDefaultColor(color) {
|
|
180
116
|
if (!this.globe || !this.gl) {
|
|
181
117
|
console.warn("Globe or WebGL context is not initialized.");
|
|
182
118
|
return;
|
|
183
119
|
}
|
|
184
120
|
this._options.defaultColor = color;
|
|
185
121
|
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
|
|
202
122
|
this.globe.DrawRender();
|
|
203
123
|
}
|
|
204
124
|
setCameraAttraction(isOn) {
|
|
@@ -212,18 +132,11 @@ export class ArcOnTerrainPlugin {
|
|
|
212
132
|
init(globe, gl) {
|
|
213
133
|
this.globe = globe;
|
|
214
134
|
this.gl = gl;
|
|
215
|
-
this._frameCounterTrigger = new FrameCounterTrigger(globe, 15, 1000, (globeChanges) => {
|
|
216
|
-
if (this._freed)
|
|
217
|
-
return;
|
|
218
|
-
this.__buildDynamicArcs();
|
|
219
|
-
});
|
|
220
135
|
this.program = LineStripProgramCache.get(globe);
|
|
221
|
-
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, DYNAMIC_STRATEGY_START_LOD
|
|
222
|
-
this.__buildStaticArcs();
|
|
223
|
-
}); // Initialize static-dynamic strategy with a transition level of 8
|
|
136
|
+
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, DYNAMIC_STRATEGY_START_LOD); // Initialize static-dynamic strategy with a transition level of 8
|
|
224
137
|
this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
|
|
225
|
-
this.
|
|
226
|
-
this.
|
|
138
|
+
this._fillBufferManagerMap();
|
|
139
|
+
this._bufferOrchestrator = new BufferOrchestrator();
|
|
227
140
|
this._arcUBOHandler = this.program.createUBO();
|
|
228
141
|
this._arcUBOHandler.update(new Map([
|
|
229
142
|
["u_color", new Float32Array(this._options.defaultColor)],
|
|
@@ -235,49 +148,39 @@ export class ArcOnTerrainPlugin {
|
|
|
235
148
|
console.warn("Globe or WebGL context is not initialized.");
|
|
236
149
|
return;
|
|
237
150
|
}
|
|
238
|
-
const globe = this.globe;
|
|
239
151
|
this._staticDynamicStrategy?.updateState();
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
this._frameCounterTrigger?.trigger();
|
|
244
|
-
const { gl, program, bufferOrchestrator, _vao, _arcUBOHandler, } = this;
|
|
245
|
-
if (!gl || !program || !bufferOrchestrator || !_vao || !_arcUBOHandler) {
|
|
152
|
+
this._buildArcs(); // can be async
|
|
153
|
+
const { gl, program, _bufferOrchestrator, _vao, _arcUBOHandler, } = this;
|
|
154
|
+
if (!gl || !program || !_bufferOrchestrator || !_vao || !_arcUBOHandler) {
|
|
246
155
|
console.warn("WebGL context, program, or buffer orchestrator is not initialized.");
|
|
247
156
|
return;
|
|
248
157
|
}
|
|
249
158
|
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;
|
|
253
159
|
const drawOptions = {
|
|
254
160
|
drawRange: {
|
|
255
161
|
first: 0,
|
|
256
|
-
count:
|
|
162
|
+
count: _bufferOrchestrator.length * (this._options.vertexCount + 1)
|
|
257
163
|
},
|
|
258
164
|
indexes: null
|
|
259
165
|
};
|
|
260
166
|
program.draw(_vao, drawOptions, this._opacity, _arcUBOHandler);
|
|
261
167
|
gl.enable(gl.DEPTH_TEST);
|
|
262
168
|
}
|
|
263
|
-
_buildArcs(
|
|
169
|
+
_buildArcs() {
|
|
264
170
|
const state = this._staticDynamicStrategy?.getState();
|
|
265
|
-
if (state === StaticDynamicState.
|
|
266
|
-
this.
|
|
171
|
+
if (state === StaticDynamicState.TO_STATIC) {
|
|
172
|
+
this.__buildStaticArcs();
|
|
267
173
|
}
|
|
268
|
-
else if (
|
|
269
|
-
this.
|
|
174
|
+
else if (state === StaticDynamicState.DYNAMIC) {
|
|
175
|
+
this.__buildArcs();
|
|
270
176
|
}
|
|
271
177
|
}
|
|
272
|
-
__buildStaticArcs(
|
|
273
|
-
const { globe, _arcMap, _cameraUniformBlock,
|
|
274
|
-
if (!globe || !_cameraUniformBlock || !
|
|
178
|
+
__buildStaticArcs(keys = [], calledFromInsert = false) {
|
|
179
|
+
const { globe, _arcMap, _cameraUniformBlock, bufferManagerMap, _bufferOrchestrator } = this;
|
|
180
|
+
if (!globe || !_cameraUniformBlock || !bufferManagerMap || !_bufferOrchestrator) {
|
|
275
181
|
console.warn("Globe or camera uniform block is not initialized.");
|
|
276
182
|
return;
|
|
277
183
|
}
|
|
278
|
-
const bufferKey = [this.globe.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"];
|
|
279
|
-
if (!this.bufferManagersMap?.has(bufferKey[0]))
|
|
280
|
-
return;
|
|
281
184
|
const longLat = [0, 0];
|
|
282
185
|
const _attractionStrength = 0;
|
|
283
186
|
const longLatArr = new Float32Array(2 * this._options.vertexCount);
|
|
@@ -285,43 +188,60 @@ export class ArcOnTerrainPlugin {
|
|
|
285
188
|
key: "staticArcs",
|
|
286
189
|
longLatArr: longLatArr,
|
|
287
190
|
height: null,
|
|
288
|
-
color: this._options.defaultColor
|
|
289
|
-
msl: null
|
|
191
|
+
color: this._options.defaultColor
|
|
290
192
|
}];
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
193
|
+
if (keys.length == 0) {
|
|
194
|
+
for (const [key, [arcInstance, arcInput]] of _arcMap) {
|
|
195
|
+
arc.copy(_0arc, arcInstance);
|
|
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
|
+
}
|
|
294
212
|
}
|
|
295
213
|
else {
|
|
296
|
-
keys
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
214
|
+
for (let key of keys) {
|
|
215
|
+
if (!_arcMap.has(key)) {
|
|
216
|
+
console.warn(`Arc with key ${key} not found in arcMap.`);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
const [arcInstance, arcInput] = _arcMap.get(key);
|
|
220
|
+
arc.copy(_0arc, arcInstance);
|
|
221
|
+
const generatedPoints = evenlySpacedArcPoints(_0arc.p0, _0arc.normal, _0arc.coverAngle, this._options.vertexCount);
|
|
222
|
+
for (let i = 0; i < generatedPoints.length; i++) {
|
|
223
|
+
const point = generatedPoints[i];
|
|
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
|
+
}
|
|
306
236
|
}
|
|
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);
|
|
312
237
|
}
|
|
313
238
|
}
|
|
314
|
-
|
|
315
|
-
const { globe, _arcMap, _cameraUniformBlock,
|
|
316
|
-
if (!globe || !_cameraUniformBlock || !
|
|
239
|
+
__buildArcs() {
|
|
240
|
+
const { globe, _arcMap, _cameraUniformBlock, bufferManagerMap } = this;
|
|
241
|
+
if (!globe || !_cameraUniformBlock || !bufferManagerMap) {
|
|
317
242
|
console.warn("Globe or camera uniform block is not initialized.");
|
|
318
243
|
return;
|
|
319
244
|
}
|
|
320
|
-
const bufferKey = [
|
|
321
|
-
this.globe.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"
|
|
322
|
-
];
|
|
323
|
-
if (!this.bufferManagersMap?.has(bufferKey[0]))
|
|
324
|
-
return;
|
|
325
245
|
const { cameraAttractionIsOn } = this._options;
|
|
326
246
|
const lookAtPosition = _cameraUniformBlock.getLookAtVector();
|
|
327
247
|
const cameraPosition = _cameraUniformBlock.getCameraVector();
|
|
@@ -339,15 +259,7 @@ export class ArcOnTerrainPlugin {
|
|
|
339
259
|
})();
|
|
340
260
|
const result = [];
|
|
341
261
|
const longLat = [0, 0];
|
|
342
|
-
|
|
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);
|
|
262
|
+
for (const [key, [arcInstance, arcInput]] of _arcMap) {
|
|
351
263
|
arc.copy(_0arc, arcInstance);
|
|
352
264
|
const isOnArc = arc.closestPoint(_attractionPoint, _0arc, cameraPosition);
|
|
353
265
|
if (!isOnArc) {
|
|
@@ -371,13 +283,13 @@ export class ArcOnTerrainPlugin {
|
|
|
371
283
|
key: key,
|
|
372
284
|
longLatArr: longLatArr,
|
|
373
285
|
height: arcInput.height ?? this._options.defaultHeightFromGroundIn3D,
|
|
374
|
-
|
|
286
|
+
// color: arcInput.color // Use the color from the arc map
|
|
375
287
|
});
|
|
376
288
|
}
|
|
377
|
-
// this.
|
|
378
|
-
this.
|
|
289
|
+
// this._bufferOrchestrator.resetWithCapacity(bufferManagerMap, result.length);
|
|
290
|
+
this._bufferOrchestrator.insertBulk(result, bufferManagerMap, ["position3d", "position2d"]);
|
|
379
291
|
}
|
|
380
|
-
|
|
292
|
+
_fillBufferManagerMap() {
|
|
381
293
|
const { gl, globe } = this;
|
|
382
294
|
if (!gl || !globe) {
|
|
383
295
|
console.warn("WebGL context or globe is not initialized.");
|
|
@@ -385,19 +297,19 @@ export class ArcOnTerrainPlugin {
|
|
|
385
297
|
}
|
|
386
298
|
const g2D = globe2Dcoordinates(globe);
|
|
387
299
|
const { flatViewOn, globeViewOn, variativeColorsOn } = this._options;
|
|
388
|
-
this.
|
|
300
|
+
this.bufferManagerMap = new Map();
|
|
389
301
|
if (globeViewOn) {
|
|
390
|
-
this.
|
|
302
|
+
this.bufferManagerMap.set("position3d", {
|
|
391
303
|
bufferManager: new BufferManager(gl, 3 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
392
304
|
adaptor: (item) => {
|
|
393
|
-
const { longLatArr, height = this._options.defaultHeightFromGroundIn3D
|
|
394
|
-
const result = globe3Dcoordinates(globe, longLatArr,
|
|
305
|
+
const { longLatArr, height = this._options.defaultHeightFromGroundIn3D } = item;
|
|
306
|
+
const result = globe3Dcoordinates(globe, height)(longLatArr, { paddingCount: 1 });
|
|
395
307
|
return result;
|
|
396
308
|
}
|
|
397
309
|
});
|
|
398
310
|
}
|
|
399
311
|
if (flatViewOn) {
|
|
400
|
-
this.
|
|
312
|
+
this.bufferManagerMap.set("position2d", {
|
|
401
313
|
bufferManager: new BufferManager(gl, 2 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
402
314
|
adaptor: (item) => {
|
|
403
315
|
const { longLatArr } = item;
|
|
@@ -406,8 +318,8 @@ export class ArcOnTerrainPlugin {
|
|
|
406
318
|
});
|
|
407
319
|
}
|
|
408
320
|
if (this._options.variativeColorsOn) {
|
|
409
|
-
const _colorArray = new Float32Array(4 * (this._options.vertexCount + 1));
|
|
410
|
-
this.
|
|
321
|
+
const _colorArray = new Float32Array(4 * (this._options.vertexCount + 1));
|
|
322
|
+
this.bufferManagerMap.set("color", {
|
|
411
323
|
bufferManager: new BufferManager(gl, 4 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
412
324
|
adaptor: (item) => {
|
|
413
325
|
// Calculate color based on radius
|
|
@@ -432,7 +344,7 @@ export class ArcOnTerrainPlugin {
|
|
|
432
344
|
return null;
|
|
433
345
|
this._coordinaateBufferKeysForUpdate.push(key);
|
|
434
346
|
// @ts-ignore
|
|
435
|
-
const bufferManager = this.
|
|
347
|
+
const bufferManager = this.bufferManagerMap.get(key).bufferManager;
|
|
436
348
|
// @ts-ignore
|
|
437
349
|
return createBufferAndReadInfo(bufferManager.buffer);
|
|
438
350
|
});
|
|
@@ -442,15 +354,6 @@ export class ArcOnTerrainPlugin {
|
|
|
442
354
|
bufferObjects[2] // color
|
|
443
355
|
);
|
|
444
356
|
}
|
|
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
|
-
}
|
|
454
357
|
free() {
|
|
455
358
|
if (this._freed) {
|
|
456
359
|
console.warn("Plugin already freed");
|
|
@@ -461,7 +364,7 @@ export class ArcOnTerrainPlugin {
|
|
|
461
364
|
return;
|
|
462
365
|
}
|
|
463
366
|
this._arcUBOHandler?.free();
|
|
464
|
-
this.
|
|
367
|
+
this.bufferManagerMap?.forEach((manager) => {
|
|
465
368
|
manager.bufferManager.free();
|
|
466
369
|
});
|
|
467
370
|
CameraUniformBlockTotemCache.release(this.globe);
|