@pirireis/webglobeplugins 0.0.10 → 0.1.1

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.0.10",
3
+ "version": "0.1.1",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -33,6 +33,7 @@ out vec4 v_color;
33
33
  void main() {
34
34
  if( flag == 1.0 || radius == 0.0 ) return; // 1.0 is hide
35
35
  v_color = color;
36
+ if ( pad_angle == 0.0 ) v_color.rgb += 0.2;
36
37
  gl_PointSize = 2.0;
37
38
 
38
39
  float odd = mod(float(gl_VertexID), 2.0);
@@ -50,8 +51,8 @@ void main() {
50
51
  if ( compass == 1 ){
51
52
  limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
52
53
  } else {
53
- limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
54
- // limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
54
+ // limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
55
+ limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
55
56
  }
56
57
  v_limp = limp;
57
58
  gl_Position = mercatorXYTo2DPoint(limp);
@@ -269,7 +270,8 @@ export class BufferManager extends BufferOffsetManager {
269
270
  updateCentersHide(data) {
270
271
  const { gl, buffer } = this;
271
272
  const items = [];
272
- for (const { centerID, hide } of data) {
273
+ for (const { centerID, hide = null } of data) {
274
+ if (hide === null) continue;
273
275
  const block = new Float32Array([hide]);
274
276
  const center = this._centerMaps.get(centerID);
275
277
  if (!center) continue;
@@ -227,7 +227,8 @@ export default class {
227
227
  updateCentersHide(data) {
228
228
  const { gl, buffer } = this;
229
229
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
230
- for (let { centerID, hide } of data) {
230
+ for (let { centerID, hide = null } of data) {
231
+ if (hide === null) continue;
231
232
  const rings = this._centerMap.get(centerID).get("rings");
232
233
  for (let i = 0; i < rings.length; i++) {
233
234
  const offset = this._ringOffsets.get(rings[i]);
@@ -51,8 +51,8 @@ void main() {
51
51
  if ( compass == 1 ){
52
52
  limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
53
53
  } else {
54
- limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
55
- // limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
54
+ // limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
55
+ limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
56
56
  }
57
57
  v_limp = limp;
58
58
  gl_Position = mercatorXYTo2DPoint(limp);
@@ -0,0 +1,7 @@
1
+
2
+ export const ENUM_HIDE = Object.freeze({ SHOW: 0, HIDE: 1, HIDE_1_DEGREE_PADDINGS: 2 });
3
+ export const ENUM_TEXT_HIDE = Object.freeze({ SHOW: 0, HIDE: 1 });
4
+ export const COMPASS_MODES = Object.freeze({
5
+ COMPASS: 1,
6
+ REAL: 0,
7
+ });
@@ -1,3 +1,3 @@
1
- import RangeRings, { ENUM_HIDE } from './rangerings';
2
-
3
- export { RangeRings, ENUM_HIDE };
1
+ import RangeRings from './rangerings';
2
+ import { ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES } from './enum';
3
+ export { RangeRings, ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES };
@@ -0,0 +1,434 @@
1
+
2
+ import {
3
+ CSGlobe,
4
+ CSObjectTypes,
5
+ CSIconTypes,
6
+ CSObjectArrayUpdateTypes,
7
+ GlobeManager
8
+ } from "@pirireis/webglobe";
9
+ import { ENUM_HIDE, ENUM_TEXT_HIDE, COMPASS_MODES } from "./enum";
10
+
11
+
12
+ const Degree = 180 / Math.PI;
13
+
14
+
15
+
16
+ const fidKey = "__fid__";
17
+
18
+
19
+ const object = {
20
+ "displayName": "CompassRose",
21
+ "layerType": 3,
22
+
23
+ "wkbGeom": null,
24
+ "wfsLayerName": null,
25
+ "objectType": "point",
26
+ "bbox": null,
27
+ "startLod": 2,
28
+ "endLod": 30,
29
+ "continuousLOD": true,
30
+ "MVTXYZName": "hd_seyp",
31
+ "rasterize": false,
32
+ }
33
+
34
+
35
+ export default class RangeRingAngleText {
36
+ constructor(globe, { style = null, flatCompassMode = COMPASS_MODES.REAL } = {}) {
37
+ this.globe = globe;
38
+ this.ObjectArray = globe.ObjectArray;
39
+
40
+ this._flatCompassMode = flatCompassMode;
41
+ this._lastImplicitCompassMode = this.__implicitCompassMode();
42
+ if (style) {
43
+ this.style = style;
44
+ } else {
45
+ this.style = this.ObjectArray.GetDefaultStyle();
46
+ const { labels } = this.style;
47
+ const label = labels[0];
48
+ label.offset = { x: 0, y: 0 };
49
+ label.fontFamily.hollowWidth = 1;
50
+ label.vAlignment = 2;
51
+ label.hAlignment = 2;
52
+ label.size = 17;
53
+ // this.style.filter = [
54
+ // {
55
+ // rule: ["any", ["<", "startLod", "LOD"]],
56
+ // name: "startLODRule",
57
+ // style: {
58
+ // opacity: 0
59
+ // }
60
+
61
+ // }
62
+ // ];
63
+ }
64
+
65
+ this.style.labels[0].text = "`${aci}`"
66
+ this.style.fidKey = fidKey;
67
+ this.object = Object.assign({}, object, { style: this.style });
68
+
69
+ this._centerCollection = new Map();
70
+ // new inner MAP params
71
+ // hide
72
+ // textHide
73
+
74
+ this.ObjectArray.Add(this.object);
75
+
76
+ }
77
+
78
+
79
+ setCompass(mode) {
80
+ if (mode === this._flatCompassMode) return;
81
+ this._flatCompassMode = mode;
82
+ this.__onCompassChange();
83
+ }
84
+
85
+
86
+ free() {
87
+ this.flush();
88
+ this.ObjectArray.RemoveObject(this.object);
89
+ }
90
+
91
+
92
+
93
+ /**
94
+ * @param {Array<{centerID,stepAngle, x, y, rings>} ringDatas
95
+ * centerID: string | ObjectArray fidKey de kullanilir
96
+ * stepAngle: number | 0-360 arasinda
97
+ * x, y: number | merkez koordinatlari lat long radian. Globe icin dereceye iceride cevrilir
98
+ * rings: Array<{radius: number}> | En buyuk halkaya centik acilari yazilir, Sonraki adim yaricaplarin uzunlugunu yazdirmak
99
+ *
100
+ * eger bir centerID zaten var ise: Onceki noktalar dusurulur ve yeniden eklenir
101
+ *
102
+ * */
103
+ insertBulk(ringDatas) {
104
+
105
+ const addBucket = {
106
+ coords: [],
107
+ coordsZ: [],
108
+ attribs: []
109
+ }
110
+
111
+ const deleteBucket = {
112
+ coords: [],
113
+ coordsZ: [],
114
+ attribs: []
115
+ }
116
+
117
+ for (const { centerID, x, y, rings, stepAngle, hide = ENUM_HIDE.SHOW, textHide = ENUM_TEXT_HIDE.SHOW } of ringDatas) {
118
+ if (this._centerCollection.has(centerID)) {
119
+ const stepAngle = this._centerCollection.get(centerID).get("stepAngle");
120
+ this._fillDeleteBucket(centerID, stepAngle, deleteBucket);
121
+ }
122
+ const maxRadius = rings.reduce((acc, { radius }) => Math.max(acc, radius), 0);
123
+ this._appendCircle(x, y, maxRadius, stepAngle, centerID, addBucket);
124
+ this._centerCollection.set(centerID,
125
+ new Map([
126
+ ["stepAngle", stepAngle],
127
+ ["maxRadius", maxRadius],
128
+ ["x", x],
129
+ ["y", y],
130
+ ["hide", hide],
131
+ ["textHide", textHide]
132
+ ]));
133
+ }
134
+
135
+ if (deleteBucket.coords.length > 0) this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
136
+ if (addBucket.coords.length > 0) this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD);
137
+
138
+ }
139
+
140
+ /**
141
+ * @param {Array<{centerID, x,y}>} centerDatas
142
+ * aci ve radiuslarin tutulmasi gereklidir.
143
+ * */
144
+ updateCentersXY(centerDatas) {
145
+ const updateBucket = {
146
+ coords: [],
147
+ coordsZ: [],
148
+ attribs: []
149
+ }
150
+ for (const { centerID, x, y } of centerDatas) {
151
+ if (this._centerCollection.has(centerID)) {
152
+ const centerMap = this._centerCollection.get(centerID);
153
+ const maxRadius = centerMap.get("maxRadius");
154
+ const stepAngle = centerMap.get("stepAngle");
155
+ // long, lat, radius, step, centerID, outBucket
156
+ this._appendCircle(x, y, maxRadius, stepAngle, centerID, updateBucket);
157
+ centerMap.set("x", x);
158
+ centerMap.set("y", y);
159
+
160
+ }
161
+ }
162
+ for (const attribs of updateBucket.attribs) {
163
+ delete attribs["aci"];
164
+ }
165
+ if (updateBucket.coords.length > 0) {
166
+ this._updateData(updateBucket, CSObjectArrayUpdateTypes.UPDATE);
167
+ }
168
+ }
169
+
170
+
171
+
172
+ /**
173
+ *
174
+ * @param {Array<{centerID:string, hide: bool}} centerHides
175
+ */
176
+ updateCentersHide(centerHides) {
177
+ const addBucket = {
178
+ coords: [],
179
+ coordsZ: [],
180
+ attribs: []
181
+ };
182
+ const deleteBucket = {
183
+ coords: [],
184
+ coordsZ: [],
185
+ attribs: []
186
+ };
187
+ for (const { centerID, textHide = null, hide = null } of centerHides) {
188
+ if (!this._centerCollection.has(centerID)) continue;
189
+ const centerMap = this._centerCollection.get(centerID);
190
+
191
+ const isHidden = centerMap.get("hide") === ENUM_HIDE.HIDE || centerMap.get("textHide") === ENUM_TEXT_HIDE.HIDE;
192
+
193
+ const _hide = hide !== null ? hide : centerMap.get("hide");
194
+ const _textHide = textHide !== null ? textHide : centerMap.get("textHide");
195
+
196
+ const show = _hide !== ENUM_HIDE.HIDE && _textHide === ENUM_TEXT_HIDE.SHOW;
197
+ if (!isHidden && !show) {
198
+ this._fillDeleteBucket(centerID, deleteBucket);
199
+ } else if (isHidden && show) {
200
+ this._appendCircle(centerMap.get("x"), centerMap.get("y"), centerMap.get("maxRadius"), centerMap.get("stepAngle"), centerID, addBucket);
201
+ }
202
+ if (hide !== null) centerMap.set("hide", hide);
203
+ if (textHide !== null) centerMap.set("textHide", textHide);
204
+ }
205
+ if (deleteBucket.coords.length > 0) this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
206
+ if (addBucket.coords.length > 0) this._updateData(addBucket, CSObjectArrayUpdateTypes.ADD);
207
+ }
208
+
209
+
210
+ // TODO : Implement this
211
+ deleteCenters(centerIDs) {
212
+ const deleteBucket = {
213
+ coords: [],
214
+ coordsZ: [],
215
+ attribs: []
216
+ }
217
+ for (const centerID of centerIDs) {
218
+ if (this._centerCollection.has(centerID)) {
219
+ this._fillDeleteBucket(centerID, deleteBucket);
220
+ this._centerCollection.delete(centerID);
221
+ }
222
+ }
223
+ this._updateData(deleteBucket, CSObjectArrayUpdateTypes.DELETE);
224
+ }
225
+
226
+
227
+
228
+
229
+
230
+ flush() {
231
+ const data = {
232
+ coords: [],
233
+ coordsZ: [],
234
+ attribs: []
235
+ };
236
+ this._idCollector = new Set();
237
+ this.ObjectArray.SetData(this.object, data);
238
+ }
239
+
240
+ //------------------GLOBE EVENTS------------------//
241
+
242
+ setGeometry() {
243
+ this.__onCompassChange();
244
+ }
245
+
246
+
247
+ //------------------PRIVATE METHODS------------------//
248
+
249
+ __implicitCompassMode() {
250
+ const is3D = this.globe.api_GetCurrentGeometry() === 0;
251
+ if (is3D) {
252
+ return COMPASS_MODES.REAL;
253
+ } else {
254
+ return this._flatCompassMode;
255
+ }
256
+ }
257
+
258
+
259
+ __onCompassChange() {
260
+ if (this._lastImplicitCompassMode === this.__implicitCompassMode()) return;
261
+ this._lastImplicitCompassMode = this.__implicitCompassMode();
262
+ this._updateAll();
263
+ }
264
+
265
+
266
+
267
+ // TODO: compass ve gercek mesafeye gore farkli hesaplamalar yapilacak __implicitCompassMode
268
+ _appendCircle(long, lat, radius, step, centerID, outBucket) {
269
+ const currentCompassMode = this.__implicitCompassMode();
270
+ if (currentCompassMode == COMPASS_MODES.REAL) {
271
+ this.__realCoords(long, lat, radius, step, centerID, outBucket);
272
+ } else if (currentCompassMode == COMPASS_MODES.COMPASS) {
273
+ // throw new Error("Not implemented yet");
274
+ this.__compassCoords(long, lat, radius, step, centerID, outBucket);
275
+ }
276
+
277
+ }
278
+
279
+ __realCoords(long, lat, radius, stepAngle, centerID, outBucket) {
280
+ const { coords, coordsZ, attribs } = outBucket;
281
+
282
+ const coords_ = realCircle(long, lat, radius, stepAngle / Degree);
283
+ { // add 0
284
+ const { long, lat } = coords_[0];
285
+ coords.push(long, lat);
286
+ coordsZ.push(0);
287
+ const key = this._key(centerID, 0);
288
+ // fidkey is the key
289
+ attribs.push({
290
+ "__fid__": key,
291
+ "aci": "K"
292
+ });
293
+ }
294
+ let aci = stepAngle;
295
+ const cutAway = 0 == (360 % stepAngle) ? 1 : 0;
296
+ for (let i = 1; i < coords_.length - cutAway; i++) {
297
+ const { long, lat } = coords_[i];
298
+ coords.push(long, lat);
299
+ coordsZ.push(0);
300
+ const key = this._key(centerID, i);
301
+ // fidkey is the key
302
+ attribs.push({
303
+ "__fid__": key,
304
+ "aci": aci.toString()
305
+ })
306
+ aci += stepAngle;
307
+ }
308
+ }
309
+
310
+
311
+ __compassCoords(long, lat, radius, stepAngle, centerID, outBucket) {
312
+
313
+ const Dlong = Degree * long;
314
+ const Dlat = Degree * lat;
315
+
316
+ const R = 6371.0 * 1000;
317
+ const { coords, coordsZ, attribs } = outBucket;
318
+ const { globe } = this;
319
+ const radianRadius = radius / R;
320
+ const scale = Math.cos(lat);
321
+ { // add 0
322
+ const x = Dlong + Degree * (radianRadius * Math.cos(Math.PI / 2));
323
+ const y = Dlat + Degree * (radianRadius * Math.sin(Math.PI / 2) * scale);
324
+ coords.push(x, y);
325
+ coordsZ.push(0);
326
+ const key = this._key(centerID, 0);
327
+ attribs.push({
328
+ "__fid__": key,
329
+ "aci": "K"
330
+ })
331
+ }
332
+ let aci = stepAngle;
333
+ let i = 1;
334
+ const RStep = stepAngle / Degree;
335
+ for (let cstep = Math.PI / 2 - RStep; cstep > -Math.PI * 1.5; cstep -= RStep) {
336
+ if (aci >= 360) break;
337
+ const x = Dlong + Degree * (radianRadius * Math.cos(cstep));
338
+ const y = Dlat + Degree * (radianRadius * Math.sin(cstep) * scale);
339
+ coords.push(x, y);
340
+ coordsZ.push(0);
341
+ const key = this._key(centerID, i++);
342
+ attribs.push({
343
+ "__fid__": key,
344
+ "aci": Math.floor(aci).toString()
345
+ })
346
+ aci += stepAngle;
347
+ }
348
+ }
349
+
350
+
351
+ _updateData(bucket, mode) {
352
+ this.ObjectArray.UpdateData(this.object, mode, [bucket], { attribs: false, icon: false, text: false });
353
+ }
354
+
355
+
356
+ _key(centerRingKey, limpIndex) {
357
+ return `${centerRingKey}_${limpIndex}`;
358
+ }
359
+
360
+ _fillDeleteBucket(centerID, outDeleteBucket) {
361
+
362
+ const centerMap = this._centerCollection.get(centerID);
363
+ const stepAngle = centerMap.get("stepAngle");
364
+ const { coords, coordsZ, attribs } = outDeleteBucket;
365
+ let i = 0;
366
+ for (let aci = 0; aci < 360; aci += stepAngle) {
367
+ const key = this._key(centerID, i++);
368
+ coords.push(0, 0);
369
+ coordsZ.push(0);
370
+ attribs.push({
371
+ "__fid__": key,
372
+ });
373
+ }
374
+ }
375
+
376
+ _updateAll() {
377
+ const updateBucket = {
378
+ coords: [],
379
+ coordsZ: [],
380
+ attribs: []
381
+ }
382
+ for (const [centerID, centerMap] of this._centerCollection) {
383
+ const isHidden = centerMap.get("hide") === ENUM_HIDE.HIDE || centerMap.get("textHide") === ENUM_TEXT_HIDE.HIDE;
384
+ if (isHidden) continue;
385
+ const x = centerMap.get("x");
386
+ const y = centerMap.get("y");
387
+ const maxRadius = centerMap.get("maxRadius");
388
+ const stepAngle = centerMap.get("stepAngle");
389
+ this._appendCircle(x, y, maxRadius, stepAngle, centerID, updateBucket);
390
+ }
391
+ this._updateData(updateBucket, CSObjectArrayUpdateTypes.UPDATE);
392
+ }
393
+
394
+ }
395
+
396
+
397
+ const readCoords = (long, lat, radius, stepAngle) => {
398
+
399
+ const result = []
400
+ const degree = radius / R;
401
+
402
+ return result;
403
+ }
404
+
405
+
406
+
407
+
408
+ const R = 6371.0;
409
+
410
+ const flatCircle = (longitude, latitude, radius, paddingAngles) => {
411
+ const degree = radius / R;
412
+ const points = [];
413
+
414
+ for (const angle of paddingAngles) {
415
+ const x = longitude + degree * Math.cos(angle);
416
+ const y = latitude + degree * Math.sin(angle);
417
+ points.push({ long: x, lat: y });
418
+ }
419
+ return points;
420
+ }
421
+
422
+ const realCircle = (longitude, latitude, radius, stepAngle) => {
423
+ const R = 6371000;
424
+
425
+ const degree = radius / R;
426
+ const points = [];
427
+ for (let step = Math.PI / 2.0; step > -Math.PI * 1.5; step -= stepAngle) {
428
+ const y = latitude + degree * Math.sin(step);
429
+ const x = longitude + degree * Math.cos(step) / Math.cos(y);
430
+
431
+ points.push({ long: Degree * x, lat: Degree * y });
432
+ }
433
+ return points;
434
+ }
@@ -1,8 +1,9 @@
1
1
  import { rings } from "../programs";
2
-
2
+ import { COMPASS_MODES } from "./enum";
3
3
  import { PaddingFreeAngleCache } from "../programs/rings/distancering";
4
- const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
5
4
 
5
+ import RangeRingAngleText from "./rangeringangletext";
6
+ const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
6
7
 
7
8
  /**
8
9
  * @typedef RangeRingData
@@ -18,14 +19,13 @@ const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
18
19
  */
19
20
 
20
21
 
21
- export const ENUM_HIDE = Object.freeze({ SHOW: 0, HIDE: 1, HIDE_1_DEGREE_PADDINGS: 2 });
22
-
23
22
 
24
23
  export default class {
25
24
 
26
- constructor(id, oneDegreePadding = true, compass = 1, circleEdgeCount = 360) {
25
+ constructor(id, { oneDegreePadding = true, compass = COMPASS_MODES.COMPASS, circleEdgeCount = 360, showNumbers = true } = {}) {
27
26
  this.id = id;
28
27
  this.compass = compass;
28
+ this._showNumbers = showNumbers;
29
29
  this.circleEdgeCount = circleEdgeCount;
30
30
  this._onedegreepaddingOn = oneDegreePadding;
31
31
  this.bufferManager = null;
@@ -40,10 +40,13 @@ export default class {
40
40
  this.globe = globe;
41
41
  this.circleFlatProgram = new CircleFlatProgram(globe, gl);
42
42
  this.paddyFlatProgram = new PaddyFlatProgram(globe, gl);
43
-
44
43
  this.paddingFreeAngleProgram = PaddingFreeAngleCache.getProgram(globe);
44
+ if (this._showNumbers) {
45
+ this._textPlugin = new RangeRingAngleText(globe, { flatCompassMode: this.compass });
46
+ }
45
47
  }
46
48
 
49
+ // TODO: Add text free
47
50
  free() {
48
51
  this.circleFlatProgram.free();
49
52
  this.paddyFlatProgram.free();
@@ -53,6 +56,23 @@ export default class {
53
56
  }
54
57
 
55
58
 
59
+
60
+ // // TODO: Client should reinsert all data to be able to see numbers. Think Better Solution.
61
+ // setShowNumbers(showNumbers) {
62
+ // this._showNumbers = showNumbers;
63
+ // if (this._showNumbers) {
64
+ // this._textPlugin = new RangeRingAngleText(this.globe);
65
+ // } else {
66
+ // this._textPlugin?.free();
67
+ // this._textPlugin = null;
68
+ // }
69
+ // }
70
+
71
+ setGeometry() {
72
+ this._textPlugin?.setGeometry();
73
+ }
74
+
75
+
56
76
  draw3D() {
57
77
  const { circleFlatProgram, paddyFlatProgram, paddingFreeAngleProgram, bufferManager, compass, gl, circleEdgeCount, paddingBufferManager } = this;
58
78
  // if (globe.api_GetCurrentGeometry() === 0) return; // do not draw in 3D mode
@@ -77,6 +97,7 @@ export default class {
77
97
  */
78
98
  setCampass(compass) {
79
99
  this.compass = compass;
100
+ this._textPlugin?.setCompass(compass);
80
101
  }
81
102
 
82
103
  initilizeBufferManager(initialRingCapacity, bufferDrawType) {
@@ -96,6 +117,7 @@ export default class {
96
117
 
97
118
  this.bufferManager.insertBulk(insertData);
98
119
  this.paddingBufferManager.insertBulk(items);
120
+ this._textPlugin?.insertBulk(items);
99
121
  this.globe.DrawRender();
100
122
  }
101
123
 
@@ -103,6 +125,7 @@ export default class {
103
125
  updateCentersXY(items) {
104
126
  this.bufferManager.updateCentersXY(items);
105
127
  this.paddingBufferManager.updateCentersXY(items);
128
+ this._textPlugin?.updateCentersXY(items);
106
129
  this.globe.DrawRender();
107
130
  }
108
131
 
@@ -119,6 +142,7 @@ export default class {
119
142
 
120
143
  this.bufferManager.removeCenters(centerIds);
121
144
  this.paddingBufferManager.removeCenters(centerIds);
145
+ this._textPlugin?.removeCenters(centerIds);
122
146
  // this.bufferManager.defrag();
123
147
  // this.paddingBufferManager.defrag();
124
148
  this.globe.DrawRender();
@@ -129,6 +153,7 @@ export default class {
129
153
  updateCentersHide(centerHides) {
130
154
  this.bufferManager.updateCentersHide(centerHides);
131
155
  this.paddingBufferManager.updateCentersHide(centerHides);
156
+ this._textPlugin?.updateCentersHide(centerHides);
132
157
  this.globe.DrawRender();
133
158
  }
134
159
  }
@@ -73,8 +73,6 @@ vec4 cartesian3DToGLPosition( vec3 position) {
73
73
 
74
74
  // pi / pole = 2 / R
75
75
 
76
-
77
-
78
76
  export const longLatRadToMercator = R + PI + `
79
77
  vec2 longLatRadToMercator( vec2 longLatRad) {
80
78
  float x = R * longLatRad.x;
@@ -94,7 +92,6 @@ vec3 longLatRadToCartesian3D( vec2 longLat) {
94
92
  `;
95
93
 
96
94
 
97
-
98
95
  // TODO: Make it precise. It doesnt use haversine formula. If this changes, change the formmula which calculates text position.
99
96
  export const circleLimpFromLongLatRadCenterCartesian3D = R + `
100
97
  vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float angle) {
@@ -109,17 +106,17 @@ vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float
109
106
  }
110
107
  `;
111
108
 
112
- // TODO: Make it precise.
109
+ // TODO: Make it precise. Y axis is not correct.
110
+
111
+ // ln | tan [ (x/2) + (π/4) ] | + C
113
112
  export const circleLimpFromLongLatRadCenterMercatorRealDistance = `
114
113
  vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle){
115
-
116
114
  float radius_radian = radius / R;
117
115
  float lat = center.y - radius_radian * sin(angle);
118
-
119
116
  float scale = 1.0/abs( cos( lat ) );
117
+ float y = log( tan( PI / 4.0 + lat / 2.0 ) ) * R;
120
118
  vec2 center_ = longLatRadToMercator(center);
121
119
  float x = center_.x + scale * radius * cos(angle);
122
- float y = center_.y - scale * radius * sin(angle);
123
120
  return vec2(x, y);
124
121
  }
125
122
  `;