new TextureAtlas(options)
A TextureAtlas stores multiple images in one square texture and keeps
track of the texture coordinates for each image. TextureAtlas is dynamic,
meaning new images can be added at any point in time.
Calling addImages is more space-efficient than calling addImage multiple times.
Texture coordinates are subject to change if the texture atlas resizes, so it is
important to check
TextureAtlas#getGUID
before using old values.
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Object with the following properties:
|
Throws:
-
DeveloperError : borderWidthInPixels must be greater than or equal to zero.
-
DeveloperError : initialSize must be greater than zero.
Source:
Scene/TextureAtlas.js, line 57
Members
-
borderWidthInPixels :Number
-
The amount of spacing between adjacent images in pixels.Source: Scene/TextureAtlas.js, line 107
-
guid :String
-
The atlas' globally unique identifier (GUID). The GUID changes whenever the texture atlas is modified. Classes that use a texture atlas should check if the GUID has changed before processing the atlas data.Source: Scene/TextureAtlas.js, line 159
-
numberOfImages :Number
-
The number of images in the texture atlas. This value increases every time addImage or addImages is called. Texture coordinates are subject to change if the texture atlas resizes, so it is important to check
TextureAtlas#getGUID
before using old values.Source: Scene/TextureAtlas.js, line 145 -
texture :Texture
-
The texture that all of the images are being written to.Source: Scene/TextureAtlas.js, line 131
-
textureCoordinates :Array.<BoundingRectangle>
-
An array of
BoundingRectangle
texture coordinate regions for all the images in the texture atlas. The x and y values of the rectangle correspond to the bottom-left corner of the texture coordinate. The coordinates are in the order that the corresponding images were added to the atlas.Source: Scene/TextureAtlas.js, line 120
Methods
-
addImage(image) → Number
-
Adds an image to the texture atlas. Calling addImages is more space-efficient than calling addImage multiple times. Texture coordinates are subject to change if the texture atlas resizes, so it is important to check
TextureAtlas#getGUID
before using old values.Name Type Description image
Image An image to be added to the texture atlas. Returns:
The index of the newly added image.See:
Source: Scene/TextureAtlas.js, line 327 -
addImages(images) → Number
-
Adds an array of images to the texture atlas. Calling addImages is more space-efficient than calling addImage multiple times. Texture coordinates are subject to change if the texture atlas resizes, so it is important to check
TextureAtlas#getGUID
before using old values.Name Type Description images
Array.<Image> An array of Image
to be added to the texture atlas.Returns:
The first index of the newly added images.See:
Source: Scene/TextureAtlas.js, line 347 -
addSubRegions(image, subRegions) → Number
-
Add a set of sub-regions to one atlas image as additional image indices.
Name Type Description image
Image An image to be added to the texture atlas. subRegions
Array.<BoundingRectangle> An array of BoundingRectangle
sub-regions measured in pixels from the bottom-left.Returns:
The index of the first newly-added region.Source: Scene/TextureAtlas.js, line 391 -
destroy() → undefined
-
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 aDeveloperError
exception. Therefore, assign the return value (undefined
) to the object as done in the example.Returns:
Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
atlas = atlas && atlas.destroy();
See:
Source: Scene/TextureAtlas.js, line 446 -
-
isDestroyed() → Boolean
-
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 aDeveloperError
exception.Returns:
True if this object was destroyed; otherwise, false.See:
Source: Scene/TextureAtlas.js, line 425