未验证 提交 3860dc59 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #14408 from donmccurdy/feat-gltfloader-loadingmanager-compat

GLTFLoader: Ensure LoadingManager onLoad is supported.
......@@ -27,6 +27,28 @@ THREE.GLTFLoader = ( function () {
var path = this.path !== undefined ? this.path : THREE.LoaderUtils.extractUrlBase( url );
// Tells the LoadingManager to track an extra item, which resolves after
// the model is fully loaded. This means the count of items loaded will
// be incorrect, but ensures manager.onLoad() does not fire early.
scope.manager.itemStart( url );
var _onError = function ( e ) {
if ( onError ) {
onError( e );
} else {
console.error( e );
}
scope.manager.itemEnd( url );
scope.manager.itemError( url );
};
var loader = new THREE.FileLoader( scope.manager );
loader.setResponseType( 'arraybuffer' );
......@@ -35,23 +57,21 @@ THREE.GLTFLoader = ( function () {
try {
scope.parse( data, path, onLoad, onError );
} catch ( e ) {
scope.parse( data, path, function ( gltf ) {
if ( onError !== undefined ) {
onLoad( gltf );
onError( e );
scope.manager.itemEnd( url );
} else {
}, _onError );
throw e;
} catch ( e ) {
}
_onError( e );
}
}, onProgress, onError );
}, onProgress, _onError );
},
......
......@@ -97,6 +97,10 @@
scene.add( gltf.scene );
}, undefined, function ( e ) {
console.error( e );
} );
renderer = new THREE.WebGLRenderer( { antialias: true } );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册