The .drft container · interface

DrftSource

What a caller hands over to be baked.

Explained in The .drft container.

interface DrftSource
import type { DrftSource } from '@driftengine/drft';

Properties

NameTypeDescription
meshesreadonlyreadonly (MeshData | DrftAssembly)[]The meshes by ordinal. An assembly — painted copies of kit pieces — stands in a slot like any mesh and is written as one required MSHC chunk; see drftAssembly.ts.
kitreadonlyoptionalreadonly number[]The ordinals of the meshes that are kit pieces, ascending: drawn only as copies inside the assemblies, never on their own. One required KITS chunk, ahead of the geometry. A piece comes before every assembly that copies it, is never an assembly itself, and is neither placed by INST nor named by a region.
materialsreadonlyoptionalreadonly DrftMaterial[]One material per mesh, by ordinal, or absent for an asset that names none.
More

All or nothing: a partial list would make material n mean a different mesh depending on how many came before it, which is the kind of off-by-one that shows up as one wrong surface in a scene and is looked for everywhere except here.

texturesreadonlyoptionalreadonly DrftTextureSource[]
substancesreadonlyoptionalreadonly DrftSubstanceEntry[]Which substance each material is made of, or absent for a file that labels none.
More

Written as one SUBS chunk at 1.8. It pairs by the material ordinal carried per entry rather than by position, so a file labelling only its fourth material says so.

fieldsreadonlyoptionalreadonly DrftSdfvEntry[]The signed distance field of each mesh that has one, or absent for a file carrying none.
More

Written as one SDFV chunk at 1.13. It pairs by the mesh ordinal carried per entry rather than by position, so a file with a field for only its fourth mesh says so — SUBS's rule, and MORP is the chunk that found out why it is a rule.

networksreadonlyoptionalreadonly DrftNetwork[]The networks this file carries, or absent for a file carrying none.
More

Written as one NNET chunk at 1.14, each network found by its role rather than by position.

graphsreadonlyoptionalreadonly DrftGraph[]The graphs this file carries — networks built from operators rather than dense layers — or absent for a file carrying none. Written as one NGRF chunk at 1.15, each found by its role.
collidersreadonlyoptionalreadonly Float32Array[]The convex hulls this asset collides as, or absent for a file that carries none.
More

Each entry is xyz-packed points in the asset's own space, at most 64 of them, which is what hullShape takes. Written as one COLL chunk at 1.12. See drftColliders.ts for why the format carries points rather than shapes.

lodsreadonlyoptionalreadonly MeshData[]Coarse whole-asset levels of detail, coarsest first, or absent for a file with none.
More

Each one stands in for the entire model rather than for one part of it, which is the argument docs/FORMAT.md §4.6 makes: a single decimated body reads as a car, and 187 coarse fragments read as a mess. They are written first so a sequential fetch has an outline on screen within the first few kilobytes, and they carry no material entry because they carry their colour per vertex — MATL pairs with MESH by ordinal and nothing else.

levelsreadonlyoptionalreadonly Uint8Array[]Discrete levels of detail, finest first, each a complete .drft of its own.
More

Distinct from lods above in every way that matters: those are one merged outline per level for a progressive load, these are whole alternative models a source authored by hand, each with its own materials and hierarchy. See CHUNK_LODF.

nodesreadonlyoptionalreadonly DrftNode[]The asset's own hierarchy, or absent for one mesh at the origin.
More

What NODE carries, and what rigid TRS animation drives. A reader that skips the chunk gets the meshes exactly as it always did, which is why this is additive.

instancesreadonlyoptionalreadonly DrftInstanceGroup[]Meshes drawn many times: one INST chunk, written ahead of the geometry and required. The mesh a group names holds one copy; see drftInstances.ts.
regionsreadonlyoptionalreadonly DrftRegion[]The regions of a streamed world: one required REGN chunk each, written just ahead of the meshes it introduces. The meshes no region names come first, then each region's new meshes in region order — the writer refuses any other order rather than renumbering what the regions and the materials point at. See drftRegions.ts.
lightVolumereadonlyoptionalDrftLightVolumeA world's fixed lights summed offline into one dense volume: one optional LVOL chunk, after the geometry, since the world draws lit by its exact lights until it lands. See drftLightVolume.ts.
lightsreadonlyoptionalreadonly DrftLight[]The lights the scene was authored with: one LITE chunk, optional. See drftLights.ts.
quantisereadonlyoptionalbooleanWrite each mesh as MSHQ rather than MESH: constants, 16-bit ranges and octahedral directions, about a third of the bytes, within the bounds drftQuantised.ts states. Off unless asked, so a caller writing a file gets the bytes it always got; the baker asks by default.
skinsreadonlyoptionalreadonly DrftSkin[]Skins, one SKIN chunk each, or absent for an asset that deforms nothing.
clipsreadonlyoptionalreadonly AnimationClip[]Clips, one ANIM chunk each, or absent for an asset that animates nothing.
splatsreadonlyoptionalDrftSplatsA Gaussian splat capture, or absent for a file carrying none.
More

Written as several SPLT blocks, interleaved across the whole capture so any prefix of the file is a complete sparse version of it. See coarseFirst.ts for the ordering and CHUNK_SPLT for why it is several chunks rather than one.

dtexreadonlyoptionalreadonly DtexEntry[]A decode program per material, or absent for a file whose materials are ordinary.
More

One DTEX chunk each, paired to a MATL entry by the index inside the chunk rather than by the order they appear. A file may carry one for some of its materials and not others — a scene where one surface came from a capture and the rest were authored — and a reader pairing by position would hand the wrong material the wrong texture with nothing to fail on.

entitiesreadonlyoptionalEntsSceneThe things in the scene, as serializeWorld wrote them.
More

A scene, not an asset: this is what a capture proposes or an editor saves, and a file may carry geometry with no scene at all — which is every baked model this format has ever held.

texturesFirstreadonlyoptionalbooleanThe textures ahead of the geometry rather than after it. A model wants its outline before its pictures, so a viewer sees a shape early; a world whose every region wears the same texture arrays wants the pictures before its first region, or that region waits for the file's end. What it costs a model that asks: its first part arrives later by the size of its pictures.