pixi.js
    Preparing search index...

    Interface CacheAsTextureMixinAdvanced

    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.

    interface CacheAsTextureMixin {
        cacheAsBitmap: boolean;
        cacheAsTexture: (val: boolean | CacheAsTextureOptions) => void;
        isCachedAsTexture: boolean;
        updateCacheTexture: () => void;
    }

    Hierarchy

    • Required<CacheAsTextureMixinConstructor>
      • CacheAsTextureMixin
    Index

    Properties

    cacheAsBitmap: boolean

    Legacy property for backwards compatibility with PixiJS v7 and below. Use cacheAsTexture instead.

    since 8.0.0

    cacheAsTexture: (val: boolean | CacheAsTextureOptions) => void

    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.

    Type declaration

      • (val: boolean | CacheAsTextureOptions): void
      • 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

    // 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
    isCachedAsTexture: boolean

    Whether this container is currently cached as a texture.

    // Check cache state
    if (container.isCachedAsTexture) {
    console.log('Container is cached');
    }
    updateCacheTexture: () => void

    Updates the cached texture of this container. This will flag the container's cached texture to be redrawn on the next render.

    // Basic update after changes
    container.updateCacheTexture();