Menu - Top - Home - Donate to Me

H3DU.TextureAtlas

Back to documentation index.

H3DU.TextureAtlas()

A texture atlas specifies the location and size of images within a single texture. It is useful when multiple different images should be drawn at once without having to load multiple textures or doing multiple texture binds. Instead, those images can be packed into one texture and the application can draw different portions of that texture at once. The texture atlas can specify where those portions are found.

This implementation supports the ".atlas" format.

NOTE: The constructor should not be called directly by applications. Use the H3DU.TextureAtlas.load method to get an H3DU.TextureAtlas object.

This class is considered a supplementary class to the Public Domain HTML 3D Library and is not considered part of that library.

To use this class, you must include the script "extras/text.js"; the class is not included in the "h3du_min.js" file which makes up the HTML 3D Library. Example:

<script type="text/javascript" src="extras/text.js"></script>

Methods

(static) H3DU.TextureAtlas.load(atlasFileName)

Loads a texture atlas definition from a file. Note that this method only loads the texture atlas data and not the bitmaps used by the texture atlas.

Parameters

Return Value

A promise that is resolved when the texture atlas data is loaded successfully (the result will be an H3DU.TextureAtlas object), and is rejected when an error occurs. (Type: Promise.<H3DU.TextureAtlas>)

H3DU.TextureAtlas#loadTextures(textureLoader)

Loads the texture files used by this texture atlas.

Parameters

Return Value

A promise as described in H3DU.getPromiseResultsAll. If the promise resolves, each item in the resulting array will be a loaded H3DU.Texture object. (Type: Promise.<Array.<H3DU.Texture>>)

(static) H3DU.TextureAtlas.loadWithTextures(atlasFileName, textureLoader)

Loads a texture atlas definition from a file along with the textures it uses.

Parameters

Return Value

A promise that is resolved when the texture atlas data and textures are loaded successfully, and is rejected when an error occurs. If the promise is resolved, the result will be an object with the following keys:

(Type: Promise)

H3DU.TextureAtlas#makeSprites(sprites)

Makes a shape group used to display one or more sprites. For the sprites to show upright, the coordinate system should have the X axis pointing right and the Y axis pointing down (for example, an orthographic projection where the left and top coordinates are less than the right and bottom coordinates, respectively). The size of each sprite will be in pixels; therefore, for best results, the coordinate system should be scaled so that one unit equals one pixel.

Parameters

Return Value

The generated group of shapes. (Type: H3DU.ShapeGroup)

Back to documentation index.