← All components Next componentPhotographer Portfolio→
Sections · Grid
Acoustic Ripple Wall
A wall of perforated acoustic-felt tiles on invisible springs: your cursor sends radial waves through it, nearby tiles sink and lean towards it, the one under it lights up.
<AcousticRippleWall />Live
Move across the wall
Customize
Felt
Accent#f0abfc
Felt#25212f
Text#efeaf6
Installation
Use it in your project
Or skip the copy-paste
One command: writes the file and installs the dependencies.
$ npx deepui-cli add acoustic-ripple-wall
01
Install
The 3D packages this component is built on.
$ npm install three @react-three/fiber @react-three/drei && npm install -D @types/three
02
Add the component
One self-contained file: create components/AcousticRippleWall.tsx and paste it in.
components/AcousticRippleWall.tsx
1"use client";23import { useEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";4import * as THREE from "three";5import { RoundedBoxGeometry } from "three/examples/jsm/geometries/RoundedBoxGeometry.js";6import { Canvas, useFrame, useThree, type CanvasProps } from "@react-three/fiber";7import { Environment, Lightformer } from "@react-three/drei";89/**10 * The shared props API of DeepUI's individual 3D components (not the full-page templates, which keep11 * their own tailored scenes).12 *13 * The props are grouped by concern. A component extends ONLY the groups it really applies, so its14 * type never advertises a knob that does nothing (a card has no particles, a background has no tilt):15 *16 * interface MyCardProps extends CursorProps, TiltProps, MaterialProps, PerformanceProps { … }17 *18 * `Base3DComponentProps` is every group at once, for tooling that handles any component. Same name,19 * same unit and same meaning everywhere; the default values live in DEFAULT_3D_PROPS. These files are20 * inlined into each component's single-file bundle (lib/bundle-source.mjs), only what it uses.21 */2223/** Which rotation axes follow the pointer. "x-only": the object nods (up / down); "y-only": it turns (left / right). */24export type TiltAxis = "both" | "x-only" | "y-only" | "none";2526/** 1. Cursor: how the pointer pulls, pushes and drags the object. */27interface CursorProps {28 /** Reach of the pointer's influence, in the component's own space: CSS pixels for pixel-laid-out widgets, world units for 3D scenes (each component says which). Default 220 (px). */29 cursorRadius?: number;30 /** Positive pulls things towards the pointer, negative pushes them away (repulsion, shockwave). Default 1. */31 cursorForce?: number;32 /** How far the object slides towards the pointer, 0 (stays put) to 1 (follows closely). Default 0. */33 magneticStrength?: number;34 /** Share of the remaining distance the motion closes each frame (at 60 fps), 0.01 (heavy, slow) to 1 (instant). Default 0.1. */35 cursorDamping?: number;36}3738/** 2. Tilt and parallax: the object leans towards the pointer, its layers slide against each other. */39interface TiltProps {40 /** Largest lean towards the pointer, in degrees. Default 15. */41 maxTiltAngle?: number;42 /** Axes that follow the pointer. Default "both". */43 tiltAxis?: TiltAxis;44 /** Lean away from the pointer instead of towards it. Default false. */45 invertTilt?: boolean;46 /** How far apart the depth layers slide when the object tilts, 0 (flat) to 2. Default 1. */47 parallaxOffset?: number;48}4950/** 3. Text and 3D typography, for components that draw a label. */51interface Text3DProps {52 /** The label drawn by the component. */53 text?: string;54 /** Scale of the lettering. Default 1. */55 fontSize?: number;56 /** Extrusion depth of 3D letters. Default 0.2. */57 textDepth?: number;58 /** Bevelled, light-catching edges on 3D letters. Default true. */59 bevelEnabled?: boolean;60 /** Custom font: a .woff / .ttf (flat text) or a typeface .json (extruded text). */61 fontUrl?: string;62}6364/** 4. Rendering, materials and glow. */65interface MaterialProps {66 /** Main color of the object. Default "#6366f1". */67 primaryColor?: string;68 /** Color of the glow. Default "#00f0ff". */69 emissiveColor?: string;70 /** Strength of the glow, 0 (none) to 3. Default 1. */71 emissiveIntensity?: number;72 /** 0 (mirror, glass) to 1 (matte). Default 0.3. */73 roughness?: number;74 /** 0 (plastic, organic) to 1 (metal). Default 0.5. */75 metalness?: number;76 /** 0 (opaque) to 1 (clear glass): see-through, refracting surfaces. Default 0. */77 transmission?: number;78 /** Technical wireframe rendering. Default false. */79 wireframe?: boolean;80}8182/** 5. Particles, idle motion and shader animation. */83interface MotionProps {84 /** Number of instanced elements. Default depends on the component. */85 particleCount?: number;86 /** Spin on its own, in radians per second (negative: the other way; 0.5 ≈ one turn in 12 s). Default 0. */87 autoRotateSpeed?: number;88 /** Pulses or ripples per second. Default 1. */89 pulseRate?: number;90 /** Amplitude of the noise deformation, 0 (none) to 2. Default 1. */91 displacementScale?: number;92}9394/** 6. Environment and camera. */95interface EnvironmentProps {96 /** Camera field of view, in degrees. Default depends on the component. */97 cameraFov?: number;98 /** Color of the depth fog. Default "#0a0a0a". */99 fogColor?: string;100 /** Thickness of the fog, 0 (none) to 0.2. Default 0. */101 fogDensity?: number;102}103104/** 7. Performance and accessibility. */105interface PerformanceProps {106 /** Lighter rendering for weak devices: pixel ratio 1, fewer instances, smaller environment maps. Default false. */107 lowPowerMode?: boolean;108 /** Under the OS "reduce motion" setting, stop idle spin, pulses and deformation (pointer feedback stays). Default true. */109 respectReducedMotion?: boolean;110 /** Stop the render loop while the component is scrolled out of view. Default true. */111 pauseWhenOffscreen?: boolean;112}113114/** Every group at once. Components extend only the groups they apply (see the top of this file). */115interface Base3DComponentProps116 extends CursorProps,117 TiltProps,118 Text3DProps,119 MaterialProps,120 MotionProps,121 EnvironmentProps,122 PerformanceProps {}123124type Defaults = Required<Omit<Base3DComponentProps, "text" | "fontUrl" | "particleCount" | "cameraFov">>;125126/** The values a prop takes when it is left out. A component may override one, and then documents it. */127const DEFAULT_3D_PROPS: Defaults = {128 cursorRadius: 220,129 cursorForce: 1,130 magneticStrength: 0,131 cursorDamping: 0.1,132 maxTiltAngle: 15,133 tiltAxis: "both",134 invertTilt: false,135 parallaxOffset: 1,136 fontSize: 1,137 textDepth: 0.2,138 bevelEnabled: true,139 primaryColor: "#6366f1",140 emissiveColor: "#00f0ff",141 emissiveIntensity: 1,142 roughness: 0.3,143 metalness: 0.5,144 transmission: 0,145 wireframe: false,146 autoRotateSpeed: 0,147 pulseRate: 1,148 displacementScale: 1,149 fogColor: "#0a0a0a",150 fogDensity: 0,151 lowPowerMode: false,152 respectReducedMotion: true,153 pauseWhenOffscreen: true,154};155156/** True under 768px: scenes recompose (camera farther, layouts in columns). */157function useIsMobile() {158 const [mobile, setMobile] = useState(false);159 useEffect(() => {160 const query = window.matchMedia("(max-width: 767px)");161 const sync = () => setMobile(query.matches);162 sync();163 query.addEventListener("change", sync);164 return () => query.removeEventListener("change", sync);165 }, []);166 return mobile;167}168169function usePrefersReducedMotion() {170 const [reduced, setReduced] = useState(false);171 useEffect(() => {172 const query = window.matchMedia("(prefers-reduced-motion: reduce)");173 const sync = () => setReduced(query.matches);174 sync();175 query.addEventListener("change", sync);176 return () => query.removeEventListener("change", sync);177 }, []);178 return reduced;179}180181/** Pointer over an element, in -1..1 (y up), through window listeners (no re-render). */182function usePointer(target: RefObject<HTMLElement | null>) {183 const pointer = useRef({ x: 0, y: 0, inside: false });184 useEffect(() => {185 const move = (event: PointerEvent) => {186 const el = target.current;187 if (!el) return;188 const r = el.getBoundingClientRect();189 const p = pointer.current;190 p.x = ((event.clientX - r.left) / r.width) * 2 - 1;191 p.y = -(((event.clientY - r.top) / r.height) * 2 - 1);192 p.inside = Math.abs(p.x) <= 1 && Math.abs(p.y) <= 1;193 };194 window.addEventListener("pointermove", move, { passive: true });195 return () => window.removeEventListener("pointermove", move);196 }, [target]);197 return pointer;198}199200/**201 * Keeps the camera's view wide enough for content `width` world units across (portrait screens get a202 * farther camera instead of cropped sides). Call inside the Canvas.203 */204function FitWidth({ width, distance, target = [0, 0, 0] }: { width: number; distance: number; target?: [number, number, number] }) {205 const camera = useThree((s) => s.camera) as THREE.PerspectiveCamera;206 const size = useThree((s) => s.size);207 useEffect(() => {208 const aspect = size.width / Math.max(size.height, 1);209 const halfFov = THREE.MathUtils.degToRad(camera.fov / 2);210 // Distance at which `width` fits horizontally, never closer than the requested distance211 const needed = width / 2 / (Math.tan(halfFov) * aspect);212 const dir = camera.position.clone().sub(new THREE.Vector3(...target)).normalize();213 camera.position.copy(new THREE.Vector3(...target).addScaledVector(dir, Math.max(distance, needed)));214 camera.lookAt(...target);215 camera.updateProjectionMatrix();216 }, [camera, size, width, distance, target]);217 return null;218}219220/**221 * The <Canvas> frameloop for `pauseWhenOffscreen`: "never" while the element is out of view. Put the ref222 * on the element that wraps the canvas (outside it: this hook runs in the component, not in the scene).223 */224function useOffscreenFrameloop(ref: RefObject<HTMLElement | null>, pauseWhenOffscreen: boolean = DEFAULT_3D_PROPS.pauseWhenOffscreen): "always" | "never" {225 // In view at first: some WebGL backends show an opaque canvas if it is paused before its first frame226 const [inView, setInView] = useState(true);227 useEffect(() => {228 const el = ref.current;229 if (!el || !pauseWhenOffscreen) return undefined;230 const observer = new IntersectionObserver(([entry]) => setInView(entry.isIntersecting));231 observer.observe(el);232 return () => observer.disconnect();233 }, [ref, pauseWhenOffscreen]);234 return !pauseWhenOffscreen || inView ? "always" : "never";235}236237// Shared by the testimonial sections: the testimonial shape, the common props and sample content.238239interface TestimonialItem {240 id: string;241 author: string;242 role: string;243 company: string;244 quote: string;245 /** 0 to 5 stars. */246 rating?: number;247 /** A result worth highlighting, e.g. "+140% conversion". */248 highlightMetric?: string;249}250251interface DeepTestimonialProps {252 /** The testimonials, in order. */253 items: TestimonialItem[];254 /** Pointer, drag, swipe and tilt. Default true. */255 interactive?: boolean;256 /**257 * Each section has its own material (holographic foil, porcelain, acoustic felt, obsidian): "glass" is its258 * translucent version, "solid" its opaque one. The default depends on the section.259 */260 variant?: "glass" | "solid";261 /** Speed of the motion (rotation, scrolling, idle float). Default 1. */262 speed?: number;263 /** Color of the highlights, of the active card's border and of the card details. Default "#a78bfa". */264 accentColor?: string;265 /** Base color of the cards' material (foil, porcelain, felt, stone). The default depends on the section. */266 surfaceColor?: string;267 /** Color of the quotes and names. The default depends on the section (dark ink on porcelain, light elsewhere). */268 textColor?: string;269 /** Extra classes for the section. */270 className?: string;271}272273const TESTIMONIAL_DEFAULTS = {274 interactive: true,275 variant: "glass",276 speed: 1,277 accentColor: "#a78bfa",278} as const;279280// Small pieces of the testimonial cards, shared by every section (no 3D dependency).281282/** Five stars, `rating` of them filled. */283function Stars({ rating, color, size = 13, empty = "rgba(255,255,255,0.18)" }: { rating: number; color: string; size?: number; empty?: string }) {284 const full = Math.max(0, Math.min(5, Math.round(rating)));285 return (286 <span className="flex gap-0.5" role="img" aria-label={`${full} out of 5 stars`}>287 {Array.from({ length: 5 }, (_, i) => (288 <svg key={i} viewBox="0 0 20 20" width={size} height={size} aria-hidden="true" style={{ fill: i < full ? color : empty }}>289 <path d="M10 1.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L10 14.8l-5.2 2.8 1-5.8L1.5 7.7l5.9-.8z" />290 </svg>291 ))}292 </span>293 );294}295296/** "AB" from "Ada Byron". */297function initials(name: string) {298 return name299 .split(/\s+/)300 .filter(Boolean)301 .slice(0, 2)302 .map((part) => part[0]?.toUpperCase() ?? "")303 .join("");304}305306/** `color` at `percent`% opacity, for any CSS color. */307function fade(color: string, percent: number) {308 return `color-mix(in srgb, ${color} ${percent}%, transparent)`;309}310311// Building blocks of the testimonial sections. The quotes are real HTML of the section, laid in 3D over312// the canvas (see the card layer below): crisp on any screen, selectable, read by screen readers and313// indexed, and present even before WebGL has started.314315/** CSS size of a card's HTML. Its 3D slab has the same proportions. */316const CARD_PX = { width: 360, height: 236 };317318const CARD_ASPECT = CARD_PX.height / CARD_PX.width;319320type Variant = NonNullable<DeepTestimonialProps["variant"]>;321322function isTouchDevice() {323 return typeof window !== "undefined" && window.matchMedia("(pointer: coarse)").matches;324}325326interface TestimonialCanvasProps extends Omit<CanvasProps, "children" | "style" | "gl" | "frameloop" | "dpr"> {327 children: ReactNode;328}329330/**331 * Canvas filling its positioned parent: pixel ratio capped (1.5 on touch screens), render loop paused332 * off-screen. The canvas itself ignores the pointer; the cards (HTML) and the section handle it.333 */334function TestimonialCanvas({ children, ...canvasProps }: TestimonialCanvasProps) {335 const ref = useRef<HTMLDivElement>(null);336 const frameloop = useOffscreenFrameloop(ref, true);337 const [touch] = useState(isTouchDevice);338 return (339 <div ref={ref} className="absolute inset-0">340 <Canvas341 dpr={[1, touch ? 1.5 : 2]}342 frameloop={frameloop}343 gl={{ antialias: !touch, alpha: true, powerPreference: "high-performance" }}344 style={{ pointerEvents: "none" }}345 {...canvasProps}346 >347 {children}348 </Canvas>349 </div>350 );351}352353/** Procedural studio lighting (no HDR file): soft key, two strip lights, one in the accent color. */354function StudioLights({ accent }: { accent: string }) {355 return (356 <>357 <ambientLight intensity={0.35} />358 <directionalLight position={[3, 5, 6]} intensity={1.4} />359 <Environment resolution={256} frames={1}>360 <Lightformer form="rect" intensity={2.2} position={[0, 6, 4]} rotation-x={-Math.PI / 3} scale={[12, 3, 1]} />361 <Lightformer form="rect" intensity={3} color={accent} position={[-7, 1, 2]} rotation-y={Math.PI / 2} scale={[10, 1.2, 1]} />362 <Lightformer form="rect" intensity={1.6} position={[7, -1, 3]} rotation-y={-Math.PI / 2} scale={[10, 1, 1]} />363 <Lightformer form="ring" intensity={1.2} color={accent} position={[0, 0, -6]} scale={4} />364 </Environment>365 </>366 );367}368369/** Bends a geometry around the Y axis (radius > 0, convex side towards +Z). */370function bend(geometry: THREE.BufferGeometry, radius: number) {371 const pos = geometry.attributes.position as THREE.BufferAttribute;372 for (let i = 0; i < pos.count; i++) {373 const x = pos.getX(i);374 const z = pos.getZ(i);375 const a = x / radius;376 const r = radius + z;377 pos.setXYZ(i, Math.sin(a) * r, pos.getY(i), Math.cos(a) * r - radius);378 }379 geometry.computeVertexNormals();380 return geometry;381}382383function roundedRect(width: number, height: number, radius: number) {384 const shape = new THREE.Shape();385 const w = width / 2;386 const h = height / 2;387 const r = Math.min(radius, w, h);388 shape.moveTo(-w + r, -h);389 shape.lineTo(w - r, -h);390 shape.quadraticCurveTo(w, -h, w, -h + r);391 shape.lineTo(w, h - r);392 shape.quadraticCurveTo(w, h, w - r, h);393 shape.lineTo(-w + r, h);394 shape.quadraticCurveTo(-w, h, -w, h - r);395 shape.lineTo(-w, -h + r);396 shape.quadraticCurveTo(-w, -h, -w + r, -h);397 return shape;398}399400/** Imperative handle of a slab: fade and highlight it from useFrame, without re-rendering. */401interface SlabHandle {402 group: THREE.Group | null;403 /** 0 (invisible) to 1. */404 setOpacity: (opacity: number) => void;405 /** 0 to 1: glow of the accent border. */406 setHighlight: (amount: number) => void;407}408409/**410 * The material family of a slab. Each section has its own:411 * - "porcelain": frosted white acrylic (glass) or glazed porcelain (solid), for dark ink text.412 * - "felt": perforated acoustic felt, behind a thin glass sheet (glass) or bare (solid).413 */414type Finish = "porcelain" | "felt";415416/** Fibers and a grid of perforations, as a bump map (1 world unit per repeat). */417function feltTexture() {418 const size = 256;419 const canvas = document.createElement("canvas");420 canvas.width = canvas.height = size;421 const ctx = canvas.getContext("2d");422 if (ctx) {423 ctx.fillStyle = "#808080";424 ctx.fillRect(0, 0, size, size);425 // Short random fibers426 for (let i = 0; i < 2600; i++) {427 const x = Math.random() * size;428 const y = Math.random() * size;429 const a = Math.random() * Math.PI;430 const l = 2 + Math.random() * 6;431 const shade = 100 + Math.random() * 70;432 ctx.strokeStyle = `rgba(${shade},${shade},${shade},0.55)`;433 ctx.lineWidth = 0.6;434 ctx.beginPath();435 ctx.moveTo(x, y);436 ctx.lineTo(x + Math.cos(a) * l, y + Math.sin(a) * l);437 ctx.stroke();438 }439 // Perforations: 8 per world unit440 const step = size / 8;441 for (let gx = 0; gx < 8; gx++) {442 for (let gy = 0; gy < 8; gy++) {443 const g = ctx.createRadialGradient(gx * step + step / 2, gy * step + step / 2, 0, gx * step + step / 2, gy * step + step / 2, step * 0.2);444 g.addColorStop(0, "#000000");445 g.addColorStop(0.75, "#202020");446 g.addColorStop(1, "rgba(128,128,128,0)");447 ctx.fillStyle = g;448 ctx.beginPath();449 ctx.arc(gx * step + step / 2, gy * step + step / 2, step * 0.2, 0, Math.PI * 2);450 ctx.fill();451 }452 }453 }454 const texture = new THREE.CanvasTexture(canvas);455 texture.wrapS = texture.wrapT = THREE.RepeatWrapping;456 texture.colorSpace = THREE.NoColorSpace;457 return texture;458}459460interface SlabMaterials {461 body: THREE.MeshPhysicalMaterial;462 face: THREE.MeshPhysicalMaterial;463 faceOpacity: number;464 textures: THREE.Texture[];465}466467function slabMaterials(finish: Finish, variant: Variant, surface: string): SlabMaterials {468 const glass = variant === "glass";469 const tint = new THREE.Color(surface);470471 if (finish === "porcelain") {472 const body = glass473 ? new THREE.MeshPhysicalMaterial({ color: tint, transmission: 0.85, thickness: 0.6, roughness: 0.5, ior: 1.45, clearcoat: 0.4, transparent: true })474 : new THREE.MeshPhysicalMaterial({ color: tint, roughness: 0.3, clearcoat: 0.9, clearcoatRoughness: 0.18, transparent: true });475 const face = new THREE.MeshPhysicalMaterial({ color: tint, roughness: glass ? 0.62 : 0.48, clearcoat: glass ? 0 : 0.5, clearcoatRoughness: 0.3, transparent: true, opacity: glass ? 0.82 : 1 });476 return { body, face, faceOpacity: glass ? 0.82 : 1, textures: [] };477 }478479 const bump = feltTexture();480 const sheen = tint.clone().lerp(new THREE.Color("#ffffff"), 0.35);481 const felt = () => new THREE.MeshPhysicalMaterial({ color: tint, roughness: 1, metalness: 0, sheen: 1, sheenRoughness: 0.65, sheenColor: sheen, bumpMap: bump, bumpScale: 1.4, transparent: true });482 const body = felt();483 // Glass: a thin clear sheet over the felt; solid: the felt itself, perforations and all484 const face = glass485 ? new THREE.MeshPhysicalMaterial({ color: "#ffffff", transmission: 1, thickness: 0.08, roughness: 0.04, ior: 1.5, clearcoat: 1, clearcoatRoughness: 0.03, transparent: true })486 : felt();487 return { body, face, faceOpacity: 1, textures: [bump] };488}489490interface SlabProps {491 width: number;492 /** Width / height ratio of the HTML card it carries. Default CARD_ASPECT. */493 aspect?: number;494 finish: Finish;495 variant: Variant;496 /** Base color of the material (porcelain, felt). */497 surface: string;498 accent: string;499 /** Thickness, world units. Default 0.14. */500 depth?: number;501 /** Bend radius (a slab cut from a cylinder). 0 = flat. */502 curve?: number;503 handle: (api: SlabHandle) => void;504 children?: ReactNode;505}506507/** A card's 3D body, in one of the material families above. An accent border glows when highlighted. */508function Slab({ width, aspect = CARD_ASPECT, finish, variant, surface, accent, depth = 0.14, curve = 0, handle, children }: SlabProps) {509 const height = width * aspect;510 const radius = Math.min(width, height) * 0.08;511512 const geometries = useMemo(() => {513 const body = curve > 0 ? bend(new THREE.BoxGeometry(width, height, depth, 32, 1, 1), curve) : new RoundedBoxGeometry(width, height, depth, 4, radius);514 if (curve > 0) {515 // Enough columns to follow the bend516 const flat = new THREE.PlaneGeometry(width - depth * 0.9, height - depth * 0.9, 32, 1);517 flat.translate(0, 0, depth / 2 + 0.004);518 bend(flat, curve);519 return { body, face: flat, rim: bend(new THREE.BoxGeometry(width * 1.03, height * 1.05, depth * 0.6, 32, 1, 1), curve) };520 }521 const face = new THREE.ShapeGeometry(roundedRect(width - depth * 0.9, height - depth * 0.9, radius * 0.8), 12);522 face.translate(0, 0, depth / 2 + 0.004);523 const rim = new THREE.ShapeGeometry(roundedRect(width * 1.035, height * 1.05, radius * 1.1), 12);524 rim.translate(0, 0, -depth / 2 - 0.004);525 return { body, face, rim };526 }, [width, height, depth, radius, curve]);527528 const materials = useMemo(() => {529 const set = slabMaterials(finish, variant, surface);530 const rim = new THREE.MeshBasicMaterial({ color: accent, transparent: true, opacity: 0, toneMapped: false, depthWrite: false });531 return { ...set, rim };532 }, [finish, variant, surface, accent]);533534 useEffect(() => () => Object.values(geometries).forEach((g) => g.dispose()), [geometries]);535 useEffect(536 () => () => {537 materials.body.dispose();538 materials.face.dispose();539 materials.rim.dispose();540 materials.textures.forEach((t) => t.dispose());541 },542 [materials]543 );544545 const group = useRef<THREE.Group>(null);546 const opacity = useRef(1);547 const highlight = useRef(0);548 useEffect(() => {549 const apply = () => {550 const o = opacity.current;551 materials.body.opacity = o;552 materials.face.opacity = materials.faceOpacity * o;553 materials.rim.opacity = highlight.current * 0.85 * o;554 if (group.current) group.current.visible = o > 0.01;555 };556 handle({557 get group() {558 return group.current;559 },560 setOpacity(value) {561 if (Math.abs(value - opacity.current) < 0.002) return;562 opacity.current = value;563 apply();564 },565 setHighlight(value) {566 if (Math.abs(value - highlight.current) < 0.002) return;567 highlight.current = value;568 apply();569 },570 });571 apply();572 }, [handle, materials]);573574 return (575 <group ref={group}>576 <mesh geometry={geometries.rim} material={materials.rim} renderOrder={0} />577 <mesh geometry={geometries.body} material={materials.body} renderOrder={1} />578 <mesh geometry={geometries.face} material={materials.face} renderOrder={2} />579 {children}580 </group>581 );582}583584/** The card layouts, one per material family. */585type CardTheme = "porcelain" | "felt";586587/** Default text color of each layout. */588const CARD_TEXT: Record<CardTheme, string> = { porcelain: "#17151d", felt: "#efeaf6" };589590interface TestimonialCardProps {591 item: TestimonialItem;592 accent: string;593 theme: CardTheme;594 /** Text color. Default: CARD_TEXT[theme]. */595 text?: string;596}597598const figureStyle = { width: CARD_PX.width, height: CARD_PX.height, backfaceVisibility: "hidden", WebkitBackfaceVisibility: "hidden" } as const;599600/** The quote as semantic HTML: a figure with a blockquote and its attribution. */601function TestimonialCard({ item, accent, theme, text = CARD_TEXT[theme] }: TestimonialCardProps) {602 if (theme === "porcelain") {603 // Editorial: dark ink on white, a large accent quote mark, an initials badge604 return (605 <figure className="relative m-0 flex flex-col overflow-hidden text-left" style={{ ...figureStyle, color: text, padding: "18px 24px 20px" }}>606 <div className="flex items-start justify-between">607 <span aria-hidden="true" className="font-serif text-[52px] leading-[0.8]" style={{ color: accent }}>608 “609 </span>610 {item.highlightMetric ? (611 <span className="mt-1 rounded-md px-2 py-1 font-mono text-[10px] font-semibold uppercase tracking-[0.1em]" style={{ background: fade(text, 6), color: fade(text, 70) }}>612 {item.highlightMetric}613 </span>614 ) : null}615 </div>616 <blockquote className="m-0 mt-1 line-clamp-4 font-serif text-[16px] leading-[1.42]" style={{ color: fade(text, 90) }}>617 {item.quote}618 </blockquote>619 <figcaption className="mt-auto flex items-center gap-3">620 <span aria-hidden="true" className="grid size-8 shrink-0 place-items-center rounded-full text-[11px] font-semibold text-white" style={{ background: `linear-gradient(135deg, ${accent}, ${text})` }}>621 {initials(item.author)}622 </span>623 <span className="flex min-w-0 flex-col">624 <span className="text-[13px] font-semibold">{item.author}</span>625 <span className="truncate text-[11px]" style={{ color: fade(text, 55) }}>626 {item.role} · {item.company}627 </span>628 </span>629 {item.rating !== undefined ? (630 <span className="ml-auto">631 <Stars rating={item.rating} color={text} size={11} empty={fade(text, 15)} />632 </span>633 ) : null}634 </figcaption>635 </figure>636 );637 }638639 // Felt: quiet and centered, the metric as an eyebrow, the quote, the name640 return (641 <figure className="m-0 flex flex-col items-center justify-center overflow-hidden text-center" style={{ ...figureStyle, color: text, padding: "20px 26px" }}>642 {item.highlightMetric ? (643 <span className="font-mono text-[10px] uppercase tracking-[0.28em]" style={{ color: accent }}>644 {item.highlightMetric}645 </span>646 ) : null}647 <blockquote className="m-0 mt-3 line-clamp-4 text-[15px] font-light leading-[1.5]" style={{ color: fade(text, 90) }}>648 “{item.quote}”649 </blockquote>650 <figcaption className="mt-4 flex flex-col items-center gap-1">651 <span className="text-[12px] font-medium tracking-[0.04em]">652 {item.author} <span style={{ color: fade(text, 45) }}>— {item.company}</span>653 </span>654 {item.rating !== undefined ? <Stars rating={item.rating} color={accent} size={10} empty={fade(text, 18)} /> : null}655 </figcaption>656 </figure>657 );658}659660// The cards are ordinary DOM elements of the section (same React tree, server-friendly, no portal), laid661// in 3D with CSS: a "camera" element reproduces the WebGL camera (perspective + inverse view matrix)662// and each card takes the world matrix of an anchor object in the scene, like three's CSS3DRenderer.663// The anchors are scaled so a card spans its slab.664665interface CardLayer {666 view: RefObject<HTMLDivElement | null>;667 camera: RefObject<HTMLDivElement | null>;668 anchors: RefObject<(THREE.Object3D | null)[]>;669 elements: RefObject<(HTMLDivElement | null)[]>;670}671672function useCardLayer(): CardLayer {673 const view = useRef<HTMLDivElement>(null);674 const camera = useRef<HTMLDivElement>(null);675 const anchors = useRef<(THREE.Object3D | null)[]>([]);676 const elements = useRef<(HTMLDivElement | null)[]>([]);677 return useMemo(() => ({ view, camera, anchors, elements }), []);678}679680/** Where card `index` lies in the scene: put it inside the card's group, just in front of its slab. */681function CardAnchor({ layer, index, width, z, px = CARD_PX.width }: { layer: CardLayer; index: number; width: number; z: number; px?: number }) {682 return (683 <group684 ref={(object) => {685 layer.anchors.current[index] = object;686 }}687 position={[0, 0, z]}688 scale={width / px}689 />690 );691}692693const cssNumber = (v: number) => (Math.abs(v) < 1e-10 ? 0 : v);694695// The layer measures the world in CSS pixels (WORLD_PX per world unit) so the cards keep a transform scale696// close to 1: at a tiny scale (1 px per unit), Chromium rasterizes the text far from its layout box.697// Scaling the whole view space does not change the perspective projection.698const WORLD_PX = 150;699700function cameraCss(m: THREE.Matrix4) {701 const e = m.elements;702 const k = WORLD_PX;703 const f = [e[0], -e[1], e[2], e[3], e[4], -e[5], e[6], e[7], e[8], -e[9], e[10], e[11], e[12] * k, -e[13] * k, e[14] * k, e[15]];704 return `matrix3d(${f.map(cssNumber).join(",")})`;705}706707function objectCss(m: THREE.Matrix4) {708 const e = m.elements;709 const k = WORLD_PX;710 const f = [e[0] * k, e[1] * k, e[2] * k, e[3], -e[4] * k, -e[5] * k, -e[6] * k, -e[7], e[8] * k, e[9] * k, e[10] * k, e[11], e[12] * k, e[13] * k, e[14] * k, e[15]];711 return `translate(-50%,-50%)matrix3d(${f.map(cssNumber).join(",")})`;712}713714/** Inside the Canvas, after the scene: copies the camera and the anchors onto the card layer every frame. */715function CardLayerSync({ layer }: { layer: CardLayer }) {716 const last = useRef({ perspective: -1, width: -1, height: -1 });717 useFrame(({ camera, size }) => {718 const view = layer.view.current;719 const cam = layer.camera.current;720 if (!view || !cam) return;721 const perspective = (camera as THREE.PerspectiveCamera).projectionMatrix.elements[5] * 0.5 * size.height;722 const l = last.current;723 if (l.perspective !== perspective) {724 view.style.perspective = `${perspective}px`;725 view.style.visibility = "visible";726 l.perspective = perspective;727 }728 if (l.width !== size.width || l.height !== size.height) {729 cam.style.width = `${size.width}px`;730 cam.style.height = `${size.height}px`;731 l.width = size.width;732 l.height = size.height;733 }734 camera.updateMatrixWorld();735 cam.style.transform = `translateZ(${perspective}px)${cameraCss(camera.matrixWorldInverse)}translate(${size.width / 2}px,${size.height / 2}px)`;736 layer.anchors.current.forEach((anchor, i) => {737 const el = layer.elements.current[i];738 if (!anchor || !el) return;739 anchor.updateWorldMatrix(true, false);740 el.style.transform = objectCss(anchor.matrixWorld);741 });742 });743 return null;744}745746/** The DOM side of the layer, over the canvas. Its cards are LayerCards. */747function CardLayerView({ layer, children }: { layer: CardLayer; children: ReactNode }) {748 return (749 // Hidden until the first frame has placed the cards (before that they would pile up in a corner)750 <div ref={layer.view} className="pointer-events-none absolute inset-0 overflow-hidden" style={{ visibility: "hidden" }}>751 <div ref={layer.camera} className="absolute left-0 top-0" style={{ transformStyle: "preserve-3d" }}>752 {children}753 </div>754 </div>755 );756}757758interface LayerCardProps extends Partial<TestimonialCardProps> {759 layer: CardLayer;760 index: number;761 /** A repeated copy (rings, ribbons): hidden from screen readers so each quote is read once. */762 duplicate?: boolean;763 onSelect?: () => void;764 onHover?: (hovered: boolean) => void;765 /** A card of your own instead of TestimonialCard (the anchor's `px` must match its width). */766 children?: ReactNode;767}768769/** One card of the layer, placed every frame on its anchor. */770function LayerCard({ layer, index, duplicate = false, onSelect, onHover, children, ...card }: LayerCardProps) {771 return (772 <div773 ref={(el) => {774 layer.elements.current[index] = el;775 }}776 aria-hidden={duplicate ? true : undefined}777 className="absolute left-0 top-0 rounded-2xl outline-none focus-visible:ring-2 focus-visible:ring-white/70"778 style={{ pointerEvents: onSelect || onHover ? "auto" : "none", cursor: onSelect ? "pointer" : undefined, transformStyle: "preserve-3d", willChange: "transform" }}779 role={onSelect ? "button" : undefined}780 tabIndex={onSelect && !duplicate ? 0 : undefined}781 onClick={onSelect}782 onKeyDown={783 onSelect784 ? (event) => {785 if (event.key === "Enter" || event.key === " ") {786 event.preventDefault();787 onSelect();788 }789 }790 : undefined791 }792 onPointerEnter={onHover ? () => onHover(true) : undefined}793 onPointerLeave={onHover ? () => onHover(false) : undefined}794 >795 {children ?? (card.item && card.accent && card.theme ? <TestimonialCard item={card.item} accent={card.accent} theme={card.theme} text={card.text} /> : null)}796 </div>797 );798}799800export type AcousticRippleWallProps = DeepTestimonialProps;801802const TILE_W = 2.4;803const TILE_H = TILE_W * CARD_ASPECT;804const GAP = 0.1; // micro-gaps between the tiles805const MAX_TILES = 9;806const MAX_RIPPLES = 6;807const WAVE_SPEED = 3.2; // world units per second at speed 1808809interface Tile {810 x: number;811 y: number;812 z: number;813 vz: number;814 rx: number;815 vrx: number;816 ry: number;817 vry: number;818 glow: number;819}820821interface Ripple {822 x: number;823 y: number;824 age: number;825}826827function layout(count: number, columns: number) {828 const rows = Math.ceil(count / columns);829 return Array.from({ length: count }, (_, i) => {830 const row = Math.floor(i / columns);831 // The last row is centered when it is not full832 const inRow = row === rows - 1 ? count - row * columns : columns;833 const col = i % columns;834 return {835 x: (col - (inRow - 1) / 2) * (TILE_W + GAP),836 y: ((rows - 1) / 2 - row) * (TILE_H + GAP),837 };838 });839}840841/** Damped spring step (semi-implicit Euler). */842function spring(value: number, velocity: number, target: number, stiffness: number, damping: number, dt: number): [number, number] {843 const v = velocity + (stiffness * (target - value) - damping * velocity) * dt;844 return [value + v * dt, v];845}846847interface WallProps {848 items: TestimonialItem[];849 columns: number;850 variant: Variant;851 surface: string;852 accent: string;853 speed: number;854 interactive: boolean;855 still: boolean;856 pointer: RefObject<{ x: number; y: number; inside: boolean }>;857 layer: CardLayer;858}859860function Wall({ items, columns, variant, surface, accent, speed, interactive, still, pointer, layer }: WallProps) {861 const n = items.length;862 const homes = useMemo(() => layout(n, columns), [n, columns]);863 const tiles = useRef<Tile[]>([]);864 const groups = useRef<(THREE.Group | null)[]>([]);865 const slabs = useRef<(SlabHandle | null)[]>([]);866 const ripples = useRef<Ripple[]>([]);867 const last = useRef({ tile: -1, x: 0, y: 0 });868 const camera = useThree((s) => s.camera);869 const scratch = useMemo(() => ({ raycaster: new THREE.Raycaster(), plane: new THREE.Plane(new THREE.Vector3(0, 0, 1), 0), hit: new THREE.Vector3(), ndc: new THREE.Vector2() }), []);870871 const bindings = useMemo(872 () =>873 items.map((_, i) => ({874 group: (g: THREE.Group | null) => {875 groups.current[i] = g;876 },877 slab: (api: SlabHandle) => {878 slabs.current[i] = api;879 },880 })),881 [items]882 );883884 useFrame((state, delta) => {885 const dt = Math.min(delta, 1 / 30);886 const ptr = pointer.current;887888 // Pointer on the wall plane889 let px = 1e6;890 let py = 1e6;891 let under = -1;892 if (interactive && ptr.inside) {893 scratch.ndc.set(ptr.x, ptr.y);894 scratch.raycaster.setFromCamera(scratch.ndc, camera);895 if (scratch.raycaster.ray.intersectPlane(scratch.plane, scratch.hit)) {896 px = scratch.hit.x;897 py = scratch.hit.y;898 under = homes.findIndex((h) => Math.abs(px - h.x) <= TILE_W / 2 && Math.abs(py - h.y) <= TILE_H / 2);899 }900 }901902 // A ripple starts each time the pointer enters a tile or travels far enough903 const l = last.current;904 if (px < 1e5 && (under !== l.tile || Math.hypot(px - l.x, py - l.y) > 1.1)) {905 ripples.current.push({ x: px, y: py, age: 0 });906 if (ripples.current.length > MAX_RIPPLES) ripples.current.shift();907 l.x = px;908 l.y = py;909 }910 l.tile = under;911 const waveSpeed = WAVE_SPEED * Math.max(speed, 0.1);912 ripples.current.forEach((r) => {913 r.age += dt;914 });915 ripples.current = ripples.current.filter((r) => r.age < 3.5);916917 for (let i = 0; i < n; i++) {918 const home = homes[i];919 const t = (tiles.current[i] ??= { x: home.x, y: home.y, z: 0, vz: 0, rx: 0, vrx: 0, ry: 0, vry: 0, glow: 0 });920921 // Pressure under the pointer: the near tiles sink and lean towards it922 const dx = px - home.x;923 const dy = py - home.y;924 const d = Math.hypot(dx, dy);925 const press = px < 1e5 ? Math.exp(-(d * d) / 6) : 0;926 let zTarget = -0.45 * press;927 const rxTarget = press * THREE.MathUtils.clamp(-dy * 0.22, -0.3, 0.3);928 const ryTarget = press * THREE.MathUtils.clamp(dx * 0.22, -0.3, 0.3);929930 // Radial waves: a ring travelling out from each ripple's origin, fading with age and distance931 let wave = 0;932 for (const r of ripples.current) {933 const dist = Math.hypot(home.x - r.x, home.y - r.y);934 const front = r.age * waveSpeed - dist;935 if (front < 0) continue;936 wave += Math.sin(front * 2.4) * Math.exp(-front * 0.9) * Math.exp(-r.age * 0.9) * 0.3;937 }938 if (!still) {939 zTarget += wave;940 zTarget += Math.sin(state.clock.elapsedTime * 0.8 * speed + i * 0.9) * 0.015;941 }942943 // Hidden springs on Z (and on the tilt): the tiles bounce back on their own944 for (let k = 0; k < 2; k++) {945 [t.z, t.vz] = spring(t.z, t.vz, zTarget, 140, 11, dt / 2);946 [t.rx, t.vrx] = spring(t.rx, t.vrx, rxTarget, 90, 12, dt / 2);947 [t.ry, t.vry] = spring(t.ry, t.vry, ryTarget, 90, 12, dt / 2);948 }949 t.glow = THREE.MathUtils.damp(t.glow, i === under ? 1 : Math.min(Math.abs(wave) * 2.5, 0.5), 8, dt);950951 const g = groups.current[i];952 if (g) {953 g.position.set(home.x, home.y, t.z);954 g.rotation.set(t.rx, t.ry, 0);955 }956 slabs.current[i]?.setHighlight(t.glow);957 }958 });959960 return (961 <>962 <pointLight position={[0, 1.5, 3.5]} intensity={12} distance={10} color="#ffffff" />963 {items.map((item, i) => (964 <group key={item.id} ref={bindings[i].group} position={[homes[i].x, homes[i].y, 0]}>965 <Slab width={TILE_W} finish="felt" variant={variant} surface={surface} accent={accent} depth={0.16} handle={bindings[i].slab}>966 <CardAnchor layer={layer} index={i} width={TILE_W} z={0.09} />967 </Slab>968 </group>969 ))}970 </>971 );972}973974/**975 * An architectural wall of 6 to 9 perforated acoustic-felt tiles (behind a thin glass sheet when976 * "glass") separated by micro-gaps, each on invisible springs.977 * Moving the pointer sends radial waves through the wall: nearby tiles sink and lean towards it, the978 * tile under it lights its border. Three columns on desktop, two on phones.979 */980export default function AcousticRippleWall({981 items,982 interactive = TESTIMONIAL_DEFAULTS.interactive,983 variant = "solid",984 speed = TESTIMONIAL_DEFAULTS.speed,985 accentColor = "#f0abfc",986 surfaceColor = "#25212f",987 textColor = "#efeaf6",988 className = "",989}: AcousticRippleWallProps) {990 const section = useRef<HTMLElement>(null);991 const pointer = usePointer(section);992 const reduced = usePrefersReducedMotion();993 const mobile = useIsMobile();994 const layer = useCardLayer();995 const tiles = useMemo(() => items.slice(0, MAX_TILES), [items]);996 const columns = mobile ? 2 : 3;997 const rows = Math.ceil(tiles.length / columns);998 const wallWidth = columns * (TILE_W + GAP);999 const wallHeight = rows * (TILE_H + GAP);10001001 return (1002 <section1003 ref={section}1004 aria-label="Customer testimonials"1005 className={`relative w-full overflow-hidden ${className}`}1006 style={{ height: mobile ? `max(${rows * 34}vw, 560px)` : "min(92svh, 860px)", minHeight: 560 }}1007 >1008 <TestimonialCanvas camera={{ fov: 32, near: 0.1, far: 100, position: [0, 0, 10] }}>1009 <FitWidth width={wallWidth + 1.2} distance={Math.max(9, wallHeight * 1.9)} />1010 <StudioLights accent={accentColor} />1011 <Wall items={tiles} columns={columns} variant={variant} surface={surfaceColor} accent={accentColor} speed={speed} interactive={interactive} still={reduced} pointer={pointer} layer={layer} />1012 <CardLayerSync layer={layer} />1013 </TestimonialCanvas>1014 <CardLayerView layer={layer}>1015 {tiles.map((item, i) => (1016 <LayerCard key={item.id} layer={layer} index={i} item={item} accent={accentColor} theme="felt" text={textColor} />1017 ))}1018 </CardLayerView>1019 </section>1020 );1021}
03
Drop it in a page
Updated live with the settings above.
app/page.tsx
1import AcousticRippleWall from "@/components/AcousticRippleWall";23export default function Section() {4 return (5 // The component fills this box: give it a position and a height6 <div style={{ position: "relative", width: "100%", height: "100vh" }}>7 <AcousticRippleWall8 variant="solid"9 speed={1}10 accentColor="#f0abfc"11 surfaceColor="#25212f"12 textColor="#efeaf6"13 interactive14 items={testimonials}15 />16 </div>17 );18}