Components88 / 118
Tape Trail
A roll of tape printed with your projects rolls across a soft grey floor after your cursor, leaning into its turns, and lays a printed strip of project tiles wherever it goes. Point at a tile to see the project, click to open it, and press Space to roll the tape back up.
3D3DPortfolioPortfolioHeroHerothree.jsthree.jsShadowsShadowsCursorCursorSquash & stretchSquash & stretchGSAPGSAP
Lead the roll with your cursorClick a tile to open it
Tweak
LIVELIVELook
Rewind button
Usage
Follows your tweaks.
usage.tsx
import { TapeTrail } from "@/components/inreact/tape-trail";
const projects = [
{ src: "/work/studio.jpg", title: "Studio site", href: "/work/studio" },
{ src: "/work/app.jpg", title: "Banking app", href: "/work/app" },
// ...
];
export function Work() {
return <TapeTrail projects={projects} height={640} />;
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/tape-trail.jsonOr copy the source
Install the dependencies, then save this as components/inreact/tape-trail.tsx.
terminal
npm install gsap threecomponents/inreact/tape-trail.tsx
"use client";
import { gsap } from "gsap";
import * as THREE from "three";
import { useEffect, useRef, useState } from "react";
/**
* Tape Trail: a roll of your work that unspools across the floor.
*
* A roll of tape printed with your projects rolls over a soft grey floor
* after your cursor, leaning into its turns, and lays a printed strip of
* project tiles wherever it goes: loops, spirals, your own scribbles. Its
* outer layer always shows the stretch of tape it will lay next. Point at a
* tile on the floor to see which project it is; click to open it. Press
* Space (or Rewind) and the roll rolls back along its trail, winding the
* tape back up. Left alone it wanders by itself. Real 3D (three): soft
* shadows, physical materials, image-based light.
*
* <TapeTrail projects={[{ src: "/work/1.jpg", title: "Studio site", href: "/work/studio" }, ...]} />
*/
export interface TapeProject {
src: string;
title?: string;
href?: string;
}
export interface TapeTrailProps {
projects: TapeProject[];
height?: number;
/** Floor colour (the page behind the scene). */
background?: string;
/** Show the Rewind button. */
controls?: boolean;
onSelect?: (project: TapeProject, index: number) => void;
className?: string;
}
const reduced = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const clamp = (a: number, b: number, v: number) => Math.max(a, Math.min(b, v));
const R = 0.98, CORE = 0.6, WID = 1; // roll radius, core radius, tape width (world units)
const TILE = 1.22; // one project along the tape
const STEP = 0.045; // trail sample spacing
const MAXP = 1800; // trail samples kept
const RMIN = 0.85; // tightest turn radius (keeps the tape from folding)
type Spring = { x: number; v: number; t: number };
const spring = (b: Spring, k: number, c: number, h: number) => {
for (let i = 0; i < 2; i++) (b.v += (k * (b.t - b.x) - c * b.v) * (h / 2)), (b.x += b.v * (h / 2));
};
const wrapA = (a: number) => Math.atan2(Math.sin(a), Math.cos(a));
// the printed tape: each project as a framed card with its number and title
function paintTape(projects: TapeProject[], onReady: () => void) {
const n = projects.length;
const cw = Math.floor(Math.min(420, 4096 / n)), ch = Math.round(cw / TILE);
const c = document.createElement("canvas");
c.width = cw * n;
c.height = ch;
const x = c.getContext("2d")!;
const card = (i: number, im?: HTMLImageElement) => {
const ox = i * cw, m = Math.round(ch * 0.07);
x.fillStyle = "#fbfbfa";
x.fillRect(ox, 0, cw, ch);
const iw = cw - m * 2, ih = ch - m * 2 - Math.round(ch * 0.13);
x.fillStyle = "#d9d9d6";
x.fillRect(ox + m, m, iw, ih);
if (im) {
const z = Math.max(iw / im.naturalWidth, ih / im.naturalHeight);
const w = im.naturalWidth * z, h = im.naturalHeight * z;
x.save();
x.beginPath();
x.rect(ox + m, m, iw, ih);
x.clip();
x.drawImage(im, ox + m + (iw - w) / 2, m + (ih - h) / 2, w, h);
x.restore();
}
x.fillStyle = "#151515";
x.font = `600 ${Math.round(ch * 0.075)}px system-ui, sans-serif`;
x.textBaseline = "middle";
const ty = ch - m - Math.round(ch * 0.06);
x.fillText(`#${String(i + 1).padStart(2, "0")}`, ox + m, ty);
const t = projects[i].title ?? "";
x.font = `500 ${Math.round(ch * 0.06)}px system-ui, sans-serif`;
x.textAlign = "right";
x.fillText(t, ox + cw - m, ty, cw * 0.6);
x.textAlign = "left";
// a thin cut between cards
x.fillStyle = "#e7e7e4";
x.fillRect(ox, 0, 2, ch);
};
projects.forEach((_, i) => card(i));
projects.forEach((p, i) => {
const im = new Image();
im.crossOrigin = "anonymous";
im.onload = () => {
card(i, im);
onReady();
};
im.src = p.src;
});
return c;
}
// the roll's ends: a wound edge of fine rings with a little grain
function paintEnds() {
const S = 512, c = document.createElement("canvas");
c.width = c.height = S;
const x = c.getContext("2d")!;
x.fillStyle = "#d8d5ce"; // the stacked edges of white photo paper
x.fillRect(0, 0, S, S);
const cx = S / 2;
for (let r = cx * (CORE / R); r < cx; r += 1.6) {
const g = 206 + Math.round(Math.sin(r * 0.9) * 7 + (Math.random() - 0.5) * 22);
x.strokeStyle = `rgb(${g},${g - 2},${g - 7})`;
x.lineWidth = 1.2;
x.beginPath();
x.arc(cx, cx, r, 0, Math.PI * 2);
x.stroke();
}
return c;
}
export function TapeTrail({ projects, height = 560, background = "#e4e4e2", controls = true, onSelect, className }: TapeTrailProps) {
const rootRef = useRef<HTMLDivElement>(null);
const hostRef = useRef<HTMLDivElement>(null);
const tipRef = useRef<HTMLDivElement>(null);
const rewindRef = useRef<() => void>(() => {});
const [W, setW] = useState(0);
const [tip, setTip] = useState("");
const selRef = useRef(onSelect);
selRef.current = onSelect;
const n = projects.length;
useEffect(() => {
const el = rootRef.current;
if (!el) return;
const ro = new ResizeObserver(([e]) => setW(Math.round(e.contentRect.width)));
ro.observe(el);
return () => ro.disconnect();
}, []);
useEffect(() => {
const host = hostRef.current, root = rootRef.current, tipEl = tipRef.current;
if (!host || !root || !tipEl || !W || !n) return;
const still = reduced();
const H = height;
// renderer
const canvas = document.createElement("canvas");
canvas.style.cssText = "position:absolute;inset:0;width:100%;height:100%;";
host.appendChild(canvas);
let renderer: THREE.WebGLRenderer;
try {
renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true });
} catch {
canvas.remove();
return;
}
renderer.setPixelRatio(Math.min(2, window.devicePixelRatio || 1));
renderer.setSize(W, H, false);
renderer.setClearColor(0x000000, 0);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFShadowMap;
renderer.toneMapping = THREE.NeutralToneMapping;
renderer.toneMappingExposure = 1.06;
renderer.outputColorSpace = THREE.SRGBColorSpace;
const scene = new THREE.Scene();
const pmrem = new THREE.PMREMGenerator(renderer);
// a dark photo studio with softboxes, for reflections only: gloss then shows as clean bright highlights
// over vivid prints, instead of a milky haze from a bright room
const studio = new THREE.Scene();
studio.background = new THREE.Color(0x1d1d21);
const box = (w: number, h: number, x: number, y: number, z: number, k: number) => {
const m = new THREE.Mesh(new THREE.PlaneGeometry(w, h), new THREE.MeshBasicMaterial({ color: new THREE.Color(k, k, k), side: THREE.DoubleSide }));
m.position.set(x, y, z);
m.lookAt(0, 0, 0);
studio.add(m);
};
// a narrow softbox about 50° up behind the scene: the flat tape mirrors it as one gloss band sweeping across the prints
box(3.2, 1.6, -1.6, 7.0, -7.1, 7);
box(3, 9, 9, 4, -1, 1.6); // a side strip, for highlights along the roll
box(3, 9, -9, 4, 2, 0.9); // a fainter fill strip opposite
const floorBounce = new THREE.Mesh(new THREE.PlaneGeometry(40, 40), new THREE.MeshBasicMaterial({ color: 0x2a2a2c }));
floorBounce.rotation.x = -Math.PI / 2;
(floorBounce.material as THREE.MeshBasicMaterial).color.set(0x3a3a3e);
floorBounce.position.y = -6;
studio.add(floorBounce);
const env = pmrem.fromScene(studio, 0.03).texture;
studio.traverse((o) => o instanceof THREE.Mesh && (o.geometry.dispose(), (o.material as THREE.Material).dispose()));
scene.environment = env;
scene.environmentIntensity = 1.0;
// camera: close and angled down at the floor, framing about 7 x 5 units
const camera = new THREE.PerspectiveCamera(36, W / H, 0.1, 100);
const fit = Math.max(1, 1.45 / (W / H));
const camBase = new THREE.Vector3(0, 5.7 * fit, 6.1 * fit);
camera.position.copy(camBase);
camera.lookAt(0, 0, 0.25);
const hemi = new THREE.HemisphereLight(0xffffff, 0xd6d6d2, 1.45);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffffff, 2.5);
sun.position.set(5, 9, 3.5);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -9;
sun.shadow.camera.right = 9;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -9;
sun.shadow.radius = 6;
sun.shadow.blurSamples = 16;
sun.shadow.bias = -0.0004;
scene.add(sun);
// floor: only its shadows (the page colour shows through)
const floor = new THREE.Mesh(new THREE.PlaneGeometry(60, 60), new THREE.ShadowMaterial({ opacity: 0.22 }));
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
// textures
const tapeCanvas = paintTape(projects, () => void (tapeTex.needsUpdate = true));
const tapeTex = new THREE.CanvasTexture(tapeCanvas);
tapeTex.colorSpace = THREE.SRGBColorSpace;
tapeTex.wrapS = THREE.RepeatWrapping;
tapeTex.anisotropy = renderer.capabilities.getMaxAnisotropy();
const endTex = new THREE.CanvasTexture(paintEnds());
endTex.colorSpace = THREE.SRGBColorSpace;
const LEN = n * TILE; // one full run of the tape
// the trail: a ribbon laid along the path (preallocated, grown in place)
const pos = new Float32Array(MAXP * 2 * 3);
const uv = new Float32Array(MAXP * 2 * 2);
const nor = new Float32Array(MAXP * 2 * 3);
for (let i = 0; i < MAXP * 2; i++) nor[i * 3 + 1] = 1;
const idx: number[] = [];
for (let i = 0; i < MAXP - 1; i++) {
const a = i * 2;
// wound so the ribbon's front faces point up: the sun and the gloss then light the prints from above
idx.push(a, a + 2, a + 1, a + 1, a + 2, a + 3);
}
const trailGeo = new THREE.BufferGeometry();
trailGeo.setAttribute("position", new THREE.BufferAttribute(pos, 3).setUsage(THREE.DynamicDrawUsage));
trailGeo.setAttribute("uv", new THREE.BufferAttribute(uv, 2).setUsage(THREE.DynamicDrawUsage));
trailGeo.setAttribute("normal", new THREE.BufferAttribute(nor, 3));
trailGeo.setIndex(idx);
trailGeo.setDrawRange(0, 0);
// glossy photo paper: a clear lacquer over the print catches crisp studio reflections
// (the room's reflection is kept low on the laid tape: seen at this angle, a strong one would wash the prints out)
const trailMat = new THREE.MeshPhysicalMaterial({ map: tapeTex, roughness: 0.55, metalness: 0, clearcoat: 1, clearcoatRoughness: 0.05, specularIntensity: 0.25, side: THREE.DoubleSide });
const trail = new THREE.Mesh(trailGeo, trailMat);
trail.receiveShadow = true;
trail.frustumCulled = false;
scene.add(trail);
// the roll: printed outer face, wound ends, a card core
const rollRoot = new THREE.Group(); // position + heading
const lean = new THREE.Group(); // banks into turns, pivoting on the floor
const hop = new THREE.Group(); // hops and squashes
const spin = new THREE.Group(); // rolls
rollRoot.add(lean);
lean.add(hop);
hop.add(spin);
spin.position.y = R;
scene.add(rollRoot);
const outerGeo = new THREE.CylinderGeometry(R, R, WID, 128, 1, true);
outerGeo.rotateZ(Math.PI / 2);
const outerMat = new THREE.MeshPhysicalMaterial({ map: tapeTex, roughness: 0.32, metalness: 0, clearcoat: 1, clearcoatRoughness: 0.06, specularIntensity: 0.8 });
const ru = { uS: { value: 0 }, uThC: { value: 0 }, uLen: { value: LEN }, uR: { value: R } };
outerMat.onBeforeCompile = (sh) => {
Object.assign(sh.uniforms, ru);
sh.fragmentShader =
"uniform float uS;\nuniform float uThC;\nuniform float uLen;\nuniform float uR;\n" +
sh.fragmentShader.replace(
"#include <map_fragment>",
`#ifdef USE_MAP
// the outer layer shows the tape still to be laid: s + (arc ahead of the contact)
float th = vMapUv.x * 6.28318530718;
float ahead = mod(th - uThC, 6.28318530718);
vec2 tuv = vec2((uS + ahead * uR) / uLen, vMapUv.y);
vec4 sampledDiffuseColor = texture2D(map, tuv);
diffuseColor *= sampledDiffuseColor;
#endif`,
);
};
const outer = new THREE.Mesh(outerGeo, outerMat);
outer.castShadow = true;
const innerGeo = new THREE.CylinderGeometry(CORE, CORE, WID * 0.995, 64, 1, true);
innerGeo.rotateZ(Math.PI / 2);
const inner = new THREE.Mesh(innerGeo, new THREE.MeshStandardMaterial({ color: 0xa8a49c, roughness: 0.85, side: THREE.BackSide }));
const endGeo = new THREE.RingGeometry(CORE, R, 128, 1);
// planar uv across the ring so the painted rings line up
const eu = endGeo.attributes.uv, ep = endGeo.attributes.position;
for (let i = 0; i < eu.count; i++) eu.setXY(i, ep.getX(i) / (2 * R) + 0.5, ep.getY(i) / (2 * R) + 0.5);
// the wound edges: a satin sheen across the stacked layers
const endMat = new THREE.MeshPhysicalMaterial({ map: endTex, roughness: 0.45, clearcoat: 0.5, clearcoatRoughness: 0.25 });
const endA = new THREE.Mesh(endGeo, endMat), endB = new THREE.Mesh(endGeo, endMat);
endA.rotation.y = Math.PI / 2;
endA.position.x = WID / 2;
endB.rotation.y = -Math.PI / 2;
endB.position.x = -WID / 2;
endA.castShadow = endB.castShadow = true;
spin.add(outer, inner, endA, endB);
// state
const st = { x: -1.6, z: 0.4, th: 0.4, v: 0, s: 0, hopY: 0, hopV: 0, rewinding: false, lastStep: 0 };
const leanS: Spring = { x: 0, v: 0, t: 0 };
const sq: Spring = { x: 0, v: 0, t: 0 };
const path: { x: number; z: number; th: number; s: number }[] = [];
const target = new THREE.Vector3(1, 0, 0);
let pointer = false, pointerAt = 0, autoT = 0, wasMoving = false;
// rewrite only from the first changed sample (the head moves every frame; a splice rewrites all)
let from = 0;
const writeTrail = () => {
const N = path.length;
for (let i = Math.max(0, from); i < N; i++) {
const p = path[i];
const nx = Math.cos(p.th), nz = -Math.sin(p.th); // right-hand side of the heading
const y = 0.003 + i * 3.2e-6; // newer tape lies on top where paths cross
const a = i * 6;
pos[a] = p.x - nx * WID * 0.5;
pos[a + 1] = y;
pos[a + 2] = p.z - nz * WID * 0.5;
pos[a + 3] = p.x + nx * WID * 0.5;
pos[a + 4] = y;
pos[a + 5] = p.z + nz * WID * 0.5;
const b = i * 4, u0 = p.s / LEN;
uv[b] = u0;
uv[b + 1] = 0;
uv[b + 2] = u0;
uv[b + 3] = 1;
}
trailGeo.attributes.position.needsUpdate = true;
trailGeo.attributes.uv.needsUpdate = true;
trailGeo.setDrawRange(0, Math.max(0, N - 1) * 6);
from = N;
};
let dirty = false;
const touch = (i: number) => {
from = Math.min(from, i);
dirty = true;
};
const ray = new THREE.Raycaster();
const plane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 0);
const ndc = new THREE.Vector2();
const floorAt = (cx: number, cy: number) => {
const r = root.getBoundingClientRect();
ndc.set(((cx - r.left) / W) * 2 - 1, -((cy - r.top) / H) * 2 + 1);
ray.setFromCamera(ndc, camera);
const p = new THREE.Vector3();
return ray.ray.intersectPlane(plane, p) ? p : null;
};
// which project is under a floor point (the newest tape on top wins)
const projectAt = (p: THREE.Vector3) => {
for (let i = path.length - 1; i > 0; i--) {
const a = path[i];
const dx = p.x - a.x, dz = p.z - a.z;
if (dx * dx + dz * dz > 0.6) continue;
const fx = Math.sin(a.th), fz = Math.cos(a.th);
const along = dx * fx + dz * fz, across = dx * Math.cos(a.th) - dz * Math.sin(a.th);
if (Math.abs(along) <= STEP * 0.75 && Math.abs(across) <= WID / 2) {
const k = Math.floor((a.s + along) / TILE);
return ((k % n) + n) % n;
}
}
return -1;
};
let lastFloor: THREE.Vector3 | null = null, tipTick = 0, hoverIdx = -1;
const refreshTip = (p: THREE.Vector3) => {
const k = projectAt(p);
if (k !== hoverIdx) {
hoverIdx = k;
setTip(k >= 0 ? `#${String(k + 1).padStart(2, "0")} ${projects[k].title ?? ""}` : "");
root.style.cursor = k >= 0 ? "pointer" : "";
}
};
const tick = (_t: number, ms: number) => {
const dt = Math.min(ms / 1000, 1 / 30);
const now = performance.now();
if (st.rewinding) {
// roll back along the trail, winding the tape up
let back = (still ? 40 : 7.5) * dt;
while (back > 0 && path.length > 1) {
const last = path[path.length - 1], prev = path[path.length - 2];
const seg = last.s - prev.s;
if (back >= seg) {
path.pop();
touch(path.length - 1);
back -= seg;
} else {
const f = back / seg;
last.x += (prev.x - last.x) * f;
last.z += (prev.z - last.z) * f;
last.s -= back;
back = 0;
touch(path.length - 1);
}
}
const h = path[path.length - 1];
if (h) {
st.x = h.x;
st.z = h.z;
st.th = h.th;
st.s = h.s;
}
st.v = -7.5;
if (path.length <= 1) {
st.rewinding = false;
st.v = 0;
path.length = 0;
st.lastStep = st.s;
}
} else {
// steer toward the target, like a wheel: speed follows distance, turns are limited
if (!pointer || now - pointerAt > 2600) {
autoT += dt;
const a = autoT * 0.32;
const rr = 1.5 + Math.sin(autoT * 0.11) * 0.6;
target.set(Math.cos(a) * rr * 1.45, 0, Math.sin(a * 1.27) * rr * 0.85 + 0.2);
}
const dx = target.x - st.x, dz = target.z - st.z, dist = Math.hypot(dx, dz);
const want = dist > 0.25 ? clamp(0, 4.2, (dist - 0.2) * 2.2) : 0;
st.v += (want - st.v) * Math.min(1, dt * (want > st.v ? 2.6 : 4.5));
if (still) st.v = want > 0 ? Math.min(want, 3) : 0;
if (dist > 0.05 && st.v > 0.02) {
const desired = Math.atan2(dx, dz);
const maxTurn = (st.v / RMIN) * dt;
const d = clamp(-maxTurn, maxTurn, wrapA(desired - st.th) * Math.min(1, dt * 6));
st.th += d;
leanS.t = clamp(-0.32, 0.32, (-d / Math.max(dt, 1e-3)) * st.v * 0.05);
} else leanS.t = 0;
const ds = st.v * dt;
st.x += Math.sin(st.th) * ds;
st.z += Math.cos(st.th) * ds;
st.s += ds;
// a little hop as it sets off
const moving = st.v > 0.35;
if (moving && !wasMoving && st.hopY <= 0 && !still) st.hopV = 1.6;
wasMoving = moving;
if (path.length === 0 || st.s - st.lastStep >= STEP) {
path.push({ x: st.x, z: st.z, th: st.th, s: st.s });
st.lastStep = st.s;
touch(path.length - 1);
if (path.length >= MAXP) path.splice(0, 240), touch(0); // the oldest tape lifts away
} else if (path.length) {
// keep the newest end glued under the roll
const h = path[path.length - 1];
h.x = st.x;
h.z = st.z;
h.th = st.th;
h.s = st.s;
touch(path.length - 1);
}
}
// hop + squash on landing
if (st.hopY > 0 || st.hopV > 0) {
st.hopV -= 14 * dt;
st.hopY += st.hopV * dt;
if (st.hopY <= 0) {
st.hopY = 0;
sq.v -= Math.min(6, Math.abs(st.hopV) * 2.2);
st.hopV = 0;
}
}
if (still) leanS.x = 0, sq.x = 0;
else {
spring(leanS, 90, 9, dt); // follow-through: wobbles upright when it straightens
spring(sq, 260, 11, dt);
}
rollRoot.position.set(st.x, 0, st.z);
rollRoot.rotation.y = st.th;
lean.rotation.z = leanS.x;
hop.position.y = st.hopY;
const q = clamp(-0.25, 0.25, sq.x);
hop.scale.set(1 + q * 0.6, 1 - q, 1 + q * 0.3);
const alpha = st.s / R;
spin.rotation.x = alpha;
ru.uS.value = st.s;
ru.uThC.value = alpha - Math.PI / 2;
if (dirty) {
writeTrail();
dirty = false;
// the tape under a still cursor may have changed (rewind, new tape)
if (lastFloor && ++tipTick % 8 === 0) refreshTip(lastFloor);
}
renderer.render(scene, camera);
};
gsap.ticker.add(tick);
const rewind = () => {
if (path.length > 1) st.rewinding = true;
};
rewindRef.current = rewind;
const moveTip = (e: PointerEvent) => {
const r = root.getBoundingClientRect();
const x = e.clientX - r.left, y = e.clientY - r.top;
// flip to the cursor's left near the right edge, above it near the bottom
const fx = x > W * 0.62 ? `calc(${(x - 12).toFixed(0)}px - 100%)` : `${(x + 14).toFixed(0)}px`;
const fy = y > H * 0.82 ? `calc(${(y - 10).toFixed(0)}px - 100%)` : `${(y + 14).toFixed(0)}px`;
tipEl.style.transform = `translate3d(${fx},${fy},0)`;
};
const onMove = (e: PointerEvent) => {
const p = floorAt(e.clientX, e.clientY);
if (!p) return;
pointer = true;
pointerAt = performance.now();
target.set(clamp(-7, 7, p.x), 0, clamp(-4.5, 5, p.z));
lastFloor = p;
refreshTip(p);
moveTip(e);
};
const onLeave = () => {
pointer = false;
lastFloor = null;
hoverIdx = -1;
setTip("");
};
const onClick = (e: MouseEvent) => {
const p = floorAt(e.clientX, e.clientY);
if (!p) return;
const k = projectAt(p);
if (k < 0) return;
selRef.current?.(projects[k], k);
if (projects[k].href) window.location.href = projects[k].href!;
};
const onKey = (e: KeyboardEvent) => {
if (e.key === " ") {
e.preventDefault();
rewind();
}
};
root.addEventListener("pointermove", onMove);
root.addEventListener("pointerleave", onLeave);
root.addEventListener("click", onClick);
root.addEventListener("keydown", onKey);
return () => {
gsap.ticker.remove(tick);
root.removeEventListener("pointermove", onMove);
root.removeEventListener("pointerleave", onLeave);
root.removeEventListener("click", onClick);
root.removeEventListener("keydown", onKey);
[trailGeo, outerGeo, innerGeo, endGeo, floor.geometry].forEach((g) => g.dispose());
[trailMat, outerMat, endMat, inner.material as THREE.Material, floor.material as THREE.Material].forEach((m) => m.dispose());
tapeTex.dispose();
endTex.dispose();
env.dispose();
pmrem.dispose();
renderer.dispose();
canvas.remove();
};
}, [W, height, n, projects]);
const fs = Math.round(clamp(8, 13, height * 0.024));
return (
<div
ref={rootRef}
tabIndex={0}
role="region"
aria-label="Projects"
className={["relative w-full overflow-hidden outline-none select-none", className].filter(Boolean).join(" ")}
style={{ height, background }}
>
<div ref={hostRef} aria-hidden="true" className="absolute inset-0" />
<div ref={tipRef} className="pointer-events-none absolute top-0 left-0 will-change-transform" style={{ opacity: tip ? 1 : 0, transition: "opacity .15s" }}>
<span className="block rounded-full bg-[#151515] px-3 py-1.5 font-medium whitespace-pre text-white shadow-[0_2px_6px_rgba(0,0,0,.12),0_10px_24px_rgba(0,0,0,.16)]" style={{ fontSize: fs }}>
{tip || " "}
</span>
</div>
{controls && (
<button
type="button"
onClick={(e) => {
e.stopPropagation();
rewindRef.current();
}}
className="absolute inline-flex items-center rounded-full bg-white/80 font-medium text-[#151515] shadow-[0_1px_2px_rgba(0,0,0,.08),0_8px_20px_rgba(0,0,0,.1)] backdrop-blur-sm transition-transform duration-200 hover:scale-[1.04] active:scale-95"
style={{ fontSize: fs, gap: fs * 0.55, padding: `${fs * 0.6}px ${fs * 1.05}px`, right: fs * 1.3, bottom: fs * 1.3 }}
>
<svg viewBox="0 0 24 24" width={fs + 2} height={fs + 2} fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<path d="M3 12a9 9 0 1 0 3-6.7" />
<path d="M3 4v5h5" />
</svg>
Rewind
<kbd className="rounded bg-black/[.07] px-1.5 py-px font-mono text-[0.85em] text-black/55">Space</kbd>
</button>
)}
</div>
);
}
export default TapeTrail;
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
6 propsprojects{ src: string; title?: string; href?: string }[]The projects printed on the tape.heightnumberHeight, px.default 560default 560backgroundstringFloor colour.default "#e4e4e2"default "#e4e4e2"controlsbooleanShow the Rewind button.default truedefault trueonSelect(project, index) => voidCalled when a tile is clicked.classNamestringExtra classes.