Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jscastro76/threebox/llms.txt
Use this file to discover all available pages before exploring further.
Object Caching System
Threebox automatically caches 3D models to improve performance when loading multiple instances of the same object. TheobjectsCache is a built-in Map that stores loaded models for reuse.
How Caching Works
When you load a 3D model withclone: true (default), Threebox caches the first instance and returns duplicates for subsequent loads:
Threebox.js:76
loadObj method:
Threebox.js:719-744
Clone vs No-Clone Strategy
When
clone: true, all instances share the same geometry and textures, significantly reducing GPU memory usage and draw calls.Performance Monitoring
Threebox provides methods to monitor WebGL resource usage:Memory Information
Real-Time Performance Stats
Combine with Three.js Stats module for comprehensive monitoring:Optimization Best Practices
Use Object Caching
Enable
clone: true for repeated models to share geometry and texturesLimit Draw Calls
Cloned objects result in fewer GPU draw calls - 1 vs N for non-cloned
Dispose Properly
Use
tb.dispose() to free resources before navigationMonitor Memory
Regularly check
tb.memory() to track resource usageCalculating GPU Memory Usage
From the performance example, here’s how to estimate memory:Threebox.js:250-263
Performance Comparison
| Method | GPU Draw Calls | GPU Memory | WebGL Geometries | WebGL Textures |
|---|---|---|---|---|
| Cloned (100 objects) | 1 | ~5 MB | 1x | 1x |
| Non-Cloned (100 objects) | 100 | ~500 MB | 100x | 100x |
Clear and Dispose
Clearing Objects
Threebox.js:947-971
Complete Disposal
Threebox.js:1092-1114
dispose() method:
- Clears all objects from
tb.world - Disposes cached objects in
objectsCache - Removes the map instance
- Frees WebGL resources
- Cleans up the renderer