Class: FileLoader

zen3d.FileLoader(manager)

new FileLoader(manager)

A low level class for loading resources with XMLHttpRequest, used internaly by most loaders. It can also be used directly to load any file type that does not have a loader.
Parameters:
Name Type Description
manager zen3d.LoadingManager — The loadingManager for the loader to use. Default is zen3d.DefaultLoadingManager.
Source:

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

setMimeType(value) → {zen3d.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
Source:
Returns:
Type
zen3d.FileLoader

setPath(value) → {zen3d.FileLoader}

Set the base path or URL from which to load files. This can be useful if you are loading many models from the same directory.
Parameters:
Name Type Description
value string
Source:
Returns:
Type
zen3d.FileLoader

setRequestHeader(value) → {zen3d.FileLoader}

The request header used in HTTP request. Default is undefined.
Parameters:
Name Type Description
value string
Source:
Returns:
Type
zen3d.FileLoader

setResponseType(value) → {zen3d.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
Source:
Returns:
Type
zen3d.FileLoader

setWithCredentials(value) → {zen3d.FileLoader}

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.
Parameters:
Name Type Description
value boolean
Source:
Returns:
Type
zen3d.FileLoader