@pirireis/webglobeplugins 0.13.0-alpha → 0.15.0-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.
Files changed (55) hide show
  1. package/Math/arc-cdf-points.js +20 -0
  2. package/Math/arc-generate-points copy.js +1 -0
  3. package/Math/arc.js +21 -8
  4. package/Math/circle.js +35 -16
  5. package/Math/templete-shapes/grid-visually-equal.js +66 -0
  6. package/altitude-locator/plugin.js +3 -2
  7. package/bearing-line/plugin.js +1 -2
  8. package/circle-line-chain/plugin.js +4 -7
  9. package/compass-rose/compass-rose-padding-flat.js +12 -0
  10. package/package.json +1 -1
  11. package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
  12. package/programs/line-on-globe/linestrip/linestrip.js +6 -4
  13. package/programs/line-on-globe/naive-accurate-flexible.js +23 -16
  14. package/programs/picking/pickable-renderer.js +1 -2
  15. package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
  16. package/programs/rings/partial-ring/piece-of-pie.js +26 -13
  17. package/programs/totems/camerauniformblock.js +1 -1
  18. package/programs/totems/index.js +1 -1
  19. package/range-tools-on-terrain/bearing-line/adapters.js +111 -0
  20. package/range-tools-on-terrain/bearing-line/plugin.js +360 -0
  21. package/range-tools-on-terrain/circle-line-chain/adapters.js +83 -0
  22. package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +351 -0
  23. package/range-tools-on-terrain/circle-line-chain/plugin.js +388 -0
  24. package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
  25. package/range-tools-on-terrain/range-ring/adapters.js +25 -0
  26. package/range-tools-on-terrain/range-ring/plugin.js +31 -0
  27. package/range-tools-on-terrain/range-ring/types.js +1 -0
  28. package/rangerings/plugin.js +7 -11
  29. package/semiplugins/lightweight/line-plugin.js +195 -0
  30. package/semiplugins/lightweight/piece-of-pie-plugin.js +175 -0
  31. package/semiplugins/shape-on-terrain/arc-plugin.js +368 -0
  32. package/{shape-on-terrain/circle/plugin.js → semiplugins/shape-on-terrain/circle-plugin.js} +67 -38
  33. package/semiplugins/shape-on-terrain/derived/padding-plugin.js +101 -0
  34. package/semiplugins/shape-on-terrain/one-degree-padding.js +85 -0
  35. package/semiplugins/type.js +1 -0
  36. package/types.js +0 -11
  37. package/util/account/create-buffermap-orchastration.js +39 -0
  38. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -3
  39. package/util/check/typecheck.js +15 -1
  40. package/util/geometry/index.js +3 -2
  41. package/util/gl-util/buffer/attribute-loader.js +2 -5
  42. package/util/gl-util/draw-options/methods.js +4 -5
  43. package/util/webglobjectbuilders.js +5 -10
  44. package/write-text/context-text3.js +17 -0
  45. package/write-text/context-text3old.js +152 -0
  46. package/programs/line-on-globe/circle-accurate.js +0 -176
  47. package/programs/line-on-globe/circle.js +0 -166
  48. package/programs/line-on-globe/to-the-surface.js +0 -111
  49. package/programs/totems/canvas-webglobe-info1.js +0 -106
  50. package/shape-on-terrain/arc/naive/plugin.js +0 -250
  51. package/util/check/get.js +0 -14
  52. package/util/gl-util/draw-options/types.js +0 -15
  53. package/util/webglobjectbuilders1.js +0 -219
  54. /package/{util/gl-util/buffer/types.js → programs/line-on-globe/paddings/paddings.js} +0 -0
  55. /package/{shape-on-terrain/type.js → range-tools-on-terrain/bearing-line/types.js} +0 -0
@@ -0,0 +1,388 @@
1
+ import { CircleOnTerrainPlugin } from "../../semiplugins/shape-on-terrain/circle-plugin";
2
+ import { LinePlugin } from "../../semiplugins/lightweight/line-plugin";
3
+ import { ArcOnTerrainPlugin } from "../../semiplugins/shape-on-terrain/arc-plugin";
4
+ import { keyMethod, lineDataAdaptor, arcDataAdaptor, circleDataAdaptor, getOpacity } from "./adapters";
5
+ import { ContextTextWriter3 } from "../../write-text/context-text3";
6
+ import { ChainListMap } from "./chain-list-map";
7
+ import { mapGetOrThrow } from "../../util/check/typecheck";
8
+ const textWriterGetOrThrow = mapGetOrThrow("textWriterIDs is invalid");
9
+ export class CircleLineChainPlugin {
10
+ id;
11
+ globe = null;
12
+ gl = null;
13
+ circlePlugin = null;
14
+ linePlugin = null;
15
+ arcPlugin = null;
16
+ _freed = false;
17
+ _opacities;
18
+ _drawCircleOn = true;
19
+ _textWritersMap;
20
+ _textDataPreAdaptor = undefined;
21
+ _chainListMap;
22
+ _arcAdaptor = arcDataAdaptor;
23
+ _lineAdaptor = lineDataAdaptor;
24
+ _circleAdaptor = circleDataAdaptor;
25
+ _semiPluginOptions = {
26
+ circleOnTerrainOptions: {
27
+ variativeColorsOn: false,
28
+ defaultColor: [1, 1, 1, 1],
29
+ defaultHeightFromGroundIn3D: 30,
30
+ },
31
+ arcOnTerrainOptions: {
32
+ flatViewOn: true,
33
+ globeViewOn: true,
34
+ variativeColorsOn: false,
35
+ defaultColor: [1, 1, 1, 1],
36
+ defaultHeightFromGroundIn3D: 0,
37
+ vertexCount: 32,
38
+ cameraAttractionIsOn: true // If true, camera attraction is enabled else evenly distributed arc points are used
39
+ },
40
+ lineOptions: {
41
+ flatViewOn: true,
42
+ globeViewOn: true,
43
+ variativeColorsOn: false,
44
+ defaultColor: [1, 1, 1, 1],
45
+ dashedLineOpacityVariativeOn: false,
46
+ dashedLineRatioVariativeOn: false,
47
+ bufferType: "DYNAMIC_DRAW",
48
+ opacity: 1.0
49
+ }
50
+ };
51
+ constructor(id, { drawCircleOn, textWritersMap, textDataPreAdaptor, opacities, lineAdaptor, arcAdaptor, circleAdaptor, arcOnTerrainOptions, circleOnTerrainOptions, lineOptions } = {}) {
52
+ const defaults = {
53
+ drawCircleOn: true,
54
+ textWritersMap: new Map(),
55
+ textDataPreAdaptor: undefined,
56
+ lineAdaptor: lineDataAdaptor,
57
+ arcAdaptor: arcDataAdaptor,
58
+ circleAdaptor: circleDataAdaptor,
59
+ opacities: {
60
+ general: 1,
61
+ circle: null,
62
+ flatStraightLine: null,
63
+ flatGreatCircle: null,
64
+ globeArcFitsTerrain: null,
65
+ globeArcNotFitsTerrain: null
66
+ }
67
+ };
68
+ const finalOpacities = { ...defaults.opacities, ...opacities };
69
+ const config = {
70
+ ...defaults,
71
+ drawCircleOn: drawCircleOn ?? defaults.drawCircleOn,
72
+ textWritersMap: textWritersMap ?? defaults.textWritersMap,
73
+ textDataPreAdaptor: textDataPreAdaptor ?? defaults.textDataPreAdaptor,
74
+ lineAdaptor: lineAdaptor ?? defaults.lineAdaptor,
75
+ arcAdaptor: arcAdaptor ?? defaults.arcAdaptor,
76
+ circleAdaptor: circleAdaptor ?? defaults.circleAdaptor,
77
+ opacities: finalOpacities
78
+ };
79
+ this._semiPluginOptions.circleOnTerrainOptions = {
80
+ ...this._semiPluginOptions.circleOnTerrainOptions,
81
+ ...circleOnTerrainOptions
82
+ };
83
+ this._semiPluginOptions.arcOnTerrainOptions = {
84
+ ...this._semiPluginOptions.arcOnTerrainOptions,
85
+ ...arcOnTerrainOptions
86
+ };
87
+ this._semiPluginOptions.lineOptions = {
88
+ ...this._semiPluginOptions.lineOptions,
89
+ ...lineOptions
90
+ };
91
+ this.id = id;
92
+ this._drawCircleOn = config.drawCircleOn;
93
+ this._textWritersMap = config.textWritersMap;
94
+ this._textDataPreAdaptor = config.textDataPreAdaptor;
95
+ this._chainListMap = new ChainListMap(keyMethod);
96
+ this._arcAdaptor = config.arcAdaptor;
97
+ this._lineAdaptor = config.lineAdaptor;
98
+ this._circleAdaptor = config.circleAdaptor;
99
+ this._opacities = config.opacities;
100
+ this._checktextWritersMap(this._textWritersMap);
101
+ this._textWritersMap.forEach((writer) => {
102
+ writer.setKeyAdaptor((v) => v.__identity__);
103
+ });
104
+ }
105
+ // API
106
+ insertBulk(chains, { textWriterIDs = [] } = {}) {
107
+ if (this._freed) {
108
+ console.warn("CircleLineChainPlugin is freed, cannot insert bulk.");
109
+ return;
110
+ }
111
+ if (chains.length === 0)
112
+ return;
113
+ const chainKeys = [];
114
+ const chainsToClean = [];
115
+ for (const { chainKey, chainProperties, nodes } of chains) {
116
+ if (this._chainListMap.hasChain(chainKey)) {
117
+ chainsToClean.push(chainKey);
118
+ }
119
+ this._chainListMap.setChain(chainKey, nodes);
120
+ this._chainListMap.setChainProperties(chainKey, chainProperties);
121
+ chainKeys.push(chainKey);
122
+ }
123
+ this._cleanChainsFromSemiPlugins(chainsToClean);
124
+ // Reconstruct chains
125
+ this._reconstructChains(chainKeys);
126
+ // Update texts
127
+ this._updateTexts(chainKeys, textWriterIDs);
128
+ this.globe?.DrawRender();
129
+ }
130
+ addNode(node, chainKey, { theNodeKeyFront, textWriterIDs = [] } = {}) {
131
+ if (this._freed) {
132
+ console.warn("CircleLineChainPlugin is freed, cannot add node.");
133
+ return;
134
+ }
135
+ this._cleanChainsFromSemiPlugins([chainKey]);
136
+ this._chainListMap.addNode(node, chainKey, theNodeKeyFront);
137
+ this._reconstructChains([chainKey]);
138
+ this._updateTexts([chainKey], textWriterIDs);
139
+ this.globe?.DrawRender();
140
+ }
141
+ getChain(chainKey) {
142
+ return this._chainListMap.getNodes(chainKey);
143
+ }
144
+ setDrawCircleOn(value) {
145
+ if (this._freed) {
146
+ console.warn("CircleLineChainPlugin is freed, cannot set drawCircleOn.");
147
+ return;
148
+ }
149
+ this._drawCircleOn = value;
150
+ this.globe?.DrawRender();
151
+ }
152
+ setOpacities(opacities) {
153
+ // TODO: Check opacities
154
+ this._opacities = {
155
+ ...this._opacities,
156
+ ...opacities
157
+ };
158
+ // set Opacities of plugins
159
+ this.globe?.DrawRender();
160
+ }
161
+ deleteChains(chainKeys) {
162
+ if (this._freed) {
163
+ console.warn("CircleLineChainPlugin is freed, cannot delete chains.");
164
+ return;
165
+ }
166
+ for (const chainKey of chainKeys) {
167
+ const keys = this._chainListMap.deleteChainAndReturnChainKeys(chainKey);
168
+ if (keys.length <= 1) {
169
+ console.warn("No chains were deleted, chainKeys might be invalid.");
170
+ return;
171
+ }
172
+ keys.pop(); // Remove the last key which which is destination of the last circle
173
+ this.linePlugin?.deleteBulk(keys);
174
+ this.arcPlugin?.deleteBulk(keys);
175
+ this.circlePlugin?.deleteBulk(keys);
176
+ this._updateTexts(chainKeys, Array.from(this._textWritersMap.keys()));
177
+ }
178
+ }
179
+ deleteNodes(keysAndNodes, { textWriterIDs = [] } = {}) {
180
+ if (this._freed) {
181
+ console.warn("CircleLineChainPlugin is freed, cannot delete nodes.");
182
+ return;
183
+ }
184
+ const chainKeysToReconstruct = [];
185
+ keysAndNodes.forEach(({ chainKey, nodeKeys }) => {
186
+ this._chainListMap.deleteNodesBelongToAChain(chainKey, nodeKeys);
187
+ chainKeysToReconstruct.push(chainKey);
188
+ });
189
+ this._cleanChainsFromSemiPlugins(chainKeysToReconstruct);
190
+ this._reconstructChains(chainKeysToReconstruct);
191
+ this._updateTexts(chainKeysToReconstruct, textWriterIDs);
192
+ this.globe?.DrawRender();
193
+ }
194
+ updateNodesProperties(chainKey, nodesAndPropertyMap, { textWriterIDs = [] } = {}) {
195
+ if (this._freed) {
196
+ console.warn("CircleLineChainPlugin is freed, cannot update nodes properties.");
197
+ return;
198
+ }
199
+ this._chainListMap.updateNodesProperties(chainKey, nodesAndPropertyMap);
200
+ this._cleanChainsFromSemiPlugins([chainKey]);
201
+ this._reconstructChains([chainKey]);
202
+ this._updateTexts([chainKey], textWriterIDs);
203
+ this.globe?.DrawRender();
204
+ }
205
+ updateCoordinatesBulk(chains, { textWriterIDs = [] } = {}) {
206
+ if (this._freed) {
207
+ console.warn("CircleLineChainPlugin is freed, cannot update coordinates.");
208
+ return;
209
+ }
210
+ const chainKeys = [];
211
+ for (const chain of chains) {
212
+ const { chainKey, nodes } = chain;
213
+ chainKeys.push(chainKey);
214
+ nodes.forEach((node, index) => {
215
+ this._chainListMap.updateCoordsinatesOfNode(node, chainKey);
216
+ });
217
+ }
218
+ this._updateTexts(chainKeys, textWriterIDs);
219
+ this._reconstructChains(chainKeys);
220
+ }
221
+ updateNodeCoordinates(node, chainKey, { textWriterIDs = [] } = {}) {
222
+ if (this._freed) {
223
+ console.warn("CircleLineChainPlugin is freed, cannot update node coordinates.");
224
+ return;
225
+ }
226
+ this._chainListMap.updateCoordsinatesOfNode(node, chainKey);
227
+ if (textWriterIDs && textWriterIDs.length > 0) {
228
+ this._updateTexts([chainKey], textWriterIDs);
229
+ }
230
+ this._reconstructChains([chainKey]);
231
+ this.globe?.DrawRender();
232
+ }
233
+ updateChainProperties(chainKey, properties) {
234
+ if (this._freed) {
235
+ console.warn("CircleLineChainPlugin is freed, cannot update chain properties.");
236
+ return;
237
+ }
238
+ this._chainListMap.updateChainProperties(chainKey, properties);
239
+ this._cleanChainsFromSemiPlugins([chainKey]);
240
+ this._reconstructChains([chainKey]);
241
+ this._updateTexts([chainKey], Array.from(this._textWritersMap.keys()));
242
+ this.globe?.DrawRender();
243
+ }
244
+ updateText(textWriterIDs, chainKeys = null) {
245
+ if (this._freed) {
246
+ console.warn("CircleLineChainPlugin is freed, cannot update text.");
247
+ return;
248
+ }
249
+ if (!chainKeys) {
250
+ chainKeys = Array.from(this._chainListMap.getAllChainKeysIterator());
251
+ }
252
+ this._updateTexts(chainKeys, textWriterIDs);
253
+ this.globe?.DrawRender();
254
+ }
255
+ // IMPLICIT METHODS
256
+ _checktextWritersMap(textWritersMap) {
257
+ if (!(textWritersMap instanceof Map))
258
+ throw new Error("textWritersMap is not an instance of Map");
259
+ textWritersMap.forEach((v) => {
260
+ if (!(v instanceof ContextTextWriter3))
261
+ throw new Error("textWritersMap element is not an instance of ContextTextWriter3");
262
+ });
263
+ }
264
+ _updateTexts(chainKeys, textWriterIDs) {
265
+ if (textWriterIDs.length === 0)
266
+ return;
267
+ const textWriters = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
268
+ chainKeys.forEach((chainKey) => {
269
+ this._chainListMap.textUpdate(chainKey, textWriters, this._textDataPreAdaptor);
270
+ });
271
+ }
272
+ _cleanChainsFromSemiPlugins(chainKeys) {
273
+ if (!this.globe || !this.gl) {
274
+ throw new Error("Globe or WebGL context is not initialized");
275
+ }
276
+ for (const chainKey of chainKeys) {
277
+ // Clean chains from text writers
278
+ const nodeKeys = this._chainListMap.getNodeKeysOfChain(chainKey);
279
+ nodeKeys.pop(); // Remove the last key which is destination of the last circle
280
+ this.circlePlugin?.deleteBulk(nodeKeys);
281
+ this.linePlugin?.deleteBulk(nodeKeys);
282
+ this.arcPlugin?.deleteBulk(nodeKeys);
283
+ }
284
+ }
285
+ _reconstructChains(chainKeys) {
286
+ // TODO: this is core
287
+ // Get chain nodes
288
+ const globe = this.globe;
289
+ if (!globe || !this.gl) {
290
+ throw new Error("Globe or WebGL context is not initialized");
291
+ }
292
+ for (let chainKey of chainKeys) {
293
+ const chain = this._chainListMap.getChain(chainKey);
294
+ if (!chain) {
295
+ console.warn(`Chain with key ${chainKey} not found.`);
296
+ continue;
297
+ }
298
+ const lineInput = this._lineAdaptor(chain);
299
+ const arcInput = this._arcAdaptor(chain);
300
+ const circleInput = this._circleAdaptor(globe, chain);
301
+ this.linePlugin?.insertBulk(lineInput);
302
+ this.arcPlugin?.insertBulk(arcInput);
303
+ this.circlePlugin?.insertBulk(circleInput);
304
+ }
305
+ }
306
+ // GLOBE INTERFACE METHODS
307
+ init(globe, gl) {
308
+ this.globe = globe;
309
+ this.gl = gl;
310
+ // Initialize sub-plugins with unique IDs
311
+ this.circlePlugin = new CircleOnTerrainPlugin(`${this.id}_unregistered_circles`, this._semiPluginOptions.circleOnTerrainOptions);
312
+ this.linePlugin = new LinePlugin(`${this.id}_unregistered_lines`, this._semiPluginOptions.lineOptions);
313
+ this.arcPlugin = new ArcOnTerrainPlugin(`${this.id}_unregistered_arcs`, this._semiPluginOptions.arcOnTerrainOptions);
314
+ this.circlePlugin.init(globe, gl);
315
+ this.linePlugin.init(globe, gl);
316
+ this.arcPlugin.init(globe, gl);
317
+ }
318
+ draw3D() {
319
+ if (this._freed) {
320
+ console.warn("CircleLineChainPlugin is freed, cannot draw.");
321
+ return;
322
+ }
323
+ const { globe, gl } = this;
324
+ if (!globe || !gl) {
325
+ console.warn("Globe or WebGL context is not initialized, cannot draw.");
326
+ return;
327
+ }
328
+ const circleOpacity = getOpacity(this._opacities, "circle");
329
+ if (this._drawCircleOn && circleOpacity !== 0) {
330
+ this.circlePlugin?.setPluginOpacity(circleOpacity);
331
+ this.circlePlugin?.draw3D();
332
+ }
333
+ const currentGeometry = globe.api_GetCurrentGeometry();
334
+ switch (currentGeometry) {
335
+ case 0: {
336
+ // globe view
337
+ const lineOpacity = getOpacity(this._opacities, "globeArc");
338
+ if (lineOpacity !== 0) {
339
+ this.linePlugin?.setPluginOpacity(lineOpacity);
340
+ this.linePlugin?.draw3D();
341
+ }
342
+ const arcOpacity = getOpacity(this._opacities, "globeArcFitsTerrain");
343
+ if (arcOpacity !== 0) {
344
+ this.arcPlugin?.setPluginOpacity(arcOpacity);
345
+ this.arcPlugin?.draw3D();
346
+ }
347
+ break;
348
+ }
349
+ case 1: {
350
+ // flat view
351
+ const lineOpacity = getOpacity(this._opacities, "flatStraightLine");
352
+ if (lineOpacity !== 0) {
353
+ this.linePlugin?.setPluginOpacity(lineOpacity);
354
+ this.linePlugin?.draw3D();
355
+ }
356
+ const arcOpacity = getOpacity(this._opacities, "flatGreatCircleLine");
357
+ if (arcOpacity !== 0) {
358
+ this.arcPlugin?.setPluginOpacity(arcOpacity);
359
+ this.arcPlugin?.draw3D();
360
+ }
361
+ break;
362
+ }
363
+ default: {
364
+ throw new Error("Unknown geometry type, Implementation need on Circle-Line-Chain Plugin");
365
+ }
366
+ }
367
+ this._textWritersMap.forEach((writer) => {
368
+ writer.draw();
369
+ });
370
+ }
371
+ free() {
372
+ if (this._freed)
373
+ return;
374
+ this._freed = true;
375
+ // Free sub-plugins
376
+ this.circlePlugin?.free();
377
+ this.linePlugin?.free();
378
+ this.arcPlugin?.free();
379
+ // Clear text writers map
380
+ this._textWritersMap.clear();
381
+ // Clear references
382
+ this.globe = null;
383
+ this.gl = null;
384
+ this.circlePlugin = null;
385
+ this.linePlugin = null;
386
+ this.arcPlugin = null;
387
+ }
388
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ // export const rangeRingToPaddingInputAdapter = () => (rangeRing: RangeRingInput): PaddingInput => {
2
+ // return {
3
+ // key: rangeRing.key,
4
+ // center: [rangeRing.long, rangeRing.lat],
5
+ // radius: rangeRing.radius,
6
+ // color: rangeRing.rgba as Color,
7
+ // altitude: rangeRing.altitude,
8
+ // };
9
+ // }
10
+ export const rangeRingToCircleInputAdapter = (rangeRing) => {
11
+ return rangeRing.rings.map(ring => ({
12
+ key: ring.rindID,
13
+ center: [rangeRing.long, rangeRing.lat],
14
+ radius: ring.radius,
15
+ color: rangeRing.rgba,
16
+ altitude: rangeRing.altitude,
17
+ }));
18
+ };
19
+ function rangeRingToPaddingsCoordinatesAdapter(globe, center, rangeRing, startAngle, stepAngle) {
20
+ return new Float32Array();
21
+ }
22
+ export const rangeRingToArcInputAdapter = (globe, rangeRing) => {
23
+ // TODO;
24
+ return [];
25
+ };
@@ -0,0 +1,31 @@
1
+ import { CircleOnTerrainPlugin } from "../../semiplugins/shape-on-terrain/circle-plugin";
2
+ import { ArcOnTerrainPlugin } from "../../semiplugins/shape-on-terrain/arc-plugin";
3
+ import { LinePlugin } from "../../semiplugins/lightweight/line-plugin";
4
+ // @ts-ignore
5
+ export class RangeRingPlugin {
6
+ id;
7
+ globe = null;
8
+ gl = null;
9
+ circlePlugin;
10
+ arcPlugin;
11
+ linePlugin;
12
+ _memory = new Map();
13
+ constructor(id) {
14
+ this.id = id;
15
+ this.circlePlugin = new CircleOnTerrainPlugin(this.id + "-circle");
16
+ this.arcPlugin = new ArcOnTerrainPlugin(this.id + "-arc", {
17
+ vertexCount: 5,
18
+ });
19
+ this.linePlugin = new LinePlugin(this.id + "-line");
20
+ }
21
+ insertBulk(items) {
22
+ }
23
+ _build() {
24
+ }
25
+ init(globe, gl) {
26
+ this.globe = globe;
27
+ this.gl = gl;
28
+ }
29
+ draw3D() {
30
+ }
31
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -28,7 +28,7 @@ import { centerCoords2dflatDataCreatorWithRadius, CircleCache as CircleCache2D }
28
28
  import { CircleCache as CircleCache3D } from "../programs/line-on-globe/circle-accurate-3d";
29
29
  import { LinesColorInstancedFlatCache } from "../programs/line-on-globe/lines-color-instanced-flat";
30
30
  import { BufferOrchestrator, BufferManager } from "../util/account";
31
- import { mapGetOrThrow } from "../util/check/get";
31
+ // import { mapGetOrThrow } from "../util/check/get";
32
32
  import { populateFloat32Array } from "../util/jshelpers/data-filler";
33
33
  import { RingAccount, ringBigPaddingKeyMethod, ringKeyMethod } from "./ring-account";
34
34
  import { CirclePadding3DCache } from "../programs/line-on-globe/degree-padding-around-circle-3d";
@@ -36,13 +36,9 @@ import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate-flexi
36
36
  import RangeRingAngleText from "./rangeringangletext";
37
37
  import { Z_ALPHA_MODE } from "../programs/line-on-globe/util";
38
38
  import { ENUM_HIDE } from "./enum";
39
- import { opacityCheck, constraintFloat } from "../util/check/typecheck";
40
- import { normalize } from "../util/geometry";
39
+ import { opacityCheck, mapGetOrThrow } from "../util/check/typecheck";
40
+ import { sphereCoord } from "../util/geometry/index";
41
41
  const CIRCLE_FLAT_EDGE_COUNT = 362; // 360 + 2 for closing the circle and a cutting point
42
- const coordOnSphere = (long, lat, globe, altitude = 0) => {
43
- const coord = globe.api_GetCartesian3DPoint(long, lat, 0, 0);
44
- return normalize(coord, 6378.137 + altitude);
45
- };
46
42
  /**
47
43
  *
48
44
  *
@@ -395,8 +391,8 @@ class RangeRings {
395
391
  key: ringBigPaddingKeyMethod(centerID, ringID, azimuthAngle),
396
392
  circlePoint2d: new Float32Array(globe.api_GetMercator2DPoint(circlePoint.long, circlePoint.lat)),
397
393
  paddingPoint2d: new Float32Array(globe.api_GetMercator2DPoint(paddingPoint.long, paddingPoint.lat)),
398
- circlePoint3d: coordOnSphere(circlePoint.long, circlePoint.lat, globe, altitude / 1000),
399
- paddingPoint3d: coordOnSphere(paddingPoint.long, paddingPoint.lat, globe, altitude / 1000),
394
+ circlePoint3d: sphereCoord(circlePoint.long, circlePoint.lat, globe, altitude / 1000),
395
+ paddingPoint3d: sphereCoord(paddingPoint.long, paddingPoint.lat, globe, altitude / 1000),
400
396
  rgba: color,
401
397
  hide,
402
398
  textHide
@@ -412,14 +408,14 @@ class RangeRings {
412
408
  if (centerItem === undefined)
413
409
  throw new Error("Center not found");
414
410
  const { long, lat, rgba, rings, hide = 0, textHide = 0, altitude: centralAltitude = 0 } = centerItem;
415
- const centerCoords3d = coordOnSphere(long, lat, globe, centralAltitude / 1000);
411
+ const centerCoords3d = sphereCoord(long, lat, globe, centralAltitude / 1000);
416
412
  const result = [];
417
413
  for (const { ringID, radius, padding, __identity__, altitude = centralAltitude } of rings) {
418
414
  const key = __identity__;
419
415
  const centerCoords2dflat = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radius, { edgeCount: CIRCLE_FLAT_EDGE_COUNT });
420
416
  const radiusPadding = hide === ENUM_HIDE.HIDE_1_DEGREE_PADDINGS ? radius : radius - padding / 3;
421
417
  const targetPoint = globe.Math.FindPointByPolar(long, lat, radius, 0); // long lat
422
- const targetCoords3d = coordOnSphere(targetPoint.long, targetPoint.lat, globe, altitude / 1000);
418
+ const targetCoords3d = sphereCoord(targetPoint.long, targetPoint.lat, globe, altitude / 1000);
423
419
  const centerCoords2dflatForPadding = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radiusPadding, { edgeCount: CIRCLE_FLAT_EDGE_COUNT });
424
420
  result.push({
425
421
  key,