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
| Function | Kind | Description |
|---|---|---|
clockOf | function | Returns fixed steps since this world's animation clock origin. |
encode | function | Writes a playback's start/rate into a sprite, replacing its static UVs. |
frameAt | function | Resolves the same frame the GPU selects. |
hasPivot | function | Reports whether GPU playback already applies the supplied slice pivot. |
packed | function | Returns the GPU buffer: count, four-float directory entries, millisecond lookup offsets and eight-float frame... |
playbackOf | function | Identifies the playback encoded in a sprite. |
rebaseClock | function | Re-anchors a clock that reached the precision limit. |
register | function | Registers a shared sheet/tag/slice playback, or returns its existing id. |
revision | function | Returns the generation of the shared table, including sheet reloads. |
tickCount | function | Returns the number of authored millisecond ticks in a playback. |
Values
| Value | Kind | Description |
|---|---|---|
REBASE_STEPS | variable | |
TICK_HZ | variable |
Functions#
clockOffunction#
function clockOf(borrows world: ecs.World): numberReturns fixed steps since this world's animation clock origin.
Arguments
| Name | Type | Description |
|---|---|---|
borrows world | ecs.World | the world whose sprites are playing |
Returns
| Type | Description |
|---|---|
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): nilWrites a playback's start/rate into a sprite, replacing its static UVs.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive target | rendercomponents.Sprite | the mutable sprite |
id | integer | a registered playback |
start | number | the start step, or the held tick when rate is zero |
rate | number | milliseconds advanced per fixed step |
loop | boolean | whether to wrap at the end |
Returns
| Type | Description |
|---|---|
nil |
frameAtfunction#
function frameAt(id: integer, tick: number, loop: boolean): integerResolves the same frame the GPU selects.
Arguments
| Name | Type | Description |
|---|---|---|
id | integer | a playback id |
tick | number | the elapsed milliseconds |
loop | boolean | whether the cycle repeats |
Returns
| Type | Description |
|---|---|
integer | a one-based sheet frame, or zero for an unknown playback |
hasPivotfunction#
function hasPivot(id: integer, sheetId: integer, sliceId: integer): booleanReports whether GPU playback already applies the supplied slice pivot.
Arguments
| Name | Type | Description |
|---|---|---|
id | integer | shared playback identifier |
sheetId | integer | owning sheet |
sliceId | integer | animated slice |
Returns
| Type | Description |
|---|---|
boolean | true when this playback resolves that anchor |
packedfunction#
function packed(): stringReturns the GPU buffer: count, four-float directory entries, millisecond lookup offsets and eight-float frame entries (UV, image, pivot, padding).
Returns
| Type | Description |
|---|---|
string | immutable host-endian float32 bytes, rebuilt only on change |
playbackOffunction#
function playbackOf(borrows target: rendercomponents.Sprite): integerIdentifies the playback encoded in a sprite.
Arguments
| Name | Type | Description |
|---|---|---|
borrows target | rendercomponents.Sprite | a sprite component |
Returns
| Type | Description |
|---|---|
integer | a playback id, or zero for an ordinary UV region |
rebaseClockfunction#
function rebaseClock(borrows world: ecs.World): numberRe-anchors a clock that reached the precision limit. The animation plugin rewrites running starts in the same step.
Arguments
| Name | Type | Description |
|---|---|---|
borrows world | ecs.World | the world whose clock may move |
Returns
| Type | Description |
|---|---|
number | the shift, or zero before the limit |
registerfunction#
function register(source: sheet.Sheet, tag: integer, slice: integer?): integerRegisters a shared sheet/tag/slice playback, or returns its existing id.
Arguments
| Name | Type | Description |
|---|---|---|
source | sheet.Sheet | the authored sheet |
tag | integer | its tag id, or zero for the whole sheet |
slice | integer? | its slice id, or nil for the center pivot |
Returns
| Type | Description |
|---|---|
integer | a stable process-local playback id |
revisionfunction#
function revision(): integerReturns the generation of the shared table, including sheet reloads.
Returns
| Type | Description |
|---|---|
integer | a generation suitable for an upload cache |
tickCountfunction#
function tickCount(id: integer): integerReturns the number of authored millisecond ticks in a playback.
Arguments
| Name | Type | Description |
|---|---|---|
id | integer | a playback id |
Returns
| Type | Description |
|---|---|
integer | its cycle length, or zero for an unknown id |
Values#
REBASE_STEPSvariable#
const REBASE_STEPS: integerTICK_HZvariable#
const TICK_HZ: number