Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added onLoadStart & onLoadComplete callbacks #440

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/three/TilesRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class TilesRenderer extends TilesRendererBase {
this.visibleTiles = new Set();
this._autoDisableRendererCulling = true;
this.optimizeRaycast = true;
this.loading = false;

this.onLoadTileSet = null;
this.onLoadModel = null;
Expand Down Expand Up @@ -675,6 +676,29 @@ export class TilesRenderer extends TilesRendererBase {
cached.scene = scene;
cached.metadata = metadata;

if ( ! this.loading && this.parseQueue.items.length > 0 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check this.parseQueue.items.length > 0 || this.downloadQueue.items.length > 0


if ( this.onLoadStart ) {

this.onLoadStart( );

}
this.loading = true;

}
Comment on lines +679 to +688
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It occurs to me that this will not trigger if we're in a case where only one tile has downloaded - because this condition will be checked only once a file has been fully parsed. Perhaps this "onStart" condition should go at the end of the update function, instead?


if ( this.loading && this.parseQueue.items.length === 0 && this.downloadQueue.items.length === this.parseQueue.items.length ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check if this.downloadQueue.items.length === 0?


if ( this.onLoadComplete ) {

this.onLoadComplete( );
this.loading = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.loading should be set to false regardless of whether onLoadComplete is set.


}

}


if ( this.onLoadModel ) {

this.onLoadModel( scene, tile );
Expand Down
Loading