[name]

A loader for loading a [page:Scene] from a JSON resource.

Constructor

[name]( [page:LoadingManager manager] )

[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
Creates a new [name].

Properties

Methods

[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )

[page:String url] — required
[page:Function onLoad] — Will be called when load completes. The argument will be an [page:Object] containing the loaded components.
[page:Function onProgress] — Will be called while load progresses. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.
[page:Function onError] — Will be called when load errors.
Begin loading from url and call onLoad with the parsed scene.

[method:Object parse]( [page:Object json], [page:Function callbackFinished], [page:String url] )

[page:Object json] — The JSON structure to parse.
[page:Function callbackFinished] — Will be called when parse completes.
[page:String url] — Will be used as base for assets' relative URLs.
Parse a JSON scene description and return a new [page:Object] with fully instantiated Three.js objects.

[method:null setCrossOrigin]( [page:String value] )

[page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.

[method:null addGeometryHandler]( [page:String typeID], [page:Function loaderClass] )

[page:String typeID] — The type to handle.
[page:Function loaderClass] — The handler class.
Add an handler for a specific geometry type.

[method:null addHierarchyHandler]( [page:String typeID], [page:Function loaderClass] )

[page:String typeID] — The type to handle.
[page:Function loaderClass] — The handler class.
Add an handler for a specific object type.

Example

// instantiate a loader var loader = new THREE.SceneLoader(); // Handle STL geometries loader.addGeometryHandler( "stl", THREE.STLLoader ); // Handle OBJ objects loader.addHierarchyHandler( "obj", THREE.OBJLoader ); // load a JSON resource loader.load( // resource URL 'scenes/test_scene.js', // Function when resource is loaded function ( result ) { scene.add( result.scene ); }, // Function called when download progresses function ( xhr ) { console.log( (xhr.loaded / xhr.total * 100) + '% loaded' ); }, // Function called when download errors function ( xhr ) { console.log( 'An error happened' ); } ); [example:webgl_loader_scene]

Source

[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/SceneLoader.js examples/js/loaders/SceneLoader.js]