@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,508 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
5
+ var __assign = (this && this.__assign) || function () {
6
+ __assign = Object.assign || function(t) {
7
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
8
+ s = arguments[i];
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
+ t[p] = s[p];
11
+ }
12
+ return t;
13
+ };
14
+ return __assign.apply(this, arguments);
15
+ };
16
+ var __rest = (this && this.__rest) || function (s, e) {
17
+ var t = {};
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
+ t[p] = s[p];
20
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
+ t[p[i]] = s[p[i]];
24
+ }
25
+ return t;
26
+ };
27
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
28
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
29
+ if (ar || !(i in from)) {
30
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
31
+ ar[i] = from[i];
32
+ }
33
+ }
34
+ return to.concat(ar || Array.prototype.slice.call(from));
35
+ };
36
+ import * as React from 'react';
37
+ import styled, { css } from 'styled-components';
38
+ import { mat4 } from 'gl-matrix';
39
+ import { GL } from './GL';
40
+ import { PointsVertexShader, PointsFragmentShader } from './PointsShader';
41
+ import { TextureVertexShader, TextureFragmentShader } from './TextureShader';
42
+ import { OutputVertexShader, OutputFragmentShader } from './OutputShader';
43
+ import { FadeVertexShader, FadeFragmentShader } from './FadeShader';
44
+ import { OutlineVertexShader, OutlineFragmentShader } from './OutlineShader';
45
+ import { SphereVertexShader, SphereFragmentShader } from './SphereShader';
46
+ import { RgbColor } from '../../helper/RgbColor';
47
+ var VERTEX_TEXTURE_SIZE = 2048; // horizontal and vertical resolution
48
+ var UV_TEXTURE_SIZE = 1024;
49
+ var OUTPUT_TEXTURE_SIZE = 2048;
50
+ var ParticleGlobeBase = function (props) {
51
+ var wrapperRef = React.useRef(null);
52
+ var canvasRef = React.useRef(null);
53
+ var gl = React.useRef(null);
54
+ // Programs:
55
+ var textureProgram = React.useRef(null);
56
+ var pointsProgram = React.useRef(null);
57
+ var outputProgram = React.useRef(null);
58
+ var fadeProgram = React.useRef(null);
59
+ var outlineProgram = React.useRef(null);
60
+ var sphereProgram = React.useRef(null);
61
+ // Textures:
62
+ var texture1 = React.useRef(null);
63
+ var texture2 = React.useRef(null);
64
+ var textureOut = React.useRef(null);
65
+ var textureUV = React.useRef(null);
66
+ var textureLandmass = React.useRef(null);
67
+ var textureSphere = React.useRef(null);
68
+ // Frame buffers:
69
+ var fbo1 = React.useRef(null);
70
+ var fbo2 = React.useRef(null);
71
+ var fboOut = React.useRef(null);
72
+ var fboSphere = React.useRef(null);
73
+ // Data buffers:
74
+ var squareBuffer = React.useRef(null);
75
+ var pointsBuffer = React.useRef(null);
76
+ var sphereVerticesBuffer = React.useRef(null);
77
+ var sphereNormalsBuffer = React.useRef(null);
78
+ var sphereTexCoordsBuffer = React.useRef(null);
79
+ var sphereElementCount = React.useRef(0);
80
+ // Other:
81
+ var animationID = React.useRef(null);
82
+ var angleX = React.useRef(props.angleX);
83
+ var angleY = React.useRef(props.angleY);
84
+ var frame = React.useRef(0);
85
+ var swap = React.useRef(false);
86
+ var mouseX = React.useRef(0);
87
+ var mouseY = React.useRef(0);
88
+ var createSourceTexture = function (gl, size) {
89
+ // Prepare x,y positions for vertices;
90
+ // Reserve 2 bytes for X-position, and 2 bytes for Y-position,
91
+ // so a total of 4 bytes per vertex.
92
+ var arr = new Uint8Array(VERTEX_TEXTURE_SIZE * VERTEX_TEXTURE_SIZE * 4);
93
+ arr.fill(255);
94
+ for (var i = 0; i < props.numParticles; i++) {
95
+ var x = Math.random();
96
+ var y = Math.random();
97
+ // Multiply this by 65536 to occupy two bytes.
98
+ var xx = Math.floor(x * 32768) + 16384; // 655
99
+ var yy = Math.floor(y * 32768) + 16384; // 655
100
+ arr[i * 4 + 0] = xx >> 8; // 2
101
+ arr[i * 4 + 1] = xx & 255; // 143
102
+ arr[i * 4 + 2] = yy >> 8; // 2
103
+ arr[i * 4 + 3] = yy & 255; // 143
104
+ }
105
+ return GL.createRGBATexture(gl, VERTEX_TEXTURE_SIZE, arr, false);
106
+ };
107
+ var createEmptyTexture = function (gl, size) {
108
+ return GL.createRGBATexture(gl, size, null, false);
109
+ };
110
+ var createUVTexture = function (gl, image) {
111
+ return GL.createImageTexture(gl, image, false);
112
+ };
113
+ var createLandmassTexture = function (gl, image) {
114
+ return GL.createImageTexture(gl, image, true);
115
+ };
116
+ var createPointsBuffer = function (gl) {
117
+ pointsBuffer.current = gl.createBuffer();
118
+ gl.bindBuffer(gl.ARRAY_BUFFER, pointsBuffer.current);
119
+ var positions = [];
120
+ // Create vertex indices: 0, 1, 2, ...
121
+ for (var i = 0; i < props.numParticles; i++)
122
+ positions.push(i);
123
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);
124
+ };
125
+ var createSquareBuffer = function (gl) {
126
+ // Create 6 vertices that form 2 triangles, with texture coordinates
127
+ // so that a texture exactly covers the rectangle formed by the
128
+ // triangles.
129
+ squareBuffer.current = gl.createBuffer();
130
+ gl.bindBuffer(gl.ARRAY_BUFFER, squareBuffer.current);
131
+ var a = 1.0;
132
+ var positions = [
133
+ // Triangle 1:
134
+ // coords, tcoords
135
+ -a, -a, 0.0, 1.0,
136
+ -a, a, 0.0, 0.0,
137
+ a, a, 1.0, 0.0,
138
+ // coords, tcoords
139
+ // Triangle 2:
140
+ -a, -a, 0.0, 1.0,
141
+ a, -a, 1.0, 1.0,
142
+ a, a, 1.0, 0.0
143
+ ];
144
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);
145
+ };
146
+ var createSphere = function (gl, radius, latBands, longBands) {
147
+ var positions = [];
148
+ var normals = [];
149
+ var textureCoords = [];
150
+ for (var lat = 0; lat < latBands; ++lat) {
151
+ for (var long = 0; long < longBands; ++long) {
152
+ var theta = lat * Math.PI / latBands;
153
+ var phi = long * 2 * Math.PI / longBands;
154
+ var x1 = Math.cos(phi) * Math.sin(theta);
155
+ var y1 = Math.cos(theta);
156
+ var z1 = Math.sin(phi) * Math.sin(theta);
157
+ var u1 = long / longBands; // Horizontal texture coordinate
158
+ var v1 = 1 - (lat / latBands); // Vertical texture coordinate (inverted for proper mapping)
159
+ var x2 = Math.cos(phi) * Math.sin(theta + Math.PI / latBands);
160
+ var y2 = Math.cos(theta + Math.PI / latBands);
161
+ var z2 = Math.sin(phi) * Math.sin(theta + Math.PI / latBands);
162
+ var u2 = long / longBands; // Same horizontal texture coordinate
163
+ var v2 = 1 - ((lat + 1) / latBands); // Next latitude for the next triangle
164
+ var x3 = Math.cos(phi + (2 * Math.PI / longBands)) * Math.sin(theta);
165
+ var y3 = Math.cos(theta);
166
+ var z3 = Math.sin(phi + (2 * Math.PI / longBands)) * Math.sin(theta);
167
+ var u3 = (long + 1) / longBands; // Next longitude
168
+ var v3 = 1 - (lat / latBands); // Same vertical texture coordinate
169
+ // Push the first triangle
170
+ positions.push(radius * x1, radius * y1, radius * z1);
171
+ normals.push(x1, y1, z1);
172
+ textureCoords.push(u1, v1);
173
+ positions.push(radius * x2, radius * y2, radius * z2);
174
+ normals.push(x2, y2, z2);
175
+ textureCoords.push(u2, v2);
176
+ positions.push(radius * x3, radius * y3, radius * z3);
177
+ normals.push(x3, y3, z3);
178
+ textureCoords.push(u3, v3);
179
+ // Push the second triangle
180
+ positions.push(radius * x2, radius * y2, radius * z2);
181
+ normals.push(x2, y2, z2);
182
+ textureCoords.push(u2, v2);
183
+ positions.push(radius * x3, radius * y3, radius * z3);
184
+ normals.push(x3, y3, z3);
185
+ textureCoords.push(u3, v3);
186
+ var x4 = Math.cos(phi + (2 * Math.PI / longBands)) * Math.sin(theta + Math.PI / latBands);
187
+ var y4 = Math.cos(theta + Math.PI / latBands);
188
+ var z4 = Math.sin(phi + (2 * Math.PI / longBands)) * Math.sin(theta + Math.PI / latBands);
189
+ var u4 = (long + 1) / longBands; // Next longitude
190
+ var v4 = 1 - ((lat + 1) / latBands); // Next latitude for the next triangle
191
+ positions.push(radius * x4, radius * y4, radius * z4);
192
+ normals.push(x4, y4, z4);
193
+ textureCoords.push(u4, v4);
194
+ }
195
+ }
196
+ sphereVerticesBuffer.current = gl.createBuffer();
197
+ gl.bindBuffer(gl.ARRAY_BUFFER, sphereVerticesBuffer.current);
198
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);
199
+ sphereNormalsBuffer.current = gl.createBuffer();
200
+ gl.bindBuffer(gl.ARRAY_BUFFER, sphereNormalsBuffer.current);
201
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normals), gl.STATIC_DRAW);
202
+ sphereTexCoordsBuffer.current = gl.createBuffer();
203
+ gl.bindBuffer(gl.ARRAY_BUFFER, sphereTexCoordsBuffer.current);
204
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(textureCoords), gl.STATIC_DRAW);
205
+ sphereElementCount.current = positions.length / 3;
206
+ };
207
+ var drawVertices = function (gl, sourceTexture) {
208
+ var program = pointsProgram.current;
209
+ gl.useProgram(program);
210
+ // Random seed:
211
+ gl.uniform1i(gl.getUniformLocation(program, "u_frame"), frame.current);
212
+ gl.uniform1f(gl.getUniformLocation(program, "u_seed"), Math.random());
213
+ // Particle lifetime:
214
+ gl.uniform1f(gl.getUniformLocation(program, "u_minlifetime"), props.minLifetime);
215
+ gl.uniform1f(gl.getUniformLocation(program, "u_maxlifetime"), props.maxLifetime);
216
+ // Speed factor:
217
+ gl.uniform1f(gl.getUniformLocation(program, "u_speedfactor"), props.speedFactor);
218
+ // Texture:
219
+ gl.activeTexture(gl.TEXTURE0);
220
+ gl.bindTexture(gl.TEXTURE_2D, sourceTexture);
221
+ gl.uniform1i(gl.getUniformLocation(program, "u_texture"), 0);
222
+ gl.uniform1f(gl.getUniformLocation(program, "u_resolution"), VERTEX_TEXTURE_SIZE);
223
+ gl.activeTexture(gl.TEXTURE1);
224
+ gl.bindTexture(gl.TEXTURE_2D, textureUV.current);
225
+ gl.uniform1i(gl.getUniformLocation(program, "u_uvtexture"), 1);
226
+ gl.uniform1f(gl.getUniformLocation(program, "u_uvresolution"), UV_TEXTURE_SIZE);
227
+ var aIndex = gl.getAttribLocation(program, "a_index");
228
+ gl.bindBuffer(gl.ARRAY_BUFFER, pointsBuffer.current);
229
+ gl.vertexAttribPointer(aIndex, 1, gl.FLOAT, false, 0, 0);
230
+ gl.enableVertexAttribArray(aIndex);
231
+ gl.disable(gl.BLEND);
232
+ gl.drawArrays(gl.POINTS, 0, props.numParticles);
233
+ };
234
+ var drawTexture = function (gl, texture, blend, flip, brightness) {
235
+ if (blend === void 0) { blend = true; }
236
+ if (flip === void 0) { flip = false; }
237
+ if (brightness === void 0) { brightness = 1.0; }
238
+ var program = textureProgram.current;
239
+ gl.useProgram(program);
240
+ // Bind the texture:
241
+ gl.activeTexture(gl.TEXTURE0);
242
+ gl.bindTexture(gl.TEXTURE_2D, texture);
243
+ gl.uniform1i(gl.getUniformLocation(program, "u_texture"), 0);
244
+ // Is the texture flipped vertically?
245
+ gl.uniform1i(gl.getUniformLocation(program, "u_flip"), flip ? 1 : 0);
246
+ // Texture brightness
247
+ gl.uniform1f(gl.getUniformLocation(program, "u_brightness"), brightness);
248
+ // Bind vertices and texture coordinates:
249
+ var aPos = gl.getAttribLocation(program, "a_pos");
250
+ var aTexPos = gl.getAttribLocation(program, "a_texpos");
251
+ gl.bindBuffer(gl.ARRAY_BUFFER, squareBuffer.current);
252
+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
253
+ gl.enableVertexAttribArray(aPos);
254
+ gl.vertexAttribPointer(aTexPos, 2, gl.FLOAT, false, 16, 8);
255
+ gl.enableVertexAttribArray(aTexPos);
256
+ if (blend) {
257
+ gl.enable(gl.BLEND);
258
+ gl.blendFunc(gl.ONE, gl.ONE);
259
+ }
260
+ else {
261
+ gl.enable(gl.BLEND);
262
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
263
+ }
264
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
265
+ };
266
+ var drawOutput = function (gl, texture) {
267
+ var program = outputProgram.current;
268
+ gl.useProgram(program);
269
+ // Stops - fill up to 12 stops by using values > 1 for filler stops.
270
+ // e.g. [0.0, 0.5, 1.0, 2.0....] means that only the first 3 stops are used.
271
+ var stops = __spreadArray([], props.gradientStops.map(function (s) { return s.pos; }), true);
272
+ while (stops.length < 12)
273
+ stops.push(2.0);
274
+ gl.uniform1fv(gl.getUniformLocation(program, 'u_gradientStops'), new Float32Array(stops));
275
+ var colors = props.gradientStops.map(function (s) { return RgbColor.toRGBA(s.color); }).flat();
276
+ gl.uniform4fv(gl.getUniformLocation(program, 'u_gradientColors'), new Float32Array(colors));
277
+ // The vertex atlas texture goes in:
278
+ gl.activeTexture(gl.TEXTURE0);
279
+ gl.bindTexture(gl.TEXTURE_2D, texture);
280
+ gl.uniform1i(gl.getUniformLocation(program, "u_texture"), 0);
281
+ gl.uniform1f(gl.getUniformLocation(program, "u_resolution"), VERTEX_TEXTURE_SIZE);
282
+ gl.activeTexture(gl.TEXTURE1);
283
+ gl.bindTexture(gl.TEXTURE_2D, textureUV.current);
284
+ gl.uniform1i(gl.getUniformLocation(program, "u_uvtexture"), 1);
285
+ gl.uniform1f(gl.getUniformLocation(program, "u_uvresolution"), UV_TEXTURE_SIZE);
286
+ // Point size:
287
+ gl.uniform1f(gl.getUniformLocation(program, "u_pointsize"), props.pointSize);
288
+ // Vertex indices:
289
+ var aIndex = gl.getAttribLocation(program, "a_index");
290
+ gl.bindBuffer(gl.ARRAY_BUFFER, pointsBuffer.current);
291
+ gl.vertexAttribPointer(aIndex, 1, gl.FLOAT, false, 0, 0);
292
+ gl.enableVertexAttribArray(aIndex);
293
+ // Draw points:
294
+ gl.enable(gl.BLEND);
295
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
296
+ gl.drawArrays(gl.POINTS, 0, props.numParticles);
297
+ };
298
+ var drawOutline = function (gl) {
299
+ var program = outlineProgram.current;
300
+ gl.useProgram(program);
301
+ gl.activeTexture(gl.TEXTURE0);
302
+ gl.bindTexture(gl.TEXTURE_2D, textureUV.current);
303
+ gl.uniform1i(gl.getUniformLocation(program, "u_texture"), 0);
304
+ var aPos = gl.getAttribLocation(program, "a_pos");
305
+ var aTexPos = gl.getAttribLocation(program, "a_texpos");
306
+ gl.bindBuffer(gl.ARRAY_BUFFER, squareBuffer.current);
307
+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
308
+ gl.enableVertexAttribArray(aPos);
309
+ gl.vertexAttribPointer(aTexPos, 2, gl.FLOAT, false, 16, 8);
310
+ gl.enableVertexAttribArray(aTexPos);
311
+ gl.enable(gl.BLEND);
312
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
313
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
314
+ };
315
+ var drawSphere = function (gl) {
316
+ var program = sphereProgram.current;
317
+ gl.useProgram(program);
318
+ gl.clearDepth(1.0); // Clear everything
319
+ gl.enable(gl.DEPTH_TEST); // Enable depth testing
320
+ gl.depthFunc(gl.LEQUAL); // Near things obscure far things
321
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
322
+ //gl.enable(gl.CULL_FACE);
323
+ //gl.cullFace(gl.BACK);
324
+ var fieldOfView = (45 * Math.PI) / 180; // in radians
325
+ var aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;
326
+ var zNear = 1.0;
327
+ var zFar = 100.0;
328
+ var projectionMatrix = mat4.create();
329
+ // note: glmatrix.js always has the first argument
330
+ // as the destination to receive the result.
331
+ mat4.perspective(projectionMatrix, fieldOfView, aspect, zNear, zFar);
332
+ // Set the drawing position to the "identity" point, which is
333
+ // the center of the scene.
334
+ var modelViewMatrix = mat4.create();
335
+ // Now move the drawing position a bit to where we want to
336
+ // start drawing the square.
337
+ mat4.translate(modelViewMatrix, // destination matrix
338
+ modelViewMatrix, // matrix to translate
339
+ [0.0, 0.0, -2.61]); // amount to translate
340
+ mat4.rotate(modelViewMatrix, modelViewMatrix, angleX.current * Math.PI / 180 + (props.responsive ? mouseY.current / 10.0 : 0), [1, 0, 0]);
341
+ mat4.rotate(modelViewMatrix, modelViewMatrix, angleY.current * Math.PI / 180 + (props.responsive ? mouseX.current / 10.0 : 0), [0, 1, 0]);
342
+ gl.uniformMatrix4fv(gl.getUniformLocation(program, "uProjectionMatrix"), false, projectionMatrix);
343
+ gl.uniformMatrix4fv(gl.getUniformLocation(program, "uModelViewMatrix"), false, modelViewMatrix);
344
+ gl.activeTexture(gl.TEXTURE0);
345
+ gl.bindTexture(gl.TEXTURE_2D, textureSphere.current);
346
+ gl.uniform1i(gl.getUniformLocation(program, "uTexture"), 0);
347
+ gl.bindBuffer(gl.ARRAY_BUFFER, sphereVerticesBuffer.current);
348
+ var aPosition = gl.getAttribLocation(program, "aPosition");
349
+ gl.vertexAttribPointer(aPosition, 3, gl.FLOAT, false, 0, 0);
350
+ gl.enableVertexAttribArray(aPosition);
351
+ gl.bindBuffer(gl.ARRAY_BUFFER, sphereNormalsBuffer.current);
352
+ var aNormal = gl.getAttribLocation(program, "aNormal");
353
+ gl.vertexAttribPointer(aNormal, 3, gl.FLOAT, false, 0, 0);
354
+ gl.enableVertexAttribArray(aNormal);
355
+ gl.bindBuffer(gl.ARRAY_BUFFER, sphereTexCoordsBuffer.current);
356
+ var aTexCoord = gl.getAttribLocation(program, "aTexCoord");
357
+ gl.vertexAttribPointer(aTexCoord, 2, gl.FLOAT, false, 0, 0);
358
+ gl.enableVertexAttribArray(aTexCoord);
359
+ gl.disable(gl.BLEND);
360
+ gl.drawArrays(gl.TRIANGLES, 0, sphereElementCount.current);
361
+ };
362
+ var drawFade = function (gl) {
363
+ var program = fadeProgram.current;
364
+ gl.useProgram(program);
365
+ var aPos = gl.getAttribLocation(program, "a_pos");
366
+ gl.bindBuffer(gl.ARRAY_BUFFER, squareBuffer.current);
367
+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
368
+ gl.enableVertexAttribArray(aPos);
369
+ gl.enable(gl.BLEND);
370
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
371
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
372
+ };
373
+ var draw = function (gl) {
374
+ frame.current++;
375
+ swap.current = !swap.current;
376
+ // Draw into swapping framebuffer:
377
+ gl.viewport(0, 0, VERTEX_TEXTURE_SIZE, VERTEX_TEXTURE_SIZE);
378
+ gl.bindFramebuffer(gl.FRAMEBUFFER, swap.current ? fbo2.current : fbo1.current);
379
+ gl.clearColor(0.0, 0.0, 0.0, 1.0); // clear to transparent
380
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
381
+ drawVertices(gl, swap.current ? texture1.current : texture2.current);
382
+ // Draw result into "out" framebuffer:
383
+ gl.viewport(0, 0, OUTPUT_TEXTURE_SIZE, OUTPUT_TEXTURE_SIZE);
384
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fboOut.current);
385
+ if (props.trails == 0) {
386
+ gl.clearColor(0.0, 0.0, 0.0, 0.0); // clear to transparent
387
+ gl.clear(gl.COLOR_BUFFER_BIT);
388
+ }
389
+ else {
390
+ if (frame.current % props.trails == 0)
391
+ drawFade(gl);
392
+ }
393
+ drawOutput(gl, swap.current ? texture2.current : texture1.current);
394
+ if (props.outlines) {
395
+ drawOutline(gl);
396
+ }
397
+ if (props.globe == true) {
398
+ // Sphere view: draw to sphere fbo
399
+ gl.viewport(0, 0, OUTPUT_TEXTURE_SIZE, OUTPUT_TEXTURE_SIZE);
400
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fboSphere.current);
401
+ gl.clearColor(0.0, 0.0, 0.0, 1.0); // clear to black
402
+ gl.clear(gl.COLOR_BUFFER_BIT);
403
+ if (props.landmass != 'none')
404
+ drawTexture(gl, textureLandmass.current, false, false, props.brightness);
405
+ drawTexture(gl, textureOut.current, true, true, 1.0);
406
+ // Sphere view: draw sphere texture to screen
407
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
408
+ gl.viewport(0, 0, 1024, 768);
409
+ gl.clearColor(0.0, 0.0, 0.0, 0.0); // clear to transparent
410
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
411
+ drawSphere(gl);
412
+ }
413
+ else {
414
+ // Map view: draw directly to screen:
415
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
416
+ gl.viewport(0, 0, 1024 * 2, 768 * 2);
417
+ gl.clearColor(0.0, 0.0, 0.0, 0.0); // clear to transparent
418
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
419
+ if (props.landmass != 'none')
420
+ drawTexture(gl, textureLandmass.current, false);
421
+ drawTexture(gl, textureOut.current, true, true);
422
+ }
423
+ };
424
+ var handleMouseMove = function (e) {
425
+ mouseX.current = e.clientX / wrapperRef.current.clientWidth * 2.0 - 1.0;
426
+ mouseY.current = e.clientY / wrapperRef.current.clientHeight * 2.0 - 1.0;
427
+ };
428
+ var animate = function () {
429
+ draw(gl.current);
430
+ angleX.current = (angleX.current + props.deltaX) % 360;
431
+ angleY.current = (angleY.current + props.deltaY) % 360;
432
+ animationID.current = requestAnimationFrame(animate);
433
+ };
434
+ var setup = function (uvImage, nightImage) {
435
+ if (!canvasRef.current)
436
+ return;
437
+ gl.current = canvasRef.current.getContext("webgl");
438
+ pointsProgram.current = GL.createProgram(gl.current, PointsVertexShader, PointsFragmentShader);
439
+ outputProgram.current = GL.createProgram(gl.current, OutputVertexShader, OutputFragmentShader);
440
+ fadeProgram.current = GL.createProgram(gl.current, FadeVertexShader, FadeFragmentShader);
441
+ outlineProgram.current = GL.createProgram(gl.current, OutlineVertexShader, OutlineFragmentShader);
442
+ sphereProgram.current = GL.createProgram(gl.current, SphereVertexShader, SphereFragmentShader);
443
+ textureProgram.current = GL.createProgram(gl.current, TextureVertexShader, TextureFragmentShader);
444
+ createPointsBuffer(gl.current);
445
+ createSquareBuffer(gl.current);
446
+ createSphere(gl.current, 1, 60, 60);
447
+ texture1.current = createSourceTexture(gl.current, VERTEX_TEXTURE_SIZE);
448
+ texture2.current = createEmptyTexture(gl.current, VERTEX_TEXTURE_SIZE);
449
+ textureUV.current = createUVTexture(gl.current, uvImage);
450
+ textureOut.current = createEmptyTexture(gl.current, OUTPUT_TEXTURE_SIZE);
451
+ if (props.landmass != 'none')
452
+ textureLandmass.current = createLandmassTexture(gl.current, nightImage);
453
+ textureSphere.current = createEmptyTexture(gl.current, OUTPUT_TEXTURE_SIZE);
454
+ fbo1.current = GL.createFrameBuffer(gl.current, texture1.current);
455
+ fbo2.current = GL.createFrameBuffer(gl.current, texture2.current);
456
+ fboOut.current = GL.createFrameBuffer(gl.current, textureOut.current);
457
+ fboSphere.current = GL.createFrameBuffer(gl.current, textureSphere.current);
458
+ animationID.current = window.requestAnimationFrame(animate);
459
+ };
460
+ var step2 = function (image) {
461
+ if (props.landmass != 'none') {
462
+ var img_1 = new Image();
463
+ img_1.onload = function () { return setup(image, img_1); };
464
+ img_1.src = props.landmass == 'day' ? "resources/color-2048.jpg" : "resources/night-2048.jpg";
465
+ }
466
+ else {
467
+ setup(image, null);
468
+ }
469
+ };
470
+ var start = function () {
471
+ var img = new Image();
472
+ img.onload = function () { return step2(img); };
473
+ img.src = "resources/normals-currents.png";
474
+ };
475
+ React.useEffect(function () {
476
+ start();
477
+ if (props.responsive)
478
+ document.addEventListener('mousemove', handleMouseMove);
479
+ return function () {
480
+ window.cancelAnimationFrame(animationID.current);
481
+ document.removeEventListener('mousemove', handleMouseMove);
482
+ };
483
+ }, []);
484
+ return (React.createElement("div", { className: props.className, ref: wrapperRef },
485
+ React.createElement("canvas", { ref: canvasRef, width: "1024", height: "768" })));
486
+ };
487
+ var ParticleGlobeStyled = styled(ParticleGlobeBase)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background-color: transparent;\n box-sizing: border-box;\n ", "\n canvas {\n width: 100%;\n height: 100%;\n }\n ", "\n"], ["\n position: relative;\n z-index: 0;\n width: 100%;\n height: 100%;\n background-color: transparent;\n box-sizing: border-box;\n ", "\n canvas {\n width: 100%;\n height: 100%;\n }\n ", "\n"])), function (p) { return p.globe && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: ", "px;\n "], ["\n padding: ", "px;\n "])), p.glow); }, function (p) { return p.globe && css(templateObject_2 || (templateObject_2 = __makeTemplateObject([" \n &:before {\n position: absolute;\n z-index: -1;\n content: '';\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n background: radial-gradient(circle closest-side at center, black 0%, black calc(100% - ", "px), white calc(100% - ", "px), transparent 100%);\n }\n "], [" \n &:before {\n position: absolute;\n z-index: -1;\n content: '';\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n background: radial-gradient(circle closest-side at center, black 0%, black calc(100% - ", "px), white calc(100% - ", "px), transparent 100%);\n }\n "])), p.glow + 2, p.glow + 2); });
488
+ var ParticleGlobeWrapper = function (props) {
489
+ return React.createElement(ParticleGlobeStyled, __assign({}, props));
490
+ };
491
+ var ParticleGlobe = function (_a) {
492
+ var _b = _a.numParticles, numParticles = _b === void 0 ? 100000 : _b, _c = _a.globe, globe = _c === void 0 ? false : _c, _d = _a.trails, trails = _d === void 0 ? 0 : _d, _e = _a.pointSize, pointSize = _e === void 0 ? 1 : _e, _f = _a.angleX, angleX = _f === void 0 ? 15 : _f, _g = _a.angleY, angleY = _g === void 0 ? 0 : _g, _h = _a.deltaX, deltaX = _h === void 0 ? 0 : _h, _j = _a.deltaY, deltaY = _j === void 0 ? 0.02 : _j, _k = _a.outlines, outlines = _k === void 0 ? false : _k, _l = _a.minLifetime, minLifetime = _l === void 0 ? 60 : _l, _m = _a.maxLifetime, maxLifetime = _m === void 0 ? 1000 : _m, _o = _a.glow, glow = _o === void 0 ? 0 : _o, _p = _a.landmass, landmass = _p === void 0 ? 'none' : _p, _q = _a.brightness, brightness = _q === void 0 ? 1.0 : _q, _r = _a.speedFactor, speedFactor = _r === void 0 ? 1000.0 : _r, _s = _a.responsive, responsive = _s === void 0 ? false : _s, _t = _a.gradientStops, gradientStops = _t === void 0 ? [
493
+ { pos: 0.0, color: '#2c425300' },
494
+ { pos: 0.01, color: '#2c425300' },
495
+ { pos: 0.1, color: '#2c4253ff' },
496
+ { pos: 0.30, color: '#3c698aff' },
497
+ { pos: 0.50, color: '#35abe2ff' },
498
+ { pos: 1.0, color: '#ffffffff' }
499
+ ] : _t, props = __rest(_a, ["numParticles", "globe", "trails", "pointSize", "angleX", "angleY", "deltaX", "deltaY", "outlines", "minLifetime", "maxLifetime", "glow", "landmass", "brightness", "speedFactor", "responsive", "gradientStops"]);
500
+ var _u = React.useState(0), time = _u[0], setTime = _u[1];
501
+ React.useEffect(function () {
502
+ setTime(Date.now());
503
+ }, [numParticles, globe, trails, pointSize]);
504
+ return (React.createElement(ParticleGlobeWrapper, __assign({ key: time, numParticles: numParticles, gradientStops: gradientStops, globe: globe, trails: trails, pointSize: pointSize, angleX: angleX, angleY: angleY, deltaX: deltaX, deltaY: deltaY, outlines: outlines, minLifetime: minLifetime, maxLifetime: maxLifetime, glow: glow, landmass: landmass, brightness: brightness, speedFactor: speedFactor, responsive: responsive }, props)));
505
+ };
506
+ export { ParticleGlobe };
507
+ var templateObject_1, templateObject_2, templateObject_3;
508
+ // MARCH, SEPTEMBER
@@ -0,0 +1,3 @@
1
+ declare const PointsVertexShader = "\n\n attribute float a_index;\n uniform mat4 uModelViewMatrix;\n uniform mat4 uProjectionMatrix;\n uniform sampler2D u_texture;\n uniform float u_resolution;\n uniform sampler2D u_uvtexture;\n uniform float u_uvresolution;\n uniform float u_seed;\n varying vec4 v_color;\n uniform float u_minlifetime;\n uniform float u_maxlifetime;\n uniform float u_speedfactor;\n\n // Current animation frame. 0+\n uniform int u_frame;\n\n float random (vec2 uv) {\n return fract(sin(dot(uv.xy,\n vec2(12.9898,78.233))) * 43758.5453123);\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 \n vec2 encodeValue(float value) {\n value = value * SCALE + OFFSET;\n float y = mod(value, BASE);\n float x = floor(value / BASE);\n return vec2(x, y) / BASE;\n }\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 // Encode (x,y) coordinates into a pixel value.\n vec4 encode(vec2 coord) {\n return vec4(encodeValue(coord.x), encodeValue(coord.y));\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 vec2 getRandomPos(vec2 pos) {\n return vec2(random(pos * u_seed), random(pos * u_seed * 3.314));\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 // A particle's lifetime is its index mod MAX (MAX classes), plus a constant (MIN).\n int lifetime = int(mod(a_index, u_maxlifetime) + u_minlifetime); \n // v0 = 1.0\n // v1 = 2.0\n // ..\n // v99 = 100.0\n // v100 = 1.0\n // v101 = 2.0\n // ..\n // v199 = 100.0\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 // Check lifetime.\n if(int(mod(float(u_frame), u_maxlifetime) + u_minlifetime) == lifetime) {\n pos = getRandomPos(pos);\n }\n\n // Move particle with speed:\n vec2 speed = decodeSpeed(pos);\n\n if(speed.x == 99.0) {\n pos = getRandomPos(pos);\n speed = decodeSpeed(pos);\n } else {\n pos += speed / u_speedfactor;\n // Wrap coords:\n if(pos.x >= 1.0) pos.x -= 1.0;\n if(pos.x < 0.0) pos.x += 1.0;\n if(pos.y < 0.0) pos.y += 1.0;\n if(pos.y >= 1.0) pos.y -= 1.0;\n }\n\n gl_Position = vec4(\n texCoord.x * 2.0 - 1.0 + 0.5/u_resolution, // Add half pixelsize to center pixel.\n texCoord.y * 2.0 - 1.0 + 0.5/u_resolution, // Add half pixelsize to center pixel.\n 0.0, 1.0);\n\n // Set size & color:\n gl_PointSize = 1.0;\n v_color = vec4(encode(pos));\n }\n";
2
+ declare const PointsFragmentShader = "\n precision mediump float;\n varying vec4 v_color;\n\n void main() {\n gl_FragColor = v_color;\n }\n";
3
+ export { PointsVertexShader, PointsFragmentShader };
@@ -0,0 +1,4 @@
1
+ import { DecodeSpeed } from "./include/decodeSpeed.include";
2
+ var PointsVertexShader = /*glsl*/ "\n\n attribute float a_index;\n uniform mat4 uModelViewMatrix;\n uniform mat4 uProjectionMatrix;\n uniform sampler2D u_texture;\n uniform float u_resolution;\n uniform sampler2D u_uvtexture;\n uniform float u_uvresolution;\n uniform float u_seed;\n varying vec4 v_color;\n uniform float u_minlifetime;\n uniform float u_maxlifetime;\n uniform float u_speedfactor;\n\n // Current animation frame. 0+\n uniform int u_frame;\n\n float random (vec2 uv) {\n return fract(sin(dot(uv.xy,\n vec2(12.9898,78.233))) * 43758.5453123);\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 \n vec2 encodeValue(float value) {\n value = value * SCALE + OFFSET;\n float y = mod(value, BASE);\n float x = floor(value / BASE);\n return vec2(x, y) / BASE;\n }\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 // Encode (x,y) coordinates into a pixel value.\n vec4 encode(vec2 coord) {\n return vec4(encodeValue(coord.x), encodeValue(coord.y));\n }\n\n ".concat(DecodeSpeed, "\n\n vec2 getRandomPos(vec2 pos) {\n return vec2(random(pos * u_seed), random(pos * u_seed * 3.314));\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 // A particle's lifetime is its index mod MAX (MAX classes), plus a constant (MIN).\n int lifetime = int(mod(a_index, u_maxlifetime) + u_minlifetime); \n // v0 = 1.0\n // v1 = 2.0\n // ..\n // v99 = 100.0\n // v100 = 1.0\n // v101 = 2.0\n // ..\n // v199 = 100.0\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 // Check lifetime.\n if(int(mod(float(u_frame), u_maxlifetime) + u_minlifetime) == lifetime) {\n pos = getRandomPos(pos);\n }\n\n // Move particle with speed:\n vec2 speed = decodeSpeed(pos);\n\n if(speed.x == 99.0) {\n pos = getRandomPos(pos);\n speed = decodeSpeed(pos);\n } else {\n pos += speed / u_speedfactor;\n // Wrap coords:\n if(pos.x >= 1.0) pos.x -= 1.0;\n if(pos.x < 0.0) pos.x += 1.0;\n if(pos.y < 0.0) pos.y += 1.0;\n if(pos.y >= 1.0) pos.y -= 1.0;\n }\n\n gl_Position = vec4(\n texCoord.x * 2.0 - 1.0 + 0.5/u_resolution, // Add half pixelsize to center pixel.\n texCoord.y * 2.0 - 1.0 + 0.5/u_resolution, // Add half pixelsize to center pixel.\n 0.0, 1.0);\n\n // Set size & color:\n gl_PointSize = 1.0;\n v_color = vec4(encode(pos));\n }\n");
3
+ var PointsFragmentShader = /*glsl*/ "\n precision mediump float;\n varying vec4 v_color;\n\n void main() {\n gl_FragColor = v_color;\n }\n";
4
+ export { PointsVertexShader, PointsFragmentShader };
@@ -0,0 +1,3 @@
1
+ declare const SphereVertexShader = "\n attribute vec4 aPosition;\n attribute vec3 aNormal;\n attribute vec2 aTexCoord;\n uniform sampler2D uTexture;\n uniform mat4 uModelViewMatrix;\n uniform mat4 uProjectionMatrix; \n\n varying vec2 vTexCoord;\n varying vec3 vNormal;\n \n\n void main() {\n vec4 rotatedPosition = uModelViewMatrix * aPosition;\n float z = (rotatedPosition.z + 4.0) / 2.0;\n gl_Position = uProjectionMatrix * rotatedPosition; \n\n vNormal = aNormal;\n vTexCoord = aTexCoord;\n }\n";
2
+ declare const SphereFragmentShader = "\n precision mediump float;\n uniform sampler2D uTexture;\n\n varying vec3 vNormal;\n varying vec2 vTexCoord;\n\n void main() {\n gl_FragColor = vec4(vTexCoord, 0.5, 1.0); // Simple color based on texture coordinates\n gl_FragColor = texture2D(uTexture, vec2(1.0 - vTexCoord.x, vTexCoord.y));\n }\n";
3
+ export { SphereVertexShader, SphereFragmentShader };
@@ -0,0 +1,3 @@
1
+ var SphereVertexShader = /*glsl*/ "\n attribute vec4 aPosition;\n attribute vec3 aNormal;\n attribute vec2 aTexCoord;\n uniform sampler2D uTexture;\n uniform mat4 uModelViewMatrix;\n uniform mat4 uProjectionMatrix; \n\n varying vec2 vTexCoord;\n varying vec3 vNormal;\n \n\n void main() {\n vec4 rotatedPosition = uModelViewMatrix * aPosition;\n float z = (rotatedPosition.z + 4.0) / 2.0;\n gl_Position = uProjectionMatrix * rotatedPosition; \n\n vNormal = aNormal;\n vTexCoord = aTexCoord;\n }\n";
2
+ var SphereFragmentShader = /*glsl*/ "\n precision mediump float;\n uniform sampler2D uTexture;\n\n varying vec3 vNormal;\n varying vec2 vTexCoord;\n\n void main() {\n gl_FragColor = vec4(vTexCoord, 0.5, 1.0); // Simple color based on texture coordinates\n gl_FragColor = texture2D(uTexture, vec2(1.0 - vTexCoord.x, vTexCoord.y));\n }\n";
3
+ export { SphereVertexShader, SphereFragmentShader };
@@ -0,0 +1,3 @@
1
+ declare const TextureVertexShader = "\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 = a_texpos;\n }\n";
2
+ declare const TextureFragmentShader = "\n precision mediump float;\n \n uniform sampler2D u_texture;\n varying vec2 v_texpos;\n uniform int u_flip;\n uniform float u_brightness;\n \n void main() {\n gl_FragColor = texture2D(u_texture, u_flip == 1 ? vec2(v_texpos.x, 1.0 - v_texpos.y) : v_texpos) * u_brightness;\n }\n";
3
+ export { TextureVertexShader, TextureFragmentShader };
@@ -0,0 +1,3 @@
1
+ var TextureVertexShader = /*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 = a_texpos;\n }\n";
2
+ var TextureFragmentShader = /*glsl*/ "\n precision mediump float;\n \n uniform sampler2D u_texture;\n varying vec2 v_texpos;\n uniform int u_flip;\n uniform float u_brightness;\n \n void main() {\n gl_FragColor = texture2D(u_texture, u_flip == 1 ? vec2(v_texpos.x, 1.0 - v_texpos.y) : v_texpos) * u_brightness;\n }\n";
3
+ export { TextureVertexShader, TextureFragmentShader };
@@ -0,0 +1,2 @@
1
+ declare const DecodeSpeed = "\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";
2
+ export { DecodeSpeed };
@@ -0,0 +1,2 @@
1
+ var DecodeSpeed = /*glsl*/ "\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";
2
+ export { DecodeSpeed };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longline/aqua-ui",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "AquaUI",
5
5
  "author": "Alexander van Oostenrijk / Longline Environment",
6
6
  "license": "Commercial",
@@ -35,6 +35,7 @@
35
35
  "@storybook/test": "^8.2.9",
36
36
  "@storybook/theming": "^8.2.9",
37
37
  "copy-webpack-plugin": "^12.0.2",
38
+ "pngjs": "^7.0.0",
38
39
  "storybook": "^8.2.9",
39
40
  "svg-spritemap-webpack-plugin": "^4.5.1",
40
41
  "typescript": "^5.5.4",
@@ -55,6 +56,7 @@
55
56
  "@types/react-transition-group": "^4.4.11",
56
57
  "awesome-debounce-promise": "^2.1.0",
57
58
  "date-fns": "^4.1.0",
59
+ "gl-matrix": "^3.4.3",
58
60
  "mapbox-gl": "^3.7.0",
59
61
  "react": "^18.3.1",
60
62
  "react-dom": "^18.3.1",
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ interface IProps {
3
+ children?: React.ReactNode;
4
+ }
5
+ /**
6
+ * `Auth` serves as an authentication and authorization context. It wraps an application,
7
+ * providing it with the `useAuth` hook. This hook is used to determine if a user is currently
8
+ * authenticated, and redirect to a different route if necessary.
9
+ *
10
+ * Wrap an application:
11
+ *
12
+ * ```tsx
13
+ * <Auth>
14
+ * ...
15
+ * </Auth>
16
+ * ```
17
+ *
18
+ * In the application, use `useAuth`:
19
+ *
20
+ * ```tsx
21
+ * const auth = useAuth();
22
+ * auth.signin("access", "refresh");
23
+ * ```
24
+ */
25
+ declare const Auth: (props: IProps) => React.JSX.Element;
26
+ export { Auth };