@pirireis/webglobeplugins 0.0.4 → 0.0.6

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.
@@ -0,0 +1,382 @@
1
+ import { createProgram, shaderfunctions } from "../../../util";
2
+ import { BufferOffsetManager } from "../../../util/account";
3
+ import CameraUniformBlockTotem, { CameraUniformBlockString } from "../../totems/camerauniformblock";
4
+ import { globeProgramCache, noRegisterGlobeProgramCache } from "../../programcache";
5
+
6
+
7
+ const vertexShader = `#version 300 es ` +
8
+ shaderfunctions.PI +
9
+ shaderfunctions.R +
10
+ shaderfunctions.POLE +
11
+ CameraUniformBlockString +
12
+ shaderfunctions.mercatorXYTo2DPoint +
13
+ shaderfunctions.longLatRadToMercator +
14
+ shaderfunctions.longLatRadToCartesian3D +
15
+ shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
16
+ shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
17
+ shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
18
+
19
+ in vec2 center;
20
+ in float radius;
21
+ in float pad_range;
22
+ in vec4 color;
23
+ in float flag;
24
+ in float pad_angle;
25
+
26
+ uniform int compass;
27
+
28
+ out vec2 v_limp;
29
+ out vec4 v_color;
30
+
31
+
32
+ void main() {
33
+ if( flag == 1.0 || radius == 0.0 ) return; // 1.0 is hide
34
+ v_color = color;
35
+ gl_PointSize = 2.0;
36
+
37
+ float odd = mod(float(gl_VertexID), 2.0);
38
+ float index = (float(gl_VertexID)- odd ) / 2.0;
39
+ float angle = pad_angle - 1.5707963267948966192313216916398;
40
+ float radius_ = radius - (pad_range * odd);
41
+
42
+ if ( is3D){
43
+ gl_Position = projection * view * vec4(
44
+ circleLimpFromLongLatRadCenterCartesian3D( center, radius_, angle) - translate, 1.0);
45
+ v_limp = vec2(0.0, 0.0);
46
+ return;
47
+ }
48
+ vec2 limp;
49
+ if ( compass == 1 ){
50
+ limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
51
+ } else {
52
+ limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
53
+ }
54
+ v_limp = limp;
55
+ gl_Position = mercatorXYTo2DPoint(limp);
56
+ }`;
57
+
58
+ const fragmentShader = `#version 300 es
59
+ precision highp float; ` +
60
+ shaderfunctions.POLE + `
61
+ in vec4 v_color;
62
+ in vec2 v_limp;
63
+ out vec4 outColor;
64
+ void main() {
65
+ if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ discard; }
66
+ outColor = v_color;
67
+ }`;
68
+
69
+
70
+
71
+
72
+ class Logic {
73
+
74
+ constructor(globe) {
75
+
76
+ this.globe = globe;
77
+ this.gl = globe.gl;
78
+ this.program = createProgram(this.gl, vertexShader, fragmentShader);
79
+
80
+ {
81
+ const gl = this.gl;
82
+ this.center = gl.getAttribLocation(this.program, "center");
83
+ this.radius = gl.getAttribLocation(this.program, "radius");
84
+ this.pad_range = gl.getAttribLocation(this.program, "pad_range");
85
+ this.color = gl.getAttribLocation(this.program, "color");
86
+ this.flag = gl.getAttribLocation(this.program, "flag");
87
+ this.pad_angle = gl.getAttribLocation(this.program, "pad_angle");
88
+
89
+ }
90
+
91
+ this.cameraBlockBindingPoint = 0;
92
+ const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
93
+ this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
94
+ this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
95
+ this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
96
+
97
+
98
+ {
99
+ const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
100
+ this.gl.useProgram(this.program);
101
+ this.gl.uniform1i(this._compassLocation, 1);
102
+ this._lastCompass = 1;
103
+ this.gl.useProgram(currentProgram);
104
+ }
105
+ }
106
+
107
+
108
+ draw(attrBufferManager, compass) {
109
+
110
+ const { gl, program, cameraBlockBindingPoint, cameraBlockTotem, _compassLocation } = this;
111
+
112
+ gl.useProgram(program);
113
+ attrBufferManager.bindPaddingVAO();
114
+ cameraBlockTotem.bind(cameraBlockBindingPoint);
115
+ if (compass !== this._lastCompass) {
116
+ gl.uniform1i(_compassLocation, compass);
117
+ this._lastCompass = compass;
118
+ }
119
+ gl.disable(gl.DEPTH_TEST);
120
+ gl.drawArraysInstanced(gl.LINES, 0, 2, attrBufferManager.length);
121
+ gl.enable(gl.DEPTH_TEST);
122
+ cameraBlockTotem.unbind(cameraBlockBindingPoint);
123
+ gl.bindVertexArray(null);
124
+
125
+ }
126
+ initilizeBufferManager({ bufferType = "DYNAMIC_DRAW", initialRingCapacity = 10 } = {}) {
127
+ return new BufferManager(this.gl, bufferType, initialRingCapacity);
128
+
129
+ }
130
+
131
+ }
132
+
133
+
134
+ export const PaddingFreeAngleCache = Object.freeze({
135
+ getProgram: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
136
+ releaseProgram: (globe) => globeProgramCache.releaseProgram(globe, Logic)
137
+ })
138
+
139
+
140
+
141
+ export class BufferManager extends BufferOffsetManager {
142
+ constructor(gl, bufferType, initialRingCapacity = 10) {
143
+ super(10, { capacity: initialRingCapacity, bufferType });
144
+ this.gl = gl;
145
+ this.bufferType = bufferType;
146
+ this.buffer = gl.createBuffer();
147
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
148
+ gl.bufferData(gl.ARRAY_BUFFER, this.capacity * this.itemSize * 4, gl[bufferType]);
149
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
150
+ this._centerMaps = new Map();
151
+ this.vao = gl.createVertexArray();
152
+
153
+ {
154
+ gl.bindVertexArray(this.vao);
155
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
156
+ gl.enableVertexAttribArray(0);
157
+ gl.enableVertexAttribArray(1);
158
+ gl.enableVertexAttribArray(2);
159
+ gl.enableVertexAttribArray(3);
160
+ gl.enableVertexAttribArray(4);
161
+ gl.enableVertexAttribArray(5);
162
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 40, 0);
163
+ gl.vertexAttribPointer(1, 1, gl.FLOAT, false, 40, 8);
164
+ gl.vertexAttribPointer(2, 1, gl.FLOAT, false, 40, 12);
165
+ gl.vertexAttribPointer(3, 4, gl.FLOAT, false, 40, 16);
166
+ gl.vertexAttribPointer(4, 1, gl.FLOAT, false, 40, 32);
167
+ gl.vertexAttribPointer(5, 1, gl.FLOAT, false, 40, 36);
168
+ // divisor
169
+ gl.vertexAttribDivisor(0, 1);
170
+ gl.vertexAttribDivisor(1, 1);
171
+ gl.vertexAttribDivisor(2, 1);
172
+ gl.vertexAttribDivisor(3, 1);
173
+ gl.vertexAttribDivisor(4, 1);
174
+ gl.vertexAttribDivisor(5, 1);
175
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
176
+ gl.bindVertexArray(null);
177
+ }
178
+ }
179
+
180
+
181
+ __centerMapMethod(x, y, rgba, rings, hide, paddingAngles) {
182
+ return new Map([
183
+ ["x", x],
184
+ ["y", y],
185
+ ["rgba", rgba],
186
+ ["rings", rings],
187
+ ["hide", hide],
188
+ ["paddingAngles", paddingAngles]
189
+ ])
190
+ }
191
+
192
+
193
+
194
+
195
+ bindPaddingVAO() {
196
+ this.gl.bindVertexArray(this.vao);
197
+ }
198
+
199
+ //TODO: implement this
200
+ // insertBulk is gone. no update feature
201
+ // addBulk is added.
202
+ // deletes old centers given
203
+ insertBulk(data) {
204
+ const { gl, buffer } = this;
205
+
206
+ const deleteCentersList = [];
207
+ for (const { centerID } of data) {
208
+ if (this._centerMaps.has(centerID)) {
209
+ deleteCentersList.push(centerID);
210
+ }
211
+ }
212
+ if (deleteCentersList.length > 0) {
213
+ this.removeCenters(deleteCentersList);
214
+ }
215
+
216
+
217
+ const requiredSpace = this.__requiredSpaceForBulk(data);
218
+
219
+ const spaceLeft = this.spaceLeft;
220
+ console.log("space left:", spaceLeft, "required space:", requiredSpace);
221
+ if (requiredSpace > spaceLeft) {
222
+ console.log("new capacity:", this.capacity + requiredSpace - spaceLeft)
223
+ this.extendBuffer(gl, buffer, this.bufferType, this.capacity + requiredSpace - spaceLeft);
224
+ }
225
+
226
+ const items = [];
227
+
228
+ for (const { centerID, x, y, rgba, paddingAngles, hide = false, rings } of data) {
229
+
230
+ this._centerMaps.set(centerID, this.__centerMapMethod(x, y, rgba, rings, hide, paddingAngles)); // x,y, rgba, hide prograbably not needed
231
+
232
+ const hideFlag = hide ? 1 : 0;
233
+ for (const { ringID, radius, padding } of rings) {
234
+ for (const paddingAngle of paddingAngles) {
235
+ const _offsetMapKey = `${centerID}_${ringID}_${paddingAngle}`;
236
+ const offset = this.getOffset(_offsetMapKey) | this.nextOffset();
237
+ items.push({
238
+ offset: offset,
239
+ payload: new Float32Array([x, y, radius, padding, rgba[0], rgba[1], rgba[2], rgba[3], hideFlag, paddingAngle])
240
+ })
241
+ this.offSetMap.set(_offsetMapKey, offset);
242
+ }
243
+ }
244
+ }
245
+ const partOffset = 0;
246
+
247
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
248
+ for (let { offset, payload } of items) {
249
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset, payload);
250
+ }
251
+ }
252
+
253
+
254
+ updateCentersXY(data) {
255
+ const { gl, buffer } = this;
256
+ const items = [];
257
+
258
+ for (const { centerID, x, y } of data) {
259
+ const center = this._centerMaps.get(centerID);
260
+ center.set("x", x);
261
+ center.set("y", y);
262
+ const payload = new Float32Array([x, y]);
263
+ const paddingAngles = center.get("paddingAngles");
264
+ const rings = center.get("rings");
265
+ for (const { ringID } of rings) {
266
+ for (const paddingAngle of paddingAngles) {
267
+ const offsetKey = offsetMapKey(centerID, ringID, paddingAngle);
268
+ items.push({ offset: this.getOffset(offsetKey), payload });
269
+ }
270
+ }
271
+ }
272
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
273
+ for (let { offset, payload } of items) {
274
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset, payload);
275
+ }
276
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
277
+ }
278
+
279
+
280
+
281
+ //TODO: test
282
+ updateCentersHide(data) {
283
+ const { gl, buffer } = this;
284
+ const items = [];
285
+ for (const { centerID, hide } of data) {
286
+ const block = new Float32Array([hide]);
287
+ const center = this._centerMaps.get(centerID);
288
+ if (!center) continue;
289
+ const paddingAngles = center.get("paddingAngles");
290
+ const rings = center.get("rings");
291
+ for (const { ringID } of rings) {
292
+ for (const paddingAngle of paddingAngles) {
293
+ const offsetKey = offsetMapKey(centerID, ringID, paddingAngle);
294
+ items.push({ key: offsetKey, payload: block });
295
+ }
296
+ }
297
+ }
298
+ this._updatePartial(items, 8, gl, buffer);
299
+ }
300
+
301
+ updateCentersColor(data) {
302
+ const { gl, buffer } = this;
303
+ const items = [];
304
+ for (const { centerID, rgba } of data) {
305
+ const center = this._centerMaps.get(centerID);
306
+ if (!center) continue;
307
+ center.set("rgba", rgba);
308
+ const paddingAngles = center.get("paddingAngles");
309
+ const rings = center.get("rings");
310
+ const payload = new Float32Array(rgba);
311
+ for (const { ringID } of rings) {
312
+ for (const paddingAngle of paddingAngles) {
313
+ const offsetKey = offsetMapKey(centerID, ringID, paddingAngle);
314
+ items.push({ key: offsetKey, payload });
315
+ }
316
+ }
317
+ }
318
+ this._updatePartial(items, 4, gl, buffer);
319
+ }
320
+
321
+
322
+
323
+ __requiredSpaceForBulk(data) {
324
+ let space = 0;
325
+ for (const { paddingAngles, rings } of data) {
326
+ space += paddingAngles.length * rings.length;
327
+ }
328
+ return space;
329
+ }
330
+
331
+ // TODO: TEST IT WITH INSERT
332
+ removeCenters(centerIDs) {
333
+ const keys = [];
334
+ for (const centerID of centerIDs) {
335
+ const center = this._centerMaps.get(centerID);
336
+ if (!center) continue;
337
+ const rings = center.get("rings");
338
+ const paddingAngles = center.get("paddingAngles");
339
+ for (const { ringID } of rings) {
340
+ for (const paddingAngle of paddingAngles) {
341
+ keys.push(offsetMapKey(centerID, ringID, paddingAngle));
342
+ }
343
+ }
344
+ this._centerMaps.delete(centerID);
345
+ }
346
+ this._removeFromBuffer(keys);
347
+ }
348
+ }
349
+
350
+
351
+ const offsetMapKey = (centerID, ringID, paddingAngle) => `${centerID}_${ringID}_${paddingAngle}`;
352
+
353
+
354
+
355
+ /**
356
+ * {center has x,y, color, paddingAngles, rings} key: centerID
357
+ * {ring has ranges, paddings} key: ringKey
358
+ * _offSetMap => | key: centerID_ringKey_paddingAngle | value: offset |
359
+ *
360
+ * insertCenter
361
+ *
362
+ * insertRing
363
+ *
364
+ * updateCenter ---> updatesRings ---> updatesPaddings
365
+ * centerMap ringMap
366
+ * keeps keeps
367
+ * list of Rings list of Paddings
368
+ *
369
+ *
370
+ * needs an adaptor to convert currently implemented data into this format.
371
+ * current format:
372
+ * center = {
373
+ * centerID,
374
+ * x,
375
+ * y,
376
+ * rings: [
377
+ * radius,
378
+ * paddingRadius,
379
+ * rgba,
380
+ * ]
381
+ * }
382
+ */
@@ -5,6 +5,14 @@
5
5
  * Buffer is initialized with ring capacity and buffer is created with that capacity. It might be called buffer orphaning.
6
6
  *
7
7
  * */
8
+
9
+
10
+ /**
11
+ * TODO
12
+ * delete registerCenter
13
+ *
14
+ *
15
+ */
8
16
  const RING_SIZE = 9;
9
17
 
10
18
  export default class {
@@ -14,7 +22,7 @@ export default class {
14
22
  * @param {Number} options.initialRingCapacity
15
23
  * @param {String} options.bufferType - "static" or "dynamic"
16
24
  * */
17
- constructor(gl, globe, { initialRingCapacity = 20, bufferType = "static", implicitExtentionRate = 1.2 } = {}) {
25
+ constructor(gl, globe, { initialRingCapacity = 20, bufferType = "STATIC_DRAW", implicitExtentionRate = 1.2 } = {}) {
18
26
  this.gl = gl;
19
27
  this.globe = globe;
20
28
  this._capacity = initialRingCapacity;
@@ -158,77 +166,7 @@ export default class {
158
166
  }
159
167
 
160
168
 
161
- /**
162
- * @typedef centerIdringIdRadiusPaddingRgbaHide
163
- * @property {String} centerID
164
- * @property {String} ringID
165
- * @property {Number} radius
166
- * @property {Number} padding
167
- * @property {Array<Number>} rgba - [r,g,b,a]
168
- * @param {Array<centerIdringIdRadiusPaddingRgbaHide>} centerIdringIdRadiusPaddingRgbaHideList
169
- * */
170
- insertRings(centerIdringIdRadiusPaddingRgbaHideList) {
171
- { // capacity check
172
- this._implicitExtendBufferInNeed(centerIdringIdRadiusPaddingRgbaHideList.length);
173
- }
174
- const { gl, buffer } = this;
175
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
176
- for (let { centerID, ringID, radius, padding, rgba, hide = false } of centerIdringIdRadiusPaddingRgbaHideList) {
177
- if (!this._centerMap.has(centerID)) {
178
- console.warn("Center is not registered yet");
179
- return;
180
- }
181
- const x = this._centerMap.get(centerID).get("x");
182
- const y = this._centerMap.get(centerID).get("y");
183
- const bufferData = new Float32Array([x, y, radius, padding, ...rgba, hide ? 1 : 0]);
184
- const key = this._ringKey(centerID, ringID);
185
- let offset;
186
- if (!this._ringOffsets.has(key)) {
187
- offset = this._nextBufferOffset();
188
- this._ringOffsets.set(key, offset);
189
- this._centerMap.get(centerID).get("rings").push(key);
190
- } else {
191
- offset = this._ringOffsets.get(key);
192
- }
193
- gl.bufferSubData(gl.ARRAY_BUFFER, offset, bufferData);
194
- }
195
- gl.bindBuffer(gl.ARRAY_BUFFER, null);
196
- this.globe.DrawRender();
197
- }
198
-
199
169
 
200
- /**
201
- * @typedef centerIDringID
202
- * @property {String} centerID
203
- * @property {String} ringID
204
- * @param {Array<centerIDringID>} centerIDringIDs
205
- * @returns
206
- */
207
- removeRings(centerIDringIDs) {
208
- const { gl, buffer } = this;
209
- const zero = new Float32Array([0]);
210
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
211
- for (let { centerID, ringID } of centerIDringIDs) {
212
- if (!this._centerMap.has(centerID)) {
213
- console.warn("Center is not registered yet");
214
- return;
215
- }
216
- const key = this._ringKey(centerID, ringID);
217
- if (!this._ringOffsets.has(key)) {
218
- console.warn("Ring is not registered yet");
219
- return;
220
- }
221
- const offset = this._ringOffsets.get(key);
222
- this._removedRingsOffsetStack.push(offset);
223
- this._ringOffsets.delete(key);
224
- // set range to 0, 3rd index of float32array
225
- gl.bufferSubData(gl.ARRAY_BUFFER, offset + 8, zero);
226
- this._centerMap.get(centerID).get("rings").splice(this._centerMap.get(centerID).get("rings").indexOf(key), 1);
227
- this._ringCounter--;
228
- }
229
- gl.bindBuffer(gl.ARRAY_BUFFER, null);
230
- this.globe.DrawRender();
231
- }
232
170
 
233
171
  /**
234
172
  * @param {Array<string>} centerIDs
@@ -239,8 +177,9 @@ export default class {
239
177
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
240
178
  for (let centerID of centerIDs) {
241
179
  if (!this._centerMap.has(centerID)) {
242
- console.warn("Center is not registered yet");
243
- return;
180
+ // console.warn("Center is not registered yet");
181
+ // return;
182
+ continue;
244
183
  }
245
184
  const center = this._centerMap.get(centerID);
246
185
  const rings = center.get("rings");
@@ -260,10 +199,10 @@ export default class {
260
199
 
261
200
 
262
201
  /**
263
- * @typedef centerIDxyList
202
+ *
264
203
  * @property {String} centerID
265
- * @property {Number} x mercator x
266
- * @property {Number} y mercator y
204
+ * @property {Number} x radians x
205
+ * @property {Number} y radians y
267
206
  * @param {*} centerIDxyList
268
207
  */
269
208
  updateCentersXY(centerIDxyList) {
@@ -282,10 +221,23 @@ export default class {
282
221
  }
283
222
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
284
223
  this.globe.DrawRender();
285
-
286
224
  }
287
225
 
288
226
 
227
+ updateCentersHide(data) {
228
+ const { gl, buffer } = this;
229
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
230
+ for (let { centerID, hide } of data) {
231
+ const rings = this._centerMap.get(centerID).get("rings");
232
+ for (let i = 0; i < rings.length; i++) {
233
+ const offset = this._ringOffsets.get(rings[i]);
234
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset + 32, new Float32Array([hide]));
235
+ }
236
+ }
237
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
238
+ this.globe.DrawRender();
239
+ }
240
+
289
241
  /**
290
242
  *
291
243
  * @typedef centerData
@@ -312,10 +264,19 @@ export default class {
312
264
  this.globe.DrawRender();
313
265
  }
314
266
 
315
-
316
-
317
267
  insertBulk(rangeRingDatas) {
318
268
  const { gl, buffer } = this;
269
+
270
+ {// remove existring centers
271
+ const existingCenterIDs = [];
272
+ for (let { centerID } of rangeRingDatas) {
273
+ if (this._centerMap.has(centerID)) {
274
+ existingCenterIDs.push(centerID);
275
+ }
276
+ }
277
+ this.removeCenters(existingCenterIDs);
278
+ }
279
+
319
280
  { // capacity check
320
281
  let incomingRingSize = 0;
321
282
  for (let { rings } of rangeRingDatas) {
@@ -325,19 +286,19 @@ export default class {
325
286
  }
326
287
  this._implicitExtendBufferInNeed(incomingRingSize);
327
288
  }
328
-
329
289
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
330
290
  for (let { centerID, x, y, rings } of rangeRingDatas) {
331
- if (!this._centerMap.has(centerID)) {
332
- this.registerCenter(centerID, { x, y })
333
- } else {
334
- const rings = this._centerMap.get(centerID).get("rings");
335
- const xy = new Float32Array([x, y]);
336
- for (let i = 0; i < rings.length; i++) {
337
- const offset = this._ringOffsets.get(rings[i]);
338
- gl.bufferSubData(gl.ARRAY_BUFFER, offset, xy);
339
- }
340
- }
291
+ // if (!this._centerMap.has(centerID)) {
292
+ this.registerCenter(centerID, { x, y })
293
+ // } else {
294
+ // const rings = this._centerMap.get(centerID).get("rings");
295
+ // const xy = new Float32Array([x, y]);
296
+ // const emptyBlock =
297
+ // for (let i = 0; i < rings.length; i++) {
298
+ // const offset = this._ringOffsets.get(rings[i]);
299
+ // gl.bufferSubData(gl.ARRAY_BUFFER, offset, );
300
+ // }
301
+ // }
341
302
  for (let { ringID, radius, padding, rgba, hide = false } of rings) {
342
303
  const key = this._ringKey(centerID, ringID);
343
304
  const bufferData = new Float32Array([x, y, radius, padding, ...rgba, hide ? 1 : 0]);
@@ -350,10 +311,8 @@ export default class {
350
311
  } else {
351
312
  const offset = this._ringOffsets.get(key);
352
313
  gl.bufferSubData(gl.ARRAY_BUFFER, offset, bufferData);
353
-
354
314
  }
355
315
  }
356
-
357
316
  }
358
317
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
359
318
  this.globe.DrawRender();
@@ -384,6 +343,29 @@ export default class {
384
343
  }
385
344
 
386
345
 
346
+ /**
347
+ *
348
+ * @param {Array<{centerID, rgba}} centersColors
349
+ */
350
+ updateCentersColor(centersColors) {
351
+ const { gl, buffer } = this;
352
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
353
+ for (let { centerID, rgba } of centersColors) {
354
+ if (!this._centerMap.has(centerID)) {
355
+ console.warn("Center is not registered yet");
356
+ continue;
357
+ }
358
+ const rings = this._centerMap.get(centerID).get("rings");
359
+ const block = new Float32Array(rgba);
360
+ for (let i = 0; i < rings.length; i++) {
361
+ const offset = this._ringOffsets.get(rings[i]);
362
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset + 16, block);
363
+ }
364
+ }
365
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
366
+ this.globe.DrawRender();
367
+ }
368
+
387
369
  // ----------------- INTERNAL METHODS ----------------- //
388
370
 
389
371
 
@@ -438,7 +420,6 @@ export default class {
438
420
 
439
421
 
440
422
  _implicitExtendBufferInNeed(incomingRingSize) {
441
- console.log("implicitExtendBufferInNeed", { incomingRingSize, "capacity left": this.capacityLeft(), "capacity": this._capacity, "ring counter": this._ringCounter });
442
423
  const overCapacity = incomingRingSize - this.capacityLeft();
443
424
  if (overCapacity <= 0) return;
444
425
  const newCapacity = Math.ceil((this._capacity + overCapacity) * this.implicitExtentionRate);
@@ -1,5 +1,5 @@
1
1
  import CircleFlatProgram from './circleflatprogram';
2
2
  import PaddyFlatProgram from './paddyflatprogram';
3
3
  import CirclePaddySharedBuffer from './circlepaddysharedbuffer';
4
-
5
- export default { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer }
4
+ import { PaddingFreeAngleCache } from './circlepaddingfreeangleprogram';
5
+ export { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer, PaddingFreeAngleCache };
@@ -28,8 +28,11 @@ out vec4 v_color;
28
28
 
29
29
 
30
30
  void main() {
31
- if( flag == 1.0 || radius == 0.0 ) return; // 1.0 is hide
32
- v_color = color;
31
+
32
+ float alpha_padding = z_level * z_level / (pad_range/ 100.0 );
33
+ if( flag == 2.0 || flag == 1.0 || radius == 0.0 || alpha_padding < 0.1 || z_level < 3.0 ) return; // 1.0 is hide
34
+ v_color = vec4(color.rgb, alpha_padding);
35
+
33
36
  gl_PointSize = 2.0;
34
37
 
35
38
  float odd = mod(float(gl_VertexID), 2.0);
@@ -1,3 +1,3 @@
1
- import RangeRings from './rangerings';
1
+ import RangeRings, { ENUM_HIDE } from './rangerings';
2
2
 
3
- export { RangeRings };
3
+ export { RangeRings, ENUM_HIDE };