@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.
Files changed (166) hide show
  1. package/Math/angle-calculation.js +8 -8
  2. package/Math/arc.js +18 -18
  3. package/Math/bounds/line-bbox.js +78 -80
  4. package/Math/constants.js +3 -3
  5. package/Math/juction/arc-plane.js +23 -23
  6. package/Math/juction/line-sphere.js +11 -11
  7. package/Math/juction/plane-plane.js +11 -11
  8. package/Math/line.js +14 -16
  9. package/Math/methods.js +65 -70
  10. package/Math/plane.js +16 -18
  11. package/Math/quaternion.js +45 -49
  12. package/Math/utils.js +2 -2
  13. package/Math/vec3.js +42 -45
  14. package/algorithms/search-binary.js +4 -4
  15. package/altitude-locator/draw-subset-obj.js +7 -8
  16. package/altitude-locator/plugin.js +98 -114
  17. package/arrowfield/adaptor.js +3 -4
  18. package/arrowfield/index.js +2 -2
  19. package/arrowfield/plugin.js +62 -65
  20. package/bearing-line/index.js +1 -1
  21. package/bearing-line/plugin.js +200 -226
  22. package/circle-line-chain/chain-list-map.js +82 -88
  23. package/circle-line-chain/plugin.js +134 -165
  24. package/circle-line-chain/util.js +1 -1
  25. package/compass-rose/compass-rose-padding-flat.js +108 -133
  26. package/compass-rose/compass-text-writer.js +62 -70
  27. package/compass-rose/index.js +2 -2
  28. package/compassrose/compassrose.js +46 -50
  29. package/compassrose/index.js +1 -1
  30. package/heatwave/index.js +2 -2
  31. package/heatwave/isobar/objectarraylabels.js +44 -48
  32. package/heatwave/isobar/plugin.js +104 -123
  33. package/heatwave/isobar/quadtreecontours.js +76 -92
  34. package/heatwave/plugins/heatwaveglobeshell.js +69 -87
  35. package/index.js +11 -11
  36. package/package.json +1 -1
  37. package/partialrings/buffer-manager.js +32 -64
  38. package/partialrings/index.js +1 -1
  39. package/partialrings/plugin.js +48 -84
  40. package/partialrings/program.js +136 -47
  41. package/pin/pin-object-array.js +83 -86
  42. package/pin/pin-point-totem.js +21 -22
  43. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
  44. package/point-heat-map/plugin-webworker.js +40 -45
  45. package/point-heat-map/point-to-heat-map-flow.js +40 -42
  46. package/point-tracks/key-methods.js +1 -1
  47. package/point-tracks/plugin.js +137 -162
  48. package/programs/arrowfield/index.js +1 -1
  49. package/programs/arrowfield/logic.js +170 -62
  50. package/programs/arrowfield/object.js +33 -35
  51. package/programs/data2legend/density-to-legend.js +45 -21
  52. package/programs/data2legend/point-to-density-texture.js +52 -27
  53. package/programs/float2legendwithratio/index.js +1 -1
  54. package/programs/float2legendwithratio/logic.js +88 -42
  55. package/programs/float2legendwithratio/object.js +43 -46
  56. package/programs/globe-util/is-globe-moved.js +10 -11
  57. package/programs/globeshell/index.js +1 -1
  58. package/programs/globeshell/wiggle/index.js +1 -1
  59. package/programs/globeshell/wiggle/logic.js +191 -98
  60. package/programs/globeshell/wiggle/object.js +33 -35
  61. package/programs/helpers/blender/program.js +36 -19
  62. package/programs/helpers/fadeaway/index.js +1 -1
  63. package/programs/helpers/fadeaway/logic.js +35 -13
  64. package/programs/helpers/fadeaway/object.js +9 -10
  65. package/programs/helpers/index.js +1 -1
  66. package/programs/index.js +8 -8
  67. package/programs/line-on-globe/angled-line.js +91 -32
  68. package/programs/line-on-globe/circle-accurate-3d.js +82 -32
  69. package/programs/line-on-globe/circle-accurate-flat.js +108 -50
  70. package/programs/line-on-globe/circle-accurate.js +103 -33
  71. package/programs/line-on-globe/circle.js +97 -32
  72. package/programs/line-on-globe/degree-padding-around-circle-3d.js +83 -33
  73. package/programs/line-on-globe/lines-color-instanced-flat.js +79 -34
  74. package/programs/line-on-globe/linestrip.js +111 -45
  75. package/programs/line-on-globe/naive-accurate-flexible.js +120 -50
  76. package/programs/line-on-globe/to-the-surface.js +58 -29
  77. package/programs/line-on-globe/util.js +1 -1
  78. package/programs/picking/pickable-renderer.js +117 -33
  79. package/programs/point-on-globe/element-globe-surface-glow.js +78 -38
  80. package/programs/point-on-globe/element-point-glow.js +103 -35
  81. package/programs/point-on-globe/square-pixel-point.js +76 -27
  82. package/programs/programcache.js +13 -13
  83. package/programs/rings/distancering/circleflatprogram.js +63 -21
  84. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +156 -145
  85. package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -197
  86. package/programs/rings/distancering/index.js +4 -4
  87. package/programs/rings/distancering/paddyflatprogram.js +73 -20
  88. package/programs/rings/distancering/paddyflatprogram2d.js +75 -22
  89. package/programs/rings/distancering/paddyflatprogram3d.js +73 -20
  90. package/programs/rings/partial-ring/piece-of-pie.js +137 -35
  91. package/programs/totems/camerauniformblock.js +64 -51
  92. package/programs/totems/canvas-webglobe-info.js +48 -40
  93. package/programs/totems/gpu-selection-uniform-block.js +44 -40
  94. package/programs/totems/index.js +1 -1
  95. package/programs/two-d/pixel-padding-for-compass.js +90 -29
  96. package/programs/util.js +6 -7
  97. package/programs/vectorfields/index.js +1 -1
  98. package/programs/vectorfields/logics/drawrectangleparticles.js +70 -29
  99. package/programs/vectorfields/logics/index.js +3 -3
  100. package/programs/vectorfields/logics/pixelbased.js +91 -35
  101. package/programs/vectorfields/logics/ubo.js +31 -25
  102. package/programs/vectorfields/pingpongbuffermanager.js +30 -34
  103. package/rangerings/index.js +4 -4
  104. package/rangerings/plugin.js +202 -258
  105. package/rangerings/rangeringangletext.js +108 -120
  106. package/rangerings/ring-account.js +52 -69
  107. package/shaders/fragment-toy/firework.js +55 -1
  108. package/shaders/fragment-toy/singularity.js +55 -1
  109. package/timetracks/adaptors-line-strip.js +26 -37
  110. package/timetracks/adaptors.js +47 -61
  111. package/timetracks/index.js +4 -4
  112. package/timetracks/plugin-line-strip.js +63 -71
  113. package/timetracks/plugin.js +69 -77
  114. package/timetracks/program-line-strip.js +296 -103
  115. package/timetracks/program.js +419 -113
  116. package/timetracks/programpoint-line-strip.js +97 -44
  117. package/timetracks/programpoint.js +90 -44
  118. package/util/account/bufferoffsetmanager.js +72 -95
  119. package/util/account/index.js +1 -1
  120. package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -44
  121. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -94
  122. package/util/account/single-attribute-buffer-management/index.js +3 -3
  123. package/util/account/single-attribute-buffer-management/object-store.js +29 -30
  124. package/util/account/util.js +2 -4
  125. package/util/algorithms/search-binary.js +4 -4
  126. package/util/check/get.js +5 -5
  127. package/util/check/typecheck.js +13 -15
  128. package/util/geometry/index.js +9 -11
  129. package/util/gl-util/buffer/attribute-loader.js +8 -20
  130. package/util/gl-util/buffer/index.js +1 -1
  131. package/util/gl-util/draw-options/methods.js +8 -9
  132. package/util/gl-util/uniform-block/manager.js +67 -67
  133. package/util/heatwavedatamanager/datamanager.js +56 -116
  134. package/util/heatwavedatamanager/index.js +2 -2
  135. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +37 -40
  136. package/util/heatwavedatamanager/pointcoordsmeta.js +9 -10
  137. package/util/index.js +6 -6
  138. package/util/interpolation/timetrack/index.js +1 -1
  139. package/util/interpolation/timetrack/timetrack-interpolator.js +27 -29
  140. package/util/interpolation/timetrack/web-worker-str.js +179 -1
  141. package/util/interpolation/timetrack/web-worker.js +4 -4
  142. package/util/jshelpers/data-filler.js +7 -7
  143. package/util/jshelpers/timefilters.js +7 -7
  144. package/util/picking/fence.js +7 -7
  145. package/util/picking/picker-displayer.js +46 -52
  146. package/util/programs/draw-texture-on-canvas.js +39 -21
  147. package/util/programs/shapesonglobe.js +104 -64
  148. package/util/programs/supersampletotextures.js +45 -39
  149. package/util/programs/texturetoglobe.js +98 -48
  150. package/util/shaderfunctions/geometrytransformations.js +322 -27
  151. package/util/shaderfunctions/nodata.js +7 -1
  152. package/util/shaderfunctions/noisefunctions.js +39 -9
  153. package/util/surface-line-data/arcs-to-cuts.js +20 -23
  154. package/util/webglobe/rasteroverlay.js +35 -37
  155. package/util/webglobjectbuilders.js +55 -60
  156. package/util/webglobjectbuilders1.js +48 -49
  157. package/waveparticles/adaptor.js +6 -7
  158. package/waveparticles/index.js +2 -2
  159. package/waveparticles/plugin.js +79 -84
  160. package/wind/imagetovectorfieldandmagnitude.js +15 -15
  161. package/wind/index.js +4 -4
  162. package/wind/plugin.js +453 -251
  163. package/wind/vectorfieldimage.js +5 -5
  164. package/write-text/attached-text-writer.js +46 -48
  165. package/write-text/context-text.js +51 -58
  166. 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
- var util = __importStar(require("../util"));
43
- var imagetovectorfieldandmagnitude_1 = __importDefault(require("./imagetovectorfieldandmagnitude"));
44
- var util_1 = require("../util");
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
- 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 = [
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
- var windyLegendData = {
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
- var WindPlugin = /** @class */ (function () {
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
- 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;
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
- 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
- });
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
- WindPlugin.prototype.setColorRamp = function (colors) {
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
- 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);
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
- WindPlugin.prototype.setLegend = function (legendData) {
261
- var gl = this.gl;
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
- var thresholds = legendData.thresholds, values = legendData.values;
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
- var maxVelocity = thresholds[thresholds.length - 1];
272
- var colors = [];
273
- for (var i = 0; i < thresholds.length; i++) {
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
- var colorRamp = util.getColorRamp(colors);
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
- 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
- });
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
- WindPlugin.prototype.setWind = function (windData) {
532
+ setWind(windData) {
329
533
  if (windData === null) {
330
534
  return;
331
535
  }
332
- var windDataMeta = this._windDataMeta;
333
- var gl = this.gl;
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
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- var minXY = this._latLongToPixelXY(windDataMeta.bbox[1], windDataMeta.bbox[0]);
343
- var maxXY = this._latLongToPixelXY(windDataMeta.bbox[3], windDataMeta.bbox[2]);
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
- WindPlugin.prototype.setWindDataWithImageBase64 = function (windData) {
362
- var _this = this;
363
- var image = util.createImageFromBase64(windData.image);
364
- image.onload = function () {
565
+ setWindDataWithImageBase64(windData) {
566
+ const image = util.createImageFromBase64(windData.image);
567
+ image.onload = () => {
365
568
  windData.image = image;
366
- _this.setWind(windData);
569
+ this.setWind(windData);
367
570
  };
368
- };
369
- WindPlugin.prototype.getPointCoordinatesDataCalculator = function () {
571
+ }
572
+ getPointCoordinatesDataCalculator() {
370
573
  if (!this.coordinatesDataCalculator)
371
574
  this._createPointCoordinatesDataCalculator();
372
575
  return this.coordinatesDataCalculator;
373
- };
374
- WindPlugin.prototype._createPointCoordinatesDataCalculator = function () {
375
- var _a = this._windDataMeta, bbox = _a.bbox, width = _a.width, height = _a.height;
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
- WindPlugin.prototype._setCoorcinatesDataCalculatorData = function () {
581
+ }
582
+ _setCoorcinatesDataCalculatorData() {
380
583
  if (!this.windData || !this.coordinatesDataCalculator) {
381
584
  return;
382
585
  }
383
- var magnitude = (0, imagetovectorfieldandmagnitude_1.default)(this.windData);
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
- WindPlugin.prototype._latLongToPixelXY = function (latitude, longitude) {
592
+ _latLongToPixelXY(latitude, longitude) {
390
593
  return {
391
594
  x: (longitude + 180) / 360,
392
595
  y: (90 - latitude) / 180
393
596
  };
394
- };
395
- WindPlugin.prototype._loadBoundingBoxData = function (minX, minY, maxX, maxY) {
597
+ }
598
+ _loadBoundingBoxData(minX, minY, maxX, maxY) {
396
599
  // console.log("minX", minX, "minY", minY, "maxX", maxX, "maxY", maxY)
397
- var gl = this.gl;
398
- var bboxMatrix = new Float32Array([
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
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- WindPlugin.prototype._doDraw = function () {
413
- var globe = this.globe;
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
- WindPlugin.prototype._draw = function () {
434
- var gl = this.gl;
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
- WindPlugin.prototype.draw3D = function (projMatrix, modelviewMatrix, transPos) {
441
- var gl = this.gl;
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
- var depthTest = gl.isEnabled(gl.DEPTH_TEST);
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
- WindPlugin.prototype._drawScreen = function () {
468
- var _a = this, gl = _a.gl, globe = _a.globe;
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
- var temp = this.backgroundTexture;
685
+ const temp = this.backgroundTexture;
483
686
  this.backgroundTexture = this.screenTexture;
484
687
  this.screenTexture = temp;
485
- };
486
- WindPlugin.prototype._drawTexture = function (texture, opacity) {
487
- var gl = this.gl;
488
- var program = this.screenProgram;
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
- WindPlugin.prototype._loadRampMax = function () {
497
- var gl = this.gl;
498
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- 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;
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
- 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;
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
- var _b = globe.api_GetCurrentWorldWH(), width = _b.width, height = _b.height;
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
- WindPlugin.prototype.setGeometry = function () {
740
+ setGeometry() {
538
741
  if (this.windData === null) {
539
742
  return;
540
743
  }
541
- var _a = this, globe = _a.globe, gl = _a.gl;
542
- var geometry = globe.api_GetCurrentGeometry();
543
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- WindPlugin.prototype._updateParticles = function () {
563
- var gl = this.gl;
564
- var program = this.updateProgram;
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
- var temp = this.particleStateTexture0;
778
+ const temp = this.particleStateTexture0;
576
779
  this.particleStateTexture0 = this.particleStateTexture1;
577
780
  this.particleStateTexture1 = temp;
578
- };
579
- WindPlugin.prototype._resetMachineStates = function () {
580
- var _a = this, gl = _a.gl, globe = _a.globe;
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
- WindPlugin.prototype._loadHeight = function () {
587
- var _a = this, gl = _a.gl, drawSphereProgram = _a.drawSphereProgram;
788
+ }
789
+ _loadHeight() {
790
+ const { gl, drawSphereProgram } = this;
588
791
  if (gl == null)
589
792
  return;
590
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- WindPlugin.prototype._loadMinMaxSpeed = function () {
596
- var _a = this, gl = _a.gl, drawSphereProgram = _a.drawSphereProgram, drawFlatProgram = _a.drawFlatProgram;
797
+ }
798
+ _loadMinMaxSpeed() {
799
+ const { gl, drawSphereProgram, drawFlatProgram } = this;
597
800
  if (gl == null)
598
801
  return;
599
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- WindPlugin.prototype._loadFadeOpacity = function () {
609
- var _a = this, gl = _a.gl, screenProgram = _a.screenProgram;
810
+ }
811
+ _loadFadeOpacity() {
812
+ const { gl, screenProgram } = this;
610
813
  if (gl == null) {
611
814
  return;
612
815
  }
613
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- WindPlugin.prototype._loadSpeedFactor = function () {
619
- var _a = this, gl = _a.gl, globe = _a.globe, updateProgram = _a.updateProgram;
820
+ }
821
+ _loadSpeedFactor() {
822
+ const { gl, globe, updateProgram } = this;
620
823
  if (gl == null) {
621
824
  return;
622
825
  }
623
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- WindPlugin.prototype._loadDropRate = function () {
629
- var _a = this, gl = _a.gl, updateProgram = _a.updateProgram;
830
+ }
831
+ _loadDropRate() {
832
+ const { gl, updateProgram } = this;
630
833
  if (gl == null) {
631
834
  return;
632
835
  }
633
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- WindPlugin.prototype._loadDropRateBump = function () {
639
- var _a = this, gl = _a.gl, updateProgram = _a.updateProgram;
840
+ }
841
+ _loadDropRateBump() {
842
+ const { gl, updateProgram } = this;
640
843
  if (gl == null) {
641
844
  return;
642
845
  }
643
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- WindPlugin.prototype._loadBaseOpacity = function () {
649
- var _a = this, gl = _a.gl, drawSphereProgram = _a.drawSphereProgram, drawFlatProgram = _a.drawFlatProgram;
850
+ }
851
+ _loadBaseOpacity() {
852
+ const { gl, drawSphereProgram, drawFlatProgram } = this;
650
853
  if (gl == null) {
651
854
  return;
652
855
  }
653
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- WindPlugin.prototype._loadPointSize = function () {
661
- var _a = this, gl = _a.gl, drawSphereProgram = _a.drawSphereProgram, drawFlatProgram = _a.drawFlatProgram;
862
+ }
863
+ _loadPointSize() {
864
+ const { gl, drawSphereProgram, drawFlatProgram } = this;
662
865
  if (gl == null) {
663
866
  return;
664
867
  }
665
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
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
- WindPlugin.prototype.init = function (globe, gl) {
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
- 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);
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
- WindPlugin.prototype.free = function () {
707
- var gl = this.gl;
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
- return WindPlugin;
723
- }());
924
+ }
925
+ }
724
926
  exports.default = WindPlugin;