Răsfoiți Sursa

DRACOLoader: Update docs and typings.

Don McCurdy 6 ani în urmă
părinte
comite
6952abd94b

+ 3 - 5
docs/examples/en/loaders/GLTFLoader.html

@@ -56,11 +56,9 @@
 		var loader = new THREE.GLTFLoader();
 		var loader = new THREE.GLTFLoader();
 
 
 		// Optional: Provide a DRACOLoader instance to decode compressed mesh data
 		// 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
 		// Load a glTF resource
 		loader.load(
 		loader.load(

+ 32 - 27
docs/examples/zh/loaders/DRACOLoader.html

@@ -34,10 +34,7 @@
 		var loader = new THREE.DRACOLoader();
 		var loader = new THREE.DRACOLoader();
 
 
 		// Specify path to a folder containing WASM/JS decoding libraries.
 		// 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
 		// Load a Draco geometry
 		loader.load(
 		loader.load(
@@ -90,52 +87,60 @@
 		Creates a new [name].
 		Creates a new [name].
 		</p>
 		</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>
 		<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>
 		</p>
 
 
-		<h3>[method:null setDecoderConfig]( [param:Object config] )</h3>
+		<h3>[method:this setPath]( [param:String path] )</h3>
 		<p>
 		<p>
-			[page:String config.type] - (Optional) <em>"js"</em> or <em>"wasm"</em>.<br />
+		[page:String path] — Base path.
 		</p>
 		</p>
 		<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>
 		</p>
 
 
-		<h3>[method:Promise getDecoderModule]()</h3>
+		<h3>[method:this setCrossOrigin]( [param:String value] )</h3>
 		<p>
 		<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>
 		</p>
 
 
-		<h3>[method:null releaseDecoderModule]()</h3>
+		<h3>[method:this setDecoderPath]( [param:String value] )</h3>
 		<p>
 		<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>
 		</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>
 		<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>
 		<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>
 		</p>
 
 
-		<h3>[method:DRACOLoader setPath]( [param:String path] )</h3>
+		<h3>[method:this setWorkerLimit]( [param:Number workerLimit] )</h3>
 		<p>
 		<p>
-		[page:String path] — Base path.
+			[page:Number workerLimit] - Maximum number of workers to be allocated. Default is 4.<br />
 		</p>
 		</p>
 		<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>
 		</p>
 
 
 		<h2>Source</h2>
 		<h2>Source</h2>

+ 3 - 5
docs/examples/zh/loaders/GLTFLoader.html

@@ -56,11 +56,9 @@
 		var loader = new THREE.GLTFLoader();
 		var loader = new THREE.GLTFLoader();
 
 
 		// Optional: Provide a DRACOLoader instance to decode compressed mesh data
 		// 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
 		// Load a glTF resource
 		loader.load(
 		loader.load(

+ 6 - 11
examples/jsm/loaders/DRACOLoader.d.ts

@@ -1,21 +1,16 @@
 import {
 import {
   LoadingManager,
   LoadingManager,
-  BufferGeometry,
-  TrianglesDrawModes
+  BufferGeometry
 } from '../../../src/Three';
 } from '../../../src/Three';
 
 
 export class DRACOLoader {
 export class DRACOLoader {
   constructor(manager?: LoadingManager);
   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;
   load(url: string, onLoad: (geometry: BufferGeometry) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
   setPath(path: string): DRACOLoader;
   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;
 }
 }

+ 3 - 2
examples/webgl_animation_keyframes.html

@@ -78,10 +78,11 @@
 				path + 'posz' + format, path + 'negz' + format
 				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();
 			var loader = new GLTFLoader();
-			loader.setDRACOLoader( new DRACOLoader() );
+			loader.setDRACOLoader( dracoLoader );
 			loader.load( 'models/gltf/LittlestTokyo.glb', function ( gltf ) {
 			loader.load( 'models/gltf/LittlestTokyo.glb', function ( gltf ) {
 
 
 				var model = gltf.scene;
 				var model = gltf.scene;