@pirireis/webglobeplugins 0.15.9-alpha → 0.15.11-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.15.9-alpha",
3
+ "version": "0.15.11-alpha",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -1,4 +1,4 @@
1
- import { BufferOrchestrator, BufferManager, ObjectStore } from "../util/account";
1
+ import { BufferOrchestrator, BufferManager, ObjectStore } from "../util/account/index";
2
2
  import { PickerDisplayer } from "../util/picking/picker-displayer";
3
3
  import { PointOnGlobeProgramCache } from "../programs/point-on-globe/square-pixel-point";
4
4
  import { wgs84ToCartesian3d, wgs84ToMercator } from "../Math/methods";
@@ -35,6 +35,9 @@ class PointTracksPlugin {
35
35
  hoveredPointSize: hoveredPointSize ? hoveredPointSize : 4
36
36
  };
37
37
  this._objectStoreExtraParameters = objectStoreExtraParameters;
38
+ this._objectStoreExtraParametersFiltered = objectStoreExtraParameters.filter(param => {
39
+ return !["long", "lat", "height", "ID", "trackID"].includes(param);
40
+ });
38
41
  }
39
42
  init(globe, gl) {
40
43
  this.globe = globe;
@@ -142,7 +145,7 @@ class PointTracksPlugin {
142
145
  */
143
146
  insertBulk(tracks) {
144
147
  this._fillTracksToPointsMap(tracks); // TODO error should be at the top
145
- const flattenedPoints = tracks.map(trackToFlatPoints).flat();
148
+ const flattenedPoints = tracks.map(trackToFlatPoints, this._objectStoreExtraParametersFiltered).flat();
146
149
  const currentLoad = this._bufferOrchestrator.length;
147
150
  if (currentLoad + flattenedPoints.length >= 2147483647) {
148
151
  throw new Error("Too many points, Point count cannot exceed 2147483647");
@@ -198,6 +201,23 @@ class PointTracksPlugin {
198
201
  }
199
202
  this.globe.DrawRender();
200
203
  }
204
+ updateTrackColor(trackID, rgba) {
205
+ if (!this._tracksToPointsMap.has(trackID)) {
206
+ console.warn(`Track with ID ${trackID} does not exist.`);
207
+ return;
208
+ }
209
+ const pointSet = this._tracksToPointsMap.get(trackID);
210
+ const points = Array.from(pointSet);
211
+ const { _bufferOrchestrator, _bufferManagersMap } = this;
212
+ _bufferOrchestrator.updateBulk(points.map((pointID) => {
213
+ return {
214
+ key: keyMethod(trackID, pointID),
215
+ rgba: new Float32Array(rgba)
216
+ };
217
+ }), _bufferManagersMap, ["rgba"]);
218
+ this._refillFocus();
219
+ this.globe?.DrawRender();
220
+ }
201
221
  // GLOBE API METHODS
202
222
  free() {
203
223
  if (this._isFreed)
@@ -250,7 +270,7 @@ class PointTracksPlugin {
250
270
  const trackID = track.trackID;
251
271
  const points = track.points;
252
272
  if (!this._tracksToPointsMap.has(trackID)) {
253
- this._tracksToPointsMap.set(trackID, new Set());
273
+ this._tracksToPointsMap.set(trackID, new Set()); // TODO: alternative to Set?
254
274
  }
255
275
  const pointSet = this._tracksToPointsMap.get(trackID);
256
276
  for (let p = 0; p < points.length; p++) {
@@ -315,7 +335,7 @@ class PointTracksPlugin {
315
335
  return true;
316
336
  }
317
337
  }
318
- const trackToFlatPoints = (track) => {
338
+ const trackToFlatPoints = (track, extraParameters) => {
319
339
  const trackID = track.trackID;
320
340
  const points = track.points;
321
341
  const rgba = new Float32Array(track.rgba);
@@ -330,6 +350,12 @@ const trackToFlatPoints = (track) => {
330
350
  rgba,
331
351
  trackID
332
352
  });
353
+ for (let i = 0; i < extraParameters.length; i++) {
354
+ const param = extraParameters[i];
355
+ if (point.hasOwnProperty(param)) {
356
+ flatPoints[flatPoints.length - 1][param] = point[param];
357
+ }
358
+ }
333
359
  }
334
360
  return flatPoints;
335
361
  };
@@ -287,7 +287,12 @@ export class ArcOnTerrainPlugin {
287
287
  });
288
288
  }
289
289
  // this._bufferOrchestrator.resetWithCapacity(bufferManagerMap, result.length);
290
- this._bufferOrchestrator.insertBulk(result, bufferManagerMap, ["position3d", "position2d"]);
290
+ const bufferNames = [];
291
+ if (this._options.globeViewOn)
292
+ bufferNames.push("position3d");
293
+ if (this._options.flatViewOn)
294
+ bufferNames.push("position2d");
295
+ this._bufferOrchestrator.insertBulk(result, bufferManagerMap, bufferNames);
291
296
  }
292
297
  _fillBufferManagerMap() {
293
298
  const { gl, globe } = this;