Design.dev design.dev
Scroll Effects · Component Template

Particle Morph

150,000 grains that form a title, a nebula, a spinning disc, and a ringed planet as you scroll. The same grains throughout, with real depth of field.

Live demo

Output of this prompt · Claude Fable 5.2 · WebGL

Scroll inside the demo to morph the particles through each chapter. Move the pointer to part the dust.

The Prompt 1,233 words

Build a scroll-driven story told by 150,000 particles that rearrange themselves: they condense into the title, dissolve into a nebula, flatten into a spinning protoplanetary disc and finally settle as a lit, ringed planet. It is for a science museum's new gallery, "From dust: how planets are made". Every grain is the same grain throughout, there is real depth of field, and the pointer parts the dust. It should be mistaken for a 3D engine. Match my project's existing stack, conventions, and design tokens. If there are none, output a single HTML file with inline CSS and JavaScript and zero dependencies. Raw WebGL points only: no Three.js, no textures, no images.

LOOK
- Page #04050A, text #F4EFE6, secondary text the same at 66%. ui-sans-serif, system-ui throughout.
- Chapter headings clamp(44px, 6.2vw, 104px), weight 640, line-height 0.92, letter-spacing -0.05em. Body 17px.
- Particles are additive (blend ONE, ONE) on a clear color of (0.016, 0.02, 0.039), so dense regions burn toward white on their own. A radial vignette sits over the canvas.

STRUCTURE
- One wrapper. Inside it, a stage that is position: sticky, top 0, 100svh tall, with margin-bottom -100svh, holding the canvas, a nav bar (left "Hall of Planetary Science / Gallery 4", right a pill "Book a visit"), a chapter rail on the right edge and a time readout bottom left.
- Then four sections that scroll over the stage: the opening (100svh) and three chapters (135svh each), so the story is about 5 screens long.
- Opening: the h1 "From dust" is in the DOM but visually hidden, because the particles spell it. Under the particle title: "How planets are made, told with 150,000 grains. A new permanent gallery, open from 14 February.", a pill "Begin 4.6 billion years ago" and a small "or just scroll".
- Chapters, each a heading and a paragraph in a 470px column on the left: "First, a cloud." / "Then a disc." / "Then worlds." The last one ends with a "Book a visit" pill.
- Rail: four links (From dust, A cloud, A disc, Worlds) drawn as short lines; the current one grows from 18px to 40px on a spring and shows its label.
- Readout: "4,600 million years ago", interpolating 4,600, 4,599, 4,540 across the chapters. Hidden on the opening.

THE GRAINS
- 150,000 points (70,000 under 760px wide), from a seeded random generator so every visit is identical. Each has four positions, one per shape, plus four random numbers. Five attributes in all.
- Title: draw "FROM DUST" (two lines on portrait screens) at weight 800 on a 2D canvas, then sample points inside the letters (collect the opaque pixels once and pick from that list, never an unbounded rejection loop). Scale it to 80% of the visible width (90% on portrait) and lift it above center. Rebuild this one buffer when the aspect ratio changes.
- Cloud: 88% of points in six Gaussian clumps strung along a lazy S, denser at their hearts, 12% scattered through a box; then pull every point through two octaves of a sine flow field so the clumps stretch into filaments.
- Disc: 13% in a tight Gaussian core. The rest at radius 0.16 + 2.1u^0.62, kept or rejected by 0.3 + 0.7(0.5 + 0.5 cos(2(angle - 3.1 ln(r + 0.3)))) for two spiral arms, with thickness growing with radius.
- Planet: 56% on a sphere of radius 0.92; 44% in a flat ring from 1.26 to 2.18 with two gaps cut out.
- About 2% of the points are far stars that sit on a distant shell in every shape.

THE VERTEX SHADER
- Progress p runs 0 to 3. Between two shapes, each grain leaves at its own moment: t = smoothstep(seed x 0.5, seed x 0.5 + 0.5, fract(p)). Position = mix(A, B, t) plus a sine flow field times sin(pi t) x 0.42, so every grain detours through turbulence mid-flight.
- Each shape keeps moving by itself: title grains shimmer by about a hundredth of a unit; the cloud drifts on the flow field; disc and ring grains orbit at speed proportional to r^-1.5; the planet turns.
- Color is computed per shape and mixed with t. Title: warm white to orange. Cloud: violet to pink with a few teal grains. Disc: white-hot core, orange, dull red, then blue-gray at the rim. Planet: sandy bands from a sine of latitude; rings icy blue-white with fine radial banding.
- Once p passes 2.55 the planet becomes solid: sphere grains facing away fade out, facing grains are lit from the upper left with a Lambert term raised to 1.3 and drawn twice as large so the globe fills in, and ring grains behind the globe are hidden.
- Camera: yaw and pitch follow the pointer (0.3 and 0.16 radians at the edges) plus a slow sway; perspective with a 40 degree field of view from 4.4 units away, done by hand in the shader.
- Depth of field: blur = |distance from the focal plane| x 1.5. Point size grows by blur x 3.2 and alpha falls by 1 / (1 + 5 blur²). The flat title is pin sharp; the near and far edges of the disc and rings melt into bokeh.
- Pointer: in screen space, grains within reach are pushed outward by 0.17 x exp(-16 d²) and swell slightly.
- On wide screens, shapes after the title shift 0.78 units right so the copy has the left half. On narrow ones they scale by min(1, aspect x 0.62).
- Fragment shader: a soft round point, smoothstep from the edge to 20% radius.

MOTION
- Opening: over 2.6 seconds the title condenses out of a wide scatter of the cloud, each grain arriving at its own time and brightening as it lands.
- Scroll maps to p with a plateau: each shape holds for the first and last 18% of its chapter and morphs in between. Ease p toward its target at 4.5 per second so wheel steps never jump.
- Chapter captions use CSS scroll-driven animation only (animation-timeline: view()): they rise 60px, sharpen from a 14px blur, hold, then leave the same way. No scroll listener touches them.
- Nav, rail and opening copy sharpen in on a CSS spring (a damped spring sampled into linear()) after the title has formed.

BEHAVIOR
- If frames take longer than 30ms for 24 frames running, draw 18% fewer grains (points are generated in random order, so any prefix is a fair sample), down to 40%. Never drop frames to keep count.
- Pause when the tab is hidden or the story is off screen. Canvas at up to 2x device pixels.
- Without WebGL, show the h1 as ordinary large type.

ACCESSIBILITY
- The canvas is aria-hidden; the story is fully readable as headings and paragraphs. One h1.
- The rail is a nav of real links with aria-current on the active chapter.
- prefers-reduced-motion: no opening, no drift or orbit, captions simply visible; the shape snaps to the nearest chapter as the page scrolls and a single frame is drawn each time.

NEVER
- No library, sprite texture or image.
- No lines connecting particles, no constellation mesh.
- No depth buffer tricks or post-processing passes: additive points only.
- No scroll hijacking. The page scrolls natively and the particles follow.
- No rainbow. Each shape has its own small palette.
  1. CopyThe full prompt, one click.
  2. PasteInto Cursor, Claude Code, or any agent.
  3. CompareAgainst the live demo above.
Particle Morph
Copied to clipboard