new Texture
Create a new Texture object that wraps a WebGL texture.
Methods
-
copyFrom
-
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 getWidth().
-
DeveloperError : yOffset + source.height must be less than or equal to getHeight().
-
DeveloperError : This texture was destroyed, i.e., destroy() was called.
Example
texture.copyFrom({ width : 1, height : 1, arrayBufferView : new Uint8Array([255, 0, 0, 255]) });
-
-
copyFromFramebuffer
-
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>
getWidth() optional height
Number <optional>
getHeight() 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 getWidth().
-
DeveloperError : yOffset + height must be less than or equal to getHeight().
-
-
destroy
-
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 thanisDestroyed
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();
-
generateMipmap
-
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.
-
-
getDimensions
-
Gets the dimensions of this texture as a {Cartesian2}.
Throws:
DeveloperError : This texture was destroyed, i.e., destroy() was called.Returns:
Cartesian2 The dimensions of this texture. -
getFlipY
-
Returns true if the source pixels are flipped vertically when the texture is created or updated, i.e.,
UNPACK_FLIP_Y_WEBGL
is used.Throws:
DeveloperError : This texture was destroyed, i.e., destroy() was called.Returns:
Boolean True if the source pixels are flipped vertically; otherwise, false. -
getHeight
-
Gets the height of this texture.
Throws:
DeveloperError : This texture was destroyed, i.e., destroy() was called. -
getPixelDatatype
-
DOC_TBA
Throws:
DeveloperError : This texture was destroyed, i.e., destroy() was called. -
getPixelFormat
-
DOC_TBA
Throws:
DeveloperError : This texture was destroyed, i.e., destroy() was called. -
getPreMultiplyAlpha
-
DOC_TBA
Throws:
DeveloperError : This texture was destroyed, i.e., destroy() was called. -
getSampler
-
Gets the sampler to use when sampling this texture.
Throws:
DeveloperError : This texture was destroyed, i.e., destroy() was called. -
getWidth
-
Gets the width of this texture.
Throws:
DeveloperError : This texture was destroyed, i.e., destroy() was called. -
isDestroyed
-
Returns true if this object was destroyed; otherwise, false.
If this object was destroyed, it should not be used; calling any function other thanisDestroyed
will result in a DeveloperError exception.Returns:
Boolean True if this object was destroyed; otherwise, false.See:
-
setSampler
-
Sets the sampler to use when sampling this texture.
Parameters:
Name Type Argument Description sampler
<optional>
The sampler to use. 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. Throws:
DeveloperError : This texture was destroyed, i.e., destroy() was called.