Skip to content

Commit 7204cd5

Browse files
Mugen87abernier
authored andcommitted
GLTFLoader: Honor Firefox version when checking for ImageBitmap. (mrdoob#23909)
* GLTFLoader: Honor Firefox version when checking for ImageBitmap. * GLTFLoader: Clarify ImageBitmap check. * GLTFLoader: Clean up. * GLTFLoader: More clean up.
1 parent 6a206ed commit 7204cd5

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

examples/jsm/loaders/GLTFLoader.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ class GLTFMaterialsUnlitExtension {
650650
*
651651
* Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
652652
*/
653-
class GLTFMaterialsEmissiveStrengthExtension {
653+
class GLTFMaterialsEmissiveStrengthExtension {
654654

655655
constructor( parser ) {
656656

@@ -670,8 +670,8 @@ class GLTFMaterialsUnlitExtension {
670670

671671
}
672672

673-
const emissiveStrength = materialDef.extensions[this.name].emissiveStrength;
674-
673+
const emissiveStrength = materialDef.extensions[ this.name ].emissiveStrength;
674+
675675
if ( emissiveStrength !== undefined ) {
676676

677677
materialParams.emissiveIntensity = emissiveStrength;
@@ -2315,14 +2315,19 @@ class GLTFParser {
23152315

23162316
// Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
23172317
// expensive work of uploading a texture to the GPU off the main thread.
2318-
if ( typeof createImageBitmap !== 'undefined' && /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === false ) {
23192318

2320-
this.textureLoader = new ImageBitmapLoader( this.options.manager );
2319+
const isSafari = /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === true;
2320+
const isFirefox = navigator.userAgent.indexOf( 'Firefox' ) > - 1;
2321+
const firefoxVersion = isFirefox ? navigator.userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
23212322

2322-
} else {
2323+
if ( typeof createImageBitmap === 'undefined' || isSafari || ( isFirefox && firefoxVersion < 98 ) ) {
23232324

23242325
this.textureLoader = new TextureLoader( this.options.manager );
23252326

2327+
} else {
2328+
2329+
this.textureLoader = new ImageBitmapLoader( this.options.manager );
2330+
23262331
}
23272332

23282333
this.textureLoader.setCrossOrigin( this.options.crossOrigin );
@@ -2627,9 +2632,9 @@ class GLTFParser {
26272632

26282633
case 'animation':
26292634
dependency = this._invokeOne( function ( ext ) {
2630-
2635+
26312636
return ext.loadAnimation && ext.loadAnimation( index );
2632-
2637+
26332638
} );
26342639
break;
26352640

0 commit comments

Comments
 (0)