Model Cache Fixes (February 2026)
Overview
Two critical bugs in the IndexedDB processed model cache were fixed in February 2026. These bugs caused missing objects (altars, trees) and lost textures (white/wrong colors) after browser restarts. The fixes ensure reliable model caching without visual corruption.Bug #1: Missing Objects
Symptoms
- Objects disappear after browser restart (altars, trees, buildings)
- Scene hierarchy incomplete
- Console errors about missing meshes
- Inconsistent object counts between sessions
Root Cause
TheserializeNode() function used findIndex-by-name to map hierarchy nodes to mesh data:
"", "Cube", "Cube") all resolved to the same index. During deserialization, Three.js add() auto-removes objects from their previous parent, so only the last reference survived.
Example Failure:
Fix
Use object-identity map instead of name-based lookup:Bug #2: Lost Textures
Symptoms
- White or grey materials after browser restart
- Textures not loading
- Correct geometry but wrong colors
- Trees appear grey instead of green
Root Cause
Textures were serialized as ephemeralblob: URLs but never reloaded during deserialization:
Fix
Extract raw RGBA pixel data via canvas and restore asTHREE.DataTexture:
Bug #3: Grey Tree Materials (WebGPU)
Symptoms
- Trees appear grey in WebGPU renderer
- Dissolve effect not working
instanceof MeshStandardMaterialcheck fails
Root Cause
ThecreateDissolveMaterial() function used instanceof MeshStandardMaterial which fails for MeshStandardNodeMaterial in the WebGPU build:
MeshStandardNodeMaterial for WebGPU compatibility, but they don’t pass instanceof MeshStandardMaterial checks.
Fix
Use duck-type property check instead ofinstanceof:
Cache Version Bump
ThePROCESSED_CACHE_VERSION was bumped from 2 to 3 to invalidate broken cache entries:
Debugging Tools
Disable Cache
Bypass the cache entirely for debugging:- Verify cache is causing the issue
- Test model loading without cache
- Force fresh model processing
Clear Cache
Delete the entire cache database:Inspect Cache
View cached models:Verify Texture Data
Check if textures are properly serialized:Performance Impact
Cache Size
Before: ~2-5 MB per model (blob URLs + metadata) After: ~5-15 MB per model (raw RGBA pixels + metadata) Trade-off: Larger cache size for reliability and instant texture availability.Load Time
Before:- Cache hit: 50-100ms (blob URL loading + async texture decode)
- Cache miss: 500-2000ms (GLTF parse + texture load)
- Cache hit: 20-50ms (synchronous DataTexture creation)
- Cache miss: 500-2000ms (unchanged)
Testing
Verify Fix
- Load a model with duplicate mesh names (e.g., altar, tree)
- Verify all objects are visible
- Reload page (cache hit)
- Verify all objects still visible
- Check textures are correct colors
Regression Test
Rollback
If you encounter issues with the new cache:Related Changes
Files Modified:packages/shared/src/utils/rendering/ModelCache.ts- Core cache implementationpackages/shared/src/systems/shared/world/GPUVegetation.ts- Dissolve material fix
- Version 1: Original implementation (pre-2025)
- Version 2: Added collision data caching (2025)
- Version 3: Fixed missing objects and texture persistence (February 2026)
Related Documentation
- Arena Performance Optimizations - Related rendering improvements
- Terrain Height Cache Fix - Another cache-related fix
- ClientLoader.ts - Model loading system