From dc8233c1d5559e98c2d83b70c6da62a5dd1b7d9e Mon Sep 17 00:00:00 2001
From: Robert Long [method:null setDRACOLoader]( [param:DRACOLoader dracoLoader] )
Refer to this [link:https://github.com/mrdoob/three.js/tree/dev/examples/js/libs/draco#readme readme] for the details of Draco and its decoder.
+ [page:String value] — When true, [page:Function parse] and [page:Function load] will return an object with the parser property set. +
++ When lazy loading is enabled and the provided url points to a .gltf file [page:Function load] will only download the .gltf file. [page:Function parse] and [page:Function load] will not call parser.parse() or parser.getDependency(). Examples: +
+
+ var loader = new THREE.GLTFLoader();
+
+ loader.setLazy(true);
+
+ loader.load('foo.gltf', function ( gltf ) {
+
+ var parser = gltf.parser;
+
+ // Modify the glTF before calling parse
+ parser.json.node[ 3 ].extensions = { EXT_foo: { bufferView: 3 } };
+
+ // Load part of the gltf
+ parser.getDependency( "bufferView", 1 ).then( createNavMesh );
+
+ // Load the entire glTF
+ parser.parse( function ( scene, scenes, cameras, animations, json ) { } );
+
+ } );
+
+
[page:ArrayBuffer data] — glTF asset to parse, as an ArrayBuffer or JSON string.
diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js
index 8946d295adebc2..9175cd47696f2e 100644
--- a/examples/js/loaders/GLTFLoader.js
+++ b/examples/js/loaders/GLTFLoader.js
@@ -12,6 +12,7 @@ THREE.GLTFLoader = ( function () {
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
this.dracoLoader = null;
+ this.lazy = false;
}
@@ -76,6 +77,13 @@ THREE.GLTFLoader = ( function () {
},
+ setLazy: function ( lazy ) {
+
+ this.lazy = lazy;
+ return this;
+
+ },
+
parse: function ( data, path, onLoad, onError ) {
var content;
@@ -172,6 +180,14 @@ THREE.GLTFLoader = ( function () {
} );
+ if ( this.lazy ) {
+
+ onLoad( { parser: parser } );
+
+ return;
+
+ }
+
parser.parse( function ( scene, scenes, cameras, animations, json ) {
var glTF = {
From 77afa8cb776225332fcf24980b9fcc973387cb8f Mon Sep 17 00:00:00 2001
From: Robert Long