浏览代码

GLTFLoader: Parsing provided data only if is not in JSON format. Fix for #12470

Antonio Gomez 7 年之前
父节点
当前提交
fa245d0018
共有 1 个文件被更改,包括 11 次插入3 次删除
  1. 11 3
      examples/js/loaders/GLTFLoader.js

+ 11 - 3
examples/js/loaders/GLTFLoader.js

@@ -74,14 +74,22 @@ THREE.GLTFLoader = ( function () {
 
 				extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data );
 				content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content;
+				var json = JSON.parse( content );
 
 			} else {
 
-				content = convertUint8ArrayToString( new Uint8Array( data ) );
+				try {
 
-			}
+					var json = JSON.parse( data );
+
+				} catch ( e ) {
 
-			var json = JSON.parse( content );
+					content = convertUint8ArrayToString( new Uint8Array( data ) );
+					var json = JSON.parse( content );
+
+				}
+
+			}
 
 			if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {