The .drft container · interface

DrftAsset

A decoded asset. See docs/FORMAT.md for what each chunk carries.

Explained in The .drft container.

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

Properties

NameTypeDescription
meshesreadonlyreadonly MeshData[]
lodsreadonlyreadonly MeshData[]Coarse whole-asset levels of detail, coarsest first, or empty for a file carrying none.
More

Separate from meshes because they are not parts of the model: each one is the model, at a resolution that arrives sooner. A consumer reading a whole file at once has no use for them and ignores them; the streaming loader draws the best one it has until the real geometry is complete. See DrftLoader and docs/FORMAT.md §4.6.

levelsreadonlyreadonly Uint8Array[]Discrete levels of detail, finest first, each a complete .drft still in its bytes.
More

Handed over unparsed on purpose. A level is a whole model, and a consumer that picks one by distance wants exactly one of them — parsing all four to hand back three that will not be drawn is work nobody asked for. Pass the one you want to readDrft again.

splatsreadonlyDrftSplatBlock | nullThe whole capture, assembled from every SPLT block in ordinal order, or null for a file carrying none.
More

Assembled rather than handed over as blocks, because a caller reading a whole file at once has no use for the split: it exists so a stream can put a sparse capture on screen early, and DrftStream.onSplats is where that matters. The records still arrive in the file's coarse-first order, so a consumer that draws a prefix of them draws a sparse whole.

dtexreadonlyreadonly DtexEntry[]A decode program per material, or empty for a file that carries none.
More

Each says which MATL entry it belongs to. A reader that does not know this chunk skips it by its length and loses only the material it could not have decoded, which is what keeps the format's freeze intact.

entitiesreadonlyEntsScene | nullThe things in the scene, or null for a file that is an asset rather than a scene.
nodesreadonlyreadonly DrftNode[]The asset's own hierarchy, or empty for a file carrying no NODE.
More

Empty means what it always meant — one mesh at the origin — so a caller written before 1.6 behaves identically against a file with a hierarchy it ignores.

instancesreadonlyreadonly DrftInstanceGroup[]Meshes drawn many times, each group naming the mesh that holds one copy and a matrix a copy. Empty for a file that instances nothing, which is every file before 1.18.
lightsreadonlyreadonly DrftLight[]The lights the scene was authored with, or empty. LITE, defined at 1.18.
skinsreadonlyreadonly DrftSkin[]Skins, in the order their chunks appear. Empty for a file that deforms nothing.
clipsreadonlyreadonly AnimationClip[]Clips, in the order their chunks appear. Empty for a file that animates nothing.
materialsreadonlyreadonly DrftMaterial[]One per mesh by ordinal, or empty when the file names no materials.
texturesreadonlyreadonly DrftTexture[]
substancesreadonlyreadonly { readonly material: number; readonly substance: string; }[]Which substance each material is made of, or empty where the file labels none.
More

The SUBS chunk, added at 1.8. Hand these to installChemistry().match — which matches exactly and reports what it could not, rather than guessing.

fieldsreadonlyreadonly DrftSdfvEntry[]The signed distance field of each mesh that carries one, or empty for a file with none.
More

The SDFV chunk, added at 1.13. Views over the fetched buffer, so a file that carries fields for geometry a consumer never traces through costs one view apiece and no copy. Hand them to composeGlobalField, which is what turns per-object fields into a world around the camera.

networksreadonlyreadonly DrftNetwork[]The networks the file carries, each with the role a consumer asks for it by, or empty.
More

The NNET chunk, added at 1.14. Weights are views over the fetched buffer, in the precision they were written in — half-precision bits stay bits, because the device uploads them as such.

graphsreadonlyreadonly DrftGraph[]The graphs the file carries — networks built from operators — each with its role, or empty.
More

The NGRF chunk, added at 1.15. Tensors are views over the fetched buffer where its alignment allows, in the precision they were written in. @driftengine/texture validates one before it runs, naming any operator it lacks.

collidersreadonlyreadonly Float32Array[]The convex hulls this asset collides as, or empty for a file carrying no COLL.
More

Views over the fetched buffer, xyz-packed, in the asset's own space. Turning them into shapes is one line and belongs to whoever has a physics package:

const shapes = asset.colliders.map((points) => hullShape(points));
regionsreadonlyreadonly DrftRegion[]The regions of a streamed world, in the order they were written, or empty. REGN, defined at 1.21: each names the meshes it draws at every level, its props, occluders and collision.
lightVolumereadonlyDrftLightVolume | nullA world's summed lights, or null for a file carrying no LVOL. Defined at 1.22.
kitreadonlyreadonly number[]The meshes that are kit pieces, ascending, or empty. KITS, defined at 1.23. A piece is in meshes like any other, and is drawn only as copies inside the assemblies.
assembliesreadonlyReadonlyMap<number, DrftAssembly>Each MSHC mesh as the file carried it, by ordinal, or empty. Its slot in meshes holds it expanded — which for a world built from a kit is most of a gigabyte, so a consumer of such a file streams it (DrftStream.onAssembly) rather than reading it whole.
skippedreadonlyreadonly string[]Optional chunks this reader did not understand, in file order. Diagnostics only.
versionMajorreadonlynumber
versionMinorreadonlynumber