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