@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.
- package/Math/angle-calculation.js +8 -8
- package/Math/arc.js +18 -18
- package/Math/bounds/line-bbox.js +78 -80
- package/Math/constants.js +3 -3
- package/Math/juction/arc-plane.js +23 -23
- package/Math/juction/line-sphere.js +11 -11
- package/Math/juction/plane-plane.js +11 -11
- package/Math/line.js +14 -16
- package/Math/methods.js +65 -70
- package/Math/plane.js +16 -18
- package/Math/quaternion.js +45 -49
- package/Math/utils.js +2 -2
- package/Math/vec3.js +42 -45
- package/algorithms/search-binary.js +4 -4
- package/altitude-locator/draw-subset-obj.js +7 -8
- package/altitude-locator/plugin.js +98 -114
- package/arrowfield/adaptor.js +3 -4
- package/arrowfield/index.js +2 -2
- package/arrowfield/plugin.js +62 -65
- package/bearing-line/index.js +1 -1
- package/bearing-line/plugin.js +200 -226
- package/circle-line-chain/chain-list-map.js +82 -88
- package/circle-line-chain/plugin.js +134 -165
- package/circle-line-chain/util.js +1 -1
- package/compass-rose/compass-rose-padding-flat.js +108 -133
- package/compass-rose/compass-text-writer.js +62 -70
- package/compass-rose/index.js +2 -2
- package/compassrose/compassrose.js +46 -50
- package/compassrose/index.js +1 -1
- package/heatwave/index.js +2 -2
- package/heatwave/isobar/objectarraylabels.js +44 -48
- package/heatwave/isobar/plugin.js +104 -123
- package/heatwave/isobar/quadtreecontours.js +76 -92
- package/heatwave/plugins/heatwaveglobeshell.js +69 -87
- package/index.js +11 -11
- package/package.json +1 -1
- package/partialrings/buffer-manager.js +32 -64
- package/partialrings/index.js +1 -1
- package/partialrings/plugin.js +48 -84
- package/partialrings/program.js +136 -47
- package/pin/pin-object-array.js +83 -86
- package/pin/pin-point-totem.js +21 -22
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
- package/point-heat-map/plugin-webworker.js +40 -45
- package/point-heat-map/point-to-heat-map-flow.js +40 -42
- package/point-tracks/key-methods.js +1 -1
- package/point-tracks/plugin.js +137 -162
- package/programs/arrowfield/index.js +1 -1
- package/programs/arrowfield/logic.js +170 -62
- package/programs/arrowfield/object.js +33 -35
- package/programs/data2legend/density-to-legend.js +45 -21
- package/programs/data2legend/point-to-density-texture.js +52 -27
- package/programs/float2legendwithratio/index.js +1 -1
- package/programs/float2legendwithratio/logic.js +88 -42
- package/programs/float2legendwithratio/object.js +43 -46
- package/programs/globe-util/is-globe-moved.js +10 -11
- package/programs/globeshell/index.js +1 -1
- package/programs/globeshell/wiggle/index.js +1 -1
- package/programs/globeshell/wiggle/logic.js +191 -98
- package/programs/globeshell/wiggle/object.js +33 -35
- package/programs/helpers/blender/program.js +36 -19
- package/programs/helpers/fadeaway/index.js +1 -1
- package/programs/helpers/fadeaway/logic.js +35 -13
- package/programs/helpers/fadeaway/object.js +9 -10
- package/programs/helpers/index.js +1 -1
- package/programs/index.js +8 -8
- package/programs/line-on-globe/angled-line.js +91 -32
- package/programs/line-on-globe/circle-accurate-3d.js +82 -32
- package/programs/line-on-globe/circle-accurate-flat.js +108 -50
- package/programs/line-on-globe/circle-accurate.js +103 -33
- package/programs/line-on-globe/circle.js +97 -32
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +83 -33
- package/programs/line-on-globe/lines-color-instanced-flat.js +79 -34
- package/programs/line-on-globe/linestrip.js +111 -45
- package/programs/line-on-globe/naive-accurate-flexible.js +120 -50
- package/programs/line-on-globe/to-the-surface.js +58 -29
- package/programs/line-on-globe/util.js +1 -1
- package/programs/picking/pickable-renderer.js +117 -33
- package/programs/point-on-globe/element-globe-surface-glow.js +78 -38
- package/programs/point-on-globe/element-point-glow.js +103 -35
- package/programs/point-on-globe/square-pixel-point.js +76 -27
- package/programs/programcache.js +13 -13
- package/programs/rings/distancering/circleflatprogram.js +63 -21
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +156 -145
- package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -197
- package/programs/rings/distancering/index.js +4 -4
- package/programs/rings/distancering/paddyflatprogram.js +73 -20
- package/programs/rings/distancering/paddyflatprogram2d.js +75 -22
- package/programs/rings/distancering/paddyflatprogram3d.js +73 -20
- package/programs/rings/partial-ring/piece-of-pie.js +137 -35
- package/programs/totems/camerauniformblock.js +64 -51
- package/programs/totems/canvas-webglobe-info.js +48 -40
- package/programs/totems/gpu-selection-uniform-block.js +44 -40
- package/programs/totems/index.js +1 -1
- package/programs/two-d/pixel-padding-for-compass.js +90 -29
- package/programs/util.js +6 -7
- package/programs/vectorfields/index.js +1 -1
- package/programs/vectorfields/logics/drawrectangleparticles.js +70 -29
- package/programs/vectorfields/logics/index.js +3 -3
- package/programs/vectorfields/logics/pixelbased.js +91 -35
- package/programs/vectorfields/logics/ubo.js +31 -25
- package/programs/vectorfields/pingpongbuffermanager.js +30 -34
- package/rangerings/index.js +4 -4
- package/rangerings/plugin.js +202 -258
- package/rangerings/rangeringangletext.js +108 -120
- package/rangerings/ring-account.js +52 -69
- package/shaders/fragment-toy/firework.js +55 -1
- package/shaders/fragment-toy/singularity.js +55 -1
- package/timetracks/adaptors-line-strip.js +26 -37
- package/timetracks/adaptors.js +47 -61
- package/timetracks/index.js +4 -4
- package/timetracks/plugin-line-strip.js +63 -71
- package/timetracks/plugin.js +69 -77
- package/timetracks/program-line-strip.js +296 -103
- package/timetracks/program.js +419 -113
- package/timetracks/programpoint-line-strip.js +97 -44
- package/timetracks/programpoint.js +90 -44
- package/util/account/bufferoffsetmanager.js +72 -95
- package/util/account/index.js +1 -1
- package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -44
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -94
- package/util/account/single-attribute-buffer-management/index.js +3 -3
- package/util/account/single-attribute-buffer-management/object-store.js +29 -30
- package/util/account/util.js +2 -4
- package/util/algorithms/search-binary.js +4 -4
- package/util/check/get.js +5 -5
- package/util/check/typecheck.js +13 -15
- package/util/geometry/index.js +9 -11
- package/util/gl-util/buffer/attribute-loader.js +8 -20
- package/util/gl-util/buffer/index.js +1 -1
- package/util/gl-util/draw-options/methods.js +8 -9
- package/util/gl-util/uniform-block/manager.js +67 -67
- package/util/heatwavedatamanager/datamanager.js +56 -116
- package/util/heatwavedatamanager/index.js +2 -2
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +37 -40
- package/util/heatwavedatamanager/pointcoordsmeta.js +9 -10
- package/util/index.js +6 -6
- package/util/interpolation/timetrack/index.js +1 -1
- package/util/interpolation/timetrack/timetrack-interpolator.js +27 -29
- package/util/interpolation/timetrack/web-worker-str.js +179 -1
- package/util/interpolation/timetrack/web-worker.js +4 -4
- package/util/jshelpers/data-filler.js +7 -7
- package/util/jshelpers/timefilters.js +7 -7
- package/util/picking/fence.js +7 -7
- package/util/picking/picker-displayer.js +46 -52
- package/util/programs/draw-texture-on-canvas.js +39 -21
- package/util/programs/shapesonglobe.js +104 -64
- package/util/programs/supersampletotextures.js +45 -39
- package/util/programs/texturetoglobe.js +98 -48
- package/util/shaderfunctions/geometrytransformations.js +322 -27
- package/util/shaderfunctions/nodata.js +7 -1
- package/util/shaderfunctions/noisefunctions.js +39 -9
- package/util/surface-line-data/arcs-to-cuts.js +20 -23
- package/util/webglobe/rasteroverlay.js +35 -37
- package/util/webglobjectbuilders.js +55 -60
- package/util/webglobjectbuilders1.js +48 -49
- package/waveparticles/adaptor.js +6 -7
- package/waveparticles/index.js +2 -2
- package/waveparticles/plugin.js +79 -84
- package/wind/imagetovectorfieldandmagnitude.js +15 -15
- package/wind/index.js +4 -4
- package/wind/plugin.js +453 -251
- package/wind/vectorfieldimage.js +5 -5
- package/write-text/attached-text-writer.js +46 -48
- package/write-text/context-text.js +51 -58
- 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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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(
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
48
|
-
for (
|
|
49
|
-
|
|
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
|
-
|
|
57
|
-
for (
|
|
58
|
-
|
|
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
|
-
|
|
73
|
-
|
|
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
|
|
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
|
-
|
|
71
|
+
min() { return this.levels[0].min[0]; }
|
|
82
72
|
// Get the maximum elevation in the mipmap
|
|
83
|
-
|
|
73
|
+
max() { return this.levels[0].max[0]; }
|
|
84
74
|
// Get an array of contour levels for a specified contour interval
|
|
85
|
-
|
|
75
|
+
intervals(interval) {
|
|
86
76
|
if (interval <= 0)
|
|
87
77
|
throw new Error('Contour interval must be positive');
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
129
|
-
|
|
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
|
-
|
|
147
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
199
|
-
this.evaluateContour(level, { maxMipmapLevel
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
segments.push({ start
|
|
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(
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
segments.forEach(
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
235
|
+
console.error(`Contour remaining fragment size mismatch ${fragmentStart.size} ${fragmentEnd.size}`);
|
|
251
236
|
}
|
|
252
237
|
});
|
|
253
|
-
|
|
238
|
+
const smoothOpts = {
|
|
254
239
|
kernelWidth: smoothKernelWidth,
|
|
255
240
|
cycles: smoothCycles,
|
|
256
241
|
};
|
|
257
242
|
// Closed rings and any unclosed line strings
|
|
258
|
-
return
|
|
259
|
-
.
|
|
260
|
-
|
|
261
|
-
|
|
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,
|
|
270
|
-
|
|
271
|
-
|
|
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 =
|
|
258
|
+
pointAt = i => line[(i + line.length) % line.length];
|
|
275
259
|
}
|
|
276
260
|
else {
|
|
277
|
-
pointAt =
|
|
261
|
+
pointAt = i => line[Math.min(Math.max(i, 0), line.length - 1)];
|
|
278
262
|
}
|
|
279
|
-
|
|
280
|
-
for (
|
|
281
|
-
|
|
282
|
-
|
|
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 (
|
|
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 (
|
|
277
|
+
for (let i = 0; i < kernelWidth; i++) {
|
|
294
278
|
px += line[i][0];
|
|
295
279
|
py += line[i][1];
|
|
296
280
|
}
|
|
297
|
-
|
|
298
|
-
for (
|
|
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
|
-
|
|
313
|
-
|
|
314
|
-
return { scaleX
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
|
|
33
|
+
setHeight(height) {
|
|
44
34
|
this.globeShell.setHeight(height);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
gl.viewport
|
|
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
|
-
|
|
50
|
+
}
|
|
51
|
+
setEscapeValue(escapeValue) {
|
|
62
52
|
this._escapeValue = escapeValue;
|
|
63
53
|
this.heatProgram.setEscapeValue(escapeValue);
|
|
64
|
-
}
|
|
65
|
-
|
|
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
|
-
|
|
58
|
+
}
|
|
59
|
+
_coordinatesDataCalculatorID() {
|
|
70
60
|
return this.id + "_coordinatesDataCalculator";
|
|
71
|
-
}
|
|
72
|
-
|
|
61
|
+
}
|
|
62
|
+
updateTime(time) {
|
|
73
63
|
this.dataManager.updateTime(time);
|
|
74
64
|
this.globe.DrawRender();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
76
|
+
}
|
|
77
|
+
setBBox(minLon, minLat, maxLon, maxLat) {
|
|
91
78
|
this._bbox = [minLon, minLat, maxLon, maxLat];
|
|
92
|
-
this.globeShell.setBBox({ minLon
|
|
79
|
+
this.globeShell.setBBox({ minLon, minLat, maxLon, maxLat });
|
|
93
80
|
this.drawHeat();
|
|
94
|
-
}
|
|
95
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
104
|
+
}
|
|
105
|
+
off() {
|
|
120
106
|
this._isOn = false;
|
|
121
|
-
}
|
|
122
|
-
|
|
107
|
+
}
|
|
108
|
+
on() {
|
|
123
109
|
this._isOn = true;
|
|
124
|
-
}
|
|
125
|
-
|
|
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
|
-
|
|
147
|
-
this._dataWidthHeight = { width
|
|
129
|
+
}
|
|
130
|
+
setDataWidthHeight(width, height) {
|
|
131
|
+
this._dataWidthHeight = { width, height };
|
|
148
132
|
this.heatProgram.setDataWidthHeight(width, height);
|
|
149
133
|
this.setGeometry();
|
|
150
|
-
}
|
|
151
|
-
|
|
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
|
-
|
|
142
|
+
}
|
|
143
|
+
setOpacity(opacity) {
|
|
160
144
|
(0, typecheck_1.opacityCheck)(opacity);
|
|
161
145
|
this.globeShell.setOpacity(opacity);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.globeShell.setBBox({ minLon
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
201
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
37
|
+
const wind = __importStar(require("./wind"));
|
|
38
38
|
exports.wind = wind;
|
|
39
|
-
|
|
39
|
+
const waveparticles = __importStar(require("./waveparticles"));
|
|
40
40
|
exports.waveparticles = waveparticles;
|
|
41
|
-
|
|
41
|
+
const timetracks = __importStar(require("./timetracks"));
|
|
42
42
|
exports.timetracks = timetracks;
|
|
43
|
-
|
|
43
|
+
const arrowfield = __importStar(require("./arrowfield"));
|
|
44
44
|
exports.arrowfield = arrowfield;
|
|
45
|
-
|
|
45
|
+
const rangerings = __importStar(require("./rangerings"));
|
|
46
46
|
exports.rangerings = rangerings;
|
|
47
|
-
|
|
47
|
+
const partialring = __importStar(require("./partialrings"));
|
|
48
48
|
exports.partialring = partialring;
|
|
49
|
-
|
|
49
|
+
const compassrose = __importStar(require("./compassrose"));
|
|
50
50
|
exports.compassrose = compassrose;
|
|
51
|
-
|
|
51
|
+
const heatwave = __importStar(require("./heatwave"));
|
|
52
52
|
exports.heatwave = heatwave;
|
|
53
|
-
|
|
53
|
+
const util = __importStar(require("./util"));
|
|
54
54
|
exports.util = util;
|
|
55
|
-
|
|
55
|
+
const programs = __importStar(require("./programs"));
|
|
56
56
|
exports.programs = programs;
|
|
57
|
-
|
|
57
|
+
const pointheatmap = __importStar(require("./point-heat-map"));
|
|
58
58
|
exports.pointheatmap = pointheatmap;
|