Documentation - v19.9.0-dev
    Preparing search index...

    Handle an atlas texture: a texture containing multiple sub-textures. Each sub-texture ID encodes its (row, col) position:

    id = (row << 16) | col row = (id >> 16) & 0xFFFF col = id & 0xFFFF

    This keeps IDs stable even if the atlas size changes.

    Index

    Constructors

    Properties

    altasSlotSize: number
    dataTexture: DataTexture
    signals: { onGrow: Signal<() => void> } = ...
    slotsHashImageUrl: Map<string, string> = ...

    Associate hash with dataUrl

    slotsHashSlotId: Map<string, number> = ...

    Texture atlas indexing using slot coordinates. ID encodes (row, col) as: id = (row << 16) | col Decode with: row = (id >> 16) & 0xFFFF col = id & 0xFFFF

    Unlike linear indexing, this is stable even if the atlas size changes. each slotId is store with a hash

    slotUseCounts: Map<string, number> = ...

    store the number of time a texture is used

    Accessors

    • get getAtlasSlotCount(): number

      Returns number

    • get hasFreeSlot(): boolean

      Returns boolean

    • get maxTextures(): number

      Returns number

    Methods

    • Add a texture in the atlas

      Parameters

      • hash: string

        the imageUrl as hash

      • imageUrl: string

        the dataUrl

      Returns { drawPromise: Promise<void>; slotId: number }

    • Completely clears the atlas:

      • wipes GPU texture
      • removes all slot mappings
      • resets usage counters

      Returns Promise<void>

    • Parameters

      • ctx: CanvasRenderingContext2D | null
      • cellX: number
      • cellY: number

      Returns void

    • Parameters

      • canvasSize: number

      Returns HTMLCanvasElement

    • Parameters

      • id: number

      Returns { col: number; row: number }

    • Parameters

      • slotId: number
      • imageUrl: string

      Returns Promise<void>

    • Parameters

      • ctx: CanvasRenderingContext2D | null
      • img: HTMLImageElement
      • cellX: number
      • cellY: number
      • zoneHeight: number

      Returns void

    • Parameters

      • row: number
      • col: number

      Returns number

    • Free one instance texture

      Parameters

      • hash: string

      Returns void

    • Free one instance texture using the slotId instead of the hash

      Parameters

      • slotId: number

      Returns void

    • Free a slotId if the texture is deleted

      Parameters

      • hash: string

      Returns void

    • Parameters

      • hash: string

      Returns number | undefined

    • Parameters

      • imageUrl: string

      Returns Promise<HTMLImageElement>

    • Lock a slot for a texture and return the locked slotId if the texture is already stored, return the slotId already used, overwise return the new slotId

      Parameters

      • hash: string

        imageUrl as hash

      Returns number