3d-spinner 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -11
- package/dist/animation-label.d.ts +8 -0
- package/dist/animation-label.js +47 -0
- package/dist/animation.d.ts +2 -0
- package/dist/animations/charged-orb.d.ts +55 -0
- package/dist/animations/charged-orb.js +229 -0
- package/dist/animations/grid-assembly.d.ts +67 -0
- package/dist/animations/grid-assembly.js +268 -0
- package/dist/animations/object-motion.d.ts +19 -7
- package/dist/animations/object-motion.js +38 -32
- package/dist/animations/particles.d.ts +110 -0
- package/dist/animations/particles.js +209 -0
- package/dist/cjs/animations/charged-orb.cjs +1334 -0
- package/dist/cjs/animations/grid-assembly.cjs +1498 -0
- package/dist/cjs/animations/object-motion.cjs +1449 -0
- package/dist/cjs/animations/particles.cjs +1940 -0
- package/dist/cjs/animations/spin.cjs +1300 -0
- package/dist/cjs/composite-animation.cjs +58 -0
- package/dist/cjs/engines/little-3d-engine/little-3d-engine.cjs +1433 -0
- package/dist/cjs/engines/little-3d-engine/loaders/obj.cjs +87 -0
- package/dist/cjs/engines/little-3d-engine/renderers/canvas2d-textured.cjs +345 -0
- package/dist/cjs/engines/little-3d-engine/renderers/webgl-textured.cjs +528 -0
- package/dist/cjs/engines/little-3d-engine/renderers/webgpu-textured.cjs +712 -0
- package/dist/cjs/engines/little-tween-engine/little-tween-engine.cjs +279 -0
- package/dist/cjs/index.cjs +120 -0
- package/dist/cjs/motion/motion.cjs +140 -0
- package/dist/cjs/motion/transitions.cjs +80 -0
- package/dist/cjs/prefabs/prefabs.cjs +3450 -0
- package/dist/composite-animation.d.ts +18 -0
- package/dist/composite-animation.js +39 -0
- package/dist/engines/little-3d-engine/little-3d-engine.d.ts +17 -12
- package/dist/engines/little-3d-engine/little-3d-engine.js +13 -8
- package/dist/engines/little-3d-engine/loaders/obj.d.ts +12 -4
- package/dist/engines/little-3d-engine/loaders/obj.js +44 -5
- package/dist/engines/little-3d-engine/renderer.d.ts +7 -1
- package/dist/engines/little-3d-engine/renderer.js +2 -0
- package/dist/engines/little-3d-engine/renderers/canvas2d-textured.d.ts +20 -0
- package/dist/engines/little-3d-engine/renderers/canvas2d-textured.js +135 -0
- package/dist/engines/little-3d-engine/renderers/textured-helpers.d.ts +9 -0
- package/dist/engines/little-3d-engine/renderers/textured-helpers.js +35 -0
- package/dist/engines/little-3d-engine/renderers/webgl-textured.d.ts +43 -0
- package/dist/engines/little-3d-engine/renderers/webgl-textured.js +211 -0
- package/dist/engines/little-3d-engine/renderers/webgpu-textured.d.ts +45 -0
- package/dist/engines/little-3d-engine/renderers/webgpu-textured.js +300 -0
- package/dist/engines/little-3d-engine/renderers/webgpu.d.ts +11 -6
- package/dist/engines/little-3d-engine/shapes/complex/plane.d.ts +3 -0
- package/dist/engines/little-3d-engine/shapes/complex/plane.js +33 -0
- package/dist/engines/little-3d-engine/shapes/{cube.d.ts → primitives/cube.d.ts} +1 -1
- package/dist/engines/little-3d-engine/shapes/{octahedron.d.ts → primitives/octahedron.d.ts} +1 -1
- package/dist/engines/little-3d-engine/shapes/{pyramid.d.ts → primitives/pyramid.d.ts} +1 -1
- package/dist/engines/little-3d-engine/shapes/primitives/quad.d.ts +9 -0
- package/dist/engines/little-3d-engine/shapes/primitives/quad.js +18 -0
- package/dist/engines/little-3d-engine/shapes/{cube-sphere.d.ts → primitives/spheres/cube-sphere.d.ts} +1 -1
- package/dist/engines/little-3d-engine/shapes/{icosphere.d.ts → primitives/spheres/icosphere.d.ts} +1 -1
- package/dist/engines/little-3d-engine/shapes/{icosphere.js → primitives/spheres/icosphere.js} +1 -1
- package/dist/engines/little-3d-engine/shapes/{octa-sphere.d.ts → primitives/spheres/octa-sphere.d.ts} +1 -1
- package/dist/engines/little-3d-engine/shapes/{octa-sphere.js → primitives/spheres/octa-sphere.js} +1 -1
- package/dist/engines/little-3d-engine/shapes/{uv-sphere.d.ts → primitives/spheres/uv-sphere.d.ts} +1 -1
- package/dist/engines/little-3d-engine/shapes/{tetrahedron.d.ts → primitives/tetrahedron.d.ts} +1 -1
- package/dist/engines/little-3d-engine/textures/dynamic/canvas-texture.d.ts +1 -0
- package/dist/engines/little-3d-engine/textures/dynamic/canvas-texture.js +8 -0
- package/dist/engines/little-3d-engine/textures/dynamic/shine.d.ts +2 -0
- package/dist/engines/little-3d-engine/textures/dynamic/shine.js +14 -0
- package/dist/engines/little-3d-engine/textures/dynamic/star.d.ts +2 -0
- package/dist/engines/little-3d-engine/textures/dynamic/star.js +16 -0
- package/dist/engines/little-3d-engine/textures/dynamic/streak.d.ts +5 -0
- package/dist/engines/little-3d-engine/textures/dynamic/streak.js +20 -0
- package/dist/index.d.ts +2 -1
- package/dist/prefabs/charged-orb.d.ts +17 -0
- package/dist/prefabs/charged-orb.js +37 -0
- package/dist/prefabs/crystal-comet.d.ts +4 -0
- package/dist/prefabs/crystal-comet.js +41 -0
- package/dist/prefabs/ghost-train.d.ts +9 -0
- package/dist/prefabs/ghost-train.js +44 -0
- package/dist/prefabs/grid-assembly.d.ts +13 -0
- package/dist/prefabs/grid-assembly.js +15 -0
- package/dist/prefabs/monochrome-streak.d.ts +4 -0
- package/dist/prefabs/monochrome-streak.js +25 -0
- package/dist/prefabs/plane-star-trail.d.ts +4 -0
- package/dist/prefabs/plane-star-trail.js +40 -0
- package/dist/prefabs/prefabs.d.ts +10 -0
- package/dist/prefabs/prefabs.js +9 -0
- package/dist/prefabs/pulsing-starfield.d.ts +4 -0
- package/dist/prefabs/pulsing-starfield.js +27 -0
- package/dist/prefabs/rocket-launch.d.ts +8 -0
- package/dist/prefabs/rocket-launch.js +59 -0
- package/dist/prefabs/spinner.d.ts +7 -0
- package/dist/prefabs/spinner.js +17 -0
- package/dist/prefabs/star-swarm.d.ts +4 -0
- package/dist/prefabs/star-swarm.js +27 -0
- package/dist/prefabs/types.d.ts +46 -0
- package/dist/prefabs/types.js +1 -0
- package/dist/umd/spinner.global.js +4212 -0
- package/dist/umd/spinner.global.min.js +113 -0
- package/package.json +67 -11
- /package/dist/engines/little-3d-engine/shapes/{cube.js → primitives/cube.js} +0 -0
- /package/dist/engines/little-3d-engine/shapes/{octahedron.js → primitives/octahedron.js} +0 -0
- /package/dist/engines/little-3d-engine/shapes/{pyramid.js → primitives/pyramid.js} +0 -0
- /package/dist/engines/little-3d-engine/shapes/{cube-sphere.js → primitives/spheres/cube-sphere.js} +0 -0
- /package/dist/engines/little-3d-engine/shapes/{uv-sphere.js → primitives/spheres/uv-sphere.js} +0 -0
- /package/dist/engines/little-3d-engine/shapes/{tetrahedron.js → primitives/tetrahedron.js} +0 -0
package/dist/engines/little-3d-engine/shapes/{icosphere.js → primitives/spheres/icosphere.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sphereFromTriangles } from "
|
|
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 = [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function canvasTexture(draw: (ctx: CanvasRenderingContext2D) => void, size?: number): 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,16 @@
|
|
|
1
|
+
import { canvasTexture } from "./canvas-texture.js";
|
|
2
|
+
/** A white five-point star on a transparent square canvas. */
|
|
3
|
+
export function starTexture() {
|
|
4
|
+
return canvasTexture((ctx) => {
|
|
5
|
+
ctx.translate(48, 48);
|
|
6
|
+
ctx.fillStyle = "#fff";
|
|
7
|
+
ctx.beginPath();
|
|
8
|
+
for (let index = 0; index < 10; index++) {
|
|
9
|
+
const radius = index % 2 === 0 ? 43 : 16;
|
|
10
|
+
const angle = (index * Math.PI) / 5 - Math.PI / 2;
|
|
11
|
+
ctx.lineTo(radius * Math.cos(angle), radius * Math.sin(angle));
|
|
12
|
+
}
|
|
13
|
+
ctx.closePath();
|
|
14
|
+
ctx.fill();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -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,9 @@
|
|
|
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 pulls in and runs laps
|
|
5
|
+
* around a tilted square track, shedding a trail of pale stars while progress
|
|
6
|
+
* climbs; at 100% the whole convoy flies off along the track, cars following
|
|
7
|
+
* the lead one by one, and the star trail drains behind them.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ghostTrain(options?: MotionProgressPrefabOptions): ProgressSpinnerOptions;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CompositeAnimation } from "../composite-animation.js";
|
|
2
|
+
import { ObjectMotionAnimation } from "../animations/object-motion.js";
|
|
3
|
+
import { ParticlesAnimation } from "../animations/particles.js";
|
|
4
|
+
import { cube, starTexture } from "../engines/little-3d-engine/little-3d-engine.js";
|
|
5
|
+
import { squareMotion } from "../motion/square.js";
|
|
6
|
+
import { progressSpinner } from "./spinner.js";
|
|
7
|
+
/**
|
|
8
|
+
* A progress story: a translucent train of ice cubes pulls in and runs laps
|
|
9
|
+
* around a tilted square track, shedding a trail of pale stars while progress
|
|
10
|
+
* climbs; at 100% the whole convoy flies off along the track, cars following
|
|
11
|
+
* the lead one by one, and the star trail drains behind them.
|
|
12
|
+
*/
|
|
13
|
+
export function ghostTrain(options = {}) {
|
|
14
|
+
const motion = options.object?.motion ?? squareMotion({ size: 1.7, periodMs: 6800, tilt: 0.5 });
|
|
15
|
+
const particles = options.particles ?? {};
|
|
16
|
+
// The object defines the primary direction; the particles trail its actual position through
|
|
17
|
+
// the intro/outro fly transitions (not the bare path), so the two layers stay in sync.
|
|
18
|
+
const object = new ObjectMotionAnimation({
|
|
19
|
+
mesh: () => cube(1, ["#bae6fd", "#7dd3fc", "#38bdf8", "#0ea5e9", "#a5f3fc", "#e0f2fe"]),
|
|
20
|
+
motion,
|
|
21
|
+
size: 0.3,
|
|
22
|
+
transparency: { mode: "two-sided", opacity: 0.55 },
|
|
23
|
+
tail: { count: 4, gapMs: 240 },
|
|
24
|
+
backend: options.backend,
|
|
25
|
+
...options.object,
|
|
26
|
+
label: options.object?.label,
|
|
27
|
+
});
|
|
28
|
+
const trail = new ParticlesAnimation({
|
|
29
|
+
rate: 30,
|
|
30
|
+
lifeMs: 1700,
|
|
31
|
+
size: 0.13,
|
|
32
|
+
speed: 0.07,
|
|
33
|
+
colors: ["#e0f2fe", "#a5f3fc", "#c4b5fd"],
|
|
34
|
+
texture: particles.texture ?? starTexture(),
|
|
35
|
+
emitter: object.trailEmitter(),
|
|
36
|
+
outroMs: object.outroDurationMs,
|
|
37
|
+
seed: 17,
|
|
38
|
+
backend: options.backend,
|
|
39
|
+
...particles,
|
|
40
|
+
label: options.label ?? particles.label,
|
|
41
|
+
fadeLabel: options.fadeLabel ?? particles.fadeLabel,
|
|
42
|
+
});
|
|
43
|
+
return progressSpinner(new CompositeAnimation([trail, object]), options);
|
|
44
|
+
}
|
|
@@ -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,8 @@
|
|
|
1
|
+
import type { ProgressSpinnerOptions } from "../index.js";
|
|
2
|
+
import type { MotionProgressPrefabOptions } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A progress story: a silver rocket glides in and patrols a slow loop on a
|
|
5
|
+
* column of embers while progress climbs; at 100% it pitches up and blasts off
|
|
6
|
+
* the top of the view, exhaust trailing behind it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function rocketLaunch(options?: MotionProgressPrefabOptions): ProgressSpinnerOptions;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CompositeAnimation } from "../composite-animation.js";
|
|
2
|
+
import { ObjectMotionAnimation } from "../animations/object-motion.js";
|
|
3
|
+
import { ParticlesAnimation } from "../animations/particles.js";
|
|
4
|
+
import { pyramid, shineTexture } from "../engines/little-3d-engine/little-3d-engine.js";
|
|
5
|
+
import { easeInCubic } from "../engines/little-tween-engine/core/tweens.js";
|
|
6
|
+
import { circleMotion } from "../motion/circle.js";
|
|
7
|
+
import { progressSpinner } from "./spinner.js";
|
|
8
|
+
// C1 launch: the handoff velocity coasts to a stop while the vertical climb
|
|
9
|
+
// accelerates, so the nose rotates smoothly from the patrol tangent to straight up.
|
|
10
|
+
const launchUp = ({ delta, position, velocity, durationMs }) => {
|
|
11
|
+
const coast = durationMs * delta * (1 - 0.5 * delta);
|
|
12
|
+
const climb = 5.5 * easeInCubic(delta);
|
|
13
|
+
return {
|
|
14
|
+
position: {
|
|
15
|
+
x: position.x + (velocity?.x ?? 0) * coast,
|
|
16
|
+
y: position.y + (velocity?.y ?? 0) * coast + climb,
|
|
17
|
+
z: position.z + (velocity?.z ?? 0) * coast,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A progress story: a silver rocket glides in and patrols a slow loop on a
|
|
23
|
+
* column of embers while progress climbs; at 100% it pitches up and blasts off
|
|
24
|
+
* the top of the view, exhaust trailing behind it.
|
|
25
|
+
*/
|
|
26
|
+
export function rocketLaunch(options = {}) {
|
|
27
|
+
const motion = options.object?.motion
|
|
28
|
+
?? circleMotion({ radius: 0.55, periodMs: 7000, tilt: 0.15 });
|
|
29
|
+
const particles = options.particles ?? {};
|
|
30
|
+
const object = new ObjectMotionAnimation({
|
|
31
|
+
mesh: () => pyramid(1, ["#e2e8f0", "#f8fafc", "#cbd5e1", "#94a3b8", "#e2e8f0"]),
|
|
32
|
+
motion,
|
|
33
|
+
size: 0.44,
|
|
34
|
+
facing: "+y",
|
|
35
|
+
outro: { transition: launchUp, durationMs: 1300 },
|
|
36
|
+
backend: options.backend,
|
|
37
|
+
...options.object,
|
|
38
|
+
label: options.object?.label,
|
|
39
|
+
});
|
|
40
|
+
const exhaust = new ParticlesAnimation({
|
|
41
|
+
rate: 46,
|
|
42
|
+
lifeMs: 1100,
|
|
43
|
+
size: 0.18,
|
|
44
|
+
speed: 0.5,
|
|
45
|
+
direction: { x: 0, y: -1, z: 0 },
|
|
46
|
+
spread: 0.3,
|
|
47
|
+
gravity: { x: 0, y: -0.6, z: 0 },
|
|
48
|
+
colors: ["#fde047", "#fb923c", "#ef4444", "#fef3c7"],
|
|
49
|
+
texture: particles.texture ?? shineTexture(),
|
|
50
|
+
emitter: object.trailEmitter(),
|
|
51
|
+
outroMs: object.outroDurationMs,
|
|
52
|
+
seed: 9,
|
|
53
|
+
backend: options.backend,
|
|
54
|
+
...particles,
|
|
55
|
+
label: options.label ?? particles.label,
|
|
56
|
+
fadeLabel: options.fadeLabel ?? particles.fadeLabel,
|
|
57
|
+
});
|
|
58
|
+
return progressSpinner(new CompositeAnimation([exhaust, object]), options);
|
|
59
|
+
}
|
|
@@ -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
|
+
}
|