Diorama

Made for a big screen.

This site is one 3D scene, built for a computer: a wide window and a mouse. Open dioramajs.dev on a desktop or a laptop to see it.This site is one 3D scene, built for a wide window. Make this one wider, or open dioramajs.dev on a larger screen.

GitHub

DioramaDocs

Field class

A displacement field over the box: `size` × `size` cells, each a vector in box px (y up) that the pointer pushes along its path.

View as Markdown
import { Field } from '@dioramajs/media/liquid'

. Every step it decays, spreads to the neighbours and drifts along itself. Deterministic: the same strokes and steps give the same field.

class Field

Members

NameTypeDescription
constructor
constructor(size: number): Field
peaknumber

Largest displacement in the field, px.

Default 0.

readonly sizenumber
readonly xFloat32Array
readonly yFloat32Array
clear
clear(): void
step
step(
  seconds: number,
  duration: number,
  swirl: number,
  width: number,
  height: number,
): void

One step of seconds: the field fades to 2% over duration, spreads to its neighbours and, by swirl, drifts along itself with the box width × height px.

stroke
stroke(
  ax: number,
  ay: number,
  bx: number,
  by: number,
  radius: number,
  width: number,
  height: number,
): void

Pushes the cells within radius px of the segment from a to b (box px, y up, the box width × height) along the segment, most near it: a pass deposits about its own length.

write
write(out: Uint16Array, width: number, height: number): void

Packs the field into half floats, four per cell: the displacement in px, then the slope of its length (px per px), which the water style reads as the slope of a surface.

Defined in packages/media/src/liquid.ts.