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) → {}
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> |
The data structure for the filters. |
Array<PIXI.MaskData> |
The data structure for the stencil masks. |
PIXI.utils.CanvasRenderTarget |
|
Methods from BaseRenderTexture
void |
Destroys this texture. |
void |
|
void |
|
Events from BaseRenderTexture
Properties inherited from BaseTexture
number |
|
number |
|
PIXI.ALPHA_MODES |
|
number |
|
string |
|
boolean |
|
number |
|
PIXI.FORMATS |
|
number |
|
boolean |
|
PIXI.MIPMAP_MODES |
|
PIXI.BaseTexture |
|
number |
|
number |
|
number |
|
PIXI.Resource |
|
PIXI.SCALE_MODES |
|
PIXI.TARGETS |
|
Array<string> |
|
PIXI.TYPES |
|
boolean |
|
number |
|
PIXI.WRAP_MODES |
|
number |
|
number |
|
number |
|
Methods inherited from BaseTexture
PIXI.BaseTexture |
Utility function for BaseTexture|Texture cast. |
PIXI.ICanvasImageSource |
|
this |
|
this |
|
this |
|
this |
|
this |
|
void |
Invalidates the object. Texture becomes valid if width and height are greater than zero. |
Inherited Events from BaseTexture
Public Properties
maskStack: Array<PIXI.MaskData>
The data structure for the stencil masks.
Protected Properties
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() → {void}
Destroys this texture.
Type | Description |
---|---|
void |
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.
Type | Description |
---|---|
void |
resize(desiredWidth: number, desiredHeight: number) → {void}
Resizes the BaseRenderTexture.
Name | Type | Description |
---|---|---|
desiredWidth | number |
The desired width to resize to. |
desiredHeight | number |
The desired height to resize to. |
Type | Description |
---|---|
void |
Events
Fired when a not-immediately-available source finishes loading.
Name | Type | Description |
---|---|---|
baseTexture | PIXI.BaseTexture |
Resource loaded. |