Skip to content

Commit

Permalink
comments (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Jul 6, 2024
1 parent 0068739 commit 2e41b43
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/three/TilesRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@ export class TilesRenderer extends TilesRendererBase {
this.activeTiles = new Set();
this.visibleTiles = new Set();
this.optimizeRaycast = true;
this._autoDisableRendererCulling = true;
this._eventDispatcher = new EventDispatcher();

// flag indicating whether frustum culling should be disabled
this._autoDisableRendererCulling = true;

// flag indicating whether tiles are actively loading so events can be fired
this._loadingTiles = false;

this.onLoadTileSet = null;
this.onLoadModel = null;
this.onDisposeModel = null;
Expand Down Expand Up @@ -641,6 +646,16 @@ export class TilesRenderer extends TilesRendererBase {

}

// check if this is the beginning of a new set of tiles to load and dispatch and event
const stats = this.stats;
const currentlyLoading = stats.parsing + stats.downloading;
if ( this._loadingTiles === false && currentlyLoading > 0 ) {

this.dispatchEvent( { type: 'tiles-load-start' } );
this._loadingTiles = true;

}

return promise.then( result => {

let scene;
Expand Down Expand Up @@ -734,6 +749,7 @@ export class TilesRenderer extends TilesRendererBase {
cached.scene = scene;
cached.metadata = metadata;

// dispatch an event indicating that this model has completed
this.dispatchEvent( {
type: 'load-model',
scene,
Expand All @@ -746,6 +762,15 @@ export class TilesRenderer extends TilesRendererBase {

}

// dispatch an "end" event if all tiles have finished loading
const currentlyLoading = stats.parsing + stats.downloading;
if ( this._loadingTiles === true && currentlyLoading === 1 ) {

this.dispatchEvent( { type: 'tiles-load-end' } );
this._loadingTiles = false;

}

} );

}
Expand Down

0 comments on commit 2e41b43

Please sign in to comment.