@pirireis/webglobeplugins 0.9.8 → 0.9.9
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/index.js +58 -15
- package/package.json +1 -1
- package/dist/Math/angle-calculation.js +0 -15
- package/dist/Math/arc.js +0 -65
- package/dist/Math/bounds/line-bbox.js +0 -188
- package/dist/Math/constants.js +0 -9
- package/dist/Math/frustum/camera.js +0 -24
- package/dist/Math/frustum/from-globeinfo.js +0 -48
- package/dist/Math/frustum/types.js +0 -2
- package/dist/Math/globe-util/horizon-plane.js +0 -112
- package/dist/Math/index.js +0 -1
- package/dist/Math/juction/arc-plane.js +0 -83
- package/dist/Math/juction/line-sphere.js +0 -25
- package/dist/Math/juction/plane-plane.js +0 -58
- package/dist/Math/line.js +0 -56
- package/dist/Math/matrix4.js +0 -1
- package/dist/Math/methods.js +0 -201
- package/dist/Math/plane.js +0 -60
- package/dist/Math/quaternion.js +0 -104
- package/dist/Math/types.js +0 -2
- package/dist/Math/utils.js +0 -4
- package/dist/Math/vec3.js +0 -126
- package/dist/algorithms/search-binary.js +0 -19
- package/dist/altitude-locator/adaptors.js +0 -1
- package/dist/altitude-locator/draw-subset-obj.js +0 -18
- package/dist/altitude-locator/keymethod.js +0 -1
- package/dist/altitude-locator/plugin.js +0 -341
- package/dist/altitude-locator/types.js +0 -23
- package/dist/arrowfield/adaptor.js +0 -14
- package/dist/arrowfield/index.js +0 -10
- package/dist/arrowfield/plugin.js +0 -86
- package/dist/bearing-line/index.js +0 -8
- package/dist/bearing-line/plugin.js +0 -449
- package/dist/circle-line-chain/chain-list-map.js +0 -205
- package/dist/circle-line-chain/init.js +0 -1
- package/dist/circle-line-chain/plugin.js +0 -424
- package/dist/circle-line-chain/util.js +0 -5
- package/dist/compass-rose/compass-rose-padding-flat.js +0 -225
- package/dist/compass-rose/compass-text-writer.js +0 -153
- package/dist/compass-rose/index.js +0 -7
- package/dist/compassrose/compassrose.js +0 -296
- package/dist/compassrose/index.js +0 -8
- package/dist/globe-types.js +0 -1
- package/dist/heatwave/index.js +0 -10
- package/dist/heatwave/isobar/objectarraylabels.js +0 -202
- package/dist/heatwave/isobar/plugin.js +0 -343
- package/dist/heatwave/isobar/quadtreecontours.js +0 -300
- package/dist/heatwave/plugins/heatwaveglobeshell.js +0 -206
- package/dist/index.js +0 -58
- package/dist/jest.config.js +0 -7
- package/dist/partialrings/buffer-manager.js +0 -81
- package/dist/partialrings/index.js +0 -41
- package/dist/partialrings/plugin.js +0 -135
- package/dist/partialrings/program.js +0 -286
- package/dist/pin/pin-object-array.js +0 -305
- package/dist/pin/pin-point-totem.js +0 -60
- package/dist/point-heat-map/adaptors/timetracksplugin-format-to-this.js +0 -66
- package/dist/point-heat-map/index.js +0 -1
- package/dist/point-heat-map/plugin-webworker.js +0 -126
- package/dist/point-heat-map/point-to-heat-map-flow.js +0 -127
- package/dist/point-tracks/key-methods.js +0 -5
- package/dist/point-tracks/plugin.js +0 -338
- package/dist/programs/arrowfield/index.js +0 -7
- package/dist/programs/arrowfield/logic.js +0 -257
- package/dist/programs/arrowfield/object.js +0 -66
- package/dist/programs/data2legend/density-to-legend.js +0 -101
- package/dist/programs/data2legend/point-to-density-texture.js +0 -100
- package/dist/programs/float2legendwithratio/index.js +0 -8
- package/dist/programs/float2legendwithratio/logic.js +0 -171
- package/dist/programs/float2legendwithratio/object.js +0 -110
- package/dist/programs/globe-util/is-globe-moved.js +0 -21
- package/dist/programs/globeshell/index.js +0 -8
- package/dist/programs/globeshell/noise/noises.js +0 -1
- package/dist/programs/globeshell/wiggle/index.js +0 -8
- package/dist/programs/globeshell/wiggle/logic.js +0 -345
- package/dist/programs/globeshell/wiggle/object.js +0 -72
- package/dist/programs/helpers/blender/index.js +0 -1
- package/dist/programs/helpers/blender/program.js +0 -79
- package/dist/programs/helpers/fadeaway/index.js +0 -7
- package/dist/programs/helpers/fadeaway/logic.js +0 -72
- package/dist/programs/helpers/fadeaway/object.js +0 -20
- package/dist/programs/helpers/index.js +0 -8
- package/dist/programs/index.js +0 -58
- package/dist/programs/interface.js +0 -1
- package/dist/programs/line-on-globe/angled-line.js +0 -176
- package/dist/programs/line-on-globe/circle-accurate-3d.js +0 -141
- package/dist/programs/line-on-globe/circle-accurate-flat.js +0 -216
- package/dist/programs/line-on-globe/circle-accurate.js +0 -178
- package/dist/programs/line-on-globe/circle.js +0 -167
- package/dist/programs/line-on-globe/degree-padding-around-circle-3d.js +0 -159
- package/dist/programs/line-on-globe/index.js +0 -1
- package/dist/programs/line-on-globe/lines-color-instanced-flat.js +0 -136
- package/dist/programs/line-on-globe/linestrip.js +0 -171
- package/dist/programs/line-on-globe/naive-accurate-flexible.js +0 -195
- package/dist/programs/line-on-globe/to-the-surface.js +0 -111
- package/dist/programs/line-on-globe/util.js +0 -8
- package/dist/programs/picking/pickable-renderer.js +0 -188
- package/dist/programs/point-on-globe/element-globe-surface-glow.js +0 -142
- package/dist/programs/point-on-globe/element-point-glow.js +0 -153
- package/dist/programs/point-on-globe/square-pixel-point.js +0 -174
- package/dist/programs/programcache.js +0 -131
- package/dist/programs/rings/distancering/circleflatprogram.js +0 -156
- package/dist/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -369
- package/dist/programs/rings/distancering/circlepaddysharedbuffer.js +0 -357
- package/dist/programs/rings/distancering/index.js +0 -14
- package/dist/programs/rings/distancering/paddyflatprogram.js +0 -172
- package/dist/programs/rings/distancering/paddyflatprogram2d.js +0 -174
- package/dist/programs/rings/distancering/paddyflatprogram3d.js +0 -172
- package/dist/programs/rings/distancering/shader.js +0 -1
- package/dist/programs/rings/index.js +0 -17
- package/dist/programs/rings/partial-ring/piece-of-pie.js +0 -275
- package/dist/programs/totems/camerauniformblock.js +0 -160
- package/dist/programs/totems/canvas-webglobe-info.js +0 -110
- package/dist/programs/totems/gpu-selection-uniform-block.js +0 -108
- package/dist/programs/totems/index.js +0 -40
- package/dist/programs/two-d/pixel-circle.js +0 -1
- package/dist/programs/two-d/pixel-padding-for-compass.js +0 -162
- package/dist/programs/util.js +0 -17
- package/dist/programs/vectorfields/index.js +0 -23
- package/dist/programs/vectorfields/logics/drawrectangleparticles.js +0 -107
- package/dist/programs/vectorfields/logics/index.js +0 -12
- package/dist/programs/vectorfields/logics/pixelbased.js +0 -142
- package/dist/programs/vectorfields/logics/ubo.js +0 -63
- package/dist/programs/vectorfields/pingpongbuffermanager.js +0 -76
- package/dist/rangerings/enum.js +0 -5
- package/dist/rangerings/index.js +0 -15
- package/dist/rangerings/plugin.js +0 -560
- package/dist/rangerings/rangeringangletext.js +0 -329
- package/dist/rangerings/ring-account.js +0 -117
- package/dist/shaders/fragment-toy/firework.js +0 -58
- package/dist/shaders/fragment-toy/singularity.js +0 -59
- package/dist/shape-on-terrain/arc/naive/plugin.js +0 -252
- package/dist/timetracks/adaptors-line-strip.js +0 -71
- package/dist/timetracks/adaptors.js +0 -122
- package/dist/timetracks/index.js +0 -19
- package/dist/timetracks/plugin-line-strip.js +0 -250
- package/dist/timetracks/plugin.js +0 -258
- package/dist/timetracks/program-line-strip.js +0 -611
- package/dist/timetracks/program.js +0 -772
- package/dist/timetracks/programpoint-line-strip.js +0 -154
- package/dist/timetracks/programpoint.js +0 -147
- package/dist/types.js +0 -15
- package/dist/util/account/bufferoffsetmanager.js +0 -179
- package/dist/util/account/index.js +0 -23
- package/dist/util/account/single-attribute-buffer-management/buffer-manager.js +0 -108
- package/dist/util/account/single-attribute-buffer-management/buffer-orchestrator.js +0 -150
- package/dist/util/account/single-attribute-buffer-management/index.js +0 -9
- package/dist/util/account/single-attribute-buffer-management/object-store.js +0 -51
- package/dist/util/account/single-attribute-buffer-management/types.js +0 -2
- package/dist/util/account/util.js +0 -22
- package/dist/util/algorithms/index.js +0 -1
- package/dist/util/algorithms/search-binary.js +0 -28
- package/dist/util/check/get.js +0 -18
- package/dist/util/check/index.js +0 -1
- package/dist/util/check/typecheck.js +0 -49
- package/dist/util/geometry/index.js +0 -51
- package/dist/util/gl-util/buffer/attribute-loader.js +0 -69
- package/dist/util/gl-util/buffer/index.js +0 -6
- package/dist/util/gl-util/buffer/types.js +0 -1
- package/dist/util/gl-util/draw-options/methods.js +0 -38
- package/dist/util/gl-util/draw-options/types.js +0 -15
- package/dist/util/gl-util/uniform-block/manager.js +0 -156
- package/dist/util/gl-util/uniform-block/shader.js +0 -1
- package/dist/util/gl-util/uniform-block/types.js +0 -8
- package/dist/util/heatwavedatamanager/datamanager.js +0 -152
- package/dist/util/heatwavedatamanager/index.js +0 -10
- package/dist/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +0 -122
- package/dist/util/heatwavedatamanager/pointcoordsmeta.js +0 -20
- package/dist/util/index.js +0 -57
- package/dist/util/interpolation/index.js +0 -1
- package/dist/util/interpolation/timetrack/index.js +0 -5
- package/dist/util/interpolation/timetrack/timetrack-interpolator.js +0 -79
- package/dist/util/interpolation/timetrack/web-worker-str.js +0 -183
- package/dist/util/interpolation/timetrack/web-worker.js +0 -48
- package/dist/util/jshelpers/data-filler.js +0 -20
- package/dist/util/jshelpers/equality.js +0 -20
- package/dist/util/jshelpers/index.js +0 -37
- package/dist/util/jshelpers/timefilters.js +0 -32
- package/dist/util/picking/fence.js +0 -46
- package/dist/util/picking/picker-displayer.js +0 -139
- package/dist/util/programs/draw-texture-on-canvas.js +0 -89
- package/dist/util/programs/index.js +0 -17
- package/dist/util/programs/shapesonglobe.js +0 -214
- package/dist/util/programs/supersampletotextures.js +0 -113
- package/dist/util/programs/texturetoglobe.js +0 -182
- package/dist/util/shaderfunctions/geometrytransformations.js +0 -340
- package/dist/util/shaderfunctions/index.js +0 -18
- package/dist/util/shaderfunctions/nodata.js +0 -11
- package/dist/util/shaderfunctions/noisefunctions.js +0 -43
- package/dist/util/surface-line-data/arc-bboxes.js +0 -25
- package/dist/util/surface-line-data/arcs-to-cuts.js +0 -50
- package/dist/util/surface-line-data/cut-arc.js +0 -1
- package/dist/util/surface-line-data/flow.js +0 -28
- package/dist/util/surface-line-data/rbush-manager.js +0 -1
- package/dist/util/surface-line-data/types.js +0 -1
- package/dist/util/surface-line-data/web-worker.js +0 -1
- package/dist/util/webglobe/gldefaultstates.js +0 -7
- package/dist/util/webglobe/index.js +0 -18
- package/dist/util/webglobe/rasteroverlay.js +0 -78
- package/dist/util/webglobjectbuilders.js +0 -388
- package/dist/util/webglobjectbuilders1.js +0 -237
- package/dist/waveparticles/adaptor.js +0 -17
- package/dist/waveparticles/index.js +0 -10
- package/dist/waveparticles/plugin.js +0 -266
- package/dist/wind/imagetovectorfieldandmagnitude.js +0 -35
- package/dist/wind/index.js +0 -14
- package/dist/wind/plugin.js +0 -926
- package/dist/wind/vectorfieldimage.js +0 -25
- package/dist/write-text/attached-text-writer.js +0 -91
- package/dist/write-text/context-text.js +0 -98
- package/dist/write-text/context-text3.js +0 -155
- package/dist/write-text/index.js +0 -5
- package/dist/write-text/writer-plugin.js +0 -8
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UniformBlockManager = void 0;
|
|
4
|
-
require("./types");
|
|
5
|
-
const typeSizes = {
|
|
6
|
-
'float': 4,
|
|
7
|
-
'vec2': 8,
|
|
8
|
-
'vec3': 16, // vec3 takes up same space as vec4 due to alignment
|
|
9
|
-
'vec4': 16,
|
|
10
|
-
'mat2': 32, // 2 vec4s (16 * 2)
|
|
11
|
-
'mat3': 48, // 3 vec4s (16 * 3)
|
|
12
|
-
'mat4': 64, // 4 vec4s (16 * 4)
|
|
13
|
-
'int': 4,
|
|
14
|
-
'ivec2': 8,
|
|
15
|
-
'ivec3': 16,
|
|
16
|
-
'ivec4': 16,
|
|
17
|
-
'bool': 4
|
|
18
|
-
};
|
|
19
|
-
const typeAlignments = {
|
|
20
|
-
'float': 4,
|
|
21
|
-
'vec2': 8,
|
|
22
|
-
'vec3': 16,
|
|
23
|
-
'vec4': 16,
|
|
24
|
-
'mat2': 16, // aligns to vec4 boundary
|
|
25
|
-
'mat3': 16, // aligns to vec4 boundary
|
|
26
|
-
'mat4': 16, // aligns to vec4 boundary
|
|
27
|
-
'int': 4,
|
|
28
|
-
'ivec2': 8,
|
|
29
|
-
'ivec3': 16,
|
|
30
|
-
'ivec4': 16,
|
|
31
|
-
'bool': 4
|
|
32
|
-
};
|
|
33
|
-
const typeArrayConstructors = {
|
|
34
|
-
'float': Float32Array,
|
|
35
|
-
'vec2': Float32Array,
|
|
36
|
-
'vec3': Float32Array,
|
|
37
|
-
'vec4': Float32Array,
|
|
38
|
-
'mat2': Float32Array,
|
|
39
|
-
'mat3': Float32Array,
|
|
40
|
-
'mat4': Float32Array,
|
|
41
|
-
'int': Int32Array,
|
|
42
|
-
'ivec2': Int32Array,
|
|
43
|
-
'ivec3': Int32Array,
|
|
44
|
-
'ivec4': Int32Array,
|
|
45
|
-
'bool': Float32Array
|
|
46
|
-
};
|
|
47
|
-
class UniformBlockManager {
|
|
48
|
-
constructor(blockName, blockMembers, bindingPoint, prefix = "") {
|
|
49
|
-
this.blockName = blockName;
|
|
50
|
-
this.blockMembers = blockMembers;
|
|
51
|
-
this.bindingPoint = bindingPoint;
|
|
52
|
-
this.prefix = prefix;
|
|
53
|
-
this.offsetMap = this.__create_LayoutSTD140_OffsetMap();
|
|
54
|
-
this.size = this.__calculateSize();
|
|
55
|
-
}
|
|
56
|
-
glslCode() {
|
|
57
|
-
let code = `layout(std140) uniform ${this.blockName} {`;
|
|
58
|
-
for (const member of this.blockMembers) {
|
|
59
|
-
const { name, type } = member;
|
|
60
|
-
code += `${type} ${this.prefix}${name};`;
|
|
61
|
-
}
|
|
62
|
-
if (this.prefix) {
|
|
63
|
-
code += `} ${this.prefix};`;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
code += `};`;
|
|
67
|
-
}
|
|
68
|
-
return code;
|
|
69
|
-
}
|
|
70
|
-
createUBO(gl, bufferWriteType = "STATIC_DRAW") {
|
|
71
|
-
const ubo = gl.createBuffer();
|
|
72
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
gl.bufferData(gl.UNIFORM_BUFFER, this.size, gl[bufferWriteType]);
|
|
75
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, ubo);
|
|
76
|
-
for (const member of this.blockMembers) {
|
|
77
|
-
const { name, type, value = null } = member;
|
|
78
|
-
;
|
|
79
|
-
const offset = this.offsetMap.get(name);
|
|
80
|
-
const data = (value === null) ? new typeArrayConstructors[type](typeSizes[type] / 4).fill(NaN) : value;
|
|
81
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
|
|
82
|
-
}
|
|
83
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
84
|
-
return {
|
|
85
|
-
ubo,
|
|
86
|
-
update: (nameValueMap) => this.updateUBO(gl, ubo, nameValueMap),
|
|
87
|
-
bind: () => this.bind(gl, ubo),
|
|
88
|
-
unbind: () => this.unbind(gl),
|
|
89
|
-
free: () => gl.deleteBuffer(ubo),
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
updateUBO(gl, ubo, nameValueMap) {
|
|
93
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
94
|
-
for (const [name, value] of nameValueMap.entries()) {
|
|
95
|
-
const offset = this.offsetMap.get(name);
|
|
96
|
-
if (offset === undefined) {
|
|
97
|
-
throw new Error(`Uniform block member ${name} not found in offset map.`);
|
|
98
|
-
}
|
|
99
|
-
// @ts-ignore
|
|
100
|
-
const type = this.blockMembers.find(member => member.name === name).type;
|
|
101
|
-
let data;
|
|
102
|
-
if (Array.isArray(value)) {
|
|
103
|
-
data = new typeArrayConstructors[type](value);
|
|
104
|
-
}
|
|
105
|
-
else if (typeof value === 'number') {
|
|
106
|
-
data = new typeArrayConstructors[type]([value]);
|
|
107
|
-
}
|
|
108
|
-
else if (value instanceof ArrayBuffer) {
|
|
109
|
-
data = new typeArrayConstructors[type](value);
|
|
110
|
-
}
|
|
111
|
-
else if (ArrayBuffer.isView(value) && !(value instanceof DataView))
|
|
112
|
-
data = (typeof value === 'number') ? new typeArrayConstructors[type]([value]) : new typeArrayConstructors[type](value);
|
|
113
|
-
else {
|
|
114
|
-
throw new Error(`Unsupported value type for ${name}: ${typeof value}`);
|
|
115
|
-
}
|
|
116
|
-
console.log("Data to be uploaded:", data);
|
|
117
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
|
|
118
|
-
}
|
|
119
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
120
|
-
}
|
|
121
|
-
// call this after linking the program
|
|
122
|
-
assignBindingPoint(gl, program) {
|
|
123
|
-
const blockIndex = gl.getUniformBlockIndex(program, this.blockName);
|
|
124
|
-
gl.uniformBlockBinding(program, blockIndex, this.bindingPoint);
|
|
125
|
-
}
|
|
126
|
-
// call this before drawing
|
|
127
|
-
bind(gl, ubo) {
|
|
128
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, ubo);
|
|
129
|
-
}
|
|
130
|
-
// call this right after drawing
|
|
131
|
-
unbind(gl) {
|
|
132
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, null);
|
|
133
|
-
}
|
|
134
|
-
// implicit methods
|
|
135
|
-
__create_LayoutSTD140_OffsetMap() {
|
|
136
|
-
let offset = 0;
|
|
137
|
-
const offsetMap = new Map();
|
|
138
|
-
for (const member of this.blockMembers) {
|
|
139
|
-
const { name, type } = member;
|
|
140
|
-
const size = typeSizes[type];
|
|
141
|
-
const alignment = typeAlignments[type];
|
|
142
|
-
const padding = (alignment - (offset % alignment)) % alignment;
|
|
143
|
-
offset += padding;
|
|
144
|
-
offsetMap.set(name, offset);
|
|
145
|
-
offset += size;
|
|
146
|
-
}
|
|
147
|
-
return offsetMap;
|
|
148
|
-
}
|
|
149
|
-
// __create_LayoutSTD140_OffsetMap() should be called before this
|
|
150
|
-
__calculateSize() {
|
|
151
|
-
const lastOffset = Array.from(this.offsetMap.values()).pop() || 0;
|
|
152
|
-
const lastItemAlignment = typeAlignments[this.blockMembers[this.blockMembers.length - 1].type];
|
|
153
|
-
return lastOffset + lastItemAlignment;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
exports.UniformBlockManager = UniformBlockManager;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* todo:
|
|
4
|
-
* data must be processed before being set to the cache
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
class DataManager {
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param {Array<number>} timeEpocs | array of time epocs
|
|
11
|
-
* @param {Function} fetchMethod | fetchMethod(time) => Promise<data>
|
|
12
|
-
* @param {boolean} autoDownload | auto download data or not
|
|
13
|
-
*/
|
|
14
|
-
constructor(timeEpocs, fetchMethod, { autoDownload = true } = {}) {
|
|
15
|
-
this._timeEpocs = timeEpocs.sort((a, b) => a - b);
|
|
16
|
-
this._datas = [];
|
|
17
|
-
this._datas.length = timeEpocs.length;
|
|
18
|
-
// in construction
|
|
19
|
-
this._dataPromises = [];
|
|
20
|
-
this._dataPromises.length = timeEpocs.length;
|
|
21
|
-
this._fetchMethod = fetchMethod;
|
|
22
|
-
this._callbackmethods = [];
|
|
23
|
-
this._callbackmethodOwners = [];
|
|
24
|
-
this._lastTime = -1;
|
|
25
|
-
this._lastIndex = -1;
|
|
26
|
-
this.autoDownload(autoDownload);
|
|
27
|
-
}
|
|
28
|
-
autoDownload(bool, time) {
|
|
29
|
-
if (!bool) {
|
|
30
|
-
this._autoDownload = false;
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
let index = this._lastIndex === -1 ? 0 : this._lastIndex;
|
|
34
|
-
if (time !== undefined) {
|
|
35
|
-
if (time < this._timeEpocs[0] || time > this._timeEpocs[this._timeEpocs.length - 1]) {
|
|
36
|
-
this._autoDownload = bool;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
index = this._findIndex(time);
|
|
40
|
-
}
|
|
41
|
-
if (this._downloadStartIndex === index && this._autoDownload === bool)
|
|
42
|
-
return;
|
|
43
|
-
this._downloadStartIndex = index;
|
|
44
|
-
this._autoDownload = bool;
|
|
45
|
-
const recursion = (startId, currentDownloadId) => {
|
|
46
|
-
if (startId !== this._downloadStartIndex)
|
|
47
|
-
return;
|
|
48
|
-
if (currentDownloadId < this._timeEpocs.length && this._autoDownload) {
|
|
49
|
-
this._getData(currentDownloadId).then(() => {
|
|
50
|
-
recursion(startId, currentDownloadId + 1);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
recursion(index, index);
|
|
55
|
-
// save index as start index
|
|
56
|
-
//start recursive download
|
|
57
|
-
// use started id as a flag to stop the download
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @param {number} time
|
|
61
|
-
* It looks like async function is not needed here. changes just overwrites the previous changes.
|
|
62
|
-
*/
|
|
63
|
-
updateTime(time) {
|
|
64
|
-
if (time < this._timeEpocs[0] || time > this._timeEpocs[this._timeEpocs.length - 1]) {
|
|
65
|
-
this._dontRender();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
this._lastTime = time;
|
|
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);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
register(key, callback) {
|
|
80
|
-
if (this._callbackmethodOwners.indexOf(key) !== -1) {
|
|
81
|
-
console.warn("key already registered, old one is unregistered");
|
|
82
|
-
this.unregister(key);
|
|
83
|
-
}
|
|
84
|
-
this._callbackmethods.push(callback);
|
|
85
|
-
this._callbackmethodOwners.push(key);
|
|
86
|
-
if (this._lastIndex !== -1)
|
|
87
|
-
callback(this._ratio, this._datas[this._lastIndex - 1], this._datas[this._lastIndex]);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* @param {*} key | id of the owner of the callback
|
|
91
|
-
*/
|
|
92
|
-
unregister(key) {
|
|
93
|
-
let index = this._callbackmethodOwners.indexOf(key);
|
|
94
|
-
if (index !== -1) {
|
|
95
|
-
this._callbackmethods.splice(index, 1);
|
|
96
|
-
this._callbackmethodOwners.splice(index, 1);
|
|
97
|
-
}
|
|
98
|
-
if (this._callbackmethods.length === 0) {
|
|
99
|
-
this.free();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
free() {
|
|
103
|
-
this._callbackmethods = [];
|
|
104
|
-
this._callbackmethodOwners = [];
|
|
105
|
-
this._autoDownload = false;
|
|
106
|
-
}
|
|
107
|
-
_findIndex(time) {
|
|
108
|
-
const { _timeEpocs } = this;
|
|
109
|
-
let index = this._lastIndex === -1 ? 1 : this._lastIndex;
|
|
110
|
-
if (this)
|
|
111
|
-
if (time < _timeEpocs[index - 1]) {
|
|
112
|
-
while (index > 1 && time < _timeEpocs[index - 1]) {
|
|
113
|
-
index--;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else if (time > _timeEpocs[index]) {
|
|
117
|
-
while (index < _timeEpocs.length - 1 && time > _timeEpocs[index]) {
|
|
118
|
-
index++;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return index;
|
|
122
|
-
}
|
|
123
|
-
_getRatio(time, index) {
|
|
124
|
-
return (time - this._timeEpocs[index - 1]) / (this._timeEpocs[index] - this._timeEpocs[index - 1]);
|
|
125
|
-
}
|
|
126
|
-
_pushCallback(ratio, datas) {
|
|
127
|
-
for (let i = 0; i < this._callbackmethods.length; i++) {
|
|
128
|
-
this._callbackmethods[i](ratio, ...datas);
|
|
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
|
-
});
|
|
144
|
-
}
|
|
145
|
-
await this._dataPromises[index];
|
|
146
|
-
return this._datas[index];
|
|
147
|
-
}
|
|
148
|
-
_dontRender() {
|
|
149
|
-
this._pushCallback(0, [null, null]);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
exports.default = DataManager;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PointCoordinatesDataCalculator = exports.HeatWaveDataManager = void 0;
|
|
7
|
-
const pointcoordinatesdatacalculator_1 = __importDefault(require("./pointcoordinatesdatacalculator"));
|
|
8
|
-
exports.PointCoordinatesDataCalculator = pointcoordinatesdatacalculator_1.default;
|
|
9
|
-
const datamanager_1 = __importDefault(require("./datamanager"));
|
|
10
|
-
exports.HeatWaveDataManager = datamanager_1.default;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const pointcoordsmeta_1 = __importDefault(require("./pointcoordsmeta"));
|
|
7
|
-
const pointObject = (long, lat, posIndex, callback) => {
|
|
8
|
-
return { long, lat, posIndex, callback };
|
|
9
|
-
};
|
|
10
|
-
class PointCoordinatesDataCalculator {
|
|
11
|
-
constructor(bbox, width, height) {
|
|
12
|
-
this._pointObjects = {};
|
|
13
|
-
this._ratio = 0.0;
|
|
14
|
-
this._bbox = bbox;
|
|
15
|
-
this._width = width;
|
|
16
|
-
this._height = height;
|
|
17
|
-
this._metaCalculater = new pointcoordsmeta_1.default(bbox, width, height);
|
|
18
|
-
this._texture0 = null;
|
|
19
|
-
this._texture1 = null;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {*} key
|
|
24
|
-
* @param {*} lat
|
|
25
|
-
* @param {*} long
|
|
26
|
-
* @param {*} callback | callback(data0, data1, interpolated)
|
|
27
|
-
*/
|
|
28
|
-
registerPoint(key, long, lat, callback) {
|
|
29
|
-
if (key in this._pointObjects) {
|
|
30
|
-
console.warn("key already registered, old one is unregistered");
|
|
31
|
-
this.unregisterPoint(key);
|
|
32
|
-
}
|
|
33
|
-
if (!this._isInBBox(long, lat))
|
|
34
|
-
return false;
|
|
35
|
-
const meta = this._metaCalculater.getFlooredMeta(long, lat);
|
|
36
|
-
this._pointObjects[key] = pointObject(long, lat, meta.index, callback);
|
|
37
|
-
if (this._texture0 && this._texture1) {
|
|
38
|
-
const { data0, data1, interpolated } = this._findAPoint(meta.index);
|
|
39
|
-
callback(data0, data1, interpolated);
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
_isInBBox(long, lat) {
|
|
44
|
-
return lat >= this._bbox[1] && lat <= this._bbox[3] && long >= this._bbox[0] && long <= this._bbox[2];
|
|
45
|
-
}
|
|
46
|
-
unregisterPoint(key) {
|
|
47
|
-
if (!(key in this._pointObjects))
|
|
48
|
-
return false;
|
|
49
|
-
delete this._pointObjects[key];
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
updatePoint(key, long, lat) {
|
|
53
|
-
if (!(key in this._pointObjects))
|
|
54
|
-
return false;
|
|
55
|
-
if (!this._isInBBox(long, lat))
|
|
56
|
-
return false;
|
|
57
|
-
this._pointObjects[key].long = long;
|
|
58
|
-
this._pointObjects[key].lat = lat;
|
|
59
|
-
const meta = this._metaCalculater.getFlooredMeta(long, lat);
|
|
60
|
-
this._pointObjects[key].posIndex = meta.index;
|
|
61
|
-
const { data0, data1, interpolated } = this._findAPoint(meta.index);
|
|
62
|
-
this._pointObjects[key].callback(data0, data1, interpolated);
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @param {Number} ratio 0-1
|
|
67
|
-
* @param {} textureData0
|
|
68
|
-
* @param {*} textureData1
|
|
69
|
-
*/
|
|
70
|
-
updateData(ratio, textureData0 = null, textureData1 = null) {
|
|
71
|
-
if (!textureData0 && !textureData1) {
|
|
72
|
-
this._pushPointCallBackEmpty();
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (textureData0 && textureData1) {
|
|
76
|
-
this._texture0 = textureData0;
|
|
77
|
-
this._texture1 = textureData1;
|
|
78
|
-
}
|
|
79
|
-
this._ratio = ratio;
|
|
80
|
-
this._pushPointCallbackAll();
|
|
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);
|
|
92
|
-
callback(data0, data1, interpolated);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
_pushPointCallBackEmpty() {
|
|
96
|
-
for (const key in this._pointObjects) {
|
|
97
|
-
const { callback } = this._pointObjects[key];
|
|
98
|
-
callback(null, null, null);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
flush() {
|
|
102
|
-
this._pointObjects = {};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
exports.default = PointCoordinatesDataCalculator;
|
|
106
|
-
// function test() {
|
|
107
|
-
// const cp = window.plugin.getPointCoordinatesDataCalculator();
|
|
108
|
-
// const bbox = [-15, 25, 70, 60];
|
|
109
|
-
// cp.registerPoint("left up", -15, 60, (data0, data1, interpolated) => {
|
|
110
|
-
// console.log("left up", data0, data1, interpolated);
|
|
111
|
-
// });
|
|
112
|
-
// cp.registerPoint("right up", 70, 60, (data0, data1, interpolated) => {
|
|
113
|
-
// console.log("right up", data0, data1, interpolated);
|
|
114
|
-
// });
|
|
115
|
-
// cp.registerPoint("left down", -15, 25, (data0, data1, interpolated) => {
|
|
116
|
-
// console.log("right down", data0, data1, interpolated);
|
|
117
|
-
// });
|
|
118
|
-
// cp.registerPoint("right down", 70, 25, (data0, data1, interpolated) => {
|
|
119
|
-
// console.log("right down", data0, data1, interpolated);
|
|
120
|
-
// });
|
|
121
|
-
// return cp;
|
|
122
|
-
// }
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class PointCoordsMeta {
|
|
4
|
-
constructor(bbox, width, height) {
|
|
5
|
-
this._bbox = bbox;
|
|
6
|
-
this._width = width;
|
|
7
|
-
this._height = height;
|
|
8
|
-
this._xRatio = this._width / (this._bbox[2] - this._bbox[0]);
|
|
9
|
-
this._yRatio = this._height / (this._bbox[3] - this._bbox[1]);
|
|
10
|
-
}
|
|
11
|
-
getFlooredMeta(long, lat) {
|
|
12
|
-
let x = (long - this._bbox[0]) * this._xRatio;
|
|
13
|
-
let y = (this._bbox[3] - lat) * this._yRatio;
|
|
14
|
-
x = x > 0 ? x - 1 : 0;
|
|
15
|
-
y = y > 0 ? y - 1 : 0;
|
|
16
|
-
const index = Math.floor(y) * this._width + Math.floor(x);
|
|
17
|
-
return { index };
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.default = PointCoordsMeta;
|
package/dist/util/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.heatwavedatamanager = exports.programs = exports.webglobe = exports.geometry = exports.shaderfunctions = exports.webglobjectbuilders = void 0;
|
|
40
|
-
const webglobjectbuilders = __importStar(require("./webglobjectbuilders"));
|
|
41
|
-
exports.webglobjectbuilders = webglobjectbuilders;
|
|
42
|
-
const shaderfunctions = __importStar(require("./shaderfunctions"));
|
|
43
|
-
exports.shaderfunctions = shaderfunctions;
|
|
44
|
-
const geometry = __importStar(require("./geometry"));
|
|
45
|
-
exports.geometry = geometry;
|
|
46
|
-
const webglobe = __importStar(require("./webglobe"));
|
|
47
|
-
exports.webglobe = webglobe;
|
|
48
|
-
const programs = __importStar(require("./programs"));
|
|
49
|
-
exports.programs = programs;
|
|
50
|
-
const heatwavedatamanager = __importStar(require("./heatwavedatamanager"));
|
|
51
|
-
exports.heatwavedatamanager = heatwavedatamanager;
|
|
52
|
-
__exportStar(require("./webglobe"), exports);
|
|
53
|
-
__exportStar(require("./webglobjectbuilders"), exports);
|
|
54
|
-
__exportStar(require("./shaderfunctions"), exports);
|
|
55
|
-
__exportStar(require("./geometry"), exports);
|
|
56
|
-
__exportStar(require("./programs"), exports);
|
|
57
|
-
__exportStar(require("./heatwavedatamanager"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GEOMETRY = exports.TimeTrackInterpolator = void 0;
|
|
4
|
-
const search_binary_1 = require("../../algorithms/search-binary");
|
|
5
|
-
const methods_1 = require("../../../Math/methods");
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {Array<number>} vec3 [x, y, z]
|
|
8
|
-
* @typedef {Array<number>} vec2 [x, y]
|
|
9
|
-
* @typedef {Array<number>} vec4 [x, y, z, w]
|
|
10
|
-
* @typedef {number} fraction a number between 0 and 1
|
|
11
|
-
* @typedef {Array<number>} wgs84 [long, lat]
|
|
12
|
-
*/
|
|
13
|
-
const GEOMETRY = Object.freeze({
|
|
14
|
-
CARTESIAN3D: 0,
|
|
15
|
-
MERCATOR: 1,
|
|
16
|
-
});
|
|
17
|
-
exports.GEOMETRY = GEOMETRY;
|
|
18
|
-
class TimeTrackInterpolator {
|
|
19
|
-
/**
|
|
20
|
-
* @typedef Timetrack
|
|
21
|
-
* @property {Array<vec4>}} coordinates [x,y,z, length]
|
|
22
|
-
* @property {Array<Number>} times
|
|
23
|
-
* @param {Array<Timetrack>} timeTracks
|
|
24
|
-
*/
|
|
25
|
-
constructor({ timeTracks, bbox = null, geometry = GEOMETRY.CARTESIAN3D } = {}) {
|
|
26
|
-
this.timeTracks = null;
|
|
27
|
-
this.timeTracksStartTimes = null;
|
|
28
|
-
this.geometry = geometry;
|
|
29
|
-
if (timeTracks)
|
|
30
|
-
this.setTimetracks(timeTracks);
|
|
31
|
-
if (bbox)
|
|
32
|
-
this.setBbox(bbox);
|
|
33
|
-
}
|
|
34
|
-
setGeometry(geometry) {
|
|
35
|
-
if (geometry !== GEOMETRY.CARTESIAN3D && geometry !== GEOMETRY.MERCATOR) {
|
|
36
|
-
throw new Error('Invalid geometry');
|
|
37
|
-
}
|
|
38
|
-
this.geometry = geometry;
|
|
39
|
-
}
|
|
40
|
-
setTimetracks(timeTracks) {
|
|
41
|
-
this.timeTracks = timeTracks;
|
|
42
|
-
}
|
|
43
|
-
interpolate(time) {
|
|
44
|
-
const { timeTracks, geometry } = this;
|
|
45
|
-
if (!timeTracks) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
const resultArray = [];
|
|
49
|
-
const info = {
|
|
50
|
-
outOfRange: 0,
|
|
51
|
-
processed: 0,
|
|
52
|
-
};
|
|
53
|
-
for (let i = 0; i < timeTracks.length; i++) {
|
|
54
|
-
const { times, coordinates } = timeTracks[i];
|
|
55
|
-
if (times[times.length - 1] < time)
|
|
56
|
-
continue;
|
|
57
|
-
info.processed++;
|
|
58
|
-
const timeIndex = (0, search_binary_1.findFirstIndexInRange)(times, time);
|
|
59
|
-
if (timeIndex === null) {
|
|
60
|
-
info.outOfRange++;
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
const timeFraction = (time - times[timeIndex]) / (times[timeIndex + 1] - times[timeIndex]);
|
|
64
|
-
const interpolated = (geometry === GEOMETRY.CARTESIAN3D) ?
|
|
65
|
-
(0, methods_1.sphericalLinearInterpolation_Cartesian3d)(coordinates[timeIndex], coordinates[timeIndex + 1], timeFraction) :
|
|
66
|
-
(0, methods_1.sphericalLinearInterpolation_Mercator)(coordinates[timeIndex], coordinates[timeIndex + 1], timeFraction);
|
|
67
|
-
resultArray.push(...interpolated);
|
|
68
|
-
}
|
|
69
|
-
return new Float32Array(resultArray);
|
|
70
|
-
}
|
|
71
|
-
// implicit methods
|
|
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
|
-
}
|
|
79
|
-
exports.TimeTrackInterpolator = TimeTrackInterpolator;
|