even more
This commit is contained in:
parent
82e092ba55
commit
8f50ebdb97
1 changed files with 1842 additions and 3095 deletions
|
|
@ -6,35 +6,24 @@ const maxRateAdjustment = 0.25;
|
|||
|
||||
const resyncSeconds = 0.3;
|
||||
|
||||
/**
|
||||
* Playback clock for streamed server state — renders interpolationDelaySeconds
|
||||
* behind the server clock so a newer snapshot is usually available; the cursor
|
||||
* adjusts its rate gently and only snaps after a long divergence.
|
||||
*/
|
||||
class ServerTimeline {
|
||||
private cursor?: number;
|
||||
private newestSnapshotTime?: number;
|
||||
private sinceNewestSnapshot = 0;
|
||||
private _snapshotTime = 0;
|
||||
|
||||
public get snapshotTime(): number {
|
||||
return this._snapshotTime;
|
||||
}
|
||||
public snapshotTime = 0;
|
||||
|
||||
public get renderTime(): number {
|
||||
return this.cursor ?? 0;
|
||||
}
|
||||
|
||||
public onSnapshot(timestamp: number) {
|
||||
this._snapshotTime = timestamp;
|
||||
this.snapshotTime = timestamp;
|
||||
if (this.newestSnapshotTime === undefined || timestamp > this.newestSnapshotTime) {
|
||||
this.newestSnapshotTime = timestamp;
|
||||
this.sinceNewestSnapshot = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Must be called with unscaled wall-clock time, even during the end-game
|
||||
// slow motion: the slowdown is already baked into the snapshots.
|
||||
public step(deltaTimeInSeconds: number) {
|
||||
if (this.newestSnapshotTime === undefined) {
|
||||
return;
|
||||
|
|
@ -63,7 +52,7 @@ class ServerTimeline {
|
|||
this.cursor = undefined;
|
||||
this.newestSnapshotTime = undefined;
|
||||
this.sinceNewestSnapshot = 0;
|
||||
this._snapshotTime = 0;
|
||||
this.snapshotTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue