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

GLTFLoader: Remove support detection for WebP and AVIF. #30864

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Changes from all 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
82 changes: 2 additions & 80 deletions examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,6 @@ class GLTFTextureWebPExtension {

this.parser = parser;
this.name = EXTENSIONS.EXT_TEXTURE_WEBP;
this.isSupported = null;

}

Expand Down Expand Up @@ -1610,46 +1609,7 @@ class GLTFTextureWebPExtension {

}

return this.detectSupport().then( function ( isSupported ) {

if ( isSupported ) return parser.loadTextureImage( textureIndex, extension.source, loader );

if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) {

throw new Error( 'THREE.GLTFLoader: WebP required by asset but unsupported.' );

}

// Fall back to PNG or JPEG.
return parser.loadTexture( textureIndex );

} );

}

detectSupport() {

if ( ! this.isSupported ) {

this.isSupported = new Promise( function ( resolve ) {

const image = new Image();

// Lossy test image. Support for lossy images doesn't guarantee support for all
// WebP images, unfortunately.
image.src = 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA';

image.onload = image.onerror = function () {

resolve( image.height === 1 );

};

} );

}

return this.isSupported;
return parser.loadTextureImage( textureIndex, extension.source, loader );

}

Expand All @@ -1668,7 +1628,6 @@ class GLTFTextureAVIFExtension {

this.parser = parser;
this.name = EXTENSIONS.EXT_TEXTURE_AVIF;
this.isSupported = null;

}

Expand Down Expand Up @@ -1697,44 +1656,7 @@ class GLTFTextureAVIFExtension {

}

return this.detectSupport().then( function ( isSupported ) {

if ( isSupported ) return parser.loadTextureImage( textureIndex, extension.source, loader );

if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) {

throw new Error( 'THREE.GLTFLoader: AVIF required by asset but unsupported.' );

}

// Fall back to PNG or JPEG.
return parser.loadTexture( textureIndex );

} );

}

detectSupport() {

if ( ! this.isSupported ) {

this.isSupported = new Promise( function ( resolve ) {

const image = new Image();

// Lossy test image.
image.src = 'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=';
image.onload = image.onerror = function () {

resolve( image.height === 1 );

};

} );

}

return this.isSupported;
return parser.loadTextureImage( textureIndex, extension.source, loader );

}

Expand Down