@pirireis/webglobeplugins 0.15.22-alpha → 0.15.25
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 +1 -1
- package/point-tracks/plugin.js +4 -4
- package/programs/totems/canvas-webglobe-info.js +9 -9
- package/programs/totems/globe-changes.js +21 -14
- package/range-tools-on-terrain/bearing-line/plugin.js +2 -4
- package/range-tools-on-terrain/range-ring/adapters.js +25 -9
- package/range-tools-on-terrain/range-ring/plugin.js +200 -5
- package/range-tools-on-terrain/range-ring/types.js +9 -1
- package/semiplugins/lightweight/line-plugin.js +33 -15
- package/semiplugins/shape-on-terrain/arc-plugin.js +162 -99
- package/semiplugins/shape-on-terrain/circle-plugin.js +170 -83
- package/semiplugins/shape-on-terrain/padding-1-degree.js +180 -49
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +1 -1
- package/util/build-strategy/static-dynamic.js +11 -1
- package/util/frame-counter-trigger.js +84 -0
- package/wind/imagetovectorfieldandmagnitude.js +24 -0
- package/wind/index.js +2 -2
- package/wind/plugin.js +59 -25
- package/write-text/context-text4.js +140 -0
package/package.json
CHANGED
package/point-tracks/plugin.js
CHANGED
|
@@ -14,7 +14,7 @@ const _0vec3 = /* @__PURE__ */ [0, 0, 0];
|
|
|
14
14
|
* @typedef {Array<Point>, rgba, trackID} Track
|
|
15
15
|
*/
|
|
16
16
|
class PointTracksPlugin {
|
|
17
|
-
constructor(id, { pointSize = 2, hoveredPointSize = 4, selectionPointFilling = 4, opacity = 1.0, objectStoreExtraParameters = ["long", "lat", "height"], initialCapacity =
|
|
17
|
+
constructor(id, { pointSize = 2, hoveredPointSize = 4, selectionPointFilling = 4, opacity = 1.0, objectStoreExtraParameters = ["long", "lat", "height"], initialCapacity = 1000 } = {}) {
|
|
18
18
|
this.id = id;
|
|
19
19
|
this._isFreed = false;
|
|
20
20
|
this._pointProgram = null;
|
|
@@ -25,7 +25,7 @@ class PointTracksPlugin {
|
|
|
25
25
|
this._selectedID = -1;
|
|
26
26
|
this._selectedObj = null;
|
|
27
27
|
this._tracksToPointsMap = new Map(); // one to many
|
|
28
|
-
this._opacity = opacity;
|
|
28
|
+
this._opacity = opacity ? opacity : 1.0;
|
|
29
29
|
this.program = null;
|
|
30
30
|
this._lastWH = { w: 0, h: 0 };
|
|
31
31
|
this._focusParams = { on: false, length: 0, elementBuffer: null, trackIDs: [] };
|
|
@@ -34,11 +34,11 @@ class PointTracksPlugin {
|
|
|
34
34
|
selectionPointFilling: selectionPointFilling ? selectionPointFilling : 4,
|
|
35
35
|
hoveredPointSize: hoveredPointSize ? hoveredPointSize : 4
|
|
36
36
|
};
|
|
37
|
-
this._objectStoreExtraParameters = objectStoreExtraParameters;
|
|
37
|
+
this._objectStoreExtraParameters = objectStoreExtraParameters ? objectStoreExtraParameters : [];
|
|
38
38
|
this._objectStoreExtraParametersFiltered = objectStoreExtraParameters.filter(param => {
|
|
39
39
|
return !["long", "lat", "height", "ID", "trackID"].includes(param);
|
|
40
40
|
});
|
|
41
|
-
this._bufferOrchestrator = new BufferOrchestrator({ capacity: initialCapacity });
|
|
41
|
+
this._bufferOrchestrator = new BufferOrchestrator({ capacity: initialCapacity ? initialCapacity : 1000 });
|
|
42
42
|
}
|
|
43
43
|
init(globe, gl) {
|
|
44
44
|
this.globe = globe;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { globeProgramCache } from "../programcache";
|
|
2
|
-
export const WebGlobeInfoUniformBlockString = `
|
|
3
|
-
layout(std140) uniform WebGlobeInfo {
|
|
4
|
-
vec2 canvas_resolution;
|
|
5
|
-
vec2 mouse_radian_long_lat;
|
|
6
|
-
vec2 mouse_pixel_xy;
|
|
7
|
-
float north_angle;
|
|
8
|
-
float world_tilt;
|
|
9
|
-
float earth_distance;
|
|
10
|
-
};
|
|
2
|
+
export const WebGlobeInfoUniformBlockString = `
|
|
3
|
+
layout(std140) uniform WebGlobeInfo {
|
|
4
|
+
vec2 canvas_resolution;
|
|
5
|
+
vec2 mouse_radian_long_lat;
|
|
6
|
+
vec2 mouse_pixel_xy;
|
|
7
|
+
float north_angle;
|
|
8
|
+
float world_tilt;
|
|
9
|
+
float earth_distance;
|
|
10
|
+
};
|
|
11
11
|
`;
|
|
12
12
|
export default class CanvasWebGlobeInfo {
|
|
13
13
|
id;
|
|
@@ -12,11 +12,12 @@ export class GlobeChangeObserver {
|
|
|
12
12
|
};
|
|
13
13
|
lastElevationCoefficient = NaN;
|
|
14
14
|
changes = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
geometry: false,
|
|
16
|
+
look: false,
|
|
17
|
+
lod: false,
|
|
18
|
+
lod2DWheel: false,
|
|
19
|
+
elevationScale: false,
|
|
20
|
+
screenMoved: false
|
|
20
21
|
};
|
|
21
22
|
constructor(globe) {
|
|
22
23
|
this.globe = globe;
|
|
@@ -27,24 +28,30 @@ export class GlobeChangeObserver {
|
|
|
27
28
|
this.lastElevationCoefficient = globe.api_GetZScale();
|
|
28
29
|
}
|
|
29
30
|
checkChanges() {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
this.changes.
|
|
31
|
+
const globe = this.globe;
|
|
32
|
+
const currentGeometry = globe.api_GetCurrentGeometry();
|
|
33
|
+
const currentLook = globe.api_GetCurrentLookInfo();
|
|
34
|
+
const currentLOD = globe.api_GetCurrentLODWithDecimal();
|
|
35
|
+
const currentWorldWH = globe.api_GetCurrentWorldWH();
|
|
36
|
+
this.changes.geometry = (this.lastGeometry !== currentGeometry);
|
|
37
|
+
this.changes.look = (this.lastLook.CenterLong !== currentLook.CenterLong ||
|
|
36
38
|
this.lastLook.CenterLat !== currentLook.CenterLat ||
|
|
37
39
|
this.lastLook.Distance !== currentLook.Distance ||
|
|
38
40
|
this.lastLook.Tilt !== currentLook.Tilt ||
|
|
39
|
-
this.lastLook.NorthAng !== currentLook.NorthAng
|
|
40
|
-
|
|
41
|
-
this.changes.worldWHChanged = (this.lastWorldWH.width !== currentWorldWH.width ||
|
|
41
|
+
this.lastLook.NorthAng !== currentLook.NorthAng ||
|
|
42
|
+
this.lastWorldWH.width !== currentWorldWH.width ||
|
|
42
43
|
this.lastWorldWH.height !== currentWorldWH.height);
|
|
44
|
+
this.changes.lod = (this.lastLOD !== currentLOD);
|
|
45
|
+
this.changes.lod2DWheel = (!globe.api_IsScreenMoving() && this.changes.lod);
|
|
43
46
|
// Update last known states
|
|
44
47
|
this.lastGeometry = currentGeometry;
|
|
45
48
|
this.lastLook = currentLook;
|
|
46
49
|
this.lastLOD = currentLOD;
|
|
47
50
|
this.lastWorldWH = currentWorldWH;
|
|
51
|
+
this.changes.screenMoved = (this.changes.geometry ||
|
|
52
|
+
this.changes.look ||
|
|
53
|
+
this.changes.lod ||
|
|
54
|
+
this.changes.lod2DWheel);
|
|
48
55
|
}
|
|
49
56
|
getChanges() {
|
|
50
57
|
return this.changes;
|
|
@@ -435,10 +435,8 @@ export class BearingLinePlugin {
|
|
|
435
435
|
this.linePlugin.draw3D();
|
|
436
436
|
this.linePluginBL.draw3D();
|
|
437
437
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
textWriter.draw();
|
|
441
|
-
}
|
|
438
|
+
for (const textWriter of this._textWritersMap.values()) {
|
|
439
|
+
textWriter.draw();
|
|
442
440
|
}
|
|
443
441
|
}
|
|
444
442
|
free() {
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
// altitude: rangeRing.altitude,
|
|
8
8
|
// };
|
|
9
9
|
// }
|
|
10
|
-
const keyAdapter = (centerID, rangeID) => {
|
|
10
|
+
export const keyAdapter = (centerID, rangeID) => {
|
|
11
11
|
return `${centerID}-${rangeID}`;
|
|
12
12
|
};
|
|
13
|
-
export const
|
|
13
|
+
export const allCircleKeysAdapter = (rangeRing) => {
|
|
14
14
|
const result = new Array(rangeRing.rings.length);
|
|
15
15
|
for (let i = 0; i < rangeRing.rings.length; i++) {
|
|
16
16
|
result[i] = keyAdapter(rangeRing.centerID, rangeRing.rings[i].ringID);
|
|
@@ -56,20 +56,36 @@ export const rangeRingToArcInputAdapter = (globe, rangeRingInput) => {
|
|
|
56
56
|
}
|
|
57
57
|
return result;
|
|
58
58
|
};
|
|
59
|
+
export function createColorRatios(color, stepAngle, colorFade = 0.4) {
|
|
60
|
+
const angleCount = Math.ceil(360 / stepAngle) * 2;
|
|
61
|
+
let angleLeft = 360;
|
|
62
|
+
const result = new Array(angleCount);
|
|
63
|
+
for (let i = 0; i < angleCount; i++) {
|
|
64
|
+
const currentAngle = Math.min(stepAngle, angleLeft);
|
|
65
|
+
angleLeft -= currentAngle;
|
|
66
|
+
result[i * 2] = {
|
|
67
|
+
color: [0, 0, 0, 0],
|
|
68
|
+
ratio: 1,
|
|
69
|
+
};
|
|
70
|
+
const colorRatio = {
|
|
71
|
+
// color: i % 2 === 0 ? color : [color[0] * colorFade, color[1] * colorFade, color[2] * colorFade, color[3]] as Color,
|
|
72
|
+
color: i % 2 === 0 ? color : [1 - color[0] * colorFade, 1 - color[1] * colorFade, 1 - color[2] * colorFade, color[3]],
|
|
73
|
+
ratio: currentAngle - 1
|
|
74
|
+
};
|
|
75
|
+
result[i * 2 + 1] = colorRatio;
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
59
79
|
export const padding1DegreeInputAdapter = (bearingLine) => {
|
|
60
|
-
const { long, lat, rgba, altitude = 0, rings } = bearingLine;
|
|
80
|
+
const { long, lat, rgba, altitude = 0, rings, stepAngle } = bearingLine;
|
|
61
81
|
const result = new Array(rings.length);
|
|
62
82
|
for (let i = 0; i < rings.length; i++) {
|
|
63
83
|
const ring = rings[i];
|
|
64
84
|
result[i] = {
|
|
65
85
|
key: keyAdapter(bearingLine.centerID, ring.ringID),
|
|
66
86
|
center: [long, lat],
|
|
67
|
-
|
|
68
|
-
colorsRatios:
|
|
69
|
-
color: rgba,
|
|
70
|
-
ratio: 360,
|
|
71
|
-
}
|
|
72
|
-
],
|
|
87
|
+
radius: ring.radius,
|
|
88
|
+
colorsRatios: createColorRatios(rgba, stepAngle, 0.5),
|
|
73
89
|
heightFromGroundIn3D: altitude,
|
|
74
90
|
};
|
|
75
91
|
}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { CircleOnTerrainPlugin } from "../../semiplugins/shape-on-terrain/circle-plugin";
|
|
2
2
|
import { ArcOnTerrainPlugin } from "../../semiplugins/shape-on-terrain/arc-plugin";
|
|
3
|
+
import { Padding1DegreePlugin } from '../../semiplugins/shape-on-terrain/padding-1-degree';
|
|
4
|
+
import { padding1DegreeInputAdapter, rangeRingToArcInputAdapter, rangeRingToCircleInputAdapter, allCircleKeysAdapter, allArcKeysAdapter, createColorRatios } from "./adapters";
|
|
5
|
+
export var ENUM_HIDE;
|
|
6
|
+
(function (ENUM_HIDE) {
|
|
7
|
+
ENUM_HIDE[ENUM_HIDE["SHOW"] = 0] = "SHOW";
|
|
8
|
+
ENUM_HIDE[ENUM_HIDE["HIDE"] = 1] = "HIDE";
|
|
9
|
+
ENUM_HIDE[ENUM_HIDE["HIDE_1_DEGREE_PADDINGS"] = 2] = "HIDE_1_DEGREE_PADDINGS";
|
|
10
|
+
})(ENUM_HIDE || (ENUM_HIDE = {}));
|
|
11
|
+
export var ENUM_TEXT_HIDE;
|
|
12
|
+
(function (ENUM_TEXT_HIDE) {
|
|
13
|
+
ENUM_TEXT_HIDE[ENUM_TEXT_HIDE["SHOW"] = 0] = "SHOW";
|
|
14
|
+
ENUM_TEXT_HIDE[ENUM_TEXT_HIDE["HIDE"] = 1] = "HIDE";
|
|
15
|
+
})(ENUM_TEXT_HIDE || (ENUM_TEXT_HIDE = {}));
|
|
3
16
|
// @ts-ignore
|
|
4
17
|
export class RangeRingPlugin {
|
|
5
18
|
id;
|
|
@@ -9,6 +22,8 @@ export class RangeRingPlugin {
|
|
|
9
22
|
arcPlugin;
|
|
10
23
|
paddingPlugin = null; // TODO: implement padding plugin
|
|
11
24
|
_memory = new Map();
|
|
25
|
+
_freed = false;
|
|
26
|
+
textWritersMap = new Map();
|
|
12
27
|
_semiPluginOptions = {
|
|
13
28
|
circleOnTerrainOptions: {
|
|
14
29
|
variativeColorsOn: false,
|
|
@@ -30,22 +45,202 @@ export class RangeRingPlugin {
|
|
|
30
45
|
defaultHeightFromGroundIn3D: 0,
|
|
31
46
|
},
|
|
32
47
|
};
|
|
33
|
-
constructor(id) {
|
|
48
|
+
constructor(id, { textDataPreAdaptor = (center) => center, textWritersMap = new Map(), }) {
|
|
34
49
|
this.id = id;
|
|
35
|
-
this.circlePlugin = new CircleOnTerrainPlugin(this.id + "-circle"
|
|
50
|
+
this.circlePlugin = new CircleOnTerrainPlugin(this.id + "-circle", {
|
|
51
|
+
variativeColorsOn: true,
|
|
52
|
+
});
|
|
36
53
|
this.arcPlugin = new ArcOnTerrainPlugin(this.id + "-arc", {
|
|
37
|
-
|
|
54
|
+
variativeColorsOn: true,
|
|
55
|
+
vertexCount: 20,
|
|
56
|
+
});
|
|
57
|
+
this.paddingPlugin = new Padding1DegreePlugin(this.id + "-padding", {
|
|
58
|
+
variativeColorsOn: true,
|
|
59
|
+
defaultColor: [1, 1, 1, 1],
|
|
60
|
+
defaultHeightFromGroundIn3D: 0,
|
|
38
61
|
});
|
|
39
|
-
|
|
62
|
+
if (textWritersMap) {
|
|
63
|
+
this.textWritersMap = textWritersMap;
|
|
64
|
+
}
|
|
40
65
|
}
|
|
41
66
|
insertBulk(items) {
|
|
67
|
+
if (this._freed) {
|
|
68
|
+
console.warn("Plugin is freed, cannot insert items");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (this.globe === null || this.gl === null) {
|
|
72
|
+
console.warn("Globe or WebGL context is not initialized, cannot insert items");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const visableItems = items.filter(item => item.hide !== ENUM_HIDE.HIDE);
|
|
76
|
+
if (this.paddingPlugin) {
|
|
77
|
+
const paddingInputs = visableItems.map(item => padding1DegreeInputAdapter(item)).flat();
|
|
78
|
+
this.paddingPlugin.insertBulk(paddingInputs);
|
|
79
|
+
}
|
|
80
|
+
const circleInputs = visableItems.filter(item => item.hide === ENUM_HIDE.SHOW).map(rangeRingToCircleInputAdapter).flat();
|
|
81
|
+
this.circlePlugin.insertBulk(circleInputs);
|
|
82
|
+
const arcInputs = visableItems.map((item) => rangeRingToArcInputAdapter(this.globe, item)).flat();
|
|
83
|
+
this.arcPlugin.insertBulk(arcInputs);
|
|
84
|
+
for (const item of items) {
|
|
85
|
+
this._memory.set(item.centerID, item);
|
|
86
|
+
if (item.hide !== ENUM_HIDE.HIDE && item.textHide === ENUM_HIDE.SHOW) {
|
|
87
|
+
this.updateText([item.centerID]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
removeCenters(centers) {
|
|
92
|
+
if (this._freed) {
|
|
93
|
+
console.warn("Plugin is freed, cannot remove centers");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (this.globe === null || this.gl === null) {
|
|
97
|
+
console.warn("Globe or WebGL context is not initialized, cannot remove centers");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (let i = 0; i < centers.length; i++) {
|
|
101
|
+
const rangeRingInput = this._memory.get(centers[i]);
|
|
102
|
+
if (!rangeRingInput) {
|
|
103
|
+
console.warn(`No data found for centerID: ${centers[i]}`);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const circleKeys = allCircleKeysAdapter(rangeRingInput);
|
|
107
|
+
this.circlePlugin.deleteBulk(circleKeys);
|
|
108
|
+
this.paddingPlugin?.deleteBulk(circleKeys);
|
|
109
|
+
const allArcKeys = allArcKeysAdapter(rangeRingInput);
|
|
110
|
+
this.arcPlugin.deleteBulk(allArcKeys);
|
|
111
|
+
this._memory.delete(centers[i]);
|
|
112
|
+
}
|
|
113
|
+
this.globe.DrawRender();
|
|
114
|
+
}
|
|
115
|
+
updateCenters() {
|
|
42
116
|
}
|
|
43
|
-
|
|
117
|
+
updateCentersCoordinate(items) {
|
|
118
|
+
if (this._freed) {
|
|
119
|
+
console.warn("Plugin is freed, cannot update centers coordinates");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (this.globe === null || this.gl === null) {
|
|
123
|
+
console.warn("Globe or WebGL context is not initialized, cannot update centers coordinates");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const globe = this.globe;
|
|
127
|
+
for (const item of items) {
|
|
128
|
+
const { centerID, long, lat } = item;
|
|
129
|
+
const rangeRingInput = this._memory.get(centerID);
|
|
130
|
+
if (rangeRingInput) {
|
|
131
|
+
rangeRingInput.long = long;
|
|
132
|
+
rangeRingInput.lat = lat;
|
|
133
|
+
const arcData = rangeRingToArcInputAdapter(globe, rangeRingInput);
|
|
134
|
+
this.arcPlugin.updateCoordinates(arcData);
|
|
135
|
+
const circleData = rangeRingToCircleInputAdapter(rangeRingInput);
|
|
136
|
+
this.circlePlugin.updateCoordinates(circleData);
|
|
137
|
+
this.paddingPlugin?.updateCoordinates(circleData);
|
|
138
|
+
this.updateText([centerID]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
updateCentersColor(items) {
|
|
143
|
+
if (this._freed) {
|
|
144
|
+
console.warn("Plugin is freed, cannot update centers color");
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (this.globe === null || this.gl === null) {
|
|
148
|
+
console.warn("Globe or WebGL context is not initialized, cannot update centers color");
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// update Colors from memory map
|
|
152
|
+
for (let item of items) {
|
|
153
|
+
const data = this._memory.get(item.centerID);
|
|
154
|
+
if (!data) {
|
|
155
|
+
console.warn(`No data found for centerID: ${item.centerID}`);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
data.rgba = item.rgba;
|
|
159
|
+
// update arc Colors
|
|
160
|
+
const arcColors = allArcKeysAdapter(data).map(key => ({ key, color: data.rgba }));
|
|
161
|
+
this.arcPlugin.updateColors(arcColors, false);
|
|
162
|
+
const circleColors = allCircleKeysAdapter(data).map(key => ({ key, color: data.rgba }));
|
|
163
|
+
this.circlePlugin.updateColors(circleColors);
|
|
164
|
+
if (this.paddingPlugin) {
|
|
165
|
+
const colorRatios = createColorRatios(data.rgba, data.stepAngle, 0.5);
|
|
166
|
+
for (const { key } of circleColors) {
|
|
167
|
+
this.paddingPlugin?.updateColorRatios(key, colorRatios, false);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
this.updateText([item.centerID]);
|
|
171
|
+
}
|
|
172
|
+
this.globe.DrawRender();
|
|
173
|
+
}
|
|
174
|
+
updateCentersHide() {
|
|
44
175
|
}
|
|
45
176
|
init(globe, gl) {
|
|
46
177
|
this.globe = globe;
|
|
47
178
|
this.gl = gl;
|
|
179
|
+
this.circlePlugin.init(globe, gl);
|
|
180
|
+
this.arcPlugin.init(globe, gl);
|
|
181
|
+
this.paddingPlugin?.init(globe, gl);
|
|
48
182
|
}
|
|
49
183
|
draw3D() {
|
|
184
|
+
if (this._freed) {
|
|
185
|
+
console.warn("RangeRing Plugin is freed, cannot draw");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
this.arcPlugin.draw3D();
|
|
189
|
+
this.paddingPlugin?.draw3D();
|
|
190
|
+
this.circlePlugin.draw3D();
|
|
191
|
+
for (const [key, writer] of this.textWritersMap) {
|
|
192
|
+
writer.draw();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
free() {
|
|
196
|
+
if (this._freed) {
|
|
197
|
+
console.warn("RangeRing Plugin is already freed");
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
this._freed = true;
|
|
201
|
+
this.circlePlugin.free();
|
|
202
|
+
this.arcPlugin.free();
|
|
203
|
+
this.paddingPlugin?.free();
|
|
204
|
+
}
|
|
205
|
+
updateText(centerIDs = null) {
|
|
206
|
+
if (this._freed) {
|
|
207
|
+
console.warn("Plugin is freed, cannot update text");
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (this.globe === null || this.gl === null) {
|
|
211
|
+
console.warn("Globe or WebGL context is not initialized, cannot update text");
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const globe = this.globe;
|
|
215
|
+
const textWritersMap = this.textWritersMap;
|
|
216
|
+
let keys = centerIDs ?? this._memory.keys();
|
|
217
|
+
for (const centerID of keys) {
|
|
218
|
+
const rangeRingData = this._memory.get(centerID);
|
|
219
|
+
if (!rangeRingData)
|
|
220
|
+
continue;
|
|
221
|
+
for (const [key, writer] of textWritersMap) {
|
|
222
|
+
writer.insertText(rangeRingData);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
deleteText(centerIDs) {
|
|
227
|
+
if (this._freed) {
|
|
228
|
+
console.warn("Plugin is freed, cannot delete text");
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (this.globe === null || this.gl === null) {
|
|
232
|
+
console.warn("Globe or WebGL context is not initialized, cannot delete text");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const globe = this.globe;
|
|
236
|
+
const textWritersMap = this.textWritersMap;
|
|
237
|
+
for (const centerID of centerIDs) {
|
|
238
|
+
const rangeRingData = this._memory.get(centerID);
|
|
239
|
+
if (!rangeRingData)
|
|
240
|
+
continue;
|
|
241
|
+
for (const [key, writer] of textWritersMap) {
|
|
242
|
+
writer.deleteText(rangeRingData);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
50
245
|
}
|
|
51
246
|
}
|
|
@@ -11,8 +11,8 @@ export class LinePlugin {
|
|
|
11
11
|
vao = null;
|
|
12
12
|
_options;
|
|
13
13
|
_uboHandler = null;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
bufferOrchestrator;
|
|
15
|
+
bufferManagersMap = new Map();
|
|
16
16
|
_freed = false;
|
|
17
17
|
constructor(id, { flatViewOn = true, globeViewOn = true, variativeColorsOn = false, defaultColor = [1, 1, 1, 1], dashedLineOpacityVariativeOn = false, dashedLineRatioVariativeOn = false, bufferType = "DYNAMIC_DRAW", opacity = 1.0, initialCapacity = 10 } = {}) {
|
|
18
18
|
this.id = id;
|
|
@@ -27,7 +27,7 @@ export class LinePlugin {
|
|
|
27
27
|
opacity: opacity ?? 1.0,
|
|
28
28
|
initialCapacity: initialCapacity ?? 10
|
|
29
29
|
};
|
|
30
|
-
this.
|
|
30
|
+
this.bufferOrchestrator = new BufferOrchestrator({ capacity: initialCapacity ?? 10 });
|
|
31
31
|
}
|
|
32
32
|
init(globe, gl) {
|
|
33
33
|
this.globe = globe;
|
|
@@ -40,7 +40,7 @@ export class LinePlugin {
|
|
|
40
40
|
if (key === null) {
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
|
-
const bufferManagerComp = this.
|
|
43
|
+
const bufferManagerComp = this.bufferManagersMap.get(key);
|
|
44
44
|
if (bufferManagerComp === undefined) {
|
|
45
45
|
throw new Error(`Buffer key ${key} does not exist in bufferManagersMap`);
|
|
46
46
|
}
|
|
@@ -53,20 +53,35 @@ export class LinePlugin {
|
|
|
53
53
|
}));
|
|
54
54
|
}
|
|
55
55
|
// PLUGIN INTERFACE METHODS
|
|
56
|
+
increaseSpace(amount) {
|
|
57
|
+
if (this._freed) {
|
|
58
|
+
console.warn("Plugin is freed, cannot increase space");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (this.globe === null) {
|
|
62
|
+
console.warn("Globe is not initialized.");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (typeof amount !== "number" || amount <= 0) {
|
|
66
|
+
console.warn("Invalid amount, must be a positive number");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.bufferOrchestrator.ensureSpace(amount, this.bufferManagersMap);
|
|
70
|
+
}
|
|
56
71
|
insertBulk(items) {
|
|
57
|
-
const {
|
|
58
|
-
if (!
|
|
72
|
+
const { bufferOrchestrator, bufferManagersMap, globe } = this;
|
|
73
|
+
if (!bufferOrchestrator || !globe) {
|
|
59
74
|
throw new Error("Buffer orchestrator or globe is not initialized.");
|
|
60
75
|
}
|
|
61
|
-
|
|
76
|
+
bufferOrchestrator.insertBulk(items, bufferManagersMap);
|
|
62
77
|
this.globe?.DrawRender();
|
|
63
78
|
}
|
|
64
79
|
deleteBulk(keys) {
|
|
65
|
-
const {
|
|
66
|
-
if (!
|
|
80
|
+
const { bufferOrchestrator, bufferManagersMap, globe } = this;
|
|
81
|
+
if (!bufferOrchestrator || !globe) {
|
|
67
82
|
throw new Error("Buffer orchestrator or globe is not initialized.");
|
|
68
83
|
}
|
|
69
|
-
|
|
84
|
+
bufferOrchestrator.deleteBulk(keys, bufferManagersMap);
|
|
70
85
|
this.globe?.DrawRender();
|
|
71
86
|
}
|
|
72
87
|
setPluginOpacity(opacity, drawRender = false) {
|
|
@@ -98,6 +113,9 @@ export class LinePlugin {
|
|
|
98
113
|
this.globe.DrawRender();
|
|
99
114
|
}
|
|
100
115
|
}
|
|
116
|
+
updateCoordinates(items) {
|
|
117
|
+
throw new Error("Method not implemented.");
|
|
118
|
+
}
|
|
101
119
|
// GLOBE INTERACTION METHODS
|
|
102
120
|
draw3D() {
|
|
103
121
|
if (this._freed) {
|
|
@@ -107,15 +125,15 @@ export class LinePlugin {
|
|
|
107
125
|
if (!this.globe || !this.gl || !this.program || !this.vao) {
|
|
108
126
|
throw new Error("Globe, GL context or program is not initialized.");
|
|
109
127
|
}
|
|
110
|
-
const {
|
|
111
|
-
if (!
|
|
128
|
+
const { bufferOrchestrator, _options, _uboHandler, vao } = this;
|
|
129
|
+
if (!bufferOrchestrator || !bufferOrchestrator || !_uboHandler) {
|
|
112
130
|
throw new Error("Buffer orchestrator is not initialized.");
|
|
113
131
|
}
|
|
114
132
|
const { flatViewOn, globeViewOn, opacity } = _options;
|
|
115
133
|
const drawOptions = {
|
|
116
134
|
drawRange: {
|
|
117
135
|
first: 0,
|
|
118
|
-
count:
|
|
136
|
+
count: bufferOrchestrator.length
|
|
119
137
|
}
|
|
120
138
|
};
|
|
121
139
|
this.gl.disable(this.gl.DEPTH_TEST); // Disable depth test for lines
|
|
@@ -134,7 +152,7 @@ export class LinePlugin {
|
|
|
134
152
|
if (this._freed)
|
|
135
153
|
return;
|
|
136
154
|
// TODO: FILL
|
|
137
|
-
this.
|
|
155
|
+
this.bufferManagersMap.forEach((manager) => {
|
|
138
156
|
manager.bufferManager.free();
|
|
139
157
|
});
|
|
140
158
|
this._uboHandler?.free();
|
|
@@ -145,7 +163,7 @@ export class LinePlugin {
|
|
|
145
163
|
_fillManagerMap() {
|
|
146
164
|
const globe = this.globe;
|
|
147
165
|
const { flatViewOn, globeViewOn, variativeColorsOn, dashedLineOpacityVariativeOn, dashedLineRatioVariativeOn, bufferType = "DYNAMIC_DRAW" } = this._options;
|
|
148
|
-
const m = this.
|
|
166
|
+
const m = this.bufferManagersMap;
|
|
149
167
|
const initialCapacity = this._options.initialCapacity;
|
|
150
168
|
if (flatViewOn) {
|
|
151
169
|
m.set("start_position", {
|