3D Scenes

Scroll Scene

A tall section with a pinned stage, so the scroll position drives what the stage shows. Text beats show for one stretch each, and a cue timeline blends any set of values between pinned points.
import { ScrollScene, ScrollBeat, useSceneProgress, createTimeline, easings, range } from "pleate/effects/scroll-scene";

Lisbon to Porto

Scroll the page: three cues pin the train at each station and the distance reads off the scroll. Scroll back up and it runs backwards.

Alfa Pendular 1310 km
Lisboa Oriente0 km
Coimbra-B218 km
Porto Campanhã337 km
01

The scroll moves the train

Each point of the scroll is one point of the line, so the train covers the same distance however fast you scroll.

02

Three cues

Lisbon, Coimbra and Porto pin where the train is. Everything in between is blended from them.

03

Back is backwards

Scroll up and the train runs back the way it came. Nothing here runs on a timer.

Props

ScrollScene stage

The pinned layer, as wide and tall as the viewport: a ThreeScene, a video, a drawing.

ReactNode

ScrollScene children

Laid over the stage, usually ScrollBeats.

ReactNode

ScrollScene length / offset / label

Viewport heights of scrolling the pin lasts, the sticky header above it, and the section's name.

number / number (px) / stringdefault 3 / 0

ScrollBeat from / to

The stretch of the scene where the beat shows.

number (0..1)

ScrollBeat fade / distance

Share of the scene spent fading in and out, and how far it rises.

number / number (px)default 0.04 / 16

useSceneProgress()

The enclosing scene's progress. Read it with useTransform for the DOM, or .get() in a render loop.

MotionValue<number>

createTimeline(base, cues, { ease })

Pins values (numbers or lists of numbers) at points from 0 to 1. Values a cue leaves out carry over. sample(t) returns one reused object and allocates nothing.

{ at, values?, ease? }[]

easings / range(t, from, to)

Curves for the stretches between cues, and a helper that splits one progress into chapters.

linear, smooth, smoother, out, in / number

Accessibility

  • The section can be named with label. Every beat stays in the reading order.
  • Focusing a link or button inside a hidden beat scrolls the page to the stretch where it shows.
  • Hidden beats ignore the pointer, so they never block the stage.
  • Reduced motion keeps the scene, since the scroll is the reader's own movement, and the beats only fade.