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

GLTFLoader: Clean up, remove getMultiDependencies().

上级 c71cdb34
......@@ -218,23 +218,7 @@ THREE.GLTFLoader = ( function () {
} );
parser.parse( function ( scene, scenes, cameras, animations, json ) {
var glTF = {
scene: scene,
scenes: scenes,
cameras: cameras,
animations: animations,
asset: json.asset,
parser: parser,
userData: {}
};
addUnknownExtensionsToUserData( extensions, glTF, json );
onLoad( glTF );
}, onError );
parser.parse( onLoad, onError );
}
......@@ -1623,7 +1607,9 @@ THREE.GLTFLoader = ( function () {
GLTFParser.prototype.parse = function ( onLoad, onError ) {
var parser = this;
var json = this.json;
var extensions = this.extensions;
// Clear the loader cache
this.cache.removeAll();
......@@ -1631,21 +1617,27 @@ THREE.GLTFLoader = ( function () {
// Mark the special nodes/meshes in json for efficient parse
this.markDefs();
// Fire the callback on complete
this.getMultiDependencies( [
Promise.all( [
'scene',
'animation',
'camera'
this.getDependencies( 'scene' ),
this.getDependencies( 'animation' ),
this.getDependencies( 'camera' ),
] ).then( function ( dependencies ) {
var scenes = dependencies.scenes || [];
var scene = scenes[ json.scene || 0 ];
var animations = dependencies.animations || [];
var cameras = dependencies.cameras || [];
var result = {
scene: dependencies[ 0 ][ json.scene || 0 ],
scenes: dependencies[ 0 ],
animations: dependencies[ 1 ],
cameras: dependencies[ 2 ],
asset: json.asset,
parser: parser,
userData: {}
};
addUnknownExtensionsToUserData( extensions, result, json );
onLoad( scene, scenes, cameras, animations, json );
onLoad( result );
} ).catch( onError );
......@@ -1818,40 +1810,6 @@ THREE.GLTFLoader = ( function () {
};
/**
* Requests all multiple dependencies of the specified types asynchronously, with caching.
* @param {Array<string>} types
* @return {Promise<Object<Array<Object>>>}
*/
GLTFParser.prototype.getMultiDependencies = function ( types ) {
var results = {};
var pending = [];
for ( var i = 0, il = types.length; i < il; i ++ ) {
var type = types[ i ];
var value = this.getDependencies( type );
// TODO: Error-prone use of a callback inside a loop.
value = value.then( function ( key, value ) {
results[ key ] = value;
}.bind( this, type + ( type === 'mesh' ? 'es' : 's' ) ) );
pending.push( value );
}
return Promise.all( pending ).then( function () {
return results;
} );
};
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
* @param {number} bufferIndex
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册