Skip to main content

Class: VoxelBoxWork

Work every voxel box being built shares, in order, a slice per frame: the frame-paced drain (createBudgetedDrain, made by createDrain) runs units until the slice has spent its budget, so however many boxes bake at once (a felled tree bakes several) the frame pays one budget for all of them. A unit that throws fails its own run, loudly, never the drain.

Constructors​

constructor​

• new VoxelBoxWork(options): VoxelBoxWork

Parameters​

NameTypeDescription
optionsObject-
options.createDrain(work: () => BudgetedWorkOutcome) => { schedule: () => void }-
options.now() => number-
options.sliceGapMsnumberA pause between units longer than this starts a new slice.

Returns​

VoxelBoxWork

Methods​

run​

▸ run(units): Promise<VoxelBoxWorkCost>

Queues units, resolving once they have all run.

Parameters​

NameType
units() => void[]

Returns​

Promise<VoxelBoxWorkCost>