new Texture
Create a new Texture object that wraps a WebGL texture.
Members
-
dimensions :Cartesian2
-
The dimensions of this texture as a {Cartesian2}.
-
flipY :Boolean
-
True if the source pixels are flipped vertically when the texture is created or updated, i.e.,
UNPACK_FLIP_Y_WEBGL
is used. -
height :Number
-
The height of this texture.
-
pixelDatatype :PixelDatatype
-
DOC_TBA
-
pixelFormat :PixelFormat
-
DOC_TBA
-
preMultiplyAlpha :Boolean
-
DOC_TBA
-
sampler :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.
-
width :Number
-
The width of this 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 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]) });
-
-
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>
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.
-
-
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.
-
-
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: