@pirireis/webglobeplugins 0.8.5 → 0.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -33,7 +33,7 @@ class PointTracksPlugin {
33
33
  this._opacity = opacity;
34
34
  this.program = null
35
35
  this._lastWH = { w: 0, h: 0 };
36
- this._focusParams = { on: false, length: 0, elementBuffer: null };
36
+ this._focusParams = { on: false, length: 0, elementBuffer: null, trackIDs: [] };
37
37
  this.pointSizes = {
38
38
  pointSize,
39
39
  selectionPointFilling,
@@ -164,6 +164,8 @@ class PointTracksPlugin {
164
164
  }
165
165
  const { _bufferManagersMap, _bufferOrchestrator } = this;
166
166
  _bufferOrchestrator.insertBulk(flattenedPoints, _bufferManagersMap);
167
+ this._refillFocus();
168
+
167
169
  this.globe?.DrawRender();
168
170
 
169
171
  }
@@ -173,6 +175,7 @@ class PointTracksPlugin {
173
175
  const capacity = 100
174
176
  this._bufferOrchestrator?.flush({ capacity });
175
177
  this._bufferManagersMap.forEach(({ bufferManager }) => bufferManager.resetWithCapacity(capacity));
178
+ this._turnOffFocus();
176
179
  this._tracksToPointsMap.clear();
177
180
  this.globe?.DrawRender();
178
181
  }
@@ -190,20 +193,11 @@ class PointTracksPlugin {
190
193
  );
191
194
  this._tracksToPointsMap.delete(trackID);
192
195
  this._redraw = true;
196
+ this._refillFocus();
197
+
193
198
  this.globe?.DrawRender();
194
199
  }
195
200
 
196
- focusTracks(trackIDs = null) {
197
- if (!this.globe) return;
198
- if (!trackIDs) {
199
- this._focusParams.on = false;
200
- this.globe?.DrawRender();
201
- return;
202
- }
203
-
204
- this._focusParams.on = this._fillElementBuffer(trackIDs);
205
- this.globe.DrawRender();
206
- }
207
201
 
208
202
  /**
209
203
  * @param {string} trackID
@@ -216,9 +210,25 @@ class PointTracksPlugin {
216
210
  _bufferManagersMap
217
211
  );
218
212
  this._deletePointsFromTracksMap(trackID, pointIDs);
213
+ this._refillFocus();
219
214
  this.globe?.DrawRender();
220
215
  }
221
216
 
217
+ focusTracks(trackIDs = null) {
218
+ if (!this.globe) return;
219
+ if (!trackIDs) {
220
+ this._focusParams.on = false;
221
+ this.globe?.DrawRender();
222
+ return;
223
+ }
224
+ this._focusParams.on = this._fillElementBuffer(trackIDs);
225
+ if (!this._focusParams.on) {
226
+ this._turnOffFocus();
227
+ }
228
+ this.globe.DrawRender();
229
+ }
230
+
231
+
222
232
  // GLOBE API METHODS
223
233
 
224
234
  free() {
@@ -293,6 +303,11 @@ class PointTracksPlugin {
293
303
  }
294
304
  }
295
305
 
306
+ _refillFocus() {
307
+ if (this._focusParams.on) {
308
+ this.focusTracks(this._focusParams.trackIDs);
309
+ }
310
+ }
296
311
 
297
312
  _deletePointsFromTracksMap(trackID, pointIDs) {
298
313
  const trackSet = this._tracksToPointsMap.get(trackID);
@@ -312,15 +327,24 @@ class PointTracksPlugin {
312
327
 
313
328
  }
314
329
 
330
+ _turnOffFocus() {
331
+ const { gl } = this;
332
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._focusParams.elementBuffer);
333
+ gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([]), gl.STATIC_DRAW);
334
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
335
+ this._focusParams.length = 0;
336
+ this._focusParams.on = false;
337
+ }
315
338
 
316
339
  _fillElementBuffer(trackIDs) {
317
340
 
318
341
  let length = 0;
319
342
  const indexes = [];
320
-
343
+ const foundTracks = []
321
344
  for (const trackID of trackIDs) {
322
345
  const pointSet = this._tracksToPointsMap.get(trackID);
323
346
  if (!pointSet) continue;
347
+ foundTracks.push(trackID);
324
348
  const points = Array.from(pointSet);
325
349
  for (const pointID of points) {
326
350
  const key = keyMethod(trackID, pointID);
@@ -329,6 +353,7 @@ class PointTracksPlugin {
329
353
  length++;
330
354
  }
331
355
  }
356
+ this._focusParams.trackIDs = foundTracks;
332
357
  this._focusParams.length = length;
333
358
  if (length === 0) {
334
359
  return false;
@@ -79,6 +79,7 @@ class PointOnGlobeProgram {
79
79
  pointSize: gl.getUniformLocation(program, "pointSize"),
80
80
  }
81
81
 
82
+ // eslint-disable-next-line
82
83
  { // assign opacity
83
84
  this._lastOpacity = 1.0;
84
85
  this._lastPointSize = 2.0;
@@ -92,13 +93,13 @@ class PointOnGlobeProgram {
92
93
  gl.uniform1i(this.uniforms.hovered_vertexID, this._lastHoveredID);
93
94
  gl.useProgram(currentProgram);
94
95
  }
95
-
96
+ // eslint-disable-next-line
96
97
  { // assign attribute locations
97
98
  gl.bindAttribLocation(program, 0, "pos3D");
98
99
  gl.bindAttribLocation(program, 1, "pos2D");
99
100
  gl.bindAttribLocation(program, 2, "rgba");
100
101
  }
101
-
102
+ // eslint-disable-next-line
102
103
  { // arrange camera uniform block
103
104
  this.cameraBlockBingingPoint = 0;
104
105
  this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
@@ -112,17 +113,19 @@ class PointOnGlobeProgram {
112
113
  const { gl } = this;
113
114
  const vao = gl.createVertexArray();
114
115
  gl.bindVertexArray(vao);
115
-
116
+ // eslint-disable-next-line
116
117
  {
117
118
  gl.bindBuffer(gl.ARRAY_BUFFER, pos3DBuffer);
118
119
  gl.enableVertexAttribArray(0);
119
120
  gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
120
121
  }
122
+ // eslint-disable-next-line
121
123
  {
122
124
  gl.bindBuffer(gl.ARRAY_BUFFER, pos2DBuffer);
123
125
  gl.enableVertexAttribArray(1);
124
126
  gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
125
127
  }
128
+ // eslint-disable-next-line
126
129
  {
127
130
  gl.bindBuffer(gl.ARRAY_BUFFER, rgbaBuffer);
128
131
  gl.enableVertexAttribArray(2);
@@ -35,7 +35,7 @@ export class BufferManager {
35
35
 
36
36
  deleteBulk(offsets) {
37
37
  const { gl, buffer, itemSize } = this;
38
- const emptyBlock = new Float32Array(this.itemSize).fill(0)
38
+ const emptyBlock = new Float32Array(this.itemSize).fill(NaN)
39
39
  const offsetMultiplier = itemSize * 4;
40
40
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
41
41
  for (let offset of offsets) {