Class: TextureAtlas

og.utils.TextureAtlas

new og.utils.TextureAtlas(width, height)

Texture atlas stores images in one texture. Each image has texture coordinates returned with node creation by addImage function.
Name Type Description
width number optional Texture atlas width, if it hasn't 1024 default.
height number optional Texture atlas height, if it hasn't 1024 default..

Members

static,constantog.utils.TextureAtlas.BORDER_SIZEnumber

Border beetween stored images.

canvascanvas

Atlas canvas.
Atlas nodes where input images store. It can be access by image.__nodeIndex.

texture

Created gl texture.

Methods

staticog.utils.TextureAtlas.getDiagonal(image){number}

Returns image diagonal size.
Name Type Description
image Object JavaSript image object.
Returns:
Type Description
number
Adds image to the atlas and returns creted node with texture coordinates of the stored image.
Name Type Description
image Object Input javascript image object.
fastInsert boolean optional If it's true atlas doesnt restore all images again and store image in the curent atlas sheme.
Returns:
Type Description
og.utils.TextureAtlasNode

assignHandler(handler)

Sets openglobus gl handler that creates gl texture.
Name Type Description
handler og.webgl.Handler WebGL handler.
Clear atlas with black.
Creates atlas gl texture.
Returns canvas object.
Returns atlas javascript image object.
Returns:
Type Description
Object

loadImage(src, success)

Asynchronous function that loads and creates image to the image cache, and call success callback when it's done.
Name Type Description
src string Image object src string.
success Object~successCallback The callback that handles the image loads done.