A special type of PIXI.Container which draws its contents to a cached RenderTexture. This is accomplished by overriding the Container#render method to draw to our own special RenderTexture.

Hierarchy (view full)

Constructors

  • Construct a CachedContainer.

    Parameters

    • Optional sprite: any

      A specific sprite to bind to this CachedContainer and its renderTexture.

    Returns CachedContainer

Properties

clearColor: number[] = ...

An RGBA array used to define the clear color of the RenderTexture

displayed: boolean = false

Should our Container also be displayed on screen, in addition to being drawn to the cached RenderTexture?

autoRender: boolean = true

If true, the Container is rendered every frame. If false, the Container is rendered only if CachedContainer#renderDirty is true.

renderDirty: boolean = true

Does the Container need to be rendered? Set to false after the Container is rendered.

_renderPaths: Map<RenderTexture, {
    renderFunction: Function;
    clearColor: number[];
}> = ...

A map of render textures, linked to their render function and an optional RGBA clear color.

Type declaration

  • renderFunction: Function
  • clearColor: number[]
#onResize: ((arg0) => any)

A bound resize function which fires on the renderer resize event.

Type declaration

    • (arg0): any
    • Parameters

      • arg0: Renderer

      Returns any

#backup: {
    sourceFrame: Rectangle;
    renderTexture: RenderTexture;
} = ...

An object which stores a reference to the normal renderer target and source frame. We track this so we can restore them after rendering our cached texture.

Type declaration

  • sourceFrame: Rectangle
  • renderTexture: RenderTexture
#renderTexture: RenderTexture
#sprite: any
textureConfiguration: {
    multisample: MSAA_QUALITY;
    scaleMode: SCALE_MODES;
    format: FORMATS;
} = {}

The texture configuration to use for this cached container

Type declaration

  • multisample: MSAA_QUALITY
  • scaleMode: SCALE_MODES
  • format: FORMATS

Abstract

Accessors

  • get sprite(): any
  • A PIXI.Sprite or SpriteMesh which is bound to this CachedContainer. The RenderTexture from this Container is associated with the Sprite which is automatically rendered.

    Returns any

  • get renderTexture(): RenderTexture
  • The primary render texture bound to this cached container.

    Returns RenderTexture

  • set alphaMode(mode): void
  • Set the alpha mode of the cached container render texture.

    Parameters

    • mode: ALPHA_MODES

    Returns void

Methods

  • Create a render texture, provide a render method and an optional clear color.

    Parameters

    • Optional options: {
          renderFunction: Function;
          clearColor: number[];
      } = {}

      Optional parameters.

      • renderFunction: Function

        Render function that will be called to render into the RT.

      • clearColor: number[]

        An optional clear color to clear the RT before rendering into it.

    Returns RenderTexture

    A reference to the created render texture.

  • Remove a previously created render texture.

    Parameters

    • renderTexture: RenderTexture

      The render texture to remove.

    • Optional destroy: boolean = true

      Should the render texture be destroyed?

    Returns void

  • Clear the cached container, removing its current contents.

    Parameters

    • Optional destroy: boolean = true

      Tell children that we should destroy texture as well.

    Returns CachedContainer

    A reference to the cleared container for chaining.

  • Parameters

    • options: any

    Returns void

    Inherit Doc

  • Parameters

    • renderer: any

    Returns void

    Inherit Doc

  • Protected

    Custom rendering for secondary render textures

    Parameters

    • renderer: Renderer

      The active canvas renderer.

    Returns void

  • Protected

    Bind a render texture to this renderer. Must be called after bindPrimaryBuffer and before bindInitialBuffer.

    Parameters

    • renderer: Renderer

      The active canvas renderer.

    • tex: RenderTexture

      The texture to bind.

    • Optional clearColor: number[]

      A custom clear color.

    Returns void

  • Private

    Bind the primary render texture to the renderer, replacing and saving the original buffer and source frame.

    Parameters

    • renderer: Renderer

      The active canvas renderer.

    Returns void

  • Private

    Remove the render texture from the Renderer, re-binding the original buffer.

    Parameters

    • renderer: Renderer

      The active canvas renderer.

    Returns void

  • Private

    Resize bound render texture(s) when the dimensions or resolution of the Renderer have changed.

    Parameters

    • renderer: Renderer

      The active canvas renderer.

    Returns void

  • Resize a render texture passed as a parameter with the renderer.

    Parameters

    • renderer: Renderer

      The active canvas renderer.

    • rt: RenderTexture

      The render texture to resize.

    Returns void