|
@@ -0,0 +1,145 @@
|
|
|
|
+<!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.
|
|
|
|
+ THREE.DRACOLoader.setDecoderPath( '/examples/js/libs/draco' );
|
|
|
|
+
|
|
|
|
+ // Optional: Pre-fetch Draco WASM/JS module.
|
|
|
|
+ THREE.DRACOLoader.getDecoderModule();
|
|
|
|
+
|
|
|
|
+ // 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>Static Methods</h2>
|
|
|
|
+
|
|
|
|
+ <h3>[method:null setDecoderPath]( [param:String value] )</h3>
|
|
|
|
+ <p>
|
|
|
|
+ [page:String value] — Path to folder containing the JS and WASM decoder libraries.
|
|
|
|
+ </p>
|
|
|
|
+
|
|
|
|
+ <h3>[method:null 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 loading the decoders.
|
|
|
|
+ </p>
|
|
|
|
+
|
|
|
|
+ <h3>[method:Promise getDecoderModule]()</h3>
|
|
|
|
+ <p>
|
|
|
|
+ Requests the decoder libraries, if not already loaded.
|
|
|
|
+ </p>
|
|
|
|
+
|
|
|
|
+ <h3>[method:null releaseDecoderModule]()</h3>
|
|
|
|
+ <p>
|
|
|
|
+ Disposes of the decoder library and deallocates memory. The decoder
|
|
|
|
+ [link:https://github.com/google/draco/issues/349 cannot be reloaded afterward].
|
|
|
|
+ </p>
|
|
|
|
+
|
|
|
|
+ <h2>Methods</h2>
|
|
|
|
+
|
|
|
|
+ <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:DRACOLoader setPath]( [param:String path] )</h3>
|
|
|
|
+ <p>
|
|
|
|
+ [page:String path] — Base path.
|
|
|
|
+ </p>
|
|
|
|
+ <p>
|
|
|
|
+ Set the base path for the <em>.drc</em> file.
|
|
|
|
+ </p>
|
|
|
|
+
|
|
|
|
+ <h2>Source</h2>
|
|
|
|
+
|
|
|
|
+ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/DRACOLoader.js examples/js/loaders/DRACOLoader.js]
|
|
|
|
+ </body>
|
|
|
|
+</html>
|