@uxfront/scene 0.1.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.
Files changed (51) hide show
  1. package/README.md +128 -0
  2. package/dist/experience.d.ts +40 -0
  3. package/dist/experience.js +306 -0
  4. package/dist/formations/corridor/index.d.ts +8 -0
  5. package/dist/formations/corridor/index.js +52 -0
  6. package/dist/formations/corridor/shader.js +37 -0
  7. package/dist/formations/index.d.ts +11 -0
  8. package/dist/formations/index.js +11 -0
  9. package/dist/formations/ink/index.d.ts +10 -0
  10. package/dist/formations/ink/index.js +53 -0
  11. package/dist/formations/ink/shader.js +177 -0
  12. package/dist/formations/monolith/index.d.ts +5 -0
  13. package/dist/formations/monolith/index.js +49 -0
  14. package/dist/formations/monolith/mark.js +89 -0
  15. package/dist/formations/monolith/shader.js +120 -0
  16. package/dist/formations/plates/art.d.ts +46 -0
  17. package/dist/formations/plates/art.js +238 -0
  18. package/dist/formations/plates/geometry.d.ts +5 -0
  19. package/dist/formations/plates/geometry.js +8 -0
  20. package/dist/formations/plates/index.d.ts +13 -0
  21. package/dist/formations/plates/index.js +67 -0
  22. package/dist/formations/plates/shader.js +97 -0
  23. package/dist/formations/prism/geometry.d.ts +4 -0
  24. package/dist/formations/prism/geometry.js +15 -0
  25. package/dist/formations/prism/index.d.ts +9 -0
  26. package/dist/formations/prism/index.js +64 -0
  27. package/dist/formations/prism/shader.js +140 -0
  28. package/dist/formations/tokens/geometry.d.ts +4 -0
  29. package/dist/formations/tokens/geometry.js +22 -0
  30. package/dist/formations/tokens/index.d.ts +18 -0
  31. package/dist/formations/tokens/index.js +79 -0
  32. package/dist/formations/tokens/shader.js +125 -0
  33. package/dist/gl/compose.d.ts +14 -0
  34. package/dist/gl/compose.js +52 -0
  35. package/dist/gl/constants.d.ts +6 -0
  36. package/dist/gl/constants.js +7 -0
  37. package/dist/gl/engine.js +559 -0
  38. package/dist/gl/formation.d.ts +7 -0
  39. package/dist/gl/formation.js +39 -0
  40. package/dist/gl/glsl.d.ts +9 -0
  41. package/dist/gl/glsl.js +419 -0
  42. package/dist/gl/math.d.ts +16 -0
  43. package/dist/gl/math.js +102 -0
  44. package/dist/gl/stage.d.ts +28 -0
  45. package/dist/gl/stage.js +55 -0
  46. package/dist/gl/types.d.ts +103 -0
  47. package/dist/index.d.ts +10 -0
  48. package/dist/index.js +9 -0
  49. package/dist/layout.d.ts +9 -0
  50. package/dist/layout.js +10 -0
  51. package/package.json +51 -0
@@ -0,0 +1,177 @@
1
+ import { damp } from "../../gl/math.js";
2
+ //#region src/formations/ink/shader.ts
3
+ const POUR_HEAD_START = 1;
4
+ const POURED_SECONDS = 60;
5
+ const SCROLL = 9;
6
+ const RUSH = 4;
7
+ const EASE = 2.5;
8
+ const glsl = `
9
+ const float $TOP = 3.2;
10
+ const int $INKS = 5;
11
+
12
+ uniform float $clock;
13
+ uniform float $pour;
14
+
15
+ // Where each ink enters (x, z), how thick the pour is, and how many seconds
16
+ // it takes to sink through the frame.
17
+ const vec4 $SOURCE[$INKS] = vec4[$INKS](
18
+ vec4(-0.8, 0.5, 0.1, 16.0),
19
+ vec4(0.4, -1.2, 0.12, 18.0),
20
+ vec4(1.3, 0.9, 0.09, 15.0),
21
+ vec4(2.1, -0.4, 0.12, 17.0),
22
+ vec4(3.1, 0.2, 0.1, 16.5)
23
+ );
24
+
25
+ // The direction each pour leans as it enters.
26
+ const vec2 $LEAN[$INKS] = vec2[$INKS](
27
+ vec2(0.35, -0.1),
28
+ vec2(-0.2, 0.25),
29
+ vec2(0.25, -0.3),
30
+ vec2(-0.35, 0.15),
31
+ vec2(-0.2, -0.2)
32
+ );
33
+
34
+ // Each pour's ink, and a second ink that marbles through it.
35
+ const vec3 $INK[$INKS] = vec3[$INKS](
36
+ vec3(0.12, 0.62, 1.0),
37
+ vec3(1.0, 0.16, 0.52),
38
+ vec3(0.3, 0.26, 1.0),
39
+ vec3(1.0, 0.46, 0.14),
40
+ vec3(0.62, 0.22, 1.0)
41
+ );
42
+ const vec3 $MIX[$INKS] = vec3[$INKS](
43
+ vec3(0.3, 0.26, 1.0),
44
+ vec3(0.62, 0.22, 1.0),
45
+ vec3(0.1, 0.85, 0.9),
46
+ vec3(1.0, 0.16, 0.52),
47
+ vec3(1.0, 0.16, 0.52)
48
+ );
49
+
50
+ // Ink enters fast and settles into a slow sink:
51
+ // d(depth)/dt = SINK + JET * e^(-JET_FALL * depth).
52
+ const float $SINK = 0.22;
53
+ const float $JET = 0.9;
54
+ const float $JET_FALL = 0.9;
55
+
56
+ // Seconds to sink to a depth, and the depth reached after some seconds.
57
+ float $timeAt(float depth) {
58
+ return (depth + log(($SINK + $JET * exp(-$JET_FALL * depth)) / ($SINK + $JET)) / $JET_FALL) / $SINK;
59
+ }
60
+ float $depthAt(float t) {
61
+ return log((($SINK + $JET) * exp($SINK * $JET_FALL * t) - $JET) / $SINK) / $JET_FALL;
62
+ }
63
+
64
+ // The water: one current shared by every ink. Its eddies sink with the ink,
65
+ // so they are carried down instead of standing still.
66
+ vec3 $velocity(vec3 p, vec2 src, vec2 lean, float t) {
67
+ float depth = max($TOP - p.y, 0.0);
68
+ float jet = exp(-depth * $JET_FALL);
69
+ float stir = smoothstep(0.2, 2.2, depth);
70
+ vec3 q = vec3(p.x, p.y + t * 0.2, p.z) * 0.38 + vec3(0.0, 0.0, t * 0.02);
71
+ vec3 v = bitangent(q) * (0.05 + 0.42 * stir);
72
+ v.y -= $SINK + $JET * jet;
73
+ // Water does not compress: as the pour slows it has to widen, or ink piles
74
+ // up wherever it stalls.
75
+ v.xz += lean * jet + (p.xz - src) * (0.5 * $JET * $JET_FALL * jet + 0.06 * stir);
76
+ return v;
77
+ }
78
+
79
+ Particle $main(uint id, float sel, Frame f) {
80
+ float time = f.time;
81
+ uint s = seedOf(id, 0x1B56C4E9u);
82
+ float a = rnd(s);
83
+ float b = rnd(s);
84
+ float c = rnd(s);
85
+ float d = rnd(s);
86
+ float e = rnd(s);
87
+ Particle P = blank();
88
+
89
+ if (sel < 0.96) {
90
+ // Every particle traces the path a drop of ink took from the source since
91
+ // it was poured. Neighbours on the pour ring follow neighbouring paths, so
92
+ // the ink folds into thin sheets instead of scattering like smoke.
93
+ int k = int(id % uint($INKS));
94
+ float fk = float(k);
95
+ vec4 src = $SOURCE[k];
96
+ // The ink keeps its own clock, which races ahead while the page scrolls.
97
+ float now = $clock;
98
+ float life = src.w;
99
+ float age = fract(a + now / life);
100
+ float born = now - age * life;
101
+ // The water starts clear: only ink poured since the formation scrolled in
102
+ // shows, and the first of it arrives as one fat billow.
103
+ float lead = $pour - age * life;
104
+ float first = 1.0 - smoothstep(0.0, 3.0, lead);
105
+ // It pours in gulps: fat billows linked by thin threads.
106
+ float gulp = max(pow(0.5 + 0.5 * sin(born * (0.8 + 0.11 * fk) + fk * 2.1), 3.0), first);
107
+ float th = b * TAU;
108
+ float r = src.z * mix(0.25, 1.6, gulp) * (1.0 + first) * (c < 0.7 ? 1.0 : sqrt(d));
109
+ vec3 p = vec3(src.x + cos(th) * r, $TOP, src.y + sin(th) * r);
110
+ // Steps of equal depth: short while the pour is fast, long once it slows.
111
+ float reach = $depthAt(age * life);
112
+ float prev = 0.0;
113
+ for (int i = 1; i <= 6; i++) {
114
+ float next = $timeAt(reach * float(i) / 6.0);
115
+ float h = next - prev;
116
+ p += $velocity(p, src.xy, $LEAN[k], born + prev + h * 0.5) * h;
117
+ prev = next;
118
+ }
119
+ // Finer curls, sinking with the ink.
120
+ float depth = $TOP - p.y;
121
+ p += bitangent(vec3(p.x, p.y + now * 0.2, p.z) * 0.95 + 5.3) * 0.15 * smoothstep(0.3, 2.5, depth);
122
+
123
+ // As it ages, some of the ink bleeds from the sheets into the water.
124
+ float bleed = e * e * e * e;
125
+ vec2 g = gauss(rnd(s), rnd(s));
126
+ p += vec3(g.x, g.y * 0.7, rnd(s) * 2.0 - 1.0) * bleed * (0.02 + 0.35 * age);
127
+
128
+ // The second ink comes in bands, one gulp to the next, and down one side.
129
+ float m = clamp(0.5 + 0.7 * sin(born * 0.45 + fk * 1.3) + 0.4 * sin(th + fk), 0.0, 1.0);
130
+ vec3 ink = mix($INK[k], $MIX[k], m);
131
+ float fade = smoothstep(0.0, 0.04, age) * (1.0 - smoothstep(0.7, 1.0, age)) * smoothstep(0.0, 0.5, lead);
132
+ P.pos = p;
133
+ P.col = ink * mix(0.062, 0.02, bleed) * mix(0.45, 1.0, gulp) * fade;
134
+ P.size = mix(1.7, 2.3, age) + bleed * age * 2.5;
135
+ } else {
136
+ // Specks suspended in the water.
137
+ vec3 p = vec3(mix(-6.0, 6.0, a), mix(-2.8, 2.4, b), mix(-2.5, 2.5, c));
138
+ p.y = mod(p.y - time * 0.02 + 2.8, 5.2) - 2.8;
139
+ P.pos = p;
140
+ P.col = vec3(0.55, 0.6, 1.0) * 0.05;
141
+ P.size = 0.85;
142
+ }
143
+ return P;
144
+ }
145
+ `;
146
+ /**
147
+ * The ink keeps its own clock. Scrolling while it is on screen owes the ink
148
+ * some flow, paid back through a speed that eases up and down: it cannot be
149
+ * scrolled past before it pours, yet never lurches with the wheel. Without
150
+ * motion the ink stands still, and only sinks while the page scrolls.
151
+ */
152
+ function createShader() {
153
+ let clock = 0;
154
+ let owed = 0;
155
+ let rush = 0;
156
+ let pour = POUR_HEAD_START;
157
+ return {
158
+ glsl,
159
+ update({ gl, get }, { presence, motion, scrolled, dt }) {
160
+ const shown = presence > 0;
161
+ if (!shown || !motion) owed = 0;
162
+ else owed += scrolled * SCROLL;
163
+ rush = damp(rush, Math.min(owed * EASE * .25, RUSH), EASE, dt);
164
+ const rushed = Math.min(owed, rush * dt);
165
+ owed -= rushed;
166
+ if (motion) clock += dt + rushed;
167
+ else if (shown) clock += scrolled * SCROLL;
168
+ if (!shown) pour = POUR_HEAD_START;
169
+ else if (!motion) pour = POURED_SECONDS;
170
+ else pour += dt + rushed;
171
+ gl.uniform1f(get("clock"), clock);
172
+ gl.uniform1f(get("pour"), pour);
173
+ }
174
+ };
175
+ }
176
+ //#endregion
177
+ export { createShader };
@@ -0,0 +1,5 @@
1
+ import { Formation, FormationOptions } from "../../gl/types.js";
2
+ //#region src/formations/monolith/index.d.ts
3
+ /** A 1:4:9 slab of light over a mirror floor, the UXFront mark inlaid in its face. Suits a hero. */
4
+ export declare function monolith(options: FormationOptions): Formation;
5
+ //#endregion
@@ -0,0 +1,49 @@
1
+ import { defineFormation, mergeViews } from "../../gl/formation.js";
2
+ //#region src/formations/monolith/index.ts
3
+ /** A 1:4:9 slab of light over a mirror floor, the UXFront mark inlaid in its face. Suits a hero. */
4
+ function monolith(options) {
5
+ return defineFormation({
6
+ key: options.key ?? "monolith",
7
+ label: options.label,
8
+ views: mergeViews({
9
+ desktop: {
10
+ eye: [
11
+ 2.6,
12
+ .55,
13
+ 10.5
14
+ ],
15
+ target: [
16
+ 0,
17
+ -.2,
18
+ 0
19
+ ],
20
+ fov: 30,
21
+ span: [1.2, 2.2],
22
+ shift: [.4, .04]
23
+ },
24
+ mobile: {
25
+ eye: [
26
+ 1.8,
27
+ .55,
28
+ 10.6
29
+ ],
30
+ target: [
31
+ 0,
32
+ -.1,
33
+ 0
34
+ ],
35
+ fov: 34,
36
+ span: [1.1, 2.1],
37
+ shift: [0, .5]
38
+ }
39
+ }, options.views),
40
+ look: {
41
+ bloom: 1,
42
+ reflect: 1,
43
+ ...options.look
44
+ },
45
+ shader: () => import("./shader.js").then((m) => m.shader)
46
+ });
47
+ }
48
+ //#endregion
49
+ export { monolith };
@@ -0,0 +1,89 @@
1
+ //#region src/formations/monolith/mark.ts
2
+ /**
3
+ * The UXFront mark (UxFrontMark.vue) in GLSL, for the monolith to carry.
4
+ * Four copies of one U, each a quarter turn from the last. Units are the
5
+ * SVG's, with y up: the top U's arms run from y = 38 down to 16, bend with
6
+ * radius 14 and meet along a base at y = 2. Keep in step with the SVG path.
7
+ */
8
+ const markGlsl = `
9
+ const float $M_HALF = 4.0;
10
+ // Centreline length of one U: two arms, a base and two quarter bends.
11
+ const float $M_U = 58.0 + 14.0 * PI;
12
+
13
+ vec2 $turn(vec2 p, int k) {
14
+ if (k == 1) return vec2(-p.y, p.x);
15
+ if (k == 2) return -p;
16
+ if (k == 3) return vec2(p.y, -p.x);
17
+ return p;
18
+ }
19
+
20
+ // The top U's centreline offset by s (outwards), at arc length d along it,
21
+ // starting from the left arm's tip. The offset curve is 58 + (14 + s)π long.
22
+ vec2 $uAt(float d, float s) {
23
+ float r = 14.0 + s;
24
+ float bend = 0.5 * PI * r;
25
+ if (d < 22.0) return vec2(-21.0 - s, 38.0 - d);
26
+ d -= 22.0;
27
+ if (d < bend) return vec2(-7.0, 16.0) - r * vec2(cos(d / r), sin(d / r));
28
+ d -= bend;
29
+ if (d < 14.0) return vec2(-7.0 + d, 2.0 - s);
30
+ d -= 14.0;
31
+ if (d < bend) return vec2(7.0, 16.0) + r * vec2(sin(d / r), -cos(d / r));
32
+ return vec2(21.0 + s, 16.0 + d - bend);
33
+ }
34
+
35
+ // Distance to the top U's centreline.
36
+ float $uDist(vec2 p) {
37
+ p.x = abs(p.x);
38
+ float d = min(
39
+ length(p - vec2(min(p.x, 7.0), 2.0)),
40
+ length(p - vec2(21.0, clamp(p.y, 16.0, 38.0)))
41
+ );
42
+ vec2 q = p - vec2(7.0, 16.0);
43
+ if (q.x > 0.0 && q.y < 0.0) d = min(d, abs(length(q) - 14.0));
44
+ return d;
45
+ }
46
+
47
+ // Distance to U number k (the top U turned k quarter turns).
48
+ float $uDistTo(vec2 p, int k) {
49
+ return $uDist($turn(p, (4 - k) & 3));
50
+ }
51
+
52
+ // Distance to the nearest centreline: the stroke is where it's under $M_HALF.
53
+ float $markDist(vec2 p) {
54
+ return min(min($uDist(p), $uDist($turn(p, 1))), min($uDist($turn(p, 2)), $uDist($turn(p, 3))));
55
+ }
56
+
57
+ // A point spread evenly over the top U's stroke, round caps included.
58
+ vec2 $uFill(float pick, float across, float along) {
59
+ const float BAND = $M_U * 2.0 * $M_HALF;
60
+ const float CAPS = PI * $M_HALF * $M_HALF;
61
+ if (pick * (BAND + CAPS) < BAND) {
62
+ // Offset curves outside the bends are longer: pick the offset in proportion.
63
+ const float A = $M_U;
64
+ const float B = PI * $M_HALF;
65
+ float s = (sqrt((A - B) * (A - B) + 4.0 * A * B * across) - A) / PI;
66
+ return $uAt(along * (58.0 + (14.0 + s) * PI), s);
67
+ }
68
+ float side = across < 0.5 ? -1.0 : 1.0;
69
+ float t = fract(across * 2.0) * PI;
70
+ return vec2(side * 21.0, 38.0) + $M_HALF * sqrt(along) * vec2(cos(t), sin(t));
71
+ }
72
+
73
+ // A point spread evenly along the top U's outline, round caps included.
74
+ vec2 $uEdge(float u) {
75
+ const float INNER = 58.0 + (14.0 - $M_HALF) * PI;
76
+ const float OUTER = 58.0 + (14.0 + $M_HALF) * PI;
77
+ const float CAP = PI * $M_HALF;
78
+ float e = u * (INNER + OUTER + 2.0 * CAP);
79
+ if (e < INNER) return $uAt(e, -$M_HALF);
80
+ e -= INNER;
81
+ if (e < OUTER) return $uAt(e, $M_HALF);
82
+ e -= OUTER;
83
+ float side = e < CAP ? -1.0 : 1.0;
84
+ float t = mod(e, CAP) / $M_HALF;
85
+ return vec2(side * 21.0, 38.0) + $M_HALF * vec2(cos(t), sin(t));
86
+ }
87
+ `;
88
+ //#endregion
89
+ export { markGlsl };
@@ -0,0 +1,120 @@
1
+ import { markGlsl } from "./mark.js";
2
+ //#region src/formations/monolith/shader.ts
3
+ const shader = { glsl: `
4
+ const vec3 $SIZE = vec3(0.6, 1.35, 0.15);
5
+ // The mark on the front face: where its centre sits and how big a mark unit is.
6
+ const vec2 $MARK_AT = vec2(0.0, 0.35);
7
+ const float $MARK_SCALE = 0.008;
8
+ // The mark borrows its particles from the faces: brighten the rest to match.
9
+ const float $FACE_GAIN = 0.74 / 0.66;
10
+ ${markGlsl}
11
+
12
+ Particle $main(uint id, float sel, Frame frame) {
13
+ float time = frame.time;
14
+ uint s = seedOf(id, 0x1B873593u);
15
+ float a = rnd(s);
16
+ float b = rnd(s);
17
+ float c = rnd(s);
18
+ float d = rnd(s);
19
+ Particle P = blank();
20
+ P.refl = 1.0;
21
+ float scanY = mod(time * 0.28, 4.6) - 2.3;
22
+
23
+ if (sel < 0.13) {
24
+ // Edges, picked by length so every edge has the same density.
25
+ float e = a * 4.2;
26
+ float t = b * 2.0 - 1.0;
27
+ float s1 = c < 0.5 ? -1.0 : 1.0;
28
+ float s2 = d < 0.5 ? -1.0 : 1.0;
29
+ vec3 p;
30
+ if (e < 1.2) p = vec3(t * $SIZE.x, s1 * $SIZE.y, s2 * $SIZE.z);
31
+ else if (e < 3.9) p = vec3(s1 * $SIZE.x, t * $SIZE.y, s2 * $SIZE.z);
32
+ else p = vec3(s1 * $SIZE.x, s2 * $SIZE.y, t * $SIZE.z);
33
+ float scan = exp(-pow((p.y - scanY) * 4.0, 2.0));
34
+ P.pos = p;
35
+ P.col = vec3(0.86, 0.9, 1.0) * (0.55 + scan * 0.8);
36
+ P.size = 0.8;
37
+ } else if (sel < 0.21) {
38
+ // The mark, inlaid in the front face: a bright outline around a frosted stroke.
39
+ bool edge = sel < 0.17;
40
+ vec2 m = vec2(0.0);
41
+ bool shown = false;
42
+ // Spread over the Us' union: the outline skips what another U covers, and
43
+ // where strokes overlap only the first U keeps its fill.
44
+ for (int i = 0; i < 4 && !shown; i++) {
45
+ int k = min(int(rnd(s) * 4.0), 3);
46
+ m = $turn(edge ? $uEdge(rnd(s)) : $uFill(rnd(s), rnd(s), rnd(s)), k);
47
+ shown = true;
48
+ for (int j = 0; j < 4; j++) {
49
+ if (j == k || (!edge && j > k)) continue;
50
+ if ($uDistTo(m, j) < $M_HALF - (edge ? 0.3 : 0.0)) shown = false;
51
+ }
52
+ }
53
+ vec2 q = $MARK_AT + m * $MARK_SCALE;
54
+ float scan = exp(-pow((q.y - scanY) * 4.0, 2.0));
55
+ P.pos = vec3(q, $SIZE.z);
56
+ if (edge) {
57
+ P.col = vec3(0.86, 0.9, 1.0) * (0.45 + scan * 0.9);
58
+ P.size = 0.75;
59
+ } else {
60
+ P.col = vec3(0.7, 0.78, 1.0) * (0.06 + scan * 0.2);
61
+ P.size = 1.1;
62
+ }
63
+ if (!shown) P.col = vec3(0.0);
64
+ } else if (sel < 0.87) {
65
+ // Faces, picked by area: soft frosted glass crossed by fine strata.
66
+ float f = a * 8.82;
67
+ float u = b * 2.0 - 1.0;
68
+ float v = c * 2.0 - 1.0;
69
+ float sg = d < 0.5 ? -1.0 : 1.0;
70
+ bool strata = fract(d * 17.0) < 0.42;
71
+ vec3 p;
72
+ if (f < 6.48) p = vec3(u * $SIZE.x, v * $SIZE.y, sg * $SIZE.z);
73
+ else if (f < 8.1) p = vec3(sg * $SIZE.x, v * $SIZE.y, u * $SIZE.z);
74
+ else {
75
+ p = vec3(u * $SIZE.x, sg * $SIZE.y, v * $SIZE.z);
76
+ strata = false;
77
+ }
78
+ if (strata) p.y = clamp((floor(p.y / 0.075) + 0.5) * 0.075, -$SIZE.y, $SIZE.y);
79
+ // The strata break around the mark, as if it were cut into the stone.
80
+ float cut = 1.0;
81
+ if (strata && f < 6.48 && sg > 0.0) {
82
+ cut = smoothstep($M_HALF + 2.0, $M_HALF + 5.0, $markDist((p.xy - $MARK_AT) / $MARK_SCALE));
83
+ }
84
+ float rise = 0.5 + 0.5 * sin(p.y * 2.2 - time * 0.9);
85
+ float scan = exp(-pow((p.y - scanY) * 3.0, 2.0));
86
+ float base = (0.35 + 0.65 * smoothstep($SIZE.y, -$SIZE.y, p.y)) * $FACE_GAIN;
87
+ P.pos = p;
88
+ if (strata) {
89
+ P.col = vec3(0.74, 0.8, 1.0) * (0.05 + 0.05 * rise + scan * 0.4) * base * cut;
90
+ P.size = 0.7;
91
+ } else {
92
+ P.col = vec3(0.62, 0.7, 1.0) * (0.018 + scan * 0.05) * base;
93
+ P.size = 1.9;
94
+ }
95
+ } else if (sel < 0.895) {
96
+ // Motes lifting off the top, like heat.
97
+ float rise = fract(a + time * 0.03);
98
+ vec3 p = vec3((b * 2.0 - 1.0) * $SIZE.x, $SIZE.y + rise * 3.2, (c * 2.0 - 1.0) * $SIZE.z);
99
+ p.x += sin(rise * 5.0 + d * TAU + time * 0.3) * rise * 0.55;
100
+ p.z += cos(rise * 4.0 + d * TAU) * rise * 0.4;
101
+ P.pos = p;
102
+ P.col = vec3(0.8, 0.85, 1.0) * 0.32 * smoothstep(0.0, 0.1, rise) * pow(1.0 - rise, 2.0);
103
+ P.size = 0.7;
104
+ } else {
105
+ // The floor: a dot grid fading into the dark.
106
+ float ang = a * TAU;
107
+ float rad = 0.95 + sqrt(b) * 7.5;
108
+ vec2 q = vec2(cos(ang), sin(ang)) * rad;
109
+ q = (floor(q / 0.32) + 0.5) * 0.32;
110
+ P.pos = vec3(q.x, FLOOR_Y, q.y);
111
+ float fall = smoothstep(8.2, 0.9, length(q));
112
+ P.col = vec3(0.6, 0.66, 0.95) * 0.08 * fall * fall;
113
+ P.size = 0.75;
114
+ P.refl = 0.0;
115
+ }
116
+ return P;
117
+ }
118
+ ` };
119
+ //#endregion
120
+ export { shader };
@@ -0,0 +1,46 @@
1
+ import { Vec2 } from "../../gl/math.js";
2
+ //#region src/formations/plates/art.d.ts
3
+ /**
4
+ * Plate artwork, drawn by the shader from a uniform table. Coordinates are
5
+ * plate-local (`PLATE` half extents): u to the right, v away from the viewer.
6
+ * `plate` is 0 (top), 1 or 2 (bottom).
7
+ */
8
+ export type PlateShape = {
9
+ kind: "seg";
10
+ plate: number;
11
+ a: Vec2;
12
+ b: Vec2;
13
+ bright: number;
14
+ } | {
15
+ kind: "rrect";
16
+ plate: number;
17
+ c: Vec2;
18
+ h: Vec2;
19
+ r: number;
20
+ bright: number;
21
+ } | {
22
+ kind: "circle";
23
+ plate: number;
24
+ c: Vec2;
25
+ r: number;
26
+ bright: number;
27
+ } | {
28
+ kind: "disc";
29
+ plate: number;
30
+ c: Vec2;
31
+ r: number;
32
+ bright: number;
33
+ };
34
+ /** A line segment. */
35
+ export declare const seg: (plate: number, a: Vec2, b: Vec2, bright?: number) => PlateShape;
36
+ /** A rounded rectangle outline: centre, half size and corner radius. */
37
+ export declare const rrect: (plate: number, c: Vec2, h: Vec2, r: number, bright?: number) => PlateShape;
38
+ /** A circle outline. */
39
+ export declare const circle: (plate: number, c: Vec2, r: number, bright?: number) => PlateShape;
40
+ /** A filled disc. */
41
+ export declare const disc: (plate: number, c: Vec2, r: number, bright?: number) => PlateShape;
42
+ /** The plate's own border. */
43
+ export declare const plateBorder: (plate: number, bright: number) => PlateShape;
44
+ /** Open Components: an interface (UX), its API (DX) and its semantic tree (AX). */
45
+ export declare const OPEN_COMPONENTS_ART: PlateShape[];
46
+ //#endregion