diff --git a/examples/jsm/loaders/DRACOLoader.js b/examples/jsm/loaders/DRACOLoader.js index 25fcfa251bc212..f04c521c22b4a9 100644 --- a/examples/jsm/loaders/DRACOLoader.js +++ b/examples/jsm/loaders/DRACOLoader.js @@ -82,13 +82,14 @@ class DRACOLoader extends Loader { } - parse( buffer, onLoad, onError ) { + + parse( buffer, onLoad, onError = ()=>{} ) { this.decodeDracoFile( buffer, onLoad, null, null, SRGBColorSpace ).catch( onError ); } - decodeDracoFile( buffer, callback, attributeIDs, attributeTypes, vertexColorSpace = LinearSRGBColorSpace ) { + decodeDracoFile( buffer, callback, attributeIDs, attributeTypes, vertexColorSpace = LinearSRGBColorSpace, onError = () => {} ) { const taskConfig = { attributeIDs: attributeIDs || this.defaultAttributeIDs, @@ -97,7 +98,7 @@ class DRACOLoader extends Loader { vertexColorSpace: vertexColorSpace, }; - return this.decodeGeometry( buffer, taskConfig ).then( callback ); + return this.decodeGeometry( buffer, taskConfig ).then( callback ).catch( onError ); } @@ -156,7 +157,12 @@ class DRACOLoader extends Loader { } ); } ) - .then( ( message ) => this._createGeometry( message.geometry ) ); + .then( ( message ) => this._createGeometry( message.geometry ) ) + .catch( ( error ) => { + + throw new Error( error ); + + } ); // Remove task from the task list. // Note: replaced '.finally()' with '.catch().then()' block - iOS 11 support (#19416) diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index 1cc15ac3588eb5..440ecb714846d4 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -1923,7 +1923,7 @@ class GLTFDracoMeshCompressionExtension { return parser.getDependency( 'bufferView', bufferViewIndex ).then( function ( bufferView ) { - return new Promise( function ( resolve ) { + return new Promise( function ( resolve, reject ) { dracoLoader.decodeDracoFile( bufferView, function ( geometry ) { @@ -1938,7 +1938,7 @@ class GLTFDracoMeshCompressionExtension { resolve( geometry ); - }, threeAttributeMap, attributeTypeMap ); + }, threeAttributeMap, attributeTypeMap, LinearSRGBColorSpace, reject ); } );