new TextureAtlas()
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 | Default | Description |
---|---|---|---|
options.scene |
Scene | The scene in which the texture gets created. | |
options.pixelFormat |
PixelFormat |
PixelFormat.RGBA
|
optional The pixel format of the texture. |
options.borderWidthInPixels |
Number |
1
|
optional The amount of spacing between adjacent images in pixels. |
options.initialSize |
Cartesian2 |
new Cartesian2(16.0, 16.0)
|
optional The initial side lengths of the texture. |
options.images |
Image[] |
optional
Optional array of Image to be added to the atlas. Same as calling addImages(images) . |
|
options.image |
Image |
optional
Optional single image to be added to the atlas. Same as calling addImage(image) . |
Throws:
-
DeveloperError : borderWidthInPixels must be greater than or equal to zero.
-
DeveloperError : initialSize must be greater than zero.
Source:
Scene/TextureAtlas.js, line 56
Members
-
borderWidthInPixels :Number
-
The amount of spacing between adjacent images in pixels.Source: Scene/TextureAtlas.js, line 106
-
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 158
-
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 144 -
texture :Texture
-
The texture that all of the images are being written to.Source: Scene/TextureAtlas.js, line 130
-
textureCoordinates :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 119
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 329 -
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
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 352 -
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
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 399 -
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 458 -
-
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 435