@longline/aqua-ui 1.0.16 → 1.0.18

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 (62) hide show
  1. package/containers/PublicRoute/Help.d.ts +13 -0
  2. package/containers/PublicRoute/Help.js +28 -0
  3. package/containers/PublicRoute/PublicRoute.d.ts +11 -0
  4. package/containers/PublicRoute/PublicRoute.js +45 -0
  5. package/containers/PublicRoute/index.d.ts +1 -0
  6. package/containers/PublicRoute/index.js +1 -0
  7. package/controls/Dropzone/Dropbox.d.ts +14 -0
  8. package/controls/Dropzone/Dropbox.js +47 -0
  9. package/controls/Dropzone/Dropzone.d.ts +30 -0
  10. package/controls/Dropzone/Dropzone.js +30 -0
  11. package/controls/Dropzone/index.d.ts +1 -0
  12. package/controls/Dropzone/index.js +1 -0
  13. package/helper/RgbColor.d.ts +5 -0
  14. package/helper/RgbColor.js +8 -0
  15. package/map/Map/Map.d.ts +16 -1
  16. package/map/Map/Map.js +3 -3
  17. package/modules/Globe/Elevations.d.ts +6 -0
  18. package/modules/Globe/Elevations.js +14 -0
  19. package/modules/Globe/FragmentShader.d.ts +2 -0
  20. package/modules/Globe/FragmentShader.js +2 -0
  21. package/modules/Globe/Globe.d.ts +7 -0
  22. package/modules/Globe/Globe.js +140 -0
  23. package/modules/Globe/VertexShader.d.ts +2 -0
  24. package/modules/Globe/VertexShader.js +2 -0
  25. package/modules/Globe/index.d.ts +1 -0
  26. package/modules/Globe/index.js +1 -0
  27. package/modules/ParticleGlobe/FadeShader.d.ts +3 -0
  28. package/modules/ParticleGlobe/FadeShader.js +3 -0
  29. package/modules/ParticleGlobe/GL.d.ts +7 -0
  30. package/modules/ParticleGlobe/GL.js +65 -0
  31. package/modules/ParticleGlobe/OutlineFragmentShader.d.ts +2 -0
  32. package/modules/ParticleGlobe/OutlineFragmentShader.js +2 -0
  33. package/modules/ParticleGlobe/OutlineShader.d.ts +3 -0
  34. package/modules/ParticleGlobe/OutlineShader.js +3 -0
  35. package/modules/ParticleGlobe/OutputShader.d.ts +3 -0
  36. package/modules/ParticleGlobe/OutputShader.js +4 -0
  37. package/modules/ParticleGlobe/OutputVertexShaderOld.d.ts +2 -0
  38. package/modules/ParticleGlobe/OutputVertexShaderOld.js +2 -0
  39. package/modules/ParticleGlobe/ParticleGlobe.d.ts +91 -0
  40. package/modules/ParticleGlobe/ParticleGlobe.js +508 -0
  41. package/modules/ParticleGlobe/PointsShader.d.ts +3 -0
  42. package/modules/ParticleGlobe/PointsShader.js +4 -0
  43. package/modules/ParticleGlobe/SphereShader.d.ts +3 -0
  44. package/modules/ParticleGlobe/SphereShader.js +3 -0
  45. package/modules/ParticleGlobe/TextureShader.d.ts +3 -0
  46. package/modules/ParticleGlobe/TextureShader.js +3 -0
  47. package/modules/ParticleGlobe/include/decodeSpeed.include.d.ts +2 -0
  48. package/modules/ParticleGlobe/include/decodeSpeed.include.js +2 -0
  49. package/package.json +3 -1
  50. package/services/Auth/Auth.d.ts +26 -0
  51. package/services/Auth/Auth.js +63 -0
  52. package/services/Auth/AuthContext.d.ts +11 -0
  53. package/services/Auth/AuthContext.js +3 -0
  54. package/services/Auth/index.d.ts +2 -0
  55. package/services/Auth/index.js +2 -0
  56. package/services/Auth/useAuth.d.ts +5 -0
  57. package/services/Auth/useAuth.js +9 -0
  58. package/spritemap.svg +1 -1
  59. package/svg/index.d.ts +2 -0
  60. package/svg/index.js +2 -1
  61. package/svg/other/index.d.ts +3 -0
  62. package/svg/other/index.js +4 -0
@@ -0,0 +1,65 @@
1
+ var GL = /** @class */ (function () {
2
+ function GL() {
3
+ }
4
+ GL.createProgram = function (gl, vertexSource, fragmentSource) {
5
+ var vertexShader = gl.createShader(gl.VERTEX_SHADER);
6
+ gl.shaderSource(vertexShader, vertexSource);
7
+ gl.compileShader(vertexShader);
8
+ var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
9
+ gl.shaderSource(fragmentShader, fragmentSource);
10
+ gl.compileShader(fragmentShader);
11
+ var program = gl.createProgram();
12
+ gl.attachShader(program, vertexShader);
13
+ gl.attachShader(program, fragmentShader);
14
+ gl.linkProgram(program);
15
+ return program;
16
+ };
17
+ GL.createRGBATexture = function (gl, size, content, interpolated) {
18
+ var texture = gl.createTexture();
19
+ gl.bindTexture(gl.TEXTURE_2D, texture);
20
+ // Define size and format of level 0:
21
+ var level = 0;
22
+ var internalFormat = gl.RGBA;
23
+ var border = 0;
24
+ var format = gl.RGBA;
25
+ var type = gl.UNSIGNED_BYTE;
26
+ gl.texImage2D(gl.TEXTURE_2D, level, internalFormat, size, size, border, format, type, content);
27
+ if (!interpolated) {
28
+ // Set filtering to NEAREST so there's no interpolation:
29
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
30
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
31
+ }
32
+ return texture;
33
+ };
34
+ GL.createImageTexture = function (gl, image, interpolation) {
35
+ var texture = gl.createTexture();
36
+ gl.bindTexture(gl.TEXTURE_2D, texture);
37
+ // Define size and format of level 0:
38
+ var level = 0;
39
+ var internalFormat = gl.RGBA;
40
+ var format = gl.RGBA;
41
+ var type = gl.UNSIGNED_BYTE;
42
+ gl.texImage2D(gl.TEXTURE_2D, level, internalFormat, format, type, image);
43
+ if (interpolation) {
44
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
45
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
46
+ }
47
+ else {
48
+ // Set filtering to NEAREST so there's no interpolation:
49
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
50
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
51
+ }
52
+ return texture;
53
+ };
54
+ GL.createFrameBuffer = function (gl, texture) {
55
+ // Create and bind the framebuffer:
56
+ var fbo = gl.createFramebuffer();
57
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
58
+ // Attach the texture as the first color attachment:
59
+ var attachmentPoint = gl.COLOR_ATTACHMENT0;
60
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, attachmentPoint, gl.TEXTURE_2D, texture, 0);
61
+ return fbo;
62
+ };
63
+ return GL;
64
+ }());
65
+ export { GL };
@@ -0,0 +1,2 @@
1
+ declare const OutlineFragmentShader = "\n precision mediump float;\n \n uniform sampler2D u_texture;\n varying vec2 v_texpos;\n \n void main() {\n vec4 color = texture2D(u_texture, v_texpos);\n if(color == vec4(0.0, 0.0, 0.0, 1.0)) {\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n }\n";
2
+ export { OutlineFragmentShader };
@@ -0,0 +1,2 @@
1
+ var OutlineFragmentShader = /*glsl*/ "\n precision mediump float;\n \n uniform sampler2D u_texture;\n varying vec2 v_texpos;\n \n void main() {\n vec4 color = texture2D(u_texture, v_texpos);\n if(color == vec4(0.0, 0.0, 0.0, 1.0)) {\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n }\n";
2
+ export { OutlineFragmentShader };
@@ -0,0 +1,3 @@
1
+ declare const OutlineVertexShader = "\n attribute vec2 a_pos;\n attribute vec2 a_texpos;\n uniform sampler2D u_texture;\n varying vec2 v_texpos;\n\n void main() {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n v_texpos = vec2(a_texpos.x, a_texpos.y);\n }\n";
2
+ declare const OutlineFragmentShader = "\n precision mediump float;\n \n uniform sampler2D u_texture;\n varying vec2 v_texpos;\n \n void main() {\n vec4 color = texture2D(u_texture, v_texpos);\n if(color == vec4(0.0, 0.0, 0.0, 1.0)) {\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n }\n";
3
+ export { OutlineVertexShader, OutlineFragmentShader };
@@ -0,0 +1,3 @@
1
+ var OutlineVertexShader = /*glsl*/ "\n attribute vec2 a_pos;\n attribute vec2 a_texpos;\n uniform sampler2D u_texture;\n varying vec2 v_texpos;\n\n void main() {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n v_texpos = vec2(a_texpos.x, a_texpos.y);\n }\n";
2
+ var OutlineFragmentShader = /*glsl*/ "\n precision mediump float;\n \n uniform sampler2D u_texture;\n varying vec2 v_texpos;\n \n void main() {\n vec4 color = texture2D(u_texture, v_texpos);\n if(color == vec4(0.0, 0.0, 0.0, 1.0)) {\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n }\n";
3
+ export { OutlineVertexShader, OutlineFragmentShader };
@@ -0,0 +1,3 @@
1
+ declare const OutputVertexShader = "\n // Current vertex index:\n attribute float a_index;\n\n // Encoded vertices texture:\n uniform sampler2D u_texture;\n uniform float u_resolution;\n \n // UV texture\n uniform sampler2D u_uvtexture;\n uniform float u_uvresolution; \n\n // Output: vertex color to draw.\n varying vec4 v_color;\n\n // Gradient:\n uniform float u_gradientStops[12];\n uniform vec4 u_gradientColors[12]; \n\n // Point size:\n uniform float u_pointsize;\n\n //\n // Given a value, find its corresponding color in the gradient stops.\n //\n vec4 getGradientColor(float position) {\n // Find left and right stop:\n float left = -1.0;\n float right = 99.0;\n vec4 leftColor;\n vec4 rightColor;\n\n for(int i = 0; i < 12; i++) {\n if (u_gradientStops[i] <= position) {\n left = u_gradientStops[i]; \n leftColor = u_gradientColors[i];\n } else break;\n }\n\n for(int i = 12 - 1; i >= 0; i--) {\n if (u_gradientStops[i] >= position) {\n right = u_gradientStops[i]; \n rightColor = u_gradientColors[i];\n } else break;\n }\n\n // Distance between stops:\n float width = right - left;\n // Distance from left stop:\n float dist = position - left;\n // Right stop weight:\n float weight;\n if(dist == 0.0) {\n weight = dist;\n } else {\n weight = dist / width;\n }\n\n float r = leftColor.x + (rightColor.x - leftColor.x) * weight;\n float g = leftColor.y + (rightColor.y - leftColor.y) * weight;\n float b = leftColor.z + (rightColor.z - leftColor.z) * weight;\n float a = leftColor.w + (rightColor.w - leftColor.w) * weight;\n return vec4(r, g, b, a); \n } \n\n //\n // Given a vertex index, calculate its texture coordinates in the source\n // texture. Texture coordinates are 0..1, 0..1. \n // For vertex #1 and a texture of 10x10, this will return vec2(0.1, 0.0).\n // For vertex #1 and a texture of 16,16, this will return vec2(0.0625, 0.0).\n //\n vec2 indexToTexCoords(float index) {\n float yIndex = floor(index / u_resolution); // 0..1\n float xIndex = mod(index, u_resolution); // 0..1\n return vec2(xIndex, yIndex) / u_resolution;\n }\n\n const float BASE = 255.0;\n const float SCALE = 32768.0;\n const float OFFSET = 16384.0;\n\n float decodeValue(vec2 channels) {\n return (dot(channels, vec2(BASE * BASE, BASE)) - OFFSET) / SCALE;\n }\n // Decode a pixel value into x,y coordinates (0..1, 0..1)\n vec2 decode(vec4 pixel) {\n return vec2(\n decodeValue(pixel.xy),\n decodeValue(pixel.zw)\n );\n }\n\n \n //\n // Given a vertex coordinate (0..1, 0..1), find UV from texture.\n // Returns (-0.5..0.5,-0.5..0.5)\n //\n vec2 decodeSpeed(vec2 coord) {\n vec2 invcoord = vec2(coord.x, 1.0 - coord.y);\n vec4 pixel = texture2D(u_uvtexture, invcoord + 0.5/u_uvresolution);\n if(pixel.x == 0.0 && pixel.y == 0.0 && pixel.z == 0.0 && pixel.w == 0.0) return vec2(99.0, 99.0);\n // x-coordinate is RG, y-coordinate is BA:\n float u = dot(pixel.xy, vec2(255.0 * 255.0, 255.0)) / 65536.0;\n float v = dot(pixel.zw, vec2(255.0 * 255.0, 255.0)) / 65536.0;\n return vec2(u - 0.5, v - 0.5);\n }\n\n\n\n void main() {\n // From the vertex's index, get the coordinates in the texture where its\n // position is stored.\n vec2 texCoord = indexToTexCoords(a_index);\n\n // Use the vertex's index to get its current position from the texture,\n // in the 0..1, 0..1 range.\n vec2 pos = decode(texture2D(u_texture, texCoord + 0.5/u_resolution));\n\n // Vertex may be on land. If its speed is 99 according to the UV map,\n // don't draw it.\n vec2 speed = decodeSpeed(pos);\n if(speed.x == 99.0) {\n v_color = vec4(1.0,1.0,1.0,0.0);\n return;\n }\n\n // Transform position into -1..1 range:\n pos = pos * 2.0 - 1.0;\n gl_Position = vec4(pos, 0.0, 1.0);\n\n // Point size and color:\n gl_PointSize = u_pointsize;\n float absspeed = length(speed); // Max U and V are 0.5. Max vector length is then 0.7072\n v_color = getGradientColor(absspeed / 0.7072);\n\n // Show some particles in red for easy tracing:\n // if(a_index < 100.0) {\n // v_color = vec4(1.0, 0.0, 0.0, 1.0);\n // gl_PointSize = 5.0;\n // }\n }\n";
2
+ declare const OutputFragmentShader = "\n precision mediump float;\n varying vec4 v_color;\n \n void main() {\n gl_FragColor = vec4(v_color);\n }\n";
3
+ export { OutputVertexShader, OutputFragmentShader };
@@ -0,0 +1,4 @@
1
+ import { DecodeSpeed } from "./include/decodeSpeed.include";
2
+ var OutputVertexShader = /*glsl*/ "\n // Current vertex index:\n attribute float a_index;\n\n // Encoded vertices texture:\n uniform sampler2D u_texture;\n uniform float u_resolution;\n \n // UV texture\n uniform sampler2D u_uvtexture;\n uniform float u_uvresolution; \n\n // Output: vertex color to draw.\n varying vec4 v_color;\n\n // Gradient:\n uniform float u_gradientStops[12];\n uniform vec4 u_gradientColors[12]; \n\n // Point size:\n uniform float u_pointsize;\n\n //\n // Given a value, find its corresponding color in the gradient stops.\n //\n vec4 getGradientColor(float position) {\n // Find left and right stop:\n float left = -1.0;\n float right = 99.0;\n vec4 leftColor;\n vec4 rightColor;\n\n for(int i = 0; i < 12; i++) {\n if (u_gradientStops[i] <= position) {\n left = u_gradientStops[i]; \n leftColor = u_gradientColors[i];\n } else break;\n }\n\n for(int i = 12 - 1; i >= 0; i--) {\n if (u_gradientStops[i] >= position) {\n right = u_gradientStops[i]; \n rightColor = u_gradientColors[i];\n } else break;\n }\n\n // Distance between stops:\n float width = right - left;\n // Distance from left stop:\n float dist = position - left;\n // Right stop weight:\n float weight;\n if(dist == 0.0) {\n weight = dist;\n } else {\n weight = dist / width;\n }\n\n float r = leftColor.x + (rightColor.x - leftColor.x) * weight;\n float g = leftColor.y + (rightColor.y - leftColor.y) * weight;\n float b = leftColor.z + (rightColor.z - leftColor.z) * weight;\n float a = leftColor.w + (rightColor.w - leftColor.w) * weight;\n return vec4(r, g, b, a); \n } \n\n //\n // Given a vertex index, calculate its texture coordinates in the source\n // texture. Texture coordinates are 0..1, 0..1. \n // For vertex #1 and a texture of 10x10, this will return vec2(0.1, 0.0).\n // For vertex #1 and a texture of 16,16, this will return vec2(0.0625, 0.0).\n //\n vec2 indexToTexCoords(float index) {\n float yIndex = floor(index / u_resolution); // 0..1\n float xIndex = mod(index, u_resolution); // 0..1\n return vec2(xIndex, yIndex) / u_resolution;\n }\n\n const float BASE = 255.0;\n const float SCALE = 32768.0;\n const float OFFSET = 16384.0;\n\n float decodeValue(vec2 channels) {\n return (dot(channels, vec2(BASE * BASE, BASE)) - OFFSET) / SCALE;\n }\n // Decode a pixel value into x,y coordinates (0..1, 0..1)\n vec2 decode(vec4 pixel) {\n return vec2(\n decodeValue(pixel.xy),\n decodeValue(pixel.zw)\n );\n }\n\n ".concat(DecodeSpeed, "\n\n void main() {\n // From the vertex's index, get the coordinates in the texture where its\n // position is stored.\n vec2 texCoord = indexToTexCoords(a_index);\n\n // Use the vertex's index to get its current position from the texture,\n // in the 0..1, 0..1 range.\n vec2 pos = decode(texture2D(u_texture, texCoord + 0.5/u_resolution));\n\n // Vertex may be on land. If its speed is 99 according to the UV map,\n // don't draw it.\n vec2 speed = decodeSpeed(pos);\n if(speed.x == 99.0) {\n v_color = vec4(1.0,1.0,1.0,0.0);\n return;\n }\n\n // Transform position into -1..1 range:\n pos = pos * 2.0 - 1.0;\n gl_Position = vec4(pos, 0.0, 1.0);\n\n // Point size and color:\n gl_PointSize = u_pointsize;\n float absspeed = length(speed); // Max U and V are 0.5. Max vector length is then 0.7072\n v_color = getGradientColor(absspeed / 0.7072);\n\n // Show some particles in red for easy tracing:\n // if(a_index < 100.0) {\n // v_color = vec4(1.0, 0.0, 0.0, 1.0);\n // gl_PointSize = 5.0;\n // }\n }\n");
3
+ var OutputFragmentShader = /*glsl*/ "\n precision mediump float;\n varying vec4 v_color;\n \n void main() {\n gl_FragColor = vec4(v_color);\n }\n";
4
+ export { OutputVertexShader, OutputFragmentShader };
@@ -0,0 +1,2 @@
1
+ declare const OutputVertexShader = "\n // Current vertex index:\n attribute float a_index;\n\n // Encoded vertices texture:\n uniform sampler2D u_texture;\n uniform float u_resolution;\n \n // UV texture\n uniform sampler2D u_uvtexture;\n uniform float u_uvresolution; \n\n // Output: vertex color to draw.\n varying vec4 v_color;\n\n uniform float u_gradientStops[12];\n uniform vec4 u_gradientColors[12]; \n\n //\n // Given a value, find its corresponding color in the gradient stops.\n //\n vec4 getGradientColor(float position) {\n // Find left and right stop:\n float left = -1.0;\n float right = 99.0;\n vec4 leftColor;\n vec4 rightColor;\n\n for(int i = 0; i < 12; i++) {\n if (u_gradientStops[i] <= position) {\n left = u_gradientStops[i]; \n leftColor = u_gradientColors[i];\n } else break;\n }\n\n for(int i = 12 - 1; i >= 0; i--) {\n if (u_gradientStops[i] >= position) {\n right = u_gradientStops[i]; \n rightColor = u_gradientColors[i];\n } else break;\n }\n\n // Distance between stops:\n float width = right - left;\n // Distance from left stop:\n float dist = position - left;\n // Right stop weight:\n float weight;\n if(dist == 0.0) {\n weight = dist;\n } else {\n weight = dist / width;\n }\n\n float r = leftColor.x + (rightColor.x - leftColor.x) * weight;\n float g = leftColor.y + (rightColor.y - leftColor.y) * weight;\n float b = leftColor.z + (rightColor.z - leftColor.z) * weight;\n float a = leftColor.w + (rightColor.w - leftColor.w) * weight;\n return vec4(r, g, b, a); \n } \n\n //\n // Given a vertex index, calculate its texture coordinates in the source\n // texture. Texture coordinates are 0..1, 0..1. \n // For vertex #1 and a texture of 10x10, this will return vec2(0.1, 0.0).\n // For vertex #1 and a texture of 16,16, this will return vec2(0.0625, 0.0).\n //\n vec2 indexToTexCoords(float index) {\n float yIndex = floor(index / u_resolution); // 0..1\n float xIndex = mod(index, u_resolution); // 0..1\n return vec2(xIndex, yIndex) / u_resolution;\n }\n\n const float BASE = 255.0;\n const float SCALE = 32768.0;\n const float OFFSET = 16384.0;\n\n float decodeValue(vec2 channels) {\n return (dot(channels, vec2(BASE * BASE, BASE)) - OFFSET) / SCALE;\n }\n // Decode a pixel value into x,y coordinates (0..1, 0..1)\n vec2 decode(vec4 pixel) {\n return vec2(\n decodeValue(pixel.xy),\n decodeValue(pixel.zw)\n );\n }\n\n //\n // Given a vertex coordinate (0..1, 0..1), find UV from texture.\n vec2 decodeSpeed(vec2 coord) {\n vec2 invcoord = vec2(coord.x, 1.0 - coord.y);\n vec4 pixel = texture2D(u_uvtexture, invcoord + 0.5/u_uvresolution);\n // pixel = texture2D(u_uvtexture, vec2(0.9, 0.1));\n if(pixel.w == 0.0) return vec2(99.0, 99.0);\n return vec2(pixel.x - 0.5, pixel.y - 0.5);\n } \n\n void main() {\n // From the vertex's index, get the coordinates in the texture where its\n // position is stored.\n vec2 texCoord = indexToTexCoords(a_index);\n\n // Use the vertex's index to get its current position from the texture,\n // in the 0..1, 0..1 range.\n vec2 pos = decode(texture2D(u_texture, texCoord + 0.5/u_resolution));\n\n // Vertex may be on land. If its speed is 99 according to the UV map,\n // don't draw it.\n vec2 speed = decodeSpeed(pos);\n if(speed.x == 99.0) {\n v_color = vec4(0.0,0.0,0.0,0.0);\n return;\n }\n\n // Transform position into -1..1 range:\n pos = pos * 2.0 - 1.0;\n\n gl_Position = vec4(pos, 0.0, 1.0);\n\n gl_PointSize = 1.0;\n \n float absspeed = length(speed); // up to 0.6\n v_color = getGradientColor(absspeed * 3.5);\n }\n";
2
+ export { OutputVertexShader };
@@ -0,0 +1,2 @@
1
+ var OutputVertexShader = /*glsl*/ "\n // Current vertex index:\n attribute float a_index;\n\n // Encoded vertices texture:\n uniform sampler2D u_texture;\n uniform float u_resolution;\n \n // UV texture\n uniform sampler2D u_uvtexture;\n uniform float u_uvresolution; \n\n // Output: vertex color to draw.\n varying vec4 v_color;\n\n uniform float u_gradientStops[12];\n uniform vec4 u_gradientColors[12]; \n\n //\n // Given a value, find its corresponding color in the gradient stops.\n //\n vec4 getGradientColor(float position) {\n // Find left and right stop:\n float left = -1.0;\n float right = 99.0;\n vec4 leftColor;\n vec4 rightColor;\n\n for(int i = 0; i < 12; i++) {\n if (u_gradientStops[i] <= position) {\n left = u_gradientStops[i]; \n leftColor = u_gradientColors[i];\n } else break;\n }\n\n for(int i = 12 - 1; i >= 0; i--) {\n if (u_gradientStops[i] >= position) {\n right = u_gradientStops[i]; \n rightColor = u_gradientColors[i];\n } else break;\n }\n\n // Distance between stops:\n float width = right - left;\n // Distance from left stop:\n float dist = position - left;\n // Right stop weight:\n float weight;\n if(dist == 0.0) {\n weight = dist;\n } else {\n weight = dist / width;\n }\n\n float r = leftColor.x + (rightColor.x - leftColor.x) * weight;\n float g = leftColor.y + (rightColor.y - leftColor.y) * weight;\n float b = leftColor.z + (rightColor.z - leftColor.z) * weight;\n float a = leftColor.w + (rightColor.w - leftColor.w) * weight;\n return vec4(r, g, b, a); \n } \n\n //\n // Given a vertex index, calculate its texture coordinates in the source\n // texture. Texture coordinates are 0..1, 0..1. \n // For vertex #1 and a texture of 10x10, this will return vec2(0.1, 0.0).\n // For vertex #1 and a texture of 16,16, this will return vec2(0.0625, 0.0).\n //\n vec2 indexToTexCoords(float index) {\n float yIndex = floor(index / u_resolution); // 0..1\n float xIndex = mod(index, u_resolution); // 0..1\n return vec2(xIndex, yIndex) / u_resolution;\n }\n\n const float BASE = 255.0;\n const float SCALE = 32768.0;\n const float OFFSET = 16384.0;\n\n float decodeValue(vec2 channels) {\n return (dot(channels, vec2(BASE * BASE, BASE)) - OFFSET) / SCALE;\n }\n // Decode a pixel value into x,y coordinates (0..1, 0..1)\n vec2 decode(vec4 pixel) {\n return vec2(\n decodeValue(pixel.xy),\n decodeValue(pixel.zw)\n );\n }\n\n //\n // Given a vertex coordinate (0..1, 0..1), find UV from texture.\n vec2 decodeSpeed(vec2 coord) {\n vec2 invcoord = vec2(coord.x, 1.0 - coord.y);\n vec4 pixel = texture2D(u_uvtexture, invcoord + 0.5/u_uvresolution);\n // pixel = texture2D(u_uvtexture, vec2(0.9, 0.1));\n if(pixel.w == 0.0) return vec2(99.0, 99.0);\n return vec2(pixel.x - 0.5, pixel.y - 0.5);\n } \n\n void main() {\n // From the vertex's index, get the coordinates in the texture where its\n // position is stored.\n vec2 texCoord = indexToTexCoords(a_index);\n\n // Use the vertex's index to get its current position from the texture,\n // in the 0..1, 0..1 range.\n vec2 pos = decode(texture2D(u_texture, texCoord + 0.5/u_resolution));\n\n // Vertex may be on land. If its speed is 99 according to the UV map,\n // don't draw it.\n vec2 speed = decodeSpeed(pos);\n if(speed.x == 99.0) {\n v_color = vec4(0.0,0.0,0.0,0.0);\n return;\n }\n\n // Transform position into -1..1 range:\n pos = pos * 2.0 - 1.0;\n\n gl_Position = vec4(pos, 0.0, 1.0);\n\n gl_PointSize = 1.0;\n \n float absspeed = length(speed); // up to 0.6\n v_color = getGradientColor(absspeed * 3.5);\n }\n";
2
+ export { OutputVertexShader };
@@ -0,0 +1,91 @@
1
+ import * as React from 'react';
2
+ import { IGradientStop } from '../../map/layers/InterpolationLayer/IGradientStop';
3
+ interface IProps {
4
+ /** @ignore */
5
+ className?: string;
6
+ /**
7
+ * Gradient stops. A default gradient is preset.
8
+ */
9
+ gradientStops?: IGradientStop[];
10
+ /**
11
+ * Number of particles.
12
+ * @default 100000;
13
+ */
14
+ numParticles?: number;
15
+ /**
16
+ * If true, renders a globe. Otherwise a flat map.
17
+ * @default false
18
+ */
19
+ globe?: boolean;
20
+ /**
21
+ * The original particle speed (in m/s) is divided by this factor to calculate
22
+ * the final particle speed in pixels/frame.
23
+ * @edefault 1000.0
24
+ */
25
+ speedFactor?: number;
26
+ /**
27
+ * If not 0, draw particle trails. The value is the fade strength.
28
+ * @default 0
29
+ */
30
+ trails?: number;
31
+ /**
32
+ * Point size (in pixels). Minimum is 1.
33
+ * @default 1
34
+ */
35
+ pointSize?: number;
36
+ /**
37
+ * X-axis angle, in degrees (0-360)
38
+ * @default 15
39
+ */
40
+ angleX?: number;
41
+ /**
42
+ * Y-axis angle, in degrees (0-360)
43
+ * @default 0
44
+ */
45
+ angleY?: number;
46
+ /**
47
+ * X-axis (horizontal axis) rotation per frame, in degrees (0-360)
48
+ * @default 0
49
+ */
50
+ deltaX?: number;
51
+ /**
52
+ * Y-axis (vertical axis) rotation per frame, in degrees (0-360)
53
+ * @default 0.02
54
+ */
55
+ deltaY?: number;
56
+ /**
57
+ * If true, draw landmass outlines.
58
+ * @default false
59
+ */
60
+ outlines?: boolean;
61
+ /**
62
+ * @default 60
63
+ */
64
+ minLifetime?: number;
65
+ /**
66
+ * @default 1000
67
+ */
68
+ maxLifetime?: number;
69
+ /**
70
+ * Adds an aura to the globe. This is the thickness of the aura, in pixels.
71
+ * @default 0
72
+ */
73
+ glow?: number;
74
+ /**
75
+ * Landmass display.
76
+ * @default none
77
+ */
78
+ landmass?: 'day' | 'night' | 'none';
79
+ /**
80
+ * Landmass brightness.
81
+ * @default 1.0
82
+ */
83
+ brightness?: number;
84
+ /**
85
+ * If set, globe rotates slightly when the mouse approximates the corners of the viewport.
86
+ * @default false
87
+ */
88
+ responsive?: boolean;
89
+ }
90
+ declare const ParticleGlobe: ({ numParticles, globe, trails, pointSize, angleX, angleY, deltaX, deltaY, outlines, minLifetime, maxLifetime, glow, landmass, brightness, speedFactor, responsive, gradientStops, ...props }: IProps) => React.JSX.Element;
91
+ export { ParticleGlobe };