Loader
Base class for implementing loaders.
Constructor
Loader
function Loader( manager: LoadingManager ): void;
manager — The loadingManager for the loader to use. Default is THREE.DefaultLoadingManager.
Creates a new Loader.
Properties
crossOrigin
crossOrigin: String;
The crossOrigin string to implement CORS for loading the url from a different
domain that allows CORS. Default is anonymous.
withCredentials
withCredentials: Boolean;
Whether the XMLHttpRequest uses credentials. See .setWithCredentials.
Default is false.
manager
manager: LoadingManager;
The loadingManager the loader is using. Default is DefaultLoadingManager.
path
path: String;
The base path from which the asset will be loaded. Default is the empty string.
resourcePath
resourcePath: String;
The base path from which additional resources like textures will be loaded. Default is the empty string.
requestHeader
requestHeader: Object;
The request header used in HTTP request. See .setRequestHeader. Default is empty object.
Methods
load
function load( ): undefined;
This method needs to be implement by all concrete loaders. It holds the logic for loading the asset from the backend.
loadAsync
function loadAsync( url: String, onProgress: Function ): Promise;
url — A string containing the path/URL of the file to be loaded.
onProgress (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.
This method is equivalent to .load, but returns a Promise.
onLoad is handled by Promise.resolve and onError is handled by Promise.reject.
parse
function parse( ): undefined;
This method needs to be implement by all concrete loaders. It holds the logic for parsing the asset into three.js entities.
setCrossOrigin
function setCrossOrigin( crossOrigin: String ): this;
crossOrigin — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
setWithCredentials
function setWithCredentials( value: Boolean ): this;
Whether the XMLHttpRequest uses credentials such as cookies, authorization
headers or TLS client certificates. See XMLHttpRequest.withCredentials.
Note that this has no effect if you are loading files locally or from the same
domain.
setPath
function setPath( path: String ): this;
path — Set the base path for the asset.
setResourcePath
function setResourcePath( resourcePath: String ): this;
resourcePath — Set the base path for dependent resources like textures.
setRequestHeader
function setRequestHeader( requestHeader: Object ): this;
requestHeader - key: The name of the header whose value is to be set. value: The value to set as the body of the header.
Set the request header used in HTTP request.