tecs.gfx.frametable

Shared sprite animation tables. A playback names a sheet, tag and slice; every entity playing it shares one millisecond lookup table. Instances carry a start step and rate, so changing frames performs no CPU work and uploads no instances. The clock re-anchors every 524288 fixed steps to preserve millisecond precision.

Module contents

Functions

FunctionKindDescription
clockOffunctionReturns fixed steps since this world's animation clock origin.
encodefunctionWrites a playback's start/rate into a sprite, replacing its static UVs.
frameAtfunctionResolves the same frame the GPU selects.
hasPivotfunctionReports whether GPU playback already applies the supplied slice pivot.
packedfunctionReturns the GPU buffer: count, four-float directory entries, millisecond lookup offsets and eight-float frame...
playbackOffunctionIdentifies the playback encoded in a sprite.
rebaseClockfunctionRe-anchors a clock that reached the precision limit.
registerfunctionRegisters a shared sheet/tag/slice playback, or returns its existing id.
revisionfunctionReturns the generation of the shared table, including sheet reloads.
tickCountfunctionReturns the number of authored millisecond ticks in a playback.

Values

ValueKindDescription
REBASE_STEPSvariable
TICK_HZvariable

Functions#

clockOffunction#

function clockOf(borrows world: ecs.World): number

Returns fixed steps since this world's animation clock origin.

Arguments

NameTypeDescription
borrows worldecs.World

the world whose sprites are playing

Returns

TypeDescription
number

the clock shared by the CPU queries and GPU lookup

encodefunction#

function encode(exclusive target: rendercomponents.Sprite, id: integer, start: number, rate: number, loop: boolean): nil

Writes a playback's start/rate into a sprite, replacing its static UVs.

Arguments

NameTypeDescription
exclusive targetrendercomponents.Sprite

the mutable sprite

idinteger

a registered playback

startnumber

the start step, or the held tick when rate is zero

ratenumber

milliseconds advanced per fixed step

loopboolean

whether to wrap at the end

Returns

TypeDescription
nil

frameAtfunction#

function frameAt(id: integer, tick: number, loop: boolean): integer

Resolves the same frame the GPU selects.

Arguments

NameTypeDescription
idinteger

a playback id

ticknumber

the elapsed milliseconds

loopboolean

whether the cycle repeats

Returns

TypeDescription
integer

a one-based sheet frame, or zero for an unknown playback

hasPivotfunction#

function hasPivot(id: integer, sheetId: integer, sliceId: integer): boolean

Reports whether GPU playback already applies the supplied slice pivot.

Arguments

NameTypeDescription
idinteger

shared playback identifier

sheetIdinteger

owning sheet

sliceIdinteger

animated slice

Returns

TypeDescription
boolean

true when this playback resolves that anchor

packedfunction#

function packed(): string

Returns the GPU buffer: count, four-float directory entries, millisecond lookup offsets and eight-float frame entries (UV, image, pivot, padding).

Returns

TypeDescription
string

immutable host-endian float32 bytes, rebuilt only on change

playbackOffunction#

function playbackOf(borrows target: rendercomponents.Sprite): integer

Identifies the playback encoded in a sprite.

Arguments

NameTypeDescription
borrows targetrendercomponents.Sprite

a sprite component

Returns

TypeDescription
integer

a playback id, or zero for an ordinary UV region

rebaseClockfunction#

function rebaseClock(borrows world: ecs.World): number

Re-anchors a clock that reached the precision limit. The animation plugin rewrites running starts in the same step.

Arguments

NameTypeDescription
borrows worldecs.World

the world whose clock may move

Returns

TypeDescription
number

the shift, or zero before the limit

registerfunction#

function register(source: sheet.Sheet, tag: integer, slice: integer?): integer

Registers a shared sheet/tag/slice playback, or returns its existing id.

Arguments

NameTypeDescription
sourcesheet.Sheet

the authored sheet

taginteger

its tag id, or zero for the whole sheet

sliceinteger?

its slice id, or nil for the center pivot

Returns

TypeDescription
integer

a stable process-local playback id

revisionfunction#

function revision(): integer

Returns the generation of the shared table, including sheet reloads.

Returns

TypeDescription
integer

a generation suitable for an upload cache

tickCountfunction#

function tickCount(id: integer): integer

Returns the number of authored millisecond ticks in a playback.

Arguments

NameTypeDescription
idinteger

a playback id

Returns

TypeDescription
integer

its cycle length, or zero for an unknown id

Values#

REBASE_STEPSvariable#

const REBASE_STEPS: integer

TICK_HZvariable#

const TICK_HZ: number