@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
package/wind/plugin.js
CHANGED
|
@@ -39,9 +39,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const util = __importStar(require("../util"));
|
|
43
|
+
const imagetovectorfieldandmagnitude_1 = __importDefault(require("./imagetovectorfieldandmagnitude"));
|
|
44
|
+
const util_1 = require("../util");
|
|
45
45
|
/**
|
|
46
46
|
* Shader Dökümanı:
|
|
47
47
|
* * Vektör alan haritasında kaçış değeri
|
|
@@ -71,13 +71,258 @@ var util_1 = require("../util");
|
|
|
71
71
|
* @property {Array} thresholds - list of integers
|
|
72
72
|
* @property {Array} values - list of colors
|
|
73
73
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
const quadVert = `
|
|
75
|
+
precision mediump float;
|
|
76
|
+
|
|
77
|
+
attribute vec2 a_pos;
|
|
78
|
+
|
|
79
|
+
varying vec2 v_tex_pos;
|
|
80
|
+
|
|
81
|
+
void main() {
|
|
82
|
+
v_tex_pos = a_pos;
|
|
83
|
+
gl_Position = vec4(1.0 - 2.0 * a_pos, 0, 1);
|
|
84
|
+
}`;
|
|
85
|
+
const screenFrag = `precision mediump float;
|
|
86
|
+
|
|
87
|
+
uniform sampler2D u_screen;
|
|
88
|
+
uniform float u_opacity;
|
|
89
|
+
|
|
90
|
+
varying vec2 v_tex_pos;
|
|
91
|
+
|
|
92
|
+
void main() {
|
|
93
|
+
vec4 color = texture2D(u_screen, 1.0 - v_tex_pos);
|
|
94
|
+
// a hack to guarantee opacity fade out even with a value close to 1.0
|
|
95
|
+
gl_FragColor = vec4( floor(255.0 * color * u_opacity) / 255.0);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
`;
|
|
99
|
+
const updateFrag = `
|
|
100
|
+
precision highp float;
|
|
101
|
+
|
|
102
|
+
uniform sampler2D u_particles;
|
|
103
|
+
uniform sampler2D u_wind;
|
|
104
|
+
uniform vec2 u_wind_res;
|
|
105
|
+
uniform vec2 u_wind_min;
|
|
106
|
+
uniform vec2 u_wind_max;
|
|
107
|
+
uniform float u_rand_seed;
|
|
108
|
+
uniform float u_speed_factor;
|
|
109
|
+
uniform float u_drop_rate;
|
|
110
|
+
uniform float u_drop_rate_bump;
|
|
111
|
+
|
|
112
|
+
varying vec2 v_tex_pos;
|
|
113
|
+
|
|
114
|
+
// pseudo-random generator
|
|
115
|
+
const vec3 rand_constants = vec3(12.9898, 78.233, 4375.85453);
|
|
116
|
+
float rand(const vec2 co) {
|
|
117
|
+
float t = dot(rand_constants.xy, co);
|
|
118
|
+
return fract(sin(t) * (rand_constants.z + t));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// wind speed lookup; use manual bilinear filtering based on 4 adjacent pixels for smooth interpolation
|
|
122
|
+
vec2 lookup_wind(const vec2 uv) {
|
|
123
|
+
// return texture2D(u_wind, uv).rg; // lower-res hardware filtering
|
|
124
|
+
vec2 px = 1.0 / u_wind_res;
|
|
125
|
+
vec2 vc = (floor(uv * u_wind_res)) * px;
|
|
126
|
+
vec2 f = fract(uv * u_wind_res);
|
|
127
|
+
vec2 tl = texture2D(u_wind, vc).rg;
|
|
128
|
+
vec2 tr = texture2D(u_wind, vc + vec2(px.x, 0)).rg;
|
|
129
|
+
vec2 bl = texture2D(u_wind, vc + vec2(0, px.y)).rg;
|
|
130
|
+
vec2 br = texture2D(u_wind, vc + px).rg;
|
|
131
|
+
return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
void main() {
|
|
135
|
+
vec4 color = texture2D(u_particles, v_tex_pos);
|
|
136
|
+
vec2 pos = vec2(
|
|
137
|
+
color.r / 255.0 + color.b,
|
|
138
|
+
color.g / 255.0 + color.a); // decode particle position from pixel RGBA
|
|
139
|
+
|
|
140
|
+
if ( texture2D(u_wind, pos).rg == vec2(0.0, 0.0) ) {
|
|
141
|
+
discard;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
vec2 velocity = mix(u_wind_min, u_wind_max, lookup_wind(pos));
|
|
145
|
+
float speed_t = length(velocity) / length(u_wind_max);
|
|
146
|
+
|
|
147
|
+
// take EPSG:4236 distortion into account for calculating where the particle moved
|
|
148
|
+
// float distortion = 1.0; //cos(radians(pos.y * 180.0 - 90.0));
|
|
149
|
+
// vec2 offset = vec2(velocity.x / distortion, -velocity.y) * 0.0001 * u_speed_factor;
|
|
150
|
+
vec2 offset = vec2(velocity.x, velocity.y) * 0.0001 * u_speed_factor;
|
|
151
|
+
|
|
152
|
+
// update particle position, wrapping around the date line
|
|
153
|
+
pos = fract(1.0 + pos + offset);
|
|
154
|
+
|
|
155
|
+
// a random seed to use for the particle drop
|
|
156
|
+
vec2 seed = (pos + v_tex_pos) * u_rand_seed;
|
|
157
|
+
|
|
158
|
+
// drop rate is a chance a particle will restart at random position, to avoid degeneration
|
|
159
|
+
float drop_rate = u_drop_rate + speed_t * u_drop_rate_bump;
|
|
160
|
+
float drop = step(1.0 - drop_rate, rand(seed));
|
|
161
|
+
|
|
162
|
+
vec2 random_pos = vec2(
|
|
163
|
+
rand(seed + 1.3),
|
|
164
|
+
rand(seed + 2.1));
|
|
165
|
+
pos = mix(pos, random_pos, drop);
|
|
166
|
+
|
|
167
|
+
// encode the new particle position back into RGBA
|
|
168
|
+
gl_FragColor = vec4(
|
|
169
|
+
fract(pos * 255.0),
|
|
170
|
+
floor(pos * 255.0) / 255.0);
|
|
171
|
+
}
|
|
172
|
+
`;
|
|
173
|
+
const drawFrag = `precision mediump float;
|
|
174
|
+
|
|
175
|
+
uniform sampler2D u_wind;
|
|
176
|
+
uniform vec2 u_wind_min;
|
|
177
|
+
uniform vec2 u_wind_max;
|
|
178
|
+
uniform sampler2D u_color_ramp;
|
|
179
|
+
uniform float u_color_ramp_max;
|
|
180
|
+
uniform float u_base_opacity;
|
|
181
|
+
|
|
182
|
+
uniform float u_min_speed;
|
|
183
|
+
uniform float u_max_speed;
|
|
184
|
+
|
|
185
|
+
varying vec2 v_particle_pos;
|
|
186
|
+
|
|
187
|
+
void main() {
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
if ( texture2D(u_wind, v_particle_pos).rg == vec2(0.0, 0.0) ) {
|
|
191
|
+
discard;
|
|
192
|
+
}
|
|
193
|
+
vec2 velocity = mix(u_wind_min, u_wind_max, texture2D(u_wind, v_particle_pos).rg);
|
|
194
|
+
float speed = length(velocity);
|
|
195
|
+
if (speed < u_min_speed || speed > u_max_speed) {
|
|
196
|
+
discard;
|
|
197
|
+
}
|
|
198
|
+
if (speed >= u_color_ramp_max) {
|
|
199
|
+
gl_FragColor = texture2D(u_color_ramp,
|
|
200
|
+
vec2( 0.99999 , 0.0001 )) * u_base_opacity;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
float speed_t = speed / u_color_ramp_max; // length(u_wind_max); //
|
|
205
|
+
// color ramp olusturulan method finalde texture ters çevriliyor. bu yüzden speed_t 1.0 - speed_t oluyor.
|
|
206
|
+
speed_t = 1.0 - speed_t;
|
|
207
|
+
// color ramp is encoded in a 16.0 x 16.0 texture
|
|
208
|
+
vec2 ramp_pos = vec2(
|
|
209
|
+
fract(16.0 * speed_t),
|
|
210
|
+
floor(16.0 * speed_t) / 16.0);
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
gl_FragColor = texture2D(u_color_ramp, ramp_pos) * u_base_opacity;
|
|
214
|
+
}
|
|
215
|
+
`;
|
|
216
|
+
const drawSphereVert = `
|
|
217
|
+
precision mediump float;
|
|
218
|
+
|
|
219
|
+
attribute float a_index;
|
|
220
|
+
|
|
221
|
+
uniform float u_point_size;
|
|
222
|
+
uniform sampler2D u_particles;
|
|
223
|
+
uniform float u_particles_res;
|
|
224
|
+
|
|
225
|
+
uniform float u_height;
|
|
226
|
+
|
|
227
|
+
varying vec2 v_particle_pos;
|
|
228
|
+
varying float v_z;
|
|
229
|
+
|
|
230
|
+
uniform mat3 u_bbox_matrix;
|
|
231
|
+
|
|
232
|
+
uniform mat4 uModelViewMatrix;
|
|
233
|
+
uniform mat4 uProjectionMatrix;
|
|
234
|
+
uniform vec3 uTranslate;
|
|
235
|
+
|
|
236
|
+
const float PI = 3.141592653589793;
|
|
237
|
+
const float R = 6378.137;
|
|
238
|
+
|
|
239
|
+
vec3 cartesian3DPoint( float longRad, float latRad, float height) {
|
|
240
|
+
float radius = R + height;
|
|
241
|
+
float x = radius * sin(latRad) * cos(longRad);
|
|
242
|
+
float y = radius * sin(latRad) * sin(longRad);
|
|
243
|
+
float z = radius * cos(latRad);
|
|
244
|
+
return vec3(
|
|
245
|
+
x,
|
|
246
|
+
y,
|
|
247
|
+
z) ;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
void main() {
|
|
251
|
+
vec4 color = texture2D(u_particles, vec2(
|
|
252
|
+
fract(a_index / u_particles_res),
|
|
253
|
+
floor(a_index / u_particles_res) / u_particles_res));
|
|
254
|
+
|
|
255
|
+
v_particle_pos = vec2(
|
|
256
|
+
color.r / 255.0 + color.b,
|
|
257
|
+
color.g / 255.0 + color.a);
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
if ( v_particle_pos.y < 0.0265 || v_particle_pos.y > 0.9735 ) {
|
|
261
|
+
gl_Position = vec4(-2.0, -2.0, -2.0, 1.0);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
vec3 pos = u_bbox_matrix * vec3(v_particle_pos.x, v_particle_pos.y, 1.0);
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
float xRad = PI * (2.0 * pos.x - 1.0);
|
|
268
|
+
float yRad = pos.y * PI;
|
|
269
|
+
|
|
270
|
+
pos = cartesian3DPoint(xRad, yRad, u_height);
|
|
271
|
+
gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(pos - uTranslate, 1.0);
|
|
272
|
+
gl_PointSize = u_point_size;
|
|
273
|
+
|
|
274
|
+
}`;
|
|
275
|
+
const drawFlatVert = `
|
|
276
|
+
precision mediump float;
|
|
277
|
+
|
|
278
|
+
uniform mat3 u_bbox_matrix;
|
|
279
|
+
|
|
280
|
+
uniform vec3 uTranslate;
|
|
281
|
+
// uniform mat4 uModelViewMatrix;
|
|
282
|
+
uniform mat4 uProjectionMatrix;
|
|
283
|
+
|
|
284
|
+
attribute float a_index;
|
|
285
|
+
uniform sampler2D u_particles;
|
|
286
|
+
uniform float u_particles_res;
|
|
287
|
+
uniform float u_point_size;
|
|
288
|
+
uniform vec2 u_mapWH;
|
|
289
|
+
uniform vec2 u_scrWH;
|
|
290
|
+
|
|
291
|
+
varying vec2 v_particle_pos;
|
|
292
|
+
|
|
293
|
+
const float PI = 3.141592653589793;
|
|
294
|
+
const float POLE = 20037508.34;
|
|
295
|
+
const float POLE_BY_PI = POLE / PI;
|
|
296
|
+
const float HALF_PI = PI / 2.0;
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
void main() {
|
|
300
|
+
|
|
301
|
+
vec4 color = texture2D(u_particles, vec2(
|
|
302
|
+
fract(a_index / u_particles_res),
|
|
303
|
+
floor(a_index / u_particles_res) / u_particles_res));
|
|
304
|
+
|
|
305
|
+
v_particle_pos = vec2(
|
|
306
|
+
color.r / 255.0 + color.b,
|
|
307
|
+
color.g / 255.0 + color.a);
|
|
308
|
+
|
|
309
|
+
if ( v_particle_pos.y < 0.0265 || v_particle_pos.y > 0.9735 ) {
|
|
310
|
+
gl_Position = vec4(-2.0, -2.0, -2.0, 1.0);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
vec3 pos = u_bbox_matrix * vec3(v_particle_pos.x, v_particle_pos.y, 1.0);
|
|
314
|
+
|
|
315
|
+
float x = (2.0 * pos.x - 1.0);
|
|
316
|
+
float mercator_x = x * POLE;
|
|
317
|
+
float mercator_y = log( tan( ( 1.0 - pos.y ) * HALF_PI ) ) * POLE_BY_PI;
|
|
318
|
+
|
|
319
|
+
float normalizedX = ( mercator_x - uTranslate.x) / u_mapWH.x;
|
|
320
|
+
float normalizedY = ( mercator_y - uTranslate.y) / u_mapWH.y;
|
|
321
|
+
gl_Position = uProjectionMatrix * vec4(normalizedX * u_scrWH.x, (1.0 - normalizedY) * u_scrWH.y, 0.0, 1.0);
|
|
322
|
+
|
|
323
|
+
gl_PointSize = u_point_size;
|
|
324
|
+
}`;
|
|
325
|
+
const defaultRampColors = [
|
|
81
326
|
[0.0, '#5e4fa2'],
|
|
82
327
|
[0.08, '#3288bd'],
|
|
83
328
|
[0.2, '#66c2a5'],
|
|
@@ -88,7 +333,7 @@ var defaultRampColors = [
|
|
|
88
333
|
[0.7, '#f46d43'],
|
|
89
334
|
[1.0, '#d53e4f']
|
|
90
335
|
];
|
|
91
|
-
|
|
336
|
+
const windyLegendData = {
|
|
92
337
|
"thresholds": [0, 3, 3, 5, 5, 7, 10, 10, 13, 15, 15, 17, 20, 20, 25, 25, 30],
|
|
93
338
|
// 0 5 10 20 30 40 60
|
|
94
339
|
// "thresholds": [0, 5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 40, 60],
|
|
@@ -112,7 +357,7 @@ var windyLegendData = {
|
|
|
112
357
|
"#5B88A1"
|
|
113
358
|
]
|
|
114
359
|
};
|
|
115
|
-
|
|
360
|
+
class WindPlugin {
|
|
116
361
|
/**
|
|
117
362
|
* @param {String} id
|
|
118
363
|
* @param {Object} windDataMeta
|
|
@@ -132,8 +377,7 @@ var WindPlugin = /** @class */ (function () {
|
|
|
132
377
|
* @param {number} numParticles - number of particles | positive integer
|
|
133
378
|
* @param {LegendData} options.legendData - legend data
|
|
134
379
|
*/
|
|
135
|
-
|
|
136
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.fadeOpacity, fadeOpacity = _c === void 0 ? 0.746 : _c, _d = _b.speedFactor, speedFactor = _d === void 0 ? 0.6 : _d, _e = _b.dropRate, dropRate = _e === void 0 ? 0.007 : _e, _f = _b.dropRateBump, dropRateBump = _f === void 0 ? 0.001 : _f, _g = _b.baseOpacity, baseOpacity = _g === void 0 ? 1.0 : _g, _h = _b.pointSize, pointSize = _h === void 0 ? 2.0 : _h, _j = _b.minSpeed, minSpeed = _j === void 0 ? 0.0 : _j, _k = _b.maxSpeed, maxSpeed = _k === void 0 ? 1000.0 : _k, _l = _b.height, height = _l === void 0 ? 0.0 : _l, _m = _b.numParticles, numParticles = _m === void 0 ? 40000 : _m, _o = _b.legendData, legendData = _o === void 0 ? windyLegendData : _o;
|
|
380
|
+
constructor(id, windDataMeta, { fadeOpacity = 0.746, speedFactor = 0.6, dropRate = 0.007, dropRateBump = 0.001, baseOpacity = 1.0, pointSize = 2.0, minSpeed = 0.0, maxSpeed = 1000.0, height = 0.0, numParticles = 40000, legendData = windyLegendData } = {}) {
|
|
137
381
|
this.id = id;
|
|
138
382
|
this._windDataMeta = windDataMeta;
|
|
139
383
|
this.globe = null;
|
|
@@ -158,98 +402,62 @@ var WindPlugin = /** @class */ (function () {
|
|
|
158
402
|
this._drawParticles = this._drawParticlesSphere;
|
|
159
403
|
this._lastLOD = 0;
|
|
160
404
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
},
|
|
199
|
-
enumerable: false,
|
|
200
|
-
configurable: true
|
|
201
|
-
});
|
|
202
|
-
Object.defineProperty(WindPlugin.prototype, "dropRate", {
|
|
203
|
-
set: function (value) {
|
|
204
|
-
this._dropRate = value;
|
|
205
|
-
this._loadDropRate();
|
|
206
|
-
},
|
|
207
|
-
enumerable: false,
|
|
208
|
-
configurable: true
|
|
209
|
-
});
|
|
210
|
-
Object.defineProperty(WindPlugin.prototype, "dropRateBump", {
|
|
211
|
-
set: function (value) {
|
|
212
|
-
this._dropRateBump = value;
|
|
213
|
-
this._loadDropRateBump();
|
|
214
|
-
},
|
|
215
|
-
enumerable: false,
|
|
216
|
-
configurable: true
|
|
217
|
-
});
|
|
218
|
-
Object.defineProperty(WindPlugin.prototype, "baseOpacity", {
|
|
219
|
-
set: function (value) {
|
|
220
|
-
this._baseOpacity = value;
|
|
221
|
-
this._loadBaseOpacity();
|
|
222
|
-
},
|
|
223
|
-
enumerable: false,
|
|
224
|
-
configurable: true
|
|
225
|
-
});
|
|
226
|
-
Object.defineProperty(WindPlugin.prototype, "pointSize", {
|
|
227
|
-
set: function (value) {
|
|
228
|
-
this._pointSize = value;
|
|
229
|
-
this._loadPointSize();
|
|
230
|
-
},
|
|
231
|
-
enumerable: false,
|
|
232
|
-
configurable: true
|
|
233
|
-
});
|
|
405
|
+
// Uniforms are loaded once, on initiation and when they are changed.
|
|
406
|
+
set height(value) {
|
|
407
|
+
this._height = value;
|
|
408
|
+
this._loadHeight();
|
|
409
|
+
}
|
|
410
|
+
set minSpeed(value) {
|
|
411
|
+
this._minSpeed = value;
|
|
412
|
+
this._loadMinMaxSpeed();
|
|
413
|
+
}
|
|
414
|
+
set maxSpeed(value) {
|
|
415
|
+
this._maxSpeed = value;
|
|
416
|
+
this._loadMinMaxSpeed();
|
|
417
|
+
}
|
|
418
|
+
set fadeOpacity(value) {
|
|
419
|
+
this._fadeOpacity = value;
|
|
420
|
+
this._loadFadeOpacity();
|
|
421
|
+
}
|
|
422
|
+
set speedFactor(value) {
|
|
423
|
+
this._speedFactor = value;
|
|
424
|
+
this._loadSpeedFactor();
|
|
425
|
+
}
|
|
426
|
+
set dropRate(value) {
|
|
427
|
+
this._dropRate = value;
|
|
428
|
+
this._loadDropRate();
|
|
429
|
+
}
|
|
430
|
+
set dropRateBump(value) {
|
|
431
|
+
this._dropRateBump = value;
|
|
432
|
+
this._loadDropRateBump();
|
|
433
|
+
}
|
|
434
|
+
set baseOpacity(value) {
|
|
435
|
+
this._baseOpacity = value;
|
|
436
|
+
this._loadBaseOpacity();
|
|
437
|
+
}
|
|
438
|
+
set pointSize(value) {
|
|
439
|
+
this._pointSize = value;
|
|
440
|
+
this._loadPointSize();
|
|
441
|
+
}
|
|
234
442
|
// Color ramp methods.
|
|
235
443
|
// Color ramp is used to colorize the particles according to their speed.
|
|
236
444
|
// Legend max value is used to normalize the speed values.
|
|
237
|
-
|
|
445
|
+
setColorRamp(colors) {
|
|
238
446
|
// lookup texture for colorizing the particles according to their speed
|
|
239
447
|
if (this.gl == null) {
|
|
240
448
|
return;
|
|
241
449
|
}
|
|
242
450
|
this.colorRampTexture = util.createTexture(this.gl, this.gl.LINEAR, util.getColorRamp(colors), 16, 16);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
451
|
+
}
|
|
452
|
+
setColorRampDefault() {
|
|
453
|
+
const { uMax, uMin, vMax, vMin } = this.windData;
|
|
454
|
+
const maxSpeed = Math.sqrt(uMax * uMax + vMax * vMax);
|
|
455
|
+
const minSpeed = Math.sqrt(uMin * uMin + vMin * vMin);
|
|
248
456
|
// console.log("maxSpeed", maxSpeed, "minSpeed", minSpeed);
|
|
249
457
|
this._rampMax = maxSpeed > minSpeed ? maxSpeed : minSpeed;
|
|
250
458
|
this._loadRampMax();
|
|
251
459
|
this.setColorRamp(defaultRampColors);
|
|
252
|
-
}
|
|
460
|
+
}
|
|
253
461
|
/**
|
|
254
462
|
*
|
|
255
463
|
* @param {*} legendData
|
|
@@ -257,64 +465,60 @@ var WindPlugin = /** @class */ (function () {
|
|
|
257
465
|
* @param {Array} legendData.values - list of colors in hex format like #ff0000 (alpha is not included)
|
|
258
466
|
*
|
|
259
467
|
*/
|
|
260
|
-
|
|
261
|
-
|
|
468
|
+
setLegend(legendData) {
|
|
469
|
+
const { gl } = this;
|
|
262
470
|
if (gl === null) {
|
|
263
471
|
throw new Error("wind plugin. setColorRampFromService is called before plugin is registered.");
|
|
264
472
|
}
|
|
265
|
-
|
|
473
|
+
const { thresholds, values } = legendData;
|
|
266
474
|
if (thresholds.length === 0 || values.length === 0) {
|
|
267
475
|
return;
|
|
268
476
|
}
|
|
269
477
|
thresholds.push(thresholds[thresholds.length - 1]);
|
|
270
478
|
values.push(values[values.length - 1]);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
for (
|
|
479
|
+
const maxVelocity = thresholds[thresholds.length - 1];
|
|
480
|
+
const colors = [];
|
|
481
|
+
for (let i = 0; i < thresholds.length; i++) {
|
|
274
482
|
colors.push([
|
|
275
483
|
thresholds[i] / maxVelocity,
|
|
276
484
|
values[i]
|
|
277
485
|
]);
|
|
278
486
|
}
|
|
279
|
-
|
|
487
|
+
const colorRamp = util.getColorRamp(colors);
|
|
280
488
|
this.colorRampTexture = util.createTexture(gl, gl.LINEAR, colorRamp, 16, 16);
|
|
281
489
|
this._rampMax = maxVelocity;
|
|
282
490
|
this._loadRampMax();
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
},
|
|
315
|
-
enumerable: false,
|
|
316
|
-
configurable: true
|
|
317
|
-
});
|
|
491
|
+
}
|
|
492
|
+
// particle coordinates are encoded into RGBA texture
|
|
493
|
+
set numParticles(numParticles) {
|
|
494
|
+
const gl = this.gl;
|
|
495
|
+
// we create a square texture where each pixel will hold a particle position encoded as RGBA
|
|
496
|
+
const particleRes = this.particleStateResolution = Math.ceil(Math.sqrt(numParticles));
|
|
497
|
+
this._numParticles = particleRes * particleRes;
|
|
498
|
+
const particleState = new Uint8Array(this._numParticles * 4);
|
|
499
|
+
for (let i = 0; i < particleState.length; i++) {
|
|
500
|
+
particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions
|
|
501
|
+
}
|
|
502
|
+
// textures to hold the particle state for the current and the next frame
|
|
503
|
+
this.particleStateTexture0 = util.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
|
|
504
|
+
this.particleStateTexture1 = util.createTexture(gl, gl.NEAREST, particleState, particleRes, particleRes);
|
|
505
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
506
|
+
gl.useProgram(this.updateProgram.program);
|
|
507
|
+
gl.uniform1f(this.updateProgram.u_wind_res, this.particleStateResolution);
|
|
508
|
+
gl.useProgram(this.drawSphereProgram.program);
|
|
509
|
+
gl.uniform1f(this.drawSphereProgram.u_particles_res, this.particleStateResolution);
|
|
510
|
+
gl.useProgram(this.drawFlatProgram.program);
|
|
511
|
+
gl.uniform1f(this.drawFlatProgram.u_particles_res, this.particleStateResolution);
|
|
512
|
+
gl.useProgram(currentProgram);
|
|
513
|
+
// console.log("numParticles", this._numParticles);
|
|
514
|
+
const particleIndices = new Float32Array(this._numParticles);
|
|
515
|
+
for (let i = 0; i < this._numParticles; i++)
|
|
516
|
+
particleIndices[i] = i;
|
|
517
|
+
this.particleIndexBuffer = util.createBuffer(gl, particleIndices);
|
|
518
|
+
}
|
|
519
|
+
get numParticles() {
|
|
520
|
+
return this._numParticles;
|
|
521
|
+
}
|
|
318
522
|
// Vector field texture is used to calculate the particle movement.
|
|
319
523
|
/**
|
|
320
524
|
* @param {Object} windData
|
|
@@ -325,27 +529,27 @@ var WindPlugin = /** @class */ (function () {
|
|
|
325
529
|
* @param {number} windData.uMax - maximum u value
|
|
326
530
|
* @param {number} windData.vMax - maximum v value
|
|
327
531
|
*/
|
|
328
|
-
|
|
532
|
+
setWind(windData) {
|
|
329
533
|
if (windData === null) {
|
|
330
534
|
return;
|
|
331
535
|
}
|
|
332
|
-
|
|
333
|
-
|
|
536
|
+
const windDataMeta = this._windDataMeta;
|
|
537
|
+
const gl = this.gl;
|
|
334
538
|
this.windData = windData;
|
|
335
539
|
this.windTexture = util.createTexture(gl, gl.LINEAR, windData.image);
|
|
336
|
-
|
|
540
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
337
541
|
gl.useProgram(this.updateProgram.program);
|
|
338
542
|
gl.uniform2f(this.updateProgram.u_wind_res, windDataMeta.width, windDataMeta.height);
|
|
339
543
|
gl.uniform2f(this.updateProgram.u_wind_min, this.windData.uMin, this.windData.vMin);
|
|
340
544
|
gl.uniform2f(this.updateProgram.u_wind_max, this.windData.uMax, this.windData.vMax);
|
|
341
545
|
this.setGeometry();
|
|
342
|
-
|
|
343
|
-
|
|
546
|
+
const minXY = this._latLongToPixelXY(windDataMeta.bbox[1], windDataMeta.bbox[0]);
|
|
547
|
+
const maxXY = this._latLongToPixelXY(windDataMeta.bbox[3], windDataMeta.bbox[2]);
|
|
344
548
|
this._loadBoundingBoxData(minXY.x, minXY.y, maxXY.x, maxXY.y);
|
|
345
549
|
gl.useProgram(currentProgram);
|
|
346
550
|
this._setCoorcinatesDataCalculatorData();
|
|
347
551
|
this.resize();
|
|
348
|
-
}
|
|
552
|
+
}
|
|
349
553
|
// Vector field texture is used to calculate the particle movement.
|
|
350
554
|
/**
|
|
351
555
|
* @param {Object} windData
|
|
@@ -358,59 +562,58 @@ var WindPlugin = /** @class */ (function () {
|
|
|
358
562
|
* @param {number} windData.vMax - maximum v value
|
|
359
563
|
* @param {Array} windData.bbox - bounding box [minLon, minLat, maxLon, maxLat]
|
|
360
564
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
image.onload = function () {
|
|
565
|
+
setWindDataWithImageBase64(windData) {
|
|
566
|
+
const image = util.createImageFromBase64(windData.image);
|
|
567
|
+
image.onload = () => {
|
|
365
568
|
windData.image = image;
|
|
366
|
-
|
|
569
|
+
this.setWind(windData);
|
|
367
570
|
};
|
|
368
|
-
}
|
|
369
|
-
|
|
571
|
+
}
|
|
572
|
+
getPointCoordinatesDataCalculator() {
|
|
370
573
|
if (!this.coordinatesDataCalculator)
|
|
371
574
|
this._createPointCoordinatesDataCalculator();
|
|
372
575
|
return this.coordinatesDataCalculator;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
576
|
+
}
|
|
577
|
+
_createPointCoordinatesDataCalculator() {
|
|
578
|
+
const { bbox, width, height } = this._windDataMeta;
|
|
376
579
|
this.coordinatesDataCalculator = new util_1.PointCoordinatesDataCalculator(bbox, width, height);
|
|
377
580
|
this._setCoorcinatesDataCalculatorData();
|
|
378
|
-
}
|
|
379
|
-
|
|
581
|
+
}
|
|
582
|
+
_setCoorcinatesDataCalculatorData() {
|
|
380
583
|
if (!this.windData || !this.coordinatesDataCalculator) {
|
|
381
584
|
return;
|
|
382
585
|
}
|
|
383
|
-
|
|
586
|
+
const magnitude = (0, imagetovectorfieldandmagnitude_1.default)(this.windData);
|
|
384
587
|
this.coordinatesDataCalculator.updateData(0, magnitude, magnitude);
|
|
385
|
-
}
|
|
588
|
+
}
|
|
386
589
|
// -----------------------------------------------
|
|
387
590
|
// --- inner methods ---
|
|
388
591
|
// -----------------------------------------------
|
|
389
|
-
|
|
592
|
+
_latLongToPixelXY(latitude, longitude) {
|
|
390
593
|
return {
|
|
391
594
|
x: (longitude + 180) / 360,
|
|
392
595
|
y: (90 - latitude) / 180
|
|
393
596
|
};
|
|
394
|
-
}
|
|
395
|
-
|
|
597
|
+
}
|
|
598
|
+
_loadBoundingBoxData(minX, minY, maxX, maxY) {
|
|
396
599
|
// console.log("minX", minX, "minY", minY, "maxX", maxX, "maxY", maxY)
|
|
397
|
-
|
|
398
|
-
|
|
600
|
+
const gl = this.gl;
|
|
601
|
+
const bboxMatrix = new Float32Array([
|
|
399
602
|
maxX - minX, 0, 0,
|
|
400
603
|
0, maxY - minY, 0,
|
|
401
604
|
minX, minY, 1
|
|
402
605
|
]);
|
|
403
|
-
|
|
606
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
404
607
|
gl.useProgram(this.drawSphereProgram.program);
|
|
405
608
|
gl.uniformMatrix3fv(this.drawSphereProgram.u_bbox_matrix, false, bboxMatrix);
|
|
406
609
|
gl.useProgram(this.drawFlatProgram.program);
|
|
407
610
|
gl.uniformMatrix3fv(this.drawFlatProgram.u_bbox_matrix, false, bboxMatrix);
|
|
408
611
|
gl.useProgram(currentProgram);
|
|
409
|
-
}
|
|
612
|
+
}
|
|
410
613
|
// When the screen is moved, the particles are reset to random positions.
|
|
411
614
|
// During movement plugin should not draw the particles.
|
|
412
|
-
|
|
413
|
-
|
|
615
|
+
_doDraw() {
|
|
616
|
+
const globe = this.globe;
|
|
414
617
|
if (this.windData === null) {
|
|
415
618
|
return false;
|
|
416
619
|
}
|
|
@@ -429,23 +632,23 @@ var WindPlugin = /** @class */ (function () {
|
|
|
429
632
|
}
|
|
430
633
|
return true;
|
|
431
634
|
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
635
|
+
}
|
|
636
|
+
_draw() {
|
|
637
|
+
const gl = this.gl;
|
|
435
638
|
this._drawScreen();
|
|
436
639
|
this._updateParticles();
|
|
437
640
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
438
|
-
}
|
|
641
|
+
}
|
|
439
642
|
// globe calls `draw3D` method on each frame
|
|
440
|
-
|
|
441
|
-
|
|
643
|
+
draw3D(projMatrix, modelviewMatrix, transPos) {
|
|
644
|
+
const gl = this.gl;
|
|
442
645
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
443
646
|
this.transPos.set([transPos.x, transPos.y, transPos.z], 0);
|
|
444
647
|
this.projMatrix = projMatrix;
|
|
445
648
|
this.modelviewMatrix = modelviewMatrix;
|
|
446
649
|
gl.activeTexture(gl.TEXTURE0);
|
|
447
650
|
if (this._doDraw()) {
|
|
448
|
-
|
|
651
|
+
const depthTest = gl.isEnabled(gl.DEPTH_TEST);
|
|
449
652
|
if (depthTest)
|
|
450
653
|
gl.disable(gl.DEPTH_TEST);
|
|
451
654
|
// if (gl.disable(gl.STENCIL_TEST); //
|
|
@@ -463,9 +666,9 @@ var WindPlugin = /** @class */ (function () {
|
|
|
463
666
|
// this._drawTexture(this.colorRampTexture, 1.0);
|
|
464
667
|
this._resetMachineStates();
|
|
465
668
|
this.globe.DrawRender();
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
|
|
669
|
+
}
|
|
670
|
+
_drawScreen() {
|
|
671
|
+
const { gl, globe } = this;
|
|
469
672
|
util.bindTexture(gl, this.windTexture, 0);
|
|
470
673
|
util.bindTexture(gl, this.particleStateTexture0, 1);
|
|
471
674
|
// draw the screen into a temporary framebuffer to retain it as the background on the next frame
|
|
@@ -479,33 +682,33 @@ var WindPlugin = /** @class */ (function () {
|
|
|
479
682
|
this._drawTexture(this.screenTexture, 1.0);
|
|
480
683
|
gl.disable(gl.BLEND);
|
|
481
684
|
// save the current screen as the background for the next frame
|
|
482
|
-
|
|
685
|
+
const temp = this.backgroundTexture;
|
|
483
686
|
this.backgroundTexture = this.screenTexture;
|
|
484
687
|
this.screenTexture = temp;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
688
|
+
}
|
|
689
|
+
_drawTexture(texture, opacity) {
|
|
690
|
+
const gl = this.gl;
|
|
691
|
+
const program = this.screenProgram;
|
|
489
692
|
gl.useProgram(program.program);
|
|
490
693
|
util.bindAttribute(gl, this.quadBuffer, program.a_pos, 2);
|
|
491
694
|
util.bindTexture(gl, texture, 2);
|
|
492
695
|
gl.uniform1i(program.u_screen, 2);
|
|
493
696
|
gl.uniform1f(program.u_opacity, opacity);
|
|
494
697
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
698
|
+
}
|
|
699
|
+
_loadRampMax() {
|
|
700
|
+
const { gl } = this;
|
|
701
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
499
702
|
// console.log("load ramp max", this._rampMax);
|
|
500
703
|
gl.useProgram(this.drawSphereProgram.program);
|
|
501
704
|
gl.uniform1f(this.drawSphereProgram.u_color_ramp_max, this._rampMax);
|
|
502
705
|
gl.useProgram(this.drawFlatProgram.program);
|
|
503
706
|
gl.uniform1f(this.drawFlatProgram.u_color_ramp_max, this._rampMax);
|
|
504
707
|
gl.useProgram(currentProgram);
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
708
|
+
}
|
|
709
|
+
_drawParticlesSphere() {
|
|
710
|
+
const { gl, projMatrix, modelviewMatrix, transPos } = this;
|
|
711
|
+
const program = this.drawSphereProgram;
|
|
509
712
|
gl.useProgram(program.program);
|
|
510
713
|
util.bindAttribute(gl, this.particleIndexBuffer, program.a_index, 1);
|
|
511
714
|
util.bindTexture(gl, this.colorRampTexture, 2);
|
|
@@ -516,10 +719,10 @@ var WindPlugin = /** @class */ (function () {
|
|
|
516
719
|
gl.uniformMatrix4fv(program.uModelViewMatrix, false, modelviewMatrix);
|
|
517
720
|
gl.uniform3fv(program.uTranslate, transPos);
|
|
518
721
|
gl.drawArrays(gl.POINTS, 0, this._numParticles);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
722
|
+
}
|
|
723
|
+
_drawParticlesFlat() {
|
|
724
|
+
const { gl, transPos, projMatrix, globe } = this;
|
|
725
|
+
const program = this.drawFlatProgram;
|
|
523
726
|
gl.useProgram(program.program);
|
|
524
727
|
util.bindAttribute(gl, this.particleIndexBuffer, program.a_index, 1);
|
|
525
728
|
util.bindTexture(gl, this.colorRampTexture, 2);
|
|
@@ -527,20 +730,20 @@ var WindPlugin = /** @class */ (function () {
|
|
|
527
730
|
gl.uniform1i(program.u_particles, 1);
|
|
528
731
|
gl.uniform1i(program.u_color_ramp, 2);
|
|
529
732
|
gl.uniform2f(program.u_scrWH, globe.api_ScrW(), globe.api_ScrH());
|
|
530
|
-
|
|
733
|
+
const { width, height } = globe.api_GetCurrentWorldWH();
|
|
531
734
|
gl.uniform2f(program.u_mapWH, width, height);
|
|
532
735
|
gl.uniformMatrix4fv(program.uProjectionMatrix, false, projMatrix);
|
|
533
736
|
gl.uniform3fv(program.uTranslate, transPos);
|
|
534
737
|
gl.drawArrays(gl.POINTS, 0, this._numParticles);
|
|
535
|
-
}
|
|
738
|
+
}
|
|
536
739
|
// globe calls `setGeometry` method on map projection change. FLAT or SPHERE
|
|
537
|
-
|
|
740
|
+
setGeometry() {
|
|
538
741
|
if (this.windData === null) {
|
|
539
742
|
return;
|
|
540
743
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
744
|
+
const { globe, gl } = this;
|
|
745
|
+
const geometry = globe.api_GetCurrentGeometry();
|
|
746
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
544
747
|
if (geometry === globe.api_GeometryTypes().SPHERE) {
|
|
545
748
|
this._drawParticles = this._drawParticlesSphere;
|
|
546
749
|
gl.useProgram(this.drawSphereProgram.program);
|
|
@@ -558,10 +761,10 @@ var WindPlugin = /** @class */ (function () {
|
|
|
558
761
|
}
|
|
559
762
|
gl.useProgram(currentProgram);
|
|
560
763
|
this.resize();
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
764
|
+
}
|
|
765
|
+
_updateParticles() {
|
|
766
|
+
const gl = this.gl;
|
|
767
|
+
const program = this.updateProgram;
|
|
565
768
|
gl.useProgram(program.program);
|
|
566
769
|
gl.viewport(0, 0, this.particleStateResolution, this.particleStateResolution);
|
|
567
770
|
util.bindAttribute(gl, this.quadBuffer, program.a_pos, 2);
|
|
@@ -572,31 +775,31 @@ var WindPlugin = /** @class */ (function () {
|
|
|
572
775
|
util.bindFramebuffer(gl, this.framebuffer, this.particleStateTexture1);
|
|
573
776
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
574
777
|
// swap the particle state textures so the new one becomes the current one
|
|
575
|
-
|
|
778
|
+
const temp = this.particleStateTexture0;
|
|
576
779
|
this.particleStateTexture0 = this.particleStateTexture1;
|
|
577
780
|
this.particleStateTexture1 = temp;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
781
|
+
}
|
|
782
|
+
_resetMachineStates() {
|
|
783
|
+
const { gl, globe } = this;
|
|
581
784
|
// gl.disable(gl.DEPTH_TEST);
|
|
582
785
|
// gl.disable(gl.STENCIL_TEST);
|
|
583
786
|
gl.activeTexture(gl.TEXTURE0);
|
|
584
787
|
gl.viewport(0, 0, globe.api_ScrW(), globe.api_ScrH());
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
|
|
788
|
+
}
|
|
789
|
+
_loadHeight() {
|
|
790
|
+
const { gl, drawSphereProgram } = this;
|
|
588
791
|
if (gl == null)
|
|
589
792
|
return;
|
|
590
|
-
|
|
793
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
591
794
|
gl.useProgram(drawSphereProgram.program);
|
|
592
795
|
gl.uniform1f(drawSphereProgram.u_height, this._height);
|
|
593
796
|
gl.useProgram(currentProgram);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
|
|
797
|
+
}
|
|
798
|
+
_loadMinMaxSpeed() {
|
|
799
|
+
const { gl, drawSphereProgram, drawFlatProgram } = this;
|
|
597
800
|
if (gl == null)
|
|
598
801
|
return;
|
|
599
|
-
|
|
802
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
600
803
|
gl.useProgram(drawSphereProgram.program);
|
|
601
804
|
gl.uniform1f(drawSphereProgram.u_min_speed, this._minSpeed);
|
|
602
805
|
gl.uniform1f(drawSphereProgram.u_max_speed, this._maxSpeed);
|
|
@@ -604,73 +807,73 @@ var WindPlugin = /** @class */ (function () {
|
|
|
604
807
|
gl.uniform1f(drawFlatProgram.u_min_speed, this._minSpeed);
|
|
605
808
|
gl.uniform1f(drawFlatProgram.u_max_speed, this._maxSpeed);
|
|
606
809
|
gl.useProgram(currentProgram);
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
|
|
810
|
+
}
|
|
811
|
+
_loadFadeOpacity() {
|
|
812
|
+
const { gl, screenProgram } = this;
|
|
610
813
|
if (gl == null) {
|
|
611
814
|
return;
|
|
612
815
|
}
|
|
613
|
-
|
|
816
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
614
817
|
gl.useProgram(screenProgram.program);
|
|
615
818
|
gl.uniform1f(screenProgram.u_opacity, this._fadeOpacity);
|
|
616
819
|
gl.useProgram(currentProgram);
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
|
|
820
|
+
}
|
|
821
|
+
_loadSpeedFactor() {
|
|
822
|
+
const { gl, globe, updateProgram } = this;
|
|
620
823
|
if (gl == null) {
|
|
621
824
|
return;
|
|
622
825
|
}
|
|
623
|
-
|
|
826
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
624
827
|
gl.useProgram(updateProgram.program);
|
|
625
828
|
gl.uniform1f(updateProgram.u_speed_factor, this._speedFactor / Math.ceil(Math.sqrt(globe.api_GetCurrentLOD())));
|
|
626
829
|
gl.useProgram(currentProgram);
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
|
|
830
|
+
}
|
|
831
|
+
_loadDropRate() {
|
|
832
|
+
const { gl, updateProgram } = this;
|
|
630
833
|
if (gl == null) {
|
|
631
834
|
return;
|
|
632
835
|
}
|
|
633
|
-
|
|
836
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
634
837
|
gl.useProgram(updateProgram.program);
|
|
635
838
|
gl.uniform1f(updateProgram.u_drop_rate, this._dropRate);
|
|
636
839
|
gl.useProgram(currentProgram);
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
|
|
840
|
+
}
|
|
841
|
+
_loadDropRateBump() {
|
|
842
|
+
const { gl, updateProgram } = this;
|
|
640
843
|
if (gl == null) {
|
|
641
844
|
return;
|
|
642
845
|
}
|
|
643
|
-
|
|
846
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
644
847
|
gl.useProgram(updateProgram.program);
|
|
645
848
|
gl.uniform1f(updateProgram.u_drop_rate_bump, this._dropRateBump);
|
|
646
849
|
gl.useProgram(currentProgram);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
|
|
850
|
+
}
|
|
851
|
+
_loadBaseOpacity() {
|
|
852
|
+
const { gl, drawSphereProgram, drawFlatProgram } = this;
|
|
650
853
|
if (gl == null) {
|
|
651
854
|
return;
|
|
652
855
|
}
|
|
653
|
-
|
|
856
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
654
857
|
gl.useProgram(drawSphereProgram.program);
|
|
655
858
|
gl.uniform1f(drawSphereProgram.u_base_opacity, this._baseOpacity);
|
|
656
859
|
gl.useProgram(drawFlatProgram.program);
|
|
657
860
|
gl.uniform1f(drawFlatProgram.u_base_opacity, this._baseOpacity);
|
|
658
861
|
gl.useProgram(currentProgram);
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
862
|
+
}
|
|
863
|
+
_loadPointSize() {
|
|
864
|
+
const { gl, drawSphereProgram, drawFlatProgram } = this;
|
|
662
865
|
if (gl == null) {
|
|
663
866
|
return;
|
|
664
867
|
}
|
|
665
|
-
|
|
868
|
+
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
666
869
|
gl.useProgram(drawSphereProgram.program);
|
|
667
870
|
gl.uniform1f(drawSphereProgram.u_point_size, this._pointSize);
|
|
668
871
|
gl.useProgram(drawFlatProgram.program);
|
|
669
872
|
gl.uniform1f(drawFlatProgram.u_point_size, this._pointSize);
|
|
670
873
|
gl.useProgram(currentProgram);
|
|
671
|
-
}
|
|
874
|
+
}
|
|
672
875
|
// globe plugin init methodu
|
|
673
|
-
|
|
876
|
+
init(globe, gl) {
|
|
674
877
|
// console.log("init wind plugin")
|
|
675
878
|
this.globe = globe;
|
|
676
879
|
this.gl = gl;
|
|
@@ -693,18 +896,18 @@ var WindPlugin = /** @class */ (function () {
|
|
|
693
896
|
}
|
|
694
897
|
this.numParticles = this._numParticles;
|
|
695
898
|
this.resize();
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
899
|
+
}
|
|
900
|
+
resize(a, b) {
|
|
901
|
+
const { gl, globe } = this;
|
|
902
|
+
const emptyPixels = new Uint8Array(globe.api_ScrW() * globe.api_ScrH() * 4);
|
|
700
903
|
// screen textures to hold the drawn screen for the previous and the current frame
|
|
701
904
|
this.backgroundTexture = util.createTexture(gl, gl.LINEAR, emptyPixels, globe.api_ScrW(), globe.api_ScrH());
|
|
702
905
|
this.screenTexture = util.createTexture(gl, gl.LINEAR, emptyPixels, globe.api_ScrW(), globe.api_ScrH());
|
|
703
906
|
gl.viewport(0, 0, globe.api_ScrW(), globe.api_ScrH());
|
|
704
|
-
}
|
|
907
|
+
}
|
|
705
908
|
// globe calls this `free` on plugin object unregistration
|
|
706
|
-
|
|
707
|
-
|
|
909
|
+
free() {
|
|
910
|
+
const gl = this.gl;
|
|
708
911
|
gl.deleteBuffer(this.quadBuffer);
|
|
709
912
|
gl.deleteFramebuffer(this.framebuffer);
|
|
710
913
|
gl.deleteTexture(this.backgroundTexture);
|
|
@@ -718,7 +921,6 @@ var WindPlugin = /** @class */ (function () {
|
|
|
718
921
|
gl.deleteProgram(this.updateProgram.program);
|
|
719
922
|
gl.deleteProgram(this.drawFlatProgram.program);
|
|
720
923
|
gl.deleteBuffer(this.particleIndexBuffer);
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
}());
|
|
924
|
+
}
|
|
925
|
+
}
|
|
724
926
|
exports.default = WindPlugin;
|