浏览代码

GLTFLoader: Fix handling of GLTF files with optional KTX2 extensions

If KTX2 loader wasn't registered, we would previously fail to load GLTF
files that used BasisU; this is a problem since files that don't require
BasisU support but specify it optionally would incorrectly fail.

The tradeoff here is that the error message that we previously emitted
for cases where the extension was required is now no more; we need some
mechanism for required extensions to actually be enforced to solve this.
Arseny Kapoulkine 4 年之前
父节点
当前提交
9a7349aff8
共有 2 个文件被更改,包括 4 次插入2 次删除
  1. 2 1
      examples/js/loaders/GLTFLoader.js
  2. 2 1
      examples/jsm/loaders/GLTFLoader.js

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

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

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

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