Backgrounds

Prism

A raymarched glass prism splitting a beam into its spectrum — an SDF solid turned in a hazy volume, a white shaft entering one face and a fan of spectral bands leaving another, each band bent by its own wavelength-dependent deviation so the fan spreads the way dispersion actually spreads. The beams are analytic capsule glows integrated against the view ray, not a second march, which is what keeps sixty-four steps and eight bands inside a frame budget. Drag orbits the solid with momentum; the haze is what makes the shafts readable at all, because light in clean air is invisible until it hits something.

Install

bun add ogl

Then copy 2 files into your project:

  • components/registry/prism/prism.tsx
  • hooks/use-animation-loop.ts

Props

PropTypeDefaultDescription
dispersionnumber0.5Wavelength spread across the fan — zero collapses the spectrum back into one refracted shaft.
bandsnumber6Spectral samples in the exit fan.
beamIntensitynumber1Brightness of the shaft and the fan together.
beamColorstring (hex)"#ffffff"Tint of the incoming shaft.
saturationnumber0.9Spectral saturation of the fan — zero washes every band back to the beam color.
fognumber0.3Density of the participating haze. The beams are only as visible as the air is dirty.
autoRotatebooleantrueIdle turn; a drag takes over and momentum hands back.
rotateSpeednumber0.3Idle rotation rate.

What It Demonstrates

Orbit
An element circling around another in a continuous path.
Drag
Moving an element by grabbing it, often with momentum when released.
Momentum
Motion that carries velocity, especially after a drag or interruption.
Loop
An animation that repeats, a set number of times or infinitely.

Related Components

Appears In