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

EffectDefinition interface

What `defineEffect` takes: the params, the options and `setup`.

View as Markdown
import type { EffectDefinition } from '@dioramajs/diorama/effects'
interface EffectDefinition<P extends ParamSpec>

Members

NameTypeDescription
readonly animate?AnimatePolicy<P>

Defaults to the update's answer when it returns a boolean, else to what the effect reads: time animates every visible frame, hoverTime while hovered or hover decays, neither means 'input'.

readonly bleed?number

Extra px around the box for visibility, for copies displaced past it. Default 0.

readonly burst?boolean

Objects in ctx.overlay outlive a hidden or removed element while the effect still asks for frames itself (a burst): its update returned true, or its animate function says so. false ties them to the element: a pane or a layer of the page that only animates its state. Default true.

readonly media?boolean | 'optional'

Needs the <img> or <video> as a texture. Implies on: 'img, video', ready before setup. 'optional' reads it when the element is one and runs without it on other elements.

readonly name?string

kebab-case token in data-dio, e.g. image-ripple. Defaults to the key the effect is registered under (the file name when a build plugin finds it).

readonly on?string

Selector of the elements this effect accepts. Others are skipped with a warning.

readonly params?P

Defaults. Their types become the param types.

readonly presence?'fade' | 'custom'

Page transitions. 'fade' (default) multiplies the copy's alpha by u.presence. With 'custom' the effect reads u.presence or input.presence itself.

readonly quality?QualitySpec<P>

How the effect gets cheaper on weaker GPUs. Read by the runtime and by the docs.

readonly rebuild?readonly (keyof P & string)[]

Params whose change re-runs setup. String and choice params always do.

readonly reducedMotion?'static' | 'off'

'static' (default) runs with motion inputs zeroed and time frozen. 'off' skips the effect.

readonly when?When

Media query the page must match or the instance is off. 'hover' means '(hover: hover)'.

setup
setup(ctx: EffectContext<P>): void | EffectUpdate | Promise<void | EffectUpdate>

Builds the effect once per instance. May return an update that runs every drawn frame.

Also exported from @dioramajs/effects.

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