Skip to content

Commit 7566236

Browse files
committed
Added isRenderTexture property.
1 parent 261cb79 commit 7566236

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ The process of managing scissors in the WebGLRenderer has been completely rewrit
5050
* You can now play animations in reverse! Use the new `Sprite.anims.playReverse` method to play a pre-defined animation in reverse from its starting frame. Or call `Sprite.anims.reverse` to immediately reverse the flow of an already running animation. Animations running in reverse still count towards the repeat total and respect the yoyo flag (thanks @khaleb85)
5151
* The `ParticleEmitterManager` now has the Transform component. This means you can now set the position, rotation or scale of the Emitter Manager, and it will influence every Emitter it is rendering. The Managers transform is mixed with that of the Camera. This works in both Canvas and WebGL.
5252
* `TextureManager.addRenderTexture` is a new method that will add a Render Texture into the Texture Manager, allowing you to use it as the texture for Game Objects just by using the texture key. Modifying the source Render Texture will immediately modify any Game Objects using it.
53+
* TextureSource has a new boolean property `isRenderTexture` which is set automatically when it's created.
5354

5455
### Updates
5556

src/textures/TextureSource.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,17 @@ var TextureSource = new Class({
4747
* The Texture this TextureSource belongs to.
4848
*
4949
* @name Phaser.Textures.TextureSource#texture
50-
* @type {string}
50+
* @type {Phaser.Textures.Texture}
5151
* @since 3.0.0
5252
*/
5353
this.texture = texture;
5454

5555
/**
56-
* The source image data. This is either an Image Element, or a Canvas Element.
56+
* The source image data.
57+
* This is either an Image Element, a Canvas Element or a RenderTexture.
5758
*
5859
* @name Phaser.Textures.TextureSource#image
59-
* @type {(HTMLImageElement|HTMLCanvasElement)}
60+
* @type {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture)}
6061
* @since 3.0.0
6162
*/
6263
this.image = source;
@@ -120,6 +121,15 @@ var TextureSource = new Class({
120121
*/
121122
this.isCanvas = (source instanceof HTMLCanvasElement);
122123

124+
/**
125+
* Is the source image a Render Texture?
126+
*
127+
* @name Phaser.Textures.TextureSource#isRenderTexture
128+
* @type {boolean}
129+
* @since 3.12.0
130+
*/
131+
this.isRenderTexture = (source.type === 'RenderTexture');
132+
123133
/**
124134
* Are the source image dimensions a power of two?
125135
*
@@ -158,6 +168,10 @@ var TextureSource = new Class({
158168
{
159169
this.glTexture = this.renderer.canvasToTexture(this.image);
160170
}
171+
else if (this.isRenderTexture)
172+
{
173+
this.glTexture = this.image.texture;
174+
}
161175
else
162176
{
163177
this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode);

0 commit comments

Comments
 (0)