3d-spinner 0.9.2 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +66 -4
  2. package/dist/animation-label.d.ts +8 -0
  3. package/dist/animation-label.js +47 -0
  4. package/dist/animation.d.ts +2 -0
  5. package/dist/animations/charged-orb.d.ts +55 -0
  6. package/dist/animations/charged-orb.js +229 -0
  7. package/dist/animations/ghost-train.d.ts +72 -0
  8. package/dist/animations/ghost-train.js +247 -0
  9. package/dist/animations/grid-assembly.d.ts +70 -0
  10. package/dist/animations/grid-assembly.js +282 -0
  11. package/dist/animations/object-motion.d.ts +19 -7
  12. package/dist/animations/object-motion.js +38 -32
  13. package/dist/animations/particles.d.ts +110 -0
  14. package/dist/animations/particles.js +209 -0
  15. package/dist/animations/rocket-launch.d.ts +58 -0
  16. package/dist/animations/rocket-launch.js +375 -0
  17. package/dist/cjs/animations/charged-orb.cjs +1334 -0
  18. package/dist/cjs/animations/grid-assembly.cjs +1380 -0
  19. package/dist/cjs/animations/object-motion.cjs +124 -43
  20. package/dist/cjs/animations/particles.cjs +1940 -0
  21. package/dist/cjs/animations/spin.cjs +4 -3
  22. package/dist/cjs/composite-animation.cjs +58 -0
  23. package/dist/cjs/engines/little-3d-engine/little-3d-engine.cjs +143 -22
  24. package/dist/cjs/engines/little-3d-engine/loaders/obj.cjs +30 -1
  25. package/dist/cjs/engines/little-3d-engine/renderers/canvas2d-textured.cjs +345 -0
  26. package/dist/cjs/engines/little-3d-engine/renderers/webgl-textured.cjs +528 -0
  27. package/dist/cjs/engines/little-3d-engine/renderers/webgpu-textured.cjs +712 -0
  28. package/dist/cjs/prefabs/prefabs.cjs +3916 -0
  29. package/dist/composite-animation.d.ts +18 -0
  30. package/dist/composite-animation.js +39 -0
  31. package/dist/engines/little-3d-engine/little-3d-engine.d.ts +17 -12
  32. package/dist/engines/little-3d-engine/little-3d-engine.js +13 -8
  33. package/dist/engines/little-3d-engine/loaders/obj.d.ts +12 -4
  34. package/dist/engines/little-3d-engine/loaders/obj.js +44 -5
  35. package/dist/engines/little-3d-engine/renderer.d.ts +7 -1
  36. package/dist/engines/little-3d-engine/renderer.js +2 -0
  37. package/dist/engines/little-3d-engine/renderers/canvas2d-textured.d.ts +20 -0
  38. package/dist/engines/little-3d-engine/renderers/canvas2d-textured.js +135 -0
  39. package/dist/engines/little-3d-engine/renderers/textured-helpers.d.ts +9 -0
  40. package/dist/engines/little-3d-engine/renderers/textured-helpers.js +35 -0
  41. package/dist/engines/little-3d-engine/renderers/webgl-textured.d.ts +43 -0
  42. package/dist/engines/little-3d-engine/renderers/webgl-textured.js +211 -0
  43. package/dist/engines/little-3d-engine/renderers/webgpu-textured.d.ts +45 -0
  44. package/dist/engines/little-3d-engine/renderers/webgpu-textured.js +300 -0
  45. package/dist/engines/little-3d-engine/renderers/webgpu.d.ts +11 -6
  46. package/dist/engines/little-3d-engine/shapes/complex/plane.d.ts +3 -0
  47. package/dist/engines/little-3d-engine/shapes/complex/plane.js +33 -0
  48. package/dist/engines/little-3d-engine/shapes/{cube.d.ts → primitives/cube.d.ts} +1 -1
  49. package/dist/engines/little-3d-engine/shapes/{octahedron.d.ts → primitives/octahedron.d.ts} +1 -1
  50. package/dist/engines/little-3d-engine/shapes/{pyramid.d.ts → primitives/pyramid.d.ts} +1 -1
  51. package/dist/engines/little-3d-engine/shapes/primitives/quad.d.ts +9 -0
  52. package/dist/engines/little-3d-engine/shapes/primitives/quad.js +18 -0
  53. package/dist/engines/little-3d-engine/shapes/{cube-sphere.d.ts → primitives/spheres/cube-sphere.d.ts} +1 -1
  54. package/dist/engines/little-3d-engine/shapes/{icosphere.d.ts → primitives/spheres/icosphere.d.ts} +1 -1
  55. package/dist/engines/little-3d-engine/shapes/{icosphere.js → primitives/spheres/icosphere.js} +1 -1
  56. package/dist/engines/little-3d-engine/shapes/{octa-sphere.d.ts → primitives/spheres/octa-sphere.d.ts} +1 -1
  57. package/dist/engines/little-3d-engine/shapes/{octa-sphere.js → primitives/spheres/octa-sphere.js} +1 -1
  58. package/dist/engines/little-3d-engine/shapes/{uv-sphere.d.ts → primitives/spheres/uv-sphere.d.ts} +1 -1
  59. package/dist/engines/little-3d-engine/shapes/{tetrahedron.d.ts → primitives/tetrahedron.d.ts} +1 -1
  60. package/dist/engines/little-3d-engine/textures/dynamic/canvas-texture.d.ts +1 -0
  61. package/dist/engines/little-3d-engine/textures/dynamic/canvas-texture.js +8 -0
  62. package/dist/engines/little-3d-engine/textures/dynamic/shine.d.ts +2 -0
  63. package/dist/engines/little-3d-engine/textures/dynamic/shine.js +14 -0
  64. package/dist/engines/little-3d-engine/textures/dynamic/star.d.ts +14 -0
  65. package/dist/engines/little-3d-engine/textures/dynamic/star.js +31 -0
  66. package/dist/engines/little-3d-engine/textures/dynamic/streak.d.ts +5 -0
  67. package/dist/engines/little-3d-engine/textures/dynamic/streak.js +20 -0
  68. package/dist/index.d.ts +2 -1
  69. package/dist/prefabs/charged-orb.d.ts +17 -0
  70. package/dist/prefabs/charged-orb.js +37 -0
  71. package/dist/prefabs/crystal-comet.d.ts +4 -0
  72. package/dist/prefabs/crystal-comet.js +41 -0
  73. package/dist/prefabs/ghost-train.d.ts +10 -0
  74. package/dist/prefabs/ghost-train.js +37 -0
  75. package/dist/prefabs/grid-assembly.d.ts +13 -0
  76. package/dist/prefabs/grid-assembly.js +15 -0
  77. package/dist/prefabs/monochrome-streak.d.ts +4 -0
  78. package/dist/prefabs/monochrome-streak.js +25 -0
  79. package/dist/prefabs/plane-star-trail.d.ts +4 -0
  80. package/dist/prefabs/plane-star-trail.js +40 -0
  81. package/dist/prefabs/prefabs.d.ts +10 -0
  82. package/dist/prefabs/prefabs.js +9 -0
  83. package/dist/prefabs/pulsing-starfield.d.ts +4 -0
  84. package/dist/prefabs/pulsing-starfield.js +27 -0
  85. package/dist/prefabs/rocket-launch.d.ts +10 -0
  86. package/dist/prefabs/rocket-launch.js +16 -0
  87. package/dist/prefabs/spinner.d.ts +7 -0
  88. package/dist/prefabs/spinner.js +17 -0
  89. package/dist/prefabs/star-swarm.d.ts +4 -0
  90. package/dist/prefabs/star-swarm.js +27 -0
  91. package/dist/prefabs/types.d.ts +46 -0
  92. package/dist/prefabs/types.js +1 -0
  93. package/dist/umd/spinner.global.js +2407 -85
  94. package/dist/umd/spinner.global.min.js +60 -5
  95. package/package.json +43 -2
  96. /package/dist/engines/little-3d-engine/shapes/{cube.js → primitives/cube.js} +0 -0
  97. /package/dist/engines/little-3d-engine/shapes/{octahedron.js → primitives/octahedron.js} +0 -0
  98. /package/dist/engines/little-3d-engine/shapes/{pyramid.js → primitives/pyramid.js} +0 -0
  99. /package/dist/engines/little-3d-engine/shapes/{cube-sphere.js → primitives/spheres/cube-sphere.js} +0 -0
  100. /package/dist/engines/little-3d-engine/shapes/{uv-sphere.js → primitives/spheres/uv-sphere.js} +0 -0
  101. /package/dist/engines/little-3d-engine/shapes/{tetrahedron.js → primitives/tetrahedron.js} +0 -0
@@ -1,4 +1,4 @@
1
- import type { Mesh } from "../core/mesh.js";
1
+ import type { Mesh } from "../../../core/mesh.js";
2
2
  /**
3
3
  * Build a cube-sphere (spherified cube) centered on the origin: each cube face
4
4
  * is gridded and projected onto the sphere. Even, all-quad, no poles.
@@ -1,4 +1,4 @@
1
- import type { Mesh } from "../core/mesh.js";
1
+ import type { Mesh } from "../../../core/mesh.js";
2
2
  /**
3
3
  * Build an icosphere (subdivided icosahedron) centered on the origin. Gives the
4
4
  * most uniform triangle distribution of the sphere types.
@@ -1,4 +1,4 @@
1
- import { sphereFromTriangles } from "../core/geometry.js";
1
+ import { sphereFromTriangles } from "../../../core/geometry.js";
2
2
  const DEFAULT_COLORS = ["#3b82f6", "#8b5cf6", "#ec4899", "#f59e0b", "#10b981", "#ef4444"];
3
3
  const T = (1 + Math.sqrt(5)) / 2;
4
4
  const SEED_VERTICES = [
@@ -1,4 +1,4 @@
1
- import type { Mesh } from "../core/mesh.js";
1
+ import type { Mesh } from "../../../core/mesh.js";
2
2
  /**
3
3
  * Build an octa-sphere (subdivided octahedron) centered on the origin.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { sphereFromTriangles } from "../core/geometry.js";
1
+ import { sphereFromTriangles } from "../../../core/geometry.js";
2
2
  const DEFAULT_COLORS = ["#3b82f6", "#8b5cf6", "#ec4899", "#f59e0b", "#10b981", "#ef4444"];
3
3
  const SEED_VERTICES = [
4
4
  { x: 1, y: 0, z: 0 },
@@ -1,4 +1,4 @@
1
- import type { Mesh } from "../core/mesh.js";
1
+ import type { Mesh } from "../../../core/mesh.js";
2
2
  /**
3
3
  * Build a UV (latitude/longitude) sphere centered on the origin.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { Mesh } from "../core/mesh.js";
1
+ import type { Mesh } from "../../core/mesh.js";
2
2
  /**
3
3
  * Build a regular tetrahedron mesh centered on the origin.
4
4
  *
@@ -0,0 +1 @@
1
+ export declare function canvasTexture(draw: (ctx: CanvasRenderingContext2D) => void, size?: number): HTMLCanvasElement;
@@ -0,0 +1,8 @@
1
+ export function canvasTexture(draw, size = 96) {
2
+ const canvas = document.createElement("canvas");
3
+ canvas.width = canvas.height = size;
4
+ const ctx = canvas.getContext("2d");
5
+ if (ctx)
6
+ draw(ctx);
7
+ return canvas;
8
+ }
@@ -0,0 +1,2 @@
1
+ /** A soft radial glow for particle billboards. */
2
+ export declare function shineTexture(): HTMLCanvasElement;
@@ -0,0 +1,14 @@
1
+ import { canvasTexture } from "./canvas-texture.js";
2
+ /** A soft radial glow for particle billboards. */
3
+ export function shineTexture() {
4
+ return canvasTexture((ctx) => {
5
+ const halo = ctx.createRadialGradient(48, 48, 1, 48, 48, 46);
6
+ halo.addColorStop(0, "rgba(255,255,255,1)");
7
+ halo.addColorStop(0.08, "rgba(255,255,255,1)");
8
+ halo.addColorStop(0.22, "rgba(210,240,255,0.7)");
9
+ halo.addColorStop(0.55, "rgba(120,200,255,0.22)");
10
+ halo.addColorStop(1, "rgba(80,160,255,0)");
11
+ ctx.fillStyle = halo;
12
+ ctx.fillRect(0, 0, 96, 96);
13
+ });
14
+ }
@@ -0,0 +1,14 @@
1
+ /** Options for {@link starTexture}. */
2
+ export interface StarTextureOptions {
3
+ /**
4
+ * Radius of a soft glow drawn around the star, in canvas pixels. A blurred
5
+ * copy of the star is composited underneath the crisp one, so the glow takes
6
+ * the particle's tint. Default `0` (no glow).
7
+ */
8
+ glow?: number;
9
+ }
10
+ /**
11
+ * A white five-point star on a transparent square canvas. With `glow`, a
12
+ * blurred copy is composited beneath the crisp star for a soft halo.
13
+ */
14
+ export declare function starTexture(options?: StarTextureOptions): HTMLCanvasElement;
@@ -0,0 +1,31 @@
1
+ import { canvasTexture } from "./canvas-texture.js";
2
+ function drawStar(ctx) {
3
+ ctx.save();
4
+ ctx.translate(48, 48);
5
+ ctx.fillStyle = "#fff";
6
+ ctx.beginPath();
7
+ for (let index = 0; index < 10; index++) {
8
+ const radius = index % 2 === 0 ? 43 : 16;
9
+ const angle = (index * Math.PI) / 5 - Math.PI / 2;
10
+ ctx.lineTo(radius * Math.cos(angle), radius * Math.sin(angle));
11
+ }
12
+ ctx.closePath();
13
+ ctx.fill();
14
+ ctx.restore();
15
+ }
16
+ /**
17
+ * A white five-point star on a transparent square canvas. With `glow`, a
18
+ * blurred copy is composited beneath the crisp star for a soft halo.
19
+ */
20
+ export function starTexture(options = {}) {
21
+ const glow = Math.max(0, options.glow ?? 0);
22
+ return canvasTexture((ctx) => {
23
+ if (glow > 0) {
24
+ ctx.save();
25
+ ctx.filter = `blur(${glow}px)`;
26
+ drawStar(ctx);
27
+ ctx.restore();
28
+ }
29
+ drawStar(ctx);
30
+ });
31
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A horizontal streak fading from transparent to white.
3
+ * Head at x=91 (alignToMotion rolls the billboard +x onto the velocity).
4
+ */
5
+ export declare function streakTexture(): HTMLCanvasElement;
@@ -0,0 +1,20 @@
1
+ import { canvasTexture } from "./canvas-texture.js";
2
+ /**
3
+ * A horizontal streak fading from transparent to white.
4
+ * Head at x=91 (alignToMotion rolls the billboard +x onto the velocity).
5
+ */
6
+ export function streakTexture() {
7
+ return canvasTexture((ctx) => {
8
+ const gradient = ctx.createLinearGradient(5, 0, 91, 0);
9
+ gradient.addColorStop(0, "rgba(255,255,255,0)");
10
+ gradient.addColorStop(0.7, "rgba(255,255,255,0.4)");
11
+ gradient.addColorStop(1, "rgba(255,255,255,1)");
12
+ ctx.strokeStyle = gradient;
13
+ ctx.lineWidth = 3.5;
14
+ ctx.lineCap = "round";
15
+ ctx.beginPath();
16
+ ctx.moveTo(5, 48);
17
+ ctx.lineTo(91, 48);
18
+ ctx.stroke();
19
+ });
20
+ }
package/dist/index.d.ts CHANGED
@@ -34,4 +34,5 @@ export interface Spinner {
34
34
  destroy(): void;
35
35
  }
36
36
  export declare function createSpinner(target: HTMLElement, options: SpinnerOptions): Spinner;
37
- export type { SpinnerAnimation, AnimationFrame } from "./animation.js";
37
+ export type { SpinnerAnimation, AnimationFrame, AnimationLabel } from "./animation.js";
38
+ export type { CompositeAnimationLayer } from "./composite-animation.js";
@@ -0,0 +1,17 @@
1
+ import { type ChargedOrbOptions } from "../animations/charged-orb.js";
2
+ import type { ProgressSpinnerOptions } from "../index.js";
3
+ import type { ParticlesOptions } from "../animations/particles.js";
4
+ import type { ProgressPrefabOptions } from "./types.js";
5
+ export interface ChargedOrbPrefabOptions extends ProgressPrefabOptions {
6
+ /** Overrides for the orb layer. */
7
+ orb?: ChargedOrbOptions;
8
+ /** Overrides for the particle layer. */
9
+ particles?: ParticlesOptions;
10
+ }
11
+ /**
12
+ * A progress story: the center orb pops straight to full size, and every 10%
13
+ * of progress a mini orb pops out of it into an evenly spread satellite ring,
14
+ * each satellite trailing its own spark stream; at 100% the satellites take
15
+ * one extra lap, dive back into the big orb, and the orb pops away.
16
+ */
17
+ export declare function chargedOrb(options?: ChargedOrbPrefabOptions): ProgressSpinnerOptions;
@@ -0,0 +1,37 @@
1
+ import { CompositeAnimation } from "../composite-animation.js";
2
+ import { ParticlesAnimation } from "../animations/particles.js";
3
+ import { ChargedOrbAnimation } from "../animations/charged-orb.js";
4
+ import { shineTexture } from "../engines/little-3d-engine/little-3d-engine.js";
5
+ import { progressSpinner } from "./spinner.js";
6
+ /**
7
+ * A progress story: the center orb pops straight to full size, and every 10%
8
+ * of progress a mini orb pops out of it into an evenly spread satellite ring,
9
+ * each satellite trailing its own spark stream; at 100% the satellites take
10
+ * one extra lap, dive back into the big orb, and the orb pops away.
11
+ */
12
+ export function chargedOrb(options = {}) {
13
+ const particles = options.particles ?? {};
14
+ const rate = particles.rate ?? 60;
15
+ const orb = new ChargedOrbAnimation({
16
+ backend: options.backend,
17
+ ...options.orb,
18
+ });
19
+ // One spark stream per satellite: the emitter cycles spawn slots across the
20
+ // live mini orbs, so its gap must match the particle layer's emission gap.
21
+ const streams = new ParticlesAnimation({
22
+ rate,
23
+ lifeMs: 1200,
24
+ size: 0.12,
25
+ speed: 0.05,
26
+ colors: ["#ffffff", "#a5f3fc", "#818cf8"],
27
+ texture: particles.texture ?? shineTexture(),
28
+ emitter: orb.satelliteEmitter(1000 / rate),
29
+ outroMs: orb.outroEmitMs,
30
+ seed: 5,
31
+ backend: options.backend,
32
+ ...particles,
33
+ label: options.label ?? particles.label,
34
+ fadeLabel: options.fadeLabel ?? particles.fadeLabel,
35
+ });
36
+ return progressSpinner(new CompositeAnimation([orb, streams]), options);
37
+ }
@@ -0,0 +1,4 @@
1
+ import type { IndeterminateSpinnerOptions } from "../index.js";
2
+ import type { MotionPrefabOptions } from "./types.js";
3
+ /** A spinning crystal primitive with a luminous comet trail. */
4
+ export declare function crystalComet(options?: MotionPrefabOptions): IndeterminateSpinnerOptions;
@@ -0,0 +1,41 @@
1
+ import { CompositeAnimation } from "../composite-animation.js";
2
+ import { ObjectMotionAnimation } from "../animations/object-motion.js";
3
+ import { ParticlesAnimation } from "../animations/particles.js";
4
+ import { shineTexture, tetrahedron } from "../engines/little-3d-engine/little-3d-engine.js";
5
+ import { figureEightMotion } from "../motion/figure-eight.js";
6
+ import { spinner } from "./spinner.js";
7
+ /** A spinning crystal primitive with a luminous comet trail. */
8
+ export function crystalComet(options = {}) {
9
+ const motion = options.object?.motion ?? figureEightMotion({ size: 0.66, periodMs: 7200 });
10
+ const particles = options.particles ?? {};
11
+ // The object defines the primary direction; the particles trail its actual position through
12
+ // the intro/outro fly transitions (not the bare path), so the two layers stay in sync.
13
+ const object = new ObjectMotionAnimation({
14
+ mesh: () => tetrahedron(1, ["#f0f9ff", "#7dd3fc", "#818cf8", "#e879f9"]),
15
+ motion,
16
+ size: 0.42,
17
+ rotation: { spinX: 0.002, spinY: 0.003 },
18
+ backend: options.backend,
19
+ ...options.object,
20
+ label: options.object?.label,
21
+ });
22
+ const animation = new CompositeAnimation([
23
+ new ParticlesAnimation({
24
+ rate: 44,
25
+ lifeMs: 2300,
26
+ size: 0.25,
27
+ speed: 0.08,
28
+ colors: ["#ffffff", "#bae6fd", "#818cf8"],
29
+ texture: particles.texture ?? shineTexture(),
30
+ emitter: object.trailEmitter(),
31
+ outroMs: object.outroDurationMs,
32
+ seed: 28,
33
+ backend: options.backend,
34
+ ...particles,
35
+ label: options.label ?? particles.label ?? "Polishing pixels",
36
+ fadeLabel: options.fadeLabel ?? particles.fadeLabel,
37
+ }),
38
+ object,
39
+ ]);
40
+ return spinner(animation, options);
41
+ }
@@ -0,0 +1,10 @@
1
+ import type { ProgressSpinnerOptions } from "../index.js";
2
+ import type { MotionProgressPrefabOptions } from "./types.js";
3
+ /**
4
+ * A progress story: a translucent train of ice cubes runs laps around a tilted
5
+ * square track, shedding a trail of pale stars. Every 2% of progress attaches
6
+ * one more car, popping it into existence at the tail; at 100% the whole convoy
7
+ * peels off the track one after another and accelerates away, clearing the view
8
+ * within four seconds as the star trail drains behind it.
9
+ */
10
+ export declare function ghostTrain(options?: MotionProgressPrefabOptions): ProgressSpinnerOptions;
@@ -0,0 +1,37 @@
1
+ import { CompositeAnimation } from "../composite-animation.js";
2
+ import { GhostTrainAnimation } from "../animations/ghost-train.js";
3
+ import { ParticlesAnimation } from "../animations/particles.js";
4
+ import { starTexture } from "../engines/little-3d-engine/little-3d-engine.js";
5
+ import { progressSpinner } from "./spinner.js";
6
+ /**
7
+ * A progress story: a translucent train of ice cubes runs laps around a tilted
8
+ * square track, shedding a trail of pale stars. Every 2% of progress attaches
9
+ * one more car, popping it into existence at the tail; at 100% the whole convoy
10
+ * peels off the track one after another and accelerates away, clearing the view
11
+ * within four seconds as the star trail drains behind it.
12
+ */
13
+ export function ghostTrain(options = {}) {
14
+ const particles = options.particles ?? {};
15
+ const train = new GhostTrainAnimation({
16
+ motion: options.object?.motion,
17
+ backend: options.backend,
18
+ });
19
+ // The lead car defines the primary direction; the stars trail its actual position
20
+ // through the laps and the accelerating blast-off, so the two layers stay in sync.
21
+ const trail = new ParticlesAnimation({
22
+ rate: 30,
23
+ lifeMs: 1700,
24
+ size: 0.15,
25
+ speed: 0.11,
26
+ colors: ["#e0f2fe", "#a5f3fc", "#c4b5fd"],
27
+ texture: particles.texture ?? starTexture({ glow: 5 }),
28
+ emitter: train.trailEmitter(),
29
+ outroMs: train.outroDurationMs,
30
+ seed: 17,
31
+ backend: options.backend,
32
+ ...particles,
33
+ label: options.label ?? particles.label,
34
+ fadeLabel: options.fadeLabel ?? particles.fadeLabel,
35
+ });
36
+ return progressSpinner(new CompositeAnimation([trail, train]), options);
37
+ }
@@ -0,0 +1,13 @@
1
+ import { type GridAssemblyOptions } from "../animations/grid-assembly.js";
2
+ import type { ProgressSpinnerOptions } from "../index.js";
3
+ import type { ProgressPrefabOptions } from "./types.js";
4
+ export interface GridAssemblyPrefabOptions extends ProgressPrefabOptions {
5
+ /** Overrides for the assembly animation. */
6
+ assembly?: GridAssemblyOptions;
7
+ }
8
+ /**
9
+ * A progress story: 25 shapes fly in and circle the view edge, dock one by one
10
+ * into a 5x5 grid as progress climbs, hold the finished grid for a moment at
11
+ * 100%, then dive into the center and vanish with a small pop.
12
+ */
13
+ export declare function gridAssembly(options?: GridAssemblyPrefabOptions): ProgressSpinnerOptions;
@@ -0,0 +1,15 @@
1
+ import { GridAssemblyAnimation, } from "../animations/grid-assembly.js";
2
+ import { progressSpinner } from "./spinner.js";
3
+ /**
4
+ * A progress story: 25 shapes fly in and circle the view edge, dock one by one
5
+ * into a 5x5 grid as progress climbs, hold the finished grid for a moment at
6
+ * 100%, then dive into the center and vanish with a small pop.
7
+ */
8
+ export function gridAssembly(options = {}) {
9
+ return progressSpinner(new GridAssemblyAnimation({
10
+ backend: options.backend,
11
+ label: options.label,
12
+ fadeLabel: options.fadeLabel,
13
+ ...options.assembly,
14
+ }), options);
15
+ }
@@ -0,0 +1,4 @@
1
+ import type { IndeterminateSpinnerOptions } from "../index.js";
2
+ import type { ParticlePrefabOptions } from "./types.js";
3
+ /** A fountain of black and white streaks that turn with their travel direction. */
4
+ export declare function monochromeStreak(options?: ParticlePrefabOptions): IndeterminateSpinnerOptions;
@@ -0,0 +1,25 @@
1
+ import { ParticlesAnimation } from "../animations/particles.js";
2
+ import { streakTexture } from "../engines/little-3d-engine/little-3d-engine.js";
3
+ import { spinner } from "./spinner.js";
4
+ /** A fountain of black and white streaks that turn with their travel direction. */
5
+ export function monochromeStreak(options = {}) {
6
+ const particles = options.particles ?? {};
7
+ return spinner(new ParticlesAnimation({
8
+ rate: 70,
9
+ lifeMs: 2800,
10
+ size: 0.38,
11
+ speed: 1.35,
12
+ direction: { x: 0, y: 1, z: 0 },
13
+ spread: 0.62,
14
+ gravity: { x: 0, y: -1.45, z: 0 },
15
+ colors: ["#fff", "#000"],
16
+ texture: particles.texture ?? streakTexture(),
17
+ spin: 0,
18
+ alignToMotion: true,
19
+ seed: 37,
20
+ backend: options.backend,
21
+ ...particles,
22
+ label: options.label ?? particles.label ?? "Loading...",
23
+ fadeLabel: options.fadeLabel ?? particles.fadeLabel,
24
+ }), options);
25
+ }
@@ -0,0 +1,4 @@
1
+ import type { IndeterminateSpinnerOptions } from "../index.js";
2
+ import type { MotionPrefabOptions } from "./types.js";
3
+ /** A small plane looping through a stream of colorful star particles. */
4
+ export declare function planeStarTrail(options?: MotionPrefabOptions): IndeterminateSpinnerOptions;
@@ -0,0 +1,40 @@
1
+ import { CompositeAnimation } from "../composite-animation.js";
2
+ import { ObjectMotionAnimation } from "../animations/object-motion.js";
3
+ import { ParticlesAnimation } from "../animations/particles.js";
4
+ import { planeMesh, starTexture } from "../engines/little-3d-engine/little-3d-engine.js";
5
+ import { figureEightMotion } from "../motion/figure-eight.js";
6
+ import { spinner } from "./spinner.js";
7
+ /** A small plane looping through a stream of colorful star particles. */
8
+ export function planeStarTrail(options = {}) {
9
+ const motion = options.object?.motion ?? figureEightMotion({ size: 0.72, periodMs: 6200 });
10
+ const particles = options.particles ?? {};
11
+ // The object defines the primary direction; the particles trail its actual position through
12
+ // the intro/outro fly transitions (not the bare path), so the two layers stay in sync.
13
+ const object = new ObjectMotionAnimation({
14
+ mesh: planeMesh,
15
+ motion,
16
+ size: 0.48,
17
+ backend: options.backend,
18
+ ...options.object,
19
+ label: options.object?.label,
20
+ });
21
+ const animation = new CompositeAnimation([
22
+ new ParticlesAnimation({
23
+ rate: 34,
24
+ lifeMs: 1900,
25
+ size: 0.16,
26
+ speed: 0.11,
27
+ colors: ["#fde047", "#f472b6", "#7dd3fc"],
28
+ texture: particles.texture ?? starTexture(),
29
+ emitter: object.trailEmitter(),
30
+ outroMs: object.outroDurationMs,
31
+ seed: 11,
32
+ backend: options.backend,
33
+ ...particles,
34
+ label: options.label ?? particles.label ?? "Flying in...",
35
+ fadeLabel: options.fadeLabel ?? particles.fadeLabel,
36
+ }),
37
+ object,
38
+ ]);
39
+ return spinner(animation, options);
40
+ }
@@ -0,0 +1,10 @@
1
+ export type { MotionPrefabOptions, MotionProgressPrefabOptions, ParticlePrefabOptions, PrefabOptions, ProgressPrefabOptions, } from "./types.js";
2
+ export { chargedOrb, type ChargedOrbPrefabOptions } from "./charged-orb.js";
3
+ export { crystalComet } from "./crystal-comet.js";
4
+ export { ghostTrain } from "./ghost-train.js";
5
+ export { gridAssembly, type GridAssemblyPrefabOptions } from "./grid-assembly.js";
6
+ export { monochromeStreak } from "./monochrome-streak.js";
7
+ export { planeStarTrail } from "./plane-star-trail.js";
8
+ export { pulsingStarfield } from "./pulsing-starfield.js";
9
+ export { rocketLaunch } from "./rocket-launch.js";
10
+ export { starSwarm } from "./star-swarm.js";
@@ -0,0 +1,9 @@
1
+ export { chargedOrb } from "./charged-orb.js";
2
+ export { crystalComet } from "./crystal-comet.js";
3
+ export { ghostTrain } from "./ghost-train.js";
4
+ export { gridAssembly } from "./grid-assembly.js";
5
+ export { monochromeStreak } from "./monochrome-streak.js";
6
+ export { planeStarTrail } from "./plane-star-trail.js";
7
+ export { pulsingStarfield } from "./pulsing-starfield.js";
8
+ export { rocketLaunch } from "./rocket-launch.js";
9
+ export { starSwarm } from "./star-swarm.js";
@@ -0,0 +1,4 @@
1
+ import type { IndeterminateSpinnerOptions } from "../index.js";
2
+ import type { ParticlePrefabOptions } from "./types.js";
3
+ /** High-shine particles drifting around a slowly pulsing HTML message. */
4
+ export declare function pulsingStarfield(options?: ParticlePrefabOptions): IndeterminateSpinnerOptions;
@@ -0,0 +1,27 @@
1
+ import { ParticlesAnimation } from "../animations/particles.js";
2
+ import { shineTexture } from "../engines/little-3d-engine/little-3d-engine.js";
3
+ import { spinner } from "./spinner.js";
4
+ function pulsingLabel() {
5
+ const label = document.createElement("div");
6
+ label.innerHTML = `<style>
7
+ @keyframes spinner-prefab-pulse { 0%,100% { color:#fff; transform:scale(1); } 50% { color:#93c5fd; transform:scale(1.06); } }
8
+ </style><div style="animation:spinner-prefab-pulse 2.4s ease-in-out infinite;font-size:2rem">Loading the good stuff</div>`;
9
+ return label;
10
+ }
11
+ /** High-shine particles drifting around a slowly pulsing HTML message. */
12
+ export function pulsingStarfield(options = {}) {
13
+ const particles = options.particles ?? {};
14
+ return spinner(new ParticlesAnimation({
15
+ rate: 48,
16
+ lifeMs: 4200,
17
+ size: 0.3,
18
+ speed: 0.34,
19
+ colors: ["#ffffff", "#dbeafe", "#93c5fd", "#c4b5fd"],
20
+ texture: particles.texture ?? shineTexture(),
21
+ seed: 71,
22
+ backend: options.backend,
23
+ ...particles,
24
+ label: options.label ?? particles.label ?? pulsingLabel(),
25
+ fadeLabel: options.fadeLabel ?? particles.fadeLabel,
26
+ }), options);
27
+ }
@@ -0,0 +1,10 @@
1
+ import type { ProgressSpinnerOptions } from "../index.js";
2
+ import type { ProgressPrefabOptions } from "./types.js";
3
+ /**
4
+ * A progress story on a launch pad: every 5% of progress a small rocket slides
5
+ * in cartoon-style from the right and lines up under the progress text, idling
6
+ * on a thin wisp of smoke. At 100% the whole row blasts off in a loose stagger
7
+ * on columns of fire; partway up, three of them suddenly veer 30-50 degrees and
8
+ * streak away.
9
+ */
10
+ export declare function rocketLaunch(options?: ProgressPrefabOptions): ProgressSpinnerOptions;
@@ -0,0 +1,16 @@
1
+ import { RocketLaunchAnimation } from "../animations/rocket-launch.js";
2
+ import { progressSpinner } from "./spinner.js";
3
+ /**
4
+ * A progress story on a launch pad: every 5% of progress a small rocket slides
5
+ * in cartoon-style from the right and lines up under the progress text, idling
6
+ * on a thin wisp of smoke. At 100% the whole row blasts off in a loose stagger
7
+ * on columns of fire; partway up, three of them suddenly veer 30-50 degrees and
8
+ * streak away.
9
+ */
10
+ export function rocketLaunch(options = {}) {
11
+ return progressSpinner(new RocketLaunchAnimation({
12
+ backend: options.backend,
13
+ label: options.label,
14
+ fadeLabel: options.fadeLabel,
15
+ }), options);
16
+ }
@@ -0,0 +1,7 @@
1
+ import type { CompositeAnimation } from "../composite-animation.js";
2
+ import type { ParticlesAnimation } from "../animations/particles.js";
3
+ import type { SpinnerAnimation } from "../animation.js";
4
+ import type { IndeterminateSpinnerOptions, ProgressSpinnerOptions } from "../index.js";
5
+ import type { PrefabOptions, ProgressPrefabOptions } from "./types.js";
6
+ export declare function spinner(animation: CompositeAnimation | ParticlesAnimation, options: PrefabOptions): IndeterminateSpinnerOptions;
7
+ export declare function progressSpinner(animation: SpinnerAnimation, options: ProgressPrefabOptions): ProgressSpinnerOptions;
@@ -0,0 +1,17 @@
1
+ export function spinner(animation, options) {
2
+ return {
3
+ type: "indeterminate",
4
+ animation,
5
+ loop: options.loop,
6
+ periodMs: options.periodMs,
7
+ };
8
+ }
9
+ export function progressSpinner(animation, options) {
10
+ return {
11
+ type: "progress",
12
+ animation,
13
+ progress: options.progress ?? 0.001,
14
+ timeout: options.timeout,
15
+ until: options.until,
16
+ };
17
+ }
@@ -0,0 +1,4 @@
1
+ import type { IndeterminateSpinnerOptions } from "../index.js";
2
+ import type { ParticlePrefabOptions } from "./types.js";
3
+ /** Bright star particles wandering around a centered loading message. */
4
+ export declare function starSwarm(options?: ParticlePrefabOptions): IndeterminateSpinnerOptions;
@@ -0,0 +1,27 @@
1
+ import { ParticlesAnimation } from "../animations/particles.js";
2
+ import { starTexture } from "../engines/little-3d-engine/little-3d-engine.js";
3
+ import { wanderMotion } from "../motion/wander.js";
4
+ import { spinner } from "./spinner.js";
5
+ /** Bright star particles wandering around a centered loading message. */
6
+ export function starSwarm(options = {}) {
7
+ const particles = options.particles ?? {};
8
+ const emitter = particles.emitter ?? wanderMotion({
9
+ bounds: { x: 1.1, y: 0.72, z: 0.35 },
10
+ periodMs: 7200,
11
+ seed: 19,
12
+ });
13
+ return spinner(new ParticlesAnimation({
14
+ rate: 38,
15
+ lifeMs: 2600,
16
+ size: 0.15,
17
+ speed: 0.17,
18
+ colors: ["#fef08a", "#f9a8d4", "#a5f3fc"],
19
+ texture: particles.texture ?? starTexture(),
20
+ emitter,
21
+ seed: 91,
22
+ backend: options.backend,
23
+ ...particles,
24
+ label: options.label ?? particles.label ?? "Loading...",
25
+ fadeLabel: options.fadeLabel ?? particles.fadeLabel,
26
+ }), options);
27
+ }
@@ -0,0 +1,46 @@
1
+ import type { AnimationLabel } from "../animation.js";
2
+ import type { ObjectMotionOptions } from "../animations/object-motion.js";
3
+ import type { ParticlesOptions } from "../animations/particles.js";
4
+ import type { Backend } from "../engines/little-3d-engine/little-3d-engine.js";
5
+ export interface PrefabOptions {
6
+ /** Rendering backend used by every layer. Default `"canvas2d"`. */
7
+ backend?: Backend;
8
+ /** Text or custom HTML shown over the prefab. */
9
+ label?: AnimationLabel;
10
+ /** Fade the label during intro and outro. Default `true`. */
11
+ fadeLabel?: boolean;
12
+ /** Indeterminate progress loop. Default `"bounce"`. */
13
+ loop?: "bounce" | "restart";
14
+ /** Milliseconds for one progress sweep. Default `2000`. */
15
+ periodMs?: number;
16
+ }
17
+ export interface ProgressPrefabOptions {
18
+ /** Rendering backend used by every layer. Default `"canvas2d"`. */
19
+ backend?: Backend;
20
+ /** Text or custom HTML shown over the prefab (progress mode shows a percentage). */
21
+ label?: AnimationLabel;
22
+ /** Fade the label with the story's beginning and end. Default `true`. */
23
+ fadeLabel?: boolean;
24
+ /** Initial progress 0..1. Defaults just above zero so the story begins on mount. */
25
+ progress?: number;
26
+ /** Auto-complete (drive progress to 1) after this many milliseconds. */
27
+ timeout?: number;
28
+ /** Auto-complete at this absolute time. If both are set, the earlier wins. */
29
+ until?: Date;
30
+ }
31
+ export interface MotionPrefabOptions extends PrefabOptions {
32
+ /** Overrides for the moving object layer, including `mesh` and `motion`. */
33
+ object?: Partial<ObjectMotionOptions>;
34
+ /** Overrides for the particle layer. */
35
+ particles?: ParticlesOptions;
36
+ }
37
+ export interface ParticlePrefabOptions extends PrefabOptions {
38
+ /** Overrides for the particle animation. */
39
+ particles?: ParticlesOptions;
40
+ }
41
+ export interface MotionProgressPrefabOptions extends ProgressPrefabOptions {
42
+ /** Overrides for the moving object layer, including `mesh` and `motion`. */
43
+ object?: Partial<ObjectMotionOptions>;
44
+ /** Overrides for the particle layer. */
45
+ particles?: ParticlesOptions;
46
+ }
@@ -0,0 +1 @@
1
+ export {};