提交 ee9c6e4c 编写于 作者: D Don McCurdy

DRACOLoader: Update docs, add missing setPath() method.

上级 2bce91d1
......@@ -34,10 +34,7 @@
var loader = new THREE.DRACOLoader();
// Specify path to a folder containing WASM/JS decoding libraries.
THREE.DRACOLoader.setDecoderPath( '/examples/js/libs/draco' );
// Optional: Pre-fetch Draco WASM/JS module.
THREE.DRACOLoader.getDecoderModule();
loader.setDecoderPath( '/examples/js/libs/draco' );
// Load a Draco geometry
loader.load(
......@@ -90,52 +87,60 @@
Creates a new [name].
</p>
<h2>Static Methods</h2>
<h2>Methods</h2>
<h3>[method:null setDecoderPath]( [param:String value] )</h3>
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<p>
[page:String value] — Path to folder containing the JS and WASM decoder libraries.
[page:String url] — A string containing the path/URL of the <em>.drc</em> file.<br />
[page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
[page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
[page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
</p>
<p>
Begin loading from url and call the <em>onLoad</em> function with the decompressed geometry.
</p>
<h3>[method:null setDecoderConfig]( [param:Object config] )</h3>
<h3>[method:this setPath]( [param:String path] )</h3>
<p>
[page:String config.type] - (Optional) <em>"js"</em> or <em>"wasm"</em>.<br />
[page:String path] — Base path.
</p>
<p>
Provides configuration for the decoder libraries. Configuration cannot be changed
after loading the decoders.
Set the base path for the <em>.drc</em> file.
</p>
<h3>[method:Promise getDecoderModule]()</h3>
<h3>[method:this setCrossOrigin]( [param:String value] )</h3>
<p>
Requests the decoder libraries, if not already loaded.
[page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
</p>
<h3>[method:null releaseDecoderModule]()</h3>
<h3>[method:this setDecoderPath]( [param:String value] )</h3>
<p>
Disposes of the decoder library and deallocates memory. The decoder
[link:https://github.com/google/draco/issues/349 cannot be reloaded afterward].
[page:String value] — Path to folder containing the JS and WASM decoder libraries.
</p>
<h2>Methods</h2>
<h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
<h3>[method:this setDecoderConfig]( [param:Object config] )</h3>
<p>
[page:String url] — A string containing the path/URL of the <em>.drc</em> file.<br />
[page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
[page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
[page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
[page:String config.type] - (Optional) <em>"js"</em> or <em>"wasm"</em>.<br />
</p>
<p>
Begin loading from url and call the <em>onLoad</em> function with the decompressed geometry.
Provides configuration for the decoder libraries. Configuration cannot be changed
after decoding begins.
</p>
<h3>[method:DRACOLoader setPath]( [param:String path] )</h3>
<h3>[method:this setWorkerLimit]( [param:Number workerLimit] )</h3>
<p>
[page:String path] — Base path.
[page:Number workerLimit] - Maximum number of workers to be allocated. Default is 4.<br />
</p>
<p>
Set the base path for the <em>.drc</em> file.
Sets the maximum number of [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers Web Workers]
to be used during decoding. A lower limit may be preferable if workers are also for other tasks
in the application.
</p>
<h3>[method:this dispose]()</h3>
<p>
Disposes of the decoder resources and deallocates memory. The decoder
[link:https://github.com/google/draco/issues/349 cannot be reloaded afterward].
</p>
<h2>Source</h2>
......
......@@ -6,6 +6,7 @@ THREE.DRACOLoader = function ( manager ) {
this.manager = manager || THREE.DefaultLoadingManager;
this.path = '';
this.crossOrigin = 'anonymous';
this.decoderPath = '';
......@@ -37,6 +38,14 @@ THREE.DRACOLoader.prototype = {
constructor: THREE.DRACOLoader,
setPath: function ( path ) {
this.path = path;
return this;
},
setCrossOrigin: function ( crossOrigin ) {
this.crossOrigin = crossOrigin;
......@@ -94,6 +103,7 @@ THREE.DRACOLoader.prototype = {
var loader = new THREE.FileLoader( this.manager );
loader.setPath( this.path );
loader.setResponseType( 'arraybuffer' );
if ( this.crossOrigin === 'use-credentials' ) {
......
......@@ -13,6 +13,7 @@ var DRACOLoader = function ( manager ) {
this.manager = manager || DefaultLoadingManager;
this.path = '';
this.crossOrigin = 'anonymous';
this.decoderPath = '';
......@@ -44,6 +45,14 @@ DRACOLoader.prototype = {
constructor: DRACOLoader,
setPath: function ( path ) {
this.path = path;
return this;
},
setCrossOrigin: function ( crossOrigin ) {
this.crossOrigin = crossOrigin;
......@@ -101,6 +110,7 @@ DRACOLoader.prototype = {
var loader = new FileLoader( this.manager );
loader.setPath( this.path );
loader.setResponseType( 'arraybuffer' );
if ( this.crossOrigin === 'use-credentials' ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册