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
.drftreader: 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
AnimationClipBcImage- A block-compressed image, as a
CODEC_BCpayload holds it. DrftAssemblyDrftAsset- A decoded asset. See docs/FORMAT.md for what each chunk carries.
DrftGraphDrftGraphNodeDrftGraphTensorDrftGraphValueDrftHead- What
HEADsays about the asset as a whole. DrftInstanceGroupDrftLightDrftLightVolume- 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.
DrftNetworkDrftNnetDrftNode- A node in the asset's own hierarchy.
meshis -1 for a node that draws nothing. DrftRegionDrftRegionCollisionDrftRegionLevelDrftSdfvDrftSdfvEntryDrftSkin- 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.
DrftSubsDrftSubstanceEntryDrftTexture- 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
MATLentry it belongs to. DtexMaterialEntsScene- A world as data.
@driftengine/entities'SerializedSceneis 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.
MeshletLevelNavPolyMesh- A polygon mesh and where it stands.
@driftengine/nav'sPolyMeshis 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
widthbyheightdown to 1x1 has. bcLevelBytes- The bytes level
levelof awidthbyheightsurface takes informat. buildAssemblybuildClipbuildCollidersbuildDtexbuildEntsbuildInstancesbuildKitbuildLightsbuildLightVolumebuildMeshletsbuildMorphbuildNavmbuildNgrf- 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.
buildNodesbuildRegionbuildSdfv- Write the chunk. Refuses anything a reader would have to guess about.
buildSkinbuildSubsu32count, then per entry:u32material,u32name 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.
expandAssemblyisAssembly- 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 meshm, andbefore[meshCount]those after the last. A streaming reader then always has a region before the meshes it introduces. readAssembly- One
MSHCpayload, checked on its own; its pieces are the caller's to check. readBcPayload- A payload read back, its levels as views over
bytes. readClipreadColliders- The hulls a
COLLchunk carries, as views over the fetched buffer. readDrftreadDtex- The material a
DTEXchunk carries, as views over the fetched buffer. readEnts- The scene an
ENTSchunk carries. readInstances- The groups in an
INSTpayload, 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
LITEpayload. readLightVolumereadMeshlets- The level an
MSHLchunk carries, as views over the fetched buffer. readMorphreadNavm- The mesh a
NAVMchunk 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.
readNodesreadRegion- One
REGNpayload, checked on its own against the file's mesh count. readSdfv- Read the chunk, refusing every shape a reader would otherwise have to trust.
readSkinreadSubsstreamDrft- Read a
.drftfrom 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
.drftinto oneArrayBuffer.
Types
BcFormat- The block formats a
CODEC_BCpayload may hold: what one 4x4 block of texels encodes. DrftAttributeDrftLightKindPieceLookup- 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_COLORATTR_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
grainone bit along. ATTR_ROUGHNESSATTR_SPECULAR- Which optional attributes a
MESHchunk carries. ATTR_TANGENT- Added in 1.4, and the first optional attribute wider than three floats a vertex.
ATTR_UVSBC_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_JPEGCODEC_PNG- How a
TEXSpayload is encoded. CODEC_RAWCODEC_WEBPCOPY_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
hullShapeaccepts. 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_BYTESu32mesh, threeu32dimensions and sixf32bounds. 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