TextureAtlas

Source: TextureAtlas.ts:17

Texture atlas stores images in one texture. Each image has its own atlas texture coordinates.


Constructor

new TextureAtlas( width?: number, height?: number, colorSpace?: string | number, ): TextureAtlas

Parameters

  • width (number, optional, default: 1024) — Texture atlas width, if it hasn't 1024 default.
  • height (number, optional, default: 1024) — Texture atlas height, if it hasn't 1024 default.
  • colorSpace (string | number, optional, default: "\"linear\"") — Texture atlas color space. Available values: "linear", "srgb", 0, 1.

Instance Methods

getImage(): HTMLImageElement

Returns atlas javascript image object.

Returns

  • HTMLImageElement

getCanvas(): HTMLCanvasElement

Returns canvas object.

Returns

  • HTMLCanvasElement

clearCanvas()

Clear atlas with black.

assignHandler(handler: Handler)

Sets openglobus gl handler that creates gl texture.

Parameters

  • handler (Handler) — WebGL handler.

getDiagonal(image: HTMLImageElementExt): number

Returns image diagonal size.

Parameters

  • image (HTMLImageElementExt) — Image object.

Returns

  • number

addImage( image: HTMLImageElementExt, fastInsert?: boolean, ): TextureAtlasNode | undefined

Adds image to the atlas and returns created node with texture coordinates of the stored image.

Parameters

  • image (HTMLImageElementExt) — Input javascript image object.
  • fastInsert (boolean, optional, default: false) — If it's true atlas doesn't restore all images again and store image in the current atlas scheme.

Returns

  • TextureAtlasNode | undefined

_makeAtlas(fastInsert?: boolean)

Main atlas making function.

Parameters

  • fastInsert (boolean, optional, default: false) — If it's true atlas doesn't restore all images again and store image in the current atlas scheme.

createTexture()

Creates atlas gl texture.

loadImage(src: string, success: ImagesCacheManagerCallback)

Asynchronous function that loads and creates image to the image cache, and call success callback when it's done.

Parameters

  • src (string) — Image object src string.
  • success (ImagesCacheManagerCallback) — The callback that handles the image loads done.