@pirireis/webglobeplugins 0.9.11 → 0.9.13

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