Skip to content

Commit

Permalink
DracoLoader: Fix not calling onError(). (mrdoob#27306)
Browse files Browse the repository at this point in the history
* fix onError load

* onError

* LinearSRGBColorSpace instead of undefined

* default onError = () => {}; call onError to cleanup code;
  • Loading branch information
Benjythebee authored and AdaRoseCannon committed Jan 15, 2024
1 parent aa59afc commit 797ebd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions examples/jsm/loaders/DRACOLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 );

}

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {

Expand All @@ -1938,7 +1938,7 @@ class GLTFDracoMeshCompressionExtension {

resolve( geometry );

}, threeAttributeMap, attributeTypeMap );
}, threeAttributeMap, attributeTypeMap, LinearSRGBColorSpace, reject );

} );

Expand Down

0 comments on commit 797ebd7

Please sign in to comment.