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

Surface interface

The element's single GL copy.

View as Markdown
import type { Surface } from '@dioramajs/diorama/effects'

Effects add transforms in the order they sit on the element.

interface Surface

Members

NameTypeDescription
readonly materialMeshBasicNodeMaterial

The material currently drawn. Replaced when the set of transforms changes.

readonly meshMesh

A 1x1 plane on the box. Shared: read or tweak it, never dispose or reparent it.

color
color(transform: (color: Node<'vec4'>, input: SurfaceInput) => Node): Off

Changes the colour. sample(uv) reads the element's media with crop and masks applied.

position
position(transform: (position: Node<'vec3'>, uv: Node<'vec2'>) => Node): Off

Moves vertices in the plane's local 1x1 space.

segments
segments(count: number): void

Requests plane subdivisions. The largest request wins, default 1.

uv
uv(transform: (uv: Node<'vec2'>) => Node): Off

Bends box UV (0..1, y up) before sampling.

zoom
zoom(scale: number, x?: number, y?: number): void

Frames the media: scales it by scale about the box centre, then moves it by x, y (box units, y up), on top of object-fit. Unlike a uv transform this framing is known outside the shader: copy.cropAt includes it and a crop set by the copy's owner replaces it, so a flight starts and lands in it. Kept until called again; called from update, it shows in that frame. The framings of the element's effects combine in effect order. Default 1, 0, 0.

Also exported from @dioramajs/effects.

Defined in packages/effects/src/types.ts.