Constructor
new FileLoader()
Extends
Members
crossOrigin :String
The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
Type:
- String
- Overrides
- Default Value
- 'anonymous'
manager :t3d.LoadingManager
The loadingManager the loader is using.
Type:
- Overrides
- Default Value
- t3d.DefaultLoadingManager
mimeType :String
The expected mimeType. See t3d.FileLoader.setMimeType.
Type:
- String
- Default Value
- undefined
path :String
The base path from which the asset will be loaded.
Type:
- String
- Overrides
- Default Value
- ''
requestHeader :Object
The request header used in HTTP request.
Type:
- Object
- Overrides
- Default Value
- {}
responseType :String
The expected response type. See t3d.FileLoader.setResponseType.
Type:
- String
- Default Value
- undefined
withCredentials :Boolean
Whether the XMLHttpRequest uses credentials.
Type:
- Boolean
- Overrides
- Default Value
- false
Methods
load(url, onLoad=opt, onProgress=opt, onError=opt)
Load the URL and pass the response to the onLoad function.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url | String | — the path or URL to the file. This can also be a Data URI. | |
onLoad= | function | <optional> | — Will be called when loading completes. The argument will be the loaded response. |
onProgress= | function | <optional> | — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .total and .loaded bytes. |
onError= | function | <optional> | — Will be called if an error occurs. |
- Overrides
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. |
- Overrides
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. |
- Overrides
Returns:
- Type:
- this
setMimeType(value) → {t3d.FileLoader}
Set the expected mimeType of the file being loaded. Note that in many cases this will be determined automatically, so by default it is undefined.
Parameters:
Name | Type | Description |
---|---|---|
value | String |
Returns:
- Type:
- t3d.
FileLoader
setPath(path) → {this}
Parameters:
Name | Type | Description |
---|---|---|
path | String | Set the base path for the asset. |
- Overrides
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. |
- Overrides
Returns:
- Type:
- this
setResponseType(value) → {t3d.FileLoader}
Change the response type. Valid values are: text or empty string (default) - returns the data as string. arraybuffer - loads the data into a ArrayBuffer and returns that. blob - returns the data as a Blob. document - parses the file using the DOMParser. json - parses the file using JSON.parse.
Parameters:
Name | Type | Description |
---|---|---|
value | String |
Returns:
- Type:
- t3d.
FileLoader
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. |
- Overrides
Returns:
- Type:
- this