@pirireis/webglobeplugins 0.9.11 → 0.9.13

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