Interface: CacheAsTextureMixin
Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/cacheAsTextureMixin.d.ts:15
The CacheAsTextureMixin interface provides methods and properties for caching a container as a texture. This can improve rendering performance for complex static containers by allowing them to be rendered as a single texture. It includes methods to enable or disable caching, update the cached texture, and check 1if the container is currently cached.
Advanced
Extends
Required<CacheAsTextureMixinConstructor>
Properties
~~cacheAsBitmap~~
> cacheAsBitmap: boolean
Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/cacheAsTextureMixin.d.ts:61
Legacy property for backwards compatibility with PixiJS v7 and below.
Use cacheAsTexture instead.
Deprecated
since 8.0.0
cacheAsTexture
> cacheAsTexture: (val) => void
Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/cacheAsTextureMixin.d.ts:45
Caches this container as a texture. This allows the container to be rendered as a single texture, which can improve performance for complex static containers.
Parameters
val
boolean | CacheAsTextureOptions
If true, enables caching with default options. If false, disables caching. Can also pass options object to configure caching behavior.
Returns
void
Example
// Basic caching
container.cacheAsTexture(true);
// With custom options
container.cacheAsTexture({
resolution: 2,
antialias: true,
});
// Disable caching
container.cacheAsTexture(false);
// Cache a complex UI
const ui = new Container();
// Add multiple children...
ui.cacheAsTexture(true);
ui.updateCacheTexture(); // Update if contents change
See
- Container#updateCacheTexture For updating cached content
- Container#isCachedAsTexture For checking cache state
Overrides
VideoSpriteMemory.cacheAsTexture
isCachedAsTexture
> readonly isCachedAsTexture: boolean
Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/cacheAsTextureMixin.d.ts:75
Whether this container is currently cached as a texture.
Example
// Check cache state
if (container.isCachedAsTexture) {
console.log('Container is cached');
}
See
- Container#cacheAsTexture For enabling caching
- Container#updateCacheTexture For updating cache
updateCacheTexture
> updateCacheTexture: () => void
Defined in: node_modules/pixi.js/lib/scene/container/container-mixins/cacheAsTextureMixin.d.ts:55
Updates the cached texture of this container. This will flag the container's cached texture to be redrawn on the next render.
Returns
void
Example
// Basic update after changes
container.updateCacheTexture();