@pirireis/webglobeplugins 0.9.10 → 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 (166) hide show
  1. package/Math/angle-calculation.js +8 -8
  2. package/Math/arc.js +18 -18
  3. package/Math/bounds/line-bbox.js +80 -78
  4. package/Math/constants.js +3 -3
  5. package/Math/juction/arc-plane.js +23 -23
  6. package/Math/juction/line-sphere.js +11 -11
  7. package/Math/juction/plane-plane.js +11 -11
  8. package/Math/line.js +16 -14
  9. package/Math/methods.js +72 -67
  10. package/Math/plane.js +18 -16
  11. package/Math/quaternion.js +49 -45
  12. package/Math/utils.js +2 -2
  13. package/Math/vec3.js +45 -42
  14. package/algorithms/search-binary.js +4 -4
  15. package/altitude-locator/draw-subset-obj.js +8 -7
  16. package/altitude-locator/plugin.js +113 -97
  17. package/arrowfield/adaptor.js +4 -3
  18. package/arrowfield/index.js +2 -2
  19. package/arrowfield/plugin.js +65 -62
  20. package/bearing-line/index.js +1 -1
  21. package/bearing-line/plugin.js +225 -200
  22. package/circle-line-chain/chain-list-map.js +88 -82
  23. package/circle-line-chain/plugin.js +154 -129
  24. package/circle-line-chain/util.js +1 -1
  25. package/compass-rose/compass-rose-padding-flat.js +126 -104
  26. package/compass-rose/compass-text-writer.js +70 -62
  27. package/compass-rose/index.js +2 -2
  28. package/compassrose/compassrose.js +50 -46
  29. package/compassrose/index.js +1 -1
  30. package/heatwave/index.js +2 -2
  31. package/heatwave/isobar/objectarraylabels.js +48 -44
  32. package/heatwave/isobar/plugin.js +123 -104
  33. package/heatwave/isobar/quadtreecontours.js +92 -76
  34. package/heatwave/plugins/heatwaveglobeshell.js +87 -69
  35. package/index.js +11 -11
  36. package/package.json +1 -1
  37. package/partialrings/buffer-manager.js +64 -32
  38. package/partialrings/index.js +1 -1
  39. package/partialrings/plugin.js +84 -48
  40. package/partialrings/program.js +47 -136
  41. package/pin/pin-object-array.js +86 -83
  42. package/pin/pin-point-totem.js +22 -21
  43. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
  44. package/point-heat-map/plugin-webworker.js +45 -40
  45. package/point-heat-map/point-to-heat-map-flow.js +42 -40
  46. package/point-tracks/key-methods.js +1 -1
  47. package/point-tracks/plugin.js +142 -127
  48. package/programs/arrowfield/index.js +1 -1
  49. package/programs/arrowfield/logic.js +62 -170
  50. package/programs/arrowfield/object.js +35 -33
  51. package/programs/data2legend/density-to-legend.js +21 -45
  52. package/programs/data2legend/point-to-density-texture.js +27 -52
  53. package/programs/float2legendwithratio/index.js +1 -1
  54. package/programs/float2legendwithratio/logic.js +42 -88
  55. package/programs/float2legendwithratio/object.js +46 -43
  56. package/programs/globe-util/is-globe-moved.js +11 -10
  57. package/programs/globeshell/index.js +1 -1
  58. package/programs/globeshell/wiggle/index.js +1 -1
  59. package/programs/globeshell/wiggle/logic.js +98 -191
  60. package/programs/globeshell/wiggle/object.js +35 -33
  61. package/programs/helpers/blender/program.js +19 -36
  62. package/programs/helpers/fadeaway/index.js +1 -1
  63. package/programs/helpers/fadeaway/logic.js +13 -35
  64. package/programs/helpers/fadeaway/object.js +10 -9
  65. package/programs/helpers/index.js +1 -1
  66. package/programs/index.js +8 -8
  67. package/programs/line-on-globe/angled-line.js +32 -91
  68. package/programs/line-on-globe/circle-accurate-3d.js +32 -82
  69. package/programs/line-on-globe/circle-accurate-flat.js +50 -108
  70. package/programs/line-on-globe/circle-accurate.js +33 -103
  71. package/programs/line-on-globe/circle.js +32 -97
  72. package/programs/line-on-globe/degree-padding-around-circle-3d.js +33 -83
  73. package/programs/line-on-globe/lines-color-instanced-flat.js +34 -79
  74. package/programs/line-on-globe/linestrip.js +39 -100
  75. package/programs/line-on-globe/naive-accurate-flexible.js +48 -118
  76. package/programs/line-on-globe/to-the-surface.js +29 -58
  77. package/programs/line-on-globe/util.js +1 -1
  78. package/programs/picking/pickable-renderer.js +33 -117
  79. package/programs/point-on-globe/element-globe-surface-glow.js +38 -78
  80. package/programs/point-on-globe/element-point-glow.js +35 -103
  81. package/programs/point-on-globe/square-pixel-point.js +27 -76
  82. package/programs/programcache.js +13 -13
  83. package/programs/rings/distancering/circleflatprogram.js +21 -63
  84. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +145 -156
  85. package/programs/rings/distancering/circlepaddysharedbuffer.js +197 -121
  86. package/programs/rings/distancering/index.js +4 -4
  87. package/programs/rings/distancering/paddyflatprogram.js +20 -73
  88. package/programs/rings/distancering/paddyflatprogram2d.js +22 -75
  89. package/programs/rings/distancering/paddyflatprogram3d.js +20 -73
  90. package/programs/rings/partial-ring/piece-of-pie.js +35 -137
  91. package/programs/totems/camerauniformblock.js +51 -64
  92. package/programs/totems/canvas-webglobe-info.js +40 -48
  93. package/programs/totems/gpu-selection-uniform-block.js +40 -44
  94. package/programs/totems/index.js +1 -1
  95. package/programs/two-d/pixel-padding-for-compass.js +29 -90
  96. package/programs/util.js +7 -6
  97. package/programs/vectorfields/index.js +1 -1
  98. package/programs/vectorfields/logics/drawrectangleparticles.js +29 -70
  99. package/programs/vectorfields/logics/index.js +3 -3
  100. package/programs/vectorfields/logics/pixelbased.js +35 -91
  101. package/programs/vectorfields/logics/ubo.js +25 -31
  102. package/programs/vectorfields/pingpongbuffermanager.js +34 -30
  103. package/rangerings/index.js +4 -4
  104. package/rangerings/plugin.js +252 -202
  105. package/rangerings/rangeringangletext.js +120 -108
  106. package/rangerings/ring-account.js +69 -52
  107. package/shaders/fragment-toy/firework.js +1 -55
  108. package/shaders/fragment-toy/singularity.js +1 -55
  109. package/timetracks/adaptors-line-strip.js +37 -26
  110. package/timetracks/adaptors.js +61 -47
  111. package/timetracks/index.js +4 -4
  112. package/timetracks/plugin-line-strip.js +63 -59
  113. package/timetracks/plugin.js +69 -65
  114. package/timetracks/program-line-strip.js +103 -296
  115. package/timetracks/program.js +113 -419
  116. package/timetracks/programpoint-line-strip.js +44 -97
  117. package/timetracks/programpoint.js +44 -90
  118. package/util/account/bufferoffsetmanager.js +95 -72
  119. package/util/account/index.js +1 -1
  120. package/util/account/single-attribute-buffer-management/buffer-manager.js +43 -39
  121. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +94 -64
  122. package/util/account/single-attribute-buffer-management/index.js +3 -3
  123. package/util/account/single-attribute-buffer-management/object-store.js +30 -28
  124. package/util/account/util.js +4 -2
  125. package/util/algorithms/search-binary.js +4 -4
  126. package/util/check/get.js +5 -5
  127. package/util/check/typecheck.js +15 -13
  128. package/util/geometry/index.js +11 -9
  129. package/util/gl-util/buffer/attribute-loader.js +20 -8
  130. package/util/gl-util/buffer/index.js +1 -1
  131. package/util/gl-util/draw-options/methods.js +7 -7
  132. package/util/gl-util/uniform-block/manager.js +67 -55
  133. package/util/heatwavedatamanager/datamanager.js +116 -56
  134. package/util/heatwavedatamanager/index.js +2 -2
  135. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +40 -37
  136. package/util/heatwavedatamanager/pointcoordsmeta.js +10 -9
  137. package/util/index.js +6 -6
  138. package/util/interpolation/timetrack/index.js +1 -1
  139. package/util/interpolation/timetrack/timetrack-interpolator.js +29 -27
  140. package/util/interpolation/timetrack/web-worker-str.js +1 -179
  141. package/util/interpolation/timetrack/web-worker.js +4 -4
  142. package/util/jshelpers/data-filler.js +7 -7
  143. package/util/jshelpers/timefilters.js +7 -7
  144. package/util/picking/fence.js +7 -7
  145. package/util/picking/picker-displayer.js +52 -46
  146. package/util/programs/draw-texture-on-canvas.js +21 -39
  147. package/util/programs/shapesonglobe.js +64 -104
  148. package/util/programs/supersampletotextures.js +39 -45
  149. package/util/programs/texturetoglobe.js +48 -98
  150. package/util/shaderfunctions/geometrytransformations.js +27 -322
  151. package/util/shaderfunctions/nodata.js +1 -7
  152. package/util/shaderfunctions/noisefunctions.js +9 -39
  153. package/util/surface-line-data/arcs-to-cuts.js +23 -20
  154. package/util/webglobe/rasteroverlay.js +37 -35
  155. package/util/webglobjectbuilders.js +60 -55
  156. package/util/webglobjectbuilders1.js +49 -48
  157. package/waveparticles/adaptor.js +7 -6
  158. package/waveparticles/index.js +2 -2
  159. package/waveparticles/plugin.js +84 -79
  160. package/wind/imagetovectorfieldandmagnitude.js +15 -15
  161. package/wind/index.js +4 -4
  162. package/wind/plugin.js +251 -453
  163. package/wind/vectorfieldimage.js +5 -5
  164. package/write-text/attached-text-writer.js +48 -46
  165. package/write-text/context-text.js +58 -51
  166. package/write-text/context-text3.js +74 -69
@@ -1,20 +1,30 @@
1
1
  "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.scaleParameters = scaleParameters;
4
13
  // © 2019 3D Robotics. License: Apache-2.0
5
14
  /* eslint no-plusplus: "off", prefer-rest-params: "off" */
6
- const OUTSIDE = 0;
7
- const ABOVE = 1;
8
- const BELOW = 2;
9
- const WITHIN = 3;
15
+ var OUTSIDE = 0;
16
+ var ABOVE = 1;
17
+ var BELOW = 2;
18
+ var WITHIN = 3;
10
19
  // Build mipmap layer N from layer N+1
11
- function mipmapReduce({ min, max, width, height, scale }) {
12
- const outWidth = Math.ceil(width / 2);
13
- const outHeight = Math.ceil(height / 2);
20
+ function mipmapReduce(_a) {
21
+ var min = _a.min, max = _a.max, width = _a.width, height = _a.height, scale = _a.scale;
22
+ var outWidth = Math.ceil(width / 2);
23
+ var outHeight = Math.ceil(height / 2);
14
24
  function reduceWith(data, reduce) {
15
- const out = new Float32Array(outWidth * outHeight);
16
- let x;
17
- let y;
25
+ var out = new Float32Array(outWidth * outHeight);
26
+ var x;
27
+ var y;
18
28
  for (y = 0; y < Math.floor(height / 2); y++) {
19
29
  for (x = 0; x < Math.floor(width / 2); x++) {
20
30
  out[y * outWidth + x] = reduce(data[(y * 2 + 0) * width + (x * 2 + 0)], data[(y * 2 + 0) * width + (x * 2 + 1)], data[(y * 2 + 1) * width + (x * 2 + 0)], data[(y * 2 + 1) * width + (x * 2 + 1)]);
@@ -34,18 +44,18 @@ function mipmapReduce({ min, max, width, height, scale }) {
34
44
  return out;
35
45
  }
36
46
  function minFinite() {
37
- let r = Infinity;
38
- for (let i = 0; i < arguments.length; i++) { // significantly faster than the code Babel generates for ...args
39
- const v = arguments[i];
47
+ var r = Infinity;
48
+ for (var i = 0; i < arguments.length; i++) { // significantly faster than the code Babel generates for ...args
49
+ var v = arguments[i];
40
50
  if (v < r)
41
51
  r = v;
42
52
  }
43
53
  return r;
44
54
  }
45
55
  function maxFinite() {
46
- let r = -Infinity;
47
- for (let i = 0; i < arguments.length; i++) {
48
- const v = arguments[i];
56
+ var r = -Infinity;
57
+ for (var i = 0; i < arguments.length; i++) {
58
+ var v = arguments[i];
49
59
  if (v > r)
50
60
  r = v;
51
61
  }
@@ -59,43 +69,45 @@ function mipmapReduce({ min, max, width, height, scale }) {
59
69
  scale: scale * 2,
60
70
  };
61
71
  }
62
- class ContourMipmap {
63
- constructor(raster, width, height) {
72
+ var ContourMipmap = /** @class */ (function () {
73
+ function ContourMipmap(raster, width, height) {
64
74
  // Bottom mipmap layer is just the raster: at each pixel the minimum and maximum are the same
65
- this.levels = [{ min: raster, max: raster, width, height, scale: 1 }];
75
+ this.levels = [{ min: raster, max: raster, width: width, height: height, scale: 1 }];
66
76
  while (this.levels[0].width > 1 || this.levels[0].height > 1) {
67
77
  this.levels.unshift(mipmapReduce(this.levels[0]));
68
78
  }
69
79
  }
70
80
  // Get the minimum elevation in the mipmap
71
- min() { return this.levels[0].min[0]; }
81
+ ContourMipmap.prototype.min = function () { return this.levels[0].min[0]; };
72
82
  // Get the maximum elevation in the mipmap
73
- max() { return this.levels[0].max[0]; }
83
+ ContourMipmap.prototype.max = function () { return this.levels[0].max[0]; };
74
84
  // Get an array of contour levels for a specified contour interval
75
- intervals(interval) {
85
+ ContourMipmap.prototype.intervals = function (interval) {
76
86
  if (interval <= 0)
77
87
  throw new Error('Contour interval must be positive');
78
- const min = this.min();
79
- const max = this.max();
80
- const levels = [];
81
- let level = Math.ceil(min / interval) * interval;
88
+ var min = this.min();
89
+ var max = this.max();
90
+ var levels = [];
91
+ var level = Math.ceil(min / interval) * interval;
82
92
  while (level < max) {
83
93
  levels.push(level);
84
94
  level += interval;
85
95
  }
86
96
  return levels;
87
- }
97
+ };
88
98
  // Walk the quadtree for a specified contour level, and pass quadtree nodes
89
99
  // and contour line segments to the callbacks. This is used for visualizing
90
100
  // the quadtree; in most cases you should use .contour() instead, which
91
101
  // assembles the line segments into lines and rings.
92
- evaluateContour(contourLevel, { maxMipmapLevel }, addLine, addNode) {
102
+ ContourMipmap.prototype.evaluateContour = function (contourLevel, _a, addLine, addNode) {
103
+ var _this = this;
104
+ var maxMipmapLevel = _a.maxMipmapLevel;
93
105
  maxMipmapLevel = maxMipmapLevel || this.levels.length - 1;
94
106
  // Test the mipmap at the given coordinate and level, returning whether the contour line is ABOVE, BELOW, or WITHIN this mipmap cell
95
107
  // If the mipmap is out of bounds or NaN at that point, OUTSIDE is returned.
96
- const evaluate = (l, x, y) => {
97
- const ml = this.levels[l];
98
- const i = ml.width * y + x;
108
+ var evaluate = function (l, x, y) {
109
+ var ml = _this.levels[l];
110
+ var i = ml.width * y + x;
99
111
  if (x >= ml.width || y >= ml.height || !Number.isFinite(ml.min[i]) || !Number.isFinite(ml.max[i]))
100
112
  return OUTSIDE;
101
113
  if (ml.min[i] >= contourLevel)
@@ -113,8 +125,8 @@ class ContourMipmap {
113
125
  // level, it is added directly, otherwise split the edge and recurse at a
114
126
  // more detailed mipmap level.
115
127
  function edgeH(l, x, y) {
116
- const e1 = evaluate(l, x, y);
117
- const e2 = evaluate(l, x + 1, y);
128
+ var e1 = evaluate(l, x, y);
129
+ var e2 = evaluate(l, x + 1, y);
118
130
  if (e1 === ABOVE && e2 === BELOW) {
119
131
  addLine(l, x + 1, y + 1, x + 1, y);
120
132
  }
@@ -131,8 +143,8 @@ class ContourMipmap {
131
143
  // Like edgeH, but for horizontal contour lines between the passed cell
132
144
  // and its vertical neighbor below.
133
145
  function edgeV(l, x, y) {
134
- const e1 = evaluate(l, x, y);
135
- const e2 = evaluate(l, x, y + 1);
146
+ var e1 = evaluate(l, x, y);
147
+ var e2 = evaluate(l, x, y + 1);
136
148
  if (e1 === ABOVE && e2 === BELOW) {
137
149
  addLine(l, x, y + 1, x + 1, y + 1);
138
150
  }
@@ -148,7 +160,7 @@ class ContourMipmap {
148
160
  // It recurses into the four quadrants of the cell, and also uses edgeH and
149
161
  // edgeV to add the contour lines that exist between quadrants.
150
162
  function node(l, x, y) {
151
- let e = evaluate(l, x, y);
163
+ var e = evaluate(l, x, y);
152
164
  if (e === WITHIN) {
153
165
  node(l + 1, x * 2 + 0, y * 2 + 0);
154
166
  node(l + 1, x * 2 + 1, y * 2 + 0);
@@ -165,7 +177,7 @@ class ContourMipmap {
165
177
  }
166
178
  }
167
179
  node(0, 0, 0);
168
- }
180
+ };
169
181
  // Generate a contour line for a specified value
170
182
  //
171
183
  // level: Value in the input array at which to draw a contour line
@@ -179,25 +191,28 @@ class ContourMipmap {
179
191
  // }
180
192
  //
181
193
  // Returns an array of lines, where each line is an array of [x, y] pairs.
182
- contour(level, { maxMipmapLevel, smoothKernelWidth = 2, smoothCycles = 2, minPoints = 0 } = {}) {
194
+ ContourMipmap.prototype.contour = function (level, _a) {
195
+ var _this = this;
196
+ var _b = _a === void 0 ? {} : _a, maxMipmapLevel = _b.maxMipmapLevel, _c = _b.smoothKernelWidth, smoothKernelWidth = _c === void 0 ? 2 : _c, _d = _b.smoothCycles, smoothCycles = _d === void 0 ? 2 : _d, _e = _b.minPoints, minPoints = _e === void 0 ? 0 : _e;
183
197
  // Use the quadtree algorithm to generate line segments that make up the contour
184
- const segments = [];
185
- this.evaluateContour(level, { maxMipmapLevel }, (l, x1, y1, x2, y2) => {
186
- const scale = this.levels[l].scale;
187
- const start = [scale * x1, scale * y1];
188
- const end = [scale * x2, scale * y2];
189
- segments.push({ start, end });
198
+ var segments = [];
199
+ this.evaluateContour(level, { maxMipmapLevel: maxMipmapLevel }, function (l, x1, y1, x2, y2) {
200
+ var scale = _this.levels[l].scale;
201
+ var start = [scale * x1, scale * y1];
202
+ var end = [scale * x2, scale * y2];
203
+ segments.push({ start: start, end: end });
190
204
  });
191
- segments.sort((a, b) => key(a.start) - key(b.start));
205
+ segments.sort(function (a, b) { return key(a.start) - key(b.start); });
192
206
  // .. and then join them together into rings
193
207
  // An arbitrary function to use a 2D point as a Map key
194
208
  function key(a) { return a[0] + a[1] * 65536; }
195
- const fragmentStart = new Map();
196
- const fragmentEnd = new Map();
197
- const rings = [];
198
- segments.forEach(({ start, end }) => {
199
- const a = fragmentEnd.get(key(start));
200
- const b = fragmentStart.get(key(end));
209
+ var fragmentStart = new Map();
210
+ var fragmentEnd = new Map();
211
+ var rings = [];
212
+ segments.forEach(function (_a) {
213
+ var start = _a.start, end = _a.end;
214
+ var a = fragmentEnd.get(key(start));
215
+ var b = fragmentStart.get(key(end));
201
216
  if (a && b) {
202
217
  fragmentEnd.delete(key(start));
203
218
  fragmentStart.delete(key(end));
@@ -208,7 +223,7 @@ class ContourMipmap {
208
223
  }
209
224
  else {
210
225
  // Join two lines together
211
- const c = a.concat(b);
226
+ var c = a.concat(b);
212
227
  fragmentStart.set(key(c[0]), c);
213
228
  fragmentEnd.set(key(c[c.length - 1]), c);
214
229
  }
@@ -227,45 +242,46 @@ class ContourMipmap {
227
242
  }
228
243
  else {
229
244
  // New line doesn't connect to any existing line
230
- const c = [start, end];
245
+ var c = [start, end];
231
246
  fragmentStart.set(key(start), c);
232
247
  fragmentEnd.set(key(end), c);
233
248
  }
234
249
  if (fragmentStart.size !== fragmentEnd.size) {
235
- console.error(`Contour remaining fragment size mismatch ${fragmentStart.size} ${fragmentEnd.size}`);
250
+ console.error("Contour remaining fragment size mismatch ".concat(fragmentStart.size, " ").concat(fragmentEnd.size));
236
251
  }
237
252
  });
238
- const smoothOpts = {
253
+ var smoothOpts = {
239
254
  kernelWidth: smoothKernelWidth,
240
255
  cycles: smoothCycles,
241
256
  };
242
257
  // Closed rings and any unclosed line strings
243
- return [...rings, ...fragmentStart.values()]
244
- .filter(l => l.length >= minPoints && l.length >= smoothKernelWidth * 2)
245
- .map(l => smooth(l, smoothOpts));
246
- }
247
- }
258
+ return __spreadArray(__spreadArray([], rings, true), fragmentStart.values(), true).filter(function (l) { return l.length >= minPoints && l.length >= smoothKernelWidth * 2; })
259
+ .map(function (l) { return smooth(l, smoothOpts); });
260
+ };
261
+ return ContourMipmap;
262
+ }());
248
263
  // Smooth a line by repeatedly applying a rectangular filter to approximate
249
264
  // a gaussian filter. It detects closed loops and preserves them.
250
265
  // The line is passed as an array of `[x, y]` pairs.
251
266
  //
252
267
  // kernelWidth: Width of the rectangular filter kernel
253
268
  // cycles: Number of times to apply the kernel
254
- function smooth(line, { kernelWidth = 2, cycles = 2 }) {
255
- const isLoop = line[0][0] === line[line.length - 1][0] && line[0][1] === line[line.length - 1][1];
256
- let pointAt;
269
+ function smooth(line, _a) {
270
+ var _b = _a.kernelWidth, kernelWidth = _b === void 0 ? 2 : _b, _c = _a.cycles, cycles = _c === void 0 ? 2 : _c;
271
+ var isLoop = line[0][0] === line[line.length - 1][0] && line[0][1] === line[line.length - 1][1];
272
+ var pointAt;
257
273
  if (isLoop) {
258
- pointAt = i => line[(i + line.length) % line.length];
274
+ pointAt = function (i) { return line[(i + line.length) % line.length]; };
259
275
  }
260
276
  else {
261
- pointAt = i => line[Math.min(Math.max(i, 0), line.length - 1)];
277
+ pointAt = function (i) { return line[Math.min(Math.max(i, 0), line.length - 1)]; };
262
278
  }
263
- const sc = 1.0 / (kernelWidth * 2);
264
- for (let cycle = 0; cycle < cycles; cycle++) {
265
- let px = 0;
266
- let py = 0;
279
+ var sc = 1.0 / (kernelWidth * 2);
280
+ for (var cycle = 0; cycle < cycles; cycle++) {
281
+ var px = 0;
282
+ var py = 0;
267
283
  if (isLoop) {
268
- for (let i = line.length - kernelWidth; i < line.length; i++) {
284
+ for (var i = line.length - kernelWidth; i < line.length; i++) {
269
285
  px += line[i][0];
270
286
  py += line[i][1];
271
287
  }
@@ -274,12 +290,12 @@ function smooth(line, { kernelWidth = 2, cycles = 2 }) {
274
290
  px = line[0][0] * kernelWidth;
275
291
  py = line[0][1] * kernelWidth;
276
292
  }
277
- for (let i = 0; i < kernelWidth; i++) {
293
+ for (var i = 0; i < kernelWidth; i++) {
278
294
  px += line[i][0];
279
295
  py += line[i][1];
280
296
  }
281
- const res = line.slice();
282
- for (let i = 0; i < line.length; i++) {
297
+ var res = line.slice();
298
+ for (var i = 0; i < line.length; i++) {
283
299
  res[i] = [px * sc, py * sc];
284
300
  px += pointAt(i + kernelWidth)[0] - pointAt(i - kernelWidth)[0];
285
301
  py += pointAt(i + kernelWidth)[1] - pointAt(i - kernelWidth)[1];
@@ -293,8 +309,8 @@ function smooth(line, { kernelWidth = 2, cycles = 2 }) {
293
309
  return line;
294
310
  }
295
311
  function scaleParameters(minLongitude, minLatitude, maxLongitude, maxLatitude, width, height) {
296
- const scaleX = (maxLongitude - minLongitude) / width;
297
- const scaleY = (maxLatitude - minLatitude) / height;
298
- return { scaleX, scaleY };
312
+ var scaleX = (maxLongitude - minLongitude) / width;
313
+ var scaleY = (maxLatitude - minLatitude) / height;
314
+ return { scaleX: scaleX, scaleY: scaleY };
299
315
  }
300
316
  exports.default = ContourMipmap;
@@ -1,8 +1,17 @@
1
1
  "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const util_1 = require("../../util");
4
- const programs_1 = require("../../programs");
5
- const typecheck_1 = require("../../util/check/typecheck");
12
+ var util_1 = require("../../util");
13
+ var programs_1 = require("../../programs");
14
+ var typecheck_1 = require("../../util/check/typecheck");
6
15
  /**
7
16
  * @param id : string
8
17
  * @param dataManager : DataManager
@@ -10,8 +19,9 @@ const typecheck_1 = require("../../util/check/typecheck");
10
19
  * @param dataWidthHeight : {width: number, height: number}
11
20
  * @param options : {bbox: number[], minMaxEdges: {min: number, max: number}, escapeValue: number, resolution: number[], meshPartition: number[]}
12
21
  */
13
- class HeatWaveGlobeShellPlugin {
14
- constructor(id, dataManager, colorRampData, dataWidthHeight, { bbox = [-180, -90, 180, 90], minMaxEdges = { min: -99999, max: 99999 }, escapeValue = 99999, resolution = [2056, 2056], yFlip = true, } = {}) {
22
+ var HeatWaveGlobeShellPlugin = /** @class */ (function () {
23
+ function HeatWaveGlobeShellPlugin(id, dataManager, colorRampData, dataWidthHeight, _a) {
24
+ var _b = _a === void 0 ? {} : _a, _c = _b.bbox, bbox = _c === void 0 ? [-180, -90, 180, 90] : _c, _d = _b.minMaxEdges, minMaxEdges = _d === void 0 ? { min: -99999, max: 99999 } : _d, _e = _b.escapeValue, escapeValue = _e === void 0 ? 99999 : _e, _f = _b.resolution, resolution = _f === void 0 ? [2056, 2056] : _f, _g = _b.yFlip, yFlip = _g === void 0 ? true : _g;
15
25
  this.id = id;
16
26
  this.dataManager = dataManager;
17
27
  this._dataWidthHeight = dataWidthHeight;
@@ -30,60 +40,63 @@ class HeatWaveGlobeShellPlugin {
30
40
  this.enabled = false;
31
41
  this.isAble = false;
32
42
  }
33
- setHeight(height) {
43
+ HeatWaveGlobeShellPlugin.prototype.setHeight = function (height) {
34
44
  this.globeShell.setHeight(height);
35
- }
36
- drawHeat() {
37
- const gl = this.gl;
45
+ };
46
+ HeatWaveGlobeShellPlugin.prototype.drawHeat = function () {
47
+ var gl = this.gl;
38
48
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
39
49
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._coloredHeatTexture, 0);
40
50
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
41
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
42
- const currentWidth = gl.canvas.width;
43
- const currentHeight = gl.canvas.height;
44
- gl.viewport(0, 0, ...this._resolution);
51
+ var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
52
+ var currentWidth = gl.canvas.width;
53
+ var currentHeight = gl.canvas.height;
54
+ gl.viewport.apply(gl, __spreadArray([0, 0], this._resolution, false));
45
55
  this.heatProgram.draw();
46
56
  gl.viewport(0, 0, currentWidth, currentHeight);
47
57
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
48
58
  gl.useProgram(currentProgram);
49
59
  this.globe.DrawRender();
50
- }
51
- setEscapeValue(escapeValue) {
60
+ };
61
+ HeatWaveGlobeShellPlugin.prototype.setEscapeValue = function (escapeValue) {
52
62
  this._escapeValue = escapeValue;
53
63
  this.heatProgram.setEscapeValue(escapeValue);
54
- }
55
- _createPointCoordinatesDataCalculator() {
64
+ };
65
+ HeatWaveGlobeShellPlugin.prototype._createPointCoordinatesDataCalculator = function () {
56
66
  this.coordinatesDataCalculator = new util_1.PointCoordinatesDataCalculator(this._bbox, this._dataWidthHeight.width, this._dataWidthHeight.height);
57
67
  this.dataManager.register(this._coordinatesDataCalculatorID(), this.coordinatesDataCalculator.updateData.bind(this.coordinatesDataCalculator));
58
- }
59
- _coordinatesDataCalculatorID() {
68
+ };
69
+ HeatWaveGlobeShellPlugin.prototype._coordinatesDataCalculatorID = function () {
60
70
  return this.id + "_coordinatesDataCalculator";
61
- }
62
- updateTime(time) {
71
+ };
72
+ HeatWaveGlobeShellPlugin.prototype.updateTime = function (time) {
63
73
  this.dataManager.updateTime(time);
64
74
  this.globe.DrawRender();
65
- }
66
- setWiggle({ wiggleInKm = null, wiggleSpeed = null } = {}) {
67
- this.globeShell.setWiggle({ wiggleInKm, wiggleSpeed });
68
- }
69
- setMinMaxEdges(min = null, max = null) {
75
+ };
76
+ HeatWaveGlobeShellPlugin.prototype.setWiggle = function (_a) {
77
+ var _b = _a === void 0 ? {} : _a, _c = _b.wiggleInKm, wiggleInKm = _c === void 0 ? null : _c, _d = _b.wiggleSpeed, wiggleSpeed = _d === void 0 ? null : _d;
78
+ this.globeShell.setWiggle({ wiggleInKm: wiggleInKm, wiggleSpeed: wiggleSpeed });
79
+ };
80
+ HeatWaveGlobeShellPlugin.prototype.setMinMaxEdges = function (min, max) {
81
+ if (min === void 0) { min = null; }
82
+ if (max === void 0) { max = null; }
70
83
  if (min)
71
84
  this._minMaxEdges.min = min;
72
85
  if (max)
73
86
  this._minMaxEdges.max = max;
74
87
  this.heatProgram.setMinMaxEdges(this._minMaxEdges.min, this._minMaxEdges.max);
75
88
  this.drawHeat();
76
- }
77
- setBBox(minLon, minLat, maxLon, maxLat) {
89
+ };
90
+ HeatWaveGlobeShellPlugin.prototype.setBBox = function (minLon, minLat, maxLon, maxLat) {
78
91
  this._bbox = [minLon, minLat, maxLon, maxLat];
79
- this.globeShell.setBBox({ minLon, minLat, maxLon, maxLat });
92
+ this.globeShell.setBBox({ minLon: minLon, minLat: minLat, maxLon: maxLon, maxLat: maxLat });
80
93
  this.drawHeat();
81
- }
82
- getPointCoordinatesDataCalculator() {
94
+ };
95
+ HeatWaveGlobeShellPlugin.prototype.getPointCoordinatesDataCalculator = function () {
83
96
  if (!this.coordinatesDataCalculator)
84
97
  this._createPointCoordinatesDataCalculator();
85
98
  return this.coordinatesDataCalculator;
86
- }
99
+ };
87
100
  /**
88
101
  * @param {*} values n + 1 number of color hex values without alpha channel. Ex: ["#ff0000", "#00ff00", "#0000ff"]
89
102
  * @param {*} thresholds n number of thresholds. Ex: [0, 10, 20]
@@ -92,23 +105,26 @@ class HeatWaveGlobeShellPlugin {
92
105
  * There are maximum 256 pixels in the color ramp.
93
106
  * The first values array is minimum edge value which is the first pixel, the second comes one pixel after the first.
94
107
  */
95
- setColorRamp(values, thresholds, mode = "interpolated") {
96
- const lowest = thresholds[0];
97
- const highest = thresholds[thresholds.length - 1];
98
- const range = highest - lowest;
99
- const clampedThresholds = thresholds.map((t) => (t - lowest) / range);
100
- const colors = (0, util_1.getColorRampModed)(values, clampedThresholds, mode);
108
+ HeatWaveGlobeShellPlugin.prototype.setColorRamp = function (values, thresholds, mode) {
109
+ if (mode === void 0) { mode = "interpolated"; }
110
+ var lowest = thresholds[0];
111
+ var highest = thresholds[thresholds.length - 1];
112
+ var range = highest - lowest;
113
+ var clampedThresholds = thresholds.map(function (t) { return (t - lowest) / range; });
114
+ var colors = (0, util_1.getColorRampModed)(values, clampedThresholds, mode);
101
115
  this.heatProgram.setColorRampTextureData(colors, 256);
102
116
  this.heatProgram.setColorRampRange(lowest, highest);
103
117
  this.drawHeat();
104
- }
105
- off() {
118
+ };
119
+ HeatWaveGlobeShellPlugin.prototype.off = function () {
106
120
  this._isOn = false;
107
- }
108
- on() {
121
+ };
122
+ HeatWaveGlobeShellPlugin.prototype.on = function () {
109
123
  this._isOn = true;
110
- }
111
- _updateData(ratio, textureData0 = null, textureData1 = null) {
124
+ };
125
+ HeatWaveGlobeShellPlugin.prototype._updateData = function (ratio, textureData0, textureData1) {
126
+ if (textureData0 === void 0) { textureData0 = null; }
127
+ if (textureData1 === void 0) { textureData1 = null; }
112
128
  if (!textureData0 || !textureData1) {
113
129
  if (this._disCarded)
114
130
  return;
@@ -126,33 +142,34 @@ class HeatWaveGlobeShellPlugin {
126
142
  this.heatProgram.setFloatTextureData(textureData0, textureData1, this._dataWidthHeight.width, this._dataWidthHeight.height, this._yFlip);
127
143
  }
128
144
  this.drawHeat();
129
- }
130
- setDataWidthHeight(width, height) {
131
- this._dataWidthHeight = { width, height };
145
+ };
146
+ HeatWaveGlobeShellPlugin.prototype.setDataWidthHeight = function (width, height) {
147
+ this._dataWidthHeight = { width: width, height: height };
132
148
  this.heatProgram.setDataWidthHeight(width, height);
133
149
  this.setGeometry();
134
- }
135
- draw3D() {
150
+ };
151
+ HeatWaveGlobeShellPlugin.prototype.draw3D = function () {
136
152
  if (!this._isOn)
137
153
  return;
138
154
  // if (!this.isAble) return;
139
155
  this.gl.disable(this.gl.DEPTH_TEST);
140
156
  this.globeShell.draw();
141
157
  this.gl.enable(this.gl.DEPTH_TEST);
142
- }
143
- setOpacity(opacity) {
158
+ };
159
+ HeatWaveGlobeShellPlugin.prototype.setOpacity = function (opacity) {
144
160
  (0, typecheck_1.opacityCheck)(opacity);
145
161
  this.globeShell.setOpacity(opacity);
146
- }
147
- _setAfterInit() {
148
- const [minLon, minLat, maxLon, maxLat] = this._bbox;
149
- this.globeShell.setBBox({ minLon, minLat, maxLon, maxLat });
162
+ };
163
+ HeatWaveGlobeShellPlugin.prototype._setAfterInit = function () {
164
+ var _a = this._bbox, minLon = _a[0], minLat = _a[1], maxLon = _a[2], maxLat = _a[3];
165
+ this.globeShell.setBBox({ minLon: minLon, minLat: minLat, maxLon: maxLon, maxLat: maxLat });
150
166
  this.setColorRamp(this._colorRampData.values, this._colorRampData.thresholds, this._colorRampData.mode);
151
167
  delete this._colorRampData;
152
168
  this.setMinMaxEdges(this._minMaxEdges.min, this._minMaxEdges.max);
153
169
  this.setEscapeValue(this._escapeValue);
154
- }
155
- _init(globe, gl) {
170
+ };
171
+ HeatWaveGlobeShellPlugin.prototype._init = function (globe, gl) {
172
+ var _this = this;
156
173
  this.globeShell = new programs_1.GlobeShellWiggle(gl, globe, {
157
174
  minLon: this._bbox[0],
158
175
  minLat: this._bbox[1],
@@ -166,22 +183,22 @@ class HeatWaveGlobeShellPlugin {
166
183
  });
167
184
  this.heatProgram = new programs_1.Float2LegendWithRatio(gl);
168
185
  this._frameBuffer = gl.createFramebuffer();
169
- this.dataManager.register(this.id, (ratio, t1, t2) => this._updateData(ratio, t1, t2));
186
+ this.dataManager.register(this.id, function (ratio, t1, t2) { return _this._updateData(ratio, t1, t2); });
170
187
  this.setResolution(this._resolution[0], this._resolution[1]);
171
- }
172
- init(globe, gl) {
188
+ };
189
+ HeatWaveGlobeShellPlugin.prototype.init = function (globe, gl) {
173
190
  this.globe = globe;
174
191
  this.gl = gl;
175
192
  this._init(globe, gl);
176
193
  this._setAfterInit();
177
- }
178
- setGeometry() {
194
+ };
195
+ HeatWaveGlobeShellPlugin.prototype.setGeometry = function () {
179
196
  // globeShell has an implicit program, registered and sets its own geometry.
180
197
  return;
181
- }
198
+ };
182
199
  // sets Density of middle texture which is used with framebuffers
183
- setResolution(width, height) {
184
- const gl = this.gl;
200
+ HeatWaveGlobeShellPlugin.prototype.setResolution = function (width, height) {
201
+ var gl = this.gl;
185
202
  this._resolution = [width, height];
186
203
  this._coloredHeatTexture = gl.createTexture();
187
204
  gl.bindTexture(gl.TEXTURE_2D, this._coloredHeatTexture);
@@ -192,8 +209,8 @@ class HeatWaveGlobeShellPlugin {
192
209
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
193
210
  gl.bindTexture(gl.TEXTURE_2D, null);
194
211
  this.globeShell.setTexture(this._coloredHeatTexture);
195
- }
196
- free() {
212
+ };
213
+ HeatWaveGlobeShellPlugin.prototype.free = function () {
197
214
  if (this.coordinatesDataCalculator) {
198
215
  this.dataManager.unregister(this._coordinatesDataCalculatorID());
199
216
  this.coordinatesDataCalculator = null;
@@ -201,6 +218,7 @@ class HeatWaveGlobeShellPlugin {
201
218
  this.dataManager.unregister(this.id);
202
219
  this.globeShell.free();
203
220
  this.heatProgram.free();
204
- }
205
- }
221
+ };
222
+ return HeatWaveGlobeShellPlugin;
223
+ }());
206
224
  exports.default = HeatWaveGlobeShellPlugin;
package/index.js CHANGED
@@ -34,25 +34,25 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.pointheatmap = exports.partialring = exports.arrowfield = exports.programs = exports.util = exports.heatwave = exports.compassrose = exports.rangerings = exports.timetracks = exports.waveparticles = exports.wind = void 0;
37
- const wind = __importStar(require("./wind"));
37
+ var wind = __importStar(require("./wind"));
38
38
  exports.wind = wind;
39
- const waveparticles = __importStar(require("./waveparticles"));
39
+ var waveparticles = __importStar(require("./waveparticles"));
40
40
  exports.waveparticles = waveparticles;
41
- const timetracks = __importStar(require("./timetracks"));
41
+ var timetracks = __importStar(require("./timetracks"));
42
42
  exports.timetracks = timetracks;
43
- const arrowfield = __importStar(require("./arrowfield"));
43
+ var arrowfield = __importStar(require("./arrowfield"));
44
44
  exports.arrowfield = arrowfield;
45
- const rangerings = __importStar(require("./rangerings"));
45
+ var rangerings = __importStar(require("./rangerings"));
46
46
  exports.rangerings = rangerings;
47
- const partialring = __importStar(require("./partialrings"));
47
+ var partialring = __importStar(require("./partialrings"));
48
48
  exports.partialring = partialring;
49
- const compassrose = __importStar(require("./compassrose"));
49
+ var compassrose = __importStar(require("./compassrose"));
50
50
  exports.compassrose = compassrose;
51
- const heatwave = __importStar(require("./heatwave"));
51
+ var heatwave = __importStar(require("./heatwave"));
52
52
  exports.heatwave = heatwave;
53
- const util = __importStar(require("./util"));
53
+ var util = __importStar(require("./util"));
54
54
  exports.util = util;
55
- const programs = __importStar(require("./programs"));
55
+ var programs = __importStar(require("./programs"));
56
56
  exports.programs = programs;
57
- const pointheatmap = __importStar(require("./point-heat-map"));
57
+ var pointheatmap = __importStar(require("./point-heat-map"));
58
58
  exports.pointheatmap = pointheatmap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.9.10",
3
+ "version": "0.9.11",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",