Capítulo 194 de 859
A loader for loading a JSON resource in the JSON Object/Scene format. The files are internally loaded via FileLoader.
const loader = new THREE.ObjectLoader();
const obj = await loader.loadAsync( 'models/json/example.json' );
scene.add( obj );
// Alternatively, to parse a previously loaded JSON structure
const object = await loader.parseAsync( a_json_object );
scene.add( object );
Constructor
| Signature |
|---|
new ObjectLoader( manager : LoadingManager ) |
Methods
| Method | Description |
|---|---|
.load( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback ) | Starts loading from the given URL and pass the loaded 3D object to the onLoad() callback. |
.loadAsync( url : string, onProgress : onProgressCallback ) : Promise.<Object3D> (async) | Async version of ObjectLoader#load. |
.parse( json : Object, onLoad : onLoad ) : Object3D | Parses the given JSON. This is used internally by ObjectLoader#load but can also be used directly to parse a previously loaded JSON structure. |
.parseAsync( json : Object ) : Promise.<Object3D> (async) | Async version of ObjectLoader#parse. |