3d-spinner 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animations/ghost-train.d.ts +1 -1
- package/dist/animations/grid-assembly.d.ts +1 -1
- package/dist/cjs/animations/charged-orb.cjs +7 -2
- package/dist/cjs/animations/grid-assembly.cjs +7 -2
- package/dist/cjs/animations/object-motion.cjs +7 -2
- package/dist/cjs/animations/particles.cjs +14 -4
- package/dist/cjs/animations/spin.cjs +7 -2
- package/dist/cjs/engines/little-3d-engine/little-3d-engine.cjs +7 -2
- package/dist/cjs/engines/little-3d-engine/renderers/webgl-textured.cjs +14 -4
- package/dist/cjs/prefabs/prefabs.cjs +14 -4
- package/dist/engines/little-3d-engine/renderers/webgl-textured.js +8 -3
- package/dist/engines/little-3d-engine/renderers/webgl.js +7 -2
- package/dist/umd/spinner.global.js +16 -4
- package/dist/umd/spinner.global.min.js +7 -7
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import type { MotionController } from "../motion/controller.js";
|
|
|
4
4
|
export interface GhostTrainOptions {
|
|
5
5
|
/** How the convoy moves. Default a tilted square track. */
|
|
6
6
|
motion?: MotionController;
|
|
7
|
-
/** Uniform car size in scene units. Default `0.
|
|
7
|
+
/** Uniform car size in scene units. Default `0.15`. */
|
|
8
8
|
size?: number;
|
|
9
9
|
/** Rendering backend. Default `"canvas2d"`. */
|
|
10
10
|
backend?: Backend;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnimationFrame, AnimationLabel, SpinnerAnimation } from "../animation.js";
|
|
2
2
|
import { type Backend, type Mesh } from "../engines/little-3d-engine/little-3d-engine.js";
|
|
3
3
|
export interface GridAssemblyOptions {
|
|
4
|
-
/** Meshes (or factories) cycled across the 25 shapes. Defaults to a
|
|
4
|
+
/** Meshes (or factories) cycled across the 25 shapes. Defaults to a single pastel dark-blue cube. */
|
|
5
5
|
meshes?: Array<Mesh | (() => Mesh)>;
|
|
6
6
|
/** Uniform shape size in scene units. Default `0.34`. */
|
|
7
7
|
size?: number;
|
|
@@ -414,9 +414,11 @@ void main() {
|
|
|
414
414
|
const data = expandToTriangles(mesh);
|
|
415
415
|
const vao = gl.createVertexArray();
|
|
416
416
|
gl.bindVertexArray(vao);
|
|
417
|
+
const buffers = [];
|
|
417
418
|
const attribute = (location, array, size = 3) => {
|
|
418
419
|
if (location < 0) return;
|
|
419
420
|
const buffer = gl.createBuffer();
|
|
421
|
+
buffers.push(buffer);
|
|
420
422
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
421
423
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
422
424
|
gl.enableVertexAttribArray(location);
|
|
@@ -428,7 +430,7 @@ void main() {
|
|
|
428
430
|
attribute(loc.aEmissive, data.emissives);
|
|
429
431
|
attribute(loc.aSpecular, data.speculars, 4);
|
|
430
432
|
gl.bindVertexArray(null);
|
|
431
|
-
const result = { vao, count: data.count };
|
|
433
|
+
const result = { vao, buffers, count: data.count };
|
|
432
434
|
this.cache.set(mesh, result);
|
|
433
435
|
return result;
|
|
434
436
|
}
|
|
@@ -486,7 +488,10 @@ void main() {
|
|
|
486
488
|
destroy() {
|
|
487
489
|
const gl = this.gl;
|
|
488
490
|
if (gl) {
|
|
489
|
-
for (const mesh of this.cache.values())
|
|
491
|
+
for (const mesh of this.cache.values()) {
|
|
492
|
+
gl.deleteVertexArray(mesh.vao);
|
|
493
|
+
for (const buffer of mesh.buffers) gl.deleteBuffer(buffer);
|
|
494
|
+
}
|
|
490
495
|
if (this.program) gl.deleteProgram(this.program);
|
|
491
496
|
}
|
|
492
497
|
this.cache.clear();
|
|
@@ -389,9 +389,11 @@ void main() {
|
|
|
389
389
|
const data = expandToTriangles(mesh);
|
|
390
390
|
const vao = gl.createVertexArray();
|
|
391
391
|
gl.bindVertexArray(vao);
|
|
392
|
+
const buffers = [];
|
|
392
393
|
const attribute = (location, array, size = 3) => {
|
|
393
394
|
if (location < 0) return;
|
|
394
395
|
const buffer = gl.createBuffer();
|
|
396
|
+
buffers.push(buffer);
|
|
395
397
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
396
398
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
397
399
|
gl.enableVertexAttribArray(location);
|
|
@@ -403,7 +405,7 @@ void main() {
|
|
|
403
405
|
attribute(loc.aEmissive, data.emissives);
|
|
404
406
|
attribute(loc.aSpecular, data.speculars, 4);
|
|
405
407
|
gl.bindVertexArray(null);
|
|
406
|
-
const result = { vao, count: data.count };
|
|
408
|
+
const result = { vao, buffers, count: data.count };
|
|
407
409
|
this.cache.set(mesh, result);
|
|
408
410
|
return result;
|
|
409
411
|
}
|
|
@@ -461,7 +463,10 @@ void main() {
|
|
|
461
463
|
destroy() {
|
|
462
464
|
const gl = this.gl;
|
|
463
465
|
if (gl) {
|
|
464
|
-
for (const mesh of this.cache.values())
|
|
466
|
+
for (const mesh of this.cache.values()) {
|
|
467
|
+
gl.deleteVertexArray(mesh.vao);
|
|
468
|
+
for (const buffer of mesh.buffers) gl.deleteBuffer(buffer);
|
|
469
|
+
}
|
|
465
470
|
if (this.program) gl.deleteProgram(this.program);
|
|
466
471
|
}
|
|
467
472
|
this.cache.clear();
|
|
@@ -389,9 +389,11 @@ void main() {
|
|
|
389
389
|
const data = expandToTriangles(mesh);
|
|
390
390
|
const vao = gl.createVertexArray();
|
|
391
391
|
gl.bindVertexArray(vao);
|
|
392
|
+
const buffers = [];
|
|
392
393
|
const attribute = (location, array, size = 3) => {
|
|
393
394
|
if (location < 0) return;
|
|
394
395
|
const buffer = gl.createBuffer();
|
|
396
|
+
buffers.push(buffer);
|
|
395
397
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
396
398
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
397
399
|
gl.enableVertexAttribArray(location);
|
|
@@ -403,7 +405,7 @@ void main() {
|
|
|
403
405
|
attribute(loc.aEmissive, data.emissives);
|
|
404
406
|
attribute(loc.aSpecular, data.speculars, 4);
|
|
405
407
|
gl.bindVertexArray(null);
|
|
406
|
-
const result = { vao, count: data.count };
|
|
408
|
+
const result = { vao, buffers, count: data.count };
|
|
407
409
|
this.cache.set(mesh, result);
|
|
408
410
|
return result;
|
|
409
411
|
}
|
|
@@ -461,7 +463,10 @@ void main() {
|
|
|
461
463
|
destroy() {
|
|
462
464
|
const gl = this.gl;
|
|
463
465
|
if (gl) {
|
|
464
|
-
for (const mesh of this.cache.values())
|
|
466
|
+
for (const mesh of this.cache.values()) {
|
|
467
|
+
gl.deleteVertexArray(mesh.vao);
|
|
468
|
+
for (const buffer of mesh.buffers) gl.deleteBuffer(buffer);
|
|
469
|
+
}
|
|
465
470
|
if (this.program) gl.deleteProgram(this.program);
|
|
466
471
|
}
|
|
467
472
|
this.cache.clear();
|
|
@@ -389,9 +389,11 @@ void main() {
|
|
|
389
389
|
const data = expandToTriangles(mesh);
|
|
390
390
|
const vao = gl.createVertexArray();
|
|
391
391
|
gl.bindVertexArray(vao);
|
|
392
|
+
const buffers = [];
|
|
392
393
|
const attribute = (location, array, size = 3) => {
|
|
393
394
|
if (location < 0) return;
|
|
394
395
|
const buffer = gl.createBuffer();
|
|
396
|
+
buffers.push(buffer);
|
|
395
397
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
396
398
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
397
399
|
gl.enableVertexAttribArray(location);
|
|
@@ -403,7 +405,7 @@ void main() {
|
|
|
403
405
|
attribute(loc.aEmissive, data.emissives);
|
|
404
406
|
attribute(loc.aSpecular, data.speculars, 4);
|
|
405
407
|
gl.bindVertexArray(null);
|
|
406
|
-
const result = { vao, count: data.count };
|
|
408
|
+
const result = { vao, buffers, count: data.count };
|
|
407
409
|
this.cache.set(mesh, result);
|
|
408
410
|
return result;
|
|
409
411
|
}
|
|
@@ -461,7 +463,10 @@ void main() {
|
|
|
461
463
|
destroy() {
|
|
462
464
|
const gl = this.gl;
|
|
463
465
|
if (gl) {
|
|
464
|
-
for (const mesh of this.cache.values())
|
|
466
|
+
for (const mesh of this.cache.values()) {
|
|
467
|
+
gl.deleteVertexArray(mesh.vao);
|
|
468
|
+
for (const buffer of mesh.buffers) gl.deleteBuffer(buffer);
|
|
469
|
+
}
|
|
465
470
|
if (this.program) gl.deleteProgram(this.program);
|
|
466
471
|
}
|
|
467
472
|
this.cache.clear();
|
|
@@ -1403,9 +1408,11 @@ void main() {
|
|
|
1403
1408
|
const data = expandToTriangles(mesh);
|
|
1404
1409
|
const vao = gl.createVertexArray();
|
|
1405
1410
|
gl.bindVertexArray(vao);
|
|
1411
|
+
const buffers = [];
|
|
1406
1412
|
const attribute = (location, array, size) => {
|
|
1407
1413
|
if (location < 0) return;
|
|
1408
1414
|
const buffer = gl.createBuffer();
|
|
1415
|
+
buffers.push(buffer);
|
|
1409
1416
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
1410
1417
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
1411
1418
|
gl.enableVertexAttribArray(location);
|
|
@@ -1415,7 +1422,7 @@ void main() {
|
|
|
1415
1422
|
attribute(loc.aColor, data.colors, 3);
|
|
1416
1423
|
attribute(loc.aUV, planarUVs(mesh), 2);
|
|
1417
1424
|
gl.bindVertexArray(null);
|
|
1418
|
-
const result = { vao, count: data.count };
|
|
1425
|
+
const result = { vao, buffers, count: data.count };
|
|
1419
1426
|
this.buffers.set(mesh, result);
|
|
1420
1427
|
return result;
|
|
1421
1428
|
}
|
|
@@ -1453,7 +1460,10 @@ void main() {
|
|
|
1453
1460
|
const gl = this.gl;
|
|
1454
1461
|
if (gl) {
|
|
1455
1462
|
for (const texture of this.textures.values()) gl.deleteTexture(texture);
|
|
1456
|
-
for (const
|
|
1463
|
+
for (const cached of this.buffers.values()) {
|
|
1464
|
+
gl.deleteVertexArray(cached.vao);
|
|
1465
|
+
for (const buffer of cached.buffers) gl.deleteBuffer(buffer);
|
|
1466
|
+
}
|
|
1457
1467
|
if (this.program) gl.deleteProgram(this.program);
|
|
1458
1468
|
}
|
|
1459
1469
|
this.textures.clear();
|
|
@@ -389,9 +389,11 @@ void main() {
|
|
|
389
389
|
const data = expandToTriangles(mesh);
|
|
390
390
|
const vao = gl.createVertexArray();
|
|
391
391
|
gl.bindVertexArray(vao);
|
|
392
|
+
const buffers = [];
|
|
392
393
|
const attribute = (location, array, size = 3) => {
|
|
393
394
|
if (location < 0) return;
|
|
394
395
|
const buffer = gl.createBuffer();
|
|
396
|
+
buffers.push(buffer);
|
|
395
397
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
396
398
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
397
399
|
gl.enableVertexAttribArray(location);
|
|
@@ -403,7 +405,7 @@ void main() {
|
|
|
403
405
|
attribute(loc.aEmissive, data.emissives);
|
|
404
406
|
attribute(loc.aSpecular, data.speculars, 4);
|
|
405
407
|
gl.bindVertexArray(null);
|
|
406
|
-
const result = { vao, count: data.count };
|
|
408
|
+
const result = { vao, buffers, count: data.count };
|
|
407
409
|
this.cache.set(mesh, result);
|
|
408
410
|
return result;
|
|
409
411
|
}
|
|
@@ -461,7 +463,10 @@ void main() {
|
|
|
461
463
|
destroy() {
|
|
462
464
|
const gl = this.gl;
|
|
463
465
|
if (gl) {
|
|
464
|
-
for (const mesh of this.cache.values())
|
|
466
|
+
for (const mesh of this.cache.values()) {
|
|
467
|
+
gl.deleteVertexArray(mesh.vao);
|
|
468
|
+
for (const buffer of mesh.buffers) gl.deleteBuffer(buffer);
|
|
469
|
+
}
|
|
465
470
|
if (this.program) gl.deleteProgram(this.program);
|
|
466
471
|
}
|
|
467
472
|
this.cache.clear();
|
|
@@ -417,9 +417,11 @@ void main() {
|
|
|
417
417
|
const data = expandToTriangles(mesh);
|
|
418
418
|
const vao = gl.createVertexArray();
|
|
419
419
|
gl.bindVertexArray(vao);
|
|
420
|
+
const buffers = [];
|
|
420
421
|
const attribute = (location, array, size = 3) => {
|
|
421
422
|
if (location < 0) return;
|
|
422
423
|
const buffer = gl.createBuffer();
|
|
424
|
+
buffers.push(buffer);
|
|
423
425
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
424
426
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
425
427
|
gl.enableVertexAttribArray(location);
|
|
@@ -431,7 +433,7 @@ void main() {
|
|
|
431
433
|
attribute(loc.aEmissive, data.emissives);
|
|
432
434
|
attribute(loc.aSpecular, data.speculars, 4);
|
|
433
435
|
gl.bindVertexArray(null);
|
|
434
|
-
const result = { vao, count: data.count };
|
|
436
|
+
const result = { vao, buffers, count: data.count };
|
|
435
437
|
this.cache.set(mesh, result);
|
|
436
438
|
return result;
|
|
437
439
|
}
|
|
@@ -489,7 +491,10 @@ void main() {
|
|
|
489
491
|
destroy() {
|
|
490
492
|
const gl = this.gl;
|
|
491
493
|
if (gl) {
|
|
492
|
-
for (const mesh of this.cache.values())
|
|
494
|
+
for (const mesh of this.cache.values()) {
|
|
495
|
+
gl.deleteVertexArray(mesh.vao);
|
|
496
|
+
for (const buffer of mesh.buffers) gl.deleteBuffer(buffer);
|
|
497
|
+
}
|
|
493
498
|
if (this.program) gl.deleteProgram(this.program);
|
|
494
499
|
}
|
|
495
500
|
this.cache.clear();
|
|
@@ -265,9 +265,11 @@ void main() {
|
|
|
265
265
|
const data = expandToTriangles(mesh);
|
|
266
266
|
const vao = gl.createVertexArray();
|
|
267
267
|
gl.bindVertexArray(vao);
|
|
268
|
+
const buffers = [];
|
|
268
269
|
const attribute = (location, array, size = 3) => {
|
|
269
270
|
if (location < 0) return;
|
|
270
271
|
const buffer = gl.createBuffer();
|
|
272
|
+
buffers.push(buffer);
|
|
271
273
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
272
274
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
273
275
|
gl.enableVertexAttribArray(location);
|
|
@@ -279,7 +281,7 @@ void main() {
|
|
|
279
281
|
attribute(loc.aEmissive, data.emissives);
|
|
280
282
|
attribute(loc.aSpecular, data.speculars, 4);
|
|
281
283
|
gl.bindVertexArray(null);
|
|
282
|
-
const result = { vao, count: data.count };
|
|
284
|
+
const result = { vao, buffers, count: data.count };
|
|
283
285
|
this.cache.set(mesh, result);
|
|
284
286
|
return result;
|
|
285
287
|
}
|
|
@@ -337,7 +339,10 @@ void main() {
|
|
|
337
339
|
destroy() {
|
|
338
340
|
const gl = this.gl;
|
|
339
341
|
if (gl) {
|
|
340
|
-
for (const mesh of this.cache.values())
|
|
342
|
+
for (const mesh of this.cache.values()) {
|
|
343
|
+
gl.deleteVertexArray(mesh.vao);
|
|
344
|
+
for (const buffer of mesh.buffers) gl.deleteBuffer(buffer);
|
|
345
|
+
}
|
|
341
346
|
if (this.program) gl.deleteProgram(this.program);
|
|
342
347
|
}
|
|
343
348
|
this.cache.clear();
|
|
@@ -513,9 +518,11 @@ var WebGLTexturedRenderer = class {
|
|
|
513
518
|
const data = expandToTriangles(mesh);
|
|
514
519
|
const vao = gl.createVertexArray();
|
|
515
520
|
gl.bindVertexArray(vao);
|
|
521
|
+
const buffers = [];
|
|
516
522
|
const attribute = (location, array, size) => {
|
|
517
523
|
if (location < 0) return;
|
|
518
524
|
const buffer = gl.createBuffer();
|
|
525
|
+
buffers.push(buffer);
|
|
519
526
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
520
527
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
521
528
|
gl.enableVertexAttribArray(location);
|
|
@@ -525,7 +532,7 @@ var WebGLTexturedRenderer = class {
|
|
|
525
532
|
attribute(loc.aColor, data.colors, 3);
|
|
526
533
|
attribute(loc.aUV, planarUVs(mesh), 2);
|
|
527
534
|
gl.bindVertexArray(null);
|
|
528
|
-
const result = { vao, count: data.count };
|
|
535
|
+
const result = { vao, buffers, count: data.count };
|
|
529
536
|
this.buffers.set(mesh, result);
|
|
530
537
|
return result;
|
|
531
538
|
}
|
|
@@ -563,7 +570,10 @@ var WebGLTexturedRenderer = class {
|
|
|
563
570
|
const gl = this.gl;
|
|
564
571
|
if (gl) {
|
|
565
572
|
for (const texture of this.textures.values()) gl.deleteTexture(texture);
|
|
566
|
-
for (const
|
|
573
|
+
for (const cached of this.buffers.values()) {
|
|
574
|
+
gl.deleteVertexArray(cached.vao);
|
|
575
|
+
for (const buffer of cached.buffers) gl.deleteBuffer(buffer);
|
|
576
|
+
}
|
|
567
577
|
if (this.program) gl.deleteProgram(this.program);
|
|
568
578
|
}
|
|
569
579
|
this.textures.clear();
|
|
@@ -414,9 +414,11 @@ void main() {
|
|
|
414
414
|
const data = expandToTriangles(mesh);
|
|
415
415
|
const vao = gl.createVertexArray();
|
|
416
416
|
gl.bindVertexArray(vao);
|
|
417
|
+
const buffers = [];
|
|
417
418
|
const attribute = (location, array, size = 3) => {
|
|
418
419
|
if (location < 0) return;
|
|
419
420
|
const buffer = gl.createBuffer();
|
|
421
|
+
buffers.push(buffer);
|
|
420
422
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
421
423
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
422
424
|
gl.enableVertexAttribArray(location);
|
|
@@ -428,7 +430,7 @@ void main() {
|
|
|
428
430
|
attribute(loc.aEmissive, data.emissives);
|
|
429
431
|
attribute(loc.aSpecular, data.speculars, 4);
|
|
430
432
|
gl.bindVertexArray(null);
|
|
431
|
-
const result = { vao, count: data.count };
|
|
433
|
+
const result = { vao, buffers, count: data.count };
|
|
432
434
|
this.cache.set(mesh, result);
|
|
433
435
|
return result;
|
|
434
436
|
}
|
|
@@ -486,7 +488,10 @@ void main() {
|
|
|
486
488
|
destroy() {
|
|
487
489
|
const gl = this.gl;
|
|
488
490
|
if (gl) {
|
|
489
|
-
for (const mesh of this.cache.values())
|
|
491
|
+
for (const mesh of this.cache.values()) {
|
|
492
|
+
gl.deleteVertexArray(mesh.vao);
|
|
493
|
+
for (const buffer of mesh.buffers) gl.deleteBuffer(buffer);
|
|
494
|
+
}
|
|
490
495
|
if (this.program) gl.deleteProgram(this.program);
|
|
491
496
|
}
|
|
492
497
|
this.cache.clear();
|
|
@@ -1428,9 +1433,11 @@ void main() {
|
|
|
1428
1433
|
const data = expandToTriangles(mesh);
|
|
1429
1434
|
const vao = gl.createVertexArray();
|
|
1430
1435
|
gl.bindVertexArray(vao);
|
|
1436
|
+
const buffers = [];
|
|
1431
1437
|
const attribute = (location, array, size) => {
|
|
1432
1438
|
if (location < 0) return;
|
|
1433
1439
|
const buffer = gl.createBuffer();
|
|
1440
|
+
buffers.push(buffer);
|
|
1434
1441
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
1435
1442
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
1436
1443
|
gl.enableVertexAttribArray(location);
|
|
@@ -1440,7 +1447,7 @@ void main() {
|
|
|
1440
1447
|
attribute(loc.aColor, data.colors, 3);
|
|
1441
1448
|
attribute(loc.aUV, planarUVs(mesh), 2);
|
|
1442
1449
|
gl.bindVertexArray(null);
|
|
1443
|
-
const result = { vao, count: data.count };
|
|
1450
|
+
const result = { vao, buffers, count: data.count };
|
|
1444
1451
|
this.buffers.set(mesh, result);
|
|
1445
1452
|
return result;
|
|
1446
1453
|
}
|
|
@@ -1478,7 +1485,10 @@ void main() {
|
|
|
1478
1485
|
const gl = this.gl;
|
|
1479
1486
|
if (gl) {
|
|
1480
1487
|
for (const texture of this.textures.values()) gl.deleteTexture(texture);
|
|
1481
|
-
for (const
|
|
1488
|
+
for (const cached of this.buffers.values()) {
|
|
1489
|
+
gl.deleteVertexArray(cached.vao);
|
|
1490
|
+
for (const buffer of cached.buffers) gl.deleteBuffer(buffer);
|
|
1491
|
+
}
|
|
1482
1492
|
if (this.program) gl.deleteProgram(this.program);
|
|
1483
1493
|
}
|
|
1484
1494
|
this.textures.clear();
|
|
@@ -141,10 +141,12 @@ export class WebGLTexturedRenderer {
|
|
|
141
141
|
const data = expandToTriangles(mesh);
|
|
142
142
|
const vao = gl.createVertexArray();
|
|
143
143
|
gl.bindVertexArray(vao);
|
|
144
|
+
const buffers = [];
|
|
144
145
|
const attribute = (location, array, size) => {
|
|
145
146
|
if (location < 0)
|
|
146
147
|
return;
|
|
147
148
|
const buffer = gl.createBuffer();
|
|
149
|
+
buffers.push(buffer);
|
|
148
150
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
149
151
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
150
152
|
gl.enableVertexAttribArray(location);
|
|
@@ -154,7 +156,7 @@ export class WebGLTexturedRenderer {
|
|
|
154
156
|
attribute(loc.aColor, data.colors, 3);
|
|
155
157
|
attribute(loc.aUV, planarUVs(mesh), 2);
|
|
156
158
|
gl.bindVertexArray(null);
|
|
157
|
-
const result = { vao, count: data.count };
|
|
159
|
+
const result = { vao, buffers, count: data.count };
|
|
158
160
|
this.buffers.set(mesh, result);
|
|
159
161
|
return result;
|
|
160
162
|
}
|
|
@@ -195,8 +197,11 @@ export class WebGLTexturedRenderer {
|
|
|
195
197
|
if (gl) {
|
|
196
198
|
for (const texture of this.textures.values())
|
|
197
199
|
gl.deleteTexture(texture);
|
|
198
|
-
for (const
|
|
199
|
-
gl.deleteVertexArray(
|
|
200
|
+
for (const cached of this.buffers.values()) {
|
|
201
|
+
gl.deleteVertexArray(cached.vao);
|
|
202
|
+
for (const buffer of cached.buffers)
|
|
203
|
+
gl.deleteBuffer(buffer);
|
|
204
|
+
}
|
|
200
205
|
if (this.program)
|
|
201
206
|
gl.deleteProgram(this.program);
|
|
202
207
|
}
|
|
@@ -122,10 +122,12 @@ export class WebGLRenderer {
|
|
|
122
122
|
const data = expandToTriangles(mesh);
|
|
123
123
|
const vao = gl.createVertexArray();
|
|
124
124
|
gl.bindVertexArray(vao);
|
|
125
|
+
const buffers = [];
|
|
125
126
|
const attribute = (location, array, size = 3) => {
|
|
126
127
|
if (location < 0)
|
|
127
128
|
return;
|
|
128
129
|
const buffer = gl.createBuffer();
|
|
130
|
+
buffers.push(buffer);
|
|
129
131
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
130
132
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
131
133
|
gl.enableVertexAttribArray(location);
|
|
@@ -137,7 +139,7 @@ export class WebGLRenderer {
|
|
|
137
139
|
attribute(loc.aEmissive, data.emissives);
|
|
138
140
|
attribute(loc.aSpecular, data.speculars, 4);
|
|
139
141
|
gl.bindVertexArray(null);
|
|
140
|
-
const result = { vao, count: data.count };
|
|
142
|
+
const result = { vao, buffers, count: data.count };
|
|
141
143
|
this.cache.set(mesh, result);
|
|
142
144
|
return result;
|
|
143
145
|
}
|
|
@@ -199,8 +201,11 @@ export class WebGLRenderer {
|
|
|
199
201
|
destroy() {
|
|
200
202
|
const gl = this.gl;
|
|
201
203
|
if (gl) {
|
|
202
|
-
for (const mesh of this.cache.values())
|
|
204
|
+
for (const mesh of this.cache.values()) {
|
|
203
205
|
gl.deleteVertexArray(mesh.vao);
|
|
206
|
+
for (const buffer of mesh.buffers)
|
|
207
|
+
gl.deleteBuffer(buffer);
|
|
208
|
+
}
|
|
204
209
|
if (this.program)
|
|
205
210
|
gl.deleteProgram(this.program);
|
|
206
211
|
}
|
|
@@ -417,9 +417,11 @@ void main() {
|
|
|
417
417
|
const data = expandToTriangles(mesh);
|
|
418
418
|
const vao = gl.createVertexArray();
|
|
419
419
|
gl.bindVertexArray(vao);
|
|
420
|
+
const buffers = [];
|
|
420
421
|
const attribute = (location, array, size = 3) => {
|
|
421
422
|
if (location < 0) return;
|
|
422
423
|
const buffer = gl.createBuffer();
|
|
424
|
+
buffers.push(buffer);
|
|
423
425
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
424
426
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
425
427
|
gl.enableVertexAttribArray(location);
|
|
@@ -431,7 +433,7 @@ void main() {
|
|
|
431
433
|
attribute(loc.aEmissive, data.emissives);
|
|
432
434
|
attribute(loc.aSpecular, data.speculars, 4);
|
|
433
435
|
gl.bindVertexArray(null);
|
|
434
|
-
const result = { vao, count: data.count };
|
|
436
|
+
const result = { vao, buffers, count: data.count };
|
|
435
437
|
this.cache.set(mesh, result);
|
|
436
438
|
return result;
|
|
437
439
|
}
|
|
@@ -489,7 +491,10 @@ void main() {
|
|
|
489
491
|
destroy() {
|
|
490
492
|
const gl = this.gl;
|
|
491
493
|
if (gl) {
|
|
492
|
-
for (const mesh of this.cache.values())
|
|
494
|
+
for (const mesh of this.cache.values()) {
|
|
495
|
+
gl.deleteVertexArray(mesh.vao);
|
|
496
|
+
for (const buffer of mesh.buffers) gl.deleteBuffer(buffer);
|
|
497
|
+
}
|
|
493
498
|
if (this.program) gl.deleteProgram(this.program);
|
|
494
499
|
}
|
|
495
500
|
this.cache.clear();
|
|
@@ -1431,9 +1436,11 @@ void main() {
|
|
|
1431
1436
|
const data = expandToTriangles(mesh);
|
|
1432
1437
|
const vao = gl.createVertexArray();
|
|
1433
1438
|
gl.bindVertexArray(vao);
|
|
1439
|
+
const buffers = [];
|
|
1434
1440
|
const attribute = (location, array, size) => {
|
|
1435
1441
|
if (location < 0) return;
|
|
1436
1442
|
const buffer = gl.createBuffer();
|
|
1443
|
+
buffers.push(buffer);
|
|
1437
1444
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
1438
1445
|
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
|
|
1439
1446
|
gl.enableVertexAttribArray(location);
|
|
@@ -1443,7 +1450,7 @@ void main() {
|
|
|
1443
1450
|
attribute(loc.aColor, data.colors, 3);
|
|
1444
1451
|
attribute(loc.aUV, planarUVs(mesh), 2);
|
|
1445
1452
|
gl.bindVertexArray(null);
|
|
1446
|
-
const result = { vao, count: data.count };
|
|
1453
|
+
const result = { vao, buffers, count: data.count };
|
|
1447
1454
|
this.buffers.set(mesh, result);
|
|
1448
1455
|
return result;
|
|
1449
1456
|
}
|
|
@@ -1481,7 +1488,10 @@ void main() {
|
|
|
1481
1488
|
const gl = this.gl;
|
|
1482
1489
|
if (gl) {
|
|
1483
1490
|
for (const texture of this.textures.values()) gl.deleteTexture(texture);
|
|
1484
|
-
for (const
|
|
1491
|
+
for (const cached of this.buffers.values()) {
|
|
1492
|
+
gl.deleteVertexArray(cached.vao);
|
|
1493
|
+
for (const buffer of cached.buffers) gl.deleteBuffer(buffer);
|
|
1494
|
+
}
|
|
1485
1495
|
if (this.program) gl.deleteProgram(this.program);
|
|
1486
1496
|
}
|
|
1487
1497
|
this.textures.clear();
|
|
@@ -1633,6 +1643,7 @@ void main() {
|
|
|
1633
1643
|
var stdin_exports = {};
|
|
1634
1644
|
__export(stdin_exports, {
|
|
1635
1645
|
Camera: () => Camera,
|
|
1646
|
+
Canvas2DTexturedRenderer: () => Canvas2DTexturedRenderer,
|
|
1636
1647
|
ChargedOrbAnimation: () => ChargedOrbAnimation,
|
|
1637
1648
|
CompositeAnimation: () => CompositeAnimation,
|
|
1638
1649
|
GridAssemblyAnimation: () => GridAssemblyAnimation,
|
|
@@ -4803,6 +4814,7 @@ void main() {
|
|
|
4803
4814
|
|
|
4804
4815
|
// <stdin>
|
|
4805
4816
|
init_webgl_textured();
|
|
4817
|
+
init_canvas2d_textured();
|
|
4806
4818
|
init_webgpu_textured();
|
|
4807
4819
|
|
|
4808
4820
|
// src/engines/little-3d-engine/loaders/obj.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Spinner3D=(()=>{var
|
|
1
|
+
var Spinner3D=(()=>{var yt=Object.defineProperty;var ki=Object.getOwnPropertyDescriptor;var Di=Object.getOwnPropertyNames;var ji=Object.prototype.hasOwnProperty;var U=(n,e,t)=>()=>{if(t)throw t[0];try{return n&&(e=n(n=0)),e}catch(i){throw t=[i],i}};var le=(n,e)=>{for(var t in e)yt(n,t,{get:e[t],enumerable:!0})},Bi=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Di(e))!ji.call(n,r)&&r!==t&&yt(n,r,{get:()=>e[r],enumerable:!(i=ki(e,r))||i.enumerable});return n};var Ui=n=>Bi(yt({},"__esModule",{value:!0}),n);function fn(n,e,t){return{x:n,y:e,z:t}}function S(n,e){return{x:n.x-e.x,y:n.y-e.y,z:n.z-e.z}}function T(n,e){return{x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x}}function W(n,e){return n.x*e.x+n.y*e.y+n.z*e.z}function V(n,e){return{x:n.x*e,y:n.y*e,z:n.z*e}}function g(n){let e=Math.hypot(n.x,n.y,n.z);return e===0?{x:0,y:0,z:0}:{x:n.x/e,y:n.y/e,z:n.z/e}}function z(n,e){let t=new Array(16);for(let i=0;i<4;i++)for(let r=0;r<4;r++){let o=0;for(let s=0;s<4;s++)o+=n[s*4+r]*e[i*4+s];t[i*4+r]=o}return t}function Ae(n,e,t){return[1,0,0,0,0,1,0,0,0,0,1,0,n,e,t,1]}function bn(n){return[n,0,0,0,0,n,0,0,0,0,n,0,0,0,0,1]}function Ve(n){let e=Math.cos(n),t=Math.sin(n);return[1,0,0,0,0,e,t,0,0,-t,e,0,0,0,0,1]}function ke(n){let e=Math.cos(n),t=Math.sin(n);return[e,0,-t,0,0,1,0,0,t,0,e,0,0,0,0,1]}function De(n){let e=Math.cos(n),t=Math.sin(n);return[e,t,0,0,-t,e,0,0,0,0,1,0,0,0,0,1]}function yn(n,e,t,i){let r=1/Math.tan(n/2),o=1/(t-i);return[r/e,0,0,0,0,r,0,0,0,0,(i+t)*o,-1,0,0,2*i*t*o,0]}function je(n,e){let t=n[0]*e.x+n[4]*e.y+n[8]*e.z+n[12],i=n[1]*e.x+n[5]*e.y+n[9]*e.z+n[13],r=n[2]*e.x+n[6]*e.y+n[10]*e.z+n[14],o=n[3]*e.x+n[7]*e.y+n[11]*e.z+n[15]||1;return{x:t/o,y:i/o,z:r/o}}function fe(n,e){return{x:n[0]*e.x+n[4]*e.y+n[8]*e.z+n[12],y:n[1]*e.x+n[5]*e.y+n[9]*e.z+n[13],z:n[2]*e.x+n[6]*e.y+n[10]*e.z+n[14]}}var N=U(()=>{"use strict"});function ue(n){let e=n.trim().replace("#",""),t=e.length===3?e.split("").map(r=>r+r).join(""):e,i=parseInt(t,16);return[i>>16&255,i>>8&255,i&255]}function X(n){let e=0;for(let l of n.faces)e+=Math.max(0,l.indices.length-2);let t=new Float32Array(e*9),i=new Float32Array(e*9),r=new Float32Array(e*9),o=new Float32Array(e*9),s=new Float32Array(e*12),a=0,c=0;for(let l of n.faces){let u=n.vertices[l.indices[0]],p=n.vertices[l.indices[1]],d=n.vertices[l.indices[2]],h=g(T(S(p,u),S(d,u))),[m,b,f]=ue(l.color),y=m/255,M=b/255,x=f/255,v=l.material?.emissive,I=v?v[0]:0,E=v?v[1]:0,_=v?v[2]:0,B=l.material?.specular,Ci=B?B[0]:0,Ri=B?B[1]:0,wi=B?B[2]:0,Fi=B?l.material?.shininess??32:1;for(let _e=1;_e<l.indices.length-1;_e++){let _i=[l.indices[0],l.indices[_e],l.indices[_e+1]];for(let Vi of _i){let bt=n.vertices[Vi];t[a]=bt.x,t[a+1]=bt.y,t[a+2]=bt.z,i[a]=h.x,i[a+1]=h.y,i[a+2]=h.z,r[a]=y,r[a+1]=M,r[a+2]=x,o[a]=I,o[a+1]=E,o[a+2]=_,s[c]=Ci,s[c+1]=Ri,s[c+2]=wi,s[c+3]=Fi,a+=3,c+=4}}}return{positions:t,normals:i,colors:r,emissives:o,speculars:s,count:t.length/3}}function xt(n,e){return{x:(n.x+e.x)/2,y:(n.y+e.y)/2,z:(n.z+e.z)/2}}function Be(n,e,t,i,r){let o=t/2,s=e.map(u=>u.map(p=>g(n[p]))),a=Math.max(0,Math.floor(i)-1);for(let u=0;u<a;u++){let p=[];for(let[d,h,m]of s){let b=g(xt(d,h)),f=g(xt(h,m)),y=g(xt(m,d));p.push([d,b,y],[h,f,b],[m,y,f],[b,f,y])}s=p}let c=[],l=s.map((u,p)=>{let d=c.length;return c.push(V(u[0],o),V(u[1],o),V(u[2],o)),{indices:[d,d+1,d+2],color:r[p%r.length]}});return{vertices:c,faces:l}}var $=U(()=>{"use strict";N()});function Xi(n){return Math.min(1,Math.max(0,n))}function Mt(n){return Math.round(Math.min(255,Math.max(0,n)))}function Yi(n,e,t,i){let r=Math.max(0,W(n,t.toLight)),o=Xi(t.ambient+t.intensity*r),[s,a,c]=ue(e),l=s*o,u=a*o,p=c*o,d=i?.material,h=d?.specular,m=i?.viewDir;if(h&&m&&r>0){let f=g({x:t.toLight.x+m.x,y:t.toLight.y+m.y,z:t.toLight.z+m.z}),y=d?.shininess??32,M=Math.pow(Math.max(0,W(n,f)),y)*t.intensity*255;l+=M*h[0],u+=M*h[1],p+=M*h[2]}let b=d?.emissive;return b&&(l+=b[0]*255,u+=b[1]*255,p+=b[2]*255),[Mt(l),Mt(u),Mt(p)]}function gt(n,e,t,i){let[r,o,s]=Yi(n,e,t,i);return`rgb(${r}, ${o}, ${s})`}var Wi,ye,Ue=U(()=>{"use strict";N();$();Wi={direction:{x:-.4,y:-.7,z:-.6},intensity:.85,ambient:.25};ye=class{constructor(e){this.options={...Wi,...e},this.params={toLight:g(V(this.options.direction,-1)),intensity:this.options.intensity,ambient:this.options.ambient}}shade(e,t,i){return gt(e,t,this.params,i)}}});var Mn={};le(Mn,{WebGLRenderer:()=>Oe});function xn(n,e,t){let i=n.createShader(e);if(n.shaderSource(i,t),n.compileShader(i),!n.getShaderParameter(i,n.COMPILE_STATUS))throw new Error(`3d-spinner: shader compile failed: ${n.getShaderInfoLog(i)}`);return i}function Ki(n){let e=n.createProgram();if(n.attachShader(e,xn(n,n.VERTEX_SHADER,qi)),n.attachShader(e,xn(n,n.FRAGMENT_SHADER,Qi)),n.linkProgram(e),!n.getProgramParameter(e,n.LINK_STATUS))throw new Error(`3d-spinner: program link failed: ${n.getProgramInfoLog(e)}`);return e}var qi,Qi,Oe,vt=U(()=>{"use strict";$();J();qi=`#version 300 es
|
|
2
2
|
in vec3 aPos;
|
|
3
3
|
in vec3 aNormal;
|
|
4
4
|
in vec3 aColor;
|
|
@@ -46,7 +46,7 @@ void main() {
|
|
|
46
46
|
}
|
|
47
47
|
lit += vEmissive;
|
|
48
48
|
fragColor = vec4(lit, uOpacity);
|
|
49
|
-
}`;Oe=class{constructor(e={}){this.cache=new Map;if(e.background){let[t,i,r]=ue(e.background);this.clearColor=[t/255,i/255,r/255,1]}else this.clearColor=[0,0,0,0]}init(e){let t=e.getContext("webgl2");if(!t)throw new Error("3d-spinner: WebGL2 is not supported in this browser.");this.gl=t,this.program=Ki(t),this.locations={aPos:t.getAttribLocation(this.program,"aPos"),aNormal:t.getAttribLocation(this.program,"aNormal"),aColor:t.getAttribLocation(this.program,"aColor"),aEmissive:t.getAttribLocation(this.program,"aEmissive"),aSpecular:t.getAttribLocation(this.program,"aSpecular"),uViewProj:t.getUniformLocation(this.program,"uViewProj"),uModel:t.getUniformLocation(this.program,"uModel"),uToLight:t.getUniformLocation(this.program,"uToLight"),uEye:t.getUniformLocation(this.program,"uEye"),uIntensity:t.getUniformLocation(this.program,"uIntensity"),uAmbient:t.getUniformLocation(this.program,"uAmbient"),uOpacity:t.getUniformLocation(this.program,"uOpacity")},t.enable(t.DEPTH_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t.frontFace(t.CCW)}resize(){let e=this.gl;if(!e)return;let t=e.canvas;e.viewport(0,0,t.width,t.height)}buffers(e){let t=this.cache.get(e);if(t)return t;let i=this.gl,r=this.locations,o=X(e),s=i.createVertexArray();i.bindVertexArray(s);let a=(
|
|
49
|
+
}`;Oe=class{constructor(e={}){this.cache=new Map;if(e.background){let[t,i,r]=ue(e.background);this.clearColor=[t/255,i/255,r/255,1]}else this.clearColor=[0,0,0,0]}init(e){let t=e.getContext("webgl2");if(!t)throw new Error("3d-spinner: WebGL2 is not supported in this browser.");this.gl=t,this.program=Ki(t),this.locations={aPos:t.getAttribLocation(this.program,"aPos"),aNormal:t.getAttribLocation(this.program,"aNormal"),aColor:t.getAttribLocation(this.program,"aColor"),aEmissive:t.getAttribLocation(this.program,"aEmissive"),aSpecular:t.getAttribLocation(this.program,"aSpecular"),uViewProj:t.getUniformLocation(this.program,"uViewProj"),uModel:t.getUniformLocation(this.program,"uModel"),uToLight:t.getUniformLocation(this.program,"uToLight"),uEye:t.getUniformLocation(this.program,"uEye"),uIntensity:t.getUniformLocation(this.program,"uIntensity"),uAmbient:t.getUniformLocation(this.program,"uAmbient"),uOpacity:t.getUniformLocation(this.program,"uOpacity")},t.enable(t.DEPTH_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t.frontFace(t.CCW)}resize(){let e=this.gl;if(!e)return;let t=e.canvas;e.viewport(0,0,t.width,t.height)}buffers(e){let t=this.cache.get(e);if(t)return t;let i=this.gl,r=this.locations,o=X(e),s=i.createVertexArray();i.bindVertexArray(s);let a=[],c=(u,p,d=3)=>{if(u<0)return;let h=i.createBuffer();a.push(h),i.bindBuffer(i.ARRAY_BUFFER,h),i.bufferData(i.ARRAY_BUFFER,p,i.STATIC_DRAW),i.enableVertexAttribArray(u),i.vertexAttribPointer(u,d,i.FLOAT,!1,0,0)};c(r.aPos,o.positions),c(r.aNormal,o.normals),c(r.aColor,o.colors),c(r.aEmissive,o.emissives),c(r.aSpecular,o.speculars,4),i.bindVertexArray(null);let l={vao:s,buffers:a,count:o.count};return this.cache.set(e,l),l}render(e){let t=this.gl,i=this.locations;if(!(!t||!this.program||!i)){t.clearColor(...this.clearColor),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),t.useProgram(this.program),t.uniformMatrix4fv(i.uViewProj,!1,new Float32Array(e.viewProjection)),t.uniform3f(i.uToLight,e.light.toLight.x,e.light.toLight.y,e.light.toLight.z),t.uniform3f(i.uEye,e.eye.x,e.eye.y,e.eye.z),t.uniform1f(i.uIntensity,e.light.intensity),t.uniform1f(i.uAmbient,e.light.ambient),t.disable(t.BLEND),t.depthMask(!0),t.cullFace(t.BACK);for(let r of e.items){if(r.transparency)continue;let o=this.buffers(r.mesh);t.uniformMatrix4fv(i.uModel,!1,new Float32Array(r.model)),t.uniform1f(i.uOpacity,1),t.bindVertexArray(o.vao),t.drawArrays(t.TRIANGLES,0,o.count)}t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.depthMask(!1);for(let r of e.items){let o=r.transparency;if(!o)continue;let s=this.buffers(r.mesh);if(t.uniformMatrix4fv(i.uModel,!1,new Float32Array(r.model)),t.bindVertexArray(s.vao),o.mode==="two-sided"){let a=Y(o);t.cullFace(t.FRONT),t.uniform1f(i.uOpacity,a.back),t.drawArrays(t.TRIANGLES,0,s.count),t.cullFace(t.BACK),t.uniform1f(i.uOpacity,a.front),t.drawArrays(t.TRIANGLES,0,s.count)}else t.cullFace(t.BACK),t.uniform1f(i.uOpacity,F(o.opacity,.35)),t.drawArrays(t.TRIANGLES,0,s.count)}t.depthMask(!0),t.disable(t.BLEND),t.cullFace(t.BACK),t.bindVertexArray(null)}}destroy(){let e=this.gl;if(e){for(let t of this.cache.values()){e.deleteVertexArray(t.vao);for(let i of t.buffers)e.deleteBuffer(i)}this.program&&e.deleteProgram(this.program)}this.cache.clear(),this.gl=void 0,this.program=void 0,this.locations=void 0}}});var gn={};le(gn,{WebGPURenderer:()=>Te});var Zi,$i,Ge,Te,At=U(()=>{"use strict";$();N();J();Zi=`
|
|
50
50
|
struct Uniforms {
|
|
51
51
|
viewProj: mat4x4<f32>,
|
|
52
52
|
model: mat4x4<f32>,
|
|
@@ -95,7 +95,7 @@ fn fs(in: VSOut) -> @location(0) vec4<f32> {
|
|
|
95
95
|
lit = lit + in.emissive;
|
|
96
96
|
return vec4<f32>(lit, u.params.z);
|
|
97
97
|
}
|
|
98
|
-
`,$i=[1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1],Ge=256,Te=class{constructor(e={}){this.uniformCapacity=0;this.depthSize="";this.destroyed=!1;this.cache=new Map;if(e.background){let[t,i,r]=ue(e.background);this.clearValue={r:t/255,g:i/255,b:r/255,a:1},this.alphaMode="opaque"}else this.clearValue={r:0,g:0,b:0,a:0},this.alphaMode="premultiplied"}async init(e){let t=navigator.gpu;if(!t)throw new Error("3d-spinner: WebGPU is not supported in this browser.");let i=await t.requestAdapter();if(!i)throw new Error("3d-spinner: no WebGPU adapter is available.");let r=await i.requestDevice();if(this.destroyed){r.destroy?.();return}let o=e.getContext("webgpu");if(!o)throw new Error("3d-spinner: could not get a WebGPU canvas context.");let s=t.getPreferredCanvasFormat();o.configure({device:r,format:s,alphaMode:this.alphaMode});let a=r.createShaderModule({code:Zi}),c=globalThis.GPUShaderStage,l=r.createBindGroupLayout({entries:[{binding:0,visibility:c.VERTEX|c.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0,minBindingSize:176}}]}),u=(m,b=3)=>({arrayStride:b*4,attributes:[{shaderLocation:m,offset:0,format:`float32x${b}`}]}),p=r.createPipelineLayout({bindGroupLayouts:[l]}),
|
|
98
|
+
`,$i=[1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1],Ge=256,Te=class{constructor(e={}){this.uniformCapacity=0;this.depthSize="";this.destroyed=!1;this.cache=new Map;if(e.background){let[t,i,r]=ue(e.background);this.clearValue={r:t/255,g:i/255,b:r/255,a:1},this.alphaMode="opaque"}else this.clearValue={r:0,g:0,b:0,a:0},this.alphaMode="premultiplied"}async init(e){let t=navigator.gpu;if(!t)throw new Error("3d-spinner: WebGPU is not supported in this browser.");let i=await t.requestAdapter();if(!i)throw new Error("3d-spinner: no WebGPU adapter is available.");let r=await i.requestDevice();if(this.destroyed){r.destroy?.();return}let o=e.getContext("webgpu");if(!o)throw new Error("3d-spinner: could not get a WebGPU canvas context.");let s=t.getPreferredCanvasFormat();o.configure({device:r,format:s,alphaMode:this.alphaMode});let a=r.createShaderModule({code:Zi}),c=globalThis.GPUShaderStage,l=r.createBindGroupLayout({entries:[{binding:0,visibility:c.VERTEX|c.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0,minBindingSize:176}}]}),u=(m,b=3)=>({arrayStride:b*4,attributes:[{shaderLocation:m,offset:0,format:`float32x${b}`}]}),p=r.createPipelineLayout({bindGroupLayouts:[l]}),d={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},h=(m,b)=>r.createRenderPipeline({layout:p,vertex:{module:a,entryPoint:"vs",buffers:[u(0),u(1),u(2),u(3),u(4,4)]},fragment:{module:a,entryPoint:"fs",targets:[{format:s,...b?{blend:d}:{}}]},primitive:{topology:"triangle-list",cullMode:m,frontFace:"ccw"},depthStencil:{format:"depth24plus",depthWriteEnabled:!b,depthCompare:"less"}});this.pipeline=h("back",!1),this.transparentBackPipeline=h("front",!0),this.transparentFrontPipeline=h("back",!0),this.canvas=e,this.device=r,this.context=o}resize(){this.ensureDepth()}ensureDepth(){let e=this.canvas;if(!this.device||!e)return;let t=Math.max(1,e.width),i=Math.max(1,e.height),r=`${t}x${i}`;r===this.depthSize&&this.depthTexture||(this.depthTexture?.destroy?.(),this.depthTexture=this.device.createTexture({size:{width:t,height:i},format:"depth24plus",usage:globalThis.GPUTextureUsage.RENDER_ATTACHMENT}),this.depthSize=r)}buffers(e){let t=this.cache.get(e);if(t)return t;let i=X(e),r=globalThis.GPUBufferUsage.VERTEX|globalThis.GPUBufferUsage.COPY_DST,o=a=>{let c=this.device.createBuffer({size:a.byteLength,usage:r});return this.device.queue.writeBuffer(c,0,a),c},s={position:o(i.positions),normal:o(i.normals),color:o(i.colors),emissive:o(i.emissives),specular:o(i.speculars),count:i.count};return this.cache.set(e,s),s}ensureUniformCapacity(e){e<=this.uniformCapacity&&this.uniformBuffer||(this.uniformBuffer?.destroy?.(),this.uniformBuffer=this.device.createBuffer({size:Math.max(1,e)*Ge,usage:globalThis.GPUBufferUsage.UNIFORM|globalThis.GPUBufferUsage.COPY_DST}),this.uniformCapacity=e)}render(e){if(this.destroyed||!this.device||!this.context||!this.pipeline||e.width===0||e.height===0||e.items.length===0)return;this.ensureDepth();let t=[];for(let c of e.items)c.transparency||t.push({item:c,opacity:1,pipeline:this.pipeline});for(let c of e.items){let l=c.transparency;if(l)if(l.mode==="two-sided"){let u=Y(l);t.push({item:c,opacity:u.back,pipeline:this.transparentBackPipeline}),t.push({item:c,opacity:u.front,pipeline:this.transparentFrontPipeline})}else t.push({item:c,opacity:F(l.opacity,.35),pipeline:this.transparentFrontPipeline})}this.ensureUniformCapacity(t.length);let i=z($i,e.viewProjection),r=this.pipeline.getBindGroupLayout(0),o=this.device.createBindGroup({layout:r,entries:[{binding:0,resource:{buffer:this.uniformBuffer,offset:0,size:176}}]});t.forEach((c,l)=>{let u=new Float32Array(Ge/4);u.set(i,0),u.set(c.item.model,16),u.set([e.light.toLight.x,e.light.toLight.y,e.light.toLight.z,0],32),u.set([e.light.intensity,e.light.ambient,c.opacity,0],36),u.set([e.eye.x,e.eye.y,e.eye.z,0],40),this.device.queue.writeBuffer(this.uniformBuffer,l*Ge,u)});let s=this.device.createCommandEncoder(),a=s.beginRenderPass({colorAttachments:[{view:this.context.getCurrentTexture().createView(),clearValue:this.clearValue,loadOp:"clear",storeOp:"store"}],depthStencilAttachment:{view:this.depthTexture.createView(),depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}});t.forEach((c,l)=>{let u=this.buffers(c.item.mesh);a.setPipeline(c.pipeline),a.setBindGroup(0,o,[l*Ge]),a.setVertexBuffer(0,u.position),a.setVertexBuffer(1,u.normal),a.setVertexBuffer(2,u.color),a.setVertexBuffer(3,u.emissive),a.setVertexBuffer(4,u.specular),a.draw(u.count)}),a.end(),this.device.queue.submit([s.finish()])}destroy(){this.destroyed=!0;for(let e of this.cache.values())e.position.destroy?.(),e.normal.destroy?.(),e.color.destroy?.(),e.emissive.destroy?.(),e.specular.destroy?.();this.cache.clear(),this.uniformBuffer?.destroy?.(),this.depthTexture?.destroy?.(),this.device?.destroy?.(),this.device=void 0,this.context=void 0,this.pipeline=void 0,this.transparentBackPipeline=void 0,this.transparentFrontPipeline=void 0,this.uniformBuffer=void 0,this.depthTexture=void 0,this.canvas=void 0}}});var vn={};le(vn,{Canvas2DRenderer:()=>Se});var Se,Ot=U(()=>{"use strict";Ue();N();J();Se=class{constructor(e={}){this.options=e;this.dpr=1}init(e){this.ctx=e.getContext("2d")??void 0}resize(e,t,i){this.dpr=i,this.ctx?.setTransform(i,0,0,i,0,0)}render(e){let t=this.ctx;if(!t)return;this.options.background?(t.fillStyle=this.options.background,t.fillRect(0,0,e.width,e.height)):t.clearRect(0,0,e.width,e.height);let i=[];for(let r of e.items){let o=r.mesh.vertices.map(a=>fe(r.model,a)),s=r.transparency?.mode==="two-sided"?Y(r.transparency):void 0;for(let a of r.mesh.faces){let c=o[a.indices[0]],l=o[a.indices[1]],u=o[a.indices[2]],p=g(T(S(l,c),S(u,c))),d=W(p,S(e.eye,c))>0,h=r.transparency;if(!d&&h?.mode!=="two-sided")continue;let m=1;h?.mode==="one-sided"?m=F(h.opacity,.35):s&&(m=d?s.front:s.back);let b=a.indices.map(x=>{let v=je(e.viewProjection,o[x]);return{x:(v.x*.5+.5)*e.width,y:(1-(v.y*.5+.5))*e.height}}),f=0;for(let x of a.indices){let v=S(o[x],e.eye);f+=W(v,v)}f/=a.indices.length;let y,M=a.material;if(M)if(M.specular){let x=0,v=0,I=0;for(let B of a.indices)x+=o[B].x,v+=o[B].y,I+=o[B].z;let E=1/a.indices.length,_=g(S(e.eye,{x:x*E,y:v*E,z:I*E}));y={material:M,viewDir:_}}else y={material:M};i.push({points:b,color:gt(p,a.color,e.light,y),depth:f,opacity:m})}}i.sort((r,o)=>o.depth-r.depth);for(let r of i)if(!(r.points.length<3)){t.beginPath(),t.moveTo(r.points[0].x,r.points[0].y);for(let o=1;o<r.points.length;o++)t.lineTo(r.points[o].x,r.points[o].y);t.closePath(),t.fillStyle=r.color,t.strokeStyle=r.color,t.lineWidth=1,t.globalAlpha=r.opacity,t.fill(),t.stroke()}t.globalAlpha=1}destroy(){this.ctx=void 0}}});function F(n,e){return Math.max(0,Math.min(1,n??e))}function Y(n){let e=F(n.frontOpacity??n.opacity,.56),t=n.opacity===void 0?.84:e*(2/3);return{front:e,back:F(n.backOpacity,t)}}function He(n,e){let t=[],i=[];for(let r of n)(r.transparency?i:t).push(r);return i.sort((r,o)=>{let s=r.model[12]-e.x,a=r.model[13]-e.y,c=r.model[14]-e.z,l=o.model[12]-e.x,u=o.model[13]-e.y,p=o.model[14]-e.z;return l*l+u*u+p*p-(s*s+a*a+c*c)}),t.concat(i)}async function An(n,e={}){if(typeof n=="function")return n(e);switch(n){case"webgl":return new(await Promise.resolve().then(()=>(vt(),Mn))).WebGLRenderer(e);case"webgpu":return new(await Promise.resolve().then(()=>(At(),gn))).WebGPURenderer(e);default:return new(await Promise.resolve().then(()=>(Ot(),vn))).Canvas2DRenderer(e)}}var J=U(()=>{"use strict"});function et(n){let e=1/0,t=1/0,i=-1/0,r=-1/0;for(let u of n.vertices)e=Math.min(e,u.x),t=Math.min(t,u.y),i=Math.max(i,u.x),r=Math.max(r,u.y);let o=i-e||1,s=r-t||1,a=0;for(let u of n.faces)a+=Math.max(0,u.indices.length-2);let c=new Float32Array(a*6),l=0;for(let u of n.faces)for(let p=1;p<u.indices.length-1;p++)for(let d of[u.indices[0],u.indices[p],u.indices[p+1]]){let h=n.vertices[d];c[l]=(h.x-e)/o,c[l+1]=1-(h.y-t)/s,l+=2}return c}var tn=U(()=>{"use strict"});var nn={};le(nn,{WebGPUTexturedRenderer:()=>nt});function Ur(n){return n?n.mode==="two-sided"?Y(n).front:F(n.opacity,.35):1}var jr,Br,tt,nt,it=U(()=>{"use strict";$();N();J();tn();At();jr=`
|
|
99
99
|
struct Uniforms {
|
|
100
100
|
viewProj: mat4x4<f32>,
|
|
101
101
|
model: mat4x4<f32>,
|
|
@@ -125,7 +125,7 @@ fn fs(in: VSOut) -> @location(0) vec4<f32> {
|
|
|
125
125
|
let t = textureSample(tex, samp, in.uv);
|
|
126
126
|
return vec4<f32>(t.rgb * in.color, t.a * u.params.x);
|
|
127
127
|
}
|
|
128
|
-
`,Br=[1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1],tt=256;nt=class extends Te{constructor(){super(...arguments);this.texturedCapacity=0;this.sources=new Map;this.textures=new Map;this.retired=[];this.texturedBuffers=new Map;this.bindGroups=new Map}setTexture(t,i){this.sources.set(t,i)}async init(t){await super.init(t);let i=this.device;if(!i)return;let r=navigator.gpu.getPreferredCanvasFormat(),o=i.createShaderModule({code:jr}),s=globalThis.GPUShaderStage,a=i.createBindGroupLayout({entries:[{binding:0,visibility:s.VERTEX|s.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0,minBindingSize:144}},{binding:1,visibility:s.FRAGMENT,texture:{}},{binding:2,visibility:s.FRAGMENT,sampler:{}}]}),c=(l,u)=>({arrayStride:u*4,attributes:[{shaderLocation:l,offset:0,format:`float32x${u}`}]});this.texturedPipeline=i.createRenderPipeline({layout:i.createPipelineLayout({bindGroupLayouts:[a]}),vertex:{module:o,entryPoint:"vs",buffers:[c(0,3),c(1,2),c(2,3)]},fragment:{module:o,entryPoint:"fs",targets:[{format:r,blend:{color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"back",frontFace:"ccw"},depthStencil:{format:"depth24plus",depthWriteEnabled:!1,depthCompare:"less"}}),this.sampler=i.createSampler({magFilter:"linear",minFilter:"linear"})}textureFor(t){let i=this.textures.get(t);if(i)return i;let r=this.device,o=globalThis.GPUTextureUsage,s=r.createTexture({size:{width:1,height:1},format:"rgba8unorm",usage:o.TEXTURE_BINDING|o.COPY_DST});r.queue.writeTexture({texture:s},new Uint8Array([255,255,255,255]),{},{width:1,height:1}),this.textures.set(t,s);let a=async l=>{let u=l instanceof HTMLImageElement?await createImageBitmap(l):l;if(this.destroyed||!this.device||this.textures.get(t)!==s)return;let p=u.width||1,
|
|
128
|
+
`,Br=[1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1],tt=256;nt=class extends Te{constructor(){super(...arguments);this.texturedCapacity=0;this.sources=new Map;this.textures=new Map;this.retired=[];this.texturedBuffers=new Map;this.bindGroups=new Map}setTexture(t,i){this.sources.set(t,i)}async init(t){await super.init(t);let i=this.device;if(!i)return;let r=navigator.gpu.getPreferredCanvasFormat(),o=i.createShaderModule({code:jr}),s=globalThis.GPUShaderStage,a=i.createBindGroupLayout({entries:[{binding:0,visibility:s.VERTEX|s.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0,minBindingSize:144}},{binding:1,visibility:s.FRAGMENT,texture:{}},{binding:2,visibility:s.FRAGMENT,sampler:{}}]}),c=(l,u)=>({arrayStride:u*4,attributes:[{shaderLocation:l,offset:0,format:`float32x${u}`}]});this.texturedPipeline=i.createRenderPipeline({layout:i.createPipelineLayout({bindGroupLayouts:[a]}),vertex:{module:o,entryPoint:"vs",buffers:[c(0,3),c(1,2),c(2,3)]},fragment:{module:o,entryPoint:"fs",targets:[{format:r,blend:{color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"back",frontFace:"ccw"},depthStencil:{format:"depth24plus",depthWriteEnabled:!1,depthCompare:"less"}}),this.sampler=i.createSampler({magFilter:"linear",minFilter:"linear"})}textureFor(t){let i=this.textures.get(t);if(i)return i;let r=this.device,o=globalThis.GPUTextureUsage,s=r.createTexture({size:{width:1,height:1},format:"rgba8unorm",usage:o.TEXTURE_BINDING|o.COPY_DST});r.queue.writeTexture({texture:s},new Uint8Array([255,255,255,255]),{},{width:1,height:1}),this.textures.set(t,s);let a=async l=>{let u=l instanceof HTMLImageElement?await createImageBitmap(l):l;if(this.destroyed||!this.device||this.textures.get(t)!==s)return;let p=u.width||1,d=u.height||1,h=this.device.createTexture({size:{width:p,height:d},format:"rgba8unorm",usage:o.TEXTURE_BINDING|o.COPY_DST|o.RENDER_ATTACHMENT});this.device.queue.copyExternalImageToTexture({source:u},{texture:h},{width:p,height:d}),this.retired.push(s),this.textures.set(t,h),this.bindGroups.delete(t)},c=this.sources.get(t);if(typeof c=="string"){let l=new Image;l.onload=()=>{a(l)},l.src=c}else a(c);return this.textures.get(t)}buffersFor(t){let i=this.texturedBuffers.get(t);if(i)return i;let r=X(t),o=globalThis.GPUBufferUsage.VERTEX|globalThis.GPUBufferUsage.COPY_DST,s=c=>{let l=this.device.createBuffer({size:c.byteLength,usage:o});return this.device.queue.writeBuffer(l,0,c),l},a={position:s(r.positions),uv:s(et(t)),color:s(r.colors),count:r.count};return this.texturedBuffers.set(t,a),a}bindGroupFor(t){let i=this.textureFor(t),r=this.bindGroups.get(t);if(r&&r.buffer===this.texturedUniforms&&r.texture===i)return r.group;let o=this.device.createBindGroup({layout:this.texturedPipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.texturedUniforms,offset:0,size:144}},{binding:1,resource:i.createView()},{binding:2,resource:this.sampler}]});return this.bindGroups.set(t,{group:o,buffer:this.texturedUniforms,texture:i}),o}render(t){let i=[],r=[];for(let l of t.items)(this.sources.has(l.mesh)?r:i).push(l);if(super.render(r.length?{...t,items:i}:t),!r.length||this.destroyed||!this.device||!this.context||!this.texturedPipeline||t.width===0||t.height===0)return;this.ensureDepth(),(r.length>this.texturedCapacity||!this.texturedUniforms)&&(this.texturedUniforms?.destroy?.(),this.texturedUniforms=this.device.createBuffer({size:r.length*tt,usage:globalThis.GPUBufferUsage.UNIFORM|globalThis.GPUBufferUsage.COPY_DST}),this.texturedCapacity=r.length);let o=z(Br,t.viewProjection);r.forEach((l,u)=>{let p=new Float32Array(tt/4);p.set(o,0),p.set(l.model,16),p.set([Ur(l.transparency),0,0,0],32),this.device.queue.writeBuffer(this.texturedUniforms,u*tt,p)});let s=i.length>0,a=this.device.createCommandEncoder(),c=a.beginRenderPass({colorAttachments:[{view:this.context.getCurrentTexture().createView(),clearValue:this.clearValue,loadOp:s?"load":"clear",storeOp:"store"}],depthStencilAttachment:{view:this.depthTexture.createView(),depthClearValue:1,depthLoadOp:s?"load":"clear",depthStoreOp:"store"}});c.setPipeline(this.texturedPipeline),r.forEach((l,u)=>{let p=this.buffersFor(l.mesh);c.setBindGroup(0,this.bindGroupFor(l.mesh),[u*tt]),c.setVertexBuffer(0,p.position),c.setVertexBuffer(1,p.uv),c.setVertexBuffer(2,p.color),c.draw(p.count)}),c.end(),this.device.queue.submit([a.finish()])}destroy(){for(let t of this.textures.values())t.destroy?.();for(let t of this.retired.splice(0))t.destroy?.();for(let t of this.texturedBuffers.values())t.position.destroy?.(),t.uv.destroy?.(),t.color.destroy?.();this.textures.clear(),this.texturedBuffers.clear(),this.bindGroups.clear(),this.sources.clear(),this.texturedUniforms?.destroy?.(),this.texturedUniforms=void 0,this.texturedPipeline=void 0,this.sampler=void 0,super.destroy()}}});var rn={};le(rn,{WebGLTexturedRenderer:()=>rt});function kn(n,e,t){let i=n.createShader(e);if(n.shaderSource(i,t),n.compileShader(i),!n.getShaderParameter(i,n.COMPILE_STATUS))throw new Error(`3d-spinner: shader compile failed: ${n.getShaderInfoLog(i)}`);return i}function Hr(n){let e=n.createProgram();if(n.attachShader(e,kn(n,n.VERTEX_SHADER,Nr)),n.attachShader(e,kn(n,n.FRAGMENT_SHADER,Gr)),n.linkProgram(e),!n.getProgramParameter(e,n.LINK_STATUS))throw new Error(`3d-spinner: program link failed: ${n.getProgramInfoLog(e)}`);return e}function Wr(n){return n?n.mode==="two-sided"?Y(n).front:F(n.opacity,.35):1}var Nr,Gr,rt,ot=U(()=>{"use strict";$();J();tn();vt();Nr=`#version 300 es
|
|
129
129
|
in vec3 aPos;
|
|
130
130
|
in vec2 aUV;
|
|
131
131
|
in vec3 aColor;
|
|
@@ -147,8 +147,8 @@ out vec4 fragColor;
|
|
|
147
147
|
void main() {
|
|
148
148
|
vec4 t = texture(uTexture, vUV);
|
|
149
149
|
fragColor = vec4(t.rgb * vColor, t.a * uOpacity);
|
|
150
|
-
}`;rt=class{constructor(e={}){this.sources=new Map;this.textures=new Map;this.buffers=new Map;this.inner=new Oe(e)}setTexture(e,t){this.sources.set(e,t)}init(e){this.inner.init(e);let t=e.getContext("webgl2");this.gl=t,this.program=Hr(t),this.locations={aPos:t.getAttribLocation(this.program,"aPos"),aUV:t.getAttribLocation(this.program,"aUV"),aColor:t.getAttribLocation(this.program,"aColor"),uViewProj:t.getUniformLocation(this.program,"uViewProj"),uModel:t.getUniformLocation(this.program,"uModel"),uTexture:t.getUniformLocation(this.program,"uTexture"),uOpacity:t.getUniformLocation(this.program,"uOpacity")}}resize(){this.inner.resize()}textureFor(e){let t=this.textures.get(e);if(t)return t;let i=this.gl,r=i.createTexture();i.bindTexture(i.TEXTURE_2D,r),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array([255,255,255,255])),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),this.textures.set(e,r);let o=a=>{!this.gl||this.textures.get(e)!==r||(this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,a))},s=this.sources.get(e);if(typeof s=="string"){let a=new Image;a.onload=()=>o(a),a.src=s}else o(s);return r}buffersFor(e){let t=this.buffers.get(e);if(t)return t;let i=this.gl,r=this.locations,o=X(e),s=i.createVertexArray();i.bindVertexArray(s);let a=(l,u,p)=>{if(l<0)return;let h=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,h),i.bufferData(i.ARRAY_BUFFER,u,i.STATIC_DRAW),i.enableVertexAttribArray(l),i.vertexAttribPointer(l,p,i.FLOAT,!1,0,0)};a(r.aPos,o.positions,3),a(r.aColor,o.colors,3),a(r.aUV,et(e),2),i.bindVertexArray(null);let c={vao:s,count:o.count};return this.buffers.set(e,c),c}render(e){let t=[],i=[];for(let s of e.items)(this.sources.has(s.mesh)?i:t).push(s);if(this.inner.render(i.length?{...e,items:t}:e),!i.length)return;let r=this.gl,o=this.locations;if(!(!r||!this.program||!o)){r.useProgram(this.program),r.uniformMatrix4fv(o.uViewProj,!1,new Float32Array(e.viewProjection)),r.uniform1i(o.uTexture,0),r.activeTexture(r.TEXTURE0),r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.depthMask(!1);for(let s of i){let a=this.buffersFor(s.mesh);r.bindTexture(r.TEXTURE_2D,this.textureFor(s.mesh)),r.uniformMatrix4fv(o.uModel,!1,new Float32Array(s.model)),r.uniform1f(o.uOpacity,Wr(s.transparency)),r.bindVertexArray(a.vao),r.drawArrays(r.TRIANGLES,0,a.count)}r.depthMask(!0),r.disable(r.BLEND),r.bindVertexArray(null)}}destroy(){let e=this.gl;if(e){for(let t of this.textures.values())e.deleteTexture(t);for(let t of this.buffers.values())e.deleteVertexArray(t.vao);this.program&&e.deleteProgram(this.program)}this.textures.clear(),this.buffers.clear(),this.sources.clear(),this.gl=void 0,this.program=void 0,this.locations=void 0,this.inner.destroy()}}});var rn={};le(rn,{Canvas2DTexturedRenderer:()=>nn});function Dn(n){if(n instanceof HTMLImageElement)return n.complete&&n.naturalWidth>0?{width:n.naturalWidth,height:n.naturalHeight}:void 0;if(n instanceof HTMLVideoElement)return n.readyState>=2?{width:n.videoWidth,height:n.videoHeight}:void 0;if(n instanceof SVGImageElement){let t=n.width.baseVal.value,i=n.height.baseVal.value;return t>0&&i>0?{width:t,height:i}:void 0}if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};let e=n;return e.width>0&&e.height>0?{width:e.width,height:e.height}:void 0}function jn(n,e,t,i){let[r,o,s]=t,[a,c,l]=i,u=r.x*(o.y-s.y)+o.x*(s.y-r.y)+s.x*(r.y-o.y);if(Math.abs(u)<1e-8)return;let p=(a.x*(o.y-s.y)+c.x*(s.y-r.y)+l.x*(r.y-o.y))/u,h=(a.x*(s.x-o.x)+c.x*(r.x-s.x)+l.x*(o.x-r.x))/u,d=(a.x*(o.x*s.y-s.x*o.y)+c.x*(s.x*r.y-r.x*s.y)+l.x*(r.x*o.y-o.x*r.y))/u,m=(a.y*(o.y-s.y)+c.y*(s.y-r.y)+l.y*(r.y-o.y))/u,b=(a.y*(s.x-o.x)+c.y*(r.x-s.x)+l.y*(o.x-r.x))/u,f=(a.y*(o.x*s.y-s.x*o.y)+c.y*(s.x*r.y-r.x*s.y)+l.y*(r.x*o.y-o.x*r.y))/u;n.save(),n.beginPath(),n.moveTo(a.x,a.y),n.lineTo(c.x,c.y),n.lineTo(l.x,l.y),n.closePath(),n.clip(),n.transform(p,m,h,b,d,f),n.drawImage(e,0,0),n.restore()}var nn,on=U(()=>{"use strict";N();J();vt();nn=class{constructor(e={}){this.sources=new Map;this.loaded=new Map;this.dpr=1;this.inner=new Se(e)}setTexture(e,t){if(this.sources.set(e,t),typeof t=="string"&&!this.loaded.has(t)){let i=new Image;i.src=t,this.loaded.set(t,i)}}init(e){this.inner.init(e),this.ctx=e.getContext("2d")??void 0}resize(e,t,i){this.dpr=i,this.inner.resize(e,t,i)}drawable(e){let t=this.sources.get(e);return typeof t=="string"?this.loaded.get(t):t}render(e){let t=e.items.filter(o=>{if(!this.sources.has(o.mesh))return!0;let s=this.drawable(o.mesh);return!s||!Dn(s)});this.inner.render({...e,items:t});let i=this.ctx;if(!i)return;i.setTransform(this.dpr,0,0,this.dpr,0,0);let r=new Map;for(let o of e.items){let s=this.drawable(o.mesh);if(!s)continue;let a=Dn(s);if(!a)continue;let c=r.get(o.mesh);if(!c){c=document.createElement("canvas"),c.width=a.width,c.height=a.height;let f=c.getContext("2d");if(!f)continue;f.drawImage(s,0,0,a.width,a.height),f.globalCompositeOperation="source-in",f.fillStyle=o.mesh.faces[0]?.color??"#ffffff",f.fillRect(0,0,a.width,a.height),r.set(o.mesh,c)}let u=o.mesh.vertices.map(f=>fe(o.model,f)).map(f=>{let y=je(e.viewProjection,f);return{x:(y.x*.5+.5)*e.width,y:(1-(y.y*.5+.5))*e.height}}),p=o.mesh.faces[0];if(!p||p.indices.length!==4)continue;let[h,d,m,b]=p.indices.map(f=>u[f]);i.globalAlpha=o.transparency?.mode==="one-sided"?F(o.transparency.opacity,.35):1,jn(i,c,[{x:0,y:a.height},{x:a.width,y:a.height},{x:a.width,y:0}],[h,d,m]),jn(i,c,[{x:0,y:a.height},{x:a.width,y:0},{x:0,y:0}],[h,m,b])}i.globalAlpha=1}destroy(){this.inner.destroy(),this.ctx=void 0,this.sources.clear(),this.loaded.clear()}}});var as={};le(as,{Camera:()=>be,ChargedOrbAnimation:()=>Le,CompositeAnimation:()=>H,GridAssemblyAnimation:()=>Ce,Light:()=>ye,Little3dEngine:()=>P,LittleTweenEngine:()=>dn,ObjectMotionAnimation:()=>me,ParticlesAnimation:()=>L,SpinAnimation:()=>Qt,WebGLTexturedRenderer:()=>rt,WebGPUTexturedRenderer:()=>nt,attachMaterial:()=>O,centerAndScaleMesh:()=>Vn,chargedOrb:()=>oi,circleMotion:()=>Ii,createSpinner:()=>Gi,cross:()=>T,crystalComet:()=>si,cube:()=>te,cubeSphere:()=>En,cubic:()=>Tt,dot:()=>W,ease:()=>Ze,easeInBack:()=>Bt,easeInBounce:()=>Wt,easeInCirc:()=>kt,easeInCubic:()=>se,easeInElastic:()=>Nt,easeInExpo:()=>_t,easeInOutBack:()=>Ut,easeInOutBounce:()=>Xt,easeInOutCirc:()=>jt,easeInOutCubic:()=>de,easeInOutElastic:()=>Ht,easeInOutExpo:()=>Vt,easeInOutQuad:()=>zt,easeInOutQuart:()=>Rt,easeInOutQuint:()=>Ft,easeInOutSine:()=>It,easeInQuad:()=>oe,easeInQuart:()=>Qe,easeInQuint:()=>Ke,easeInSine:()=>Pt,easeOutBack:()=>q,easeOutBounce:()=>xe,easeOutCirc:()=>Dt,easeOutCubic:()=>ee,easeOutElastic:()=>Gt,easeOutExpo:()=>Pe,easeOutQuad:()=>he,easeOutQuart:()=>Ct,easeOutQuint:()=>wt,easeOutSine:()=>Lt,easeTypes:()=>Yt,enterFromObjectDirection:()=>Kt,expandToTriangles:()=>X,figureEightMotion:()=>ge,ghostTrain:()=>hi,gridAssembly:()=>di,grow:()=>Or,icosphere:()=>Ee,leaveInObjectDirection:()=>Zt,linear:()=>At,monochromeStreak:()=>mi,normalize:()=>g,octaSphere:()=>Sn,octahedron:()=>On,orderRenderItems:()=>He,parseObj:()=>ss,particleField:()=>Gn,planeMesh:()=>Ye,planeStarTrail:()=>fi,pulsingStarfield:()=>bi,pyramid:()=>Xe,quad:()=>pe,quadratic:()=>Ot,quartic:()=>St,quintic:()=>Et,rocketLaunch:()=>Pi,scale:()=>V,shineTexture:()=>re,shrink:()=>Tr,squareMotion:()=>lt,starSwarm:()=>Li,starTexture:()=>ie,streakTexture:()=>qe,subtract:()=>S,tetrahedron:()=>We,transform:()=>Ne,uvSphere:()=>Tn,vec3:()=>fn,wanderMotion:()=>ht});function mn(n){return Number.isNaN(n)?0:Math.min(1,Math.max(0,n))}function Ni(n,e,t){return n+(e-n)*t}function Gi(n,e){if(!(n instanceof HTMLElement))throw new Error("3d-spinner: createSpinner requires a target HTMLElement.");let{animation:t}=e,i=e.type==="indeterminate";if(i&&e.periodMs!==void 0&&(!Number.isFinite(e.periodMs)||e.periodMs<=0))throw new RangeError("3d-spinner: periodMs must be a finite number greater than zero.");t.mount(n);let r=performance.now(),o=0,s=!1,a=!1,c=!1,l=!1,u=0,p=0,h=1/0;if(!i){let x=e;typeof x.progress=="number"&&(u=mn(x.progress),p=u),typeof x.timeout=="number"&&(h=Math.min(h,r+x.timeout)),x.until instanceof Date&&(h=Math.min(h,x.until.getTime()))}function d(x){if(!i)return x>=h&&(p=1),u=Ni(u,p,.12),Math.abs(p-u)<5e-4&&(u=p),u;let v=e,I=v.periodMs??2e3,E=(x-r)/I;if((v.loop??"bounce")==="restart")return E-Math.floor(E);let _=E-2*Math.floor(E/2);return _<=1?_:2-_}function m(x){if(s)return;let v=d(x);!c&&(i||v>0)&&(t.enter(x),c=!0),!l&&c&&!i&&v>=1&&p>=1&&(t.exit(x),l=!0);let I=i?v:p;if(t.render(x,{progress:v,targetProgress:I,indeterminate:i}),l&&t.isFinished()){b();return}o=requestAnimationFrame(m)}function b(){s||(s=!0,o&&cancelAnimationFrame(o),o=0)}function f(x){i||(p=mn(x))}function y(){if(!(s||l)){if(!c){b();return}t.exit(performance.now()),l=!0}}function M(){a||(a=!0,b(),t.destroy())}return o=requestAnimationFrame(m),{setProgress:f,stop:y,destroy:M}}N();var Hi={position:{x:0,y:0,z:4},fov:55*Math.PI/180,near:.1,far:100},be=class{constructor(e){this.options={...Hi,...e}}toView(e){let{position:t}=this.options;return fe(Ae(-t.x,-t.y,-t.z),e)}viewProjection(e){let{position:t,fov:i,near:r,far:o}=this.options,s=Ae(-t.x,-t.y,-t.z),a=yn(i,e,r,o);return z(a,s)}toScreen(e,t,i){return{x:(e.x*.5+.5)*t,y:(1-(e.y*.5+.5))*i}}};Ue();N();function O(n,e){if(e)for(let t of n.faces)t.material=e;return n}function Ne(n){return{position:n?.position??{x:0,y:0,z:0},rotation:n?.rotation??{x:0,y:0,z:0},scale:n?.scale??1}}J();Ue();var Ji=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"];function te(n=1,e=Ji,t){let i=n/2,r=[{x:-i,y:-i,z:i},{x:i,y:-i,z:i},{x:i,y:i,z:i},{x:-i,y:i,z:i},{x:-i,y:-i,z:-i},{x:i,y:-i,z:-i},{x:i,y:i,z:-i},{x:-i,y:i,z:-i}],o=[{indices:[0,1,2,3],color:e[0%e.length]},{indices:[5,4,7,6],color:e[1%e.length]},{indices:[3,2,6,7],color:e[2%e.length]},{indices:[4,5,1,0],color:e[3%e.length]},{indices:[1,5,6,2],color:e[4%e.length]},{indices:[4,0,3,7],color:e[5%e.length]}];return O({vertices:r,faces:o},t)}var er=["#3b82f6"];function pe(n=1,e=er,t){let i=n/2,r=[{x:-i,y:-i,z:0},{x:i,y:-i,z:0},{x:i,y:i,z:0},{x:-i,y:i,z:0}];return O({vertices:r,faces:[{indices:[0,1,2,3],color:e[0]}]},t)}var tr=["#3b82f6","#8b5cf6","#ec4899","#f59e0b"];function We(n=1,e=tr,t){let i=n/2,r=[{x:i,y:i,z:i},{x:i,y:-i,z:-i},{x:-i,y:i,z:-i},{x:-i,y:-i,z:i}],o=[{indices:[0,1,2],color:e[0%e.length]},{indices:[0,3,1],color:e[1%e.length]},{indices:[0,2,3],color:e[2%e.length]},{indices:[1,3,2],color:e[3%e.length]}];return O({vertices:r,faces:o},t)}var nr=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444","#06b6d4","#eab308"];function On(n=1,e=nr,t){let i=n/2,r=[{x:i,y:0,z:0},{x:-i,y:0,z:0},{x:0,y:i,z:0},{x:0,y:-i,z:0},{x:0,y:0,z:i},{x:0,y:0,z:-i}],o=[{indices:[4,0,2],color:e[0%e.length]},{indices:[4,2,1],color:e[1%e.length]},{indices:[4,1,3],color:e[2%e.length]},{indices:[4,3,0],color:e[3%e.length]},{indices:[5,2,0],color:e[4%e.length]},{indices:[5,1,2],color:e[5%e.length]},{indices:[5,3,1],color:e[6%e.length]},{indices:[5,0,3],color:e[7%e.length]}];return O({vertices:r,faces:o},t)}var ir=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981"];function Xe(n=1,e=ir,t){let i=n/2,r=[{x:-i,y:-i,z:i},{x:i,y:-i,z:i},{x:i,y:-i,z:-i},{x:-i,y:-i,z:-i},{x:0,y:i,z:0}],o=[{indices:[0,3,2,1],color:e[0%e.length]},{indices:[4,0,1],color:e[1%e.length]},{indices:[4,1,2],color:e[2%e.length]},{indices:[4,2,3],color:e[3%e.length]},{indices:[4,3,0],color:e[4%e.length]}];return O({vertices:r,faces:o},t)}var rr=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"];function Tn(n=1,e=1,t=rr,i){let r=n/2,o=Math.max(1,Math.floor(e)),s=Math.max(4,o*4),a=Math.max(2,o*2),c=[{x:0,y:r,z:0}],l=(m,b)=>1+(m-1)*s+b;for(let m=1;m<a;m++){let b=Math.PI*m/a,f=r*Math.cos(b),y=r*Math.sin(b);for(let M=0;M<s;M++){let x=2*Math.PI*M/s;c.push({x:y*Math.cos(x),y:f,z:y*Math.sin(x)})}}let u=c.length;c.push({x:0,y:-r,z:0});let p=[],h=0,d=()=>t[h++%t.length];for(let m=0;m<s;m++)p.push({indices:[0,l(1,(m+1)%s),l(1,m)],color:d()});for(let m=1;m<a-1;m++)for(let b=0;b<s;b++){let f=(b+1)%s;p.push({indices:[l(m,b),l(m,f),l(m+1,f),l(m+1,b)],color:d()})}for(let m=0;m<s;m++)p.push({indices:[u,l(a-1,m),l(a-1,(m+1)%s)],color:d()});return O({vertices:c,faces:p},i)}$();var or=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"],k=(1+Math.sqrt(5))/2,sr=[{x:-1,y:k,z:0},{x:1,y:k,z:0},{x:-1,y:-k,z:0},{x:1,y:-k,z:0},{x:0,y:-1,z:k},{x:0,y:1,z:k},{x:0,y:-1,z:-k},{x:0,y:1,z:-k},{x:k,y:0,z:-1},{x:k,y:0,z:1},{x:-k,y:0,z:-1},{x:-k,y:0,z:1}],ar=[[0,11,5],[0,5,1],[0,1,7],[0,7,10],[0,10,11],[1,5,9],[5,11,4],[11,10,2],[10,7,6],[7,1,8],[3,9,4],[3,4,2],[3,2,6],[3,6,8],[3,8,9],[4,9,5],[2,4,11],[6,2,10],[8,6,7],[9,8,1]];function Ee(n=1,e=1,t=or,i){return O(Be(sr,ar,n,e,t),i)}$();var cr=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"],lr=[{x:1,y:0,z:0},{x:-1,y:0,z:0},{x:0,y:1,z:0},{x:0,y:-1,z:0},{x:0,y:0,z:1},{x:0,y:0,z:-1}],ur=[[4,0,2],[4,2,1],[4,1,3],[4,3,0],[5,2,0],[5,1,2],[5,3,1],[5,0,3]];function Sn(n=1,e=1,t=cr,i){return O(Be(lr,ur,n,e,t),i)}var pr=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"],hr=[{normal:[0,0,1],right:[1,0,0],up:[0,1,0]},{normal:[0,0,-1],right:[-1,0,0],up:[0,1,0]},{normal:[1,0,0],right:[0,0,-1],up:[0,1,0]},{normal:[-1,0,0],right:[0,0,1],up:[0,1,0]},{normal:[0,1,0],right:[1,0,0],up:[0,0,-1]},{normal:[0,-1,0],right:[1,0,0],up:[0,0,1]}];function En(n=1,e=1,t=pr,i){let r=n/2,o=Math.max(1,Math.floor(e)),s=[],a=[],c=0;for(let l of hr){let u=s.length;for(let h=0;h<=o;h++)for(let d=0;d<=o;d++){let m=-1+2*h/o,b=-1+2*d/o,f=l.normal[0]+m*l.right[0]+b*l.up[0],y=l.normal[1]+m*l.right[1]+b*l.up[1],M=l.normal[2]+m*l.right[2]+b*l.up[2],x=Math.hypot(f,y,M);s.push({x:f/x*r,y:y/x*r,z:M/x*r})}let p=(h,d)=>u+h*(o+1)+d;for(let h=0;h<o;h++)for(let d=0;d<o;d++)a.push({indices:[p(h,d),p(h+1,d),p(h+1,d+1),p(h,d+1)],color:t[c++%t.length]})}return O({vertices:s,faces:a},i)}var C=["#e0f2fe","#7dd3fc","#38bdf8","#f8fafc"];function Ye(n=C,e){return O({vertices:[{x:.9,y:0,z:0},{x:-.2,y:0,z:.82},{x:-.55,y:0,z:.16},{x:-.72,y:0,z:0},{x:-.55,y:0,z:-.16},{x:-.2,y:0,z:-.82},{x:-.08,y:.12,z:0},{x:-.08,y:-.1,z:0},{x:-.52,y:.38,z:0}],faces:[{indices:[6,1,0],color:n[0]??C[0]},{indices:[6,2,1],color:n[3]??C[3]},{indices:[6,3,2],color:n[1]??C[1]},{indices:[6,4,3],color:n[2]??C[2]},{indices:[6,5,4],color:n[3]??C[3]},{indices:[6,0,5],color:n[0]??C[0]},{indices:[7,0,1],color:n[1]??C[1]},{indices:[7,1,2],color:n[2]??C[2]},{indices:[7,2,3],color:n[1]??C[1]},{indices:[7,3,4],color:n[2]??C[2]},{indices:[7,4,5],color:n[1]??C[1]},{indices:[7,5,0],color:n[2]??C[2]},{indices:[3,6,8],color:n[0]??C[0]},{indices:[3,8,6],color:n[1]??C[1]}]},e)}function ne(n,e=96){let t=document.createElement("canvas");t.width=t.height=e;let i=t.getContext("2d");return i&&n(i),t}function Pn(n){n.save(),n.translate(48,48),n.fillStyle="#fff",n.beginPath();for(let e=0;e<10;e++){let t=e%2===0?43:16,i=e*Math.PI/5-Math.PI/2;n.lineTo(t*Math.cos(i),t*Math.sin(i))}n.closePath(),n.fill(),n.restore()}function ie(n={}){let e=Math.max(0,n.glow??0);return ne(t=>{e>0&&(t.save(),t.filter=`blur(${e}px)`,Pn(t),t.restore()),Pn(t)})}function re(){return ne(n=>{let e=n.createRadialGradient(48,48,1,48,48,46);e.addColorStop(0,"rgba(255,255,255,1)"),e.addColorStop(.08,"rgba(255,255,255,1)"),e.addColorStop(.22,"rgba(210,240,255,0.7)"),e.addColorStop(.55,"rgba(120,200,255,0.22)"),e.addColorStop(1,"rgba(80,160,255,0)"),n.fillStyle=e,n.fillRect(0,0,96,96)})}function qe(){return ne(n=>{let e=n.createLinearGradient(5,0,91,0);e.addColorStop(0,"rgba(255,255,255,0)"),e.addColorStop(.7,"rgba(255,255,255,0.4)"),e.addColorStop(1,"rgba(255,255,255,1)"),n.strokeStyle=e,n.lineWidth=3.5,n.lineCap="round",n.beginPath(),n.moveTo(5,48),n.lineTo(91,48),n.stroke()})}$();J();N();function dr(n){let e=z(De(n.rotation.z),z(ke(n.rotation.y),Ve(n.rotation.x)));return z(Ae(n.position.x,n.position.y,n.position.z),z(e,bn(n.scale)))}var P=class{constructor(e={}){this.scene=[];this.cssWidth=0;this.cssHeight=0;this.ready=!1;this.generation=0;this.rafId=0;this.running=!1;this.camera=new be(e.camera),this.light=new ye(e.light),this.backend=e.backend??"canvas2d",this.background=e.background}async mount(e){let t=document.createElement("canvas");t.style.display="block",t.style.width="100%",t.style.height="100%",e.appendChild(t),this.canvas=t,this.observer=new ResizeObserver(()=>this.resize()),this.observer.observe(t),this.resize();let i=this.generation,r=()=>{this.canvas===t&&(this.observer?.disconnect(),this.observer=void 0,t.remove(),this.canvas=void 0)};try{let o=await An(this.backend,{background:this.background});if(i!==this.generation){o.destroy(),r();return}if(await o.init(t),i!==this.generation){o.destroy(),r();return}this.renderer=o,this.resize(),this.ready=!0}catch(o){throw r(),o}}add(e,t){let i={mesh:e,transform:Ne(t),transparency:t?.transparency,remove:()=>{let r=this.scene.indexOf(i);r>=0&&this.scene.splice(r,1)}};return this.scene.push(i),i}resize(){let e=this.canvas;if(!e)return;let t=window.devicePixelRatio||1;this.cssWidth=e.clientWidth||e.parentElement?.clientWidth||0,this.cssHeight=e.clientHeight||e.parentElement?.clientHeight||0,e.width=Math.max(1,Math.round(this.cssWidth*t)),e.height=Math.max(1,Math.round(this.cssHeight*t)),this.renderer?.resize(this.cssWidth,this.cssHeight,t)}render(){if(!this.ready||!this.renderer)return;let e=this.cssWidth,t=this.cssHeight;if(e===0||t===0)return;let i=this.scene.map(o=>({mesh:o.mesh,model:dr(o.transform),transparency:o.transparency})),r=this.camera.options.position;this.renderer.render({items:He(i,r),viewProjection:this.camera.viewProjection(e/t),eye:r,light:this.light.params,width:e,height:t})}start(){if(this.running)return;this.running=!0;let e=()=>{this.running&&(this.render(),this.rafId=requestAnimationFrame(e))};this.rafId=requestAnimationFrame(e)}stop(){this.running=!1,this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0}destroy(){this.generation++,this.ready=!1,this.stop(),this.observer?.disconnect(),this.observer=void 0,this.renderer?.destroy(),this.renderer=void 0,this.canvas?.remove(),this.canvas=void 0}};function A(n,e){return Number.isNaN(n)?0:e?n:Math.min(1,Math.max(0,n))}function At(n,e=!1){return A(n,e)}function Ot(n,e=!1){return oe(n,e)}function Tt(n,e=!1){return se(n,e)}function St(n,e=!1){return Qe(n,e)}function Et(n,e=!1){return Ke(n,e)}function Pt(n,e=!1){let t=A(n,e);return 1-Math.cos(t*Math.PI/2)}function Lt(n,e=!1){let t=A(n,e);return Math.sin(t*Math.PI/2)}function It(n,e=!1){let t=A(n,e);return-(Math.cos(Math.PI*t)-1)/2}function oe(n,e=!1){let t=A(n,e);return t*t}function he(n,e=!1){let t=A(n,e);return 1-(1-t)*(1-t)}function zt(n,e=!1){let t=A(n,e);return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2}function se(n,e=!1){let t=A(n,e);return t*t*t}function ee(n,e=!1){let t=A(n,e);return 1-Math.pow(1-t,3)}function de(n,e=!1){let t=A(n,e);return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}function Qe(n,e=!1){let t=A(n,e);return t*t*t*t}function Ct(n,e=!1){let t=A(n,e);return 1-Math.pow(1-t,4)}function Rt(n,e=!1){let t=A(n,e);return t<.5?8*t*t*t*t:1-Math.pow(-2*t+2,4)/2}function Ke(n,e=!1){let t=A(n,e);return t*t*t*t*t}function wt(n,e=!1){let t=A(n,e);return 1-Math.pow(1-t,5)}function Ft(n,e=!1){let t=A(n,e);return t<.5?16*t*t*t*t*t:1-Math.pow(-2*t+2,5)/2}function _t(n,e=!1){let t=A(n,e);return t===0?0:Math.pow(2,10*t-10)}function Pe(n,e=!1){let t=A(n,e);return t===1?1:1-Math.pow(2,-10*t)}function Vt(n,e=!1){let t=A(n,e);return t===0?0:t===1?1:t<.5?Math.pow(2,20*t-10)/2:(2-Math.pow(2,-20*t+10))/2}function kt(n,e=!1){let t=A(n,e);return 1-Math.sqrt(1-Math.pow(t,2))}function Dt(n,e=!1){let t=A(n,e);return Math.sqrt(1-Math.pow(t-1,2))}function jt(n,e=!1){let t=A(n,e);return t<.5?(1-Math.sqrt(1-Math.pow(2*t,2)))/2:(Math.sqrt(1-Math.pow(-2*t+2,2))+1)/2}function Bt(n,e=!1){let t=A(n,e),i=1.70158;return(i+1)*t*t*t-i*t*t}function q(n,e=!1){let t=A(n,e),i=1.70158;return 1+(i+1)*Math.pow(t-1,3)+i*Math.pow(t-1,2)}function Ut(n,e=!1){let t=A(n,e),r=1.70158*1.525;return t<.5?Math.pow(2*t,2)*((r+1)*2*t-r)/2:(Math.pow(2*t-2,2)*((r+1)*(t*2-2)+r)+2)/2}function Nt(n,e=!1){let t=A(n,e),i=2*Math.PI/3;return t===0?0:t===1?1:-Math.pow(2,10*t-10)*Math.sin((t*10-10.75)*i)}function Gt(n,e=!1){let t=A(n,e),i=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*i)+1}function Ht(n,e=!1){let t=A(n,e),i=2*Math.PI/4.5;return t===0?0:t===1?1:t<.5?-(Math.pow(2,20*t-10)*Math.sin((20*t-11.125)*i))/2:Math.pow(2,-20*t+10)*Math.sin((20*t-11.125)*i)/2+1}function Wt(n,e=!1){let t=A(n,e);return 1-xe(1-t,!0)}function xe(n,e=!1){let t=A(n,e),i=7.5625,r=2.75;return t<1/r?i*t*t:t<2/r?(t-=1.5/r,i*t*t+.75):t<2.5/r?(t-=2.25/r,i*t*t+.9375):(t-=2.625/r,i*t*t+.984375)}function Xt(n,e=!1){let t=A(n,e);return t<.5?(1-xe(1-2*t,!0))/2:(1+xe(2*t-1,!0))/2}var Yt={linear:At,quadratic:Ot,cubic:Tt,quartic:St,quintic:Et,easeInSine:Pt,easeOutSine:Lt,easeInOutSine:It,easeInQuad:oe,easeOutQuad:he,easeInOutQuad:zt,easeInCubic:se,easeOutCubic:ee,easeInOutCubic:de,easeInQuart:Qe,easeOutQuart:Ct,easeInOutQuart:Rt,easeInQuint:Ke,easeOutQuint:wt,easeInOutQuint:Ft,easeInExpo:_t,easeOutExpo:Pe,easeInOutExpo:Vt,easeInCirc:kt,easeOutCirc:Dt,easeInOutCirc:jt,easeInBack:Bt,easeOutBack:q,easeInOutBack:Ut,easeInElastic:Nt,easeOutElastic:Gt,easeInOutElastic:Ht,easeInBounce:Wt,easeOutBounce:xe,easeInOutBounce:Xt};function Ze(n,e,t=!1){return Yt[n](e,t)}function mr(n={}){return{popDurationMs:n.popDurationMs??500,overextend:n.overextend??.2,startSnapRatio:n.startSnapRatio??.2,loadingText:n.loadingText===void 0?"loading":n.loadingText,doneText:n.doneText??"done",doneFadeDurationMs:n.doneFadeDurationMs??2e3,removeOnComplete:n.removeOnComplete??!1}}function qt(n,e,t){return t<=0?1:Math.min(1,Math.max(0,(n-e)/t))}var $e=class{constructor(e={}){this.phase="idle";this.phaseStart=0;this.activeProgress=0;this.popTarget=0;this.doneFadeStart=0;this.options=mr(e)}enter(e){this.phase==="idle"&&(this.phase="startPop",this.phaseStart=e,this.activeProgress=0,this.popTarget=0)}exit(e){this.phase!=="startPop"&&this.phase!=="active"||(this.phase="endPop",this.phaseStart=e)}isFinished(){return this.phase==="finished"}update(e,t,i){let{popDurationMs:r,overextend:o,startSnapRatio:s,loadingText:a,doneText:c,doneFadeDurationMs:l,removeOnComplete:u}=this.options,p=i??t;(this.phase==="startPop"||this.phase==="active")&&(this.activeProgress=t,this.phase==="startPop"&&(this.popTarget=Math.max(this.popTarget,p,t)));let h=0,d=null,m=0,b=!1;if(this.phase==="startPop"){let f=qt(e,this.phaseStart,r),y=this.popTarget*(1+o);if(f<s){let M=s>0?f/s:1;h=y*Pe(M)}else{let M=s<1?(f-s)/(1-s):1;h=y+(this.activeProgress-y)*ee(M)}f>=1&&(this.phase="active")}else if(this.phase==="active")h=this.activeProgress;else if(this.phase==="endPop"){let f=qt(e,this.phaseStart,r),y=1+o;f<.5?h=1+(y-1)*he(f*2):h=y*(1-oe((f-.5)*2)),f>=1&&(this.phase="done",this.doneFadeStart=e,h=0)}if(this.phase==="startPop"||this.phase==="active")a!==!1&&(d=a,m=.65);else if(this.phase==="endPop")d=c,m=.65;else if(this.phase==="done"){let f=qt(e,this.doneFadeStart,l);f>=1?(u&&(b=!0),this.phase="finished"):(d=c,m=.65*(1-f))}return{scale:h,text:d,textOpacity:m,hidden:b}}};var fr=["position:absolute","inset:0","display:flex","align-items:center","justify-content:center","pointer-events:none","font:600 1.1rem/1.2 system-ui,sans-serif","letter-spacing:0.06em","text-transform:lowercase","color:rgba(255,255,255,0.65)","z-index:1"].join(";");function br(n){return n?typeof n=="function"?n():n:te()}function yr(n,e){if(e===void 0||Array.isArray(e)&&e.length===0)return n;let t=Array.isArray(e)?i=>e[i%e.length]:()=>e;return{vertices:n.vertices,faces:n.faces.map((i,r)=>({...i,color:t(r)}))}}function xr(n,e){return e?{vertices:n.vertices,faces:n.faces.map(t=>({...t,material:e}))}:n}var Qt=class{constructor(e={}){this.exited=!1;this.mesh=xr(yr(br(e.shape),e.color),e.material),this.spinX=e.spinX??7e-4,this.spinY=e.spinY??.0011,this.backend=e.backend,this.transparency=e.transparency,this.progress=e.progressAnimation?new $e(e.progressAnimation):void 0}mount(e){e.style.position="relative";let t=new P({backend:this.backend,camera:{position:{x:0,y:0,z:2.8}}});if(this.handle=t.add(this.mesh,{transparency:this.transparency}),this.engine=t,t.mount(e).catch(i=>{e.textContent=i instanceof Error?i.message:String(i)}),this.progress){let i=document.createElement("div");i.style.cssText=fr,i.setAttribute("aria-hidden","true"),i.hidden=!0,e.appendChild(i),this.label=i}}enter(e){this.progress?.enter(e)}exit(e){this.exited=!0,this.progress?.exit(e)}isFinished(){return this.progress?this.progress.isFinished():this.exited}render(e,t){if(!this.engine||!this.handle)return;let i=this.handle.transform.rotation;if(i.x=e*this.spinX,i.y=e*this.spinY,this.progress){let r=this.progress.update(e,t.progress,t.targetProgress);this.handle.transform.scale=r.hidden?0:r.scale,this.applyLabel(r)}else this.handle.transform.scale=1;this.engine.render()}destroy(){this.label?.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.handle=void 0}applyLabel(e){if(this.label){if(e.hidden||e.text==null){this.label.hidden=!0,this.label.textContent="";return}this.label.hidden=!1,this.label.textContent=e.text,this.label.style.opacity=String(e.textOpacity)}}};var Mr=["position:absolute","inset:0","display:flex","align-items:center","justify-content:center","pointer-events:none","font:700 1.6rem/1 system-ui,sans-serif","letter-spacing:0.02em","color:rgba(255,255,255,0.9)","text-shadow:0 1px 10px rgba(0,0,0,0.6)","z-index:1"].join(";");function Q(n,e,t,i,r){if(e===1/0)return 0;let o=t<=0?1:Math.max(0,Math.min(1,(n-e)/t)),s=i===1/0?1:r<=0?0:Math.max(0,Math.min(1,1-(n-i)/r));return Math.min(o,s)}function K(n,e){var i;let t=document.createElement("div");return t.style.cssText=Mr,t.setAttribute("role","status"),typeof e=="string"?t.textContent=e:e&&((i=e.style).pointerEvents||(i.pointerEvents="auto"),t.appendChild(e)),n.appendChild(t),{container:t,setText(r){typeof e!="object"&&(t.textContent=r)},setOpacity(r){t.style.opacity=String(r)}}}N();function Ln(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function Je(n,e){return{x:n.x*e,y:n.y*e,z:n.z*e}}function In(n){return Math.hypot(n.x,n.y,n.z)}function gr(n){let e=In(n);return e<1e-6?{x:1,y:0,z:0}:Je(n,1/e)}function vr(n,e){return gr(e??n.direction??n.velocity??{x:1,y:0,z:0})}function Ar(n){let t=n-1;return 1+(1.70158+1)*t*t*t+1.70158*t*t}function zn(n,e,t){let i=n.velocity?In(n.velocity):0;if(n.velocity&&i>1e-6&&!e.direction)return n.velocity;let r=e.distance??3.5;return Je(vr(n,e.direction),r/t)}function Kt(n={}){return e=>{let t=Math.max(1,e.durationMs),i=zn(e,n,t),r=t-e.elapsedMs;return{position:Ln(e.position,Je(i,-r))}}}function Zt(n={}){return e=>{let t=Math.max(1,e.durationMs),i=zn(e,n,t);return{position:Ln(e.position,Je(i,e.elapsedMs))}}}function Or(){return n=>({size:(n.size??1)*Ar(n.delta)})}function Tr(){return n=>({size:(n.size??1)*(1-n.delta*n.delta)})}var Sr={x:0,y:1,z:0},Er=2100,Pr=2100,Lr=26,Cn=.7,Ir=.12,$t=8,zr={"+x":n=>n,"-x":n=>({x:-n.x,y:n.y,z:-n.z}),"+z":n=>({x:n.z,y:n.y,z:-n.x}),"-z":n=>({x:-n.z,y:n.y,z:n.x}),"+y":n=>({x:n.y,y:-n.x,z:n.z}),"-y":n=>({x:-n.y,y:n.x,z:n.z})};function Cr(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function Rr(n){return typeof n=="function"?n():n}function wr(n,e){return e===void 0?n:{vertices:n.vertices,faces:n.faces.map(t=>({...t,color:e}))}}function Fr(n,e){if(e==="+x")return n;let t=zr[e];return{vertices:n.vertices.map(t),faces:n.faces}}function Vn(n,e){let t=1/0,i=1/0,r=1/0,o=-1/0,s=-1/0,a=-1/0;for(let d of n.vertices)t=Math.min(t,d.x),i=Math.min(i,d.y),r=Math.min(r,d.z),o=Math.max(o,d.x),s=Math.max(s,d.y),a=Math.max(a,d.z);let c=(t+o)/2,l=(i+s)/2,u=(r+a)/2,p=Math.max(o-t,s-i,a-r)||1,h=e/p;return{vertices:n.vertices.map(d=>({x:(d.x-c)*h,y:(d.y-l)*h,z:(d.z-u)*h})),faces:n.faces}}function _r(n,e){let t=g(n),i=T(t,Sr);Math.hypot(i.x,i.y,i.z)<1e-4&&(i={x:0,y:0,z:1}),i=g(i);let r=T(i,t),o=Cr(V(r,Math.cos(e)),V(i,Math.sin(e))),s=g(T(t,o));return{x:Math.atan2(T(s,t).z,s.z),y:Math.asin(Math.max(-1,Math.min(1,-t.z))),z:Math.atan2(t.y,t.x)}}function Rn(n,e,t){return z(De(t),z(ke(e),Ve(n)))}function Vr(n){return Math.hypot(n[0],n[1])>1e-6?{x:Math.atan2(n[9],n[10]),y:Math.asin(Math.max(-1,Math.min(1,-n[8]))),z:Math.atan2(n[4],n[0])}:{x:Math.atan2(-n[6],n[5]),y:Math.asin(Math.max(-1,Math.min(1,-n[8]))),z:0}}function kr(n,e){return Vr(z(Rn(n.x,n.y,n.z),Rn(e.x,e.y,e.z)))}function Dr(n){return Math.max(0,Math.min(1,n))}function wn(n,e){return V(S(n.positionAt(e+1),n.positionAt(e-1)),.5)}function Fn(n,e){return Math.hypot(n.x,n.y,n.z)>1e-6?g(n):e}function _n(n,e,t){return n?typeof n=="function"?{transition:n,durationMs:t}:{transition:n.transition,durationMs:Math.max(0,n.durationMs??t)}:{transition:e,durationMs:t}}var me=class{constructor(e){this.handles=[];this.banks=[];this.headings=[];this.started=!1;this.finished=!1;this.introStart=0;this.outroStart=1/0;this.outroPosition={x:0,y:0,z:0};this.outroVelocity={x:0,y:0,z:0};this.outroDirection={x:1,y:0,z:0};let t=Vn(Rr(e.mesh),e.size??1),i=Fr(t,e.facing??"+x");this.mesh=wr(i,e.color),this.motion=e.motion,this.backend=e.backend,this.transparency=e.transparency,this.labelContent=e.label,this.fadeLabel=e.fadeLabel??!0,this.tailCount=Math.max(0,Math.floor(e.tail?.count??0)),this.tailGap=Math.max(0,e.tail?.gapMs??0),this.intro=_n(e.intro,Kt(),Er),this.outro=_n(e.outro,Zt(),Pr);let r=e.rotation;this.rotationOffset={x:r?.x??0,y:r?.y??0,z:r?.z??0},this.rotationSpin={x:r?.spinX??0,y:r?.spinY??0,z:r?.spinZ??0},this.hasExtraRotation=this.rotationOffset.x!==0||this.rotationOffset.y!==0||this.rotationOffset.z!==0||this.rotationSpin.x!==0||this.rotationSpin.y!==0||this.rotationSpin.z!==0}mount(e){e.style.position||(e.style.position="relative");let t=new P({backend:this.backend,camera:{position:{x:0,y:0,z:3}}});for(let i=0;i<=this.tailCount;i++)this.handles.push(t.add(this.mesh,{transparency:this.transparency})),this.banks.push(0),this.headings.push({x:1,y:0,z:0});this.engine=t,t.mount(e).catch(i=>{e.textContent=i instanceof Error?i.message:String(i)}),this.label=K(e,this.labelContent),this.fadeLabel&&this.label.setOpacity(0)}enter(e){this.started||(this.started=!0,this.introStart=e)}exit(e){!this.started||this.outroStart!==1/0||(this.outroPosition=this.motion.positionAt(e),this.outroVelocity=wn(this.motion,e),this.outroDirection=Fn(this.outroVelocity,this.headings[0]),this.outroStart=e)}isFinished(){return this.finished}get outroDurationMs(){return this.outro.durationMs}trailEmitter(){return{positionAt:e=>this.sampleAt(e)?.position??this.motion.positionAt(e)}}render(e,t){if(!(!this.engine||!this.label)){this.outroStart!==1/0&&e>=this.outroStart+this.outro.durationMs+this.tailCount*this.tailGap&&(this.finished=!0);for(let i=0;i<this.handles.length;i++){let r=this.handles[i].transform,o=e-i*this.tailGap,s=this.sampleAt(o);if(!s){r.scale=0;continue}r.scale=s.size;let a=s.orientation;if(!a){let c=S(this.positionAt(o+$t)??s.position,s.position);Math.hypot(c.x,c.y,c.z)>1e-5&&(this.headings[i]=g(c));let l=this.aheadAt(o)??this.headings[i],u=Math.max(-Cn,Math.min(Cn,T(this.headings[i],l).y*Lr));this.banks[i]+=(u-this.banks[i])*Ir,a=_r(this.headings[i],this.banks[i])}this.hasExtraRotation&&(a=kr(a,{x:this.rotationOffset.x+this.rotationSpin.x*o,y:this.rotationOffset.y+this.rotationSpin.y*o,z:this.rotationOffset.z+this.rotationSpin.z*o})),r.position.x=s.position.x,r.position.y=s.position.y,r.position.z=s.position.z,r.rotation.x=a.x,r.rotation.y=a.y,r.rotation.z=a.z}this.label.setText(t.indeterminate?typeof this.labelContent=="string"?this.labelContent:"":`${Math.round(t.progress*100)}%`),this.fadeLabel&&this.label.setOpacity(Q(e,this.started?this.introStart:1/0,this.intro.durationMs,this.outroStart,this.outro.durationMs)),this.engine.render()}}destroy(){this.label?.container.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.handles.length=0}aheadAt(e){let t=this.positionAt(e+$t),i=this.positionAt(e+2*$t);if(!t||!i)return;let r=S(i,t);if(!(Math.hypot(r.x,r.y,r.z)<=1e-5))return g(r)}positionAt(e){return this.sampleAt(e)?.position}sampleAt(e){if(!(!this.started||e<this.introStart)){if(e<this.introStart+this.intro.durationMs)return this.transitionSample("intro",e,this.intro,this.introStart);if(this.outroStart!==1/0){if(e>this.outroStart+this.outro.durationMs)return;if(e>=this.outroStart)return this.transitionSample("outro",e,this.outro,this.outroStart)}return{position:this.motion.positionAt(e),size:1}}}transitionSample(e,t,i,r){let o=Math.max(0,t-r),s=i.durationMs===0?1:Dr(o/i.durationMs),a=this.transitionInput(e,s,o,i.durationMs,r),c=i.transition(a);return this.applyTransitionOutput(a,c,e,t)}transitionInput(e,t,i,r,o){if(e==="intro"){let s=o+r,a=wn(this.motion,s);return{delta:t,position:this.motion.positionAt(s),direction:Fn(a,{x:1,y:0,z:0}),velocity:a,size:1,durationMs:r,elapsedMs:i,phase:e}}return{delta:t,position:this.outroPosition,direction:this.outroDirection,velocity:this.outroVelocity,size:1,durationMs:r,elapsedMs:i,phase:e}}applyTransitionOutput(e,t,i,r){return{position:t.position??(i==="intro"?this.motion.positionAt(r):e.position),size:t.size??e.size??1,orientation:t.orientation}}};var Xr=["#fde047","#fb923c","#f472b6","#60a5fa"],Nn=.15,Yr=.6;function Me(n,e,t){let i=(n^Math.imul(e+1,2654435769)^Math.imul(t+1,2246822507))>>>0;return i=Math.imul(i^i>>>16,73244475),i=Math.imul(i^i>>>16,73244475),i^=i>>>16,(i>>>0)/4294967296}function Bn(n,e,t){let i=Math.max(0,Math.min(1,(t-n)/(e-n)));return i*i*(3-2*i)}function Un(n,e){if(!Number.isFinite(n)||n<=0)throw new RangeError(`3d-spinner: ${e} must be a finite number greater than zero.`);return n}function qr(n){let e=g(n),t=Math.abs(e.y)<.99?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=g(T(t,e));return{d:e,right:i,up:T(e,i)}}function Gn(n={}){let e=Un(n.rate??20,"rate"),t=Un(n.lifeMs??1800,"lifeMs"),i=n.size??.16,r=n.speed??.6,o=n.gravity,s=n.spread??.5,a=Math.max(0,Math.min(1,n.opacity??.9)),c=n.spin??.002,l=n.alignToMotion??!1,u=n.seed??1,p=n.direction&&qr(n.direction),h=1e3/e,d=m=>{let b=Me(u,m,0),f=2*Math.PI*Me(u,m,1);if(!p){let E=2*b-1,_=Math.sqrt(Math.max(0,1-E*E));return{x:_*Math.cos(f),y:_*Math.sin(f),z:E}}let y=1-b*(1-Math.cos(s)),M=Math.sqrt(Math.max(0,1-y*y)),{d:x,right:v,up:I}=p;return{x:x.x*y+(v.x*Math.cos(f)+I.x*Math.sin(f))*M,y:x.y*y+(v.y*Math.cos(f)+I.y*Math.sin(f))*M,z:x.z*y+(v.z*Math.cos(f)+I.z*Math.sin(f))*M}};return{maxLive:Math.ceil(t*e/1e3)+1,spawnGapMs:h,lifeMs:t,sample(m,b){if(m<0)return;let f=b-m*h;if(f<0||f>=t)return;let y=f/1e3,M=d(m),x=r*(.6+.8*Me(u,m,2)),v=x*y,I=o?.5*y*y:0,E=f/t,_=l?Math.atan2(M.y*x+(o?.y??0)*y,M.x*x+(o?.x??0)*y):2*Math.PI*Me(u,m,3)+(2*Me(u,m,4)-1)*c*f;return{position:{x:M.x*v+(o?o.x*I:0),y:M.y*v+(o?o.y*I:0),z:M.z*v+(o?o.z*I:0)},roll:_,size:i*(.7+.6*Me(u,m,5)),opacity:a*Bn(0,Nn,E)*(1-Bn(Yr,1,E))}}}}var L=class{constructor(e={}){this.handles=[];this.fades=[];this.enterAt=1/0;this.exitAt=1/0;this.finished=!1;this.field=Gn(e),this.colors=e.colors??Xr,this.backend=e.backend,this.texture=e.texture,this.labelContent=e.label,this.fadeLabel=e.fadeLabel??!0,this.emitter=e.emitter,this.outroMs=Math.max(0,e.outroMs??0)}mount(e){e.style.position||(e.style.position="relative");let t=this.colors.map(s=>pe(1,[s])),i=this.texture,r=i?async s=>{let a=this.backend==="webgpu"?new(await Promise.resolve().then(()=>(it(),en))).WebGPUTexturedRenderer(s):this.backend==="webgl"?new(await Promise.resolve().then(()=>(ot(),tn))).WebGLTexturedRenderer(s):new(await Promise.resolve().then(()=>(on(),rn))).Canvas2DTexturedRenderer(s);for(let c of t)a.setTexture(c,i);return a}:this.backend,o=new P({backend:r,camera:{position:{x:0,y:0,z:3}},light:{intensity:0,ambient:1}});for(let s=0;s<this.field.maxLive;s++){let a={mode:"one-sided",opacity:0};this.fades.push(a),this.handles.push(o.add(t[s%t.length],{scale:0,transparency:a}))}this.engine=o,o.mount(e).catch(s=>{e.textContent=s instanceof Error?s.message:String(s)}),this.label=K(e,this.labelContent),this.fadeLabel&&this.label.setOpacity(0)}enter(e){this.enterAt===1/0&&(this.enterAt=e)}exit(e){this.exitAt===1/0&&(this.exitAt=e)}isFinished(){return this.finished}render(e,t){if(!(!this.engine||!this.label)){this.exitAt!==1/0&&e>=this.exitAt+this.outroMs+this.field.lifeMs&&(this.finished=!0);for(let i of this.handles)i.transform.scale=0;if(this.enterAt!==1/0){let i=e-this.enterAt,r=this.field.spawnGapMs,o=Math.max(0,Math.ceil((i-this.field.lifeMs)/r)),s=Math.floor(i/r);this.exitAt!==1/0&&(s=Math.min(s,Math.floor((this.exitAt-this.enterAt+this.outroMs)/r))),o=Math.max(o,s-this.field.maxLive+1);for(let a=o;a<=s;a++){let c=this.field.sample(a,i);if(!c)continue;let l=a%this.handles.length,u=this.handles[l].transform,p=this.emitter?.positionAt(this.enterAt+a*r);u.position.x=c.position.x+(p?.x??0),u.position.y=c.position.y+(p?.y??0),u.position.z=c.position.z+(p?.z??0),u.rotation.z=c.roll,u.scale=c.size,this.fades[l].opacity=c.opacity}}this.label.setText(t.indeterminate?typeof this.labelContent=="string"?this.labelContent:"":`${Math.round(t.progress*100)}%`),this.fadeLabel&&this.label.setOpacity(Q(e,this.enterAt,this.field.lifeMs*Nn,this.exitAt,this.field.lifeMs)),this.engine.render()}}destroy(){this.label?.container.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.handles.length=0,this.fades.length=0}};var D=10,Qr=3,Hn=.76,Kr=.36,Zr={mode:"two-sided",frontOpacity:.68,backOpacity:.87},Wn=1.2,Xn=.8,sn=Math.PI*2,$r=500,Jr=550,eo=2.5,to=250,an=250,cn=1300,Kn=600,Zn=45,Yn=Kn+(D-1)*Zn+150,no=420,io={x:0,y:0,z:50},qn={specular:[1,1,1],shininess:28},ro=["#67e8f9","#22d3ee","#0ea5e9","#38bdf8","#7dd3fc"],Qn=[["#e0f2fe","#bae6fd","#7dd3fc"],["#c7d2fe","#a5b4fc","#818cf8"],["#a5f3fc","#67e8f9","#22d3ee"]];function st(n){return Math.max(0,Math.min(1,n))}var Le=class{constructor(e={}){this.minis=[];this.blends=new Array(D).fill(0);this.offsets=new Array(D).fill(0);this.enterAt=1/0;this.exitAt=1/0;this.allOutAt=1/0;this.lastNow=0;this.finished=!1;this.orbitPeriodMs=e.orbitPeriodMs??6e3,this.backend=e.backend}mount(e){e.style.position||(e.style.position="relative");let t=new P({backend:this.backend,camera:{position:{x:0,y:0,z:Qr}}});this.center=t.add(Ee(1,2,ro,qn),{scale:0});for(let i=0;i<D;i++){let r=Ee(1,1,Qn[i%Qn.length],qn);this.minis.push(t.add(r,{scale:0,transparency:{...Zr}}))}this.engine=t,t.mount(e).catch(i=>{e.textContent=i instanceof Error?i.message:String(i)})}enter(e){this.enterAt===1/0&&(this.enterAt=e)}exit(e){this.exitAt===1/0&&(this.exitAt=e)}isFinished(){return this.finished}get outroEmitMs(){return an+cn+Yn}satelliteEmitter(e){return{positionAt:t=>{let i=[];for(let o=0;o<D;o++){let s=this.miniSample(o,t);s&&i.push(s.position)}if(i.length===0)return io;let r=Math.abs(Math.floor(t/e))%i.length;return i[r]}}}render(e,t){if(!this.engine||!this.center)return;if(this.enterAt===1/0){this.center.transform.scale=0;for(let o of this.minis)o.transform.scale=0;this.engine.render();return}let i=this.lastNow===0?16:Math.min(50,e-this.lastNow);this.lastNow=e,this.updateBlends(i,t.progress,e),this.updateSpread(i);let r=e-this.enterAt;this.center.transform.scale=this.centerScale(e,r),this.center.transform.rotation.x=r*2e-4,this.center.transform.rotation.y=r*5e-4;for(let o=0;o<D;o++){let s=this.minis[o].transform,a=this.miniSample(o,e);if(!a){s.scale=0;continue}s.position.x=a.position.x,s.position.y=a.position.y,s.position.z=a.position.z,s.scale=a.scale,s.rotation.y=r*.0012}this.engine.render()}destroy(){this.engine?.destroy(),this.engine=void 0,this.center=void 0,this.minis.length=0}updateBlends(e,t,i){let r=this.exitAt!==1/0,o=r?D:Math.min(D,Math.floor(t*D+1e-9)),s=e/Jr*(r?eo:1);for(let a=0;a<D;a++){let c=a<o?1:0,l=this.blends[a];c>l&&(a===0||this.blends[a-1]>=.6)?(this.blends[a]=Math.min(1,l+s),l===0&&(this.offsets[a]=this.slotAngle(a))):c<l&&(a===D-1||this.blends[a+1]<=.4)&&(this.blends[a]=Math.max(0,l-s))}r&&this.allOutAt===1/0&&this.blends.every(a=>a>=1)&&(this.allOutAt=i)}updateSpread(e){let t=1-Math.exp(-e/to);for(let i=0;i<D;i++)this.blends[i]<=0||(this.offsets[i]+=(this.slotAngle(i)-this.offsets[i])*t)}slotAngle(e){let t=Math.max(1,this.blends.filter(i=>i>0).length);return sn*Math.min(e,t-1)/t}baseAngleAt(e){let t=-sn*(e-this.enterAt)/this.orbitPeriodMs;if(this.allOutAt!==1/0){let i=st((e-this.allOutAt-an)/cn);t-=sn*de(i)}return t}reenterStart(){return this.allOutAt+an+cn}miniSample(e,t){let i=this.blends[e];if(i<=0)return;let r=ee(i),o=Kr*q(i);if(this.allOutAt!==1/0){let c=this.reenterStart()+e*Zn,l=se(st((t-c)/Kn));if(l>=1)return;r*=1-l,o*=1-l}let s=this.baseAngleAt(t)+this.offsets[e],a=Math.sin(s)*Wn*r;return{position:{x:Math.cos(s)*Wn*r,y:a*Math.cos(Xn),z:a*Math.sin(Xn)},scale:o}}centerScale(e,t){if(this.allOutAt!==1/0){let i=st((e-this.reenterStart()-Yn)/no);if(i>=1)return this.finished=!0,0;if(i>0)return Hn*(i<.35?1+.18*he(i/.35):1.18*(1-oe((i-.35)/.65)))}return Hn*q(st(t/$r))}};var ct=5,R=ct*ct,$n=4,Jn=55*Math.PI/180,ae=Math.PI*2,ii=900,ri=60,oo=(R-1)*ri+ii,so=.35,ao=.65,co=2.5,lo=2e3,ei=380,uo=80,po=1e3,Ie=700,ho=500,ti=170,mo=600,fo=["#8397c6","#7186b8","#6176a8","#93a6cf","#556a9c","#7a8fc0"],bo=[()=>te(1,fo)];function at(n){return Math.max(0,Math.min(1,n))}function yo(n){let e=at(n);return e*e*(3-2*e)}function xo(n){return typeof n=="function"?n():n}function ni(n){let e=n-ae*Math.floor(n/ae);return e>Math.PI?e-ae:e}function ze(n,e){let t=(Math.imul(n+1,2654435769)^Math.imul(e+1,2246822507))>>>0;return t=Math.imul(t^t>>>16,73244475),t^=t>>>16,(t>>>0)/4294967296}var Ce=class{constructor(e={}){this.handles=[];this.blends=new Array(R).fill(0);this.dockedAt=new Array(R).fill(1/0);this.tumbleX=[];this.tumbleY=[];this.collapseDelay=[];this.popStarted=new Array(R).fill(!1);this.maxCollapseDelay=0;this.fades=[];this.slots=[];this.aspect=16/9;this.enterAt=1/0;this.exitAt=1/0;this.allDockedAt=1/0;this.collapseAt=1/0;this.lastNow=0;this.finished=!1;let t=e.meshes&&e.meshes.length>0?e.meshes:bo;this.meshes=t.map(xo),this.size=e.size??.34,this.orbitPeriodMs=e.orbitPeriodMs??9e3,this.dockMs=e.dockMs??800,this.backend=e.backend,this.labelContent=e.label,this.fadeLabel=e.fadeLabel??!0;let i=this.size+(e.gap??.12);for(let r=0;r<R;r++){let o=Math.floor(r/ct),s=r%ct;this.slots.push({x:(s-2)*i,y:(2-o)*i,z:0}),this.tumbleX.push(ae*ze(r,2)-Math.PI),this.tumbleY.push(ae*ze(r,4)-Math.PI),this.collapseDelay.push(ze(r,7)*ho)}this.maxCollapseDelay=Math.max(...this.collapseDelay)}mount(e){e.style.position||(e.style.position="relative");let t=new P({backend:this.backend,camera:{position:{x:0,y:0,z:$n},fov:Jn}});for(let r=0;r<R;r++)this.fades.push({mode:"one-sided",opacity:1}),this.handles.push(t.add(this.meshes[r%this.meshes.length],{scale:0}));this.engine=t,t.mount(e).catch(r=>{e.textContent=r instanceof Error?r.message:String(r)});let i=()=>{e.clientWidth>0&&e.clientHeight>0&&(this.aspect=e.clientWidth/e.clientHeight)};i(),this.observer=new ResizeObserver(i),this.observer.observe(e),this.label=K(e,this.labelContent),this.fadeLabel&&this.label.setOpacity(0)}enter(e){this.enterAt===1/0&&(this.enterAt=e)}exit(e){this.exitAt===1/0&&(this.exitAt=e)}isFinished(){return this.finished}render(e,t){if(!this.engine||!this.label)return;if(this.enterAt===1/0){for(let r of this.handles)r.transform.scale=0;this.engine.render();return}let i=this.lastNow===0?16:Math.min(50,e-this.lastNow);this.lastNow=e,this.updateBlends(i,t.progress,e),this.exitAt!==1/0&&this.allDockedAt!==1/0&&this.collapseAt===1/0&&(this.collapseAt=Math.max(this.exitAt,this.allDockedAt)+po),e>=this.collapseAt?this.renderCollapse(e):this.renderStory(e,i),this.label.setText(t.indeterminate?typeof this.labelContent=="string"?this.labelContent:"":`${Math.round(t.progress*100)}%`),this.fadeLabel&&this.label.setOpacity(Q(e,this.enterAt,mo,this.collapseAt,Ie)),this.collapseAt!==1/0&&e>=this.collapseAt+this.maxCollapseDelay+Ie+ti&&(this.finished=!0),this.engine.render()}destroy(){this.observer?.disconnect(),this.observer=void 0,this.label?.container.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.handles.length=0,this.fades.length=0}updateBlends(e,t,i){let r=this.exitAt!==1/0,s=i-this.enterAt>=oo?r?R:Math.min(R,Math.floor(t*R+1e-9)):0,a=e/this.dockMs*(r?co:1);for(let l=0;l<R;l++){let u=l<s?1:0,p=this.blends[l];u>p&&(l===0||this.blends[l-1]>=so)?this.blends[l]=Math.min(1,p+a):u<p&&(l===R-1||this.blends[l+1]<=ao)&&(this.blends[l]=Math.max(0,p-a)),this.blends[l]>=1?this.dockedAt[l]===1/0&&(this.dockedAt[l]=i):this.dockedAt[l]=1/0}s===R&&this.blends.every(l=>l>=1)?this.allDockedAt===1/0&&(this.allDockedAt=i):r||(this.allDockedAt=1/0)}renderStory(e,t){let i=e-this.enterAt,r=Math.tan(Jn/2)*$n,o=r*this.aspect,s=Math.max(.6,Math.min(o,r)-this.size*.55),a=(Math.max(o,r)*1.25+this.size*2)/s;for(let c=0;c<R;c++){let l=this.handles[c].transform,u=yo(this.blends[c]),p=at((i-c*ri)/ii),h=1+(a-1)*(1-ee(p)),d=Math.PI/2-c/R*ae-i/this.orbitPeriodMs*ae,m=Math.cos(d)*s*h,b=Math.sin(d)*s*h,f=this.slots[c];if(l.position.x=m+(f.x-m)*u,l.position.y=b+(f.y-b)*u,l.position.z=0,l.scale=this.size,this.blends[c]===0&&(this.tumbleX[c]=ni(this.tumbleX[c]+(4e-4+8e-4*ze(c,1))*t),this.tumbleY[c]=ni(this.tumbleY[c]+(6e-4+.001*ze(c,3))*t)),l.rotation.z=0,this.blends[c]>=1){let y=(i+c*uo)%lo,M=y<ei&&e-y>=this.dockedAt[c];l.rotation.x=0,l.rotation.y=M?ae*de(y/ei):0}else{let y=1-u;l.rotation.x=this.tumbleX[c]*y,l.rotation.y=this.tumbleY[c]*y}}}renderCollapse(e){this.captured||(this.captured=this.handles.map(t=>({...t.transform.position})));for(let t=0;t<R;t++){let i=this.handles[t].transform,r=this.captured[t],o=e-this.collapseAt-this.collapseDelay[t];if(o<=0){i.position.x=r.x,i.position.y=r.y,i.position.z=r.z,i.scale=this.size;continue}let s=se(at(o/Ie));if(i.position.x=r.x*(1-s),i.position.y=r.y*(1-s),i.position.z=r.z*(1-s),i.scale=this.size*(1-.99*s),o>=Ie){this.popStarted[t]||(this.popStarted[t]=!0,this.handles[t].transparency=this.fades[t]);let a=at((o-Ie)/ti);this.fades[t].opacity=1-a,i.scale=a>=1?0:this.size*.01*(1+1.6*Math.sin(Math.PI*a))}}}};var H=class{constructor(e){this.elements=[];this.layers=e.map(t=>"animation"in t?t:{animation:t})}mount(e){e.style.position="relative";for(let[t,i]of this.layers.entries()){let r=document.createElement("div");r.style.cssText=`position:absolute;inset:0;z-index:${i.zIndex??t}`,e.appendChild(r),this.elements.push(r),i.animation.mount(r)}}enter(e){for(let t of this.layers)t.animation.enter(e)}exit(e){for(let t of this.layers)t.animation.exit(e)}render(e,t){for(let i of this.layers)i.animation.render(e,t)}isFinished(){return this.layers.every(e=>e.animation.isFinished())}destroy(){for(let e of this.layers)e.animation.destroy();for(let e of this.elements)e.remove();this.elements.length=0}};function Z(n,e){return{type:"indeterminate",animation:n,loop:e.loop,periodMs:e.periodMs}}function ce(n,e){return{type:"progress",animation:n,progress:e.progress??.001,timeout:e.timeout,until:e.until}}function oi(n={}){let e=n.particles??{},t=e.rate??60,i=new Le({backend:n.backend,...n.orb}),r=new L({rate:t,lifeMs:1200,size:.12,speed:.05,colors:["#ffffff","#a5f3fc","#818cf8"],texture:e.texture??re(),emitter:i.satelliteEmitter(1e3/t),outroMs:i.outroEmitMs,seed:5,backend:n.backend,...e,label:n.label??e.label,fadeLabel:n.fadeLabel??e.fadeLabel});return ce(new H([i,r]),n)}function ge(n={}){let e=n.size??1,t=n.periodMs??3600;return{positionAt(i){let r=i/t*Math.PI*2;return{x:e*1.5*Math.sin(r),y:e*1*Math.sin(r)*Math.cos(r),z:e*1.05*Math.cos(r)}}}}function si(n={}){let e=n.object?.motion??ge({size:.66,periodMs:7200}),t=n.particles??{},i=new me({mesh:()=>We(1,["#f0f9ff","#7dd3fc","#818cf8","#e879f9"]),motion:e,size:.42,rotation:{spinX:.002,spinY:.003},backend:n.backend,...n.object,label:n.object?.label}),r=new H([new L({rate:44,lifeMs:2300,size:.25,speed:.08,colors:["#ffffff","#bae6fd","#818cf8"],texture:t.texture??re(),emitter:i.trailEmitter(),outroMs:i.outroDurationMs,seed:28,backend:n.backend,...t,label:n.label??t.label??"Polishing pixels",fadeLabel:n.fadeLabel??t.fadeLabel}),i]);return Z(r,n)}function lt(n={}){let e=(n.size??2.4)/2,t=n.periodMs??4e3,i=n.tilt??.45,r=n.direction??1,o=Math.cos(i),s=Math.sin(i);return{positionAt(a){let c=r*a/t,l=(c-Math.floor(c))*4,u=Math.floor(l),p=l-u,h,d;return u===0?(h=-e+2*e*p,d=-e):u===1?(h=e,d=-e+2*e*p):u===2?(h=e-2*e*p,d=e):(h=-e,d=e-2*e*p),{x:h,y:d*o,z:d*s}}}}var ve=50,ui=3,pi=55*Math.PI/180,ai=Math.tan(pi/2)*ui,Mo=130,ci=320,go=8,vo=.4*Math.PI/180,Ao=4e3,Oo=1e3,li=1200,To={mode:"two-sided",opacity:.275},So=["#bae6fd","#7dd3fc","#38bdf8","#0ea5e9","#a5f3fc","#e0f2fe"],Eo={emissive:[.1,.2,.3]},Po={x:0,y:1,z:0};function Lo(n){return Math.max(0,Math.min(1,n))}function Io(n){let e=g(n),t=T(e,Po);Math.hypot(t.x,t.y,t.z)<1e-4&&(t={x:0,y:0,z:1}),t=g(t);let i=T(t,e),r=g(T(e,i));return{x:Math.atan2(T(r,e).z,r.z),y:Math.asin(Math.max(-1,Math.min(1,-e.z))),z:Math.atan2(e.y,e.x)}}function zo(n,e,t){let i=g(n),r=g(e),o=Math.max(-1,Math.min(1,W(i,r))),s=Math.acos(o);if(s<=t||s<1e-4)return r;let a=Math.sin(s);if(a<1e-4)return r;let c=t/s,l=Math.sin((1-c)*s)/a,u=Math.sin(c*s)/a;return g({x:i.x*l+r.x*u,y:i.y*l+r.y*u,z:i.z*l+r.z*u})}var ut=class{constructor(e={}){this.cars=[];this.appear=new Array(ve).fill(0);this.headings=new Array(ve).fill(void 0);this.aspect=16/9;this.enterAt=1/0;this.outroAt=1/0;this.carsAtOutro=0;this.exitPathTime=0;this.exitPoint={x:0,y:0,z:0};this.exitDir={x:1,y:0,z:0};this.exitSpeed=.001;this.lastNow=0;this.finished=!1;this.motion=e.motion??lt({size:1.7,periodMs:6800,tilt:.5}),this.size=e.size??.15,this.backend=e.backend,this.labelContent=e.label,this.fadeLabel=e.fadeLabel??!0}mount(e){e.style.position||(e.style.position="relative");let t=new P({backend:this.backend,camera:{position:{x:0,y:0,z:ui},fov:pi}}),i=te(1,So,Eo);for(let o=0;o<ve;o++)this.cars.push(t.add(i,{scale:0,transparency:{...To}}));this.engine=t,t.mount(e).catch(o=>{e.textContent=o instanceof Error?o.message:String(o)});let r=()=>{e.clientWidth>0&&e.clientHeight>0&&(this.aspect=e.clientWidth/e.clientHeight)};r(),this.observer=new ResizeObserver(r),this.observer.observe(e),this.label=K(e,this.labelContent),this.fadeLabel&&this.label.setOpacity(0)}enter(e){this.enterAt===1/0&&(this.enterAt=e)}exit(e){if(this.outroAt!==1/0||this.enterAt===1/0)return;this.outroAt=e,this.carsAtOutro=this.appear.filter(o=>o>.5).length,this.exitPathTime=e-this.enterAt;let t=this.motion.positionAt(this.exitPathTime),i=S(this.motion.positionAt(this.exitPathTime+1),this.motion.positionAt(this.exitPathTime-1)),r=Math.hypot(i.x,i.y,i.z);this.exitPoint=t,r>1e-6&&(this.exitSpeed=r/2),this.exitDir=r>1e-6?g(i):{x:1,y:0,z:0}}isFinished(){return this.finished}get outroDurationMs(){return li}trailEmitter(){return{positionAt:e=>this.enterAt===1/0?this.motion.positionAt(e):this.pathPosition(e-this.enterAt+this.warp(e))}}render(e,t){if(!this.engine||!this.label)return;for(let c of this.cars)c.transform.scale=0;if(this.enterAt===1/0){this.engine.render();return}let i=this.lastNow===0?16:Math.min(50,e-this.lastNow);this.lastNow=e;let r=this.outroAt!==1/0?this.carsAtOutro:Math.min(ve,Math.round(t.progress*ve)),o=ai*this.aspect,s=this.warp(e),a=!1;for(let c=0;c<ve;c++){let l=c<r?1:0;if(this.appear[c]=Lo(this.appear[c]+Math.sign(l-this.appear[c])*(i/ci)),this.appear[c]<=0){this.headings[c]=void 0;continue}let u=e-this.enterAt-c*Mo+s,p=this.pathPosition(u);if(Math.abs(p.x)>o+this.size||Math.abs(p.y)>ai+this.size)continue;let h=S(this.pathPosition(u+go),p),d=Math.hypot(h.x,h.y,h.z)>1e-5?h:this.headings[c]??{x:1,y:0,z:0};this.headings[c]=this.headings[c]?zo(this.headings[c],d,vo*i):g(d);let m=Io(this.headings[c]),b=this.cars[c].transform;b.position.x=p.x,b.position.y=p.y,b.position.z=p.z,b.rotation.x=m.x,b.rotation.y=m.y,b.rotation.z=m.z,b.scale=this.size*q(this.appear[c]),a=!0}this.label.setText(t.indeterminate?typeof this.labelContent=="string"?this.labelContent:"":`${Math.round(t.progress*100)}%`),this.fadeLabel&&this.label.setOpacity(Q(e,this.enterAt,ci,this.outroAt,li)),this.outroAt!==1/0&&e>this.outroAt+300&&(!a||e>=this.outroAt+Ao)&&(this.finished=!0),this.engine.render()}destroy(){this.observer?.disconnect(),this.observer=void 0,this.label?.container.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.cars.length=0}warp(e){if(this.outroAt===1/0)return 0;let t=(e-this.outroAt)/1e3;return .5*Oo*t*t}pathPosition(e){if(this.outroAt===1/0||e<=this.exitPathTime)return this.motion.positionAt(e);let t=this.exitSpeed*(e-this.exitPathTime);return{x:this.exitPoint.x+this.exitDir.x*t,y:this.exitPoint.y+this.exitDir.y*t,z:this.exitPoint.z+this.exitDir.z*t}}};function hi(n={}){let e=n.particles??{},t=new ut({motion:n.object?.motion,backend:n.backend}),i=new L({rate:30,lifeMs:1700,size:.15,speed:.11,colors:["#e0f2fe","#a5f3fc","#c4b5fd"],texture:e.texture??ie({glow:5}),emitter:t.trailEmitter(),outroMs:t.outroDurationMs,seed:17,backend:n.backend,...e,label:n.label??e.label,fadeLabel:n.fadeLabel??e.fadeLabel});return ce(new H([i,t]),n)}function di(n={}){return ce(new Ce({backend:n.backend,label:n.label,fadeLabel:n.fadeLabel,...n.assembly}),n)}function mi(n={}){let e=n.particles??{};return Z(new L({rate:70,lifeMs:2800,size:.38,speed:1.35,direction:{x:0,y:1,z:0},spread:.62,gravity:{x:0,y:-1.45,z:0},colors:["#fff","#000"],texture:e.texture??qe(),spin:0,alignToMotion:!0,seed:37,backend:n.backend,...e,label:n.label??e.label??"Loading...",fadeLabel:n.fadeLabel??e.fadeLabel}),n)}function fi(n={}){let e=n.object?.motion??ge({size:.72,periodMs:6200}),t=n.particles??{},i=new me({mesh:Ye,motion:e,size:.48,backend:n.backend,...n.object,label:n.object?.label}),r=new H([new L({rate:34,lifeMs:1900,size:.16,speed:.11,colors:["#fde047","#f472b6","#7dd3fc"],texture:t.texture??ie(),emitter:i.trailEmitter(),outroMs:i.outroDurationMs,seed:11,backend:n.backend,...t,label:n.label??t.label??"Flying in...",fadeLabel:n.fadeLabel??t.fadeLabel}),i]);return Z(r,n)}function Co(){let n=document.createElement("div");return n.innerHTML=`<style>
|
|
150
|
+
}`;rt=class{constructor(e={}){this.sources=new Map;this.textures=new Map;this.buffers=new Map;this.inner=new Oe(e)}setTexture(e,t){this.sources.set(e,t)}init(e){this.inner.init(e);let t=e.getContext("webgl2");this.gl=t,this.program=Hr(t),this.locations={aPos:t.getAttribLocation(this.program,"aPos"),aUV:t.getAttribLocation(this.program,"aUV"),aColor:t.getAttribLocation(this.program,"aColor"),uViewProj:t.getUniformLocation(this.program,"uViewProj"),uModel:t.getUniformLocation(this.program,"uModel"),uTexture:t.getUniformLocation(this.program,"uTexture"),uOpacity:t.getUniformLocation(this.program,"uOpacity")}}resize(){this.inner.resize()}textureFor(e){let t=this.textures.get(e);if(t)return t;let i=this.gl,r=i.createTexture();i.bindTexture(i.TEXTURE_2D,r),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array([255,255,255,255])),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),this.textures.set(e,r);let o=a=>{!this.gl||this.textures.get(e)!==r||(this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,a))},s=this.sources.get(e);if(typeof s=="string"){let a=new Image;a.onload=()=>o(a),a.src=s}else o(s);return r}buffersFor(e){let t=this.buffers.get(e);if(t)return t;let i=this.gl,r=this.locations,o=X(e),s=i.createVertexArray();i.bindVertexArray(s);let a=[],c=(u,p,d)=>{if(u<0)return;let h=i.createBuffer();a.push(h),i.bindBuffer(i.ARRAY_BUFFER,h),i.bufferData(i.ARRAY_BUFFER,p,i.STATIC_DRAW),i.enableVertexAttribArray(u),i.vertexAttribPointer(u,d,i.FLOAT,!1,0,0)};c(r.aPos,o.positions,3),c(r.aColor,o.colors,3),c(r.aUV,et(e),2),i.bindVertexArray(null);let l={vao:s,buffers:a,count:o.count};return this.buffers.set(e,l),l}render(e){let t=[],i=[];for(let s of e.items)(this.sources.has(s.mesh)?i:t).push(s);if(this.inner.render(i.length?{...e,items:t}:e),!i.length)return;let r=this.gl,o=this.locations;if(!(!r||!this.program||!o)){r.useProgram(this.program),r.uniformMatrix4fv(o.uViewProj,!1,new Float32Array(e.viewProjection)),r.uniform1i(o.uTexture,0),r.activeTexture(r.TEXTURE0),r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.depthMask(!1);for(let s of i){let a=this.buffersFor(s.mesh);r.bindTexture(r.TEXTURE_2D,this.textureFor(s.mesh)),r.uniformMatrix4fv(o.uModel,!1,new Float32Array(s.model)),r.uniform1f(o.uOpacity,Wr(s.transparency)),r.bindVertexArray(a.vao),r.drawArrays(r.TRIANGLES,0,a.count)}r.depthMask(!0),r.disable(r.BLEND),r.bindVertexArray(null)}}destroy(){let e=this.gl;if(e){for(let t of this.textures.values())e.deleteTexture(t);for(let t of this.buffers.values()){e.deleteVertexArray(t.vao);for(let i of t.buffers)e.deleteBuffer(i)}this.program&&e.deleteProgram(this.program)}this.textures.clear(),this.buffers.clear(),this.sources.clear(),this.gl=void 0,this.program=void 0,this.locations=void 0,this.inner.destroy()}}});var on={};le(on,{Canvas2DTexturedRenderer:()=>st});function Dn(n){if(n instanceof HTMLImageElement)return n.complete&&n.naturalWidth>0?{width:n.naturalWidth,height:n.naturalHeight}:void 0;if(n instanceof HTMLVideoElement)return n.readyState>=2?{width:n.videoWidth,height:n.videoHeight}:void 0;if(n instanceof SVGImageElement){let t=n.width.baseVal.value,i=n.height.baseVal.value;return t>0&&i>0?{width:t,height:i}:void 0}if(typeof VideoFrame<"u"&&n instanceof VideoFrame)return{width:n.displayWidth,height:n.displayHeight};let e=n;return e.width>0&&e.height>0?{width:e.width,height:e.height}:void 0}function jn(n,e,t,i){let[r,o,s]=t,[a,c,l]=i,u=r.x*(o.y-s.y)+o.x*(s.y-r.y)+s.x*(r.y-o.y);if(Math.abs(u)<1e-8)return;let p=(a.x*(o.y-s.y)+c.x*(s.y-r.y)+l.x*(r.y-o.y))/u,d=(a.x*(s.x-o.x)+c.x*(r.x-s.x)+l.x*(o.x-r.x))/u,h=(a.x*(o.x*s.y-s.x*o.y)+c.x*(s.x*r.y-r.x*s.y)+l.x*(r.x*o.y-o.x*r.y))/u,m=(a.y*(o.y-s.y)+c.y*(s.y-r.y)+l.y*(r.y-o.y))/u,b=(a.y*(s.x-o.x)+c.y*(r.x-s.x)+l.y*(o.x-r.x))/u,f=(a.y*(o.x*s.y-s.x*o.y)+c.y*(s.x*r.y-r.x*s.y)+l.y*(r.x*o.y-o.x*r.y))/u;n.save(),n.beginPath(),n.moveTo(a.x,a.y),n.lineTo(c.x,c.y),n.lineTo(l.x,l.y),n.closePath(),n.clip(),n.transform(p,m,d,b,h,f),n.drawImage(e,0,0),n.restore()}var st,at=U(()=>{"use strict";N();J();Ot();st=class{constructor(e={}){this.sources=new Map;this.loaded=new Map;this.dpr=1;this.inner=new Se(e)}setTexture(e,t){if(this.sources.set(e,t),typeof t=="string"&&!this.loaded.has(t)){let i=new Image;i.src=t,this.loaded.set(t,i)}}init(e){this.inner.init(e),this.ctx=e.getContext("2d")??void 0}resize(e,t,i){this.dpr=i,this.inner.resize(e,t,i)}drawable(e){let t=this.sources.get(e);return typeof t=="string"?this.loaded.get(t):t}render(e){let t=e.items.filter(o=>{if(!this.sources.has(o.mesh))return!0;let s=this.drawable(o.mesh);return!s||!Dn(s)});this.inner.render({...e,items:t});let i=this.ctx;if(!i)return;i.setTransform(this.dpr,0,0,this.dpr,0,0);let r=new Map;for(let o of e.items){let s=this.drawable(o.mesh);if(!s)continue;let a=Dn(s);if(!a)continue;let c=r.get(o.mesh);if(!c){c=document.createElement("canvas"),c.width=a.width,c.height=a.height;let f=c.getContext("2d");if(!f)continue;f.drawImage(s,0,0,a.width,a.height),f.globalCompositeOperation="source-in",f.fillStyle=o.mesh.faces[0]?.color??"#ffffff",f.fillRect(0,0,a.width,a.height),r.set(o.mesh,c)}let u=o.mesh.vertices.map(f=>fe(o.model,f)).map(f=>{let y=je(e.viewProjection,f);return{x:(y.x*.5+.5)*e.width,y:(1-(y.y*.5+.5))*e.height}}),p=o.mesh.faces[0];if(!p||p.indices.length!==4)continue;let[d,h,m,b]=p.indices.map(f=>u[f]);i.globalAlpha=o.transparency?.mode==="one-sided"?F(o.transparency.opacity,.35):1,jn(i,c,[{x:0,y:a.height},{x:a.width,y:a.height},{x:a.width,y:0}],[d,h,m]),jn(i,c,[{x:0,y:a.height},{x:a.width,y:0},{x:0,y:0}],[d,m,b])}i.globalAlpha=1}destroy(){this.inner.destroy(),this.ctx=void 0,this.sources.clear(),this.loaded.clear()}}});var as={};le(as,{Camera:()=>be,Canvas2DTexturedRenderer:()=>st,ChargedOrbAnimation:()=>Pe,CompositeAnimation:()=>H,GridAssemblyAnimation:()=>Ce,Light:()=>ye,Little3dEngine:()=>L,LittleTweenEngine:()=>dn,ObjectMotionAnimation:()=>me,ParticlesAnimation:()=>P,SpinAnimation:()=>Zt,WebGLTexturedRenderer:()=>rt,WebGPUTexturedRenderer:()=>nt,attachMaterial:()=>O,centerAndScaleMesh:()=>Vn,chargedOrb:()=>oi,circleMotion:()=>Ii,createSpinner:()=>Gi,cross:()=>T,crystalComet:()=>si,cube:()=>te,cubeSphere:()=>En,cubic:()=>Et,dot:()=>W,ease:()=>Ze,easeInBack:()=>Nt,easeInBounce:()=>Yt,easeInCirc:()=>jt,easeInCubic:()=>se,easeInElastic:()=>Ht,easeInExpo:()=>kt,easeInOutBack:()=>Gt,easeInOutBounce:()=>qt,easeInOutCirc:()=>Ut,easeInOutCubic:()=>de,easeInOutElastic:()=>Xt,easeInOutExpo:()=>Dt,easeInOutQuad:()=>Rt,easeInOutQuart:()=>Ft,easeInOutQuint:()=>Vt,easeInOutSine:()=>Ct,easeInQuad:()=>oe,easeInQuart:()=>Qe,easeInQuint:()=>Ke,easeInSine:()=>It,easeOutBack:()=>q,easeOutBounce:()=>xe,easeOutCirc:()=>Bt,easeOutCubic:()=>ee,easeOutElastic:()=>Wt,easeOutExpo:()=>Le,easeOutQuad:()=>he,easeOutQuart:()=>wt,easeOutQuint:()=>_t,easeOutSine:()=>zt,easeTypes:()=>Qt,enterFromObjectDirection:()=>$t,expandToTriangles:()=>X,figureEightMotion:()=>ge,ghostTrain:()=>hi,gridAssembly:()=>di,grow:()=>Or,icosphere:()=>Ee,leaveInObjectDirection:()=>Jt,linear:()=>Tt,monochromeStreak:()=>mi,normalize:()=>g,octaSphere:()=>Sn,octahedron:()=>On,orderRenderItems:()=>He,parseObj:()=>ss,particleField:()=>Gn,planeMesh:()=>Ye,planeStarTrail:()=>fi,pulsingStarfield:()=>bi,pyramid:()=>Xe,quad:()=>pe,quadratic:()=>St,quartic:()=>Lt,quintic:()=>Pt,rocketLaunch:()=>Li,scale:()=>V,shineTexture:()=>re,shrink:()=>Tr,squareMotion:()=>pt,starSwarm:()=>Pi,starTexture:()=>ie,streakTexture:()=>qe,subtract:()=>S,tetrahedron:()=>We,transform:()=>Ne,uvSphere:()=>Tn,vec3:()=>fn,wanderMotion:()=>mt});function mn(n){return Number.isNaN(n)?0:Math.min(1,Math.max(0,n))}function Ni(n,e,t){return n+(e-n)*t}function Gi(n,e){if(!(n instanceof HTMLElement))throw new Error("3d-spinner: createSpinner requires a target HTMLElement.");let{animation:t}=e,i=e.type==="indeterminate";if(i&&e.periodMs!==void 0&&(!Number.isFinite(e.periodMs)||e.periodMs<=0))throw new RangeError("3d-spinner: periodMs must be a finite number greater than zero.");t.mount(n);let r=performance.now(),o=0,s=!1,a=!1,c=!1,l=!1,u=0,p=0,d=1/0;if(!i){let x=e;typeof x.progress=="number"&&(u=mn(x.progress),p=u),typeof x.timeout=="number"&&(d=Math.min(d,r+x.timeout)),x.until instanceof Date&&(d=Math.min(d,x.until.getTime()))}function h(x){if(!i)return x>=d&&(p=1),u=Ni(u,p,.12),Math.abs(p-u)<5e-4&&(u=p),u;let v=e,I=v.periodMs??2e3,E=(x-r)/I;if((v.loop??"bounce")==="restart")return E-Math.floor(E);let _=E-2*Math.floor(E/2);return _<=1?_:2-_}function m(x){if(s)return;let v=h(x);!c&&(i||v>0)&&(t.enter(x),c=!0),!l&&c&&!i&&v>=1&&p>=1&&(t.exit(x),l=!0);let I=i?v:p;if(t.render(x,{progress:v,targetProgress:I,indeterminate:i}),l&&t.isFinished()){b();return}o=requestAnimationFrame(m)}function b(){s||(s=!0,o&&cancelAnimationFrame(o),o=0)}function f(x){i||(p=mn(x))}function y(){if(!(s||l)){if(!c){b();return}t.exit(performance.now()),l=!0}}function M(){a||(a=!0,b(),t.destroy())}return o=requestAnimationFrame(m),{setProgress:f,stop:y,destroy:M}}N();var Hi={position:{x:0,y:0,z:4},fov:55*Math.PI/180,near:.1,far:100},be=class{constructor(e){this.options={...Hi,...e}}toView(e){let{position:t}=this.options;return fe(Ae(-t.x,-t.y,-t.z),e)}viewProjection(e){let{position:t,fov:i,near:r,far:o}=this.options,s=Ae(-t.x,-t.y,-t.z),a=yn(i,e,r,o);return z(a,s)}toScreen(e,t,i){return{x:(e.x*.5+.5)*t,y:(1-(e.y*.5+.5))*i}}};Ue();N();function O(n,e){if(e)for(let t of n.faces)t.material=e;return n}function Ne(n){return{position:n?.position??{x:0,y:0,z:0},rotation:n?.rotation??{x:0,y:0,z:0},scale:n?.scale??1}}J();Ue();var Ji=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"];function te(n=1,e=Ji,t){let i=n/2,r=[{x:-i,y:-i,z:i},{x:i,y:-i,z:i},{x:i,y:i,z:i},{x:-i,y:i,z:i},{x:-i,y:-i,z:-i},{x:i,y:-i,z:-i},{x:i,y:i,z:-i},{x:-i,y:i,z:-i}],o=[{indices:[0,1,2,3],color:e[0%e.length]},{indices:[5,4,7,6],color:e[1%e.length]},{indices:[3,2,6,7],color:e[2%e.length]},{indices:[4,5,1,0],color:e[3%e.length]},{indices:[1,5,6,2],color:e[4%e.length]},{indices:[4,0,3,7],color:e[5%e.length]}];return O({vertices:r,faces:o},t)}var er=["#3b82f6"];function pe(n=1,e=er,t){let i=n/2,r=[{x:-i,y:-i,z:0},{x:i,y:-i,z:0},{x:i,y:i,z:0},{x:-i,y:i,z:0}];return O({vertices:r,faces:[{indices:[0,1,2,3],color:e[0]}]},t)}var tr=["#3b82f6","#8b5cf6","#ec4899","#f59e0b"];function We(n=1,e=tr,t){let i=n/2,r=[{x:i,y:i,z:i},{x:i,y:-i,z:-i},{x:-i,y:i,z:-i},{x:-i,y:-i,z:i}],o=[{indices:[0,1,2],color:e[0%e.length]},{indices:[0,3,1],color:e[1%e.length]},{indices:[0,2,3],color:e[2%e.length]},{indices:[1,3,2],color:e[3%e.length]}];return O({vertices:r,faces:o},t)}var nr=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444","#06b6d4","#eab308"];function On(n=1,e=nr,t){let i=n/2,r=[{x:i,y:0,z:0},{x:-i,y:0,z:0},{x:0,y:i,z:0},{x:0,y:-i,z:0},{x:0,y:0,z:i},{x:0,y:0,z:-i}],o=[{indices:[4,0,2],color:e[0%e.length]},{indices:[4,2,1],color:e[1%e.length]},{indices:[4,1,3],color:e[2%e.length]},{indices:[4,3,0],color:e[3%e.length]},{indices:[5,2,0],color:e[4%e.length]},{indices:[5,1,2],color:e[5%e.length]},{indices:[5,3,1],color:e[6%e.length]},{indices:[5,0,3],color:e[7%e.length]}];return O({vertices:r,faces:o},t)}var ir=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981"];function Xe(n=1,e=ir,t){let i=n/2,r=[{x:-i,y:-i,z:i},{x:i,y:-i,z:i},{x:i,y:-i,z:-i},{x:-i,y:-i,z:-i},{x:0,y:i,z:0}],o=[{indices:[0,3,2,1],color:e[0%e.length]},{indices:[4,0,1],color:e[1%e.length]},{indices:[4,1,2],color:e[2%e.length]},{indices:[4,2,3],color:e[3%e.length]},{indices:[4,3,0],color:e[4%e.length]}];return O({vertices:r,faces:o},t)}var rr=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"];function Tn(n=1,e=1,t=rr,i){let r=n/2,o=Math.max(1,Math.floor(e)),s=Math.max(4,o*4),a=Math.max(2,o*2),c=[{x:0,y:r,z:0}],l=(m,b)=>1+(m-1)*s+b;for(let m=1;m<a;m++){let b=Math.PI*m/a,f=r*Math.cos(b),y=r*Math.sin(b);for(let M=0;M<s;M++){let x=2*Math.PI*M/s;c.push({x:y*Math.cos(x),y:f,z:y*Math.sin(x)})}}let u=c.length;c.push({x:0,y:-r,z:0});let p=[],d=0,h=()=>t[d++%t.length];for(let m=0;m<s;m++)p.push({indices:[0,l(1,(m+1)%s),l(1,m)],color:h()});for(let m=1;m<a-1;m++)for(let b=0;b<s;b++){let f=(b+1)%s;p.push({indices:[l(m,b),l(m,f),l(m+1,f),l(m+1,b)],color:h()})}for(let m=0;m<s;m++)p.push({indices:[u,l(a-1,m),l(a-1,(m+1)%s)],color:h()});return O({vertices:c,faces:p},i)}$();var or=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"],k=(1+Math.sqrt(5))/2,sr=[{x:-1,y:k,z:0},{x:1,y:k,z:0},{x:-1,y:-k,z:0},{x:1,y:-k,z:0},{x:0,y:-1,z:k},{x:0,y:1,z:k},{x:0,y:-1,z:-k},{x:0,y:1,z:-k},{x:k,y:0,z:-1},{x:k,y:0,z:1},{x:-k,y:0,z:-1},{x:-k,y:0,z:1}],ar=[[0,11,5],[0,5,1],[0,1,7],[0,7,10],[0,10,11],[1,5,9],[5,11,4],[11,10,2],[10,7,6],[7,1,8],[3,9,4],[3,4,2],[3,2,6],[3,6,8],[3,8,9],[4,9,5],[2,4,11],[6,2,10],[8,6,7],[9,8,1]];function Ee(n=1,e=1,t=or,i){return O(Be(sr,ar,n,e,t),i)}$();var cr=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"],lr=[{x:1,y:0,z:0},{x:-1,y:0,z:0},{x:0,y:1,z:0},{x:0,y:-1,z:0},{x:0,y:0,z:1},{x:0,y:0,z:-1}],ur=[[4,0,2],[4,2,1],[4,1,3],[4,3,0],[5,2,0],[5,1,2],[5,3,1],[5,0,3]];function Sn(n=1,e=1,t=cr,i){return O(Be(lr,ur,n,e,t),i)}var pr=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"],hr=[{normal:[0,0,1],right:[1,0,0],up:[0,1,0]},{normal:[0,0,-1],right:[-1,0,0],up:[0,1,0]},{normal:[1,0,0],right:[0,0,-1],up:[0,1,0]},{normal:[-1,0,0],right:[0,0,1],up:[0,1,0]},{normal:[0,1,0],right:[1,0,0],up:[0,0,-1]},{normal:[0,-1,0],right:[1,0,0],up:[0,0,1]}];function En(n=1,e=1,t=pr,i){let r=n/2,o=Math.max(1,Math.floor(e)),s=[],a=[],c=0;for(let l of hr){let u=s.length;for(let d=0;d<=o;d++)for(let h=0;h<=o;h++){let m=-1+2*d/o,b=-1+2*h/o,f=l.normal[0]+m*l.right[0]+b*l.up[0],y=l.normal[1]+m*l.right[1]+b*l.up[1],M=l.normal[2]+m*l.right[2]+b*l.up[2],x=Math.hypot(f,y,M);s.push({x:f/x*r,y:y/x*r,z:M/x*r})}let p=(d,h)=>u+d*(o+1)+h;for(let d=0;d<o;d++)for(let h=0;h<o;h++)a.push({indices:[p(d,h),p(d+1,h),p(d+1,h+1),p(d,h+1)],color:t[c++%t.length]})}return O({vertices:s,faces:a},i)}var C=["#e0f2fe","#7dd3fc","#38bdf8","#f8fafc"];function Ye(n=C,e){return O({vertices:[{x:.9,y:0,z:0},{x:-.2,y:0,z:.82},{x:-.55,y:0,z:.16},{x:-.72,y:0,z:0},{x:-.55,y:0,z:-.16},{x:-.2,y:0,z:-.82},{x:-.08,y:.12,z:0},{x:-.08,y:-.1,z:0},{x:-.52,y:.38,z:0}],faces:[{indices:[6,1,0],color:n[0]??C[0]},{indices:[6,2,1],color:n[3]??C[3]},{indices:[6,3,2],color:n[1]??C[1]},{indices:[6,4,3],color:n[2]??C[2]},{indices:[6,5,4],color:n[3]??C[3]},{indices:[6,0,5],color:n[0]??C[0]},{indices:[7,0,1],color:n[1]??C[1]},{indices:[7,1,2],color:n[2]??C[2]},{indices:[7,2,3],color:n[1]??C[1]},{indices:[7,3,4],color:n[2]??C[2]},{indices:[7,4,5],color:n[1]??C[1]},{indices:[7,5,0],color:n[2]??C[2]},{indices:[3,6,8],color:n[0]??C[0]},{indices:[3,8,6],color:n[1]??C[1]}]},e)}function ne(n,e=96){let t=document.createElement("canvas");t.width=t.height=e;let i=t.getContext("2d");return i&&n(i),t}function Ln(n){n.save(),n.translate(48,48),n.fillStyle="#fff",n.beginPath();for(let e=0;e<10;e++){let t=e%2===0?43:16,i=e*Math.PI/5-Math.PI/2;n.lineTo(t*Math.cos(i),t*Math.sin(i))}n.closePath(),n.fill(),n.restore()}function ie(n={}){let e=Math.max(0,n.glow??0);return ne(t=>{e>0&&(t.save(),t.filter=`blur(${e}px)`,Ln(t),t.restore()),Ln(t)})}function re(){return ne(n=>{let e=n.createRadialGradient(48,48,1,48,48,46);e.addColorStop(0,"rgba(255,255,255,1)"),e.addColorStop(.08,"rgba(255,255,255,1)"),e.addColorStop(.22,"rgba(210,240,255,0.7)"),e.addColorStop(.55,"rgba(120,200,255,0.22)"),e.addColorStop(1,"rgba(80,160,255,0)"),n.fillStyle=e,n.fillRect(0,0,96,96)})}function qe(){return ne(n=>{let e=n.createLinearGradient(5,0,91,0);e.addColorStop(0,"rgba(255,255,255,0)"),e.addColorStop(.7,"rgba(255,255,255,0.4)"),e.addColorStop(1,"rgba(255,255,255,1)"),n.strokeStyle=e,n.lineWidth=3.5,n.lineCap="round",n.beginPath(),n.moveTo(5,48),n.lineTo(91,48),n.stroke()})}$();J();N();function dr(n){let e=z(De(n.rotation.z),z(ke(n.rotation.y),Ve(n.rotation.x)));return z(Ae(n.position.x,n.position.y,n.position.z),z(e,bn(n.scale)))}var L=class{constructor(e={}){this.scene=[];this.cssWidth=0;this.cssHeight=0;this.ready=!1;this.generation=0;this.rafId=0;this.running=!1;this.camera=new be(e.camera),this.light=new ye(e.light),this.backend=e.backend??"canvas2d",this.background=e.background}async mount(e){let t=document.createElement("canvas");t.style.display="block",t.style.width="100%",t.style.height="100%",e.appendChild(t),this.canvas=t,this.observer=new ResizeObserver(()=>this.resize()),this.observer.observe(t),this.resize();let i=this.generation,r=()=>{this.canvas===t&&(this.observer?.disconnect(),this.observer=void 0,t.remove(),this.canvas=void 0)};try{let o=await An(this.backend,{background:this.background});if(i!==this.generation){o.destroy(),r();return}if(await o.init(t),i!==this.generation){o.destroy(),r();return}this.renderer=o,this.resize(),this.ready=!0}catch(o){throw r(),o}}add(e,t){let i={mesh:e,transform:Ne(t),transparency:t?.transparency,remove:()=>{let r=this.scene.indexOf(i);r>=0&&this.scene.splice(r,1)}};return this.scene.push(i),i}resize(){let e=this.canvas;if(!e)return;let t=window.devicePixelRatio||1;this.cssWidth=e.clientWidth||e.parentElement?.clientWidth||0,this.cssHeight=e.clientHeight||e.parentElement?.clientHeight||0,e.width=Math.max(1,Math.round(this.cssWidth*t)),e.height=Math.max(1,Math.round(this.cssHeight*t)),this.renderer?.resize(this.cssWidth,this.cssHeight,t)}render(){if(!this.ready||!this.renderer)return;let e=this.cssWidth,t=this.cssHeight;if(e===0||t===0)return;let i=this.scene.map(o=>({mesh:o.mesh,model:dr(o.transform),transparency:o.transparency})),r=this.camera.options.position;this.renderer.render({items:He(i,r),viewProjection:this.camera.viewProjection(e/t),eye:r,light:this.light.params,width:e,height:t})}start(){if(this.running)return;this.running=!0;let e=()=>{this.running&&(this.render(),this.rafId=requestAnimationFrame(e))};this.rafId=requestAnimationFrame(e)}stop(){this.running=!1,this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0}destroy(){this.generation++,this.ready=!1,this.stop(),this.observer?.disconnect(),this.observer=void 0,this.renderer?.destroy(),this.renderer=void 0,this.canvas?.remove(),this.canvas=void 0}};function A(n,e){return Number.isNaN(n)?0:e?n:Math.min(1,Math.max(0,n))}function Tt(n,e=!1){return A(n,e)}function St(n,e=!1){return oe(n,e)}function Et(n,e=!1){return se(n,e)}function Lt(n,e=!1){return Qe(n,e)}function Pt(n,e=!1){return Ke(n,e)}function It(n,e=!1){let t=A(n,e);return 1-Math.cos(t*Math.PI/2)}function zt(n,e=!1){let t=A(n,e);return Math.sin(t*Math.PI/2)}function Ct(n,e=!1){let t=A(n,e);return-(Math.cos(Math.PI*t)-1)/2}function oe(n,e=!1){let t=A(n,e);return t*t}function he(n,e=!1){let t=A(n,e);return 1-(1-t)*(1-t)}function Rt(n,e=!1){let t=A(n,e);return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2}function se(n,e=!1){let t=A(n,e);return t*t*t}function ee(n,e=!1){let t=A(n,e);return 1-Math.pow(1-t,3)}function de(n,e=!1){let t=A(n,e);return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}function Qe(n,e=!1){let t=A(n,e);return t*t*t*t}function wt(n,e=!1){let t=A(n,e);return 1-Math.pow(1-t,4)}function Ft(n,e=!1){let t=A(n,e);return t<.5?8*t*t*t*t:1-Math.pow(-2*t+2,4)/2}function Ke(n,e=!1){let t=A(n,e);return t*t*t*t*t}function _t(n,e=!1){let t=A(n,e);return 1-Math.pow(1-t,5)}function Vt(n,e=!1){let t=A(n,e);return t<.5?16*t*t*t*t*t:1-Math.pow(-2*t+2,5)/2}function kt(n,e=!1){let t=A(n,e);return t===0?0:Math.pow(2,10*t-10)}function Le(n,e=!1){let t=A(n,e);return t===1?1:1-Math.pow(2,-10*t)}function Dt(n,e=!1){let t=A(n,e);return t===0?0:t===1?1:t<.5?Math.pow(2,20*t-10)/2:(2-Math.pow(2,-20*t+10))/2}function jt(n,e=!1){let t=A(n,e);return 1-Math.sqrt(1-Math.pow(t,2))}function Bt(n,e=!1){let t=A(n,e);return Math.sqrt(1-Math.pow(t-1,2))}function Ut(n,e=!1){let t=A(n,e);return t<.5?(1-Math.sqrt(1-Math.pow(2*t,2)))/2:(Math.sqrt(1-Math.pow(-2*t+2,2))+1)/2}function Nt(n,e=!1){let t=A(n,e),i=1.70158;return(i+1)*t*t*t-i*t*t}function q(n,e=!1){let t=A(n,e),i=1.70158;return 1+(i+1)*Math.pow(t-1,3)+i*Math.pow(t-1,2)}function Gt(n,e=!1){let t=A(n,e),r=1.70158*1.525;return t<.5?Math.pow(2*t,2)*((r+1)*2*t-r)/2:(Math.pow(2*t-2,2)*((r+1)*(t*2-2)+r)+2)/2}function Ht(n,e=!1){let t=A(n,e),i=2*Math.PI/3;return t===0?0:t===1?1:-Math.pow(2,10*t-10)*Math.sin((t*10-10.75)*i)}function Wt(n,e=!1){let t=A(n,e),i=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*i)+1}function Xt(n,e=!1){let t=A(n,e),i=2*Math.PI/4.5;return t===0?0:t===1?1:t<.5?-(Math.pow(2,20*t-10)*Math.sin((20*t-11.125)*i))/2:Math.pow(2,-20*t+10)*Math.sin((20*t-11.125)*i)/2+1}function Yt(n,e=!1){let t=A(n,e);return 1-xe(1-t,!0)}function xe(n,e=!1){let t=A(n,e),i=7.5625,r=2.75;return t<1/r?i*t*t:t<2/r?(t-=1.5/r,i*t*t+.75):t<2.5/r?(t-=2.25/r,i*t*t+.9375):(t-=2.625/r,i*t*t+.984375)}function qt(n,e=!1){let t=A(n,e);return t<.5?(1-xe(1-2*t,!0))/2:(1+xe(2*t-1,!0))/2}var Qt={linear:Tt,quadratic:St,cubic:Et,quartic:Lt,quintic:Pt,easeInSine:It,easeOutSine:zt,easeInOutSine:Ct,easeInQuad:oe,easeOutQuad:he,easeInOutQuad:Rt,easeInCubic:se,easeOutCubic:ee,easeInOutCubic:de,easeInQuart:Qe,easeOutQuart:wt,easeInOutQuart:Ft,easeInQuint:Ke,easeOutQuint:_t,easeInOutQuint:Vt,easeInExpo:kt,easeOutExpo:Le,easeInOutExpo:Dt,easeInCirc:jt,easeOutCirc:Bt,easeInOutCirc:Ut,easeInBack:Nt,easeOutBack:q,easeInOutBack:Gt,easeInElastic:Ht,easeOutElastic:Wt,easeInOutElastic:Xt,easeInBounce:Yt,easeOutBounce:xe,easeInOutBounce:qt};function Ze(n,e,t=!1){return Qt[n](e,t)}function mr(n={}){return{popDurationMs:n.popDurationMs??500,overextend:n.overextend??.2,startSnapRatio:n.startSnapRatio??.2,loadingText:n.loadingText===void 0?"loading":n.loadingText,doneText:n.doneText??"done",doneFadeDurationMs:n.doneFadeDurationMs??2e3,removeOnComplete:n.removeOnComplete??!1}}function Kt(n,e,t){return t<=0?1:Math.min(1,Math.max(0,(n-e)/t))}var $e=class{constructor(e={}){this.phase="idle";this.phaseStart=0;this.activeProgress=0;this.popTarget=0;this.doneFadeStart=0;this.options=mr(e)}enter(e){this.phase==="idle"&&(this.phase="startPop",this.phaseStart=e,this.activeProgress=0,this.popTarget=0)}exit(e){this.phase!=="startPop"&&this.phase!=="active"||(this.phase="endPop",this.phaseStart=e)}isFinished(){return this.phase==="finished"}update(e,t,i){let{popDurationMs:r,overextend:o,startSnapRatio:s,loadingText:a,doneText:c,doneFadeDurationMs:l,removeOnComplete:u}=this.options,p=i??t;(this.phase==="startPop"||this.phase==="active")&&(this.activeProgress=t,this.phase==="startPop"&&(this.popTarget=Math.max(this.popTarget,p,t)));let d=0,h=null,m=0,b=!1;if(this.phase==="startPop"){let f=Kt(e,this.phaseStart,r),y=this.popTarget*(1+o);if(f<s){let M=s>0?f/s:1;d=y*Le(M)}else{let M=s<1?(f-s)/(1-s):1;d=y+(this.activeProgress-y)*ee(M)}f>=1&&(this.phase="active")}else if(this.phase==="active")d=this.activeProgress;else if(this.phase==="endPop"){let f=Kt(e,this.phaseStart,r),y=1+o;f<.5?d=1+(y-1)*he(f*2):d=y*(1-oe((f-.5)*2)),f>=1&&(this.phase="done",this.doneFadeStart=e,d=0)}if(this.phase==="startPop"||this.phase==="active")a!==!1&&(h=a,m=.65);else if(this.phase==="endPop")h=c,m=.65;else if(this.phase==="done"){let f=Kt(e,this.doneFadeStart,l);f>=1?(u&&(b=!0),this.phase="finished"):(h=c,m=.65*(1-f))}return{scale:d,text:h,textOpacity:m,hidden:b}}};var fr=["position:absolute","inset:0","display:flex","align-items:center","justify-content:center","pointer-events:none","font:600 1.1rem/1.2 system-ui,sans-serif","letter-spacing:0.06em","text-transform:lowercase","color:rgba(255,255,255,0.65)","z-index:1"].join(";");function br(n){return n?typeof n=="function"?n():n:te()}function yr(n,e){if(e===void 0||Array.isArray(e)&&e.length===0)return n;let t=Array.isArray(e)?i=>e[i%e.length]:()=>e;return{vertices:n.vertices,faces:n.faces.map((i,r)=>({...i,color:t(r)}))}}function xr(n,e){return e?{vertices:n.vertices,faces:n.faces.map(t=>({...t,material:e}))}:n}var Zt=class{constructor(e={}){this.exited=!1;this.mesh=xr(yr(br(e.shape),e.color),e.material),this.spinX=e.spinX??7e-4,this.spinY=e.spinY??.0011,this.backend=e.backend,this.transparency=e.transparency,this.progress=e.progressAnimation?new $e(e.progressAnimation):void 0}mount(e){e.style.position="relative";let t=new L({backend:this.backend,camera:{position:{x:0,y:0,z:2.8}}});if(this.handle=t.add(this.mesh,{transparency:this.transparency}),this.engine=t,t.mount(e).catch(i=>{e.textContent=i instanceof Error?i.message:String(i)}),this.progress){let i=document.createElement("div");i.style.cssText=fr,i.setAttribute("aria-hidden","true"),i.hidden=!0,e.appendChild(i),this.label=i}}enter(e){this.progress?.enter(e)}exit(e){this.exited=!0,this.progress?.exit(e)}isFinished(){return this.progress?this.progress.isFinished():this.exited}render(e,t){if(!this.engine||!this.handle)return;let i=this.handle.transform.rotation;if(i.x=e*this.spinX,i.y=e*this.spinY,this.progress){let r=this.progress.update(e,t.progress,t.targetProgress);this.handle.transform.scale=r.hidden?0:r.scale,this.applyLabel(r)}else this.handle.transform.scale=1;this.engine.render()}destroy(){this.label?.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.handle=void 0}applyLabel(e){if(this.label){if(e.hidden||e.text==null){this.label.hidden=!0,this.label.textContent="";return}this.label.hidden=!1,this.label.textContent=e.text,this.label.style.opacity=String(e.textOpacity)}}};var Mr=["position:absolute","inset:0","display:flex","align-items:center","justify-content:center","pointer-events:none","font:700 1.6rem/1 system-ui,sans-serif","letter-spacing:0.02em","color:rgba(255,255,255,0.9)","text-shadow:0 1px 10px rgba(0,0,0,0.6)","z-index:1"].join(";");function Q(n,e,t,i,r){if(e===1/0)return 0;let o=t<=0?1:Math.max(0,Math.min(1,(n-e)/t)),s=i===1/0?1:r<=0?0:Math.max(0,Math.min(1,1-(n-i)/r));return Math.min(o,s)}function K(n,e){var i;let t=document.createElement("div");return t.style.cssText=Mr,t.setAttribute("role","status"),typeof e=="string"?t.textContent=e:e&&((i=e.style).pointerEvents||(i.pointerEvents="auto"),t.appendChild(e)),n.appendChild(t),{container:t,setText(r){typeof e!="object"&&(t.textContent=r)},setOpacity(r){t.style.opacity=String(r)}}}N();function Pn(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function Je(n,e){return{x:n.x*e,y:n.y*e,z:n.z*e}}function In(n){return Math.hypot(n.x,n.y,n.z)}function gr(n){let e=In(n);return e<1e-6?{x:1,y:0,z:0}:Je(n,1/e)}function vr(n,e){return gr(e??n.direction??n.velocity??{x:1,y:0,z:0})}function Ar(n){let t=n-1;return 1+(1.70158+1)*t*t*t+1.70158*t*t}function zn(n,e,t){let i=n.velocity?In(n.velocity):0;if(n.velocity&&i>1e-6&&!e.direction)return n.velocity;let r=e.distance??3.5;return Je(vr(n,e.direction),r/t)}function $t(n={}){return e=>{let t=Math.max(1,e.durationMs),i=zn(e,n,t),r=t-e.elapsedMs;return{position:Pn(e.position,Je(i,-r))}}}function Jt(n={}){return e=>{let t=Math.max(1,e.durationMs),i=zn(e,n,t);return{position:Pn(e.position,Je(i,e.elapsedMs))}}}function Or(){return n=>({size:(n.size??1)*Ar(n.delta)})}function Tr(){return n=>({size:(n.size??1)*(1-n.delta*n.delta)})}var Sr={x:0,y:1,z:0},Er=2100,Lr=2100,Pr=26,Cn=.7,Ir=.12,en=8,zr={"+x":n=>n,"-x":n=>({x:-n.x,y:n.y,z:-n.z}),"+z":n=>({x:n.z,y:n.y,z:-n.x}),"-z":n=>({x:-n.z,y:n.y,z:n.x}),"+y":n=>({x:n.y,y:-n.x,z:n.z}),"-y":n=>({x:-n.y,y:n.x,z:n.z})};function Cr(n,e){return{x:n.x+e.x,y:n.y+e.y,z:n.z+e.z}}function Rr(n){return typeof n=="function"?n():n}function wr(n,e){return e===void 0?n:{vertices:n.vertices,faces:n.faces.map(t=>({...t,color:e}))}}function Fr(n,e){if(e==="+x")return n;let t=zr[e];return{vertices:n.vertices.map(t),faces:n.faces}}function Vn(n,e){let t=1/0,i=1/0,r=1/0,o=-1/0,s=-1/0,a=-1/0;for(let h of n.vertices)t=Math.min(t,h.x),i=Math.min(i,h.y),r=Math.min(r,h.z),o=Math.max(o,h.x),s=Math.max(s,h.y),a=Math.max(a,h.z);let c=(t+o)/2,l=(i+s)/2,u=(r+a)/2,p=Math.max(o-t,s-i,a-r)||1,d=e/p;return{vertices:n.vertices.map(h=>({x:(h.x-c)*d,y:(h.y-l)*d,z:(h.z-u)*d})),faces:n.faces}}function _r(n,e){let t=g(n),i=T(t,Sr);Math.hypot(i.x,i.y,i.z)<1e-4&&(i={x:0,y:0,z:1}),i=g(i);let r=T(i,t),o=Cr(V(r,Math.cos(e)),V(i,Math.sin(e))),s=g(T(t,o));return{x:Math.atan2(T(s,t).z,s.z),y:Math.asin(Math.max(-1,Math.min(1,-t.z))),z:Math.atan2(t.y,t.x)}}function Rn(n,e,t){return z(De(t),z(ke(e),Ve(n)))}function Vr(n){return Math.hypot(n[0],n[1])>1e-6?{x:Math.atan2(n[9],n[10]),y:Math.asin(Math.max(-1,Math.min(1,-n[8]))),z:Math.atan2(n[4],n[0])}:{x:Math.atan2(-n[6],n[5]),y:Math.asin(Math.max(-1,Math.min(1,-n[8]))),z:0}}function kr(n,e){return Vr(z(Rn(n.x,n.y,n.z),Rn(e.x,e.y,e.z)))}function Dr(n){return Math.max(0,Math.min(1,n))}function wn(n,e){return V(S(n.positionAt(e+1),n.positionAt(e-1)),.5)}function Fn(n,e){return Math.hypot(n.x,n.y,n.z)>1e-6?g(n):e}function _n(n,e,t){return n?typeof n=="function"?{transition:n,durationMs:t}:{transition:n.transition,durationMs:Math.max(0,n.durationMs??t)}:{transition:e,durationMs:t}}var me=class{constructor(e){this.handles=[];this.banks=[];this.headings=[];this.started=!1;this.finished=!1;this.introStart=0;this.outroStart=1/0;this.outroPosition={x:0,y:0,z:0};this.outroVelocity={x:0,y:0,z:0};this.outroDirection={x:1,y:0,z:0};let t=Vn(Rr(e.mesh),e.size??1),i=Fr(t,e.facing??"+x");this.mesh=wr(i,e.color),this.motion=e.motion,this.backend=e.backend,this.transparency=e.transparency,this.labelContent=e.label,this.fadeLabel=e.fadeLabel??!0,this.tailCount=Math.max(0,Math.floor(e.tail?.count??0)),this.tailGap=Math.max(0,e.tail?.gapMs??0),this.intro=_n(e.intro,$t(),Er),this.outro=_n(e.outro,Jt(),Lr);let r=e.rotation;this.rotationOffset={x:r?.x??0,y:r?.y??0,z:r?.z??0},this.rotationSpin={x:r?.spinX??0,y:r?.spinY??0,z:r?.spinZ??0},this.hasExtraRotation=this.rotationOffset.x!==0||this.rotationOffset.y!==0||this.rotationOffset.z!==0||this.rotationSpin.x!==0||this.rotationSpin.y!==0||this.rotationSpin.z!==0}mount(e){e.style.position||(e.style.position="relative");let t=new L({backend:this.backend,camera:{position:{x:0,y:0,z:3}}});for(let i=0;i<=this.tailCount;i++)this.handles.push(t.add(this.mesh,{transparency:this.transparency})),this.banks.push(0),this.headings.push({x:1,y:0,z:0});this.engine=t,t.mount(e).catch(i=>{e.textContent=i instanceof Error?i.message:String(i)}),this.label=K(e,this.labelContent),this.fadeLabel&&this.label.setOpacity(0)}enter(e){this.started||(this.started=!0,this.introStart=e)}exit(e){!this.started||this.outroStart!==1/0||(this.outroPosition=this.motion.positionAt(e),this.outroVelocity=wn(this.motion,e),this.outroDirection=Fn(this.outroVelocity,this.headings[0]),this.outroStart=e)}isFinished(){return this.finished}get outroDurationMs(){return this.outro.durationMs}trailEmitter(){return{positionAt:e=>this.sampleAt(e)?.position??this.motion.positionAt(e)}}render(e,t){if(!(!this.engine||!this.label)){this.outroStart!==1/0&&e>=this.outroStart+this.outro.durationMs+this.tailCount*this.tailGap&&(this.finished=!0);for(let i=0;i<this.handles.length;i++){let r=this.handles[i].transform,o=e-i*this.tailGap,s=this.sampleAt(o);if(!s){r.scale=0;continue}r.scale=s.size;let a=s.orientation;if(!a){let c=S(this.positionAt(o+en)??s.position,s.position);Math.hypot(c.x,c.y,c.z)>1e-5&&(this.headings[i]=g(c));let l=this.aheadAt(o)??this.headings[i],u=Math.max(-Cn,Math.min(Cn,T(this.headings[i],l).y*Pr));this.banks[i]+=(u-this.banks[i])*Ir,a=_r(this.headings[i],this.banks[i])}this.hasExtraRotation&&(a=kr(a,{x:this.rotationOffset.x+this.rotationSpin.x*o,y:this.rotationOffset.y+this.rotationSpin.y*o,z:this.rotationOffset.z+this.rotationSpin.z*o})),r.position.x=s.position.x,r.position.y=s.position.y,r.position.z=s.position.z,r.rotation.x=a.x,r.rotation.y=a.y,r.rotation.z=a.z}this.label.setText(t.indeterminate?typeof this.labelContent=="string"?this.labelContent:"":`${Math.round(t.progress*100)}%`),this.fadeLabel&&this.label.setOpacity(Q(e,this.started?this.introStart:1/0,this.intro.durationMs,this.outroStart,this.outro.durationMs)),this.engine.render()}}destroy(){this.label?.container.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.handles.length=0}aheadAt(e){let t=this.positionAt(e+en),i=this.positionAt(e+2*en);if(!t||!i)return;let r=S(i,t);if(!(Math.hypot(r.x,r.y,r.z)<=1e-5))return g(r)}positionAt(e){return this.sampleAt(e)?.position}sampleAt(e){if(!(!this.started||e<this.introStart)){if(e<this.introStart+this.intro.durationMs)return this.transitionSample("intro",e,this.intro,this.introStart);if(this.outroStart!==1/0){if(e>this.outroStart+this.outro.durationMs)return;if(e>=this.outroStart)return this.transitionSample("outro",e,this.outro,this.outroStart)}return{position:this.motion.positionAt(e),size:1}}}transitionSample(e,t,i,r){let o=Math.max(0,t-r),s=i.durationMs===0?1:Dr(o/i.durationMs),a=this.transitionInput(e,s,o,i.durationMs,r),c=i.transition(a);return this.applyTransitionOutput(a,c,e,t)}transitionInput(e,t,i,r,o){if(e==="intro"){let s=o+r,a=wn(this.motion,s);return{delta:t,position:this.motion.positionAt(s),direction:Fn(a,{x:1,y:0,z:0}),velocity:a,size:1,durationMs:r,elapsedMs:i,phase:e}}return{delta:t,position:this.outroPosition,direction:this.outroDirection,velocity:this.outroVelocity,size:1,durationMs:r,elapsedMs:i,phase:e}}applyTransitionOutput(e,t,i,r){return{position:t.position??(i==="intro"?this.motion.positionAt(r):e.position),size:t.size??e.size??1,orientation:t.orientation}}};var Xr=["#fde047","#fb923c","#f472b6","#60a5fa"],Nn=.15,Yr=.6;function Me(n,e,t){let i=(n^Math.imul(e+1,2654435769)^Math.imul(t+1,2246822507))>>>0;return i=Math.imul(i^i>>>16,73244475),i=Math.imul(i^i>>>16,73244475),i^=i>>>16,(i>>>0)/4294967296}function Bn(n,e,t){let i=Math.max(0,Math.min(1,(t-n)/(e-n)));return i*i*(3-2*i)}function Un(n,e){if(!Number.isFinite(n)||n<=0)throw new RangeError(`3d-spinner: ${e} must be a finite number greater than zero.`);return n}function qr(n){let e=g(n),t=Math.abs(e.y)<.99?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=g(T(t,e));return{d:e,right:i,up:T(e,i)}}function Gn(n={}){let e=Un(n.rate??20,"rate"),t=Un(n.lifeMs??1800,"lifeMs"),i=n.size??.16,r=n.speed??.6,o=n.gravity,s=n.spread??.5,a=Math.max(0,Math.min(1,n.opacity??.9)),c=n.spin??.002,l=n.alignToMotion??!1,u=n.seed??1,p=n.direction&&qr(n.direction),d=1e3/e,h=m=>{let b=Me(u,m,0),f=2*Math.PI*Me(u,m,1);if(!p){let E=2*b-1,_=Math.sqrt(Math.max(0,1-E*E));return{x:_*Math.cos(f),y:_*Math.sin(f),z:E}}let y=1-b*(1-Math.cos(s)),M=Math.sqrt(Math.max(0,1-y*y)),{d:x,right:v,up:I}=p;return{x:x.x*y+(v.x*Math.cos(f)+I.x*Math.sin(f))*M,y:x.y*y+(v.y*Math.cos(f)+I.y*Math.sin(f))*M,z:x.z*y+(v.z*Math.cos(f)+I.z*Math.sin(f))*M}};return{maxLive:Math.ceil(t*e/1e3)+1,spawnGapMs:d,lifeMs:t,sample(m,b){if(m<0)return;let f=b-m*d;if(f<0||f>=t)return;let y=f/1e3,M=h(m),x=r*(.6+.8*Me(u,m,2)),v=x*y,I=o?.5*y*y:0,E=f/t,_=l?Math.atan2(M.y*x+(o?.y??0)*y,M.x*x+(o?.x??0)*y):2*Math.PI*Me(u,m,3)+(2*Me(u,m,4)-1)*c*f;return{position:{x:M.x*v+(o?o.x*I:0),y:M.y*v+(o?o.y*I:0),z:M.z*v+(o?o.z*I:0)},roll:_,size:i*(.7+.6*Me(u,m,5)),opacity:a*Bn(0,Nn,E)*(1-Bn(Yr,1,E))}}}}var P=class{constructor(e={}){this.handles=[];this.fades=[];this.enterAt=1/0;this.exitAt=1/0;this.finished=!1;this.field=Gn(e),this.colors=e.colors??Xr,this.backend=e.backend,this.texture=e.texture,this.labelContent=e.label,this.fadeLabel=e.fadeLabel??!0,this.emitter=e.emitter,this.outroMs=Math.max(0,e.outroMs??0)}mount(e){e.style.position||(e.style.position="relative");let t=this.colors.map(s=>pe(1,[s])),i=this.texture,r=i?async s=>{let a=this.backend==="webgpu"?new(await Promise.resolve().then(()=>(it(),nn))).WebGPUTexturedRenderer(s):this.backend==="webgl"?new(await Promise.resolve().then(()=>(ot(),rn))).WebGLTexturedRenderer(s):new(await Promise.resolve().then(()=>(at(),on))).Canvas2DTexturedRenderer(s);for(let c of t)a.setTexture(c,i);return a}:this.backend,o=new L({backend:r,camera:{position:{x:0,y:0,z:3}},light:{intensity:0,ambient:1}});for(let s=0;s<this.field.maxLive;s++){let a={mode:"one-sided",opacity:0};this.fades.push(a),this.handles.push(o.add(t[s%t.length],{scale:0,transparency:a}))}this.engine=o,o.mount(e).catch(s=>{e.textContent=s instanceof Error?s.message:String(s)}),this.label=K(e,this.labelContent),this.fadeLabel&&this.label.setOpacity(0)}enter(e){this.enterAt===1/0&&(this.enterAt=e)}exit(e){this.exitAt===1/0&&(this.exitAt=e)}isFinished(){return this.finished}render(e,t){if(!(!this.engine||!this.label)){this.exitAt!==1/0&&e>=this.exitAt+this.outroMs+this.field.lifeMs&&(this.finished=!0);for(let i of this.handles)i.transform.scale=0;if(this.enterAt!==1/0){let i=e-this.enterAt,r=this.field.spawnGapMs,o=Math.max(0,Math.ceil((i-this.field.lifeMs)/r)),s=Math.floor(i/r);this.exitAt!==1/0&&(s=Math.min(s,Math.floor((this.exitAt-this.enterAt+this.outroMs)/r))),o=Math.max(o,s-this.field.maxLive+1);for(let a=o;a<=s;a++){let c=this.field.sample(a,i);if(!c)continue;let l=a%this.handles.length,u=this.handles[l].transform,p=this.emitter?.positionAt(this.enterAt+a*r);u.position.x=c.position.x+(p?.x??0),u.position.y=c.position.y+(p?.y??0),u.position.z=c.position.z+(p?.z??0),u.rotation.z=c.roll,u.scale=c.size,this.fades[l].opacity=c.opacity}}this.label.setText(t.indeterminate?typeof this.labelContent=="string"?this.labelContent:"":`${Math.round(t.progress*100)}%`),this.fadeLabel&&this.label.setOpacity(Q(e,this.enterAt,this.field.lifeMs*Nn,this.exitAt,this.field.lifeMs)),this.engine.render()}}destroy(){this.label?.container.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.handles.length=0,this.fades.length=0}};var D=10,Qr=3,Hn=.76,Kr=.36,Zr={mode:"two-sided",frontOpacity:.68,backOpacity:.87},Wn=1.2,Xn=.8,sn=Math.PI*2,$r=500,Jr=550,eo=2.5,to=250,an=250,cn=1300,Kn=600,Zn=45,Yn=Kn+(D-1)*Zn+150,no=420,io={x:0,y:0,z:50},qn={specular:[1,1,1],shininess:28},ro=["#67e8f9","#22d3ee","#0ea5e9","#38bdf8","#7dd3fc"],Qn=[["#e0f2fe","#bae6fd","#7dd3fc"],["#c7d2fe","#a5b4fc","#818cf8"],["#a5f3fc","#67e8f9","#22d3ee"]];function ct(n){return Math.max(0,Math.min(1,n))}var Pe=class{constructor(e={}){this.minis=[];this.blends=new Array(D).fill(0);this.offsets=new Array(D).fill(0);this.enterAt=1/0;this.exitAt=1/0;this.allOutAt=1/0;this.lastNow=0;this.finished=!1;this.orbitPeriodMs=e.orbitPeriodMs??6e3,this.backend=e.backend}mount(e){e.style.position||(e.style.position="relative");let t=new L({backend:this.backend,camera:{position:{x:0,y:0,z:Qr}}});this.center=t.add(Ee(1,2,ro,qn),{scale:0});for(let i=0;i<D;i++){let r=Ee(1,1,Qn[i%Qn.length],qn);this.minis.push(t.add(r,{scale:0,transparency:{...Zr}}))}this.engine=t,t.mount(e).catch(i=>{e.textContent=i instanceof Error?i.message:String(i)})}enter(e){this.enterAt===1/0&&(this.enterAt=e)}exit(e){this.exitAt===1/0&&(this.exitAt=e)}isFinished(){return this.finished}get outroEmitMs(){return an+cn+Yn}satelliteEmitter(e){return{positionAt:t=>{let i=[];for(let o=0;o<D;o++){let s=this.miniSample(o,t);s&&i.push(s.position)}if(i.length===0)return io;let r=Math.abs(Math.floor(t/e))%i.length;return i[r]}}}render(e,t){if(!this.engine||!this.center)return;if(this.enterAt===1/0){this.center.transform.scale=0;for(let o of this.minis)o.transform.scale=0;this.engine.render();return}let i=this.lastNow===0?16:Math.min(50,e-this.lastNow);this.lastNow=e,this.updateBlends(i,t.progress,e),this.updateSpread(i);let r=e-this.enterAt;this.center.transform.scale=this.centerScale(e,r),this.center.transform.rotation.x=r*2e-4,this.center.transform.rotation.y=r*5e-4;for(let o=0;o<D;o++){let s=this.minis[o].transform,a=this.miniSample(o,e);if(!a){s.scale=0;continue}s.position.x=a.position.x,s.position.y=a.position.y,s.position.z=a.position.z,s.scale=a.scale,s.rotation.y=r*.0012}this.engine.render()}destroy(){this.engine?.destroy(),this.engine=void 0,this.center=void 0,this.minis.length=0}updateBlends(e,t,i){let r=this.exitAt!==1/0,o=r?D:Math.min(D,Math.floor(t*D+1e-9)),s=e/Jr*(r?eo:1);for(let a=0;a<D;a++){let c=a<o?1:0,l=this.blends[a];c>l&&(a===0||this.blends[a-1]>=.6)?(this.blends[a]=Math.min(1,l+s),l===0&&(this.offsets[a]=this.slotAngle(a))):c<l&&(a===D-1||this.blends[a+1]<=.4)&&(this.blends[a]=Math.max(0,l-s))}r&&this.allOutAt===1/0&&this.blends.every(a=>a>=1)&&(this.allOutAt=i)}updateSpread(e){let t=1-Math.exp(-e/to);for(let i=0;i<D;i++)this.blends[i]<=0||(this.offsets[i]+=(this.slotAngle(i)-this.offsets[i])*t)}slotAngle(e){let t=Math.max(1,this.blends.filter(i=>i>0).length);return sn*Math.min(e,t-1)/t}baseAngleAt(e){let t=-sn*(e-this.enterAt)/this.orbitPeriodMs;if(this.allOutAt!==1/0){let i=ct((e-this.allOutAt-an)/cn);t-=sn*de(i)}return t}reenterStart(){return this.allOutAt+an+cn}miniSample(e,t){let i=this.blends[e];if(i<=0)return;let r=ee(i),o=Kr*q(i);if(this.allOutAt!==1/0){let c=this.reenterStart()+e*Zn,l=se(ct((t-c)/Kn));if(l>=1)return;r*=1-l,o*=1-l}let s=this.baseAngleAt(t)+this.offsets[e],a=Math.sin(s)*Wn*r;return{position:{x:Math.cos(s)*Wn*r,y:a*Math.cos(Xn),z:a*Math.sin(Xn)},scale:o}}centerScale(e,t){if(this.allOutAt!==1/0){let i=ct((e-this.reenterStart()-Yn)/no);if(i>=1)return this.finished=!0,0;if(i>0)return Hn*(i<.35?1+.18*he(i/.35):1.18*(1-oe((i-.35)/.65)))}return Hn*q(ct(t/$r))}};var ut=5,R=ut*ut,$n=4,Jn=55*Math.PI/180,ae=Math.PI*2,ii=900,ri=60,oo=(R-1)*ri+ii,so=.35,ao=.65,co=2.5,lo=2e3,ei=380,uo=80,po=1e3,Ie=700,ho=500,ti=170,mo=600,fo=["#8397c6","#7186b8","#6176a8","#93a6cf","#556a9c","#7a8fc0"],bo=[()=>te(1,fo)];function lt(n){return Math.max(0,Math.min(1,n))}function yo(n){let e=lt(n);return e*e*(3-2*e)}function xo(n){return typeof n=="function"?n():n}function ni(n){let e=n-ae*Math.floor(n/ae);return e>Math.PI?e-ae:e}function ze(n,e){let t=(Math.imul(n+1,2654435769)^Math.imul(e+1,2246822507))>>>0;return t=Math.imul(t^t>>>16,73244475),t^=t>>>16,(t>>>0)/4294967296}var Ce=class{constructor(e={}){this.handles=[];this.blends=new Array(R).fill(0);this.dockedAt=new Array(R).fill(1/0);this.tumbleX=[];this.tumbleY=[];this.collapseDelay=[];this.popStarted=new Array(R).fill(!1);this.maxCollapseDelay=0;this.fades=[];this.slots=[];this.aspect=16/9;this.enterAt=1/0;this.exitAt=1/0;this.allDockedAt=1/0;this.collapseAt=1/0;this.lastNow=0;this.finished=!1;let t=e.meshes&&e.meshes.length>0?e.meshes:bo;this.meshes=t.map(xo),this.size=e.size??.34,this.orbitPeriodMs=e.orbitPeriodMs??9e3,this.dockMs=e.dockMs??800,this.backend=e.backend,this.labelContent=e.label,this.fadeLabel=e.fadeLabel??!0;let i=this.size+(e.gap??.12);for(let r=0;r<R;r++){let o=Math.floor(r/ut),s=r%ut;this.slots.push({x:(s-2)*i,y:(2-o)*i,z:0}),this.tumbleX.push(ae*ze(r,2)-Math.PI),this.tumbleY.push(ae*ze(r,4)-Math.PI),this.collapseDelay.push(ze(r,7)*ho)}this.maxCollapseDelay=Math.max(...this.collapseDelay)}mount(e){e.style.position||(e.style.position="relative");let t=new L({backend:this.backend,camera:{position:{x:0,y:0,z:$n},fov:Jn}});for(let r=0;r<R;r++)this.fades.push({mode:"one-sided",opacity:1}),this.handles.push(t.add(this.meshes[r%this.meshes.length],{scale:0}));this.engine=t,t.mount(e).catch(r=>{e.textContent=r instanceof Error?r.message:String(r)});let i=()=>{e.clientWidth>0&&e.clientHeight>0&&(this.aspect=e.clientWidth/e.clientHeight)};i(),this.observer=new ResizeObserver(i),this.observer.observe(e),this.label=K(e,this.labelContent),this.fadeLabel&&this.label.setOpacity(0)}enter(e){this.enterAt===1/0&&(this.enterAt=e)}exit(e){this.exitAt===1/0&&(this.exitAt=e)}isFinished(){return this.finished}render(e,t){if(!this.engine||!this.label)return;if(this.enterAt===1/0){for(let r of this.handles)r.transform.scale=0;this.engine.render();return}let i=this.lastNow===0?16:Math.min(50,e-this.lastNow);this.lastNow=e,this.updateBlends(i,t.progress,e),this.exitAt!==1/0&&this.allDockedAt!==1/0&&this.collapseAt===1/0&&(this.collapseAt=Math.max(this.exitAt,this.allDockedAt)+po),e>=this.collapseAt?this.renderCollapse(e):this.renderStory(e,i),this.label.setText(t.indeterminate?typeof this.labelContent=="string"?this.labelContent:"":`${Math.round(t.progress*100)}%`),this.fadeLabel&&this.label.setOpacity(Q(e,this.enterAt,mo,this.collapseAt,Ie)),this.collapseAt!==1/0&&e>=this.collapseAt+this.maxCollapseDelay+Ie+ti&&(this.finished=!0),this.engine.render()}destroy(){this.observer?.disconnect(),this.observer=void 0,this.label?.container.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.handles.length=0,this.fades.length=0}updateBlends(e,t,i){let r=this.exitAt!==1/0,s=i-this.enterAt>=oo?r?R:Math.min(R,Math.floor(t*R+1e-9)):0,a=e/this.dockMs*(r?co:1);for(let l=0;l<R;l++){let u=l<s?1:0,p=this.blends[l];u>p&&(l===0||this.blends[l-1]>=so)?this.blends[l]=Math.min(1,p+a):u<p&&(l===R-1||this.blends[l+1]<=ao)&&(this.blends[l]=Math.max(0,p-a)),this.blends[l]>=1?this.dockedAt[l]===1/0&&(this.dockedAt[l]=i):this.dockedAt[l]=1/0}s===R&&this.blends.every(l=>l>=1)?this.allDockedAt===1/0&&(this.allDockedAt=i):r||(this.allDockedAt=1/0)}renderStory(e,t){let i=e-this.enterAt,r=Math.tan(Jn/2)*$n,o=r*this.aspect,s=Math.max(.6,Math.min(o,r)-this.size*.55),a=(Math.max(o,r)*1.25+this.size*2)/s;for(let c=0;c<R;c++){let l=this.handles[c].transform,u=yo(this.blends[c]),p=lt((i-c*ri)/ii),d=1+(a-1)*(1-ee(p)),h=Math.PI/2-c/R*ae-i/this.orbitPeriodMs*ae,m=Math.cos(h)*s*d,b=Math.sin(h)*s*d,f=this.slots[c];if(l.position.x=m+(f.x-m)*u,l.position.y=b+(f.y-b)*u,l.position.z=0,l.scale=this.size,this.blends[c]===0&&(this.tumbleX[c]=ni(this.tumbleX[c]+(4e-4+8e-4*ze(c,1))*t),this.tumbleY[c]=ni(this.tumbleY[c]+(6e-4+.001*ze(c,3))*t)),l.rotation.z=0,this.blends[c]>=1){let y=(i+c*uo)%lo,M=y<ei&&e-y>=this.dockedAt[c];l.rotation.x=0,l.rotation.y=M?ae*de(y/ei):0}else{let y=1-u;l.rotation.x=this.tumbleX[c]*y,l.rotation.y=this.tumbleY[c]*y}}}renderCollapse(e){this.captured||(this.captured=this.handles.map(t=>({...t.transform.position})));for(let t=0;t<R;t++){let i=this.handles[t].transform,r=this.captured[t],o=e-this.collapseAt-this.collapseDelay[t];if(o<=0){i.position.x=r.x,i.position.y=r.y,i.position.z=r.z,i.scale=this.size;continue}let s=se(lt(o/Ie));if(i.position.x=r.x*(1-s),i.position.y=r.y*(1-s),i.position.z=r.z*(1-s),i.scale=this.size*(1-.99*s),o>=Ie){this.popStarted[t]||(this.popStarted[t]=!0,this.handles[t].transparency=this.fades[t]);let a=lt((o-Ie)/ti);this.fades[t].opacity=1-a,i.scale=a>=1?0:this.size*.01*(1+1.6*Math.sin(Math.PI*a))}}}};var H=class{constructor(e){this.elements=[];this.layers=e.map(t=>"animation"in t?t:{animation:t})}mount(e){e.style.position="relative";for(let[t,i]of this.layers.entries()){let r=document.createElement("div");r.style.cssText=`position:absolute;inset:0;z-index:${i.zIndex??t}`,e.appendChild(r),this.elements.push(r),i.animation.mount(r)}}enter(e){for(let t of this.layers)t.animation.enter(e)}exit(e){for(let t of this.layers)t.animation.exit(e)}render(e,t){for(let i of this.layers)i.animation.render(e,t)}isFinished(){return this.layers.every(e=>e.animation.isFinished())}destroy(){for(let e of this.layers)e.animation.destroy();for(let e of this.elements)e.remove();this.elements.length=0}};function Z(n,e){return{type:"indeterminate",animation:n,loop:e.loop,periodMs:e.periodMs}}function ce(n,e){return{type:"progress",animation:n,progress:e.progress??.001,timeout:e.timeout,until:e.until}}function oi(n={}){let e=n.particles??{},t=e.rate??60,i=new Pe({backend:n.backend,...n.orb}),r=new P({rate:t,lifeMs:1200,size:.12,speed:.05,colors:["#ffffff","#a5f3fc","#818cf8"],texture:e.texture??re(),emitter:i.satelliteEmitter(1e3/t),outroMs:i.outroEmitMs,seed:5,backend:n.backend,...e,label:n.label??e.label,fadeLabel:n.fadeLabel??e.fadeLabel});return ce(new H([i,r]),n)}function ge(n={}){let e=n.size??1,t=n.periodMs??3600;return{positionAt(i){let r=i/t*Math.PI*2;return{x:e*1.5*Math.sin(r),y:e*1*Math.sin(r)*Math.cos(r),z:e*1.05*Math.cos(r)}}}}function si(n={}){let e=n.object?.motion??ge({size:.66,periodMs:7200}),t=n.particles??{},i=new me({mesh:()=>We(1,["#f0f9ff","#7dd3fc","#818cf8","#e879f9"]),motion:e,size:.42,rotation:{spinX:.002,spinY:.003},backend:n.backend,...n.object,label:n.object?.label}),r=new H([new P({rate:44,lifeMs:2300,size:.25,speed:.08,colors:["#ffffff","#bae6fd","#818cf8"],texture:t.texture??re(),emitter:i.trailEmitter(),outroMs:i.outroDurationMs,seed:28,backend:n.backend,...t,label:n.label??t.label??"Polishing pixels",fadeLabel:n.fadeLabel??t.fadeLabel}),i]);return Z(r,n)}function pt(n={}){let e=(n.size??2.4)/2,t=n.periodMs??4e3,i=n.tilt??.45,r=n.direction??1,o=Math.cos(i),s=Math.sin(i);return{positionAt(a){let c=r*a/t,l=(c-Math.floor(c))*4,u=Math.floor(l),p=l-u,d,h;return u===0?(d=-e+2*e*p,h=-e):u===1?(d=e,h=-e+2*e*p):u===2?(d=e-2*e*p,h=e):(d=-e,h=e-2*e*p),{x:d,y:h*o,z:h*s}}}}var ve=50,ui=3,pi=55*Math.PI/180,ai=Math.tan(pi/2)*ui,Mo=130,ci=320,go=8,vo=.4*Math.PI/180,Ao=4e3,Oo=1e3,li=1200,To={mode:"two-sided",opacity:.275},So=["#bae6fd","#7dd3fc","#38bdf8","#0ea5e9","#a5f3fc","#e0f2fe"],Eo={emissive:[.1,.2,.3]},Lo={x:0,y:1,z:0};function Po(n){return Math.max(0,Math.min(1,n))}function Io(n){let e=g(n),t=T(e,Lo);Math.hypot(t.x,t.y,t.z)<1e-4&&(t={x:0,y:0,z:1}),t=g(t);let i=T(t,e),r=g(T(e,i));return{x:Math.atan2(T(r,e).z,r.z),y:Math.asin(Math.max(-1,Math.min(1,-e.z))),z:Math.atan2(e.y,e.x)}}function zo(n,e,t){let i=g(n),r=g(e),o=Math.max(-1,Math.min(1,W(i,r))),s=Math.acos(o);if(s<=t||s<1e-4)return r;let a=Math.sin(s);if(a<1e-4)return r;let c=t/s,l=Math.sin((1-c)*s)/a,u=Math.sin(c*s)/a;return g({x:i.x*l+r.x*u,y:i.y*l+r.y*u,z:i.z*l+r.z*u})}var ht=class{constructor(e={}){this.cars=[];this.appear=new Array(ve).fill(0);this.headings=new Array(ve).fill(void 0);this.aspect=16/9;this.enterAt=1/0;this.outroAt=1/0;this.carsAtOutro=0;this.exitPathTime=0;this.exitPoint={x:0,y:0,z:0};this.exitDir={x:1,y:0,z:0};this.exitSpeed=.001;this.lastNow=0;this.finished=!1;this.motion=e.motion??pt({size:1.7,periodMs:6800,tilt:.5}),this.size=e.size??.15,this.backend=e.backend,this.labelContent=e.label,this.fadeLabel=e.fadeLabel??!0}mount(e){e.style.position||(e.style.position="relative");let t=new L({backend:this.backend,camera:{position:{x:0,y:0,z:ui},fov:pi}}),i=te(1,So,Eo);for(let o=0;o<ve;o++)this.cars.push(t.add(i,{scale:0,transparency:{...To}}));this.engine=t,t.mount(e).catch(o=>{e.textContent=o instanceof Error?o.message:String(o)});let r=()=>{e.clientWidth>0&&e.clientHeight>0&&(this.aspect=e.clientWidth/e.clientHeight)};r(),this.observer=new ResizeObserver(r),this.observer.observe(e),this.label=K(e,this.labelContent),this.fadeLabel&&this.label.setOpacity(0)}enter(e){this.enterAt===1/0&&(this.enterAt=e)}exit(e){if(this.outroAt!==1/0||this.enterAt===1/0)return;this.outroAt=e,this.carsAtOutro=this.appear.filter(o=>o>.5).length,this.exitPathTime=e-this.enterAt;let t=this.motion.positionAt(this.exitPathTime),i=S(this.motion.positionAt(this.exitPathTime+1),this.motion.positionAt(this.exitPathTime-1)),r=Math.hypot(i.x,i.y,i.z);this.exitPoint=t,r>1e-6&&(this.exitSpeed=r/2),this.exitDir=r>1e-6?g(i):{x:1,y:0,z:0}}isFinished(){return this.finished}get outroDurationMs(){return li}trailEmitter(){return{positionAt:e=>this.enterAt===1/0?this.motion.positionAt(e):this.pathPosition(e-this.enterAt+this.warp(e))}}render(e,t){if(!this.engine||!this.label)return;for(let c of this.cars)c.transform.scale=0;if(this.enterAt===1/0){this.engine.render();return}let i=this.lastNow===0?16:Math.min(50,e-this.lastNow);this.lastNow=e;let r=this.outroAt!==1/0?this.carsAtOutro:Math.min(ve,Math.round(t.progress*ve)),o=ai*this.aspect,s=this.warp(e),a=!1;for(let c=0;c<ve;c++){let l=c<r?1:0;if(this.appear[c]=Po(this.appear[c]+Math.sign(l-this.appear[c])*(i/ci)),this.appear[c]<=0){this.headings[c]=void 0;continue}let u=e-this.enterAt-c*Mo+s,p=this.pathPosition(u);if(Math.abs(p.x)>o+this.size||Math.abs(p.y)>ai+this.size)continue;let d=S(this.pathPosition(u+go),p),h=Math.hypot(d.x,d.y,d.z)>1e-5?d:this.headings[c]??{x:1,y:0,z:0};this.headings[c]=this.headings[c]?zo(this.headings[c],h,vo*i):g(h);let m=Io(this.headings[c]),b=this.cars[c].transform;b.position.x=p.x,b.position.y=p.y,b.position.z=p.z,b.rotation.x=m.x,b.rotation.y=m.y,b.rotation.z=m.z,b.scale=this.size*q(this.appear[c]),a=!0}this.label.setText(t.indeterminate?typeof this.labelContent=="string"?this.labelContent:"":`${Math.round(t.progress*100)}%`),this.fadeLabel&&this.label.setOpacity(Q(e,this.enterAt,ci,this.outroAt,li)),this.outroAt!==1/0&&e>this.outroAt+300&&(!a||e>=this.outroAt+Ao)&&(this.finished=!0),this.engine.render()}destroy(){this.observer?.disconnect(),this.observer=void 0,this.label?.container.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.cars.length=0}warp(e){if(this.outroAt===1/0)return 0;let t=(e-this.outroAt)/1e3;return .5*Oo*t*t}pathPosition(e){if(this.outroAt===1/0||e<=this.exitPathTime)return this.motion.positionAt(e);let t=this.exitSpeed*(e-this.exitPathTime);return{x:this.exitPoint.x+this.exitDir.x*t,y:this.exitPoint.y+this.exitDir.y*t,z:this.exitPoint.z+this.exitDir.z*t}}};function hi(n={}){let e=n.particles??{},t=new ht({motion:n.object?.motion,backend:n.backend}),i=new P({rate:30,lifeMs:1700,size:.15,speed:.11,colors:["#e0f2fe","#a5f3fc","#c4b5fd"],texture:e.texture??ie({glow:5}),emitter:t.trailEmitter(),outroMs:t.outroDurationMs,seed:17,backend:n.backend,...e,label:n.label??e.label,fadeLabel:n.fadeLabel??e.fadeLabel});return ce(new H([i,t]),n)}function di(n={}){return ce(new Ce({backend:n.backend,label:n.label,fadeLabel:n.fadeLabel,...n.assembly}),n)}function mi(n={}){let e=n.particles??{};return Z(new P({rate:70,lifeMs:2800,size:.38,speed:1.35,direction:{x:0,y:1,z:0},spread:.62,gravity:{x:0,y:-1.45,z:0},colors:["#fff","#000"],texture:e.texture??qe(),spin:0,alignToMotion:!0,seed:37,backend:n.backend,...e,label:n.label??e.label??"Loading...",fadeLabel:n.fadeLabel??e.fadeLabel}),n)}function fi(n={}){let e=n.object?.motion??ge({size:.72,periodMs:6200}),t=n.particles??{},i=new me({mesh:Ye,motion:e,size:.48,backend:n.backend,...n.object,label:n.object?.label}),r=new H([new P({rate:34,lifeMs:1900,size:.16,speed:.11,colors:["#fde047","#f472b6","#7dd3fc"],texture:t.texture??ie(),emitter:i.trailEmitter(),outroMs:i.outroDurationMs,seed:11,backend:n.backend,...t,label:n.label??t.label??"Flying in...",fadeLabel:n.fadeLabel??t.fadeLabel}),i]);return Z(r,n)}function Co(){let n=document.createElement("div");return n.innerHTML=`<style>
|
|
151
151
|
@keyframes spinner-prefab-pulse { 0%,100% { color:#fff; transform:scale(1); } 50% { color:#93c5fd; transform:scale(1.06); } }
|
|
152
|
-
</style><div style="animation:spinner-prefab-pulse 2.4s ease-in-out infinite;font-size:2rem">Loading the good stuff</div>`,n}function bi(n={}){let e=n.particles??{};return Z(new
|
|
152
|
+
</style><div style="animation:spinner-prefab-pulse 2.4s ease-in-out infinite;font-size:2rem">Loading the good stuff</div>`,n}function bi(n={}){let e=n.particles??{};return Z(new P({rate:48,lifeMs:4200,size:.3,speed:.34,colors:["#ffffff","#dbeafe","#93c5fd","#c4b5fd"],texture:e.texture??re(),seed:71,backend:n.backend,...e,label:n.label??e.label??Co(),fadeLabel:n.fadeLabel??e.fadeLabel}),n)}var w=20,Si=3,Ei=55*Math.PI/180,yi=Math.tan(Ei/2)*Si,Re=.12,we=-.5,xi=.3,Mi=460,gi=.45,Ro=2.5,ln=620,wo=5.2,Fo=2e3,_o=3,vi=.2,Vo=.8,Ai=30,ko=50,Do=Math.PI/180,un=1400,jo=320,Bo=.55,Uo=.17,No=.16,Go=104,pn=420,Ho=55,Wo=950,Oi=.25,Xo=.09,Yo=.15,qo=.9,Qo=140,Ko=["#e2e8f0","#cbd5e1"],Zo=["#fef3c7","#fde047","#fb923c","#ef4444"],$o=["#e2e8f0","#f8fafc","#cbd5e1","#94a3b8","#e2e8f0"];function Jo(n){return Math.max(0,Math.min(1,n))}function Fe(n,e,t){let i=Jo((t-n)/(e-n));return i*i*(3-2*i)}function j(n,e){let t=(Math.imul(n+1,2654435769)^Math.imul(e+1,2246822507))>>>0;return t=Math.imul(t^t>>>16,73244475),t^=t>>>16,(t>>>0)/4294967296}function Ti(n,e){return ne(t=>{let i=t.createRadialGradient(48,48,1,48,48,47);i.addColorStop(0,`rgba(255,255,255,${n})`),i.addColorStop(e,`rgba(255,255,255,${n*.6})`),i.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=i,t.fillRect(0,0,96,96)})}var dt=class{constructor(e={}){this.rockets=[];this.smoke=[];this.fire=[];this.smokeFades=[];this.fireFades=[];this.blends=new Array(w).fill(0);this.groundedAt=new Array(w).fill(1/0);this.turnS=new Array(w).fill(1/0);this.turnDir=[];this.turnRoll=new Array(w).fill(0);this.stagger=new Array(w).fill(0);this.aspect=16/9;this.enterAt=1/0;this.exitAt=1/0;this.launchedAt=1/0;this.lastNow=0;this.finished=!1;this.backend=e.backend,this.labelContent=e.label,this.fadeLabel=e.fadeLabel??!0;for(let i=0;i<w;i++)this.turnDir.push({x:0,y:1}),this.stagger[i]=j(i,7)*ln;let t=Array.from({length:w},(i,r)=>r).sort((i,r)=>j(i,11)-j(r,11));for(let i of t.slice(0,_o)){let r=vi+j(i,12)*(Vo-vi),o=(Ai+j(i,13)*(ko-Ai))*Do,s=j(i,14)<.5?-1:1;this.turnS[i]=r-we,this.turnDir[i]={x:s*Math.sin(o),y:Math.cos(o)},this.turnRoll[i]=-s*o}}mount(e){e.style.position||(e.style.position="relative");let t=Ko.map(u=>pe(1,[u])),i=Zo.map(u=>pe(1,[u])),r=Ti(.85,.5),o=Ti(1,.32),s=async u=>{let p=this.backend==="webgpu"?new(await Promise.resolve().then(()=>(it(),nn))).WebGPUTexturedRenderer(u):this.backend==="webgl"?new(await Promise.resolve().then(()=>(ot(),rn))).WebGLTexturedRenderer(u):new(await Promise.resolve().then(()=>(at(),on))).Canvas2DTexturedRenderer(u);for(let d of t)p.setTexture(d,r);for(let d of i)p.setTexture(d,o);return p},a=new L({backend:s,camera:{position:{x:0,y:0,z:Si},fov:Ei}}),c=Xe(1,$o);for(let u=0;u<w;u++)this.rockets.push(a.add(c,{scale:0}));for(let u=0;u<Go;u++){let p={mode:"one-sided",opacity:0};this.smokeFades.push(p),this.smoke.push(a.add(t[u%t.length],{scale:0,transparency:p}))}for(let u=0;u<Qo;u++){let p={mode:"one-sided",opacity:0};this.fireFades.push(p),this.fire.push(a.add(i[u%i.length],{scale:0,transparency:p}))}this.engine=a,a.mount(e).catch(u=>{e.textContent=u instanceof Error?u.message:String(u)});let l=()=>{e.clientWidth>0&&e.clientHeight>0&&(this.aspect=e.clientWidth/e.clientHeight)};l(),this.observer=new ResizeObserver(l),this.observer.observe(e),this.label=K(e,this.labelContent),this.fadeLabel&&this.label.setOpacity(0)}enter(e){this.enterAt===1/0&&(this.enterAt=e)}exit(e){this.exitAt===1/0&&(this.exitAt=e)}isFinished(){return this.finished}render(e,t){if(!this.engine||!this.label)return;for(let p of this.rockets)p.transform.scale=0;for(let p of this.smokeFades)p.opacity=0;for(let p of this.fireFades)p.opacity=0;for(let p of this.smoke)p.transform.scale=0;for(let p of this.fire)p.transform.scale=0;if(this.enterAt===1/0){this.engine.render();return}let i=this.lastNow===0?16:Math.min(50,e-this.lastNow);this.lastNow=e;let r=this.exitAt!==1/0;this.updateBlends(i,t.progress,e,r),r&&this.launchedAt===1/0&&this.blends.every(p=>p>=1)&&(this.launchedAt=e);let o=this.launchedAt!==1/0,s=yi*this.aspect,a=Math.min(s*.8,1.18),c=s+.6,l=0,u=0;for(let p=0;p<w;p++){let d=-a+2*a*p/(w-1),h=o?this.launchedAt+this.stagger[p]:1/0,m=e-h;if(o&&m>=0){this.renderAscent(p,d,m,s),u=this.emitFire(p,d,m,u);continue}let b=this.blends[p];if(b<=0)continue;let f=this.rockets[p].transform;f.position.x=c+(d-c)*q(b),f.position.y=we,f.position.z=0,f.rotation.x=0,f.rotation.y=0,f.rotation.z=0,f.scale=Re*Fe(0,.6,b),this.groundedAt[p]!==1/0&&(l=this.emitSmoke(p,d,e,h,l))}this.label.setText(t.indeterminate?typeof this.labelContent=="string"?this.labelContent:"":`${Math.round(t.progress*100)}%`),this.fadeLabel&&this.label.setOpacity(Q(e,this.enterAt,Mi,this.launchedAt,ln)),o&&e>=this.launchedAt+ln+Fo&&(this.finished=!0),this.engine.render()}destroy(){this.observer?.disconnect(),this.observer=void 0,this.label?.container.remove(),this.label=void 0,this.engine?.destroy(),this.engine=void 0,this.rockets.length=0,this.smoke.length=0,this.fire.length=0,this.smokeFades.length=0,this.fireFades.length=0}updateBlends(e,t,i,r){let o=r?w:Math.min(w,Math.round(t*w)),s=e/Mi*(r?Ro:1);for(let a=0;a<w;a++){let c=a<o?1:0,l=this.blends[a];c>l&&(a===0||this.blends[a-1]>=gi)?this.blends[a]=Math.min(1,l+s):c<l&&(a===w-1||this.blends[a+1]<=1-gi)&&(this.blends[a]=Math.max(0,l-s)),this.blends[a]>=1?this.groundedAt[a]===1/0&&(this.groundedAt[a]=i):this.groundedAt[a]=1/0}}ascentDistance(e){let t=e/1e3;return .5*wo*t*t}ascentPose(e,t,i){let r=this.ascentDistance(i),o=this.turnS[e];if(r<=o)return{pos:{x:t,y:we+r},dir:{x:0,y:1},roll:0};let s=r-o,a=this.turnDir[e];return{pos:{x:t+a.x*s,y:we+o+a.y*s},dir:a,roll:this.turnRoll[e]}}renderAscent(e,t,i,r){let{pos:o,roll:s}=this.ascentPose(e,t,i);if(o.y>yi+.4||Math.abs(o.x)>r+.4)return;let a=this.rockets[e].transform;a.position.x=o.x,a.position.y=o.y,a.position.z=0,a.rotation.x=0,a.rotation.y=0,a.rotation.z=s,a.scale=Re}emitFire(e,t,i,r){let o=Ho,s=Math.min(Math.floor(i/o),Math.floor(Wo/o)),a=Math.max(0,Math.ceil((i-pn)/o));for(let c=a;c<=s;c++){if(r>=this.fire.length)return r;let l=c*o,u=i-l;if(u<0||u>=pn)continue;let p=u/pn,d=u/1e3,h=this.ascentPose(e,t,l),m={x:-h.dir.x,y:-h.dir.y},b={x:-h.dir.y,y:h.dir.x},f=(j(e*97+c,1)-.5)*Xo,y=h.pos.x+m.x*Re*.5,M=h.pos.y+m.y*Re*.5,x=this.fire[r].transform;x.position.x=y+m.x*Oi*d+b.x*f,x.position.y=M+m.y*Oi*d+b.y*f-.12*d*d,x.position.z=xi,x.rotation.z=j(e*97+c,2)*Math.PI*2,x.scale=Yo*(.7+.5*j(e*97+c,3))*(1-.55*p),this.fireFades[r].opacity=qo*Fe(0,.15,p)*(1-Fe(.55,1,p)),r++}return r}emitSmoke(e,t,i,r,o){let s=this.groundedAt[e],a=i-s,c=jo,l=Number.isFinite(r)?r-s:a,u=Math.min(Math.floor(a/c),Math.floor(l/c)),p=Math.max(0,Math.ceil((a-un)/c)),d=we-Re*.4;for(let h=p;h<=u;h++){if(o>=this.smoke.length)return o;let m=a-h*c;if(m<0||m>=un)continue;let b=m/un,f=(j(e*131+h,1)-.5)*.14,y=this.smoke[o].transform;y.position.x=t+f*b,y.position.y=d+Bo*b,y.position.z=xi,y.rotation.z=j(e*131+h,2)*Math.PI*2,y.scale=Uo*(.5+.8*b)*(.7+.6*j(e*131+h,3)),this.smokeFades[o].opacity=No*Fe(0,.25,b)*(1-Fe(.5,1,b)),o++}return o}};function Li(n={}){return ce(new dt({backend:n.backend,label:n.label,fadeLabel:n.fadeLabel}),n)}function es(n){let e=n>>>0;return()=>{e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function hn(n,e,t){let i=[0,1,2].map(()=>({freq:.5+n()*1.4,phase:n()*Math.PI*2,weight:.5+n()})),r=i.reduce((o,s)=>o+s.weight,0);return o=>{let s=0;for(let a of i)s+=a.weight*Math.sin(e*a.freq*o+a.phase);return s/r*t}}function mt(n={}){let e=n.bounds?.x??1.4,t=n.bounds?.y??1,i=n.bounds?.z??.6,r=n.periodMs??9e3,o=n.seed??Math.random()*1e9|0,s=es(o),a=2*Math.PI/r,c=hn(s,a,e),l=hn(s,a,t),u=hn(s,a,i);return{positionAt(p){return{x:c(p),y:l(p),z:u(p)}}}}function Pi(n={}){let e=n.particles??{},t=e.emitter??mt({bounds:{x:1.1,y:.72,z:.35},periodMs:7200,seed:19});return Z(new P({rate:38,lifeMs:2600,size:.15,speed:.17,colors:["#fef08a","#f9a8d4","#a5f3fc"],texture:e.texture??ie(),emitter:t,seed:91,backend:n.backend,...e,label:n.label??e.label??"Loading...",fadeLabel:n.fadeLabel??e.fadeLabel}),n)}function Ii(n={}){let e=n.radius??1.3,t=n.periodMs??3e3,i=n.tilt??.5,r=n.direction??1,o=Math.cos(i),s=Math.sin(i);return{positionAt(a){let c=r*a/t*Math.PI*2,l=e*Math.cos(c),u=e*Math.sin(c);return{x:l,y:u*o,z:u*s}}}}ot();at();it();var ts=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#ef4444"];function ft(n){return Math.min(1,Math.max(0,n))}function ns(n){let e=Number.parseFloat(n);if(Number.isFinite(e))return Math.round(ft(e)*255).toString(16).padStart(2,"0")}function zi(n){let e=n.slice(1,4).map(Number.parseFloat);if(!(e.length!==3||!e.every(Number.isFinite)))return[ft(e[0]),ft(e[1]),ft(e[2])]}function is(n){let e={};return n.specular&&(e.specular=n.specular),n.shininess!==void 0&&(e.shininess=n.shininess),n.emissive&&(e.emissive=n.emissive),Object.keys(e).length>0?e:void 0}function rs(n){let e=new Map,t=new Map,i;for(let r of n.split(`
|
|
153
153
|
`)){let o=r.trim();if(o===""||o.startsWith("#"))continue;let s=o.split(/\s+/),a=s[0];if(a==="newmtl"){i=s.slice(1).join(" "),i&&!e.has(i)&&(e.set(i,{}),t.set(i,{}));continue}if(!i)continue;let c=e.get(i),l=t.get(i);if(a==="Kd"){let u=s.slice(1,4).map(ns);u.length===3&&u.every(p=>p!==void 0)&&(c.color=`#${u.join("")}`)}else if(a==="Ks")l.specular=zi(s);else if(a==="Ns"){let u=Number.parseFloat(s[1]);Number.isFinite(u)&&(l.shininess=Math.max(0,u))}else a==="Ke"&&(l.emissive=zi(s))}for(let[r,o]of t)e.get(r).material=is(o);return e}function os(n,e){let t=parseInt(n,10);return t<0?e+t:t-1}function ss(n,e={}){let t=e.colors??ts,i=e.useMtlColors&&e.mtl?rs(e.mtl):void 0,r=[],o=[],s;for(let a of n.split(`
|
|
154
|
-
`)){let c=a.trim();if(c===""||c.startsWith("#"))continue;let l=c.split(/\s+/),u=l[0];if(u==="v")r.push({x:parseFloat(l[1]),y:parseFloat(l[2]),z:parseFloat(l[3])});else if(u==="usemtl")s=l.slice(1).join(" ");else if(u==="f"){let p=[];for(let
|
|
154
|
+
`)){let c=a.trim();if(c===""||c.startsWith("#"))continue;let l=c.split(/\s+/),u=l[0];if(u==="v")r.push({x:parseFloat(l[1]),y:parseFloat(l[2]),z:parseFloat(l[3])});else if(u==="usemtl")s=l.slice(1).join(" ");else if(u==="f"){let p=[];for(let d=1;d<l.length;d++){let h=l[d].split("/")[0];p.push(os(h,r.length))}if(p.length>=3){let d=s?i?.get(s):void 0,h=d?.color??(i?t[0]??"#888888":t[o.length%t.length]),m={indices:p,color:h};d?.material&&(m.material=d.material),o.push(m)}}}return{vertices:r,faces:o}}var dn=class{constructor(e={}){this.type=e.type??"linear",this.overextend=e.overextend??!1}value(e,t=this.type,i=this.overextend){return Ze(t,e,i)}};return Ui(as);})();
|