123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <base href="../../../" />
- <script src="list.js"></script>
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- [page:Loader] →
- <h1>[name]</h1>
- <p class="desc">
- A loader for geometry compressed with the Draco library. <br /><br />
- [link:https://google.github.io/draco/ Draco] is an open source library for compressing and
- decompressing 3D meshes and point clouds. Compressed geometry can be significantly smaller,
- at the cost of additional decoding time on the client device.
- </p>
- <p>
- Standalone Draco files have a <em>.drc</em> extension, and contain vertex positions,
- normals, colors, and other attributes. Draco files <em>do not</em> contain materials,
- textures, animation, or node hierarchies – to use these features, embed Draco geometry
- inside of a glTF file. A normal glTF file can be converted to a Draco-compressed glTF file
- using [link:https://github.com/AnalyticalGraphicsInc/gltf-pipeline glTF-Pipeline]. When
- using Draco with glTF, an instance of DRACOLoader will be used internally by [page:GLTFLoader].
- </p>
- <h2>Example</h2>
- <code>
- // Instantiate a loader
- var loader = new THREE.DRACOLoader();
- // Specify path to a folder containing WASM/JS decoding libraries.
- loader.setDecoderPath( '/examples/js/libs/draco/' );
- // Optional: Pre-fetch Draco WASM/JS module.
- loader.preload();
- // Load a Draco geometry
- loader.load(
- // resource URL
- 'model.drc',
- // called when the resource is loaded
- function ( geometry ) {
- var material = new THREE.MeshStandardMaterial( { color: 0x606060 } );
- var mesh = new THREE.Mesh( geometry, material );
- scene.add( mesh );
- },
- // called as loading progresses
- function ( xhr ) {
- console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
- },
- // called when loading has errors
- function ( error ) {
- console.log( 'An error happened' );
- }
- );
- </code>
- [example:webgl_loader_draco]
- <h2>Browser compatibility</h2>
- <p>DRACOLoader relies on ES6 [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise Promises],
- which are not supported in IE11. To use the loader in IE11, you must
- [link:https://github.com/stefanpenner/es6-promise include a polyfill]
- providing a Promise replacement. DRACOLoader will automatically use
- either the JS or the WASM decoding library, based on browser
- capabilities.</p>
- <br>
- <hr>
- <h2>Constructor</h2>
- <h3>[name]( [param:LoadingManager manager] )</h3>
- <p>
- [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
- </p>
- <p>
- Creates a new [name].
- </p>
- <h2>Properties</h2>
- <p>See the base [page:Loader] class for common properties.</p>
- <h2>Methods</h2>
- <p>See the base [page:Loader] class for common methods.</p>
- <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</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 />
- </p>
- <p>
- Begin loading from url and call the <em>onLoad</em> function with the decompressed geometry.
- </p>
- <h3>[method:this setDecoderPath]( [param:String value] )</h3>
- <p>
- [page:String value] — Path to folder containing the JS and WASM decoder libraries.
- </p>
- <h3>[method:this setDecoderConfig]( [param:Object config] )</h3>
- <p>
- [page:String config.type] - (Optional) <em>"js"</em> or <em>"wasm"</em>.<br />
- </p>
- <p>
- Provides configuration for the decoder libraries. Configuration cannot be changed
- after decoding begins.
- </p>
- <h3>[method:this setWorkerLimit]( [param:Number workerLimit] )</h3>
- <p>
- [page:Number workerLimit] - Maximum number of workers to be allocated. Default is 4.<br />
- </p>
- <p>
- 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 preload]()</h3>
- <p>
- Requests the decoder libraries, if not already loaded.
- </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>
- <p>
- [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/DRACOLoader.js examples/js/loaders/DRACOLoader.js]
- </p>
- </body>
- </html>
|