提交 db6f9338 编写于 作者: D Don McCurdy

LegacyGLTFLoader: Fix parsing textures in GLB files.

上级 aad9c5c7
......@@ -394,16 +394,6 @@ THREE.LegacyGLTFLoader = ( function () {
};
GLTFBinaryExtension.prototype.loadTextureSourceUri = function ( source, bufferViews ) {
var metadata = source.extensions[ EXTENSIONS.KHR_BINARY_GLTF ];
var bufferView = bufferViews[ metadata.bufferView ];
var stringData = THREE.LoaderUtils.decodeText( new Uint8Array( bufferView ) );
return 'data:' + metadata.mimeType + ';base64,' + btoa( stringData );
};
/*********************************/
/********** INTERNALS ************/
/*********************************/
......@@ -1071,10 +1061,15 @@ THREE.LegacyGLTFLoader = ( function () {
var source = json.images[ texture.source ];
var sourceUri = source.uri;
var isObjectURL = false;
if ( source.extensions && source.extensions[ EXTENSIONS.KHR_BINARY_GLTF ] ) {
sourceUri = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].loadTextureSourceUri( source, dependencies.bufferViews );
var metadata = source.extensions[ EXTENSIONS.KHR_BINARY_GLTF ];
var bufferView = dependencies.bufferViews[ metadata.bufferView ];
var blob = new Blob( [ bufferView ], { type: metadata.mimeType } );
sourceUri = URL.createObjectURL( blob );
isObjectURL = true;
}
......@@ -1090,6 +1085,8 @@ THREE.LegacyGLTFLoader = ( function () {
textureLoader.load( resolveURL( sourceUri, options.path ), function ( _texture ) {
if ( isObjectURL ) URL.revokeObjectURL( sourceUri );
_texture.flipY = false;
if ( texture.name !== undefined ) _texture.name = texture.name;
......@@ -1120,6 +1117,8 @@ THREE.LegacyGLTFLoader = ( function () {
}, undefined, function () {
if ( isObjectURL ) URL.revokeObjectURL( sourceUri );
resolve();
} );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册