Skip to main content

Class: BuildStage

Defined in: render/build-stage.ts:18

Provides per-frame context during the build/evaluation pass of a scene.

Each scene node receives a BuildStage when its properties are being evaluated for a given frame. It exposes:

  • The canvas viewport dimensions and the target fps.
  • A seeded pseudo-random number generator (random) for reproducible randomness across timeline replays.
  • A smooth value-noise function (noise) built on the same seed, useful for organic motion without discontinuities.

reset() is called before each timeline replay so that every run produces identical results for the same seed.

Constructors

Constructor

new BuildStage(viewport, fps): BuildStage

Defined in: render/build-stage.ts:25

Parameters

viewport

Size2D

fps

number

Returns

BuildStage

Properties

fps

readonly fps: number

Defined in: render/build-stage.ts:23

Target frames-per-second of the composition.


viewport

readonly viewport: Size2D

Defined in: render/build-stage.ts:20

Canvas dimensions in pixels.

Methods

noise()

noise(time, frequency?): number

Defined in: render/build-stage.ts:76

Smooth 1-D value noise in [0, 1].

Samples two adjacent lattice points around time * frequency, then interpolates with a smoothstep curve (3t² - 2t³) to avoid the linear kinks of plain lerp. Useful for organic, continuously varying motion (camera shake, drift, etc.).

Parameters

time

number

Normalized timeline position, typically in [0, 1].

frequency?

number = 1

Scales time before sampling; higher values produce faster oscillation.

Returns

number


random()

random(min?, max?): number

Defined in: render/build-stage.ts:51

Returns the next pseudo-random number in [min, max).

Defaults to [0, 1) when called without arguments. The sequence is fully determined by the current seed, so the same seed always produces the same sequence across replays.

Parameters

min?

number = 0

max?

number = 1

Returns

number


reset()

reset(): void

Defined in: render/build-stage.ts:98

Resets all stateful generators so the next replay is identical to the first.

Returns

void


resetSeed()

resetSeed(): void

Defined in: render/build-stage.ts:88

Reseeds the RNG back to _currentSeed. Called before each timeline replay.

Returns

void


seed()

seed(value): void

Defined in: render/build-stage.ts:37

Sets the RNG seed for this stage.

Accepts either a numeric seed directly or a string, which is hashed into a 32-bit integer using a djb2-style hash so that human-readable names ("bounce", "sparkle") can be used as stable seeds.

Parameters

value

string | number

Returns

void