t3d. LoadingManager

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 - see t3d.DefaultLoadingManager. In general that should be sufficient, however there are times when it can be useful to have seperate loaders - for example if you want to show seperate loading bars for objects and textures. In addition to observing progress, a LoadingManager can be used to override resource URLs during loading. This may be helpful for assets coming from drag-and-drop events, WebSockets, WebRTC, or other APIs.

Constructor

new LoadingManager(onLoadopt, onProgressopt, onErroropt)

Creates a new LoadingManager.
Parameters:
NameTypeAttributesDescription
onLoadfunction<optional>
— this function will be called when all loaders are done.
onProgressfunction<optional>
— this function will be called when an item is complete.
onErrorfunction<optional>
— this function will be called a loader encounters errors.

Members

onStart :function

This function will be called when loading starts. The arguments are: url — The url of the item just loaded. itemsLoaded — the number of items already loaded so far. itemsTotal — the total amount of items to be loaded.
Type:
  • function
Default Value
  • undefined

Methods

itemEnd(url)

This should be called by any loader using the manager when the loader ended loading an url.
Parameters:
NameTypeDescription
urlStringthe loaded url.

itemError(url)

This should be called by any loader using the manager when the loader errors loading an url.
Parameters:
NameTypeDescription
urlStringthe loaded url.

itemStart(url)

This should be called by any loader using the manager when the loader starts loading an url.
Parameters:
NameTypeDescription
urlStringthe url to load.

resolveURL(url)

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.
Parameters:
NameTypeDescription
urlStringthe url to load.

setURLModifier(callback)

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 load assets from .ZIP files, drag-and-drop APIs, and Data URIs.
Parameters:
NameTypeDescription
callbackfunctionURL modifier callback. Called with url argument, and must return resolvedURL.