FrameCache provides automatic per-frame caching for expensive function calls.
This utility allows you to wrap expensive methods so that:
Usage:
// Get the singleton instanceprivate frameCache = FrameCache.getInstance()// Wrap an expensive methodprivate getCachedHandOrientation = this.frameCache.wrap( 'getHandOrientation', () => this.computeHandOrientation())// Use the cached versionconst orientation = this.getCachedHandOrientation()Results in ~0.03ms overhead compared to a simple manual caching solution. Copy
// Get the singleton instanceprivate frameCache = FrameCache.getInstance()// Wrap an expensive methodprivate getCachedHandOrientation = this.frameCache.wrap( 'getHandOrientation', () => this.computeHandOrientation())// Use the cached versionconst orientation = this.getCachedHandOrientation()Results in ~0.03ms overhead compared to a simple manual caching solution.
Static
Clear all caches managed by this instance
Remove a cached function
Wrap a function with per-frame caching.
Unique identifier for this cached function
The expensive function to cache
A cached version of the function
Wrap a method with per-frame caching, preserving 'this' context.
The object context ('this')
The expensive method to cache
A cached version of the method
FrameCache provides automatic per-frame caching for expensive function calls.
This utility allows you to wrap expensive methods so that:
Usage: