From abbf28a79a6f0a6223a4ecba22401a125c8af77e Mon Sep 17 00:00:00 2001 From: pmjo Date: Sat, 15 Jun 2024 14:39:37 +0300 Subject: [PATCH] Use ImageBitmapLoader in GLTFLoader for Safari >= 17, fixes texture loading in a web worker (#28560) --- examples/jsm/loaders/GLTFLoader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index ef68d8fbc197ae..dcbd637694d369 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -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 );