Bläddra i källkod

Update GLTFLoader with a more refined detection of optional extensions

Arseny Kapoulkine 4 år sedan
förälder
incheckning
88799bcd78
2 ändrade filer med 20 tillägg och 4 borttagningar
  1. 10 2
      examples/js/loaders/GLTFLoader.js
  2. 10 2
      examples/jsm/loaders/GLTFLoader.js

+ 10 - 2
examples/js/loaders/GLTFLoader.js

@@ -696,8 +696,16 @@ THREE.GLTFLoader = ( function () {
 
 		if ( ! loader ) {
 
-			// Assumes that the extension is optional and that a fallback texture is present; ideally we should handle extensionsRequired better
-			return null;
+			if ( json.extensionsRequired && json.extensionsRequired.includes( this.name ) ) {
+
+				throw new Error( 'THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' );
+
+			} else {
+
+				// Assumes that the extension is optional and that a fallback texture is present
+				return null;
+
+			}
 
 		}
 

+ 10 - 2
examples/jsm/loaders/GLTFLoader.js

@@ -759,8 +759,16 @@ var GLTFLoader = ( function () {
 
 		if ( ! loader ) {
 
-			// Assumes that the extension is optional and that a fallback texture is present; ideally we should handle extensionsRequired better
-			return null;
+			if ( json.extensionsRequired && json.extensionsRequired.includes( this.name ) ) {
+
+				throw new Error( 'THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' );
+
+			} else {
+
+				// Assumes that the extension is optional and that a fallback texture is present
+				return null;
+
+			}
 
 		}