Constructor
new Loader(manageropt)
Creates a new Loader.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
manager | t3d. | <optional> | t3d.DefaultLoadingManager | The loadingManager the loader is using. |
Members
crossOrigin :String
The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
Type:
- String
- Default Value
- 'anonymous'
manager :t3d.LoadingManager
The loadingManager the loader is using.
Type:
- Default Value
- t3d.DefaultLoadingManager
path :String
The base path from which the asset will be loaded.
Type:
- String
- Default Value
- ''
requestHeader :Object
The request header used in HTTP request.
Type:
- Object
- Default Value
- {}
withCredentials :Boolean
Whether the XMLHttpRequest uses credentials.
Type:
- Boolean
- Default Value
- false
Methods
load()
This method needs to be implement by all concrete loaders. It holds the logic for loading the asset from the backend.
loadAsync(url, onProgressopt) → {Promise}
This method is equivalent to .load, but returns a Promise. onLoad is handled by Promise.resolve and onError is handled by Promise.reject.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url | String | A string containing the path/URL of the file to be loaded. | |
onProgress | function | <optional> | A function to be called while the loading is in progress. The argument will be the ProgressEvent instance, which contains .lengthComputable, .total and .loaded. If the server does not set the Content-Length header; .total will be 0. |
Returns:
- Type:
- Promise
setCrossOrigin(crossOrigin) → {this}
Parameters:
Name | Type | Description |
---|---|---|
crossOrigin | String | The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS. |
Returns:
- Type:
- this
setPath(path) → {this}
Parameters:
Name | Type | Description |
---|---|---|
path | String | Set the base path for the asset. |
Returns:
- Type:
- this
setRequestHeader(requestHeader) → {this}
Parameters:
Name | Type | Description |
---|---|---|
requestHeader | Object | key: The name of the header whose value is to be set. value: The value to set as the body of the header. |
Returns:
- Type:
- this
setWithCredentials(value) → {this}
Parameters:
Name | Type | Description |
---|---|---|
value | Boolean | Whether the XMLHttpRequest uses credentials such as cookies, authorization headers or TLS client certificates. Note that this has no effect if you are loading files locally or from the same domain. |
Returns:
- Type:
- this