@pirireis/webglobeplugins 0.9.6 → 0.9.7
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/package.json +5 -2
- package/Math/angle-calculation.js +0 -14
- package/Math/arc.ts +0 -76
- package/Math/bounds/line-bbox.js +0 -225
- package/Math/constants.ts +0 -11
- package/Math/frustum/camera.ts +0 -32
- package/Math/frustum/from-globeinfo.ts +0 -63
- package/Math/frustum/types.ts +0 -11
- package/Math/globe-util/horizon-plane.ts +0 -137
- package/Math/index.js +0 -0
- package/Math/juction/arc-plane.ts +0 -114
- package/Math/juction/line-sphere.ts +0 -30
- package/Math/juction/plane-plane.ts +0 -66
- package/Math/line.ts +0 -70
- package/Math/matrix4.ts +0 -0
- package/Math/methods.js +0 -237
- package/Math/plane.ts +0 -86
- package/Math/quaternion.ts +0 -120
- package/Math/roadmap.md +0 -10
- package/Math/types.ts +0 -45
- package/Math/utils.js +0 -3
- package/Math/vec3.ts +0 -155
- package/algorithms/search-binary.js +0 -14
- package/altitude-locator/adaptors.js +0 -0
- package/altitude-locator/draw-subset-obj.js +0 -27
- package/altitude-locator/keymethod.js +0 -0
- package/altitude-locator/plugin.js +0 -439
- package/altitude-locator/types.js +0 -26
- package/arrowfield/adaptor.js +0 -11
- package/arrowfield/index.js +0 -3
- package/arrowfield/plugin.js +0 -128
- package/bearing-line/index.js +0 -2
- package/bearing-line/plugin.js +0 -512
- package/circle-line-chain/chain-list-map.js +0 -221
- package/circle-line-chain/init.js +0 -0
- package/circle-line-chain/plugin.js +0 -469
- package/circle-line-chain/readme.md +0 -57
- package/circle-line-chain/util.js +0 -1
- package/compass-rose/compass-rose-padding-flat.js +0 -266
- package/compass-rose/compass-text-writer.js +0 -173
- package/compass-rose/index.js +0 -3
- package/compassrose/compassrose.js +0 -341
- package/compassrose/index.js +0 -2
- package/depth-locator/readme.md +0 -26
- package/globe-types.ts +0 -13
- package/heatwave/index.js +0 -4
- package/heatwave/isobar/objectarraylabels.js +0 -247
- package/heatwave/isobar/plugin.js +0 -340
- package/heatwave/isobar/quadtreecontours.js +0 -336
- package/heatwave/plugins/heatwaveglobeshell.js +0 -258
- package/jest.config.js +0 -6
- package/partialrings/buffer-manager.js +0 -89
- package/partialrings/goals.md +0 -17
- package/partialrings/index.js +0 -3
- package/partialrings/plugin.js +0 -160
- package/partialrings/program.js +0 -324
- package/pin/pin-object-array.js +0 -381
- package/pin/pin-point-totem.js +0 -77
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +0 -78
- package/point-heat-map/index.js +0 -0
- package/point-heat-map/plugin-webworker.js +0 -151
- package/point-heat-map/point-to-heat-map-flow.js +0 -150
- package/point-heat-map/readme.md +0 -15
- package/point-tracks/key-methods.js +0 -3
- package/point-tracks/plugin.js +0 -394
- package/programs/arrowfield/index.js +0 -2
- package/programs/arrowfield/logic.js +0 -286
- package/programs/arrowfield/object.js +0 -89
- package/programs/data2legend/density-to-legend.js +0 -115
- package/programs/data2legend/point-to-density-texture.js +0 -114
- package/programs/float2legendwithratio/index.js +0 -3
- package/programs/float2legendwithratio/logic.js +0 -194
- package/programs/float2legendwithratio/object.js +0 -141
- package/programs/globe-util/is-globe-moved.js +0 -27
- package/programs/globeshell/index.js +0 -2
- package/programs/globeshell/noise/noises.js +0 -0
- package/programs/globeshell/wiggle/index.js +0 -6
- package/programs/globeshell/wiggle/logic.js +0 -371
- package/programs/globeshell/wiggle/object.js +0 -93
- package/programs/helpers/blender/index.js +0 -0
- package/programs/helpers/blender/program.js +0 -91
- package/programs/helpers/fadeaway/index.js +0 -3
- package/programs/helpers/fadeaway/logic.js +0 -76
- package/programs/helpers/fadeaway/object.js +0 -20
- package/programs/helpers/index.js +0 -2
- package/programs/index.js +0 -21
- package/programs/interface.ts +0 -7
- package/programs/line-on-globe/angled-line.js +0 -206
- package/programs/line-on-globe/circle-accurate-3d.js +0 -167
- package/programs/line-on-globe/circle-accurate-flat.js +0 -262
- package/programs/line-on-globe/circle-accurate.js +0 -202
- package/programs/line-on-globe/circle.js +0 -191
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +0 -188
- package/programs/line-on-globe/index.js +0 -0
- package/programs/line-on-globe/lines-color-instanced-flat.js +0 -151
- package/programs/line-on-globe/linestrip.ts +0 -228
- package/programs/line-on-globe/naive-accurate-flexible.js +0 -239
- package/programs/line-on-globe/to-the-surface.js +0 -129
- package/programs/line-on-globe/util.js +0 -8
- package/programs/picking/pickable-renderer.js +0 -216
- package/programs/point-on-globe/element-globe-surface-glow.js +0 -168
- package/programs/point-on-globe/element-point-glow.js +0 -184
- package/programs/point-on-globe/square-pixel-point.js +0 -189
- package/programs/programcache.ts +0 -131
- package/programs/rings/distancering/circleflatprogram.js +0 -136
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -378
- package/programs/rings/distancering/circlepaddysharedbuffer.js +0 -420
- package/programs/rings/distancering/index.js +0 -5
- package/programs/rings/distancering/paddyflatprogram.js +0 -146
- package/programs/rings/distancering/paddyflatprogram2d.js +0 -150
- package/programs/rings/distancering/paddyflatprogram3d.js +0 -146
- package/programs/rings/distancering/shader.js +0 -0
- package/programs/rings/index.js +0 -1
- package/programs/rings/partial-ring/piece-of-pie.js +0 -315
- package/programs/totems/camerauniformblock.d.ts +0 -48
- package/programs/totems/camerauniformblock.js +0 -197
- package/programs/totems/canvas-webglobe-info.js +0 -136
- package/programs/totems/gpu-selection-uniform-block.js +0 -132
- package/programs/totems/index.ts +0 -2
- package/programs/two-d/pixel-circle.js +0 -0
- package/programs/two-d/pixel-padding-for-compass.js +0 -174
- package/programs/util.js +0 -20
- package/programs/vectorfields/index.js +0 -3
- package/programs/vectorfields/logics/drawrectangleparticles.js +0 -125
- package/programs/vectorfields/logics/index.js +0 -5
- package/programs/vectorfields/logics/pixelbased.js +0 -161
- package/programs/vectorfields/logics/ubo.js +0 -64
- package/programs/vectorfields/pingpongbuffermanager.js +0 -80
- package/publish.bat +0 -60
- package/rangerings/enum.js +0 -3
- package/rangerings/index.js +0 -5
- package/rangerings/plugin.js +0 -649
- package/rangerings/rangeringangletext.js +0 -368
- package/rangerings/ring-account.js +0 -129
- package/shaders/fragment-toy/firework.js +0 -55
- package/shaders/fragment-toy/singularity.js +0 -59
- package/shape-on-terrain/arc/naive/plugin.ts +0 -304
- package/shape-on-terrain/goal.md +0 -12
- package/tests/Math/junction/arc-plane.test.ts +0 -133
- package/tests/Math/junction/plane-plane.test.ts +0 -82
- package/tests/Math/plane.test.ts +0 -43
- package/tests/Math/vec3.test.ts +0 -14
- package/timetracks/adaptors-line-strip.js +0 -80
- package/timetracks/adaptors.js +0 -133
- package/timetracks/index.js +0 -6
- package/timetracks/plugin-line-strip.js +0 -295
- package/timetracks/plugin.js +0 -304
- package/timetracks/program-line-strip.js +0 -688
- package/timetracks/program.js +0 -850
- package/timetracks/programpoint-line-strip.js +0 -175
- package/timetracks/programpoint.js +0 -168
- package/timetracks/readme.md +0 -1
- package/tsconfig.json +0 -22
- package/types.ts +0 -17
- package/util/account/bufferoffsetmanager.js +0 -209
- package/util/account/index.js +0 -6
- package/util/account/single-attribute-buffer-management/buffer-manager.ts +0 -119
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.ts +0 -173
- package/util/account/single-attribute-buffer-management/index.ts +0 -13
- package/util/account/single-attribute-buffer-management/object-store.ts +0 -65
- package/util/account/single-attribute-buffer-management/types.ts +0 -39
- package/util/account/util.js +0 -22
- package/util/algorithms/index.js +0 -0
- package/util/algorithms/search-binary.js +0 -26
- package/util/check/get.js +0 -13
- package/util/check/index.js +0 -0
- package/util/check/typecheck.js +0 -39
- package/util/geometry/index.js +0 -53
- package/util/gl-util/buffer/attribute-loader.ts +0 -85
- package/util/gl-util/buffer/index.ts +0 -6
- package/util/gl-util/buffer/types.ts +0 -13
- package/util/gl-util/draw-options/methods.ts +0 -66
- package/util/gl-util/draw-options/types.ts +0 -28
- package/util/gl-util/uniform-block/manager.ts +0 -187
- package/util/gl-util/uniform-block/roadmap.md +0 -70
- package/util/gl-util/uniform-block/shader.js +0 -0
- package/util/gl-util/uniform-block/types.ts +0 -27
- package/util/heatwavedatamanager/datamanager.js +0 -168
- package/util/heatwavedatamanager/index.js +0 -3
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +0 -133
- package/util/heatwavedatamanager/pointcoordsmeta.js +0 -22
- package/util/index.js +0 -13
- package/util/interpolation/index.js +0 -0
- package/util/interpolation/timetrack/index.js +0 -9
- package/util/interpolation/timetrack/timetrack-interpolator.js +0 -88
- package/util/interpolation/timetrack/web-worker-str.js +0 -180
- package/util/interpolation/timetrack/web-worker.js +0 -51
- package/util/jshelpers/data-filler.js +0 -19
- package/util/jshelpers/equality.js +0 -17
- package/util/jshelpers/index.js +0 -1
- package/util/jshelpers/timefilters.js +0 -32
- package/util/picking/fence.js +0 -46
- package/util/picking/picker-displayer.js +0 -177
- package/util/programs/draw-texture-on-canvas.js +0 -102
- package/util/programs/index.js +0 -1
- package/util/programs/shapesonglobe.js +0 -246
- package/util/programs/supersampletotextures.js +0 -142
- package/util/programs/texturetoglobe.js +0 -203
- package/util/shaderfunctions/geometrytransformations.ts +0 -388
- package/util/shaderfunctions/index.js +0 -2
- package/util/shaderfunctions/nodata.js +0 -10
- package/util/shaderfunctions/noisefunctions.js +0 -44
- package/util/surface-line-data/arc-bboxes.ts +0 -42
- package/util/surface-line-data/arcs-to-cuts.js +0 -74
- package/util/surface-line-data/cut-arc.js +0 -0
- package/util/surface-line-data/flow.ts +0 -52
- package/util/surface-line-data/rbush-manager.js +0 -0
- package/util/surface-line-data/types.ts +0 -27
- package/util/surface-line-data/web-worker.js +0 -0
- package/util/webglobe/gldefaultstates.js +0 -5
- package/util/webglobe/index.js +0 -2
- package/util/webglobe/rasteroverlay.js +0 -96
- package/util/webglobjectbuilders.ts +0 -456
- package/util/webglobjectbuilders1.js +0 -271
- package/waveparticles/adaptor.js +0 -16
- package/waveparticles/index.js +0 -3
- package/waveparticles/plugin.js +0 -313
- package/wind/imagetovectorfieldandmagnitude.js +0 -39
- package/wind/index.js +0 -5
- package/wind/plugin.js +0 -1057
- package/wind/vectorfieldimage.js +0 -27
- package/write-text/attached-text-writer.js +0 -105
- package/write-text/context-text.js +0 -125
- package/write-text/context-text3.js +0 -178
- package/write-text/index.js +0 -1
- package/write-text/writer-plugin.js +0 -7
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import './types'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents the range of vertices or instances to draw.
|
|
5
|
-
*/
|
|
6
|
-
interface DrawRange {
|
|
7
|
-
first?: number;
|
|
8
|
-
count: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Parameters for drawing with optional element buffer and draw mode.
|
|
13
|
-
*/
|
|
14
|
-
interface DrawRangeIndexParams {
|
|
15
|
-
drawRange: DrawRange;
|
|
16
|
-
elementBuffer?: WebGLBuffer | null;
|
|
17
|
-
elementBufferIndexType?: GLenum;
|
|
18
|
-
drawMode?: GLenum | null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Draws instanced geometry using WebGL2.
|
|
23
|
-
*/
|
|
24
|
-
const drawInstanced = (
|
|
25
|
-
gl: WebGL2RenderingContext,
|
|
26
|
-
mode: GLenum,
|
|
27
|
-
drawOptions: DrawRangeIndexParams,
|
|
28
|
-
vertexCount: number
|
|
29
|
-
): void => {
|
|
30
|
-
const { drawRange, elementBufferIndexType = gl.UNSIGNED_INT } = drawOptions;
|
|
31
|
-
const { first = 0, count: instanceCount = 1 } = drawRange;
|
|
32
|
-
if (first > 0 || drawOptions.elementBuffer) {
|
|
33
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, drawOptions.elementBuffer ?? null);
|
|
34
|
-
gl.drawElementsInstanced(mode, vertexCount, elementBufferIndexType, first, instanceCount);
|
|
35
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
36
|
-
} else {
|
|
37
|
-
gl.drawArraysInstanced(mode, first, vertexCount, instanceCount);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Draws geometry using WebGL2.
|
|
43
|
-
*/
|
|
44
|
-
const drawArrays = (
|
|
45
|
-
gl: WebGL2RenderingContext,
|
|
46
|
-
defaultMode: GLenum,
|
|
47
|
-
drawOptions: DrawRangeIndexParams
|
|
48
|
-
): void => {
|
|
49
|
-
const {
|
|
50
|
-
drawRange,
|
|
51
|
-
elementBuffer,
|
|
52
|
-
elementBufferIndexType = gl.UNSIGNED_INT,
|
|
53
|
-
drawMode = null
|
|
54
|
-
} = drawOptions;
|
|
55
|
-
const { first = 0, count } = drawRange;
|
|
56
|
-
const mode = drawMode ?? defaultMode;
|
|
57
|
-
if (elementBuffer) {
|
|
58
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer);
|
|
59
|
-
gl.drawElements(mode, count, elementBufferIndexType, first);
|
|
60
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
61
|
-
} else {
|
|
62
|
-
gl.drawArrays(mode, first, count);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { drawArrays, drawInstanced }
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef DrawRange
|
|
3
|
-
* @type {Object}
|
|
4
|
-
* @property {int} first
|
|
5
|
-
* @property {int} count
|
|
6
|
-
*
|
|
7
|
-
* @typedef DrawRangeIndexParams
|
|
8
|
-
* @type {Object}
|
|
9
|
-
* @property {null|DrawRange} drawRange
|
|
10
|
-
* @property {null|ElementBuffer} elementBuffer
|
|
11
|
-
* @property {null|indexType} indexType
|
|
12
|
-
* @property {null|int} drawMode
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
type DrawRange = {
|
|
18
|
-
first: number;
|
|
19
|
-
count: number;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type DrawRangeIndexParams = {
|
|
23
|
-
drawRange: DrawRange;
|
|
24
|
-
elementBuffer?: WebGLBuffer;
|
|
25
|
-
elementBufferIndexType?: number;
|
|
26
|
-
drawMode?: number;
|
|
27
|
-
};
|
|
28
|
-
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import "./types";
|
|
2
|
-
|
|
3
|
-
const typeSizes = {
|
|
4
|
-
'float': 4,
|
|
5
|
-
'vec2': 8,
|
|
6
|
-
'vec3': 16, // vec3 takes up same space as vec4 due to alignment
|
|
7
|
-
'vec4': 16,
|
|
8
|
-
'mat2': 32, // 2 vec4s (16 * 2)
|
|
9
|
-
'mat3': 48, // 3 vec4s (16 * 3)
|
|
10
|
-
'mat4': 64, // 4 vec4s (16 * 4)
|
|
11
|
-
'int': 4,
|
|
12
|
-
'ivec2': 8,
|
|
13
|
-
'ivec3': 16,
|
|
14
|
-
'ivec4': 16,
|
|
15
|
-
'bool': 4
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const typeAlignments = {
|
|
19
|
-
'float': 4,
|
|
20
|
-
'vec2': 8,
|
|
21
|
-
'vec3': 16,
|
|
22
|
-
'vec4': 16,
|
|
23
|
-
'mat2': 16, // aligns to vec4 boundary
|
|
24
|
-
'mat3': 16, // aligns to vec4 boundary
|
|
25
|
-
'mat4': 16, // aligns to vec4 boundary
|
|
26
|
-
'int': 4,
|
|
27
|
-
'ivec2': 8,
|
|
28
|
-
'ivec3': 16,
|
|
29
|
-
'ivec4': 16,
|
|
30
|
-
'bool': 4
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const typeArrayConstructors = {
|
|
35
|
-
'float': Float32Array,
|
|
36
|
-
'vec2': Float32Array,
|
|
37
|
-
'vec3': Float32Array,
|
|
38
|
-
'vec4': Float32Array,
|
|
39
|
-
'mat2': Float32Array,
|
|
40
|
-
'mat3': Float32Array,
|
|
41
|
-
'mat4': Float32Array,
|
|
42
|
-
'int': Int32Array,
|
|
43
|
-
'ivec2': Int32Array,
|
|
44
|
-
'ivec3': Int32Array,
|
|
45
|
-
'ivec4': Int32Array,
|
|
46
|
-
'bool': Float32Array
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
class UniformBlockManager {
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
* @param {UniformBlockName} blockName
|
|
55
|
-
* @param {Array<UniformBlockMember} blockMembers
|
|
56
|
-
* @param {string} prefix usage name of block in the shader
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
blockName: string;
|
|
60
|
-
blockMembers: Array<UniformBlockMember>;
|
|
61
|
-
bindingPoint: number;
|
|
62
|
-
prefix: string;
|
|
63
|
-
offsetMap: Map<string, number>;
|
|
64
|
-
size: number;
|
|
65
|
-
|
|
66
|
-
constructor(blockName: string, blockMembers: Array<UniformBlockMember>, bindingPoint: number, prefix: string = "") {
|
|
67
|
-
this.blockName = blockName;
|
|
68
|
-
this.blockMembers = blockMembers;
|
|
69
|
-
this.bindingPoint = bindingPoint;
|
|
70
|
-
this.prefix = prefix;
|
|
71
|
-
this.offsetMap = this.__create_LayoutSTD140_OffsetMap();
|
|
72
|
-
this.size = this.__calculateSize();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
glslCode() {
|
|
78
|
-
let code = `layout(std140) uniform ${this.blockName} {`;
|
|
79
|
-
for (const member of this.blockMembers) {
|
|
80
|
-
const { name, type } = member;
|
|
81
|
-
code += `${type} ${this.prefix}${name};`;
|
|
82
|
-
}
|
|
83
|
-
if (this.prefix) {
|
|
84
|
-
code += `} ${this.prefix};`;
|
|
85
|
-
} else {
|
|
86
|
-
code += `};`;
|
|
87
|
-
}
|
|
88
|
-
return code;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
createUBO(gl: WebGL2RenderingContext, bufferWriteType: string = "STATIC_DRAW"): UBOHandler {
|
|
93
|
-
const ubo = gl.createBuffer();
|
|
94
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
gl.bufferData(gl.UNIFORM_BUFFER, this.size, gl[bufferWriteType]);
|
|
97
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, ubo);
|
|
98
|
-
|
|
99
|
-
for (const member of this.blockMembers) {
|
|
100
|
-
const { name, type, value = null } = member;;
|
|
101
|
-
const offset = this.offsetMap.get(name) as number;
|
|
102
|
-
const data = (value === null) ? new typeArrayConstructors[type](typeSizes[type] / 4).fill(NaN) : value;
|
|
103
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
|
|
104
|
-
}
|
|
105
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
106
|
-
|
|
107
|
-
return { // TODO typedef this, encapsulate this in a class or something, ask ai
|
|
108
|
-
ubo,
|
|
109
|
-
update: (nameValueMap: NameValueMap) => this.updateUBO(gl, ubo, nameValueMap),
|
|
110
|
-
bind: () => this.bind(gl, ubo),
|
|
111
|
-
unbind: () => this.unbind(gl),
|
|
112
|
-
free: () => gl.deleteBuffer(ubo),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
updateUBO(gl: WebGL2RenderingContext, ubo: WebGLBuffer, nameValueMap: NameValueMap) {
|
|
118
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
119
|
-
for (const [name, value] of nameValueMap.entries()) {
|
|
120
|
-
const offset = this.offsetMap.get(name);
|
|
121
|
-
if (offset === undefined) {
|
|
122
|
-
throw new Error(`Uniform block member ${name} not found in offset map.`);
|
|
123
|
-
}
|
|
124
|
-
// @ts-ignore
|
|
125
|
-
const type = this.blockMembers.find(member => member.name === name).type;
|
|
126
|
-
let data: Float32Array | Int32Array | ArrayBuffer | DataView;
|
|
127
|
-
if (Array.isArray(value)) {
|
|
128
|
-
data = new typeArrayConstructors[type](value);
|
|
129
|
-
} else if (typeof value === 'number') {
|
|
130
|
-
data = new typeArrayConstructors[type]([value]);
|
|
131
|
-
} else if (value instanceof ArrayBuffer) {
|
|
132
|
-
data = new typeArrayConstructors[type](value);
|
|
133
|
-
} else if (ArrayBuffer.isView(value) && !(value instanceof DataView))
|
|
134
|
-
data = (typeof value === 'number') ? new typeArrayConstructors[type]([value]) : new typeArrayConstructors[type](value);
|
|
135
|
-
else {
|
|
136
|
-
throw new Error(`Unsupported value type for ${name}: ${typeof value}`);
|
|
137
|
-
}
|
|
138
|
-
console.log("Data to be uploaded:", data);
|
|
139
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, data);
|
|
140
|
-
}
|
|
141
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// call this after linking the program
|
|
145
|
-
assignBindingPoint(gl: WebGL2RenderingContext, program: WebGLProgram) {
|
|
146
|
-
const blockIndex = gl.getUniformBlockIndex(program, this.blockName);
|
|
147
|
-
gl.uniformBlockBinding(program, blockIndex, this.bindingPoint);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// call this before drawing
|
|
151
|
-
bind(gl: WebGL2RenderingContext, ubo: WebGLBuffer) {
|
|
152
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, ubo);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// call this right after drawing
|
|
156
|
-
unbind(gl: WebGL2RenderingContext) {
|
|
157
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.bindingPoint, null);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// implicit methods
|
|
162
|
-
__create_LayoutSTD140_OffsetMap(): Map<string, number> {
|
|
163
|
-
let offset = 0;
|
|
164
|
-
const offsetMap = new Map();
|
|
165
|
-
for (const member of this.blockMembers) {
|
|
166
|
-
const { name, type } = member;
|
|
167
|
-
const size = typeSizes[type];
|
|
168
|
-
const alignment = typeAlignments[type];
|
|
169
|
-
const padding = (alignment - (offset % alignment)) % alignment;
|
|
170
|
-
offset += padding;
|
|
171
|
-
offsetMap.set(name, offset);
|
|
172
|
-
offset += size;
|
|
173
|
-
}
|
|
174
|
-
return offsetMap;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// __create_LayoutSTD140_OffsetMap() should be called before this
|
|
178
|
-
__calculateSize() {
|
|
179
|
-
const lastOffset = Array.from(this.offsetMap.values()).pop() as number || 0;
|
|
180
|
-
const lastItemAlignment = typeAlignments[this.blockMembers[this.blockMembers.length - 1].type];
|
|
181
|
-
return lastOffset + lastItemAlignment;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
export { UniformBlockManager };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# UniformBlock Wrapper
|
|
2
|
-
|
|
3
|
-
- Uniform shader string
|
|
4
|
-
- bind/unbind
|
|
5
|
-
- set/get uniform value generic
|
|
6
|
-
|
|
7
|
-
## INPUT
|
|
8
|
-
- uniform block name
|
|
9
|
-
- Array<{type, name}> UniformBlockMembers
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## PROCESS
|
|
13
|
-
|
|
14
|
-
- Calculate and save starting offset of each member
|
|
15
|
-
- Create UBO
|
|
16
|
-
- Bind UBO
|
|
17
|
-
- Set uniform value
|
|
18
|
-
|
|
19
|
-
### Calculate and save starting offset of each member
|
|
20
|
-
|
|
21
|
-
layout(std140) is a convention. The calculation should be done according to this convention.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
type | size
|
|
25
|
-
--- | ---
|
|
26
|
-
float | 4
|
|
27
|
-
vec2 | 8
|
|
28
|
-
vec3 | 12
|
|
29
|
-
vec4 | 16
|
|
30
|
-
mat2 | 16
|
|
31
|
-
mat3 | 48
|
|
32
|
-
mat4 | 64
|
|
33
|
-
|
|
34
|
-
A line is 16 bytes aligned. Alignment can be shared if previous member is equal or bigger then the next member and the sum of the sizes are smaller then 16 bytes.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
## setMethod
|
|
46
|
-
|
|
47
|
-
update({
|
|
48
|
-
color = null,
|
|
49
|
-
bboxOffsetRad = null,
|
|
50
|
-
bboxSizeRad = null,
|
|
51
|
-
resolution = null,
|
|
52
|
-
tailLengthRatio = null,
|
|
53
|
-
wingLengthRatio = null,
|
|
54
|
-
height = null,
|
|
55
|
-
opacity = null,
|
|
56
|
-
noDataValue = null,
|
|
57
|
-
} = {}) {
|
|
58
|
-
const { gl, ubo } = this;
|
|
59
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
60
|
-
if (color !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array(color));
|
|
61
|
-
if (opacity !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 12, new Float32Array([opacity]));
|
|
62
|
-
if (bboxOffsetRad !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 16, new Float32Array(bboxOffsetRad));
|
|
63
|
-
if (bboxSizeRad !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 24, new Float32Array(bboxSizeRad));
|
|
64
|
-
if (resolution !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 32, new Float32Array(resolution));
|
|
65
|
-
if (tailLengthRatio !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 40, new Float32Array([tailLengthRatio]));
|
|
66
|
-
if (wingLengthRatio !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 44, new Float32Array([wingLengthRatio]));
|
|
67
|
-
if (height !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 48, new Float32Array([height]));
|
|
68
|
-
if (noDataValue !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 52, new Float32Array([noDataValue]));
|
|
69
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
70
|
-
}
|
|
File without changes
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {string} UniformBlockName
|
|
3
|
-
*
|
|
4
|
-
* @typedef {string} GLSLType | mat4, mat3, vec4, vec3, vec2, float, int, bool
|
|
5
|
-
* @typedef {{name: string, type: GLSLType, value: null|Float32Array}} UniformBlockMember
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type UniformBlockName = string;
|
|
11
|
-
type GLSLType = "mat4" | "mat3" | "vec4" | "vec3" | "vec2" | "float" | "int" | "bool";
|
|
12
|
-
type UniformBlockMember = {
|
|
13
|
-
name: string;
|
|
14
|
-
type: GLSLType;
|
|
15
|
-
value: Float32Array | null;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type NameValueMap = Map<string, Array<number> | DataView | ArrayBuffer>;
|
|
20
|
-
|
|
21
|
-
type UBOHandler = {
|
|
22
|
-
ubo: WebGLBuffer;
|
|
23
|
-
update: (nameValueMap: Map<string, any>) => void;
|
|
24
|
-
bind: () => void;
|
|
25
|
-
unbind: () => void;
|
|
26
|
-
free: () => void;
|
|
27
|
-
};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* todo:
|
|
3
|
-
* data must be processed before being set to the cache
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export default class DataManager {
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {Array<number>} timeEpocs | array of time epocs
|
|
10
|
-
* @param {Function} fetchMethod | fetchMethod(time) => Promise<data>
|
|
11
|
-
* @param {boolean} autoDownload | auto download data or not
|
|
12
|
-
*/
|
|
13
|
-
constructor(timeEpocs, fetchMethod, { autoDownload = true } = {}) {
|
|
14
|
-
|
|
15
|
-
this._timeEpocs = timeEpocs.sort((a, b) => a - b);
|
|
16
|
-
this._datas = []; this._datas.length = timeEpocs.length;
|
|
17
|
-
|
|
18
|
-
// in construction
|
|
19
|
-
this._dataPromises = []; this._dataPromises.length = timeEpocs.length;
|
|
20
|
-
|
|
21
|
-
this._fetchMethod = fetchMethod;
|
|
22
|
-
this._callbackmethods = [];
|
|
23
|
-
this._callbackmethodOwners = [];
|
|
24
|
-
this._lastTime = -1;
|
|
25
|
-
this._lastIndex = -1;
|
|
26
|
-
this.autoDownload(autoDownload);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
autoDownload(bool, time) {
|
|
31
|
-
if (!bool) {
|
|
32
|
-
this._autoDownload = false;
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
let index = this._lastIndex === -1 ? 0 : this._lastIndex;
|
|
36
|
-
if (time !== undefined) {
|
|
37
|
-
if (time < this._timeEpocs[0] || time > this._timeEpocs[this._timeEpocs.length - 1]) {
|
|
38
|
-
this._autoDownload = bool;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
index = this._findIndex(time);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (this._downloadStartIndex === index && this._autoDownload === bool) return;
|
|
45
|
-
this._downloadStartIndex = index;
|
|
46
|
-
this._autoDownload = bool;
|
|
47
|
-
const recursion = (startId, currentDownloadId) => {
|
|
48
|
-
if (startId !== this._downloadStartIndex) return;
|
|
49
|
-
if (currentDownloadId < this._timeEpocs.length && this._autoDownload) {
|
|
50
|
-
this._getData(currentDownloadId).then(() => {
|
|
51
|
-
recursion(startId, currentDownloadId + 1);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
recursion(index, index);
|
|
56
|
-
// save index as start index
|
|
57
|
-
//start recursive download
|
|
58
|
-
|
|
59
|
-
// use started id as a flag to stop the download
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {number} time
|
|
66
|
-
* It looks like async function is not needed here. changes just overwrites the previous changes.
|
|
67
|
-
*/
|
|
68
|
-
updateTime(time) {
|
|
69
|
-
if (time < this._timeEpocs[0] || time > this._timeEpocs[this._timeEpocs.length - 1]) {
|
|
70
|
-
this._dontRender();
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this._lastTime = time;
|
|
74
|
-
const index = this._findIndex(time);
|
|
75
|
-
const ratio = this._getRatio(time, index);
|
|
76
|
-
Promise.all([this._getData(index - 1), this._getData(index)]).then((datas) => {
|
|
77
|
-
if (this._lastTime === time) {
|
|
78
|
-
this._lastIndex = index;
|
|
79
|
-
this._ratio = ratio;
|
|
80
|
-
this._pushCallback(ratio, datas);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
register(key, callback) {
|
|
87
|
-
if (this._callbackmethodOwners.indexOf(key) !== -1) {
|
|
88
|
-
console.warn("key already registered, old one is unregistered");
|
|
89
|
-
this.unregister(key);
|
|
90
|
-
}
|
|
91
|
-
this._callbackmethods.push(callback);
|
|
92
|
-
this._callbackmethodOwners.push(key);
|
|
93
|
-
if (this._lastIndex !== -1) callback(this._ratio, this._datas[this._lastIndex - 1], this._datas[this._lastIndex]);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @param {*} key | id of the owner of the callback
|
|
99
|
-
*/
|
|
100
|
-
unregister(key) {
|
|
101
|
-
let index = this._callbackmethodOwners.indexOf(key);
|
|
102
|
-
if (index !== -1) {
|
|
103
|
-
this._callbackmethods.splice(index, 1);
|
|
104
|
-
this._callbackmethodOwners.splice(index, 1);
|
|
105
|
-
}
|
|
106
|
-
if (this._callbackmethods.length === 0) {
|
|
107
|
-
this.free();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
free() {
|
|
113
|
-
this._callbackmethods = [];
|
|
114
|
-
this._callbackmethodOwners = [];
|
|
115
|
-
this._autoDownload = false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
_findIndex(time) {
|
|
119
|
-
const { _timeEpocs } = this;
|
|
120
|
-
let index = this._lastIndex === -1 ? 1 : this._lastIndex;
|
|
121
|
-
if (this)
|
|
122
|
-
if (time < _timeEpocs[index - 1]) {
|
|
123
|
-
while (index > 1 && time < _timeEpocs[index - 1]) {
|
|
124
|
-
index--;
|
|
125
|
-
}
|
|
126
|
-
} else if (time > _timeEpocs[index]) {
|
|
127
|
-
while (index < _timeEpocs.length - 1 && time > _timeEpocs[index]) {
|
|
128
|
-
index++;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return index;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
_getRatio(time, index) {
|
|
136
|
-
return (time - this._timeEpocs[index - 1]) / (this._timeEpocs[index] - this._timeEpocs[index - 1]);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
_pushCallback(ratio, datas) {
|
|
141
|
-
for (let i = 0; i < this._callbackmethods.length; i++) {
|
|
142
|
-
this._callbackmethods[i](ratio, ...datas);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
async _getData(index) {
|
|
148
|
-
if (index < 0 || index >= this._timeEpocs.length) {
|
|
149
|
-
throw new Error("Index out of range");
|
|
150
|
-
}
|
|
151
|
-
if (!this._datas[index]) {
|
|
152
|
-
if (!this._dataPromises[index]) this._dataPromises[index] = this._fetchMethod(this._timeEpocs[index]).then((data) => {
|
|
153
|
-
this._datas[index] = data;
|
|
154
|
-
}, (error) => {
|
|
155
|
-
console.error("error", error);
|
|
156
|
-
}).finally(() => {
|
|
157
|
-
this._dataPromises[index] = null;
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
await this._dataPromises[index];
|
|
161
|
-
return this._datas[index];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
_dontRender() {
|
|
165
|
-
this._pushCallback(0, [null, null]);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import PointCoordsMeta from "./pointcoordsmeta";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const pointObject = (long, lat, posIndex, callback) => {
|
|
5
|
-
return { long, lat, posIndex, callback };
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default class PointCoordinatesDataCalculator {
|
|
9
|
-
constructor(bbox, width, height) {
|
|
10
|
-
this._pointObjects = {};
|
|
11
|
-
|
|
12
|
-
this._ratio = 0.0;
|
|
13
|
-
|
|
14
|
-
this._bbox = bbox;
|
|
15
|
-
this._width = width;
|
|
16
|
-
this._height = height;
|
|
17
|
-
this._metaCalculater = new PointCoordsMeta(bbox, width, height);
|
|
18
|
-
|
|
19
|
-
this._texture0 = null;
|
|
20
|
-
this._texture1 = null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @param {*} key
|
|
26
|
-
* @param {*} lat
|
|
27
|
-
* @param {*} long
|
|
28
|
-
* @param {*} callback | callback(data0, data1, interpolated)
|
|
29
|
-
*/
|
|
30
|
-
registerPoint(key, long, lat, callback) {
|
|
31
|
-
if (key in this._pointObjects) {
|
|
32
|
-
console.warn("key already registered, old one is unregistered");
|
|
33
|
-
this.unregisterPoint(key);
|
|
34
|
-
}
|
|
35
|
-
if (!this._isInBBox(long, lat)) return false;
|
|
36
|
-
|
|
37
|
-
const meta = this._metaCalculater.getFlooredMeta(long, lat)
|
|
38
|
-
|
|
39
|
-
this._pointObjects[key] = pointObject(long, lat, meta.index, callback);
|
|
40
|
-
if (this._texture0 && this._texture1) {
|
|
41
|
-
const { data0, data1, interpolated } = this._findAPoint(meta.index);
|
|
42
|
-
callback(data0, data1, interpolated);
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
_isInBBox(long, lat) {
|
|
48
|
-
return lat >= this._bbox[1] && lat <= this._bbox[3] && long >= this._bbox[0] && long <= this._bbox[2];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
unregisterPoint(key) {
|
|
53
|
-
if (!(key in this._pointObjects)) return false;
|
|
54
|
-
delete this._pointObjects[key];
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
updatePoint(key, long, lat) {
|
|
59
|
-
|
|
60
|
-
if (!(key in this._pointObjects)) return false;
|
|
61
|
-
if (!this._isInBBox(long, lat)) return false;
|
|
62
|
-
this._pointObjects[key].long = long;
|
|
63
|
-
this._pointObjects[key].lat = lat;
|
|
64
|
-
const meta = this._metaCalculater.getFlooredMeta(long, lat);
|
|
65
|
-
this._pointObjects[key].posIndex = meta.index;
|
|
66
|
-
const { data0, data1, interpolated } = this._findAPoint(meta.index);
|
|
67
|
-
this._pointObjects[key].callback(data0, data1, interpolated);
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @param {Number} ratio 0-1
|
|
73
|
-
* @param {} textureData0
|
|
74
|
-
* @param {*} textureData1
|
|
75
|
-
*/
|
|
76
|
-
updateData(ratio, textureData0 = null, textureData1 = null) {
|
|
77
|
-
if (!textureData0 && !textureData1) {
|
|
78
|
-
this._pushPointCallBackEmpty();
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (textureData0 && textureData1) {
|
|
82
|
-
this._texture0 = textureData0;
|
|
83
|
-
this._texture1 = textureData1;
|
|
84
|
-
}
|
|
85
|
-
this._ratio = ratio;
|
|
86
|
-
this._pushPointCallbackAll();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_findAPoint(posIndex) {
|
|
91
|
-
const data0 = this._texture0[posIndex];
|
|
92
|
-
const data1 = this._texture1[posIndex];
|
|
93
|
-
const interpolated = data0 * (1 - this._ratio) + data1 * this._ratio;
|
|
94
|
-
return { data0, data1, interpolated };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
_pushPointCallbackAll() {
|
|
98
|
-
for (const key in this._pointObjects) {
|
|
99
|
-
const { posIndex, callback } = this._pointObjects[key];
|
|
100
|
-
const { data0, data1, interpolated } = this._findAPoint(posIndex);
|
|
101
|
-
callback(data0, data1, interpolated);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_pushPointCallBackEmpty() {
|
|
106
|
-
for (const key in this._pointObjects) {
|
|
107
|
-
const { callback } = this._pointObjects[key];
|
|
108
|
-
callback(null, null, null);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
flush() {
|
|
113
|
-
this._pointObjects = {};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// function test() {
|
|
118
|
-
// const cp = window.plugin.getPointCoordinatesDataCalculator();
|
|
119
|
-
// const bbox = [-15, 25, 70, 60];
|
|
120
|
-
// cp.registerPoint("left up", -15, 60, (data0, data1, interpolated) => {
|
|
121
|
-
// console.log("left up", data0, data1, interpolated);
|
|
122
|
-
// });
|
|
123
|
-
// cp.registerPoint("right up", 70, 60, (data0, data1, interpolated) => {
|
|
124
|
-
// console.log("right up", data0, data1, interpolated);
|
|
125
|
-
// });
|
|
126
|
-
// cp.registerPoint("left down", -15, 25, (data0, data1, interpolated) => {
|
|
127
|
-
// console.log("right down", data0, data1, interpolated);
|
|
128
|
-
// });
|
|
129
|
-
// cp.registerPoint("right down", 70, 25, (data0, data1, interpolated) => {
|
|
130
|
-
// console.log("right down", data0, data1, interpolated);
|
|
131
|
-
// });
|
|
132
|
-
// return cp;
|
|
133
|
-
// }
|