@pirireis/webglobeplugins 0.13.0-alpha → 0.14.0-alpha

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.
Files changed (54) hide show
  1. package/Math/arc-cdf-points.js +20 -0
  2. package/Math/arc-generate-points copy.js +1 -0
  3. package/Math/arc.js +21 -8
  4. package/Math/circle.js +35 -16
  5. package/Math/templete-shapes/grid-visually-equal.js +66 -0
  6. package/altitude-locator/plugin.js +3 -2
  7. package/bearing-line/plugin.js +1 -2
  8. package/circle-line-chain/plugin.js +4 -7
  9. package/compass-rose/compass-rose-padding-flat.js +12 -0
  10. package/package.json +1 -1
  11. package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
  12. package/programs/line-on-globe/linestrip/linestrip.js +5 -3
  13. package/programs/line-on-globe/naive-accurate-flexible.js +23 -16
  14. package/programs/picking/pickable-renderer.js +1 -2
  15. package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
  16. package/programs/rings/partial-ring/piece-of-pie.js +26 -13
  17. package/programs/totems/camerauniformblock.js +1 -1
  18. package/programs/totems/index.js +1 -1
  19. package/range-tools-on-terrain/bearing-line/adapters.js +111 -0
  20. package/range-tools-on-terrain/bearing-line/plugin.js +360 -0
  21. package/range-tools-on-terrain/circle-line-chain/adapters.js +83 -0
  22. package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +351 -0
  23. package/range-tools-on-terrain/circle-line-chain/plugin.js +389 -0
  24. package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
  25. package/range-tools-on-terrain/range-ring/adapters.js +25 -0
  26. package/range-tools-on-terrain/range-ring/plugin.js +31 -0
  27. package/range-tools-on-terrain/range-ring/types.js +1 -0
  28. package/rangerings/plugin.js +7 -11
  29. package/semiplugins/lightweight/line-plugin.js +195 -0
  30. package/semiplugins/lightweight/piece-of-pie-plugin.js +175 -0
  31. package/semiplugins/shape-on-terrain/arc-plugin.js +368 -0
  32. package/{shape-on-terrain/circle/plugin.js → semiplugins/shape-on-terrain/circle-plugin.js} +67 -38
  33. package/semiplugins/shape-on-terrain/derived/padding-plugin.js +96 -0
  34. package/semiplugins/type.js +1 -0
  35. package/types.js +0 -11
  36. package/util/account/create-buffermap-orchastration.js +39 -0
  37. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -3
  38. package/util/check/typecheck.js +15 -1
  39. package/util/geometry/index.js +3 -2
  40. package/util/gl-util/buffer/attribute-loader.js +2 -5
  41. package/util/gl-util/draw-options/methods.js +4 -5
  42. package/util/webglobjectbuilders.js +4 -9
  43. package/write-text/context-text3.js +17 -0
  44. package/write-text/context-text3old.js +152 -0
  45. package/programs/line-on-globe/circle-accurate.js +0 -176
  46. package/programs/line-on-globe/circle.js +0 -166
  47. package/programs/line-on-globe/to-the-surface.js +0 -111
  48. package/programs/totems/canvas-webglobe-info1.js +0 -106
  49. package/shape-on-terrain/arc/naive/plugin.js +0 -250
  50. package/util/check/get.js +0 -14
  51. package/util/gl-util/buffer/types.js +0 -1
  52. package/util/gl-util/draw-options/types.js +0 -15
  53. package/util/webglobjectbuilders1.js +0 -219
  54. /package/{shape-on-terrain/type.js → range-tools-on-terrain/bearing-line/types.js} +0 -0
@@ -0,0 +1,351 @@
1
+ /**
2
+ * set and get node data
3
+ * node indexes;
4
+ */
5
+ export class ChainListMap {
6
+ _chainMap;
7
+ _chainSideProperties;
8
+ _indexMap; // hold list index of lastly updated nodes. on add delete goes empty
9
+ keyMethod;
10
+ constructor(keyMethod) {
11
+ this._chainMap = new Map();
12
+ this._chainSideProperties = new Map();
13
+ this._indexMap = new Map();
14
+ this.keyMethod = keyMethod;
15
+ }
16
+ hasChain(chainKey) {
17
+ return this._chainMap.has(chainKey);
18
+ }
19
+ getNodes(chainKey) {
20
+ return this._chainMap.get(chainKey);
21
+ }
22
+ /**
23
+ *
24
+ * @param node
25
+ * @param chainKey
26
+ * @param theNodeKeyFront
27
+ */
28
+ addNode(node, chainKey, theNodeKeyFront = null) {
29
+ const chain = this.getNodes(chainKey);
30
+ if (!chain)
31
+ return;
32
+ let frontIndex = null;
33
+ for (let i = 0; i < chain.length; i++) {
34
+ const n_ode = chain[i];
35
+ if (n_ode.key === node.key) {
36
+ throw new Error("Chain node already exists");
37
+ }
38
+ if (n_ode.key === theNodeKeyFront) {
39
+ frontIndex = i;
40
+ }
41
+ }
42
+ if (theNodeKeyFront !== null) {
43
+ if (frontIndex !== null) {
44
+ chain.splice(frontIndex, 0, node);
45
+ }
46
+ else {
47
+ throw new Error("Could not find theNodeKeyFront");
48
+ }
49
+ }
50
+ else {
51
+ chain.push(node);
52
+ }
53
+ node.__identity__ = this.keyMethod(chainKey, node.key);
54
+ this._resetIndexChain(chainKey);
55
+ }
56
+ deleteNodesBelongToAChain(chainKey, nodeKeys) {
57
+ const chain = this._chainMap.get(chainKey);
58
+ if (!chain)
59
+ return [];
60
+ const deleteKeys = [];
61
+ const removeSet = new Set(nodeKeys);
62
+ const newChain = [];
63
+ for (let i = 0; i < chain.length - 1; i++) {
64
+ const node = chain[i];
65
+ const dKey = node.__identity__;
66
+ this._indexMap.delete(dKey);
67
+ if (removeSet.has(node.key)) {
68
+ deleteKeys.push(dKey);
69
+ }
70
+ else {
71
+ newChain.push(node);
72
+ }
73
+ }
74
+ { // last item case
75
+ const lastItem = chain[chain.length - 1];
76
+ this._indexMap.delete(lastItem.__identity__);
77
+ if (removeSet.has(lastItem.key)) {
78
+ if (chain.length > 1) {
79
+ deleteKeys.push(chain[chain.length - 2].__identity__);
80
+ deleteKeys.push(chain[chain.length - 1].__identity__);
81
+ }
82
+ }
83
+ else {
84
+ newChain.push(lastItem);
85
+ }
86
+ }
87
+ this._chainMap.set(chainKey, newChain);
88
+ return deleteKeys;
89
+ }
90
+ deleteChainAndReturnChainKeys(chainKey) {
91
+ const keys = this.getNodeKeysOfChain(chainKey);
92
+ this._chainMap.delete(chainKey);
93
+ this._chainSideProperties.delete(chainKey); // TODO: this might be this way but adding this know can cause side effects
94
+ for (const key of keys)
95
+ this._indexMap.delete(key);
96
+ return keys;
97
+ }
98
+ updateNode(node, chainKey) {
99
+ const index = this.getIndexOfNode(chainKey, node.key);
100
+ if (index === undefined)
101
+ return;
102
+ const chain = this._chainMap.get(chainKey);
103
+ if (!chain)
104
+ return;
105
+ node.__identity__ = this.keyMethod(chainKey, node.key);
106
+ chain[index] = node;
107
+ }
108
+ updateNodesProperties(chainKey, nodes) {
109
+ nodes.forEach((node) => {
110
+ const index = this.getIndexOfNode(chainKey, node.key);
111
+ if (index === undefined)
112
+ return;
113
+ const chain = this._chainMap.get(chainKey);
114
+ if (!chain)
115
+ return;
116
+ const chainNode = chain[index];
117
+ if (node.circleProperties) {
118
+ if (typeof chainNode.circleProperties !== 'object')
119
+ chainNode.circleProperties = {};
120
+ Object.entries(node.circleProperties).forEach(([key, value]) => {
121
+ chainNode.circleProperties[key] = value;
122
+ });
123
+ }
124
+ if (node.lineProperties) {
125
+ if (typeof chainNode.lineProperties !== 'object')
126
+ chainNode.lineProperties = {};
127
+ Object.entries(node.lineProperties).forEach(([key, value]) => {
128
+ chainNode.lineProperties[key] = value;
129
+ });
130
+ }
131
+ });
132
+ }
133
+ updateCoordsinatesOfNode(node, chainKey) {
134
+ const index = this.getIndexOfNode(chainKey, node.key);
135
+ if (index === undefined)
136
+ return;
137
+ const chain = this._chainMap.get(chainKey);
138
+ if (!chain)
139
+ return;
140
+ chain[index].long = node.long;
141
+ chain[index].lat = node.lat;
142
+ }
143
+ setChain(chainKey, nodeList) {
144
+ if (this._chainMap.has(chainKey))
145
+ this._flushIndexMap();
146
+ this._chainMap.set(chainKey, nodeList);
147
+ nodeList.forEach((v) => v.__identity__ = this.keyMethod(chainKey, v.key));
148
+ }
149
+ setChainProperties(chainKey, properties) {
150
+ this._chainSideProperties.set(chainKey, properties);
151
+ }
152
+ /**
153
+ *
154
+ * @param chainKey
155
+ * @param properties
156
+ * // after this method update text and buffer data of the chain
157
+ */
158
+ updateChainProperties(chainKey, properties) {
159
+ const memoryProperties = this._chainSideProperties.get(chainKey);
160
+ if (!memoryProperties)
161
+ return;
162
+ properties.forEach((value, key) => {
163
+ memoryProperties[key] = value;
164
+ });
165
+ }
166
+ // TODO: bad name clean up, need to check on frontend
167
+ getNodeProperties(chainKey) {
168
+ return this._chainSideProperties.get(chainKey);
169
+ }
170
+ getChainProperties(chainKey) {
171
+ return this._chainSideProperties.get(chainKey);
172
+ }
173
+ /**
174
+ *
175
+ * @param chainKey
176
+ * @param callback | (value, index, array) => expected output
177
+ */
178
+ calculateBufferPropertiesChain(chainKey, callback, result) {
179
+ const chain = this._chainMap.get(chainKey);
180
+ if (!chain)
181
+ return;
182
+ const props = this._chainSideProperties.get(chainKey);
183
+ if (!props)
184
+ return;
185
+ for (let i = 0; i < chain.length - 1; i++) {
186
+ const node = callback(chain[i], i, chain, props);
187
+ if (node !== null)
188
+ result.push(node);
189
+ }
190
+ }
191
+ /**
192
+ * @param chainKey
193
+ * @param textWriterObjs
194
+ * @param dataPreAdaptor use nodeKeys on updateCoordinatesOnly
195
+ */
196
+ textUpdate(chainKey, textWriterObjs, dataPreAdaptor) {
197
+ const chain = this._chainMap.get(chainKey);
198
+ if (!chain)
199
+ return;
200
+ const data = (dataPreAdaptor) ? chain.map(dataPreAdaptor) : chain;
201
+ const properties = this._chainSideProperties.get(chainKey);
202
+ if (!properties)
203
+ return;
204
+ textWriterObjs.forEach((writer) => {
205
+ writer.insertTextBulk(data, properties);
206
+ });
207
+ }
208
+ getAllChainKeysIterator() {
209
+ return this._chainMap.keys();
210
+ }
211
+ getIndexOfNode(chainKey, nodeKey) {
212
+ const key = this.keyMethod(chainKey, nodeKey);
213
+ if (this._indexMap.has(key))
214
+ return this._indexMap.get(key);
215
+ const chain = this._chainMap.get(chainKey);
216
+ if (!chain)
217
+ return undefined;
218
+ for (let i = 0; i < chain.length; i++) {
219
+ const node = chain[i];
220
+ this._indexMap.set(key, i);
221
+ if (node.key === nodeKey) {
222
+ return i;
223
+ }
224
+ }
225
+ return undefined;
226
+ }
227
+ _flushIndexMap() {
228
+ this._indexMap.clear();
229
+ }
230
+ _resetIndexChain(chainKey) {
231
+ const chain = this._chainMap.get(chainKey);
232
+ if (!chain)
233
+ return;
234
+ for (let i = 0; i < chain.length; i++) {
235
+ const node = chain[i];
236
+ this._indexMap.set(this.keyMethod(chainKey, node.key), i);
237
+ }
238
+ }
239
+ getNodeKeysOfChain(chainKey) {
240
+ const chain = this._chainMap.get(chainKey);
241
+ if (!chain) {
242
+ console.warn(`Chain with key ${chainKey} not found.`);
243
+ return [];
244
+ }
245
+ ;
246
+ const result = chain.map((v) => v.__identity__);
247
+ return result;
248
+ }
249
+ getChain(chainKey, output) {
250
+ const nodes = this.getNodes(chainKey);
251
+ if (!nodes)
252
+ return undefined;
253
+ const chainProperties = this.getChainProperties(chainKey) ?? {};
254
+ // Directly modify the output object
255
+ if (!output) {
256
+ output = {}; // Create a new object if not provided
257
+ }
258
+ output.chainKey = chainKey;
259
+ output.chainProperties = chainProperties;
260
+ output.nodes = nodes;
261
+ return output;
262
+ }
263
+ }
264
+ // // #####################################
265
+ // // #####################################
266
+ // this.clcPlugin = new CircleLineChainPlugin('circleLineChain', {
267
+ // textDataPreAdaptor: _this.textWriter.preAdaptor,
268
+ // textWritersMap: new Map([
269
+ // ['distance', this.textWriter.distance],
270
+ // ['totalDistance', this.textWriter.totalDistance],
271
+ // ]),
272
+ // });
273
+ // // #####################################
274
+ // // #####################################
275
+ // _this.clcPlugin.deleteNodes(
276
+ // [
277
+ // {
278
+ // chainKey: chainKey,
279
+ // nodeKeys: [currentNodes[index].key],
280
+ // },
281
+ // ],
282
+ // { textWriterIDs: ['distance', 'totalDistance'] },
283
+ // );
284
+ // // #####################################
285
+ // // #####################################
286
+ // this.clcPlugin.updateText(['distance', 'totalDistance']);
287
+ // // #####################################
288
+ // // #####################################
289
+ // this.clcPlugin.updateNodeCoordinates(
290
+ // {
291
+ // key: key,
292
+ // lat: lat,
293
+ // long: long,
294
+ // },
295
+ // chainKey,
296
+ // { textWriterIDs: ['distance', 'totalDistance'] },
297
+ // );
298
+ // // #####################################
299
+ // // #####################################
300
+ // this.clcPlugin.deleteChains([chainKey]);
301
+ // // #####################################
302
+ // // #####################################
303
+ // for (const key of this.clcPlugin._chainListMap._chainMap.keys()) { }
304
+ // // #####################################
305
+ // // #####################################
306
+ // _this.clcPlugin.insertBulk(
307
+ // [
308
+ // {
309
+ // chainKey: chainKey,
310
+ // nodes: [{ ...currentNode }, { ...nextNode }],
311
+ // chainProperties: {
312
+ // ...pluginOptions,
313
+ // rgba: HelperJS.normalizeRGBA(pluginOptions.rgba),
314
+ // dashOpacity: 1,
315
+ // },
316
+ // },
317
+ // ],
318
+ // {
319
+ // textWriterIDs: ['distance', 'totalDistance'],
320
+ // },
321
+ // );
322
+ // // #####################################
323
+ // // #####################################
324
+ // _this.clcPlugin.addNode(
325
+ // {
326
+ // key: `point-${chainNodes.length + 1}-${uuidv4()}`,
327
+ // lat: currentCoords.lat,
328
+ // long: currentCoords.long,
329
+ // circleProperties: {},
330
+ // },
331
+ // chainKey,
332
+ // {
333
+ // theNodeKeyFront: null,
334
+ // textWriterIDs: ['distance', 'totalDistance'],
335
+ // },
336
+ // );
337
+ // // #####################################
338
+ // // #####################################
339
+ // _this.clcPlugin.updateNodesProperties(chainKey, updateNodes, {
340
+ // textWriterIDs: ['distance', 'totalDistance'],
341
+ // });
342
+ // // #####################################
343
+ // // #####################################
344
+ // this.clcPlugin._chainListMap.getChain(chainKey); // ismi degisti. plugininde benzer metodu var.
345
+ // // #####################################
346
+ // // #####################################
347
+ // this.clcPlugin.setDrawCircleOn(show);
348
+ // // #####################################
349
+ // // #####################################
350
+ // this.clcPlugin.free();
351
+ // // #####################################