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

Track the number of tiles loading since loading had finished previously #920

Merged
merged 4 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
34 changes: 26 additions & 8 deletions src/base/TilesRendererBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,12 @@ export class TilesRendererBase {

}

set loadSiblings( v ) {
get loadProgress() {

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;

}

Expand All @@ -108,6 +105,7 @@ export class TilesRendererBase {
this.fetchOptions = {};
this.plugins = [];
this.queuedTiles = [];
this.cachedSinceLoadComplete = new Set();

const lruCache = new LRUCache();
lruCache.unloadPriorityCallback = lruPriorityCallback;
Expand All @@ -125,6 +123,7 @@ export class TilesRendererBase {
this.downloadQueue = downloadQueue;
this.parseQueue = parseQueue;
this.stats = {
inCacheSinceLoad: 0,
inCache: 0,
parsing: 0,
downloading: 0,
Expand Down Expand Up @@ -642,6 +641,13 @@ export class TilesRendererBase {

// Decrement stats
stats.inCache --;
if ( this.cachedSinceLoadComplete.has( tile ) ) {

this.cachedSinceLoadComplete.delete( tile );
stats.inCacheSinceLoad --;

}

if ( t.__loadingState === LOADING ) {

stats.downloading --;
Expand All @@ -666,6 +672,8 @@ export class TilesRendererBase {

}

this.cachedSinceLoadComplete.add( tile );
stats.inCacheSinceLoad ++;
stats.inCache ++;
stats.downloading ++;
tile.__loadingState = LOADING;
Expand Down Expand Up @@ -809,6 +817,16 @@ export class TilesRendererBase {

}

} )
.finally( () => {

if ( stats.parsing === 0 && stats.downloading === 0 ) {

this.cachedSinceLoadComplete.clear();
stats.inCacheSinceLoad = 0;

}

} );

}
Expand Down
Loading