Three Scene
import { ThreeScene, loadModel, scrubAnimation, frameObject, disposeObject } from "pleate/effects/three-scene";Folding sheet
Scroll the page: a sheet in the accent color folds into twelve pleats while the camera moves through four cues. Switch the palette and it recolors.
One sheet, twelve folds
Scroll down and the sheet folds, scroll back up and it opens again.
The camera follows cues
Four cues pin the camera, the turn and the fold. Between them everything blends.
Drawn only when it changes
While the page is still, off screen or in a hidden tab, no frames are drawn.
Props
- setup(ctx)
Builds the scene once per mount. ctx has renderer, scene, camera, canvas, palette (accent, fg, bg, surface as THREE.Color), phone, reduced and invalidate().
(ctx) => { frame?, theme?, dispose? } | Promise- frame({ progress, time, delta })
Runs before each render. Set the camera and the objects from progress here.
function- progress
Defaults to the enclosing ScrollScene's progress.
MotionValue<number>- loop
demand draws only when the progress, the size or the theme changes, or on invalidate(). always also runs the time clock.
"demand" | "always"default "demand"- maxDpr / phoneMaxDpr / adaptive
Pixel ratio caps, and stepping the resolution down while frames run slow.
number / number / booleandefault 1.75 / 1.25 / true- shadows / transparent / fov
Shadow maps, a see-through canvas and the camera's field of view.
boolean / boolean / numberdefault false / true / 35- fallback / label
Shown without WebGL2. A label makes the canvas a named image, otherwise it is decorative.
ReactNode / string- loadModel(url, { draco, ktx2, renderer, shadows })
Loads .glb or .gltf. Meshopt works out of the box. Draco and KTX2 decoders are served from folders on your own site, never a CDN.
Promise<GLTF>- scrubAnimation(root, clips, names?)
Puts a model's clips on the scroll: seek(progress) in frame().
{ mixer, duration, seek(t) }- frameObject(camera, object, margin)
Backs the camera off until an object of any size fits, and returns its center.
Vector3default margin 1.2
Accessibility
- Pass label to describe the picture; without it the canvas is hidden from screen readers.
- Nothing draws off screen or in a hidden tab, and the WebGL context is released on unmount.
- Reduced motion stops the time clock of loop="always". Scroll driven changes still draw, since the reader moves them.
- Without WebGL2 the fallback shows in place of the canvas.