Skip to content

Commit

Permalink
DRACOLoader: Update docs and typings.
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy committed Aug 23, 2019
1 parent beaaed2 commit c102383
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 50 deletions.
8 changes: 3 additions & 5 deletions docs/examples/en/loaders/GLTFLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ <h2>Example</h2>
var loader = new THREE.GLTFLoader();

// Optional: Provide a DRACOLoader instance to decode compressed mesh data
THREE.DRACOLoader.setDecoderPath( '/examples/js/libs/draco' );
loader.setDRACOLoader( new THREE.DRACOLoader() );

// Optional: Pre-fetch Draco WASM/JS module, to save time while parsing.
THREE.DRACOLoader.getDecoderModule();
var dracoLoader = new THREE.DRACOLoader();
dracoLoader.setDecoderPath( '/examples/js/libs/draco' );
loader.setDRACOLoader( dracoLoader );

// Load a glTF resource
loader.load(
Expand Down
59 changes: 32 additions & 27 deletions docs/examples/zh/loaders/DRACOLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ <h2>Example</h2>
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(
Expand Down Expand Up @@ -90,52 +87,60 @@ <h3>[name]( [param:LoadingManager manager] )</h3>
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>
Expand Down
8 changes: 3 additions & 5 deletions docs/examples/zh/loaders/GLTFLoader.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ <h2>Example</h2>
var loader = new THREE.GLTFLoader();

// Optional: Provide a DRACOLoader instance to decode compressed mesh data
THREE.DRACOLoader.setDecoderPath( '/examples/js/libs/draco' );
loader.setDRACOLoader( new THREE.DRACOLoader() );

// Optional: Pre-fetch Draco WASM/JS module, to save time while parsing.
THREE.DRACOLoader.getDecoderModule();
var dracoLoader = new THREE.DRACOLoader();
dracoLoader.setDecoderPath( '/examples/js/libs/draco' );
loader.setDRACOLoader( dracoLoader );

// Load a glTF resource
loader.load(
Expand Down
17 changes: 6 additions & 11 deletions examples/jsm/loaders/DRACOLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import {
LoadingManager,
BufferGeometry,
TrianglesDrawModes
BufferGeometry
} from '../../../src/Three';

export class DRACOLoader {
constructor(manager?: LoadingManager);

static setDecoderPath(path: string): void;
static setDecoderConfig(config: object): void;
static getDecoderModule(): Promise<any>;
static releaseDecoderModule(): void;

load(url: string, onLoad: (geometry: BufferGeometry) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
setPath(path: string): DRACOLoader;
setVerbosity(level: number): DRACOLoader;
setDrawMode(drawMode: TrianglesDrawModes): DRACOLoader;
setSkipDequantization(attributeName: 'position', skip?: boolean): DRACOLoader;
isVersionSupported(version: number, callback: (isVersionSupported: boolean) => any): void;
setDecoderPath(path: string): DRACOLoader;
setDecoderConfig(config: object): DRACOLoader;
setCrossOrigin(crossOrigin: string): DRACOLoader;
setWorkerLimit(workerLimit: number): DRACOLoader;
dispose(): DRACOLoader;
}
5 changes: 3 additions & 2 deletions examples/webgl_animation_keyframes.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@
path + 'posz' + format, path + 'negz' + format
] );

DRACOLoader.setDecoderPath( 'js/libs/draco/gltf/' );
var dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath( 'js/libs/draco/gltf/' );

var loader = new GLTFLoader();
loader.setDRACOLoader( new DRACOLoader() );
loader.setDRACOLoader( dracoLoader );
loader.load( 'models/gltf/LittlestTokyo.glb', function ( gltf ) {

var model = gltf.scene;
Expand Down

0 comments on commit c102383

Please sign in to comment.