Skip to content
English
Light and relief comes with Pro. Its preview shows once you unlock it.

How it works

A height field describes the print: a raised heron and reed, a carved waterline. Central differences give every point a unit normal N. The lamp turns around the print on a ring at a fixed height; Shading paints N · L, so slopes facing the lamp are bright and slopes turned away are dark. The ridge (A) and the groove (B) light on opposite sides, a line that runs along the light fades, and light from below makes the relief seem to flip. Normals colours each slope by the way it faces, with the ring as the key; Highlights shows where a slope mirrors the lamp up to the viewer. Colours come from the theme's tokens.

Use it for

  • Teach shading, surface normals and the dot product N · L in a physics, optics or computer-graphics lesson.
  • Show why the direction of light changes how a relief, a coin, a fingerprint or a landscape model reads.

Look elsewhere when

  • The relief is a fixed, built-in model and the shading has no shadows cast across the print; it is not a renderer for your own images or a measurement tool.

Usage

import { RakingLightRelief } from './RakingLightRelief.jsx'

export function ShadingLesson() {
  const [angle, setAngle] = React.useState(145)
  return <RakingLightRelief angle={angle} onAngleChange={setAngle} elevation={20} defaultLayer="surface" />
}

Props

PropTypeDefaultWhat it does
anglenumber—Controlled lamp direction in degrees: 0 is from the right, 90 from the top.
defaultAnglenumber145Starting lamp direction when uncontrolled; Reset returns to it.
onAngleChange(angle: number, info: { reason }) => void—Receives the whole-degree direction (0–359) and why it changed: 'drag', 'press', 'tap', 'key', 'reset' or 'cancel'.
layer'surface' | 'normals' | 'specular'—Controlled view: shading, normals or highlights.
defaultLayer'surface' | 'normals' | 'specular''surface'Starting view when uncontrolled.
onLayerChange(layer: string) => void—Receives the newly chosen view.
elevationnumber20How high the lamp stands above the print, in degrees (5–80). Low, raking light makes the relief stronger.
labelsobject—Replaces any visible or announced string: title, formula, ridge, groove, lamp, direction, valueText, from (eight directions), help, layer, surface, normals, specular, the five hints (above, below, side, normalsHint, specularHint) and reset.
localestring'en'Locale for the angle readout.

Accessibility

  • The lamp is a slider: Tab to it, arrows turn it to the next 5 degrees, Page Up and Page Down by 45, Home and End go to 0 and 359. Its value is announced with the direction in words.
  • The three views are toggle buttons with aria-pressed; the hint under the figure changes with them and is announced politely. The print has a text label with the view and the angle.

Motion

After a key, a tap or Reset the lamp glides round the ring the short way for --ds-duration-base and the print relights each frame; while dragged it follows the pointer directly. The ring's colour key fades in with the Normals view. With reduced motion every change lands at once.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

RakingLightRelief.jsxraking-light-relief.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Form inputs
Availability grid comes with Pro. Its preview shows once you unlock it.
Boolean operations comes with Pro. Its preview shows once you unlock it.
Cascader comes with Pro. Its preview shows once you unlock it.