Content

The .drft container

140 symbols, imported from @driftengine/drft.

Explained in The .drft container.

Classes

DrftError
Thrown for any malformed or unreadable file, with the offset that failed.
DrftStream
An incremental .drft reader: feed it bytes, it reports each chunk as that chunk completes.
RegionLedger
What regions must be to each other: an id once, a level mesh in one region's one level, and a group's prototype never also a level mesh. Kept across chunks by the writer, the whole-file reader and the stream alike, so a file one of them refuses the others refuse too.

Interfaces

AnimationClip
BcImage
A block-compressed image, as a CODEC_BC payload holds it.
DrftAssembly
DrftAsset
A decoded asset. See docs/FORMAT.md for what each chunk carries.
DrftGraph
DrftGraphNode
DrftGraphTensor
DrftGraphValue
DrftHead
What HEAD says about the asset as a whole.
DrftInstanceGroup
DrftLight
DrftLightVolume
The same shape as core's DenseLightVolume, so a read volume goes straight to the renderer.
DrftManifest
What the file says is coming, known from the first few kilobytes.
DrftMaterial
One surface, stored once per mesh rather than once per vertex.
DrftMorph
One mesh's morph deltas, and which mesh they belong to.
DrftNetwork
DrftNnet
DrftNode
A node in the asset's own hierarchy. mesh is -1 for a node that draws nothing.
DrftRegion
DrftRegionCollision
DrftRegionLevel
DrftSdfv
DrftSdfvEntry
DrftSkin
A skin: the joints, their inverse bind matrices, and nothing about how it is played.
DrftSource
What a caller hands over to be baked.
DrftSplatBlock
One block of a capture, as the reader hands it back.
DrftSplats
A capture, as the writer is handed it.
DrftStreamHandlers
Called as each kind of thing finishes arriving. Every one is optional.
DrftStreamPacing
When a stream stops to let something else run, and how.
DrftSubs
DrftSubstanceEntry
DrftTexture
An embedded image, still compressed. Decoding is the consumer's, through createImageBitmap.
DrftTextureSource
An image to embed, already compressed, with what its own header said about it.
DtexEntry
A material's decode program, and which MATL entry it belongs to.
DtexMaterial
EntsScene
A world as data. @driftengine/entities' SerializedScene is one of these.
Joint
One joint: where it hangs and what it is called.
JointTrack
One joint's keys for one of its three transforms.
MeshData
A description of vertex data, and the check that it is coherent.
MeshletLevel
NavPolyMesh
A polygon mesh and where it stands. @driftengine/nav's PolyMesh is one of these.

Functions

assemblyBounds
Min xyz then max xyz of every copy: its piece's box through its matrix, corner by corner.
bcChainLength
How many levels a full chain from width by height down to 1x1 has.
bcLevelBytes
The bytes level level of a width by height surface takes in format.
buildAssembly
buildClip
buildColliders
buildDtex
buildEnts
buildInstances
buildKit
buildLights
buildLightVolume
buildMeshlets
buildMorph
buildNavm
buildNgrf
Write the chunk. Refuses anything a reader would have to guess about.
buildNnet
Write the chunk. Refuses anything a reader would have to guess about.
buildNodes
buildRegion
buildSdfv
Write the chunk. Refuses anything a reader would have to guess about.
buildSkin
buildSubs
u32 count, then per entry: u32 material, u32 name bytes, then the UTF-8 name.
checkAssembly
What an assembly must be on its own: known bits, whole records, surfaces it names, finite numbers, whole layers, and no copy flattened to nothing — whose normals would be a division by zero rather than a direction.
checkCopies
What an assembly must be to the kit around it: every copy a declared piece that comes before it in the file — so a streaming reader holds the piece when the copy lands — and every piece carrying what the assembly asks of it. Shared by the writer and both readers, so a file one refuses the others refuse too.
coarseFirstOrder
The order to write a capture's splats in, so that every prefix of the file is a complete sparse capture rather than a finished corner of one.
codecName
What a codec is called, for a message naming what was not understood.
expandAssembly
isAssembly
Whether a mesh slot holds an assembly rather than vertices.
nnetWeightCount
How many weights and biases a shape needs, in evalNetwork's layout.
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.
readAssembly
One MSHC payload, checked on its own; its pieces are the caller's to check.
readBcPayload
A payload read back, its levels as views over bytes.
readClip
readColliders
The hulls a COLL chunk carries, as views over the fetched buffer.
readDrft
readDtex
The material a DTEX chunk carries, as views over the fetched buffer.
readEnts
The scene an ENTS chunk carries.
readInstances
The groups in an INST payload, each checked against the file's mesh count.
readKit
The kit's pieces, ascending and each a mesh the file carries.
readLights
The lights in a LITE payload.
readLightVolume
readMeshlets
The level an MSHL chunk carries, as views over the fetched buffer.
readMorph
readNavm
The mesh a NAVM chunk carries, as views over the fetched buffer.
readNgrf
Read the chunk, refusing every structure and offset a reader would otherwise have to trust.
readNnet
Read the chunk, refusing every shape a reader would otherwise have to trust.
readNodes
readRegion
One REGN payload, checked on its own against the file's mesh count.
readSdfv
Read the chunk, refusing every shape a reader would otherwise have to trust.
readSkin
readSubs
streamDrft
Read a .drft from a fetch response as it arrives.
validateMeshData
Every attribute covers every vertex, and every index names one that exists.
writeBcPayload
The payload for image. Refuses a level whose size is not the one its position requires.
writeDrft
Bake a .drft into one ArrayBuffer.

Types

BcFormat
The block formats a CODEC_BC payload may hold: what one 4x4 block of texels encodes.
DrftAttribute
DrftLightKind
PieceLookup
Finds a kit piece by mesh ordinal.
TrackPath
Which of a joint's three transforms a track drives.

Constants

ASSEMBLY_ATTRIBUTES
The optional arrays an assembled mesh may carry. Skinning is a piece of a character, not a kit.
ATTR_CHANNEL
Added in 1.23: MeshData.channel, four floats a vertex — sway, sky, opacity, and a spare lane.
ATTR_EMISSIVE_COLOR
ATTR_GRAIN
Added in 1.1, and the worked example of why the order is frozen rather than tidy.
ATTR_LAYERS
Added in 1.20: which image of a texture array each vertex's face wears. See MeshData.layers.
ATTR_RELIEF
Added in 1.3, and it is the same story as grain one bit along.
ATTR_ROUGHNESS
ATTR_SPECULAR
Which optional attributes a MESH chunk carries.
ATTR_TANGENT
Added in 1.4, and the first optional attribute wider than three floats a vertex.
ATTR_UVS
BC_BLOCK_BYTES
Bytes per 4x4 block of each format.
CODEC_BC
Added in 1.24: block-compressed images, kept as the blocks they were authored in.
CODEC_JPEG
CODEC_PNG
How a TEXS payload is encoded.
CODEC_RAW
CODEC_WEBP
COPY_MATRIX_FLOATS
A copy's matrix: three columns of the linear part, then the translation.
COPY_UV_FLOATS
A copy's texture stretch: u along each piece axis, v along each, then the offset.
DEFAULT_STREAM_SLICE_MS
How long a stream may work before it gives way for a task, in milliseconds. The loader's own frame budget is six, and this is the same share of a 60 Hz frame for the same reason.
DRFT_VERSION_MAJOR
The generation of the layout. Bumped only when a byte changes meaning.
DRFT_VERSION_MINOR
Additive revisions within a generation: new optional chunks, new attribute bits, new enum values with a defined fallback. Never a changed meaning.
DTEX_ADDRESS_MODES
Address modes the decode vocabulary has. Mirrors ADDRESS_MODE_COUNT; asserted equal by a test.
DTEX_MAX_TILES
How many tiles one material may carry. Well past what a streaming budget permits.
DTEX_REGISTERS
Registers the decode vocabulary has. Mirrors MAX_REGISTERS; asserted equal by a test.
MAX_CLUSTERS
How many clusters one level may carry. Well past what a streaming budget permits.
MAX_COLLIDER_HULLS
A cap on hulls per asset, so a malformed length cannot ask a reader for gigabytes.
MAX_COLLIDER_POINTS
How many points one hull may carry, which is what hullShape accepts.
NNET_ENTRY_BYTES
Role, three counts, eight widths, precision and weight count.
NNET_MAX_HIDDEN
Hidden layers the entry table has room for.
NNET_MAX_WIDTH
The widest layer a network may declare.
REGION_MAX_LEVELS
The most levels a region may carry; the runtime keeps one value of a byte for "none".
SDFV_ENTRY_BYTES
u32 mesh, three u32 dimensions and six f32 bounds. A field's samples are elsewhere.
SDFV_MAX_SAMPLES
The most samples one field may declare.
SDFV_WHOLE_FILE
The mesh ordinal that means the file's static geometry as a whole, in the file's own space.
SURFACE
Where each value sits in a surface, whichever of them the mesh carries.
SURFACE_FLOATS