PIXI.BaseRenderTexture

class BaseRenderTexture extends PIXI.BaseTexture

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:

let renderer = PIXI.autoDetectRenderer();
let baseRenderTexture = new PIXI.BaseRenderTexture({ width: 800, height: 600 });
let renderTexture = new PIXI.RenderTexture(baseRenderTexture);
let sprite = PIXI.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()

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

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

Constructor


new PIXI.BaseRenderTexture(options: IBaseTextureOptions) → {}
Parameters:
Name Type Attributes Default Description
options IBaseTextureOptions
options.width number

<optional>

100

The width of the base render texture.

options.height number

<optional>

100

The height of the base render texture.

options.scaleMode PIXI.SCALE_MODES

<optional>

PIXI.settings.SCALE_MODE

See PIXI.SCALE_MODES for possible values.

options.resolution number

<optional>

PIXI.settings.RESOLUTION

The resolution / device pixel ratio of the texture being generated.

options.multisample PIXI.MSAA_QUALITY

<optional>

PIXI.MSAA_QUALITY.NONE

The number of samples of the frame buffer.

Summary


Properties from BaseRenderTexture

Array<any>
filterStack

The data structure for the filters.

Array<PIXI.MaskData>
maskStack

The data structure for the stencil masks.

PIXI.utils.CanvasRenderTarget
protected _canvasRenderTarget = undefined

Methods from BaseRenderTexture

Events from BaseRenderTexture

Inherited Events from BaseTexture

Public Properties


filterStack BaseRenderTexture.ts:55
filterStack: Array

The data structure for the filters.

maskStack BaseRenderTexture.ts:52
maskStack: Array<PIXI.MaskData>

The data structure for the stencil masks.

Protected Properties


_canvasRenderTarget BaseTexture.ts:17
protected _canvasRenderTarget: PIXI.utils.CanvasRenderTarget = undefined

A reference to the canvas render target (we only need one as this can be shared across renderers)

Public Methods


destroy BaseRenderTexture.ts:128
destroy() → {void}

Destroys this texture.

Returns:
Type Description
void
dispose BaseRenderTexture.ts:115
dispose() → {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:
Type Description
void
resize BaseRenderTexture.ts:104
resize(desiredWidth: number, desiredHeight: number) → {void}

Resizes the BaseRenderTexture.

Parameters:
Name Type Description
desiredWidth number

The desired width to resize to.

desiredHeight number

The desired height to resize to.

Returns:
Type Description
void

Events


loaded BaseTexture.ts:264

Fired when a not-immediately-available source finishes loading.

Parameters:
Name Type Description
baseTexture PIXI.BaseTexture

Resource loaded.


Powered by webdoc!