Преглед изворни кода

GLTFLoader: Honor Firefox version when checking for ImageBitmap. (#23909)

* GLTFLoader: Honor Firefox version when checking for ImageBitmap.

* GLTFLoader: Clarify ImageBitmap check.

* GLTFLoader: Clean up.

* GLTFLoader: More clean up.
Michael Herzog пре 3 година
родитељ
комит
54e04e5984
1 измењених фајлова са 13 додато и 8 уклоњено
  1. 13 8
      examples/jsm/loaders/GLTFLoader.js

+ 13 - 8
examples/jsm/loaders/GLTFLoader.js

@@ -650,7 +650,7 @@ class GLTFMaterialsUnlitExtension {
  *
  * Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
  */
- class GLTFMaterialsEmissiveStrengthExtension {
+class GLTFMaterialsEmissiveStrengthExtension {
 
 	constructor( parser ) {
 
@@ -670,8 +670,8 @@ class GLTFMaterialsUnlitExtension {
 
 		}
 
-		const emissiveStrength = materialDef.extensions[this.name].emissiveStrength;
-		
+		const emissiveStrength = materialDef.extensions[ this.name ].emissiveStrength;
+
 		if ( emissiveStrength !== undefined ) {
 
 			materialParams.emissiveIntensity = emissiveStrength;
@@ -2315,14 +2315,19 @@ class GLTFParser {
 
 		// Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
 		// expensive work of uploading a texture to the GPU off the main thread.
-		if ( typeof createImageBitmap !== 'undefined' && /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === false ) {
 
-			this.textureLoader = new ImageBitmapLoader( this.options.manager );
+		const isSafari = /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === true;
+		const isFirefox = navigator.userAgent.indexOf( 'Firefox' ) > - 1;
+		const firefoxVersion = isFirefox ? navigator.userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
 
-		} else {
+		if ( typeof createImageBitmap === 'undefined' || isSafari || ( isFirefox && firefoxVersion < 98 ) ) {
 
 			this.textureLoader = new TextureLoader( this.options.manager );
 
+		} else {
+
+			this.textureLoader = new ImageBitmapLoader( this.options.manager );
+
 		}
 
 		this.textureLoader.setCrossOrigin( this.options.crossOrigin );
@@ -2627,9 +2632,9 @@ class GLTFParser {
 
 				case 'animation':
 					dependency = this._invokeOne( function ( ext ) {
-		
+
 						return ext.loadAnimation && ext.loadAnimation( index );
-		
+
 					} );
 					break;