Liquid Chrome
Thick bars of mirror-polished black chrome sweep across the dark and cross, melting into each other with rounded fillets. Each is a true rounded tube reflecting a studio of long soft boxes: razor-thin white highlights along every edge, deep black faces and a faint warm and cool tint at the grazing angles, with a real bloom on the brightest light. The lights swing with your cursor so every highlight slides along the metal as the chrome swells toward it, a click ripples the surface, and scrolling turns the sculpture.
Tweak
LIVELIVEColour
Chrome
Motion
Interactive
The lights swing with the cursor, clicks ripple the chrome
Usage
Follows your tweaks.
import { LiquidChrome } from "@/components/inreact/liquid-chrome";
export function Hero() {
return (
<LiquidChrome
className="h-screen w-full"
>
{/* optional: your hero content, drawn above the chrome */}
</LiquidChrome>
);
}Install with the CLI
npx shadcn@latest add https://inreact.vercel.app/r/liquid-chrome.jsonOr copy the source
Install the dependencies, then save this as components/inreact/liquid-chrome.tsx.
npm install gsap"use client";
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { useEffect, useRef, type ReactNode } from "react";
gsap.registerPlugin(ScrollTrigger);
/**
* Liquid Chrome: a lattice of mirror-polished bars crossing in the dark.
*
* Thick bars of black chrome sweep across the frame and cross, melting into each
* other with soft rounded fillets where they meet. Each bar is a true rounded
* tube with a real surface normal, so it reflects a dark studio lit by long soft
* boxes: razor-thin white highlights run along every edge, the faces stay deep
* black, and a faint warm and cool tint creeps in at the grazing angles. A real
* bloom pass lets the brightest highlights glow.
*
* It is always alive: the bars drift and turn slowly and the reflections glide.
* It reacts: the studio lights swing with your cursor, so every highlight slides
* along the metal, and the chrome swells toward the cursor like liquid; a click
* sends a ripple through the surface; scrolling turns the whole sculpture. On
* load the highlights sweep on, as if the lights were switched on one by one.
*
* <LiquidChrome className="h-screen w-full">
* <YourHero />
* </LiquidChrome>
*
* WebGL: one shader (smooth-union distance field of the bars, a rounded-tube
* height profile, normals, an environment of soft boxes), 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 LiquidChromeProps {
/** Colour of the highlights. */
light?: string;
/** Tint of the metal in shadow. */
metal?: string;
/** Warm tint at grazing angles. */
warm?: string;
/** Cool tint at grazing angles. */
cool?: string;
/** Background colour. */
background?: string;
/** Thickness of the bars. */
thickness?: number;
/** Strength of the bloom. */
glow?: number;
/** Speed of the drift. */
speed?: number;
/** Cursor light and swell, click ripple. */
interactive?: boolean;
/** Scroll container if the page does not scroll the window. */
scroller?: Element | null;
/** Foreground content, drawn above the chrome. */
children?: ReactNode;
className?: string;
}
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, uMouse, uRipC, uEnv;
uniform float uTime, uIn, uW, uRot, uHover, uRip, uRipAmp;
uniform vec3 uLight, uMetal, uWarm, uCool, uBg;
varying vec2 vUv;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
float sdSeg(vec2 p, vec2 a, vec2 b) {
vec2 pa = p - a, ba = b - a;
float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
return length(pa - ba * h);
}
// smooth union: the bars melt into each other with a rounded fillet
float smin(float a, float b, float k) {
float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);
return mix(b, a, h) - k * h * (1.0 - h);
}
float asp;
// the lattice in two layers: the main cross and its brace in front, a parallel pair set back behind
float field(vec2 p, float layer) {
vec2 c = vec2(asp * 0.5, 0.5);
float t = uTime * 0.08;
vec2 q = p - c;
float cr = cos(uRot), sr = sin(uRot);
q = mat2(cr, -sr, sr, cr) * q;
// the cursor draws the metal toward it, like liquid; the back layer less, being further away
vec2 mq = uMouse - c;
mq = mat2(cr, -sr, sr, cr) * mq;
vec2 dm = q - mq;
q -= dm * (layer < 0.5 ? 0.35 : 0.15) * exp(-dot(dm, dm) / 0.03) * uHover;
float L = 2.2;
float a1 = 0.95 + 0.06 * sin(t);
float a2 = -0.85 + 0.05 * sin(t * 1.3 + 1.0);
vec2 d1 = vec2(cos(a1), sin(a1)) * L, d2 = vec2(cos(a2), sin(a2)) * L;
if (layer > 0.5) {
// the back pair drifts a little slower, for parallax
vec2 o3 = vec2(0.32, 0.28) + 0.03 * vec2(sin(t * 0.8), cos(t * 0.6));
float d = sdSeg(q, o3 - d1 * 0.7, o3 + d1 * 0.7) - uW * 0.75;
vec2 o4 = vec2(-0.42, -0.3) + 0.03 * vec2(cos(t * 0.7), sin(t * 0.9));
return smin(d, sdSeg(q, o4 - d2 * 0.7, o4 + d2 * 0.7) - uW * 0.75, 0.03);
}
vec2 o1 = vec2(0.05 * sin(t * 0.7), 0.0), o2 = vec2(-0.12, 0.04 * sin(t * 0.9));
float d = sdSeg(q, o1 - d1, o1 + d1) - uW;
d = smin(d, sdSeg(q, o2 - d2, o2 + d2) - uW, 0.035);
vec2 o5 = vec2(-0.3, 0.44);
d = smin(d, sdSeg(q, o5 - d1 * 0.18, o5 + d1 * 0.18) - uW * 0.6, 0.025);
return d;
}
// the bar's profile: a thin bevelled lip at the edge, a small step, then the broad rounded face
float height(vec2 p, float layer) {
float d = field(p, layer);
float w = uW * (layer > 0.5 ? 0.75 : 1.0);
float x = clamp(-d / w, 0.0, 1.0);
float lip = smoothstep(0.0, 0.07, x) * 0.35;
float face = pow(sqrt(max(0.0, 1.0 - (1.0 - x) * (1.0 - x))), 0.6);
float h = mix(lip, face, smoothstep(0.07, 0.16, x));
// a click's ripple through the surface
float rl = length(p - uRipC);
h += sin(rl * 60.0 - uRip * 40.0) * exp(-pow((rl - uRip * 1.4) / 0.08, 2.0)) * 0.08 * uRipAmp * step(0.0, -d);
return h * w;
}
// the studio: black, lit by long soft boxes; their direction swings with the cursor
vec3 env(vec3 r) {
float e = 0.0;
vec2 sw = uEnv;
vec3 a1 = normalize(vec3(0.6 + sw.x, -0.7 + sw.y, 0.4));
vec3 a2 = normalize(vec3(-0.75 + sw.x * 0.6, 0.35 + sw.y * 0.6, 0.55));
vec3 a3 = normalize(vec3(0.15, 0.9, 0.4));
e += exp(-pow((dot(r, a1) - 0.55) / 0.03, 2.0)) * 1.3;
e += exp(-pow((dot(r, a2) - 0.5) / 0.04, 2.0)) * 0.8;
e += exp(-pow((dot(r, a3) - 0.62) / 0.07, 2.0)) * 0.25;
// a broad soft box overhead, catching the flat tops of the bars in big soft gleams
vec3 a4 = normalize(vec3(-0.25 + sw.x * 0.5, 0.25 + sw.y * 0.5, 1.0));
e += smoothstep(0.93, 0.995, dot(r, a4)) * 0.9;
e += smoothstep(0.2, 1.0, r.z) * 0.03;
return vec3(e);
}
// the chrome at p for one layer: colour (rgb) and coverage (a)
vec4 shade(vec2 p, float layer) {
float d = field(p, layer);
if (d > 0.004) return vec4(0.0);
float e = 1.0 / uRes.y;
float h0 = height(p, layer);
float hx = height(p + vec2(e, 0.0), layer);
float hy = height(p + vec2(0.0, e), layer);
vec3 n = normalize(vec3(-(hx - h0) / e, -(hy - h0) / e, 1.0));
vec3 r = reflect(vec3(0.0, 0.0, -1.0), n);
// a faint prism: each colour reflects off a very slightly different normal, fringing the brightest edges
vec3 rr = reflect(vec3(0.0, 0.0, -1.0), normalize(n + vec3(0.006, 0.0, 0.0)));
vec3 rb = reflect(vec3(0.0, 0.0, -1.0), normalize(n - vec3(0.006, 0.0, 0.0)));
vec3 refl = vec3(env(rr).r, env(r).g, env(rb).b) * uLight;
float fr = pow(1.0 - max(n.z, 0.0), 3.0);
vec3 tint = mix(uCool, uWarm, 0.5 + 0.5 * r.x);
vec3 metal = uMetal * (0.04 + 0.06 * n.z) + refl * (0.75 + 0.5 * fr) + tint * fr * 0.15;
// the back layer sits further away: dimmer and cooler
if (layer > 0.5) metal *= vec3(0.55, 0.58, 0.64);
float cover = 1.0 - smoothstep(-0.0015, 0.0015, d);
return vec4(metal, cover);
}
void main() {
float H = uRes.y;
asp = uRes.x / uRes.y;
vec2 p = gl_FragCoord.xy / H;
vec3 col = uBg;
// the back layer, with its own soft shadow on the dark
float db = field(p, 1.0);
col *= 1.0 - 0.4 * exp(-max(db, 0.0) / 0.03);
vec4 back = shade(p, 1.0);
col = mix(col, back.rgb, back.a);
// the front layer casts a soft shadow onto the back one, then sits over it
float df = field(p + vec2(-0.012, 0.018), 0.0);
col *= 1.0 - 0.55 * exp(-max(df, 0.0) / 0.025);
vec4 front = shade(p, 0.0);
col = mix(col, front.rgb, front.a);
// on load the lights come on, sweeping across
col *= smoothstep(0.0, 0.35, uIn * 1.4 - (p.x / asp) * 0.4);
col += (hash(gl_FragCoord.xy + fract(uTime) * 91.0) - 0.5) / 255.0;
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.6, 1.0, 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.5;
vec3 x = sc + bl * uGlow;
vec3 col = x / (1.0 + max(x - 0.85, 0.0) * 1.3);
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 LiquidChrome({
light = "#ffffff",
metal = "#9aa3b4",
warm = "#ffb27a",
cool = "#7ab8ff",
background = "#000000",
thickness = 1,
glow = 0.6,
speed = 1,
interactive = true,
scroller,
children,
className,
}: LiquidChromeProps) {
const hostRef = useRef<HTMLDivElement>(null);
const props = useRef({ light, metal, warm, cool, background, thickness, glow, speed, interactive });
const redraw = useRef<(() => void) | null>(null);
useEffect(() => {
props.current = { light, metal, warm, cool, background, thickness, glow, speed, interactive };
redraw.current?.();
}, [light, metal, warm, cool, background, thickness, 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 = `linear-gradient(55deg, ${p.background} 40%, ${p.metal}55 48%, ${p.light} 50%, ${p.metal}55 52%, ${p.background} 60%), ${p.background}`;
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", "uMouse", "uRipC", "uEnv", "uTime", "uIn", "uW", "uRot", "uHover", "uRip", "uRipAmp", "uLight", "uMetal", "uWarm", "uCool", "uBg"]);
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, 2);
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 (positions in height units, y up) ----
const s = { in: still ? 1 : 0, rot: still ? 0 : -0.25, spin: 0, ex: 0, ey: 0, dx: 0, dy: 0, mx: -9, my: -9, hover: 0, rip: 0, ripAmp: 0, rx: 0, ry: 0 };
let time = still ? 10 : 0;
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;
const aspect = w / h;
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 void sits a little right of centre on wide screens, centred on narrow ones, leaving room for content
const off = Math.min(0.18, Math.max(0, (aspect - 1) * 0.12));
gl.uniform2f(US.uMouse, s.mx, s.my);
gl.uniform2f(US.uRipC, s.rx, s.ry);
gl.uniform2f(US.uEnv, s.ex + s.dx, s.ey + s.dy);
gl.uniform1f(US.uTime, time);
gl.uniform1f(US.uIn, s.in);
gl.uniform1f(US.uW, 0.055 * p.thickness);
gl.uniform1f(US.uRot, s.rot + s.spin);
gl.uniform1f(US.uHover, s.hover);
gl.uniform1f(US.uRip, s.rip);
gl.uniform1f(US.uRipAmp, s.ripAmp);
gl.uniform3fv(US.uLight, rgb(p.light));
gl.uniform3fv(US.uMetal, rgb(p.metal));
gl.uniform3fv(US.uWarm, rgb(p.warm));
gl.uniform3fv(US.uCool, rgb(p.cool));
gl.uniform3fv(US.uBg, rgb(p.background));
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) {
draw();
redraw.current = draw;
return () => {
redraw.current = null;
ro.disconnect();
freeTargets();
canvas.remove();
gl.getExtension("WEBGL_lose_context")?.loseContext();
};
}
// ---- on load: the lights come on and the sculpture turns into place ----
const intro = gsap
.timeline({ delay: 0.1 })
.to(s, { in: 1, duration: 2.4, ease: "power2.inOut" }, 0)
.to(s, { rot: 0, duration: 3.4, ease: "expo.out" }, 0);
// ---- idle: the lights glide, so the reflections never sit still ----
const drift = gsap
.timeline({ repeat: -1, yoyo: true })
.to(s, { dx: 0.25, dy: 0.15, duration: 5, ease: "sine.inOut" })
.to(s, { dx: -0.2, dy: -0.12, duration: 5.5, ease: "sine.inOut" });
// ---- cursor: the lights swing with it and the chrome swells toward it ----
const exTo = gsap.quickTo(s, "ex", { duration: 0.9, ease: "power3" });
const eyTo = gsap.quickTo(s, "ey", { duration: 0.9, ease: "power3" });
const mxTo = gsap.quickTo(s, "mx", { duration: 0.7, ease: "power3" });
const myTo = gsap.quickTo(s, "my", { duration: 0.7, ease: "power3" });
const hoverTo = gsap.quickTo(s, "hover", { duration: 0.9, ease: "power2.inOut" });
const local = (e: PointerEvent) => {
const r = host.getBoundingClientRect();
return { x: (e.clientX - r.left) / r.height, y: (r.bottom - e.clientY) / r.height, nx: (e.clientX - r.left) / r.width - 0.5, ny: (r.bottom - e.clientY) / r.height - 0.5 };
};
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);
exTo(p.nx * 1.1);
eyTo(p.ny * 1.1);
};
const leave = () => {
first = true;
hoverTo(0);
exTo(0);
eyTo(0);
};
// ---- click: a ripple runs through the chrome ----
const down = (e: PointerEvent) => {
if (!props.current.interactive) return;
const p = local(e);
s.rx = p.x;
s.ry = p.y;
gsap.killTweensOf(s, "rip,ripAmp");
gsap.fromTo(s, { rip: 0 }, { rip: 1, duration: 1.8, ease: "power2.out" });
gsap.timeline().fromTo(s, { ripAmp: 0 }, { ripAmp: 1, duration: 0.15, ease: "sine.out" }).to(s, { ripAmp: 0, duration: 1.6, ease: "sine.in" });
};
host.addEventListener("pointermove", move);
host.addEventListener("pointerleave", leave);
host.addEventListener("pointerdown", down);
// ---- scroll: the sculpture turns ----
const spinTo = gsap.quickTo(s, "spin", { duration: 1.3, ease: "power3" });
const st = ScrollTrigger.create({
trigger: host,
scroller: scroller ?? undefined,
start: "top bottom",
end: "bottom top",
onUpdate: (self) => spinTo((self.progress - 0.5) * 0.6),
});
// ---- 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();
drift.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 propslightstringColour of the highlights.default "#ffffff"default "#ffffff"metalstringTint of the metal in shadow.default "#9aa3b4"default "#9aa3b4"warmstringWarm tint at grazing angles.default "#ffb27a"default "#ffb27a"coolstringCool tint at grazing angles.default "#7ab8ff"default "#7ab8ff"backgroundstringBackground colour.default "#000000"default "#000000"thicknessnumberThickness of the bars.default 1default 1glownumberStrength of the bloom.default 0.6default 0.6speednumberSpeed of the drift.default 1default 1interactivebooleanCursor light and swell, click ripple.default truedefault truescrollerElement | nullScroll container, if the page does not scroll the window.childrenReactNodeForeground content, drawn above the chrome.classNamestringSize it, e.g. h-screen w-full.