The .drft container · interface
DrftStreamHandlers
Called as each kind of thing finishes arriving. Every one is optional.
Explained in The .drft container.
interface DrftStreamHandlersimport type { DrftStreamHandlers } from '@driftengine/drft';In depth
A consumer that wants the whole asset at once should use readDrft; these exist so a scene
can put a coarse thing on screen and improve it, which is the point of streaming at all.
Properties
| Name | Type | Description |
|---|---|---|
onManifestreadonlyoptional | (manifest: DrftManifest) => void | The table has arrived, so what is coming is now known. Fires once, before anything else. |
onHeadreadonlyoptional | (head: DrftHead) => void | |
onLodreadonlyoptional | (mesh: MeshData, level: number) => void | A coarse whole-model level, with its level ordinal: 0 is the coarsest.MoreFires before any part on a file the baker laid out, which is the whole point of it — a complete object on screen while the parts are still arriving. A caller that draws it must stop drawing it in the same frame it starts drawing the model, or the two are both there. |
onMeshreadonlyoptional | (mesh: MeshData, ordinal: number) => void | One mesh, in the order the file lays them out, with its ordinal in that order. A kit piece is
not one — it goes to onPiece — and an assembly is one only where onAssembly is absent, in
which case it arrives here expanded. |
onKitreadonlyoptional | (pieces: readonly number[]) => void | The ordinals of the kit's pieces, once, when KITS lands — ahead of the geometry, so a
consumer knows which meshes are drawn only as copies before any of them arrives. |
onPiecereadonlyoptional | (mesh: MeshData, ordinal: number) => void | One kit piece, as it lands. The stream keeps it for the assemblies that copy it. |
onAssemblyreadonlyoptional | (assembly: DrftAssembly, ordinal: number, piece: PieceLookup) => void | One assembly as the file carried it, with a lookup for its pieces, which have all arrived. A
consumer that pages its world keeps it this small and expands it (expandAssembly) when it is
needed; without this handler the stream expands it and calls onMesh. |
onSplatsreadonlyoptional | (block: DrftSplatBlock, ordinal: number) => void | One block of a Gaussian splat capture, with its ordinal.MoreEvery block is a sparse version of the whole capture, so the first one is already worth
drawing — that is what the writer's coarse-first ordering buys and it is the reason splats
are in this container rather than in a file of their own. A consumer allocates from
|
onNodesreadonlyoptional | (nodes: readonly DrftNode[]) => void | The asset's hierarchy, once, when its NODE chunk lands.MoreHanded over whole rather than a node at a time: a hierarchy is one chunk and a partial one is not useful — a child whose parent has not arrived cannot be placed. |
onInstancesreadonlyoptional | (groups: readonly DrftInstanceGroup[]) => void | The asset's instance groups, once, when INST lands — ahead of the meshes, where the writer
puts it, so a consumer knows a mesh is drawn many times before that mesh arrives. |
onRegionreadonlyoptional | (region: DrftRegion) => void | One region of a streamed world, when its REGN lands — ahead of the meshes it introduces, so
a consumer knows a mesh is a region's level or prop before it arrives. See drftRegions.ts. |
onLightVolumereadonlyoptional | (volume: DrftLightVolume) => void | A world's summed lights, once, when LVOL lands. See drftLightVolume.ts. |
onLightsreadonlyoptional | (lights: readonly DrftLight[]) => void | The lights the scene was authored with, once, when LITE lands. See drftLights.ts. |
onFieldsreadonlyoptional | (fields: readonly DrftSdfvEntry[]) => void | The distance fields indirect light is traced against, once, when SDFV lands. Each names the
mesh it belongs to, or SDFV_WHOLE_FILE for one over all of the file's static geometry. |
onMorphreadonlyoptional | (morph: DrftMorph) => void | One mesh's morph deltas, naming the mesh ordinal they belong to. |
onSkinreadonlyoptional | (skin: DrftSkin, ordinal: number) => void | One skin, as its SKIN chunk lands. Several arrive for an asset with several. |
onClipreadonlyoptional | (clip: AnimationClip, ordinal: number) => void | One clip, as its ANIM chunk lands.MorePer chunk rather than collected, for the reason |
onCollidersreadonlyoptional | (hulls: readonly Float32Array[]) => void | The convex hulls the asset collides as, once, when COLL lands. See drftColliders.ts.MoreThese three — collision, the navigation mesh and the entities — were |
onNavigationreadonlyoptional | (navigation: NavPolyMesh) => void | The navigation mesh, once, when NAVM lands. See navm.ts. |
onEntitiesreadonlyoptional | (entities: EntsScene) => void | The serialised entities, once, when ENTS lands. See ents.ts. |
onMaterialsreadonlyoptional | (materials: readonly DrftMaterial[]) => void | |
onTexturereadonlyoptional | (texture: DrftTexture, ordinal: number) => void |