Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DracoLoader: Fix not calling onError(). #27306

Merged
merged 4 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions examples/jsm/loaders/DRACOLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,18 @@ class DRACOLoader extends Loader {

}


parse( buffer, onLoad, onError ) {

this.decodeDracoFile( buffer, onLoad, null, null, SRGBColorSpace ).catch( onError );
this.decodeDracoFile( buffer, onLoad, null, null, SRGBColorSpace ).catch( ( error ) => {
Mugen87 marked this conversation as resolved.
Show resolved Hide resolved

onError && onError( error );

} );

}

decodeDracoFile( buffer, callback, attributeIDs, attributeTypes, vertexColorSpace = LinearSRGBColorSpace ) {
decodeDracoFile( buffer, callback, attributeIDs, attributeTypes, vertexColorSpace = LinearSRGBColorSpace, onError = undefined ) {

const taskConfig = {
attributeIDs: attributeIDs || this.defaultAttributeIDs,
Expand All @@ -97,7 +102,11 @@ class DRACOLoader extends Loader {
vertexColorSpace: vertexColorSpace,
};

return this.decodeGeometry( buffer, taskConfig ).then( callback );
return this.decodeGeometry( buffer, taskConfig ).then( callback ).catch( ( error ) => {

onError && onError( error );

} );

}

Expand Down Expand Up @@ -156,7 +165,12 @@ class DRACOLoader extends Loader {
} );

} )
.then( ( message ) => this._createGeometry( message.geometry ) );
.then( ( message ) => this._createGeometry( message.geometry ) )
.catch( ( error ) => {

throw new Error( error );

} );
donmccurdy marked this conversation as resolved.
Show resolved Hide resolved

// 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