From 14a3573490edcc69c99ec34f6ec6b005cfd27a89 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Fri, 4 Apr 2025 16:03:03 +0200 Subject: [PATCH] GLTFLoader: Remove support detection for WebP and AVIF. --- examples/jsm/loaders/GLTFLoader.js | 82 +----------------------------- 1 file changed, 2 insertions(+), 80 deletions(-) diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index 1169d8a2ecbdf1..92abfd7918091b 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -1581,7 +1581,6 @@ class GLTFTextureWebPExtension { this.parser = parser; this.name = EXTENSIONS.EXT_TEXTURE_WEBP; - this.isSupported = null; } @@ -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 ); } @@ -1668,7 +1628,6 @@ class GLTFTextureAVIFExtension { this.parser = parser; this.name = EXTENSIONS.EXT_TEXTURE_AVIF; - this.isSupported = null; } @@ -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 ); }