A Texture object is a multidimensional container of pixel data.
You can create a texture using the GraphicsDevice.createTexture function.
Summary
Set the data by passing in an array of numbers.
Pixel data consists of an array of numbers, one value for each component of every pixel. The number of components per pixel depends on the pixel format.
Create the texture as dynamic if you are planning to update the pixel data at runtime. If the texture has a mipmap chain all the levels will be recalculated.
This function accepts Typed Arrays and will set the data in an optimized way if the size and type of the Typed Array are appropriate for the PixelFormat of the Texture (as described in the WebGL standards).
Changing the pixel data can be an expensive operation.
Syntax
//set the data post-creation for a 2x2 texture of depth 1 and format 'R8G8B8A8'
texture.setData([255, 0, 0, 255,
0, 255, 0, 255,
0, 255, 0, 255,
0, 0, 255, 255]);
When Typed Arrays are available, the following is also valid
texture.setData(new Uint8Array([255, 0, 0, 255,
0, 255, 0, 255,
0, 255, 0, 255,
0, 0, 255, 255]));
To only update a region of the texture
texture.setData(pixelData, face, level, x, y, width, height);
Where face should be zero except for cubemap textures and level refers to the mipmap level to be updated.
Summary
Releases the Texture resources; the object will be invalid after the method is called.
Syntax
texture.destroy();
Summary
The name of the texture object, usually the path to the image file that provided the pixel data.
Syntax
var textureName = texture.name;
Note
Read Only
Summary
The unique identification number of the Texture object.
Syntax
var textureId = texture.id;
Note
Read Only
Summary
Width of the top-level of the texture in pixels.
Syntax
var textureWidth = texture.width;
Note
Read Only
Summary
Height of the top-level of the texture in pixels.
Syntax
var textureHeight = texture.height;
Note
Read Only
Summary
Depth of the top-level of the texture in pixels. It would be 1 for non 3D textures.
Syntax
var textureDepth = texture.depth;
Note
Read Only
Summary
Format used to store the pixel data.
Syntax
var textureFormat = texture.format;
var gd == TurbulenzEngine.getGraphicsDevice();
if (textureFormat === gd.PIXELFORMAT_R8G8B8A8)
{
// ...
}
Note
Read Only
Summary
True if the texture is a cubemap, false otherwise.
Syntax
var isCubemap = texture.cubemap;
Note
Read Only
Summary
True if the texture has a mipmap chain, false otherwise.
Syntax
var hasMipmaps = texture.mipmaps;
Note
Read Only
Summary
True if the texture can be rendered to, false otherwise.
Syntax
var isRenderable = texture.renderable;
Note
Read Only
Summary
True if the texture was created as dynamic and hence can be modified at runtime, false otherwise.
Syntax
var isDynamic = texture.dynamic;
Note
Read Only