Three.js Scroll Bridge Build — Planks Assemble Ahead

Three.js Scroll Bridge Build Crossing · Scroll · Plain HTML, CSS & JS · Live preview

Share & Support

What's included

Features

Build frontier at p × 1.16 leads the first-person walker — construction stays ~7 planks ahead by construction
Parameter-keyed plank windows: each board flies in as the frontier passes its span position
Planks arrive from 26 below and 14 ahead, untwisting from seeded spins — never fading in
Rope rails as per-segment cylinders scaling taut slightly behind their planks
Half-sine catenary sag shared by planks, ropes, and the walker camera height — the dip is felt, not just seen
Footstep bob from |sin(p × 60)| keyed to scroll, so steps only happen while moving
Displaced-vertex canyon cliffs with computed normals, river 58 units down, fog-matched depth
Fully reversible: scrolling back unbuilds the bridge in your wake, plank by plank

About this UI Snippet

How to Build a Scroll-Driven Bridge Crossing With Three.js and GSAP

Screenshot of the Three.js Scroll Bridge Build Crossing snippet rendered live

The Three.js Scroll Bridge Build Crossing snippet puts the camera in first person at the edge of a canyon and lets scroll walk it across — with the catch that the rope bridge does not exist yet: planks fly up from the depths and twist into place just ahead of each footstep, rope rails zipping along behind them, so the walker is perpetually a few steps from the void. GSAP's ScrollTrigger scrubs the crossing; a build frontier that *leads* the camera turns one value into both journey and construction.

The frontier leads the walker

Two derived positions move across the span: the camera at raw progress p, and the build frontier at p × (1 + LEAD) with LEAD = 0.16. Because the frontier multiplier exceeds one, construction stays ahead of the walker — about seven planks of safety margin at mid-span — and both positions finish together at the far cliff. Each plank compares the frontier against its own span parameter through a short window, the parameter-keyed stagger pattern from the domino run, but here the front *creates* rather than destroys.

Planks arrive with story

A plank's local progress drives an easeOutCubic flight from 26 units below and 14 units ahead, untwisting from a seeded random spin as it rises — so each board visibly *arrives from somewhere* rather than fading in. The seeded hash (shared across this series since the Rubik's cube assembly) keeps every plank's tumble identical across reloads and reversals. Rope rail segments scale up along their length (scale.y from 0 to 1) slightly behind the planks they connect, reading as rope being pulled taut segment by segment.

A catenary from one sine

Real rope bridges sag. Every plank's rest height is sin(u × π) × −2.4 — a half-sine dip that approximates a catenary closely enough at this scale — and the rope segments inherit the sag by connecting neighboring plank positions with per-segment rotation from atan2. Crucially, the walker camera's height follows the same sag function evaluated at its own position, so descending into the dip and climbing out of it is *felt* in first person, not just seen.

A footstep bob sells first person

The camera's Y adds |sin(p × 60)| × 0.35 — the absolute-value sine that mimics the rise-fall-rise of walking gait, keyed to scroll so steps only happen while moving. The look-at aims 16 units ahead at the arrival zone where planks are flying in (the natural place a person crossing a half-built bridge would stare), then lifts toward the far side as the crossing completes. Canyon walls are displaced-vertex boxes with computeVertexNormals for jagged cliff shading, and a river plane 58 units below plus matched fog supply the vertigo.

One value, two motions, honest reversal

Scrolling backwards is the full effect in reverse: the walker retreats while planks *behind* the frontier tumble back into the depths and rope segments unzip — the bridge unbuilds itself in your wake. Nothing fires or toggles; walker, frontier, plank flights, rope scales, sag, bob, and the SPAN HUD all derive from one scrubbed number. For the sibling that builds a structure while orbiting it rather than crossing it, see the voxel build; for another first-person scrubbed traversal, the staircase climb.

Build with AI

Build, Understand, Optimize, and Extend It With AI

You do not need to invent the frontier-lead pattern — it is the heart of this snippet and transfers to any "path builds ahead of you" idea. Paste the HTML, CSS, and JS into an AI assistant like Claude and ask it to explain the two-position derivation, the seeded plank tumbles, or why the camera height shares the sag function. The same assistant can raise the stakes — wind that sways planks and ropes on clock time with amplitude peaking mid-span, a plank that arrives late (window offset) for a heart-skip beat, fog rolling up from the river as you descend into the dip, or milestone labels on every eighth plank. It can also convert the crossing into third person by orbiting a walker figure with the same two-position math. Treat the code as a starting point to interrogate and reshape, not a finished artifact.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a "scroll-driven bridge build crossing" in plain HTML, CSS, and JavaScript using Three.js and GSAP's ScrollTrigger plugin, all loaded from a CDN (no bundler, no build step).

Requirements:
- A pinned full-viewport section with a canvas, WebGLRenderer, PerspectiveCamera (resized with aspect on window resize), cool ambient + warm directional light, and Fog matched to the background.
- A canyon: two cliff walls from BoxGeometry with vertices jittered by a seeded sin-hash (no Math.random) and computeVertexNormals for jagged shading, separated by a ~70-unit gap, with a dark river plane ~58 units below.
- 46 wooden planks spanning the gap, each resting at a half-sine catenary sag y = sin(u × π) × −2.4. Rope rails on both sides as thin cylinder segments connecting neighboring plank positions, rotated via atan2 to follow the sag.
- One GSAP tween (ease "none") scrubbing p 0→1 on a ScrollTrigger with pin: true, scrub ~0.5, end ~+=500%.
- TWO derived positions: the first-person camera crosses at raw p; a build frontier moves at p × 1.16. Each plank's local progress = clamp((frontier − u) / 0.09), driving an easeOutCubic flight from 26 units below and 14 units ahead while untwisting from a per-plank seeded spin. Rope segments scale.y from 0 to 1 on the same windows, slightly behind their planks.
- Walker camera: x from p across the gap, height = sag(p) + 4.6 + footstep bob |sin(p × 60)| × 0.35 + small clock sway; lookAt ~16 units ahead at the plank arrival zone, lifting toward the far side near the end.
- A SPAN % HUD from p and an intro overlay fading at p > 0.02.
- Confirm scrolling backwards retreats the walker while the bridge unbuilds in reverse — planks tumbling back into the canyon along their identical seeded paths.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Step by step

How to Use

  1. 1
    Load the three CDN scriptsAdd three.min.js, gsap.min.js, and ScrollTrigger.min.js in that order before the snippet JS.
  2. 2
    Paste HTML, CSS, and JSYou stand first-person at a cliff edge — canyon walls drop to a river far below, no bridge in sight, SPAN 0% in the HUD.
  3. 3
    Scroll to walkPlanks fly up from the depths and untwist into place a few steps ahead while rope rails zip taut behind them — your footstep bob begins.
  4. 4
    Feel the sagThe camera descends into the catenary dip at mid-span and climbs out, always a safe margin behind the build frontier.
  5. 5
    Scroll backThe bridge unbuilds in your wake — planks tumble back into the canyon in exact reverse as you retreat.
  6. 6
    Retune the crossingChange GAP, PLANKS, LEAD (safety margin), or the sag amplitude — frontier, ropes, and camera height all recompute.

Real-world uses

Common Use Cases

Onboarding and migration journeys
The pitch writes itself — "we build the path as you walk it" — for migration tools, guided setups, and managed services, annotated via scroll pin steps.
Trust and partnership storytelling
Agencies and consultancies get a first-person metaphor for stepwise commitment; land the far cliff on the CTA.
Adventure and platformer promos
A canyon crossing with just-in-time platforms is native gaming vocabulary — hand off to a scroll camera path level tour.
Teaching frontier-lead scrub design
The two-position pattern (actor at p, world-builder at p × k) is reusable for any "path appears ahead of you" sequence.
Portfolio narratives with stakes
The vertigo framing keeps attention through a long scroll better than a flat scroll horizontal pin section.
Roadmap and milestone reveals
Each plank a shipped milestone, the frontier your delivery pace — the SPAN HUD doubles as roadmap progress.

Got questions?

Frequently Asked Questions

Two positions derive from one scrubbed value: the camera crosses at raw p while the build frontier moves at p × (1 + 0.16). Since the frontier runs 16% faster, it leads by a growing-then-shrinking margin that peaks mid-span (~7 planks) and converges at the far cliff, where both reach 1 together. Each plank's flight window is keyed to the frontier, so the safety margin is structural — no timing coordination can drift.

Opacity fades read as UI; motion reads as construction. Each plank's local progress drives an easeOutCubic flight from 26 units down and 14 units forward while untwisting from a seeded random spin, so boards visibly arrive from the canyon and settle. The seeded hash keeps every tumble identical across reloads and scroll reversals — Math.random would break the unbuild-in-reverse effect.

A half-sine: each plank rests at sin(u × π) × −2.4, dipping 2.4 units at mid-span — a close visual approximation of a catenary at this scale. Rope segments connect neighboring plank rest positions with rotation from atan2, inheriting the curve, and the walker camera evaluates the same function at its own position so the descent into the dip is experienced in first person.

Three layers on the camera: the sag-following base height, a footstep bob of |sin(p × 60)| × 0.35 — the absolute sine's cusps mimic heel strikes, and being keyed to p means steps stop when scrolling stops — and a slow clock sway for idle life. The look-at aims at the plank arrival zone ahead, which is where a real person crossing a half-built bridge would look.

Yes. Export via the JSX, Vue, Angular, or Tailwind buttons. Build cliffs, planks, ropes, and the ScrollTrigger inside a mount effect against a canvas ref. Note each plank clones the wood material — dispose all clones on cleanup along with rope and cliff geometries, kill the ScrollTrigger, and call renderer.dispose() so the pin and WebGL context release.