@pirireis/webglobeplugins 0.4.0-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,6 +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.setKeyAdaptor((v, i, c, probs) => keyMethod(probs.chainKey, v.key)));
32
33
  this._opacity = 1;
33
34
  this._chainListMap = new ChainListMap();
34
35
  this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
@@ -125,7 +126,7 @@ export class CircleLineChainPlugin {
125
126
  });
126
127
  }
127
128
  this._reconstructChains(chainKeys);
128
- this._insertTexts(chainKeys, textWriterIDs);
129
+ this._updateTexts(chainKeys, textWriterIDs);
129
130
  }
130
131
 
131
132
 
@@ -137,7 +138,7 @@ export class CircleLineChainPlugin {
137
138
  updateChainProperties(chainKey, propertyMap, { textWriterIDs = [] } = {}) {
138
139
  this._chainListMap.updateChainProperties(chainKey, propertyMap);
139
140
  this._reconstructChains([chainKey]);
140
- if (textWriterIDs) this._insertTexts([chainKey], textWriterIDs);
141
+ if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
141
142
  }
142
143
 
143
144
  // ---- insertBulk family
@@ -171,7 +172,7 @@ export class CircleLineChainPlugin {
171
172
  chainKeysToConstruct.push(chainKey);
172
173
  }
173
174
  this._reconstructChains(chainKeysToConstruct);
174
- if (textWriterIDs) this._insertTexts(chainKeysToConstruct, textWriterIDs);
175
+ if (textWriterIDs) this._updateTexts(chainKeysToConstruct, textWriterIDs);
175
176
  }
176
177
 
177
178
  /**
@@ -180,20 +181,20 @@ export class CircleLineChainPlugin {
180
181
  * @param {*} chainKey
181
182
  * @param {*} theNodeKeyFront | node key of the next node, null places to the last
182
183
  */
183
- addNode(node, chainKey, { theNodeKeyFront = null, textContextIDs = [] } = {}) {
184
+ addNode(node, chainKey, { theNodeKeyFront = null, textWriterIDs = [] } = {}) {
184
185
  // TODO: if before object is null update the last two elements of the chain only.
185
186
  console.log("addNode", node, chainKey, theNodeKeyFront);
186
187
  this._chainListMap.addNode(node, chainKey, theNodeKeyFront);
187
- if (textContextIDs) this._insertTexts([chainKey], textContextIDs);
188
+ if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
188
189
  this._reconstructChains([chainKey]);
189
190
 
190
191
  }
191
192
 
192
193
 
193
194
 
194
- updateNodeCoordinates(node, chainKey, { textContextIDs = [] } = {}) {
195
+ updateNodeCoordinates(node, chainKey, { textWriterIDs = [] } = {}) {
195
196
  this._chainListMap.updateNode(node, chainKey);
196
- if (textContextIDs) this._insertTexts([chainKey], textContextIDs);
197
+ if (textWriterIDs) this._updateTexts([chainKey], textWriterIDs);
197
198
  this._reconstructChains([chainKey]);
198
199
  }
199
200
 
@@ -220,7 +221,7 @@ export class CircleLineChainPlugin {
220
221
  }
221
222
  console.log("delete chain keys", chainKeys);
222
223
  console.log("deletechains bufferKeys", bufferKeys);
223
- this._insertTexts(chainKeys, this._textContextWriterInjectionMap.keys());
224
+ this._updateTexts(chainKeys, this._textContextWriterInjectionMap.keys());
224
225
  this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
225
226
  this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
226
227
  }
@@ -230,7 +231,7 @@ export class CircleLineChainPlugin {
230
231
  *
231
232
  * @param {Array<{key, nodeKeys:[]} keysAndNodes
232
233
  */
233
- deleteNodes(keysAndNodes) {
234
+ deleteNodes(keysAndNodes, { textWriterIDs = [] } = {}) {
234
235
  const bufferKeys = [];
235
236
  const chainKeysToReconstuct = [];
236
237
  keysAndNodes.forEach(({ chainKey, nodeKeys }) => {
@@ -239,13 +240,14 @@ export class CircleLineChainPlugin {
239
240
  });
240
241
  this._reconstructChains(chainKeysToReconstuct);
241
242
  this._textContextWriterInjectionMap.forEach((writer) => writer.deleteTextBulk(bufferKeys));
243
+ if (textWriterIDs) this._updateTexts(chainKeysToReconstuct, textWriterIDs)
242
244
  this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
243
245
  }
244
246
 
245
247
 
246
248
  // implicit
247
249
 
248
- _insertTexts(chainKeys, textWriterIDs) {
250
+ _updateTexts(chainKeys, textWriterIDs) {
249
251
  const textWriters = textWriterIDs.map((v) => this._textContextWriterInjectionMap.get(v));
250
252
  chainKeys.forEach((chainKey) => {
251
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.0a",
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;