new PIXI.RenderTexture (baseRenderTexture, frame) overrides
Name | Type | Attributes | Description |
---|---|---|---|
baseRenderTexture |
PIXI.BaseRenderTexture |
The base texture object that this texture uses. |
|
frame |
PIXI.Rectangle |
<optional> |
The rectangle frame of the texture to show. |
Example
import { autoDetectRenderer, RenderTexture, Sprite } from 'pixi.js';
const renderer = autoDetectRenderer();
const renderTexture = RenderTexture.create({ width: 800, height: 600 });
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 });
// Note that you should not create a new renderer, but reuse the same one as the rest of the application.
// 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 renderTexture = new RenderTexture.create({ width: 100, height: 100 });
renderer.render(sprite, { renderTexture }); // Renders to center of RenderTexture
Extends
Members
filterFrame PIXI.Rectangle | null readonly
Stores sourceFrame
when this texture is inside current filter stack.
You can read it inside filters.
The key for pooled texture of FilterSystem.
framebuffer PIXI.Framebuffer readonly
Shortcut to this.baseTexture.framebuffer
, saves baseTexture cast.
multisample PIXI.MSAA_QUALITY
Shortcut to this.framebuffer.multisample
.
- Default Value:
- PIXI.MSAA_QUALITY.NONE
Methods
PIXI.RenderTexture.create (options) PIXI.RenderTexture static
A short hand way of creating a render texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
IBaseTextureOptions |
<optional> |
Options |
|
options.width |
number |
<optional> |
100 |
The width of the render texture |
options.height |
number |
<optional> |
100 |
The height of the render texture |
options.scaleMode |
PIXI.SCALE_MODES |
<optional> |
PIXI.BaseTexture.defaultOptions.scaleMode |
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 |
Returns:
Type | Description |
---|---|
PIXI.RenderTexture | The new render texture |
Resizes the RenderTexture.
Name | Type | Default | Description |
---|---|---|---|
desiredWidth |
number |
The desired width to resize to. |
|
desiredHeight |
number |
The desired height to resize to. |
|
resizeBaseTexture |
boolean | true |
Should the baseTexture.width and height values be resized as well? |
Changes the resolution of baseTexture, but does not change framebuffer size.
Name | Type | Description |
---|---|---|
resolution |
number |
The new resolution to apply to RenderTexture |
Inherited Properties
From class PIXI.Texture
_frame PIXI.Rectangle inherited
This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)
baseTexture PIXI.BaseTexture<R> inherited
The base texture that this texture uses.
defaultAnchor PIXI.Point inherited
Anchor point that is used as default if sprite is created with this texture.
Changing the defaultAnchor
at a later point of time will not update Sprite's anchor point.
- Default Value:
- {0,0}
defaultBorders PIXI.ITextureBorders inherited
Default width of the non-scalable border that is used if 9-slice plane is created with this texture.
- Since:
- 7.2.0
- See:
destroyed boolean readonly inherited
Has the texture been destroyed?
frame PIXI.Rectangle inherited
The frame specifies the region of the base texture that this texture uses.
Please call updateUvs()
after you change coordinates of frame
manually.
height number inherited
The height of the Texture in pixels.
noFrame boolean inherited
Does this Texture have any frame data assigned to it?
This mode is enabled automatically if no frame was passed inside constructor.
In this mode texture is subscribed to baseTexture events, and fires update
on any change.
Beware, after loading or resize of baseTexture event can fired two times! If you want more control, subscribe on baseTexture itself.
Any assignment of frame
switches off noFrame
mode.
Example
texture.on('update', () => {});
orig PIXI.Rectangle inherited
This is the area of original texture, before it was put in atlas.
resolution number readonly inherited
Returns resolution of baseTexture
rotate number inherited
Indicates whether the texture is rotated inside the atlas set to 2 to compensate for texture packer rotation set to 6 to compensate for spine packer rotation can be used to rotate or mirror sprites See PIXI.groupD8 for explanation
textureCacheIds Array<string> inherited
The ids under which this Texture has been added to the texture cache. This is automatically set as long as Texture.addToCache is used, but may not be set if a Texture is added directly to the TextureCache array.
trim PIXI.Rectangle inherited
This is the trimmed area of original texture, before it was put in atlas
Please call updateUvs()
after you change coordinates of trim
manually.
uvMatrix PIXI.TextureMatrix inherited
Default TextureMatrix instance for this texture. By default, that object is not created because its heavy.
valid boolean inherited
This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.
width number inherited
The width of the Texture in pixels.
_updateID number protected inherited
Update ID is observed by sprites and TextureMatrix instances. Call updateUvs() to increment it.
_uvs PIXI.TextureUvs protected inherited
The WebGL UV data cache. Can be used as quad UV.
Inherited Methods
From class PIXI.Texture
castToBaseTexture () PIXI.BaseTexture inherited
Utility function for BaseTexture|Texture cast.
Returns:
Type | Description |
---|---|
PIXI.BaseTexture |
clone () PIXI.Texture inherited
Creates a new texture object that acts the same as this one.
Returns:
Type | Description |
---|---|
PIXI.Texture |
|
destroy (destroyBase) void inherited
Destroys this texture
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
destroyBase |
boolean |
<optional> |
false |
Whether to destroy the base texture as well |
Fires:
update () void inherited
Updates this texture on the gpu.
Calls the TextureResource update.
If you adjusted frame
manually, please call updateUvs()
instead.
updateUvs () void inherited
Updates the internal WebGL UV cache. Use it after you change frame
or trim
of the texture.
Call it after changing the frame
onBaseTextureUpdated (baseTexture) void protected inherited
Called when the base texture is updated
Name | Type | Description |
---|---|---|
baseTexture |
PIXI.BaseTexture |
The base texture. |