@uxfront/scene 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,75 @@
1
+ import { smoothstep } from "../../gl/math.js";
2
+ import { defineFormation, mergeViews } from "../../gl/formation.js";
3
+ import { BEAMS, CONVERGE, beamProgress, beamReach, streamPoint } from "./geometry.js";
4
+ //#region src/formations/threshold/index.ts
5
+ /** The white stream's label: how far down the stream, and how far above it. */
6
+ const LABEL_AT = .3;
7
+ const LABEL_ABOVE = .32;
8
+ /**
9
+ * The seven beams of light, one per rail of the prism, cross a film of light
10
+ * into whatever comes next. The film is a soap film on a ring: its colours
11
+ * swirl as it drains, and ripples spread from where each beam goes through.
12
+ * Beyond it the light is faster: the beams turn the corner and converge into
13
+ * one white stream, the prism in reverse, which races off into the distance,
14
+ * its pulses stretched into streaks. They break through one after another as
15
+ * the chapter is read, and the stream brightens as each one joins it.
16
+ *
17
+ * Anchor `threshold:stream` sits just above the white stream, for its label,
18
+ * and shows once every beam has joined it.
19
+ */
20
+ function threshold(options) {
21
+ return defineFormation({
22
+ key: options.key ?? "threshold",
23
+ label: options.label,
24
+ views: mergeViews({
25
+ desktop: {
26
+ eye: [
27
+ 1.5,
28
+ .6,
29
+ 10.5
30
+ ],
31
+ target: [
32
+ .9,
33
+ .1,
34
+ -.6
35
+ ],
36
+ fov: 30,
37
+ span: [2.9, 1.8],
38
+ shift: [-.3, 0]
39
+ },
40
+ mobile: {
41
+ eye: [
42
+ 1.5,
43
+ .6,
44
+ 10.5
45
+ ],
46
+ target: [
47
+ .75,
48
+ .1,
49
+ -.6
50
+ ],
51
+ fov: 34,
52
+ span: [1.8, 1.5],
53
+ shift: [0, .3]
54
+ }
55
+ }, options.views),
56
+ look: {
57
+ bloom: 1.15,
58
+ reflect: .6,
59
+ ...options.look
60
+ },
61
+ anchors: [{
62
+ id: "stream",
63
+ place: ({ approach, local }, out) => {
64
+ streamPoint(LABEL_AT, out);
65
+ out[1] += LABEL_ABOVE;
66
+ const joined = (CONVERGE + LABEL_AT) / 11;
67
+ const reach = beamReach(BEAMS - 1, beamProgress(approach, local));
68
+ return smoothstep(joined, Math.min(1, joined + .25), reach);
69
+ }
70
+ }],
71
+ shader: () => import("./shader.js").then((m) => m.shader)
72
+ });
73
+ }
74
+ //#endregion
75
+ export { threshold };
@@ -0,0 +1,186 @@
1
+ import { glslArray, glslFloat, glslVec } from "../../gl/glsl.js";
2
+ import { SPECTRUM } from "../prism/spectrum.js";
3
+ import { ACROSS, BEAMS, BEAM_APPROACH, BREAK, CENTER, CONVERGE, CROSSING, FASTER, IN_DIR, MERGE, NORMAL, OUT_DIR, RADIUS, UP } from "./geometry.js";
4
+ //#region src/formations/threshold/shader.ts
5
+ const SPLIT = FASTER * 5 / (11 + FASTER * 5);
6
+ const RATE = .04;
7
+ const SPEED = 5 * RATE / SPLIT;
8
+ const shader = { glsl: `
9
+ const vec3 $C = ${glslVec(CENTER)};
10
+ const float $R = ${glslFloat(RADIUS)};
11
+ const vec3 $N = ${glslVec(NORMAL)};
12
+ const vec3 $U = ${glslVec(ACROSS)};
13
+ const vec3 $V = ${glslVec(UP)};
14
+ const vec3 $IN = ${glslVec(IN_DIR)};
15
+ const vec3 $OUT = ${glslVec(OUT_DIR)};
16
+ const float $IN_LEN = ${glslFloat(5)};
17
+ const float $OUT_LEN = ${glslFloat(11)};
18
+ const float $FASTER = ${glslFloat(FASTER)};
19
+ const float $CONVERGE = ${glslFloat(CONVERGE)};
20
+ const vec3 $MERGE = ${glslVec(MERGE)};
21
+ // The next framework's light: white, with a faint sheen of every colour.
22
+ const vec3 $WHITE = vec3(1.0, 0.97, 0.94);
23
+ const float $SPLIT = ${glslFloat(SPLIT)};
24
+ const float $RATE = ${glslFloat(RATE)};
25
+ const float $SPEED = ${glslFloat(SPEED)};
26
+
27
+ // The prism's spectrum, one colour per beam.
28
+ const vec3 $SPECTRUM[${BEAMS}] = ${glslArray("vec3", SPECTRUM.map(glslVec))};
29
+
30
+ float $progress(Frame f) {
31
+ if (f.approach < 1.0) return f.approach * ${glslFloat(BEAM_APPROACH)};
32
+ return mix(${glslFloat(BEAM_APPROACH)}, 1.0, f.local);
33
+ }
34
+ float $reach(int i, float progress) {
35
+ float o = ${glslFloat(BREAK.from)} + float(i) * ${glslFloat(BREAK.step)};
36
+ return smoothstep(o, o + ${glslFloat(BREAK.span)}, progress);
37
+ }
38
+
39
+ // Where beam i crosses the film, in the film's plane (across, up).
40
+ vec2 $crossing(int i) { return vec2(0.0, ${glslFloat(CROSSING[0])} - float(i) * ${glslFloat(CROSSING[1])}); }
41
+ vec3 $onFilm(vec2 q) { return $C + $U * q.x + $V * q.y; }
42
+
43
+ // How far along its beam a particle is, from its phase.
44
+ float $along(float phase) {
45
+ if (phase < $SPLIT) return phase / $SPLIT * $IN_LEN;
46
+ return $IN_LEN + (phase - $SPLIT) / (1.0 - $SPLIT) * $OUT_LEN;
47
+ }
48
+ // Beyond the film, the beam turns the corner and converges with the others on
49
+ // $MERGE, then runs on as one white stream. merged: 0 at the film, 1 from $MERGE.
50
+ vec3 $beamPoint(vec3 through, float dist, out float merged) {
51
+ merged = 0.0;
52
+ if (dist < $IN_LEN) return through - $IN * ($IN_LEN - dist);
53
+ float t = dist - $IN_LEN;
54
+ merged = 1.0;
55
+ if (t > $CONVERGE) return $MERGE + $OUT * (t - $CONVERGE);
56
+ float u = t / $CONVERGE;
57
+ merged = u;
58
+ vec3 p1 = through + $IN * $CONVERGE * 0.4;
59
+ vec3 p2 = $MERGE - $OUT * $CONVERGE * 0.35;
60
+ float v = 1.0 - u;
61
+ return v * v * v * through + 3.0 * v * v * u * p1 + 3.0 * v * u * u * p2 + u * u * u * $MERGE;
62
+ }
63
+ // When the light at dist set off: pulses travel with it, faster beyond the film.
64
+ float $arrival(float dist) {
65
+ if (dist < $IN_LEN) return dist / $SPEED;
66
+ return $IN_LEN / $SPEED + (dist - $IN_LEN) / ($SPEED * $FASTER);
67
+ }
68
+
69
+ // A soap film drains: thin at the top, thicker below, in swirling bands.
70
+ float $thickness(vec2 q, float t) {
71
+ vec2 w = q + 0.3 * vec2(sin(q.y * 2.3 + t * 0.4), sin(q.x * 2.9 - t * 0.35));
72
+ w += 0.12 * vec2(sin(w.y * 4.1 - t * 0.6), sin(w.x * 3.7 + t * 0.5));
73
+ return 0.35 - w.y * 0.4 + 0.08 * sin(length(w) * 3.0 - t * 0.3);
74
+ }
75
+ // Thin-film interference: the colour of a film of thickness h.
76
+ vec3 $iridescence(float h) {
77
+ return 0.55 + 0.45 * cos(TAU * (h * 1.7 + vec3(0.0, 0.33, 0.67)));
78
+ }
79
+
80
+ // Rings spreading over the film from where each beam goes through, three at a
81
+ // time, and one wide ring as it breaks through.
82
+ float $ripples(vec2 q, float progress, float time) {
83
+ float w = 0.0;
84
+ for (int i = 0; i < ${BEAMS}; i++) {
85
+ float reach = $reach(i, progress);
86
+ if (reach <= 0.0) continue;
87
+ float d = length(q - $crossing(i));
88
+ for (int k = 0; k < 3; k++) {
89
+ float r = fract(time * 0.22 + float(k) / 3.0 + float(i) * 0.137);
90
+ float ring = exp(-pow((d - r * $R * 1.3) * 24.0, 2.0));
91
+ w += ring * pow(1.0 - r, 2.0) * smoothstep(0.0, 0.1, r);
92
+ }
93
+ float burst = smoothstep(0.0, 0.8, reach);
94
+ w += exp(-pow((d - burst * $R * 2.2) * 14.0, 2.0)) * (1.0 - burst) * 3.0;
95
+ }
96
+ return w;
97
+ }
98
+
99
+ Particle $main(uint id, float sel, Frame f) {
100
+ float progress = $progress(f);
101
+ float time = f.time;
102
+ uint s = seedOf(id, 0x7E5A01D3u);
103
+ float a = rnd(s);
104
+ float b = rnd(s);
105
+ float c = rnd(s);
106
+ float d = rnd(s);
107
+ Particle P = blank();
108
+ vec2 g = gauss(b, c);
109
+ float halo = step(0.82, d);
110
+
111
+ if (sel < 0.46) {
112
+ // Seven beams: slow on this side of the film, faster beyond it.
113
+ int i = min(int(sel / 0.46 * ${glslFloat(BEAMS)}), ${BEAMS - 1});
114
+ float reach = $reach(i, progress);
115
+ float dist = $along(fract(a + time * $RATE));
116
+ float beyond = step($IN_LEN, dist);
117
+ float grown = $IN_LEN + reach * $OUT_LEN;
118
+ float merged;
119
+ vec3 p = $beamPoint($onFilm($crossing(i)), dist, merged);
120
+ float joined = smoothstep(0.55, 1.0, merged);
121
+ vec3 side = normalize(cross(mix($IN, $OUT, merged), $V));
122
+ vec2 off = g * mix(0.014, 0.05, halo) * (1.0 + 0.4 * joined);
123
+ P.pos = p + $V * off.x + side * off.y;
124
+ // Each beam keeps its own beat until it joins the stream, then they pulse as one.
125
+ float beat = float(i) * 1.3 * (1.0 - joined);
126
+ float pulse = pow(0.5 + 0.5 * sin(($arrival(dist) - time) * 4.0 + beat), 10.0);
127
+ float front = beyond * smoothstep(grown - 0.5, grown, dist) * (1.0 - smoothstep(0.97, 1.0, reach));
128
+ float shown = 1.0 - step(grown, dist);
129
+ float fade = smoothstep(0.0, 2.5, dist) * (1.0 - smoothstep($IN_LEN + $OUT_LEN * 0.3, $IN_LEN + $OUT_LEN * 0.8, dist));
130
+ // Sparser beyond the film, where the light moves faster: brighter to match.
131
+ // Where the seven overlap, each gives less, or the stream blows out.
132
+ float gain = mix(1.0, $FASTER * 1.2, beyond) * mix(1.0, 0.4, joined);
133
+ // The colours mix into white as the beams meet, and the stream shimmers.
134
+ vec3 white = mix($WHITE, $iridescence((dist - $IN_LEN) * 0.12 - time * 0.08), 0.12);
135
+ vec3 col = mix($SPECTRUM[i], white, smoothstep(0.25, 1.0, merged) * beyond);
136
+ P.col = col * mix(0.8, 0.1, halo) * (1.0 + pulse * 1.6 + front * 3.0) * gain * fade * shown;
137
+ P.size = mix(0.8, 1.1, halo);
138
+ P.refl = 1.0;
139
+ } else if (sel < 0.55) {
140
+ // Ripple rings, crisp over the film's glow.
141
+ int i = min(int(a * ${glslFloat(BEAMS)}), ${BEAMS - 1});
142
+ float reach = $reach(i, progress);
143
+ float k = floor(b * 3.0);
144
+ float r = fract(time * 0.22 + k / 3.0 + float(i) * 0.137);
145
+ vec2 q = $crossing(i) + r * $R * 1.3 * vec2(cos(c * TAU), sin(c * TAU));
146
+ float inside = 1.0 - smoothstep($R * 0.97, $R, length(q));
147
+ P.pos = $onFilm(q);
148
+ float life = pow(1.0 - r, 2.0) * smoothstep(0.0, 0.1, r);
149
+ P.col = mix($SPECTRUM[i], vec3(1.0), 0.55) * 0.3 * life * inside * smoothstep(0.0, 0.3, reach);
150
+ P.size = 0.75;
151
+ P.refl = 1.0;
152
+ } else if (sel < 0.85) {
153
+ // The film, iridescent, lit up by the ripples.
154
+ float rr = $R * sqrt(b);
155
+ vec2 q = rr * vec2(cos(c * TAU), sin(c * TAU));
156
+ float w = $ripples(q, progress, time);
157
+ float h = $thickness(q, time);
158
+ float edge = smoothstep($R * 0.7, $R, rr);
159
+ P.pos = $onFilm(q) + $N * w * 0.02;
160
+ P.col = $iridescence(h) * (0.028 + 0.04 * edge + 0.14 * w);
161
+ P.size = 0.9;
162
+ P.refl = 1.0;
163
+ } else if (sel < 0.9) {
164
+ // The ring that holds the film.
165
+ float ang = a * TAU;
166
+ vec2 q = ($R + g.x * 0.006) * vec2(cos(ang), sin(ang));
167
+ P.pos = $onFilm(q) + $N * g.y * 0.008;
168
+ float glint = pow(0.5 + 0.5 * cos(ang - time * 0.4), 10.0);
169
+ P.col = mix(vec3(0.82, 0.87, 1.0), $iridescence(ang / TAU + time * 0.03), 0.4) * (0.5 + glint);
170
+ P.size = 0.8;
171
+ P.refl = 1.0;
172
+ } else {
173
+ // Specks carried by the same current: slow on this side, fast beyond.
174
+ vec2 q = vec2(mix(-4.0, 4.0, a), mix(-1.2, 2.6, b));
175
+ float dist = $along(fract(c + time * $RATE * 0.5));
176
+ float beyond = step($IN_LEN, dist);
177
+ vec3 through = $onFilm(q);
178
+ P.pos = dist < $IN_LEN ? through - $IN * ($IN_LEN - dist) : through + $OUT * (dist - $IN_LEN);
179
+ P.col = vec3(0.7, 0.75, 0.95) * 0.06 * step(0.35, d) * mix(1.0, $FASTER, beyond);
180
+ P.size = 0.9;
181
+ }
182
+ return P;
183
+ }
184
+ ` };
185
+ //#endregion
186
+ export { shader };
package/dist/gl/glsl.d.ts CHANGED
@@ -6,4 +6,8 @@
6
6
  */
7
7
  /** Formats a number as a GLSL float literal, for constants interpolated into shaders. */
8
8
  export declare const glslFloat: (n: number) => string;
9
+ /** Formats two to four numbers as a GLSL vector literal, like `vec3(1.0, 0.5, 0.0)`. */
10
+ export declare const glslVec: (values: readonly number[]) => string;
11
+ /** Formats GLSL literals of one type as an array constructor, like `float[2](0.5, 1.0)`. */
12
+ export declare const glslArray: (type: string, items: readonly string[]) => string;
9
13
  //#endregion
package/dist/gl/glsl.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { SHAPE_POINT } from "./shapes.js";
1
2
  //#region src/gl/glsl.ts
2
3
  /**
3
4
  * The particle pipeline shared by every formation, and the post-processing
@@ -6,6 +7,13 @@
6
7
  */
7
8
  /** Formats a number as a GLSL float literal, for constants interpolated into shaders. */
8
9
  const glslFloat = (n) => Number.isInteger(n) ? `${n}.0` : `${n}`;
10
+ /** Formats two to four numbers as a GLSL vector literal, like `vec3(1.0, 0.5, 0.0)`. */
11
+ const glslVec = (values) => {
12
+ if (values.length < 2 || values.length > 4) throw new Error(`A GLSL vector holds 2 to 4 numbers, not ${values.length}.`);
13
+ return `vec${values.length}(${values.map(glslFloat).join(", ")})`;
14
+ };
15
+ /** Formats GLSL literals of one type as an array constructor, like `float[2](0.5, 1.0)`. */
16
+ const glslArray = (type, items) => `${type}[${items.length}](\n ${items.join(",\n ")}\n)`;
9
17
  /** Helpers every formation can use: hashing, noise, curl flow and path sampling. */
10
18
  const COMMON = `
11
19
  #define PI 3.141592653589793
@@ -127,7 +135,7 @@ vec2 rrectPoint(vec4 g, float r, float t) {
127
135
  float a = d / rr;
128
136
  return c + vec2(-inner.x, inner.y) + r * vec2(-cos(a), sin(a));
129
137
  }
130
- `;
138
+ ${SHAPE_POINT}`;
131
139
  /** Declarations every formation's `$main` works with. */
132
140
  const PARTICLE_TYPES = `
133
141
  struct Particle {
@@ -416,4 +424,4 @@ void main() {
416
424
  }
417
425
  `;
418
426
  //#endregion
419
- export { BLOOM_DOWN_FRAG, BLOOM_PREFILTER_FRAG, BLOOM_UP_FRAG, COMMON, COMPOSITE_FRAG, PARTICLE_FRAG, PARTICLE_MAIN, PARTICLE_TYPES, PARTICLE_UNIFORMS, QUAD_VERT, TRAIL_FRAG, glslFloat };
427
+ export { BLOOM_DOWN_FRAG, BLOOM_PREFILTER_FRAG, BLOOM_UP_FRAG, COMMON, COMPOSITE_FRAG, PARTICLE_FRAG, PARTICLE_MAIN, PARTICLE_TYPES, PARTICLE_UNIFORMS, QUAD_VERT, TRAIL_FRAG, glslArray, glslFloat, glslVec };
package/dist/gl/math.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  //#region src/gl/math.d.ts
2
2
  export type Vec2 = [number, number];
3
3
  export type Vec3 = [number, number, number];
4
+ export type Vec4 = [number, number, number, number];
4
5
  export type Mat4 = Float32Array;
5
6
  export declare const clamp: (value: number, min: number, max: number) => number;
6
7
  export declare const lerp: (a: number, b: number, t: number) => number;
@@ -0,0 +1,53 @@
1
+ import { Vec2, Vec4 } from "./math.js";
2
+ //#region src/gl/shapes.d.ts
3
+ /**
4
+ * Line art drawn in particles, in a formation's own 2D art units. Outlines
5
+ * (`seg`, `rrect`, `circle`) spread their particles along the line, fills
6
+ * (`disc`, `fill`: a filled rounded rectangle) over the area. `bright` scales
7
+ * the shape's light.
8
+ */
9
+ export type Shape = {
10
+ kind: "seg";
11
+ a: Vec2;
12
+ b: Vec2;
13
+ bright: number;
14
+ } | {
15
+ kind: "rrect";
16
+ c: Vec2;
17
+ h: Vec2;
18
+ r: number;
19
+ bright: number;
20
+ } | {
21
+ kind: "circle";
22
+ c: Vec2;
23
+ r: number;
24
+ bright: number;
25
+ } | {
26
+ kind: "disc";
27
+ c: Vec2;
28
+ r: number;
29
+ bright: number;
30
+ } | {
31
+ kind: "fill";
32
+ c: Vec2;
33
+ h: Vec2;
34
+ r: number;
35
+ bright: number;
36
+ };
37
+ export interface PackedShapes {
38
+ /** Geometry: `seg` a.xy, b.xy; `rrect` and `fill` centre, half size; `circle` and `disc` centre, radius. */
39
+ a: Vec4[];
40
+ /** Kind, corner radius, tag, brightness. */
41
+ b: Vec4[];
42
+ /** Cumulative share of the particles, by line length (or area, for fills). The last one is past 1. */
43
+ cdf: number[];
44
+ /** Divide by it to keep the lines' brightness independent of how much art there is. */
45
+ totalWeight: number;
46
+ }
47
+ /**
48
+ * Packs line art into rows for `shapePoint(A, B, b, c)` in the shader.
49
+ * Particles pick a shape by the CDF, so every line gets the same particle
50
+ * density. `tag` fills the free slot, `B.z`, like the plate a shape is on.
51
+ */
52
+ export declare function packShapes<S extends Shape>(shapes: readonly S[], tag?: (shape: S) => number): PackedShapes;
53
+ //#endregion
@@ -0,0 +1,72 @@
1
+ //#region src/gl/shapes.ts
2
+ /** Shape kinds as `shapePoint` reads them, in `B.x`. */
3
+ const KIND = {
4
+ seg: 0,
5
+ rrect: 1,
6
+ circle: 2,
7
+ disc: 3,
8
+ fill: 4
9
+ };
10
+ const shapeWeight = (shape) => {
11
+ if (shape.kind === "seg") return Math.hypot(shape.b[0] - shape.a[0], shape.b[1] - shape.a[1]);
12
+ if (shape.kind === "rrect") {
13
+ const r = Math.min(shape.r, shape.h[0], shape.h[1]);
14
+ return 4 * (shape.h[0] + shape.h[1]) - 8 * r + 2 * Math.PI * r;
15
+ }
16
+ if (shape.kind === "circle") return 2 * Math.PI * shape.r;
17
+ if (shape.kind === "disc") return Math.PI * shape.r * shape.r * 24;
18
+ return 4 * shape.h[0] * shape.h[1] * 24;
19
+ };
20
+ /**
21
+ * Packs line art into rows for `shapePoint(A, B, b, c)` in the shader.
22
+ * Particles pick a shape by the CDF, so every line gets the same particle
23
+ * density. `tag` fills the free slot, `B.z`, like the plate a shape is on.
24
+ */
25
+ function packShapes(shapes, tag = () => 0) {
26
+ if (shapes.length === 0) throw new Error("Line art needs at least one shape.");
27
+ const weights = shapes.map(shapeWeight);
28
+ const totalWeight = weights.reduce((sum, w) => sum + w, 0);
29
+ let running = 0;
30
+ const cdf = weights.map((w) => (running += w) / totalWeight);
31
+ cdf[cdf.length - 1] = 1.0001;
32
+ return {
33
+ a: shapes.map((shape) => {
34
+ if (shape.kind === "seg") return [...shape.a, ...shape.b];
35
+ if (shape.kind === "rrect" || shape.kind === "fill") return [...shape.c, ...shape.h];
36
+ return [
37
+ ...shape.c,
38
+ shape.r,
39
+ 0
40
+ ];
41
+ }),
42
+ b: shapes.map((shape) => [
43
+ KIND[shape.kind],
44
+ shape.kind === "rrect" || shape.kind === "fill" ? shape.r : 0,
45
+ tag(shape),
46
+ shape.bright
47
+ ]),
48
+ cdf,
49
+ totalWeight
50
+ };
51
+ }
52
+ /** The shader side of `packShapes`, in the helpers every formation gets. */
53
+ const SHAPE_POINT = `
54
+ // A point on a shape packed by packShapes() (rows A and B), from two uniform
55
+ // randoms: outlines take b along the line, fills spread b and c over the area.
56
+ vec2 shapePoint(vec4 A, vec4 B, float b, float c) {
57
+ int kind = int(B.x + 0.5);
58
+ if (kind == 0) return mix(A.xy, A.zw, b);
59
+ if (kind == 1) return rrectPoint(A, B.y, b);
60
+ if (kind == 2) return A.xy + A.z * vec2(cos(b * TAU), sin(b * TAU));
61
+ if (kind == 3) return A.xy + A.z * sqrt(c) * vec2(cos(b * TAU), sin(b * TAU));
62
+ // Even over the rectangle, with the corners pulled in onto their arcs.
63
+ vec2 p = (vec2(b, c) * 2.0 - 1.0) * A.zw;
64
+ vec2 inner = A.zw - B.y;
65
+ vec2 d = max(abs(p) - inner, 0.0);
66
+ float len = length(d);
67
+ if (len > B.y) p = sign(p) * (inner + d * (B.y / len));
68
+ return A.xy + p;
69
+ }
70
+ `;
71
+ //#endregion
72
+ export { SHAPE_POINT, packShapes };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { Mat4, Vec2, Vec3, clamp, damp, lerp, lerp3, projectToScreen, smoothstep } from "./gl/math.js";
1
+ import { Mat4, Vec2, Vec3, Vec4, clamp, damp, lerp, lerp3, projectToScreen, smoothstep } from "./gl/math.js";
2
2
  import { AnchorDef, Formation, FormationDef, FormationFrame, FormationLook, FormationOptions, FormationProgress, FormationShader, FormationViews, StageView, Uniforms } from "./gl/types.js";
3
+ import { PackedShapes, Shape, packShapes } from "./gl/shapes.js";
3
4
  import { Experience, ExperienceOptions, ExperienceState, GlStatus, createExperience, initialExperienceState } from "./experience.js";
4
5
  import { ShaderPart, composeParticleShader, namespaceGlsl } from "./gl/compose.js";
5
6
  import { BASE_PARTICLES, FLOOR_Y } from "./gl/constants.js";
6
7
  import { defineFormation, mergeViews } from "./gl/formation.js";
7
- import { glslFloat } from "./gl/glsl.js";
8
+ import { glslArray, glslFloat, glslVec } from "./gl/glsl.js";
8
9
  import { SectionSpan, approachOf, localOf, presenceOf, progressOf, stageAt } from "./gl/stage.js";
9
10
  import { STACKED_QUERY } from "./layout.js";
10
- export { type AnchorDef, BASE_PARTICLES, type Experience, type ExperienceOptions, type ExperienceState, FLOOR_Y, type Formation, type FormationDef, type FormationFrame, type FormationLook, type FormationOptions, type FormationProgress, type FormationShader, type FormationViews, type GlStatus, type Mat4, STACKED_QUERY, type SectionSpan, type ShaderPart, type StageView, type Uniforms, type Vec2, type Vec3, approachOf, clamp, composeParticleShader, createExperience, damp, defineFormation, glslFloat, initialExperienceState, lerp, lerp3, localOf, mergeViews, namespaceGlsl, presenceOf, progressOf, projectToScreen, smoothstep, stageAt };
11
+ export { type AnchorDef, BASE_PARTICLES, type Experience, type ExperienceOptions, type ExperienceState, FLOOR_Y, type Formation, type FormationDef, type FormationFrame, type FormationLook, type FormationOptions, type FormationProgress, type FormationShader, type FormationViews, type GlStatus, type Mat4, type PackedShapes, STACKED_QUERY, type SectionSpan, type ShaderPart, type Shape, type StageView, type Uniforms, type Vec2, type Vec3, type Vec4, approachOf, clamp, composeParticleShader, createExperience, damp, defineFormation, glslArray, glslFloat, glslVec, initialExperienceState, lerp, lerp3, localOf, mergeViews, namespaceGlsl, packShapes, presenceOf, progressOf, projectToScreen, smoothstep, stageAt };
package/dist/index.js CHANGED
@@ -2,8 +2,9 @@ import { clamp, damp, lerp, lerp3, projectToScreen, smoothstep } from "./gl/math
2
2
  import { approachOf, localOf, presenceOf, progressOf, stageAt } from "./gl/stage.js";
3
3
  import { createExperience, initialExperienceState } from "./experience.js";
4
4
  import { BASE_PARTICLES, FLOOR_Y } from "./gl/constants.js";
5
- import { glslFloat } from "./gl/glsl.js";
5
+ import { packShapes } from "./gl/shapes.js";
6
+ import { glslArray, glslFloat, glslVec } from "./gl/glsl.js";
6
7
  import { composeParticleShader, namespaceGlsl } from "./gl/compose.js";
7
8
  import { defineFormation, mergeViews } from "./gl/formation.js";
8
9
  import { STACKED_QUERY } from "./layout.js";
9
- export { BASE_PARTICLES, FLOOR_Y, STACKED_QUERY, approachOf, clamp, composeParticleShader, createExperience, damp, defineFormation, glslFloat, initialExperienceState, lerp, lerp3, localOf, mergeViews, namespaceGlsl, presenceOf, progressOf, projectToScreen, smoothstep, stageAt };
10
+ export { BASE_PARTICLES, FLOOR_Y, STACKED_QUERY, approachOf, clamp, composeParticleShader, createExperience, damp, defineFormation, glslArray, glslFloat, glslVec, initialExperienceState, lerp, lerp3, localOf, mergeViews, namespaceGlsl, packShapes, presenceOf, progressOf, projectToScreen, smoothstep, stageAt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxfront/scene",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "The scroll-driven WebGL particle scene behind the uxfront.com family of homepages: a pluggable formation pipeline, a formation catalog and a framework-agnostic scroll controller.",
5
5
  "keywords": [
6
6
  "particles",
@@ -35,9 +35,6 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "dependencies": {
39
- "lenis": "^1.3.26"
40
- },
41
38
  "devDependencies": {
42
39
  "@uxfront/typescript-config": "0.1.0",
43
40
  "tsdown": "^0.23.0",