Skip to content

@orillusion/core


Class: TextureAtlas ​

Defined in: src/assets/TextureAtlas.ts:16

Texture atlas — a base texture plus a dictionary of named Sprite assets. Returned by Engine3D.resFor(ctx).loadAtlas(url).

Each region parsed from the atlas JSON becomes a Sprite that shares the atlas's texture and carries its own UV region / pivot. Pair with SpriteRenderer.sprite = atlas.get('name') to render.

Constructors ​

Constructor ​

new TextureAtlas(texture): TextureAtlas

Defined in: src/assets/TextureAtlas.ts:24

Parameters ​

texture ​

Texture

Returns ​

TextureAtlas

Properties ​

texture ​

texture: Texture

Defined in: src/assets/TextureAtlas.ts:18

The shared base texture that all sprites in this atlas reference.


sprites ​

readonly sprites: Map<string, Sprite>

Defined in: src/assets/TextureAtlas.ts:20

Named sprites parsed from the atlas, keyed by region id.


name ​

name: string = ''

Defined in: src/assets/TextureAtlas.ts:22

Optional atlas name.

Methods ​

get() ​

get(id): Sprite

Defined in: src/assets/TextureAtlas.ts:30

Look up a named sprite. Returns undefined if the atlas has no such region.

Parameters ​

id ​

string

Returns ​

Sprite


add() ​

add(id, region): Sprite

Defined in: src/assets/TextureAtlas.ts:35

Register a sprite. region is normalized UV.

Parameters ​

id ​

string

region ​

Vector4

Returns ​

Sprite


addPixelRect() ​

addPixelRect(id, pixelRect, atlasWidth, atlasHeight): Sprite

Defined in: src/assets/TextureAtlas.ts:46

Register a sprite from a pixel-space rect in the source texture.

Parameters ​

id ​

string

pixelRect ​
x ​

number

y ​

number

w ​

number

h ​

number

atlasWidth ​

number

atlasHeight ​

number

Returns ​

Sprite