@pirireis/webglobeplugins 0.15.10-alpha → 0.15.12-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
package/point-tracks/plugin.js
CHANGED
|
@@ -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
|
};
|
|
@@ -98,6 +98,30 @@ export class BearingLinePlugin {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
+
setDefaultSemiPluginColor(semiPluginName, color) {
|
|
102
|
+
if (this._freed) {
|
|
103
|
+
throw new Error("Plugin has been freed, cannot set default semi plugin color.");
|
|
104
|
+
}
|
|
105
|
+
if (!this.globe) {
|
|
106
|
+
throw new Error("Globe is not set, cannot set default semi plugin color.");
|
|
107
|
+
}
|
|
108
|
+
switch (semiPluginName) {
|
|
109
|
+
case "circleOnTerrain":
|
|
110
|
+
this.circlePlugin.setDefaultColor(color);
|
|
111
|
+
break;
|
|
112
|
+
case "arcOnTerrain":
|
|
113
|
+
this.arcPlugin.setDefaultColor(color);
|
|
114
|
+
break;
|
|
115
|
+
case "line":
|
|
116
|
+
this.linePlugin.setDefaultColor(color);
|
|
117
|
+
break;
|
|
118
|
+
case "pieceOfPie":
|
|
119
|
+
this.pieceOfPiePlugin.setDefaultColor(color);
|
|
120
|
+
break;
|
|
121
|
+
default:
|
|
122
|
+
throw new Error(`Unknown semi plugin name: ${semiPluginName}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
101
125
|
setDoDrawVRM(drawVRM) {
|
|
102
126
|
if (this._freed) {
|
|
103
127
|
throw new Error("Plugin has been freed, cannot set draw VRM.");
|
|
@@ -47,6 +47,17 @@ export class PieceOfPiePlugin {
|
|
|
47
47
|
this.drawMode = drawMode;
|
|
48
48
|
this.globe?.DrawRender();
|
|
49
49
|
}
|
|
50
|
+
setDefaultColor(color) {
|
|
51
|
+
if (this._isFreed) {
|
|
52
|
+
console.warn("PieceOfPiePlugin is freed, cannot set default color.");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!Array.isArray(color) || color.length !== 4) {
|
|
56
|
+
throw new Error("Color must be an array of 4 numbers [R, G, B, A].");
|
|
57
|
+
}
|
|
58
|
+
this._uboHandler?.updateSingle("u_color", new Float32Array(color));
|
|
59
|
+
this.globe?.DrawRender();
|
|
60
|
+
}
|
|
50
61
|
_createBufferManagersMap() {
|
|
51
62
|
const { gl, globe, _pluginOptions } = this;
|
|
52
63
|
const { bufferType, initialCapacity } = _pluginOptions;
|