@pirireis/webglobeplugins 0.9.11 → 0.9.12

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