|
@@ -11,16 +11,47 @@
|
|
|
|
|
|
<h1>[name]</h1>
|
|
<h1>[name]</h1>
|
|
|
|
|
|
- <div class="desc">A low level class for loading resources with XmlHttpRequest, used internaly by most loaders.</div>
|
|
|
|
|
|
+ <div class="desc">
|
|
|
|
+ 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.
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <h2>Example</h2>
|
|
|
|
+ <div>
|
|
|
|
+ [example:webgl_loader_msgpack WebGL / loader / msgpack]<br />
|
|
|
|
+ [example:webgl_morphtargets_human WebGL / morphtargets / human]<br />
|
|
|
|
+ </div>
|
|
|
|
+ <code>
|
|
|
|
+var loader = new THREE.FileLoader();
|
|
|
|
+
|
|
|
|
+//load a text file a output the result to the console
|
|
|
|
+loader.load(
|
|
|
|
+ // resource URL
|
|
|
|
+ 'example.txt',
|
|
|
|
+
|
|
|
|
+ // Function when resource is loaded
|
|
|
|
+ function ( data ) {
|
|
|
|
+ // output the text to the console
|
|
|
|
+ console.log( data )
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // Function called when download progresses
|
|
|
|
+ function ( xhr ) {
|
|
|
|
+ console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // Function called when download errors
|
|
|
|
+ function ( xhr ) {
|
|
|
|
+ console.error( 'An error happened' );
|
|
|
|
+ } );
|
|
|
|
+ </code>
|
|
|
|
|
|
<h2>Constructor</h2>
|
|
<h2>Constructor</h2>
|
|
|
|
|
|
<h3>[name]( [page:LoadingManager manager] )</h3>
|
|
<h3>[name]( [page:LoadingManager manager] )</h3>
|
|
<div>
|
|
<div>
|
|
- [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- Creates a new [name].
|
|
|
|
|
|
+ [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use.
|
|
|
|
+ Default is [page:DefaultLoadingManager].
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@@ -28,36 +59,61 @@
|
|
|
|
|
|
<h3>[property:Cache cache]</h3>
|
|
<h3>[property:Cache cache]</h3>
|
|
<div>
|
|
<div>
|
|
- A [page:Cache cache] instance that hold the response from each request made through this loader, so each file is requested once.
|
|
|
|
|
|
+ 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.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
+ <h3>[property:String mimeType]</h3>
|
|
|
|
+ <div>
|
|
|
|
+ The expected [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types mimeType].
|
|
|
|
+ See [page:.setMimeType]. Default is *undefined*.
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <h3>[property:String path]</h3>
|
|
|
|
+ <div>The base path from which files will be loaded. See [page:.setPath]. Default is *undefined*.</div>
|
|
|
|
+
|
|
<h3>[property:String responseType]</h3>
|
|
<h3>[property:String responseType]</h3>
|
|
|
|
+ <div>The expected response type. See [page:.setResponseType]. Default is *undefined*.</div>
|
|
|
|
+
|
|
|
|
+ <h3>[property:String withCredentials]</h3>
|
|
<div>
|
|
<div>
|
|
- Can be set to change the response type.
|
|
|
|
|
|
+ Whether the XMLHttpRequest uses credentials such as cookies, authorization headers or
|
|
|
|
+ TLS client certificates. See [page:.setWithCredentials] and
|
|
|
|
+ [link:https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials XMLHttpRequest.withCredentials].
|
|
|
|
+ Default is *undefined*.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
<h2>Methods</h2>
|
|
<h2>Methods</h2>
|
|
|
|
|
|
<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
|
|
<h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
|
|
<div>
|
|
<div>
|
|
[page:String url] — required<br />
|
|
[page:String url] — required<br />
|
|
- [page:Function onLoad] — Will be called when load completes. The argument will be the loaded text response.<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, that contain .[page:Integer total] and .[page:Integer loaded] bytes.<br />
|
|
[page:Function onProgress] — Will be called while load progresses. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.<br />
|
|
- [page:Function onError] — Will be called when load errors.<br />
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
|
|
+ [page:Function onError] — Will be called if an error occurs.<br /><br />
|
|
|
|
+
|
|
Begin loading from url and return the [page:String text] response that will contain the data.
|
|
Begin loading from url and return the [page:String text] response that will contain the data.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <h3>[method:null setCrossOrigin]( [page:String value] )</h3>
|
|
|
|
- <div>
|
|
|
|
- [page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
|
|
|
|
- </div>
|
|
|
|
|
|
+
|
|
|
|
|
|
<h3>[method:null setResponseType]( [page:String value] )</h3>
|
|
<h3>[method:null setResponseType]( [page:String value] )</h3>
|
|
<div>
|
|
<div>
|
|
- [page:String value] — the empty string (default), "arraybuffer", "blob", "document", "json", or "text".
|
|
|
|
|
|
+ [page:String value] — the response type. Default is '' (empty string).<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 />
|
|
|
|
+
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h2>Source</h2>
|
|
<h2>Source</h2>
|