Capítulo 674 de 859
Handles and keeps track of loaded and pending data. A default global instance of this class is created and used by loaders if not supplied manually.
In general that should be sufficient, however there are times when it can be useful to have separate loaders - for example if you want to show separate loading bars for objects and textures.
const manager = new THREE.LoadingManager();
manager.onLoad = () => console.log( 'Loading complete!' );
const loader1 = new OBJLoader( manager );
const loader2 = new ColladaLoader( manager );
Constructor
| Signature |
|---|
new LoadingManager( onLoad : function, onProgress : function, onError : function ) |
Properties
| Property | Description |
|---|---|
.abortController : AbortController | Used for aborting ongoing requests in loaders using this manager. |
| `.onError : function | undefined` |
| `.onLoad : function | undefined` |
| `.onProgress : function | undefined` |
| `.onStart : function | undefined` |
Methods
| Method | Description |
|---|---|
.abort() : LoadingManager | Can be used to abort ongoing loading requests in loaders using this manager. The abort only works if the loaders implement Loader#abort and AbortSignal.any() is supported in th… |
.addHandler( regex : string, loader : Loader ) : LoadingManager | Registers a loader with the given regular expression. Can be used to define what loader should be used in order to load specific files. A typical use case is to overwrite the default loader for textu… |
.getHandler( file : string ) : Loader | Can be used to retrieve the registered loader for the given file path. |
.itemEnd( url : string ) | This should be called by any loader using the manager when the loader ended loading an item. |
.itemError( url : string ) | This should be called by any loader using the manager when the loader encounters an error when loading an item. |
.itemStart( url : string ) | This should be called by any loader using the manager when the loader starts loading an item. |
.removeHandler( regex : string ) : LoadingManager | Removes the loader for the given regular expression. |
.resolveURL( url : string ) : string | Given a URL, uses the URL modifier callback (if any) and returns a resolved URL. If no URL modifier is set, returns the original URL. |
.setURLModifier( transform : function ) : LoadingManager | If provided, the callback will be passed each resource URL before a request is sent. The callback may return the original URL, or a new URL to override loading behavior. This behavior can be used to … |