Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FileLoader doc #13489

Merged
merged 1 commit into from
Mar 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 40 additions & 37 deletions docs/api/loaders/FileLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2>Example</h2>
<code>
var loader = new THREE.FileLoader();

//load a text file a output the result to the console
//load a text file and output the result to the console
loader.load(
// resource URL
'example.txt',
Expand All @@ -47,27 +47,25 @@ <h2>Example</h2>
);
</code>

<h2>Constructor</h2>

<h3>[name]( [param:LoadingManager manager] )</h3>
<div>
[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use.
Default is [page:DefaultLoadingManager].
<em>Note:</em> The cache must be enabled using
<code>THREE.Cache.enabled = true;</code>
This is a global property and only needs to be set once to be used by all loaders that use FileLoader internally.
[page:Cache Cache] is a cache module that holds the response from each request made through this loader, so each file is requested once.
</div>


<h2>Properties</h2>
<h2>Constructor</h2>

<h3>[property:Cache cache]</h3>
<h3>[name] ( [param:LoadingManager manager] )</h3>
<div>
A reference to [page:Cache Cache] that hold the response from each request made
through this loader, so each file is requested once.<br /><br />

<em>Note:</em>The cache must be enabled using
<code>THREE.Cache.enabled = true.</code>
This is a global property and only needs to be set once to be used by all loaders that use FileLoader internally.
[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use.
Default is [page:DefaultLoadingManager].
</div>


<h2>Properties</h2>

<h3>[property:LoadingManager manager]</h3>
<div>
The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
Expand All @@ -82,29 +80,31 @@ <h3>[property:String mimeType]</h3>
<h3>[property:String path]</h3>
<div>The base path from which files will be loaded. See [page:.setPath]. Default is *undefined*.</div>

<h3>[property:object requestHeader]</h3>
<div>The [link:https://developer.mozilla.org/en-US/docs/Glossary/Request_header request header] used in HTTP request. See [page:.setRequestHeader]. Default is *undefined*.</div>

<h3>[property:String responseType]</h3>
<div>The expected response type. See [page:.setResponseType]. Default is *undefined*.</div>

<h3>[property:String withCredentials]</h3>
<div>
Whether the XMLHttpRequest uses credentials - see [page:.setWithCredentials].
Whether the XMLHttpRequest uses credentials. See [page:.setWithCredentials].
Default is *undefined*.
</div>



<h2>Methods</h2>

<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<div>
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] — Will be called when loading completes. The argument will be the loaded response.<br />
[page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance,
which contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
[page:Function onError] — Will be called if an error occurs.<br /><br />

Load the URL and pass the response to the onLoad function.
[page:String url] — the path or URL to the file. This can also be a
[link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
[page:Function onLoad] (optional) — Will be called when loading completes. The argument will be the loaded response.<br />
[page:Function onProgress] (optional) — Will be called while load progresses. The argument will be the XMLHttpRequest instance,
which contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
[page:Function onError] (optional) — Will be called if an error occurs.<br /><br />

Load the URL and pass the response to the onLoad function.
</div>

<h3>[method:FileLoader setMimeType]( [param:String mimeType] )</h3>
Expand All @@ -119,28 +119,31 @@ <h3>[method:FileLoader setPath]( [param:String path] )</h3>
you are loading many models from the same directory.
</div>

<h3>[method:FileLoader setResponseType]( [param:String responseType] )</h3>
<h3>[method:FileLoader setRequestHeader]( [param:object requestHeader] )</h3>
<div>
[page:String responseType] — Default is '' (empty string).<br /><br />
[page:object requestHeader] - key: The name of the header whose value is to be set. value: The value to set as the body of the header.<br /><br />

Change the response type. Valid values are:<br />
[page:String text], empty string (default), or any other value. Any file type, returns the unprocessed file data.<br />
[page:String arraybuffer] - loads the data into a [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer ArrayBuffer] and returns that.<br />
[page:String blob] - returns the data as a [link:https://developer.mozilla.org/en/docs/Web/API/Blob Blob].<br />
[page:String document] - parse the file using the [link:https://developer.mozilla.org/en-US/docs/Web/API/DOMParser DOMParser].<br />
[page:String json] - parse the file using [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse JSON.parse].<br />
Set the [link:https://developer.mozilla.org/en-US/docs/Glossary/Request_header request header] used in HTTP request.
</div>

<h3>[method:FileLoader setResponseType]( [param:String responseType] )</h3>
<div>
Change the response type. Valid values are:<br />
[page:String text] or empty string (default) - returns the data as [page:String string].<br />
[page:String arraybuffer] - loads the data into a [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer ArrayBuffer] and returns that.<br />
[page:String blob] - returns the data as a [link:https://developer.mozilla.org/en/docs/Web/API/Blob Blob].<br />
[page:String document] - parses the file using the [link:https://developer.mozilla.org/en-US/docs/Web/API/DOMParser DOMParser].<br />
[page:String json] - parses the file using [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse JSON.parse].<br />
</div>

<h3>[method:FileLoader setWithCredentials]( [param:Boolean value] )</h3>
Whether the XMLHttpRequest uses credentials such as cookies, authorization headers or
TLS client certificates. See
[link:https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials XMLHttpRequest.withCredentials].<br />
Note that this has no effect if you are loading files locally or from the same domain.
<div>

Whether the XMLHttpRequest uses credentials such as cookies, authorization headers or
TLS client certificates. See [link:https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials XMLHttpRequest.withCredentials].<br />
Note that this has no effect if you are loading files locally or from the same domain.
</div>


<h2>Source</h2>

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
Expand Down