From 5c1f0713a53ef9c609260ba889681358aa79611e Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Fri, 20 Dec 2024 11:37:44 +0900 Subject: [PATCH] Fixes --- example/src/plugins/UnloadTilesPlugin.js | 6 ++++-- src/utilities/LRUCache.js | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/example/src/plugins/UnloadTilesPlugin.js b/example/src/plugins/UnloadTilesPlugin.js index bcdd77b7..fdc11634 100644 --- a/example/src/plugins/UnloadTilesPlugin.js +++ b/example/src/plugins/UnloadTilesPlugin.js @@ -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 ) { @@ -88,6 +88,8 @@ export class UnloadTilesPlugin { lruCache.minSize = Infinity; lruCache.maxSize = Infinity; lruCache.maxBytesSize = Infinity; + lruCache.unloadPercent = 1; + lruCache.autoMarkUnused = false; }; @@ -96,7 +98,7 @@ export class UnloadTilesPlugin { if ( visible ) { lruCache.add( tile, unloadCallback ); - lruCache.markUnused( tile ); + lruCache.markUsed( tile ); deferCallbacks.cancel( tile ); } else { diff --git a/src/utilities/LRUCache.js b/src/utilities/LRUCache.js index ecb8123f..878e0523 100644 --- a/src/utilities/LRUCache.js +++ b/src/utilities/LRUCache.js @@ -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 @@ -380,7 +381,7 @@ class LRUCache { } - scheduleUnload( markUnused = true ) { + scheduleUnload() { if ( ! this.scheduled ) { @@ -390,7 +391,7 @@ class LRUCache { this.scheduled = false; this.unloadUnusedContent(); - if ( markUnused ) { + if ( this.autoMarkUnused ) { this.markUnusedQueued = true;