瀏覽代碼

Merge pull request #20518 from zeux/ktx-optional

GLTFLoader: Fix handling of GLTF files with optional KTX2 extensions
Mr.doob 4 年之前
父節點
當前提交
99771f6ccf
共有 2 個文件被更改,包括 20 次插入2 次删除
  1. 10 1
      examples/js/loaders/GLTFLoader.js
  2. 10 1
      examples/jsm/loaders/GLTFLoader.js

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

@@ -696,7 +696,16 @@ THREE.GLTFLoader = ( function () {
 
 		if ( ! loader ) {
 
-			throw new Error( 'THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' );
+			if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) {
+
+				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 - 1
examples/jsm/loaders/GLTFLoader.js

@@ -759,7 +759,16 @@ var GLTFLoader = ( function () {
 
 		if ( ! loader ) {
 
-			throw new Error( 'THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' );
+			if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) {
+
+				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;
+
+			}
 
 		}