Skip to content

Commit

Permalink
Use ImageBitmapLoader in GLTFLoader for Safari >= 17, fixes texture l…
Browse files Browse the repository at this point in the history
…oading in a web worker (mrdoob#28560)
  • Loading branch information
paugit committed Jun 15, 2024
1 parent dd18c85 commit abbf28a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2580,18 +2580,20 @@ class GLTFParser {
// expensive work of uploading a texture to the GPU off the main thread.

let isSafari = false;
let safariVersion = - 1;
let isFirefox = false;
let firefoxVersion = - 1;

if ( typeof navigator !== 'undefined' ) {

isSafari = /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === true;
safariVersion = isSafari ? navigator.userAgent.match( /Version\/(\d+)/ )[ 1 ] : - 1;
isFirefox = navigator.userAgent.indexOf( 'Firefox' ) > - 1;
firefoxVersion = isFirefox ? navigator.userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;

}

if ( typeof createImageBitmap === 'undefined' || isSafari || ( isFirefox && firefoxVersion < 98 ) ) {
if ( typeof createImageBitmap === 'undefined' || ( isSafari && safariVersion < 17 ) || ( isFirefox && firefoxVersion < 98 ) ) {

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

Expand Down

0 comments on commit abbf28a

Please sign in to comment.