@rippleflow/water-distortion 0.1.3 → 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 +6 -2
- 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 +20 -27
- package/dist/water-distortion.cjs.map +1 -1
- package/dist/water-distortion.js +379 -348
- 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,8 +131,8 @@ 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
|
-
uniform float u_textureEnabled;
|
|
136
136
|
uniform float u_normalScale;
|
|
137
137
|
uniform float u_refractionStrength;
|
|
138
138
|
uniform float u_specularIntensity;
|
|
@@ -140,21 +140,9 @@ uniform float u_crestIntensity;
|
|
|
140
140
|
uniform float u_causticIntensity;
|
|
141
141
|
uniform float u_time;
|
|
142
142
|
|
|
143
|
-
const float DOM_CAUSTIC_GAIN = ${
|
|
144
|
-
const float DOM_SCREEN_COMPENSATION = ${
|
|
145
|
-
const float DOM_MAX_ALPHA = ${
|
|
146
|
-
|
|
147
|
-
vec3 proceduralBackground(vec2 uv) {
|
|
148
|
-
vec3 deep = vec3(0.055, 0.075, 0.070);
|
|
149
|
-
vec3 teal = vec3(0.060, 0.320, 0.310);
|
|
150
|
-
vec3 coral = vec3(0.680, 0.230, 0.190);
|
|
151
|
-
vec3 gold = vec3(0.850, 0.710, 0.360);
|
|
152
|
-
float diagonal = smoothstep(0.05, 0.95, uv.x * 0.72 + uv.y * 0.28);
|
|
153
|
-
vec3 color = mix(deep, teal, diagonal);
|
|
154
|
-
color = mix(color, coral, smoothstep(0.18, 0.76, uv.x - uv.y * 0.18) * 0.36);
|
|
155
|
-
color = mix(color, gold, smoothstep(0.58, 1.0, uv.y + uv.x * 0.16) * 0.24);
|
|
156
|
-
return color;
|
|
157
|
-
}
|
|
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)};
|
|
158
146
|
|
|
159
147
|
vec4 causticLayer(vec2 uv, vec2 bend, mat2 rotation, float scale, vec2 drift) {
|
|
160
148
|
vec2 p = rotation * (uv * scale + drift * u_time);
|
|
@@ -174,15 +162,20 @@ void main() {
|
|
|
174
162
|
float dy = up - down;
|
|
175
163
|
float signedCurvature = left + right + down + up - height * 4.0;
|
|
176
164
|
vec3 normal = normalize(vec3(-dx * u_normalScale, 1.0, -dy * u_normalScale));
|
|
177
|
-
vec2
|
|
178
|
-
|
|
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,
|
|
179
174
|
vec2(0.001),
|
|
180
175
|
vec2(0.999)
|
|
181
176
|
);
|
|
182
177
|
|
|
183
|
-
vec3 base =
|
|
184
|
-
? texture2D(u_background, refractedUv).rgb
|
|
185
|
-
: proceduralBackground(refractedUv);
|
|
178
|
+
vec3 base = texture2D(u_background, refractedUv).rgb;
|
|
186
179
|
|
|
187
180
|
float gradient = length(vec2(dx, dy)) * u_normalScale;
|
|
188
181
|
float crest = smoothstep(0.012, 0.24, gradient);
|
|
@@ -268,10 +261,10 @@ void main() {
|
|
|
268
261
|
}
|
|
269
262
|
|
|
270
263
|
vec3 color = base + highlight - vec3(0.015, 0.055, 0.070) * visibleTrough * 0.45;
|
|
271
|
-
gl_FragColor = vec4(color,
|
|
264
|
+
gl_FragColor = vec4(color, textureAlpha);
|
|
272
265
|
}
|
|
273
266
|
`;
|
|
274
|
-
class
|
|
267
|
+
class nt {
|
|
275
268
|
constructor(e, n = () => {
|
|
276
269
|
}) {
|
|
277
270
|
f(this, "gl");
|
|
@@ -293,13 +286,15 @@ class rt {
|
|
|
293
286
|
f(this, "textureImage");
|
|
294
287
|
f(this, "textureReady", !1);
|
|
295
288
|
f(this, "textureNeedsUpload", !1);
|
|
289
|
+
f(this, "textureWidth", 0);
|
|
290
|
+
f(this, "textureHeight", 0);
|
|
296
291
|
f(this, "activityPixels");
|
|
297
|
-
f(this, "wakeAUniforms", new Float32Array(
|
|
298
|
-
f(this, "wakeBUniforms", new Float32Array(
|
|
299
|
-
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));
|
|
300
295
|
this.canvas = e, this.requestRender = n;
|
|
301
|
-
const { gl: t, isWebGL2: i, canLinearFloat: a } =
|
|
302
|
-
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(
|
|
303
298
|
t.ARRAY_BUFFER,
|
|
304
299
|
new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]),
|
|
305
300
|
t.STATIC_DRAW
|
|
@@ -307,13 +302,17 @@ class rt {
|
|
|
307
302
|
}
|
|
308
303
|
resize(e, n, t, i) {
|
|
309
304
|
this.cssWidth = Math.max(1, e), this.cssHeight = Math.max(1, n);
|
|
310
|
-
const a = Math.min(2, Math.max(1, t || 1)),
|
|
311
|
-
(this.canvas.width !==
|
|
312
|
-
const
|
|
313
|
-
|
|
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());
|
|
314
313
|
}
|
|
315
314
|
setTextureSource(e) {
|
|
316
|
-
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))
|
|
317
316
|
return;
|
|
318
317
|
if (typeof e != "string") {
|
|
319
318
|
this.textureImage = e, this.textureNeedsUpload = !0;
|
|
@@ -334,7 +333,7 @@ class rt {
|
|
|
334
333
|
}
|
|
335
334
|
render(e, n = 0) {
|
|
336
335
|
const t = this.gl;
|
|
337
|
-
this.stateTextures && (e.texture ? this.setTextureSource(e.texture) : this.setTextureSource(void 0), this.uploadTextureIfNeeded(e), t.useProgram(this.materialProgram.program), t.bindFramebuffer(t.FRAMEBUFFER, null), t.viewport(0, 0, this.canvas.width, this.canvas.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), !(e.mode !== "dom" &&
|
|
336
|
+
this.stateTextures && (e.texture ? this.setTextureSource(e.texture) : this.setTextureSource(void 0), this.uploadTextureIfNeeded(e), t.useProgram(this.materialProgram.program), t.bindFramebuffer(t.FRAMEBUFFER, null), t.viewport(0, 0, this.canvas.width, this.canvas.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), !(e.mode !== "dom" && !this.textureReady) && (t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.stateTextures[this.readIndex]), t.activeTexture(t.TEXTURE1), t.bindTexture(t.TEXTURE_2D, this.backgroundTexture), t.activeTexture(t.TEXTURE2), t.bindTexture(t.TEXTURE_2D, this.causticTexture), this.prepareQuad(this.materialProgram), this.setMaterialUniforms(e, n), t.drawArrays(t.TRIANGLE_STRIP, 0, 4)));
|
|
338
337
|
}
|
|
339
338
|
hasVisibleActivity() {
|
|
340
339
|
if (!this.framebuffers)
|
|
@@ -354,7 +353,7 @@ class rt {
|
|
|
354
353
|
} finally {
|
|
355
354
|
e.bindFramebuffer(e.FRAMEBUFFER, null);
|
|
356
355
|
}
|
|
357
|
-
return
|
|
356
|
+
return ut(
|
|
358
357
|
this.activityPixels,
|
|
359
358
|
this.simWidth,
|
|
360
359
|
this.simHeight
|
|
@@ -375,14 +374,14 @@ class rt {
|
|
|
375
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);
|
|
376
375
|
}
|
|
377
376
|
recreateState() {
|
|
378
|
-
var
|
|
377
|
+
var s, u;
|
|
379
378
|
const e = this.gl;
|
|
380
|
-
(
|
|
379
|
+
(s = this.stateTextures) == null || s.forEach((c) => e.deleteTexture(c)), (u = this.framebuffers) == null || u.forEach((c) => e.deleteFramebuffer(c));
|
|
381
380
|
const n = this.createStateTexture(), t = this.createStateTexture(), i = this.createFramebuffer(n), a = this.createFramebuffer(t);
|
|
382
381
|
this.stateTextures = [n, t], this.framebuffers = [i, a], this.readIndex = 0, this.clear();
|
|
383
382
|
}
|
|
384
383
|
createStateTexture() {
|
|
385
|
-
const e = this.gl, n =
|
|
384
|
+
const e = this.gl, n = $(e.createTexture(), "WebGL texture");
|
|
386
385
|
if (e.bindTexture(e.TEXTURE_2D, n), e.texParameteri(
|
|
387
386
|
e.TEXTURE_2D,
|
|
388
387
|
e.TEXTURE_MIN_FILTER,
|
|
@@ -419,7 +418,7 @@ class rt {
|
|
|
419
418
|
return n;
|
|
420
419
|
}
|
|
421
420
|
createFramebuffer(e) {
|
|
422
|
-
const n = this.gl, t =
|
|
421
|
+
const n = this.gl, t = $(n.createFramebuffer(), "WebGL framebuffer");
|
|
423
422
|
if (n.bindFramebuffer(n.FRAMEBUFFER, t), n.framebufferTexture2D(
|
|
424
423
|
n.FRAMEBUFFER,
|
|
425
424
|
n.COLOR_ATTACHMENT0,
|
|
@@ -455,11 +454,11 @@ class rt {
|
|
|
455
454
|
0,
|
|
456
455
|
e.RGBA,
|
|
457
456
|
e.UNSIGNED_BYTE,
|
|
458
|
-
|
|
457
|
+
ot()
|
|
459
458
|
), e.generateMipmap(e.TEXTURE_2D);
|
|
460
459
|
}
|
|
461
460
|
uploadTextureIfNeeded(e) {
|
|
462
|
-
if (e.mode === "dom" || !this.textureImage || !this.textureNeedsUpload && !
|
|
461
|
+
if (e.mode === "dom" || !this.textureImage || !this.textureNeedsUpload && !ct(this.textureImage))
|
|
463
462
|
return;
|
|
464
463
|
const n = this.gl;
|
|
465
464
|
try {
|
|
@@ -470,9 +469,11 @@ class rt {
|
|
|
470
469
|
n.RGBA,
|
|
471
470
|
n.UNSIGNED_BYTE,
|
|
472
471
|
this.textureImage
|
|
473
|
-
), 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;
|
|
474
475
|
} catch {
|
|
475
|
-
this.textureReady = !1, this.textureNeedsUpload = !1;
|
|
476
|
+
this.textureReady = !1, this.textureNeedsUpload = !1, this.textureWidth = 0, this.textureHeight = 0;
|
|
476
477
|
}
|
|
477
478
|
}
|
|
478
479
|
prepareQuad(e) {
|
|
@@ -480,57 +481,84 @@ class rt {
|
|
|
480
481
|
n.bindBuffer(n.ARRAY_BUFFER, this.quadBuffer), n.enableVertexAttribArray(e.position), n.vertexAttribPointer(e.position, 2, n.FLOAT, !1, 0, 0);
|
|
481
482
|
}
|
|
482
483
|
setSimulationUniforms(e, n, t) {
|
|
483
|
-
const i = this.gl, a = this.simulationProgram.program,
|
|
484
|
-
|
|
485
|
-
for (let
|
|
486
|
-
const m = e[
|
|
487
|
-
|
|
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;
|
|
488
489
|
}
|
|
489
|
-
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);
|
|
490
491
|
}
|
|
491
492
|
setMaterialUniforms(e, n) {
|
|
492
|
-
const t = this.gl, i = this.materialProgram.program, a =
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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);
|
|
497
505
|
}
|
|
498
506
|
}
|
|
499
|
-
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() {
|
|
500
528
|
const r = new Uint8Array(C * C * 4);
|
|
501
529
|
for (let e = 0; e < C; e += 1)
|
|
502
530
|
for (let n = 0; n < C; n += 1) {
|
|
503
|
-
const t = (n + 0.5) / C, i = (e + 0.5) / C, a = Math.round(ce(t, i, 0) * 255),
|
|
504
|
-
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;
|
|
505
533
|
}
|
|
506
534
|
return r;
|
|
507
535
|
}
|
|
508
536
|
function ce(r, e, n) {
|
|
509
|
-
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,
|
|
510
|
-
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;
|
|
511
539
|
for (let P = -1; P <= 1; P += 1)
|
|
512
540
|
for (let U = -1; U <= 1; U += 1) {
|
|
513
|
-
const k =
|
|
514
|
-
D <
|
|
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);
|
|
515
543
|
}
|
|
516
|
-
const
|
|
517
|
-
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));
|
|
518
546
|
}
|
|
519
|
-
function
|
|
547
|
+
function ge(r, e, n) {
|
|
520
548
|
const t = Math.sin(r * 127.1 + e * 311.7 + n * 74.7) * 43758.5453123;
|
|
521
549
|
return t - Math.floor(t);
|
|
522
550
|
}
|
|
523
|
-
function
|
|
551
|
+
function Le(r, e) {
|
|
524
552
|
return (r % e + e) % e;
|
|
525
553
|
}
|
|
526
|
-
function
|
|
527
|
-
const t =
|
|
554
|
+
function ke(r, e, n) {
|
|
555
|
+
const t = Xe((n - r) / (e - r));
|
|
528
556
|
return t * t * (3 - t * 2);
|
|
529
557
|
}
|
|
530
|
-
function
|
|
558
|
+
function Xe(r) {
|
|
531
559
|
return Math.min(1, Math.max(0, r));
|
|
532
560
|
}
|
|
533
|
-
function
|
|
561
|
+
function st(r) {
|
|
534
562
|
const e = {
|
|
535
563
|
alpha: !0,
|
|
536
564
|
antialias: !1,
|
|
@@ -562,51 +590,51 @@ function it(r) {
|
|
|
562
590
|
canLinearFloat: !!t.getExtension("OES_texture_float_linear")
|
|
563
591
|
};
|
|
564
592
|
}
|
|
565
|
-
function
|
|
566
|
-
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");
|
|
567
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)) {
|
|
568
|
-
const
|
|
569
|
-
throw r.deleteProgram(a), new Error(
|
|
596
|
+
const u = r.getProgramInfoLog(a) || "Unknown shader link error.";
|
|
597
|
+
throw r.deleteProgram(a), new Error(u);
|
|
570
598
|
}
|
|
571
|
-
const
|
|
572
|
-
if (
|
|
599
|
+
const s = r.getAttribLocation(a, "a_position");
|
|
600
|
+
if (s < 0)
|
|
573
601
|
throw new Error("WaterDistortion could not bind its quad attribute.");
|
|
574
|
-
return { program: a, position:
|
|
602
|
+
return { program: a, position: s };
|
|
575
603
|
}
|
|
576
|
-
function
|
|
577
|
-
const t =
|
|
604
|
+
function De(r, e, n) {
|
|
605
|
+
const t = $(r.createShader(e), "WebGL shader");
|
|
578
606
|
if (r.shaderSource(t, n), r.compileShader(t), !r.getShaderParameter(t, r.COMPILE_STATUS)) {
|
|
579
607
|
const i = r.getShaderInfoLog(t) || "Unknown shader compile error.";
|
|
580
608
|
throw r.deleteShader(t), new Error(i);
|
|
581
609
|
}
|
|
582
610
|
return t;
|
|
583
611
|
}
|
|
584
|
-
function
|
|
612
|
+
function _(r, e, n) {
|
|
585
613
|
const t = r.getUniformLocation(e, n);
|
|
586
614
|
if (!t)
|
|
587
615
|
throw new Error(`WaterDistortion could not bind uniform ${n}.`);
|
|
588
616
|
return t;
|
|
589
617
|
}
|
|
590
|
-
function
|
|
618
|
+
function $(r, e) {
|
|
591
619
|
if (!r)
|
|
592
620
|
throw new Error(`WaterDistortion could not create ${e}.`);
|
|
593
621
|
return r;
|
|
594
622
|
}
|
|
595
|
-
function
|
|
623
|
+
function ct(r) {
|
|
596
624
|
return typeof HTMLCanvasElement < "u" && r instanceof HTMLCanvasElement || typeof HTMLVideoElement < "u" && r instanceof HTMLVideoElement || typeof OffscreenCanvas < "u" && r instanceof OffscreenCanvas;
|
|
597
625
|
}
|
|
598
|
-
function
|
|
626
|
+
function ut(r, e, n, t = et) {
|
|
599
627
|
const i = Math.max(0, Math.floor(e)), a = Math.max(0, Math.floor(n));
|
|
600
628
|
if (i === 0 || a === 0)
|
|
601
629
|
return !1;
|
|
602
|
-
const
|
|
603
|
-
for (let
|
|
604
|
-
for (let
|
|
605
|
-
const
|
|
606
|
-
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)
|
|
607
635
|
return !0;
|
|
608
|
-
const m =
|
|
609
|
-
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)
|
|
610
638
|
return !0;
|
|
611
639
|
}
|
|
612
640
|
return !1;
|
|
@@ -624,8 +652,8 @@ const L = {
|
|
|
624
652
|
velocityClamp: 1.35,
|
|
625
653
|
cursorSmoothing: 0.2,
|
|
626
654
|
segmentSpacing: 18
|
|
627
|
-
},
|
|
628
|
-
function
|
|
655
|
+
}, lt = 24;
|
|
656
|
+
function ve(r) {
|
|
629
657
|
return {
|
|
630
658
|
width: Math.max(1, r.width ?? L.width),
|
|
631
659
|
height: Math.max(1, r.height ?? L.height),
|
|
@@ -655,7 +683,7 @@ function ge(r) {
|
|
|
655
683
|
0.05,
|
|
656
684
|
r.velocityClamp ?? L.velocityClamp
|
|
657
685
|
),
|
|
658
|
-
cursorSmoothing:
|
|
686
|
+
cursorSmoothing: d(
|
|
659
687
|
r.cursorSmoothing ?? L.cursorSmoothing,
|
|
660
688
|
0,
|
|
661
689
|
0.9
|
|
@@ -666,24 +694,24 @@ function ge(r) {
|
|
|
666
694
|
)
|
|
667
695
|
};
|
|
668
696
|
}
|
|
669
|
-
function
|
|
697
|
+
function Pe(r, e, n = r.timeStamp) {
|
|
670
698
|
const t = typeof r.getCoalescedEvents == "function" ? r.getCoalescedEvents() : [], i = t.length > 0 ? t : [r], a = n - r.timeStamp;
|
|
671
|
-
return i.map((
|
|
672
|
-
x:
|
|
673
|
-
y:
|
|
674
|
-
time:
|
|
699
|
+
return i.map((s) => ({
|
|
700
|
+
x: s.clientX - e.left,
|
|
701
|
+
y: s.clientY - e.top,
|
|
702
|
+
time: s.timeStamp + a
|
|
675
703
|
}));
|
|
676
704
|
}
|
|
677
|
-
class
|
|
705
|
+
class ht {
|
|
678
706
|
constructor(e = {}) {
|
|
679
707
|
f(this, "options");
|
|
680
708
|
f(this, "previous");
|
|
681
709
|
f(this, "smoothedVelocity", 0);
|
|
682
710
|
f(this, "disturbances", []);
|
|
683
|
-
this.options =
|
|
711
|
+
this.options = ve(e);
|
|
684
712
|
}
|
|
685
713
|
configure(e) {
|
|
686
|
-
this.options =
|
|
714
|
+
this.options = ve({
|
|
687
715
|
...this.options,
|
|
688
716
|
...e
|
|
689
717
|
});
|
|
@@ -697,25 +725,25 @@ class ct {
|
|
|
697
725
|
if (!t)
|
|
698
726
|
return this.previous = n, this.disturbances;
|
|
699
727
|
n.time <= t.time && (n.time = t.time + 0.01);
|
|
700
|
-
const i = this.smoothSample(t, n), a =
|
|
728
|
+
const i = this.smoothSample(t, n), a = Je(t, i);
|
|
701
729
|
if (a < 0.35)
|
|
702
730
|
return this.previous = i, this.disturbances;
|
|
703
|
-
const
|
|
731
|
+
const s = a / Math.max(0.01, i.time - t.time), u = d(1 - this.options.cursorSmoothing, 0.12, 1);
|
|
704
732
|
this.smoothedVelocity = O(
|
|
705
733
|
this.smoothedVelocity,
|
|
706
|
-
|
|
707
|
-
|
|
734
|
+
s,
|
|
735
|
+
u
|
|
708
736
|
), this.previous = i;
|
|
709
|
-
const
|
|
710
|
-
|
|
737
|
+
const c = Math.min(
|
|
738
|
+
lt,
|
|
711
739
|
Math.max(1, Math.ceil(a / this.options.segmentSpacing))
|
|
712
740
|
);
|
|
713
|
-
for (let
|
|
714
|
-
const
|
|
741
|
+
for (let h = 0; h < c; h += 1) {
|
|
742
|
+
const v = h / c, x = (h + 1) / c;
|
|
715
743
|
this.disturbances.push(
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
744
|
+
xe(
|
|
745
|
+
Be(t, i, v),
|
|
746
|
+
Be(t, i, x),
|
|
719
747
|
this.smoothedVelocity,
|
|
720
748
|
this.options
|
|
721
749
|
)
|
|
@@ -725,8 +753,8 @@ class ct {
|
|
|
725
753
|
}
|
|
726
754
|
clampSample(e) {
|
|
727
755
|
return {
|
|
728
|
-
x:
|
|
729
|
-
y:
|
|
756
|
+
x: d(e.x, 0, this.options.width),
|
|
757
|
+
y: d(e.y, 0, this.options.height),
|
|
730
758
|
time: e.time
|
|
731
759
|
};
|
|
732
760
|
}
|
|
@@ -739,39 +767,40 @@ class ct {
|
|
|
739
767
|
};
|
|
740
768
|
}
|
|
741
769
|
}
|
|
742
|
-
function
|
|
743
|
-
const i =
|
|
770
|
+
function xe(r, e, n, t) {
|
|
771
|
+
const i = ve(t), a = d(
|
|
744
772
|
n * i.velocityScale / i.velocityClamp,
|
|
745
773
|
0,
|
|
746
774
|
1
|
|
747
|
-
),
|
|
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);
|
|
748
776
|
return {
|
|
749
|
-
ax:
|
|
750
|
-
ay: 1 -
|
|
751
|
-
bx:
|
|
752
|
-
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,
|
|
753
781
|
radius: i.interactionRadius / i.height,
|
|
754
782
|
wakeStrength: i.wakeStrength * O(0.18, 1, a),
|
|
755
783
|
troughStrength: i.troughStrength,
|
|
756
784
|
ridgeStrength: i.ridgeStrength,
|
|
757
785
|
ridgeOffset: i.ridgeOffset / i.height,
|
|
758
|
-
wakeLength:
|
|
786
|
+
wakeLength: c / i.height,
|
|
759
787
|
velocity: a
|
|
760
788
|
};
|
|
761
789
|
}
|
|
762
|
-
function
|
|
790
|
+
function Be(r, e, n) {
|
|
763
791
|
return {
|
|
764
792
|
x: O(r.x, e.x, n),
|
|
765
793
|
y: O(r.y, e.y, n),
|
|
766
794
|
time: O(r.time, e.time, n)
|
|
767
795
|
};
|
|
768
796
|
}
|
|
769
|
-
function
|
|
770
|
-
const e =
|
|
771
|
-
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);
|
|
772
800
|
}
|
|
773
|
-
const
|
|
801
|
+
const E = {
|
|
774
802
|
mode: "texture",
|
|
803
|
+
textureFit: "fill",
|
|
775
804
|
damping: 0.98,
|
|
776
805
|
waveSpeed: 0.4,
|
|
777
806
|
normalScale: 20,
|
|
@@ -794,136 +823,137 @@ const x = {
|
|
|
794
823
|
interactionMode: "move",
|
|
795
824
|
runInBackground: !1,
|
|
796
825
|
pauseKey: void 0
|
|
797
|
-
}, G = 1e3 / 60,
|
|
798
|
-
function
|
|
826
|
+
}, G = 1e3 / 60, ft = 4, Ce = 360, Ne = 24, mt = 200;
|
|
827
|
+
function gt(r) {
|
|
799
828
|
return r instanceof Element && r.closest(
|
|
800
829
|
"a, button, input, select, textarea, [contenteditable]:not([contenteditable=false])"
|
|
801
830
|
) !== null;
|
|
802
831
|
}
|
|
803
|
-
function
|
|
832
|
+
function vt(r) {
|
|
804
833
|
const e = r.strength === void 0 ? void 0 : r.strength / 48;
|
|
805
834
|
return {
|
|
806
|
-
mode: r.mode ??
|
|
835
|
+
mode: r.mode ?? E.mode,
|
|
807
836
|
texture: r.texture,
|
|
808
|
-
|
|
809
|
-
|
|
837
|
+
textureFit: r.textureFit ?? E.textureFit,
|
|
838
|
+
damping: d(
|
|
839
|
+
r.damping ?? r.dissipation ?? E.damping,
|
|
810
840
|
0.85,
|
|
811
841
|
0.998
|
|
812
842
|
),
|
|
813
|
-
waveSpeed:
|
|
814
|
-
normalScale:
|
|
815
|
-
r.normalScale ??
|
|
843
|
+
waveSpeed: d(r.waveSpeed ?? E.waveSpeed, 0.05, 1),
|
|
844
|
+
normalScale: d(
|
|
845
|
+
r.normalScale ?? E.normalScale,
|
|
816
846
|
1,
|
|
817
847
|
80
|
|
818
848
|
),
|
|
819
|
-
refractionStrength:
|
|
820
|
-
r.refractionStrength ??
|
|
849
|
+
refractionStrength: d(
|
|
850
|
+
r.refractionStrength ?? E.refractionStrength,
|
|
821
851
|
0,
|
|
822
852
|
2.5
|
|
823
853
|
),
|
|
824
|
-
specularIntensity:
|
|
825
|
-
r.specularIntensity ??
|
|
854
|
+
specularIntensity: d(
|
|
855
|
+
r.specularIntensity ?? E.specularIntensity,
|
|
826
856
|
0,
|
|
827
857
|
3
|
|
828
858
|
),
|
|
829
|
-
crestIntensity:
|
|
830
|
-
r.crestIntensity ??
|
|
859
|
+
crestIntensity: d(
|
|
860
|
+
r.crestIntensity ?? E.crestIntensity,
|
|
831
861
|
0,
|
|
832
862
|
3
|
|
833
863
|
),
|
|
834
|
-
causticIntensity:
|
|
835
|
-
r.causticIntensity ??
|
|
864
|
+
causticIntensity: d(
|
|
865
|
+
r.causticIntensity ?? E.causticIntensity,
|
|
836
866
|
0,
|
|
837
867
|
3
|
|
838
868
|
),
|
|
839
|
-
simulationResolution:
|
|
869
|
+
simulationResolution: d(
|
|
840
870
|
Math.round(
|
|
841
|
-
r.simulationResolution ??
|
|
871
|
+
r.simulationResolution ?? E.simulationResolution
|
|
842
872
|
),
|
|
843
873
|
64,
|
|
844
874
|
384
|
|
845
875
|
),
|
|
846
|
-
wakeStrength:
|
|
847
|
-
r.wakeStrength ?? r.rippleStrength ?? e ??
|
|
876
|
+
wakeStrength: d(
|
|
877
|
+
r.wakeStrength ?? r.rippleStrength ?? e ?? E.wakeStrength,
|
|
848
878
|
0,
|
|
849
879
|
3
|
|
850
880
|
),
|
|
851
|
-
interactionRadius:
|
|
852
|
-
r.interactionRadius ??
|
|
881
|
+
interactionRadius: d(
|
|
882
|
+
r.interactionRadius ?? E.interactionRadius,
|
|
853
883
|
2,
|
|
854
884
|
80
|
|
855
885
|
),
|
|
856
|
-
troughStrength:
|
|
857
|
-
r.troughStrength ??
|
|
886
|
+
troughStrength: d(
|
|
887
|
+
r.troughStrength ?? E.troughStrength,
|
|
858
888
|
0,
|
|
859
889
|
3
|
|
860
890
|
),
|
|
861
|
-
ridgeStrength:
|
|
862
|
-
r.ridgeStrength ??
|
|
891
|
+
ridgeStrength: d(
|
|
892
|
+
r.ridgeStrength ?? E.ridgeStrength,
|
|
863
893
|
0,
|
|
864
894
|
3
|
|
865
895
|
),
|
|
866
|
-
ridgeOffset:
|
|
867
|
-
r.ridgeOffset ??
|
|
896
|
+
ridgeOffset: d(
|
|
897
|
+
r.ridgeOffset ?? E.ridgeOffset,
|
|
868
898
|
0,
|
|
869
899
|
80
|
|
870
900
|
),
|
|
871
|
-
wakeLength:
|
|
872
|
-
r.wakeLength ??
|
|
901
|
+
wakeLength: d(
|
|
902
|
+
r.wakeLength ?? E.wakeLength,
|
|
873
903
|
1,
|
|
874
904
|
240
|
|
875
905
|
),
|
|
876
|
-
velocityScale:
|
|
877
|
-
r.velocityScale ??
|
|
906
|
+
velocityScale: d(
|
|
907
|
+
r.velocityScale ?? E.velocityScale,
|
|
878
908
|
0.01,
|
|
879
909
|
4
|
|
880
910
|
),
|
|
881
|
-
velocityClamp:
|
|
882
|
-
r.velocityClamp ??
|
|
911
|
+
velocityClamp: d(
|
|
912
|
+
r.velocityClamp ?? E.velocityClamp,
|
|
883
913
|
0.05,
|
|
884
914
|
8
|
|
885
915
|
),
|
|
886
|
-
cursorSmoothing:
|
|
887
|
-
r.cursorSmoothing ??
|
|
916
|
+
cursorSmoothing: d(
|
|
917
|
+
r.cursorSmoothing ?? E.cursorSmoothing,
|
|
888
918
|
0,
|
|
889
919
|
0.9
|
|
890
920
|
),
|
|
891
|
-
segmentSpacing:
|
|
892
|
-
r.segmentSpacing ??
|
|
921
|
+
segmentSpacing: d(
|
|
922
|
+
r.segmentSpacing ?? E.segmentSpacing,
|
|
893
923
|
1,
|
|
894
924
|
96
|
|
895
925
|
),
|
|
896
|
-
idleTimeout: Math.max(120, r.idleTimeout ??
|
|
897
|
-
interactionMode: r.interactionMode ??
|
|
898
|
-
runInBackground: r.runInBackground ??
|
|
899
|
-
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
|
|
900
930
|
};
|
|
901
931
|
}
|
|
902
|
-
function
|
|
903
|
-
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 = {
|
|
904
934
|
...e,
|
|
905
935
|
width: n.width,
|
|
906
936
|
height: n.height,
|
|
907
937
|
wakeLength: e.interactionRadius * 1.5
|
|
908
938
|
};
|
|
909
939
|
return [
|
|
910
|
-
|
|
940
|
+
xe(
|
|
911
941
|
{ x: t - a, y: i },
|
|
912
942
|
{ x: t + a, y: i },
|
|
913
|
-
|
|
914
|
-
|
|
943
|
+
s,
|
|
944
|
+
u
|
|
915
945
|
),
|
|
916
|
-
|
|
946
|
+
xe(
|
|
917
947
|
{ x: t, y: i - a },
|
|
918
948
|
{ x: t, y: i + a },
|
|
919
|
-
|
|
920
|
-
|
|
949
|
+
s,
|
|
950
|
+
u
|
|
921
951
|
)
|
|
922
952
|
];
|
|
923
953
|
}
|
|
924
|
-
function
|
|
925
|
-
const [e, n] =
|
|
926
|
-
return
|
|
954
|
+
function xt(r) {
|
|
955
|
+
const [e, n] = Ze(!1);
|
|
956
|
+
return q(() => {
|
|
927
957
|
if (!r || typeof window > "u" || !window.matchMedia) {
|
|
928
958
|
n(!1);
|
|
929
959
|
return;
|
|
@@ -938,71 +968,72 @@ function mt(r) {
|
|
|
938
968
|
};
|
|
939
969
|
}, [r]), e;
|
|
940
970
|
}
|
|
941
|
-
const
|
|
971
|
+
const pt = Qe(function(e, n) {
|
|
942
972
|
const {
|
|
943
973
|
underlay: t,
|
|
944
974
|
children: i,
|
|
945
975
|
foreground: a,
|
|
946
|
-
className:
|
|
947
|
-
style:
|
|
948
|
-
reducedMotion:
|
|
949
|
-
} = e,
|
|
950
|
-
}),
|
|
951
|
-
}), H =
|
|
952
|
-
}), P =
|
|
953
|
-
|
|
954
|
-
), ue =
|
|
955
|
-
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(
|
|
956
986
|
n,
|
|
957
987
|
() => ({
|
|
958
988
|
triggerRipple(S) {
|
|
959
|
-
B.current ||
|
|
960
|
-
|
|
989
|
+
B.current || b.current || H.current(
|
|
990
|
+
We(
|
|
961
991
|
S,
|
|
962
992
|
g.current,
|
|
963
|
-
|
|
993
|
+
Q.current
|
|
964
994
|
)
|
|
965
995
|
);
|
|
966
996
|
}
|
|
967
997
|
}),
|
|
968
998
|
[]
|
|
969
|
-
),
|
|
999
|
+
), q(() => {
|
|
970
1000
|
var S;
|
|
971
|
-
B.current = ue, ue && (m.current.reset(), I.current = null, P.current = [], z.current = 0,
|
|
972
|
-
}, [ue]),
|
|
973
|
-
const 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;
|
|
974
1004
|
if (!S)
|
|
975
1005
|
return;
|
|
976
|
-
const { width: K, height:
|
|
1006
|
+
const { width: K, height: M } = Q.current;
|
|
977
1007
|
S.resize(
|
|
978
1008
|
K,
|
|
979
|
-
|
|
1009
|
+
M,
|
|
980
1010
|
window.devicePixelRatio,
|
|
981
|
-
|
|
982
|
-
), S.setTextureSource(
|
|
1011
|
+
T.simulationResolution
|
|
1012
|
+
), S.setTextureSource(T.texture), w.current();
|
|
983
1013
|
}, [
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
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;
|
|
996
1027
|
if (!S || !K)
|
|
997
1028
|
return;
|
|
998
1029
|
k.current = typeof document.hasFocus == "function" ? document.hasFocus() : !0;
|
|
999
|
-
let
|
|
1030
|
+
let M = null, ae, te = G, pe = !1, re;
|
|
1000
1031
|
const Y = () => {
|
|
1001
|
-
|
|
1002
|
-
},
|
|
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) => {
|
|
1003
1034
|
m.current.configure({
|
|
1004
1035
|
width: o,
|
|
1005
|
-
height:
|
|
1036
|
+
height: l,
|
|
1006
1037
|
interactionRadius: g.current.interactionRadius,
|
|
1007
1038
|
wakeStrength: g.current.wakeStrength,
|
|
1008
1039
|
troughStrength: g.current.troughStrength,
|
|
@@ -1014,56 +1045,56 @@ const gt = $e(function(e, n) {
|
|
|
1014
1045
|
cursorSmoothing: g.current.cursorSmoothing,
|
|
1015
1046
|
segmentSpacing: g.current.segmentSpacing
|
|
1016
1047
|
});
|
|
1017
|
-
},
|
|
1018
|
-
const F = Math.max(1, o),
|
|
1019
|
-
|
|
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(
|
|
1020
1051
|
F,
|
|
1021
|
-
|
|
1052
|
+
y,
|
|
1022
1053
|
window.devicePixelRatio,
|
|
1023
1054
|
g.current.simulationResolution
|
|
1024
1055
|
);
|
|
1025
|
-
},
|
|
1026
|
-
|
|
1056
|
+
}, Ee = () => {
|
|
1057
|
+
M == null || M.render(g.current, performance.now() * 1e-3);
|
|
1027
1058
|
}, X = () => {
|
|
1028
|
-
|
|
1029
|
-
},
|
|
1030
|
-
Y(), m.current.reset(), I.current = null, X(),
|
|
1031
|
-
},
|
|
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 = () => {
|
|
1032
1063
|
const o = g.current;
|
|
1033
|
-
let
|
|
1034
|
-
if (!(!B.current && !
|
|
1064
|
+
let l = !1;
|
|
1065
|
+
if (!(!B.current && !b.current && U.current && (o.runInBackground || !document.hidden && k.current))) {
|
|
1035
1066
|
X();
|
|
1036
1067
|
return;
|
|
1037
1068
|
}
|
|
1038
|
-
if (
|
|
1039
|
-
const
|
|
1040
|
-
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;
|
|
1041
1072
|
}
|
|
1042
|
-
(!o.runInBackground ||
|
|
1043
|
-
},
|
|
1044
|
-
|
|
1045
|
-
const
|
|
1046
|
-
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)) {
|
|
1047
1078
|
X();
|
|
1048
1079
|
return;
|
|
1049
1080
|
}
|
|
1050
1081
|
if (B.current) {
|
|
1051
|
-
P.current = [],
|
|
1082
|
+
P.current = [], M.render(l, o * 1e-3), X();
|
|
1052
1083
|
return;
|
|
1053
1084
|
}
|
|
1054
|
-
const F =
|
|
1055
|
-
o -
|
|
1085
|
+
const F = l.runInBackground ? Ce : ft, y = ae === void 0 ? G : d(
|
|
1086
|
+
o - ae,
|
|
1056
1087
|
0,
|
|
1057
|
-
|
|
1088
|
+
l.runInBackground ? G * Ce : 64
|
|
1058
1089
|
);
|
|
1059
|
-
|
|
1060
|
-
|
|
1090
|
+
ae = o, te = Math.min(
|
|
1091
|
+
te + y,
|
|
1061
1092
|
G * F
|
|
1062
1093
|
);
|
|
1063
|
-
let
|
|
1064
|
-
for (;
|
|
1065
|
-
|
|
1066
|
-
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) {
|
|
1067
1098
|
w.current();
|
|
1068
1099
|
return;
|
|
1069
1100
|
}
|
|
@@ -1071,8 +1102,8 @@ const gt = $e(function(e, n) {
|
|
|
1071
1102
|
w.current();
|
|
1072
1103
|
return;
|
|
1073
1104
|
}
|
|
1074
|
-
if (
|
|
1075
|
-
o <
|
|
1105
|
+
if (pe) {
|
|
1106
|
+
o < W.current ? w.current() : X();
|
|
1076
1107
|
return;
|
|
1077
1108
|
}
|
|
1078
1109
|
if (o < D.current) {
|
|
@@ -1080,122 +1111,122 @@ const gt = $e(function(e, n) {
|
|
|
1080
1111
|
return;
|
|
1081
1112
|
}
|
|
1082
1113
|
try {
|
|
1083
|
-
|
|
1114
|
+
M.hasVisibleActivity() ? (D.current = o + mt, w.current()) : X();
|
|
1084
1115
|
} catch {
|
|
1085
|
-
|
|
1116
|
+
pe = !0, o < W.current ? w.current() : X();
|
|
1086
1117
|
}
|
|
1087
1118
|
}, le = () => {
|
|
1088
|
-
|
|
1089
|
-
A.current = null,
|
|
1090
|
-
}, 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));
|
|
1091
1122
|
};
|
|
1092
1123
|
w.current = le;
|
|
1093
1124
|
try {
|
|
1094
|
-
|
|
1125
|
+
M = new nt(K, () => {
|
|
1095
1126
|
w.current();
|
|
1096
|
-
}),
|
|
1127
|
+
}), x.current = M, M.setTextureSource(g.current.texture);
|
|
1097
1128
|
} catch {
|
|
1098
|
-
return K.style.display = "none",
|
|
1129
|
+
return K.style.display = "none", x.current = null, w.current = () => {
|
|
1099
1130
|
}, () => {
|
|
1100
1131
|
};
|
|
1101
1132
|
}
|
|
1102
|
-
const
|
|
1133
|
+
const he = () => {
|
|
1103
1134
|
const o = K.getBoundingClientRect();
|
|
1104
|
-
return
|
|
1105
|
-
},
|
|
1106
|
-
|
|
1107
|
-
},
|
|
1108
|
-
if (
|
|
1135
|
+
return Ke(o.width, o.height), o;
|
|
1136
|
+
}, Se = () => {
|
|
1137
|
+
he(), Ee();
|
|
1138
|
+
}, de = (o) => {
|
|
1139
|
+
if (b.current || o.length === 0)
|
|
1109
1140
|
return;
|
|
1110
|
-
const
|
|
1111
|
-
for (const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
const
|
|
1115
|
-
z.current = Math.max(z.current,
|
|
1116
|
-
|
|
1117
|
-
|
|
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)
|
|
1118
1149
|
), D.current = 0, le();
|
|
1119
1150
|
};
|
|
1120
|
-
H.current =
|
|
1121
|
-
const
|
|
1122
|
-
const
|
|
1123
|
-
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)
|
|
1124
1155
|
return;
|
|
1125
1156
|
m.current.reset();
|
|
1126
|
-
const F =
|
|
1127
|
-
|
|
1128
|
-
|
|
1157
|
+
const F = he(), [y] = Pe(o, F, performance.now());
|
|
1158
|
+
y && ((l.interactionMode === "click" || l.interactionMode === "drag") && de(
|
|
1159
|
+
We(
|
|
1129
1160
|
{
|
|
1130
|
-
x:
|
|
1131
|
-
y:
|
|
1161
|
+
x: y.x / Q.current.width,
|
|
1162
|
+
y: y.y / Q.current.height
|
|
1132
1163
|
},
|
|
1133
|
-
|
|
1134
|
-
|
|
1164
|
+
l,
|
|
1165
|
+
Q.current
|
|
1135
1166
|
)
|
|
1136
|
-
),
|
|
1137
|
-
},
|
|
1138
|
-
const
|
|
1139
|
-
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)
|
|
1140
1171
|
return;
|
|
1141
|
-
const F =
|
|
1142
|
-
for (const
|
|
1143
|
-
|
|
1144
|
-
},
|
|
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) => {
|
|
1145
1176
|
I.current !== null && I.current !== o.pointerId || (I.current = null, m.current.reset());
|
|
1146
|
-
},
|
|
1147
|
-
const
|
|
1148
|
-
!
|
|
1149
|
-
}, ye = () => {
|
|
1150
|
-
Y(), document.hidden && !g.current.runInBackground ? re() : Q();
|
|
1151
|
-
}, Re = () => {
|
|
1152
|
-
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()));
|
|
1153
1180
|
}, we = () => {
|
|
1154
|
-
|
|
1155
|
-
},
|
|
1156
|
-
|
|
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();
|
|
1157
1188
|
};
|
|
1158
|
-
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1189
|
+
N.current = Ye, Se();
|
|
1190
|
+
const Ae = new ResizeObserver(() => {
|
|
1191
|
+
Se(), le();
|
|
1161
1192
|
});
|
|
1162
|
-
|
|
1163
|
-
let
|
|
1164
|
-
return "IntersectionObserver" in window && (
|
|
1165
|
-
const
|
|
1166
|
-
U.current =
|
|
1167
|
-
}),
|
|
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, {
|
|
1168
1199
|
passive: !0
|
|
1169
|
-
}), S.addEventListener("pointermove",
|
|
1200
|
+
}), S.addEventListener("pointermove", ye, {
|
|
1170
1201
|
passive: !0
|
|
1171
|
-
}), S.addEventListener("pointerup",
|
|
1202
|
+
}), S.addEventListener("pointerup", Z, {
|
|
1172
1203
|
passive: !0
|
|
1173
|
-
}), S.addEventListener("pointerleave",
|
|
1204
|
+
}), S.addEventListener("pointerleave", Z, {
|
|
1174
1205
|
passive: !0
|
|
1175
|
-
}), S.addEventListener("pointercancel",
|
|
1206
|
+
}), S.addEventListener("pointercancel", Z, {
|
|
1176
1207
|
passive: !0
|
|
1177
|
-
}), window.addEventListener("blur",
|
|
1208
|
+
}), window.addEventListener("blur", be), window.addEventListener("focus", Me), document.addEventListener("keydown", Re), document.addEventListener("visibilitychange", we), () => {
|
|
1178
1209
|
var o;
|
|
1179
|
-
Y(),
|
|
1180
|
-
},
|
|
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 = () => {
|
|
1181
1212
|
}, H.current = () => {
|
|
1182
1213
|
};
|
|
1183
1214
|
};
|
|
1184
|
-
}, []),
|
|
1215
|
+
}, []), q(() => {
|
|
1185
1216
|
m.current.reset(), I.current = null;
|
|
1186
|
-
}, [
|
|
1187
|
-
|
|
1188
|
-
}, [
|
|
1189
|
-
!
|
|
1190
|
-
}, [
|
|
1191
|
-
const
|
|
1192
|
-
...
|
|
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,
|
|
1193
1224
|
position: "relative",
|
|
1194
1225
|
overflow: "hidden",
|
|
1195
1226
|
isolation: "isolate"
|
|
1196
1227
|
};
|
|
1197
|
-
return /* @__PURE__ */
|
|
1198
|
-
t ? /* @__PURE__ */
|
|
1228
|
+
return /* @__PURE__ */ $e("div", { ref: h, className: s, style: He, children: [
|
|
1229
|
+
t ? /* @__PURE__ */ fe(
|
|
1199
1230
|
"div",
|
|
1200
1231
|
{
|
|
1201
1232
|
style: {
|
|
@@ -1208,10 +1239,10 @@ const gt = $e(function(e, n) {
|
|
|
1208
1239
|
children: t
|
|
1209
1240
|
}
|
|
1210
1241
|
) : null,
|
|
1211
|
-
/* @__PURE__ */
|
|
1242
|
+
/* @__PURE__ */ fe(
|
|
1212
1243
|
"canvas",
|
|
1213
1244
|
{
|
|
1214
|
-
ref:
|
|
1245
|
+
ref: v,
|
|
1215
1246
|
"aria-hidden": "true",
|
|
1216
1247
|
style: {
|
|
1217
1248
|
position: "absolute",
|
|
@@ -1220,24 +1251,24 @@ const gt = $e(function(e, n) {
|
|
|
1220
1251
|
width: "100%",
|
|
1221
1252
|
height: "100%",
|
|
1222
1253
|
pointerEvents: "none",
|
|
1223
|
-
mixBlendMode:
|
|
1254
|
+
mixBlendMode: T.mode === "dom" ? "screen" : "normal"
|
|
1224
1255
|
}
|
|
1225
1256
|
}
|
|
1226
1257
|
),
|
|
1227
|
-
/* @__PURE__ */
|
|
1258
|
+
/* @__PURE__ */ fe(
|
|
1228
1259
|
"div",
|
|
1229
1260
|
{
|
|
1230
1261
|
style: {
|
|
1231
1262
|
position: "relative",
|
|
1232
1263
|
zIndex: 2
|
|
1233
1264
|
},
|
|
1234
|
-
children:
|
|
1265
|
+
children: Oe
|
|
1235
1266
|
}
|
|
1236
1267
|
)
|
|
1237
1268
|
] });
|
|
1238
|
-
}),
|
|
1269
|
+
}), Tt = pt;
|
|
1239
1270
|
export {
|
|
1240
|
-
|
|
1241
|
-
|
|
1271
|
+
pt as WaterDistortion,
|
|
1272
|
+
Tt as WaterLayer
|
|
1242
1273
|
};
|
|
1243
1274
|
//# sourceMappingURL=water-distortion.js.map
|