@pirireis/webglobeplugins 0.9.11 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Math/angle-calculation.js +8 -8
- package/Math/arc.js +18 -18
- package/Math/bounds/line-bbox.js +78 -80
- package/Math/constants.js +3 -3
- package/Math/juction/arc-plane.js +23 -23
- package/Math/juction/line-sphere.js +11 -11
- package/Math/juction/plane-plane.js +11 -11
- package/Math/line.js +14 -16
- package/Math/methods.js +65 -70
- package/Math/plane.js +16 -18
- package/Math/quaternion.js +45 -49
- package/Math/utils.js +2 -2
- package/Math/vec3.js +42 -45
- package/algorithms/search-binary.js +4 -4
- package/altitude-locator/draw-subset-obj.js +7 -8
- package/altitude-locator/plugin.js +98 -114
- package/arrowfield/adaptor.js +3 -4
- package/arrowfield/index.js +2 -2
- package/arrowfield/plugin.js +62 -65
- package/bearing-line/index.js +1 -1
- package/bearing-line/plugin.js +200 -226
- package/circle-line-chain/chain-list-map.js +82 -88
- package/circle-line-chain/plugin.js +134 -165
- package/circle-line-chain/util.js +1 -1
- package/compass-rose/compass-rose-padding-flat.js +108 -133
- package/compass-rose/compass-text-writer.js +62 -70
- package/compass-rose/index.js +2 -2
- package/compassrose/compassrose.js +46 -50
- package/compassrose/index.js +1 -1
- package/heatwave/index.js +2 -2
- package/heatwave/isobar/objectarraylabels.js +44 -48
- package/heatwave/isobar/plugin.js +104 -123
- package/heatwave/isobar/quadtreecontours.js +76 -92
- package/heatwave/plugins/heatwaveglobeshell.js +69 -87
- package/index.js +11 -11
- package/package.json +1 -1
- package/partialrings/buffer-manager.js +32 -64
- package/partialrings/index.js +1 -1
- package/partialrings/plugin.js +48 -84
- package/partialrings/program.js +136 -47
- package/pin/pin-object-array.js +83 -86
- package/pin/pin-point-totem.js +21 -22
- package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
- package/point-heat-map/plugin-webworker.js +40 -45
- package/point-heat-map/point-to-heat-map-flow.js +40 -42
- package/point-tracks/key-methods.js +1 -1
- package/point-tracks/plugin.js +137 -162
- package/programs/arrowfield/index.js +1 -1
- package/programs/arrowfield/logic.js +170 -62
- package/programs/arrowfield/object.js +33 -35
- package/programs/data2legend/density-to-legend.js +45 -21
- package/programs/data2legend/point-to-density-texture.js +52 -27
- package/programs/float2legendwithratio/index.js +1 -1
- package/programs/float2legendwithratio/logic.js +88 -42
- package/programs/float2legendwithratio/object.js +43 -46
- package/programs/globe-util/is-globe-moved.js +10 -11
- package/programs/globeshell/index.js +1 -1
- package/programs/globeshell/wiggle/index.js +1 -1
- package/programs/globeshell/wiggle/logic.js +191 -98
- package/programs/globeshell/wiggle/object.js +33 -35
- package/programs/helpers/blender/program.js +36 -19
- package/programs/helpers/fadeaway/index.js +1 -1
- package/programs/helpers/fadeaway/logic.js +35 -13
- package/programs/helpers/fadeaway/object.js +9 -10
- package/programs/helpers/index.js +1 -1
- package/programs/index.js +8 -8
- package/programs/line-on-globe/angled-line.js +91 -32
- package/programs/line-on-globe/circle-accurate-3d.js +82 -32
- package/programs/line-on-globe/circle-accurate-flat.js +108 -50
- package/programs/line-on-globe/circle-accurate.js +103 -33
- package/programs/line-on-globe/circle.js +97 -32
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +83 -33
- package/programs/line-on-globe/lines-color-instanced-flat.js +79 -34
- package/programs/line-on-globe/linestrip.js +111 -45
- package/programs/line-on-globe/naive-accurate-flexible.js +120 -50
- package/programs/line-on-globe/to-the-surface.js +58 -29
- package/programs/line-on-globe/util.js +1 -1
- package/programs/picking/pickable-renderer.js +117 -33
- package/programs/point-on-globe/element-globe-surface-glow.js +78 -38
- package/programs/point-on-globe/element-point-glow.js +103 -35
- package/programs/point-on-globe/square-pixel-point.js +76 -27
- package/programs/programcache.js +13 -13
- package/programs/rings/distancering/circleflatprogram.js +63 -21
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +156 -145
- package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -197
- package/programs/rings/distancering/index.js +4 -4
- package/programs/rings/distancering/paddyflatprogram.js +73 -20
- package/programs/rings/distancering/paddyflatprogram2d.js +75 -22
- package/programs/rings/distancering/paddyflatprogram3d.js +73 -20
- package/programs/rings/partial-ring/piece-of-pie.js +137 -35
- package/programs/totems/camerauniformblock.js +64 -51
- package/programs/totems/canvas-webglobe-info.js +48 -40
- package/programs/totems/gpu-selection-uniform-block.js +44 -40
- package/programs/totems/index.js +1 -1
- package/programs/two-d/pixel-padding-for-compass.js +90 -29
- package/programs/util.js +6 -7
- package/programs/vectorfields/index.js +1 -1
- package/programs/vectorfields/logics/drawrectangleparticles.js +70 -29
- package/programs/vectorfields/logics/index.js +3 -3
- package/programs/vectorfields/logics/pixelbased.js +91 -35
- package/programs/vectorfields/logics/ubo.js +31 -25
- package/programs/vectorfields/pingpongbuffermanager.js +30 -34
- package/rangerings/index.js +4 -4
- package/rangerings/plugin.js +202 -258
- package/rangerings/rangeringangletext.js +108 -120
- package/rangerings/ring-account.js +52 -69
- package/shaders/fragment-toy/firework.js +55 -1
- package/shaders/fragment-toy/singularity.js +55 -1
- package/timetracks/adaptors-line-strip.js +26 -37
- package/timetracks/adaptors.js +47 -61
- package/timetracks/index.js +4 -4
- package/timetracks/plugin-line-strip.js +63 -71
- package/timetracks/plugin.js +69 -77
- package/timetracks/program-line-strip.js +296 -103
- package/timetracks/program.js +419 -113
- package/timetracks/programpoint-line-strip.js +97 -44
- package/timetracks/programpoint.js +90 -44
- package/util/account/bufferoffsetmanager.js +72 -95
- package/util/account/index.js +1 -1
- package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -44
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -94
- package/util/account/single-attribute-buffer-management/index.js +3 -3
- package/util/account/single-attribute-buffer-management/object-store.js +29 -30
- package/util/account/util.js +2 -4
- package/util/algorithms/search-binary.js +4 -4
- package/util/check/get.js +5 -5
- package/util/check/typecheck.js +13 -15
- package/util/geometry/index.js +9 -11
- package/util/gl-util/buffer/attribute-loader.js +8 -20
- package/util/gl-util/buffer/index.js +1 -1
- package/util/gl-util/draw-options/methods.js +8 -9
- package/util/gl-util/uniform-block/manager.js +67 -67
- package/util/heatwavedatamanager/datamanager.js +56 -116
- package/util/heatwavedatamanager/index.js +2 -2
- package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +37 -40
- package/util/heatwavedatamanager/pointcoordsmeta.js +9 -10
- package/util/index.js +6 -6
- package/util/interpolation/timetrack/index.js +1 -1
- package/util/interpolation/timetrack/timetrack-interpolator.js +27 -29
- package/util/interpolation/timetrack/web-worker-str.js +179 -1
- package/util/interpolation/timetrack/web-worker.js +4 -4
- package/util/jshelpers/data-filler.js +7 -7
- package/util/jshelpers/timefilters.js +7 -7
- package/util/picking/fence.js +7 -7
- package/util/picking/picker-displayer.js +46 -52
- package/util/programs/draw-texture-on-canvas.js +39 -21
- package/util/programs/shapesonglobe.js +104 -64
- package/util/programs/supersampletotextures.js +45 -39
- package/util/programs/texturetoglobe.js +98 -48
- package/util/shaderfunctions/geometrytransformations.js +322 -27
- package/util/shaderfunctions/nodata.js +7 -1
- package/util/shaderfunctions/noisefunctions.js +39 -9
- package/util/surface-line-data/arcs-to-cuts.js +20 -23
- package/util/webglobe/rasteroverlay.js +35 -37
- package/util/webglobjectbuilders.js +55 -60
- package/util/webglobjectbuilders1.js +48 -49
- package/waveparticles/adaptor.js +6 -7
- package/waveparticles/index.js +2 -2
- package/waveparticles/plugin.js +79 -84
- package/wind/imagetovectorfieldandmagnitude.js +15 -15
- package/wind/index.js +4 -4
- package/wind/plugin.js +453 -251
- package/wind/vectorfieldimage.js +5 -5
- package/write-text/attached-text-writer.js +46 -48
- package/write-text/context-text.js +51 -58
- package/write-text/context-text3.js +69 -74
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const util_1 = require("../../../util");
|
|
4
|
+
class Logic {
|
|
5
|
+
constructor() {
|
|
6
6
|
this.id = "GlobeShellProgram";
|
|
7
7
|
this.description = "This program implements flyweight pattern for globe." +
|
|
8
8
|
"At globes draw3D call stack, this program should be prior to any program that uses it." +
|
|
9
9
|
"draw3D method of this object only sets Projetion, ModelView and Translate matrices and if the mode is 2D mapWH .";
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
init(globe, gl) {
|
|
12
12
|
this.gl = gl;
|
|
13
13
|
this.globe = globe;
|
|
14
14
|
this.programWrapper = this._createProgramWrapper();
|
|
@@ -17,20 +17,119 @@ var Logic = /** @class */ (function () {
|
|
|
17
17
|
this.resize();
|
|
18
18
|
this.updateTime(0);
|
|
19
19
|
this.setMesh({ xRes: 64, yRes: 64, eastWestTied: false });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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);
|
|
27
126
|
gl.useProgram(program);
|
|
28
127
|
this.shellBlockBindingPoint = 0;
|
|
29
|
-
|
|
128
|
+
const shellBlockIndex = gl.getUniformBlockIndex(program, "ShellBlock");
|
|
30
129
|
gl.uniformBlockBinding(program, shellBlockIndex, this.shellBlockBindingPoint);
|
|
31
130
|
gl.useProgram(currentProgram);
|
|
32
131
|
return {
|
|
33
|
-
program
|
|
132
|
+
program,
|
|
34
133
|
u_model_view_matrix: gl.getUniformLocation(program, "u_model_view_matrix"),
|
|
35
134
|
u_projection_matrix: gl.getUniformLocation(program, "u_projection_matrix"),
|
|
36
135
|
u_translate: gl.getUniformLocation(program, "u_translate"),
|
|
@@ -40,22 +139,21 @@ var Logic = /** @class */ (function () {
|
|
|
40
139
|
u_texture: gl.getUniformLocation(program, "u_texture"),
|
|
41
140
|
u_mesh_resolution: gl.getUniformLocation(program, "u_mesh_resolution"),
|
|
42
141
|
};
|
|
43
|
-
}
|
|
142
|
+
}
|
|
44
143
|
// this method implements data part of flyweight pattern
|
|
45
|
-
|
|
144
|
+
getShellBlockBufferManager() {
|
|
46
145
|
return new ShellBlockManager(this.gl);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
146
|
+
}
|
|
147
|
+
updateTime(time) {
|
|
148
|
+
const { gl, programWrapper } = this;
|
|
149
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
51
150
|
gl.useProgram(programWrapper.program);
|
|
52
151
|
gl.uniform1f(this.programWrapper.u_time, time);
|
|
53
152
|
gl.useProgram(currentProgram);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var currentProgram = null;
|
|
153
|
+
}
|
|
154
|
+
setRotationAndTranslation(uProjectionMatrix, uModelViewMatrix, uTranslate, resetCurrentProgram = false) {
|
|
155
|
+
const gl = this.gl;
|
|
156
|
+
let currentProgram = null;
|
|
59
157
|
if (resetCurrentProgram) {
|
|
60
158
|
currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
61
159
|
}
|
|
@@ -67,35 +165,35 @@ var Logic = /** @class */ (function () {
|
|
|
67
165
|
gl.uniform3fv(this.programWrapper.u_translate, this._transformArray);
|
|
68
166
|
if (resetCurrentProgram)
|
|
69
167
|
gl.useProgram(currentProgram);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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;
|
|
76
174
|
gl.useProgram(program);
|
|
77
175
|
if (globe.api_GetCurrentGeometry() === globe.api_GeometryTypes().FLAT) {
|
|
78
176
|
gl.uniform2f(u_scrWH, globe.api_ScrW(), globe.api_ScrH());
|
|
79
177
|
}
|
|
80
178
|
gl.uniform1i(u_is3D, is3D);
|
|
81
179
|
gl.useProgram(currentProgram);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
180
|
+
}
|
|
181
|
+
resize() {
|
|
182
|
+
const { gl, globe } = this;
|
|
85
183
|
if (!globe)
|
|
86
184
|
return;
|
|
87
|
-
|
|
88
|
-
|
|
185
|
+
const { program, u_scrWH } = this.programWrapper;
|
|
186
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
89
187
|
gl.useProgram(program);
|
|
90
188
|
if (globe.api_GetCurrentGeometry() === globe.api_GeometryTypes().FLAT) {
|
|
91
189
|
gl.uniform2f(u_scrWH, globe.api_ScrW(), globe.api_ScrH());
|
|
92
190
|
}
|
|
93
191
|
gl.useProgram(currentProgram);
|
|
94
|
-
}
|
|
192
|
+
}
|
|
95
193
|
// only sets data does not draw
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
194
|
+
draw3D(uProjectionMatrix, uModelViewMatrix, uTranslate) {
|
|
195
|
+
const { gl, globe } = this;
|
|
196
|
+
const { program, u_model_view_matrix, u_projection_matrix, u_translate } = this.programWrapper;
|
|
99
197
|
gl.disable(gl.DEPTH_TEST);
|
|
100
198
|
gl.useProgram(program);
|
|
101
199
|
gl.uniformMatrix4fv(u_projection_matrix, false, uProjectionMatrix);
|
|
@@ -103,15 +201,14 @@ var Logic = /** @class */ (function () {
|
|
|
103
201
|
// this._transformArray.set([], 0);
|
|
104
202
|
gl.uniform3f(u_translate, uTranslate.x, uTranslate.y, uTranslate.z);
|
|
105
203
|
if (globe.api_GetCurrentGeometry() === 1) {
|
|
106
|
-
|
|
204
|
+
const { width, height } = globe.api_GetCurrentWorldWH();
|
|
107
205
|
gl.uniform2fv(this.programWrapper.u_mapWH, [width, height]);
|
|
108
206
|
}
|
|
109
207
|
gl.enable(gl.DEPTH_TEST);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var program = programWrapper.program, u_texture = programWrapper.u_texture;
|
|
208
|
+
}
|
|
209
|
+
draw(texture, shellBlockDataManager, drawLines = false) {
|
|
210
|
+
const { gl, programWrapper, _vao, _drawCount } = this;
|
|
211
|
+
const { program, u_texture } = programWrapper;
|
|
115
212
|
gl.useProgram(program);
|
|
116
213
|
gl.bindVertexArray(_vao);
|
|
117
214
|
gl.activeTexture(gl.TEXTURE0);
|
|
@@ -124,39 +221,38 @@ var Logic = /** @class */ (function () {
|
|
|
124
221
|
gl.drawElements(gl.TRIANGLES, _drawCount, gl.UNSIGNED_SHORT, 0);
|
|
125
222
|
shellBlockDataManager.unbind();
|
|
126
223
|
gl.bindVertexArray(null);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
224
|
+
}
|
|
225
|
+
free() {
|
|
226
|
+
const { gl, programWrapper, _vao, _indexBuffer } = this;
|
|
130
227
|
gl.deleteBuffer(_indexBuffer);
|
|
131
228
|
gl.deleteVertexArray(_vao);
|
|
132
229
|
gl.deleteProgram(programWrapper.program);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
var xRes = _a.xRes, yRes = _a.yRes, eastWestTied = _a.eastWestTied;
|
|
230
|
+
}
|
|
231
|
+
setMesh({ xRes, yRes, eastWestTied }) {
|
|
136
232
|
this._xRes = xRes;
|
|
137
233
|
this._yRes = yRes;
|
|
138
|
-
|
|
234
|
+
const { _vao } = this._meshUP(xRes, yRes, eastWestTied);
|
|
139
235
|
this._vao = _vao;
|
|
140
236
|
this._setUMeshResolution(xRes, yRes);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
237
|
+
}
|
|
238
|
+
_setUMeshResolution(xRes, yRes) {
|
|
239
|
+
const { gl, programWrapper } = this;
|
|
240
|
+
const { u_mesh_resolution } = programWrapper;
|
|
241
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
146
242
|
gl.useProgram(programWrapper.program);
|
|
147
243
|
gl.uniform2f(u_mesh_resolution, xRes, yRes);
|
|
148
244
|
gl.useProgram(currentProgram);
|
|
149
245
|
this._drawCount = 6 * ((xRes - 1) * (yRes - 1));
|
|
150
|
-
}
|
|
151
|
-
|
|
246
|
+
}
|
|
247
|
+
_meshUP(xRes, yRes, eastWestTied) {
|
|
152
248
|
this._drawCount = 6 * ((xRes - 1) * (yRes - 1));
|
|
153
|
-
|
|
249
|
+
const indices = new Uint16Array(this._drawCount);
|
|
154
250
|
{
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
for (
|
|
158
|
-
for (
|
|
159
|
-
|
|
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;
|
|
160
256
|
indices[indicesIndex++] = ind + xRes;
|
|
161
257
|
indices[indicesIndex++] = ind + 1;
|
|
162
258
|
indices[indicesIndex++] = ind;
|
|
@@ -167,9 +263,9 @@ var Logic = /** @class */ (function () {
|
|
|
167
263
|
index += xRes;
|
|
168
264
|
}
|
|
169
265
|
if (eastWestTied) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
for (
|
|
266
|
+
let left = (yRes - 1);
|
|
267
|
+
let right = 0;
|
|
268
|
+
for (let i = 0; i < xRes - 1; i++) {
|
|
173
269
|
indices[indicesIndex++] = left + xRes;
|
|
174
270
|
indices[indicesIndex++] = right;
|
|
175
271
|
indices[indicesIndex++] = left;
|
|
@@ -181,49 +277,47 @@ var Logic = /** @class */ (function () {
|
|
|
181
277
|
}
|
|
182
278
|
}
|
|
183
279
|
}
|
|
184
|
-
|
|
185
|
-
|
|
280
|
+
const gl = this.gl;
|
|
281
|
+
const _vao = gl.createVertexArray();
|
|
186
282
|
gl.bindVertexArray(_vao);
|
|
187
|
-
|
|
283
|
+
const indexBuffer = gl.createBuffer();
|
|
188
284
|
this._indexBuffer = indexBuffer;
|
|
189
285
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
|
190
286
|
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
|
|
191
287
|
gl.bindVertexArray(null);
|
|
192
|
-
return { _vao
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
}());
|
|
288
|
+
return { _vao };
|
|
289
|
+
}
|
|
290
|
+
}
|
|
196
291
|
exports.default = Logic;
|
|
197
|
-
|
|
198
|
-
|
|
292
|
+
class ShellBlockManager {
|
|
293
|
+
constructor(gl) {
|
|
199
294
|
this.gl = gl;
|
|
200
295
|
this.buffer = gl.createBuffer();
|
|
201
296
|
gl.bindBuffer(gl.UNIFORM_BUFFER, this.buffer);
|
|
202
297
|
gl.bufferData(gl.UNIFORM_BUFFER, 32, gl.DYNAMIC_DRAW);
|
|
203
298
|
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
204
299
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
var _j = this, gl = _j.gl, buffer = _j.buffer;
|
|
300
|
+
update({ gridSizeRad = null, gridOffsetRad = null, height = null, wiggleInKM = null, innerTime = null, opacity = null } = {}) {
|
|
301
|
+
const { gl, buffer } = this;
|
|
208
302
|
gl.bindBuffer(gl.UNIFORM_BUFFER, buffer);
|
|
209
303
|
if (gridOffsetRad !== null) {
|
|
210
|
-
|
|
304
|
+
const offset = new Float32Array(gridOffsetRad);
|
|
211
305
|
gl.bufferSubData(gl.UNIFORM_BUFFER, 0, offset);
|
|
212
306
|
}
|
|
213
307
|
if (gridSizeRad !== null) {
|
|
214
|
-
|
|
308
|
+
const size = new Float32Array(gridSizeRad);
|
|
215
309
|
gl.bufferSubData(gl.UNIFORM_BUFFER, 8, size);
|
|
216
310
|
}
|
|
217
311
|
if (height !== null) {
|
|
218
|
-
|
|
312
|
+
const heightArray = new Float32Array([height]);
|
|
219
313
|
gl.bufferSubData(gl.UNIFORM_BUFFER, 16, heightArray);
|
|
220
314
|
}
|
|
221
315
|
if (wiggleInKM !== null) {
|
|
222
|
-
|
|
316
|
+
const wiggleArray = new Float32Array([wiggleInKM]);
|
|
223
317
|
gl.bufferSubData(gl.UNIFORM_BUFFER, 20, wiggleArray);
|
|
224
318
|
}
|
|
225
319
|
if (innerTime !== null) {
|
|
226
|
-
|
|
320
|
+
const innerTimeArray = new Float32Array([innerTime]);
|
|
227
321
|
gl.bufferSubData(gl.UNIFORM_BUFFER, 24, innerTimeArray);
|
|
228
322
|
}
|
|
229
323
|
if (opacity !== null) {
|
|
@@ -231,22 +325,21 @@ var ShellBlockManager = /** @class */ (function () {
|
|
|
231
325
|
console.warn('Invalid opacity value');
|
|
232
326
|
return;
|
|
233
327
|
}
|
|
234
|
-
|
|
328
|
+
const op = new Float32Array([opacity]);
|
|
235
329
|
gl.bufferSubData(gl.UNIFORM_BUFFER, 28, op);
|
|
236
330
|
}
|
|
237
331
|
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
332
|
+
}
|
|
333
|
+
bind() {
|
|
334
|
+
const { gl, buffer } = this;
|
|
241
335
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.shellBlockBindingPoint, buffer);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
336
|
+
}
|
|
337
|
+
free() {
|
|
338
|
+
const { gl, buffer } = this;
|
|
245
339
|
gl.deleteBuffer(buffer);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
340
|
+
}
|
|
341
|
+
unbind() {
|
|
342
|
+
const { gl } = this;
|
|
249
343
|
gl.bindBufferBase(gl.UNIFORM_BUFFER, this.shellBlockBindingPoint, null);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
}());
|
|
344
|
+
}
|
|
345
|
+
}
|
|
@@ -3,72 +3,70 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const programcache_1 = require("../../programcache");
|
|
7
|
+
const logic_1 = __importDefault(require("./logic"));
|
|
8
|
+
class GlobeShell {
|
|
9
|
+
constructor(gl, globe, { minLon = -180, maxLon = 180, minLat = -90, maxLat = 90, height = 0, u_opacity = 1, wiggleInKM = 0, wiggleSpeed = 0,
|
|
10
|
+
// eastWestTied, Not implemented yet
|
|
11
|
+
} = {}) {
|
|
11
12
|
this.gl = gl;
|
|
12
13
|
this.globe = globe;
|
|
13
14
|
this.program = programcache_1.globeProgramCache.getProgram(globe, logic_1.default);
|
|
14
15
|
this.shellBlockManager = this.program.getShellBlockBufferManager();
|
|
15
16
|
this.update = this.shellBlockManager.update.bind(this.shellBlockManager);
|
|
16
17
|
this.innerTime = 0;
|
|
17
|
-
this.setBBox({ minLon
|
|
18
|
+
this.setBBox({ minLon, maxLon, minLat, maxLat });
|
|
18
19
|
this.setOpacity(u_opacity);
|
|
19
20
|
this.setHeight(height);
|
|
20
|
-
this.setWiggle({ wiggleSpeed
|
|
21
|
+
this.setWiggle({ wiggleSpeed, wiggleInKM });
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
setTexture(texture) {
|
|
23
24
|
this.texture = texture;
|
|
24
25
|
this.globe.DrawRender();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
this.shellBlockManager.update({ height
|
|
26
|
+
}
|
|
27
|
+
setHeight(height) {
|
|
28
|
+
this.shellBlockManager.update({ height });
|
|
28
29
|
this.globe.DrawRender();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
this.shellBlockManager.update({ opacity
|
|
30
|
+
}
|
|
31
|
+
setOpacity(opacity) {
|
|
32
|
+
this.shellBlockManager.update({ opacity });
|
|
32
33
|
this.globe.DrawRender();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.bbox = { minLon: minLon, maxLon: maxLon, minLat: minLat, maxLat: maxLat };
|
|
34
|
+
}
|
|
35
|
+
setBBox({ minLon = -180, maxLon = 180, minLat = -90, maxLat = 90 } = {}) {
|
|
36
|
+
this.bbox = { minLon, maxLon, minLat, maxLat };
|
|
37
37
|
// x
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const horOffset = (minLon) * Math.PI / 180;
|
|
39
|
+
const horSize = (maxLon - minLon) * Math.PI / 180;
|
|
40
40
|
// y
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const vertOffset = (90 - maxLat) * Math.PI / 180;
|
|
42
|
+
const vertSize = (maxLat - minLat) * Math.PI / 180;
|
|
43
|
+
const offset_rad = new Float32Array([horOffset, vertOffset]);
|
|
44
|
+
const size_rad = new Float32Array([horSize, vertSize]);
|
|
45
45
|
this.shellBlockManager.update({ gridSizeRad: size_rad, gridOffsetRad: offset_rad });
|
|
46
46
|
this.globe.DrawRender();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
var _b = _a.wiggleSpeed, wiggleSpeed = _b === void 0 ? null : _b, _c = _a.wiggleInKM, wiggleInKM = _c === void 0 ? null : _c;
|
|
47
|
+
}
|
|
48
|
+
setWiggle({ wiggleSpeed = null, wiggleInKM = null }) {
|
|
50
49
|
if (wiggleInKM !== null)
|
|
51
50
|
this.wiggleInKM = wiggleInKM;
|
|
52
51
|
if (wiggleSpeed !== null)
|
|
53
52
|
this.wiggleSpeed = wiggleSpeed;
|
|
54
|
-
this.shellBlockManager.update({ wiggleInKM
|
|
55
|
-
}
|
|
53
|
+
this.shellBlockManager.update({ wiggleInKM });
|
|
54
|
+
}
|
|
56
55
|
/**
|
|
57
56
|
*
|
|
58
57
|
* @param {*} program modelView, projection, translate, mapWH, scrWH, should be set before calling this function
|
|
59
58
|
*/
|
|
60
|
-
|
|
59
|
+
draw() {
|
|
61
60
|
this.program.draw(this.texture, this.shellBlockManager);
|
|
62
61
|
if (this.wiggleInKM > 0 && this.wiggleSpeed > 0) {
|
|
63
62
|
this.innerTime += this.wiggleSpeed;
|
|
64
63
|
this.shellBlockManager.update({ innerTime: this.innerTime });
|
|
65
64
|
this.globe.DrawRender();
|
|
66
65
|
}
|
|
67
|
-
}
|
|
68
|
-
|
|
66
|
+
}
|
|
67
|
+
free() {
|
|
69
68
|
programcache_1.globeProgramCache.releaseProgram(this.globe, logic_1.default);
|
|
70
69
|
this.shellBlockManager.free();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}());
|
|
70
|
+
}
|
|
71
|
+
}
|
|
74
72
|
exports.default = GlobeShell;
|
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const util_1 = require("../util");
|
|
4
4
|
/**
|
|
5
5
|
* Blends two float32textures with given ratio.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const vertexShader = `#version 300 es
|
|
8
|
+
in vec2 a_position;
|
|
9
|
+
out vec2 v_texCoord;
|
|
10
|
+
void main() {
|
|
11
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
12
|
+
v_texCoord = a_position * 0.5 + 0.5;
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
const fragmentShader = `#version 300 es
|
|
16
|
+
uniform sampler2D u_texture0;
|
|
17
|
+
uniform sampler2D u_texture1;
|
|
18
|
+
uniform float u_ratio;
|
|
19
|
+
in v_texCoord;
|
|
20
|
+
out vec4 outColor;
|
|
21
|
+
void main() {
|
|
22
|
+
vec4 color0 = texture(u_texture0, v_texCoord);
|
|
23
|
+
vec4 color1 = texture(u_texture1, v_texCoord);
|
|
24
|
+
outColor = mix(color0, color1, u_ratio);
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
class BlenderProgram {
|
|
28
|
+
constructor(gl) {
|
|
11
29
|
this.gl = gl;
|
|
12
30
|
this.programWrapper = this._createProgramWrapper();
|
|
13
31
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
32
|
+
_craeteProgramWrapper() {
|
|
33
|
+
const gl = this.gl;
|
|
34
|
+
const program = (0, util_1.createProgram)(gl, vertexShader, fragmentShader);
|
|
17
35
|
this.vao = gl.createVertexArray();
|
|
18
36
|
gl.bindVertexArray(this.vao);
|
|
19
37
|
this._buffer = gl.createBuffer();
|
|
@@ -30,10 +48,10 @@ var BlenderProgram = /** @class */ (function () {
|
|
|
30
48
|
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
|
|
31
49
|
gl.bindVertexArray(null);
|
|
32
50
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
33
|
-
return { program
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
return { program, uniforms: { u_texture0: gl.getUniformLocation(program, 'u_texture0'), u_texture1: gl.getUniformLocation(program, 'u_texture1'), u_ratio: gl.getUniformLocation(program, 'u_ratio') } };
|
|
52
|
+
}
|
|
53
|
+
draw(ratio, texture0, texture1) {
|
|
54
|
+
const gl = this.gl;
|
|
37
55
|
gl.useProgram(this.programWrapper.program);
|
|
38
56
|
gl.bindVertexArray(this.vao);
|
|
39
57
|
gl.activeTexture(gl.TEXTURE1);
|
|
@@ -45,10 +63,10 @@ var BlenderProgram = /** @class */ (function () {
|
|
|
45
63
|
gl.uniform1f(this.programWrapper.uniforms.u_ratio, ratio);
|
|
46
64
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
47
65
|
gl.bindVertexArray(null);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
}
|
|
67
|
+
createFloat32Texture(width, height) {
|
|
68
|
+
const gl = this.gl;
|
|
69
|
+
const texture = gl.createTexture();
|
|
52
70
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
53
71
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.R32F, width, height, 0, gl.RED, gl.FLOAT, null);
|
|
54
72
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
@@ -56,7 +74,6 @@ var BlenderProgram = /** @class */ (function () {
|
|
|
56
74
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
57
75
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
58
76
|
return texture;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}());
|
|
77
|
+
}
|
|
78
|
+
}
|
|
62
79
|
exports.default = BlenderProgram;
|
|
@@ -3,5 +3,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
const object_1 = __importDefault(require("./object"));
|
|
7
7
|
exports.default = object_1.default;
|