@pirireis/webglobeplugins 0.6.26-a → 0.6.28-a

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.
@@ -3,7 +3,6 @@ import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate';
3
3
  import { CircleCache as Circle3DCache } from '../programs/line-on-globe/circle-accurate-3d';
4
4
  import { CircleCache, EDGE_COUNT as flatCircleEdgeCount, centerCoords2dflatDataCreator } from '../programs/line-on-globe/circle-accurate-flat';
5
5
  import { BufferOrchestrator, BufferManager } from '../util/account';
6
- import { AngledLineProgramCache } from '../programs/line-on-globe/angled-line'; // TODO calculate the bearing target for 2d and 3d and use lineOnGlobeProgram
7
6
  import { mapGetOrThrow } from "../util/check/get";
8
7
  import { populateFloat32Array } from "../util/jshelpers/data-filler";
9
8
  import { ContextTextWriter } from '../write-text/context-text'
@@ -34,6 +33,7 @@ const constraintFloat = (x, lowerBound, upperBound) => {
34
33
  *
35
34
  */
36
35
 
36
+ // TODO UPDATE TO ContextTextWriter3
37
37
 
38
38
 
39
39
  export default class Plugin {
@@ -130,11 +130,8 @@ export default class Plugin {
130
130
  this.globe = globe;
131
131
  this.lineProgram = LineOnGlobeCache.get(globe);
132
132
  this.ringProgram = pieceOfPieProgramCache.get(globe);
133
- this.angledLineProgram = AngledLineProgramCache.get(globe);
134
133
  this.circleProgram = CircleCache.get(globe);
135
134
  this.circle3DProgram = Circle3DCache.get(globe);
136
- // this.angleTextContext = new ContextTextWriter(globe);
137
- // this.distanceTextContext = new ContextTextWriter(globe);
138
135
  const circleFlatEdgeCount = this.circleFlatEdgeCount
139
136
  {
140
137
  // createBuffers
@@ -363,7 +360,7 @@ export default class Plugin {
363
360
  * @param {Array<{key, long, lat, endLong, endLat, bearingAngle}>} items
364
361
  * @param {Array<string>} textWriterInjectionSubSetIDs | textContextInjectionMap keys to be used for writing text.
365
362
  */
366
- updateCoordinatesBulk(items, textWriterInjectionSubSetIDs = []) { //TODO
363
+ updateCoordinatesBulk(items, textWriterInjectionSubSetIDs = []) {
367
364
  const injectionsSubSet = textWriterGetOrThrow(this._textContextInjectionMap, textWriterInjectionSubSetIDs);;
368
365
  const { globe, bufferOrchestrator, bufferManagersCompMap, } = this;
369
366
  const data = []
@@ -489,7 +486,6 @@ export default class Plugin {
489
486
  this.bufferManagersCompMap.forEach(({ bufferManager, adaptor }) => {
490
487
  bufferManager.free();
491
488
  });
492
-
493
489
  const { gl, globe } = this;
494
490
  gl.deleteVertexArray(this.lineVao);
495
491
  gl.deleteVertexArray(this.ringVao);
@@ -499,7 +495,6 @@ export default class Plugin {
499
495
  LineOnGlobeCache.release(globe);
500
496
  pieceOfPieProgramCache.release(globe);
501
497
  CircleCache.release(globe);
502
- AngledLineProgramCache.release(globe);
503
498
  Circle3DCache.release(globe)
504
499
  this.isFreed = true;
505
500
  }
@@ -8,7 +8,6 @@ import { mapGetOrThrow } from "../util/check/get";
8
8
  import { keyMethod } from "./util";
9
9
  import { populateFloat32Array } from "../util/jshelpers/data-filler";
10
10
  import { ContextTextWriter3 } from '../write-text/context-text3';
11
- // TODO: Add update buffer and update text mehods on add, delete, update methods
12
11
 
13
12
 
14
13
  /**
@@ -282,7 +281,6 @@ export class CircleLineChainPlugin {
282
281
  * @param {*} theNodeKeyFront | node key of the next node, null places to the last
283
282
  */
284
283
  addNode(node, chainKey, { theNodeKeyFront = null, textWriterIDs = [] } = {}) {
285
- // TODO: if before object is null update the last two elements of the chain only.
286
284
  this._chainListMap.addNode(node, chainKey, theNodeKeyFront);
287
285
  if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
288
286
  this._reconstructChains([chainKey]);
@@ -412,7 +410,6 @@ export class CircleLineChainPlugin {
412
410
 
413
411
 
414
412
  // GLOBE API
415
- //TODO:
416
413
  free() {
417
414
  if (this.isFreed) return;
418
415
  this.bufferManagersCompMap.forEach(({ bufferManager }) => {
@@ -426,12 +423,13 @@ export class CircleLineChainPlugin {
426
423
  const { gl } = this;
427
424
  gl.deleteVertexArray(this.lineVao);
428
425
  gl.deleteVertexArray(this.circleVao2d);
429
- // gl.deleteVertexArray(this.toOriginVao);
426
+ gl.deleteVertexArray(this.circle3DVao);
430
427
  this.lineProgram = null;
431
428
  this.circleProgram2d = null;
432
429
  this.isFreed = true;
433
430
  }
434
431
 
432
+
435
433
  draw3D() {
436
434
  const { gl, globe } = this;
437
435
  gl.disable(gl.DEPTH_TEST);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.6.26-a",
3
+ "version": "0.6.28-a",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -15,9 +15,12 @@ import {
15
15
  * Plus 1 for returning to the start point. 1 for cutting the circle into pieces.
16
16
  */
17
17
  const EDGE_COUNT = 62;
18
-
18
+ const escape_value = 200_000_000;
19
19
  const vertexShaderSource = `#version 300 es
20
20
  precision highp float;
21
+
22
+ # define escape_value ${escape_value}.0
23
+
21
24
  ${CameraUniformBlockString}
22
25
  ${mercatorXYToGLPosition}
23
26
 
@@ -34,7 +37,10 @@ out vec4 v_color;
34
37
  out float v_dash_ratio;
35
38
  out float v_dash_opacity;
36
39
  out vec2 v_limp;
40
+
41
+
37
42
  void main() {
43
+ if ( position2d.x == escape_value && position2d.y == escape_value){ return; }
38
44
  interpolation = float( gl_VertexID % edge_count ) / float(edge_count);
39
45
  if ( gl_VertexID % edge_count == 0 ) { return; } // cut on the first point.
40
46
  if ( is3D ) {
@@ -216,14 +222,25 @@ function centerCoords2dflatDataCreatorWithRadius(globe, centerLong, centerLat, r
216
222
  360 / (edgeCount - 2), // 1 for return to start point, 1 for cutting circles
217
223
  );
218
224
 
225
+ let { long: lastlg, lat: lastlt } = pointsLongLat[0];
219
226
  for (let i = 1; i < edgeCount; i++) {
220
227
  const { long: lg, lat: lt } = pointsLongLat[i - 1];
221
- centerCoords2dflat.set(globe.api_GetMercator2DPoint(lg, lt), i * 2);
228
+ if (manhattanDistance(lastlg, lastlt, lg, lt) < 170) {
229
+ centerCoords2dflat.set(globe.api_GetMercator2DPoint(lg, lt), i * 2);
230
+ } else {
231
+ centerCoords2dflat.set([escape_value, escape_value], i * 2);
232
+ }
233
+ lastlg = lg;
234
+ lastlt = lt;
222
235
  }
223
236
  return centerCoords2dflat;
224
237
  }
225
238
 
226
239
 
240
+ function manhattanDistance(x1, y1, x2, y2) {
241
+ return Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2));
242
+ }
243
+
227
244
  export {
228
245
  CircleCache, EDGE_COUNT, centerCoords2dflatDataCreator, centerCoords2dflatDataCreatorWithRadius
229
246
  }
@@ -34,7 +34,7 @@ void main() {
34
34
  }
35
35
  float gap = distance(posA, posB);
36
36
  float z_alpha;
37
- if ( z_alpha_on == 1 || gap > 40000000.0){
37
+ if ( z_alpha_on == 1 || gap > 37000000.0){
38
38
  z_alpha = z_level * z_level / ( gap / 100.0 );
39
39
  if( z_alpha < 0.1 ) {return;}
40
40
  if( z_alpha > 1.0 ) {z_alpha = 1.0;}
@@ -1,4 +1,4 @@
1
- import RangeRings from './rangerings';
1
+ import { RangeRings } from "./plugin";
2
2
  import RangeRingAngleText from './rangeringangletext';
3
3
  import { ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES } from './enum';
4
4
  export { RangeRings, ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES, RangeRingAngleText };
@@ -33,7 +33,7 @@
33
33
  * @typedef {Array<{ringID, radius, padding}>} rings
34
34
  * @param {Array<centerID:string, x:number, y:number, stepAngle:number, rgba:[4 numbers], rings:rings} items
35
35
 
36
- * @method updateCentersXY @param {Array<{centerID, x, y}>} items
36
+ * @method updateCentersCoordinate @param {Array<{centerID, long,lat}>} items
37
37
  * @method updateCentersColor @param {Array<{centerID, rgba:[4 numbers]}>} centerColors
38
38
  *
39
39
  * @method updateCentersHide @param {Array<{centerID, hide, textHide}>} centerHides
@@ -76,7 +76,7 @@ import RangeRingAngleText from "./rangeringangletext";
76
76
  * [+] big paddings does not remove
77
77
  */
78
78
 
79
- // TODO make x, y -> long, lat
79
+ // TODO make long,lat -> long, lat
80
80
 
81
81
  class RangeRings {
82
82
  constructor(id, { oneDegreePadding = true, showNumbers = true, numbersStyle = null, opacity = 1 } = {}) {
@@ -112,7 +112,7 @@ class RangeRings {
112
112
  this._padding2dProgram = LinesColorInstancedFlatCache.get(globe);
113
113
  this._padding3dProgram = CirclePadding3DCache.get(globe);
114
114
  this._bigPadding3dFlatProgram = LineOnGlobeCache.get(globe);
115
- // this._padding3dProgram
115
+
116
116
  }
117
117
 
118
118
 
@@ -230,12 +230,6 @@ class RangeRings {
230
230
  ]
231
231
  );
232
232
 
233
- // this.bigPaddingVAO = this._padding2dProgram.createVAO(
234
- // { buffer: this.bufferManagersCompMapPadding.get("circlePoint").bufferManager.buffer, size: 2, stride: 0, offset: 0 },
235
- // { buffer: this.bufferManagersCompMapPadding.get("paddingPoint").bufferManager.buffer, size: 2, stride: 0, offset: 0 },
236
- // { buffer: this.bufferManagersCompMapPadding.get("rgba").bufferManager.buffer, size: 4, stride: 0, offset: 0 },
237
- // );
238
-
239
233
  this._bigPadding3dFlatVAO = this._bigPadding3dFlatProgram.createVAO(
240
234
  ...["circlePoint", "circlePoint3d", "paddingPoint", "paddingPoint3d", "dashRatio", "dashOpacity", "rgba",].map(key => obj(this.bufferManagersCompMapPadding.get(key)))
241
235
  );
@@ -274,10 +268,22 @@ class RangeRings {
274
268
  free() {
275
269
  if (this._isFreed) return;
276
270
  const { globe } = this;
271
+ this.bufferManagersCompMap.forEach(({ bufferManager }) => bufferManager.free());
272
+ this.bufferManagersCompMapPadding.forEach(({ bufferManager }) => bufferManager.free());
273
+ // delete vaos
274
+ this.gl.deleteVertexArray(this.circle2DVao);
275
+ this.gl.deleteVertexArray(this.circle3DVao);
276
+ this.gl.deleteVertexArray(this.oneDegreePaddingVao);
277
+ this.gl.deleteVertexArray(this._padding3dOneDegreeVao);
278
+ this.gl.deleteVertexArray(this._bigPadding3dFlatVAO);
279
+ // delete programs
277
280
  CircleCache2D.release(globe);
278
281
  CircleCache3D.release(globe);
282
+ LinesColorInstancedFlatCache.release(globe);
283
+ CirclePadding3DCache.release(globe);
284
+ LineOnGlobeCache.release(globe);
279
285
  this.textPlugin?.free();
280
- // free buffer managers
286
+
281
287
  this._isFreed = true;
282
288
  }
283
289
 
@@ -285,9 +291,9 @@ class RangeRings {
285
291
  // API
286
292
 
287
293
  /**
288
- * @method updateCentersXY @param { Array < { centerID, x, y } >} items
294
+ * @method updateCentersCoordinate @param { Array < { centerID, long,lat } >} items
289
295
  */
290
- updateCentersXY(items) {
296
+ updateCentersCoordinate(items) {
291
297
  // Algorithm
292
298
  /**
293
299
  * 1. ask centerRingAccount for existing rings COORDINATE RELATED KEYS
@@ -295,7 +301,7 @@ class RangeRings {
295
301
  * 3. update buffer orchestators
296
302
  */
297
303
 
298
- this._ringAccount.updateCentersXY(items);
304
+ this._ringAccount.updateCentersCoordinate(items);
299
305
  const { globe,
300
306
  bufferOrchestrator, bufferManagersCompMap,
301
307
  paddingBufferOrchestrator, bufferManagersCompMapPadding
@@ -317,7 +323,7 @@ class RangeRings {
317
323
  /**
318
324
  * @method insertBulk
319
325
  * @typedef { Array < { ringID, radius, padding } >} rings
320
- * @param { Array < centerID: string, x: number, y: number, stepAngle: number, rgba: [4 numbers], rings: rings, hide, textHide } items
326
+ * @param { Array < centerID: string, long: number, lat: number, stepAngle: number, rgba: [4 numbers], rings: rings, hide, textHide } items
321
327
  */
322
328
  insertBulk(items) {
323
329
  // Algorithm
@@ -483,14 +489,14 @@ class RangeRings {
483
489
  const centerItem = this._ringAccount.getCenter(centerID);
484
490
  if (centerItem === undefined) throw new Error("Center not found");
485
491
  const findPointByPolar = globe.Math.FindPointByPolar;
486
- const { x, y, stepAngle, rgba, rings, hide = 0, textHide = 0 } = centerItem;
492
+ const { long, lat, stepAngle, rgba, rings, hide = 0, textHide = 0 } = centerItem;
487
493
  const result = [];
488
494
  const color = hide === 1 ? new Float32Array([0, 0, 0, 0]) : new Float32Array(rgba)
489
495
  for (const { ringID, radius, padding } of rings) {
490
496
  let azimuthAngle = 0;
491
497
  while (azimuthAngle < 360) {
492
- const circlePoint = globe.Math.FindPointByPolar(x, y, radius, azimuthAngle); // long lat
493
- const paddingPoint = globe.Math.FindPointByPolar(x, y, radius - padding, azimuthAngle); // long lat
498
+ const circlePoint = globe.Math.FindPointByPolar(long, lat, radius, azimuthAngle); // long lat
499
+ const paddingPoint = globe.Math.FindPointByPolar(long, lat, radius - padding, azimuthAngle); // long lat
494
500
  result.push({
495
501
  key: ringBigPaddingKeyMethod(centerID, ringID, azimuthAngle),
496
502
  circlePoint: new Float32Array(globe.api_GetMercator2DPoint(circlePoint.long, circlePoint.lat)),
@@ -513,18 +519,15 @@ class RangeRings {
513
519
  const centerItem = this._ringAccount.getCenter(centerID);
514
520
  if (centerItem === undefined) throw new Error("Center not found");
515
521
 
516
- const { x, y, stepAngle, rgba, rings, hide = 0, textHide = 0 } = centerItem;
517
-
518
- const long = x;
519
- const lat = y;
522
+ const { long, lat, stepAngle, rgba, rings, hide = 0, textHide = 0 } = centerItem;
520
523
  const centerCoords3d = globe.api_GetCartesian3DPoint(long, lat, 0, 0);
521
524
 
522
525
  const result = [];
523
526
 
524
527
  for (const { ringID, radius, padding } of rings) {
525
528
  const key = ringKeyMethod(centerID, ringID);
526
- const centerCoords2dflat = centerCoords2dflatDataCreatorWithRadius(globe, x, y, radius, { edgeCount: _circleFlatEdgeCount });
527
- const centerCoords2dflatForPadding = centerCoords2dflatDataCreatorWithRadius(globe, x, y, radius - padding / 3, { edgeCount: _circleFlatEdgeCount });
529
+ const centerCoords2dflat = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radius, { edgeCount: _circleFlatEdgeCount });
530
+ const centerCoords2dflatForPadding = centerCoords2dflatDataCreatorWithRadius(globe, long, lat, radius - padding / 3, { edgeCount: _circleFlatEdgeCount });
528
531
  result.push({
529
532
  key,
530
533
  centerCoords3d,
@@ -544,7 +547,7 @@ class RangeRings {
544
547
  __reconstructCentralPaddingProperties(centerID) {
545
548
  const centerItem = this._ringAccount.getCenter(centerID);
546
549
  if (centerItem === undefined) throw new Error("Center not found");
547
- const { x, y, stepAngle, rgba, rings, hide = 0, textHide = 0 } = centerItem;
550
+ const { long, lat, stepAngle, rgba, rings, hide = 0, textHide = 0 } = centerItem;
548
551
  const result = [];
549
552
  for (const { ringID, } of rings) {
550
553
  let angle = 0;
@@ -94,10 +94,10 @@ export default class RangeRingAngleText {
94
94
 
95
95
 
96
96
  /**
97
- * @param {Array<{centerID,stepAngle, x, y, rings>} ringDatas
97
+ * @param {Array<{centerID,stepAngle, long,lat, rings>} ringDatas
98
98
  * centerID: string | ObjectArray fidKey de kullanilir
99
99
  * stepAngle: number | 0-360 arasinda
100
- * x, y: number | merkez koordinatlari lat long radian. Globe icin dereceye iceride cevrilir
100
+ * long,lat: number | merkez koordinatlari lat long radian. Globe icin dereceye iceride cevrilir
101
101
  * rings: Array<{radius: number}> | En buyuk halkaya centik acilari yazilir, Sonraki adim yaricaplarin uzunlugunu yazdirmak
102
102
  *
103
103
  * eger bir centerID zaten var ise: Onceki noktalar dusurulur ve yeniden eklenir
@@ -117,20 +117,20 @@ export default class RangeRingAngleText {
117
117
  attribs: []
118
118
  }
119
119
 
120
- for (const { centerID, x, y, rings, stepAngle, hide = ENUM_HIDE.SHOW, textHide = ENUM_TEXT_HIDE.SHOW } of ringDatas) {
120
+ for (const { centerID, long, lat, rings, stepAngle, hide = ENUM_HIDE.SHOW, textHide = ENUM_TEXT_HIDE.SHOW } of ringDatas) {
121
121
  if (this._centerCollection.has(centerID)) {
122
122
  this._fillDeleteBucket(centerID, deleteBucket);
123
123
  }
124
124
  const maxRadius = rings.reduce((acc, { radius }) => Math.max(acc, radius), 0);
125
125
  const textHide_ = _hideAll ? ENUM_TEXT_HIDE.HIDE : textHide;
126
126
  const show = hide !== ENUM_HIDE.HIDE && textHide_ === ENUM_TEXT_HIDE.SHOW;
127
- if (show) this._appendCircle(x, y, maxRadius, stepAngle, centerID, addBucket);
127
+ if (show) this._appendCircle(long, lat, maxRadius, stepAngle, centerID, addBucket);
128
128
  this._centerCollection.set(centerID,
129
129
  new Map([
130
130
  ["stepAngle", stepAngle],
131
131
  ["maxRadius", maxRadius],
132
- ["x", x],
133
- ["y", y],
132
+ ["long", long],
133
+ ["lat", lat],
134
134
  ["hide", hide],
135
135
  ["textHide", textHide_]
136
136
  ]));
@@ -151,11 +151,11 @@ export default class RangeRingAngleText {
151
151
  coordsZ: [],
152
152
  attribs: []
153
153
  }
154
- for (const { centerID, x, y } of centerDatas) {
154
+ for (const { centerID, long, lat } of centerDatas) {
155
155
  if (this._centerCollection.has(centerID)) {
156
156
  const centerMap = this._centerCollection.get(centerID);
157
- centerMap.set("x", x);
158
- centerMap.set("y", y);
157
+ centerMap.set("long", long);
158
+ centerMap.set("lat", lat);
159
159
  const hide = centerMap.get("hide");
160
160
  const textHide = centerMap.get("textHide");
161
161
  const isHidden = hide === ENUM_HIDE.HIDE || textHide === ENUM_TEXT_HIDE.HIDE;
@@ -163,7 +163,7 @@ export default class RangeRingAngleText {
163
163
  const maxRadius = centerMap.get("maxRadius");
164
164
  const stepAngle = centerMap.get("stepAngle");
165
165
  // long, lat, radius, step, centerID, outBucket
166
- this._appendCircle(x, y, maxRadius, stepAngle, centerID, updateBucket);
166
+ this._appendCircle(long, lat, maxRadius, stepAngle, centerID, updateBucket);
167
167
 
168
168
  }
169
169
  }
@@ -209,7 +209,7 @@ export default class RangeRingAngleText {
209
209
  if (!isHidden && !show) {
210
210
  this._fillDeleteBucket(centerID, deleteBucket);
211
211
  } else if (isHidden && show) {
212
- this._appendCircle(centerMap.get("x"), centerMap.get("y"), centerMap.get("maxRadius"), centerMap.get("stepAngle"), centerID, addBucket);
212
+ this._appendCircle(centerMap.get("long"), centerMap.get("lat"), centerMap.get("maxRadius"), centerMap.get("stepAngle"), centerID, addBucket);
213
213
  }
214
214
  if (hide !== null) centerMap.set("hide", hide);
215
215
  if (textHide !== null) centerMap.set("textHide", textHide);
@@ -267,11 +267,11 @@ export default class RangeRingAngleText {
267
267
  const hideText = centerMap.get("textHide");
268
268
  const isHidden = hideText === ENUM_TEXT_HIDE.HIDE;
269
269
  if (isHidden) {
270
- const x = centerMap.get("x");
271
- const y = centerMap.get("y");
270
+ const long = centerMap.get("long");
271
+ const lat = centerMap.get("lat");
272
272
  const maxRadius = centerMap.get("maxRadius");
273
273
  const stepAngle = centerMap.get("stepAngle");
274
- this._appendCircle(x, y, maxRadius, stepAngle, centerID, addBucket);
274
+ this._appendCircle(long, lat, maxRadius, stepAngle, centerID, addBucket);
275
275
  centerMap.set("hide", ENUM_HIDE.SHOW);
276
276
  centerMap.set("textHide", ENUM_TEXT_HIDE.SHOW);
277
277
  }
@@ -326,7 +326,7 @@ export default class RangeRingAngleText {
326
326
  this.__realCoords(long, lat, radius, step, centerID, outBucket);
327
327
  } else if (currentCompassMode == COMPASS_MODES.COMPASS) {
328
328
  // throw new Error("Not implemented yet");
329
- this.__compassCoords(long, lat, radius, step, centerID, outBucket);
329
+ // this.__compassCoords(long, lat, radius, step, centerID, outBucket);
330
330
  }
331
331
 
332
332
  }
@@ -334,7 +334,7 @@ export default class RangeRingAngleText {
334
334
  __realCoords(long, lat, radius, stepAngle, centerID, outBucket) {
335
335
  const { coords, coordsZ, attribs } = outBucket;
336
336
 
337
- const coords_ = realCircle(long, lat, radius, stepAngle / Degree);
337
+ const coords_ = realCircle(this.globe, long, lat, radius, stepAngle);
338
338
  { // add 0
339
339
  const { long, lat } = coords_[0];
340
340
  coords.push(long, lat);
@@ -356,7 +356,7 @@ export default class RangeRingAngleText {
356
356
  // fidkey is the key
357
357
  attribs.push({
358
358
  "__fid__": key,
359
- "aci": aci.toString()
359
+ "aci": (360 - aci).toString().padStart(3, '0')
360
360
  })
361
361
  aci += stepAngle;
362
362
  }
@@ -376,7 +376,7 @@ export default class RangeRingAngleText {
376
376
  { // add 0
377
377
  const x = Dlong + Degree * (radianRadius * Math.cos(Math.PI / 2));
378
378
  const y = Dlat + Degree * (radianRadius * Math.sin(Math.PI / 2) * scale);
379
- coords.push(x, y);
379
+ coords.push(long, lat);
380
380
  coordsZ.push(0);
381
381
  const key = this._key(centerID, 0);
382
382
  attribs.push({
@@ -391,7 +391,7 @@ export default class RangeRingAngleText {
391
391
  if (aci >= 360) break;
392
392
  const x = Dlong + Degree * (radianRadius * Math.cos(cstep));
393
393
  const y = Dlat + Degree * (radianRadius * Math.sin(cstep) * scale);
394
- coords.push(x, y);
394
+ coords.push(long, lat);
395
395
  coordsZ.push(0);
396
396
  const key = this._key(centerID, i++);
397
397
  attribs.push({
@@ -437,11 +437,11 @@ export default class RangeRingAngleText {
437
437
  for (const [centerID, centerMap] of this._centerCollection) {
438
438
  const isHidden = centerMap.get("hide") === ENUM_HIDE.HIDE || centerMap.get("textHide") === ENUM_TEXT_HIDE.HIDE;
439
439
  if (isHidden) continue;
440
- const x = centerMap.get("x");
441
- const y = centerMap.get("y");
440
+ const long = centerMap.get("long");
441
+ const lat = centerMap.get("lat");
442
442
  const maxRadius = centerMap.get("maxRadius");
443
443
  const stepAngle = centerMap.get("stepAngle");
444
- this._appendCircle(x, y, maxRadius, stepAngle, centerID, updateBucket);
444
+ this._appendCircle(long, lat, maxRadius, stepAngle, centerID, updateBucket);
445
445
  }
446
446
  this._updateData(updateBucket, CSObjectArrayUpdateTypes.UPDATE);
447
447
  }
@@ -462,28 +462,14 @@ const readCoords = (long, lat, radius, stepAngle) => {
462
462
 
463
463
  const R = 6371.0;
464
464
 
465
- const flatCircle = (longitude, latitude, radius, paddingAngles) => {
466
- const degree = radius / R;
467
- const points = [];
468
-
469
- for (const angle of paddingAngles) {
470
- const x = longitude + degree * Math.cos(angle);
471
- const y = latitude + degree * Math.sin(angle);
472
- points.push({ long: x, lat: y });
473
- }
474
- return points;
475
- }
476
-
477
- const realCircle = (longitude, latitude, radius, stepAngle) => {
478
- const R = 6371000;
479
465
 
480
- const degree = radius / R;
481
- const points = [];
482
- for (let step = Math.PI / 2.0; step > -Math.PI * 1.5; step -= stepAngle) {
483
- const y = latitude + degree * Math.sin(step);
484
- const x = longitude + degree * Math.cos(step) / Math.cos(y);
485
-
486
- points.push({ long: Degree * x, lat: Degree * y });
487
- }
488
- return points;
466
+ const realCircle = (globe, longitude, latitude, radius, stepAngle) => {
467
+ const pointsLongLat = globe.Math.GetEllipseGeo(
468
+ longitude,
469
+ latitude,
470
+ radius,
471
+ radius,
472
+ 0,
473
+ stepAngle);
474
+ return pointsLongLat;
489
475
  }
@@ -23,13 +23,13 @@ class RingAccount {
23
23
  }
24
24
 
25
25
  /**
26
- * @typedef {centerID, x, y, rings} centeralItem
26
+ * @typedef {centerID, long,lat, rings} centeralItem
27
27
  *
28
28
  */
29
29
  insertCenter(centeralItem) {
30
30
  this._centeralMap.set(centeralItem.centerID, {
31
- x: centeralItem.x,
32
- y: centeralItem.y,
31
+ long: centeralItem.long,
32
+ lat: centeralItem.lat,
33
33
  rings: centeralItem.rings,
34
34
  rgba: new Float32Array(centeralItem.rgba),
35
35
  hide: centeralItem.hide,
@@ -43,12 +43,12 @@ class RingAccount {
43
43
  return this._centeralMap.get(centerID);
44
44
  }
45
45
 
46
- updateCentersXY(items) {
47
- for (const { centerID, x, y } of items) {
46
+ updateCentersCoordinate(items) {
47
+ for (const { centerID, long, lat } of items) {
48
48
  const center = this.getCenter(centerID);
49
49
  if (center) {
50
- center.x = x;
51
- center.y = y;
50
+ center.long = long;
51
+ center.lat = lat;
52
52
  }
53
53
  }
54
54
  }
@@ -786,7 +786,7 @@ export default class TrackGlowLineProgram {
786
786
  gl.uniform3fv(_lineProgram.uTranslate, uTranslate);
787
787
 
788
788
  gl.bindVertexArray(_lineProgram.vao);
789
- gl.drawArrays(gl.LINES, 0, this._totalLength);
789
+ gl.drawArrays(gl.LINES, 0, this._totalLength); // TODO: line_strip with thombstone to reduce buffer size in half
790
790
  gl.drawBuffers([
791
791
  gl.COLOR_ATTACHMENT0,
792
792
  gl.NONE
@@ -66,7 +66,7 @@ export class ContextTextWriter {
66
66
 
67
67
 
68
68
 
69
- insertText(key, lat, long, text,) { // TODO: Make it more generic
69
+ insertText(key, lat, long, text,) {
70
70
  this.itemMap.set(key, { lat, long, text });
71
71
  }
72
72
 
@@ -22,6 +22,8 @@ export class ContextTextWriter3 {
22
22
  opacity: 1.0,
23
23
  zMode: CSZMode.Z_GROUND_PERVERTEX,
24
24
  },
25
+ xOffset = 0,
26
+ yOffset = 0,
25
27
  doDraw = true,
26
28
  textAdaptor = null,
27
29
  coordinatesAdaptor = null,
@@ -29,8 +31,7 @@ export class ContextTextWriter3 {
29
31
  opacityAdaptor = null,
30
32
  angleAdaptor = null,
31
33
  angleOnSphere = false,
32
- xOffset = 0,
33
- yOffset = 0,
34
+ positionAdaptor = (item, i, container, properties) => "left",
34
35
  zoomLevelAdaptor = (zoomLevel) => (item) => {
35
36
  return {
36
37
  opacityMultiplier: 1,
@@ -49,7 +50,7 @@ export class ContextTextWriter3 {
49
50
  this.keyAdaptor = keyAdaptor;
50
51
 
51
52
  this.zoomLevelAdaptor = zoomLevelAdaptor;
52
-
53
+ this.positionAdaptor = positionAdaptor;
53
54
  this.opacityAdaptor = opacityAdaptor ? opacityAdaptor : () => 1;
54
55
  this.angleOnSphere = angleOnSphere;
55
56
  if (angleAdaptor) {
@@ -104,7 +105,7 @@ export class ContextTextWriter3 {
104
105
  const zoomLevel = globe.api_GetCurrentLODWithDecimal();
105
106
  const zoomAdaptor = this.zoomLevelAdaptor(zoomLevel);
106
107
  for (const [key, item] of itemMap) {
107
- const { lat, long, text, opacity = null, angle = null, payload } = item;
108
+ const { lat, long, text, opacity = null, angle = null, payload, position } = item;
108
109
  const { x, y } = globe.api_GetScreenPointFromGeo(
109
110
  {
110
111
  long: long,
@@ -116,7 +117,7 @@ export class ContextTextWriter3 {
116
117
  const { opacityMultiplier, sizeMultiplier } = zoomAdaptor(payload);
117
118
  const o = (opacity === null ? opacity_ : opacity * opacity_) * opacityMultiplier;
118
119
  textFont.size = sizeMultiplier * textSize;
119
-
120
+ textFont.position = position;
120
121
  if (x !== null && y !== null) globe.api_DrawContextTextMultiLine(text, textFont, o, { x: x + xOffset, y: y - yOffset }, angleIsOn, angle);
121
122
  }
122
123
  textFont.size = textSize;
@@ -154,7 +155,8 @@ export class ContextTextWriter3 {
154
155
  };
155
156
  const opacity = this.opacityAdaptor(item, id, container, properties);
156
157
  const angle = this.angleAdaptor(item, id, container, properties);
157
- this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle, payload: item });
158
+ const position = this.positionAdaptor(item, id, container, properties);
159
+ this.itemMap.set(key, { long: coords.long, lat: coords.lat, text, opacity, angle, payload: item, position });
158
160
  }
159
161
 
160
162
  clear() {