GLTFLoader
Defined in: addons/src/loaders/GLTFLoader.ts:844
Reads glTF 2.0 files into the engine’s classes, with the methods of three.js’s GLTFLoader
that a page needs: load, loadAsync, parse and parseAsync.
The node tree becomes Object3Ds. Each mesh primitive becomes a Mesh with a
BufferGeometry and a PhysicalMaterial made from the factors of pbrMetallicRoughness.
Textures, skins, animations and morph targets are skipped, and each skip is a sentence in the
result’s warnings. A sparse accessor, a compressed buffer and an extension the file requires
and the loader does not know are errors.
const gltf = await new GLTFLoader().loadAsync('/assets/bunny.glb');scene.add(gltf.scene);Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new GLTFLoader():
GLTFLoader
Returns
Section titled “Returns”GLTFLoader
Methods
Section titled “Methods”load()
Section titled “load()”load(
url,onLoad,onProgress?,onError?):void
Defined in: addons/src/loaders/GLTFLoader.ts:850
Fetches url and parses it. Calls onLoad with the result, or onError with the error (the
error goes to the console when there is no onError). onProgress gets the bytes loaded
while the file comes in.
Parameters
Section titled “Parameters”string
onLoad
Section titled “onLoad”(gltf) => void
onProgress?
Section titled “onProgress?”(event) => void
onError?
Section titled “onError?”(error) => void
Returns
Section titled “Returns”void
loadAsync()
Section titled “loadAsync()”loadAsync(
url,onProgress?):Promise<GLTF>
Defined in: addons/src/loaders/GLTFLoader.ts:860
Fetches url and parses it. Rejects with an Error that starts with GLTFLoader:.
Parameters
Section titled “Parameters”string
onProgress?
Section titled “onProgress?”(event) => void
Returns
Section titled “Returns”Promise<GLTF>
parse()
Section titled “parse()”parse(
data,path,onLoad,onError?):void
Defined in: addons/src/loaders/GLTFLoader.ts:869
Parses data: the text of a .gltf, the bytes of a .gltf or the bytes of a .glb. path
is the directory that the file’s relative buffer URIs are read from, with or without its last
/. Calls onLoad or onError, as load does.
Parameters
Section titled “Parameters”string | ArrayBuffer | ArrayBufferView
string
onLoad
Section titled “onLoad”(gltf) => void
onError?
Section titled “onError?”(error) => void
Returns
Section titled “Returns”void
parseAsync()
Section titled “parseAsync()”parseAsync(
data,path?):Promise<GLTF>
Defined in: addons/src/loaders/GLTFLoader.ts:879
Parses data as parse does and resolves to the result.
Parameters
Section titled “Parameters”string | ArrayBuffer | ArrayBufferView
string = ''
Returns
Section titled “Returns”Promise<GLTF>