Skip to content

Commit

Permalink
DRACOLoader: Update module cleanup/examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
Don McCurdy committed Jan 16, 2018
1 parent 1941ca0 commit 537a602
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
22 changes: 15 additions & 7 deletions examples/js/loaders/draco/DRACOLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,26 @@ THREE.DRACOLoader.setDecoderPath = function ( path ) {
THREE.DRACOLoader.setDecoderConfig = function ( config ) {
var wasmBinary = THREE.DRACOLoader.decoderConfig.wasmBinary;
THREE.DRACOLoader.decoderConfig = config || {};
THREE.DRACOLoader.decoderModulePromise = null;
THREE.DRACOLoader.releaseDecoderModule();

// Reuse WASM binary.
if ( wasmBinary ) THREE.DRACOLoader.decoderConfig.wasmBinary = wasmBinary;
};

/**
* Gets WebAssembly or asm.js singleton instance of DracoDecoderModule
* after testing for browser support. Returns Promise that resolves when
* module is available.
* @return {Promise<{decoder: DracoDecoderModule}>}
*/
/**
* Releases the singleton DracoDecoderModule instance. Module will be recreated
* with the next decoding call.
*/
THREE.DRACOLoader.releaseDecoderModule = function () {
THREE.DRACOLoader.decoderModulePromise = null;
};

/**
* Gets WebAssembly or asm.js singleton instance of DracoDecoderModule
* after testing for browser support. Returns Promise that resolves when
* module is available.
* @return {Promise<{decoder: DracoDecoderModule}>}
*/
THREE.DRACOLoader.getDecoderModule = function () {
var scope = this;
var path = THREE.DRACOLoader.decoderPath;
Expand Down
3 changes: 3 additions & 0 deletions examples/webgl_loader_draco.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
mesh.receiveShadow = true;
scene.add( mesh );

// Release decoder resources.
THREE.DRACOLoader.releaseDecoderModule();

} );

// renderer
Expand Down
5 changes: 2 additions & 3 deletions examples/webgl_loader_gltf_extensions.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,8 @@

loader = new THREE.GLTFLoader();

var dracoLoader = new THREE.DRACOLoader();
dracoLoader.setDecoderPath( 'js/loaders/draco/' );
loader.setDRACOLoader( dracoLoader );
THREE.DRACOLoader.setDecoderPath( 'js/loaders/draco/' );
loader.setDRACOLoader( new THREE.DRACOLoader() );

for (var i = 0; i < extensionSelect.children.length; i++) {
var child = extensionSelect.children[i];
Expand Down

0 comments on commit 537a602

Please sign in to comment.