Renderer · class

DistanceFieldScene

Explained in Hello world.

class DistanceFieldScene
import { DistanceFieldScene } from '@driftengine/core';

Accessors

NameTypeDescription
lengthgetnumberHow many placed fields this frame has recorded.
capacitygetnumberHow many records are pooled, which a test uses to assert a steady scene stops allocating.
sourcesgetreadonly FieldSource[]This frame's distinct sources, in the order their samples are packed.
sampleCountgetnumberFloats the packed upload holds — the sum of the distinct sources' fields.
packingChangedgetbooleanWhether the samples have to be uploaded again, or the placements alone will do.
More

True when this frame's distinct sources are not the last frame's in the same order, since the offsets are positional. A scene whose fields never change answers false from its second frame on, which is what keeps a sixteen-megabyte upload out of the frame loop.

Methods

offsetOf

offsetOf(source: FieldSource): number

Where a source's samples start in the packed upload, or -1 if it is not in this frame.

ParameterTypeDescription
sourceFieldSource

record

record(source: FieldSource, model: ReadonlyMat4, albedo?: ArrayLike<number>): void

Declare a field, placed.

ParameterTypeDescription
sourceFieldSource
modelReadonlyMat4
albedo?ArrayLike<number>
More

A source whose samples do not fit is refused whole rather than clipped. Half a field on the device is not a coarser field; it is a field whose far half reads whatever the buffer held, and that composes as surfaces that are not there — the failure Wave 4A already paid for once, where a phantom surface passed 111,907 parity samples and was found by looking at a picture.

replay

replay(each: (instance: DistanceFieldInstance) => void): void
ParameterTypeDescription
each(instance: DistanceFieldInstance) => void

reset

reset(): void

Empty it for the next frame, keeping the storage and remembering what was packed.