Components83 / 118
Poster Dome
An endless wall of posters bowed into a dome, dragged in any direction. Fling it and it glides; the faster it moves, the more the dome bulges and the posters stretch along the motion. Hover a poster to lift it and pop in its badge, click to zoom in close.
GalleryGalleryInfinite canvasInfinite canvasWebGLWebGLDragDragSquash & stretchSquash & stretchGSAPGSAP
Drag and fling the wallClick a poster to zoom in
Tweak
LIVELIVELook
0.32
#3cff7a
Usage
Follows your tweaks.
usage.tsx
import { PosterDome } from "@/components/inreact/poster-dome";
const work = [
{ src: "/work/01.jpg", title: "Night Market", href: "/work/night-market" },
{ src: "/work/02.jpg", title: "Paper Moon", href: "/work/paper-moon" },
// ... (more images make a richer wall; they repeat across the infinite grid)
];
export function Wall() {
return <PosterDome posters={work} height={600} />;
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/poster-dome.jsonOr copy the source
Install the dependencies, then save this as components/inreact/poster-dome.tsx.
terminal
npm install gsap threecomponents/inreact/poster-dome.tsx
"use client";
import { gsap } from "gsap";
import * as THREE from "three";
import { useEffect, useRef, useState } from "react";
/**
* Poster Dome: an endless wall of posters bowed into a dome.
*
* An infinite wall of images you can drag in any direction, bent into a dome:
* the posters in the middle stand large, the ones at the edges curve away.
* Fling it and it glides; the faster it moves, the more the dome bulges and
* the posters stretch along the motion, and as it slows they ease back. Point
* at a poster and it lifts while the rest dim, and a badge with its title
* pops in. Click it to zoom in close (with a springy overshoot); click again
* or press Escape to zoom back out. One WebGL pass (three) + GSAP.
*
* <PosterDome posters={[{ src: "/work/1.jpg", title: "Night Market" }, ...]} />
*/
export interface DomePoster {
src: string;
title?: string;
href?: string;
}
export interface PosterDomeProps {
posters: DomePoster[];
height?: number;
/** How strongly the wall bows (0 is flat). */
dome?: number;
/** The badge colour. */
accent?: string;
background?: string;
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 CELL_W = 1, CELL_H = 1.28, GUT = 0.07; // grid units
const AT_W = 256, AT_H = 328; // atlas cell, px
const VERT = /* glsl */ `
varying vec2 vUv;
void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }`;
const FRAG = /* glsl */ `
precision highp float;
varying vec2 vUv;
uniform sampler2D uAtlas;
uniform vec2 uAtlasGrid; // cols, rows
uniform float uCount;
uniform vec2 uRes;
uniform vec2 uOff; // camera, grid units
uniform float uScale; // grid units across the short side
uniform float uDome;
uniform vec2 uVel; // grid units / s
uniform vec2 uHover; // hovered tile
uniform float uHov;
uniform vec3 uBg;
// which poster a tile shows: exact small-integer maths, mirrored in JS
float pickOf(vec2 id) { return mod(id.x * 7.0 + id.y * 3.0 + mod(id.x * id.y, 5.0), uCount); }
vec2 toGrid(vec2 s) {
// the dome: more of the wall per pixel toward the edges
float r2 = dot(s, s);
float dome = uDome * (1.0 + 0.6 * clamp(length(uVel) * 0.15, 0.0, 1.5));
vec2 g = s * (1.0 + dome * r2);
// stretch along the motion
float sp = length(uVel);
if (sp > 0.001) {
vec2 d = uVel / sp;
float st = clamp(sp * 0.035, 0.0, 0.22);
g -= d * dot(g, d) * st;
}
return g * uScale + uOff;
}
void main() {
vec2 s = (vUv - 0.5) * uRes / min(uRes.x, uRes.y);
vec2 g = toGrid(s);
vec2 cell = vec2(${CELL_W.toFixed(2)}, ${CELL_H.toFixed(2)});
vec2 id = floor(g / cell);
vec2 lc = fract(g / cell); // 0..1 within the cell
vec2 inner = (lc * cell - ${GUT.toFixed(2)} * 0.5) / (cell - ${GUT.toFixed(2)});
// rounded tile with soft edges
vec2 q = abs(inner - 0.5) * (cell - ${GUT.toFixed(2)}) - ((cell - ${GUT.toFixed(2)}) * 0.5 - 0.035);
float px = fwidth(g.x) * 1.2;
float a = 1.0 - smoothstep(-px, px, length(max(q, 0.0)) - 0.035);
float pick = pickOf(id);
vec2 at = vec2(mod(pick, uAtlasGrid.x), floor(pick / uAtlasGrid.x));
vec2 uv = (at + vec2(clamp(inner.x, 0.0, 1.0), 1.0 - clamp(inner.y, 0.0, 1.0))) / uAtlasGrid;
uv.y = 1.0 - uv.y;
vec3 col = texture2D(uAtlas, uv).rgb;
// focus: the hovered poster lifts, the rest dim a touch
float isH = step(abs(id.x - uHover.x) + abs(id.y - uHover.y), 0.5);
col *= mix(1.0, isH > 0.5 ? 1.12 : 0.72, uHov);
// the dome falls into shade toward its rim
float rim = smoothstep(1.25, 0.35, length(s * vec2(0.85, 1.0)));
col *= 0.35 + 0.65 * rim;
gl_FragColor = vec4(mix(uBg, col, a), 1.0);
}`;
export function PosterDome({ posters, height = 520, dome = 0.32, accent = "#3cff7a", background = "#0d0d0f", className }: PosterDomeProps) {
const rootRef = useRef<HTMLDivElement>(null);
const hostRef = useRef<HTMLDivElement>(null);
const badgeRef = useRef<HTMLDivElement>(null);
const popRef = useRef<HTMLDivElement>(null);
const [W, setW] = useState(0);
const [title, setTitle] = useState("");
const n = posters.length;
useEffect(() => {
const el = rootRef.current;
if (!el) return;
const ro = new ResizeObserver(([e]) => setW(e.contentRect.width));
ro.observe(el);
return () => ro.disconnect();
}, []);
useEffect(() => {
const host = hostRef.current, root = rootRef.current, badge = badgeRef.current, pop = popRef.current;
if (!host || !root || !badge || !pop || !W || !n) return;
const still = reduced();
const H = height;
// pack every poster into one atlas (cover-cropped), so one pass draws the wall
const cols = Math.min(8, Math.ceil(Math.sqrt(n * 1.3))), rows = Math.ceil(n / cols);
const atlas = document.createElement("canvas");
atlas.width = cols * AT_W;
atlas.height = rows * AT_H;
const actx = atlas.getContext("2d")!;
actx.fillStyle = "#1a1a1d";
actx.fillRect(0, 0, atlas.width, atlas.height);
const tex = new THREE.CanvasTexture(atlas);
tex.colorSpace = THREE.SRGBColorSpace;
tex.minFilter = THREE.LinearMipmapLinearFilter;
tex.anisotropy = 4;
posters.forEach((p, i) => {
const im = new Image();
im.crossOrigin = "anonymous";
im.onload = () => {
const x = (i % cols) * AT_W, y = Math.floor(i / cols) * AT_H;
const z = Math.max(AT_W / im.naturalWidth, AT_H / im.naturalHeight);
const w = im.naturalWidth * z, h = im.naturalHeight * z;
actx.save();
actx.beginPath();
actx.rect(x, y, AT_W, AT_H);
actx.clip();
actx.drawImage(im, x + (AT_W - w) / 2, y + (AT_H - h) / 2, w, h);
actx.restore();
tex.needsUpdate = true;
};
im.src = p.src;
});
const pr = Math.min(2, window.devicePixelRatio || 1);
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: false });
} catch {
canvas.remove();
return;
}
renderer.setPixelRatio(pr);
renderer.setSize(W, H, false);
const bg = new THREE.Color(background);
const mat = new THREE.ShaderMaterial({
vertexShader: VERT,
fragmentShader: FRAG,
depthTest: false,
uniforms: {
uAtlas: { value: tex },
uAtlasGrid: { value: new THREE.Vector2(cols, rows) },
uCount: { value: n },
uRes: { value: new THREE.Vector2(W, H) },
uOff: { value: new THREE.Vector2(0.5, 0.64) },
uScale: { value: 3.1 },
uDome: { value: dome },
uVel: { value: new THREE.Vector2(0, 0) },
uHover: { value: new THREE.Vector2(9999, 9999) },
uHov: { value: 0 },
uBg: { value: new THREE.Vector3(bg.r, bg.g, bg.b) },
},
});
const scene = new THREE.Scene();
const quad = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), mat);
scene.add(quad);
const camera = new THREE.Camera();
const u = mat.uniforms;
const MIN = Math.min(W, H);
const st = { x: 0.5, y: 0.64, vx: 0, vy: 0, drag: false, scale: 3.1, vel: { x: 0, y: 0 }, hov: 0, thov: 0, lx: 0.5, ly: 0.64 };
let hoverId: [number, number] | null = null;
let zoomed = false;
const ZOOM_OUT = 3.1, ZOOM_IN = 1.25;
// screen (centred, short side = 1) → grid, mirrors the shader
const toGrid = (sx: number, sy: number) => {
const r2 = sx * sx + sy * sy;
const sp = Math.hypot(st.vel.x, st.vel.y);
const d = dome * (1 + 0.6 * clamp(sp * 0.15, 0, 1.5));
let gx = sx * (1 + d * r2), gy = sy * (1 + d * r2);
if (sp > 0.001) {
const dx = st.vel.x / sp, dy = st.vel.y / sp;
const k = clamp(sp * 0.035, 0, 0.22);
const dd = gx * dx + gy * dy;
gx -= dx * dd * k;
gy -= dy * dd * k;
}
return { x: gx * st.scale + st.x, y: gy * st.scale + st.y };
};
// grid → screen, by iterating the inverse (for the badge)
const toScreen = (gx: number, gy: number) => {
const tx = (gx - st.x) / st.scale, ty = (gy - st.y) / st.scale;
let sx = tx, sy = ty;
for (let i = 0; i < 6; i++) {
const r2 = sx * sx + sy * sy;
sx = tx / (1 + dome * r2);
sy = ty / (1 + dome * r2);
}
return { x: W / 2 + sx * MIN, y: H / 2 - sy * MIN };
};
const tileAt = (clientX: number, clientY: number) => {
const r = root.getBoundingClientRect();
const sx = (clientX - r.left - W / 2) / MIN, sy = -(clientY - r.top - H / 2) / MIN;
const g = toGrid(sx, sy);
return { ix: Math.floor(g.x / CELL_W), iy: Math.floor(g.y / CELL_H) };
};
// same as the shader's pickOf (GLSL mod is always positive)
const fmod = (a: number, b: number) => a - b * Math.floor(a / b);
const pickOf = (ix: number, iy: number) => fmod(ix * 7 + iy * 3 + fmod(ix * iy, 5), n);
let lastBadge = "";
const tick = (_t: number, ms: number) => {
const dt = Math.min(ms / 1000, 1 / 30);
if (!st.drag) {
// glide with friction
st.x += st.vx * dt;
st.y += st.vy * dt;
const f = Math.pow(still ? 0 : 0.06, dt);
st.vx *= f;
st.vy *= f;
}
// the visual velocity eases toward the real one (stretch, then ease back)
const rvx = (st.x - st.lx) / Math.max(dt, 1e-3), rvy = (st.y - st.ly) / Math.max(dt, 1e-3);
st.lx = st.x;
st.ly = st.y;
const k = still ? 1 : Math.min(1, dt * 8);
st.vel.x += (rvx - st.vel.x) * k;
st.vel.y += (rvy - st.vel.y) * k;
if (still) st.vel.x = st.vel.y = 0;
st.hov += (st.thov - st.hov) * Math.min(1, dt * 10);
u.uOff.value.set(st.x, st.y);
u.uScale.value = st.scale;
u.uVel.value.set(st.vel.x, st.vel.y);
u.uHov.value = st.hov;
if (hoverId) u.uHover.value.set(hoverId[0], hoverId[1]);
// the badge follows the hovered poster's top-left corner
if (hoverId && st.hov > 0.02) {
const p = toScreen(hoverId[0] * CELL_W + GUT, (hoverId[1] + 1) * CELL_H - GUT);
const key = `${p.x.toFixed(1)}|${p.y.toFixed(1)}`;
if (key !== lastBadge) {
badge.style.transform = `translate3d(${p.x.toFixed(1)}px,${p.y.toFixed(1)}px,0)`;
lastBadge = key;
}
}
renderer.render(scene, camera);
};
gsap.ticker.add(tick);
// hover: lift the poster, pop the badge in with a squash
const setHover = (t: { ix: number; iy: number } | null) => {
const same = t && hoverId && t.ix === hoverId[0] && t.iy === hoverId[1];
if (same) return;
if (!t) {
st.thov = 0;
gsap.to(pop, { scale: 0, opacity: 0, duration: 0.18, ease: "power2.in", overwrite: true });
return;
}
hoverId = [t.ix, t.iy];
st.thov = 1;
// place it on its poster before it pops in (never a frame at the corner)
const p0 = toScreen(t.ix * CELL_W + GUT, (t.iy + 1) * CELL_H - GUT);
badge.style.transform = `translate3d(${p0.x.toFixed(1)}px,${p0.y.toFixed(1)}px,0)`;
lastBadge = "";
setTitle(posters[pickOf(t.ix, t.iy)]?.title ?? "");
if (!still)
gsap.fromTo(
pop,
{ scale: 0.3, opacity: 0 },
{ keyframes: [{ scaleX: 1.2, scaleY: 0.8, opacity: 1, duration: 0.14 }, { scaleX: 0.92, scaleY: 1.08, duration: 0.12 }, { scaleX: 1, scaleY: 1, duration: 0.4, ease: "elastic.out(1, 0.45)" }], overwrite: true },
);
else gsap.set(pop, { scale: 1, opacity: 1 });
};
// drag / fling
let sx = 0, sy = 0, ox = 0, oy = 0, moved = 0, id = -1, lt = 0, lpx = 0, lpy = 0;
const onDown = (e: PointerEvent) => {
if (e.button !== 0) return;
id = e.pointerId;
st.drag = true;
sx = lpx = e.clientX;
sy = lpy = e.clientY;
ox = st.x;
oy = st.y;
moved = 0;
lt = performance.now();
st.vx = st.vy = 0;
};
const onMove = (e: PointerEvent) => {
if (!st.drag || e.pointerId !== id) {
setHover(tileAt(e.clientX, e.clientY));
return;
}
const dx = e.clientX - sx, dy = e.clientY - sy;
moved = Math.max(moved, Math.hypot(dx, dy));
if (moved > 4) {
setHover(null);
if (!root.hasPointerCapture(e.pointerId)) {
try {
root.setPointerCapture(e.pointerId);
} catch {
/* capture is a nicety */
}
}
}
const per = st.scale / MIN; // grid units per px (centre of the dome)
st.x = ox - dx * per;
st.y = oy + dy * per;
const now = performance.now(), ddt = Math.max(1, now - lt) / 1000;
st.vx = st.vx * 0.5 + (-(e.clientX - lpx) * per / ddt) * 0.5;
st.vy = st.vy * 0.5 + ((e.clientY - lpy) * per / ddt) * 0.5;
lpx = e.clientX;
lpy = e.clientY;
lt = now;
};
const zoomTo = (ix: number, iy: number, inn: boolean) => {
zoomed = inn;
st.vx = st.vy = 0;
const tx = (ix + 0.5) * CELL_W, ty = (iy + 0.5) * CELL_H;
gsap.to(st, { x: tx, y: ty, scale: inn ? ZOOM_IN : ZOOM_OUT, duration: still ? 0 : 0.9, ease: inn ? "back.out(1.4)" : "power3.inOut", overwrite: true });
};
const onUp = (e: PointerEvent) => {
if (e.pointerId !== id) return;
id = -1;
if (!st.drag) return;
st.drag = false;
if (moved < 5) {
const t = tileAt(e.clientX, e.clientY);
if (zoomed) {
const p = posters[pickOf(t.ix, t.iy)];
if (p?.href) window.location.href = p.href;
else zoomTo(t.ix, t.iy, false);
} else zoomTo(t.ix, t.iy, true);
return;
}
const cap = 14;
st.vx = clamp(-cap, cap, st.vx);
st.vy = clamp(-cap, cap, st.vy);
if (zoomed) gsap.to(st, { scale: ZOOM_OUT, duration: 0.8, ease: "power3.out" }), (zoomed = false);
};
const onLeave = () => setHover(null);
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape" && zoomed) zoomTo(Math.floor(st.x / CELL_W), Math.floor(st.y / CELL_H), false);
const step = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] }[e.key];
if (step) {
e.preventDefault();
gsap.to(st, { x: st.x + step[0] * CELL_W, y: st.y + step[1] * CELL_H, duration: 0.5, ease: "power3.out" });
}
};
root.addEventListener("pointerdown", onDown);
root.addEventListener("pointermove", onMove);
root.addEventListener("pointerup", onUp);
root.addEventListener("pointercancel", onUp);
root.addEventListener("pointerleave", onLeave);
root.addEventListener("keydown", onKey);
return () => {
gsap.ticker.remove(tick);
gsap.killTweensOf(st);
gsap.killTweensOf(pop);
root.removeEventListener("pointerdown", onDown);
root.removeEventListener("pointermove", onMove);
root.removeEventListener("pointerup", onUp);
root.removeEventListener("pointercancel", onUp);
root.removeEventListener("pointerleave", onLeave);
root.removeEventListener("keydown", onKey);
tex.dispose();
mat.dispose();
quad.geometry.dispose();
renderer.dispose();
canvas.remove();
};
}, [W, height, n, posters, dome, background]);
// the badge scales with the wall
const badgeS = Math.round(clamp(22, 40, Math.min(W || height, height) * 0.075));
return (
<div
ref={rootRef}
tabIndex={0}
role="region"
aria-label="Poster wall"
className={["relative w-full cursor-grab touch-none overflow-hidden outline-none select-none active:cursor-grabbing", className].filter(Boolean).join(" ")}
style={{ height, background }}
>
<div ref={hostRef} aria-hidden="true" className="absolute inset-0" />
{/* the badge on the hovered poster */}
{/* the outer layer follows the poster; the inner one pops (two layers, so they never fight over transform) */}
<div ref={badgeRef} aria-hidden="true" className="pointer-events-none absolute top-0 left-0 will-change-transform">
<div ref={popRef} className="flex items-start gap-2 opacity-0" style={{ transformOrigin: "0 0", marginLeft: 10, marginTop: 10 }}>
<span className="grid shrink-0 place-items-center rounded-full text-[#0d0d0f] shadow-[0_6px_18px_rgba(0,0,0,.35)]" style={{ background: accent, width: badgeS, height: badgeS }}>
<svg viewBox="0 0 24 24" width={badgeS * 0.45} height={badgeS * 0.45} fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<path d="M5 12h13M13 6l6 6-6 6" />
</svg>
</span>
{title && <span className="max-w-[180px] rounded-md bg-black/55 px-2 py-1 leading-tight font-medium whitespace-nowrap text-white backdrop-blur-sm" style={{ fontSize: Math.max(9, badgeS * 0.3), marginTop: badgeS * 0.18 }}>{title}</span>}
</div>
</div>
</div>
);
}
export default PosterDome;
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 propsposters{ src: string; title?: string; href?: string }[]The images (they repeat across the endless wall).heightnumberHeight, px.default 520default 520domenumberHow strongly the wall bows (0 is flat).default 0.32default 0.32accentstringThe badge colour.default "#3cff7a"default "#3cff7a"backgroundstringBackground colour.default "#0d0d0f"default "#0d0d0f"classNamestringExtra classes.