@pirireis/webglobeplugins 0.15.17-alpha → 0.15.18-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/methods.js +2 -2
- package/package.json +1 -1
- package/point-tracks/plugin.js +18 -13
- package/programs/line-on-globe/linestrip/linestrip.js +0 -1
- package/programs/totems/globe-changes.js +52 -0
- package/range-tools-on-terrain/bearing-line/adapters.js +8 -5
- package/range-tools-on-terrain/bearing-line/plugin.js +6 -4
- package/range-tools-on-terrain/circle-line-chain/adapters.js +2 -0
- package/range-tools-on-terrain/circle-line-chain/plugin.js +15 -4
- package/range-tools-on-terrain/range-ring/adapters.js +59 -7
- package/range-tools-on-terrain/range-ring/plugin.js +23 -3
- package/semiplugins/lightweight/line-plugin.js +8 -4
- package/semiplugins/lightweight/piece-of-pie-plugin.js +4 -2
- package/semiplugins/shape-on-terrain/arc-plugin.js +34 -10
- package/semiplugins/shape-on-terrain/circle-plugin.js +46 -21
- package/semiplugins/shape-on-terrain/padding-1-degree.js +357 -190
- package/util/account/single-attribute-buffer-management/buffer-manager.js +12 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator copy.js +161 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +91 -5
- package/util/account/single-attribute-buffer-management/chunked-buffer-manager.js +75 -0
- package/util/account/single-attribute-buffer-management/chunked-buffer-orchestrator.js +195 -0
- package/util/account/single-attribute-buffer-management/object-store.js +7 -0
- package/util/check/typecheck.js +12 -0
- package/util/geometry/index.js +2 -1
|
@@ -1,190 +1,357 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
//
|
|
190
|
-
|
|
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
|
+
const initialCapacity = 2; // initial capacity for the buffer managers
|
|
20
|
+
// const _float32Array = new Float32Array(360 * 3 * 2).fill(NaN);
|
|
21
|
+
export class Padding1DegreePlugin {
|
|
22
|
+
id;
|
|
23
|
+
globe = null;
|
|
24
|
+
bufferOrchestrator;
|
|
25
|
+
bufferManagersMap;
|
|
26
|
+
lineProgram = null;
|
|
27
|
+
_opacityLODCoef = 1;
|
|
28
|
+
_pluginOpacity = 1; // this is used to set the opacity of the plugin
|
|
29
|
+
_innerPaddingRatio = 0.9; //
|
|
30
|
+
_float32Array = null; // this is used to forward the data to the buffer manager
|
|
31
|
+
_uboHandler = null; // this is used to forward the data to the shader program
|
|
32
|
+
_bufferNames = ["position2d", "position3d"];
|
|
33
|
+
_vao = null; // this is used to store the VAO for the plugin
|
|
34
|
+
_freed = false; // this is used to check if the plugin is freed or not
|
|
35
|
+
_lastCAM_LOD = { camInfo: -1, lod: -1 }; // this is used to store the last zoom and lod values
|
|
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
|
+
constructor(id, options = null) {
|
|
47
|
+
this.id = id;
|
|
48
|
+
this.bufferManagersMap = new Map();
|
|
49
|
+
this.lineProgram = null;
|
|
50
|
+
this._options = options ? { ...this._options, ...options } : this._options;
|
|
51
|
+
this.bufferOrchestrator = new BufferOrchestrator();
|
|
52
|
+
if (this._options.variativeColorsOn) {
|
|
53
|
+
this._bufferNames.push("color");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
insertBulk(inputs) {
|
|
57
|
+
if (this.globe === null) {
|
|
58
|
+
console.warn("Globe is not initialized, cannot insert input");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (this._freed) {
|
|
62
|
+
console.warn("Plugin is freed, cannot insert input");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const wrapper = [null];
|
|
66
|
+
this._float32Array = new Float32Array(360 * 4 * 4); // largest float32Array
|
|
67
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
68
|
+
const coords = preAdapter(this.globe, inputs[i], this._innerPaddingRatio, null);
|
|
69
|
+
const paddingInput = { ...inputs[i], ...coords };
|
|
70
|
+
this._dataMap.set(paddingInput.key, paddingInput);
|
|
71
|
+
wrapper[0] = paddingInput;
|
|
72
|
+
this.bufferOrchestrator.insertBulk(wrapper, this.bufferManagersMap, this._bufferNames);
|
|
73
|
+
}
|
|
74
|
+
this._float32Array = null;
|
|
75
|
+
this.globe?.DrawRender();
|
|
76
|
+
}
|
|
77
|
+
deleteBulk(keys) {
|
|
78
|
+
if (this.globe === null) {
|
|
79
|
+
console.warn("Globe is not initialized, cannot delete data");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (this._freed) {
|
|
83
|
+
console.warn("Plugin is freed, cannot delete data");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersMap);
|
|
87
|
+
this.globe?.DrawRender();
|
|
88
|
+
}
|
|
89
|
+
setPluginOpacity(opacity) {
|
|
90
|
+
if (this._freed) {
|
|
91
|
+
console.warn("Plugin is freed, cannot set opacity");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (this.globe === null) {
|
|
95
|
+
console.warn("Globe is not initialized, cannot set opacity");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
opacityCheck(opacity);
|
|
99
|
+
this._opacityLODCoef = opacity;
|
|
100
|
+
this._uboHandler?.updateSingle("u_opacity", new Float32Array([opacity]));
|
|
101
|
+
this.globe.DrawRender();
|
|
102
|
+
}
|
|
103
|
+
setDefaultColor(color) {
|
|
104
|
+
if (this._freed) {
|
|
105
|
+
console.warn("Plugin is freed, cannot set default color");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (this.globe === null) {
|
|
109
|
+
console.warn("Globe is not initialized, cannot set default color");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
colorCheck(color);
|
|
113
|
+
this._options.defaultColor = color;
|
|
114
|
+
this._uboHandler?.updateSingle("u_color", new Float32Array(color));
|
|
115
|
+
this.globe.DrawRender();
|
|
116
|
+
}
|
|
117
|
+
setElevationMode(mode) {
|
|
118
|
+
switch (mode) {
|
|
119
|
+
case "msl":
|
|
120
|
+
this._options.isMSL = true;
|
|
121
|
+
break;
|
|
122
|
+
case "agl":
|
|
123
|
+
this._options.isMSL = false;
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
throw new Error(`Unknown elevation mode: ${mode}`);
|
|
127
|
+
}
|
|
128
|
+
this._buildPaddings("elevation");
|
|
129
|
+
this.globe?.DrawRender();
|
|
130
|
+
}
|
|
131
|
+
init(globe) {
|
|
132
|
+
this.globe = globe;
|
|
133
|
+
this.lineProgram = LineStripProgramCache.get(globe);
|
|
134
|
+
const bufferManagersMap = new Map([
|
|
135
|
+
["position2d", {
|
|
136
|
+
bufferManager: new BufferManager(globe.gl, 360 * 2 * 3, // plus 1 to cut
|
|
137
|
+
{ bufferType: this._options.bufferType, initialCapacity: initialCapacity }),
|
|
138
|
+
adaptor: (paddingInput) => {
|
|
139
|
+
if (this._float32Array === null) {
|
|
140
|
+
throw new Error("Float32Array is not initialized");
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
this._float32Array.fill(NaN); // reset the float32Array
|
|
144
|
+
}
|
|
145
|
+
for (let i = 0; i < 360; i++) {
|
|
146
|
+
const startCoords = paddingInput.startCoords[i];
|
|
147
|
+
const endCoords = paddingInput.endCoords[i];
|
|
148
|
+
if (startCoords === null || endCoords === null) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
let coords = globe.api_GetMercator2DPoint(startCoords[0], startCoords[1]);
|
|
152
|
+
// fill the second coordinate with 0
|
|
153
|
+
this._float32Array[i * 6] = coords[0];
|
|
154
|
+
this._float32Array[i * 6 + 1] = coords[1];
|
|
155
|
+
let innerCoords = globe.api_GetMercator2DPoint(endCoords[0], endCoords[1]);
|
|
156
|
+
// fill the second coordinate with 0
|
|
157
|
+
this._float32Array[i * 6 + 2] = innerCoords[0];
|
|
158
|
+
this._float32Array[i * 6 + 3] = innerCoords[1];
|
|
159
|
+
}
|
|
160
|
+
return this._float32Array.subarray(0, 360 * 2 * 3);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
[
|
|
165
|
+
"position3d", {
|
|
166
|
+
bufferManager: new BufferManager(globe.gl, 360 * 3 * 3, // plus 1 to cut
|
|
167
|
+
{ bufferType: this._options.bufferType, initialCapacity: initialCapacity }),
|
|
168
|
+
adaptor: (paddingInput) => {
|
|
169
|
+
if (this._float32Array === null) {
|
|
170
|
+
throw new Error("Float32Array is not initialized");
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
this._float32Array.fill(NaN); // reset the float32Array
|
|
174
|
+
}
|
|
175
|
+
const _float32Array = this._float32Array;
|
|
176
|
+
for (let i = 0; i < 360; i++) {
|
|
177
|
+
const startCoords = paddingInput.startCoords[i];
|
|
178
|
+
const endCoords = paddingInput.endCoords[i];
|
|
179
|
+
if (startCoords === null || endCoords === null) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const height = paddingInput.heightFromGroundIn3D ?? this._options.defaultHeightFromGroundIn3D;
|
|
183
|
+
let coords = globe.api_GetCartesian3DPoint(startCoords[0], startCoords[1], height, this._options.isMSL);
|
|
184
|
+
// fill the second coordinate with 0
|
|
185
|
+
_float32Array[i * 9] = coords[0];
|
|
186
|
+
_float32Array[i * 9 + 1] = coords[1];
|
|
187
|
+
_float32Array[i * 9 + 2] = coords[2];
|
|
188
|
+
let innerCoords = globe.api_GetCartesian3DPoint(endCoords[0], endCoords[1], height, this._options.isMSL);
|
|
189
|
+
// fill the second coordinate with 0
|
|
190
|
+
_float32Array[i * 9 + 3] = innerCoords[0];
|
|
191
|
+
_float32Array[i * 9 + 4] = innerCoords[1];
|
|
192
|
+
_float32Array[i * 9 + 5] = innerCoords[2];
|
|
193
|
+
}
|
|
194
|
+
return _float32Array.subarray(0, 360 * 3 * 3);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
],
|
|
198
|
+
]);
|
|
199
|
+
if (this._options.variativeColorsOn) {
|
|
200
|
+
bufferManagersMap.set("color", {
|
|
201
|
+
bufferManager: new BufferManager(globe.gl, 360 * 4 * 3, // 4 for RGBA
|
|
202
|
+
{ bufferType: this._options.bufferType, initialCapacity: initialCapacity }),
|
|
203
|
+
adaptor: (paddingInput) => {
|
|
204
|
+
if (this._float32Array === null) {
|
|
205
|
+
throw new Error("Float32Array is not initialized");
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
this._float32Array.fill(NaN); // reset the float32Array
|
|
209
|
+
}
|
|
210
|
+
if (!paddingInput.colorsRatios) {
|
|
211
|
+
const color = this._options.defaultColor;
|
|
212
|
+
const colorArray = new Float32Array(360 * 4 * 3);
|
|
213
|
+
this._float32Array = colorArray; // store for forwarding
|
|
214
|
+
for (let i = 0; i < 360; i++) {
|
|
215
|
+
this._float32Array[i * 12] = color[0];
|
|
216
|
+
this._float32Array[i * 12 + 1] = color[1];
|
|
217
|
+
this._float32Array[i * 12 + 2] = color[2];
|
|
218
|
+
this._float32Array[i * 12 + 3] = color[3] * this._opacityLODCoef;
|
|
219
|
+
this._float32Array[i * 12 + 4] = color[0];
|
|
220
|
+
this._float32Array[i * 12 + 5] = color[1];
|
|
221
|
+
this._float32Array[i * 12 + 6] = color[2];
|
|
222
|
+
this._float32Array[i * 12 + 7] = 0; //color[3] * this._opacityLODCoef;
|
|
223
|
+
}
|
|
224
|
+
return this._float32Array.subarray(0, 360 * 4 * 3);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
const colorsRatios = paddingInput.colorsRatios;
|
|
228
|
+
let i = 0;
|
|
229
|
+
for (const colorRatio of colorsRatios) {
|
|
230
|
+
const color = colorRatio.color;
|
|
231
|
+
const ratio = colorRatio.ratio;
|
|
232
|
+
for (let j = 0; j < ratio; j++) {
|
|
233
|
+
this._float32Array[i * 12] = color[0];
|
|
234
|
+
this._float32Array[i * 12 + 1] = color[1];
|
|
235
|
+
this._float32Array[i * 12 + 2] = color[2];
|
|
236
|
+
this._float32Array[i * 12 + 3] = color[3] * this._opacityLODCoef;
|
|
237
|
+
this._float32Array[i * 12 + 4] = color[0];
|
|
238
|
+
this._float32Array[i * 12 + 5] = color[1];
|
|
239
|
+
this._float32Array[i * 12 + 6] = color[2];
|
|
240
|
+
this._float32Array[i * 12 + 7] = 0; // color[3] * this._opacityLODCoef;
|
|
241
|
+
i++;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return this._float32Array.subarray(0, 360 * 4 * 3);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
const vaoInput = ["position3d", "position2d", "color"].map((name) => {
|
|
250
|
+
const bufferManager = bufferManagersMap.get(name);
|
|
251
|
+
if (!bufferManager) {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
buffer: bufferManager.bufferManager.buffer,
|
|
256
|
+
stride: 0,
|
|
257
|
+
offset: 0
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
this._vao = this.lineProgram.createVAO(vaoInput[0], vaoInput[1], vaoInput[2]);
|
|
261
|
+
this.bufferManagersMap = bufferManagersMap;
|
|
262
|
+
this.bufferOrchestrator.resetWithCapacity(bufferManagersMap, initialCapacity);
|
|
263
|
+
this._uboHandler = this.lineProgram.createUBO("STATIC_DRAW");
|
|
264
|
+
this._uboHandler.updateSingle("u_color", new Float32Array(this._options.defaultColor));
|
|
265
|
+
}
|
|
266
|
+
draw3D() {
|
|
267
|
+
if (this._freed) {
|
|
268
|
+
console.warn("Plugin is freed, cannot draw");
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (this.globe === null || this.lineProgram === null || this._vao === null) {
|
|
272
|
+
console.warn("Globe or LineProgram or VAO is not initialized, cannot draw");
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const gl = this.globe.gl;
|
|
276
|
+
const drawOptions = {
|
|
277
|
+
drawRange: {
|
|
278
|
+
first: 0,
|
|
279
|
+
count: this.bufferOrchestrator.length * (360 * 3), // plus 1 is for cutting linestrips
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
gl.disable(gl.DEPTH_TEST);
|
|
283
|
+
this.lineProgram.draw(this._vao, drawOptions, this._pluginOpacity, this._uboHandler);
|
|
284
|
+
gl.enable(gl.DEPTH_TEST);
|
|
285
|
+
}
|
|
286
|
+
free() {
|
|
287
|
+
if (this._freed) {
|
|
288
|
+
console.warn("Plugin is already freed");
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (!this.globe || !this.lineProgram) {
|
|
292
|
+
console.warn("Globe or LineProgram is not initialized, cannot free the plugin");
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
this._freed = true;
|
|
296
|
+
LineStripProgramCache.release(this.lineProgram);
|
|
297
|
+
this.lineProgram = null;
|
|
298
|
+
this._uboHandler?.free();
|
|
299
|
+
this._uboHandler = null;
|
|
300
|
+
this.globe.gl.deleteVertexArray(this._vao);
|
|
301
|
+
this.globe = null;
|
|
302
|
+
this._vao = null;
|
|
303
|
+
this.bufferManagersMap.forEach((bufferManager) => {
|
|
304
|
+
bufferManager.bufferManager.free();
|
|
305
|
+
});
|
|
306
|
+
this._float32Array = null;
|
|
307
|
+
}
|
|
308
|
+
__updateLODRelatedParameters() {
|
|
309
|
+
const lod = this.globe?.api_GetCurrentLODWithDecimal();
|
|
310
|
+
this._innerPaddingRatio = 1 - Math.pow(0.7, lod);
|
|
311
|
+
}
|
|
312
|
+
_buildPaddings(level) {
|
|
313
|
+
}
|
|
314
|
+
__onCamOrLodChange() {
|
|
315
|
+
//TODO: implement -> on lod change the _innerPaddingRatio and all positions should be recalculated.
|
|
316
|
+
// calculation
|
|
317
|
+
// if cam change, recalculate 3d positions
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function preAdapter(globe, paddingInput, paddingRatio, startCoords) {
|
|
321
|
+
const endCoords = new Array(360);
|
|
322
|
+
if (startCoords === null) {
|
|
323
|
+
startCoords = new Array(360);
|
|
324
|
+
for (let i = 0; i < 360; i++) {
|
|
325
|
+
const { long, lat } = globe.Math.FindPointByPolar(paddingInput.center[0], // center long
|
|
326
|
+
paddingInput.center[1], // center lat
|
|
327
|
+
paddingInput.outerRadius, // outer radius
|
|
328
|
+
i);
|
|
329
|
+
const { long: endLong, lat: endLat } = globe.Math.FindPointByPolar(paddingInput.center[0], // center long
|
|
330
|
+
paddingInput.center[1], // center lat
|
|
331
|
+
paddingInput.outerRadius * paddingRatio, // inner radius
|
|
332
|
+
i);
|
|
333
|
+
const longDifference = Math.abs(long - endLong);
|
|
334
|
+
const latDifference = Math.abs(lat - endLat);
|
|
335
|
+
if (longDifference > 45) {
|
|
336
|
+
startCoords[i] = null;
|
|
337
|
+
endCoords[i] = null;
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
// Assign the calculated coordinates
|
|
341
|
+
startCoords[i] = [long, lat];
|
|
342
|
+
endCoords[i] = [endLong, endLat];
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
// Handle case when startCoords is provided
|
|
347
|
+
for (let i = 0; i < 360; i++) {
|
|
348
|
+
if (startCoords[i] === null) {
|
|
349
|
+
endCoords[i] = null;
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
const { long: endLong, lat: endLat } = globe.Math.FindPointByPolar(paddingInput.center[0], paddingInput.center[1], paddingInput.outerRadius * paddingRatio, i);
|
|
353
|
+
endCoords[i] = [endLong, endLat];
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return { startCoords, endCoords };
|
|
357
|
+
}
|
|
@@ -60,6 +60,18 @@ export class BufferManager {
|
|
|
60
60
|
}
|
|
61
61
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
62
62
|
}
|
|
63
|
+
insertConsecutiveBulk(items, offset, adapter, Constructor = Float32Array) {
|
|
64
|
+
const { gl, buffer, itemSize } = this;
|
|
65
|
+
const cpuBuffer = new Constructor(itemSize * items.length);
|
|
66
|
+
console.log('cpuBuffer', cpuBuffer);
|
|
67
|
+
console.log(typeof cpuBuffer);
|
|
68
|
+
for (let i = 0; i < items.length; i++) {
|
|
69
|
+
cpuBuffer.set(adapter(items[i]), i * itemSize);
|
|
70
|
+
}
|
|
71
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
72
|
+
gl.bufferSubData(gl.ARRAY_BUFFER, offset * itemSize * 4, cpuBuffer);
|
|
73
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
74
|
+
}
|
|
63
75
|
// TODO: this is broken
|
|
64
76
|
defrag(offsetValues, occupiedCapacity, newCapacity) {
|
|
65
77
|
const { gl, buffer, bufferType, itemSize } = this;
|