Texture

Texture

new

Create a new Texture object that wraps a WebGL texture.

See:
Source:

Members

:Cartesian2

The dimensions of this texture as a {Cartesian2}.

:Boolean

True if the source pixels are flipped vertically when the texture is created or updated, i.e., UNPACK_FLIP_Y_WEBGL is used.

:Number

The height of this texture.

:PixelDatatype

DOC_TBA

:PixelFormat

DOC_TBA

:Boolean

DOC_TBA

:Object

The sampler to use when sampling this texture. Create a sampler by calling Context#createSampler. If this parameter is not specified, a default sampler is used. The default sampler clamps texture coordinates in both directions, uses linear filtering for both magnification and minifcation, and uses a maximum anisotropy of 1.0.

:Number

The width of this texture.

Methods

Copy new image data into this texture, from a source {ImageData}, {HTMLImageElement}, {HTMLCanvasElement}, {HTMLVideoElement}, or an object with width, height, and arrayBufferView properties.

Parameters:
Name Type Argument Default Description
source Object The source {ImageData}, {HTMLImageElement}, {HTMLCanvasElement}, {HTMLVideoElement}, or an object with width, height, and arrayBufferView properties.
xOffset Number <optional>
0 The offset in the x direction within the texture to copy into.
yOffset Number <optional>
0 The offset in the y direction within the texture to copy into.
Throws:
  • DeveloperError : Cannot call copyFrom when the texture pixel format is DEPTH_COMPONENT or DEPTH_STENCIL.
  • DeveloperError : xOffset must be greater than or equal to zero.
  • DeveloperError : yOffset must be greater than or equal to zero.
  • DeveloperError : xOffset + source.width must be less than or equal to width.
  • DeveloperError : yOffset + source.height must be less than or equal to height.
  • DeveloperError : This texture was destroyed, i.e., destroy() was called.
Example
texture.copyFrom({
  width : 1,
  height : 1,
  arrayBufferView : new Uint8Array([255, 0, 0, 255])
});

DOC_TBA

Parameters:
Name Type Argument Default Description
xOffset Number <optional>
0 The offset in the x direction within the texture to copy into.
yOffset Number <optional>
0 The offset in the y direction within the texture to copy into.
framebufferXOffset Number <optional>
0 optional
framebufferYOffset Number <optional>
0 optional
width Number <optional>
width optional
height Number <optional>
height optional
Throws:
  • DeveloperError : Cannot call copyFromFramebuffer when the texture pixel format is DEPTH_COMPONENT or DEPTH_STENCIL.
  • DeveloperError : Cannot call copyFromFramebuffer when the texture pixel data type is FLOAT.
  • DeveloperError : This texture was destroyed, i.e., destroy() was called.
  • DeveloperError : xOffset must be greater than or equal to zero.
  • DeveloperError : yOffset must be greater than or equal to zero.
  • DeveloperError : framebufferXOffset must be greater than or equal to zero.
  • DeveloperError : framebufferYOffset must be greater than or equal to zero.
  • DeveloperError : xOffset + width must be less than or equal to width.
  • DeveloperError : yOffset + height must be less than or equal to height.

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.

Once an object is destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.

Throws:
DeveloperError : This texture was destroyed, i.e., destroy() was called.
Returns:
Example
texture = texture && texture.destroy();
See:

DOC_TBA

Parameters:
Name Type Argument Default Description
hint MipmapHint <optional>
MipmapHint.DONT_CARE optional.
Throws:
  • DeveloperError : Cannot call generateMipmap when the texture pixel format is DEPTH_COMPONENT or DEPTH_STENCIL.
  • DeveloperError : hint is invalid.
  • DeveloperError : This texture's width must be a power of two to call generateMipmap().
  • DeveloperError : This texture's height must be a power of two to call generateMipmap().
  • DeveloperError : This texture was destroyed, i.e., destroy() was called.

Returns true if this object was destroyed; otherwise, false.

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.

Returns:
Boolean True if this object was destroyed; otherwise, false.
See: