@pirireis/webglobeplugins 0.6.41-a → 0.6.43-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.
@@ -28,7 +28,7 @@ export default class BearingLinePlugin {
28
28
  {
29
29
  opacity = 1,
30
30
  textWritersMap = new Map(),
31
- textDataPreAdaptor = null,
31
+ textDataPreAdaptor = (x) => x,
32
32
  drawVRM = true,
33
33
  drawBearingLine = true,
34
34
  drawAngleRing = true,
@@ -118,11 +118,25 @@ export default class BearingLinePlugin {
118
118
  }
119
119
 
120
120
 
121
- updateText(textWriterIDs) {
121
+ /**
122
+ * @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
123
+ * @param {Array<string>} itemKeys | if empty, all texts will be updated.
124
+ */
125
+ updateText(textWriterIDs = [], itemKeys = null) {
122
126
  const textWritersMap = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
123
- this._memoryForText.forEach((item) => {
124
- textWritersMap.forEach((writer) => writer.insertText(item));
125
- });
127
+ if (itemKeys === null) {
128
+ this._memoryForText.forEach((item) => {
129
+ let _item = this._textDataPreAdaptor(item);
130
+ textWritersMap.forEach((writer) => writer.insertText(_item));
131
+ });
132
+ } else {
133
+ itemKeys.forEach((key) => {
134
+ let item = this._memoryForText.get(key);
135
+ if (item === undefined) return;
136
+ let _item = this._textDataPreAdaptor(item);
137
+ textWritersMap.forEach((writer) => writer.insertText(_item));
138
+ });
139
+ }
126
140
  this.globe.DrawRender();
127
141
  }
128
142
 
@@ -193,8 +207,8 @@ export default class BearingLinePlugin {
193
207
  for (const item of items) {
194
208
  const oldItem = this._memoryForText.get(item.key);
195
209
  let _item = oldItem !== undefined ? { ...oldItem, ...item } : item;
196
- if (this._textDataPreAdaptor !== null) _item = this._textDataPreAdaptor(_item);
197
210
  this._memoryForText.set(item.key, _item);
211
+ if (this._textDataPreAdaptor !== null) _item = this._textDataPreAdaptor(_item);
198
212
  textWritersMap.forEach((writer) => writer.insertText(_item));
199
213
  }
200
214
  }
@@ -13,9 +13,7 @@ export class ChainListMap {
13
13
  }
14
14
 
15
15
  getChain(chainKey) {
16
- if (!this._chainMap.has(chainKey)) this._chainMap.set(chainKey, []);
17
16
  return this._chainMap.get(chainKey);
18
-
19
17
  }
20
18
 
21
19
  /**
@@ -126,9 +126,16 @@ export class CircleLineChainPlugin {
126
126
  }
127
127
 
128
128
 
129
- updateText(textWriterIDs) {
130
- const chainKeyIterator = this._chainListMap.getAllChainKeysIterator();
131
- this._updateTexts(chainKeyIterator, textWriterIDs);
129
+ /**
130
+ *
131
+
132
+ /**
133
+ * @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
134
+ * @param {Array<string>} chainKeys | if empty, all texts will be updated
135
+ */
136
+ updateText(textWriterIDs = [], chainKeys = null) {
137
+ if (chainKeys === null) chainKeys = this._chainListMap.getAllChainKeysIterator();
138
+ this._updateTexts(chainKeys, textWriterIDs);
132
139
  this.globe.DrawRender();
133
140
  }
134
141
 
@@ -354,7 +361,7 @@ export class CircleLineChainPlugin {
354
361
  const textWriters = textWriterGetOrThrow(this._textWritersMap, textWriterIDs)
355
362
  chainKeys.forEach((chainKey) => {
356
363
  this._chainListMap.textUpdate(chainKey, textWriters, this._textDataPreAdaptor);
357
- })
364
+ });
358
365
  }
359
366
 
360
367
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.6.41-a",
3
+ "version": "0.6.43-a",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -51,7 +51,7 @@ import { LinesColorInstancedFlatCache } from "../programs/line-on-globe/lines-co
51
51
  import { BufferOrchestrator, BufferManager } from "../util/account";
52
52
  import { mapGetOrThrow } from "../util/check/get";
53
53
  import { populateFloat32Array } from "../util/jshelpers/data-filler";
54
- import { RingAccount, ringBigPaddingKeyMethod } from "./ring-account";
54
+ import { RingAccount, ringBigPaddingKeyMethod, ringKeyMethod } from "./ring-account";
55
55
  import { CirclePadding3DCache } from "../programs/line-on-globe/degree-padding-around-circle-3d";
56
56
  import { LineOnGlobeCache } from '../programs/line-on-globe/naive-accurate';
57
57
  import RangeRingAngleText from "./rangeringangletext";
@@ -83,12 +83,9 @@ class RangeRings {
83
83
  this._textWritersMap = textWritersMap;
84
84
  this._textDataPreAdaptor = textDataPreAdaptor;
85
85
  this._textWritersMap.forEach((textWriter) => textWriter.setKeyAdaptor((item) => item.__identity__));
86
-
87
86
  }
88
87
 
89
88
 
90
-
91
-
92
89
  // USER API
93
90
 
94
91
  /**
@@ -220,21 +217,32 @@ class RangeRings {
220
217
  * 2. delete from buffer orchestators
221
218
  * 3. mark centers as hidden
222
219
  */
223
-
224
220
  }
225
221
 
226
222
 
227
223
  /**
228
- * Use on ContextTextWriter adaptor methods are updated
229
- * */
230
- updateText(textWriterIDs) {
224
+ * @param {Array<string>} textWriterIDs textWritersMap keys to be used for writing text.
225
+ * @param {Array<string>} itemKeys if empty, all texts will be updated. Use {@link ringKeyMethod} method to get keys
226
+ */
227
+ updateText(textWriterIDs = [], itemKeys = null) {
231
228
  const textWritersMap = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
232
- this._ringAccount.updateAllText(textWritersMap, this._textDataPreAdaptor);
229
+ if (itemKeys === null) {
230
+ this._ringAccount.updateAllText(textWritersMap, this._textDataPreAdaptor);
231
+ this.globe.DrawRender();
232
+ } else {
233
+ itemKeys.forEach((key) => {
234
+ const item = this._ringAccount.getCenter(key);
235
+ if (item === undefined) throw new Error("Center not found");
236
+ const textData = this._textDataPreAdaptor(item);
237
+ textWritersMap.forEach((textWriter) => textWriter.insertText(textData));
238
+ });
239
+ }
233
240
  this.globe.DrawRender();
234
241
  }
235
242
 
236
243
 
237
244
 
245
+
238
246
  /**
239
247
  * @method removeCenters @param { Array < { centerID } >} centerIDs
240
248
  */
@@ -274,7 +282,7 @@ class RangeRings {
274
282
  * @method setOpacity @param { number } opacity
275
283
  */
276
284
  setOpacity(opacity) {
277
- if (typeof opacity !== "number" || opacity < 0 || opacity > 1) throw new Error("Invalid opacity value");
285
+ if (typeof opacity !== "number" || opacity < 0 || opacity > 1) throw new Error("Invalid value for opacity");
278
286
  this._opacity = opacity;
279
287
  this.textPlugin?.setOpacity(opacity);
280
288
  this._textWritersMap.forEach((writer) => writer.setOpacity(opacity));
@@ -455,12 +455,7 @@ ${shaderfunctions.pixelXYToCartesian3DPoint}
455
455
  ${shaderfunctions.pixelXYToCartesian2DPoint}
456
456
 
457
457
  void main() {
458
- // if ( a_color.x < .0 || a_color.y < .0 || a_color.z < .0) {
459
- // v_time = -1000000000.0;
460
- // v_track_end_time = -1000000000.0;
461
- // v_track_start_time = -1000000001.0;
462
- // return;
463
- // }
458
+
464
459
  v_time = a_time;
465
460
  v_color = a_color;
466
461
  v_track_start_time = a_track_start_time;