From 836c2f613d1eee3618e6cf4aa285f91523f45d33 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Sat, 11 Jan 2025 12:37:24 +0900 Subject: [PATCH 1/4] Track the number of tiles loading since loading had finished previously --- src/base/TilesRendererBase.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/base/TilesRendererBase.js b/src/base/TilesRendererBase.js index ea10d102..25f54575 100644 --- a/src/base/TilesRendererBase.js +++ b/src/base/TilesRendererBase.js @@ -108,6 +108,7 @@ export class TilesRendererBase { this.fetchOptions = {}; this.plugins = []; this.queuedTiles = []; + this.cachedSinceReset = new Set(); const lruCache = new LRUCache(); lruCache.unloadPriorityCallback = lruPriorityCallback; @@ -125,6 +126,7 @@ export class TilesRendererBase { this.downloadQueue = downloadQueue; this.parseQueue = parseQueue; this.stats = { + inCacheSinceReset: 0, inCache: 0, parsing: 0, downloading: 0, @@ -642,6 +644,13 @@ export class TilesRendererBase { // Decrement stats stats.inCache --; + if ( this.cachedSinceReset.has( tile ) ) { + + this.cachedSinceReset.delete( tile ); + stats.inCacheSinceReset --; + + } + if ( t.__loadingState === LOADING ) { stats.downloading --; @@ -666,6 +675,8 @@ export class TilesRendererBase { } + this.cachedSinceReset.add( tile ); + stats.inCacheSinceReset ++; stats.inCache ++; stats.downloading ++; tile.__loadingState = LOADING; @@ -809,6 +820,16 @@ export class TilesRendererBase { } + } ) + .finally( () => { + + if ( stats.parsing === 0 && stats.downloading === 0 ) { + + this.cachedSinceReset.clear(); + stats.inCacheSinceReset = 0; + + } + } ); } From 85cf97ccbf6746fac84bca2c4c6db0761baeb492 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Sun, 12 Jan 2025 13:04:01 +0900 Subject: [PATCH 2/4] Update names --- src/base/TilesRendererBase.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/base/TilesRendererBase.js b/src/base/TilesRendererBase.js index 25f54575..d03b0ccd 100644 --- a/src/base/TilesRendererBase.js +++ b/src/base/TilesRendererBase.js @@ -108,7 +108,7 @@ export class TilesRendererBase { this.fetchOptions = {}; this.plugins = []; this.queuedTiles = []; - this.cachedSinceReset = new Set(); + this.cachedSinceLoadComplete = new Set(); const lruCache = new LRUCache(); lruCache.unloadPriorityCallback = lruPriorityCallback; @@ -126,7 +126,7 @@ export class TilesRendererBase { this.downloadQueue = downloadQueue; this.parseQueue = parseQueue; this.stats = { - inCacheSinceReset: 0, + inCacheSinceLoad: 0, inCache: 0, parsing: 0, downloading: 0, @@ -644,10 +644,10 @@ export class TilesRendererBase { // Decrement stats stats.inCache --; - if ( this.cachedSinceReset.has( tile ) ) { + if ( this.cachedSinceLoadComplete.has( tile ) ) { - this.cachedSinceReset.delete( tile ); - stats.inCacheSinceReset --; + this.cachedSinceLoadComplete.delete( tile ); + stats.inCacheSinceLoad --; } @@ -675,8 +675,8 @@ export class TilesRendererBase { } - this.cachedSinceReset.add( tile ); - stats.inCacheSinceReset ++; + this.cachedSinceLoadComplete.add( tile ); + stats.inCacheSinceLoad ++; stats.inCache ++; stats.downloading ++; tile.__loadingState = LOADING; @@ -825,8 +825,8 @@ export class TilesRendererBase { if ( stats.parsing === 0 && stats.downloading === 0 ) { - this.cachedSinceReset.clear(); - stats.inCacheSinceReset = 0; + this.cachedSinceLoadComplete.clear(); + stats.inCacheSinceLoad = 0; } From efde634b980e06b791a0de51c1c7e43c4d910b44 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Mon, 13 Jan 2025 17:45:07 +0900 Subject: [PATCH 3/4] Add "loadPercent" --- src/base/TilesRendererBase.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/base/TilesRendererBase.js b/src/base/TilesRendererBase.js index d03b0ccd..9ed11336 100644 --- a/src/base/TilesRendererBase.js +++ b/src/base/TilesRendererBase.js @@ -87,15 +87,12 @@ export class TilesRendererBase { } - set loadSiblings( v ) { + get loadPercent() { - console.warn( 'TilesRenderer: "loadSiblings" option has been removed.' ); - - } - - set stopAtEmptyTiles( v ) { - - console.warn( 'TilesRenderer: "stopAtEmptyTiles" option has been removed.' ); + const stats = this.stats; + const loading = stats.downloading + stats.parsing; + const total = stats.inCacheSinceLoad; + return total === 0 ? 1.0 : 1.0 - loading / total; } From 63ee08b263a93c7813f6ce6734c31d3bc0b053d9 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Mon, 13 Jan 2025 18:07:35 +0900 Subject: [PATCH 4/4] loadPercent -> loadProgress --- README.md | 16 ++++++++-------- src/base/TilesRendererBase.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 03c0628c..c9625501 100644 --- a/README.md +++ b/README.md @@ -392,14 +392,6 @@ If true then the `raycast` functions of the loaded tile objects are overriden to If you would like to manage raycasting against tiles yourself this behavior can be disabled if needed by setting `optizeRaycast` to false. -### .preprocessURL - -```js -preprocessURL = null : ( uri : string | URL ) => string | URL; -``` - -Function to preprocess the url for each individual tile geometry or child tile set to be loaded. If null then the url is used directly. - ### .lruCache ```js @@ -446,6 +438,14 @@ manager : LoadingManager The manager used when loading tile geometry. +### .loadProgress + +```js +readOnly loadProgress : Number +``` + +Returns the total load progress between `[0, 1]`. Progress is measured since the last set of loading tiles completed. + ### .constructor ```js diff --git a/src/base/TilesRendererBase.js b/src/base/TilesRendererBase.js index 9ed11336..5500b0e6 100644 --- a/src/base/TilesRendererBase.js +++ b/src/base/TilesRendererBase.js @@ -87,7 +87,7 @@ export class TilesRendererBase { } - get loadPercent() { + get loadProgress() { const stats = this.stats; const loading = stats.downloading + stats.parsing;