@pirireis/webglobeplugins 0.9.9 → 0.9.11

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 (212) hide show
  1. package/Math/angle-calculation.js +15 -0
  2. package/Math/arc.js +65 -0
  3. package/Math/bounds/line-bbox.js +190 -0
  4. package/Math/constants.js +9 -0
  5. package/Math/frustum/camera.js +24 -0
  6. package/Math/frustum/from-globeinfo.js +48 -0
  7. package/Math/frustum/types.js +2 -0
  8. package/Math/globe-util/horizon-plane.js +112 -0
  9. package/Math/index.js +1 -0
  10. package/Math/juction/arc-plane.js +83 -0
  11. package/Math/juction/line-sphere.js +25 -0
  12. package/Math/juction/plane-plane.js +58 -0
  13. package/Math/line.js +58 -0
  14. package/Math/matrix4.js +1 -0
  15. package/Math/methods.js +206 -0
  16. package/Math/plane.js +62 -0
  17. package/Math/quaternion.js +108 -0
  18. package/Math/types.js +2 -0
  19. package/Math/utils.js +4 -0
  20. package/Math/vec3.js +129 -0
  21. package/algorithms/search-binary.js +19 -0
  22. package/altitude-locator/adaptors.js +1 -0
  23. package/altitude-locator/draw-subset-obj.js +19 -0
  24. package/altitude-locator/keymethod.js +1 -0
  25. package/altitude-locator/plugin.js +357 -0
  26. package/altitude-locator/types.js +23 -0
  27. package/arrowfield/adaptor.js +15 -0
  28. package/arrowfield/index.js +10 -0
  29. package/arrowfield/plugin.js +89 -0
  30. package/bearing-line/index.js +8 -0
  31. package/bearing-line/plugin.js +474 -0
  32. package/circle-line-chain/chain-list-map.js +211 -0
  33. package/circle-line-chain/init.js +1 -0
  34. package/circle-line-chain/plugin.js +449 -0
  35. package/circle-line-chain/util.js +5 -0
  36. package/compass-rose/compass-rose-padding-flat.js +247 -0
  37. package/compass-rose/compass-text-writer.js +161 -0
  38. package/compass-rose/index.js +7 -0
  39. package/compassrose/compassrose.js +300 -0
  40. package/compassrose/index.js +8 -0
  41. package/globe-types.js +1 -0
  42. package/heatwave/index.js +10 -0
  43. package/heatwave/isobar/objectarraylabels.js +206 -0
  44. package/heatwave/isobar/plugin.js +362 -0
  45. package/heatwave/isobar/quadtreecontours.js +316 -0
  46. package/heatwave/plugins/heatwaveglobeshell.js +224 -0
  47. package/index.js +11 -11
  48. package/jest.config.js +7 -0
  49. package/package.json +4 -4
  50. package/partialrings/buffer-manager.js +113 -0
  51. package/partialrings/index.js +41 -0
  52. package/partialrings/plugin.js +171 -0
  53. package/partialrings/program.js +197 -0
  54. package/pin/pin-object-array.js +308 -0
  55. package/pin/pin-point-totem.js +61 -0
  56. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
  57. package/point-heat-map/index.js +1 -0
  58. package/point-heat-map/plugin-webworker.js +131 -0
  59. package/point-heat-map/point-to-heat-map-flow.js +129 -0
  60. package/point-tracks/key-methods.js +5 -0
  61. package/point-tracks/plugin.js +353 -0
  62. package/programs/arrowfield/index.js +7 -0
  63. package/programs/arrowfield/logic.js +149 -0
  64. package/programs/arrowfield/object.js +68 -0
  65. package/programs/data2legend/density-to-legend.js +77 -0
  66. package/programs/data2legend/point-to-density-texture.js +75 -0
  67. package/programs/float2legendwithratio/index.js +8 -0
  68. package/programs/float2legendwithratio/logic.js +125 -0
  69. package/programs/float2legendwithratio/object.js +113 -0
  70. package/programs/globe-util/is-globe-moved.js +22 -0
  71. package/programs/globeshell/index.js +8 -0
  72. package/programs/globeshell/noise/noises.js +1 -0
  73. package/programs/globeshell/wiggle/index.js +8 -0
  74. package/programs/globeshell/wiggle/logic.js +252 -0
  75. package/programs/globeshell/wiggle/object.js +74 -0
  76. package/programs/helpers/blender/index.js +1 -0
  77. package/programs/helpers/blender/program.js +62 -0
  78. package/programs/helpers/fadeaway/index.js +7 -0
  79. package/programs/helpers/fadeaway/logic.js +50 -0
  80. package/programs/helpers/fadeaway/object.js +21 -0
  81. package/programs/helpers/index.js +8 -0
  82. package/programs/index.js +58 -0
  83. package/programs/interface.js +1 -0
  84. package/programs/line-on-globe/angled-line.js +117 -0
  85. package/programs/line-on-globe/circle-accurate-3d.js +91 -0
  86. package/programs/line-on-globe/circle-accurate-flat.js +158 -0
  87. package/programs/line-on-globe/circle-accurate.js +108 -0
  88. package/programs/line-on-globe/circle.js +102 -0
  89. package/programs/line-on-globe/degree-padding-around-circle-3d.js +109 -0
  90. package/programs/line-on-globe/index.js +1 -0
  91. package/programs/line-on-globe/lines-color-instanced-flat.js +91 -0
  92. package/programs/line-on-globe/linestrip.js +110 -0
  93. package/programs/line-on-globe/naive-accurate-flexible.js +125 -0
  94. package/programs/line-on-globe/to-the-surface.js +82 -0
  95. package/programs/line-on-globe/util.js +8 -0
  96. package/programs/picking/pickable-renderer.js +104 -0
  97. package/programs/point-on-globe/element-globe-surface-glow.js +102 -0
  98. package/programs/point-on-globe/element-point-glow.js +85 -0
  99. package/programs/point-on-globe/square-pixel-point.js +125 -0
  100. package/programs/programcache.js +131 -0
  101. package/programs/rings/distancering/circleflatprogram.js +114 -0
  102. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +358 -0
  103. package/programs/rings/distancering/circlepaddysharedbuffer.js +433 -0
  104. package/programs/rings/distancering/index.js +14 -0
  105. package/programs/rings/distancering/paddyflatprogram.js +119 -0
  106. package/programs/rings/distancering/paddyflatprogram2d.js +121 -0
  107. package/programs/rings/distancering/paddyflatprogram3d.js +119 -0
  108. package/programs/rings/distancering/shader.js +1 -0
  109. package/programs/rings/index.js +17 -0
  110. package/programs/rings/partial-ring/piece-of-pie.js +173 -0
  111. package/programs/totems/camerauniformblock.js +147 -0
  112. package/programs/totems/canvas-webglobe-info.js +102 -0
  113. package/programs/totems/gpu-selection-uniform-block.js +104 -0
  114. package/programs/totems/index.js +40 -0
  115. package/programs/two-d/pixel-circle.js +1 -0
  116. package/programs/two-d/pixel-padding-for-compass.js +101 -0
  117. package/programs/util.js +18 -0
  118. package/programs/vectorfields/index.js +23 -0
  119. package/programs/vectorfields/logics/drawrectangleparticles.js +66 -0
  120. package/programs/vectorfields/logics/index.js +12 -0
  121. package/programs/vectorfields/logics/pixelbased.js +86 -0
  122. package/programs/vectorfields/logics/ubo.js +57 -0
  123. package/programs/vectorfields/pingpongbuffermanager.js +80 -0
  124. package/rangerings/enum.js +5 -0
  125. package/rangerings/index.js +15 -0
  126. package/rangerings/plugin.js +610 -0
  127. package/rangerings/rangeringangletext.js +341 -0
  128. package/rangerings/ring-account.js +134 -0
  129. package/shaders/fragment-toy/firework.js +4 -0
  130. package/shaders/fragment-toy/singularity.js +5 -0
  131. package/shape-on-terrain/arc/naive/plugin.js +252 -0
  132. package/timetracks/adaptors-line-strip.js +82 -0
  133. package/timetracks/adaptors.js +136 -0
  134. package/timetracks/index.js +19 -0
  135. package/timetracks/plugin-line-strip.js +254 -0
  136. package/timetracks/plugin.js +262 -0
  137. package/timetracks/program-line-strip.js +418 -0
  138. package/timetracks/program.js +466 -0
  139. package/timetracks/programpoint-line-strip.js +101 -0
  140. package/timetracks/programpoint.js +101 -0
  141. package/types.js +15 -0
  142. package/util/account/bufferoffsetmanager.js +202 -0
  143. package/util/account/index.js +23 -0
  144. package/util/account/single-attribute-buffer-management/buffer-manager.js +112 -0
  145. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +180 -0
  146. package/util/account/single-attribute-buffer-management/index.js +9 -0
  147. package/util/account/single-attribute-buffer-management/object-store.js +53 -0
  148. package/util/account/single-attribute-buffer-management/types.js +2 -0
  149. package/util/account/util.js +24 -0
  150. package/util/algorithms/index.js +1 -0
  151. package/util/algorithms/search-binary.js +28 -0
  152. package/util/check/get.js +18 -0
  153. package/util/check/index.js +1 -0
  154. package/util/check/typecheck.js +51 -0
  155. package/util/geometry/index.js +53 -0
  156. package/util/gl-util/buffer/attribute-loader.js +81 -0
  157. package/util/gl-util/buffer/index.js +6 -0
  158. package/util/gl-util/buffer/types.js +1 -0
  159. package/util/gl-util/draw-options/methods.js +38 -0
  160. package/util/gl-util/draw-options/types.js +15 -0
  161. package/util/gl-util/uniform-block/manager.js +168 -0
  162. package/util/gl-util/uniform-block/shader.js +1 -0
  163. package/util/gl-util/uniform-block/types.js +8 -0
  164. package/util/heatwavedatamanager/datamanager.js +212 -0
  165. package/util/heatwavedatamanager/index.js +10 -0
  166. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +125 -0
  167. package/util/heatwavedatamanager/pointcoordsmeta.js +21 -0
  168. package/util/index.js +57 -0
  169. package/util/interpolation/index.js +1 -0
  170. package/util/interpolation/timetrack/index.js +5 -0
  171. package/util/interpolation/timetrack/timetrack-interpolator.js +81 -0
  172. package/util/interpolation/timetrack/web-worker-str.js +5 -0
  173. package/util/interpolation/timetrack/web-worker.js +48 -0
  174. package/util/jshelpers/data-filler.js +20 -0
  175. package/util/jshelpers/equality.js +20 -0
  176. package/util/jshelpers/index.js +37 -0
  177. package/util/jshelpers/timefilters.js +32 -0
  178. package/util/picking/fence.js +46 -0
  179. package/util/picking/picker-displayer.js +145 -0
  180. package/util/programs/draw-texture-on-canvas.js +71 -0
  181. package/util/programs/index.js +17 -0
  182. package/util/programs/shapesonglobe.js +174 -0
  183. package/util/programs/supersampletotextures.js +107 -0
  184. package/util/programs/texturetoglobe.js +132 -0
  185. package/util/shaderfunctions/geometrytransformations.js +45 -0
  186. package/util/shaderfunctions/index.js +18 -0
  187. package/util/shaderfunctions/nodata.js +5 -0
  188. package/util/shaderfunctions/noisefunctions.js +13 -0
  189. package/util/surface-line-data/arc-bboxes.js +25 -0
  190. package/util/surface-line-data/arcs-to-cuts.js +53 -0
  191. package/util/surface-line-data/cut-arc.js +1 -0
  192. package/util/surface-line-data/flow.js +28 -0
  193. package/util/surface-line-data/rbush-manager.js +1 -0
  194. package/util/surface-line-data/types.js +1 -0
  195. package/util/surface-line-data/web-worker.js +1 -0
  196. package/util/webglobe/gldefaultstates.js +7 -0
  197. package/util/webglobe/index.js +18 -0
  198. package/util/webglobe/rasteroverlay.js +80 -0
  199. package/util/webglobjectbuilders.js +393 -0
  200. package/util/webglobjectbuilders1.js +238 -0
  201. package/waveparticles/adaptor.js +18 -0
  202. package/waveparticles/index.js +10 -0
  203. package/waveparticles/plugin.js +271 -0
  204. package/wind/imagetovectorfieldandmagnitude.js +35 -0
  205. package/wind/index.js +14 -0
  206. package/wind/plugin.js +724 -0
  207. package/wind/vectorfieldimage.js +25 -0
  208. package/write-text/attached-text-writer.js +93 -0
  209. package/write-text/context-text.js +105 -0
  210. package/write-text/context-text3.js +160 -0
  211. package/write-text/index.js +5 -0
  212. package/write-text/writer-plugin.js +8 -0
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChainListMap = void 0;
4
+ /**
5
+ * set and get node data
6
+ * node indexes;
7
+ */
8
+ var ChainListMap = /** @class */ (function () {
9
+ function ChainListMap(keyMethod) {
10
+ this._chainMap = new Map();
11
+ this._chainSideProperties = new Map();
12
+ this._indexMap = new Map(); // hold list index of lastly updated nodes. on add delete goes empty
13
+ this.keyMethod = keyMethod;
14
+ }
15
+ ChainListMap.prototype.getChain = function (chainKey) {
16
+ return this._chainMap.get(chainKey);
17
+ };
18
+ /**
19
+ *
20
+ * @param {*} node
21
+ * @param {*} chainKey
22
+ * @param {string|null} theNodeKeyFront
23
+ */
24
+ ChainListMap.prototype.addNode = function (node, chainKey, theNodeKeyFront) {
25
+ if (theNodeKeyFront === void 0) { theNodeKeyFront = null; }
26
+ var chain = this.getChain(chainKey);
27
+ var frontIndex = null;
28
+ for (var i = 0; i < chain.length; i++) {
29
+ var n_ode = chain[i];
30
+ if (n_ode.key === node.key) {
31
+ throw new Error("Chain node already exists");
32
+ }
33
+ if (n_ode.key === theNodeKeyFront) {
34
+ frontIndex = i;
35
+ }
36
+ }
37
+ if (theNodeKeyFront !== null) {
38
+ if (frontIndex !== null) {
39
+ chain.splice(frontIndex, 0, node);
40
+ }
41
+ else {
42
+ throw new Error("Could not find theNodeKeyFront");
43
+ }
44
+ }
45
+ else {
46
+ chain.push(node);
47
+ }
48
+ node.__identity__ = this.keyMethod(chainKey, node.key);
49
+ this._resetIndexChain(chainKey);
50
+ };
51
+ ChainListMap.prototype.deleteNodesBelongToAChain = function (chainKey, nodeKeys) {
52
+ var chain = this._chainMap.get(chainKey);
53
+ var deleteKeys = [];
54
+ var removeSet = new Set(nodeKeys);
55
+ var newChain = [];
56
+ for (var i = 0; i < chain.length - 1; i++) {
57
+ var node = chain[i];
58
+ var dKey = node.__identity__;
59
+ this._indexMap.delete(dKey);
60
+ if (removeSet.has(node.key)) {
61
+ deleteKeys.push(dKey);
62
+ }
63
+ else {
64
+ newChain.push(node);
65
+ }
66
+ }
67
+ { // last item case
68
+ var lastItem = chain[chain.length - 1];
69
+ this._indexMap.delete(lastItem.__identity__);
70
+ if (removeSet.has(lastItem.key)) {
71
+ if (chain.length > 1) {
72
+ deleteKeys.push(chain[chain.length - 2].__identity__);
73
+ deleteKeys.push(chain[chain.length - 1].__identity__);
74
+ }
75
+ ;
76
+ }
77
+ else {
78
+ newChain.push(lastItem);
79
+ }
80
+ }
81
+ this._chainMap.set(chainKey, newChain);
82
+ return deleteKeys;
83
+ };
84
+ ChainListMap.prototype.deleteChainAndReturnChainKeys = function (chainKey) {
85
+ var keys = this.getNodeKeysOfChain(chainKey);
86
+ this._chainMap.delete(chainKey);
87
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
88
+ var key = keys_1[_i];
89
+ this._indexMap.delete(key);
90
+ }
91
+ return keys;
92
+ };
93
+ ChainListMap.prototype.updateNode = function (node, chainKey) {
94
+ var index = this.getIndexOfNode(chainKey, node.key);
95
+ var chain = this._chainMap.get(chainKey);
96
+ node.__identity__ = this.keyMethod(chainKey, node.key);
97
+ chain[index] = node;
98
+ };
99
+ ChainListMap.prototype.updateNodesProperties = function (chainKey, nodes) {
100
+ var _this = this;
101
+ nodes.forEach(function (node) {
102
+ var index = _this.getIndexOfNode(chainKey, node.key);
103
+ var chainNode = _this._chainMap.get(chainKey)[index];
104
+ if (node.circleProperties) {
105
+ if (typeof chainNode.circleProperties !== 'object')
106
+ chainNode.circleProperties = {};
107
+ node.circleProperties.forEach(function (value, key, container) { return chainNode.circleProperties[key] = value; });
108
+ }
109
+ if (node.lineProperties) {
110
+ if (typeof chainNode.lineProperties !== 'object')
111
+ chainNode.lineProperties = {};
112
+ node.lineProperties.forEach(function (value, key, container) { return chainNode.lineProperties[key] = value; });
113
+ }
114
+ });
115
+ };
116
+ ChainListMap.prototype.updateCoordsinatesOfNode = function (node, chainKey) {
117
+ var index = this.getIndexOfNode(chainKey, node.key);
118
+ var chain = this._chainMap.get(chainKey);
119
+ chain[index].long = node.long;
120
+ chain[index].lat = node.lat;
121
+ };
122
+ ChainListMap.prototype.setChain = function (chainKey, nodeList) {
123
+ var _this = this;
124
+ if (this._chainMap.has(chainKey))
125
+ this._flushIndexMap();
126
+ this._chainMap.set(chainKey, nodeList);
127
+ nodeList.forEach(function (v) { return v.__identity__ = _this.keyMethod(chainKey, v.key); });
128
+ };
129
+ ChainListMap.prototype.setChainProperties = function (chainKey, properties) {
130
+ this._chainSideProperties.set(chainKey, properties);
131
+ };
132
+ /**
133
+ *
134
+ * @param {string} chainKey
135
+ * @param {Map} properties
136
+ * // after this method update text and buffer data of the chain
137
+ */
138
+ ChainListMap.prototype.updateChainProperties = function (chainKey, properties) {
139
+ var memoryProperties = this._chainSideProperties.get(chainKey);
140
+ properties.forEach(function (value, key, m) {
141
+ memoryProperties[key] = value;
142
+ });
143
+ };
144
+ ChainListMap.prototype.getChainProperties = function (chainKey) {
145
+ this._chainSideProperties.get(chainKey);
146
+ };
147
+ /**
148
+ *
149
+ * @param {*} chainKey
150
+ * @param {*} callback | (value, index, array) => expexted output
151
+ */
152
+ ChainListMap.prototype.calculateBufferPropertiesChain = function (chainKey, callback, result) {
153
+ var chain = this._chainMap.get(chainKey);
154
+ var props = this._chainSideProperties.get(chainKey);
155
+ for (var i = 0; i < chain.length - 1; i++) {
156
+ var node = callback(chain[i], i, chain, props);
157
+ if (node !== null)
158
+ result.push(node);
159
+ }
160
+ };
161
+ /**
162
+ * @param {*} chainKey
163
+ * @param {*} textWriterObjs
164
+ * @param {*} nodeKeys use nodeKeys on updateCoordinatesOnly
165
+ */
166
+ ChainListMap.prototype.textUpdate = function (chainKey, textWriterObjs, dataPreAdaptor) {
167
+ var chain = this._chainMap.get(chainKey);
168
+ if (!chain)
169
+ return;
170
+ var data = (dataPreAdaptor) ? chain.map(dataPreAdaptor) : chain;
171
+ var properties = this._chainSideProperties.get(chainKey);
172
+ textWriterObjs.forEach(function (writer) {
173
+ writer.insertTextBulk(data, properties);
174
+ });
175
+ };
176
+ ChainListMap.prototype.getAllChainKeysIterator = function () {
177
+ return this._chainMap.keys();
178
+ };
179
+ ChainListMap.prototype.getIndexOfNode = function (chainKey, nodeKey) {
180
+ var key = this.keyMethod(chainKey, nodeKey);
181
+ if (this._indexMap.has(key))
182
+ return this._indexMap.get(key);
183
+ var chain = this._chainMap.get(chainKey);
184
+ for (var i = 0; i < chain.length; i++) {
185
+ var node = chain[i];
186
+ this._indexMap.set(key, i);
187
+ if (node.key === nodeKey) {
188
+ return i;
189
+ }
190
+ }
191
+ };
192
+ ChainListMap.prototype._flushIndexMap = function () {
193
+ this._indexMap.clear();
194
+ };
195
+ ChainListMap.prototype._resetIndexChain = function (chainKey) {
196
+ var chain = this._chainMap.get(chainKey);
197
+ for (var i = 0; i < chain.length; i++) {
198
+ var node = chain[i];
199
+ this._indexMap.set(this.keyMethod(chainKey, node.key), i);
200
+ }
201
+ };
202
+ ChainListMap.prototype.getNodeKeysOfChain = function (chainKey) {
203
+ var chain = this._chainMap.get(chainKey);
204
+ if (!chain)
205
+ return [];
206
+ var result = chain.map(function (v) { return v.__identity__; });
207
+ return result;
208
+ };
209
+ return ChainListMap;
210
+ }());
211
+ exports.ChainListMap = ChainListMap;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,449 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CircleLineChainPlugin = void 0;
4
+ var naive_accurate_flexible_1 = require("../programs/line-on-globe/naive-accurate-flexible");
5
+ var circle_accurate_flat_1 = require("../programs/line-on-globe/circle-accurate-flat");
6
+ var circle_accurate_3d_1 = require("../programs/line-on-globe/circle-accurate-3d");
7
+ var account_1 = require("../util/account");
8
+ var chain_list_map_1 = require("./chain-list-map");
9
+ var get_1 = require("../util/check/get");
10
+ var util_1 = require("./util");
11
+ var data_filler_1 = require("../util/jshelpers/data-filler");
12
+ var context_text3_1 = require("../write-text/context-text3");
13
+ var typecheck_1 = require("../util/check/typecheck");
14
+ var attribute_loader_1 = require("../util/gl-util/buffer/attribute-loader");
15
+ var index_1 = require("../util/geometry/index");
16
+ /**
17
+ * Insert info to chain list map (nodes and properties)
18
+ *
19
+ * ask chain list map for text data
20
+ * ask chain list map for buffer data
21
+ *
22
+ *
23
+ * addNode
24
+ * insertBulk
25
+ * deleteChain
26
+ * deleteNodes
27
+ * updateCoordinates()
28
+ * updateChainProperties
29
+ */
30
+ /**
31
+ *
32
+ *
33
+ * @typedef chain
34
+ * @property {string} chainKey
35
+ * @property {StyleProperties} chainProperties
36
+ *
37
+ * @typedef {Object} Node
38
+ * @property {string} key
39
+ * @property {number} long
40
+ * @property {number} lat
41
+ * @property {number} altitude
42
+ * @property {StyleProperties} circleProperties
43
+ *
44
+ * @typedef {Object} Node
45
+ * @property {string} key
46
+ * @property {number} long
47
+ * @property {number} lat
48
+ *
49
+ * @typedef StyleProperties
50
+ * @property {Array<number>} rgba 0-1
51
+ * @property { number} dashOpacity 0-1
52
+ * @property { number} dashRatio 0-1
53
+ * @property { number } circleDashAngle 0-360
54
+ * @property { number} altitude
55
+ *
56
+ * //property {Array<Node>} nodes
57
+ */
58
+ var textWriterGetOrThrow = (0, get_1.mapGetOrThrow)("textWriterIDs is invalid");
59
+ var CircleLineChainPlugin = /** @class */ (function () {
60
+ /**
61
+ *
62
+ * @param {*} id
63
+ * @param {Map<[key, ContextTextWriter3]} textWritersMap //import { ContextTextWriter3 } from "@pirireis/webglobeplugins/write-text/context-text3";
64
+ */
65
+ function CircleLineChainPlugin(id, _a) {
66
+ var _b = _a === void 0 ? {} : _a, _c = _b.drawCircleOn, drawCircleOn = _c === void 0 ? true : _c, _d = _b.textWritersMap, textWritersMap = _d === void 0 ? new Map() : _d, _e = _b.textDataPreAdaptor, textDataPreAdaptor = _e === void 0 ? null : _e, _f = _b.circleFlatEdgeCount, circleFlatEdgeCount = _f === void 0 ? circle_accurate_flat_1.EDGE_COUNT - 2 : _f;
67
+ this.id = id;
68
+ this._checktextWritersMap(textWritersMap);
69
+ this._textWritersMap = textWritersMap;
70
+ this._textWritersMap.forEach(function (writer) { return writer.setKeyAdaptor(function (v, i, c, properties) { return v.__identity__; }); });
71
+ this._opacity = 1;
72
+ this._chainListMap = new chain_list_map_1.ChainListMap(util_1.keyMethod);
73
+ this.bufferOrchestrator = new account_1.BufferOrchestrator({ capacity: 10 });
74
+ this._drawCircleOn = drawCircleOn;
75
+ this._textDataPreAdaptor = textDataPreAdaptor;
76
+ this._circleFlatEdgeCount = circleFlatEdgeCount + 2;
77
+ }
78
+ // init
79
+ // API
80
+ CircleLineChainPlugin.prototype.setDrawCircleOn = function (bool) {
81
+ if (typeof bool !== 'boolean')
82
+ throw new Error("setDrawCircleOn parameter must be a boolean");
83
+ this._drawCircleOn = bool;
84
+ this.globe.DrawRender();
85
+ };
86
+ // ---- updateBulk
87
+ /**
88
+ * @param {Array<chain>} data
89
+ * @typedef chain
90
+ * @property {string} chainKey
91
+ * @property {Array<Node>} nodes
92
+
93
+ */
94
+ CircleLineChainPlugin.prototype.updateCoordinatesBulk = function (data, _a) {
95
+ var _this = this;
96
+ var _b = _a === void 0 ? {} : _a, _c = _b.textWriterIDs, textWriterIDs = _c === void 0 ? [] : _c;
97
+ // update implicit data structure
98
+ // find keys to update.. (inserted data and the radius of "from")
99
+ // updateBuffers
100
+ // update text
101
+ var chainKeys = [];
102
+ var _loop_1 = function (chain) {
103
+ chainKeys.push(chain.chainKey);
104
+ chain.nodes.forEach(function (node) {
105
+ _this._chainListMap.updateCoordsinatesOfNode(node, chain.chainKey);
106
+ });
107
+ };
108
+ for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
109
+ var chain = data_1[_i];
110
+ _loop_1(chain);
111
+ }
112
+ this._reconstructChains(chainKeys);
113
+ this._updateTexts(chainKeys, textWriterIDs);
114
+ };
115
+ /**
116
+ * @param {*} chainKey
117
+ * @param {Array<{nodeKey, circleProperties:Map[propertyName ,value], lineProperties:Map[propertyName ,value] }} propertyMap
118
+ */
119
+ CircleLineChainPlugin.prototype.updateNodesProperties = function (chainKey, nodesAndPropertyMap, _a) {
120
+ var _b = _a === void 0 ? {} : _a, _c = _b.textWriterIDs, textWriterIDs = _c === void 0 ? [] : _c;
121
+ this._chainListMap.updateNodesProperties(chainKey, nodesAndPropertyMap);
122
+ this._reconstructChains([chainKey]);
123
+ this._updateTexts([chainKey], textWriterIDs);
124
+ this.globe.DrawRender();
125
+ };
126
+ /**
127
+ * @param {*} chainKey
128
+ * @param {Map<propertyName ,value} propertyMap
129
+ */
130
+ CircleLineChainPlugin.prototype.updateChainProperties = function (chainKey, propertyMap, _a) {
131
+ var _b = _a === void 0 ? {} : _a, _c = _b.textWriterIDs, textWriterIDs = _c === void 0 ? [] : _c;
132
+ this._chainListMap.updateChainProperties(chainKey, propertyMap);
133
+ this._reconstructChains([chainKey]);
134
+ if (textWriterIDs)
135
+ this._updateTexts([chainKey], textWriterIDs);
136
+ };
137
+ CircleLineChainPlugin.prototype.updateNodeCoordinates = function (node, chainKey, _a) {
138
+ var _b = _a === void 0 ? {} : _a, _c = _b.textWriterIDs, textWriterIDs = _c === void 0 ? [] : _c;
139
+ this._chainListMap.updateCoordsinatesOfNode(node, chainKey);
140
+ if (textWriterIDs)
141
+ this._updateTexts([chainKey], textWriterIDs);
142
+ this._reconstructChains([chainKey]);
143
+ this.globe.DrawRender();
144
+ };
145
+ /**
146
+ *
147
+
148
+ /**
149
+ * @param {Array<string>} textWriterIDs | textWritersMap keys to be used for writing text.
150
+ * @param {Array<string>} chainKeys | if empty, all texts will be updated
151
+ */
152
+ CircleLineChainPlugin.prototype.updateText = function (textWriterIDs, chainKeys) {
153
+ if (textWriterIDs === void 0) { textWriterIDs = []; }
154
+ if (chainKeys === void 0) { chainKeys = null; }
155
+ if (chainKeys === null)
156
+ chainKeys = this._chainListMap.getAllChainKeysIterator();
157
+ this._updateTexts(chainKeys, textWriterIDs);
158
+ this.globe.DrawRender();
159
+ };
160
+ // ---- insertBulk
161
+ /**
162
+ *
163
+ * @param {Array<chain>} data
164
+ */
165
+ CircleLineChainPlugin.prototype.insertBulk = function (data, _a) {
166
+ var _b = _a === void 0 ? {} : _a, _c = _b.textWriterIDs, textWriterIDs = _c === void 0 ? [] : _c;
167
+ // first insert everything to implicit structure,
168
+ // then iterate over data again to update text
169
+ // let _reconstractChainBufferData method interact with data and bufferOrchestrator.
170
+ var chainKeysToConstruct = [];
171
+ for (var _i = 0, data_2 = data; _i < data_2.length; _i++) {
172
+ var _d = data_2[_i], chainKey = _d.chainKey, chainProperties = _d.chainProperties, nodes = _d.nodes;
173
+ this._chainListMap.setChain(chainKey, nodes);
174
+ this._chainListMap.setChainProperties(chainKey, chainProperties);
175
+ chainKeysToConstruct.push(chainKey);
176
+ }
177
+ this._reconstructChains(chainKeysToConstruct);
178
+ if (textWriterIDs)
179
+ this._updateTexts(chainKeysToConstruct, textWriterIDs);
180
+ this.globe.DrawRender();
181
+ };
182
+ /**
183
+ * @param {Node} node
184
+ * @param {*} chainKey
185
+ * @param {*} theNodeKeyFront | node key of the next node, null places to the last
186
+ */
187
+ CircleLineChainPlugin.prototype.addNode = function (node, chainKey, _a) {
188
+ var _b = _a === void 0 ? {} : _a, _c = _b.theNodeKeyFront, theNodeKeyFront = _c === void 0 ? null : _c, _d = _b.textWriterIDs, textWriterIDs = _d === void 0 ? [] : _d;
189
+ this._chainListMap.addNode(node, chainKey, theNodeKeyFront);
190
+ if (textWriterIDs)
191
+ this._updateTexts([chainKey], textWriterIDs);
192
+ this._reconstructChains([chainKey]);
193
+ this.globe.DrawRender();
194
+ };
195
+ CircleLineChainPlugin.prototype.setOpacity = function (opacity) {
196
+ (0, typecheck_1.opacityCheck)(opacity);
197
+ this._textWritersMap.forEach(function (writer) { return writer.setOpacity(opacity); });
198
+ this._opacity = opacity;
199
+ this.globe.DrawRender();
200
+ };
201
+ CircleLineChainPlugin.prototype.getChain = function (chainKey) {
202
+ this._chainListMap.getChain(chainKey);
203
+ };
204
+ /**
205
+ *
206
+ * @param {*} chainKeys
207
+ */
208
+ CircleLineChainPlugin.prototype.deleteChains = function (chainKeys) {
209
+ var bufferKeys = [];
210
+ for (var _i = 0, chainKeys_1 = chainKeys; _i < chainKeys_1.length; _i++) {
211
+ var chainKey = chainKeys_1[_i];
212
+ bufferKeys.push.apply(bufferKeys, this._chainListMap.deleteChainAndReturnChainKeys(chainKey));
213
+ }
214
+ this._textWritersMap.forEach(function (writer) { return writer.deleteTextBulk(bufferKeys); });
215
+ this._updateTexts(chainKeys, this._textWritersMap.keys());
216
+ this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
217
+ this.globe.DrawRender();
218
+ };
219
+ /**
220
+ *
221
+ * @param {Array<{chainKey, nodeKeys:[]} keysAndNodes
222
+ */
223
+ CircleLineChainPlugin.prototype.deleteNodes = function (keysAndNodes, _a) {
224
+ var _this = this;
225
+ var _b = _a === void 0 ? {} : _a, _c = _b.textWriterIDs, textWriterIDs = _c === void 0 ? [] : _c;
226
+ var bufferKeys = [];
227
+ var chainKeysToReconstuct = [];
228
+ keysAndNodes.forEach(function (_a) {
229
+ var chainKey = _a.chainKey, nodeKeys = _a.nodeKeys;
230
+ bufferKeys.push.apply(bufferKeys, _this._chainListMap.deleteNodesBelongToAChain(chainKey, nodeKeys));
231
+ chainKeysToReconstuct.push(chainKey);
232
+ });
233
+ this._textWritersMap.forEach(function (writer) { return writer.deleteTextBulk(bufferKeys); });
234
+ this.bufferOrchestrator.deleteBulk(bufferKeys, this.bufferManagersCompMap);
235
+ this._reconstructChains(chainKeysToReconstuct);
236
+ this._updateTexts(chainKeysToReconstuct, textWriterIDs);
237
+ this.globe.DrawRender();
238
+ };
239
+ CircleLineChainPlugin.prototype.init = function (globe, gl) {
240
+ this.gl = gl;
241
+ this.globe = globe;
242
+ this._initOrchestrations();
243
+ };
244
+ // implicit
245
+ CircleLineChainPlugin.prototype._checktextWritersMap = function (textWritersMap) {
246
+ if (!(textWritersMap instanceof Map))
247
+ throw new Error("textWritersMap is not an instance of Map");
248
+ textWritersMap.forEach(function (v) {
249
+ if (!(v instanceof context_text3_1.ContextTextWriter3))
250
+ throw new Error("textWritersMap element is not an instance of ContextTextWriter3");
251
+ });
252
+ };
253
+ CircleLineChainPlugin.prototype._initOrchestrations = function () {
254
+ var _a, _b, _c;
255
+ var _this = this;
256
+ var _d = this, gl = _d.gl, globe = _d.globe;
257
+ this.lineProgram = naive_accurate_flexible_1.LineOnGlobeCache.get(globe);
258
+ this.circleProgram2d = circle_accurate_flat_1.CircleCache.get(globe);
259
+ this.circle3DProgram = circle_accurate_3d_1.CircleCache.get(globe);
260
+ var _circleFlatEdgeCount = this._circleFlatEdgeCount;
261
+ {
262
+ // createBuffers
263
+ var bufferType = "DYNAMIC_DRAW";
264
+ var initialCapacity = this.bufferOrchestrator.capacity;
265
+ this.bufferManagersCompMap = new Map([
266
+ ["centerCoords2d", {
267
+ 'bufferManager': new account_1.BufferManager(gl, 2, { bufferType: bufferType, initialCapacity: initialCapacity }),
268
+ 'adaptor': function (item) { return new Float32Array(globe.api_GetMercator2DPoint(item.long, item.lat)); },
269
+ }],
270
+ ["centerCoords3d", {
271
+ 'bufferManager': new account_1.BufferManager(gl, 3, { bufferType: bufferType, initialCapacity: initialCapacity }),
272
+ 'adaptor': function (item) { return (0, index_1.sphereCoord)(item.long, item.lat, globe, item.altitude); },
273
+ }],
274
+ ["targetCoords2d", {
275
+ 'bufferManager': new account_1.BufferManager(gl, 2, { bufferType: bufferType, initialCapacity: initialCapacity }),
276
+ 'adaptor': function (item) { return new Float32Array(globe.api_GetMercator2DPoint(item.targetLong, item.targetLat)); },
277
+ }],
278
+ ["targetCoords3d", {
279
+ 'bufferManager': new account_1.BufferManager(gl, 3, { bufferType: bufferType, initialCapacity: initialCapacity }),
280
+ 'adaptor': function (item) { return (0, index_1.sphereCoord)(item.targetLong, item.targetLat, globe, item.altitude); },
281
+ }],
282
+ ["rgba", {
283
+ 'bufferManager': new account_1.BufferManager(gl, 4, { bufferType: bufferType, initialCapacity: initialCapacity }),
284
+ 'adaptor': function (item) {
285
+ var _a;
286
+ if ((_a = item.lineProperties) === null || _a === void 0 ? void 0 : _a.rgba)
287
+ return new Float32Array(item.lineProperties.rgba);
288
+ return new Float32Array(item.chainProperties.rgba);
289
+ }
290
+ }],
291
+ // ["bigRadius", {
292
+ // 'bufferManager': new BufferManager(gl, 1, { bufferType, initialCapacity }),
293
+ // 'adaptor': (item) => new Float32Array([item.bigRadius])
294
+ // }],
295
+ ["dashRatio", {
296
+ 'bufferManager': new account_1.BufferManager(gl, 1, { bufferType: bufferType, initialCapacity: initialCapacity }),
297
+ 'adaptor': function (item) { return new Float32Array([item.chainProperties.dashRatio]); }
298
+ }],
299
+ ["dashOpacity", {
300
+ 'bufferManager': new account_1.BufferManager(gl, 1, { bufferType: bufferType, initialCapacity: initialCapacity }),
301
+ 'adaptor': function (item) { return new Float32Array([item.chainProperties.dashOpacity]); }
302
+ }],
303
+ ["circleDashAngle", {
304
+ 'bufferManager': new account_1.BufferManager(gl, 1, { bufferType: bufferType, initialCapacity: initialCapacity }),
305
+ 'adaptor': function (item) {
306
+ var _a;
307
+ if ((_a = item.circleProperties) === null || _a === void 0 ? void 0 : _a.circleDashAngle)
308
+ return new Float32Array([item.circleProperties.circleDashAngle / 360]);
309
+ return new Float32Array([item.chainProperties.circleDashAngle / 360]);
310
+ }
311
+ }],
312
+ ["rgbaCircle", {
313
+ "bufferManager": new account_1.BufferManager(gl, 4, { bufferType: bufferType, initialCapacity: initialCapacity }),
314
+ "adaptor": function (item) {
315
+ var _a;
316
+ if ((_a = item.circleProperties) === null || _a === void 0 ? void 0 : _a.rgba)
317
+ return new Float32Array(item.circleProperties.rgba);
318
+ return new Float32Array(item.chainProperties.rgba);
319
+ }
320
+ }],
321
+ // Mercator buffers
322
+ ["circleDashAngleMercator", {
323
+ 'bufferManager': new account_1.BufferManager(gl, 1 * _circleFlatEdgeCount, { bufferType: bufferType, initialCapacity: initialCapacity }),
324
+ 'adaptor': function (item) {
325
+ var _a;
326
+ if ((_a = item.circleProperties) === null || _a === void 0 ? void 0 : _a.circleDashAngle)
327
+ return new Float32Array([item.circleProperties.circleDashAngle / 360]);
328
+ return data_filler_1.populateFloat32Array.fillFloat32Array(_circleFlatEdgeCount, item.chainProperties.circleDashAngle / 360);
329
+ }
330
+ }],
331
+ ["rgbaCircleMercator", {
332
+ "bufferManager": new account_1.BufferManager(gl, 4 * _circleFlatEdgeCount, { bufferType: bufferType, initialCapacity: initialCapacity }),
333
+ "adaptor": function (item) {
334
+ var _a;
335
+ if ((_a = item.circleProperties) === null || _a === void 0 ? void 0 : _a.rgba)
336
+ return data_filler_1.populateFloat32Array.fillWithListData(_circleFlatEdgeCount, item.circleProperties.rgba);
337
+ return data_filler_1.populateFloat32Array.fillWithListData(_circleFlatEdgeCount, item.chainProperties.rgba);
338
+ }
339
+ }],
340
+ ["dashOpacityMercator", {
341
+ 'bufferManager': new account_1.BufferManager(gl, 1 * _circleFlatEdgeCount, { bufferType: bufferType, initialCapacity: initialCapacity }),
342
+ 'adaptor': function (item) { return data_filler_1.populateFloat32Array.fillFloat32Array(_circleFlatEdgeCount, item.chainProperties.dashOpacity); }
343
+ }],
344
+ ["centerCoords2dMercator", {
345
+ 'bufferManager': new account_1.BufferManager(gl, 2 * _circleFlatEdgeCount, { bufferType: bufferType, initialCapacity: initialCapacity }),
346
+ 'adaptor': function (item) { return item.centerCoords2dflat; },
347
+ }],
348
+ ]);
349
+ var obj_1 = function (key) { return (0, attribute_loader_1.createBufferAndReadInfo)(_this.bufferManagersCompMap.get(key).bufferManager.buffer); };
350
+ this.lineVao = (_a = this.lineProgram).createVAO.apply(_a, ['centerCoords2d', 'centerCoords3d', 'targetCoords2d', 'targetCoords3d', 'dashRatio', 'dashOpacity', 'rgba'
351
+ ].map(function (key) { return obj_1(key); }));
352
+ this.circleVao2d = (_b = this.circleProgram2d).createVAO.apply(_b, ["centerCoords2dMercator", "rgbaCircleMercator", "circleDashAngleMercator", "dashOpacityMercator"
353
+ ].map(function (key) { return obj_1(key); }));
354
+ this.circle3DVao = (_c = this.circle3DProgram).createVAO.apply(_c, ["centerCoords3d", "targetCoords3d", "rgbaCircle", "circleDashAngle", "dashOpacity"
355
+ ].map(function (key) { return obj_1(key); }));
356
+ }
357
+ };
358
+ CircleLineChainPlugin.prototype._updateTexts = function (chainKeys, textWriterIDs) {
359
+ var _this = this;
360
+ if (textWriterIDs.length === 0)
361
+ return;
362
+ var textWriters = textWriterGetOrThrow(this._textWritersMap, textWriterIDs);
363
+ chainKeys.forEach(function (chainKey) {
364
+ _this._chainListMap.textUpdate(chainKey, textWriters, _this._textDataPreAdaptor);
365
+ });
366
+ };
367
+ CircleLineChainPlugin.prototype._reconstructChains = function (chainKeys) {
368
+ var _this = this;
369
+ var globe = this.globe;
370
+ // const radiusM = radiusMethod(globe);
371
+ var callback = function (v, i, array, chainProperties) {
372
+ var _a, _b;
373
+ if (i === array.length - 1)
374
+ return null;
375
+ var centerCoords2dflat = (0, circle_accurate_flat_1.centerCoords2dflatDataCreator)(globe, v.long, v.lat, array[i + 1].long, array[i + 1].lat, { edgeCount: _this._circleFlatEdgeCount });
376
+ var altitude = ((_b = (_a = v.altitude) !== null && _a !== void 0 ? _a : chainProperties.altitude) !== null && _b !== void 0 ? _b : 0) / 1000;
377
+ return {
378
+ chainProperties: chainProperties,
379
+ // bigRadius: radiusM(v, i, array),
380
+ targetLong: array[i + 1].long,
381
+ targetLat: array[i + 1].lat,
382
+ altitude: altitude,
383
+ long: v.long,
384
+ lat: v.lat,
385
+ lineProperties: v.lineProperties,
386
+ circleProperties: v.circleProperties,
387
+ centerCoords2dflat: centerCoords2dflat,
388
+ key: v.__identity__
389
+ };
390
+ };
391
+ var bulkData = [];
392
+ chainKeys.forEach(function (k) {
393
+ _this._chainListMap.calculateBufferPropertiesChain(k, callback, bulkData);
394
+ });
395
+ this._insertBulk(bulkData);
396
+ };
397
+ CircleLineChainPlugin.prototype._insertBulk = function (bulkData) {
398
+ this.bufferOrchestrator.insertBulk(bulkData, this.bufferManagersCompMap);
399
+ this.globe.DrawRender();
400
+ };
401
+ // GLOBE API
402
+ CircleLineChainPlugin.prototype.free = function () {
403
+ if (this.isFreed)
404
+ return;
405
+ this.bufferManagersCompMap.forEach(function (_a) {
406
+ var bufferManager = _a.bufferManager;
407
+ bufferManager.free();
408
+ });
409
+ naive_accurate_flexible_1.LineOnGlobeCache.release(this.globe);
410
+ circle_accurate_flat_1.CircleCache.release(this.globe);
411
+ circle_accurate_3d_1.CircleCache.release(this.globe);
412
+ // LineToTheOriginCache.release(this.globe);
413
+ this._textWritersMap.forEach(function (writer) { return writer.free(); });
414
+ var gl = this.gl;
415
+ gl.deleteVertexArray(this.lineVao);
416
+ gl.deleteVertexArray(this.circleVao2d);
417
+ gl.deleteVertexArray(this.circle3DVao);
418
+ this.lineProgram = null;
419
+ this.circleProgram2d = null;
420
+ this.isFreed = true;
421
+ };
422
+ CircleLineChainPlugin.prototype.draw3D = function () {
423
+ var _a = this, gl = _a.gl, globe = _a.globe;
424
+ gl.disable(gl.DEPTH_TEST);
425
+ var drawOptions = {
426
+ drawRange: {
427
+ first: 0,
428
+ count: this.bufferOrchestrator.length
429
+ }
430
+ };
431
+ this.lineProgram.draw(this.lineVao, drawOptions, this._opacity);
432
+ this._textWritersMap.forEach(function (writer) { return writer.draw(); });
433
+ var is3D = globe.api_GetCurrentGeometry() === 0;
434
+ if (this._drawCircleOn) {
435
+ if (is3D) {
436
+ this.circle3DProgram.draw(this.circle3DVao, this.bufferOrchestrator.length, this._opacity);
437
+ }
438
+ else {
439
+ this.circleProgram2d.draw(this.circleVao2d, this.bufferOrchestrator.length, this._circleFlatEdgeCount, this._opacity);
440
+ }
441
+ }
442
+ gl.enable(gl.DEPTH_TEST);
443
+ };
444
+ return CircleLineChainPlugin;
445
+ }());
446
+ exports.CircleLineChainPlugin = CircleLineChainPlugin;
447
+ // const radiusMethod = (globe) => (v, i, array) => {
448
+ // return globe.Math.GetDist3D(v.long, v.lat, array[i + 1].long, array[i + 1].lat)
449
+ // }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.keyMethod = void 0;
4
+ var keyMethod = function (chainKey, nodeKey) { return "".concat(chainKey, "_").concat(nodeKey); };
5
+ exports.keyMethod = keyMethod;