Model loading · interface

ModelSource

A model file, plus the capabilities its format may need to be read.

Explained in Importing models.

interface ModelSource
import type { ModelSource } from '@driftengine/assets';

Properties

NameTypeDescription
namereadonlystringThe file's own name, used for its extension and in messages.
More

The extension is a claim and the magic bytes are the fact, which is why recognise runs before the dispatch below rather than after it.

bytesreadonlyUint8Array
besidereadonlyoptional(relativePath: string) => Promise<Uint8Array | null>Fetch a file named beside this one, or null where there is none.
More

Needed by a .gltf naming external buffers and by an .obj naming an .mtl. The path is relative and comes from inside the model, so a host that fetches it is choosing to resolve a name the file supplied: resolve it against the model's own directory and nothing above it.

inflatereadonlyoptionalInflatezlib-wrapped inflate, for .fbx. See fbxInflate.ts for the browser's.
inflateRawreadonlyoptionalInflateRaw deflate inflate, for the zip inside a .3mf. Not the same function as inflate.
decompressreadonlyoptionalBlendDecompressgzip and zstd, for a .blend saved compressed. See blendPacked.ts.
deriveTangentsreadonlyoptionalbooleanDerive a tangent frame where a material declares a normal map and the file supplies none.
More

On by default. A caller that is about to weld should pass false and call deriveTangentsFor afterwards, which the baker does: the derivation accumulates per index, so on a mesh stored as one vertex per triangle corner it gives every corner its own frame and the weld can merge none of them. Measured at 9,600 corners welding to 9,482 rather than 1,681.

Only glTF derives one at all, so this is inert for every other format. A frame the file supplies is kept either way.