The .drft container · function

planRegions

Where each region's chunk goes among the meshes: before[m] is the regions written just ahead of mesh m, and before[meshCount] those after the last. A streaming reader then always has a region before the meshes it introduces.

Explained in The .drft container.

function planRegions(regions: readonly DrftRegion[], meshCount: number, piecesOf?: (mesh: number) => ArrayLike<number> | undefined): DrftRegion[][]
import { planRegions } from '@driftengine/drft';

Parameters

ParameterTypeDescription
regionsreadonly DrftRegion[]
meshCountnumber
piecesOf?(mesh: number) => ArrayLike<number> | undefined

In depth

The meshes no region introduces come first, then each region's new meshes, in the order the regions are given and ascending. A region introduces the kit pieces its assemblies copy, where no earlier region did (piecesOf names them), so a piece travels with the first region that needs it rather than at the head of the file: a world's kit is most of its bytes, and a walker's first regions need a sliver of it. A piece ahead of the first mesh any region names is the file's own, as every piece was before a region could carry one, so either layout is valid. That a piece comes ahead of every assembly copying it is the kit's own rule (checkCopies). Anything else is refused by name rather than reordered, because the ordinals are what the regions and the materials already point at.