Skip to content

five-on-it / packages/net-client/src/clock / ClientClock

Class: ClientClock ​

Defined in: packages/net-client/src/clock.ts:145

Tracks the estimated server tick and the render tick for remote entities (see the module documentation).

Constructors ​

Constructor ​

new ClientClock(): ClientClock

Returns ​

ClientClock

Accessors ​

ready ​

Get Signature ​

get ready(): boolean

Defined in: packages/net-client/src/clock.ts:248

True once at least one snapshot has arrived.

Returns ​

boolean


renderTick ​

Get Signature ​

get renderTick(): number

Defined in: packages/net-client/src/clock.ts:267

The tick remote entities should be shown at: INTERP_DELAY_TICKS behind the estimate, at real time's pace, never clamped to the newest snapshot (a silence is the buffers' to extrapolate through and hold).

Returns ​

number


serverTick ​

Get Signature ​

get serverTick(): number

Defined in: packages/net-client/src/clock.ts:258

Best estimate of the server's current tick: the local time plus the filtered offset (a slack under the earliest arrival's, see the module documentation).

Returns ​

number


silence ​

Get Signature ​

get silence(): number

Defined in: packages/net-client/src/clock.ts:253

Real ticks since the newest snapshot arrived: how long the server has been silent.

Returns ​

number


tickScale ​

Get Signature ​

get tickScale(): number

Defined in: packages/net-client/src/clock.ts:275

Multiplier for the local tick interval: shorter than 1 when the server is about to starve (send inputs faster), longer when the server queue is growing.

Returns ​

number

Methods ​

advance() ​

advance(ticks): void

Defined in: packages/net-client/src/clock.ts:197

Advances the clock by ticks of real time (a frame's elapsed time over the tick's length, fractional), before the frame's snapshots are handed to it. An estimate above the top comes down at RENDER_DRIFT per tick at most, one under the band rises at CLOCK_SLEW; one inside the band holds; one that has lain more than RENDER_SNAP_TICKS outside it for a whole CLOCK_WINDOW_TICKS is put back into it at once.

Parameters ​

ticks ​

number

Returns ​

void


onSnapshot() ​

onSnapshot(serverTick, inputBuffer): void

Defined in: packages/net-client/src/clock.ts:171

Called with every snapshot (and the welcome), after the frame it arrived in has advanced the clock: an observation of the server's offset, which can only raise the top if it is the earliest arrival of the window. A snapshot older than the newest is ignored. The render tick never moves here, except for a discontinuity in the clock's first window (see the module documentation).

Parameters ​

serverTick ​

number

inputBuffer ​

number

Returns ​

void