Class BaseRenderTexture

A BaseRenderTexture is a special texture that allows any PixiJS display object to be rendered to it.

Hint: All DisplayObjects (i.e. Sprites) that render to a BaseRenderTexture should be preloaded otherwise black rectangles will be drawn instead.

A BaseRenderTexture takes a snapshot of any Display Object given to its render method. The position and rotation of the given Display Objects is ignored. For example:

Example

import { autoDetectRenderer, BaseRenderTexture, RenderTexture, Sprite } from 'pixi.js';

const renderer = autoDetectRenderer();
const baseRenderTexture = new BaseRenderTexture({ width: 800, height: 600 });
const renderTexture = new RenderTexture(baseRenderTexture);
const sprite = Sprite.from('spinObj_01.png');

sprite.position.x = 800 / 2;
sprite.position.y = 600 / 2;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;

renderer.render(sprite, { renderTexture });

// The Sprite in this case will be rendered using its local transform.
// To render this sprite at 0,0 you can clear the transform
sprite.setTransform();

const baseRenderTexture = new BaseRenderTexture({ width: 100, height: 100 });
const renderTexture = new RenderTexture(baseRenderTexture);

renderer.render(sprite, { renderTexture }); // Renders to center of RenderTexture

Memberof

PIXI

Hierarchy (view full)

Constructors

Properties

_batchEnabled: number

Number of the texture batch, used by multi-texture renderers

Member

_batchLocation: number

Location inside texture batch, used by multi-texture renderers

Member

_clear: Color
alphaMode: ALPHA_MODES

How to treat premultiplied alpha, see PIXI.ALPHA_MODES.

Member

Default

PIXI.ALPHA_MODES.UNPACK
anisotropicLevel: number

Anisotropic filtering level of texture

Member

Default

0
cacheId: string

Currently default cache ID.

Member

destroyed: boolean

Flag if BaseTexture has been destroyed.

Member

dirtyId: number

Used by TextureSystem to only update texture to the GPU when needed. Please call update() to increment it.

filterStack: any[]

The data structure for the filters.

format: FORMATS

The pixel format of the texture

Default

PIXI.FORMATS.RGBA
framebuffer: Framebuffer

The framebuffer of this base texture.

height: number

The height of the base texture set when the image has loaded

isPowerOfTwo: boolean

Whether or not the texture is a power of two, try to use power of two textures as much as you can

Default

false
ktxKeyValueData: Map<string, DataView>
maskStack: MaskData[]

The data structure for the stencil masks.

Whether its a part of another texture, handled by ArrayResource or CubeResource

Member

resolution: number

The resolution / device pixel ratio of the texture

Default

PIXI.settings.RESOLUTION
resource: Resource

The resource used by this BaseTexture, there can only be one resource per BaseTexture, but textures can share resources.

Member

target: TARGETS

The target type

Default

PIXI.TARGETS.TEXTURE_2D
textureCacheIds: string[]

The collection of alternative cache ids, since some BaseTextures can have more than one ID, short name and longer full URL

Member

type: TYPES

The type of resource data

Default

PIXI.TYPES.UNSIGNED_BYTE
valid: boolean

Generally speaking means when resource is loaded.

Member

width: number

The width of the base texture set when the image has loaded

_globalBatch: number

Global number of the texture batch, used by multi-texture renderers.

defaultOptions: IBaseTextureOptions<any>

Default options used when creating BaseTexture objects.

Static

Memberof

PIXI.BaseTexture

prefixed: string | boolean

Accessors

  • get clear(): Color
  • Color object when clearning the texture.

    Returns Color

    Since

    7.2.0

  • get clearColor(): ColorSource
  • Returns ColorSource

  • set clearColor(value): void
  • Color when clearning the texture.

    Parameters

    Returns void

  • get mipmap(): MIPMAP_MODES
  • Mipmap mode of the texture, affects downscaled images

    Returns MIPMAP_MODES

    Default

    PIXI.MIPMAP_MODES.POW2
    
  • set mipmap(value): void
  • Parameters

    Returns void

  • get multisample(): MSAA_QUALITY
  • Shortcut to this.framebuffer.multisample.

    Returns MSAA_QUALITY

    Default

    PIXI.MSAA_QUALITY.NONE
    
  • set multisample(value): void
  • Parameters

    Returns void

  • get realHeight(): number
  • Pixel height of the source of this texture

    Returns number

  • get realWidth(): number
  • Pixel width of the source of this texture

    Returns number

  • get scaleMode(): SCALE_MODES
  • The scale mode to apply when scaling this texture

    Returns SCALE_MODES

    Default

    PIXI.SCALE_MODES.LINEAR
    
  • set scaleMode(value): void
  • Parameters

    Returns void

  • get wrapMode(): WRAP_MODES
  • How the texture wraps

    Returns WRAP_MODES

    Default

    PIXI.WRAP_MODES.CLAMP
    
  • set wrapMode(value): void
  • Parameters

    Returns void

Methods

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

  • Destroys this texture.

    Returns void

  • Frees the texture and framebuffer from WebGL memory without destroying this texture object. This means you can still use the texture later which will upload it to GPU memory again.

    Returns void

    Fires

    PIXI.BaseTexture#dispose

  • Calls each of the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Rest ...args: any[]

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T

    Returns ((...args) => void)[]

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

  • Add a listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

  • Add a one-time listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns this

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns this

  • Remove the listeners of a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

  • Resizes the BaseRenderTexture.

    Parameters

    • desiredWidth: number

      The desired width to resize to.

    • desiredHeight: number

      The desired height to resize to.

    Returns void

  • Sets real size of baseTexture, preserves current resolution.

    Parameters

    • realWidth: number

      Full rendered width

    • realHeight: number

      Full rendered height

    • Optional resolution: number

      Optionally set resolution

    Returns this

    • this
  • Changes resolution

    Parameters

    • resolution: number

      res

    Returns this

    • this
  • Sets the resource if it wasn't set. Throws error if resource already present

    Parameters

    • resource: Resource

      that is managing this BaseTexture

    Returns this

    • this
  • Changes w/h/resolution. Texture becomes valid if width and height are greater than zero.

    Parameters

    • desiredWidth: number

      Desired visual width

    • desiredHeight: number

      Desired visual height

    • Optional resolution: number

      Optionally set resolution

    Returns this

    • this
  • Changes style options of BaseTexture

    Parameters

    Returns this

    • this
  • Invalidates the object. Texture becomes valid if width and height are greater than zero.

    Returns void

  • Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object.

    Parameters

    Returns void

  • Helper function that creates a base texture based on the source you provide. The source can be - image url, image element, canvas element. If the source is an image url or an image element and not in the base texture cache, it will be created and loaded.

    Type Parameters

    Parameters

    • source: string | string[] | ImageSource

      The source to create base texture from.

    • Optional options: IBaseTextureOptions<RO>

      See PIXI.BaseTexture's constructor for options.

    • Optional strict: boolean

      Enforce strict-mode, see PIXI.settings.STRICT_TEXTURE_CACHE.

    Returns BaseTexture<R, IAutoDetectOptions>

    The new base texture.

    Static

Generated using TypeDoc