Skip to content

five-on-it / packages/net-client/src/predicted / PredictedRemotes

Class: PredictedRemotes ​

Defined in: packages/net-client/src/predicted.ts:81

The remote vehicles drawn at the local time (see the module documentation).

Constructors ​

Constructor ​

new PredictedRemotes(mirror): PredictedRemotes

Defined in: packages/net-client/src/predicted.ts:90

Parameters ​

mirror ​

Mirror

Returns ​

PredictedRemotes

Properties ​

mirror ​

readonly mirror: Mirror

Defined in: packages/net-client/src/predicted.ts:83

The mirror whose twins are drawn.

Methods ​

afterSnapshots() ​

afterSnapshots(smooth?): void

Defined in: packages/net-client/src/predicted.ts:134

After them: how far each predicted twin moved with the server's word, kept as a decaying offset so the drawing does not jump (smooth false drops it, as the N key does for the player's car).

Parameters ​

smooth? ​

boolean = true

Returns ​

void


apply() ​

apply(eid, out, alpha): RemoteSample

Defined in: packages/net-client/src/predicted.ts:195

Moves out (the interpolated sample of a remote vehicle or trailer) toward where its twin stands at the local time by the vehicle's blend, alpha of the way from the last tick to the next: the player's car is drawn that far between its two last ticks, so the predicted vehicle is taken back along its velocity to the same moment. Measures the gap between the two poses and sets the blend's rate from it (blendSeconds, with the slower of the two speeds: the next frame's step takes it). Unchanged for a vehicle not blended. Returns out.

Parameters ​

eid ​

number

out ​

RemoteSample

alpha ​

number

Returns ​

RemoteSample


beforeSnapshots() ​

beforeSnapshots(): void

Defined in: packages/net-client/src/predicted.ts:120

Before a frame's snapshots are applied: where each predicted twin stands.

Returns ​

void


corrected() ​

corrected(eid): number

Defined in: packages/net-client/src/predicted.ts:112

The size of the correction the snapshots of this frame moved a predicted twin by (m), kept as an offset to decay; 0 on a frame without one. A reading for the probes.

Parameters ​

eid ​

number

Returns ​

number


correcting() ​

correcting(eid): number

Defined in: packages/net-client/src/predicted.ts:103

How far a predicted vehicle's drawing still stands off its twin (m): the correction offset left to decay, 0 when none. A reading for the probes.

Parameters ​

eid ​

number

Returns ​

number


update() ​

update(eids, dt): void

Defined in: packages/net-client/src/predicted.ts:156

Advances every blend by dt seconds toward its target (1 while the mirror predicts the vehicle, 0 otherwise), at the rate its last measured gap allows (apply), and decays the offsets; eids are the remote vehicles and trailers drawn this frame, and blends of the others are forgotten. A remote new to the page that is predicted from its first frame (one spawned, or come into the area of interest, within reach) starts on the predicted timeline: it has no drawn past on the other to blend from.

Parameters ​

eids ​

Iterable<number>

dt ​

number

Returns ​

void


weight() ​

weight(eid): number

Defined in: packages/net-client/src/predicted.ts:95

How far a remote vehicle is drawn toward its predicted pose, 0..1.

Parameters ​

eid ​

number

Returns ​

number