Backgrounds13 / 118
Prism Bloom
A crystalline loop of light in the black: fine white filaments knotted around a dark hole and reaching out in three arms, studded with spiky star nodes whose long rays split into rainbows like light through a prism, with a real bloom on the white cores. Nodes near your cursor flare and fan their rays away from it, a click bursts a flare through every node it reaches, and scrolling turns the loop and draws you in.
WebGLWebGLPrismatic raysPrismatic raysReal bloomReal bloomClick burstClick burstGSAPGSAPReduced-motion safeReduced-motion safe
Flare the lightClick to burst
Tweak
LIVELIVELight
#f4f6ff
#000000
1.00
1.00
1.00
0.80
Shape
1.00
Motion
1.00
Interactive
Nodes flare near the cursor, clicks burst a flare
Usage
Follows your tweaks.
usage.tsx
import { PrismBloom } from "@/components/inreact/prism-bloom";
export function Hero() {
return (
<PrismBloom
className="h-screen w-full"
>
{/* optional: your hero content, drawn above the light */}
</PrismBloom>
);
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/prism-bloom.jsonOr copy the source
Install the dependencies, then save this as components/inreact/prism-bloom.tsx.
terminal
npm install gsapcomponents/inreact/prism-bloom.tsx
"use client";
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { useEffect, useRef, type ReactNode } from "react";
gsap.registerPlugin(ScrollTrigger);
/**
* Prism Bloom: a crystalline loop of light that splits into rainbows.
*
* In the black, a ring of fine white filaments knots around a dark hole and
* reaches out in three arms, studded with spiky star nodes. Every node throws
* long streaks of light outward, and each streak splits as it goes, red on one
* edge and violet on the other, like light through a prism. A real bloom pass
* lets the white cores burn.
*
* It reacts: the nodes near your cursor flare and their rays swing to fan away
* from it; a click sends a flare racing out from that point, every node it
* reaches bursting into longer, brighter rays; scrolling turns the whole loop
* and draws you into it. On load the filaments spin up and the rays grow out.
* When idle the rays shimmer and the loop slowly breathes.
*
* <PrismBloom className="h-screen w-full">
* <YourHero />
* </PrismBloom>
*
* WebGL: one shader (cell filaments, star nodes, dispersed rays), then bloom
* at 1/4 and 1/16 size. GSAP drives every motion. Pauses off-screen; reduced
* motion shows a still frame; a CSS gradient without WebGL.
*/
export interface PrismBloomProps {
/** Colour of the filaments and the node cores. */
core?: string;
/** Background colour. */
background?: string;
/** How strongly the rays split into colour (0 = white light). */
dispersion?: number;
/** Length of the rays. */
rays?: number;
/** Size of the loop. */
size?: number;
/** Brightness. */
intensity?: number;
/** Strength of the bloom. */
glow?: number;
/** Speed of the idle shimmer. */
speed?: number;
/** Cursor flare, click burst. */
interactive?: boolean;
/** Scroll container if the page does not scroll the window. */
scroller?: Element | null;
/** Foreground content, drawn above the light. */
children?: ReactNode;
className?: string;
}
/** the star nodes, in reference units (height = 1) around the hole's centre, y down: x, y, size */
const NODES: [number, number, number][] = [
[-0.36, -0.26, 0.8], [-0.27, -0.18, 1.0], [-0.17, -0.13, 1.1], [-0.13, -0.19, 0.9], [-0.02, -0.2, 1.2],
[0.06, -0.15, 0.9], [0.1, -0.06, 1.0], [-0.14, -0.03, 1.1], [-0.22, 0.01, 0.9], [-0.31, 0.08, 0.8],
[-0.09, 0.1, 1.0], [-0.04, 0.17, 0.9], [-0.06, 0.27, 0.8], [0.11, 0.04, 1.2], [0.13, 0.11, 1.0], [0.17, 0.18, 0.9],
];
/** pairs of nodes joined by bundles of strands, running along the arms and round the loop */
const SEGS: [number, number][] = [
[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 13], [13, 14], [14, 15],
[2, 7], [7, 8], [8, 9], [7, 10], [10, 11], [11, 12], [1, 8], [3, 7], [10, 13],
];
const QUAD = `attribute vec2 aQ; varying vec2 vUv; void main(){ vUv = aQ * 0.5 + 0.5; gl_Position = vec4(aQ, 0.0, 1.0); }`;
const SCENE = `
precision highp float;
uniform vec2 uRes, uCenter, uMouse, uFlareC;
uniform float uTime, uIn, uRayLen, uScale, uRot, uHover, uFlare, uFlareAmp, uDisp, uIntensity;
uniform vec3 uCore, uBg;
uniform vec3 uNodes[16];
uniform vec4 uSegs[18];
varying vec2 vUv;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
vec2 hash2(vec2 p) { return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453); }
float vnoise(vec2 p) {
vec2 i = floor(p), f = fract(p);
f = f * f * (3.0 - 2.0 * f);
return mix(mix(hash(i), hash(i + vec2(1, 0)), f.x), mix(hash(i + vec2(0, 1)), hash(i + vec2(1, 1)), f.x), f.y);
}
// periodic noise around the circle, so rays have no seam
float anoise(float a, float freq, float seed) {
float x = a / 6.28318 * freq;
float i = floor(x), f = fract(x);
f = f * f * (3.0 - 2.0 * f);
return mix(hash(vec2(mod(i, freq), seed)), hash(vec2(mod(i + 1.0, freq), seed)), f);
}
// distance to the nearest cell border: the filament mesh
float cells(vec2 x) {
vec2 n = floor(x), f = fract(x);
vec2 mg = vec2(0.0), mr = vec2(0.0);
float md = 8.0;
for (int j = -1; j <= 1; j++)
for (int i = -1; i <= 1; i++) {
vec2 g = vec2(float(i), float(j));
vec2 o = hash2(n + g);
o = 0.5 + 0.45 * sin(uTime * 0.3 + 6.2831 * o);
vec2 r = g + o - f;
float d = dot(r, r);
if (d < md) { md = d; mr = r; mg = g; }
}
md = 8.0;
for (int j = -2; j <= 2; j++)
for (int i = -2; i <= 2; i++) {
vec2 g = mg + vec2(float(i), float(j));
vec2 o = hash2(n + g);
o = 0.5 + 0.45 * sin(uTime * 0.3 + 6.2831 * o);
vec2 r = g + o - f;
if (dot(mr - r, mr - r) > 0.00001) md = min(md, dot(0.5 * (mr + r), normalize(r - mr)));
}
return md;
}
void main() {
vec2 px = vec2(gl_FragCoord.x, uRes.y - gl_FragCoord.y);
float H = uRes.y;
// reference space: height units around the hole, turned and scaled
vec2 p = (px / H - uCenter) / uScale;
float cr = cos(uRot), sr = sin(uRot);
p = mat2(cr, -sr, sr, cr) * p;
vec2 m = (uMouse / H - uCenter) / uScale;
m = mat2(cr, -sr, sr, cr) * m;
vec2 fc = (uFlareC / H - uCenter) / uScale;
fc = mat2(cr, -sr, sr, cr) * fc;
vec3 col = uBg;
vec3 light = vec3(0.0);
float web = 0.0;
float r0 = length(p) * (1.0 + (anoise(atan(p.y, p.x), 5.0, 3.0) - 0.5) * 0.28);
// the body of the loop: a ring round the hole and the arms out to the nodes
float body = exp(-pow((r0 - 0.112) / 0.022, 2.0)) * 0.7;
for (int i = 0; i < 16; i++) {
vec3 nd = uNodes[i];
vec2 d = p - nd.xy;
body = max(body, exp(-dot(d, d) / (0.0011 * nd.z)));
}
// the hole stays clean and dark
body *= smoothstep(0.075, 0.1, r0);
// the strands: bundles of fine silk sagging from node to node, frayed so threads come and go
float px1 = 1.0 / (H * uScale);
for (int i = 0; i < 18; i++) {
vec4 sg = uSegs[i];
vec2 a = sg.xy, b = sg.zw;
vec2 ab = b - a;
float L = length(ab);
vec2 dir = ab / max(L, 1e-4);
vec2 nrm = vec2(-dir.y, dir.x);
vec2 q = p - a;
float u = dot(q, dir) / max(L, 1e-4);
if (u < -0.05 || u > 1.05) continue;
float v = dot(q, nrm);
float hsg = hash(vec2(float(i), 8.0));
for (int k = 0; k < 6; k++) {
float fk = float(k);
float sag = (hash(vec2(float(i), fk)) - 0.5) * 0.05 * L / 0.1 * sin(3.14159 * clamp(u, 0.0, 1.0));
float off = (fk - 2.5) * 0.0035 * sin(3.14159 * clamp(u, 0.0, 1.0)) + sag + sin(u * 9.0 + fk + uTime * 0.6) * 0.002;
float th = 1.0 - smoothstep(0.0, 1.1 * px1, abs(v - off));
float run = smoothstep(0.3, 0.55, vnoise(vec2(u * 6.0, fk * 3.1 + hsg * 9.0)));
float drawn = smoothstep(0.0, 0.12, uIn * 1.3 - u * 0.6 - hsg * 0.3);
web += th * run * drawn * (0.4 + 0.5 * hash(vec2(fk, float(i) + 3.0))) * smoothstep(-0.05, 0.05, u) * smoothstep(1.05, 0.95, u);
}
}
// the filaments: a fine crystalline mesh where the body is, drawn in on load
vec2 wq = p * 90.0 + vec2(vnoise(p * 9.0), vnoise(p * 9.0 + 4.0)) * 3.4;
float fd = cells(wq);
float fl = 1.0 - smoothstep(0.0, 0.8, fd * (H * uScale / 90.0) * 0.9);
// only some of the cell walls carry silk, so it reads as loose filaments, not a mesh
float keep = smoothstep(0.38, 0.6, vnoise(wq * 0.45 + 7.0));
float fw = smoothstep(0.3, 0.75, body) * smoothstep(0.0, 0.6, uIn - r0 * 0.8);
web += fl * keep * fw * (0.35 + 0.45 * body);
// the rim of the hole: a few taut bright threads
for (int k = 0; k < 3; k++) {
float rr = 0.097 + float(k) * 0.006 + (vnoise(vec2(atan(p.y, p.x) * 3.0, float(k))) - 0.5) * 0.008;
web += (1.0 - smoothstep(0.0, 1.2 / (H * uScale), abs(r0 - rr))) * (0.6 - float(k) * 0.15) * smoothstep(0.2, 0.7, uIn);
}
// the star nodes: a hot core, short spikes, and long rays split into colour
for (int i = 0; i < 16; i++) {
vec3 nd = uNodes[i];
vec2 d = p - nd.xy;
float r = length(d);
float a = atan(d.y, d.x);
float seed = float(i) * 7.13;
// near the cursor a node flares; a click flare lights each node as it passes
float near = exp(-dot(nd.xy - m, nd.xy - m) / 0.02) * uHover;
float fr = length(nd.xy - fc);
float burst = exp(-pow((fr - uFlare * 0.9) / 0.12, 2.0)) * uFlareAmp + uFlareAmp * 0.25 * step(fr, uFlare * 0.9);
float power = nd.z * (1.0 + near * 0.6 + burst * 0.75);
// core and fine spikes
light += uCore * exp(-r * r / 0.00006) * 1.4 * power;
float sp = pow(anoise(a, 48.0, seed), 6.0) + pow(anoise(a, 19.0, seed + 3.0), 8.0) * 0.7;
light += uCore * sp * exp(-r / (0.034 * power)) * 1.7;
light += uCore * exp(-r / 0.012) * 0.35 * power;
// rays: fan outward, away from the hole (and away from the cursor when it is near)
vec2 out1 = normalize(normalize(nd.xy + 0.0001) + vec2(-0.1, -0.55));
vec2 away = normalize(nd.xy - m + 0.0001);
vec2 dir = normalize(mix(out1, away, near * 0.8));
float side = smoothstep(0.1, 0.75, dot(d / max(r, 1e-4), dir));
float len = uRayLen * (0.08 + 0.13 * hash(vec2(seed, 1.0))) * (1.0 + near * 0.3 + burst * 0.55);
float fall = exp(-r / len) * smoothstep(0.0, 0.01, r);
// the prism: each colour's streaks sit at a slightly different angle, more so further out
float da = uDisp * (0.012 + r * 0.13);
float shim = uTime * 0.12;
float sr2 = pow(anoise(a + da, 60.0, seed + 2.0) * 0.65 + anoise(a + da + shim, 17.0, seed + 5.0) * 0.35, 9.0);
float sg = pow(anoise(a, 60.0, seed + 2.0) * 0.65 + anoise(a + shim, 17.0, seed + 5.0) * 0.35, 9.0);
float sb = pow(anoise(a - da, 60.0, seed + 2.0) * 0.65 + anoise(a - da + shim, 17.0, seed + 5.0) * 0.35, 9.0);
vec3 ray = vec3(sr2, sg, sb);
// white near the node, colour further out
ray = mix(vec3(dot(ray, vec3(0.333))), ray, clamp(smoothstep(0.0, 0.05, r) * uDisp * 1.2, 0.0, 1.0));
float grow = smoothstep(0.0, 1.0, uIn * 1.4 - fr * 0.4);
// only some nodes throw long rays; the rest just sparkle
float thrower = smoothstep(0.35, 0.6, hash(vec2(seed, 4.0))) + burst * 0.5 + near * 0.4;
light += ray * fall * side * 3.8 * power * grow * min(thrower, 1.4);
}
// the light rolls off softly, so a burst stays coloured instead of clipping to white
vec3 L = light * 0.75 * uIntensity;
col += uCore * web * 0.95 * uIntensity + (1.0 - exp(-L * 1.4)) / 1.4 * 1.6;
gl_FragColor = vec4(col, 1.0);
}`;
const BLUR = `
precision mediump float;
uniform sampler2D uTex;
uniform vec2 uStep;
varying vec2 vUv;
void main() {
vec4 c = texture2D(uTex, vUv) * 0.2270;
c += (texture2D(uTex, vUv + uStep * 1.3846) + texture2D(uTex, vUv - uStep * 1.3846)) * 0.3162;
c += (texture2D(uTex, vUv + uStep * 3.2308) + texture2D(uTex, vUv - uStep * 3.2308)) * 0.0703;
gl_FragColor = c;
}`;
const BRIGHT = `
precision mediump float;
uniform sampler2D uTex;
varying vec2 vUv;
void main() {
vec3 c = texture2D(uTex, vUv).rgb;
float l = max(c.r, max(c.g, c.b));
gl_FragColor = vec4(c * smoothstep(0.45, 0.95, l), 1.0);
}`;
const COMPOSITE = `
precision mediump float;
uniform sampler2D uScene, uBloom, uWide;
uniform float uGlow, uTime;
varying vec2 vUv;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
void main() {
vec3 sc = texture2D(uScene, vUv).rgb;
vec3 bl = texture2D(uBloom, vUv).rgb * 0.6 + texture2D(uWide, vUv).rgb * 0.45;
vec3 x = sc + bl * uGlow;
vec3 col = x / (1.0 + max(x - 0.9, 0.0) * 1.2);
col = min(col, vec3(1.0));
col += (hash(gl_FragCoord.xy + fract(uTime * 7.0) * 91.0) - 0.5) / 255.0;
gl_FragColor = vec4(col, 1.0);
}`;
const isReducedMotion = () =>
typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
function rgb(hex: string): [number, number, number] {
let h = hex.replace("#", "");
if (h.length === 3) h = h.replace(/./g, (c) => c + c);
const n = parseInt(h, 16) || 0;
return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];
}
export function PrismBloom({
core = "#f4f6ff",
background = "#000000",
dispersion = 1,
rays = 1,
size = 1,
intensity = 1,
glow = 0.8,
speed = 1,
interactive = true,
scroller,
children,
className,
}: PrismBloomProps) {
const hostRef = useRef<HTMLDivElement>(null);
const props = useRef({ core, background, dispersion, rays, size, intensity, glow, speed, interactive });
const redraw = useRef<(() => void) | null>(null);
useEffect(() => {
props.current = { core, background, dispersion, rays, size, intensity, glow, speed, interactive };
redraw.current?.();
}, [core, background, dispersion, rays, size, intensity, glow, speed, interactive]);
useEffect(() => {
const host = hostRef.current;
if (!host) return;
if (getComputedStyle(host).position === "static") host.style.position = "relative";
const still = isReducedMotion();
const canvas = document.createElement("canvas");
canvas.setAttribute("aria-hidden", "true");
canvas.style.cssText = "position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:pan-y;";
host.prepend(canvas);
const gl = canvas.getContext("webgl", { alpha: false, antialias: false, powerPreference: "high-performance" });
if (!gl) {
const p = props.current;
host.style.background = `radial-gradient(circle at 50% 55%, ${p.background} 8%, ${p.core}55 14%, ${p.background} 45%)`;
canvas.remove();
return;
}
const build = (fs: string) => {
const pr = gl.createProgram()!;
for (const [type, src] of [
[gl.VERTEX_SHADER, QUAD],
[gl.FRAGMENT_SHADER, fs],
] as const) {
const sh = gl.createShader(type)!;
gl.shaderSource(sh, src);
gl.compileShader(sh);
if (!gl.getShaderParameter(sh, gl.COMPILE_STATUS)) console.error(gl.getShaderInfoLog(sh));
gl.attachShader(pr, sh);
}
gl.linkProgram(pr);
if (!gl.getProgramParameter(pr, gl.LINK_STATUS)) console.error(gl.getProgramInfoLog(pr));
return pr;
};
const sceneProg = build(SCENE);
const blurProg = build(BLUR);
const brightProg = build(BRIGHT);
const compProg = build(COMPOSITE);
const uni = (pr: WebGLProgram, names: string[]) =>
Object.fromEntries(names.map((n) => [n, gl.getUniformLocation(pr, n)])) as Record<string, WebGLUniformLocation | null>;
const US = uni(sceneProg, ["uRes", "uCenter", "uMouse", "uFlareC", "uTime", "uIn", "uRayLen", "uScale", "uRot", "uHover", "uFlare", "uFlareAmp", "uDisp", "uIntensity", "uCore", "uBg", "uNodes", "uSegs"]);
const UB = uni(blurProg, ["uTex", "uStep"]);
const UR = uni(brightProg, ["uTex"]);
const UC = uni(compProg, ["uScene", "uBloom", "uWide", "uGlow", "uTime"]);
const quad = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, quad);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
const drawQuad = (pr: WebGLProgram) => {
const a = gl.getAttribLocation(pr, "aQ");
gl.bindBuffer(gl.ARRAY_BUFFER, quad);
gl.enableVertexAttribArray(a);
gl.vertexAttribPointer(a, 2, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLES, 0, 3);
gl.disableVertexAttribArray(a);
};
type Target = { fb: WebGLFramebuffer; tex: WebGLTexture; w: number; h: number };
const target = (tw: number, th: number): Target => {
const tex = gl.createTexture()!;
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, tw, th, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
const fb = gl.createFramebuffer()!;
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
return { fb, tex, w: tw, h: th };
};
let T: { scene: Target; a: Target; b: Target; c: Target; d: Target } | null = null;
const freeTargets = () => {
if (!T) return;
for (const x of Object.values(T)) {
gl.deleteFramebuffer(x.fb);
gl.deleteTexture(x.tex);
}
T = null;
};
let w = 1, h = 1, dpr = 1;
const resize = () => {
dpr = Math.min(window.devicePixelRatio || 1, 1.75);
w = Math.max(1, host.clientWidth);
h = Math.max(1, host.clientHeight);
canvas.width = Math.round(w * dpr);
canvas.height = Math.round(h * dpr);
const sw = canvas.width, sh = canvas.height;
freeTargets();
T = {
scene: target(sw, sh),
a: target(Math.max(1, sw >> 2), Math.max(1, sh >> 2)),
b: target(Math.max(1, sw >> 2), Math.max(1, sh >> 2)),
c: target(Math.max(1, sw >> 4), Math.max(1, sh >> 4)),
d: target(Math.max(1, sw >> 4), Math.max(1, sh >> 4)),
};
};
resize();
// ---- state: every value GSAP moves ----
const s = { in: still ? 1 : 0, scale: still ? 1 : 0.82, rot: 0, spin: 0, hover: 0, mx: -1e4, my: -1e4, flare: 0, flareAmp: 0, fcx: 0, fcy: 0, breathe: 0, push: 0 };
let time = 0;
const nodeBuf = new Float32Array(48);
const segBuf = new Float32Array(72);
const blurPass = (src: Target, dst: Target, dx: number, dy: number) => {
gl.bindFramebuffer(gl.FRAMEBUFFER, dst.fb);
gl.viewport(0, 0, dst.w, dst.h);
gl.useProgram(blurProg);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, src.tex);
gl.uniform1i(UB.uTex, 0);
gl.uniform2f(UB.uStep, dx / src.w, dy / src.h);
drawQuad(blurProg);
};
const draw = () => {
if (!T) return;
const p = props.current;
const X = T;
// the nodes drift a little on their own, each on its own slow path
NODES.forEach(([x, y, z], i) => {
const wob = 0.006 * (1 + s.breathe);
nodeBuf[i * 3] = x * (1 + s.breathe * 0.04) + Math.sin(time * 0.5 + i * 1.7) * wob;
nodeBuf[i * 3 + 1] = y * (1 + s.breathe * 0.04) + Math.cos(time * 0.43 + i * 2.3) * wob;
nodeBuf[i * 3 + 2] = z;
});
gl.bindFramebuffer(gl.FRAMEBUFFER, X.scene.fb);
gl.viewport(0, 0, X.scene.w, X.scene.h);
gl.useProgram(sceneProg);
gl.uniform2f(US.uRes, X.scene.w, X.scene.h);
// the hole sits where it does in the reference: a little left of centre, a little low
const aspect = w / h;
// narrow screens: like the reference, the hole sits right of centre so the long left arm fits
const narrow = Math.min(1, Math.max(0, (1.1 - aspect) / 0.5));
gl.uniform2f(US.uCenter, aspect * (0.5 + 0.07 * narrow) - 0.05 * (1 - narrow), 0.53);
gl.uniform2f(US.uMouse, s.mx * dpr, s.my * dpr);
gl.uniform2f(US.uFlareC, s.fcx * dpr, s.fcy * dpr);
gl.uniform1f(US.uTime, time);
gl.uniform1f(US.uIn, s.in);
gl.uniform1f(US.uRayLen, p.rays);
gl.uniform1f(US.uScale, p.size * s.scale * (1 + s.push) * Math.min(1, Math.max(0.9, aspect * 1.6)));
gl.uniform1f(US.uRot, s.rot + s.spin);
gl.uniform1f(US.uHover, s.hover);
gl.uniform1f(US.uFlare, s.flare);
gl.uniform1f(US.uFlareAmp, s.flareAmp);
gl.uniform1f(US.uDisp, p.dispersion);
gl.uniform1f(US.uIntensity, p.intensity);
gl.uniform3fv(US.uCore, rgb(p.core));
gl.uniform3fv(US.uBg, rgb(p.background));
gl.uniform3fv(US.uNodes, nodeBuf);
SEGS.forEach(([a, b], i) => segBuf.set([nodeBuf[a * 3], nodeBuf[a * 3 + 1], nodeBuf[b * 3], nodeBuf[b * 3 + 1]], i * 4));
gl.uniform4fv(US.uSegs, segBuf);
drawQuad(sceneProg);
gl.bindFramebuffer(gl.FRAMEBUFFER, X.a.fb);
gl.viewport(0, 0, X.a.w, X.a.h);
gl.useProgram(brightProg);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, X.scene.tex);
gl.uniform1i(UR.uTex, 0);
drawQuad(brightProg);
blurPass(X.a, X.b, 1, 0);
blurPass(X.b, X.a, 0, 1);
blurPass(X.a, X.c, 1, 0);
blurPass(X.c, X.d, 0, 1);
blurPass(X.d, X.c, 1.8, 0);
blurPass(X.c, X.d, 0, 1.8);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.viewport(0, 0, canvas.width, canvas.height);
gl.useProgram(compProg);
[X.scene.tex, X.a.tex, X.d.tex].forEach((tex, i) => {
gl.activeTexture(gl.TEXTURE0 + i);
gl.bindTexture(gl.TEXTURE_2D, tex);
});
gl.uniform1i(UC.uScene, 0);
gl.uniform1i(UC.uBloom, 1);
gl.uniform1i(UC.uWide, 2);
gl.uniform1f(UC.uGlow, p.glow);
gl.uniform1f(UC.uTime, time);
drawQuad(compProg);
gl.activeTexture(gl.TEXTURE0);
};
const ro = new ResizeObserver(() => {
resize();
draw();
});
ro.observe(host);
if (still) {
time = 3;
draw();
redraw.current = draw;
return () => {
redraw.current = null;
ro.disconnect();
freeTargets();
canvas.remove();
gl.getExtension("WEBGL_lose_context")?.loseContext();
};
}
// ---- on load: the filaments spin up out of the dark and the rays grow outward ----
const intro = gsap
.timeline({ delay: 0.1 })
.fromTo(s, { rot: -0.6 }, { rot: 0, duration: 3.2, ease: "expo.out" }, 0)
.to(s, { in: 1, duration: 2.6, ease: "power2.inOut" }, 0)
.to(s, { scale: 1, duration: 3.2, ease: "expo.out" }, 0);
// ---- idle: the loop breathes ----
const breathe = gsap.to(s, { breathe: 1, duration: 3.4, ease: "sine.inOut", yoyo: true, repeat: -1, delay: 2.5 });
// ---- cursor: nearby nodes flare and fan their rays away from it ----
const mxTo = gsap.quickTo(s, "mx", { duration: 0.45, ease: "power3" });
const myTo = gsap.quickTo(s, "my", { duration: 0.45, ease: "power3" });
const hoverTo = gsap.quickTo(s, "hover", { duration: 0.6, ease: "power2" });
const local = (e: PointerEvent) => {
const r = host.getBoundingClientRect();
return { x: e.clientX - r.left, y: e.clientY - r.top };
};
let first = true;
const move = (e: PointerEvent) => {
if (!props.current.interactive) return;
const p = local(e);
if (first) {
gsap.set(s, { mx: p.x, my: p.y });
first = false;
}
mxTo(p.x);
myTo(p.y);
hoverTo(1);
};
const leave = () => {
first = true;
hoverTo(0);
};
// ---- click: a flare races out from the point, bursting every node it reaches ----
const down = (e: PointerEvent) => {
if (!props.current.interactive) return;
const p = local(e);
s.fcx = p.x;
s.fcy = p.y;
gsap.killTweensOf(s, "flare,flareAmp");
gsap.fromTo(s, { flare: 0 }, { flare: 1, duration: 1.4, ease: "power2.out" });
gsap.timeline().fromTo(s, { flareAmp: 0 }, { flareAmp: 1, duration: 0.12, ease: "power2.out" }).to(s, { flareAmp: 0, duration: 1.6, ease: "power2.in" });
};
host.addEventListener("pointermove", move);
host.addEventListener("pointerleave", leave);
host.addEventListener("pointerdown", down);
// ---- scroll: the loop turns and draws you in ----
const spinTo = gsap.quickTo(s, "spin", { duration: 1.2, ease: "power3" });
const pushTo = gsap.quickTo(s, "push", { duration: 1.2, ease: "power3" });
const st = ScrollTrigger.create({
trigger: host,
scroller: scroller ?? undefined,
start: "top bottom",
end: "bottom top",
onUpdate: (self) => {
if (intro.isActive()) return;
spinTo((self.progress - 0.5) * 0.9);
pushTo(Math.max(0, self.progress - 0.5) * 0.8);
},
});
// ---- loop, only while on screen ----
let visible = true;
let prev = performance.now();
const loop = () => {
const now = performance.now();
const dt = Math.min(0.05, (now - prev) / 1000);
prev = now;
if (!visible) return;
time += dt * props.current.speed;
draw();
};
const io = new IntersectionObserver(([en]) => {
visible = en.isIntersecting;
prev = performance.now();
});
io.observe(host);
gsap.ticker.add(loop);
return () => {
gsap.ticker.remove(loop);
intro.kill();
breathe.kill();
st.kill();
io.disconnect();
ro.disconnect();
host.removeEventListener("pointermove", move);
host.removeEventListener("pointerleave", leave);
host.removeEventListener("pointerdown", down);
gsap.killTweensOf(s);
freeTargets();
canvas.remove();
gl.getExtension("WEBGL_lose_context")?.loseContext();
};
}, [scroller]);
return (
<div ref={hostRef} className={["isolate overflow-hidden", className].filter(Boolean).join(" ")} style={{ background }}>
{children && <div className="relative z-10 h-full">{children}</div>}
</div>
);
}
One prompt, any AI agent
Paste into Claude Code, Codex, Cursor or Windsurf. It carries your tweaks and the full source, so the agent installs it exactly.
Props
12 propscorestringColour of the filaments and the node cores.default "#f4f6ff"default "#f4f6ff"backgroundstringBackground colour.default "#000000"default "#000000"dispersionnumberHow strongly the rays split into colour (0 = white light).default 1default 1raysnumberLength of the rays.default 1default 1sizenumberSize of the loop.default 1default 1intensitynumberBrightness.default 1default 1glownumberStrength of the bloom.default 0.8default 0.8speednumberSpeed of the idle shimmer.default 1default 1interactivebooleanCursor flare, click burst.default truedefault truescrollerElement | nullScroll container, if the page does not scroll the window.childrenReactNodeForeground content, drawn above the light.classNamestringSize it, e.g. h-screen w-full.