@fusion.dev/helix 0.173.0 → 0.175.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.
@@ -7,6 +7,8 @@ uniform float uScroll;
7
7
  uniform vec2 uT;
8
8
  uniform float uTime;
9
9
  uniform float uSpread;
10
+ uniform float uDepth;
11
+ uniform float uDrift;
10
12
 
11
13
  float h1(float n) { return fract(sin(n * 127.1 + 311.7) * 43758.5453); }
12
14
 
@@ -39,17 +41,25 @@ vec3 strandAt(float id, float t, out vec3 info) {
39
41
  float r2 = h1(id + 1.71);
40
42
  float r3 = h1(id + 3.37);
41
43
  float r4 = h1(id + 5.93);
44
+ float r8 = h1(id + 13.7);
45
+ float r9 = h1(id + 17.3);
42
46
  float n = (r1 + r2 + r3) / 1.5 - 1.0;
43
47
  float z = (r4 - 0.5) * 2.0;
44
48
  float along = c.y + c.x * uView.x;
45
- float th = along * 0.0033 + uTime * 0.25 + r2 * 0.5;
49
+ float pace = 1.0 + uDrift * (r8 - 0.5) * 1.2;
50
+ float th = along * 0.002 * (1.0 + uDrift * (r9 - 0.5) * 0.3) + uTime * 0.25 * pace
51
+ + r2 * (0.5 + uDrift * 2.6);
46
52
  float width = c.z * uSpread;
47
- float fan = width * uView.x * (1.0 + 0.25 * sin(uTime * 0.4 + along * 0.0045));
53
+ float breadth = width * uView.x * (1.0 + 0.25 * sin(uTime * 0.4 + along * 0.0045));
48
54
  float sway = sin(along * 0.006 + uTime * 0.23) * mix(6.0, 30.0, smoothstep(0.02, 0.2, width));
49
- float lat = sway + fan * (n * cos(th) + z * 0.55 * sin(th));
50
- lat += sin(along * 0.01 + uTime * (0.6 + 0.5 * r1) + r1 * 6.283) * 12.0 * (0.3 + r3);
55
+ float ct = cos(th);
56
+ float st = sin(th);
57
+ float depth = clamp((z * 0.55 * ct - n * st) / 1.15, -1.0, 1.0);
58
+ float lat = sway + breadth * (n * ct + z * 0.55 * st) * (1.0 + uDepth * 0.35 * depth);
59
+ lat += sin(along * 0.006 * (1.0 + uDrift * (r9 - 0.5) * 0.3) + uTime * (0.6 + 0.5 * r1) * pace
60
+ + r1 * 6.283) * 12.0 * (0.3 + r3) * (1.0 + uDrift * 0.5);
51
61
  info = vec3(max(c.w, 0.0), width, along);
52
- return vec3(p + nr * lat, z * sin(th));
62
+ return vec3(p + nr * lat, depth);
53
63
  }
54
64
  `;
55
65
  export const LINE_VERTEX = `#version 300 es
@@ -57,6 +67,7 @@ layout(location = 0) in vec2 aVert;
57
67
  layout(location = 1) in float aId;
58
68
  uniform float uDpr;
59
69
  uniform float uSoftness;
70
+ uniform float uContrast;
60
71
  uniform vec3 uGlow;
61
72
  uniform vec3 uTint;
62
73
  uniform vec3 uPeak;
@@ -77,8 +88,11 @@ void main() {
77
88
  tg = length(tg) > 1e-4 ? normalize(tg) : vec2(0.0, 1.0);
78
89
  vec2 nrm = vec2(-tg.y, tg.x);
79
90
  float soft = smoothstep(0.06, 0.28, info.y) * step(1.0 - uSoftness, r6);
80
- float base = mix(0.35, 1.3, r7 * r7) * uDpr * (1.0 + 0.3 * a.z);
81
- float w = max(base + soft * mix(8.0, 36.0, r6) * uDpr, 1.0);
91
+ /* Nearer is thicker, and the back of the ribbon falls out of focus: wider
92
+ at the same energy, so it reads as haze behind the sharp strands. */
93
+ float base = mix(0.35, 1.3, r7 * r7) * uDpr * (1.0 + (0.3 + 0.5 * uDepth) * a.z);
94
+ float focus = uDepth * smoothstep(-0.1, -0.9, a.z) * 10.0 * uDpr;
95
+ float w = max(base + soft * mix(8.0, 36.0, r6) * uDpr + focus, 1.0);
82
96
  float drawW = w + 2.5 * uDpr;
83
97
  vec2 res = uView * uDpr;
84
98
  vec2 px = a.xy * uDpr + nrm * aVert.y * drawW * 0.5;
@@ -86,12 +100,18 @@ void main() {
86
100
  vSide = aVert.y * drawW / w;
87
101
  float shimmer = 0.5 + 0.5 * sin(info.z * 0.044 - uTime * (2.0 + 2.0 * r5) + r6 * 6.283);
88
102
  shimmer *= shimmer;
89
- float bright = mix(0.25, 1.0, pow(r5, 1.4));
103
+ /* Contrast spreads the strands' brightness: a few burn and most fall back.
104
+ The mean is held, so the ribbon as a whole keeps its strength. */
105
+ float spread = mix(1.4, 4.5, uContrast);
106
+ float least = mix(0.25, 0.04, uContrast);
107
+ float bright = mix(least, 1.0, pow(r5, spread)) * 0.5625 / (least + (1.0 - least) / (spread + 1.0));
90
108
  float energy = min(base, w) / w;
91
- float depth = 0.7 + 0.3 * a.z;
109
+ float fall = 0.3 + 0.5 * uDepth;
110
+ float depth = (1.0 - fall * (1.0 - a.z) * 0.5) / (1.0 - fall * 0.5);
111
+ float rest = mix(0.35, 0.15, uContrast);
92
112
  vec3 col = mix(uGlow, uTint, step(0.83, r6) * 0.9);
93
113
  col = mix(col, uPeak, step(0.93, r7) * 0.6);
94
- vColor = col * energy * info.x * (0.35 + 0.65 * shimmer) * bright * depth;
114
+ vColor = col * energy * info.x * (rest + (1.0 - rest) * shimmer) * bright * depth;
95
115
  }
96
116
  `;
97
117
  export const LINE_FRAGMENT = `#version 300 es
@@ -125,7 +145,9 @@ void main() {
125
145
  gl_Position = vec4(px.x / res.x * 2.0 - 1.0, 1.0 - px.y / res.y * 2.0, 0.0, 1.0);
126
146
  gl_PointSize = mix(1.2, 3.4, r2 * r2) * uDpr;
127
147
  float tw = 0.35 + 0.65 * (0.5 + 0.5 * sin(uTime * (0.5 + 1.8 * r) + r2 * 40.0));
128
- vColor = mix(uGlow, uPeak, 0.55) * tw * mix(0.2, 0.9, r) * info.x * 0.8;
148
+ /* By the root of the ribbon's brightness, so specks show along a dim ribbon
149
+ as well as round a bright bend. */
150
+ vColor = mix(uGlow, uPeak, 0.55) * tw * mix(0.2, 0.9, r) * sqrt(info.x) * 0.8;
129
151
  }
130
152
  `;
131
153
  export const DUST_FRAGMENT = `#version 300 es
@@ -183,10 +205,11 @@ uniform vec3 uGround;
183
205
  uniform vec3 uInk;
184
206
  uniform float uLight;
185
207
  uniform float uGain;
208
+ uniform float uBloom;
186
209
  out vec4 outColor;
187
210
  float hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }
188
211
  void main() {
189
- vec3 e = texture(uScene, vUv).rgb + texture(uNear, vUv).rgb * 1.1 + texture(uFar, vUv).rgb * 0.9;
212
+ vec3 e = texture(uScene, vUv).rgb + (texture(uNear, vUv).rgb * 1.1 + texture(uFar, vUv).rgb * 0.9) * uBloom;
190
213
  e *= uGain;
191
214
  vec3 dark = 1.0 - (1.0 - uGround) * exp(-e);
192
215
  float lum = dot(e, vec3(0.3, 0.55, 0.15));
@@ -7,8 +7,8 @@ import type { StrandsVariant } from '../path.js';
7
7
  *
8
8
  * @description
9
9
  * Placed inside a `helix-strands` with `travel`, a stop names an element with
10
- * `for` and says which form the ribbon takes when the page reaches it: a `fan`
11
- * bending through it, a `ribbon` passing through `at`, or `waves` crossing at
10
+ * `for` and says which form the ribbon takes when the page reaches it: a `bend`
11
+ * turning through it, a `ribbon` passing through `at`, or `waves` crossing at
12
12
  * its top edge. The stops are read in page order, whatever order they are
13
13
  * written in, and a stop naming no element is skipped.
14
14
  *
@@ -26,9 +26,9 @@ import type { StrandsVariant } from '../path.js';
26
26
  export declare class HelixStrandsStop extends HelixElement {
27
27
  static styles: CSSResultGroup;
28
28
  /**
29
- * Where the form sits across the page, as a share of the width: the fan's
30
- * bend or the ribbon's axis. A wave crosses the whole width and does not
31
- * read it. Unset, a fan bends at `0.4` and a ribbon runs down the middle.
29
+ * Where the form sits across the page, as a share of the width: the bend's
30
+ * apex or the ribbon's axis. A wave crosses the whole width and does not
31
+ * read it. Unset, a bend's apex sits at `0.5` and a ribbon runs down the middle.
32
32
  */
33
33
  at?: number;
34
34
  /** The id of the element the form is pinned to, in the same tree as the stop. */