A loader for glTF 2.0 resources.

glTF (GL Transmission Format) is an open format specification for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf) or binary (.glb) format. External files store textures (.jpg, .png, ...) and additional binary data (.bin). A glTF asset may deliver one or more scenes, including meshes, materials, textures, skins, skeletons, morph targets, animations, lights, and/or cameras.


GLTFLoader supports the following glTF extensions:


// Instantiate a loader var loader = new v3d.GLTFLoader(); // Load a glTF resource loader.load('models/gltf/duck/duck.gltf', function(gltf) { scene.add(gltf.scene); gltf.animations; // Array<v3d.AnimationClip> gltf.scene; // v3d.Scene gltf.scenes; // Array<v3d.Scene> gltf.cameras; // Array<v3d.Camera> }); webgl_loader_gltf



manager — The loadingManager for the loader to use. Default is v3d.DefaultLoadingManager.
Creates a new GLTFLoader.



.load (url, onLoad, onProgress, onError) : null

url — required
onLoad — Will be called when load completes. The argument will be the loaded JSON response returned from parse.
onProgress — Will be called while load progresses. The argument will be the XMLHttpRequest instance, that contains .total and .loaded bytes.
onError — Will be called when load errors.
Begin loading from url and call the callback function with the parsed response content.

.setPath (path) : null

path — Base path for loading additional resources e.g. textures and .bin data.
Set the base path for additional resources.

.setCrossOrigin (value) : null

value — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.

.parse (json, callBack, path) : null

jsonJSON object to parse.
callBack — Will be called when parse completes.
path — The base path from which to find subsequent glTF resources such as textures and .bin data files.
Parse a glTF-based JSON structure and fire callback when complete. The argument to callback will be an object that contains loaded parts: .scene, .scenes, .cameras, and .animations.


For more info on how to obtain the source code of this module see this page.