Texture2D

Texture2D

A texture class to represent a 2D texture.

Constructor

new Texture2D(spec)

Instantiates a Texture2D object.
Source:
Parameters:
Name Type Description
spec Object The specification arguments.
Name Type Description
src ArrayBuffer | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement The data to buffer.
width number The width of the texture.
height number The height of the texture.
wrap string The wrapping type over both S and T dimension.
wrapS string The wrapping type over the S dimension.
wrapT string The wrapping type over the T dimension.
filter string The min / mag filter used during scaling.
minFilter string The minification filter used during scaling.
magFilter string The magnification filter used during scaling.
mipMap bool Whether or not mip-mapping is enabled.
invertY bool Whether or not invert-y is enabled.
premultiplyAlpha bool Whether or not alpha premultiplying is enabled.
format string The texture pixel format.
type string The texture pixel component type.

Methods

bind(location) → {Texture2D}

Binds the texture object to the provided texture unit location.
Source:
Parameters:
Name Type Default Description
location number 0 The texture unit location index. Defaults to 0.
Returns:
Type:
Texture2D
The texture object, for chaining.

bufferData(data, width, height) → {Texture2D}

Buffer data into the texture.
Source:
Parameters:
Name Type Description
data Array | ArrayBuffer The data array to buffer.
width number The width of the data.
height number The height of the data.
Returns:
Type:
Texture2D
The texture object, for chaining.

bufferSubData(data, xOffset, yOffset, width, height) → {Texture2D}

Buffer partial data into the texture.
Source:
Parameters:
Name Type Default Description
data Array | ArrayBuffer The data array to buffer.
xOffset number 0 The x offset at which to buffer.
yOffset number 0 The y offset at which to buffer.
width number The width of the data.
height number The height of the data.
Returns:
Type:
Texture2D
The texture object, for chaining.

resize(width, height) → {Texture2D}

Resize the underlying texture. This clears the texture data.
Source:
Parameters:
Name Type Description
width number The new width of the texture.
height number The new height of the texture.
Returns:
Type:
Texture2D
The texture object, for chaining.

setParameters(params) → {Texture2D}

Set the texture parameters.
Source:
Parameters:
Name Type Description
params Object The parameters by name.
Name Type Description
wrap string The wrapping type over both S and T dimension.
wrapS string The wrapping type over the S dimension.
wrapT string The wrapping type over the T dimension.
filter string The min / mag filter used during scaling.
minFilter string The minification filter used during scaling.
magFilter string The magnification filter used during scaling.
Returns:
Type:
Texture2D
The texture object, for chaining.

unbind() → {Texture2D}

Unbinds the texture object.
Source:
Returns:
Type:
Texture2D
The texture object, for chaining.