From 2e41b4342482ad791e82685da832c7a3cc1cc39e Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Sat, 6 Jul 2024 10:33:29 +0900 Subject: [PATCH] comments (#602) --- src/three/TilesRenderer.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/three/TilesRenderer.js b/src/three/TilesRenderer.js index 7d2e7cd71..86aa904c4 100644 --- a/src/three/TilesRenderer.js +++ b/src/three/TilesRenderer.js @@ -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; @@ -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; @@ -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, @@ -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; + + } + } ); }