@pirireis/webglobeplugins 0.5.2 → 0.5.3-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.
@@ -80,6 +80,16 @@ export class ChainListMap {
80
80
  }
81
81
 
82
82
 
83
+ updateCoordsinatesOfNode(node, chainKey) {
84
+
85
+ const index = this.getIndexOfNode(chainKey, node.key)
86
+ const chain = this._chainMap.get(chainKey);
87
+ node.__identity__ = this.keyMethod(chainKey, node.key);
88
+ chain[index].long = node.long;
89
+ chain[index].long = node.lat;
90
+
91
+ }
92
+
83
93
  setChain(chainKey, nodeList) {
84
94
  if (this._chainMap.has(chainKey)) this._flushIndexMap();
85
95
  this._chainMap.set(chainKey, nodeList);
@@ -116,11 +126,10 @@ export class ChainListMap {
116
126
  * @param {*} chainKey
117
127
  * @param {*} callback | (value, index, array) => expexted output
118
128
  */
119
- calculateBufferPropertiesChain(chainKey, callback, result, nodeIndexes = null) {
129
+ calculateBufferPropertiesChain(chainKey, callback, result,) {
120
130
  const chain = this._chainMap.get(chainKey);
121
131
  const props = this._chainSideProperties.get(chainKey);
122
- const iterator = nodeIndexes !== null ? nodeIndexes : chain.keys();
123
- for (const i of iterator) {
132
+ for (let i = 0; i < chain.length - 1; i++) {
124
133
  const node = callback(chain[i], i, chain, props);
125
134
  if (node !== null) result.push(node);
126
135
  }
@@ -132,21 +141,12 @@ export class ChainListMap {
132
141
  * @param {*} textWriterObjs
133
142
  * @param {*} nodeKeys use nodeKeys on updateCoordinatesOnly
134
143
  */
135
- textUpdate(chainKey, textWriterObjs, nodeIndexes = null) {
144
+ textUpdate(chainKey, textWriterObjs) {
136
145
  const chain = this._chainMap.get(chainKey);
137
146
  if (!chain) return;
138
147
  const properties = this._chainSideProperties.get(chainKey);
139
- if (nodeIndexes) {
140
- textWriterObjs.forEach((writer) => {
141
- nodeIndexes.forEach((i) => {
142
- writer.insertText(chain[i], i, chain, properties);
143
- });
144
- });
145
- return;
146
- }
147
148
  textWriterObjs.forEach((writer) => {
148
- const chain = this._chainMap.get(chainKey);
149
- const properties = this._chainSideProperties.get(chainKey);
149
+
150
150
  writer.insertTextBulk(chain, properties);
151
151
  });
152
152
 
@@ -21,6 +21,16 @@ import { keyMethod } from './util';
21
21
  * updateChainProperties
22
22
  */
23
23
 
24
+
25
+ /**
26
+ * @typedef StyleProperties
27
+ * @property {[0-1,0-1,0-1,0-1]} rgba
28
+ * @property { 0-1 } dashOpacity
29
+ * @property { 0-1 } dashRatio
30
+ * @property {0-360} circleDashAngle
31
+ * @property {Array<node>} nodes
32
+ */
33
+
24
34
  const radian = Math.PI / 180;
25
35
 
26
36
  export class CircleLineChainPlugin {
@@ -28,7 +38,7 @@ export class CircleLineChainPlugin {
28
38
  constructor(id, { drawCircleOn = true, textContextWriterInjectionMap = new Map() } = {}) {
29
39
  this.id = id;
30
40
  this._textContextWriterInjectionMap = textContextWriterInjectionMap;
31
- this._textContextWriterInjectionMap.forEach((writer) => writer.setKeyAdaptor((v, i, c, probs) => v.__identity__));
41
+ this._textContextWriterInjectionMap.forEach((writer) => writer.setKeyAdaptor((v, i, c, properties) => v.__identity__));
32
42
  this._opacity = 1;
33
43
  this._chainListMap = new ChainListMap(keyMethod);
34
44
  this.bufferOrchestrator = new BufferOrchestrator({ capacity: 10 });
@@ -64,7 +74,10 @@ export class CircleLineChainPlugin {
64
74
  }],
65
75
  ["rgba", {
66
76
  'bufferManager': new BufferManager(gl, 4, { bufferType, initialCapacity }),
67
- 'adaptor': (item) => new Float32Array(item.rgba)
77
+ 'adaptor': (item) => {
78
+ if (item.lineProperties?.rgba) return new Float32Array(item.lineProperties.rgba);
79
+ return new Float32Array(item.chainProperties.rgba);
80
+ }
68
81
  }],
69
82
  ["bigRadius", {
70
83
  'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
@@ -72,27 +85,38 @@ export class CircleLineChainPlugin {
72
85
  }],
73
86
  ["dashRatio", {
74
87
  'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
75
- 'adaptor': (item) => new Float32Array([item.dashRatio])
88
+ 'adaptor': (item) => new Float32Array([item.chainProperties.dashRatio])
76
89
  }],
77
90
 
78
91
  ["dashOpacity", {
79
92
  'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
80
- 'adaptor': (item) => new Float32Array([item.dashOpacity])
93
+ 'adaptor': (item) => new Float32Array([item.chainProperties.dashOpacity])
81
94
  }],
82
95
  ["circleDashAngle", {
83
96
  'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
84
- 'adaptor': (item) => new Float32Array([item.circleDashAngle / 360])
97
+ 'adaptor': (item) => {
98
+ if (item.circleProperties?.circleDashAngle) return new Float32Array([item.circleProperties.circleDashAngle / 360]);
99
+ return new Float32Array([item.chainProperties.circleDashAngle / 360]);
100
+ }
101
+ }],
102
+ ["rgbaCircle", {
103
+ "bufferManager": new BufferManager(gl, 4, { bufferType, initialCapacity }),
104
+ "adaptor": (item) => {
105
+ if (item.circleProperties?.rgba) return new Float32Array(item.circleProperties.rgba);
106
+ return new Float32Array(item.chainProperties.rgba);
107
+ }
85
108
  }]
86
109
  ]
87
110
  );
88
111
  // (startPotisionBufferObj, endPositionBufferObj, dashRatioBufferObj, colorBufferObj)
89
112
  const obj = function (bufferManagerComp) {
113
+ console.log(bufferManagerComp);
90
114
  return { 'buffer': bufferManagerComp.bufferManager.buffer, 'stride': 0, 'offset': 0 }
91
115
  };
92
116
  this.lineVao = this.lineProgram.createVAO(
93
117
  ...['centerCoords', 'targetCoords', 'dashRatio', 'dashOpacity', 'rgba'].map(key => obj(this.bufferManagersCompMap.get(key))));
94
118
  this.circleVao = this.circleProgram.createVAO(
95
- ...["centerCoords", "bigRadius", "rgba", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
119
+ ...["centerCoords", "bigRadius", "rgbaCircle", "circleDashAngle", "dashOpacity"].map(key => obj(this.bufferManagersCompMap.get(key))));
96
120
  }
97
121
 
98
122
  }
@@ -127,7 +151,7 @@ export class CircleLineChainPlugin {
127
151
  for (const chain of data) {
128
152
  chainKeys.push(chain.chainKey);
129
153
  chain.nodes.forEach((node) => {
130
- this._chainListMap.updateNode(node, chain.chainKey);
154
+ this._chainListMap.updateCoordsinatesOfNode(node, chain.chainKey);
131
155
  });
132
156
  }
133
157
  this._reconstructChains(chainKeys);
@@ -152,16 +176,15 @@ export class CircleLineChainPlugin {
152
176
  * @param {Array<chain>} data
153
177
  * @typedef chain
154
178
  * @property {string} chainKey
155
- * @property {[0-1,0-1,0-1,0-1]} rgba
156
- * @property { 0-1 } dashOpacity
157
- * @property { 0-1 } dashRatio
158
- * @property {0-360} circleDashAngle
159
- * @property {Array<node>} nodes
179
+ * @property {StyleProperties} chainProperties
180
+
181
+ * } chainProperties
160
182
  *
161
183
  * @typedef {Object} node
162
184
  * @property {string} key
163
185
  * @property {number} long
164
186
  * @property {number} lat
187
+ * @property {StyleProperties} circleProperties
165
188
  */
166
189
  insertBulk(data, { textWriterIDs = [] } = []) {
167
190
  // first insert everything to implicit structure,
@@ -169,11 +192,9 @@ export class CircleLineChainPlugin {
169
192
  // let _reconstractChainBufferData method interact with data and bufferOrchestrator.
170
193
  const chainKeysToConstruct = [];
171
194
 
172
- for (const { chainKey, rgba, dashOpacity, dashRatio, circleDashAngle, nodes } of data) {
195
+ for (const { chainKey, chainProperties, nodes } of data) {
173
196
  this._chainListMap.setChain(chainKey, nodes);
174
- this._chainListMap.setChainProperties(chainKey, {
175
- rgba, dashOpacity, dashRatio, circleDashAngle, chainKey
176
- });
197
+ this._chainListMap.setChainProperties(chainKey, chainProperties);
177
198
  chainKeysToConstruct.push(chainKey);
178
199
  }
179
200
  this._reconstructChains(chainKeysToConstruct);
@@ -271,18 +292,17 @@ export class CircleLineChainPlugin {
271
292
  // }
272
293
 
273
294
  const radiusM = radiusMethod(globe);
274
- const callback = (v, i, array, probs) => {
295
+ const callback = (v, i, array, chainProperties) => {
275
296
  if (i == array.length - 1) return null;
276
297
  return {
277
- rgba: probs.rgba,
298
+ chainProperties: chainProperties,
278
299
  bigRadius: radiusM(v, i, array),
279
- circleDashAngle: probs.circleDashAngle,
280
- dashOpacity: probs.dashOpacity,
281
- dashRatio: probs.dashRatio,
282
- long: v.long,
283
- lat: v.lat,
284
300
  targetLong: array[i + 1].long,
285
301
  targetLat: array[i + 1].lat,
302
+ long: v.long,
303
+ lat: v.lat,
304
+ lineProperties: v.lineProperties,
305
+ circleProperties: v.circleProperties,
286
306
  key: v.__identity__
287
307
  }
288
308
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-a",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -292,7 +292,7 @@ export default class RangeRingAngleText {
292
292
 
293
293
 
294
294
 
295
- showAllVisiableCircleText() {
295
+ showAllVisibleCircleText() {
296
296
  this._hideAll = false;
297
297
  const addBucket = {
298
298
  coords: [],
@@ -54,6 +54,7 @@ export class BufferManager {
54
54
  const offsetMultiplier = itemSize * 4;
55
55
  for (let i = 0; i < blocks.length; i++) {
56
56
  const block = blocks[i];
57
+ console.log(block)
57
58
  const offset = offsets[i] * offsetMultiplier;
58
59
  if (offset !== undefined) gl.bufferSubData(gl.ARRAY_BUFFER, offset, block);
59
60
  }