@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,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const util_1 = require("../../util");
|
|
4
|
-
class default_1 {
|
|
5
|
-
constructor(gl) {
|
|
6
|
-
this.gl = gl;
|
|
7
|
-
// console.log("Float2LegendWithRatioProgram gl:", gl);
|
|
8
|
-
this._width = 1;
|
|
9
|
-
this._height = 1;
|
|
10
|
-
this._blendRatio = 0.0;
|
|
11
|
-
this.programWrapper = this._createProgramWrapper();
|
|
12
|
-
}
|
|
13
|
-
_createProgramWrapper() {
|
|
14
|
-
const vertexShaderSource = `#version 300 es
|
|
15
|
-
precision highp float;
|
|
16
|
-
|
|
17
|
-
in vec2 a_position;
|
|
18
|
-
out vec2 v_texcoord;
|
|
19
|
-
|
|
20
|
-
void main() {
|
|
21
|
-
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
22
|
-
v_texcoord = a_position * 0.5 + 0.5;
|
|
23
|
-
v_texcoord.y = 1.0 - v_texcoord.y;
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
26
|
-
const fragmentShaderSource = `#version 300 es
|
|
27
|
-
precision highp float;
|
|
28
|
-
|
|
29
|
-
in vec2 v_texcoord;
|
|
30
|
-
uniform sampler2D u_float_texture0;
|
|
31
|
-
uniform sampler2D u_float_texture1;
|
|
32
|
-
uniform sampler2D u_color_texture;
|
|
33
|
-
|
|
34
|
-
layout(std140) uniform HeatParametersBlock {
|
|
35
|
-
vec2 u_color_ramp_range; // x is min, y is range ( max - min)
|
|
36
|
-
vec2 u_min_max;
|
|
37
|
-
float u_escape_value;
|
|
38
|
-
float u_blend_ratio;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
out vec4 outColor;
|
|
42
|
-
|
|
43
|
-
void main() {
|
|
44
|
-
if ( u_blend_ratio < 0.0) {
|
|
45
|
-
outColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
float f0 = texture(u_float_texture0, v_texcoord).r;
|
|
49
|
-
float f1 = texture(u_float_texture1, v_texcoord).r;
|
|
50
|
-
// outColor = vec4(
|
|
51
|
-
|
|
52
|
-
if (f0 == u_escape_value || f1 == u_escape_value) {
|
|
53
|
-
outColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
float x = mix(f0, f1, u_blend_ratio);
|
|
57
|
-
if ( x < u_min_max.x || x > u_min_max.y) {
|
|
58
|
-
outColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
x = (x - u_color_ramp_range.x) / u_color_ramp_range.y;
|
|
62
|
-
outColor = texture(u_color_texture, vec2(x, 0.5));
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
const gl = this.gl;
|
|
66
|
-
const program = (0, util_1.createProgram)(gl, vertexShaderSource, fragmentShaderSource);
|
|
67
|
-
const vao = gl.createVertexArray();
|
|
68
|
-
gl.bindVertexArray(vao);
|
|
69
|
-
const buffer = gl.createBuffer();
|
|
70
|
-
this._buffer = buffer;
|
|
71
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
72
|
-
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
|
|
73
|
-
-1, -1,
|
|
74
|
-
1, -1,
|
|
75
|
-
1, 1,
|
|
76
|
-
-1, 1
|
|
77
|
-
]), gl.STATIC_DRAW);
|
|
78
|
-
const positionLocation = gl.getAttribLocation(program, "a_position");
|
|
79
|
-
gl.enableVertexAttribArray(positionLocation);
|
|
80
|
-
gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0);
|
|
81
|
-
gl.bindVertexArray(null);
|
|
82
|
-
this.heatParametersBlockBindingPoint = 0;
|
|
83
|
-
const heatParametersBlockIndex = gl.getUniformBlockIndex(program, "HeatParametersBlock");
|
|
84
|
-
gl.uniformBlockBinding(program, heatParametersBlockIndex, this.heatParametersBlockBindingPoint);
|
|
85
|
-
return {
|
|
86
|
-
program,
|
|
87
|
-
vao,
|
|
88
|
-
u_float_texture0: gl.getUniformLocation(program, "u_float_texture0"),
|
|
89
|
-
u_float_texture1: gl.getUniformLocation(program, "u_float_texture1"),
|
|
90
|
-
u_color_texture: gl.getUniformLocation(program, "u_color_texture"),
|
|
91
|
-
u_blend_ratio: gl.getUniformLocation(program, "u_blend_ratio"),
|
|
92
|
-
u_color_ramp_range: gl.getUniformLocation(program, "u_color_ramp_range"),
|
|
93
|
-
u_min_max: gl.getUniformLocation(program, "u_min_max"),
|
|
94
|
-
u_escape_value: gl.getUniformLocation(program, "u_escape_value")
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
getUniformBlockManager() {
|
|
98
|
-
return new HeatParametersBlockManager(this.gl);
|
|
99
|
-
}
|
|
100
|
-
draw(texture0, texture1, colorRampTexture, heatParametersBlockManager) {
|
|
101
|
-
const { gl, programWrapper } = this;
|
|
102
|
-
const { program, u_float_texture0, u_float_texture1, u_color_texture } = programWrapper;
|
|
103
|
-
gl.useProgram(program);
|
|
104
|
-
gl.bindVertexArray(programWrapper.vao);
|
|
105
|
-
gl.activeTexture(gl.TEXTURE1);
|
|
106
|
-
gl.bindTexture(gl.TEXTURE_2D, texture1);
|
|
107
|
-
gl.uniform1i(u_float_texture1, 1);
|
|
108
|
-
gl.activeTexture(gl.TEXTURE2);
|
|
109
|
-
gl.bindTexture(gl.TEXTURE_2D, colorRampTexture);
|
|
110
|
-
gl.uniform1i(u_color_texture, 2);
|
|
111
|
-
gl.activeTexture(gl.TEXTURE0);
|
|
112
|
-
gl.bindTexture(gl.TEXTURE_2D, texture0);
|
|
113
|
-
gl.uniform1i(u_float_texture0, 0);
|
|
114
|
-
heatParametersBlockManager.bind();
|
|
115
|
-
// clear output texture
|
|
116
|
-
gl.clearColor(0, 0, 0, 0);
|
|
117
|
-
gl.drawArrays(gl.TRIANGLE_FAN, 0, 4);
|
|
118
|
-
gl.bindVertexArray(null);
|
|
119
|
-
heatParametersBlockManager.unbind();
|
|
120
|
-
}
|
|
121
|
-
free() {
|
|
122
|
-
const gl = this.gl;
|
|
123
|
-
gl.deleteBuffer(this._buffer);
|
|
124
|
-
gl.deleteProgram(this.programWrapper.program);
|
|
125
|
-
gl.deleteVertexArray(this.programWrapper.vao);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
exports.default = default_1;
|
|
129
|
-
class HeatParametersBlockManager {
|
|
130
|
-
constructor(gl) {
|
|
131
|
-
this.gl = gl;
|
|
132
|
-
this.buffer = gl.createBuffer();
|
|
133
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, this.buffer);
|
|
134
|
-
gl.bufferData(gl.UNIFORM_BUFFER, 24, gl.DYNAMIC_DRAW);
|
|
135
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
136
|
-
}
|
|
137
|
-
/*
|
|
138
|
-
* @param {Array<number>} color_ramp_range [minValue,( maxValue - minValue)]
|
|
139
|
-
* @param {Array<number>} min_max [minEdge, maxEdge]
|
|
140
|
-
* @param {number} escape_value // value that will be ignored
|
|
141
|
-
* @param {number} blend_ratio // ratio of blending between two textures
|
|
142
|
-
* */
|
|
143
|
-
update({ color_ramp_range = null, min_max = null, escape_value = null, blend_ratio = null }) {
|
|
144
|
-
const { gl, buffer } = this;
|
|
145
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, buffer);
|
|
146
|
-
if (color_ramp_range) {
|
|
147
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array(color_ramp_range));
|
|
148
|
-
}
|
|
149
|
-
if (min_max) {
|
|
150
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 8, new Float32Array(min_max));
|
|
151
|
-
}
|
|
152
|
-
if (escape_value) {
|
|
153
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 16, new Float32Array([escape_value]));
|
|
154
|
-
}
|
|
155
|
-
if (blend_ratio) {
|
|
156
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 20, new Float32Array([blend_ratio]));
|
|
157
|
-
}
|
|
158
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
159
|
-
}
|
|
160
|
-
bind() {
|
|
161
|
-
const { gl, buffer } = this;
|
|
162
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.heatParametersBlockBindingPoint, buffer);
|
|
163
|
-
}
|
|
164
|
-
free() {
|
|
165
|
-
this.gl.deleteBuffer(this.buffer);
|
|
166
|
-
}
|
|
167
|
-
unbind() {
|
|
168
|
-
const { gl } = this;
|
|
169
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.heatParametersBlockBindingPoint, null);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
@@ -1,110 +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 logic_1 = __importDefault(require("./logic"));
|
|
7
|
-
const programcache_1 = require("../programcache");
|
|
8
|
-
// Uniform Buffer Objects use this
|
|
9
|
-
class DataObject {
|
|
10
|
-
constructor(gl, { width = 1, height = 1, texture0 = null, texture1 = null, colorRampTexture = null, colorRampRange = null, escapeValue = 99999, blendRatio = 0.0, minMaxEdges = null, } = {}) {
|
|
11
|
-
this.gl = gl;
|
|
12
|
-
this.programlogic = programcache_1.glProgramCache.getProgram(gl, logic_1.default);
|
|
13
|
-
this.heatParametersBlockManager = this.programlogic.getUniformBlockManager();
|
|
14
|
-
this.width = width;
|
|
15
|
-
this.height = height;
|
|
16
|
-
this.texture0 = texture0 || this._createColorRampTexture(width, height);
|
|
17
|
-
this.texture1 = texture1 || this._createColorRampTexture(width, height);
|
|
18
|
-
this.colorRampTexture = colorRampTexture || this._createColorRampTexture();
|
|
19
|
-
this.minMaxEdges = minMaxEdges || new Float32Array([-99999, 99999]);
|
|
20
|
-
this.heatParametersBlockManager.update({
|
|
21
|
-
escape_value: escapeValue,
|
|
22
|
-
blend_ratio: blendRatio,
|
|
23
|
-
min_max: minMaxEdges,
|
|
24
|
-
color_ramp_range: colorRampRange
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
_bindBlock() {
|
|
28
|
-
const gl = this.gl;
|
|
29
|
-
const program = this.programlogic.programWrapper.program;
|
|
30
|
-
gl.uniformBlockBinding(program, gl.getUniformBlockIndex(program, 'Block'), 0);
|
|
31
|
-
}
|
|
32
|
-
_createColorRampTexture() {
|
|
33
|
-
const { gl } = this;
|
|
34
|
-
const texture = gl.createTexture();
|
|
35
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
36
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
37
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
38
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
39
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
40
|
-
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
41
|
-
return texture;
|
|
42
|
-
}
|
|
43
|
-
setBlendRatio(ratio) {
|
|
44
|
-
if (ratio < 0 || ratio > 1) {
|
|
45
|
-
console.warn('Invalid blend ratio');
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
this.heatParametersBlockManager.update({ blend_ratio: ratio });
|
|
49
|
-
}
|
|
50
|
-
setEscapeValue(value) {
|
|
51
|
-
this.heatParametersBlockManager.update({ escape_value: value });
|
|
52
|
-
}
|
|
53
|
-
setTexture0(texture) {
|
|
54
|
-
this.texture0 = texture;
|
|
55
|
-
}
|
|
56
|
-
setTexture1(texture) {
|
|
57
|
-
this.texture1 = texture;
|
|
58
|
-
}
|
|
59
|
-
setColorRampTexture(texture) {
|
|
60
|
-
this.colorRampTexture = texture;
|
|
61
|
-
}
|
|
62
|
-
setDataWidthHeight(width, height) {
|
|
63
|
-
this.width = width;
|
|
64
|
-
this.height = height;
|
|
65
|
-
}
|
|
66
|
-
setFloatTextureData(data0, data1, width, height, yFlip = false) {
|
|
67
|
-
const { texture0, texture1, gl } = this;
|
|
68
|
-
gl.bindTexture(gl.TEXTURE_2D, texture0);
|
|
69
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, yFlip);
|
|
70
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.R16F, width, height, 0, gl.RED, gl.FLOAT, data0);
|
|
71
|
-
gl.bindTexture(gl.TEXTURE_2D, texture1);
|
|
72
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.R16F, width, height, 0, gl.RED, gl.FLOAT, data1);
|
|
73
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
74
|
-
}
|
|
75
|
-
discard() {
|
|
76
|
-
this.heatParametersBlockManager.update({ blend_ratio: -1 });
|
|
77
|
-
}
|
|
78
|
-
setColorRampTextureData(data, size) {
|
|
79
|
-
const { gl, colorRampTexture } = this;
|
|
80
|
-
gl.bindTexture(gl.TEXTURE_2D, colorRampTexture);
|
|
81
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);
|
|
82
|
-
}
|
|
83
|
-
setColorRampRange(min, max) {
|
|
84
|
-
if (min > max) {
|
|
85
|
-
console.warn('Invalid min max values');
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const range = max - min;
|
|
89
|
-
this.heatParametersBlockManager.update({ color_ramp_range: new Float32Array([min, range]) });
|
|
90
|
-
}
|
|
91
|
-
setMinMaxEdges(min, max) {
|
|
92
|
-
if (min)
|
|
93
|
-
this.minMaxEdges[0] = min;
|
|
94
|
-
if (max)
|
|
95
|
-
this.minMaxEdges[1] = max;
|
|
96
|
-
this.heatParametersBlockManager.update({ min_max: this.minMaxEdges });
|
|
97
|
-
}
|
|
98
|
-
draw() {
|
|
99
|
-
this.programlogic.draw(this.texture0, this.texture1, this.colorRampTexture, this.heatParametersBlockManager);
|
|
100
|
-
}
|
|
101
|
-
free() {
|
|
102
|
-
const { gl, texture0, texture1, colorRampTexture } = this;
|
|
103
|
-
gl.deleteTexture(texture0);
|
|
104
|
-
gl.deleteTexture(texture1);
|
|
105
|
-
gl.deleteTexture(colorRampTexture);
|
|
106
|
-
programcache_1.glProgramCache.releaseProgram(this.gl, logic_1.default);
|
|
107
|
-
this.heatParametersBlockManager.free();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
exports.default = DataObject;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const programcache_1 = require("../programcache");
|
|
4
|
-
class IsGlobeMoved {
|
|
5
|
-
constructor(globe) {
|
|
6
|
-
this.globe = globe;
|
|
7
|
-
this._lastLOD = globe.api_GetCurrentLODWithDecimal();
|
|
8
|
-
}
|
|
9
|
-
isMoved() {
|
|
10
|
-
const globe = this.globe;
|
|
11
|
-
if (globe.api_IsScreenMoving() || this._lastLOD != globe.api_GetCurrentLODWithDecimal()) {
|
|
12
|
-
this._lastLOD = globe.api_GetCurrentLODWithDecimal();
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const IsGlobeMovedCache = Object.freeze({
|
|
19
|
-
get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, IsGlobeMoved),
|
|
20
|
-
release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, IsGlobeMoved)
|
|
21
|
-
});
|
|
@@ -1,8 +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.GlobeShellWiggle = void 0;
|
|
7
|
-
const wiggle_1 = __importDefault(require("./globeshell/wiggle"));
|
|
8
|
-
exports.GlobeShellWiggle = wiggle_1.default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,8 +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.GlobeShellWiggle = void 0;
|
|
7
|
-
const object_1 = __importDefault(require("./object"));
|
|
8
|
-
exports.GlobeShellWiggle = object_1.default;
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const util_1 = require("../../../util");
|
|
4
|
-
class Logic {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.id = "GlobeShellProgram";
|
|
7
|
-
this.description = "This program implements flyweight pattern for globe." +
|
|
8
|
-
"At globes draw3D call stack, this program should be prior to any program that uses it." +
|
|
9
|
-
"draw3D method of this object only sets Projetion, ModelView and Translate matrices and if the mode is 2D mapWH .";
|
|
10
|
-
}
|
|
11
|
-
init(globe, gl) {
|
|
12
|
-
this.gl = gl;
|
|
13
|
-
this.globe = globe;
|
|
14
|
-
this.programWrapper = this._createProgramWrapper();
|
|
15
|
-
this._transformArray = new Float32Array(3);
|
|
16
|
-
this.setGeometry();
|
|
17
|
-
this.resize();
|
|
18
|
-
this.updateTime(0);
|
|
19
|
-
this.setMesh({ xRes: 64, yRes: 64, eastWestTied: false });
|
|
20
|
-
}
|
|
21
|
-
_createProgramWrapper() {
|
|
22
|
-
const vertexShader = `#version 300 es
|
|
23
|
-
#define R 6378.137
|
|
24
|
-
#define PI 3.1415926535897932384626433832795
|
|
25
|
-
#define POLE 20037508.34
|
|
26
|
-
#define POLE_BY_PI 6366198.2
|
|
27
|
-
#define HALF_PI 1.5707963267948966192313216916398
|
|
28
|
-
|
|
29
|
-
uniform vec2 u_mesh_resolution;
|
|
30
|
-
|
|
31
|
-
layout(std140) uniform ShellBlock {
|
|
32
|
-
vec2 u_grid_offset_rad;
|
|
33
|
-
vec2 u_grid_size_rad;
|
|
34
|
-
float u_height;
|
|
35
|
-
float u_wiggle;
|
|
36
|
-
float u_time;
|
|
37
|
-
float u_opacity;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
uniform mat4 u_model_view_matrix;
|
|
41
|
-
uniform mat4 u_projection_matrix;
|
|
42
|
-
uniform vec3 u_translate;
|
|
43
|
-
|
|
44
|
-
uniform vec2 u_mapWH;
|
|
45
|
-
uniform vec2 u_scrWH;
|
|
46
|
-
|
|
47
|
-
uniform bool u_is3D;
|
|
48
|
-
|
|
49
|
-
out float v_opacity;
|
|
50
|
-
out vec2 v_texture_coordinate;
|
|
51
|
-
|
|
52
|
-
vec2 f_texCoord(){
|
|
53
|
-
|
|
54
|
-
float x = mod( float(gl_VertexID), u_mesh_resolution.x ) / ( u_mesh_resolution.x - 1.0);
|
|
55
|
-
float y = floor( float(gl_VertexID) / u_mesh_resolution.x ) / ( u_mesh_resolution.y - 1.0);
|
|
56
|
-
return vec2(x, y);
|
|
57
|
-
//return vec2( fract( float(gl_VertexID) / u_mesh_resolution.x ), floor(float(gl_VertexID) / u_mesh_resolution.x) / u_mesh_resolution.y);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
vec3 f_onSphere(vec2 texCoord){
|
|
61
|
-
float vert = (texCoord.y * u_grid_size_rad.y ) + u_grid_offset_rad.y;
|
|
62
|
-
float hor = (texCoord.x * u_grid_size_rad.x ) + u_grid_offset_rad.x;
|
|
63
|
-
float x = sin(vert) * cos(hor);
|
|
64
|
-
float y = sin(vert) * sin(hor);
|
|
65
|
-
float z = cos(vert);
|
|
66
|
-
return vec3(x, y, z);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
vec2 f_onFlat(vec2 texCoord){
|
|
70
|
-
float x = (texCoord.x * u_grid_size_rad.x ) + u_grid_offset_rad.x;
|
|
71
|
-
float y = (texCoord.y * u_grid_size_rad.y ) + u_grid_offset_rad.y;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
float mercX = x * POLE_BY_PI;
|
|
75
|
-
float mercY = log(tan(HALF_PI - y / 2.0 )) * POLE_BY_PI;
|
|
76
|
-
|
|
77
|
-
float normX = ( mercX - u_translate.x ) / u_mapWH.x;
|
|
78
|
-
float normY = ( mercY - u_translate.y ) / u_mapWH.y;
|
|
79
|
-
return vec2(normX, normY);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
vec3 f_position(vec3 unit_sphere_pos, float wiggle){
|
|
83
|
-
return unit_sphere_pos * (R + u_height + wiggle);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
float f_wiggle(vec2 texCoord){
|
|
87
|
-
float s_contrib = 0.6*sin(texCoord.x*2.0*PI + 3.0*u_time);
|
|
88
|
-
float t_contrib = 0.8*cos(texCoord.y*4.1 + 5.0*u_time);
|
|
89
|
-
return u_wiggle * s_contrib * t_contrib * sin(texCoord.y*PI*2.0);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
void main() {
|
|
93
|
-
vec2 texCoord = f_texCoord();
|
|
94
|
-
if (u_is3D){
|
|
95
|
-
vec3 unit_sphere_pos = f_onSphere(texCoord);
|
|
96
|
-
float wiggle = f_wiggle(texCoord);
|
|
97
|
-
vec3 position = f_position(unit_sphere_pos, wiggle);
|
|
98
|
-
gl_Position = u_projection_matrix * u_model_view_matrix * vec4(position - u_translate, 1.0);
|
|
99
|
-
} else {
|
|
100
|
-
vec2 position = f_onFlat(texCoord);
|
|
101
|
-
gl_Position = u_projection_matrix * vec4(
|
|
102
|
-
position.x * u_scrWH.x,
|
|
103
|
-
(1.0 - position.y) * u_scrWH.y,
|
|
104
|
-
0.0,
|
|
105
|
-
1.0);
|
|
106
|
-
}
|
|
107
|
-
v_texture_coordinate = texCoord;
|
|
108
|
-
v_opacity = u_opacity;
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
const fragmentShader = `#version 300 es
|
|
112
|
-
precision lowp float;
|
|
113
|
-
in vec2 v_texture_coordinate;
|
|
114
|
-
in float v_opacity;
|
|
115
|
-
uniform sampler2D u_texture;
|
|
116
|
-
out vec4 outColor;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
void main() {
|
|
120
|
-
outColor = texture(u_texture, v_texture_coordinate);
|
|
121
|
-
outColor.a *= v_opacity;
|
|
122
|
-
}`;
|
|
123
|
-
const gl = this.gl;
|
|
124
|
-
const program = (0, util_1.createProgram)(gl, vertexShader, fragmentShader);
|
|
125
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
126
|
-
gl.useProgram(program);
|
|
127
|
-
this.shellBlockBindingPoint = 0;
|
|
128
|
-
const shellBlockIndex = gl.getUniformBlockIndex(program, "ShellBlock");
|
|
129
|
-
gl.uniformBlockBinding(program, shellBlockIndex, this.shellBlockBindingPoint);
|
|
130
|
-
gl.useProgram(currentProgram);
|
|
131
|
-
return {
|
|
132
|
-
program,
|
|
133
|
-
u_model_view_matrix: gl.getUniformLocation(program, "u_model_view_matrix"),
|
|
134
|
-
u_projection_matrix: gl.getUniformLocation(program, "u_projection_matrix"),
|
|
135
|
-
u_translate: gl.getUniformLocation(program, "u_translate"),
|
|
136
|
-
u_is3D: gl.getUniformLocation(program, "u_is3D"),
|
|
137
|
-
u_scrWH: gl.getUniformLocation(program, "u_scrWH"),
|
|
138
|
-
u_mapWH: gl.getUniformLocation(program, "u_mapWH"),
|
|
139
|
-
u_texture: gl.getUniformLocation(program, "u_texture"),
|
|
140
|
-
u_mesh_resolution: gl.getUniformLocation(program, "u_mesh_resolution"),
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
// this method implements data part of flyweight pattern
|
|
144
|
-
getShellBlockBufferManager() {
|
|
145
|
-
return new ShellBlockManager(this.gl);
|
|
146
|
-
}
|
|
147
|
-
updateTime(time) {
|
|
148
|
-
const { gl, programWrapper } = this;
|
|
149
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
150
|
-
gl.useProgram(programWrapper.program);
|
|
151
|
-
gl.uniform1f(this.programWrapper.u_time, time);
|
|
152
|
-
gl.useProgram(currentProgram);
|
|
153
|
-
}
|
|
154
|
-
setRotationAndTranslation(uProjectionMatrix, uModelViewMatrix, uTranslate, resetCurrentProgram = false) {
|
|
155
|
-
const gl = this.gl;
|
|
156
|
-
let currentProgram = null;
|
|
157
|
-
if (resetCurrentProgram) {
|
|
158
|
-
currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
159
|
-
}
|
|
160
|
-
;
|
|
161
|
-
gl.useProgram(this.programWrapper.program);
|
|
162
|
-
gl.uniformMatrix4fv(this.programWrapper.u_projection_matrix, false, uProjectionMatrix);
|
|
163
|
-
gl.uniformMatrix4fv(this.programWrapper.u_model_view_matrix, false, uModelViewMatrix);
|
|
164
|
-
this._transformArray.set([uTranslate.x, uTranslate.y, uTranslate.z], 0);
|
|
165
|
-
gl.uniform3fv(this.programWrapper.u_translate, this._transformArray);
|
|
166
|
-
if (resetCurrentProgram)
|
|
167
|
-
gl.useProgram(currentProgram);
|
|
168
|
-
}
|
|
169
|
-
setGeometry() {
|
|
170
|
-
const { globe, gl } = this;
|
|
171
|
-
const { u_is3D, u_scrWH, program } = this.programWrapper;
|
|
172
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
173
|
-
const is3D = this.globe.api_GetCurrentGeometry() === 0;
|
|
174
|
-
gl.useProgram(program);
|
|
175
|
-
if (globe.api_GetCurrentGeometry() === globe.api_GeometryTypes().FLAT) {
|
|
176
|
-
gl.uniform2f(u_scrWH, globe.api_ScrW(), globe.api_ScrH());
|
|
177
|
-
}
|
|
178
|
-
gl.uniform1i(u_is3D, is3D);
|
|
179
|
-
gl.useProgram(currentProgram);
|
|
180
|
-
}
|
|
181
|
-
resize() {
|
|
182
|
-
const { gl, globe } = this;
|
|
183
|
-
if (!globe)
|
|
184
|
-
return;
|
|
185
|
-
const { program, u_scrWH } = this.programWrapper;
|
|
186
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
187
|
-
gl.useProgram(program);
|
|
188
|
-
if (globe.api_GetCurrentGeometry() === globe.api_GeometryTypes().FLAT) {
|
|
189
|
-
gl.uniform2f(u_scrWH, globe.api_ScrW(), globe.api_ScrH());
|
|
190
|
-
}
|
|
191
|
-
gl.useProgram(currentProgram);
|
|
192
|
-
}
|
|
193
|
-
// only sets data does not draw
|
|
194
|
-
draw3D(uProjectionMatrix, uModelViewMatrix, uTranslate) {
|
|
195
|
-
const { gl, globe } = this;
|
|
196
|
-
const { program, u_model_view_matrix, u_projection_matrix, u_translate } = this.programWrapper;
|
|
197
|
-
gl.disable(gl.DEPTH_TEST);
|
|
198
|
-
gl.useProgram(program);
|
|
199
|
-
gl.uniformMatrix4fv(u_projection_matrix, false, uProjectionMatrix);
|
|
200
|
-
gl.uniformMatrix4fv(u_model_view_matrix, false, uModelViewMatrix);
|
|
201
|
-
// this._transformArray.set([], 0);
|
|
202
|
-
gl.uniform3f(u_translate, uTranslate.x, uTranslate.y, uTranslate.z);
|
|
203
|
-
if (globe.api_GetCurrentGeometry() === 1) {
|
|
204
|
-
const { width, height } = globe.api_GetCurrentWorldWH();
|
|
205
|
-
gl.uniform2fv(this.programWrapper.u_mapWH, [width, height]);
|
|
206
|
-
}
|
|
207
|
-
gl.enable(gl.DEPTH_TEST);
|
|
208
|
-
}
|
|
209
|
-
draw(texture, shellBlockDataManager, drawLines = false) {
|
|
210
|
-
const { gl, programWrapper, _vao, _drawCount } = this;
|
|
211
|
-
const { program, u_texture } = programWrapper;
|
|
212
|
-
gl.useProgram(program);
|
|
213
|
-
gl.bindVertexArray(_vao);
|
|
214
|
-
gl.activeTexture(gl.TEXTURE0);
|
|
215
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
216
|
-
gl.uniform1i(u_texture, 0);
|
|
217
|
-
shellBlockDataManager.bind();
|
|
218
|
-
if (drawLines)
|
|
219
|
-
gl.drawElements(gl.LINES, _drawCount, gl.UNSIGNED_SHORT, 0);
|
|
220
|
-
gl.clearColor(0, 0, 0, 0);
|
|
221
|
-
gl.drawElements(gl.TRIANGLES, _drawCount, gl.UNSIGNED_SHORT, 0);
|
|
222
|
-
shellBlockDataManager.unbind();
|
|
223
|
-
gl.bindVertexArray(null);
|
|
224
|
-
}
|
|
225
|
-
free() {
|
|
226
|
-
const { gl, programWrapper, _vao, _indexBuffer } = this;
|
|
227
|
-
gl.deleteBuffer(_indexBuffer);
|
|
228
|
-
gl.deleteVertexArray(_vao);
|
|
229
|
-
gl.deleteProgram(programWrapper.program);
|
|
230
|
-
}
|
|
231
|
-
setMesh({ xRes, yRes, eastWestTied }) {
|
|
232
|
-
this._xRes = xRes;
|
|
233
|
-
this._yRes = yRes;
|
|
234
|
-
const { _vao } = this._meshUP(xRes, yRes, eastWestTied);
|
|
235
|
-
this._vao = _vao;
|
|
236
|
-
this._setUMeshResolution(xRes, yRes);
|
|
237
|
-
}
|
|
238
|
-
_setUMeshResolution(xRes, yRes) {
|
|
239
|
-
const { gl, programWrapper } = this;
|
|
240
|
-
const { u_mesh_resolution } = programWrapper;
|
|
241
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
242
|
-
gl.useProgram(programWrapper.program);
|
|
243
|
-
gl.uniform2f(u_mesh_resolution, xRes, yRes);
|
|
244
|
-
gl.useProgram(currentProgram);
|
|
245
|
-
this._drawCount = 6 * ((xRes - 1) * (yRes - 1));
|
|
246
|
-
}
|
|
247
|
-
_meshUP(xRes, yRes, eastWestTied) {
|
|
248
|
-
this._drawCount = 6 * ((xRes - 1) * (yRes - 1));
|
|
249
|
-
const indices = new Uint16Array(this._drawCount);
|
|
250
|
-
{
|
|
251
|
-
let indicesIndex = 0;
|
|
252
|
-
let index = 0;
|
|
253
|
-
for (let j = 0; j < yRes - 1; j++) {
|
|
254
|
-
for (let i = 0; i < xRes - 1; i++) {
|
|
255
|
-
const ind = index + i;
|
|
256
|
-
indices[indicesIndex++] = ind + xRes;
|
|
257
|
-
indices[indicesIndex++] = ind + 1;
|
|
258
|
-
indices[indicesIndex++] = ind;
|
|
259
|
-
indices[indicesIndex++] = ind + xRes + 1;
|
|
260
|
-
indices[indicesIndex++] = ind + 1;
|
|
261
|
-
indices[indicesIndex++] = ind + xRes;
|
|
262
|
-
}
|
|
263
|
-
index += xRes;
|
|
264
|
-
}
|
|
265
|
-
if (eastWestTied) {
|
|
266
|
-
let left = (yRes - 1);
|
|
267
|
-
let right = 0;
|
|
268
|
-
for (let i = 0; i < xRes - 1; i++) {
|
|
269
|
-
indices[indicesIndex++] = left + xRes;
|
|
270
|
-
indices[indicesIndex++] = right;
|
|
271
|
-
indices[indicesIndex++] = left;
|
|
272
|
-
indices[indicesIndex++] = right + xRes;
|
|
273
|
-
indices[indicesIndex++] = right;
|
|
274
|
-
indices[indicesIndex++] = left + xRes;
|
|
275
|
-
left += xRes;
|
|
276
|
-
right += xRes;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
const gl = this.gl;
|
|
281
|
-
const _vao = gl.createVertexArray();
|
|
282
|
-
gl.bindVertexArray(_vao);
|
|
283
|
-
const indexBuffer = gl.createBuffer();
|
|
284
|
-
this._indexBuffer = indexBuffer;
|
|
285
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
286
|
-
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
|
|
287
|
-
gl.bindVertexArray(null);
|
|
288
|
-
return { _vao };
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
exports.default = Logic;
|
|
292
|
-
class ShellBlockManager {
|
|
293
|
-
constructor(gl) {
|
|
294
|
-
this.gl = gl;
|
|
295
|
-
this.buffer = gl.createBuffer();
|
|
296
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, this.buffer);
|
|
297
|
-
gl.bufferData(gl.UNIFORM_BUFFER, 32, gl.DYNAMIC_DRAW);
|
|
298
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
299
|
-
}
|
|
300
|
-
update({ gridSizeRad = null, gridOffsetRad = null, height = null, wiggleInKM = null, innerTime = null, opacity = null } = {}) {
|
|
301
|
-
const { gl, buffer } = this;
|
|
302
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, buffer);
|
|
303
|
-
if (gridOffsetRad !== null) {
|
|
304
|
-
const offset = new Float32Array(gridOffsetRad);
|
|
305
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 0, offset);
|
|
306
|
-
}
|
|
307
|
-
if (gridSizeRad !== null) {
|
|
308
|
-
const size = new Float32Array(gridSizeRad);
|
|
309
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 8, size);
|
|
310
|
-
}
|
|
311
|
-
if (height !== null) {
|
|
312
|
-
const heightArray = new Float32Array([height]);
|
|
313
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 16, heightArray);
|
|
314
|
-
}
|
|
315
|
-
if (wiggleInKM !== null) {
|
|
316
|
-
const wiggleArray = new Float32Array([wiggleInKM]);
|
|
317
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 20, wiggleArray);
|
|
318
|
-
}
|
|
319
|
-
if (innerTime !== null) {
|
|
320
|
-
const innerTimeArray = new Float32Array([innerTime]);
|
|
321
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 24, innerTimeArray);
|
|
322
|
-
}
|
|
323
|
-
if (opacity !== null) {
|
|
324
|
-
if (opacity < 0 || opacity > 1) {
|
|
325
|
-
console.warn('Invalid opacity value');
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
const op = new Float32Array([opacity]);
|
|
329
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 28, op);
|
|
330
|
-
}
|
|
331
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
332
|
-
}
|
|
333
|
-
bind() {
|
|
334
|
-
const { gl, buffer } = this;
|
|
335
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.shellBlockBindingPoint, buffer);
|
|
336
|
-
}
|
|
337
|
-
free() {
|
|
338
|
-
const { gl, buffer } = this;
|
|
339
|
-
gl.deleteBuffer(buffer);
|
|
340
|
-
}
|
|
341
|
-
unbind() {
|
|
342
|
-
const { gl } = this;
|
|
343
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.shellBlockBindingPoint, null);
|
|
344
|
-
}
|
|
345
|
-
}
|