Ver código fonte

GLTFLoader and KTX2Loader: Add a sanity check for navigator.userAgent before using it. (#32633)

leonmetthez 1 semana atrás
pai
commit
8649c37f56

+ 1 - 1
examples/jsm/loaders/GLTFLoader.js

@@ -2663,7 +2663,7 @@ class GLTFParser {
 		let isFirefox = false;
 		let firefoxVersion = - 1;
 
-		if ( typeof navigator !== 'undefined' ) {
+		if ( typeof navigator !== 'undefined' && typeof navigator.userAgent !== 'undefined' ) {
 
 			const userAgent = navigator.userAgent;
 

+ 1 - 0
examples/jsm/loaders/KTX2Loader.js

@@ -252,6 +252,7 @@ class KTX2Loader extends Loader {
 			};
 
 			if ( typeof navigator !== 'undefined' &&
+				typeof navigator.platform !== 'undefined' && typeof navigator.userAgent !== 'undefined' &&
 				navigator.platform.indexOf( 'Linux' ) >= 0 && navigator.userAgent.indexOf( 'Firefox' ) >= 0 &&
 				this.workerConfig.astcSupported && this.workerConfig.etc2Supported &&
 				this.workerConfig.bptcSupported && this.workerConfig.dxtSupported ) {

粤ICP备19079148号