new RenderTexture(renderer [, width] [, height] [, scaleMode] [, resolution])
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
renderer |
CanvasRenderer | WebGLRenderer | The renderer used for this RenderTexture |
||
width |
number |
<optional> |
100 | The width of the render texture |
height |
number |
<optional> |
100 | The height of the render texture |
scaleMode |
number |
<optional> |
See SCALE_MODES for possible values |
|
resolution |
number |
<optional> |
1 | The resolution of the texture being generated |
Extends
Members
-
baseTexture :BaseTexture
-
The base texture that this texture uses.
Type:
- Inherited From:
- Source:
-
crop :Rectangle
-
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)Type:
- Inherited From:
- Source:
-
frame :Rectangle
-
The frame specifies the region of the base texture that this texture uses.
Type:
- Inherited From:
- Source:
-
height :number
-
The height of the render texture
Type:
- number
- Overrides:
- Source:
-
noFrame :boolean
-
Does this Texture have any frame data assigned to it?
Type:
- boolean
- Inherited From:
- Source:
-
renderer :CanvasRenderer|WebGLRenderer
-
The renderer this RenderTexture uses. A RenderTexture can only belong to one renderer at the moment if its webGL.
Type:
-
requiresUpdate :boolean
-
This will let a renderer know that a texture has been updated (used mainly for webGL uv updates)
Type:
- boolean
- Inherited From:
- Source:
-
resolution :number
-
The Resolution of the texture.
Type:
- number
-
rotate :number
-
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 GroupD8 for explanationType:
- number
- Inherited From:
- Source:
-
trim :Rectangle
-
The texture trim data.
Type:
- Inherited From:
- Source:
-
valid :boolean
-
Type:
- boolean
- Overrides:
- Source:
-
width :number
-
The with of the render texture
Type:
- number
- Overrides:
- Source:
Methods
-
clear()
-
Clears the RenderTexture.
-
destroy(destroyBase)
-
Destroys this texture
Parameters:
Name Type Description destroyBase
boolean Whether to destroy the base texture as well
-
getBase64()
-
Will return a a base64 encoded string of this texture. It works by calling RenderTexture.getCanvas and then running toDataURL on that.
Returns:
A base64 encoded string of the texture.
- Type
- string
-
getCanvas()
-
Creates a Canvas element, renders this RenderTexture to it and then returns it.
Returns:
A Canvas element with the texture rendered on.
- Type
- HTMLCanvasElement
-
getImage()
-
Will return a HTML Image of the texture
Returns:
- Type
- Image
-
getPixel(x, y)
-
Will return a one-dimensional array containing the pixel data of a pixel within the texture in RGBA order, with integer values between 0 and 255 (included).
Parameters:
Name Type Description x
number The x coordinate of the pixel to retrieve.
y
number The y coordinate of the pixel to retrieve.
Returns:
- Type
- Uint8ClampedArray
-
getPixels()
-
Will return a one-dimensional array containing the pixel data of the entire texture in RGBA order, with integer values between 0 and 255 (included).
Returns:
- Type
- Uint8ClampedArray
-
render(displayObject [, matrix] [, clear] [, updateTransform])
-
Draw/render the given DisplayObject onto the texture.
The displayObject and descendents are transformed during this operation.
IfupdateTransform
is true then the transformations will be restored before the
method returns. Otherwise it is up to the calling code to correctly use or reset
the transformed display objects.The display object is always rendered with a worldAlpha value of 1.
Parameters:
Name Type Argument Default Description displayObject
DisplayObject The display object to render this texture on
matrix
Matrix <optional>
Optional matrix to apply to the display object before rendering.
clear
boolean <optional>
false If true the texture will be cleared before the displayObject is drawn
updateTransform
boolean <optional>
true If true the displayObject's worldTransform/worldAlpha and all children
transformations will be restored. Not restoring this information will be a little faster. -
resize(width, height, updateBase)
-
Resizes the RenderTexture.
Parameters:
Name Type Description width
number The width to resize to.
height
number The height to resize to.
updateBase
boolean Should the baseTexture.width and height values be resized as well?
Events
-
update
-
Fired when the texture is updated. This happens if the frame or the baseTexture is updated.
- Inherited From:
- Source: