Skip to content

Snapshots

Types

SnapshotData<T>

FieldTypeDescription
tnumberThe snapshot timestamp
valueTThe stored value

CircularSnapshot<T>

A snapshot buffer with circular indexing and interpolation.

Field / MethodTypeDescription
cache{ SnapshotData<T> }Internal circular buffer
pivotIndexnumber?0‑indexed pivot in the circular array
lerp(a: T, b: T, alpha: number)(T, T, number) -> TLinear interpolation function for type T
Push(t, value)(self, number, T) -> ()Inserts a snapshot at timestamp t
GetLatest()(self) -> SnapshotData<T>?Returns the most recent snapshot
GetAt(t)(self, number) -> T?Returns an interpolated value at time t

Methods

Push(t: number, value: T)

Inserts a snapshot into the buffer.

  • Maintains chronological order
  • Overwrites oldest entries when full

GetLatest() → SnapshotData<T>?

Returns the most recent snapshot, or nil if empty.


GetAt(t: number) → T?

Returns the interpolated value at timestamp t:

  • Interpolates linearly between before and after snapshots
  • Handles wrap-around between 0 and 255 timestamps
  • Returns the closest value if interpolation is not possible

Usage Notes

  • lerp must handle your type T (e.g., CFrame.Lerp, Vector3:Lerp)
  • Used internally by Chrono replication for smooth CFrame interpolation
  • Buffer automatically handles late or out-of-order packets without breaking motion continuity