@pirireis/webglobeplugins 0.15.21-alpha → 0.15.24

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.
Files changed (33) hide show
  1. package/Math/arc.js +1 -2
  2. package/Math/circle-cdf-points.js +1 -170
  3. package/Math/circle.js +0 -25
  4. package/Math/vec3.js +1 -1
  5. package/altitude-locator/plugin.js +1 -1
  6. package/package.json +1 -1
  7. package/point-tracks/plugin.js +5 -6
  8. package/programs/line-on-globe/lines-color-instanced-flat.js +0 -1
  9. package/programs/point-on-globe/element-globe-surface-glow.js +0 -1
  10. package/programs/totems/camerauniformblock.js +7 -0
  11. package/programs/totems/canvas-webglobe-info.js +9 -9
  12. package/programs/totems/globe-changes.js +21 -14
  13. package/range-tools-on-terrain/bearing-line/plugin.js +2 -5
  14. package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +4 -9
  15. package/range-tools-on-terrain/circle-line-chain/plugin.js +4 -2
  16. package/range-tools-on-terrain/range-ring/adapters.js +25 -9
  17. package/range-tools-on-terrain/range-ring/plugin.js +200 -5
  18. package/range-tools-on-terrain/range-ring/types.js +9 -1
  19. package/semiplugins/lightweight/line-plugin.js +33 -15
  20. package/semiplugins/shape-on-terrain/arc-plugin.js +162 -99
  21. package/semiplugins/shape-on-terrain/circle-plugin.js +170 -83
  22. package/semiplugins/shape-on-terrain/padding-1-degree.js +244 -63
  23. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +1 -1
  24. package/util/build-strategy/static-dynamic.js +11 -1
  25. package/util/frame-counter-trigger.js +84 -0
  26. package/wind/imagetovectorfieldandmagnitude.js +23 -0
  27. package/wind/index.js +2 -2
  28. package/wind/plugin.js +30 -9
  29. package/write-text/context-text4.js +140 -0
  30. package/Math/arc-generate-points copy.js +0 -366
  31. package/Math/globe-util/horizon-plane.js +0 -112
  32. package/altitude-locator/draw-subset-obj.js +0 -16
  33. package/semiplugins/shape-on-terrain/derived/padding-plugin.js +0 -101
@@ -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
- vertexCount: 5,
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
- this.paddingPlugin = null; // TODO: initialize padding plugin if needed
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
- _build() {
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
  }
@@ -1 +1,9 @@
1
- export {};
1
+ export const ENUM_HIDE = Object.freeze({
2
+ SHOW: 0,
3
+ HIDE: 1,
4
+ HIDE_1_DEGREE_PADDINGS: 2
5
+ });
6
+ export const ENUM_TEXT_HIDE = Object.freeze({
7
+ SHOW: 0,
8
+ HIDE: 1
9
+ });
@@ -11,8 +11,8 @@ export class LinePlugin {
11
11
  vao = null;
12
12
  _options;
13
13
  _uboHandler = null;
14
- _bufferOrchestrator;
15
- _bufferManagersMap = new Map();
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._bufferOrchestrator = new BufferOrchestrator({ capacity: initialCapacity ?? 10 });
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._bufferManagersMap.get(key);
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 { _bufferOrchestrator, _bufferManagersMap, globe } = this;
58
- if (!_bufferOrchestrator || !globe) {
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
- _bufferOrchestrator.insertBulk(items, _bufferManagersMap);
76
+ bufferOrchestrator.insertBulk(items, bufferManagersMap);
62
77
  this.globe?.DrawRender();
63
78
  }
64
79
  deleteBulk(keys) {
65
- const { _bufferOrchestrator, _bufferManagersMap, globe } = this;
66
- if (!_bufferOrchestrator || !globe) {
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
- _bufferOrchestrator.deleteBulk(keys, _bufferManagersMap);
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 { _bufferOrchestrator, _options, _uboHandler, vao } = this;
111
- if (!_bufferOrchestrator || !_bufferOrchestrator || !_uboHandler) {
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: _bufferOrchestrator.length
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._bufferManagersMap.forEach((manager) => {
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._bufferManagersMap;
166
+ const m = this.bufferManagersMap;
149
167
  const initialCapacity = this._options.initialCapacity;
150
168
  if (flatViewOn) {
151
169
  m.set("start_position", {