@pirireis/webglobeplugins 0.9.10 → 0.9.11
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 +80 -78
- 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 +16 -14
- package/Math/methods.js +72 -67
- package/Math/plane.js +18 -16
- package/Math/quaternion.js +49 -45
- package/Math/utils.js +2 -2
- package/Math/vec3.js +45 -42
- package/algorithms/search-binary.js +4 -4
- package/altitude-locator/draw-subset-obj.js +8 -7
- package/altitude-locator/plugin.js +113 -97
- package/arrowfield/adaptor.js +4 -3
- package/arrowfield/index.js +2 -2
- package/arrowfield/plugin.js +65 -62
- package/bearing-line/index.js +1 -1
- package/bearing-line/plugin.js +225 -200
- package/circle-line-chain/chain-list-map.js +88 -82
- package/circle-line-chain/plugin.js +154 -129
- package/circle-line-chain/util.js +1 -1
- package/compass-rose/compass-rose-padding-flat.js +126 -104
- package/compass-rose/compass-text-writer.js +70 -62
- package/compass-rose/index.js +2 -2
- package/compassrose/compassrose.js +50 -46
- package/compassrose/index.js +1 -1
- package/heatwave/index.js +2 -2
- package/heatwave/isobar/objectarraylabels.js +48 -44
- package/heatwave/isobar/plugin.js +123 -104
- package/heatwave/isobar/quadtreecontours.js +92 -76
- package/heatwave/plugins/heatwaveglobeshell.js +87 -69
- package/index.js +11 -11
- package/package.json +1 -1
- package/partialrings/buffer-manager.js +64 -32
- package/partialrings/index.js +1 -1
- package/partialrings/plugin.js +84 -48
- package/partialrings/program.js +47 -136
- package/pin/pin-object-array.js +86 -83
- package/pin/pin-point-totem.js +22 -21
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
- package/point-heat-map/plugin-webworker.js +45 -40
- package/point-heat-map/point-to-heat-map-flow.js +42 -40
- package/point-tracks/key-methods.js +1 -1
- package/point-tracks/plugin.js +142 -127
- package/programs/arrowfield/index.js +1 -1
- package/programs/arrowfield/logic.js +62 -170
- package/programs/arrowfield/object.js +35 -33
- package/programs/data2legend/density-to-legend.js +21 -45
- package/programs/data2legend/point-to-density-texture.js +27 -52
- package/programs/float2legendwithratio/index.js +1 -1
- package/programs/float2legendwithratio/logic.js +42 -88
- package/programs/float2legendwithratio/object.js +46 -43
- package/programs/globe-util/is-globe-moved.js +11 -10
- package/programs/globeshell/index.js +1 -1
- package/programs/globeshell/wiggle/index.js +1 -1
- package/programs/globeshell/wiggle/logic.js +98 -191
- package/programs/globeshell/wiggle/object.js +35 -33
- package/programs/helpers/blender/program.js +19 -36
- package/programs/helpers/fadeaway/index.js +1 -1
- package/programs/helpers/fadeaway/logic.js +13 -35
- package/programs/helpers/fadeaway/object.js +10 -9
- package/programs/helpers/index.js +1 -1
- package/programs/index.js +8 -8
- package/programs/line-on-globe/angled-line.js +32 -91
- package/programs/line-on-globe/circle-accurate-3d.js +32 -82
- package/programs/line-on-globe/circle-accurate-flat.js +50 -108
- package/programs/line-on-globe/circle-accurate.js +33 -103
- package/programs/line-on-globe/circle.js +32 -97
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +33 -83
- package/programs/line-on-globe/lines-color-instanced-flat.js +34 -79
- package/programs/line-on-globe/linestrip.js +39 -100
- package/programs/line-on-globe/naive-accurate-flexible.js +48 -118
- package/programs/line-on-globe/to-the-surface.js +29 -58
- package/programs/line-on-globe/util.js +1 -1
- package/programs/picking/pickable-renderer.js +33 -117
- package/programs/point-on-globe/element-globe-surface-glow.js +38 -78
- package/programs/point-on-globe/element-point-glow.js +35 -103
- package/programs/point-on-globe/square-pixel-point.js +27 -76
- package/programs/programcache.js +13 -13
- package/programs/rings/distancering/circleflatprogram.js +21 -63
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +145 -156
- package/programs/rings/distancering/circlepaddysharedbuffer.js +197 -121
- package/programs/rings/distancering/index.js +4 -4
- package/programs/rings/distancering/paddyflatprogram.js +20 -73
- package/programs/rings/distancering/paddyflatprogram2d.js +22 -75
- package/programs/rings/distancering/paddyflatprogram3d.js +20 -73
- package/programs/rings/partial-ring/piece-of-pie.js +35 -137
- package/programs/totems/camerauniformblock.js +51 -64
- package/programs/totems/canvas-webglobe-info.js +40 -48
- package/programs/totems/gpu-selection-uniform-block.js +40 -44
- package/programs/totems/index.js +1 -1
- package/programs/two-d/pixel-padding-for-compass.js +29 -90
- package/programs/util.js +7 -6
- package/programs/vectorfields/index.js +1 -1
- package/programs/vectorfields/logics/drawrectangleparticles.js +29 -70
- package/programs/vectorfields/logics/index.js +3 -3
- package/programs/vectorfields/logics/pixelbased.js +35 -91
- package/programs/vectorfields/logics/ubo.js +25 -31
- package/programs/vectorfields/pingpongbuffermanager.js +34 -30
- package/rangerings/index.js +4 -4
- package/rangerings/plugin.js +252 -202
- package/rangerings/rangeringangletext.js +120 -108
- package/rangerings/ring-account.js +69 -52
- package/shaders/fragment-toy/firework.js +1 -55
- package/shaders/fragment-toy/singularity.js +1 -55
- package/timetracks/adaptors-line-strip.js +37 -26
- package/timetracks/adaptors.js +61 -47
- package/timetracks/index.js +4 -4
- package/timetracks/plugin-line-strip.js +63 -59
- package/timetracks/plugin.js +69 -65
- package/timetracks/program-line-strip.js +103 -296
- package/timetracks/program.js +113 -419
- package/timetracks/programpoint-line-strip.js +44 -97
- package/timetracks/programpoint.js +44 -90
- package/util/account/bufferoffsetmanager.js +95 -72
- package/util/account/index.js +1 -1
- package/util/account/single-attribute-buffer-management/buffer-manager.js +43 -39
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +94 -64
- package/util/account/single-attribute-buffer-management/index.js +3 -3
- package/util/account/single-attribute-buffer-management/object-store.js +30 -28
- package/util/account/util.js +4 -2
- package/util/algorithms/search-binary.js +4 -4
- package/util/check/get.js +5 -5
- package/util/check/typecheck.js +15 -13
- package/util/geometry/index.js +11 -9
- package/util/gl-util/buffer/attribute-loader.js +20 -8
- package/util/gl-util/buffer/index.js +1 -1
- package/util/gl-util/draw-options/methods.js +7 -7
- package/util/gl-util/uniform-block/manager.js +67 -55
- package/util/heatwavedatamanager/datamanager.js +116 -56
- package/util/heatwavedatamanager/index.js +2 -2
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +40 -37
- package/util/heatwavedatamanager/pointcoordsmeta.js +10 -9
- package/util/index.js +6 -6
- package/util/interpolation/timetrack/index.js +1 -1
- package/util/interpolation/timetrack/timetrack-interpolator.js +29 -27
- package/util/interpolation/timetrack/web-worker-str.js +1 -179
- 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 +52 -46
- package/util/programs/draw-texture-on-canvas.js +21 -39
- package/util/programs/shapesonglobe.js +64 -104
- package/util/programs/supersampletotextures.js +39 -45
- package/util/programs/texturetoglobe.js +48 -98
- package/util/shaderfunctions/geometrytransformations.js +27 -322
- package/util/shaderfunctions/nodata.js +1 -7
- package/util/shaderfunctions/noisefunctions.js +9 -39
- package/util/surface-line-data/arcs-to-cuts.js +23 -20
- package/util/webglobe/rasteroverlay.js +37 -35
- package/util/webglobjectbuilders.js +60 -55
- package/util/webglobjectbuilders1.js +49 -48
- package/waveparticles/adaptor.js +7 -6
- package/waveparticles/index.js +2 -2
- package/waveparticles/plugin.js +84 -79
- package/wind/imagetovectorfieldandmagnitude.js +15 -15
- package/wind/index.js +4 -4
- package/wind/plugin.js +251 -453
- package/wind/vectorfieldimage.js +5 -5
- package/write-text/attached-text-writer.js +48 -46
- package/write-text/context-text.js +58 -51
- package/write-text/context-text3.js +74 -69
|
@@ -1,4 +1,13 @@
|
|
|
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.createBufferAndReadInfo = exports.attributeLoader = void 0;
|
|
4
13
|
require("./types");
|
|
@@ -22,7 +31,8 @@ require("./types");
|
|
|
22
31
|
* @param {Array<number>} options.escapeValues
|
|
23
32
|
* @returns
|
|
24
33
|
*/
|
|
25
|
-
|
|
34
|
+
var attributeLoader = function (gl, bufferAndReadInfo, index, size, _a) {
|
|
35
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.divisor, divisor = _c === void 0 ? null : _c, _d = _b.type, type = _d === void 0 ? null : _d, _e = _b.escapeValues, escapeValues = _e === void 0 ? null : _e, _f = _b.normalized, normalized = _f === void 0 ? false : _f;
|
|
26
36
|
if (size < 1 || size > 4)
|
|
27
37
|
throw new Error("Size must be between 1 and 4");
|
|
28
38
|
if (bufferAndReadInfo == null) {
|
|
@@ -30,7 +40,7 @@ const attributeLoader = (gl, bufferAndReadInfo, index, size, { divisor = null, t
|
|
|
30
40
|
constantFunction(gl, index, size, escapeValues);
|
|
31
41
|
return;
|
|
32
42
|
}
|
|
33
|
-
|
|
43
|
+
var buffer = bufferAndReadInfo.buffer, stride = bufferAndReadInfo.stride, offset = bufferAndReadInfo.offset;
|
|
34
44
|
if (!gl || !buffer) {
|
|
35
45
|
throw new Error("Invalid WebGL context or buffer");
|
|
36
46
|
}
|
|
@@ -40,7 +50,7 @@ const attributeLoader = (gl, bufferAndReadInfo, index, size, { divisor = null, t
|
|
|
40
50
|
if (stride < 0 || offset < 0) {
|
|
41
51
|
throw new Error("Stride and offset must be non-negative");
|
|
42
52
|
}
|
|
43
|
-
|
|
53
|
+
var attribType = type === null ? gl.FLOAT : type;
|
|
44
54
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
45
55
|
gl.enableVertexAttribArray(index);
|
|
46
56
|
gl.vertexAttribPointer(index, size, attribType, normalized, stride, offset);
|
|
@@ -56,14 +66,16 @@ exports.attributeLoader = attributeLoader;
|
|
|
56
66
|
* @param {number} offset
|
|
57
67
|
* @returns {BufferAndReadInfo}
|
|
58
68
|
*/
|
|
59
|
-
|
|
69
|
+
var createBufferAndReadInfo = function (buffer, stride, offset) {
|
|
70
|
+
if (stride === void 0) { stride = 0; }
|
|
71
|
+
if (offset === void 0) { offset = 0; }
|
|
60
72
|
if (buffer == null)
|
|
61
73
|
return null;
|
|
62
|
-
return { buffer, stride, offset };
|
|
74
|
+
return { buffer: buffer, stride: stride, offset: offset };
|
|
63
75
|
};
|
|
64
76
|
exports.createBufferAndReadInfo = createBufferAndReadInfo;
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
var constantFunction = function (gl, index, size, escapeValues) {
|
|
78
|
+
var func = "vertexAttrib".concat(size, "f");
|
|
67
79
|
// @ts-ignore
|
|
68
|
-
gl[func](index,
|
|
80
|
+
gl[func].apply(gl, __spreadArray([index], escapeValues, false));
|
|
69
81
|
};
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
// import './types';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.attributeLoader = void 0;
|
|
5
|
-
|
|
5
|
+
var attribute_loader_1 = require("./attribute-loader");
|
|
6
6
|
Object.defineProperty(exports, "attributeLoader", { enumerable: true, get: function () { return attribute_loader_1.attributeLoader; } });
|
|
@@ -5,10 +5,10 @@ require("./types");
|
|
|
5
5
|
/**
|
|
6
6
|
* Draws instanced geometry using WebGL2.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
var drawInstanced = function (gl, mode, drawOptions, vertexCount) {
|
|
9
9
|
var _a;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var drawRange = drawOptions.drawRange, _b = drawOptions.elementBufferIndexType, elementBufferIndexType = _b === void 0 ? gl.UNSIGNED_INT : _b;
|
|
11
|
+
var _c = drawRange.first, first = _c === void 0 ? 0 : _c, _d = drawRange.count, instanceCount = _d === void 0 ? 1 : _d;
|
|
12
12
|
if (first > 0 || drawOptions.elementBuffer) {
|
|
13
13
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, (_a = drawOptions.elementBuffer) !== null && _a !== void 0 ? _a : null);
|
|
14
14
|
gl.drawElementsInstanced(mode, vertexCount, elementBufferIndexType, first, instanceCount);
|
|
@@ -22,10 +22,10 @@ exports.drawInstanced = drawInstanced;
|
|
|
22
22
|
/**
|
|
23
23
|
* Draws geometry using WebGL2.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
var drawArrays = function (gl, defaultMode, drawOptions) {
|
|
26
|
+
var drawRange = drawOptions.drawRange, elementBuffer = drawOptions.elementBuffer, _a = drawOptions.elementBufferIndexType, elementBufferIndexType = _a === void 0 ? gl.UNSIGNED_INT : _a, _b = drawOptions.drawMode, drawMode = _b === void 0 ? null : _b;
|
|
27
|
+
var _c = drawRange.first, first = _c === void 0 ? 0 : _c, count = drawRange.count;
|
|
28
|
+
var mode = drawMode !== null && drawMode !== void 0 ? drawMode : defaultMode;
|
|
29
29
|
if (elementBuffer) {
|
|
30
30
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer);
|
|
31
31
|
gl.drawElements(mode, count, elementBufferIndexType, first);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UniformBlockManager = void 0;
|
|
4
4
|
require("./types");
|
|
5
|
-
|
|
5
|
+
var typeSizes = {
|
|
6
6
|
'float': 4,
|
|
7
7
|
'vec2': 8,
|
|
8
8
|
'vec3': 16, // vec3 takes up same space as vec4 due to alignment
|
|
@@ -16,7 +16,7 @@ const typeSizes = {
|
|
|
16
16
|
'ivec4': 16,
|
|
17
17
|
'bool': 4
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
var typeAlignments = {
|
|
20
20
|
'float': 4,
|
|
21
21
|
'vec2': 8,
|
|
22
22
|
'vec3': 16,
|
|
@@ -30,7 +30,7 @@ const typeAlignments = {
|
|
|
30
30
|
'ivec4': 16,
|
|
31
31
|
'bool': 4
|
|
32
32
|
};
|
|
33
|
-
|
|
33
|
+
var typeArrayConstructors = {
|
|
34
34
|
'float': Float32Array,
|
|
35
35
|
'vec2': Float32Array,
|
|
36
36
|
'vec3': Float32Array,
|
|
@@ -44,8 +44,9 @@ const typeArrayConstructors = {
|
|
|
44
44
|
'ivec4': Int32Array,
|
|
45
45
|
'bool': Float32Array
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
var UniformBlockManager = /** @class */ (function () {
|
|
48
|
+
function UniformBlockManager(blockName, blockMembers, bindingPoint, prefix) {
|
|
49
|
+
if (prefix === void 0) { prefix = ""; }
|
|
49
50
|
this.blockName = blockName;
|
|
50
51
|
this.blockMembers = blockMembers;
|
|
51
52
|
this.bindingPoint = bindingPoint;
|
|
@@ -53,52 +54,56 @@ class UniformBlockManager {
|
|
|
53
54
|
this.offsetMap = this.__create_LayoutSTD140_OffsetMap();
|
|
54
55
|
this.size = this.__calculateSize();
|
|
55
56
|
}
|
|
56
|
-
glslCode() {
|
|
57
|
-
|
|
58
|
-
for (
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
UniformBlockManager.prototype.glslCode = function () {
|
|
58
|
+
var code = "layout(std140) uniform ".concat(this.blockName, " {");
|
|
59
|
+
for (var _i = 0, _a = this.blockMembers; _i < _a.length; _i++) {
|
|
60
|
+
var member = _a[_i];
|
|
61
|
+
var name_1 = member.name, type = member.type;
|
|
62
|
+
code += "".concat(type, " ").concat(this.prefix).concat(name_1, ";");
|
|
61
63
|
}
|
|
62
64
|
if (this.prefix) {
|
|
63
|
-
code +=
|
|
65
|
+
code += "} ".concat(this.prefix, ";");
|
|
64
66
|
}
|
|
65
67
|
else {
|
|
66
|
-
code +=
|
|
68
|
+
code += "};";
|
|
67
69
|
}
|
|
68
70
|
return code;
|
|
69
|
-
}
|
|
70
|
-
createUBO(gl, bufferWriteType
|
|
71
|
-
|
|
71
|
+
};
|
|
72
|
+
UniformBlockManager.prototype.createUBO = function (gl, bufferWriteType) {
|
|
73
|
+
var _this = this;
|
|
74
|
+
if (bufferWriteType === void 0) { bufferWriteType = "STATIC_DRAW"; }
|
|
75
|
+
var ubo = gl.createBuffer();
|
|
72
76
|
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
73
77
|
// @ts-ignore
|
|
74
78
|
gl.bufferData(gl.UNIFORM_BUFFER, this.size, gl[bufferWriteType]);
|
|
75
79
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, ubo);
|
|
76
|
-
for (
|
|
77
|
-
|
|
80
|
+
for (var _i = 0, _a = this.blockMembers; _i < _a.length; _i++) {
|
|
81
|
+
var member = _a[_i];
|
|
82
|
+
var name_2 = member.name, type = member.type, _b = member.value, value = _b === void 0 ? null : _b;
|
|
78
83
|
;
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
var offset = this.offsetMap.get(name_2);
|
|
85
|
+
var data = (value === null) ? new typeArrayConstructors[type](typeSizes[type] / 4).fill(NaN) : value;
|
|
81
86
|
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
|
|
82
87
|
}
|
|
83
88
|
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
84
89
|
return {
|
|
85
|
-
ubo,
|
|
86
|
-
update: (nameValueMap)
|
|
87
|
-
bind: ()
|
|
88
|
-
unbind: ()
|
|
89
|
-
free: ()
|
|
90
|
+
ubo: ubo,
|
|
91
|
+
update: function (nameValueMap) { return _this.updateUBO(gl, ubo, nameValueMap); },
|
|
92
|
+
bind: function () { return _this.bind(gl, ubo); },
|
|
93
|
+
unbind: function () { return _this.unbind(gl); },
|
|
94
|
+
free: function () { return gl.deleteBuffer(ubo); },
|
|
90
95
|
};
|
|
91
|
-
}
|
|
92
|
-
updateUBO(gl, ubo, nameValueMap) {
|
|
96
|
+
};
|
|
97
|
+
UniformBlockManager.prototype.updateUBO = function (gl, ubo, nameValueMap) {
|
|
93
98
|
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
var _loop_1 = function (name_3, value) {
|
|
100
|
+
var offset = this_1.offsetMap.get(name_3);
|
|
96
101
|
if (offset === undefined) {
|
|
97
|
-
throw new Error(
|
|
102
|
+
throw new Error("Uniform block member ".concat(name_3, " not found in offset map."));
|
|
98
103
|
}
|
|
99
104
|
// @ts-ignore
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
var type = this_1.blockMembers.find(function (member) { return member.name === name_3; }).type;
|
|
106
|
+
var data = void 0;
|
|
102
107
|
if (Array.isArray(value)) {
|
|
103
108
|
data = new typeArrayConstructors[type](value);
|
|
104
109
|
}
|
|
@@ -111,46 +116,53 @@ class UniformBlockManager {
|
|
|
111
116
|
else if (ArrayBuffer.isView(value) && !(value instanceof DataView))
|
|
112
117
|
data = (typeof value === 'number') ? new typeArrayConstructors[type]([value]) : new typeArrayConstructors[type](value);
|
|
113
118
|
else {
|
|
114
|
-
throw new Error(
|
|
119
|
+
throw new Error("Unsupported value type for ".concat(name_3, ": ").concat(typeof value));
|
|
115
120
|
}
|
|
116
121
|
console.log("Data to be uploaded:", data);
|
|
117
122
|
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
|
|
123
|
+
};
|
|
124
|
+
var this_1 = this;
|
|
125
|
+
for (var _i = 0, _a = nameValueMap.entries(); _i < _a.length; _i++) {
|
|
126
|
+
var _b = _a[_i], name_3 = _b[0], value = _b[1];
|
|
127
|
+
_loop_1(name_3, value);
|
|
118
128
|
}
|
|
119
129
|
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
120
|
-
}
|
|
130
|
+
};
|
|
121
131
|
// call this after linking the program
|
|
122
|
-
assignBindingPoint(gl, program) {
|
|
123
|
-
|
|
132
|
+
UniformBlockManager.prototype.assignBindingPoint = function (gl, program) {
|
|
133
|
+
var blockIndex = gl.getUniformBlockIndex(program, this.blockName);
|
|
124
134
|
gl.uniformBlockBinding(program, blockIndex, this.bindingPoint);
|
|
125
|
-
}
|
|
135
|
+
};
|
|
126
136
|
// call this before drawing
|
|
127
|
-
bind(gl, ubo) {
|
|
137
|
+
UniformBlockManager.prototype.bind = function (gl, ubo) {
|
|
128
138
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, ubo);
|
|
129
|
-
}
|
|
139
|
+
};
|
|
130
140
|
// call this right after drawing
|
|
131
|
-
unbind(gl) {
|
|
141
|
+
UniformBlockManager.prototype.unbind = function (gl) {
|
|
132
142
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, null);
|
|
133
|
-
}
|
|
143
|
+
};
|
|
134
144
|
// implicit methods
|
|
135
|
-
__create_LayoutSTD140_OffsetMap() {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
for (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
145
|
+
UniformBlockManager.prototype.__create_LayoutSTD140_OffsetMap = function () {
|
|
146
|
+
var offset = 0;
|
|
147
|
+
var offsetMap = new Map();
|
|
148
|
+
for (var _i = 0, _a = this.blockMembers; _i < _a.length; _i++) {
|
|
149
|
+
var member = _a[_i];
|
|
150
|
+
var name_4 = member.name, type = member.type;
|
|
151
|
+
var size = typeSizes[type];
|
|
152
|
+
var alignment = typeAlignments[type];
|
|
153
|
+
var padding = (alignment - (offset % alignment)) % alignment;
|
|
143
154
|
offset += padding;
|
|
144
|
-
offsetMap.set(
|
|
155
|
+
offsetMap.set(name_4, offset);
|
|
145
156
|
offset += size;
|
|
146
157
|
}
|
|
147
158
|
return offsetMap;
|
|
148
|
-
}
|
|
159
|
+
};
|
|
149
160
|
// __create_LayoutSTD140_OffsetMap() should be called before this
|
|
150
|
-
__calculateSize() {
|
|
151
|
-
|
|
152
|
-
|
|
161
|
+
UniformBlockManager.prototype.__calculateSize = function () {
|
|
162
|
+
var lastOffset = Array.from(this.offsetMap.values()).pop() || 0;
|
|
163
|
+
var lastItemAlignment = typeAlignments[this.blockMembers[this.blockMembers.length - 1].type];
|
|
153
164
|
return lastOffset + lastItemAlignment;
|
|
154
|
-
}
|
|
155
|
-
|
|
165
|
+
};
|
|
166
|
+
return UniformBlockManager;
|
|
167
|
+
}());
|
|
156
168
|
exports.UniformBlockManager = UniformBlockManager;
|
|
@@ -3,16 +3,62 @@
|
|
|
3
3
|
* todo:
|
|
4
4
|
* data must be processed before being set to the cache
|
|
5
5
|
*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
17
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
|
+
function step(op) {
|
|
20
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
21
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
22
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
23
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
24
|
+
switch (op[0]) {
|
|
25
|
+
case 0: case 1: t = op; break;
|
|
26
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
27
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
28
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
29
|
+
default:
|
|
30
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
31
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
32
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
33
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
34
|
+
if (t[2]) _.ops.pop();
|
|
35
|
+
_.trys.pop(); continue;
|
|
36
|
+
}
|
|
37
|
+
op = body.call(thisArg, _);
|
|
38
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
39
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
43
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
44
|
+
if (ar || !(i in from)) {
|
|
45
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
46
|
+
ar[i] = from[i];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
50
|
+
};
|
|
6
51
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
52
|
+
var DataManager = /** @class */ (function () {
|
|
8
53
|
/**
|
|
9
54
|
*
|
|
10
55
|
* @param {Array<number>} timeEpocs | array of time epocs
|
|
11
56
|
* @param {Function} fetchMethod | fetchMethod(time) => Promise<data>
|
|
12
57
|
* @param {boolean} autoDownload | auto download data or not
|
|
13
58
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
59
|
+
function DataManager(timeEpocs, fetchMethod, _a) {
|
|
60
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.autoDownload, autoDownload = _c === void 0 ? true : _c;
|
|
61
|
+
this._timeEpocs = timeEpocs.sort(function (a, b) { return a - b; });
|
|
16
62
|
this._datas = [];
|
|
17
63
|
this._datas.length = timeEpocs.length;
|
|
18
64
|
// in construction
|
|
@@ -25,12 +71,13 @@ class DataManager {
|
|
|
25
71
|
this._lastIndex = -1;
|
|
26
72
|
this.autoDownload(autoDownload);
|
|
27
73
|
}
|
|
28
|
-
autoDownload(bool, time) {
|
|
74
|
+
DataManager.prototype.autoDownload = function (bool, time) {
|
|
75
|
+
var _this = this;
|
|
29
76
|
if (!bool) {
|
|
30
77
|
this._autoDownload = false;
|
|
31
78
|
return;
|
|
32
79
|
}
|
|
33
|
-
|
|
80
|
+
var index = this._lastIndex === -1 ? 0 : this._lastIndex;
|
|
34
81
|
if (time !== undefined) {
|
|
35
82
|
if (time < this._timeEpocs[0] || time > this._timeEpocs[this._timeEpocs.length - 1]) {
|
|
36
83
|
this._autoDownload = bool;
|
|
@@ -42,11 +89,11 @@ class DataManager {
|
|
|
42
89
|
return;
|
|
43
90
|
this._downloadStartIndex = index;
|
|
44
91
|
this._autoDownload = bool;
|
|
45
|
-
|
|
46
|
-
if (startId !==
|
|
92
|
+
var recursion = function (startId, currentDownloadId) {
|
|
93
|
+
if (startId !== _this._downloadStartIndex)
|
|
47
94
|
return;
|
|
48
|
-
if (currentDownloadId <
|
|
49
|
-
|
|
95
|
+
if (currentDownloadId < _this._timeEpocs.length && _this._autoDownload) {
|
|
96
|
+
_this._getData(currentDownloadId).then(function () {
|
|
50
97
|
recursion(startId, currentDownloadId + 1);
|
|
51
98
|
});
|
|
52
99
|
}
|
|
@@ -55,28 +102,29 @@ class DataManager {
|
|
|
55
102
|
// save index as start index
|
|
56
103
|
//start recursive download
|
|
57
104
|
// use started id as a flag to stop the download
|
|
58
|
-
}
|
|
105
|
+
};
|
|
59
106
|
/**
|
|
60
107
|
* @param {number} time
|
|
61
108
|
* It looks like async function is not needed here. changes just overwrites the previous changes.
|
|
62
109
|
*/
|
|
63
|
-
updateTime(time) {
|
|
110
|
+
DataManager.prototype.updateTime = function (time) {
|
|
111
|
+
var _this = this;
|
|
64
112
|
if (time < this._timeEpocs[0] || time > this._timeEpocs[this._timeEpocs.length - 1]) {
|
|
65
113
|
this._dontRender();
|
|
66
114
|
return;
|
|
67
115
|
}
|
|
68
116
|
this._lastTime = time;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
Promise.all([this._getData(index - 1), this._getData(index)]).then((datas)
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
117
|
+
var index = this._findIndex(time);
|
|
118
|
+
var ratio = this._getRatio(time, index);
|
|
119
|
+
Promise.all([this._getData(index - 1), this._getData(index)]).then(function (datas) {
|
|
120
|
+
if (_this._lastTime === time) {
|
|
121
|
+
_this._lastIndex = index;
|
|
122
|
+
_this._ratio = ratio;
|
|
123
|
+
_this._pushCallback(ratio, datas);
|
|
76
124
|
}
|
|
77
125
|
});
|
|
78
|
-
}
|
|
79
|
-
register(key, callback) {
|
|
126
|
+
};
|
|
127
|
+
DataManager.prototype.register = function (key, callback) {
|
|
80
128
|
if (this._callbackmethodOwners.indexOf(key) !== -1) {
|
|
81
129
|
console.warn("key already registered, old one is unregistered");
|
|
82
130
|
this.unregister(key);
|
|
@@ -85,12 +133,12 @@ class DataManager {
|
|
|
85
133
|
this._callbackmethodOwners.push(key);
|
|
86
134
|
if (this._lastIndex !== -1)
|
|
87
135
|
callback(this._ratio, this._datas[this._lastIndex - 1], this._datas[this._lastIndex]);
|
|
88
|
-
}
|
|
136
|
+
};
|
|
89
137
|
/**
|
|
90
138
|
* @param {*} key | id of the owner of the callback
|
|
91
139
|
*/
|
|
92
|
-
unregister(key) {
|
|
93
|
-
|
|
140
|
+
DataManager.prototype.unregister = function (key) {
|
|
141
|
+
var index = this._callbackmethodOwners.indexOf(key);
|
|
94
142
|
if (index !== -1) {
|
|
95
143
|
this._callbackmethods.splice(index, 1);
|
|
96
144
|
this._callbackmethodOwners.splice(index, 1);
|
|
@@ -98,15 +146,15 @@ class DataManager {
|
|
|
98
146
|
if (this._callbackmethods.length === 0) {
|
|
99
147
|
this.free();
|
|
100
148
|
}
|
|
101
|
-
}
|
|
102
|
-
free() {
|
|
149
|
+
};
|
|
150
|
+
DataManager.prototype.free = function () {
|
|
103
151
|
this._callbackmethods = [];
|
|
104
152
|
this._callbackmethodOwners = [];
|
|
105
153
|
this._autoDownload = false;
|
|
106
|
-
}
|
|
107
|
-
_findIndex(time) {
|
|
108
|
-
|
|
109
|
-
|
|
154
|
+
};
|
|
155
|
+
DataManager.prototype._findIndex = function (time) {
|
|
156
|
+
var _timeEpocs = this._timeEpocs;
|
|
157
|
+
var index = this._lastIndex === -1 ? 1 : this._lastIndex;
|
|
110
158
|
if (this)
|
|
111
159
|
if (time < _timeEpocs[index - 1]) {
|
|
112
160
|
while (index > 1 && time < _timeEpocs[index - 1]) {
|
|
@@ -119,34 +167,46 @@ class DataManager {
|
|
|
119
167
|
}
|
|
120
168
|
}
|
|
121
169
|
return index;
|
|
122
|
-
}
|
|
123
|
-
_getRatio(time, index) {
|
|
170
|
+
};
|
|
171
|
+
DataManager.prototype._getRatio = function (time, index) {
|
|
124
172
|
return (time - this._timeEpocs[index - 1]) / (this._timeEpocs[index] - this._timeEpocs[index - 1]);
|
|
125
|
-
}
|
|
126
|
-
_pushCallback(ratio, datas) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
async _getData(index) {
|
|
132
|
-
if (index < 0 || index >= this._timeEpocs.length) {
|
|
133
|
-
throw new Error("Index out of range");
|
|
134
|
-
}
|
|
135
|
-
if (!this._datas[index]) {
|
|
136
|
-
if (!this._dataPromises[index])
|
|
137
|
-
this._dataPromises[index] = this._fetchMethod(this._timeEpocs[index]).then((data) => {
|
|
138
|
-
this._datas[index] = data;
|
|
139
|
-
}, (error) => {
|
|
140
|
-
console.error("error", error);
|
|
141
|
-
}).finally(() => {
|
|
142
|
-
this._dataPromises[index] = null;
|
|
143
|
-
});
|
|
173
|
+
};
|
|
174
|
+
DataManager.prototype._pushCallback = function (ratio, datas) {
|
|
175
|
+
var _a;
|
|
176
|
+
for (var i = 0; i < this._callbackmethods.length; i++) {
|
|
177
|
+
(_a = this._callbackmethods)[i].apply(_a, __spreadArray([ratio], datas, false));
|
|
144
178
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
179
|
+
};
|
|
180
|
+
DataManager.prototype._getData = function (index) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
+
var _this = this;
|
|
183
|
+
return __generator(this, function (_a) {
|
|
184
|
+
switch (_a.label) {
|
|
185
|
+
case 0:
|
|
186
|
+
if (index < 0 || index >= this._timeEpocs.length) {
|
|
187
|
+
throw new Error("Index out of range");
|
|
188
|
+
}
|
|
189
|
+
if (!this._datas[index]) {
|
|
190
|
+
if (!this._dataPromises[index])
|
|
191
|
+
this._dataPromises[index] = this._fetchMethod(this._timeEpocs[index]).then(function (data) {
|
|
192
|
+
_this._datas[index] = data;
|
|
193
|
+
}, function (error) {
|
|
194
|
+
console.error("error", error);
|
|
195
|
+
}).finally(function () {
|
|
196
|
+
_this._dataPromises[index] = null;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return [4 /*yield*/, this._dataPromises[index]];
|
|
200
|
+
case 1:
|
|
201
|
+
_a.sent();
|
|
202
|
+
return [2 /*return*/, this._datas[index]];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
DataManager.prototype._dontRender = function () {
|
|
149
208
|
this._pushCallback(0, [null, null]);
|
|
150
|
-
}
|
|
151
|
-
|
|
209
|
+
};
|
|
210
|
+
return DataManager;
|
|
211
|
+
}());
|
|
152
212
|
exports.default = DataManager;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PointCoordinatesDataCalculator = exports.HeatWaveDataManager = void 0;
|
|
7
|
-
|
|
7
|
+
var pointcoordinatesdatacalculator_1 = __importDefault(require("./pointcoordinatesdatacalculator"));
|
|
8
8
|
exports.PointCoordinatesDataCalculator = pointcoordinatesdatacalculator_1.default;
|
|
9
|
-
|
|
9
|
+
var datamanager_1 = __importDefault(require("./datamanager"));
|
|
10
10
|
exports.HeatWaveDataManager = datamanager_1.default;
|