five-on-it / packages/net-client/src/predicted-pieces / PredictedPieces
Class: PredictedPieces
Defined in: packages/net-client/src/predicted-pieces.ts:64
The light pieces drawn at the local time (see the module documentation).
Constructors
Constructor
new PredictedPieces(
mirror):PredictedPieces
Defined in: packages/net-client/src/predicted-pieces.ts:73
Parameters
mirror
Returns
PredictedPieces
Properties
mirror
readonlymirror:Mirror
Defined in: packages/net-client/src/predicted-pieces.ts:66
The mirror whose local world's pieces are drawn.
Methods
afterSnapshots()
afterSnapshots(
smooth?):void
Defined in: packages/net-client/src/predicted-pieces.ts:172
After them: how far each piece drawn here moved with the server's word, kept as a decaying offset so the drawing does not jump, as a near car's is (smooth false drops it, as the N key does for the player's car).
Parameters
smooth?
boolean = true
Returns
void
beforeSnapshots()
beforeSnapshots():
void
Defined in: packages/net-client/src/predicted-pieces.ts:158
Before a frame's snapshots are applied: where each piece drawn here stands.
Returns
void
correcting()
correcting(
placement):number
Defined in: packages/net-client/src/predicted-pieces.ts:104
How far a piece's drawing still stands off its local pose (m): the correction offset left to decay.
Parameters
placement
number
Returns
number
local()
local():
number[]
Defined in: packages/net-client/src/predicted-pieces.ts:99
The placements on the local timeline now (their target), for whatever follows a piece that is down (a lamp's light).
Returns
number[]
placements()
placements():
IterableIterator<number>
Defined in: packages/net-client/src/predicted-pieces.ts:94
The placements drawn at the local time, wholly or in part.
Returns
IterableIterator<number>
pose()
pose(
placement,drawn,alpha):PiecePose|undefined
Defined in: packages/net-client/src/predicted-pieces.ts:190
Where to draw a placement's piece: where the local world has it, alpha of the way from the last tick to the next (taken back along its velocity and its spin to the moment the player's car is drawn at), plus its offset, blended with drawn (its snapshots' sample, when the snapshots list it loose) by its weight; the blend's rate is set from the gap between the two (blendSeconds). Undefined for a piece not drawn here.
Parameters
placement
number
drawn
RemoteSample | undefined
alpha
number
Returns
PiecePose | undefined
update()
update(
dt):void
Defined in: packages/net-client/src/predicted-pieces.ts:115
Advances every piece's blend by dt seconds: decides which loose pieces are on the local timeline from where the local world has them and the controlled entity (see the module documentation), moves each weight toward its target at its rate, decays the offsets, and forgets the pieces that have left.
Parameters
dt
number
Returns
void
weight()
weight(
placement):number
Defined in: packages/net-client/src/predicted-pieces.ts:89
How far a placement's piece is drawn toward where the local world has it, 0..1.
Parameters
placement
number
Returns
number