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