1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
<!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>
|