A loadable texture asset. This asset type loads an image from URL or source, and turn it into a texture.
Kind: global class
Promise
Promise
Color
Array.<Array.<Color>>
Kind: instance property of TextureAsset
Kind: instance property of TextureAsset
Kind: instance property of TextureAsset
Kind: instance property of TextureAsset
Kind: instance property of TextureAsset
Promise
Load the texture from it’s image URL.
Kind: instance method of TextureAsset
Returns: Promise
- Promise to resolve when fully loaded.
Param | Type | Description |
---|---|---|
params | \* |
Optional additional params. Possible values are: - generateMipMaps (default=false): if true, will generate mipmaps for this texture. - crossOrigin (default=undefined): if set, will set the crossOrigin property with this value. - flipY (default=false): if true, will flip texture on Y axis. - premultiplyAlpha (default=false): if true, will load texture with premultiply alpha flag set. |
Create this texture as an empty render target.
Kind: instance method of TextureAsset
Param | Type | Description |
---|---|---|
width | Number |
Texture width. |
height | Number |
Texture height. |
channels | Number |
Texture channels count. Defaults to 4 (RGBA). |
Create texture from loaded image instance.
Kind: instance method of TextureAsset
See: TextureAsset.load for params.
Param | Type | Description |
---|---|---|
image | Image |
Image to create texture from. Image must be loaded! |
params | \* |
Optional additional params. See load() for details. |
Promise
Create the texture from an image.
Kind: instance method of TextureAsset
Returns: Promise
- Promise to resolve when asset is ready.
See: TextureAsset.load for params.
Param | Type | Description |
---|---|---|
source | Image | String |
Image or Image source URL to create texture from. |
params | \* |
Optional additional params. See load() for details. |
Color
Get pixel color from image.
Note: this method is quite slow, if you need to perform multiple queries consider using getPixelsData()
once to get all pixels data instead.
Kind: instance method of TextureAsset
Returns: Color
- Pixel color.
Param | Type | Description |
---|---|---|
x | Number |
Pixel X value. |
y | Number |
Pixel Y value. |
Array.<Array.<Color>>
Get a 2D array with pixel colors.
Kind: instance method of TextureAsset
Returns: Array.<Array.<Color>>
- A 2D array with all texture pixel colors.
Param | Type | Description |
---|---|---|
[x] | Number |
Offset X in texture to get. Defaults to 0. |
[y] | Number |
Offset Y in texture to get. Defaults to 0. |
[width] | Number |
How many pixels to get on X axis. Defaults to texture width - x. |
[height] | Number |
How many pixels to get on Y axis. Defaults to texture height - y. |
Kind: instance method of TextureAsset