Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Dec 20, 2024
1 parent ed45e85 commit 5c1f071
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions example/src/plugins/UnloadTilesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class UnloadTilesPlugin {
const unloadCallback = tile => {

const scene = tile.cached.scene;
const visible = tiles.visibleTiles.get( tile );
const visible = tiles.visibleTiles.has( tile );

if ( ! visible ) {

Expand All @@ -88,6 +88,8 @@ export class UnloadTilesPlugin {
lruCache.minSize = Infinity;
lruCache.maxSize = Infinity;
lruCache.maxBytesSize = Infinity;
lruCache.unloadPercent = 1;
lruCache.autoMarkUnused = false;

};

Expand All @@ -96,7 +98,7 @@ export class UnloadTilesPlugin {
if ( visible ) {

lruCache.add( tile, unloadCallback );
lruCache.markUnused( tile );
lruCache.markUsed( tile );
deferCallbacks.cancel( tile );

} else {
Expand Down
5 changes: 3 additions & 2 deletions src/utilities/LRUCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class LRUCache {
this.minBytesSize = 0.3 * GIGABYTE_BYTES;
this.maxBytesSize = 0.4 * GIGABYTE_BYTES;
this.unloadPercent = 0.05;
this.autoMarkUnused = true;

// "itemSet" doubles as both the list of the full set of items currently
// stored in the cache (keys) as well as a map to the time the item was last
Expand Down Expand Up @@ -380,7 +381,7 @@ class LRUCache {

}

scheduleUnload( markUnused = true ) {
scheduleUnload() {

if ( ! this.scheduled ) {

Expand All @@ -390,7 +391,7 @@ class LRUCache {
this.scheduled = false;
this.unloadUnusedContent();

if ( markUnused ) {
if ( this.autoMarkUnused ) {

this.markUnusedQueued = true;

Expand Down

0 comments on commit 5c1f071

Please sign in to comment.