Function loadGltf
-
Parameters
- engine: EngineContext
The engine to upload GPU resources to.
- source: string | ArrayBuffer | Blob
A URL string, or the raw
ArrayBuffer/Blobof a self-contained glTF/GLB asset.
Returns Promise<AssetContainer>
- engine: EngineContext
Load a glTF/GLB asset, parse it, and upload mesh + material data to GPU. Registers a deferred PBR renderable builder and automatically parses glTF animations if present.
Returns an AssetContainer. Pass it to addToScene which adds the hierarchy, registers animation ticks, and applies any scene-level settings.
The
sourcemay be either:string) — fetches the asset. Supports both binary GLB and separate.gltf+.bin+ image files; relative.bin/image paths are resolved against non-blob:/data:URLs.blob:anddata:URL strings have no directory base, so they must be self-contained like raw data.ArrayBuffer|Blob) — loads from already-loaded local data (drag-and-drop, OPFS, afetchbody, etc.). GLB-vs-glTF is determined from the data's magic bytes, not a file extension. Because raw data has no base URL it must be self-contained: a GLB, or a glTF whose buffers/images usedata:URIs. A glTF that references external.bin/image files by relative path can only be loaded from a URL.