@brochington/shader-backgrounds 0.1.0 → 0.1.1

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.
@@ -0,0 +1,2962 @@
1
+ var st = (i) => {
2
+ throw TypeError(i);
3
+ };
4
+ var Y = (i, t, e) => t.has(i) || st("Cannot " + e);
5
+ var N = (i, t, e) => (Y(i, t, "read from private field"), e ? e.call(i) : t.get(i)), V = (i, t, e) => t.has(i) ? st("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), W = (i, t, e, s) => (Y(i, t, "write to private field"), s ? s.call(i, e) : t.set(i, e), e), _ = (i, t, e) => (Y(i, t, "access private method"), e);
6
+ function q(i) {
7
+ let t = i[0], e = i[1], s = i[2];
8
+ return Math.sqrt(t * t + e * e + s * s);
9
+ }
10
+ function K(i, t) {
11
+ return i[0] = t[0], i[1] = t[1], i[2] = t[2], i;
12
+ }
13
+ function Ot(i, t, e, s) {
14
+ return i[0] = t, i[1] = e, i[2] = s, i;
15
+ }
16
+ function rt(i, t, e) {
17
+ return i[0] = t[0] + e[0], i[1] = t[1] + e[1], i[2] = t[2] + e[2], i;
18
+ }
19
+ function nt(i, t, e) {
20
+ return i[0] = t[0] - e[0], i[1] = t[1] - e[1], i[2] = t[2] - e[2], i;
21
+ }
22
+ function kt(i, t, e) {
23
+ return i[0] = t[0] * e[0], i[1] = t[1] * e[1], i[2] = t[2] * e[2], i;
24
+ }
25
+ function Gt(i, t, e) {
26
+ return i[0] = t[0] / e[0], i[1] = t[1] / e[1], i[2] = t[2] / e[2], i;
27
+ }
28
+ function j(i, t, e) {
29
+ return i[0] = t[0] * e, i[1] = t[1] * e, i[2] = t[2] * e, i;
30
+ }
31
+ function Dt(i, t) {
32
+ let e = t[0] - i[0], s = t[1] - i[1], r = t[2] - i[2];
33
+ return Math.sqrt(e * e + s * s + r * r);
34
+ }
35
+ function Xt(i, t) {
36
+ let e = t[0] - i[0], s = t[1] - i[1], r = t[2] - i[2];
37
+ return e * e + s * s + r * r;
38
+ }
39
+ function at(i) {
40
+ let t = i[0], e = i[1], s = i[2];
41
+ return t * t + e * e + s * s;
42
+ }
43
+ function Pt(i, t) {
44
+ return i[0] = -t[0], i[1] = -t[1], i[2] = -t[2], i;
45
+ }
46
+ function qt(i, t) {
47
+ return i[0] = 1 / t[0], i[1] = 1 / t[1], i[2] = 1 / t[2], i;
48
+ }
49
+ function tt(i, t) {
50
+ let e = t[0], s = t[1], r = t[2], n = e * e + s * s + r * r;
51
+ return n > 0 && (n = 1 / Math.sqrt(n)), i[0] = t[0] * n, i[1] = t[1] * n, i[2] = t[2] * n, i;
52
+ }
53
+ function Rt(i, t) {
54
+ return i[0] * t[0] + i[1] * t[1] + i[2] * t[2];
55
+ }
56
+ function lt(i, t, e) {
57
+ let s = t[0], r = t[1], n = t[2], a = e[0], l = e[1], h = e[2];
58
+ return i[0] = r * h - n * l, i[1] = n * a - s * h, i[2] = s * l - r * a, i;
59
+ }
60
+ function Nt(i, t, e, s) {
61
+ let r = t[0], n = t[1], a = t[2];
62
+ return i[0] = r + s * (e[0] - r), i[1] = n + s * (e[1] - n), i[2] = a + s * (e[2] - a), i;
63
+ }
64
+ function $t(i, t, e, s, r) {
65
+ const n = Math.exp(-s * r);
66
+ let a = t[0], l = t[1], h = t[2];
67
+ return i[0] = e[0] + (a - e[0]) * n, i[1] = e[1] + (l - e[1]) * n, i[2] = e[2] + (h - e[2]) * n, i;
68
+ }
69
+ function Ut(i, t, e) {
70
+ let s = t[0], r = t[1], n = t[2], a = e[3] * s + e[7] * r + e[11] * n + e[15];
71
+ return a = a || 1, i[0] = (e[0] * s + e[4] * r + e[8] * n + e[12]) / a, i[1] = (e[1] * s + e[5] * r + e[9] * n + e[13]) / a, i[2] = (e[2] * s + e[6] * r + e[10] * n + e[14]) / a, i;
72
+ }
73
+ function Yt(i, t, e) {
74
+ let s = t[0], r = t[1], n = t[2], a = e[3] * s + e[7] * r + e[11] * n + e[15];
75
+ return a = a || 1, i[0] = (e[0] * s + e[4] * r + e[8] * n) / a, i[1] = (e[1] * s + e[5] * r + e[9] * n) / a, i[2] = (e[2] * s + e[6] * r + e[10] * n) / a, i;
76
+ }
77
+ function Vt(i, t, e) {
78
+ let s = t[0], r = t[1], n = t[2];
79
+ return i[0] = s * e[0] + r * e[3] + n * e[6], i[1] = s * e[1] + r * e[4] + n * e[7], i[2] = s * e[2] + r * e[5] + n * e[8], i;
80
+ }
81
+ function Wt(i, t, e) {
82
+ let s = t[0], r = t[1], n = t[2], a = e[0], l = e[1], h = e[2], o = e[3], c = l * n - h * r, u = h * s - a * n, f = a * r - l * s, d = l * f - h * u, g = h * c - a * f, p = a * u - l * c, m = o * 2;
83
+ return c *= m, u *= m, f *= m, d *= 2, g *= 2, p *= 2, i[0] = s + c + d, i[1] = r + u + g, i[2] = n + f + p, i;
84
+ }
85
+ const jt = /* @__PURE__ */ (function() {
86
+ const i = [0, 0, 0], t = [0, 0, 0];
87
+ return function(e, s) {
88
+ K(i, e), K(t, s), tt(i, i), tt(t, t);
89
+ let r = Rt(i, t);
90
+ return r > 1 ? 0 : r < -1 ? Math.PI : Math.acos(r);
91
+ };
92
+ })();
93
+ function Zt(i, t) {
94
+ return i[0] === t[0] && i[1] === t[1] && i[2] === t[2];
95
+ }
96
+ class k extends Array {
97
+ constructor(t = 0, e = t, s = t) {
98
+ return super(t, e, s), this;
99
+ }
100
+ get x() {
101
+ return this[0];
102
+ }
103
+ get y() {
104
+ return this[1];
105
+ }
106
+ get z() {
107
+ return this[2];
108
+ }
109
+ set x(t) {
110
+ this[0] = t;
111
+ }
112
+ set y(t) {
113
+ this[1] = t;
114
+ }
115
+ set z(t) {
116
+ this[2] = t;
117
+ }
118
+ set(t, e = t, s = t) {
119
+ return t.length ? this.copy(t) : (Ot(this, t, e, s), this);
120
+ }
121
+ copy(t) {
122
+ return K(this, t), this;
123
+ }
124
+ add(t, e) {
125
+ return e ? rt(this, t, e) : rt(this, this, t), this;
126
+ }
127
+ sub(t, e) {
128
+ return e ? nt(this, t, e) : nt(this, this, t), this;
129
+ }
130
+ multiply(t) {
131
+ return t.length ? kt(this, this, t) : j(this, this, t), this;
132
+ }
133
+ divide(t) {
134
+ return t.length ? Gt(this, this, t) : j(this, this, 1 / t), this;
135
+ }
136
+ inverse(t = this) {
137
+ return qt(this, t), this;
138
+ }
139
+ // Can't use 'length' as Array.prototype uses it
140
+ len() {
141
+ return q(this);
142
+ }
143
+ distance(t) {
144
+ return t ? Dt(this, t) : q(this);
145
+ }
146
+ squaredLen() {
147
+ return at(this);
148
+ }
149
+ squaredDistance(t) {
150
+ return t ? Xt(this, t) : at(this);
151
+ }
152
+ negate(t = this) {
153
+ return Pt(this, t), this;
154
+ }
155
+ cross(t, e) {
156
+ return e ? lt(this, t, e) : lt(this, this, t), this;
157
+ }
158
+ scale(t) {
159
+ return j(this, this, t), this;
160
+ }
161
+ normalize() {
162
+ return tt(this, this), this;
163
+ }
164
+ dot(t) {
165
+ return Rt(this, t);
166
+ }
167
+ equals(t) {
168
+ return Zt(this, t);
169
+ }
170
+ applyMatrix3(t) {
171
+ return Vt(this, this, t), this;
172
+ }
173
+ applyMatrix4(t) {
174
+ return Ut(this, this, t), this;
175
+ }
176
+ scaleRotateMatrix4(t) {
177
+ return Yt(this, this, t), this;
178
+ }
179
+ applyQuaternion(t) {
180
+ return Wt(this, this, t), this;
181
+ }
182
+ angle(t) {
183
+ return jt(this, t);
184
+ }
185
+ lerp(t, e) {
186
+ return Nt(this, this, t, e), this;
187
+ }
188
+ smoothLerp(t, e, s) {
189
+ return $t(this, this, t, e, s), this;
190
+ }
191
+ clone() {
192
+ return new k(this[0], this[1], this[2]);
193
+ }
194
+ fromArray(t, e = 0) {
195
+ return this[0] = t[e], this[1] = t[e + 1], this[2] = t[e + 2], this;
196
+ }
197
+ toArray(t = [], e = 0) {
198
+ return t[e] = this[0], t[e + 1] = this[1], t[e + 2] = this[2], t;
199
+ }
200
+ transformDirection(t) {
201
+ const e = this[0], s = this[1], r = this[2];
202
+ return this[0] = t[0] * e + t[4] * s + t[8] * r, this[1] = t[1] * e + t[5] * s + t[9] * r, this[2] = t[2] * e + t[6] * s + t[10] * r, this.normalize();
203
+ }
204
+ }
205
+ const ht = /* @__PURE__ */ new k();
206
+ let Ht = 1, Qt = 1, ot = !1;
207
+ class Jt {
208
+ constructor(t, e = {}) {
209
+ t.canvas || console.error("gl not passed as first argument to Geometry"), this.gl = t, this.attributes = e, this.id = Ht++, this.VAOs = {}, this.drawRange = { start: 0, count: 0 }, this.instancedCount = 0, this.gl.renderer.bindVertexArray(null), this.gl.renderer.currentGeometry = null, this.glState = this.gl.renderer.state;
210
+ for (let s in e)
211
+ this.addAttribute(s, e[s]);
212
+ }
213
+ addAttribute(t, e) {
214
+ if (this.attributes[t] = e, e.id = Qt++, e.size = e.size || 1, e.type = e.type || (e.data.constructor === Float32Array ? this.gl.FLOAT : e.data.constructor === Uint16Array ? this.gl.UNSIGNED_SHORT : this.gl.UNSIGNED_INT), e.target = t === "index" ? this.gl.ELEMENT_ARRAY_BUFFER : this.gl.ARRAY_BUFFER, e.normalized = e.normalized || !1, e.stride = e.stride || 0, e.offset = e.offset || 0, e.count = e.count || (e.stride ? e.data.byteLength / e.stride : e.data.length / e.size), e.divisor = e.instanced || 0, e.needsUpdate = !1, e.usage = e.usage || this.gl.STATIC_DRAW, e.buffer || this.updateAttribute(e), e.divisor) {
215
+ if (this.isInstanced = !0, this.instancedCount && this.instancedCount !== e.count * e.divisor)
216
+ return console.warn("geometry has multiple instanced buffers of different length"), this.instancedCount = Math.min(this.instancedCount, e.count * e.divisor);
217
+ this.instancedCount = e.count * e.divisor;
218
+ } else t === "index" ? this.drawRange.count = e.count : this.attributes.index || (this.drawRange.count = Math.max(this.drawRange.count, e.count));
219
+ }
220
+ updateAttribute(t) {
221
+ const e = !t.buffer;
222
+ e && (t.buffer = this.gl.createBuffer()), this.glState.boundBuffer !== t.buffer && (this.gl.bindBuffer(t.target, t.buffer), this.glState.boundBuffer = t.buffer), e ? this.gl.bufferData(t.target, t.data, t.usage) : this.gl.bufferSubData(t.target, 0, t.data), t.needsUpdate = !1;
223
+ }
224
+ setIndex(t) {
225
+ this.addAttribute("index", t);
226
+ }
227
+ setDrawRange(t, e) {
228
+ this.drawRange.start = t, this.drawRange.count = e;
229
+ }
230
+ setInstancedCount(t) {
231
+ this.instancedCount = t;
232
+ }
233
+ createVAO(t) {
234
+ this.VAOs[t.attributeOrder] = this.gl.renderer.createVertexArray(), this.gl.renderer.bindVertexArray(this.VAOs[t.attributeOrder]), this.bindAttributes(t);
235
+ }
236
+ bindAttributes(t) {
237
+ t.attributeLocations.forEach((e, { name: s, type: r }) => {
238
+ if (!this.attributes[s]) {
239
+ console.warn(`active attribute ${s} not being supplied`);
240
+ return;
241
+ }
242
+ const n = this.attributes[s];
243
+ this.gl.bindBuffer(n.target, n.buffer), this.glState.boundBuffer = n.buffer;
244
+ let a = 1;
245
+ r === 35674 && (a = 2), r === 35675 && (a = 3), r === 35676 && (a = 4);
246
+ const l = n.size / a, h = a === 1 ? 0 : a * a * 4, o = a === 1 ? 0 : a * 4;
247
+ for (let c = 0; c < a; c++)
248
+ this.gl.vertexAttribPointer(e + c, l, n.type, n.normalized, n.stride + h, n.offset + c * o), this.gl.enableVertexAttribArray(e + c), this.gl.renderer.vertexAttribDivisor(e + c, n.divisor);
249
+ }), this.attributes.index && this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.attributes.index.buffer);
250
+ }
251
+ draw({ program: t, mode: e = this.gl.TRIANGLES }) {
252
+ this.gl.renderer.currentGeometry !== `${this.id}_${t.attributeOrder}` && (this.VAOs[t.attributeOrder] || this.createVAO(t), this.gl.renderer.bindVertexArray(this.VAOs[t.attributeOrder]), this.gl.renderer.currentGeometry = `${this.id}_${t.attributeOrder}`), t.attributeLocations.forEach((r, { name: n }) => {
253
+ const a = this.attributes[n];
254
+ a.needsUpdate && this.updateAttribute(a);
255
+ });
256
+ let s = 2;
257
+ this.attributes.index?.type === this.gl.UNSIGNED_INT && (s = 4), this.isInstanced ? this.attributes.index ? this.gl.renderer.drawElementsInstanced(
258
+ e,
259
+ this.drawRange.count,
260
+ this.attributes.index.type,
261
+ this.attributes.index.offset + this.drawRange.start * s,
262
+ this.instancedCount
263
+ ) : this.gl.renderer.drawArraysInstanced(e, this.drawRange.start, this.drawRange.count, this.instancedCount) : this.attributes.index ? this.gl.drawElements(
264
+ e,
265
+ this.drawRange.count,
266
+ this.attributes.index.type,
267
+ this.attributes.index.offset + this.drawRange.start * s
268
+ ) : this.gl.drawArrays(e, this.drawRange.start, this.drawRange.count);
269
+ }
270
+ getPosition() {
271
+ const t = this.attributes.position;
272
+ if (t.data) return t;
273
+ if (!ot)
274
+ return console.warn("No position buffer data found to compute bounds"), ot = !0;
275
+ }
276
+ computeBoundingBox(t) {
277
+ t || (t = this.getPosition());
278
+ const e = t.data, s = t.size;
279
+ this.bounds || (this.bounds = {
280
+ min: new k(),
281
+ max: new k(),
282
+ center: new k(),
283
+ scale: new k(),
284
+ radius: 1 / 0
285
+ });
286
+ const r = this.bounds.min, n = this.bounds.max, a = this.bounds.center, l = this.bounds.scale;
287
+ r.set(1 / 0), n.set(-1 / 0);
288
+ for (let h = 0, o = e.length; h < o; h += s) {
289
+ const c = e[h], u = e[h + 1], f = e[h + 2];
290
+ r.x = Math.min(c, r.x), r.y = Math.min(u, r.y), r.z = Math.min(f, r.z), n.x = Math.max(c, n.x), n.y = Math.max(u, n.y), n.z = Math.max(f, n.z);
291
+ }
292
+ l.sub(n, r), a.add(r, n).divide(2);
293
+ }
294
+ computeBoundingSphere(t) {
295
+ t || (t = this.getPosition());
296
+ const e = t.data, s = t.size;
297
+ this.bounds || this.computeBoundingBox(t);
298
+ let r = 0;
299
+ for (let n = 0, a = e.length; n < a; n += s)
300
+ ht.fromArray(e, n), r = Math.max(r, this.bounds.center.squaredDistance(ht));
301
+ this.bounds.radius = Math.sqrt(r);
302
+ }
303
+ remove() {
304
+ for (let t in this.VAOs)
305
+ this.gl.renderer.deleteVertexArray(this.VAOs[t]), delete this.VAOs[t];
306
+ for (let t in this.attributes)
307
+ this.gl.deleteBuffer(this.attributes[t].buffer), delete this.attributes[t];
308
+ }
309
+ }
310
+ let Kt = 1;
311
+ const ct = {};
312
+ class te {
313
+ constructor(t, {
314
+ vertex: e,
315
+ fragment: s,
316
+ uniforms: r = {},
317
+ transparent: n = !1,
318
+ cullFace: a = t.BACK,
319
+ frontFace: l = t.CCW,
320
+ depthTest: h = !0,
321
+ depthWrite: o = !0,
322
+ depthFunc: c = t.LEQUAL
323
+ } = {}) {
324
+ t.canvas || console.error("gl not passed as first argument to Program"), this.gl = t, this.uniforms = r, this.id = Kt++, e || console.warn("vertex shader not supplied"), s || console.warn("fragment shader not supplied"), this.transparent = n, this.cullFace = a, this.frontFace = l, this.depthTest = h, this.depthWrite = o, this.depthFunc = c, this.blendFunc = {}, this.blendEquation = {}, this.stencilFunc = {}, this.stencilOp = {}, this.transparent && !this.blendFunc.src && (this.gl.renderer.premultipliedAlpha ? this.setBlendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA) : this.setBlendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA)), this.vertexShader = t.createShader(t.VERTEX_SHADER), this.fragmentShader = t.createShader(t.FRAGMENT_SHADER), this.program = t.createProgram(), t.attachShader(this.program, this.vertexShader), t.attachShader(this.program, this.fragmentShader), this.setShaders({ vertex: e, fragment: s });
325
+ }
326
+ setShaders({ vertex: t, fragment: e }) {
327
+ if (t && (this.gl.shaderSource(this.vertexShader, t), this.gl.compileShader(this.vertexShader), this.gl.getShaderInfoLog(this.vertexShader) !== "" && console.warn(`${this.gl.getShaderInfoLog(this.vertexShader)}
328
+ Vertex Shader
329
+ ${ut(t)}`)), e && (this.gl.shaderSource(this.fragmentShader, e), this.gl.compileShader(this.fragmentShader), this.gl.getShaderInfoLog(this.fragmentShader) !== "" && console.warn(`${this.gl.getShaderInfoLog(this.fragmentShader)}
330
+ Fragment Shader
331
+ ${ut(e)}`)), this.gl.linkProgram(this.program), !this.gl.getProgramParameter(this.program, this.gl.LINK_STATUS))
332
+ return console.warn(this.gl.getProgramInfoLog(this.program));
333
+ this.uniformLocations = /* @__PURE__ */ new Map();
334
+ let s = this.gl.getProgramParameter(this.program, this.gl.ACTIVE_UNIFORMS);
335
+ for (let a = 0; a < s; a++) {
336
+ let l = this.gl.getActiveUniform(this.program, a);
337
+ this.uniformLocations.set(l, this.gl.getUniformLocation(this.program, l.name));
338
+ const h = l.name.match(/(\w+)/g);
339
+ l.uniformName = h[0], l.nameComponents = h.slice(1);
340
+ }
341
+ this.attributeLocations = /* @__PURE__ */ new Map();
342
+ const r = [], n = this.gl.getProgramParameter(this.program, this.gl.ACTIVE_ATTRIBUTES);
343
+ for (let a = 0; a < n; a++) {
344
+ const l = this.gl.getActiveAttrib(this.program, a), h = this.gl.getAttribLocation(this.program, l.name);
345
+ h !== -1 && (r[h] = l.name, this.attributeLocations.set(l, h));
346
+ }
347
+ this.attributeOrder = r.join("");
348
+ }
349
+ setBlendFunc(t, e, s, r) {
350
+ this.blendFunc.src = t, this.blendFunc.dst = e, this.blendFunc.srcAlpha = s, this.blendFunc.dstAlpha = r, t && (this.transparent = !0);
351
+ }
352
+ setBlendEquation(t, e) {
353
+ this.blendEquation.modeRGB = t, this.blendEquation.modeAlpha = e;
354
+ }
355
+ setStencilFunc(t, e, s) {
356
+ this.stencilRef = e, this.stencilFunc.func = t, this.stencilFunc.ref = e, this.stencilFunc.mask = s;
357
+ }
358
+ setStencilOp(t, e, s) {
359
+ this.stencilOp.stencilFail = t, this.stencilOp.depthFail = e, this.stencilOp.depthPass = s;
360
+ }
361
+ applyState() {
362
+ this.depthTest ? this.gl.renderer.enable(this.gl.DEPTH_TEST) : this.gl.renderer.disable(this.gl.DEPTH_TEST), this.cullFace ? this.gl.renderer.enable(this.gl.CULL_FACE) : this.gl.renderer.disable(this.gl.CULL_FACE), this.blendFunc.src ? this.gl.renderer.enable(this.gl.BLEND) : this.gl.renderer.disable(this.gl.BLEND), this.cullFace && this.gl.renderer.setCullFace(this.cullFace), this.gl.renderer.setFrontFace(this.frontFace), this.gl.renderer.setDepthMask(this.depthWrite), this.gl.renderer.setDepthFunc(this.depthFunc), this.blendFunc.src && this.gl.renderer.setBlendFunc(this.blendFunc.src, this.blendFunc.dst, this.blendFunc.srcAlpha, this.blendFunc.dstAlpha), this.gl.renderer.setBlendEquation(this.blendEquation.modeRGB, this.blendEquation.modeAlpha), this.stencilFunc.func || this.stencilOp.stencilFail ? this.gl.renderer.enable(this.gl.STENCIL_TEST) : this.gl.renderer.disable(this.gl.STENCIL_TEST), this.gl.renderer.setStencilFunc(this.stencilFunc.func, this.stencilFunc.ref, this.stencilFunc.mask), this.gl.renderer.setStencilOp(this.stencilOp.stencilFail, this.stencilOp.depthFail, this.stencilOp.depthPass);
363
+ }
364
+ use({ flipFaces: t = !1 } = {}) {
365
+ let e = -1;
366
+ this.gl.renderer.state.currentProgram === this.id || (this.gl.useProgram(this.program), this.gl.renderer.state.currentProgram = this.id), this.uniformLocations.forEach((r, n) => {
367
+ let a = this.uniforms[n.uniformName];
368
+ for (const l of n.nameComponents) {
369
+ if (!a) break;
370
+ if (l in a)
371
+ a = a[l];
372
+ else {
373
+ if (Array.isArray(a.value))
374
+ break;
375
+ a = void 0;
376
+ break;
377
+ }
378
+ }
379
+ if (!a)
380
+ return ft(`Active uniform ${n.name} has not been supplied`);
381
+ if (a && a.value === void 0)
382
+ return ft(`${n.name} uniform is missing a value parameter`);
383
+ if (a.value.texture)
384
+ return e = e + 1, a.value.update(e), Z(this.gl, n.type, r, e);
385
+ if (a.value.length && a.value[0].texture) {
386
+ const l = [];
387
+ return a.value.forEach((h) => {
388
+ e = e + 1, h.update(e), l.push(e);
389
+ }), Z(this.gl, n.type, r, l);
390
+ }
391
+ Z(this.gl, n.type, r, a.value);
392
+ }), this.applyState(), t && this.gl.renderer.setFrontFace(this.frontFace === this.gl.CCW ? this.gl.CW : this.gl.CCW);
393
+ }
394
+ remove() {
395
+ this.gl.deleteProgram(this.program);
396
+ }
397
+ }
398
+ function Z(i, t, e, s) {
399
+ s = s.length ? ee(s) : s;
400
+ const r = i.renderer.state.uniformLocations.get(e);
401
+ if (s.length)
402
+ if (r === void 0 || r.length !== s.length)
403
+ i.renderer.state.uniformLocations.set(e, s.slice(0));
404
+ else {
405
+ if (ie(r, s)) return;
406
+ r.set ? r.set(s) : se(r, s), i.renderer.state.uniformLocations.set(e, r);
407
+ }
408
+ else {
409
+ if (r === s) return;
410
+ i.renderer.state.uniformLocations.set(e, s);
411
+ }
412
+ switch (t) {
413
+ case 5126:
414
+ return s.length ? i.uniform1fv(e, s) : i.uniform1f(e, s);
415
+ // FLOAT
416
+ case 35664:
417
+ return i.uniform2fv(e, s);
418
+ // FLOAT_VEC2
419
+ case 35665:
420
+ return i.uniform3fv(e, s);
421
+ // FLOAT_VEC3
422
+ case 35666:
423
+ return i.uniform4fv(e, s);
424
+ // FLOAT_VEC4
425
+ case 35670:
426
+ // BOOL
427
+ case 5124:
428
+ // INT
429
+ case 35678:
430
+ // SAMPLER_2D
431
+ case 36306:
432
+ // U_SAMPLER_2D
433
+ case 35680:
434
+ // SAMPLER_CUBE
435
+ case 36289:
436
+ return s.length ? i.uniform1iv(e, s) : i.uniform1i(e, s);
437
+ // SAMPLER_CUBE
438
+ case 35671:
439
+ // BOOL_VEC2
440
+ case 35667:
441
+ return i.uniform2iv(e, s);
442
+ // INT_VEC2
443
+ case 35672:
444
+ // BOOL_VEC3
445
+ case 35668:
446
+ return i.uniform3iv(e, s);
447
+ // INT_VEC3
448
+ case 35673:
449
+ // BOOL_VEC4
450
+ case 35669:
451
+ return i.uniform4iv(e, s);
452
+ // INT_VEC4
453
+ case 35674:
454
+ return i.uniformMatrix2fv(e, !1, s);
455
+ // FLOAT_MAT2
456
+ case 35675:
457
+ return i.uniformMatrix3fv(e, !1, s);
458
+ // FLOAT_MAT3
459
+ case 35676:
460
+ return i.uniformMatrix4fv(e, !1, s);
461
+ }
462
+ }
463
+ function ut(i) {
464
+ let t = i.split(`
465
+ `);
466
+ for (let e = 0; e < t.length; e++)
467
+ t[e] = e + 1 + ": " + t[e];
468
+ return t.join(`
469
+ `);
470
+ }
471
+ function ee(i) {
472
+ const t = i.length, e = i[0].length;
473
+ if (e === void 0) return i;
474
+ const s = t * e;
475
+ let r = ct[s];
476
+ r || (ct[s] = r = new Float32Array(s));
477
+ for (let n = 0; n < t; n++) r.set(i[n], n * e);
478
+ return r;
479
+ }
480
+ function ie(i, t) {
481
+ if (i.length !== t.length) return !1;
482
+ for (let e = 0, s = i.length; e < s; e++)
483
+ if (i[e] !== t[e]) return !1;
484
+ return !0;
485
+ }
486
+ function se(i, t) {
487
+ for (let e = 0, s = i.length; e < s; e++)
488
+ i[e] = t[e];
489
+ }
490
+ let H = 0;
491
+ function ft(i) {
492
+ H > 100 || (console.warn(i), H++, H > 100 && console.warn("More than 100 program warnings - stopping logs."));
493
+ }
494
+ const Q = /* @__PURE__ */ new k();
495
+ let re = 1;
496
+ class ne {
497
+ constructor({
498
+ canvas: t = document.createElement("canvas"),
499
+ width: e = 300,
500
+ height: s = 150,
501
+ dpr: r = 1,
502
+ alpha: n = !1,
503
+ depth: a = !0,
504
+ stencil: l = !1,
505
+ antialias: h = !1,
506
+ premultipliedAlpha: o = !1,
507
+ preserveDrawingBuffer: c = !1,
508
+ powerPreference: u = "default",
509
+ autoClear: f = !0,
510
+ webgl: d = 2
511
+ } = {}) {
512
+ const g = { alpha: n, depth: a, stencil: l, antialias: h, premultipliedAlpha: o, preserveDrawingBuffer: c, powerPreference: u };
513
+ this.dpr = r, this.alpha = n, this.color = !0, this.depth = a, this.stencil = l, this.premultipliedAlpha = o, this.autoClear = f, this.id = re++, d === 2 && (this.gl = t.getContext("webgl2", g)), this.isWebgl2 = !!this.gl, this.gl || (this.gl = t.getContext("webgl", g)), this.gl || console.error("unable to create webgl context"), this.gl.renderer = this, this.setSize(e, s), this.state = {}, this.state.blendFunc = { src: this.gl.ONE, dst: this.gl.ZERO }, this.state.blendEquation = { modeRGB: this.gl.FUNC_ADD }, this.state.cullFace = !1, this.state.frontFace = this.gl.CCW, this.state.depthMask = !0, this.state.depthFunc = this.gl.LEQUAL, this.state.premultiplyAlpha = !1, this.state.flipY = !1, this.state.unpackAlignment = 4, this.state.framebuffer = null, this.state.viewport = { x: 0, y: 0, width: null, height: null }, this.state.textureUnits = [], this.state.activeTextureUnit = 0, this.state.boundBuffer = null, this.state.uniformLocations = /* @__PURE__ */ new Map(), this.state.currentProgram = null, this.extensions = {}, this.isWebgl2 ? (this.getExtension("EXT_color_buffer_float"), this.getExtension("OES_texture_float_linear")) : (this.getExtension("OES_texture_float"), this.getExtension("OES_texture_float_linear"), this.getExtension("OES_texture_half_float"), this.getExtension("OES_texture_half_float_linear"), this.getExtension("OES_element_index_uint"), this.getExtension("OES_standard_derivatives"), this.getExtension("EXT_sRGB"), this.getExtension("WEBGL_depth_texture"), this.getExtension("WEBGL_draw_buffers")), this.getExtension("WEBGL_compressed_texture_astc"), this.getExtension("EXT_texture_compression_bptc"), this.getExtension("WEBGL_compressed_texture_s3tc"), this.getExtension("WEBGL_compressed_texture_etc1"), this.getExtension("WEBGL_compressed_texture_pvrtc"), this.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"), this.vertexAttribDivisor = this.getExtension("ANGLE_instanced_arrays", "vertexAttribDivisor", "vertexAttribDivisorANGLE"), this.drawArraysInstanced = this.getExtension("ANGLE_instanced_arrays", "drawArraysInstanced", "drawArraysInstancedANGLE"), this.drawElementsInstanced = this.getExtension("ANGLE_instanced_arrays", "drawElementsInstanced", "drawElementsInstancedANGLE"), this.createVertexArray = this.getExtension("OES_vertex_array_object", "createVertexArray", "createVertexArrayOES"), this.bindVertexArray = this.getExtension("OES_vertex_array_object", "bindVertexArray", "bindVertexArrayOES"), this.deleteVertexArray = this.getExtension("OES_vertex_array_object", "deleteVertexArray", "deleteVertexArrayOES"), this.drawBuffers = this.getExtension("WEBGL_draw_buffers", "drawBuffers", "drawBuffersWEBGL"), this.parameters = {}, this.parameters.maxTextureUnits = this.gl.getParameter(this.gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS), this.parameters.maxAnisotropy = this.getExtension("EXT_texture_filter_anisotropic") ? this.gl.getParameter(this.getExtension("EXT_texture_filter_anisotropic").MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
514
+ }
515
+ setSize(t, e) {
516
+ this.width = t, this.height = e, this.gl.canvas.width = t * this.dpr, this.gl.canvas.height = e * this.dpr, this.gl.canvas.style && Object.assign(this.gl.canvas.style, {
517
+ width: t + "px",
518
+ height: e + "px"
519
+ });
520
+ }
521
+ setViewport(t, e, s = 0, r = 0) {
522
+ this.state.viewport.width === t && this.state.viewport.height === e || (this.state.viewport.width = t, this.state.viewport.height = e, this.state.viewport.x = s, this.state.viewport.y = r, this.gl.viewport(s, r, t, e));
523
+ }
524
+ setScissor(t, e, s = 0, r = 0) {
525
+ this.gl.scissor(s, r, t, e);
526
+ }
527
+ enable(t) {
528
+ this.state[t] !== !0 && (this.gl.enable(t), this.state[t] = !0);
529
+ }
530
+ disable(t) {
531
+ this.state[t] !== !1 && (this.gl.disable(t), this.state[t] = !1);
532
+ }
533
+ setBlendFunc(t, e, s, r) {
534
+ this.state.blendFunc.src === t && this.state.blendFunc.dst === e && this.state.blendFunc.srcAlpha === s && this.state.blendFunc.dstAlpha === r || (this.state.blendFunc.src = t, this.state.blendFunc.dst = e, this.state.blendFunc.srcAlpha = s, this.state.blendFunc.dstAlpha = r, s !== void 0 ? this.gl.blendFuncSeparate(t, e, s, r) : this.gl.blendFunc(t, e));
535
+ }
536
+ setBlendEquation(t, e) {
537
+ t = t || this.gl.FUNC_ADD, !(this.state.blendEquation.modeRGB === t && this.state.blendEquation.modeAlpha === e) && (this.state.blendEquation.modeRGB = t, this.state.blendEquation.modeAlpha = e, e !== void 0 ? this.gl.blendEquationSeparate(t, e) : this.gl.blendEquation(t));
538
+ }
539
+ setCullFace(t) {
540
+ this.state.cullFace !== t && (this.state.cullFace = t, this.gl.cullFace(t));
541
+ }
542
+ setFrontFace(t) {
543
+ this.state.frontFace !== t && (this.state.frontFace = t, this.gl.frontFace(t));
544
+ }
545
+ setDepthMask(t) {
546
+ this.state.depthMask !== t && (this.state.depthMask = t, this.gl.depthMask(t));
547
+ }
548
+ setDepthFunc(t) {
549
+ this.state.depthFunc !== t && (this.state.depthFunc = t, this.gl.depthFunc(t));
550
+ }
551
+ setStencilMask(t) {
552
+ this.state.stencilMask !== t && (this.state.stencilMask = t, this.gl.stencilMask(t));
553
+ }
554
+ setStencilFunc(t, e, s) {
555
+ this.state.stencilFunc === t && this.state.stencilRef === e && this.state.stencilFuncMask === s || (this.state.stencilFunc = t || this.gl.ALWAYS, this.state.stencilRef = e || 0, this.state.stencilFuncMask = s || 0, this.gl.stencilFunc(t || this.gl.ALWAYS, e || 0, s || 0));
556
+ }
557
+ setStencilOp(t, e, s) {
558
+ this.state.stencilFail === t && this.state.stencilDepthFail === e && this.state.stencilDepthPass === s || (this.state.stencilFail = t, this.state.stencilDepthFail = e, this.state.stencilDepthPass = s, this.gl.stencilOp(t, e, s));
559
+ }
560
+ activeTexture(t) {
561
+ this.state.activeTextureUnit !== t && (this.state.activeTextureUnit = t, this.gl.activeTexture(this.gl.TEXTURE0 + t));
562
+ }
563
+ bindFramebuffer({ target: t = this.gl.FRAMEBUFFER, buffer: e = null } = {}) {
564
+ this.state.framebuffer !== e && (this.state.framebuffer = e, this.gl.bindFramebuffer(t, e));
565
+ }
566
+ getExtension(t, e, s) {
567
+ return e && this.gl[e] ? this.gl[e].bind(this.gl) : (this.extensions[t] || (this.extensions[t] = this.gl.getExtension(t)), e ? this.extensions[t] ? this.extensions[t][s].bind(this.extensions[t]) : null : this.extensions[t]);
568
+ }
569
+ sortOpaque(t, e) {
570
+ return t.renderOrder !== e.renderOrder ? t.renderOrder - e.renderOrder : t.program.id !== e.program.id ? t.program.id - e.program.id : t.zDepth !== e.zDepth ? t.zDepth - e.zDepth : e.id - t.id;
571
+ }
572
+ sortTransparent(t, e) {
573
+ return t.renderOrder !== e.renderOrder ? t.renderOrder - e.renderOrder : t.zDepth !== e.zDepth ? e.zDepth - t.zDepth : e.id - t.id;
574
+ }
575
+ sortUI(t, e) {
576
+ return t.renderOrder !== e.renderOrder ? t.renderOrder - e.renderOrder : t.program.id !== e.program.id ? t.program.id - e.program.id : e.id - t.id;
577
+ }
578
+ getRenderList({ scene: t, camera: e, frustumCull: s, sort: r }) {
579
+ let n = [];
580
+ if (e && s && e.updateFrustum(), t.traverse((a) => {
581
+ if (!a.visible) return !0;
582
+ a.draw && (s && a.frustumCulled && e && !e.frustumIntersectsMesh(a) || n.push(a));
583
+ }), r) {
584
+ const a = [], l = [], h = [];
585
+ n.forEach((o) => {
586
+ o.program.transparent ? o.program.depthTest ? l.push(o) : h.push(o) : a.push(o), o.zDepth = 0, !(o.renderOrder !== 0 || !o.program.depthTest || !e) && (o.worldMatrix.getTranslation(Q), Q.applyMatrix4(e.projectionViewMatrix), o.zDepth = Q.z);
587
+ }), a.sort(this.sortOpaque), l.sort(this.sortTransparent), h.sort(this.sortUI), n = a.concat(l, h);
588
+ }
589
+ return n;
590
+ }
591
+ render({ scene: t, camera: e, target: s = null, update: r = !0, sort: n = !0, frustumCull: a = !0, clear: l }) {
592
+ s === null ? (this.bindFramebuffer(), this.setViewport(this.width * this.dpr, this.height * this.dpr)) : (this.bindFramebuffer(s), this.setViewport(s.width, s.height)), (l || this.autoClear && l !== !1) && (this.depth && (!s || s.depth) && (this.enable(this.gl.DEPTH_TEST), this.setDepthMask(!0)), (this.stencil || !s || s.stencil) && (this.enable(this.gl.STENCIL_TEST), this.setStencilMask(255)), this.gl.clear(
593
+ (this.color ? this.gl.COLOR_BUFFER_BIT : 0) | (this.depth ? this.gl.DEPTH_BUFFER_BIT : 0) | (this.stencil ? this.gl.STENCIL_BUFFER_BIT : 0)
594
+ )), r && t.updateMatrixWorld(), e && e.updateMatrixWorld(), this.getRenderList({ scene: t, camera: e, frustumCull: a, sort: n }).forEach((o) => {
595
+ o.draw({ camera: e });
596
+ });
597
+ }
598
+ }
599
+ function ae(i, t) {
600
+ return i[0] = t[0], i[1] = t[1], i[2] = t[2], i[3] = t[3], i;
601
+ }
602
+ function le(i, t, e, s, r) {
603
+ return i[0] = t, i[1] = e, i[2] = s, i[3] = r, i;
604
+ }
605
+ function he(i, t) {
606
+ let e = t[0], s = t[1], r = t[2], n = t[3], a = e * e + s * s + r * r + n * n;
607
+ return a > 0 && (a = 1 / Math.sqrt(a)), i[0] = e * a, i[1] = s * a, i[2] = r * a, i[3] = n * a, i;
608
+ }
609
+ function oe(i, t) {
610
+ return i[0] * t[0] + i[1] * t[1] + i[2] * t[2] + i[3] * t[3];
611
+ }
612
+ function ce(i) {
613
+ return i[0] = 0, i[1] = 0, i[2] = 0, i[3] = 1, i;
614
+ }
615
+ function ue(i, t, e) {
616
+ e = e * 0.5;
617
+ let s = Math.sin(e);
618
+ return i[0] = s * t[0], i[1] = s * t[1], i[2] = s * t[2], i[3] = Math.cos(e), i;
619
+ }
620
+ function dt(i, t, e) {
621
+ let s = t[0], r = t[1], n = t[2], a = t[3], l = e[0], h = e[1], o = e[2], c = e[3];
622
+ return i[0] = s * c + a * l + r * o - n * h, i[1] = r * c + a * h + n * l - s * o, i[2] = n * c + a * o + s * h - r * l, i[3] = a * c - s * l - r * h - n * o, i;
623
+ }
624
+ function fe(i, t, e) {
625
+ e *= 0.5;
626
+ let s = t[0], r = t[1], n = t[2], a = t[3], l = Math.sin(e), h = Math.cos(e);
627
+ return i[0] = s * h + a * l, i[1] = r * h + n * l, i[2] = n * h - r * l, i[3] = a * h - s * l, i;
628
+ }
629
+ function de(i, t, e) {
630
+ e *= 0.5;
631
+ let s = t[0], r = t[1], n = t[2], a = t[3], l = Math.sin(e), h = Math.cos(e);
632
+ return i[0] = s * h - n * l, i[1] = r * h + a * l, i[2] = n * h + s * l, i[3] = a * h - r * l, i;
633
+ }
634
+ function ge(i, t, e) {
635
+ e *= 0.5;
636
+ let s = t[0], r = t[1], n = t[2], a = t[3], l = Math.sin(e), h = Math.cos(e);
637
+ return i[0] = s * h + r * l, i[1] = r * h - s * l, i[2] = n * h + a * l, i[3] = a * h - n * l, i;
638
+ }
639
+ function pe(i, t, e, s) {
640
+ let r = t[0], n = t[1], a = t[2], l = t[3], h = e[0], o = e[1], c = e[2], u = e[3], f, d, g, p, m;
641
+ return d = r * h + n * o + a * c + l * u, d < 0 && (d = -d, h = -h, o = -o, c = -c, u = -u), 1 - d > 1e-6 ? (f = Math.acos(d), g = Math.sin(f), p = Math.sin((1 - s) * f) / g, m = Math.sin(s * f) / g) : (p = 1 - s, m = s), i[0] = p * r + m * h, i[1] = p * n + m * o, i[2] = p * a + m * c, i[3] = p * l + m * u, i;
642
+ }
643
+ function me(i, t) {
644
+ let e = t[0], s = t[1], r = t[2], n = t[3], a = e * e + s * s + r * r + n * n, l = a ? 1 / a : 0;
645
+ return i[0] = -e * l, i[1] = -s * l, i[2] = -r * l, i[3] = n * l, i;
646
+ }
647
+ function ve(i, t) {
648
+ return i[0] = -t[0], i[1] = -t[1], i[2] = -t[2], i[3] = t[3], i;
649
+ }
650
+ function xe(i, t) {
651
+ let e = t[0] + t[4] + t[8], s;
652
+ if (e > 0)
653
+ s = Math.sqrt(e + 1), i[3] = 0.5 * s, s = 0.5 / s, i[0] = (t[5] - t[7]) * s, i[1] = (t[6] - t[2]) * s, i[2] = (t[1] - t[3]) * s;
654
+ else {
655
+ let r = 0;
656
+ t[4] > t[0] && (r = 1), t[8] > t[r * 3 + r] && (r = 2);
657
+ let n = (r + 1) % 3, a = (r + 2) % 3;
658
+ s = Math.sqrt(t[r * 3 + r] - t[n * 3 + n] - t[a * 3 + a] + 1), i[r] = 0.5 * s, s = 0.5 / s, i[3] = (t[n * 3 + a] - t[a * 3 + n]) * s, i[n] = (t[n * 3 + r] + t[r * 3 + n]) * s, i[a] = (t[a * 3 + r] + t[r * 3 + a]) * s;
659
+ }
660
+ return i;
661
+ }
662
+ function ye(i, t, e = "YXZ") {
663
+ let s = Math.sin(t[0] * 0.5), r = Math.cos(t[0] * 0.5), n = Math.sin(t[1] * 0.5), a = Math.cos(t[1] * 0.5), l = Math.sin(t[2] * 0.5), h = Math.cos(t[2] * 0.5);
664
+ return e === "XYZ" ? (i[0] = s * a * h + r * n * l, i[1] = r * n * h - s * a * l, i[2] = r * a * l + s * n * h, i[3] = r * a * h - s * n * l) : e === "YXZ" ? (i[0] = s * a * h + r * n * l, i[1] = r * n * h - s * a * l, i[2] = r * a * l - s * n * h, i[3] = r * a * h + s * n * l) : e === "ZXY" ? (i[0] = s * a * h - r * n * l, i[1] = r * n * h + s * a * l, i[2] = r * a * l + s * n * h, i[3] = r * a * h - s * n * l) : e === "ZYX" ? (i[0] = s * a * h - r * n * l, i[1] = r * n * h + s * a * l, i[2] = r * a * l - s * n * h, i[3] = r * a * h + s * n * l) : e === "YZX" ? (i[0] = s * a * h + r * n * l, i[1] = r * n * h + s * a * l, i[2] = r * a * l - s * n * h, i[3] = r * a * h - s * n * l) : e === "XZY" && (i[0] = s * a * h - r * n * l, i[1] = r * n * h - s * a * l, i[2] = r * a * l + s * n * h, i[3] = r * a * h + s * n * l), i;
665
+ }
666
+ const be = ae, we = le, Me = oe, Ce = he;
667
+ class Se extends Array {
668
+ constructor(t = 0, e = 0, s = 0, r = 1) {
669
+ super(t, e, s, r), this.onChange = () => {
670
+ }, this._target = this;
671
+ const n = ["0", "1", "2", "3"];
672
+ return new Proxy(this, {
673
+ set(a, l) {
674
+ const h = Reflect.set(...arguments);
675
+ return h && n.includes(l) && a.onChange(), h;
676
+ }
677
+ });
678
+ }
679
+ get x() {
680
+ return this[0];
681
+ }
682
+ get y() {
683
+ return this[1];
684
+ }
685
+ get z() {
686
+ return this[2];
687
+ }
688
+ get w() {
689
+ return this[3];
690
+ }
691
+ set x(t) {
692
+ this._target[0] = t, this.onChange();
693
+ }
694
+ set y(t) {
695
+ this._target[1] = t, this.onChange();
696
+ }
697
+ set z(t) {
698
+ this._target[2] = t, this.onChange();
699
+ }
700
+ set w(t) {
701
+ this._target[3] = t, this.onChange();
702
+ }
703
+ identity() {
704
+ return ce(this._target), this.onChange(), this;
705
+ }
706
+ set(t, e, s, r) {
707
+ return t.length ? this.copy(t) : (we(this._target, t, e, s, r), this.onChange(), this);
708
+ }
709
+ rotateX(t) {
710
+ return fe(this._target, this._target, t), this.onChange(), this;
711
+ }
712
+ rotateY(t) {
713
+ return de(this._target, this._target, t), this.onChange(), this;
714
+ }
715
+ rotateZ(t) {
716
+ return ge(this._target, this._target, t), this.onChange(), this;
717
+ }
718
+ inverse(t = this._target) {
719
+ return me(this._target, t), this.onChange(), this;
720
+ }
721
+ conjugate(t = this._target) {
722
+ return ve(this._target, t), this.onChange(), this;
723
+ }
724
+ copy(t) {
725
+ return be(this._target, t), this.onChange(), this;
726
+ }
727
+ normalize(t = this._target) {
728
+ return Ce(this._target, t), this.onChange(), this;
729
+ }
730
+ multiply(t, e) {
731
+ return e ? dt(this._target, t, e) : dt(this._target, this._target, t), this.onChange(), this;
732
+ }
733
+ dot(t) {
734
+ return Me(this._target, t);
735
+ }
736
+ fromMatrix3(t) {
737
+ return xe(this._target, t), this.onChange(), this;
738
+ }
739
+ fromEuler(t, e) {
740
+ return ye(this._target, t, t.order), e || this.onChange(), this;
741
+ }
742
+ fromAxisAngle(t, e) {
743
+ return ue(this._target, t, e), this.onChange(), this;
744
+ }
745
+ slerp(t, e) {
746
+ return pe(this._target, this._target, t, e), this.onChange(), this;
747
+ }
748
+ fromArray(t, e = 0) {
749
+ return this._target[0] = t[e], this._target[1] = t[e + 1], this._target[2] = t[e + 2], this._target[3] = t[e + 3], this.onChange(), this;
750
+ }
751
+ toArray(t = [], e = 0) {
752
+ return t[e] = this[0], t[e + 1] = this[1], t[e + 2] = this[2], t[e + 3] = this[3], t;
753
+ }
754
+ }
755
+ const Ae = 1e-6;
756
+ function _e(i, t) {
757
+ return i[0] = t[0], i[1] = t[1], i[2] = t[2], i[3] = t[3], i[4] = t[4], i[5] = t[5], i[6] = t[6], i[7] = t[7], i[8] = t[8], i[9] = t[9], i[10] = t[10], i[11] = t[11], i[12] = t[12], i[13] = t[13], i[14] = t[14], i[15] = t[15], i;
758
+ }
759
+ function Ee(i, t, e, s, r, n, a, l, h, o, c, u, f, d, g, p, m) {
760
+ return i[0] = t, i[1] = e, i[2] = s, i[3] = r, i[4] = n, i[5] = a, i[6] = l, i[7] = h, i[8] = o, i[9] = c, i[10] = u, i[11] = f, i[12] = d, i[13] = g, i[14] = p, i[15] = m, i;
761
+ }
762
+ function Re(i) {
763
+ return i[0] = 1, i[1] = 0, i[2] = 0, i[3] = 0, i[4] = 0, i[5] = 1, i[6] = 0, i[7] = 0, i[8] = 0, i[9] = 0, i[10] = 1, i[11] = 0, i[12] = 0, i[13] = 0, i[14] = 0, i[15] = 1, i;
764
+ }
765
+ function ze(i, t) {
766
+ let e = t[0], s = t[1], r = t[2], n = t[3], a = t[4], l = t[5], h = t[6], o = t[7], c = t[8], u = t[9], f = t[10], d = t[11], g = t[12], p = t[13], m = t[14], v = t[15], A = e * l - s * a, y = e * h - r * a, x = e * o - n * a, w = s * h - r * l, b = s * o - n * l, E = r * o - n * h, T = c * p - u * g, F = c * m - f * g, R = c * v - d * g, I = u * m - f * p, z = u * v - d * p, B = f * v - d * m, M = A * B - y * z + x * I + w * R - b * F + E * T;
767
+ return M ? (M = 1 / M, i[0] = (l * B - h * z + o * I) * M, i[1] = (r * z - s * B - n * I) * M, i[2] = (p * E - m * b + v * w) * M, i[3] = (f * b - u * E - d * w) * M, i[4] = (h * R - a * B - o * F) * M, i[5] = (e * B - r * R + n * F) * M, i[6] = (m * x - g * E - v * y) * M, i[7] = (c * E - f * x + d * y) * M, i[8] = (a * z - l * R + o * T) * M, i[9] = (s * R - e * z - n * T) * M, i[10] = (g * b - p * x + v * A) * M, i[11] = (u * x - c * b - d * A) * M, i[12] = (l * F - a * I - h * T) * M, i[13] = (e * I - s * F + r * T) * M, i[14] = (p * y - g * w - m * A) * M, i[15] = (c * w - u * y + f * A) * M, i) : null;
768
+ }
769
+ function zt(i) {
770
+ let t = i[0], e = i[1], s = i[2], r = i[3], n = i[4], a = i[5], l = i[6], h = i[7], o = i[8], c = i[9], u = i[10], f = i[11], d = i[12], g = i[13], p = i[14], m = i[15], v = t * a - e * n, A = t * l - s * n, y = t * h - r * n, x = e * l - s * a, w = e * h - r * a, b = s * h - r * l, E = o * g - c * d, T = o * p - u * d, F = o * m - f * d, R = c * p - u * g, I = c * m - f * g, z = u * m - f * p;
771
+ return v * z - A * I + y * R + x * F - w * T + b * E;
772
+ }
773
+ function gt(i, t, e) {
774
+ let s = t[0], r = t[1], n = t[2], a = t[3], l = t[4], h = t[5], o = t[6], c = t[7], u = t[8], f = t[9], d = t[10], g = t[11], p = t[12], m = t[13], v = t[14], A = t[15], y = e[0], x = e[1], w = e[2], b = e[3];
775
+ return i[0] = y * s + x * l + w * u + b * p, i[1] = y * r + x * h + w * f + b * m, i[2] = y * n + x * o + w * d + b * v, i[3] = y * a + x * c + w * g + b * A, y = e[4], x = e[5], w = e[6], b = e[7], i[4] = y * s + x * l + w * u + b * p, i[5] = y * r + x * h + w * f + b * m, i[6] = y * n + x * o + w * d + b * v, i[7] = y * a + x * c + w * g + b * A, y = e[8], x = e[9], w = e[10], b = e[11], i[8] = y * s + x * l + w * u + b * p, i[9] = y * r + x * h + w * f + b * m, i[10] = y * n + x * o + w * d + b * v, i[11] = y * a + x * c + w * g + b * A, y = e[12], x = e[13], w = e[14], b = e[15], i[12] = y * s + x * l + w * u + b * p, i[13] = y * r + x * h + w * f + b * m, i[14] = y * n + x * o + w * d + b * v, i[15] = y * a + x * c + w * g + b * A, i;
776
+ }
777
+ function Te(i, t, e) {
778
+ let s = e[0], r = e[1], n = e[2], a, l, h, o, c, u, f, d, g, p, m, v;
779
+ return t === i ? (i[12] = t[0] * s + t[4] * r + t[8] * n + t[12], i[13] = t[1] * s + t[5] * r + t[9] * n + t[13], i[14] = t[2] * s + t[6] * r + t[10] * n + t[14], i[15] = t[3] * s + t[7] * r + t[11] * n + t[15]) : (a = t[0], l = t[1], h = t[2], o = t[3], c = t[4], u = t[5], f = t[6], d = t[7], g = t[8], p = t[9], m = t[10], v = t[11], i[0] = a, i[1] = l, i[2] = h, i[3] = o, i[4] = c, i[5] = u, i[6] = f, i[7] = d, i[8] = g, i[9] = p, i[10] = m, i[11] = v, i[12] = a * s + c * r + g * n + t[12], i[13] = l * s + u * r + p * n + t[13], i[14] = h * s + f * r + m * n + t[14], i[15] = o * s + d * r + v * n + t[15]), i;
780
+ }
781
+ function Fe(i, t, e) {
782
+ let s = e[0], r = e[1], n = e[2];
783
+ return i[0] = t[0] * s, i[1] = t[1] * s, i[2] = t[2] * s, i[3] = t[3] * s, i[4] = t[4] * r, i[5] = t[5] * r, i[6] = t[6] * r, i[7] = t[7] * r, i[8] = t[8] * n, i[9] = t[9] * n, i[10] = t[10] * n, i[11] = t[11] * n, i[12] = t[12], i[13] = t[13], i[14] = t[14], i[15] = t[15], i;
784
+ }
785
+ function Ie(i, t, e, s) {
786
+ let r = s[0], n = s[1], a = s[2], l = Math.hypot(r, n, a), h, o, c, u, f, d, g, p, m, v, A, y, x, w, b, E, T, F, R, I, z, B, M, X;
787
+ return Math.abs(l) < Ae ? null : (l = 1 / l, r *= l, n *= l, a *= l, h = Math.sin(e), o = Math.cos(e), c = 1 - o, u = t[0], f = t[1], d = t[2], g = t[3], p = t[4], m = t[5], v = t[6], A = t[7], y = t[8], x = t[9], w = t[10], b = t[11], E = r * r * c + o, T = n * r * c + a * h, F = a * r * c - n * h, R = r * n * c - a * h, I = n * n * c + o, z = a * n * c + r * h, B = r * a * c + n * h, M = n * a * c - r * h, X = a * a * c + o, i[0] = u * E + p * T + y * F, i[1] = f * E + m * T + x * F, i[2] = d * E + v * T + w * F, i[3] = g * E + A * T + b * F, i[4] = u * R + p * I + y * z, i[5] = f * R + m * I + x * z, i[6] = d * R + v * I + w * z, i[7] = g * R + A * I + b * z, i[8] = u * B + p * M + y * X, i[9] = f * B + m * M + x * X, i[10] = d * B + v * M + w * X, i[11] = g * B + A * M + b * X, t !== i && (i[12] = t[12], i[13] = t[13], i[14] = t[14], i[15] = t[15]), i);
788
+ }
789
+ function Be(i, t) {
790
+ return i[0] = t[12], i[1] = t[13], i[2] = t[14], i;
791
+ }
792
+ function Tt(i, t) {
793
+ let e = t[0], s = t[1], r = t[2], n = t[4], a = t[5], l = t[6], h = t[8], o = t[9], c = t[10];
794
+ return i[0] = Math.hypot(e, s, r), i[1] = Math.hypot(n, a, l), i[2] = Math.hypot(h, o, c), i;
795
+ }
796
+ function Le(i) {
797
+ let t = i[0], e = i[1], s = i[2], r = i[4], n = i[5], a = i[6], l = i[8], h = i[9], o = i[10];
798
+ const c = t * t + e * e + s * s, u = r * r + n * n + a * a, f = l * l + h * h + o * o;
799
+ return Math.sqrt(Math.max(c, u, f));
800
+ }
801
+ const Ft = /* @__PURE__ */ (function() {
802
+ const i = [1, 1, 1];
803
+ return function(t, e) {
804
+ let s = i;
805
+ Tt(s, e);
806
+ let r = 1 / s[0], n = 1 / s[1], a = 1 / s[2], l = e[0] * r, h = e[1] * n, o = e[2] * a, c = e[4] * r, u = e[5] * n, f = e[6] * a, d = e[8] * r, g = e[9] * n, p = e[10] * a, m = l + u + p, v = 0;
807
+ return m > 0 ? (v = Math.sqrt(m + 1) * 2, t[3] = 0.25 * v, t[0] = (f - g) / v, t[1] = (d - o) / v, t[2] = (h - c) / v) : l > u && l > p ? (v = Math.sqrt(1 + l - u - p) * 2, t[3] = (f - g) / v, t[0] = 0.25 * v, t[1] = (h + c) / v, t[2] = (d + o) / v) : u > p ? (v = Math.sqrt(1 + u - l - p) * 2, t[3] = (d - o) / v, t[0] = (h + c) / v, t[1] = 0.25 * v, t[2] = (f + g) / v) : (v = Math.sqrt(1 + p - l - u) * 2, t[3] = (h - c) / v, t[0] = (d + o) / v, t[1] = (f + g) / v, t[2] = 0.25 * v), t;
808
+ };
809
+ })();
810
+ function Oe(i, t, e, s) {
811
+ let r = q([i[0], i[1], i[2]]);
812
+ const n = q([i[4], i[5], i[6]]), a = q([i[8], i[9], i[10]]);
813
+ zt(i) < 0 && (r = -r), e[0] = i[12], e[1] = i[13], e[2] = i[14];
814
+ const h = i.slice(), o = 1 / r, c = 1 / n, u = 1 / a;
815
+ h[0] *= o, h[1] *= o, h[2] *= o, h[4] *= c, h[5] *= c, h[6] *= c, h[8] *= u, h[9] *= u, h[10] *= u, Ft(t, h), s[0] = r, s[1] = n, s[2] = a;
816
+ }
817
+ function ke(i, t, e, s) {
818
+ const r = i, n = t[0], a = t[1], l = t[2], h = t[3], o = n + n, c = a + a, u = l + l, f = n * o, d = n * c, g = n * u, p = a * c, m = a * u, v = l * u, A = h * o, y = h * c, x = h * u, w = s[0], b = s[1], E = s[2];
819
+ return r[0] = (1 - (p + v)) * w, r[1] = (d + x) * w, r[2] = (g - y) * w, r[3] = 0, r[4] = (d - x) * b, r[5] = (1 - (f + v)) * b, r[6] = (m + A) * b, r[7] = 0, r[8] = (g + y) * E, r[9] = (m - A) * E, r[10] = (1 - (f + p)) * E, r[11] = 0, r[12] = e[0], r[13] = e[1], r[14] = e[2], r[15] = 1, r;
820
+ }
821
+ function Ge(i, t) {
822
+ let e = t[0], s = t[1], r = t[2], n = t[3], a = e + e, l = s + s, h = r + r, o = e * a, c = s * a, u = s * l, f = r * a, d = r * l, g = r * h, p = n * a, m = n * l, v = n * h;
823
+ return i[0] = 1 - u - g, i[1] = c + v, i[2] = f - m, i[3] = 0, i[4] = c - v, i[5] = 1 - o - g, i[6] = d + p, i[7] = 0, i[8] = f + m, i[9] = d - p, i[10] = 1 - o - u, i[11] = 0, i[12] = 0, i[13] = 0, i[14] = 0, i[15] = 1, i;
824
+ }
825
+ function De(i, t, e, s, r) {
826
+ let n = 1 / Math.tan(t / 2), a = 1 / (s - r);
827
+ return i[0] = n / e, i[1] = 0, i[2] = 0, i[3] = 0, i[4] = 0, i[5] = n, i[6] = 0, i[7] = 0, i[8] = 0, i[9] = 0, i[10] = (r + s) * a, i[11] = -1, i[12] = 0, i[13] = 0, i[14] = 2 * r * s * a, i[15] = 0, i;
828
+ }
829
+ function Xe(i, t, e, s, r, n, a) {
830
+ let l = 1 / (t - e), h = 1 / (s - r), o = 1 / (n - a);
831
+ return i[0] = -2 * l, i[1] = 0, i[2] = 0, i[3] = 0, i[4] = 0, i[5] = -2 * h, i[6] = 0, i[7] = 0, i[8] = 0, i[9] = 0, i[10] = 2 * o, i[11] = 0, i[12] = (t + e) * l, i[13] = (r + s) * h, i[14] = (a + n) * o, i[15] = 1, i;
832
+ }
833
+ function Pe(i, t, e, s) {
834
+ let r = t[0], n = t[1], a = t[2], l = s[0], h = s[1], o = s[2], c = r - e[0], u = n - e[1], f = a - e[2], d = c * c + u * u + f * f;
835
+ d === 0 ? f = 1 : (d = 1 / Math.sqrt(d), c *= d, u *= d, f *= d);
836
+ let g = h * f - o * u, p = o * c - l * f, m = l * u - h * c;
837
+ return d = g * g + p * p + m * m, d === 0 && (o ? l += 1e-6 : h ? o += 1e-6 : h += 1e-6, g = h * f - o * u, p = o * c - l * f, m = l * u - h * c, d = g * g + p * p + m * m), d = 1 / Math.sqrt(d), g *= d, p *= d, m *= d, i[0] = g, i[1] = p, i[2] = m, i[3] = 0, i[4] = u * m - f * p, i[5] = f * g - c * m, i[6] = c * p - u * g, i[7] = 0, i[8] = c, i[9] = u, i[10] = f, i[11] = 0, i[12] = r, i[13] = n, i[14] = a, i[15] = 1, i;
838
+ }
839
+ function pt(i, t, e) {
840
+ return i[0] = t[0] + e[0], i[1] = t[1] + e[1], i[2] = t[2] + e[2], i[3] = t[3] + e[3], i[4] = t[4] + e[4], i[5] = t[5] + e[5], i[6] = t[6] + e[6], i[7] = t[7] + e[7], i[8] = t[8] + e[8], i[9] = t[9] + e[9], i[10] = t[10] + e[10], i[11] = t[11] + e[11], i[12] = t[12] + e[12], i[13] = t[13] + e[13], i[14] = t[14] + e[14], i[15] = t[15] + e[15], i;
841
+ }
842
+ function mt(i, t, e) {
843
+ return i[0] = t[0] - e[0], i[1] = t[1] - e[1], i[2] = t[2] - e[2], i[3] = t[3] - e[3], i[4] = t[4] - e[4], i[5] = t[5] - e[5], i[6] = t[6] - e[6], i[7] = t[7] - e[7], i[8] = t[8] - e[8], i[9] = t[9] - e[9], i[10] = t[10] - e[10], i[11] = t[11] - e[11], i[12] = t[12] - e[12], i[13] = t[13] - e[13], i[14] = t[14] - e[14], i[15] = t[15] - e[15], i;
844
+ }
845
+ function qe(i, t, e) {
846
+ return i[0] = t[0] * e, i[1] = t[1] * e, i[2] = t[2] * e, i[3] = t[3] * e, i[4] = t[4] * e, i[5] = t[5] * e, i[6] = t[6] * e, i[7] = t[7] * e, i[8] = t[8] * e, i[9] = t[9] * e, i[10] = t[10] * e, i[11] = t[11] * e, i[12] = t[12] * e, i[13] = t[13] * e, i[14] = t[14] * e, i[15] = t[15] * e, i;
847
+ }
848
+ class U extends Array {
849
+ constructor(t = 1, e = 0, s = 0, r = 0, n = 0, a = 1, l = 0, h = 0, o = 0, c = 0, u = 1, f = 0, d = 0, g = 0, p = 0, m = 1) {
850
+ return super(t, e, s, r, n, a, l, h, o, c, u, f, d, g, p, m), this;
851
+ }
852
+ get x() {
853
+ return this[12];
854
+ }
855
+ get y() {
856
+ return this[13];
857
+ }
858
+ get z() {
859
+ return this[14];
860
+ }
861
+ get w() {
862
+ return this[15];
863
+ }
864
+ set x(t) {
865
+ this[12] = t;
866
+ }
867
+ set y(t) {
868
+ this[13] = t;
869
+ }
870
+ set z(t) {
871
+ this[14] = t;
872
+ }
873
+ set w(t) {
874
+ this[15] = t;
875
+ }
876
+ set(t, e, s, r, n, a, l, h, o, c, u, f, d, g, p, m) {
877
+ return t.length ? this.copy(t) : (Ee(this, t, e, s, r, n, a, l, h, o, c, u, f, d, g, p, m), this);
878
+ }
879
+ translate(t, e = this) {
880
+ return Te(this, e, t), this;
881
+ }
882
+ rotate(t, e, s = this) {
883
+ return Ie(this, s, t, e), this;
884
+ }
885
+ scale(t, e = this) {
886
+ return Fe(this, e, typeof t == "number" ? [t, t, t] : t), this;
887
+ }
888
+ add(t, e) {
889
+ return e ? pt(this, t, e) : pt(this, this, t), this;
890
+ }
891
+ sub(t, e) {
892
+ return e ? mt(this, t, e) : mt(this, this, t), this;
893
+ }
894
+ multiply(t, e) {
895
+ return t.length ? e ? gt(this, t, e) : gt(this, this, t) : qe(this, this, t), this;
896
+ }
897
+ identity() {
898
+ return Re(this), this;
899
+ }
900
+ copy(t) {
901
+ return _e(this, t), this;
902
+ }
903
+ fromPerspective({ fov: t, aspect: e, near: s, far: r } = {}) {
904
+ return De(this, t, e, s, r), this;
905
+ }
906
+ fromOrthogonal({ left: t, right: e, bottom: s, top: r, near: n, far: a }) {
907
+ return Xe(this, t, e, s, r, n, a), this;
908
+ }
909
+ fromQuaternion(t) {
910
+ return Ge(this, t), this;
911
+ }
912
+ setPosition(t) {
913
+ return this.x = t[0], this.y = t[1], this.z = t[2], this;
914
+ }
915
+ inverse(t = this) {
916
+ return ze(this, t), this;
917
+ }
918
+ compose(t, e, s) {
919
+ return ke(this, t, e, s), this;
920
+ }
921
+ decompose(t, e, s) {
922
+ return Oe(this, t, e, s), this;
923
+ }
924
+ getRotation(t) {
925
+ return Ft(t, this), this;
926
+ }
927
+ getTranslation(t) {
928
+ return Be(t, this), this;
929
+ }
930
+ getScaling(t) {
931
+ return Tt(t, this), this;
932
+ }
933
+ getMaxScaleOnAxis() {
934
+ return Le(this);
935
+ }
936
+ lookAt(t, e, s) {
937
+ return Pe(this, t, e, s), this;
938
+ }
939
+ determinant() {
940
+ return zt(this);
941
+ }
942
+ fromArray(t, e = 0) {
943
+ return this[0] = t[e], this[1] = t[e + 1], this[2] = t[e + 2], this[3] = t[e + 3], this[4] = t[e + 4], this[5] = t[e + 5], this[6] = t[e + 6], this[7] = t[e + 7], this[8] = t[e + 8], this[9] = t[e + 9], this[10] = t[e + 10], this[11] = t[e + 11], this[12] = t[e + 12], this[13] = t[e + 13], this[14] = t[e + 14], this[15] = t[e + 15], this;
944
+ }
945
+ toArray(t = [], e = 0) {
946
+ return t[e] = this[0], t[e + 1] = this[1], t[e + 2] = this[2], t[e + 3] = this[3], t[e + 4] = this[4], t[e + 5] = this[5], t[e + 6] = this[6], t[e + 7] = this[7], t[e + 8] = this[8], t[e + 9] = this[9], t[e + 10] = this[10], t[e + 11] = this[11], t[e + 12] = this[12], t[e + 13] = this[13], t[e + 14] = this[14], t[e + 15] = this[15], t;
947
+ }
948
+ }
949
+ function Ne(i, t, e = "YXZ") {
950
+ return e === "XYZ" ? (i[1] = Math.asin(Math.min(Math.max(t[8], -1), 1)), Math.abs(t[8]) < 0.99999 ? (i[0] = Math.atan2(-t[9], t[10]), i[2] = Math.atan2(-t[4], t[0])) : (i[0] = Math.atan2(t[6], t[5]), i[2] = 0)) : e === "YXZ" ? (i[0] = Math.asin(-Math.min(Math.max(t[9], -1), 1)), Math.abs(t[9]) < 0.99999 ? (i[1] = Math.atan2(t[8], t[10]), i[2] = Math.atan2(t[1], t[5])) : (i[1] = Math.atan2(-t[2], t[0]), i[2] = 0)) : e === "ZXY" ? (i[0] = Math.asin(Math.min(Math.max(t[6], -1), 1)), Math.abs(t[6]) < 0.99999 ? (i[1] = Math.atan2(-t[2], t[10]), i[2] = Math.atan2(-t[4], t[5])) : (i[1] = 0, i[2] = Math.atan2(t[1], t[0]))) : e === "ZYX" ? (i[1] = Math.asin(-Math.min(Math.max(t[2], -1), 1)), Math.abs(t[2]) < 0.99999 ? (i[0] = Math.atan2(t[6], t[10]), i[2] = Math.atan2(t[1], t[0])) : (i[0] = 0, i[2] = Math.atan2(-t[4], t[5]))) : e === "YZX" ? (i[2] = Math.asin(Math.min(Math.max(t[1], -1), 1)), Math.abs(t[1]) < 0.99999 ? (i[0] = Math.atan2(-t[9], t[5]), i[1] = Math.atan2(-t[2], t[0])) : (i[0] = 0, i[1] = Math.atan2(t[8], t[10]))) : e === "XZY" && (i[2] = Math.asin(-Math.min(Math.max(t[4], -1), 1)), Math.abs(t[4]) < 0.99999 ? (i[0] = Math.atan2(t[6], t[5]), i[1] = Math.atan2(t[8], t[0])) : (i[0] = Math.atan2(-t[9], t[10]), i[1] = 0)), i;
951
+ }
952
+ const vt = /* @__PURE__ */ new U();
953
+ class $e extends Array {
954
+ constructor(t = 0, e = t, s = t, r = "YXZ") {
955
+ super(t, e, s), this.order = r, this.onChange = () => {
956
+ }, this._target = this;
957
+ const n = ["0", "1", "2"];
958
+ return new Proxy(this, {
959
+ set(a, l) {
960
+ const h = Reflect.set(...arguments);
961
+ return h && n.includes(l) && a.onChange(), h;
962
+ }
963
+ });
964
+ }
965
+ get x() {
966
+ return this[0];
967
+ }
968
+ get y() {
969
+ return this[1];
970
+ }
971
+ get z() {
972
+ return this[2];
973
+ }
974
+ set x(t) {
975
+ this._target[0] = t, this.onChange();
976
+ }
977
+ set y(t) {
978
+ this._target[1] = t, this.onChange();
979
+ }
980
+ set z(t) {
981
+ this._target[2] = t, this.onChange();
982
+ }
983
+ set(t, e = t, s = t) {
984
+ return t.length ? this.copy(t) : (this._target[0] = t, this._target[1] = e, this._target[2] = s, this.onChange(), this);
985
+ }
986
+ copy(t) {
987
+ return this._target[0] = t[0], this._target[1] = t[1], this._target[2] = t[2], this.onChange(), this;
988
+ }
989
+ reorder(t) {
990
+ return this._target.order = t, this.onChange(), this;
991
+ }
992
+ fromRotationMatrix(t, e = this.order) {
993
+ return Ne(this._target, t, e), this.onChange(), this;
994
+ }
995
+ fromQuaternion(t, e = this.order, s) {
996
+ return vt.fromQuaternion(t), this._target.fromRotationMatrix(vt, e), s || this.onChange(), this;
997
+ }
998
+ fromArray(t, e = 0) {
999
+ return this._target[0] = t[e], this._target[1] = t[e + 1], this._target[2] = t[e + 2], this;
1000
+ }
1001
+ toArray(t = [], e = 0) {
1002
+ return t[e] = this[0], t[e + 1] = this[1], t[e + 2] = this[2], t;
1003
+ }
1004
+ }
1005
+ class Ue {
1006
+ constructor() {
1007
+ this.parent = null, this.children = [], this.visible = !0, this.matrix = new U(), this.worldMatrix = new U(), this.matrixAutoUpdate = !0, this.worldMatrixNeedsUpdate = !1, this.position = new k(), this.quaternion = new Se(), this.scale = new k(1), this.rotation = new $e(), this.up = new k(0, 1, 0), this.rotation._target.onChange = () => this.quaternion.fromEuler(this.rotation, !0), this.quaternion._target.onChange = () => this.rotation.fromQuaternion(this.quaternion, void 0, !0);
1008
+ }
1009
+ setParent(t, e = !0) {
1010
+ this.parent && t !== this.parent && this.parent.removeChild(this, !1), this.parent = t, e && t && t.addChild(this, !1);
1011
+ }
1012
+ addChild(t, e = !0) {
1013
+ ~this.children.indexOf(t) || this.children.push(t), e && t.setParent(this, !1);
1014
+ }
1015
+ removeChild(t, e = !0) {
1016
+ ~this.children.indexOf(t) && this.children.splice(this.children.indexOf(t), 1), e && t.setParent(null, !1);
1017
+ }
1018
+ updateMatrixWorld(t) {
1019
+ this.matrixAutoUpdate && this.updateMatrix(), (this.worldMatrixNeedsUpdate || t) && (this.parent === null ? this.worldMatrix.copy(this.matrix) : this.worldMatrix.multiply(this.parent.worldMatrix, this.matrix), this.worldMatrixNeedsUpdate = !1, t = !0);
1020
+ for (let e = 0, s = this.children.length; e < s; e++)
1021
+ this.children[e].updateMatrixWorld(t);
1022
+ }
1023
+ updateMatrix() {
1024
+ this.matrix.compose(this.quaternion, this.position, this.scale), this.worldMatrixNeedsUpdate = !0;
1025
+ }
1026
+ traverse(t) {
1027
+ if (!t(this))
1028
+ for (let e = 0, s = this.children.length; e < s; e++)
1029
+ this.children[e].traverse(t);
1030
+ }
1031
+ decompose() {
1032
+ this.matrix.decompose(this.quaternion._target, this.position, this.scale), this.rotation.fromQuaternion(this.quaternion);
1033
+ }
1034
+ lookAt(t, e = !1) {
1035
+ e ? this.matrix.lookAt(this.position, t, this.up) : this.matrix.lookAt(t, this.position, this.up), this.matrix.getRotation(this.quaternion._target), this.rotation.fromQuaternion(this.quaternion);
1036
+ }
1037
+ }
1038
+ function Ye(i, t) {
1039
+ return i[0] = t[0], i[1] = t[1], i[2] = t[2], i[3] = t[4], i[4] = t[5], i[5] = t[6], i[6] = t[8], i[7] = t[9], i[8] = t[10], i;
1040
+ }
1041
+ function Ve(i, t) {
1042
+ let e = t[0], s = t[1], r = t[2], n = t[3], a = e + e, l = s + s, h = r + r, o = e * a, c = s * a, u = s * l, f = r * a, d = r * l, g = r * h, p = n * a, m = n * l, v = n * h;
1043
+ return i[0] = 1 - u - g, i[3] = c - v, i[6] = f + m, i[1] = c + v, i[4] = 1 - o - g, i[7] = d - p, i[2] = f - m, i[5] = d + p, i[8] = 1 - o - u, i;
1044
+ }
1045
+ function We(i, t) {
1046
+ return i[0] = t[0], i[1] = t[1], i[2] = t[2], i[3] = t[3], i[4] = t[4], i[5] = t[5], i[6] = t[6], i[7] = t[7], i[8] = t[8], i;
1047
+ }
1048
+ function je(i, t, e, s, r, n, a, l, h, o) {
1049
+ return i[0] = t, i[1] = e, i[2] = s, i[3] = r, i[4] = n, i[5] = a, i[6] = l, i[7] = h, i[8] = o, i;
1050
+ }
1051
+ function Ze(i) {
1052
+ return i[0] = 1, i[1] = 0, i[2] = 0, i[3] = 0, i[4] = 1, i[5] = 0, i[6] = 0, i[7] = 0, i[8] = 1, i;
1053
+ }
1054
+ function He(i, t) {
1055
+ let e = t[0], s = t[1], r = t[2], n = t[3], a = t[4], l = t[5], h = t[6], o = t[7], c = t[8], u = c * a - l * o, f = -c * n + l * h, d = o * n - a * h, g = e * u + s * f + r * d;
1056
+ return g ? (g = 1 / g, i[0] = u * g, i[1] = (-c * s + r * o) * g, i[2] = (l * s - r * a) * g, i[3] = f * g, i[4] = (c * e - r * h) * g, i[5] = (-l * e + r * n) * g, i[6] = d * g, i[7] = (-o * e + s * h) * g, i[8] = (a * e - s * n) * g, i) : null;
1057
+ }
1058
+ function xt(i, t, e) {
1059
+ let s = t[0], r = t[1], n = t[2], a = t[3], l = t[4], h = t[5], o = t[6], c = t[7], u = t[8], f = e[0], d = e[1], g = e[2], p = e[3], m = e[4], v = e[5], A = e[6], y = e[7], x = e[8];
1060
+ return i[0] = f * s + d * a + g * o, i[1] = f * r + d * l + g * c, i[2] = f * n + d * h + g * u, i[3] = p * s + m * a + v * o, i[4] = p * r + m * l + v * c, i[5] = p * n + m * h + v * u, i[6] = A * s + y * a + x * o, i[7] = A * r + y * l + x * c, i[8] = A * n + y * h + x * u, i;
1061
+ }
1062
+ function Qe(i, t, e) {
1063
+ let s = t[0], r = t[1], n = t[2], a = t[3], l = t[4], h = t[5], o = t[6], c = t[7], u = t[8], f = e[0], d = e[1];
1064
+ return i[0] = s, i[1] = r, i[2] = n, i[3] = a, i[4] = l, i[5] = h, i[6] = f * s + d * a + o, i[7] = f * r + d * l + c, i[8] = f * n + d * h + u, i;
1065
+ }
1066
+ function Je(i, t, e) {
1067
+ let s = t[0], r = t[1], n = t[2], a = t[3], l = t[4], h = t[5], o = t[6], c = t[7], u = t[8], f = Math.sin(e), d = Math.cos(e);
1068
+ return i[0] = d * s + f * a, i[1] = d * r + f * l, i[2] = d * n + f * h, i[3] = d * a - f * s, i[4] = d * l - f * r, i[5] = d * h - f * n, i[6] = o, i[7] = c, i[8] = u, i;
1069
+ }
1070
+ function Ke(i, t, e) {
1071
+ let s = e[0], r = e[1];
1072
+ return i[0] = s * t[0], i[1] = s * t[1], i[2] = s * t[2], i[3] = r * t[3], i[4] = r * t[4], i[5] = r * t[5], i[6] = t[6], i[7] = t[7], i[8] = t[8], i;
1073
+ }
1074
+ function ti(i, t) {
1075
+ let e = t[0], s = t[1], r = t[2], n = t[3], a = t[4], l = t[5], h = t[6], o = t[7], c = t[8], u = t[9], f = t[10], d = t[11], g = t[12], p = t[13], m = t[14], v = t[15], A = e * l - s * a, y = e * h - r * a, x = e * o - n * a, w = s * h - r * l, b = s * o - n * l, E = r * o - n * h, T = c * p - u * g, F = c * m - f * g, R = c * v - d * g, I = u * m - f * p, z = u * v - d * p, B = f * v - d * m, M = A * B - y * z + x * I + w * R - b * F + E * T;
1076
+ return M ? (M = 1 / M, i[0] = (l * B - h * z + o * I) * M, i[1] = (h * R - a * B - o * F) * M, i[2] = (a * z - l * R + o * T) * M, i[3] = (r * z - s * B - n * I) * M, i[4] = (e * B - r * R + n * F) * M, i[5] = (s * R - e * z - n * T) * M, i[6] = (p * E - m * b + v * w) * M, i[7] = (m * x - g * E - v * y) * M, i[8] = (g * b - p * x + v * A) * M, i) : null;
1077
+ }
1078
+ class ei extends Array {
1079
+ constructor(t = 1, e = 0, s = 0, r = 0, n = 1, a = 0, l = 0, h = 0, o = 1) {
1080
+ return super(t, e, s, r, n, a, l, h, o), this;
1081
+ }
1082
+ set(t, e, s, r, n, a, l, h, o) {
1083
+ return t.length ? this.copy(t) : (je(this, t, e, s, r, n, a, l, h, o), this);
1084
+ }
1085
+ translate(t, e = this) {
1086
+ return Qe(this, e, t), this;
1087
+ }
1088
+ rotate(t, e = this) {
1089
+ return Je(this, e, t), this;
1090
+ }
1091
+ scale(t, e = this) {
1092
+ return Ke(this, e, t), this;
1093
+ }
1094
+ multiply(t, e) {
1095
+ return e ? xt(this, t, e) : xt(this, this, t), this;
1096
+ }
1097
+ identity() {
1098
+ return Ze(this), this;
1099
+ }
1100
+ copy(t) {
1101
+ return We(this, t), this;
1102
+ }
1103
+ fromMatrix4(t) {
1104
+ return Ye(this, t), this;
1105
+ }
1106
+ fromQuaternion(t) {
1107
+ return Ve(this, t), this;
1108
+ }
1109
+ fromBasis(t, e, s) {
1110
+ return this.set(t[0], t[1], t[2], e[0], e[1], e[2], s[0], s[1], s[2]), this;
1111
+ }
1112
+ inverse(t = this) {
1113
+ return He(this, t), this;
1114
+ }
1115
+ getNormalMatrix(t) {
1116
+ return ti(this, t), this;
1117
+ }
1118
+ }
1119
+ let ii = 0;
1120
+ class si extends Ue {
1121
+ constructor(t, { geometry: e, program: s, mode: r = t.TRIANGLES, frustumCulled: n = !0, renderOrder: a = 0 } = {}) {
1122
+ super(), t.canvas || console.error("gl not passed as first argument to Mesh"), this.gl = t, this.id = ii++, this.geometry = e, this.program = s, this.mode = r, this.frustumCulled = n, this.renderOrder = a, this.modelViewMatrix = new U(), this.normalMatrix = new ei(), this.beforeRenderCallbacks = [], this.afterRenderCallbacks = [];
1123
+ }
1124
+ onBeforeRender(t) {
1125
+ return this.beforeRenderCallbacks.push(t), this;
1126
+ }
1127
+ onAfterRender(t) {
1128
+ return this.afterRenderCallbacks.push(t), this;
1129
+ }
1130
+ draw({ camera: t } = {}) {
1131
+ t && (this.program.uniforms.modelMatrix || Object.assign(this.program.uniforms, {
1132
+ modelMatrix: { value: null },
1133
+ viewMatrix: { value: null },
1134
+ modelViewMatrix: { value: null },
1135
+ normalMatrix: { value: null },
1136
+ projectionMatrix: { value: null },
1137
+ cameraPosition: { value: null }
1138
+ }), this.program.uniforms.projectionMatrix.value = t.projectionMatrix, this.program.uniforms.cameraPosition.value = t.worldPosition, this.program.uniforms.viewMatrix.value = t.viewMatrix, this.modelViewMatrix.multiply(t.viewMatrix, this.worldMatrix), this.normalMatrix.getNormalMatrix(this.modelViewMatrix), this.program.uniforms.modelMatrix.value = this.worldMatrix, this.program.uniforms.modelViewMatrix.value = this.modelViewMatrix, this.program.uniforms.normalMatrix.value = this.normalMatrix), this.beforeRenderCallbacks.forEach((s) => s && s({ mesh: this, camera: t }));
1139
+ let e = this.program.cullFace && this.worldMatrix.determinant() < 0;
1140
+ this.program.use({ flipFaces: e }), this.geometry.draw({ mode: this.mode, program: this.program }), this.afterRenderCallbacks.forEach((s) => s && s({ mesh: this, camera: t }));
1141
+ }
1142
+ }
1143
+ const yt = {
1144
+ black: "#000000",
1145
+ white: "#ffffff",
1146
+ red: "#ff0000",
1147
+ green: "#00ff00",
1148
+ blue: "#0000ff",
1149
+ fuchsia: "#ff00ff",
1150
+ cyan: "#00ffff",
1151
+ yellow: "#ffff00",
1152
+ orange: "#ff8000"
1153
+ };
1154
+ function bt(i) {
1155
+ i.length === 4 && (i = i[0] + i[1] + i[1] + i[2] + i[2] + i[3] + i[3]);
1156
+ const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);
1157
+ return t || console.warn(`Unable to convert hex string ${i} to rgb values`), [parseInt(t[1], 16) / 255, parseInt(t[2], 16) / 255, parseInt(t[3], 16) / 255];
1158
+ }
1159
+ function ri(i) {
1160
+ return i = parseInt(i), [(i >> 16 & 255) / 255, (i >> 8 & 255) / 255, (i & 255) / 255];
1161
+ }
1162
+ function wt(i) {
1163
+ return i === void 0 ? [0, 0, 0] : arguments.length === 3 ? arguments : isNaN(i) ? i[0] === "#" ? bt(i) : yt[i.toLowerCase()] ? bt(yt[i.toLowerCase()]) : (console.warn("Color format not recognised"), [0, 0, 0]) : ri(i);
1164
+ }
1165
+ class C extends Array {
1166
+ constructor(t) {
1167
+ return Array.isArray(t) ? super(...t) : super(...wt(...arguments));
1168
+ }
1169
+ get r() {
1170
+ return this[0];
1171
+ }
1172
+ get g() {
1173
+ return this[1];
1174
+ }
1175
+ get b() {
1176
+ return this[2];
1177
+ }
1178
+ set r(t) {
1179
+ this[0] = t;
1180
+ }
1181
+ set g(t) {
1182
+ this[1] = t;
1183
+ }
1184
+ set b(t) {
1185
+ this[2] = t;
1186
+ }
1187
+ set(t) {
1188
+ return Array.isArray(t) ? this.copy(t) : this.copy(wt(...arguments));
1189
+ }
1190
+ copy(t) {
1191
+ return this[0] = t[0], this[1] = t[1], this[2] = t[2], this;
1192
+ }
1193
+ }
1194
+ function ni(i, t) {
1195
+ return i[0] = t[0], i[1] = t[1], i;
1196
+ }
1197
+ function ai(i, t, e) {
1198
+ return i[0] = t, i[1] = e, i;
1199
+ }
1200
+ function Mt(i, t, e) {
1201
+ return i[0] = t[0] + e[0], i[1] = t[1] + e[1], i;
1202
+ }
1203
+ function Ct(i, t, e) {
1204
+ return i[0] = t[0] - e[0], i[1] = t[1] - e[1], i;
1205
+ }
1206
+ function li(i, t, e) {
1207
+ return i[0] = t[0] * e[0], i[1] = t[1] * e[1], i;
1208
+ }
1209
+ function hi(i, t, e) {
1210
+ return i[0] = t[0] / e[0], i[1] = t[1] / e[1], i;
1211
+ }
1212
+ function J(i, t, e) {
1213
+ return i[0] = t[0] * e, i[1] = t[1] * e, i;
1214
+ }
1215
+ function oi(i, t) {
1216
+ var e = t[0] - i[0], s = t[1] - i[1];
1217
+ return Math.sqrt(e * e + s * s);
1218
+ }
1219
+ function ci(i, t) {
1220
+ var e = t[0] - i[0], s = t[1] - i[1];
1221
+ return e * e + s * s;
1222
+ }
1223
+ function St(i) {
1224
+ var t = i[0], e = i[1];
1225
+ return Math.sqrt(t * t + e * e);
1226
+ }
1227
+ function ui(i) {
1228
+ var t = i[0], e = i[1];
1229
+ return t * t + e * e;
1230
+ }
1231
+ function fi(i, t) {
1232
+ return i[0] = -t[0], i[1] = -t[1], i;
1233
+ }
1234
+ function di(i, t) {
1235
+ return i[0] = 1 / t[0], i[1] = 1 / t[1], i;
1236
+ }
1237
+ function gi(i, t) {
1238
+ var e = t[0], s = t[1], r = e * e + s * s;
1239
+ return r > 0 && (r = 1 / Math.sqrt(r)), i[0] = t[0] * r, i[1] = t[1] * r, i;
1240
+ }
1241
+ function pi(i, t) {
1242
+ return i[0] * t[0] + i[1] * t[1];
1243
+ }
1244
+ function At(i, t) {
1245
+ return i[0] * t[1] - i[1] * t[0];
1246
+ }
1247
+ function mi(i, t, e, s) {
1248
+ var r = t[0], n = t[1];
1249
+ return i[0] = r + s * (e[0] - r), i[1] = n + s * (e[1] - n), i;
1250
+ }
1251
+ function vi(i, t, e, s, r) {
1252
+ const n = Math.exp(-s * r);
1253
+ let a = t[0], l = t[1];
1254
+ return i[0] = e[0] + (a - e[0]) * n, i[1] = e[1] + (l - e[1]) * n, i;
1255
+ }
1256
+ function xi(i, t, e) {
1257
+ var s = t[0], r = t[1];
1258
+ return i[0] = e[0] * s + e[3] * r + e[6], i[1] = e[1] * s + e[4] * r + e[7], i;
1259
+ }
1260
+ function yi(i, t, e) {
1261
+ let s = t[0], r = t[1];
1262
+ return i[0] = e[0] * s + e[4] * r + e[12], i[1] = e[1] * s + e[5] * r + e[13], i;
1263
+ }
1264
+ function bi(i, t) {
1265
+ return i[0] === t[0] && i[1] === t[1];
1266
+ }
1267
+ class it extends Array {
1268
+ constructor(t = 0, e = t) {
1269
+ return super(t, e), this;
1270
+ }
1271
+ get x() {
1272
+ return this[0];
1273
+ }
1274
+ get y() {
1275
+ return this[1];
1276
+ }
1277
+ set x(t) {
1278
+ this[0] = t;
1279
+ }
1280
+ set y(t) {
1281
+ this[1] = t;
1282
+ }
1283
+ set(t, e = t) {
1284
+ return t.length ? this.copy(t) : (ai(this, t, e), this);
1285
+ }
1286
+ copy(t) {
1287
+ return ni(this, t), this;
1288
+ }
1289
+ add(t, e) {
1290
+ return e ? Mt(this, t, e) : Mt(this, this, t), this;
1291
+ }
1292
+ sub(t, e) {
1293
+ return e ? Ct(this, t, e) : Ct(this, this, t), this;
1294
+ }
1295
+ multiply(t) {
1296
+ return t.length ? li(this, this, t) : J(this, this, t), this;
1297
+ }
1298
+ divide(t) {
1299
+ return t.length ? hi(this, this, t) : J(this, this, 1 / t), this;
1300
+ }
1301
+ inverse(t = this) {
1302
+ return di(this, t), this;
1303
+ }
1304
+ // Can't use 'length' as Array.prototype uses it
1305
+ len() {
1306
+ return St(this);
1307
+ }
1308
+ distance(t) {
1309
+ return t ? oi(this, t) : St(this);
1310
+ }
1311
+ squaredLen() {
1312
+ return this.squaredDistance();
1313
+ }
1314
+ squaredDistance(t) {
1315
+ return t ? ci(this, t) : ui(this);
1316
+ }
1317
+ negate(t = this) {
1318
+ return fi(this, t), this;
1319
+ }
1320
+ cross(t, e) {
1321
+ return e ? At(t, e) : At(this, t);
1322
+ }
1323
+ scale(t) {
1324
+ return J(this, this, t), this;
1325
+ }
1326
+ normalize() {
1327
+ return gi(this, this), this;
1328
+ }
1329
+ dot(t) {
1330
+ return pi(this, t);
1331
+ }
1332
+ equals(t) {
1333
+ return bi(this, t);
1334
+ }
1335
+ applyMatrix3(t) {
1336
+ return xi(this, this, t), this;
1337
+ }
1338
+ applyMatrix4(t) {
1339
+ return yi(this, this, t), this;
1340
+ }
1341
+ lerp(t, e) {
1342
+ return mi(this, this, t, e), this;
1343
+ }
1344
+ smoothLerp(t, e, s) {
1345
+ return vi(this, this, t, e, s), this;
1346
+ }
1347
+ clone() {
1348
+ return new it(this[0], this[1]);
1349
+ }
1350
+ fromArray(t, e = 0) {
1351
+ return this[0] = t[e], this[1] = t[e + 1], this;
1352
+ }
1353
+ toArray(t = [], e = 0) {
1354
+ return t[e] = this[0], t[e + 1] = this[1], t;
1355
+ }
1356
+ }
1357
+ class wi extends Jt {
1358
+ constructor(t, { attributes: e = {} } = {}) {
1359
+ Object.assign(e, {
1360
+ position: { size: 2, data: new Float32Array([-1, -1, 3, -1, -1, 3]) },
1361
+ uv: { size: 2, data: new Float32Array([0, 0, 2, 0, 0, 2]) }
1362
+ }), super(t, e);
1363
+ }
1364
+ }
1365
+ class Mi {
1366
+ constructor(t, e, s = {}) {
1367
+ this.canvas = t, this.#r = null, this.#n = 0, this.#o = 0, this.#a = !1, this.#h = null, this.loop = () => {
1368
+ this.#a && (this.render(), this.#r = requestAnimationFrame(this.loop));
1369
+ }, this.#e = e;
1370
+ const r = s.pixelRatio ?? 1, n = Math.max(0.1, Math.min(4, r));
1371
+ this.#l = (s.renderScale ?? 1) * n, this.#f = s.singleRender ?? !1;
1372
+ let a = s.width || 300, l = s.height || 300;
1373
+ if (!s.width || !s.height) {
1374
+ const c = this.canvas.getBoundingClientRect();
1375
+ c.width > 0 && (a = c.width), c.height > 0 && (l = c.height);
1376
+ }
1377
+ this.#c = a, this.#u = l;
1378
+ const h = Math.max(1, Math.floor(a * this.#l)), o = Math.max(1, Math.floor(l * this.#l));
1379
+ this.#i = new ne({
1380
+ canvas: this.canvas,
1381
+ width: h,
1382
+ height: o,
1383
+ alpha: !1,
1384
+ // Opaque background
1385
+ dpr: 1
1386
+ // Don't apply device pixel ratio since we're already scaling
1387
+ }), this.gl = this.#i.gl, this.canvas.width = h, this.canvas.height = o, this.#i.setSize(h, o), this.canvas.style.width = `${a}px`, this.canvas.style.height = `${l}px`, this.init();
1388
+ }
1389
+ #i;
1390
+ #t;
1391
+ #s;
1392
+ #e;
1393
+ #r;
1394
+ #n;
1395
+ #o;
1396
+ #a;
1397
+ #l;
1398
+ #f;
1399
+ #c;
1400
+ #u;
1401
+ #h;
1402
+ init() {
1403
+ const t = new wi(this.gl), e = {
1404
+ uTime: { value: 0 },
1405
+ uResolution: {
1406
+ // Display-space resolution (CSS pixels); shaders typically use this for aspect-correct math.
1407
+ value: new it(this.#c, this.#u)
1408
+ }
1409
+ };
1410
+ this.#s = new te(this.gl, {
1411
+ vertex: this.#e.vertexShader || Ci,
1412
+ fragment: this.#e.fragmentShader,
1413
+ uniforms: {
1414
+ ...e,
1415
+ ...this.#e.uniforms
1416
+ },
1417
+ // Ensure depth test is off for background
1418
+ depthTest: !1,
1419
+ cullFace: !1
1420
+ }), this.#t = new si(this.gl, { geometry: t, program: this.#s }), this.#e.onInit && this.#e.onInit(this.gl, this.#s);
1421
+ }
1422
+ start() {
1423
+ this.#a || (this.#a = !0, this.#n = performance.now(), this.#f ? (this.render(), this.#a = !1) : this.loop());
1424
+ }
1425
+ stop() {
1426
+ this.#a = !1, this.#r !== null && (cancelAnimationFrame(this.#r), this.#r = null);
1427
+ }
1428
+ render() {
1429
+ if (this.#h) {
1430
+ const { renderWidth: s, renderHeight: r } = this.#h;
1431
+ this.#h = null, this.canvas.width = s, this.canvas.height = r, this.#i.setSize(s, r), this.canvas.style.width = `${this.#c}px`, this.canvas.style.height = `${this.#u}px`;
1432
+ }
1433
+ const t = performance.now(), e = t - this.#n;
1434
+ this.#n = t, this.#o += e * 1e-3, this.#s.uniforms.uTime.value = this.#o, this.#e.onRender && this.#e.onRender(e, this.#o), this.#i.render({ scene: this.#t });
1435
+ }
1436
+ resize(t, e) {
1437
+ if (t === void 0 || e === void 0) {
1438
+ const n = this.canvas.getBoundingClientRect();
1439
+ t = Math.max(1, n.width), e = Math.max(1, n.height);
1440
+ }
1441
+ this.#c = t, this.#u = e;
1442
+ const s = Math.max(1, Math.floor(t * this.#l)), r = Math.max(1, Math.floor(e * this.#l));
1443
+ this.canvas.style.width = `${t}px`, this.canvas.style.height = `${e}px`, this.#f ? this.#h = { renderWidth: s, renderHeight: r } : (this.canvas.width = s, this.canvas.height = r, this.#i.setSize(s, r), this.canvas.style.width = `${t}px`, this.canvas.style.height = `${e}px`), this.#s && this.#s.uniforms.uResolution.value.set(t, e), this.#e.onResize && this.#e.onResize(t, e);
1444
+ }
1445
+ dispose() {
1446
+ this.stop();
1447
+ }
1448
+ }
1449
+ const Ci = (
1450
+ /* glsl */
1451
+ `
1452
+ attribute vec2 uv;
1453
+ attribute vec2 position;
1454
+ varying vec2 vUv;
1455
+ void main() {
1456
+ vUv = uv;
1457
+ gl_Position = vec4(position, 0, 1);
1458
+ }
1459
+ `
1460
+ );
1461
+ var G, S, L, P, It, et, $, Bt, Lt;
1462
+ const O = class O {
1463
+ constructor(t, e = {}) {
1464
+ V(this, S);
1465
+ V(this, G);
1466
+ this.name = "gradient-points", this.fragmentShader = /* glsl */
1467
+ `
1468
+ precision highp float;
1469
+
1470
+ uniform float uTime;
1471
+ uniform vec2 uResolution;
1472
+
1473
+ uniform int uPointCount;
1474
+ uniform vec2 uPoints[${O.MAX_POINTS}];
1475
+ uniform vec3 uColors[${O.MAX_POINTS}];
1476
+
1477
+ varying vec2 vUv;
1478
+
1479
+ void main() {
1480
+ // 1. Normalize UVs to preserve aspect ratio
1481
+ // This ensures points placed at (0.5, 0.5) look correct on rectangles
1482
+ float aspect = uResolution.x / uResolution.y;
1483
+ vec2 uv = vUv * 2.0 - 1.0; // Transform UV 0..1 to -1..1
1484
+ uv.x *= aspect;
1485
+
1486
+ vec3 finalColor = vec3(0.0);
1487
+ float totalWeight = 0.0;
1488
+
1489
+ for (int i = 0; i < ${O.MAX_POINTS}; i++) {
1490
+ if (i >= uPointCount) break;
1491
+
1492
+ vec2 p = uPoints[i];
1493
+ p.x *= aspect; // Apply same aspect correction to point
1494
+
1495
+ // Calculate Distance
1496
+ float dist = distance(uv, p);
1497
+
1498
+ // Weight Function: 1 / (dist^power)
1499
+ // Power controls how "fat" the points are.
1500
+ // 2.0 is standard (Gravity), lower (e.g. 1.5) is softer/fuzzier.
1501
+ float w = 1.0 / pow(dist, 2.0);
1502
+
1503
+ // Clamp weight to avoid infinity at exact point location
1504
+ w = min(w, 1000.0);
1505
+
1506
+ finalColor += uColors[i] * w;
1507
+ totalWeight += w;
1508
+ }
1509
+
1510
+ // Avoid division by zero
1511
+ if (totalWeight > 0.0) {
1512
+ finalColor /= totalWeight;
1513
+ }
1514
+
1515
+ gl_FragColor = vec4(finalColor, 1.0);
1516
+ }
1517
+ `, W(this, G, []), t.length > O.MAX_POINTS && (console.warn(
1518
+ `GradientPlugin: Max points is ${O.MAX_POINTS}. Truncating.`
1519
+ ), t = t.slice(0, O.MAX_POINTS)), this.pointsConfig = t, this.defaultMotion = e.defaultMotion ?? {}, W(this, G, t.map(
1520
+ (n) => (n.colors ?? []).map((a) => {
1521
+ const l = new C(a);
1522
+ return [l.r, l.g, l.b];
1523
+ })
1524
+ )), this.colorStates = t.map(() => ({
1525
+ currentIdx: 0,
1526
+ nextIdx: 1 % 2,
1527
+ // Safe default will be fixed in loop
1528
+ t: 0
1529
+ })), this.motionStates = t.map((n) => _(this, S, Bt).call(this, n));
1530
+ const s = new Array(O.MAX_POINTS), r = new Array(O.MAX_POINTS);
1531
+ t.forEach((n, a) => {
1532
+ s[a] = [n.x, n.y];
1533
+ const l = N(this, G)[a]?.[0] ?? [0, 0, 0];
1534
+ r[a] = [l[0], l[1], l[2]], n.colors.length < 2 ? this.colorStates[a].nextIdx = 0 : this.colorStates[a].nextIdx = 1;
1535
+ });
1536
+ for (let n = t.length; n < O.MAX_POINTS; n++)
1537
+ s[n] = [0, 0], r[n] = [0, 0, 0];
1538
+ this.uniforms = {
1539
+ uPointCount: { value: t.length },
1540
+ uPoints: { value: s },
1541
+ uColors: { value: r }
1542
+ };
1543
+ }
1544
+ onRender(t) {
1545
+ const e = this.uniforms.uPoints.value, s = this.uniforms.uColors.value;
1546
+ this.pointsConfig.forEach((r, n) => {
1547
+ const a = this.motionStates[n];
1548
+ if (_(this, S, Lt).call(this, r, a, t), e[n][0] = a.x, e[n][1] = a.y, r.colors.length <= 1) return;
1549
+ const l = this.colorStates[n], h = r.speed || 1;
1550
+ l.t += t * 1e-3 * h, l.t >= 1 && (l.t = 0, l.currentIdx = l.nextIdx, l.nextIdx = (l.nextIdx + 1) % r.colors.length);
1551
+ const o = N(this, G)[n][l.currentIdx], c = N(this, G)[n][l.nextIdx], u = o[0] + (c[0] - o[0]) * l.t, f = o[1] + (c[1] - o[1]) * l.t, d = o[2] + (c[2] - o[2]) * l.t;
1552
+ s[n][0] = u, s[n][1] = f, s[n][2] = d;
1553
+ });
1554
+ }
1555
+ };
1556
+ G = new WeakMap(), S = new WeakSet(), L = function(t, e, s) {
1557
+ return Math.max(e, Math.min(s, t));
1558
+ }, P = function(t, e, s) {
1559
+ return t + (e - t) * s;
1560
+ }, It = function(t, e) {
1561
+ const s = _(this, S, L).call(this, t, 0, 1);
1562
+ switch (e) {
1563
+ case "linear":
1564
+ return s;
1565
+ case "easeInOutQuad":
1566
+ return s < 0.5 ? 2 * s * s : 1 - Math.pow(-2 * s + 2, 2) / 2;
1567
+ case "easeInOutCubic":
1568
+ return s < 0.5 ? 4 * s * s * s : 1 - Math.pow(-2 * s + 2, 3) / 2;
1569
+ default:
1570
+ return s * s * (3 - 2 * s);
1571
+ }
1572
+ }, et = function(t) {
1573
+ const e = { ...this.defaultMotion, ...t.motion ?? {} }, s = {
1574
+ minX: -1,
1575
+ maxX: 1,
1576
+ minY: -1,
1577
+ maxY: 1,
1578
+ ...e.bounds ?? {}
1579
+ };
1580
+ return s.minX > s.maxX && ([s.minX, s.maxX] = [s.maxX, s.minX]), s.minY > s.maxY && ([s.minY, s.maxY] = [s.maxY, s.minY]), {
1581
+ mode: e.mode ?? "none",
1582
+ path: e.path ?? [],
1583
+ duration: Math.max(1e-3, e.duration ?? 3),
1584
+ easing: e.easing ?? "smoothstep",
1585
+ bounds: s,
1586
+ randomRadius: Math.max(0, e.randomRadius ?? 0)
1587
+ };
1588
+ }, $ = function(t, e, s, r) {
1589
+ if (r > 0) {
1590
+ const n = Math.random() * Math.PI * 2, a = Math.sqrt(Math.random()) * r, l = t + Math.cos(n) * a, h = e + Math.sin(n) * a;
1591
+ return {
1592
+ x: _(this, S, L).call(this, l, s.minX, s.maxX),
1593
+ y: _(this, S, L).call(this, h, s.minY, s.maxY)
1594
+ };
1595
+ }
1596
+ return {
1597
+ x: _(this, S, P).call(this, s.minX, s.maxX, Math.random()),
1598
+ y: _(this, S, P).call(this, s.minY, s.maxY, Math.random())
1599
+ };
1600
+ }, Bt = function(t) {
1601
+ const e = _(this, S, et).call(this, t), s = {
1602
+ mode: e.mode,
1603
+ easing: e.easing,
1604
+ duration: e.duration,
1605
+ bounds: e.bounds,
1606
+ randomRadius: e.randomRadius,
1607
+ startX: t.x,
1608
+ startY: t.y,
1609
+ targetX: t.x,
1610
+ targetY: t.y,
1611
+ t: 1,
1612
+ pathIndex: 0,
1613
+ x: t.x,
1614
+ y: t.y
1615
+ };
1616
+ if (e.mode === "path" && e.path.length > 0)
1617
+ s.targetX = _(this, S, L).call(this, e.path[0].x, e.bounds.minX, e.bounds.maxX), s.targetY = _(this, S, L).call(this, e.path[0].y, e.bounds.minY, e.bounds.maxY), s.t = 0;
1618
+ else if (e.mode === "random") {
1619
+ const r = _(this, S, $).call(this, t.x, t.y, e.bounds, e.randomRadius);
1620
+ s.targetX = r.x, s.targetY = r.y, s.t = 0;
1621
+ }
1622
+ return s;
1623
+ }, Lt = function(t, e, s) {
1624
+ const r = _(this, S, et).call(this, t), n = e.mode !== r.mode, a = e.easing !== r.easing, l = e.duration !== r.duration, h = e.bounds.minX !== r.bounds.minX || e.bounds.maxX !== r.bounds.maxX || e.bounds.minY !== r.bounds.minY || e.bounds.maxY !== r.bounds.maxY, o = e.randomRadius !== r.randomRadius;
1625
+ if (n || a || l || h || o)
1626
+ if (e.mode = r.mode, e.easing = r.easing, e.duration = r.duration, e.bounds = r.bounds, e.randomRadius = r.randomRadius, e.startX = e.x, e.startY = e.y, e.t = 0, e.pathIndex = 0, r.mode === "path" && r.path.length > 0)
1627
+ e.targetX = _(this, S, L).call(this, r.path[0].x, r.bounds.minX, r.bounds.maxX), e.targetY = _(this, S, L).call(this, r.path[0].y, r.bounds.minY, r.bounds.maxY);
1628
+ else if (r.mode === "random") {
1629
+ const u = _(this, S, $).call(this, t.x, t.y, r.bounds, r.randomRadius);
1630
+ e.targetX = u.x, e.targetY = u.y;
1631
+ } else
1632
+ e.targetX = t.x, e.targetY = t.y, e.t = 1;
1633
+ if (r.mode === "none") {
1634
+ e.x = _(this, S, L).call(this, t.x, r.bounds.minX, r.bounds.maxX), e.y = _(this, S, L).call(this, t.y, r.bounds.minY, r.bounds.maxY), e.startX = e.x, e.startY = e.y, e.targetX = e.x, e.targetY = e.y, e.t = 1;
1635
+ return;
1636
+ }
1637
+ if (e.t += s / (r.duration * 1e3), e.t >= 1)
1638
+ if (e.x = e.targetX, e.y = e.targetY, e.startX = e.x, e.startY = e.y, e.t = 0, r.mode === "path") {
1639
+ if (r.path.length === 0) {
1640
+ e.targetX = e.x, e.targetY = e.y, e.t = 1;
1641
+ return;
1642
+ }
1643
+ e.pathIndex = (e.pathIndex + 1) % r.path.length;
1644
+ const u = r.path[e.pathIndex];
1645
+ e.targetX = _(this, S, L).call(this, u.x, r.bounds.minX, r.bounds.maxX), e.targetY = _(this, S, L).call(this, u.y, r.bounds.minY, r.bounds.maxY);
1646
+ } else {
1647
+ const u = _(this, S, $).call(this, t.x, t.y, r.bounds, r.randomRadius);
1648
+ e.targetX = u.x, e.targetY = u.y;
1649
+ }
1650
+ const c = _(this, S, It).call(this, e.t, r.easing);
1651
+ e.x = _(this, S, P).call(this, e.startX, e.targetX, c), e.y = _(this, S, P).call(this, e.startY, e.targetY, c);
1652
+ }, O.MAX_POINTS = 16;
1653
+ let _t = O;
1654
+ class _i {
1655
+ constructor(t) {
1656
+ this.name = "grainy-fog", this.fragmentShader = /* glsl */
1657
+ `
1658
+ precision highp float;
1659
+ uniform float uTimeInternal;
1660
+ uniform vec2 uResolution;
1661
+ uniform vec3 uColor1;
1662
+ uniform vec3 uColor2;
1663
+ uniform vec3 uBgColor;
1664
+ uniform float uGrain;
1665
+ uniform float uScale;
1666
+ uniform float uContrast;
1667
+ uniform int uOctaves;
1668
+ uniform float uLacunarity;
1669
+ uniform float uGain;
1670
+
1671
+ varying vec2 vUv;
1672
+
1673
+ // --- Value Noise / FBM ---
1674
+ float hash12(vec2 p) {
1675
+ // Dave Hoskins-ish: cheap, stable
1676
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
1677
+ p3 += dot(p3, p3.yzx + 33.33);
1678
+ return fract((p3.x + p3.y) * p3.z);
1679
+ }
1680
+
1681
+ float noise(in vec2 st) {
1682
+ vec2 i = floor(st);
1683
+ vec2 f = fract(st);
1684
+
1685
+ float a = hash12(i);
1686
+ float b = hash12(i + vec2(1.0, 0.0));
1687
+ float c = hash12(i + vec2(0.0, 1.0));
1688
+ float d = hash12(i + vec2(1.0, 1.0));
1689
+
1690
+ vec2 u = f * f * (3.0 - 2.0 * f);
1691
+ return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
1692
+ }
1693
+
1694
+ float fbm(in vec2 st) {
1695
+ float value = 0.0;
1696
+ float amplitude = 0.5;
1697
+ float freq = 1.0;
1698
+
1699
+ // rotate to reduce axial bias
1700
+ mat2 rot = mat2(0.80, -0.60, 0.60, 0.80);
1701
+
1702
+ for (int i = 0; i < 6; i++) {
1703
+ if (i >= uOctaves) break;
1704
+ value += amplitude * noise(st * freq);
1705
+ st = rot * st + 19.19;
1706
+ freq *= uLacunarity;
1707
+ amplitude *= uGain;
1708
+ }
1709
+
1710
+ return value;
1711
+ }
1712
+
1713
+ void main() {
1714
+ vec2 uv = vUv;
1715
+
1716
+ // aspect-correct domain
1717
+ float aspect = uResolution.x / uResolution.y;
1718
+ vec2 p = (uv - 0.5) * vec2(aspect, 1.0);
1719
+
1720
+ float t = uTimeInternal;
1721
+
1722
+ // Two-layer flow field -> richer motion
1723
+ vec2 q;
1724
+ q.x = fbm(p * uScale + vec2(0.0, 0.12 * t));
1725
+ q.y = fbm(p * (uScale * 0.9) + vec2(3.1, -0.08 * t));
1726
+
1727
+ vec2 r;
1728
+ r.x = fbm(p * (uScale * 1.2) + 1.7 * q + vec2(1.7, 9.2) + 0.15 * t);
1729
+ r.y = fbm(p * (uScale * 1.1) + 1.3 * q + vec2(8.3, 2.8) + 0.11 * t);
1730
+
1731
+ float f = fbm(p * uScale + r);
1732
+
1733
+ // Contrast curve (keeps highlights punchy)
1734
+ f = pow(clamp(f, 0.0, 1.0), 1.0 / max(0.001, uContrast));
1735
+
1736
+ // Color mix
1737
+ vec3 col = uBgColor;
1738
+ col = mix(col, uColor1, smoothstep(0.10, 0.85, f));
1739
+ col = mix(col, uColor2, smoothstep(0.15, 0.95, length(q)));
1740
+
1741
+ // Film grain in pixel space (stable-ish)
1742
+ vec2 px = uv * uResolution;
1743
+ float g = (hash12(px + t * 60.0) - 0.5) * 2.0;
1744
+ col += g * uGrain;
1745
+
1746
+ gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
1747
+ }
1748
+ `;
1749
+ const e = new C(t.firstColor), s = new C(t.secondColor), r = new C(t.backgroundColor);
1750
+ this.speed = t.speed ?? 1, this.uniforms = {
1751
+ uColor1: { value: [e.r, e.g, e.b] },
1752
+ uColor2: { value: [s.r, s.g, s.b] },
1753
+ uBgColor: { value: [r.r, r.g, r.b] },
1754
+ uGrain: { value: t.grainAmount ?? 0.12 },
1755
+ uScale: { value: t.scale ?? 2.25 },
1756
+ uContrast: { value: t.contrast ?? 1.25 },
1757
+ uOctaves: { value: Math.max(1, Math.min(6, t.octaves ?? 4)) },
1758
+ uLacunarity: { value: t.lacunarity ?? 2 },
1759
+ uGain: { value: t.gain ?? 0.5 },
1760
+ uTimeInternal: { value: 0 }
1761
+ };
1762
+ }
1763
+ onRender(t) {
1764
+ this.uniforms.uTimeInternal.value += t * 1e-3 * this.speed;
1765
+ }
1766
+ }
1767
+ class Ei {
1768
+ constructor(t) {
1769
+ this.name = "retro-grid", this.fragmentShader = /* glsl */
1770
+ `
1771
+ precision highp float;
1772
+ uniform float uTime;
1773
+ uniform vec3 uGridColor;
1774
+ uniform vec3 uBgColor;
1775
+ uniform float uSpeed;
1776
+
1777
+ varying vec2 vUv;
1778
+
1779
+ void main() {
1780
+ // Normalize UV to -1 to 1
1781
+ vec2 uv = vUv * 2.0 - 1.0;
1782
+
1783
+ // Hoziron offset
1784
+ float horizon = 0.0;
1785
+ float fov = 0.5;
1786
+
1787
+ // 3D Projection Logic
1788
+ // We only care about the bottom half for the floor
1789
+ if (uv.y > horizon) {
1790
+ // Sky (simple gradient or solid)
1791
+ gl_FragColor = vec4(uBgColor, 1.0);
1792
+ return;
1793
+ }
1794
+
1795
+ // Project the 2D pixel to 3D floor coordinates
1796
+ // x = uv.x / |y| to flare out perspective
1797
+ // z = 1.0 / |y| to simulate depth
1798
+ float floorY = abs(uv.y - horizon);
1799
+ vec3 coord = vec3(uv.x / floorY, floorY, 1.0 / floorY);
1800
+
1801
+ // Move the grid by time
1802
+ coord.z += uTime * uSpeed;
1803
+
1804
+ // Grid Logic
1805
+ vec2 gridUV = coord.xz * fov;
1806
+ vec2 grid = fract(gridUV) - 0.5;
1807
+
1808
+ // Thickness of lines (derivative for anti-aliasing approximation or hard coded)
1809
+ float line = min(abs(grid.x), abs(grid.y));
1810
+
1811
+ float gridVal = 1.0 - smoothstep(0.0, 0.05 * coord.z, line);
1812
+
1813
+ // Fade out grid near horizon (fog)
1814
+ float fog = smoothstep(0.0, 1.5, floorY);
1815
+
1816
+ vec3 color = mix(uBgColor, uGridColor, gridVal * fog);
1817
+
1818
+ gl_FragColor = vec4(color, 1.0);
1819
+ }
1820
+ `;
1821
+ const e = new C(t.gridColor), s = new C(t.backgroundColor);
1822
+ this.uniforms = {
1823
+ uGridColor: { value: [e.r, e.g, e.b] },
1824
+ uBgColor: { value: [s.r, s.g, s.b] },
1825
+ uSpeed: { value: t.speed ?? 1 }
1826
+ };
1827
+ }
1828
+ }
1829
+ const D = class D {
1830
+ constructor(t) {
1831
+ this.name = "liquid-orb", this.fragmentShader = /* glsl */
1832
+ `
1833
+ precision highp float;
1834
+ uniform vec2 uResolution;
1835
+ uniform vec3 uColor;
1836
+ uniform vec3 uBgColor;
1837
+ uniform float uGooeyness;
1838
+ uniform float uEdgeSoftness;
1839
+
1840
+ uniform int uCount;
1841
+ uniform vec3 uOrbs[${D.MAX_ORBS}]; // x, y, radius
1842
+
1843
+ varying vec2 vUv;
1844
+
1845
+ // Smooth Minimum function (The "Goo" math)
1846
+ float smin(float a, float b, float k) {
1847
+ float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);
1848
+ return mix(b, a, h) - k * h * (1.0 - h);
1849
+ }
1850
+
1851
+ void main() {
1852
+ float aspect = uResolution.x / uResolution.y;
1853
+ vec2 uv = vUv * 2.0 - 1.0;
1854
+ uv.x *= aspect;
1855
+
1856
+ // Calculate Signed Distance Field (SDF)
1857
+ // Start with a large distance
1858
+ float d = 100.0;
1859
+
1860
+ for (int i = 0; i < ${D.MAX_ORBS}; i++) {
1861
+ if (i >= uCount) break;
1862
+
1863
+ vec3 orb = uOrbs[i];
1864
+ vec2 pos = orb.xy;
1865
+ pos.x *= aspect; // Correct aspect for orb position too
1866
+
1867
+ float radius = orb.z;
1868
+
1869
+ // Distance from pixel to orb center minus radius
1870
+ float dist = length(uv - pos) - radius;
1871
+
1872
+ // Smoothly blend distances
1873
+ d = smin(d, dist, uGooeyness);
1874
+ }
1875
+
1876
+ // Render based on threshold
1877
+ // If d < 0.0, we are inside the goo
1878
+ // We use smoothstep for antialiasing the edge
1879
+ float alpha = 1.0 - smoothstep(0.0, max(0.0001, uEdgeSoftness), d);
1880
+
1881
+ vec3 color = mix(uBgColor, uColor, alpha);
1882
+
1883
+ gl_FragColor = vec4(color, 1.0);
1884
+ }
1885
+ `, this.orbs = [], this.orbData = [];
1886
+ const e = new C(t.color), s = new C(t.backgroundColor), r = Math.min(t.count ?? 5, D.MAX_ORBS);
1887
+ this.speedMultiplier = t.speed ?? 0.5;
1888
+ for (let n = 0; n < r; n++)
1889
+ this.orbs.push({
1890
+ x: (Math.random() * 2 - 1) * 0.8,
1891
+ y: (Math.random() * 2 - 1) * 0.8,
1892
+ vx: (Math.random() - 0.5) * 0.01,
1893
+ vy: (Math.random() - 0.5) * 0.01,
1894
+ radius: 0.2 + Math.random() * 0.2
1895
+ });
1896
+ this.orbData = Array.from({ length: D.MAX_ORBS }, () => [0, 0, 0]), this.uniforms = {
1897
+ uColor: { value: [e.r, e.g, e.b] },
1898
+ uBgColor: { value: [s.r, s.g, s.b] },
1899
+ uCount: { value: r },
1900
+ uOrbs: { value: this.orbData },
1901
+ uGooeyness: { value: t.gooeyness ?? 0.3 },
1902
+ uEdgeSoftness: { value: t.edgeSoftness ?? 0.02 }
1903
+ };
1904
+ }
1905
+ onRender(t) {
1906
+ let e = 0;
1907
+ for (const s of this.orbs) {
1908
+ s.x += s.vx * this.speedMultiplier * (t / 16), s.y += s.vy * this.speedMultiplier * (t / 16), (s.x < -1 || s.x > 1) && (s.vx *= -1), (s.y < -1 || s.y > 1) && (s.vy *= -1);
1909
+ const r = this.orbData[e];
1910
+ r[0] = s.x, r[1] = s.y, r[2] = s.radius, e++;
1911
+ }
1912
+ }
1913
+ };
1914
+ D.MAX_ORBS = 20;
1915
+ let Et = D;
1916
+ class Ri {
1917
+ constructor(t) {
1918
+ this.name = "caustics", this.fragmentShader = /* glsl */
1919
+ `
1920
+ precision highp float;
1921
+ #ifdef GL_OES_standard_derivatives
1922
+ #extension GL_OES_standard_derivatives : enable
1923
+ #endif
1924
+
1925
+ uniform float uTimeInternal;
1926
+ uniform vec2 uResolution;
1927
+ uniform vec3 uColor;
1928
+ uniform vec3 uBgColor;
1929
+ uniform float uIntensity;
1930
+ uniform float uScale;
1931
+ uniform float uDistortion;
1932
+ uniform float uSharpness;
1933
+ uniform float uAA;
1934
+
1935
+ varying vec2 vUv;
1936
+
1937
+ float aawidth(float x) {
1938
+ #ifdef GL_OES_standard_derivatives
1939
+ return fwidth(x);
1940
+ #else
1941
+ // Fallback: approximate 1 pixel in normalized space.
1942
+ return 1.0 / max(1.0, min(uResolution.x, uResolution.y));
1943
+ #endif
1944
+ }
1945
+
1946
+ float hash12(vec2 p) {
1947
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
1948
+ p3 += dot(p3, p3.yzx + 33.33);
1949
+ return fract((p3.x + p3.y) * p3.z);
1950
+ }
1951
+
1952
+ // Textureless "caustics-ish" pattern: warped cells + exponential falloff
1953
+ float caustics(vec2 p, float t) {
1954
+ float c = 0.0;
1955
+ float a = 1.0;
1956
+
1957
+ // Add a slow, large-scale warp so it doesn't look like static tiles
1958
+ p += uDistortion * vec2(
1959
+ sin(p.y * 1.7 + t * 0.8),
1960
+ sin(p.x * 1.3 - t * 0.7)
1961
+ );
1962
+
1963
+ for (int i = 0; i < 4; i++) {
1964
+ // repeat + distance to nearest cell edge (0 at edges)
1965
+ vec2 q = abs(fract(p) - 0.5);
1966
+ float edgeDist = min(q.x, q.y);
1967
+
1968
+ // Derivative-based AA: widen the transition as frequency increases
1969
+ float w = aawidth(edgeDist) * (1.0 + uAA * 2.0);
1970
+
1971
+ // Bright lines near edges, with controllable sharpness
1972
+ float line = 1.0 - smoothstep(0.0, w, edgeDist);
1973
+ // Emphasize peaks without introducing harsh aliasing
1974
+ float web = pow(clamp(line, 0.0, 1.0), uSharpness);
1975
+ c += web * a;
1976
+
1977
+ // zoom and drift
1978
+ p = p * 1.65 + vec2(0.12 * t, -0.10 * t);
1979
+ p += (hash12(p + float(i) * 7.7) - 0.5) * 0.25;
1980
+ a *= 0.72;
1981
+ }
1982
+
1983
+ return c;
1984
+ }
1985
+
1986
+ void main() {
1987
+ float aspect = uResolution.x / uResolution.y;
1988
+ vec2 p = (vUv - 0.5) * vec2(aspect, 1.0);
1989
+ float t = uTimeInternal;
1990
+
1991
+ // scale in aspect-correct domain
1992
+ p *= uScale;
1993
+
1994
+ float c = caustics(p, t);
1995
+
1996
+ // shape + intensity
1997
+ float brightness = pow(clamp(c, 0.0, 2.0), 1.35) * uIntensity;
1998
+
1999
+ vec3 col = uBgColor + uColor * brightness;
2000
+
2001
+ gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
2002
+ }
2003
+ `;
2004
+ const e = new C(t.color), s = new C(t.backgroundColor);
2005
+ this.speed = t.speed ?? 0.5, this.uniforms = {
2006
+ uColor: { value: [e.r, e.g, e.b] },
2007
+ uBgColor: { value: [s.r, s.g, s.b] },
2008
+ uIntensity: { value: t.intensity ?? 1 },
2009
+ uScale: { value: t.scale ?? 2.2 },
2010
+ uDistortion: { value: t.distortion ?? 0.9 },
2011
+ uSharpness: { value: t.sharpness ?? 3.2 },
2012
+ uAA: { value: t.antiAlias ?? 1 },
2013
+ uTimeInternal: { value: 0 }
2014
+ };
2015
+ }
2016
+ onRender(t) {
2017
+ this.uniforms.uTimeInternal.value += t * 1e-3 * this.speed;
2018
+ }
2019
+ }
2020
+ class zi {
2021
+ constructor(t) {
2022
+ this.name = "aurora-waves", this.fragmentShader = /* glsl */
2023
+ `
2024
+ precision highp float;
2025
+ uniform float uTimeInternal;
2026
+ uniform vec2 uResolution;
2027
+ uniform vec3 uBg;
2028
+ uniform vec3 uC1;
2029
+ uniform vec3 uC2;
2030
+ uniform float uIntensity;
2031
+ uniform float uScale;
2032
+ uniform float uGrain;
2033
+
2034
+ varying vec2 vUv;
2035
+
2036
+ float hash12(vec2 p) {
2037
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
2038
+ p3 += dot(p3, p3.yzx + 33.33);
2039
+ return fract((p3.x + p3.y) * p3.z);
2040
+ }
2041
+
2042
+ float noise(vec2 p) {
2043
+ vec2 i = floor(p);
2044
+ vec2 f = fract(p);
2045
+ float a = hash12(i);
2046
+ float b = hash12(i + vec2(1.0, 0.0));
2047
+ float c = hash12(i + vec2(0.0, 1.0));
2048
+ float d = hash12(i + vec2(1.0, 1.0));
2049
+ vec2 u = f * f * (3.0 - 2.0 * f);
2050
+ return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
2051
+ }
2052
+
2053
+ float fbm(vec2 p) {
2054
+ float v = 0.0;
2055
+ float a = 0.5;
2056
+ mat2 rot = mat2(0.80, -0.60, 0.60, 0.80);
2057
+ for (int i = 0; i < 5; i++) {
2058
+ v += a * noise(p);
2059
+ p = rot * p * 2.02 + 19.19;
2060
+ a *= 0.55;
2061
+ }
2062
+ return v;
2063
+ }
2064
+
2065
+ void main() {
2066
+ float aspect = uResolution.x / uResolution.y;
2067
+ vec2 uv = vUv;
2068
+ vec2 p = (uv - 0.5) * vec2(aspect, 1.0);
2069
+
2070
+ float t = uTimeInternal;
2071
+ vec3 col = uBg;
2072
+
2073
+ // Ribbon field: layered sin waves warped by fbm
2074
+ float warp = fbm(p * (uScale * 0.9) + vec2(0.0, 0.10 * t));
2075
+ float warp2 = fbm(p * (uScale * 1.3) + vec2(4.0, -0.07 * t));
2076
+ float y = p.y + (warp - 0.5) * 0.55 + (warp2 - 0.5) * 0.35;
2077
+
2078
+ // Multiple ribbons at different heights
2079
+ float band1 = exp(-pow((y - 0.15 + 0.08 * sin(p.x * 1.2 + t * 0.6)), 2.0) * 18.0);
2080
+ float band2 = exp(-pow((y + 0.05 + 0.10 * sin(p.x * 0.9 - t * 0.5)), 2.0) * 14.0);
2081
+ float band3 = exp(-pow((y - 0.35 + 0.06 * sin(p.x * 1.6 + t * 0.4)), 2.0) * 22.0);
2082
+
2083
+ float bands = clamp(band1 + 0.8 * band2 + 0.6 * band3, 0.0, 1.5);
2084
+ // Soft flicker-free shimmer via low-frequency fbm
2085
+ float shimmer = 0.65 + 0.35 * fbm(p * (uScale * 0.6) + vec2(2.0, t * 0.12));
2086
+
2087
+ vec3 aur = mix(uC1, uC2, clamp(0.5 + 0.5 * sin(p.x * 0.7 + t * 0.25 + warp * 2.0), 0.0, 1.0));
2088
+ col += aur * (bands * shimmer) * uIntensity;
2089
+
2090
+ // Gentle vertical fade (so content remains readable)
2091
+ float fade = smoothstep(-0.9, 0.2, p.y);
2092
+ col = mix(col, uBg, fade * 0.35);
2093
+
2094
+ // Grain
2095
+ float g = (hash12(uv * uResolution + t * 60.0) - 0.5) * 2.0;
2096
+ col += g * uGrain;
2097
+
2098
+ gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
2099
+ }
2100
+ `;
2101
+ const e = new C(t.backgroundColor), s = new C(t.color1), r = new C(t.color2);
2102
+ this.speed = t.speed ?? 0.6, this.uniforms = {
2103
+ uBg: { value: [e.r, e.g, e.b] },
2104
+ uC1: { value: [s.r, s.g, s.b] },
2105
+ uC2: { value: [r.r, r.g, r.b] },
2106
+ uIntensity: { value: t.intensity ?? 0.9 },
2107
+ uScale: { value: t.scale ?? 1.6 },
2108
+ uGrain: { value: t.grainAmount ?? 0.05 },
2109
+ uTimeInternal: { value: 0 }
2110
+ };
2111
+ }
2112
+ onRender(t) {
2113
+ this.uniforms.uTimeInternal.value += t * 1e-3 * this.speed;
2114
+ }
2115
+ }
2116
+ class Ti {
2117
+ constructor(t) {
2118
+ this.name = "soft-starfield", this.fragmentShader = /* glsl */
2119
+ `
2120
+ precision highp float;
2121
+ uniform float uTimeInternal;
2122
+ uniform vec2 uResolution;
2123
+ uniform vec3 uBg0;
2124
+ uniform vec3 uBg1;
2125
+ uniform vec3 uStar;
2126
+ uniform vec3 uNebula;
2127
+ uniform float uDensity;
2128
+ uniform float uSize;
2129
+ uniform float uTwinkle;
2130
+ uniform float uNebulaAmt;
2131
+ uniform float uGrain;
2132
+
2133
+ varying vec2 vUv;
2134
+
2135
+ float hash12(vec2 p) {
2136
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
2137
+ p3 += dot(p3, p3.yzx + 33.33);
2138
+ return fract((p3.x + p3.y) * p3.z);
2139
+ }
2140
+
2141
+ float noise(vec2 p) {
2142
+ vec2 i = floor(p);
2143
+ vec2 f = fract(p);
2144
+ float a = hash12(i);
2145
+ float b = hash12(i + vec2(1.0, 0.0));
2146
+ float c = hash12(i + vec2(0.0, 1.0));
2147
+ float d = hash12(i + vec2(1.0, 1.0));
2148
+ vec2 u = f * f * (3.0 - 2.0 * f);
2149
+ return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
2150
+ }
2151
+
2152
+ float fbm(vec2 p) {
2153
+ float v = 0.0;
2154
+ float a = 0.5;
2155
+ mat2 rot = mat2(0.80, -0.60, 0.60, 0.80);
2156
+ for (int i = 0; i < 5; i++) {
2157
+ v += a * noise(p);
2158
+ p = rot * p * 2.02 + 19.19;
2159
+ a *= 0.55;
2160
+ }
2161
+ return v;
2162
+ }
2163
+
2164
+ // Simple cell-star: one star candidate per cell, softly drawn.
2165
+ float starLayer(vec2 uv, float scale, float t) {
2166
+ vec2 p = uv * scale;
2167
+ vec2 i = floor(p);
2168
+ vec2 f = fract(p) - 0.5;
2169
+ float rnd = hash12(i);
2170
+
2171
+ // place star within cell
2172
+ vec2 o = vec2(hash12(i + 13.1), hash12(i + 71.7)) - 0.5;
2173
+ vec2 d = f - o * 0.45;
2174
+
2175
+ // size distribution: many small, few larger
2176
+ float sz = mix(0.012, 0.035, pow(rnd, 7.0)) * uSize;
2177
+ float core = exp(-dot(d, d) / (sz * sz));
2178
+
2179
+ // twinkle: slow, subtle (avoid distracting flicker)
2180
+ float tw = 1.0 + (sin((rnd * 12.0) + t * 1.5) * 0.5 + 0.5) * uTwinkle;
2181
+
2182
+ // probability via rnd threshold (density)
2183
+ float present = step(0.55, rnd) * clamp(uDensity, 0.0, 3.0);
2184
+ return core * tw * present;
2185
+ }
2186
+
2187
+ void main() {
2188
+ float aspect = uResolution.x / uResolution.y;
2189
+ vec2 uv = vUv;
2190
+ vec2 p = (uv - 0.5) * vec2(aspect, 1.0);
2191
+ float t = uTimeInternal;
2192
+
2193
+ // Background gradient
2194
+ vec3 col = mix(uBg0, uBg1, smoothstep(-0.6, 0.8, p.y));
2195
+
2196
+ // Nebula: soft, low-contrast clouds
2197
+ float n = fbm(p * 1.35 + vec2(-0.05 * t, 0.02 * t));
2198
+ float n2 = fbm(p * 2.10 + vec2(0.03 * t, -0.04 * t));
2199
+ float neb = smoothstep(0.25, 0.85, n * 0.75 + n2 * 0.35);
2200
+ col += uNebula * neb * uNebulaAmt;
2201
+
2202
+ // Stars: 3 layers parallax-ish
2203
+ float s1 = starLayer(uv + vec2(-0.010 * t, 0.006 * t), 55.0, t);
2204
+ float s2 = starLayer(uv + vec2(-0.020 * t, 0.010 * t), 90.0, t + 7.7) * 0.8;
2205
+ float s3 = starLayer(uv + vec2(-0.035 * t, 0.016 * t), 140.0, t + 13.3) * 0.6;
2206
+ float stars = clamp(s1 + s2 + s3, 0.0, 1.75);
2207
+ col += uStar * stars;
2208
+
2209
+ // Grain
2210
+ float g = (hash12(uv * uResolution + t * 60.0) - 0.5) * 2.0;
2211
+ col += g * uGrain;
2212
+
2213
+ gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
2214
+ }
2215
+ `;
2216
+ const e = new C(t.backgroundBottom), s = new C(t.backgroundTop), r = new C(t.starColor ?? "#ffffff"), n = new C(t.nebulaColor ?? "#6a5cff");
2217
+ this.speed = t.speed ?? 0.2, this.uniforms = {
2218
+ uBg0: { value: [e.r, e.g, e.b] },
2219
+ uBg1: { value: [s.r, s.g, s.b] },
2220
+ uStar: { value: [r.r, r.g, r.b] },
2221
+ uNebula: { value: [n.r, n.g, n.b] },
2222
+ uDensity: { value: t.density ?? 1 },
2223
+ uSize: { value: t.size ?? 1 },
2224
+ uTwinkle: { value: t.twinkle ?? 0.35 },
2225
+ uNebulaAmt: { value: t.nebula ?? 0.35 },
2226
+ uGrain: { value: t.grainAmount ?? 0.04 },
2227
+ uTimeInternal: { value: 0 }
2228
+ };
2229
+ }
2230
+ onRender(t) {
2231
+ this.uniforms.uTimeInternal.value += t * 1e-3 * this.speed;
2232
+ }
2233
+ }
2234
+ class Fi {
2235
+ constructor(t) {
2236
+ this.name = "contour-lines", this.fragmentShader = /* glsl */
2237
+ `
2238
+ precision highp float;
2239
+ #ifdef GL_OES_standard_derivatives
2240
+ #extension GL_OES_standard_derivatives : enable
2241
+ #endif
2242
+
2243
+ uniform float uTimeInternal;
2244
+ uniform vec2 uResolution;
2245
+ uniform vec3 uBg;
2246
+ uniform vec3 uLine;
2247
+ uniform vec3 uAccent;
2248
+ uniform float uDensity;
2249
+ uniform float uThickness;
2250
+ uniform float uWarp;
2251
+ uniform float uGlow;
2252
+ uniform float uGrain;
2253
+
2254
+ varying vec2 vUv;
2255
+
2256
+ float hash12(vec2 p) {
2257
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
2258
+ p3 += dot(p3, p3.yzx + 33.33);
2259
+ return fract((p3.x + p3.y) * p3.z);
2260
+ }
2261
+
2262
+ float noise(vec2 p) {
2263
+ vec2 i = floor(p);
2264
+ vec2 f = fract(p);
2265
+ float a = hash12(i);
2266
+ float b = hash12(i + vec2(1.0, 0.0));
2267
+ float c = hash12(i + vec2(0.0, 1.0));
2268
+ float d = hash12(i + vec2(1.0, 1.0));
2269
+ vec2 u = f * f * (3.0 - 2.0 * f);
2270
+ return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
2271
+ }
2272
+
2273
+ float fbm(vec2 p) {
2274
+ float v = 0.0;
2275
+ float a = 0.5;
2276
+ mat2 rot = mat2(0.80, -0.60, 0.60, 0.80);
2277
+ for (int i = 0; i < 5; i++) {
2278
+ v += a * noise(p);
2279
+ p = rot * p * 2.02 + 19.19;
2280
+ a *= 0.55;
2281
+ }
2282
+ return v;
2283
+ }
2284
+
2285
+ float aawidth(float x) {
2286
+ #ifdef GL_OES_standard_derivatives
2287
+ return fwidth(x);
2288
+ #else
2289
+ return 1.0 / max(1.0, min(uResolution.x, uResolution.y));
2290
+ #endif
2291
+ }
2292
+
2293
+ void main() {
2294
+ float aspect = uResolution.x / uResolution.y;
2295
+ vec2 uv = vUv;
2296
+ vec2 p = (uv - 0.5) * vec2(aspect, 1.0);
2297
+ float t = uTimeInternal;
2298
+
2299
+ // Height field
2300
+ vec2 flow = vec2(0.10 * t, -0.06 * t);
2301
+ float h = fbm(p * 1.25 + flow);
2302
+ float h2 = fbm(p * 2.10 + vec2(-0.05 * t, 0.08 * t));
2303
+ float height = h + 0.55 * h2;
2304
+
2305
+ // Warp the domain so contours bend naturally
2306
+ vec2 w = vec2(
2307
+ fbm(p * 1.2 + vec2(2.0, 0.15 * t)),
2308
+ fbm(p * 1.2 + vec2(7.0, -0.12 * t))
2309
+ );
2310
+ p += (w - 0.5) * uWarp;
2311
+
2312
+ // Contour function: periodic bands
2313
+ float c = fract((height + 0.35 * fbm(p * 1.75 + 4.0)) * uDensity);
2314
+ float distToLine = min(c, 1.0 - c);
2315
+ float wAA = aawidth(distToLine) * 1.4;
2316
+ float line = 1.0 - smoothstep(uThickness, uThickness + wAA, distToLine);
2317
+
2318
+ // Glow around lines
2319
+ float glow = smoothstep(0.45, 0.0, distToLine) * uGlow;
2320
+
2321
+ vec3 col = uBg;
2322
+ col += uLine * line;
2323
+ col += uAccent * glow;
2324
+
2325
+ // Grain
2326
+ float g = (hash12(uv * uResolution + t * 60.0) - 0.5) * 2.0;
2327
+ col += g * uGrain;
2328
+
2329
+ gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
2330
+ }
2331
+ `;
2332
+ const e = new C(t.backgroundColor), s = new C(t.lineColor), r = new C(t.accentColor ?? t.lineColor);
2333
+ this.speed = t.speed ?? 0.35, this.uniforms = {
2334
+ uBg: { value: [e.r, e.g, e.b] },
2335
+ uLine: { value: [s.r, s.g, s.b] },
2336
+ uAccent: { value: [r.r, r.g, r.b] },
2337
+ uDensity: { value: t.density ?? 12 },
2338
+ uThickness: { value: t.thickness ?? 0.075 },
2339
+ uWarp: { value: t.warp ?? 0.9 },
2340
+ uGlow: { value: t.glow ?? 0.35 },
2341
+ uGrain: { value: t.grainAmount ?? 0.04 },
2342
+ uTimeInternal: { value: 0 }
2343
+ };
2344
+ }
2345
+ onRender(t) {
2346
+ this.uniforms.uTimeInternal.value += t * 1e-3 * this.speed;
2347
+ }
2348
+ }
2349
+ class Ii {
2350
+ constructor(t) {
2351
+ this.name = "dreamy-bokeh", this.fragmentShader = /* glsl */
2352
+ `
2353
+ precision highp float;
2354
+
2355
+ uniform float uTimeInternal;
2356
+ uniform vec2 uResolution;
2357
+ uniform vec3 uBg0;
2358
+ uniform vec3 uBg1;
2359
+ uniform vec3 uA;
2360
+ uniform vec3 uB;
2361
+ uniform vec3 uC;
2362
+ uniform float uDensity;
2363
+ uniform float uSize;
2364
+ uniform float uBlur;
2365
+ uniform float uVignette;
2366
+ uniform float uGrain;
2367
+
2368
+ varying vec2 vUv;
2369
+
2370
+ float hash12(vec2 p) {
2371
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
2372
+ p3 += dot(p3, p3.yzx + 33.33);
2373
+ return fract((p3.x + p3.y) * p3.z);
2374
+ }
2375
+
2376
+ vec2 hash22(vec2 p) {
2377
+ float n = hash12(p);
2378
+ return vec2(n, hash12(p + n + 19.19));
2379
+ }
2380
+
2381
+ float softCircle(vec2 d, float r, float blur) {
2382
+ float dist = length(d);
2383
+ // inside -> 1, outside -> 0, with soft falloff
2384
+ // NOTE: smoothstep requires edge0 < edge1.
2385
+ float b = max(0.0001, blur);
2386
+ float a = 1.0 - smoothstep(max(0.0, r - b), r, dist);
2387
+ return a * a;
2388
+ }
2389
+
2390
+ vec3 palette3(float h) {
2391
+ // Smoothly mix between 3 user colors
2392
+ float t0 = smoothstep(0.0, 1.0, h);
2393
+ vec3 ab = mix(uA, uB, smoothstep(0.0, 0.65, t0));
2394
+ return mix(ab, uC, smoothstep(0.35, 1.0, t0));
2395
+ }
2396
+
2397
+ vec3 bokehLayer(vec2 uv, float scale, float t, float seed, float weight) {
2398
+ vec2 p = uv * scale;
2399
+ vec2 ip = floor(p);
2400
+ vec2 fp = fract(p);
2401
+
2402
+ vec3 col = vec3(0.0);
2403
+ float acc = 0.0;
2404
+
2405
+ // Look at neighboring cells so circles crossing boundaries still render.
2406
+ for (int j = -1; j <= 1; j++) {
2407
+ for (int i = -1; i <= 1; i++) {
2408
+ vec2 cell = ip + vec2(float(i), float(j));
2409
+ float r0 = hash12(cell + seed);
2410
+
2411
+ // density gate: fewer circles when density is low
2412
+ float present = step(0.18, r0) * clamp(uDensity, 0.0, 3.0);
2413
+ if (present <= 0.0) continue;
2414
+
2415
+ vec2 o = hash22(cell + seed * 1.7);
2416
+
2417
+ // Slow drift to avoid looking tiled/static.
2418
+ // Drift amplitude intentionally small for background usage.
2419
+ vec2 drift = 0.08 * vec2(
2420
+ sin(t * 0.25 + r0 * 6.2831),
2421
+ cos(t * 0.21 + r0 * 4.9132)
2422
+ );
2423
+
2424
+ // Center in this cell (0..1), then shift to neighbor offset
2425
+ vec2 c = vec2(float(i), float(j)) + o + drift;
2426
+ vec2 d = fp - c;
2427
+
2428
+ float radius = mix(0.10, 0.44, pow(r0, 2.3)) * uSize;
2429
+ float blur = mix(0.05, 0.18, hash12(cell + seed + 7.7)) * uBlur;
2430
+
2431
+ float a = softCircle(d, radius, blur);
2432
+
2433
+ // Add a soft “lens glow” lobe (subtle)
2434
+ float glow = exp(-dot(d, d) / max(0.0001, radius * radius) * 1.9);
2435
+ a = a * 0.72 + glow * 0.28;
2436
+
2437
+ // Color per circle, slightly biased to highlight variety
2438
+ vec3 ccol = palette3(hash12(cell + seed + 3.3));
2439
+
2440
+ // Gentle twinkle (avoid flicker)
2441
+ float tw = 1.0 + 0.12 * sin(t * 1.1 + r0 * 10.0);
2442
+
2443
+ col += ccol * a * tw;
2444
+ acc += a;
2445
+ }
2446
+ }
2447
+
2448
+ // Normalize by accumulated alpha to keep brightness stable.
2449
+ col *= weight / (1.0 + acc * 0.85);
2450
+ return col;
2451
+ }
2452
+
2453
+ void main() {
2454
+ float aspect = uResolution.x / uResolution.y;
2455
+ vec2 uv = vUv;
2456
+ vec2 p = (uv - 0.5) * vec2(aspect, 1.0);
2457
+ float t = uTimeInternal;
2458
+
2459
+ // Background gradient with a slight vertical curve.
2460
+ float g = smoothstep(-0.7, 0.85, p.y + 0.08 * sin(p.x * 0.7));
2461
+ vec3 col = mix(uBg0, uBg1, g);
2462
+
2463
+ // Multi-scale bokeh (parallax-ish via slight offsets).
2464
+ col += bokehLayer(uv + vec2(-0.010 * t, 0.006 * t), 10.0, t, 11.0, 1.0);
2465
+ col += bokehLayer(uv + vec2(-0.018 * t, 0.010 * t), 16.0, t + 3.7, 37.0, 0.9);
2466
+ col += bokehLayer(uv + vec2(-0.030 * t, 0.016 * t), 26.0, t + 9.1, 83.0, 0.7);
2467
+
2468
+ // Vignette
2469
+ float v = 1.0 - smoothstep(0.25, 1.15, length(p * vec2(1.0, 0.9)));
2470
+ col *= mix(1.0, v, clamp(uVignette, 0.0, 1.0));
2471
+
2472
+ // Grain
2473
+ float gr = (hash12(uv * uResolution + t * 61.0) - 0.5) * 2.0;
2474
+ col += gr * uGrain;
2475
+
2476
+ gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
2477
+ }
2478
+ `;
2479
+ const e = new C(t.backgroundBottom), s = new C(t.backgroundTop), r = new C(t.colorA ?? "#ffd1f3"), n = new C(t.colorB ?? "#8be9ff"), a = new C(t.colorC ?? "#b7ff9b");
2480
+ this.speed = t.speed ?? 0.25, this.uniforms = {
2481
+ uBg0: { value: [e.r, e.g, e.b] },
2482
+ uBg1: { value: [s.r, s.g, s.b] },
2483
+ uA: { value: [r.r, r.g, r.b] },
2484
+ uB: { value: [n.r, n.g, n.b] },
2485
+ uC: { value: [a.r, a.g, a.b] },
2486
+ uDensity: { value: t.density ?? 1 },
2487
+ uSize: { value: t.size ?? 1 },
2488
+ uBlur: { value: t.blur ?? 1 },
2489
+ uVignette: { value: t.vignette ?? 0.35 },
2490
+ uGrain: { value: t.grainAmount ?? 0.03 },
2491
+ uTimeInternal: { value: 0 }
2492
+ };
2493
+ }
2494
+ onRender(t) {
2495
+ this.uniforms.uTimeInternal.value += t * 1e-3 * this.speed;
2496
+ }
2497
+ }
2498
+ class Bi {
2499
+ constructor(t) {
2500
+ this.name = "ink-wash", this.fragmentShader = /* glsl */
2501
+ `
2502
+ precision highp float;
2503
+ #ifdef GL_OES_standard_derivatives
2504
+ #extension GL_OES_standard_derivatives : enable
2505
+ #endif
2506
+
2507
+ uniform float uTimeInternal;
2508
+ uniform vec2 uResolution;
2509
+ uniform vec3 uPaper;
2510
+ uniform vec3 uInk;
2511
+ uniform float uScale;
2512
+ uniform float uFlow;
2513
+ uniform float uContrast;
2514
+ uniform float uGran;
2515
+ uniform float uVignette;
2516
+ uniform float uGrain;
2517
+
2518
+ varying vec2 vUv;
2519
+
2520
+ float hash12(vec2 p) {
2521
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
2522
+ p3 += dot(p3, p3.yzx + 33.33);
2523
+ return fract((p3.x + p3.y) * p3.z);
2524
+ }
2525
+
2526
+ float noise(vec2 p) {
2527
+ vec2 i = floor(p);
2528
+ vec2 f = fract(p);
2529
+ float a = hash12(i);
2530
+ float b = hash12(i + vec2(1.0, 0.0));
2531
+ float c = hash12(i + vec2(0.0, 1.0));
2532
+ float d = hash12(i + vec2(1.0, 1.0));
2533
+ vec2 u = f * f * (3.0 - 2.0 * f);
2534
+ return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
2535
+ }
2536
+
2537
+ float fbm(vec2 p) {
2538
+ float v = 0.0;
2539
+ float a = 0.5;
2540
+ mat2 rot = mat2(0.80, -0.60, 0.60, 0.80);
2541
+ for (int i = 0; i < 6; i++) {
2542
+ v += a * noise(p);
2543
+ p = rot * p * 2.02 + 17.17;
2544
+ a *= 0.55;
2545
+ }
2546
+ return v;
2547
+ }
2548
+
2549
+ vec2 flowField(vec2 p, float t) {
2550
+ // Curl-ish flow from two fbm samples
2551
+ float n1 = fbm(p * 1.10 + vec2(0.0, t * 0.12));
2552
+ float n2 = fbm(p * 1.10 + vec2(13.1, -t * 0.10));
2553
+ vec2 f = vec2(n1 - 0.5, n2 - 0.5);
2554
+ return f;
2555
+ }
2556
+
2557
+ float aawidth(float x) {
2558
+ #ifdef GL_OES_standard_derivatives
2559
+ return fwidth(x);
2560
+ #else
2561
+ return 1.0 / max(1.0, min(uResolution.x, uResolution.y));
2562
+ #endif
2563
+ }
2564
+
2565
+ void main() {
2566
+ float aspect = uResolution.x / uResolution.y;
2567
+ vec2 uv = vUv;
2568
+ vec2 p = (uv - 0.5) * vec2(aspect, 1.0);
2569
+ float t = uTimeInternal;
2570
+
2571
+ // Base paper tone + subtle fiber texture
2572
+ float fiber = noise(uv * vec2(uResolution.x, uResolution.y) * 0.0025);
2573
+ float fiber2 = noise(uv * vec2(uResolution.x, uResolution.y) * 0.0060 + 19.19);
2574
+ vec3 col = uPaper + (fiber - 0.5) * 0.05 + (fiber2 - 0.5) * 0.03;
2575
+
2576
+ // Domain-warped pigment field
2577
+ vec2 q = p * uScale;
2578
+ vec2 f = flowField(q, t) * (0.55 * uFlow);
2579
+ vec2 r = flowField(q + f * 1.35, t + 7.7) * (0.55 * uFlow);
2580
+ vec2 w = f + r;
2581
+
2582
+ float base = fbm(q + w);
2583
+ float detail = fbm(q * 2.10 - w * 0.70 + vec2(-0.07 * t, 0.05 * t));
2584
+ float field = base * 0.72 + detail * 0.35;
2585
+
2586
+ // Contrast shaping
2587
+ field = clamp(field, 0.0, 1.0);
2588
+ field = pow(field, 1.0 / max(0.001, uContrast));
2589
+
2590
+ // Pigment coverage (soft threshold)
2591
+ float edgeW = 0.08 + 0.06 * (1.0 - uFlow);
2592
+ float ink = smoothstep(0.38 - edgeW, 0.68 + edgeW, field);
2593
+
2594
+ // “Tide lines”: emphasize places where the field changes quickly
2595
+ float grad = 0.0;
2596
+ #ifdef GL_OES_standard_derivatives
2597
+ grad = (abs(dFdx(field)) + abs(dFdy(field))) * 6.0;
2598
+ #else
2599
+ grad = aawidth(field) * 120.0;
2600
+ #endif
2601
+ float tide = smoothstep(0.20, 0.95, grad);
2602
+ tide *= (1.0 - ink) * 0.55 + ink * 0.25; // strongest near transitions
2603
+
2604
+ // Pigment granulation: high-frequency noise visible where ink exists
2605
+ float gran = noise(q * 10.0 + vec2(31.2, 17.8)) - 0.5;
2606
+ float gran2 = noise(q * 18.0 + vec2(9.7, 53.1)) - 0.5;
2607
+ float granTex = gran * 0.8 + gran2 * 0.6;
2608
+ float granAmt = uGran * (0.35 + 0.65 * ink);
2609
+
2610
+ float pigment = clamp(ink + tide * 0.35 + granTex * granAmt, 0.0, 1.0);
2611
+
2612
+ // Mix ink into paper
2613
+ col = mix(col, mix(col, uInk, 0.92), pigment);
2614
+
2615
+ // Vignette
2616
+ float v = 1.0 - smoothstep(0.25, 1.15, length(p * vec2(1.0, 0.95)));
2617
+ col *= mix(1.0, v, clamp(uVignette, 0.0, 1.0));
2618
+
2619
+ // Grain
2620
+ float g = (hash12(uv * uResolution + t * 61.0) - 0.5) * 2.0;
2621
+ col += g * uGrain;
2622
+
2623
+ gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
2624
+ }
2625
+ `;
2626
+ const e = new C(t.paperColor), s = new C(t.inkColor);
2627
+ this.speed = t.speed ?? 0.18, this.uniforms = {
2628
+ uPaper: { value: [e.r, e.g, e.b] },
2629
+ uInk: { value: [s.r, s.g, s.b] },
2630
+ uScale: { value: t.scale ?? 1.4 },
2631
+ uFlow: { value: t.flow ?? 0.85 },
2632
+ uContrast: { value: t.contrast ?? 1.15 },
2633
+ uGran: { value: t.granulation ?? 0.35 },
2634
+ uVignette: { value: t.vignette ?? 0.35 },
2635
+ uGrain: { value: t.grainAmount ?? 0.03 },
2636
+ uTimeInternal: { value: 0 }
2637
+ };
2638
+ }
2639
+ onRender(t) {
2640
+ this.uniforms.uTimeInternal.value += t * 1e-3 * this.speed;
2641
+ }
2642
+ }
2643
+ class Li {
2644
+ constructor(t) {
2645
+ this.name = "stained-glass", this.fragmentShader = /* glsl */
2646
+ `
2647
+ precision highp float;
2648
+ #ifdef GL_OES_standard_derivatives
2649
+ #extension GL_OES_standard_derivatives : enable
2650
+ #endif
2651
+
2652
+ uniform float uTimeInternal;
2653
+ uniform vec2 uResolution;
2654
+ uniform vec3 uBg;
2655
+ uniform vec3 uLead;
2656
+ uniform vec3 uA;
2657
+ uniform vec3 uB;
2658
+ uniform vec3 uC;
2659
+ uniform vec3 uD;
2660
+ uniform float uScale;
2661
+ uniform float uSeed;
2662
+ uniform float uJitter;
2663
+ uniform float uRotate;
2664
+ uniform int uVariant;
2665
+ uniform float uEdgeW;
2666
+ uniform float uEdgeSharp;
2667
+ uniform float uGlow;
2668
+ uniform float uDist;
2669
+ uniform float uGrain;
2670
+
2671
+ varying vec2 vUv;
2672
+
2673
+ float hash12(vec2 p) {
2674
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
2675
+ p3 += dot(p3, p3.yzx + 33.33);
2676
+ return fract((p3.x + p3.y) * p3.z);
2677
+ }
2678
+
2679
+ vec2 hash22(vec2 p) {
2680
+ float n = hash12(p);
2681
+ return vec2(n, hash12(p + n + 19.19));
2682
+ }
2683
+
2684
+ float noise(vec2 p) {
2685
+ vec2 i = floor(p);
2686
+ vec2 f = fract(p);
2687
+ float a = hash12(i);
2688
+ float b = hash12(i + vec2(1.0, 0.0));
2689
+ float c = hash12(i + vec2(0.0, 1.0));
2690
+ float d = hash12(i + vec2(1.0, 1.0));
2691
+ vec2 u = f * f * (3.0 - 2.0 * f);
2692
+ return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
2693
+ }
2694
+
2695
+ vec3 palette4(float h) {
2696
+ // Blend 4 colors in a loop-friendly way.
2697
+ vec3 ab = mix(uA, uB, smoothstep(0.0, 0.50, h));
2698
+ vec3 cd = mix(uC, uD, smoothstep(0.50, 1.0, h));
2699
+ return mix(ab, cd, smoothstep(0.25, 0.85, h));
2700
+ }
2701
+
2702
+ mat2 rot2(float a) {
2703
+ float s = sin(a), c = cos(a);
2704
+ return mat2(c, -s, s, c);
2705
+ }
2706
+
2707
+ // Returns:
2708
+ // x: distance to nearest site
2709
+ // y: border metric (small near borders)
2710
+ // z: random id
2711
+ vec3 voronoi(vec2 x) {
2712
+ vec2 n = floor(x);
2713
+ vec2 f = fract(x);
2714
+
2715
+ float md = 8.0;
2716
+ float md2 = 8.0;
2717
+ vec2 mr = vec2(0.0);
2718
+ vec2 seed2 = vec2(uSeed, uSeed * 1.618);
2719
+
2720
+ for (int j = -1; j <= 1; j++) {
2721
+ for (int i = -1; i <= 1; i++) {
2722
+ vec2 g = vec2(float(i), float(j));
2723
+ vec2 o = hash22(n + g + seed2);
2724
+ // Jitter controls how "random" the site is inside the cell.
2725
+ o = mix(vec2(0.5), o, clamp(uJitter, 0.0, 1.0));
2726
+ vec2 r = g + o - f;
2727
+ float d = dot(r, r);
2728
+ if (d < md) {
2729
+ md2 = md;
2730
+ md = d;
2731
+ mr = n + g + o;
2732
+ } else if (d < md2) {
2733
+ md2 = d;
2734
+ }
2735
+ }
2736
+ }
2737
+
2738
+ float d1 = sqrt(md);
2739
+ float d2 = sqrt(md2);
2740
+ float border = d2 - d1; // small at edges
2741
+ return vec3(d1, border, hash12(mr + seed2));
2742
+ }
2743
+
2744
+ void main() {
2745
+ float aspect = uResolution.x / uResolution.y;
2746
+ vec2 uv = vUv;
2747
+ vec2 p = (uv - 0.5) * vec2(aspect, 1.0);
2748
+ float t = uTimeInternal;
2749
+
2750
+ // Subtle low-frequency warp to avoid static mosaic vibe
2751
+ vec2 warp = vec2(
2752
+ noise(p * 1.5 + vec2(0.07 * t, -0.03 * t)) - 0.5,
2753
+ noise(p * 1.5 + vec2(-0.05 * t, 0.06 * t) + 19.19) - 0.5
2754
+ );
2755
+ p += warp * (0.30 * uDist);
2756
+
2757
+ // Variant transforms (changes the cell character)
2758
+ vec2 g = p;
2759
+ g = rot2(uRotate) * g;
2760
+ if (uVariant == 1) {
2761
+ // Crystal: anisotropic scaling for more "shard-like" cells
2762
+ g *= mat2(1.35, 0.35, -0.10, 0.85);
2763
+ } else if (uVariant == 2) {
2764
+ // Radial-ish twist: mild angular warp
2765
+ float ang = atan(g.y, g.x);
2766
+ float rad = length(g);
2767
+ g += 0.15 * vec2(cos(ang * 3.0 + rad * 2.0), sin(ang * 2.0 - rad * 2.4));
2768
+ }
2769
+ g *= uScale;
2770
+ vec3 v = voronoi(g);
2771
+
2772
+ float border = v.y;
2773
+ float id = v.z;
2774
+
2775
+ // Lead line mask (1 at borders)
2776
+ float w = max(0.0005, uEdgeW);
2777
+ float aa = 0.0015;
2778
+ #ifdef GL_OES_standard_derivatives
2779
+ aa = fwidth(border) / max(0.0001, uEdgeSharp);
2780
+ #endif
2781
+ float lead = 1.0 - smoothstep(w - aa, w + aa, border);
2782
+
2783
+ // Cell color from palette + gentle variation
2784
+ vec3 cell = palette4(id);
2785
+ float tint = (noise(g * 0.85 + id * 11.7) - 0.5) * 0.18;
2786
+ cell *= (1.0 + tint);
2787
+
2788
+ // Faux “glass thickness” / caustic-y highlight
2789
+ float highlight = smoothstep(0.02, 0.30, noise(g * 2.2 + vec2(0.0, t * 0.6)));
2790
+ highlight *= (1.0 - lead);
2791
+
2792
+ // Edge glow
2793
+ float glow = exp(-border * border / max(0.00001, (w * w) * 0.35));
2794
+ glow *= uGlow;
2795
+
2796
+ // Compose
2797
+ vec3 col = mix(uBg, cell, 0.92);
2798
+ col += cell * highlight * 0.10;
2799
+
2800
+ // Lead overrides + glow on top
2801
+ col = mix(col, uLead, lead);
2802
+ col += (cell * 0.55 + vec3(1.0) * 0.25) * glow;
2803
+
2804
+ // Subtle vignette
2805
+ float vig = 1.0 - smoothstep(0.35, 1.15, length(p * vec2(1.0, 0.95)));
2806
+ col *= 0.90 + 0.10 * vig;
2807
+
2808
+ // Grain
2809
+ float gr = (hash12(uv * uResolution + t * 61.0) - 0.5) * 2.0;
2810
+ col += gr * uGrain;
2811
+
2812
+ gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
2813
+ }
2814
+ `;
2815
+ const e = new C(t.backgroundColor), s = new C(t.leadColor ?? "#0b0b10"), r = new C(t.colorA ?? "#38bdf8"), n = new C(t.colorB ?? "#a78bfa"), a = new C(t.colorC ?? "#fb7185"), l = new C(t.colorD ?? "#fbbf24");
2816
+ this.speed = t.speed ?? 0.12, this.uniforms = {
2817
+ uBg: { value: [e.r, e.g, e.b] },
2818
+ uLead: { value: [s.r, s.g, s.b] },
2819
+ uA: { value: [r.r, r.g, r.b] },
2820
+ uB: { value: [n.r, n.g, n.b] },
2821
+ uC: { value: [a.r, a.g, a.b] },
2822
+ uD: { value: [l.r, l.g, l.b] },
2823
+ uScale: { value: t.scale ?? 3.2 },
2824
+ uSeed: { value: t.seed ?? 0 },
2825
+ uJitter: { value: t.jitter ?? 1 },
2826
+ uRotate: { value: t.rotation ?? 0 },
2827
+ uVariant: { value: t.variant ?? 0 },
2828
+ uEdgeW: { value: t.edgeWidth ?? 0.08 },
2829
+ uEdgeSharp: { value: t.edgeSharpness ?? 1.25 },
2830
+ uGlow: { value: t.edgeGlow ?? 0.45 },
2831
+ uDist: { value: t.distortion ?? 0.55 },
2832
+ uGrain: { value: t.grainAmount ?? 0.02 },
2833
+ uTimeInternal: { value: 0 }
2834
+ };
2835
+ }
2836
+ onRender(t) {
2837
+ this.uniforms.uTimeInternal.value += t * 1e-3 * this.speed;
2838
+ }
2839
+ }
2840
+ class Si extends HTMLElement {
2841
+ #i;
2842
+ #t = null;
2843
+ #s;
2844
+ #e = null;
2845
+ #r = 1;
2846
+ #n = !1;
2847
+ constructor() {
2848
+ super(), this.attachShadow({ mode: "open" });
2849
+ const t = document.createElement("style");
2850
+ t.textContent = `
2851
+ :host {
2852
+ display: block;
2853
+ width: 100%;
2854
+ height: 100%;
2855
+ position: relative;
2856
+ overflow: hidden;
2857
+ }
2858
+ canvas {
2859
+ display: block;
2860
+ position: absolute;
2861
+ top: 0;
2862
+ left: 0;
2863
+ /* Pixelated rendering for crisp upscaling of low-res buffers */
2864
+ image-rendering: pixelated;
2865
+ image-rendering: -webkit-optimize-contrast;
2866
+ image-rendering: crisp-edges;
2867
+ }
2868
+ ::slotted(*) {
2869
+ position: relative;
2870
+ z-index: 1;
2871
+ }
2872
+ `, this.shadowRoot.appendChild(t), this.#i = document.createElement("canvas"), this.#i.setAttribute("part", "canvas"), this.shadowRoot.appendChild(this.#i);
2873
+ const e = document.createElement("slot");
2874
+ this.shadowRoot.appendChild(e), this.#s = new ResizeObserver((s) => {
2875
+ if (this.#t && s.length > 0) {
2876
+ const { width: r, height: n } = s[0].contentRect;
2877
+ this.#t.resize(r, n);
2878
+ }
2879
+ });
2880
+ }
2881
+ connectedCallback() {
2882
+ const t = this.getAttribute("render-scale");
2883
+ if (t) {
2884
+ const s = parseFloat(t);
2885
+ isNaN(s) || (this.#r = Math.max(0.1, Math.min(2, s)));
2886
+ }
2887
+ const e = this.getAttribute("single-render");
2888
+ if (e && (this.#n = e === "true" || e === ""), this.#s.observe(this), this.#e && this.init(), this.#t) {
2889
+ const s = this.getBoundingClientRect();
2890
+ this.#t.resize(s.width, s.height);
2891
+ }
2892
+ }
2893
+ disconnectedCallback() {
2894
+ this.#s.disconnect(), this.#t && (this.#t.dispose(), this.#t = null);
2895
+ }
2896
+ set plugin(t) {
2897
+ this.#e = t, this.#t && (this.#t.stop(), this.#t.dispose(), this.#t = null), this.init();
2898
+ }
2899
+ get plugin() {
2900
+ if (!this.#e)
2901
+ throw new Error("Plugin is required");
2902
+ return this.#e;
2903
+ }
2904
+ set renderScale(t) {
2905
+ this.#r = Math.max(0.1, Math.min(2, t)), this.#t && (this.#t.stop(), this.#t.dispose(), this.#t = null), this.init();
2906
+ }
2907
+ get renderScale() {
2908
+ return this.#r;
2909
+ }
2910
+ set singleRender(t) {
2911
+ this.#n = t, this.#t && (this.#t.stop(), this.#t.dispose(), this.#t = null), this.init();
2912
+ }
2913
+ get singleRender() {
2914
+ return this.#n;
2915
+ }
2916
+ render() {
2917
+ this.#t && this.#n && this.#t.render();
2918
+ }
2919
+ init() {
2920
+ if (!this.#e) return;
2921
+ this.#t && (this.#t.stop(), this.#t.dispose(), this.#t = null);
2922
+ const t = this.getBoundingClientRect(), e = t.width > 0 ? t.width : 300, s = t.height > 0 ? t.height : 300;
2923
+ this.#t = new Mi(this.#i, this.#e, {
2924
+ width: e,
2925
+ height: s,
2926
+ renderScale: this.#r,
2927
+ singleRender: this.#n
2928
+ }), this.#t.start();
2929
+ }
2930
+ static get observedAttributes() {
2931
+ return ["render-scale", "single-render"];
2932
+ }
2933
+ attributeChangedCallback(t, e, s) {
2934
+ if (e !== s)
2935
+ switch (t) {
2936
+ case "render-scale": {
2937
+ const r = parseFloat(s);
2938
+ isNaN(r) || (this.renderScale = r);
2939
+ break;
2940
+ }
2941
+ case "single-render":
2942
+ this.singleRender = s === "true" || s === "";
2943
+ break;
2944
+ }
2945
+ }
2946
+ }
2947
+ customElements.define("shader-background", Si);
2948
+ export {
2949
+ zi as AuroraWavesPlugin,
2950
+ Ri as CausticsPlugin,
2951
+ Fi as ContourLinesPlugin,
2952
+ Ii as DreamyBokehPlugin,
2953
+ _t as GradientPlugin,
2954
+ _i as GrainyFogPlugin,
2955
+ Bi as InkWashPlugin,
2956
+ Et as LiquidOrbPlugin,
2957
+ Ei as RetroGridPlugin,
2958
+ Si as ShaderBackgroundElement,
2959
+ Mi as ShaderCanvas,
2960
+ Ti as SoftStarfieldPlugin,
2961
+ Li as StainedGlassPlugin
2962
+ };