提交 68f66090 编写于 作者: A alteredq

Added new callbacks for assets load tracking also to SceneLoader.

It works both for JSON models and textures. Handling of every asynchronously loaded asset triggers calls to "onLoadStart" and "onLoadComplete" callbacks.
上级 cb3f2fff
因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
......@@ -3,12 +3,19 @@
*/
THREE.SceneLoader = function () {
this.onLoadStart = function () {};
this.onLoadProgress = function() {};
this.onLoadComplete = function () {};
};
THREE.SceneLoader.prototype = {
load : function ( url, callback_sync, callback_async, callback_progress ) {
var scope = this;
var worker = new Worker( url );
worker.postMessage( 0 );
......@@ -189,6 +196,8 @@ THREE.SceneLoader.prototype = {
handle_mesh( geo, id );
counter_models -= 1;
scope.onLoadComplete();
async_callback_gate();
......@@ -208,6 +217,8 @@ THREE.SceneLoader.prototype = {
};
callback_progress( progress, result );
scope.onLoadProgress();
if( counter_models == 0 && counter_textures == 0 ) {
......@@ -222,6 +233,8 @@ THREE.SceneLoader.prototype = {
counter_textures -= 1;
async_callback_gate();
scope.onLoadComplete();
};
// first go synchronous elements
......@@ -342,6 +355,8 @@ THREE.SceneLoader.prototype = {
if ( g.type == "bin_mesh" || g.type == "ascii_mesh" ) {
counter_models += 1;
scope.onLoadStart();
}
......@@ -410,11 +425,19 @@ THREE.SceneLoader.prototype = {
if( tt.url instanceof Array ) {
counter_textures += tt.url.length;
for( var n = 0; n < tt.url.length; n ++ ) {
scope.onLoadStart();
}
} else {
counter_textures += 1;
scope.onLoadStart();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册