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