@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
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return { long
|
|
6
|
+
const pointcoordsmeta_1 = __importDefault(require("./pointcoordsmeta"));
|
|
7
|
+
const pointObject = (long, lat, posIndex, callback) => {
|
|
8
|
+
return { long, lat, posIndex, callback };
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
class PointCoordinatesDataCalculator {
|
|
11
|
+
constructor(bbox, width, height) {
|
|
12
12
|
this._pointObjects = {};
|
|
13
13
|
this._ratio = 0.0;
|
|
14
14
|
this._bbox = bbox;
|
|
@@ -25,51 +25,49 @@ var PointCoordinatesDataCalculator = /** @class */ (function () {
|
|
|
25
25
|
* @param {*} long
|
|
26
26
|
* @param {*} callback | callback(data0, data1, interpolated)
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
registerPoint(key, long, lat, callback) {
|
|
29
29
|
if (key in this._pointObjects) {
|
|
30
30
|
console.warn("key already registered, old one is unregistered");
|
|
31
31
|
this.unregisterPoint(key);
|
|
32
32
|
}
|
|
33
33
|
if (!this._isInBBox(long, lat))
|
|
34
34
|
return false;
|
|
35
|
-
|
|
35
|
+
const meta = this._metaCalculater.getFlooredMeta(long, lat);
|
|
36
36
|
this._pointObjects[key] = pointObject(long, lat, meta.index, callback);
|
|
37
37
|
if (this._texture0 && this._texture1) {
|
|
38
|
-
|
|
38
|
+
const { data0, data1, interpolated } = this._findAPoint(meta.index);
|
|
39
39
|
callback(data0, data1, interpolated);
|
|
40
40
|
}
|
|
41
41
|
return true;
|
|
42
|
-
}
|
|
43
|
-
|
|
42
|
+
}
|
|
43
|
+
_isInBBox(long, lat) {
|
|
44
44
|
return lat >= this._bbox[1] && lat <= this._bbox[3] && long >= this._bbox[0] && long <= this._bbox[2];
|
|
45
|
-
}
|
|
46
|
-
|
|
45
|
+
}
|
|
46
|
+
unregisterPoint(key) {
|
|
47
47
|
if (!(key in this._pointObjects))
|
|
48
48
|
return false;
|
|
49
49
|
delete this._pointObjects[key];
|
|
50
50
|
return true;
|
|
51
|
-
}
|
|
52
|
-
|
|
51
|
+
}
|
|
52
|
+
updatePoint(key, long, lat) {
|
|
53
53
|
if (!(key in this._pointObjects))
|
|
54
54
|
return false;
|
|
55
55
|
if (!this._isInBBox(long, lat))
|
|
56
56
|
return false;
|
|
57
57
|
this._pointObjects[key].long = long;
|
|
58
58
|
this._pointObjects[key].lat = lat;
|
|
59
|
-
|
|
59
|
+
const meta = this._metaCalculater.getFlooredMeta(long, lat);
|
|
60
60
|
this._pointObjects[key].posIndex = meta.index;
|
|
61
|
-
|
|
61
|
+
const { data0, data1, interpolated } = this._findAPoint(meta.index);
|
|
62
62
|
this._pointObjects[key].callback(data0, data1, interpolated);
|
|
63
63
|
return true;
|
|
64
|
-
}
|
|
64
|
+
}
|
|
65
65
|
/**
|
|
66
66
|
* @param {Number} ratio 0-1
|
|
67
67
|
* @param {} textureData0
|
|
68
68
|
* @param {*} textureData1
|
|
69
69
|
*/
|
|
70
|
-
|
|
71
|
-
if (textureData0 === void 0) { textureData0 = null; }
|
|
72
|
-
if (textureData1 === void 0) { textureData1 = null; }
|
|
70
|
+
updateData(ratio, textureData0 = null, textureData1 = null) {
|
|
73
71
|
if (!textureData0 && !textureData1) {
|
|
74
72
|
this._pushPointCallBackEmpty();
|
|
75
73
|
return;
|
|
@@ -80,31 +78,30 @@ var PointCoordinatesDataCalculator = /** @class */ (function () {
|
|
|
80
78
|
}
|
|
81
79
|
this._ratio = ratio;
|
|
82
80
|
this._pushPointCallbackAll();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return { data0
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
for (
|
|
92
|
-
|
|
93
|
-
|
|
81
|
+
}
|
|
82
|
+
_findAPoint(posIndex) {
|
|
83
|
+
const data0 = this._texture0[posIndex];
|
|
84
|
+
const data1 = this._texture1[posIndex];
|
|
85
|
+
const interpolated = data0 * (1 - this._ratio) + data1 * this._ratio;
|
|
86
|
+
return { data0, data1, interpolated };
|
|
87
|
+
}
|
|
88
|
+
_pushPointCallbackAll() {
|
|
89
|
+
for (const key in this._pointObjects) {
|
|
90
|
+
const { posIndex, callback } = this._pointObjects[key];
|
|
91
|
+
const { data0, data1, interpolated } = this._findAPoint(posIndex);
|
|
94
92
|
callback(data0, data1, interpolated);
|
|
95
93
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
for (
|
|
99
|
-
|
|
94
|
+
}
|
|
95
|
+
_pushPointCallBackEmpty() {
|
|
96
|
+
for (const key in this._pointObjects) {
|
|
97
|
+
const { callback } = this._pointObjects[key];
|
|
100
98
|
callback(null, null, null);
|
|
101
99
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
100
|
+
}
|
|
101
|
+
flush() {
|
|
104
102
|
this._pointObjects = {};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
}());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
108
105
|
exports.default = PointCoordinatesDataCalculator;
|
|
109
106
|
// function test() {
|
|
110
107
|
// const cp = window.plugin.getPointCoordinatesDataCalculator();
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
class PointCoordsMeta {
|
|
4
|
+
constructor(bbox, width, height) {
|
|
5
5
|
this._bbox = bbox;
|
|
6
6
|
this._width = width;
|
|
7
7
|
this._height = height;
|
|
8
8
|
this._xRatio = this._width / (this._bbox[2] - this._bbox[0]);
|
|
9
9
|
this._yRatio = this._height / (this._bbox[3] - this._bbox[1]);
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
getFlooredMeta(long, lat) {
|
|
12
|
+
let x = (long - this._bbox[0]) * this._xRatio;
|
|
13
|
+
let y = (this._bbox[3] - lat) * this._yRatio;
|
|
14
14
|
x = x > 0 ? x - 1 : 0;
|
|
15
15
|
y = y > 0 ? y - 1 : 0;
|
|
16
|
-
|
|
17
|
-
return { index
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}());
|
|
16
|
+
const index = Math.floor(y) * this._width + Math.floor(x);
|
|
17
|
+
return { index };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
21
20
|
exports.default = PointCoordsMeta;
|
package/util/index.js
CHANGED
|
@@ -37,17 +37,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.heatwavedatamanager = exports.programs = exports.webglobe = exports.geometry = exports.shaderfunctions = exports.webglobjectbuilders = void 0;
|
|
40
|
-
|
|
40
|
+
const webglobjectbuilders = __importStar(require("./webglobjectbuilders"));
|
|
41
41
|
exports.webglobjectbuilders = webglobjectbuilders;
|
|
42
|
-
|
|
42
|
+
const shaderfunctions = __importStar(require("./shaderfunctions"));
|
|
43
43
|
exports.shaderfunctions = shaderfunctions;
|
|
44
|
-
|
|
44
|
+
const geometry = __importStar(require("./geometry"));
|
|
45
45
|
exports.geometry = geometry;
|
|
46
|
-
|
|
46
|
+
const webglobe = __importStar(require("./webglobe"));
|
|
47
47
|
exports.webglobe = webglobe;
|
|
48
|
-
|
|
48
|
+
const programs = __importStar(require("./programs"));
|
|
49
49
|
exports.programs = programs;
|
|
50
|
-
|
|
50
|
+
const heatwavedatamanager = __importStar(require("./heatwavedatamanager"));
|
|
51
51
|
exports.heatwavedatamanager = heatwavedatamanager;
|
|
52
52
|
__exportStar(require("./webglobe"), exports);
|
|
53
53
|
__exportStar(require("./webglobjectbuilders"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWorker = void 0;
|
|
4
|
-
|
|
4
|
+
const createWorker = () => new Worker(new URL('./web-worker.js', import.meta.url), { type: 'module' });
|
|
5
5
|
exports.createWorker = createWorker;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GEOMETRY = exports.TimeTrackInterpolator = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const search_binary_1 = require("../../algorithms/search-binary");
|
|
5
|
+
const methods_1 = require("../../../Math/methods");
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Array<number>} vec3 [x, y, z]
|
|
8
8
|
* @typedef {Array<number>} vec2 [x, y]
|
|
@@ -10,20 +10,19 @@ var methods_1 = require("../../../Math/methods");
|
|
|
10
10
|
* @typedef {number} fraction a number between 0 and 1
|
|
11
11
|
* @typedef {Array<number>} wgs84 [long, lat]
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
const GEOMETRY = Object.freeze({
|
|
14
14
|
CARTESIAN3D: 0,
|
|
15
15
|
MERCATOR: 1,
|
|
16
16
|
});
|
|
17
17
|
exports.GEOMETRY = GEOMETRY;
|
|
18
|
-
|
|
18
|
+
class TimeTrackInterpolator {
|
|
19
19
|
/**
|
|
20
20
|
* @typedef Timetrack
|
|
21
21
|
* @property {Array<vec4>}} coordinates [x,y,z, length]
|
|
22
22
|
* @property {Array<Number>} times
|
|
23
23
|
* @param {Array<Timetrack>} timeTracks
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
var _b = _a === void 0 ? {} : _a, timeTracks = _b.timeTracks, _c = _b.bbox, bbox = _c === void 0 ? null : _c, _d = _b.geometry, geometry = _d === void 0 ? GEOMETRY.CARTESIAN3D : _d;
|
|
25
|
+
constructor({ timeTracks, bbox = null, geometry = GEOMETRY.CARTESIAN3D } = {}) {
|
|
27
26
|
this.timeTracks = null;
|
|
28
27
|
this.timeTracksStartTimes = null;
|
|
29
28
|
this.geometry = geometry;
|
|
@@ -32,50 +31,49 @@ var TimeTrackInterpolator = /** @class */ (function () {
|
|
|
32
31
|
if (bbox)
|
|
33
32
|
this.setBbox(bbox);
|
|
34
33
|
}
|
|
35
|
-
|
|
34
|
+
setGeometry(geometry) {
|
|
36
35
|
if (geometry !== GEOMETRY.CARTESIAN3D && geometry !== GEOMETRY.MERCATOR) {
|
|
37
36
|
throw new Error('Invalid geometry');
|
|
38
37
|
}
|
|
39
38
|
this.geometry = geometry;
|
|
40
|
-
}
|
|
41
|
-
|
|
39
|
+
}
|
|
40
|
+
setTimetracks(timeTracks) {
|
|
42
41
|
this.timeTracks = timeTracks;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
}
|
|
43
|
+
interpolate(time) {
|
|
44
|
+
const { timeTracks, geometry } = this;
|
|
46
45
|
if (!timeTracks) {
|
|
47
46
|
return null;
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const resultArray = [];
|
|
49
|
+
const info = {
|
|
51
50
|
outOfRange: 0,
|
|
52
51
|
processed: 0,
|
|
53
52
|
};
|
|
54
|
-
for (
|
|
55
|
-
|
|
53
|
+
for (let i = 0; i < timeTracks.length; i++) {
|
|
54
|
+
const { times, coordinates } = timeTracks[i];
|
|
56
55
|
if (times[times.length - 1] < time)
|
|
57
56
|
continue;
|
|
58
57
|
info.processed++;
|
|
59
|
-
|
|
58
|
+
const timeIndex = (0, search_binary_1.findFirstIndexInRange)(times, time);
|
|
60
59
|
if (timeIndex === null) {
|
|
61
60
|
info.outOfRange++;
|
|
62
61
|
continue;
|
|
63
62
|
}
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const timeFraction = (time - times[timeIndex]) / (times[timeIndex + 1] - times[timeIndex]);
|
|
64
|
+
const interpolated = (geometry === GEOMETRY.CARTESIAN3D) ?
|
|
66
65
|
(0, methods_1.sphericalLinearInterpolation_Cartesian3d)(coordinates[timeIndex], coordinates[timeIndex + 1], timeFraction) :
|
|
67
66
|
(0, methods_1.sphericalLinearInterpolation_Mercator)(coordinates[timeIndex], coordinates[timeIndex + 1], timeFraction);
|
|
68
|
-
resultArray.push
|
|
67
|
+
resultArray.push(...interpolated);
|
|
69
68
|
}
|
|
70
69
|
return new Float32Array(resultArray);
|
|
71
|
-
}
|
|
70
|
+
}
|
|
72
71
|
// implicit methods
|
|
73
|
-
|
|
74
|
-
this.timeTracks.sort(
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
this.timeTracksStartTimes = this.timeTracks.map(
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
}());
|
|
72
|
+
_orderTimeTracks() {
|
|
73
|
+
this.timeTracks.sort((a, b) => a.times[0] - b.times[0]);
|
|
74
|
+
}
|
|
75
|
+
_setStartTimes() {
|
|
76
|
+
this.timeTracksStartTimes = this.timeTracks.map(tt => tt.times[0]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
81
79
|
exports.TimeTrackInterpolator = TimeTrackInterpolator;
|
|
@@ -1,5 +1,183 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.webworkerStr = void 0;
|
|
4
|
-
|
|
4
|
+
const webworkerStr = `
|
|
5
|
+
|
|
6
|
+
const WORLD_RADIUS_3D = 6378.137;
|
|
7
|
+
const WORLD_RADIUS_MERCATOR = 6378136.99911;
|
|
8
|
+
|
|
9
|
+
const dot3 = (a, b) => {
|
|
10
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const sphericalLinearInterpolation_UnitVector = (normalizedA, normalizedB, ratio) => {
|
|
14
|
+
const theta = Math.acos(dot3(normalizedA, normalizedB));
|
|
15
|
+
if (theta < 0.000001) return normalizedA; // CALIBRATE?
|
|
16
|
+
const sinTheta = Math.sin(theta);
|
|
17
|
+
const result = [
|
|
18
|
+
(Math.sin((1.0 - ratio) * theta) * normalizedA[0] + Math.sin(ratio * theta) * normalizedB[0]) / sinTheta,
|
|
19
|
+
(Math.sin((1.0 - ratio) * theta) * normalizedA[1] + Math.sin(ratio * theta) * normalizedB[1]) / sinTheta,
|
|
20
|
+
(Math.sin((1.0 - ratio) * theta) * normalizedA[2] + Math.sin(ratio * theta) * normalizedB[2]) / sinTheta
|
|
21
|
+
];
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const radianToMercator = (xy) => {
|
|
26
|
+
return [WORLD_RADIUS_MERCATOR * xy[0], WORLD_RADIUS_MERCATOR * Math.log(Math.tan(Math.PI / 4 + xy[1] / 2))];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
const cartesian3dToRadian = (cartesian) => {
|
|
31
|
+
const x = cartesian[0];
|
|
32
|
+
const y = cartesian[1];
|
|
33
|
+
const z = cartesian[2];
|
|
34
|
+
// const length = Math.sqrt(x * x + y * y + z * z);
|
|
35
|
+
const long = Math.atan2(y, x);
|
|
36
|
+
const lat = Math.asin(z)// length);
|
|
37
|
+
return [long, lat];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const sphericalLinearInterpolation_Mercator = (normalizedA, normalizedB, ratio) => {
|
|
42
|
+
const unitVector = sphericalLinearInterpolation_UnitVector(normalizedA, normalizedB, ratio);
|
|
43
|
+
const angles = cartesian3dToRadian(unitVector);
|
|
44
|
+
return radianToMercator(angles);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const sphericalLinearInterpolation_Cartesian3d = (a, b, ratio) => {
|
|
48
|
+
const unitVector = sphericalLinearInterpolation_UnitVector(a, b, ratio);
|
|
49
|
+
const height = a[3] + (b[3] - a[3]) * ratio;
|
|
50
|
+
return [unitVector[0] * height, unitVector[1] * height, unitVector[2] * height];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const findFirstIndexInRange = (container, value) => {
|
|
54
|
+
let start = 0;
|
|
55
|
+
let end = container.length - 1;
|
|
56
|
+
let mid = 0;
|
|
57
|
+
while (start <= end) {
|
|
58
|
+
mid = Math.floor((start + end) / 2);
|
|
59
|
+
if (container[mid] <= value && value <= container[mid + 1]) return mid;
|
|
60
|
+
if (container[mid] < value) start = mid + 1;
|
|
61
|
+
else end = mid - 1;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const GEOMETRY = Object.freeze({
|
|
67
|
+
CARTESIAN3D: 0,
|
|
68
|
+
MERCATOR: 1,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
class TimeTrackInterpolator {
|
|
72
|
+
/**
|
|
73
|
+
* @typedef Timetrack
|
|
74
|
+
* @property {Array<vec4>}} coordinates [x,y,z, length]
|
|
75
|
+
* @property {Array<Number>} times
|
|
76
|
+
* @param {Array<Timetrack>} timeTracks
|
|
77
|
+
*/
|
|
78
|
+
constructor({ timeTracks, bbox = null, geometry = GEOMETRY.CARTESIAN3D } = {}) {
|
|
79
|
+
this.timeTracks = null;
|
|
80
|
+
this.timeTracksStartTimes = null;
|
|
81
|
+
this.geometry = geometry;
|
|
82
|
+
if (timeTracks) this.setTimetracks(timeTracks);
|
|
83
|
+
if (bbox) this.setBbox(bbox);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
setGeometry(geometry) {
|
|
88
|
+
if (geometry !== GEOMETRY.CARTESIAN3D && geometry !== GEOMETRY.MERCATOR) {
|
|
89
|
+
throw new Error('Invalid geometry');
|
|
90
|
+
}
|
|
91
|
+
this.geometry = geometry;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
setTimetracks(timeTracks) {
|
|
95
|
+
this.timeTracks = timeTracks;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
interpolate(time) {
|
|
100
|
+
const { timeTracks, geometry } = this;
|
|
101
|
+
if (!timeTracks) { return null; }
|
|
102
|
+
const resultArray = [];
|
|
103
|
+
const info = {
|
|
104
|
+
outOfRange: 0,
|
|
105
|
+
processed: 0,
|
|
106
|
+
}
|
|
107
|
+
for (let i = 0; i < timeTracks.length; i++) {
|
|
108
|
+
const { times, coordinates } = timeTracks[i];
|
|
109
|
+
|
|
110
|
+
if (times[times.length - 1] < time) continue;
|
|
111
|
+
info.processed++;
|
|
112
|
+
const timeIndex = findFirstIndexInRange(times, time);
|
|
113
|
+
if (timeIndex === null) { info.outOfRange++; continue; }
|
|
114
|
+
const timeFraction = (time - times[timeIndex]) / (times[timeIndex + 1] - times[timeIndex]);
|
|
115
|
+
const interpolated = (geometry === GEOMETRY.CARTESIAN3D) ?
|
|
116
|
+
sphericalLinearInterpolation_Cartesian3d(coordinates[timeIndex], coordinates[timeIndex + 1], timeFraction) :
|
|
117
|
+
sphericalLinearInterpolation_Mercator(coordinates[timeIndex], coordinates[timeIndex + 1], timeFraction);
|
|
118
|
+
resultArray.push(...interpolated);
|
|
119
|
+
}
|
|
120
|
+
return new Float32Array(resultArray);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
// implicit methods
|
|
125
|
+
|
|
126
|
+
_orderTimeTracks() {
|
|
127
|
+
this.timeTracks.sort((a, b) => a.times[0] - b.times[0]);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
_setStartTimes() {
|
|
131
|
+
this.timeTracksStartTimes = this.timeTracks.map(tt => tt.times[0]);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const interpolator = new TimeTrackInterpolator({ geometry: GEOMETRY.CARTESIAN3D });
|
|
136
|
+
|
|
137
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
138
|
+
self.onmessage = function (e) {
|
|
139
|
+
|
|
140
|
+
const { geometry = null, timeTracks = null, time = null } = e.data;
|
|
141
|
+
|
|
142
|
+
if (geometry !== null) {
|
|
143
|
+
try {
|
|
144
|
+
interpolator.setGeometry(geometry);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
147
|
+
self.postMessage({ error: error.message });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (timeTracks !== null) {
|
|
153
|
+
try {
|
|
154
|
+
interpolator.setTimetracks(timeTracks);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
157
|
+
self.postMessage({ error: error.message });
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (time !== null) {
|
|
163
|
+
try {
|
|
164
|
+
const result = interpolator.interpolate(time);
|
|
165
|
+
if(result === null) {
|
|
166
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
167
|
+
self.postMessage({ error: 'No TimeTracks Data' });
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
171
|
+
self.postMessage(result, [result.buffer]);
|
|
172
|
+
return;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
175
|
+
self.postMessage({ error: error.message });
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/* eslint-disable-next-line no-restricted-globals */
|
|
180
|
+
self.postMessage(true);
|
|
181
|
+
}
|
|
182
|
+
`;
|
|
5
183
|
exports.webworkerStr = webworkerStr;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const timetrack_interpolator_1 = require("./timetrack-interpolator");
|
|
4
|
+
const interpolator = new timetrack_interpolator_1.TimeTrackInterpolator({ geometry: timetrack_interpolator_1.GEOMETRY.CARTESIAN3D });
|
|
5
5
|
/* eslint-disable-next-line no-restricted-globals */
|
|
6
6
|
self.onmessage = function (e) {
|
|
7
|
-
|
|
7
|
+
const { geometry = null, timeTracks = null, time = null } = e.data;
|
|
8
8
|
if (geometry !== null) {
|
|
9
9
|
try {
|
|
10
10
|
interpolator.setGeometry(geometry);
|
|
@@ -27,7 +27,7 @@ self.onmessage = function (e) {
|
|
|
27
27
|
}
|
|
28
28
|
if (time !== null) {
|
|
29
29
|
try {
|
|
30
|
-
|
|
30
|
+
const result = interpolator.interpolate(time);
|
|
31
31
|
if (result === null) {
|
|
32
32
|
/* eslint-disable-next-line no-restricted-globals */
|
|
33
33
|
self.postMessage({ error: 'No TimeTracks Data' });
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.populateFloat32Array = void 0;
|
|
4
|
-
|
|
5
|
-
fillFloat32Array:
|
|
6
|
-
|
|
4
|
+
const populateFloat32Array = Object.freeze({
|
|
5
|
+
fillFloat32Array: (length, data) => {
|
|
6
|
+
const result = new Float32Array(length);
|
|
7
7
|
result.fill(data);
|
|
8
8
|
return result;
|
|
9
9
|
},
|
|
10
|
-
fillWithListData:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
for (
|
|
10
|
+
fillWithListData: (length, listdata) => {
|
|
11
|
+
const result = new Float32Array(length * listdata.length);
|
|
12
|
+
let offset = 0;
|
|
13
|
+
for (let i = 0; i < length; i++) {
|
|
14
14
|
result.set(listdata, offset);
|
|
15
15
|
offset += listdata.length;
|
|
16
16
|
}
|
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.instantDebounce = instantDebounce;
|
|
4
4
|
// TODO: fix logic error in instantDebounce
|
|
5
5
|
function instantDebounce(func, delay) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
setTimeout(
|
|
6
|
+
let timeout = null;
|
|
7
|
+
let lastArgs = null;
|
|
8
|
+
let runAtEnd = false;
|
|
9
|
+
const timeoutMethod = () => {
|
|
10
|
+
setTimeout(() => {
|
|
11
11
|
if (runAtEnd) {
|
|
12
|
-
func
|
|
12
|
+
func(...lastArgs);
|
|
13
13
|
lastArgs = null;
|
|
14
14
|
// console.log("processed with delay")
|
|
15
15
|
runAtEnd = false;
|
|
@@ -24,7 +24,7 @@ function instantDebounce(func, delay) {
|
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
func
|
|
27
|
+
func(...args);
|
|
28
28
|
// console.log("processed instantly")
|
|
29
29
|
timeout = timeoutMethod();
|
|
30
30
|
}
|
package/util/picking/fence.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fence = void 0;
|
|
4
|
-
|
|
4
|
+
const fence = (gl) => new Promise((resolve, reject) => {
|
|
5
5
|
// This will create a fence. If this follows a `readPixels()` call, then it
|
|
6
6
|
// will signal to WebGL that the read instruction should be asynchronous.
|
|
7
7
|
// This means JS can continue to work on other tasks while the read instruction
|
|
8
8
|
// completes.
|
|
9
|
-
|
|
9
|
+
const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
|
|
10
10
|
gl.flush();
|
|
11
11
|
// There are TWO possible ways to check on the status of a WebGLSync object.
|
|
12
12
|
// 1. This will check it using clientWaitSync()
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const checkStatus_v1 = () => {
|
|
14
|
+
const status = gl.clientWaitSync(sync, 0, 0);
|
|
15
15
|
// There are four possible values for status:
|
|
16
16
|
// a. ALREADY_SIGNALED and CONDITION_SATISFIED (done)
|
|
17
17
|
// b. TIMEOUT_EXPIRED (check again later)
|
|
@@ -29,8 +29,8 @@ var fence = function (gl) { return new Promise(function (resolve, reject) {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
// 2. This will check with getSyncParameter(s, gl.SYNC_STATUS)
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const checkStatus_v2 = () => {
|
|
33
|
+
const status = gl.getSyncParameter(sync, gl.SYNC_STATUS);
|
|
34
34
|
// There are only two possible values for status: SIGNALED and UNSIGNALED
|
|
35
35
|
// Note that there is no `error` signal, so there is no reason to use `reject()` here
|
|
36
36
|
if (status === gl.SIGNALED) {
|
|
@@ -42,5 +42,5 @@ var fence = function (gl) { return new Promise(function (resolve, reject) {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
setTimeout(checkStatus_v2, 1);
|
|
45
|
-
});
|
|
45
|
+
});
|
|
46
46
|
exports.fence = fence;
|