diff --git a/examples/jsm/loaders/DRACOLoader.js b/examples/jsm/loaders/DRACOLoader.js index a56104bdcf0381..4636d0a38e7830 100644 --- a/examples/jsm/loaders/DRACOLoader.js +++ b/examples/jsm/loaders/DRACOLoader.js @@ -13,6 +13,10 @@ import { const _taskCache = new WeakMap(); +const WASM_BIN_URL = new URL( '../libs/draco/draco_decoder.wasm', import.meta.url ).toString(); +const WASM_JS_URL = new URL( '../libs/draco/draco_wasm_wrapper.js', import.meta.url ).toString(); +const JS_URL = new URL( '../libs/draco/draco_decoder.js', import.meta.url ).toString(); + /** * A loader for the Draco format. * @@ -358,14 +362,31 @@ class DRACOLoader extends Loader { const useJS = typeof WebAssembly !== 'object' || this.decoderConfig.type === 'js'; const librariesPending = []; - if ( useJS ) { + if ( this.decoderPath === '' ) { + + if ( useJS ) { - librariesPending.push( this._loadLibrary( 'draco_decoder.js', 'text' ) ); + librariesPending.push( this._loadLibrary( JS_URL, 'text' ) ); + + } else { + + librariesPending.push( this._loadLibrary( WASM_JS_URL, 'text' ) ); + librariesPending.push( this._loadLibrary( WASM_BIN_URL, 'arraybuffer' ) ); + + } } else { - librariesPending.push( this._loadLibrary( 'draco_wasm_wrapper.js', 'text' ) ); - librariesPending.push( this._loadLibrary( 'draco_decoder.wasm', 'arraybuffer' ) ); + if ( useJS ) { + + librariesPending.push( this._loadLibrary( 'draco_decoder.js', 'text' ) ); + + } else { + + librariesPending.push( this._loadLibrary( 'draco_wasm_wrapper.js', 'text' ) ); + librariesPending.push( this._loadLibrary( 'draco_decoder.wasm', 'arraybuffer' ) ); + + } } diff --git a/examples/webgl_tonemapping.html b/examples/webgl_tonemapping.html index 73c6e0790d0d72..c3f7b16b70b93d 100644 --- a/examples/webgl_tonemapping.html +++ b/examples/webgl_tonemapping.html @@ -119,8 +119,6 @@ .setPath( 'textures/equirectangular/' ); const dracoLoader = new DRACOLoader(); - dracoLoader.setDecoderPath( 'jsm/libs/draco/gltf/' ); - const gltfLoader = new GLTFLoader(); gltfLoader.setDRACOLoader( dracoLoader ); gltfLoader.setPath( 'models/gltf/' );