Skip to content

Documentation / device / TextureAtlasManager

Class: TextureAtlasManager

Defined in: libs/device/src/helpers/textureatlas.ts:25

Texture atlas manager

Extended by

Constructors

Constructor

new TextureAtlasManager(device, binWidth, binHeight, rectBorderWidth, linearSpace?): TextureAtlasManager

Defined in: libs/device/src/helpers/textureatlas.ts:56

Creates a new texture atlas manager instance

Parameters

device

AbstractDevice

The render device

binWidth

number

Width of an atlas bin

binHeight

number

Height of an atlas bin

rectBorderWidth

number

Border width of an atlas

linearSpace?

boolean

true if the texture space is linear

Returns

TextureAtlasManager

Accessors

atlasTextureRestoreHandler

Get Signature

get atlasTextureRestoreHandler(): (tex) => void

Defined in: libs/device/src/helpers/textureatlas.ts:77

The texture restore handler callback function This callback function will be called whenever the device has been restored

Returns

(tex) => void

Set Signature

set atlasTextureRestoreHandler(f): void

Defined in: libs/device/src/helpers/textureatlas.ts:80

Parameters
f

(tex) => void

Returns

void


binWidth

Get Signature

get binWidth(): number

Defined in: libs/device/src/helpers/textureatlas.ts:94

Width of each atlas bin in texels.

Returns

number


binHeight

Get Signature

get binHeight(): number

Defined in: libs/device/src/helpers/textureatlas.ts:100

Height of each atlas bin in texels.

Returns

number


rectBorderWidth

Get Signature

get rectBorderWidth(): number

Defined in: libs/device/src/helpers/textureatlas.ts:106

Border reserved around each packed rectangle in texels.

Returns

number

Methods

getAtlasTexture()

getAtlasTexture(index): Texture2D<unknown>

Defined in: libs/device/src/helpers/textureatlas.ts:88

Gets the atlas texture of a given index

Parameters

index

number

Index of the atlas bin

Returns

Texture2D<unknown>

Atlas texture for given index


getAtlasInfo()

getAtlasInfo(key): AtlasInfo

Defined in: libs/device/src/helpers/textureatlas.ts:114

Gets the information about specified atlas

Parameters

key

string

Key of the atlas

Returns

AtlasInfo

Information of the atlas


isEmpty()

isEmpty(): boolean

Defined in: libs/device/src/helpers/textureatlas.ts:121

Check if no atlas has been created

Returns

boolean

true if no atlas has been created


clear()

clear(): void

Defined in: libs/device/src/helpers/textureatlas.ts:127

Removes all created atlases

Returns

void


pushCanvas()

pushCanvas(key, ctx, x, y, w, h): AtlasInfo

Defined in: libs/device/src/helpers/textureatlas.ts:145

Inserts a rectangle of a canvas to the atlas texture

Parameters

key

string

Key of the atlas

ctx

CanvasRenderingContext2D

The canvas context

x

number

x offset of the rectangle

y

number

y offset of the rectangle

w

number

width of the rectangle

h

number

height of the rectangle

Returns

AtlasInfo

The atals info or null if insert failed


pushBitmap()

pushBitmap(key, bitmap): AtlasInfo

Defined in: libs/device/src/helpers/textureatlas.ts:171

Inserts a bitmap to the atlas texture

Parameters

key

string

Key of the atlas

bitmap

ImageBitmap | ImageData

The bitmap object

Returns

AtlasInfo

The atals info or null if insert failed

Released under the MIT License.