@pirireis/webglobeplugins 0.12.0-alpha → 0.14.0-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-cdf-points.js +20 -0
- package/Math/arc-generate-points copy.js +1 -0
- package/Math/arc.js +21 -8
- package/Math/circle-cdf-points.js +0 -2
- package/Math/circle.js +35 -16
- package/Math/templete-shapes/grid-visually-equal.js +66 -0
- package/altitude-locator/plugin.js +3 -2
- package/bearing-line/plugin.js +1 -2
- package/circle-line-chain/plugin.js +4 -7
- package/compass-rose/compass-rose-padding-flat.js +12 -0
- package/package.json +1 -1
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
- package/programs/line-on-globe/linestrip/data.js +4 -0
- package/programs/line-on-globe/{linestrip.js → linestrip/linestrip.js} +37 -35
- package/programs/line-on-globe/naive-accurate-flexible.js +23 -16
- package/programs/picking/pickable-renderer.js +1 -2
- package/programs/rings/distancering/circleflatprogram.js +116 -120
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +1 -1
- package/programs/rings/distancering/circlepaddysharedbuffer.js +368 -354
- package/programs/rings/distancering/index.js +6 -5
- package/programs/rings/distancering/paddyflatprogram.js +127 -136
- package/programs/rings/distancering/paddyflatprogram2d.js +129 -138
- package/programs/rings/distancering/paddyflatprogram3d.js +128 -136
- package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
- package/programs/rings/partial-ring/piece-of-pie.js +26 -13
- package/programs/totems/camerauniformblock.js +1 -1
- package/programs/totems/index.js +1 -1
- package/programs/vectorfields/logics/pixelbased.js +5 -21
- package/range-tools-on-terrain/bearing-line/adapters.js +111 -0
- package/range-tools-on-terrain/bearing-line/plugin.js +360 -0
- package/range-tools-on-terrain/bearing-line/types.js +1 -0
- package/range-tools-on-terrain/circle-line-chain/adapters.js +83 -0
- package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +351 -0
- package/range-tools-on-terrain/circle-line-chain/plugin.js +389 -0
- package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
- package/range-tools-on-terrain/range-ring/adapters.js +25 -0
- package/range-tools-on-terrain/range-ring/plugin.js +31 -0
- package/range-tools-on-terrain/range-ring/types.js +1 -0
- package/rangerings/plugin.js +7 -11
- package/semiplugins/lightweight/line-plugin.js +195 -0
- package/semiplugins/lightweight/piece-of-pie-plugin.js +175 -0
- package/semiplugins/shape-on-terrain/arc-plugin.js +368 -0
- package/{shape-on-terrain/circle/plugin.js → semiplugins/shape-on-terrain/circle-plugin.js} +129 -68
- package/semiplugins/shape-on-terrain/derived/padding-plugin.js +96 -0
- package/semiplugins/type.js +1 -0
- package/types.js +0 -11
- package/util/account/create-buffermap-orchastration.js +39 -0
- package/util/account/index.js +2 -2
- package/util/account/single-attribute-buffer-management/buffer-manager.js +2 -3
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -3
- package/util/build-strategy/static-dynamic.js +1 -1
- package/util/check/typecheck.js +15 -1
- package/util/geometry/index.js +3 -2
- package/util/gl-util/buffer/attribute-loader.js +2 -5
- package/util/gl-util/draw-options/methods.js +4 -5
- package/util/webglobjectbuilders.js +4 -9
- package/write-text/context-text3.js +17 -0
- package/write-text/context-text3old.js +152 -0
- package/programs/line-on-globe/circle-accurate.js +0 -175
- package/programs/line-on-globe/circle.js +0 -164
- package/programs/line-on-globe/to-the-surface.js +0 -109
- package/programs/rings/distancering/shader.js +0 -1
- package/programs/totems/canvas-webglobe-info1.js +0 -106
- package/shape-on-terrain/arc/naive/plugin.js +0 -205
- package/util/check/get.js +0 -14
- package/util/gl-util/buffer/types.js +0 -1
- package/util/gl-util/draw-options/types.js +0 -15
- package/util/webglobjectbuilders1.js +0 -219
|
@@ -1,354 +1,368 @@
|
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// TODO: Delete this file if it is not needed anymore.
|
|
3
|
+
// /**
|
|
4
|
+
// * ring data model
|
|
5
|
+
// * [centerX, centerY, range, padding, r, g, b, a, hide]
|
|
6
|
+
// *
|
|
7
|
+
// * Buffer is initialized with ring capacity and buffer is created with that capacity. It might be called buffer orphaning.
|
|
8
|
+
// *
|
|
9
|
+
// * */
|
|
10
|
+
// /**
|
|
11
|
+
// * TODO
|
|
12
|
+
// * delete registerCenter
|
|
13
|
+
// *
|
|
14
|
+
// *
|
|
15
|
+
// */
|
|
16
|
+
// const RING_SIZE = 9;
|
|
17
|
+
// export default class {
|
|
18
|
+
// /**
|
|
19
|
+
// * @param {WebGL2RenderingContext} gl
|
|
20
|
+
// * @param {Object} options
|
|
21
|
+
// * @param {Number} options.initialRingCapacity
|
|
22
|
+
// * @param {String} options.bufferType - "static" or "dynamic"
|
|
23
|
+
// * */
|
|
24
|
+
// constructor(gl, globe, { initialRingCapacity = 20, bufferType = "STATIC_DRAW", implicitExtentionRate = 1.2 } = {}) {
|
|
25
|
+
// this.gl = gl;
|
|
26
|
+
// this.globe = globe;
|
|
27
|
+
// this._capacity = initialRingCapacity;
|
|
28
|
+
// this._ringCounter = 0;
|
|
29
|
+
// this._length = 0;
|
|
30
|
+
// this._centerMap = new Map(); // key, new MAP(x,y, rings:[])
|
|
31
|
+
// this._ringOffsets = new Map();
|
|
32
|
+
// this._removedRingsOffsetStack = [];
|
|
33
|
+
// this._bufferType = gl[bufferType.toUpperCase()];
|
|
34
|
+
// this.implicitExtentionRate = implicitExtentionRate;
|
|
35
|
+
// this.buffer = gl.createBuffer();
|
|
36
|
+
// { // initilize data
|
|
37
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
|
|
38
|
+
// gl.bufferData(gl.ARRAY_BUFFER, initialRingCapacity * 4 * RING_SIZE, this._bufferType);
|
|
39
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
40
|
+
// }
|
|
41
|
+
// {
|
|
42
|
+
// this._circleVAO = gl.createVertexArray();
|
|
43
|
+
// gl.bindVertexArray(this._circleVAO);
|
|
44
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
|
|
45
|
+
// gl.enableVertexAttribArray(0);
|
|
46
|
+
// gl.vertexAttribPointer(0, 2, gl.FLOAT, false, RING_SIZE * 4, 0);
|
|
47
|
+
// gl.enableVertexAttribArray(1);
|
|
48
|
+
// gl.vertexAttribPointer(1, 1, gl.FLOAT, false, RING_SIZE * 4, 2 * 4);
|
|
49
|
+
// gl.enableVertexAttribArray(2);
|
|
50
|
+
// gl.vertexAttribPointer(2, 4, gl.FLOAT, false, RING_SIZE * 4, 4 * 4);
|
|
51
|
+
// gl.enableVertexAttribArray(3);
|
|
52
|
+
// gl.vertexAttribPointer(3, 3, gl.FLOAT, false, RING_SIZE * 4, 8 * 4);
|
|
53
|
+
// // set divisors to 1
|
|
54
|
+
// gl.vertexAttribDivisor(0, 1);
|
|
55
|
+
// gl.vertexAttribDivisor(1, 1);
|
|
56
|
+
// gl.vertexAttribDivisor(2, 1);
|
|
57
|
+
// gl.vertexAttribDivisor(3, 1);
|
|
58
|
+
// gl.bindVertexArray(null);
|
|
59
|
+
// }
|
|
60
|
+
// {
|
|
61
|
+
// this._paddingVAO = gl.createVertexArray();
|
|
62
|
+
// gl.bindVertexArray(this._paddingVAO);
|
|
63
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
|
|
64
|
+
// gl.enableVertexAttribArray(0);
|
|
65
|
+
// gl.vertexAttribPointer(0, 2, gl.FLOAT, false, RING_SIZE * 4, 0);
|
|
66
|
+
// gl.enableVertexAttribArray(1);
|
|
67
|
+
// gl.vertexAttribPointer(1, 1, gl.FLOAT, false, RING_SIZE * 4, 2 * 4);
|
|
68
|
+
// gl.enableVertexAttribArray(2);
|
|
69
|
+
// gl.vertexAttribPointer(2, 1, gl.FLOAT, false, RING_SIZE * 4, 3 * 4);
|
|
70
|
+
// gl.enableVertexAttribArray(3);
|
|
71
|
+
// gl.vertexAttribPointer(3, 4, gl.FLOAT, false, RING_SIZE * 4, 4 * 4);
|
|
72
|
+
// gl.enableVertexAttribArray(4);
|
|
73
|
+
// gl.vertexAttribPointer(4, 3, gl.FLOAT, false, RING_SIZE * 4, 8 * 4);
|
|
74
|
+
// gl.vertexAttribDivisor(0, 1);
|
|
75
|
+
// gl.vertexAttribDivisor(1, 1);
|
|
76
|
+
// gl.vertexAttribDivisor(2, 1);
|
|
77
|
+
// gl.vertexAttribDivisor(3, 1);
|
|
78
|
+
// gl.vertexAttribDivisor(4, 1);
|
|
79
|
+
// gl.bindVertexArray(null);
|
|
80
|
+
// }
|
|
81
|
+
// }
|
|
82
|
+
// /**
|
|
83
|
+
// * @param {String} centerID
|
|
84
|
+
// * @param {Object} options
|
|
85
|
+
// * @param {Number} options.x
|
|
86
|
+
// * @param {Number} options.y
|
|
87
|
+
// * */
|
|
88
|
+
// registerCenter(centerID, { x = 0, y = 0 } = {}) {
|
|
89
|
+
// this._centerMap.set(centerID, new Map(
|
|
90
|
+
// [
|
|
91
|
+
// ["x", x],
|
|
92
|
+
// ["y", y],
|
|
93
|
+
// ["rings", []] // ring keys
|
|
94
|
+
// ]
|
|
95
|
+
// ));
|
|
96
|
+
// }
|
|
97
|
+
// /**
|
|
98
|
+
// *
|
|
99
|
+
// * @param {null | number} newCapacity if null, vacuum defragmentation is applied -> capacity is set to the current ring count
|
|
100
|
+
// */
|
|
101
|
+
// defrag(newCapacity = null) {
|
|
102
|
+
// const { _removedRingsOffsetStack, _ringOffsets } = this;
|
|
103
|
+
// _removedRingsOffsetStack.sort();
|
|
104
|
+
// this._capacity = newCapacity || this._ringCounter;
|
|
105
|
+
// const arrayToLoad = new Float32Array(this._capacity * RING_SIZE);
|
|
106
|
+
// const bufferData = this._getBufferData();
|
|
107
|
+
// let arrayOffset = 0;
|
|
108
|
+
// const newRingOffsets = new Map();
|
|
109
|
+
// for (const [key, offset] of _ringOffsets) {
|
|
110
|
+
// const ringOffset = offset / 4
|
|
111
|
+
// const ringData = bufferData.slice(ringOffset, ringOffset + RING_SIZE);
|
|
112
|
+
// arrayToLoad.set(ringData, arrayOffset);
|
|
113
|
+
// newRingOffsets.set(key, arrayOffset * 4);
|
|
114
|
+
// arrayOffset += RING_SIZE;
|
|
115
|
+
// }
|
|
116
|
+
// const { gl, buffer } = this;
|
|
117
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
118
|
+
// gl.bufferData(gl.ARRAY_BUFFER, arrayToLoad, this._bufferType);
|
|
119
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
120
|
+
// this._ringOffsets = newRingOffsets;
|
|
121
|
+
// this._removedRingsOffsetStack = [];
|
|
122
|
+
// this._length = this._ringCounter;
|
|
123
|
+
// }
|
|
124
|
+
// extendBuffer(newCapacity) {
|
|
125
|
+
// if (this._capacity >= newCapacity) {
|
|
126
|
+
// console.warn("New capacity is smaller than the current capacity");
|
|
127
|
+
// return;
|
|
128
|
+
// }
|
|
129
|
+
// this._capacity = newCapacity;
|
|
130
|
+
// const { gl, buffer } = this;
|
|
131
|
+
// const bufferData = this._getBufferData();
|
|
132
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
133
|
+
// gl.bufferData(gl.ARRAY_BUFFER, newCapacity * RING_SIZE * 4, this._bufferType);
|
|
134
|
+
// gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
|
|
135
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
136
|
+
// }
|
|
137
|
+
// checkCapacity(sizeLeft = 1) {
|
|
138
|
+
// return sizeLeft <= this._capacity - this._ringCounter;
|
|
139
|
+
// }
|
|
140
|
+
// capacityLeft() {
|
|
141
|
+
// return this._capacity - this._ringCounter;
|
|
142
|
+
// }
|
|
143
|
+
// get capacity() {
|
|
144
|
+
// return this._capacity;
|
|
145
|
+
// }
|
|
146
|
+
// get length() {
|
|
147
|
+
// return this._length;
|
|
148
|
+
// }
|
|
149
|
+
// get ringCount() {
|
|
150
|
+
// return this._ringCounter;
|
|
151
|
+
// }
|
|
152
|
+
// /**
|
|
153
|
+
// * @param {Array<string>} centerIDs
|
|
154
|
+
// * */
|
|
155
|
+
// removeCenters(centerIDs) {
|
|
156
|
+
// const { gl, buffer } = this;
|
|
157
|
+
// const zero = new Float32Array([0]);
|
|
158
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
159
|
+
// for (let centerID of centerIDs) {
|
|
160
|
+
// if (!this._centerMap.has(centerID)) {
|
|
161
|
+
// // console.warn("Center is not registered yet");
|
|
162
|
+
// // return;
|
|
163
|
+
// continue;
|
|
164
|
+
// }
|
|
165
|
+
// const center = this._centerMap.get(centerID);
|
|
166
|
+
// const rings = center.get("rings");
|
|
167
|
+
// for (let i = 0; i < rings.length; i++) {
|
|
168
|
+
// // set range to 0, 3rd index of float32array
|
|
169
|
+
// const offset = this._ringOffsets.get(rings[i]);
|
|
170
|
+
// gl.bufferSubData(gl.ARRAY_BUFFER, offset + 8, zero);
|
|
171
|
+
// this._removedRingsOffsetStack.push(offset);
|
|
172
|
+
// this._ringOffsets.delete(rings[i]);
|
|
173
|
+
// }
|
|
174
|
+
// this._ringCounter -= rings.length;
|
|
175
|
+
// this._centerMap.delete(centerID);
|
|
176
|
+
// }
|
|
177
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
178
|
+
// this.globe.DrawRender();
|
|
179
|
+
// }
|
|
180
|
+
// /**
|
|
181
|
+
// *
|
|
182
|
+
// * @property {String} centerID
|
|
183
|
+
// * @property {Number} x radians x
|
|
184
|
+
// * @property {Number} y radians y
|
|
185
|
+
// * @param {*} centerIDxyList
|
|
186
|
+
// */
|
|
187
|
+
// updateCentersXY(centerIDxyList) {
|
|
188
|
+
// const { gl, buffer } = this;
|
|
189
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
190
|
+
// for (let { centerID, x, y } of centerIDxyList) {
|
|
191
|
+
// const center = this._centerMap.get(centerID);
|
|
192
|
+
// center.set("x", x);
|
|
193
|
+
// center.set("y", y);
|
|
194
|
+
// const xyBlock = new Float32Array([x, y]);
|
|
195
|
+
// const rings = center.get("rings");
|
|
196
|
+
// for (let i = 0; i < rings.length; i++) {
|
|
197
|
+
// const offset = this._ringOffsets.get(rings[i]);
|
|
198
|
+
// gl.bufferSubData(gl.ARRAY_BUFFER, offset, xyBlock);
|
|
199
|
+
// }
|
|
200
|
+
// }
|
|
201
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
202
|
+
// this.globe.DrawRender();
|
|
203
|
+
// }
|
|
204
|
+
// updateCentersHide(data) {
|
|
205
|
+
// const { gl, buffer } = this;
|
|
206
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
207
|
+
// for (let { centerID, hide = null } of data) {
|
|
208
|
+
// if (hide === null) continue;
|
|
209
|
+
// const rings = this._centerMap.get(centerID).get("rings");
|
|
210
|
+
// for (let i = 0; i < rings.length; i++) {
|
|
211
|
+
// const offset = this._ringOffsets.get(rings[i]);
|
|
212
|
+
// gl.bufferSubData(gl.ARRAY_BUFFER, offset + 32, new Float32Array([hide]));
|
|
213
|
+
// }
|
|
214
|
+
// }
|
|
215
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
216
|
+
// this.globe.DrawRender();
|
|
217
|
+
// }
|
|
218
|
+
// insertBulk(rangeRingDatas) {
|
|
219
|
+
// const { gl, buffer } = this;
|
|
220
|
+
// {// remove existring centers
|
|
221
|
+
// const existingCenterIDs = [];
|
|
222
|
+
// for (let { centerID } of rangeRingDatas) {
|
|
223
|
+
// if (this._centerMap.has(centerID)) {
|
|
224
|
+
// existingCenterIDs.push(centerID);
|
|
225
|
+
// }
|
|
226
|
+
// }
|
|
227
|
+
// this.removeCenters(existingCenterIDs);
|
|
228
|
+
// }
|
|
229
|
+
// { // capacity check
|
|
230
|
+
// let incomingRingSize = 0;
|
|
231
|
+
// for (let { rings } of rangeRingDatas) {
|
|
232
|
+
// incomingRingSize += rings.length;
|
|
233
|
+
// // It should check if ring is already registered but for now it is not implemented.
|
|
234
|
+
// // Reasons: increase in complexity and performance
|
|
235
|
+
// }
|
|
236
|
+
// this._implicitExtendBufferInNeed(incomingRingSize);
|
|
237
|
+
// }
|
|
238
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
239
|
+
// for (const { centerID, x, y, rings, hide = 0 } of rangeRingDatas) {
|
|
240
|
+
// this.registerCenter(centerID, { x, y })
|
|
241
|
+
// for (const { ringID, radius, padding, rgba } of rings) {
|
|
242
|
+
// const key = this._ringKey(centerID, ringID);
|
|
243
|
+
// const bufferData = new Float32Array([x, y, radius, padding, ...rgba, hide]);
|
|
244
|
+
// const offset = this._nextBufferOffset();
|
|
245
|
+
// gl.bufferSubData(gl.ARRAY_BUFFER, offset, bufferData);
|
|
246
|
+
// this._ringOffsets.set(key, offset);
|
|
247
|
+
// this._centerMap.get(centerID).get("rings").push(key);
|
|
248
|
+
// }
|
|
249
|
+
// }
|
|
250
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
251
|
+
// this.globe.DrawRender();
|
|
252
|
+
// }
|
|
253
|
+
// /**
|
|
254
|
+
// *
|
|
255
|
+
// * @param {Array<{centerID, rgba}} centersColors
|
|
256
|
+
// */
|
|
257
|
+
// updateCentersColor(centersColors) {
|
|
258
|
+
// const { gl, buffer } = this;
|
|
259
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
260
|
+
// for (let { centerID, rgba } of centersColors) {
|
|
261
|
+
// if (!this._centerMap.has(centerID)) {
|
|
262
|
+
// console.warn("Center is not registered yet");
|
|
263
|
+
// continue;
|
|
264
|
+
// }
|
|
265
|
+
// const rings = this._centerMap.get(centerID).get("rings");
|
|
266
|
+
// const block = new Float32Array(rgba);
|
|
267
|
+
// for (let i = 0; i < rings.length; i++) {
|
|
268
|
+
// const offset = this._ringOffsets.get(rings[i]);
|
|
269
|
+
// gl.bufferSubData(gl.ARRAY_BUFFER, offset + 16, block);
|
|
270
|
+
// }
|
|
271
|
+
// }
|
|
272
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
273
|
+
// this.globe.DrawRender();
|
|
274
|
+
// }
|
|
275
|
+
// // ----------------- INTERNAL METHODS ----------------- //
|
|
276
|
+
// bindCircleVAO() {
|
|
277
|
+
// this.gl.bindVertexArray(this._circleVAO);
|
|
278
|
+
// }
|
|
279
|
+
// bindPaddingVAO() {
|
|
280
|
+
// this.gl.bindVertexArray(this._paddingVAO);
|
|
281
|
+
// }
|
|
282
|
+
// free() {
|
|
283
|
+
// this.gl.deleteBuffer(this.buffer);
|
|
284
|
+
// this.gl.deleteVertexArray(this._circleVAO);
|
|
285
|
+
// this.gl.deleteVertexArray(this._paddingVAO);
|
|
286
|
+
// }
|
|
287
|
+
// // ----------------- PRIVATE METHODS ----------------- //
|
|
288
|
+
// _getBufferData() {
|
|
289
|
+
// const { gl, buffer } = this;
|
|
290
|
+
// const size = new Float32Array(this._length * RING_SIZE);
|
|
291
|
+
// const bufferData = new Float32Array(size);
|
|
292
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
293
|
+
// gl.getBufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
|
|
294
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
295
|
+
// return bufferData;
|
|
296
|
+
// }
|
|
297
|
+
// _ringKey(centerID, ringID) {
|
|
298
|
+
// return `C=${centerID},R=${ringID}`;
|
|
299
|
+
// }
|
|
300
|
+
// _nextBufferOffset() {
|
|
301
|
+
// if (!this.checkCapacity()) {
|
|
302
|
+
// throw new Error("Buffer is full");
|
|
303
|
+
// return;
|
|
304
|
+
// }
|
|
305
|
+
// let offset;
|
|
306
|
+
// if (this._removedRingsOffsetStack.length > 0) {
|
|
307
|
+
// offset = this._removedRingsOffsetStack.pop();
|
|
308
|
+
// } else {
|
|
309
|
+
// offset = this._ringCounter * RING_SIZE * 4;
|
|
310
|
+
// this._length++;
|
|
311
|
+
// }
|
|
312
|
+
// this._ringCounter++;
|
|
313
|
+
// return offset;
|
|
314
|
+
// }
|
|
315
|
+
// _implicitExtendBufferInNeed(incomingRingSize) {
|
|
316
|
+
// const overCapacity = incomingRingSize - this.capacityLeft();
|
|
317
|
+
// if (overCapacity <= 0) return;
|
|
318
|
+
// const newCapacity = Math.ceil((this._capacity + overCapacity) * this.implicitExtentionRate);
|
|
319
|
+
// this.extendBuffer(newCapacity);
|
|
320
|
+
// }
|
|
321
|
+
// async readRing(centerID, ringID) {
|
|
322
|
+
// const key = this._ringKey(centerID, ringID);
|
|
323
|
+
// if (!this._ringOffsets.has(key)) {
|
|
324
|
+
// console.warn("Ring is not registered yet");
|
|
325
|
+
// return;
|
|
326
|
+
// }
|
|
327
|
+
// const offset = this._ringOffsets.get(key);
|
|
328
|
+
// const { gl, buffer } = this;
|
|
329
|
+
// gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
330
|
+
// const bufferData = new Float32Array(9);
|
|
331
|
+
// gl.getBufferSubData(gl.ARRAY_BUFFER, offset, bufferData);
|
|
332
|
+
// return {
|
|
333
|
+
// centerX: bufferData[0],
|
|
334
|
+
// centerY: bufferData[1],
|
|
335
|
+
// range: bufferData[2],
|
|
336
|
+
// padding: bufferData[3],
|
|
337
|
+
// rgba: [bufferData[4], bufferData[5], bufferData[6], bufferData[7]],
|
|
338
|
+
// hide: bufferData[8]
|
|
339
|
+
// }
|
|
340
|
+
// }
|
|
341
|
+
// /**
|
|
342
|
+
// * TODOS:
|
|
343
|
+
// * - bulk ring registration. This must be managed here to avoid binding and unbinding buffer multiple times
|
|
344
|
+
// * - bulk centers and rings registration
|
|
345
|
+
// *
|
|
346
|
+
// * - Check capacity on extend buffer and collect garbage
|
|
347
|
+
// * - set length to the filled part of the buffer. used for draw calls
|
|
348
|
+
// * */
|
|
349
|
+
// /**
|
|
350
|
+
// * collectGarbage with Defragmantation
|
|
351
|
+
// * Basic idea: on unregistration the last ring is moved to the removed ring's place. length is decreased by 1
|
|
352
|
+
// * Optimization: Reading buffer is expensive. So bulk defragmentation is needed to work with this approach
|
|
353
|
+
// * */
|
|
354
|
+
// }
|
|
355
|
+
// /**
|
|
356
|
+
// * Documentation
|
|
357
|
+
// *
|
|
358
|
+
// * Methods:
|
|
359
|
+
// * - insertRings(centerIdringIdRadiusPaddingRgbaHide)
|
|
360
|
+
// * - removeRings(centerIDringIDs)
|
|
361
|
+
// * - removeCenters(centerIDs)
|
|
362
|
+
// * - updateCentersXY(centerIDxyList)
|
|
363
|
+
// * - updateCenters(centerDatas)
|
|
364
|
+
// * - insertBulk(rangeRingDatas)
|
|
365
|
+
// * - updateRing(centerID, ringID, { radius, padding, rgba, hide })
|
|
366
|
+
// * - readRing(centerID, ringID)
|
|
367
|
+
// *
|
|
368
|
+
// */
|