@rippleflow/water-distortion 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/WaterDistortion.d.ts +3 -2
- package/dist/WaterDistortion.d.ts.map +1 -1
- package/dist/core/waterRenderer.d.ts +4 -0
- package/dist/core/waterRenderer.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/water-distortion.cjs +19 -11
- package/dist/water-distortion.cjs.map +1 -1
- package/dist/water-distortion.js +385 -336
- package/dist/water-distortion.js.map +1 -1
- package/package.json +1 -1
package/dist/water-distortion.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var f = (r, e, n) =>
|
|
4
|
-
import { jsxs as
|
|
5
|
-
import { forwardRef as
|
|
6
|
-
function
|
|
1
|
+
var Ve = Object.defineProperty;
|
|
2
|
+
var qe = (r, e, n) => e in r ? Ve(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var f = (r, e, n) => qe(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { jsxs as $e, jsx as fe } from "react/jsx-runtime";
|
|
5
|
+
import { forwardRef as Qe, useRef as R, useImperativeHandle as je, useEffect as q, useState as Ze } from "react";
|
|
6
|
+
function d(r, e, n) {
|
|
7
7
|
return Math.min(n, Math.max(e, r));
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function Je(r, e) {
|
|
10
10
|
return Math.hypot(e.x - r.x, e.y - r.y);
|
|
11
11
|
}
|
|
12
12
|
function O(r, e, n) {
|
|
13
13
|
return r + (e - r) * n;
|
|
14
14
|
}
|
|
15
|
-
const
|
|
15
|
+
const ee = 24, V = 32, C = 128, oe = 8, se = Math.PI * 2, me = {
|
|
16
16
|
causticGain: 0.1,
|
|
17
17
|
screenCompensation: 1.35,
|
|
18
18
|
maxAlpha: 0.9
|
|
19
|
-
},
|
|
19
|
+
}, et = {
|
|
20
20
|
gradient: 8e-4,
|
|
21
21
|
curvature: 8e-4,
|
|
22
22
|
trough: 6e-3,
|
|
23
23
|
velocity: 8e-4
|
|
24
|
-
},
|
|
24
|
+
}, Fe = `
|
|
25
25
|
attribute vec2 a_position;
|
|
26
26
|
varying vec2 v_uv;
|
|
27
27
|
|
|
@@ -29,10 +29,10 @@ void main() {
|
|
|
29
29
|
v_uv = a_position * 0.5 + 0.5;
|
|
30
30
|
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
31
31
|
}
|
|
32
|
-
`,
|
|
32
|
+
`, tt = `
|
|
33
33
|
precision highp float;
|
|
34
34
|
|
|
35
|
-
#define MAX_WAKE_SEGMENTS ${
|
|
35
|
+
#define MAX_WAKE_SEGMENTS ${ee}
|
|
36
36
|
|
|
37
37
|
varying vec2 v_uv;
|
|
38
38
|
|
|
@@ -122,7 +122,7 @@ void main() {
|
|
|
122
122
|
|
|
123
123
|
gl_FragColor = vec4(height, velocity, 0.0, 1.0);
|
|
124
124
|
}
|
|
125
|
-
`,
|
|
125
|
+
`, rt = `
|
|
126
126
|
precision highp float;
|
|
127
127
|
|
|
128
128
|
varying vec2 v_uv;
|
|
@@ -131,6 +131,7 @@ uniform sampler2D u_state;
|
|
|
131
131
|
uniform sampler2D u_background;
|
|
132
132
|
uniform sampler2D u_causticMap;
|
|
133
133
|
uniform vec2 u_texel;
|
|
134
|
+
uniform vec2 u_backgroundScale;
|
|
134
135
|
uniform float u_domMode;
|
|
135
136
|
uniform float u_normalScale;
|
|
136
137
|
uniform float u_refractionStrength;
|
|
@@ -139,9 +140,9 @@ uniform float u_crestIntensity;
|
|
|
139
140
|
uniform float u_causticIntensity;
|
|
140
141
|
uniform float u_time;
|
|
141
142
|
|
|
142
|
-
const float DOM_CAUSTIC_GAIN = ${
|
|
143
|
-
const float DOM_SCREEN_COMPENSATION = ${
|
|
144
|
-
const float DOM_MAX_ALPHA = ${
|
|
143
|
+
const float DOM_CAUSTIC_GAIN = ${me.causticGain.toFixed(2)};
|
|
144
|
+
const float DOM_SCREEN_COMPENSATION = ${me.screenCompensation.toFixed(2)};
|
|
145
|
+
const float DOM_MAX_ALPHA = ${me.maxAlpha.toFixed(2)};
|
|
145
146
|
|
|
146
147
|
vec4 causticLayer(vec2 uv, vec2 bend, mat2 rotation, float scale, vec2 drift) {
|
|
147
148
|
vec2 p = rotation * (uv * scale + drift * u_time);
|
|
@@ -161,8 +162,15 @@ void main() {
|
|
|
161
162
|
float dy = up - down;
|
|
162
163
|
float signedCurvature = left + right + down + up - height * 4.0;
|
|
163
164
|
vec3 normal = normalize(vec3(-dx * u_normalScale, 1.0, -dy * u_normalScale));
|
|
164
|
-
vec2
|
|
165
|
-
|
|
165
|
+
vec2 backgroundUv = (v_uv - vec2(0.5)) * u_backgroundScale + vec2(0.5);
|
|
166
|
+
vec2 refractedUv = (
|
|
167
|
+
v_uv + normal.xz * u_refractionStrength * 0.025 - vec2(0.5)
|
|
168
|
+
) * u_backgroundScale + vec2(0.5);
|
|
169
|
+
vec2 textureBounds =
|
|
170
|
+
step(vec2(0.0), backgroundUv) * step(backgroundUv, vec2(1.0));
|
|
171
|
+
float textureAlpha = textureBounds.x * textureBounds.y;
|
|
172
|
+
refractedUv = clamp(
|
|
173
|
+
refractedUv,
|
|
166
174
|
vec2(0.001),
|
|
167
175
|
vec2(0.999)
|
|
168
176
|
);
|
|
@@ -253,10 +261,10 @@ void main() {
|
|
|
253
261
|
}
|
|
254
262
|
|
|
255
263
|
vec3 color = base + highlight - vec3(0.015, 0.055, 0.070) * visibleTrough * 0.45;
|
|
256
|
-
gl_FragColor = vec4(color,
|
|
264
|
+
gl_FragColor = vec4(color, textureAlpha);
|
|
257
265
|
}
|
|
258
266
|
`;
|
|
259
|
-
class
|
|
267
|
+
class nt {
|
|
260
268
|
constructor(e, n = () => {
|
|
261
269
|
}) {
|
|
262
270
|
f(this, "gl");
|
|
@@ -278,13 +286,15 @@ class rt {
|
|
|
278
286
|
f(this, "textureImage");
|
|
279
287
|
f(this, "textureReady", !1);
|
|
280
288
|
f(this, "textureNeedsUpload", !1);
|
|
289
|
+
f(this, "textureWidth", 0);
|
|
290
|
+
f(this, "textureHeight", 0);
|
|
281
291
|
f(this, "activityPixels");
|
|
282
|
-
f(this, "wakeAUniforms", new Float32Array(
|
|
283
|
-
f(this, "wakeBUniforms", new Float32Array(
|
|
284
|
-
f(this, "wakeShapeUniforms", new Float32Array(
|
|
292
|
+
f(this, "wakeAUniforms", new Float32Array(ee * 4));
|
|
293
|
+
f(this, "wakeBUniforms", new Float32Array(ee * 4));
|
|
294
|
+
f(this, "wakeShapeUniforms", new Float32Array(ee * 4));
|
|
285
295
|
this.canvas = e, this.requestRender = n;
|
|
286
|
-
const { gl: t, isWebGL2: i, canLinearFloat: a } =
|
|
287
|
-
this.gl = t, this.isWebGL2 = i, this.canLinearFloat = a, this.quadBuffer =
|
|
296
|
+
const { gl: t, isWebGL2: i, canLinearFloat: a } = st(e);
|
|
297
|
+
this.gl = t, this.isWebGL2 = i, this.canLinearFloat = a, this.quadBuffer = $(t.createBuffer(), "WebGL buffer"), this.simulationProgram = Ue(t, Fe, tt), this.materialProgram = Ue(t, Fe, rt), this.backgroundTexture = $(t.createTexture(), "WebGL texture"), this.causticTexture = $(t.createTexture(), "WebGL texture"), t.bindBuffer(t.ARRAY_BUFFER, this.quadBuffer), t.bufferData(
|
|
288
298
|
t.ARRAY_BUFFER,
|
|
289
299
|
new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]),
|
|
290
300
|
t.STATIC_DRAW
|
|
@@ -292,13 +302,17 @@ class rt {
|
|
|
292
302
|
}
|
|
293
303
|
resize(e, n, t, i) {
|
|
294
304
|
this.cssWidth = Math.max(1, e), this.cssHeight = Math.max(1, n);
|
|
295
|
-
const a = Math.min(2, Math.max(1, t || 1)),
|
|
296
|
-
(this.canvas.width !==
|
|
297
|
-
const
|
|
298
|
-
|
|
305
|
+
const a = Math.min(2, Math.max(1, t || 1)), s = Math.max(1, Math.round(this.cssWidth * a)), u = Math.max(1, Math.round(this.cssHeight * a));
|
|
306
|
+
(this.canvas.width !== s || this.canvas.height !== u) && (this.canvas.width = s, this.canvas.height = u);
|
|
307
|
+
const c = Math.max(
|
|
308
|
+
V,
|
|
309
|
+
Math.round(i)
|
|
310
|
+
), h = this.cssWidth / this.cssHeight;
|
|
311
|
+
let v = c, x = c;
|
|
312
|
+
h >= 1 ? (x = Math.round(c / h), x < V && (x = V, v = Math.round(V * h))) : (v = Math.round(c * h), v < V && (v = V, x = Math.round(V / h))), !(v === this.simWidth && x === this.simHeight) && (this.simWidth = v, this.simHeight = x, this.recreateState());
|
|
299
313
|
}
|
|
300
314
|
setTextureSource(e) {
|
|
301
|
-
if (e === this.textureSource || (this.textureSource = e, this.textureImage = void 0, this.textureReady = !1, this.textureNeedsUpload = !1, !e))
|
|
315
|
+
if (e === this.textureSource || (this.textureSource = e, this.textureImage = void 0, this.textureReady = !1, this.textureNeedsUpload = !1, this.textureWidth = 0, this.textureHeight = 0, !e))
|
|
302
316
|
return;
|
|
303
317
|
if (typeof e != "string") {
|
|
304
318
|
this.textureImage = e, this.textureNeedsUpload = !0;
|
|
@@ -339,7 +353,7 @@ class rt {
|
|
|
339
353
|
} finally {
|
|
340
354
|
e.bindFramebuffer(e.FRAMEBUFFER, null);
|
|
341
355
|
}
|
|
342
|
-
return
|
|
356
|
+
return ut(
|
|
343
357
|
this.activityPixels,
|
|
344
358
|
this.simWidth,
|
|
345
359
|
this.simHeight
|
|
@@ -360,14 +374,14 @@ class rt {
|
|
|
360
374
|
(n = this.stateTextures) == null || n.forEach((i) => e.deleteTexture(i)), (t = this.framebuffers) == null || t.forEach((i) => e.deleteFramebuffer(i)), e.deleteTexture(this.backgroundTexture), e.deleteTexture(this.causticTexture), e.deleteBuffer(this.quadBuffer), e.deleteProgram(this.simulationProgram.program), e.deleteProgram(this.materialProgram.program);
|
|
361
375
|
}
|
|
362
376
|
recreateState() {
|
|
363
|
-
var
|
|
377
|
+
var s, u;
|
|
364
378
|
const e = this.gl;
|
|
365
|
-
(
|
|
379
|
+
(s = this.stateTextures) == null || s.forEach((c) => e.deleteTexture(c)), (u = this.framebuffers) == null || u.forEach((c) => e.deleteFramebuffer(c));
|
|
366
380
|
const n = this.createStateTexture(), t = this.createStateTexture(), i = this.createFramebuffer(n), a = this.createFramebuffer(t);
|
|
367
381
|
this.stateTextures = [n, t], this.framebuffers = [i, a], this.readIndex = 0, this.clear();
|
|
368
382
|
}
|
|
369
383
|
createStateTexture() {
|
|
370
|
-
const e = this.gl, n =
|
|
384
|
+
const e = this.gl, n = $(e.createTexture(), "WebGL texture");
|
|
371
385
|
if (e.bindTexture(e.TEXTURE_2D, n), e.texParameteri(
|
|
372
386
|
e.TEXTURE_2D,
|
|
373
387
|
e.TEXTURE_MIN_FILTER,
|
|
@@ -404,7 +418,7 @@ class rt {
|
|
|
404
418
|
return n;
|
|
405
419
|
}
|
|
406
420
|
createFramebuffer(e) {
|
|
407
|
-
const n = this.gl, t =
|
|
421
|
+
const n = this.gl, t = $(n.createFramebuffer(), "WebGL framebuffer");
|
|
408
422
|
if (n.bindFramebuffer(n.FRAMEBUFFER, t), n.framebufferTexture2D(
|
|
409
423
|
n.FRAMEBUFFER,
|
|
410
424
|
n.COLOR_ATTACHMENT0,
|
|
@@ -440,11 +454,11 @@ class rt {
|
|
|
440
454
|
0,
|
|
441
455
|
e.RGBA,
|
|
442
456
|
e.UNSIGNED_BYTE,
|
|
443
|
-
|
|
457
|
+
ot()
|
|
444
458
|
), e.generateMipmap(e.TEXTURE_2D);
|
|
445
459
|
}
|
|
446
460
|
uploadTextureIfNeeded(e) {
|
|
447
|
-
if (e.mode === "dom" || !this.textureImage || !this.textureNeedsUpload && !
|
|
461
|
+
if (e.mode === "dom" || !this.textureImage || !this.textureNeedsUpload && !ct(this.textureImage))
|
|
448
462
|
return;
|
|
449
463
|
const n = this.gl;
|
|
450
464
|
try {
|
|
@@ -455,9 +469,11 @@ class rt {
|
|
|
455
469
|
n.RGBA,
|
|
456
470
|
n.UNSIGNED_BYTE,
|
|
457
471
|
this.textureImage
|
|
458
|
-
), n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, 0), this.
|
|
472
|
+
), n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, 0), [this.textureWidth, this.textureHeight] = at(
|
|
473
|
+
this.textureImage
|
|
474
|
+
), this.textureReady = !0, this.textureNeedsUpload = !1;
|
|
459
475
|
} catch {
|
|
460
|
-
this.textureReady = !1, this.textureNeedsUpload = !1;
|
|
476
|
+
this.textureReady = !1, this.textureNeedsUpload = !1, this.textureWidth = 0, this.textureHeight = 0;
|
|
461
477
|
}
|
|
462
478
|
}
|
|
463
479
|
prepareQuad(e) {
|
|
@@ -465,54 +481,84 @@ class rt {
|
|
|
465
481
|
n.bindBuffer(n.ARRAY_BUFFER, this.quadBuffer), n.enableVertexAttribArray(e.position), n.vertexAttribPointer(e.position, 2, n.FLOAT, !1, 0, 0);
|
|
466
482
|
}
|
|
467
483
|
setSimulationUniforms(e, n, t) {
|
|
468
|
-
const i = this.gl, a = this.simulationProgram.program,
|
|
469
|
-
|
|
470
|
-
for (let
|
|
471
|
-
const m = e[
|
|
472
|
-
|
|
484
|
+
const i = this.gl, a = this.simulationProgram.program, s = Math.min(e.length, ee), u = this.wakeAUniforms, c = this.wakeBUniforms, h = this.wakeShapeUniforms, v = Math.max(0, e.length - ee);
|
|
485
|
+
u.fill(0), c.fill(0), h.fill(0);
|
|
486
|
+
for (let x = 0; x < s; x += 1) {
|
|
487
|
+
const m = e[v + x], p = x * 4;
|
|
488
|
+
u[p] = m.ax, u[p + 1] = m.ay, u[p + 2] = m.radius, u[p + 3] = m.wakeStrength, c[p] = m.bx, c[p + 1] = m.by, c[p + 2] = m.wakeLength, c[p + 3] = m.velocity, h[p] = m.troughStrength, h[p + 1] = m.ridgeStrength, h[p + 2] = m.ridgeOffset;
|
|
473
489
|
}
|
|
474
|
-
i.uniform1i(
|
|
490
|
+
i.uniform1i(_(i, a, "u_state"), 0), i.uniform2f(_(i, a, "u_texel"), 1 / this.simWidth, 1 / this.simHeight), i.uniform1f(_(i, a, "u_delta"), t), i.uniform1f(_(i, a, "u_damping"), n.damping), i.uniform1f(_(i, a, "u_stiffness"), n.waveSpeed), i.uniform1f(_(i, a, "u_aspect"), this.cssWidth / this.cssHeight), i.uniform1i(_(i, a, "u_wakeCount"), s), i.uniform4fv(_(i, a, "u_wakeA[0]"), u), i.uniform4fv(_(i, a, "u_wakeB[0]"), c), i.uniform4fv(_(i, a, "u_wakeShape[0]"), h);
|
|
475
491
|
}
|
|
476
492
|
setMaterialUniforms(e, n) {
|
|
477
|
-
const t = this.gl, i = this.materialProgram.program
|
|
478
|
-
|
|
493
|
+
const t = this.gl, i = this.materialProgram.program, [a, s] = it(
|
|
494
|
+
e.textureFit,
|
|
495
|
+
this.textureWidth,
|
|
496
|
+
this.textureHeight,
|
|
497
|
+
this.cssWidth,
|
|
498
|
+
this.cssHeight
|
|
499
|
+
);
|
|
500
|
+
t.uniform1i(_(t, i, "u_state"), 0), t.uniform1i(_(t, i, "u_background"), 1), t.uniform1i(_(t, i, "u_causticMap"), 2), t.uniform2f(_(t, i, "u_texel"), 1 / this.simWidth, 1 / this.simHeight), t.uniform2f(
|
|
501
|
+
_(t, i, "u_backgroundScale"),
|
|
502
|
+
a,
|
|
503
|
+
s
|
|
504
|
+
), t.uniform1f(_(t, i, "u_domMode"), e.mode === "dom" ? 1 : 0), t.uniform1f(_(t, i, "u_normalScale"), e.normalScale), t.uniform1f(_(t, i, "u_refractionStrength"), e.refractionStrength), t.uniform1f(_(t, i, "u_specularIntensity"), e.specularIntensity), t.uniform1f(_(t, i, "u_crestIntensity"), e.crestIntensity), t.uniform1f(_(t, i, "u_causticIntensity"), e.causticIntensity), t.uniform1f(_(t, i, "u_time"), n % 1e3);
|
|
479
505
|
}
|
|
480
506
|
}
|
|
481
|
-
function
|
|
507
|
+
function it(r, e, n, t, i) {
|
|
508
|
+
if (r === "fill" || !Number.isFinite(e) || !Number.isFinite(n) || !Number.isFinite(t) || !Number.isFinite(i) || e <= 0 || n <= 0 || t <= 0 || i <= 0)
|
|
509
|
+
return [1, 1];
|
|
510
|
+
if (r === "none")
|
|
511
|
+
return [t / e, i / n];
|
|
512
|
+
const a = e / n, s = t / i;
|
|
513
|
+
return r === "cover" ? a > s ? [s / a, 1] : [1, a / s] : a > s ? [1, a / s] : [s / a, 1];
|
|
514
|
+
}
|
|
515
|
+
function at(r) {
|
|
516
|
+
const e = r, n = [
|
|
517
|
+
[e.naturalWidth, e.naturalHeight],
|
|
518
|
+
[e.videoWidth, e.videoHeight],
|
|
519
|
+
[e.displayWidth, e.displayHeight],
|
|
520
|
+
[e.width, e.height]
|
|
521
|
+
];
|
|
522
|
+
for (const [t, i] of n)
|
|
523
|
+
if (typeof t == "number" && typeof i == "number" && Number.isFinite(t) && Number.isFinite(i) && t > 0 && i > 0)
|
|
524
|
+
return [t, i];
|
|
525
|
+
return [0, 0];
|
|
526
|
+
}
|
|
527
|
+
function ot() {
|
|
482
528
|
const r = new Uint8Array(C * C * 4);
|
|
483
529
|
for (let e = 0; e < C; e += 1)
|
|
484
530
|
for (let n = 0; n < C; n += 1) {
|
|
485
|
-
const t = (n + 0.5) / C, i = (e + 0.5) / C, a = Math.round(ce(t, i, 0) * 255),
|
|
486
|
-
r[
|
|
531
|
+
const t = (n + 0.5) / C, i = (e + 0.5) / C, a = Math.round(ce(t, i, 0) * 255), s = Math.round(ce(t, i, 11) * 255), u = Math.round(ce(t, i, 23) * 255), c = Math.round(ce(t, i, 37) * 255), h = (e * C + n) * 4;
|
|
532
|
+
r[h] = a, r[h + 1] = s, r[h + 2] = u, r[h + 3] = c;
|
|
487
533
|
}
|
|
488
534
|
return r;
|
|
489
535
|
}
|
|
490
536
|
function ce(r, e, n) {
|
|
491
|
-
const t = Math.sin(se * (e * 2 + n * 0.013)) * 0.12 + Math.sin(se * (r * 3 + e + n * 0.021)) * 0.06, i = Math.cos(se * (r * 2 + n * 0.017)) * 0.12 + Math.sin(se * (e * 3 - r + n * 0.019)) * 0.06, a = r * oe + t,
|
|
492
|
-
let
|
|
537
|
+
const t = Math.sin(se * (e * 2 + n * 0.013)) * 0.12 + Math.sin(se * (r * 3 + e + n * 0.021)) * 0.06, i = Math.cos(se * (r * 2 + n * 0.017)) * 0.12 + Math.sin(se * (e * 3 - r + n * 0.019)) * 0.06, a = r * oe + t, s = e * oe + i, u = Math.floor(a), c = Math.floor(s);
|
|
538
|
+
let h = Number.POSITIVE_INFINITY, v = Number.POSITIVE_INFINITY, x = 0, m = 0;
|
|
493
539
|
for (let P = -1; P <= 1; P += 1)
|
|
494
|
-
for (let
|
|
495
|
-
const k =
|
|
496
|
-
|
|
540
|
+
for (let U = -1; U <= 1; U += 1) {
|
|
541
|
+
const k = u + U, B = c + P, b = Le(k, oe), I = Le(B, oe), z = k + 0.16 + ge(b, I, n) * 0.68, W = B + 0.16 + ge(b, I, n + 1) * 0.68, D = Math.hypot(a - z, s - W);
|
|
542
|
+
D < h ? (v = h, h = D, x = b, m = I) : D < v && (v = D);
|
|
497
543
|
}
|
|
498
|
-
const
|
|
499
|
-
return
|
|
544
|
+
const p = v - h, A = 1 - ke(0.025, 0.13, p), w = 1 - ke(0.08, 0.34, p), N = 0.74 + ge(x, m, n + 2) * 0.26, H = A * A * 0.58 + w * 0.34;
|
|
545
|
+
return Xe(Math.pow(H * N, 1.12));
|
|
500
546
|
}
|
|
501
|
-
function
|
|
547
|
+
function ge(r, e, n) {
|
|
502
548
|
const t = Math.sin(r * 127.1 + e * 311.7 + n * 74.7) * 43758.5453123;
|
|
503
549
|
return t - Math.floor(t);
|
|
504
550
|
}
|
|
505
|
-
function
|
|
551
|
+
function Le(r, e) {
|
|
506
552
|
return (r % e + e) % e;
|
|
507
553
|
}
|
|
508
|
-
function
|
|
509
|
-
const t =
|
|
554
|
+
function ke(r, e, n) {
|
|
555
|
+
const t = Xe((n - r) / (e - r));
|
|
510
556
|
return t * t * (3 - t * 2);
|
|
511
557
|
}
|
|
512
|
-
function
|
|
558
|
+
function Xe(r) {
|
|
513
559
|
return Math.min(1, Math.max(0, r));
|
|
514
560
|
}
|
|
515
|
-
function
|
|
561
|
+
function st(r) {
|
|
516
562
|
const e = {
|
|
517
563
|
alpha: !0,
|
|
518
564
|
antialias: !1,
|
|
@@ -544,51 +590,51 @@ function it(r) {
|
|
|
544
590
|
canLinearFloat: !!t.getExtension("OES_texture_float_linear")
|
|
545
591
|
};
|
|
546
592
|
}
|
|
547
|
-
function
|
|
548
|
-
const t =
|
|
593
|
+
function Ue(r, e, n) {
|
|
594
|
+
const t = De(r, r.VERTEX_SHADER, e), i = De(r, r.FRAGMENT_SHADER, n), a = $(r.createProgram(), "WebGL program");
|
|
549
595
|
if (r.attachShader(a, t), r.attachShader(a, i), r.linkProgram(a), r.deleteShader(t), r.deleteShader(i), !r.getProgramParameter(a, r.LINK_STATUS)) {
|
|
550
|
-
const
|
|
551
|
-
throw r.deleteProgram(a), new Error(
|
|
596
|
+
const u = r.getProgramInfoLog(a) || "Unknown shader link error.";
|
|
597
|
+
throw r.deleteProgram(a), new Error(u);
|
|
552
598
|
}
|
|
553
|
-
const
|
|
554
|
-
if (
|
|
599
|
+
const s = r.getAttribLocation(a, "a_position");
|
|
600
|
+
if (s < 0)
|
|
555
601
|
throw new Error("WaterDistortion could not bind its quad attribute.");
|
|
556
|
-
return { program: a, position:
|
|
602
|
+
return { program: a, position: s };
|
|
557
603
|
}
|
|
558
|
-
function
|
|
559
|
-
const t =
|
|
604
|
+
function De(r, e, n) {
|
|
605
|
+
const t = $(r.createShader(e), "WebGL shader");
|
|
560
606
|
if (r.shaderSource(t, n), r.compileShader(t), !r.getShaderParameter(t, r.COMPILE_STATUS)) {
|
|
561
607
|
const i = r.getShaderInfoLog(t) || "Unknown shader compile error.";
|
|
562
608
|
throw r.deleteShader(t), new Error(i);
|
|
563
609
|
}
|
|
564
610
|
return t;
|
|
565
611
|
}
|
|
566
|
-
function
|
|
612
|
+
function _(r, e, n) {
|
|
567
613
|
const t = r.getUniformLocation(e, n);
|
|
568
614
|
if (!t)
|
|
569
615
|
throw new Error(`WaterDistortion could not bind uniform ${n}.`);
|
|
570
616
|
return t;
|
|
571
617
|
}
|
|
572
|
-
function
|
|
618
|
+
function $(r, e) {
|
|
573
619
|
if (!r)
|
|
574
620
|
throw new Error(`WaterDistortion could not create ${e}.`);
|
|
575
621
|
return r;
|
|
576
622
|
}
|
|
577
|
-
function
|
|
623
|
+
function ct(r) {
|
|
578
624
|
return typeof HTMLCanvasElement < "u" && r instanceof HTMLCanvasElement || typeof HTMLVideoElement < "u" && r instanceof HTMLVideoElement || typeof OffscreenCanvas < "u" && r instanceof OffscreenCanvas;
|
|
579
625
|
}
|
|
580
|
-
function
|
|
626
|
+
function ut(r, e, n, t = et) {
|
|
581
627
|
const i = Math.max(0, Math.floor(e)), a = Math.max(0, Math.floor(n));
|
|
582
628
|
if (i === 0 || a === 0)
|
|
583
629
|
return !1;
|
|
584
|
-
const
|
|
585
|
-
for (let
|
|
586
|
-
for (let
|
|
587
|
-
const
|
|
588
|
-
if (
|
|
630
|
+
const s = (u, c) => r[(c * i + u) * 4] ?? 0;
|
|
631
|
+
for (let u = 0; u < a; u += 1)
|
|
632
|
+
for (let c = 0; c < i; c += 1) {
|
|
633
|
+
const h = (u * i + c) * 4, v = r[h] ?? 0, x = r[h + 1] ?? 0;
|
|
634
|
+
if (v < -t.trough || Math.abs(x) > t.velocity)
|
|
589
635
|
return !0;
|
|
590
|
-
const m =
|
|
591
|
-
if (
|
|
636
|
+
const m = c > 0 ? s(c - 1, u) : v, p = c < i - 1 ? s(c + 1, u) : v, A = u > 0 ? s(c, u - 1) : v, w = u < a - 1 ? s(c, u + 1) : v, N = Math.hypot(p - m, w - A), H = Math.abs(m + p + A + w - v * 4);
|
|
637
|
+
if (N > t.gradient || H > t.curvature)
|
|
592
638
|
return !0;
|
|
593
639
|
}
|
|
594
640
|
return !1;
|
|
@@ -606,8 +652,8 @@ const L = {
|
|
|
606
652
|
velocityClamp: 1.35,
|
|
607
653
|
cursorSmoothing: 0.2,
|
|
608
654
|
segmentSpacing: 18
|
|
609
|
-
},
|
|
610
|
-
function
|
|
655
|
+
}, lt = 24;
|
|
656
|
+
function ve(r) {
|
|
611
657
|
return {
|
|
612
658
|
width: Math.max(1, r.width ?? L.width),
|
|
613
659
|
height: Math.max(1, r.height ?? L.height),
|
|
@@ -637,7 +683,7 @@ function ge(r) {
|
|
|
637
683
|
0.05,
|
|
638
684
|
r.velocityClamp ?? L.velocityClamp
|
|
639
685
|
),
|
|
640
|
-
cursorSmoothing:
|
|
686
|
+
cursorSmoothing: d(
|
|
641
687
|
r.cursorSmoothing ?? L.cursorSmoothing,
|
|
642
688
|
0,
|
|
643
689
|
0.9
|
|
@@ -648,24 +694,24 @@ function ge(r) {
|
|
|
648
694
|
)
|
|
649
695
|
};
|
|
650
696
|
}
|
|
651
|
-
function
|
|
697
|
+
function Pe(r, e, n = r.timeStamp) {
|
|
652
698
|
const t = typeof r.getCoalescedEvents == "function" ? r.getCoalescedEvents() : [], i = t.length > 0 ? t : [r], a = n - r.timeStamp;
|
|
653
|
-
return i.map((
|
|
654
|
-
x:
|
|
655
|
-
y:
|
|
656
|
-
time:
|
|
699
|
+
return i.map((s) => ({
|
|
700
|
+
x: s.clientX - e.left,
|
|
701
|
+
y: s.clientY - e.top,
|
|
702
|
+
time: s.timeStamp + a
|
|
657
703
|
}));
|
|
658
704
|
}
|
|
659
|
-
class
|
|
705
|
+
class ht {
|
|
660
706
|
constructor(e = {}) {
|
|
661
707
|
f(this, "options");
|
|
662
708
|
f(this, "previous");
|
|
663
709
|
f(this, "smoothedVelocity", 0);
|
|
664
710
|
f(this, "disturbances", []);
|
|
665
|
-
this.options =
|
|
711
|
+
this.options = ve(e);
|
|
666
712
|
}
|
|
667
713
|
configure(e) {
|
|
668
|
-
this.options =
|
|
714
|
+
this.options = ve({
|
|
669
715
|
...this.options,
|
|
670
716
|
...e
|
|
671
717
|
});
|
|
@@ -679,25 +725,25 @@ class ct {
|
|
|
679
725
|
if (!t)
|
|
680
726
|
return this.previous = n, this.disturbances;
|
|
681
727
|
n.time <= t.time && (n.time = t.time + 0.01);
|
|
682
|
-
const i = this.smoothSample(t, n), a =
|
|
728
|
+
const i = this.smoothSample(t, n), a = Je(t, i);
|
|
683
729
|
if (a < 0.35)
|
|
684
730
|
return this.previous = i, this.disturbances;
|
|
685
|
-
const
|
|
731
|
+
const s = a / Math.max(0.01, i.time - t.time), u = d(1 - this.options.cursorSmoothing, 0.12, 1);
|
|
686
732
|
this.smoothedVelocity = O(
|
|
687
733
|
this.smoothedVelocity,
|
|
688
|
-
|
|
689
|
-
|
|
734
|
+
s,
|
|
735
|
+
u
|
|
690
736
|
), this.previous = i;
|
|
691
|
-
const
|
|
692
|
-
|
|
737
|
+
const c = Math.min(
|
|
738
|
+
lt,
|
|
693
739
|
Math.max(1, Math.ceil(a / this.options.segmentSpacing))
|
|
694
740
|
);
|
|
695
|
-
for (let
|
|
696
|
-
const
|
|
741
|
+
for (let h = 0; h < c; h += 1) {
|
|
742
|
+
const v = h / c, x = (h + 1) / c;
|
|
697
743
|
this.disturbances.push(
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
744
|
+
xe(
|
|
745
|
+
Be(t, i, v),
|
|
746
|
+
Be(t, i, x),
|
|
701
747
|
this.smoothedVelocity,
|
|
702
748
|
this.options
|
|
703
749
|
)
|
|
@@ -707,8 +753,8 @@ class ct {
|
|
|
707
753
|
}
|
|
708
754
|
clampSample(e) {
|
|
709
755
|
return {
|
|
710
|
-
x:
|
|
711
|
-
y:
|
|
756
|
+
x: d(e.x, 0, this.options.width),
|
|
757
|
+
y: d(e.y, 0, this.options.height),
|
|
712
758
|
time: e.time
|
|
713
759
|
};
|
|
714
760
|
}
|
|
@@ -721,39 +767,40 @@ class ct {
|
|
|
721
767
|
};
|
|
722
768
|
}
|
|
723
769
|
}
|
|
724
|
-
function
|
|
725
|
-
const i =
|
|
770
|
+
function xe(r, e, n, t) {
|
|
771
|
+
const i = ve(t), a = d(
|
|
726
772
|
n * i.velocityScale / i.velocityClamp,
|
|
727
773
|
0,
|
|
728
774
|
1
|
|
729
|
-
),
|
|
775
|
+
), s = d(r.y / i.height, 0, 1), u = d(e.y / i.height, 0, 1), c = i.wakeLength * O(0.55, 1.35, a);
|
|
730
776
|
return {
|
|
731
|
-
ax:
|
|
732
|
-
ay: 1 -
|
|
733
|
-
bx:
|
|
734
|
-
by: 1 -
|
|
777
|
+
ax: d(r.x / i.width, 0, 1),
|
|
778
|
+
ay: 1 - s,
|
|
779
|
+
bx: d(e.x / i.width, 0, 1),
|
|
780
|
+
by: 1 - u,
|
|
735
781
|
radius: i.interactionRadius / i.height,
|
|
736
782
|
wakeStrength: i.wakeStrength * O(0.18, 1, a),
|
|
737
783
|
troughStrength: i.troughStrength,
|
|
738
784
|
ridgeStrength: i.ridgeStrength,
|
|
739
785
|
ridgeOffset: i.ridgeOffset / i.height,
|
|
740
|
-
wakeLength:
|
|
786
|
+
wakeLength: c / i.height,
|
|
741
787
|
velocity: a
|
|
742
788
|
};
|
|
743
789
|
}
|
|
744
|
-
function
|
|
790
|
+
function Be(r, e, n) {
|
|
745
791
|
return {
|
|
746
792
|
x: O(r.x, e.x, n),
|
|
747
793
|
y: O(r.y, e.y, n),
|
|
748
794
|
time: O(r.time, e.time, n)
|
|
749
795
|
};
|
|
750
796
|
}
|
|
751
|
-
function
|
|
752
|
-
const e =
|
|
753
|
-
return
|
|
797
|
+
function dt(r) {
|
|
798
|
+
const e = d(r, 0.85, 0.998), n = Math.ceil(Math.log(0.012) / Math.log(e));
|
|
799
|
+
return d(n * (1e3 / 60), 900, 5200);
|
|
754
800
|
}
|
|
755
|
-
const
|
|
801
|
+
const E = {
|
|
756
802
|
mode: "texture",
|
|
803
|
+
textureFit: "fill",
|
|
757
804
|
damping: 0.98,
|
|
758
805
|
waveSpeed: 0.4,
|
|
759
806
|
normalScale: 20,
|
|
@@ -776,136 +823,137 @@ const x = {
|
|
|
776
823
|
interactionMode: "move",
|
|
777
824
|
runInBackground: !1,
|
|
778
825
|
pauseKey: void 0
|
|
779
|
-
}, G = 1e3 / 60,
|
|
780
|
-
function
|
|
826
|
+
}, G = 1e3 / 60, ft = 4, Ce = 360, Ne = 24, mt = 200;
|
|
827
|
+
function gt(r) {
|
|
781
828
|
return r instanceof Element && r.closest(
|
|
782
829
|
"a, button, input, select, textarea, [contenteditable]:not([contenteditable=false])"
|
|
783
830
|
) !== null;
|
|
784
831
|
}
|
|
785
|
-
function
|
|
832
|
+
function vt(r) {
|
|
786
833
|
const e = r.strength === void 0 ? void 0 : r.strength / 48;
|
|
787
834
|
return {
|
|
788
|
-
mode: r.mode ??
|
|
835
|
+
mode: r.mode ?? E.mode,
|
|
789
836
|
texture: r.texture,
|
|
790
|
-
|
|
791
|
-
|
|
837
|
+
textureFit: r.textureFit ?? E.textureFit,
|
|
838
|
+
damping: d(
|
|
839
|
+
r.damping ?? r.dissipation ?? E.damping,
|
|
792
840
|
0.85,
|
|
793
841
|
0.998
|
|
794
842
|
),
|
|
795
|
-
waveSpeed:
|
|
796
|
-
normalScale:
|
|
797
|
-
r.normalScale ??
|
|
843
|
+
waveSpeed: d(r.waveSpeed ?? E.waveSpeed, 0.05, 1),
|
|
844
|
+
normalScale: d(
|
|
845
|
+
r.normalScale ?? E.normalScale,
|
|
798
846
|
1,
|
|
799
847
|
80
|
|
800
848
|
),
|
|
801
|
-
refractionStrength:
|
|
802
|
-
r.refractionStrength ??
|
|
849
|
+
refractionStrength: d(
|
|
850
|
+
r.refractionStrength ?? E.refractionStrength,
|
|
803
851
|
0,
|
|
804
852
|
2.5
|
|
805
853
|
),
|
|
806
|
-
specularIntensity:
|
|
807
|
-
r.specularIntensity ??
|
|
854
|
+
specularIntensity: d(
|
|
855
|
+
r.specularIntensity ?? E.specularIntensity,
|
|
808
856
|
0,
|
|
809
857
|
3
|
|
810
858
|
),
|
|
811
|
-
crestIntensity:
|
|
812
|
-
r.crestIntensity ??
|
|
859
|
+
crestIntensity: d(
|
|
860
|
+
r.crestIntensity ?? E.crestIntensity,
|
|
813
861
|
0,
|
|
814
862
|
3
|
|
815
863
|
),
|
|
816
|
-
causticIntensity:
|
|
817
|
-
r.causticIntensity ??
|
|
864
|
+
causticIntensity: d(
|
|
865
|
+
r.causticIntensity ?? E.causticIntensity,
|
|
818
866
|
0,
|
|
819
867
|
3
|
|
820
868
|
),
|
|
821
|
-
simulationResolution:
|
|
869
|
+
simulationResolution: d(
|
|
822
870
|
Math.round(
|
|
823
|
-
r.simulationResolution ??
|
|
871
|
+
r.simulationResolution ?? E.simulationResolution
|
|
824
872
|
),
|
|
825
873
|
64,
|
|
826
874
|
384
|
|
827
875
|
),
|
|
828
|
-
wakeStrength:
|
|
829
|
-
r.wakeStrength ?? r.rippleStrength ?? e ??
|
|
876
|
+
wakeStrength: d(
|
|
877
|
+
r.wakeStrength ?? r.rippleStrength ?? e ?? E.wakeStrength,
|
|
830
878
|
0,
|
|
831
879
|
3
|
|
832
880
|
),
|
|
833
|
-
interactionRadius:
|
|
834
|
-
r.interactionRadius ??
|
|
881
|
+
interactionRadius: d(
|
|
882
|
+
r.interactionRadius ?? E.interactionRadius,
|
|
835
883
|
2,
|
|
836
884
|
80
|
|
837
885
|
),
|
|
838
|
-
troughStrength:
|
|
839
|
-
r.troughStrength ??
|
|
886
|
+
troughStrength: d(
|
|
887
|
+
r.troughStrength ?? E.troughStrength,
|
|
840
888
|
0,
|
|
841
889
|
3
|
|
842
890
|
),
|
|
843
|
-
ridgeStrength:
|
|
844
|
-
r.ridgeStrength ??
|
|
891
|
+
ridgeStrength: d(
|
|
892
|
+
r.ridgeStrength ?? E.ridgeStrength,
|
|
845
893
|
0,
|
|
846
894
|
3
|
|
847
895
|
),
|
|
848
|
-
ridgeOffset:
|
|
849
|
-
r.ridgeOffset ??
|
|
896
|
+
ridgeOffset: d(
|
|
897
|
+
r.ridgeOffset ?? E.ridgeOffset,
|
|
850
898
|
0,
|
|
851
899
|
80
|
|
852
900
|
),
|
|
853
|
-
wakeLength:
|
|
854
|
-
r.wakeLength ??
|
|
901
|
+
wakeLength: d(
|
|
902
|
+
r.wakeLength ?? E.wakeLength,
|
|
855
903
|
1,
|
|
856
904
|
240
|
|
857
905
|
),
|
|
858
|
-
velocityScale:
|
|
859
|
-
r.velocityScale ??
|
|
906
|
+
velocityScale: d(
|
|
907
|
+
r.velocityScale ?? E.velocityScale,
|
|
860
908
|
0.01,
|
|
861
909
|
4
|
|
862
910
|
),
|
|
863
|
-
velocityClamp:
|
|
864
|
-
r.velocityClamp ??
|
|
911
|
+
velocityClamp: d(
|
|
912
|
+
r.velocityClamp ?? E.velocityClamp,
|
|
865
913
|
0.05,
|
|
866
914
|
8
|
|
867
915
|
),
|
|
868
|
-
cursorSmoothing:
|
|
869
|
-
r.cursorSmoothing ??
|
|
916
|
+
cursorSmoothing: d(
|
|
917
|
+
r.cursorSmoothing ?? E.cursorSmoothing,
|
|
870
918
|
0,
|
|
871
919
|
0.9
|
|
872
920
|
),
|
|
873
|
-
segmentSpacing:
|
|
874
|
-
r.segmentSpacing ??
|
|
921
|
+
segmentSpacing: d(
|
|
922
|
+
r.segmentSpacing ?? E.segmentSpacing,
|
|
875
923
|
1,
|
|
876
924
|
96
|
|
877
925
|
),
|
|
878
|
-
idleTimeout: Math.max(120, r.idleTimeout ??
|
|
879
|
-
interactionMode: r.interactionMode ??
|
|
880
|
-
runInBackground: r.runInBackground ??
|
|
881
|
-
pauseKey: r.pauseKey ||
|
|
926
|
+
idleTimeout: Math.max(120, r.idleTimeout ?? E.idleTimeout),
|
|
927
|
+
interactionMode: r.interactionMode ?? E.interactionMode,
|
|
928
|
+
runInBackground: r.runInBackground ?? E.runInBackground,
|
|
929
|
+
pauseKey: r.pauseKey || E.pauseKey
|
|
882
930
|
};
|
|
883
931
|
}
|
|
884
|
-
function
|
|
885
|
-
const t =
|
|
932
|
+
function We(r, e, n) {
|
|
933
|
+
const t = d(r.x, 0, 1) * n.width, i = d(r.y, 0, 1) * n.height, a = Math.max(0.5, e.interactionRadius * 0.08), s = e.velocityClamp / e.velocityScale, u = {
|
|
886
934
|
...e,
|
|
887
935
|
width: n.width,
|
|
888
936
|
height: n.height,
|
|
889
937
|
wakeLength: e.interactionRadius * 1.5
|
|
890
938
|
};
|
|
891
939
|
return [
|
|
892
|
-
|
|
940
|
+
xe(
|
|
893
941
|
{ x: t - a, y: i },
|
|
894
942
|
{ x: t + a, y: i },
|
|
895
|
-
|
|
896
|
-
|
|
943
|
+
s,
|
|
944
|
+
u
|
|
897
945
|
),
|
|
898
|
-
|
|
946
|
+
xe(
|
|
899
947
|
{ x: t, y: i - a },
|
|
900
948
|
{ x: t, y: i + a },
|
|
901
|
-
|
|
902
|
-
|
|
949
|
+
s,
|
|
950
|
+
u
|
|
903
951
|
)
|
|
904
952
|
];
|
|
905
953
|
}
|
|
906
|
-
function
|
|
907
|
-
const [e, n] =
|
|
908
|
-
return
|
|
954
|
+
function xt(r) {
|
|
955
|
+
const [e, n] = Ze(!1);
|
|
956
|
+
return q(() => {
|
|
909
957
|
if (!r || typeof window > "u" || !window.matchMedia) {
|
|
910
958
|
n(!1);
|
|
911
959
|
return;
|
|
@@ -920,71 +968,72 @@ function mt(r) {
|
|
|
920
968
|
};
|
|
921
969
|
}, [r]), e;
|
|
922
970
|
}
|
|
923
|
-
const
|
|
971
|
+
const pt = Qe(function(e, n) {
|
|
924
972
|
const {
|
|
925
973
|
underlay: t,
|
|
926
974
|
children: i,
|
|
927
975
|
foreground: a,
|
|
928
|
-
className:
|
|
929
|
-
style:
|
|
930
|
-
reducedMotion:
|
|
931
|
-
} = e,
|
|
932
|
-
}),
|
|
933
|
-
}), H =
|
|
934
|
-
}), P =
|
|
935
|
-
|
|
936
|
-
), ue =
|
|
937
|
-
g.current =
|
|
976
|
+
className: s,
|
|
977
|
+
style: u,
|
|
978
|
+
reducedMotion: c = "respect"
|
|
979
|
+
} = e, h = R(null), v = R(null), x = R(null), m = R(new ht()), p = R(null), A = R(null), w = R(() => {
|
|
980
|
+
}), N = R(() => {
|
|
981
|
+
}), H = R(() => {
|
|
982
|
+
}), P = R([]), U = R(!0), k = R(!0), B = R(!1), b = R(!1), I = R(null), z = R(0), W = R(0), D = R(0), T = vt(e), g = R(T), Q = R({ width: 1, height: 1 }), Ge = xt(
|
|
983
|
+
c === "respect"
|
|
984
|
+
), ue = c === "disable" || c === "respect" && Ge, Oe = a ?? i;
|
|
985
|
+
g.current = T, je(
|
|
938
986
|
n,
|
|
939
987
|
() => ({
|
|
940
|
-
triggerRipple(
|
|
941
|
-
B.current ||
|
|
942
|
-
|
|
943
|
-
|
|
988
|
+
triggerRipple(S) {
|
|
989
|
+
B.current || b.current || H.current(
|
|
990
|
+
We(
|
|
991
|
+
S,
|
|
944
992
|
g.current,
|
|
945
|
-
|
|
993
|
+
Q.current
|
|
946
994
|
)
|
|
947
995
|
);
|
|
948
996
|
}
|
|
949
997
|
}),
|
|
950
998
|
[]
|
|
951
|
-
),
|
|
952
|
-
var
|
|
953
|
-
B.current = ue, ue && (m.current.reset(), I.current = null, P.current = [], z.current = 0,
|
|
954
|
-
}, [ue]),
|
|
955
|
-
const
|
|
956
|
-
if (!
|
|
999
|
+
), q(() => {
|
|
1000
|
+
var S;
|
|
1001
|
+
B.current = ue, ue && (m.current.reset(), I.current = null, P.current = [], z.current = 0, W.current = 0, D.current = 0, (S = x.current) == null || S.clear()), w.current();
|
|
1002
|
+
}, [ue]), q(() => {
|
|
1003
|
+
const S = x.current;
|
|
1004
|
+
if (!S)
|
|
957
1005
|
return;
|
|
958
|
-
const { width: K, height:
|
|
959
|
-
|
|
1006
|
+
const { width: K, height: M } = Q.current;
|
|
1007
|
+
S.resize(
|
|
960
1008
|
K,
|
|
961
|
-
|
|
1009
|
+
M,
|
|
962
1010
|
window.devicePixelRatio,
|
|
963
|
-
|
|
964
|
-
),
|
|
1011
|
+
T.simulationResolution
|
|
1012
|
+
), S.setTextureSource(T.texture), w.current();
|
|
965
1013
|
}, [
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1014
|
+
T.mode,
|
|
1015
|
+
T.texture,
|
|
1016
|
+
T.textureFit,
|
|
1017
|
+
T.damping,
|
|
1018
|
+
T.waveSpeed,
|
|
1019
|
+
T.normalScale,
|
|
1020
|
+
T.refractionStrength,
|
|
1021
|
+
T.specularIntensity,
|
|
1022
|
+
T.crestIntensity,
|
|
1023
|
+
T.causticIntensity,
|
|
1024
|
+
T.simulationResolution
|
|
1025
|
+
]), q(() => {
|
|
1026
|
+
const S = h.current, K = v.current;
|
|
1027
|
+
if (!S || !K)
|
|
979
1028
|
return;
|
|
980
1029
|
k.current = typeof document.hasFocus == "function" ? document.hasFocus() : !0;
|
|
981
|
-
let
|
|
1030
|
+
let M = null, ae, te = G, pe = !1, re;
|
|
982
1031
|
const Y = () => {
|
|
983
|
-
|
|
984
|
-
},
|
|
1032
|
+
p.current !== null && (window.cancelAnimationFrame(p.current), p.current = null), A.current !== null && (window.clearTimeout(A.current), A.current = null);
|
|
1033
|
+
}, ze = (o, l) => {
|
|
985
1034
|
m.current.configure({
|
|
986
1035
|
width: o,
|
|
987
|
-
height:
|
|
1036
|
+
height: l,
|
|
988
1037
|
interactionRadius: g.current.interactionRadius,
|
|
989
1038
|
wakeStrength: g.current.wakeStrength,
|
|
990
1039
|
troughStrength: g.current.troughStrength,
|
|
@@ -996,56 +1045,56 @@ const gt = $e(function(e, n) {
|
|
|
996
1045
|
cursorSmoothing: g.current.cursorSmoothing,
|
|
997
1046
|
segmentSpacing: g.current.segmentSpacing
|
|
998
1047
|
});
|
|
999
|
-
},
|
|
1000
|
-
const F = Math.max(1, o),
|
|
1001
|
-
|
|
1048
|
+
}, Ke = (o, l) => {
|
|
1049
|
+
const F = Math.max(1, o), y = Math.max(1, l);
|
|
1050
|
+
Q.current = { width: F, height: y }, ze(F, y), M == null || M.resize(
|
|
1002
1051
|
F,
|
|
1003
|
-
|
|
1052
|
+
y,
|
|
1004
1053
|
window.devicePixelRatio,
|
|
1005
1054
|
g.current.simulationResolution
|
|
1006
1055
|
);
|
|
1007
1056
|
}, Ee = () => {
|
|
1008
|
-
|
|
1057
|
+
M == null || M.render(g.current, performance.now() * 1e-3);
|
|
1009
1058
|
}, X = () => {
|
|
1010
|
-
|
|
1011
|
-
},
|
|
1012
|
-
Y(), m.current.reset(), I.current = null, X(),
|
|
1013
|
-
},
|
|
1059
|
+
ae = void 0, te = G;
|
|
1060
|
+
}, ne = () => {
|
|
1061
|
+
Y(), m.current.reset(), I.current = null, X(), re === void 0 && (re = performance.now());
|
|
1062
|
+
}, j = () => {
|
|
1014
1063
|
const o = g.current;
|
|
1015
|
-
let
|
|
1016
|
-
if (!(!B.current && !
|
|
1064
|
+
let l = !1;
|
|
1065
|
+
if (!(!B.current && !b.current && U.current && (o.runInBackground || !document.hidden && k.current))) {
|
|
1017
1066
|
X();
|
|
1018
1067
|
return;
|
|
1019
1068
|
}
|
|
1020
|
-
if (
|
|
1021
|
-
const
|
|
1022
|
-
z.current +=
|
|
1069
|
+
if (re !== void 0) {
|
|
1070
|
+
const y = performance.now() - re;
|
|
1071
|
+
z.current += y, W.current += y, D.current += y, re = void 0, l = !0;
|
|
1023
1072
|
}
|
|
1024
|
-
(!o.runInBackground ||
|
|
1025
|
-
},
|
|
1026
|
-
|
|
1027
|
-
const
|
|
1028
|
-
if (!
|
|
1073
|
+
(!o.runInBackground || l) && X(), Ee(), w.current();
|
|
1074
|
+
}, _e = (o) => {
|
|
1075
|
+
p.current = null;
|
|
1076
|
+
const l = g.current;
|
|
1077
|
+
if (!M || b.current || !U.current || !l.runInBackground && (document.hidden || !k.current)) {
|
|
1029
1078
|
X();
|
|
1030
1079
|
return;
|
|
1031
1080
|
}
|
|
1032
1081
|
if (B.current) {
|
|
1033
|
-
P.current = [],
|
|
1082
|
+
P.current = [], M.render(l, o * 1e-3), X();
|
|
1034
1083
|
return;
|
|
1035
1084
|
}
|
|
1036
|
-
const F =
|
|
1037
|
-
o -
|
|
1085
|
+
const F = l.runInBackground ? Ce : ft, y = ae === void 0 ? G : d(
|
|
1086
|
+
o - ae,
|
|
1038
1087
|
0,
|
|
1039
|
-
|
|
1088
|
+
l.runInBackground ? G * Ce : 64
|
|
1040
1089
|
);
|
|
1041
|
-
|
|
1042
|
-
|
|
1090
|
+
ae = o, te = Math.min(
|
|
1091
|
+
te + y,
|
|
1043
1092
|
G * F
|
|
1044
1093
|
);
|
|
1045
|
-
let
|
|
1046
|
-
for (;
|
|
1047
|
-
|
|
1048
|
-
if (
|
|
1094
|
+
let J = P.current.splice(0), Ie = 0;
|
|
1095
|
+
for (; te >= G && Ie < F; )
|
|
1096
|
+
M.step(J, l, 1), J = [], te -= G, Ie += 1;
|
|
1097
|
+
if (M.render(l, o * 1e-3), P.current.length > 0) {
|
|
1049
1098
|
w.current();
|
|
1050
1099
|
return;
|
|
1051
1100
|
}
|
|
@@ -1053,131 +1102,131 @@ const gt = $e(function(e, n) {
|
|
|
1053
1102
|
w.current();
|
|
1054
1103
|
return;
|
|
1055
1104
|
}
|
|
1056
|
-
if (
|
|
1057
|
-
o <
|
|
1105
|
+
if (pe) {
|
|
1106
|
+
o < W.current ? w.current() : X();
|
|
1058
1107
|
return;
|
|
1059
1108
|
}
|
|
1060
|
-
if (o <
|
|
1109
|
+
if (o < D.current) {
|
|
1061
1110
|
w.current();
|
|
1062
1111
|
return;
|
|
1063
1112
|
}
|
|
1064
1113
|
try {
|
|
1065
|
-
|
|
1114
|
+
M.hasVisibleActivity() ? (D.current = o + mt, w.current()) : X();
|
|
1066
1115
|
} catch {
|
|
1067
|
-
|
|
1116
|
+
pe = !0, o < W.current ? w.current() : X();
|
|
1068
1117
|
}
|
|
1069
1118
|
}, le = () => {
|
|
1070
|
-
|
|
1071
|
-
A.current = null,
|
|
1072
|
-
}, G) :
|
|
1119
|
+
b.current || p.current !== null || A.current !== null || (g.current.runInBackground && document.hidden ? A.current = window.setTimeout(() => {
|
|
1120
|
+
A.current = null, _e(performance.now());
|
|
1121
|
+
}, G) : p.current = window.requestAnimationFrame(_e));
|
|
1073
1122
|
};
|
|
1074
1123
|
w.current = le;
|
|
1075
1124
|
try {
|
|
1076
|
-
|
|
1125
|
+
M = new nt(K, () => {
|
|
1077
1126
|
w.current();
|
|
1078
|
-
}),
|
|
1127
|
+
}), x.current = M, M.setTextureSource(g.current.texture);
|
|
1079
1128
|
} catch {
|
|
1080
|
-
return K.style.display = "none",
|
|
1129
|
+
return K.style.display = "none", x.current = null, w.current = () => {
|
|
1081
1130
|
}, () => {
|
|
1082
1131
|
};
|
|
1083
1132
|
}
|
|
1084
|
-
const
|
|
1133
|
+
const he = () => {
|
|
1085
1134
|
const o = K.getBoundingClientRect();
|
|
1086
|
-
return
|
|
1087
|
-
},
|
|
1088
|
-
|
|
1089
|
-
},
|
|
1090
|
-
if (
|
|
1135
|
+
return Ke(o.width, o.height), o;
|
|
1136
|
+
}, Se = () => {
|
|
1137
|
+
he(), Ee();
|
|
1138
|
+
}, de = (o) => {
|
|
1139
|
+
if (b.current || o.length === 0)
|
|
1091
1140
|
return;
|
|
1092
|
-
const
|
|
1093
|
-
for (const
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
const
|
|
1097
|
-
z.current = Math.max(z.current,
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
),
|
|
1141
|
+
const l = P.current;
|
|
1142
|
+
for (const J of o)
|
|
1143
|
+
l.push(J);
|
|
1144
|
+
l.length > Ne && l.splice(0, l.length - Ne);
|
|
1145
|
+
const y = performance.now() + g.current.idleTimeout;
|
|
1146
|
+
z.current = Math.max(z.current, y), W.current = Math.max(
|
|
1147
|
+
W.current,
|
|
1148
|
+
y + dt(g.current.damping)
|
|
1149
|
+
), D.current = 0, le();
|
|
1101
1150
|
};
|
|
1102
|
-
H.current =
|
|
1103
|
-
const
|
|
1104
|
-
const
|
|
1105
|
-
if (B.current ||
|
|
1151
|
+
H.current = de;
|
|
1152
|
+
const Te = (o) => {
|
|
1153
|
+
const l = g.current;
|
|
1154
|
+
if (B.current || b.current || !U.current || l.interactionMode === "event" || !l.runInBackground && (document.hidden || !k.current) || o.pointerType === "touch" && !o.isPrimary)
|
|
1106
1155
|
return;
|
|
1107
1156
|
m.current.reset();
|
|
1108
|
-
const F =
|
|
1109
|
-
|
|
1110
|
-
|
|
1157
|
+
const F = he(), [y] = Pe(o, F, performance.now());
|
|
1158
|
+
y && ((l.interactionMode === "click" || l.interactionMode === "drag") && de(
|
|
1159
|
+
We(
|
|
1111
1160
|
{
|
|
1112
|
-
x:
|
|
1113
|
-
y:
|
|
1161
|
+
x: y.x / Q.current.width,
|
|
1162
|
+
y: y.y / Q.current.height
|
|
1114
1163
|
},
|
|
1115
|
-
|
|
1116
|
-
|
|
1164
|
+
l,
|
|
1165
|
+
Q.current
|
|
1117
1166
|
)
|
|
1118
|
-
),
|
|
1119
|
-
},
|
|
1120
|
-
const
|
|
1121
|
-
if (B.current ||
|
|
1167
|
+
), l.interactionMode === "drag" ? (I.current = o.pointerId, m.current.addSample(y)) : l.interactionMode === "move" && m.current.addSample(y));
|
|
1168
|
+
}, ye = (o) => {
|
|
1169
|
+
const l = g.current;
|
|
1170
|
+
if (B.current || b.current || !U.current || l.interactionMode !== "move" && (l.interactionMode !== "drag" || I.current !== o.pointerId) || !l.runInBackground && (document.hidden || !k.current) || o.pointerType === "touch" && !o.isPrimary)
|
|
1122
1171
|
return;
|
|
1123
|
-
const F =
|
|
1124
|
-
for (const
|
|
1125
|
-
|
|
1126
|
-
},
|
|
1172
|
+
const F = he(), y = Pe(o, F, performance.now());
|
|
1173
|
+
for (const J of y)
|
|
1174
|
+
de(m.current.addSample(J));
|
|
1175
|
+
}, Z = (o) => {
|
|
1127
1176
|
I.current !== null && I.current !== o.pointerId || (I.current = null, m.current.reset());
|
|
1128
|
-
},
|
|
1129
|
-
const
|
|
1130
|
-
!
|
|
1131
|
-
}, ye = () => {
|
|
1132
|
-
Y(), document.hidden && !g.current.runInBackground ? re() : Q();
|
|
1133
|
-
}, Re = () => {
|
|
1134
|
-
k.current = !1, g.current.runInBackground ? (Y(), Q()) : re();
|
|
1177
|
+
}, Re = (o) => {
|
|
1178
|
+
const l = g.current.pauseKey;
|
|
1179
|
+
!l || o.code !== l || o.repeat || o.altKey || o.ctrlKey || o.metaKey || gt(o.target) || (o.preventDefault(), b.current = !b.current, b.current ? ne() : (Y(), j()));
|
|
1135
1180
|
}, we = () => {
|
|
1136
|
-
|
|
1137
|
-
},
|
|
1138
|
-
|
|
1181
|
+
Y(), document.hidden && !g.current.runInBackground ? ne() : j();
|
|
1182
|
+
}, be = () => {
|
|
1183
|
+
k.current = !1, g.current.runInBackground ? (Y(), j()) : ne();
|
|
1184
|
+
}, Me = () => {
|
|
1185
|
+
k.current = !0, Y(), j();
|
|
1186
|
+
}, Ye = () => {
|
|
1187
|
+
Y(), !g.current.runInBackground && (document.hidden || !k.current) ? ne() : j();
|
|
1139
1188
|
};
|
|
1140
|
-
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1189
|
+
N.current = Ye, Se();
|
|
1190
|
+
const Ae = new ResizeObserver(() => {
|
|
1191
|
+
Se(), le();
|
|
1143
1192
|
});
|
|
1144
|
-
|
|
1145
|
-
let
|
|
1146
|
-
return "IntersectionObserver" in window && (
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
}),
|
|
1193
|
+
Ae.observe(K);
|
|
1194
|
+
let ie;
|
|
1195
|
+
return "IntersectionObserver" in window && (ie = new IntersectionObserver((o) => {
|
|
1196
|
+
const l = o[0];
|
|
1197
|
+
U.current = l ? l.isIntersecting : !0, U.current ? j() : ne();
|
|
1198
|
+
}), ie.observe(S)), S.addEventListener("pointerdown", Te, {
|
|
1150
1199
|
passive: !0
|
|
1151
|
-
}),
|
|
1200
|
+
}), S.addEventListener("pointermove", ye, {
|
|
1152
1201
|
passive: !0
|
|
1153
|
-
}),
|
|
1202
|
+
}), S.addEventListener("pointerup", Z, {
|
|
1154
1203
|
passive: !0
|
|
1155
|
-
}),
|
|
1204
|
+
}), S.addEventListener("pointerleave", Z, {
|
|
1156
1205
|
passive: !0
|
|
1157
|
-
}),
|
|
1206
|
+
}), S.addEventListener("pointercancel", Z, {
|
|
1158
1207
|
passive: !0
|
|
1159
|
-
}), window.addEventListener("blur",
|
|
1208
|
+
}), window.addEventListener("blur", be), window.addEventListener("focus", Me), document.addEventListener("keydown", Re), document.addEventListener("visibilitychange", we), () => {
|
|
1160
1209
|
var o;
|
|
1161
|
-
Y(),
|
|
1162
|
-
},
|
|
1210
|
+
Y(), Ae.disconnect(), ie == null || ie.disconnect(), S.removeEventListener("pointerdown", Te), S.removeEventListener("pointermove", ye), S.removeEventListener("pointerup", Z), S.removeEventListener("pointerleave", Z), S.removeEventListener("pointercancel", Z), window.removeEventListener("blur", be), window.removeEventListener("focus", Me), document.removeEventListener("keydown", Re), document.removeEventListener("visibilitychange", we), (o = x.current) == null || o.dispose(), x.current = null, w.current = () => {
|
|
1211
|
+
}, N.current = () => {
|
|
1163
1212
|
}, H.current = () => {
|
|
1164
1213
|
};
|
|
1165
1214
|
};
|
|
1166
|
-
}, []),
|
|
1215
|
+
}, []), q(() => {
|
|
1167
1216
|
m.current.reset(), I.current = null;
|
|
1168
|
-
}, [
|
|
1169
|
-
|
|
1170
|
-
}, [
|
|
1171
|
-
!
|
|
1172
|
-
}, [
|
|
1173
|
-
const
|
|
1174
|
-
...
|
|
1217
|
+
}, [T.interactionMode]), q(() => {
|
|
1218
|
+
N.current();
|
|
1219
|
+
}, [T.runInBackground]), q(() => {
|
|
1220
|
+
!T.pauseKey && b.current && (b.current = !1, N.current());
|
|
1221
|
+
}, [T.pauseKey]);
|
|
1222
|
+
const He = {
|
|
1223
|
+
...u,
|
|
1175
1224
|
position: "relative",
|
|
1176
1225
|
overflow: "hidden",
|
|
1177
1226
|
isolation: "isolate"
|
|
1178
1227
|
};
|
|
1179
|
-
return /* @__PURE__ */
|
|
1180
|
-
t ? /* @__PURE__ */
|
|
1228
|
+
return /* @__PURE__ */ $e("div", { ref: h, className: s, style: He, children: [
|
|
1229
|
+
t ? /* @__PURE__ */ fe(
|
|
1181
1230
|
"div",
|
|
1182
1231
|
{
|
|
1183
1232
|
style: {
|
|
@@ -1190,10 +1239,10 @@ const gt = $e(function(e, n) {
|
|
|
1190
1239
|
children: t
|
|
1191
1240
|
}
|
|
1192
1241
|
) : null,
|
|
1193
|
-
/* @__PURE__ */
|
|
1242
|
+
/* @__PURE__ */ fe(
|
|
1194
1243
|
"canvas",
|
|
1195
1244
|
{
|
|
1196
|
-
ref:
|
|
1245
|
+
ref: v,
|
|
1197
1246
|
"aria-hidden": "true",
|
|
1198
1247
|
style: {
|
|
1199
1248
|
position: "absolute",
|
|
@@ -1202,24 +1251,24 @@ const gt = $e(function(e, n) {
|
|
|
1202
1251
|
width: "100%",
|
|
1203
1252
|
height: "100%",
|
|
1204
1253
|
pointerEvents: "none",
|
|
1205
|
-
mixBlendMode:
|
|
1254
|
+
mixBlendMode: T.mode === "dom" ? "screen" : "normal"
|
|
1206
1255
|
}
|
|
1207
1256
|
}
|
|
1208
1257
|
),
|
|
1209
|
-
/* @__PURE__ */
|
|
1258
|
+
/* @__PURE__ */ fe(
|
|
1210
1259
|
"div",
|
|
1211
1260
|
{
|
|
1212
1261
|
style: {
|
|
1213
1262
|
position: "relative",
|
|
1214
1263
|
zIndex: 2
|
|
1215
1264
|
},
|
|
1216
|
-
children:
|
|
1265
|
+
children: Oe
|
|
1217
1266
|
}
|
|
1218
1267
|
)
|
|
1219
1268
|
] });
|
|
1220
|
-
}),
|
|
1269
|
+
}), Tt = pt;
|
|
1221
1270
|
export {
|
|
1222
|
-
|
|
1223
|
-
|
|
1271
|
+
pt as WaterDistortion,
|
|
1272
|
+
Tt as WaterLayer
|
|
1224
1273
|
};
|
|
1225
1274
|
//# sourceMappingURL=water-distortion.js.map
|