()
| 44 | * Safe to call multiple times (only registers once). |
| 45 | */ |
| 46 | export function registerAllCaches(): void { |
| 47 | if (registered) { |
| 48 | return; |
| 49 | } |
| 50 | registered = true; |
| 51 | |
| 52 | // ======================================================================== |
| 53 | // Priority 0: THREE.Texture objects (must dispose first) |
| 54 | // ======================================================================== |
| 55 | |
| 56 | CacheManager.register({ |
| 57 | name: 'frustumTextures', |
| 58 | label: 'Frustum Textures', |
| 59 | priority: CacheDisposalPriority.TEXTURE, |
| 60 | clear: clearFrustumTextureCache, |
| 61 | getStats: () => { |
| 62 | const stats = getFrustumTextureCacheStats(); |
| 63 | // Textures: ~65KB each (128px bitmaps) |
| 64 | return { |
| 65 | count: stats.textures, |
| 66 | sizeBytes: stats.textures * 65000, |
| 67 | }; |
| 68 | }, |
| 69 | strategy: 'lazy', |
| 70 | memoryType: 'js', |
| 71 | showInStats: true, |
| 72 | }); |
| 73 | |
| 74 | CacheManager.register({ |
| 75 | name: 'frustumBitmaps', |
| 76 | label: 'Decoded Bitmaps', |
| 77 | priority: CacheDisposalPriority.BITMAP, |
| 78 | clear: () => {}, // Cleared with frustumTextures |
| 79 | getStats: () => { |
| 80 | const stats = getFrustumTextureCacheStats(); |
| 81 | // Bitmaps: ~65KB each (128px) |
| 82 | return { |
| 83 | count: stats.bitmaps, |
| 84 | sizeBytes: stats.bitmaps * 65000, |
| 85 | }; |
| 86 | }, |
| 87 | strategy: 'lazy', |
| 88 | memoryType: 'js', |
| 89 | showInStats: true, |
| 90 | }); |
| 91 | |
| 92 | // ======================================================================== |
| 93 | // Priority 20: Blob URLs (revoke after textures release references) |
| 94 | // Note: thumbnailCache creates blob URLs from decoded images |
| 95 | // ======================================================================== |
| 96 | |
| 97 | CacheManager.register({ |
| 98 | name: 'thumbnails', |
| 99 | label: 'Thumbnails', |
| 100 | priority: CacheDisposalPriority.BLOB_URL, |
| 101 | clear: clearThumbnailCache, |
| 102 | getStats: () => { |
| 103 | const stats = getThumbnailCacheStats(); |
no test coverage detected