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