|
@@ -11,9 +11,7 @@
|
|
|
[page:Loader] →
|
|
|
<h1>[name]</h1>
|
|
|
|
|
|
- <div class="desc">
|
|
|
- A loader for *glTF* 2.0 resources.
|
|
|
- <br /><br />
|
|
|
+ <div class="desc"> A loader for loading <em>glTF 2.0</em> resource. <br />
|
|
|
<a href="https://www.khronos.org/gltf">glTF</a> (GL Transmission Format) is an
|
|
|
<a href="https://github.com/KhronosGroup/glTF/tree/master/specification/2.0">open format specification</a>
|
|
|
for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf)
|
|
@@ -48,19 +46,38 @@
|
|
|
<h2>Example</h2>
|
|
|
|
|
|
<code>
|
|
|
- // Instantiate a loader
|
|
|
- var loader = new THREE.GLTFLoader();
|
|
|
-
|
|
|
- // Load a glTF resource
|
|
|
- loader.load( 'models/gltf/duck/duck.gltf', function ( gltf ) {
|
|
|
- scene.add( gltf.scene );
|
|
|
-
|
|
|
- gltf.animations; // Array<THREE.AnimationClip>
|
|
|
- gltf.scene; // THREE.Scene
|
|
|
- gltf.scenes; // Array<THREE.Scene>
|
|
|
- gltf.cameras; // Array<THREE.Camera>
|
|
|
- } );
|
|
|
- </code>
|
|
|
+ // Instantiate a loader
|
|
|
+ var loader = new THREE.GLTFLoader();
|
|
|
+
|
|
|
+ // Load a glTF resource
|
|
|
+ loader.load(
|
|
|
+ // resource URL
|
|
|
+ 'models/gltf/duck/duck.gltf',
|
|
|
+ // called when the resource is loaded
|
|
|
+ function ( gltf ) {
|
|
|
+
|
|
|
+ scene.add( gltf.scene );
|
|
|
+
|
|
|
+ gltf.animations; // Array<THREE.AnimationClip>
|
|
|
+ gltf.scene; // THREE.Scene
|
|
|
+ gltf.scenes; // Array<THREE.Scene>
|
|
|
+ gltf.cameras; // Array<THREE.Camera>
|
|
|
+
|
|
|
+ },
|
|
|
+ // called when loading is in progresses
|
|
|
+ function ( xhr ) {
|
|
|
+
|
|
|
+ console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
|
|
|
+
|
|
|
+ },
|
|
|
+ // called when loading has errors
|
|
|
+ function ( error ) {
|
|
|
+
|
|
|
+ console.log( 'An error happened' );
|
|
|
+
|
|
|
+ }
|
|
|
+ );
|
|
|
+ </code>
|
|
|
|
|
|
[example:webgl_loader_gltf]
|
|
|
|
|
@@ -81,10 +98,10 @@
|
|
|
|
|
|
<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
|
|
|
<div>
|
|
|
- [page:String url] — required<br />
|
|
|
- [page:Function onLoad] — Will be called when load completes. The argument will be the loaded JSON response returned from [page:Function parse].<br />
|
|
|
- [page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
|
|
|
- [page:Function onError] — Will be called when load errors.<br />
|
|
|
+ [page:String url] — A string containing the path/URL of the <em>.gltf</em> or <em>.glb</em> file.<br />
|
|
|
+ [page:Function onLoad] — (optional) A function to be called after the loading is successfully completed. The function receives the loaded JSON response returned from [page:Function parse].<br />
|
|
|
+ [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
|
|
|
+ [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
|
|
|
</div>
|
|
|
<div>
|
|
|
Begin loading from url and call the callback function with the parsed response content.
|