Loader

Base class for implementing loaders.

Constructor

Loader(manager : LoadingManager)

manager — The loadingManager for the loader to use. Default is v3d.DefaultLoadingManager.

Creates a new Loader.

Properties

.crossOrigin : String

The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS. Default is anonymous.

.withCredentials : Boolean

Whether the XMLHttpRequest uses credentials. See .setWithCredentials. Default is false.

.manager : LoadingManager

The loadingManager the loader is using. Default is DefaultLoadingManager.

.path : String

The base path from which the asset will be loaded. Default is the empty string.

.resourcePath : String

The base path from which additional resources like textures will be loaded. Default is the empty string.

.requestHeader : Object

The request header used in HTTP request. See .setRequestHeader. Default is empty object.

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 : 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()

This method needs to be implement by all concrete loaders. It holds the logic for parsing the asset into Verge3D entities.

.setCrossOrigin(crossOrigin : String) → this

crossOrigin — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.

.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(path : String) → this

path — Set the base path for the asset.

.setResourcePath(resourcePath : String) → this

resourcePath — Set the base path for dependent resources like textures.

.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.

Source

For more info on how to obtain the source code of this module see this page.