@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.
Files changed (46) hide show
  1. package/Math/arc.js +1 -2
  2. package/Math/circle-cdf-points.js +1 -170
  3. package/Math/circle.js +0 -25
  4. package/Math/methods.js +2 -2
  5. package/Math/vec3.js +6 -2
  6. package/altitude-locator/plugin.js +1 -1
  7. package/bearing-line/plugin.js +3 -2
  8. package/package.json +1 -1
  9. package/point-tracks/plugin.js +82 -22
  10. package/programs/line-on-globe/lines-color-instanced-flat.js +0 -1
  11. package/programs/line-on-globe/linestrip/linestrip.js +2 -30
  12. package/programs/point-on-globe/element-globe-surface-glow.js +0 -1
  13. package/programs/rings/partial-ring/piece-of-pie.js +55 -89
  14. package/programs/totems/camerauniformblock.js +7 -0
  15. package/programs/totems/canvas-webglobe-info.js +9 -9
  16. package/programs/totems/globe-changes.js +59 -0
  17. package/range-tools-on-terrain/bearing-line/adapters.js +8 -5
  18. package/range-tools-on-terrain/bearing-line/plugin.js +115 -18
  19. package/range-tools-on-terrain/circle-line-chain/adapters.js +15 -8
  20. package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +35 -13
  21. package/range-tools-on-terrain/circle-line-chain/plugin.js +76 -16
  22. package/range-tools-on-terrain/range-ring/adapters.js +74 -6
  23. package/range-tools-on-terrain/range-ring/plugin.js +222 -7
  24. package/range-tools-on-terrain/range-ring/types.js +9 -1
  25. package/semiplugins/interface.js +1 -0
  26. package/semiplugins/lightweight/line-plugin.js +65 -47
  27. package/semiplugins/lightweight/piece-of-pie-plugin.js +50 -25
  28. package/semiplugins/shape-on-terrain/arc-plugin.js +197 -100
  29. package/semiplugins/shape-on-terrain/circle-plugin.js +209 -90
  30. package/semiplugins/shape-on-terrain/padding-1-degree.js +538 -0
  31. package/util/account/single-attribute-buffer-management/buffer-manager.js +10 -0
  32. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +145 -8
  33. package/util/account/single-attribute-buffer-management/buffer-orchestrator1.js +159 -0
  34. package/util/account/single-attribute-buffer-management/object-store.js +7 -0
  35. package/util/build-strategy/static-dynamic.js +11 -1
  36. package/util/check/typecheck.js +12 -0
  37. package/util/frame-counter-trigger.js +84 -0
  38. package/util/geometry/index.js +2 -1
  39. package/write-text/context-text4.js +140 -0
  40. package/Math/arc-generate-points copy.js +0 -366
  41. package/Math/globe-util/horizon-plane.js +0 -112
  42. package/altitude-locator/draw-subset-obj.js +0 -16
  43. package/programs/line-on-globe/paddings/paddings.js +0 -1
  44. package/programs/rings/partial-ring/piece-of-pie copy.js +0 -286
  45. package/semiplugins/shape-on-terrain/derived/padding-plugin.js +0 -101
  46. package/semiplugins/shape-on-terrain/one-degree-padding.js +0 -85
@@ -0,0 +1,538 @@
1
+ // One Degree Padding
2
+ /**
3
+ * 2d coordinates are loaded ones
4
+ * 3d coordinates are calculated on the fly.
5
+ *
6
+ * 2d paddings are fixed size
7
+ * 3d paddings gets shortened as lod increases
8
+ *
9
+ * color buffer is shared and does not change on unless insert or delete
10
+ * changing color can be done by re inserting
11
+ *
12
+ *
13
+ *
14
+ */
15
+ import { BufferManager } from '../../util/account/single-attribute-buffer-management/buffer-manager';
16
+ import { BufferOrchestrator } from '../../util/account/single-attribute-buffer-management/buffer-orchestrator';
17
+ import { LineStripProgramCache } from '../../programs/line-on-globe/linestrip/linestrip';
18
+ import { opacityCheck, colorCheck } from '../../util/check/typecheck';
19
+ import { FrameCounterTrigger } from '../../util/frame-counter-trigger';
20
+ const initialCapacity = 2; // initial capacity for the buffer managers
21
+ // const _float32Array = new Float32Array(360 * 3 * 2).fill(NaN);
22
+ export class Padding1DegreePlugin {
23
+ id;
24
+ globe = null;
25
+ bufferOrchestrator;
26
+ bufferManagerMap;
27
+ lineProgram = null;
28
+ _innerPaddingRatio = 0.95; //
29
+ _float32Array = null; // this is used to forward the data to the buffer manager
30
+ _uboHandler = null; // this is used to forward the data to the shader program
31
+ _bufferNames = ["position2d", "position3d"];
32
+ _vao = null; // this is used to store the VAO for the plugin
33
+ _freed = false; // this is used to check if the plugin is freed or not
34
+ _userOpacity = 1;
35
+ _adaptiveOpacityMultiplier = 1;
36
+ _dataMap = new Map();
37
+ _options = {
38
+ bufferType: "STATIC_DRAW",
39
+ variativeColorsOn: false,
40
+ defaultColor: [1, 1, 1, 1], // white color
41
+ defaultHeightFromGroundIn3D: 0.1, // 10 cm from ground
42
+ adativePaddingSize: true, // if true, the padding size will be adaptive to the LOD
43
+ adaptiveOpacity: true, // if true, the opacity will be adaptive to the LOD
44
+ isMSL: false // if true, no elevation of terrain
45
+ };
46
+ _frameCounterTrigger = null;
47
+ constructor(id, options = null) {
48
+ this.id = id;
49
+ this.bufferManagerMap = new Map();
50
+ this.lineProgram = null;
51
+ this._options = options ? { ...this._options, ...options } : this._options;
52
+ this.bufferOrchestrator = new BufferOrchestrator();
53
+ if (this._options.variativeColorsOn) {
54
+ this._bufferNames.push("color");
55
+ }
56
+ }
57
+ increaseSpace(amount) {
58
+ if (this._freed) {
59
+ console.warn("Plugin is freed, cannot increase space");
60
+ return;
61
+ }
62
+ if (this.globe === null) {
63
+ console.warn("Globe is not initialized.");
64
+ return;
65
+ }
66
+ if (typeof amount !== "number" || amount <= 0) {
67
+ console.warn("Invalid amount, must be a positive number");
68
+ return;
69
+ }
70
+ this.bufferOrchestrator.ensureSpace(amount, this.bufferManagerMap);
71
+ }
72
+ insertBulk(inputs) {
73
+ if (this.globe === null) {
74
+ console.warn("Globe is not initialized, cannot insert input");
75
+ return;
76
+ }
77
+ if (this._freed) {
78
+ console.warn("Plugin is freed, cannot insert input");
79
+ return;
80
+ }
81
+ const wrapper = [null];
82
+ this._float32Array = new Float32Array(360 * 4 * 4); // largest float32Array
83
+ let newItemCount = 0;
84
+ for (let i = 0; i < inputs.length; i++) {
85
+ if (!this._dataMap.has(inputs[i].key)) {
86
+ newItemCount++;
87
+ }
88
+ }
89
+ this.bufferOrchestrator.ensureSpace(newItemCount, this.bufferManagerMap);
90
+ for (let i = 0; i < inputs.length; i++) {
91
+ const coords = preAdapter(this.globe, inputs[i], this._innerPaddingRatio, null);
92
+ const paddingInput = { ...inputs[i], ...coords };
93
+ this._dataMap.set(paddingInput.key, paddingInput);
94
+ wrapper[0] = paddingInput;
95
+ this.bufferOrchestrator.insertBulk(wrapper, this.bufferManagerMap, this._bufferNames);
96
+ }
97
+ this._float32Array = null;
98
+ this.globe?.DrawRender();
99
+ }
100
+ updateColorRatios(key, colorRatios, drawRender = true) {
101
+ if (this._freed) {
102
+ console.warn("Plugin is freed, cannot update color");
103
+ return;
104
+ }
105
+ if (this.globe === null) {
106
+ console.warn("Globe is not initialized, cannot update color");
107
+ return;
108
+ }
109
+ if (!this._options.variativeColorsOn) {
110
+ console.warn("VariativeColors are not enabled");
111
+ return;
112
+ }
113
+ if (!this._dataMap.has(key)) {
114
+ console.warn(`Key ${key} does not exist in the data map`);
115
+ return;
116
+ }
117
+ const paddingInput = this._dataMap.get(key);
118
+ if (!paddingInput) {
119
+ console.warn(`Padding input for key ${key} is not found`);
120
+ return;
121
+ }
122
+ this._float32Array = new Float32Array(360 * 4 * 4); // largest float32Array
123
+ paddingInput.colorsRatios = colorRatios;
124
+ this.bufferOrchestrator.updateBulk([paddingInput], this.bufferManagerMap, ["color"]);
125
+ this._float32Array = null;
126
+ if (drawRender) {
127
+ this.globe.DrawRender();
128
+ }
129
+ }
130
+ updateCoordinates(items) {
131
+ if (this._freed) {
132
+ console.warn("Plugin is freed, cannot update coordinates");
133
+ return;
134
+ }
135
+ if (this.globe === null) {
136
+ console.warn("Globe is not initialized, cannot update coordinates");
137
+ return;
138
+ }
139
+ this._float32Array = new Float32Array(360 * 4 * 4); // largest float32Array
140
+ const updateKeys = [];
141
+ for (const item of items) {
142
+ const paddingInput = this._dataMap.get(item.key);
143
+ if (!paddingInput) {
144
+ console.warn(`Padding input for key ${item.key} is not found`);
145
+ continue;
146
+ }
147
+ paddingInput.center = item.center;
148
+ paddingInput.radius = item.radius;
149
+ updateKeys.push(item.key);
150
+ }
151
+ this._buildPaddings("input", updateKeys);
152
+ this._float32Array = null;
153
+ this.globe.DrawRender();
154
+ }
155
+ deleteBulk(keys) {
156
+ if (this.globe === null) {
157
+ console.warn("Globe is not initialized, cannot delete data");
158
+ return;
159
+ }
160
+ if (this._freed) {
161
+ console.warn("Plugin is freed, cannot delete data");
162
+ return;
163
+ }
164
+ this.bufferOrchestrator.deleteBulk(keys, this.bufferManagerMap);
165
+ this.globe?.DrawRender();
166
+ }
167
+ setPluginOpacity(opacity, drawRender = false) {
168
+ if (this._freed) {
169
+ console.warn("Plugin is freed, cannot set opacity");
170
+ return;
171
+ }
172
+ if (this.globe === null) {
173
+ console.warn("Globe is not initialized, cannot set opacity");
174
+ return;
175
+ }
176
+ opacityCheck(opacity);
177
+ this._userOpacity = opacity;
178
+ if (drawRender) {
179
+ this.globe.DrawRender();
180
+ }
181
+ }
182
+ setDefaultColor(color) {
183
+ if (this._freed) {
184
+ console.warn("Plugin is freed, cannot set default color");
185
+ return;
186
+ }
187
+ if (this.globe === null) {
188
+ console.warn("Globe is not initialized, cannot set default color");
189
+ return;
190
+ }
191
+ colorCheck(color);
192
+ this._options.defaultColor = color;
193
+ this._uboHandler?.updateSingle("u_color", new Float32Array(color));
194
+ this.globe.DrawRender();
195
+ }
196
+ setElevationMode(mode) {
197
+ switch (mode) {
198
+ case "msl":
199
+ this._options.isMSL = true;
200
+ break;
201
+ case "agl":
202
+ this._options.isMSL = false;
203
+ break;
204
+ default:
205
+ throw new Error(`Unknown elevation mode: ${mode}`);
206
+ }
207
+ this._buildPaddings("elevation");
208
+ this.globe?.DrawRender();
209
+ }
210
+ init(globe, gl) {
211
+ this.globe = globe;
212
+ this.lineProgram = LineStripProgramCache.get(globe);
213
+ this._frameCounterTrigger = new FrameCounterTrigger(globe, 10, 1000, (globeChanges) => {
214
+ if (this._freed)
215
+ return;
216
+ this.__build(globeChanges);
217
+ globe.DrawRender();
218
+ });
219
+ this.__updateLODRelatedParameters();
220
+ this.__updateAdaptiveOpacityMultiplier();
221
+ const bufferManagerMap = new Map([
222
+ ["position2d", {
223
+ bufferManager: new BufferManager(globe.gl, 360 * 2 * 3, // plus 1 to cut
224
+ { bufferType: this._options.bufferType, initialCapacity: initialCapacity }),
225
+ adaptor: (paddingInput) => {
226
+ if (this._float32Array === null) {
227
+ throw new Error("Float32Array is not initialized");
228
+ }
229
+ else {
230
+ this._float32Array.fill(NaN); // reset the float32Array
231
+ }
232
+ for (let i = 0; i < 360; i++) {
233
+ const outerCoords = paddingInput.outerCoords[i];
234
+ const innerCoords = paddingInput.innerCoords[i];
235
+ if (outerCoords === null || innerCoords === null) {
236
+ continue;
237
+ }
238
+ let coordsOuter = globe.api_GetMercator2DPoint(outerCoords[0], outerCoords[1]);
239
+ // fill the second coordinate with 0
240
+ this._float32Array[i * 6] = coordsOuter[0];
241
+ this._float32Array[i * 6 + 1] = coordsOuter[1];
242
+ let coordsInner = globe.api_GetMercator2DPoint(innerCoords[0], innerCoords[1]);
243
+ // fill the second coordinate with 0
244
+ this._float32Array[i * 6 + 2] = coordsInner[0];
245
+ this._float32Array[i * 6 + 3] = coordsInner[1];
246
+ }
247
+ return this._float32Array.subarray(0, 360 * 2 * 3);
248
+ }
249
+ }
250
+ ],
251
+ [
252
+ "position3d", {
253
+ bufferManager: new BufferManager(globe.gl, 360 * 3 * 3, // plus 1 to cut
254
+ { bufferType: this._options.bufferType, initialCapacity: initialCapacity }),
255
+ adaptor: (paddingInput) => {
256
+ if (this._float32Array === null) {
257
+ throw new Error("Float32Array is not initialized");
258
+ }
259
+ else {
260
+ this._float32Array.fill(NaN); // reset the float32Array
261
+ }
262
+ const _float32Array = this._float32Array;
263
+ for (let i = 0; i < 360; i++) {
264
+ const outerCoords = paddingInput.outerCoords[i];
265
+ const innerCoords = paddingInput.innerCoords[i];
266
+ if (outerCoords === null || innerCoords === null) {
267
+ continue;
268
+ }
269
+ const height = paddingInput.heightFromGroundIn3D ?? this._options.defaultHeightFromGroundIn3D;
270
+ let coords = globe.api_GetCartesian3DPoint(outerCoords[0], outerCoords[1], height, this._options.isMSL);
271
+ // fill the second coordinate with 0
272
+ _float32Array[i * 9] = coords[0];
273
+ _float32Array[i * 9 + 1] = coords[1];
274
+ _float32Array[i * 9 + 2] = coords[2];
275
+ let coordsInner = globe.api_GetCartesian3DPoint(innerCoords[0], innerCoords[1], height, this._options.isMSL);
276
+ // fill the second coordinate with 0
277
+ _float32Array[i * 9 + 3] = coordsInner[0];
278
+ _float32Array[i * 9 + 4] = coordsInner[1];
279
+ _float32Array[i * 9 + 5] = coordsInner[2];
280
+ }
281
+ return _float32Array.subarray(0, 360 * 3 * 3);
282
+ }
283
+ }
284
+ ],
285
+ ]);
286
+ if (this._options.variativeColorsOn) {
287
+ bufferManagerMap.set("color", {
288
+ bufferManager: new BufferManager(globe.gl, 360 * 4 * 3, // 4 for RGBA
289
+ { bufferType: this._options.bufferType, initialCapacity: initialCapacity }),
290
+ adaptor: (paddingInput) => {
291
+ if (this._float32Array === null) {
292
+ throw new Error("Float32Array is not initialized");
293
+ }
294
+ else {
295
+ this._float32Array.fill(NaN); // reset the float32Array
296
+ }
297
+ if (!paddingInput.colorsRatios) {
298
+ const color = this._options.defaultColor;
299
+ const colorArray = new Float32Array(360 * 4 * 3);
300
+ this._float32Array = colorArray; // store for forwarding
301
+ for (let i = 0; i < 360; i++) {
302
+ this._float32Array[i * 12] = color[0];
303
+ this._float32Array[i * 12 + 1] = color[1];
304
+ this._float32Array[i * 12 + 2] = color[2];
305
+ this._float32Array[i * 12 + 3] = color[3];
306
+ this._float32Array[i * 12 + 4] = color[0];
307
+ this._float32Array[i * 12 + 5] = color[1];
308
+ this._float32Array[i * 12 + 6] = color[2];
309
+ this._float32Array[i * 12 + 7] = 0; //color[3] ;
310
+ }
311
+ return this._float32Array.subarray(0, 360 * 4 * 3);
312
+ }
313
+ else {
314
+ const colorsRatios = paddingInput.colorsRatios;
315
+ let i = 0;
316
+ for (const colorRatio of colorsRatios) {
317
+ const color = colorRatio.color;
318
+ const ratio = colorRatio.ratio;
319
+ for (let j = 0; j < ratio; j++) {
320
+ this._float32Array[i * 12] = color[0];
321
+ this._float32Array[i * 12 + 1] = color[1];
322
+ this._float32Array[i * 12 + 2] = color[2];
323
+ this._float32Array[i * 12 + 3] = color[3];
324
+ this._float32Array[i * 12 + 4] = color[0];
325
+ this._float32Array[i * 12 + 5] = color[1];
326
+ this._float32Array[i * 12 + 6] = color[2];
327
+ this._float32Array[i * 12 + 7] = 0.1; // color[3];
328
+ i++;
329
+ }
330
+ }
331
+ return this._float32Array.subarray(0, 360 * 4 * 3);
332
+ }
333
+ }
334
+ });
335
+ }
336
+ const vaoInput = ["position3d", "position2d", "color"].map((name) => {
337
+ const bufferManager = bufferManagerMap.get(name);
338
+ if (!bufferManager) {
339
+ return null;
340
+ }
341
+ return {
342
+ buffer: bufferManager.bufferManager.buffer,
343
+ stride: 0,
344
+ offset: 0
345
+ };
346
+ });
347
+ this._vao = this.lineProgram.createVAO(vaoInput[0], vaoInput[1], vaoInput[2]);
348
+ this.bufferManagerMap = bufferManagerMap;
349
+ this.bufferOrchestrator.resetWithCapacity(bufferManagerMap, initialCapacity);
350
+ this._uboHandler = this.lineProgram.createUBO("STATIC_DRAW");
351
+ this._uboHandler.updateSingle("u_color", new Float32Array(this._options.defaultColor));
352
+ }
353
+ draw3D() {
354
+ if (this._freed) {
355
+ console.warn("Plugin is freed, cannot draw");
356
+ return;
357
+ }
358
+ if (this.globe === null || this.lineProgram === null || this._vao === null) {
359
+ console.warn("Globe or LineProgram or VAO is not initialized, cannot draw");
360
+ return;
361
+ }
362
+ this._frameCounterTrigger?.trigger();
363
+ // this.__build();
364
+ const gl = this.globe.gl;
365
+ const drawOptions = {
366
+ drawRange: {
367
+ first: 0,
368
+ count: this.bufferOrchestrator.length * (360 * 3), // plus 1 is for cutting linestrips
369
+ },
370
+ };
371
+ gl.disable(gl.DEPTH_TEST);
372
+ this.lineProgram.draw(this._vao, drawOptions, this._userOpacity * this._adaptiveOpacityMultiplier, this._uboHandler);
373
+ gl.enable(gl.DEPTH_TEST);
374
+ }
375
+ free() {
376
+ if (this._freed) {
377
+ console.warn("Plugin is already freed");
378
+ return;
379
+ }
380
+ if (!this.globe || !this.lineProgram) {
381
+ console.warn("Globe or LineProgram is not initialized, cannot free the plugin");
382
+ return;
383
+ }
384
+ this._freed = true;
385
+ this._frameCounterTrigger?.free();
386
+ LineStripProgramCache.release(this.lineProgram);
387
+ this.lineProgram = null;
388
+ this._uboHandler?.free();
389
+ this._uboHandler = null;
390
+ this.globe.gl.deleteVertexArray(this._vao);
391
+ this.globe = null;
392
+ this._vao = null;
393
+ this.bufferManagerMap.forEach((bufferManager) => {
394
+ bufferManager.bufferManager.free();
395
+ });
396
+ this._float32Array = null;
397
+ }
398
+ _buildPaddings(level, subSetIDs = null) {
399
+ if (level === "input") {
400
+ this.__inner(subSetIDs);
401
+ this.__elevation(subSetIDs);
402
+ }
403
+ else if (level === "innerCircle") {
404
+ // Build inner circle paddings
405
+ if (this._options.adativePaddingSize) {
406
+ this.__innerCircle(subSetIDs);
407
+ }
408
+ this.__elevation(subSetIDs);
409
+ }
410
+ else if (level === "elevation") {
411
+ // Build elevation paddings
412
+ this.__elevation(subSetIDs);
413
+ }
414
+ }
415
+ __inner(subSetIDs = null) {
416
+ // Implement inner circle padding logic
417
+ console.log("innerCircle Level Update");
418
+ const datas = this._dataMap;
419
+ let keys;
420
+ if (subSetIDs) {
421
+ keys = subSetIDs;
422
+ }
423
+ else {
424
+ keys = Array.from(datas.keys());
425
+ }
426
+ for (const key of keys) {
427
+ const value = datas.get(key);
428
+ if (!value)
429
+ continue;
430
+ // Implement inner circle padding logic using key and value
431
+ const { innerCoords, outerCoords } = preAdapter(this.globe, value, this._innerPaddingRatio, null);
432
+ value.outerCoords = outerCoords;
433
+ value.innerCoords = innerCoords;
434
+ }
435
+ }
436
+ __innerCircle(subSetIDs = null) {
437
+ // Implement inner circle padding logic
438
+ console.log("innerCircle Level Update");
439
+ const datas = this._dataMap;
440
+ let keys;
441
+ if (subSetIDs) {
442
+ keys = subSetIDs;
443
+ }
444
+ else {
445
+ keys = Array.from(datas.keys());
446
+ }
447
+ for (const key of keys) {
448
+ const value = datas.get(key);
449
+ if (!value)
450
+ continue;
451
+ // Implement inner circle padding logic using key and value
452
+ const { innerCoords } = preAdapter(this.globe, value, this._innerPaddingRatio, value.outerCoords);
453
+ value.innerCoords = innerCoords;
454
+ }
455
+ }
456
+ __elevation(subSetIDs = null) {
457
+ this.__updateAdaptiveOpacityMultiplier();
458
+ const bufferToUpdate = [this.globe?.api_GetCurrentGeometry() === 1 ? "position2d" : "position3d"];
459
+ const datas = this._dataMap;
460
+ const wrapper = [null];
461
+ this._float32Array = new Float32Array(360 * 4 * 4); // largest float32Array
462
+ let keys;
463
+ if (subSetIDs) {
464
+ keys = subSetIDs;
465
+ }
466
+ else {
467
+ keys = Array.from(datas.keys());
468
+ }
469
+ for (const key of keys) {
470
+ const value = datas.get(key);
471
+ if (!value)
472
+ continue;
473
+ wrapper[0] = value;
474
+ this.bufferOrchestrator.updateBulk(wrapper, this.bufferManagerMap, bufferToUpdate);
475
+ }
476
+ this._float32Array = null; // reset the float32Array
477
+ }
478
+ __build(globeChanges) {
479
+ if (globeChanges.lod) {
480
+ this.__updateLODRelatedParameters();
481
+ this._buildPaddings("innerCircle");
482
+ }
483
+ else if (globeChanges.look || globeChanges.geometry) {
484
+ this._buildPaddings("elevation");
485
+ }
486
+ }
487
+ __updateLODRelatedParameters() {
488
+ const lod = this.globe?.api_GetCurrentLODWithDecimal();
489
+ this._innerPaddingRatio = 1 - Math.pow(0.7, lod);
490
+ }
491
+ __updateAdaptiveOpacityMultiplier() {
492
+ if (this._options.adaptiveOpacity === true) {
493
+ const currentLod = this.globe?.api_GetCurrentLODWithDecimal();
494
+ this._adaptiveOpacityMultiplier = Math.max(1 - (2.9 / currentLod), 0.1);
495
+ }
496
+ else {
497
+ this._adaptiveOpacityMultiplier = 1; // TODO: set this once on adaptiveOpacity is Set to false
498
+ }
499
+ }
500
+ }
501
+ function preAdapter(globe, paddingInput, paddingRatio, outerCoords) {
502
+ const innerCoords = new Array(360);
503
+ if (outerCoords === null) {
504
+ outerCoords = new Array(360);
505
+ for (let i = 0; i < 360; i++) {
506
+ const { long, lat } = globe.Math.FindPointByPolar(paddingInput.center[0], // center long
507
+ paddingInput.center[1], // center lat
508
+ paddingInput.radius, // outer radius
509
+ i);
510
+ const { long: endLong, lat: endLat } = globe.Math.FindPointByPolar(paddingInput.center[0], // center long
511
+ paddingInput.center[1], // center lat
512
+ paddingInput.radius * paddingRatio, // inner radius
513
+ i);
514
+ const longDifference = Math.abs(long - endLong);
515
+ const latDifference = Math.abs(lat - endLat);
516
+ if (longDifference > 45) {
517
+ outerCoords[i] = null;
518
+ innerCoords[i] = null;
519
+ continue;
520
+ }
521
+ // Assign the calculated coordinates
522
+ outerCoords[i] = [long, lat];
523
+ innerCoords[i] = [endLong, endLat];
524
+ }
525
+ }
526
+ else {
527
+ // Handle case when outerCoords is provided
528
+ for (let i = 0; i < 360; i++) {
529
+ if (outerCoords[i] === null) {
530
+ innerCoords[i] = null;
531
+ continue;
532
+ }
533
+ const { long: endLong, lat: endLat } = globe.Math.FindPointByPolar(paddingInput.center[0], paddingInput.center[1], paddingInput.radius * paddingRatio, i);
534
+ innerCoords[i] = [endLong, endLat];
535
+ }
536
+ }
537
+ return { outerCoords, innerCoords };
538
+ }
@@ -60,6 +60,16 @@ export class BufferManager {
60
60
  }
61
61
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
62
62
  }
63
+ insertBlock(items, offset, adapter, Constructor = Float32Array) {
64
+ const { gl, buffer, itemSize } = this;
65
+ const cpuBuffer = new Constructor(itemSize * items.length);
66
+ for (let i = 0; i < items.length; i++) {
67
+ cpuBuffer.set(adapter(items[i]), i * itemSize);
68
+ }
69
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
70
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset * itemSize * 4, cpuBuffer);
71
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
72
+ }
63
73
  // TODO: this is broken
64
74
  defrag(offsetValues, occupiedCapacity, newCapacity) {
65
75
  const { gl, buffer, bufferType, itemSize } = this;