The Texture this TextureSource belongs to.
The source image data.
Optionalwidth: number
Optional width of the source image. If not given it's derived from the source itself.
Optionalheight: number
Optional height of the source image. If not given it's derived from the source itself.
OptionalflipY: boolean
Sets the UNPACK_FLIP_Y_WEBGL flag the WebGL Texture uses during upload. Default true.
Holds the compressed texture algorithm, or null if it's not a compressed texture.
Prior to Phaser 3.60 this value always held null.
Whether the UNPACK_FLIP_Y_WEBGL flag is set on this WebGL Texture during upload.
When true, the texture data is flipped vertically as it is uploaded to the GPU.
The wrapped WebGL Texture of the source image. If this TextureSource is driven from a WebGLTexture already, then this wrapper contains a reference to that WebGLTexture.
The height of the source image. If not specified in the constructor it will check
the naturalHeight, videoHeight, and then height properties of the source image.
The image data.
This is either an Image element, Canvas element, Video Element,
or null if the source is not an HTMLElement.
Non-HTMLElement sources include compressed textures, data arrays,
and references to other WebGL textures.
Is the source image a Canvas Element?
Is the source image a WebGLTextureWrapper?
Are the source image dimensions a power of two?
Is the source image a Render Texture?
Is the source image a Video Element?
A reference to the Canvas or WebGL Renderer.
The resolution of the source image.
The Scale Mode the image will use when rendering. Either Linear or Nearest.
The source of the image data.
This is either an Image Element, a Canvas Element, a Video Element, a RenderTexture or a WebGLTextureWrapper.
In Phaser 3.60 and above it can also be a Compressed Texture data object.
The Texture this TextureSource instance belongs to.
The width of the source image. If not specified in the constructor it will check
the naturalWidth, videoWidth, and then width properties of the source image.
Destroys this Texture Source and frees associated resources.
In WebGL mode, the underlying WebGL texture is deleted from the GPU via the renderer.
If the source is a canvas, it is returned to the CanvasPool. All internal references
are then set to null.
Creates a WebGL Texture, if required, and sets the Texture filter mode.
A reference to the Phaser Game instance.
Sets the Filter Mode for this Texture.
The mode can be either Linear, the default, or Nearest.
For pixel-art you should use Nearest.
The Filter Mode.
Sets the UNPACK_FLIP_Y_WEBGL flag for the WebGL Texture during texture upload.
Optionalvalue: boolean
Should the WebGL Texture be flipped on the Y axis on texture upload or not? Default true.
Sets the wrap mode for this TextureSource. This is only available for WebGL.
The wrap mode can be one of the following:
Note that only CLAMP_TO_EDGE is supported for non-power of two textures. If another wrap mode is specified for such a texture, it will be ignored.
This TextureSource instance.
Update the underlying WebGLTexture with the current source data. This is called automatically by game systems which manage textures, such as Text or Video, or on internal data changes. You should not need to call this method manually unless you are manually updating the source data.
Updates the dimensions of this Texture Source. This is called automatically by game systems which manage textures, such as Text, which renders to a dedicated canvas that changes size.
The new width of the source image.
The new height of the source image.
Change the source data of this TextureSource. This will update the underlying WebGLTexture with the new source data.
Note that this will not update any consumers of the texture.
Frames and game objects with the Size component
will automatically cache width and height on creation, so you will need
to update them if you change the resolution of the texture this way.
The new source data.
A Texture Source is the encapsulation of the actual source data for a Texture.
It wraps the raw pixel data — typically an Image Element loaded from the file system or network, a Canvas Element, or a Video Element — and manages the corresponding WebGL texture object used by the renderer. In WebGL mode, the TextureSource creates and owns the
WebGLTextureWrapperthat is uploaded to the GPU.You will not usually create a TextureSource directly. Instead, it is created automatically when a Texture is added to the Texture Manager. You can access it via
Texture.source, which is an array of TextureSource instances. Most textures have a single source, but multi-atlas textures can have several.A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded.