@pirireis/webglobeplugins 0.4.1-a → 0.4.2-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.
@@ -29,7 +29,7 @@ export class CircleLineChainPlugin {
29
29
  constructor(id, { textContextWriterInjectionMap = new Map() } = {}) {
30
30
  this.id = id;
31
31
  this._textContextWriterInjectionMap = textContextWriterInjectionMap;
32
- this._textContextWriterInjectionMap.forEach((writer) => writer.keyAdaptor = (v, i, c, probs) => keyMethod(probs.chainKey, v.key));
32
+ this._textContextWriterInjectionMap.forEach((writer) => writer.setKeyAdaptor((v, i, c, probs) => keyMethod(probs.chainKey, v.key)));
33
33
  this._opacity = 1;
34
34
  this._chainListMap = new ChainListMap();
35
35
  this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
@@ -126,7 +126,7 @@ export class CircleLineChainPlugin {
126
126
  });
127
127
  }
128
128
  this._reconstructChains(chainKeys);
129
- this._insertTexts(chainKeys, textWriterIDs);
129
+ this._updateTexts(chainKeys, textWriterIDs);
130
130
  }
131
131
 
132
132
 
@@ -138,7 +138,7 @@ export class CircleLineChainPlugin {
138
138
  updateChainProperties(chainKey, propertyMap, { textWriterIDs = [] } = {}) {
139
139
  this._chainListMap.updateChainProperties(chainKey, propertyMap);
140
140
  this._reconstructChains([chainKey]);
141
- if (textWriterIDs) this._insertTexts([chainKey], textWriterIDs);
141
+ if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
142
142
  }
143
143
 
144
144
  // ---- insertBulk family
@@ -172,7 +172,7 @@ export class CircleLineChainPlugin {
172
172
  chainKeysToConstruct.push(chainKey);
173
173
  }
174
174
  this._reconstructChains(chainKeysToConstruct);
175
- if (textWriterIDs) this._insertTexts(chainKeysToConstruct, textWriterIDs);
175
+ if (textWriterIDs) this._updateTexts(chainKeysToConstruct, textWriterIDs);
176
176
  }
177
177
 
178
178
  /**
@@ -181,20 +181,20 @@ export class CircleLineChainPlugin {
181
181
  * @param {*} chainKey
182
182
  * @param {*} theNodeKeyFront | node key of the next node, null places to the last
183
183
  */
184
- addNode(node, chainKey, { theNodeKeyFront = null, textContextIDs = [] } = {}) {
184
+ addNode(node, chainKey, { theNodeKeyFront = null, textWriterIDs = [] } = {}) {
185
185
  // TODO: if before object is null update the last two elements of the chain only.
186
186
  console.log("addNode", node, chainKey, theNodeKeyFront);
187
187
  this._chainListMap.addNode(node, chainKey, theNodeKeyFront);
188
- if (textContextIDs) this._insertTexts([chainKey], textContextIDs);
188
+ if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
189
189
  this._reconstructChains([chainKey]);
190
190
 
191
191
  }
192
192
 
193
193
 
194
194
 
195
- updateNodeCoordinates(node, chainKey, { textContextIDs = [] } = {}) {
195
+ updateNodeCoordinates(node, chainKey, { textWriterIDs = [] } = {}) {
196
196
  this._chainListMap.updateNode(node, chainKey);
197
- if (textContextIDs) this._insertTexts([chainKey], textContextIDs);
197
+ if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
198
198
  this._reconstructChains([chainKey]);
199
199
  }
200
200
 
@@ -221,7 +221,7 @@ export class CircleLineChainPlugin {
221
221
  }
222
222
  console.log("delete chain keys", chainKeys);
223
223
  console.log("deletechains bufferKeys", bufferKeys);
224
- this._insertTexts(chainKeys, this._textContextWriterInjectionMap.keys());
224
+ this._updateTexts(chainKeys, this._textContextWriterInjectionMap.keys());
225
225
  this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
226
226
  this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
227
227
  }
@@ -231,7 +231,7 @@ export class CircleLineChainPlugin {
231
231
  *
232
232
  * @param {Array<{key, nodeKeys:[]} keysAndNodes
233
233
  */
234
- deleteNodes(keysAndNodes) {
234
+ deleteNodes(keysAndNodes, { textWriterIDs = [] } = {}) {
235
235
  const bufferKeys = [];
236
236
  const chainKeysToReconstuct = [];
237
237
  keysAndNodes.forEach(({ chainKey, nodeKeys }) => {
@@ -240,13 +240,14 @@ export class CircleLineChainPlugin {
240
240
  });
241
241
  this._reconstructChains(chainKeysToReconstuct);
242
242
  this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
243
+ if (textWriterIDs) this._updateTexts(chainKeysToReconstuct, textWriterIDs)
243
244
  this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
244
245
  }
245
246
 
246
247
 
247
248
  // implicit
248
249
 
249
- _insertTexts(chainKeys, textWriterIDs) {
250
+ _updateTexts(chainKeys, textWriterIDs) {
250
251
  const textWriters = textWriterIDs.map((v) => this._textContextWriterInjectionMap.get(v));
251
252
  chainKeys.forEach((chainKey) => {
252
253
  this._chainListMap.textUpdate(chainKey, textWriters);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.4.1-a",
3
+ "version": "0.4.2-a",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -14,6 +14,9 @@ const defaultStyle = {
14
14
  zMode: CSZMode.Z_GROUND_PERVERTEX,
15
15
  }
16
16
 
17
+ /**
18
+ * keyAdaptor should be set but higher context since it nows key methods and key method might be implicit to user
19
+ */
17
20
  export class ContextTextWriter2 {
18
21
  constructor(globe, { style = null, doDraw = true, textAdaptor = null, coordinatesAdaptor = null, keyAdaptor = null, opacityAdaptor = null } = {}) {
19
22
  this.globe = globe;
@@ -32,6 +35,9 @@ export class ContextTextWriter2 {
32
35
  }
33
36
  }
34
37
 
38
+ setKeyAdaptor(adaptor) {
39
+ this.keyAdaptor = adaptor;
40
+ }
35
41
 
36
42
  setDoDraw(bool) {
37
43
  this.doDraw = bool;