浏览代码

Update GLTFLoader with a more refined detection of optional extensions

Arseny Kapoulkine 4 年之前
父节点
当前提交
88799bcd78
共有 2 个文件被更改,包括 20 次插入4 次删除
  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;
+
+			}
 
 		}