@pirireis/webglobeplugins 0.6.30-c → 0.6.31-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.
@@ -40,14 +40,14 @@ export default class Plugin {
40
40
  /**
41
41
  *
42
42
  * @param {*} id
43
- * @param {Map<[key, ContextTextWriter3]>} textContextInjectionMap
43
+ * @param {Map<[key, ContextTextWriter3]>} textWritersMap
44
44
  *
45
45
  */
46
46
 
47
47
  constructor(id,
48
48
  {
49
49
  opacity = 1,
50
- textContextInjectionMap = new Map(),
50
+ textWritersMap = new Map(),
51
51
  textDataPreAdaptor = null,
52
52
  drawVRM = true,
53
53
  drawBearingLine = true,
@@ -58,9 +58,9 @@ export default class Plugin {
58
58
  this.id = id;
59
59
  this._opacity = opacity;
60
60
  this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
61
- this._checkTextContextWriterInjectionMap(textContextInjectionMap);
62
- this._textContextInjectionMap = textContextInjectionMap;
63
- this._textContextInjectionMap.forEach((writer) => writer.keyAdaptor = (item) => item.key);
61
+ this._checkTextContextWriterInjectionMap(textWritersMap);
62
+ this._textWritersMap = textWritersMap;
63
+ this._textWritersMap.forEach((writer) => writer.keyAdaptor = (item) => item.key);
64
64
  this.drawVRM = drawVRM;
65
65
  this.drawBearingLine = drawBearingLine;
66
66
  this.drawAngleRing = drawAngleRing;
@@ -93,7 +93,6 @@ export default class Plugin {
93
93
 
94
94
 
95
95
 
96
-
97
96
  setDoDrawAngleRing(bool) {
98
97
  if (bool === this.drawAngleRing) return;
99
98
  this.drawAngleRing = bool;
@@ -101,19 +100,14 @@ export default class Plugin {
101
100
  }
102
101
 
103
102
 
104
-
105
-
106
-
107
103
  setOpacity(opacity) {
108
104
  constraintFloat(opacity, 0, 1);
109
105
  this._opacity = opacity;
110
- this._textContextInjectionMap.forEach((writer) => writer.setOpacity(opacity));
106
+ this._textWritersMap.forEach((writer) => writer.setOpacity(opacity));
111
107
  this.globe.DrawRender();
112
108
  }
113
109
 
114
110
 
115
-
116
-
117
111
  init(globe, gl) {
118
112
  this.gl = gl;
119
113
  this.globe = globe;
@@ -157,14 +151,7 @@ export default class Plugin {
157
151
  'bufferManager': new BufferManager(gl, 3, { bufferType, initialCapacity }),
158
152
  'adaptor': (item) => new Float32Array(globe.api_GetCartesian3DPoint(item.bearingLong, item.bearingLat, 0, 0))
159
153
  }],
160
- ["startAngle", {
161
- 'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
162
- 'adaptor': (item) => new Float32Array([item.startAngle])
163
- }],
164
- ["tailAngle", {
165
- 'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
166
- 'adaptor': (item) => new Float32Array([item.tailAngle])
167
- }],
154
+
168
155
  ["startAngle2d", {
169
156
  'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
170
157
  'adaptor': (item) => new Float32Array([item.startAngle2d])
@@ -201,10 +188,7 @@ export default class Plugin {
201
188
  'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
202
189
  'adaptor': (item) => new Float32Array([item.dashRatio])
203
190
  }],
204
- ["bearingAngle", {
205
- 'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
206
- 'adaptor': (item) => new Float32Array([item.bearingAngle])
207
- }],
191
+
208
192
  ["bigRadius", {
209
193
  'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
210
194
  'adaptor': (item) => new Float32Array([item.bigRadius])
@@ -291,7 +275,7 @@ export default class Plugin {
291
275
  }
292
276
  }
293
277
  if (this.drawText) {
294
- this._textContextInjectionMap.forEach((writer) => writer.draw());
278
+ this._textWritersMap.forEach((writer) => writer.draw());
295
279
  }
296
280
  gl.enable(gl.DEPTH_TEST);
297
281
  }
@@ -313,9 +297,9 @@ export default class Plugin {
313
297
  * @property {number} dashOpacity 0-1
314
298
  * @property {number} circleDashAngle 0-360
315
299
  * @param {Array<item>} items
316
- * @param {Array<string>} textWriterIDs | textContextInjectionMap keys to be used for writing text.
300
+ * @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
317
301
  */
318
- insertBulk(items, textWriterIDs = []) {
302
+ insertBulk(items, { textWriterIDs = [] } = {}) {
319
303
  const { globe, bufferOrchestrator, bufferManagersCompMap } = this;// angleTextContext, distanceTextContext,
320
304
  const data = []
321
305
  for (let item of items) {
@@ -329,9 +313,9 @@ export default class Plugin {
329
313
 
330
314
 
331
315
  updateText(textWriterIDs) {
332
- const textContextInjectionMap = textWriterGetOrThrow(this._textContextInjectionMap, textWriterIDs);
316
+ const textWritersMap = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
333
317
  this._memoryForText.forEach((item) => {
334
- textContextInjectionMap.forEach((writer) => writer.insertText(item));
318
+ textWritersMap.forEach((writer) => writer.insertText(item));
335
319
  });
336
320
  this.globe.DrawRender();
337
321
  }
@@ -353,18 +337,18 @@ export default class Plugin {
353
337
 
354
338
  /**
355
339
  * @param {Array<{key, long, lat, endLong, endLat, bearingAngle}>} items
356
- * @param {Array<string>} textWriterIDs | textContextInjectionMap keys to be used for writing text.
340
+ * @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
357
341
  */
358
- updateCoordinatesBulk(items, textWriterIDs = []) {
342
+ updateCoordinatesBulk(items, { textWriterIDs = [] } = {}) {
359
343
  const { globe, bufferOrchestrator, bufferManagersCompMap, } = this;
360
344
  const data = []
361
345
  for (let item of items) {
362
346
  data.push(this.__updateCoordsAdaptor(item));
363
347
  }
364
348
  this.__insertTexts(items, textWriterIDs);
365
- bufferOrchestrator.updateBulk(data, bufferManagersCompMap, ["centerCoords2d", "centerCoords3d", "targetCoords2d", "targetCoords3d", "startAngle", "tailAngle",
349
+ bufferOrchestrator.updateBulk(data, bufferManagersCompMap, ["centerCoords2d", "centerCoords3d", "targetCoords2d", "targetCoords3d",
366
350
  "startAngle2d", "tailAngle2d", "startAngle3d", "tailAngle3d", "bearingTargetCoords2d", "bearingTargetCoords3d", "centerCoords2dflat",
367
- "bearingAngle", "bigRadius", "radius"]);
351
+ "bigRadius", "radius"]);
368
352
  globe.DrawRender();
369
353
  }
370
354
 
@@ -375,9 +359,9 @@ export default class Plugin {
375
359
  * @param {string} propertyIDs
376
360
  * @param {string} textWriterIDs
377
361
  * Do NOT send empty data if property ID of this data is entered or NaN is loaded to the buffer, resulting in an unwanted behaviour.
378
- * textWriterIDs = []
362
+ *{ textWriterIDs = []}
379
363
  */
380
- updatePartial(items, propertyIDs = [], textWriterIDs = []) {
364
+ updatePartial(items, propertyIDs = [], { textWriterIDs = [] } = {}) {
381
365
  if (propertyIDs.length === 0) console.warn("updatePartial is called with no target propertyIDs");
382
366
  const fixedPropertyIDs = this.__fixPartialProperties(propertyIDs)
383
367
  const { bufferOrchestrator, bufferManagersCompMap } = this;
@@ -397,13 +381,13 @@ export default class Plugin {
397
381
 
398
382
 
399
383
  __insertTexts(items, textWriterIDs) {
400
- const textContextInjectionMap = textWriterGetOrThrow(this._textContextInjectionMap, textWriterIDs);
384
+ const textWritersMap = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
401
385
  for (const item of items) {
402
386
  const oldItem = this._memoryForText.get(item.key);
403
387
  let _item = oldItem !== undefined ? { ...oldItem, ...item } : item;
404
388
  if (this._textDataPreAdaptor !== null) _item = this._textDataPreAdaptor(_item);
405
389
  this._memoryForText.set(item.key, _item);
406
- textContextInjectionMap.forEach((writer) => writer.insertText(_item));
390
+ textWritersMap.forEach((writer) => writer.insertText(_item));
407
391
  }
408
392
  }
409
393
 
@@ -505,7 +489,7 @@ export default class Plugin {
505
489
 
506
490
 
507
491
  _deleteTexts(keys) {
508
- this._textContextInjectionMap.forEach((writer) => {
492
+ this._textWritersMap.forEach((writer) => {
509
493
  writer.deleteTextBulk(keys);
510
494
  });
511
495
  }
@@ -41,18 +41,18 @@ export class CircleLineChainPlugin {
41
41
  /**
42
42
  *
43
43
  * @param {*} id
44
- * @param {Map<[key, ContextTextWriter3]} textContextWriterInjectionMap //import { ContextTextWriter3 } from "@pirireis/webglobeplugins/write-text/context-text3";
44
+ * @param {Map<[key, ContextTextWriter3]} textWritersMap //import { ContextTextWriter3 } from "@pirireis/webglobeplugins/write-text/context-text3";
45
45
  */
46
46
  constructor(id, {
47
47
  drawCircleOn = true,
48
- textContextWriterInjectionMap = new Map(),
48
+ textWritersMap = new Map(),
49
49
  textDataPreAdaptor = null,
50
50
  circleFlatEdgeCount = flatCircleEdgeCount - 2
51
51
  } = {}) {
52
52
  this.id = id;
53
- this._checkTextContextWriterInjectionMap(textContextWriterInjectionMap);
54
- this._textContextWriterInjectionMap = textContextWriterInjectionMap;
55
- this._textContextWriterInjectionMap.forEach((writer) => writer.setKeyAdaptor((v, i, c, properties) => v.__identity__));
53
+ this._checktextWritersMap(textWritersMap);
54
+ this._textWritersMap = textWritersMap;
55
+ this._textWritersMap.forEach((writer) => writer.setKeyAdaptor((v, i, c, properties) => v.__identity__));
56
56
  this._opacity = 1;
57
57
  this._chainListMap = new ChainListMap(keyMethod);
58
58
  this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
@@ -69,10 +69,10 @@ export class CircleLineChainPlugin {
69
69
  this._initOrchestrations()
70
70
  }
71
71
 
72
- _checkTextContextWriterInjectionMap(textContextWriterInjectionMap) {
73
- if (!(textContextWriterInjectionMap instanceof Map)) throw new Error("textContextWriterInjectionMap is not an instance of Map");
74
- textContextWriterInjectionMap.forEach((v) => {
75
- if (!(v instanceof ContextTextWriter3)) throw new Error("textContextWriterInjectionMap element is not an instance of ContextTextWriter3");
72
+ _checktextWritersMap(textWritersMap) {
73
+ if (!(textWritersMap instanceof Map)) throw new Error("textWritersMap is not an instance of Map");
74
+ textWritersMap.forEach((v) => {
75
+ if (!(v instanceof ContextTextWriter3)) throw new Error("textWritersMap element is not an instance of ContextTextWriter3");
76
76
  });
77
77
  }
78
78
 
@@ -258,7 +258,7 @@ export class CircleLineChainPlugin {
258
258
  * @property {number} lat
259
259
  * @property {StyleProperties} circleProperties
260
260
  */
261
- insertBulk(data, { textWriterIDs = [] } = []) {
261
+ insertBulk(data, { textWriterIDs = [] } = {}) {
262
262
  // first insert everything to implicit structure,
263
263
  // then iterate over data again to update text
264
264
  // let _reconstractChainBufferData method interact with data and bufferOrchestrator.
@@ -302,7 +302,7 @@ export class CircleLineChainPlugin {
302
302
  setOpacity(opacity) {
303
303
  if (typeof opacity !== 'number') throw new Error("opacity must be a number");
304
304
  if (opacity < 0 || 1 < opacity) throw new Error("opacity must be between 0-1");
305
- this._textContextWriterInjectionMap.forEach((writer) => writer.setOpacity(opacity));
305
+ this._textWritersMap.forEach((writer) => writer.setOpacity(opacity));
306
306
  this._opacity = opacity;
307
307
  this.globe.DrawRender();
308
308
  }
@@ -322,8 +322,8 @@ export class CircleLineChainPlugin {
322
322
  for (const chainKey of chainKeys) {
323
323
  bufferKeys.push(...this._chainListMap.deleteChainAndReturnChainKeys(chainKey));
324
324
  }
325
- this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
326
- this._updateTexts(chainKeys, this._textContextWriterInjectionMap.keys());
325
+ this._textWritersMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
326
+ this._updateTexts(chainKeys, this._textWritersMap.keys());
327
327
  this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
328
328
  this.globe.DrawRender();
329
329
  }
@@ -340,7 +340,7 @@ export class CircleLineChainPlugin {
340
340
  bufferKeys.push(...this._chainListMap.deleteNodesBelongToAChain(chainKey, nodeKeys));
341
341
  chainKeysToReconstuct.push(chainKey);
342
342
  });
343
- this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
343
+ this._textWritersMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
344
344
  this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
345
345
  this._reconstructChains(chainKeysToReconstuct);
346
346
  this._updateTexts(chainKeysToReconstuct, textWriterIDs);
@@ -359,7 +359,7 @@ export class CircleLineChainPlugin {
359
359
 
360
360
  _updateTexts(chainKeys, textWriterIDs) {
361
361
  if (textWriterIDs.length === 0) return;
362
- const textWriters = textWriterGetOrThrow(this._textContextWriterInjectionMap, textWriterIDs)
362
+ const textWriters = textWriterGetOrThrow(this._textWritersMap, textWriterIDs)
363
363
  chainKeys.forEach((chainKey) => {
364
364
  this._chainListMap.textUpdate(chainKey, textWriters, this._textDataPreAdaptor);
365
365
  })
@@ -419,7 +419,7 @@ export class CircleLineChainPlugin {
419
419
  CircleCache.release(this.globe);
420
420
  Circle3DCache.release(this.globe);
421
421
  LineToTheOriginCache.release(this.globe);
422
- this._textContextWriterInjectionMap.forEach((writer) => writer.free());
422
+ this._textWritersMap.forEach((writer) => writer.free());
423
423
  const { gl } = this;
424
424
  gl.deleteVertexArray(this.lineVao);
425
425
  gl.deleteVertexArray(this.circleVao2d);
@@ -434,7 +434,7 @@ export class CircleLineChainPlugin {
434
434
  const { gl, globe } = this;
435
435
  gl.disable(gl.DEPTH_TEST);
436
436
  this.lineProgram.draw(this.lineVao, this.bufferOrchestrator.length, this._opacity);
437
- this._textContextWriterInjectionMap.forEach((writer) => writer.draw());
437
+ this._textWritersMap.forEach((writer) => writer.draw());
438
438
  // this.lineToTheOriginProgram.draw(this.toOriginVao, this.bufferOrchestrator.length, this._opacity);
439
439
  const is3D = globe.api_GetCurrentGeometry() === 0;
440
440
  if (this._drawCircleOn) {
@@ -454,4 +454,4 @@ const radiusMethod = (globe) => (v, i, array) => {
454
454
  return globe.Math.GetDist3D(v.long, v.lat, array[i + 1].long, array[i + 1].lat)
455
455
  }
456
456
 
457
- const textWriterGetOrThrow = mapGetOrThrow("textWriterIds is invalid")
457
+ const textWriterGetOrThrow = mapGetOrThrow("textWriterIDs is invalid")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.6.30-c",
3
+ "version": "0.6.31-a",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -160,12 +160,6 @@ export class ContextTextWriter3 {
160
160
  }
161
161
 
162
162
 
163
- updateText() {
164
- this.itemMap.forEach((v, k, m) => {
165
- const { payload } = v;
166
- this.insertText(payload, 0, m, payload);
167
- });
168
- }
169
163
 
170
164
  clear() {
171
165
  this.itemMap.clear();