# `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. ## Functions ### `clockOf` _function_ ```nupp function clockOf(borrows world: ecs.World): number ``` Returns 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 | ### `encode` _function_ ```nupp 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 | 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` | | ### `frameAt` _function_ ```nupp function frameAt(id: integer, tick: number, loop: boolean): integer ``` Resolves 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 | ### `hasPivot` _function_ ```nupp function hasPivot(id: integer, sheetId: integer, sliceId: integer): boolean ``` Reports 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 | ### `packed` _function_ ```nupp 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 | Type | Description | | --- | --- | | `string` | immutable host-endian float32 bytes, rebuilt only on change | ### `playbackOf` _function_ ```nupp function playbackOf(borrows target: rendercomponents.Sprite): integer ``` Identifies 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 | ### `rebaseClock` _function_ ```nupp 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 | Name | Type | Description | | --- | --- | --- | | `borrows world` | `ecs.World` | the world whose clock may move | #### Returns | Type | Description | | --- | --- | | `number` | the shift, or zero before the limit | ### `register` _function_ ```nupp function register(source: sheet.Sheet, tag: integer, slice: integer?): integer ``` Registers 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 | ### `revision` _function_ ```nupp function revision(): integer ``` Returns the generation of the shared table, including sheet reloads. #### Returns | Type | Description | | --- | --- | | `integer` | a generation suitable for an upload cache | ### `tickCount` _function_ ```nupp function tickCount(id: integer): integer ``` Returns 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_STEPS` _variable_ ```nupp const REBASE_STEPS: integer ``` ### `TICK_HZ` _variable_ ```nupp const TICK_HZ: number ```