Timeline
Timelines implementation for lag compensation techniques in networked games
Timelines implementation for lag compensation techniques in networked games. Use it both on server and/or client-side according to your needs. The project is written primarily in JavaScript, distributed under the MIT License license, first published in 2016. Key topics include: lag-compensation, multiplayer, timelines.
@gamestdio/timeline 
Timelines implementation for lag compensation techniques in networked games.
Use it both on server and/or client-side according to your needs.
- Take snapshots of game state
- Interpolates and extrapolates values based on snapshots taken.
API
createTimeline([ maxSnapshots=10 ])- Create a Timeline instanceTimeline#takeSnapshot( state[, elapsedMs ] )- Record state on timeline historyTimeline#at( elapsedMs[, interpolate=true ] )- GetProxyobject containing interpolated values between recorded states.Timeline#offset( elapsedMs[, interpolate=true ] )- Same as#at, but from the last snapshot taken.
Example
javascriptimport { createTimeline } from '@gamestdio/timeline' var timeline = createTimeline() // first game state snapshot timeline.takeSnapshot({ player: { x: 100 }, enemy: { x: 0 } }) setTimeout(() => { // take second game state snapshot after 1000ms timeline.takeSnapshot({ player: { x: 0 }, enemy: { x: 100 } }) // // Retrieving a previous state // console.log( timeline.at( 0 ).player.x ) // => 100 console.log( timeline.at( 0 ).enemy.x ) // => 0 // // Interpolating data from known states // console.log( timeline.at( 500 ).player.x ) // => 49.75124378109453 console.log( timeline.at( 500 ).enemy.x ) // => 50.24875621890547 // // Extrapolating data between an unknown state // console.log( timeline.at( 1500 ).player.x ) // => -49.25373134328358 console.log( timeline.at( 1500 ).enemy.x ) // => 149.2537313432836 }, 1000)
To execute this example run the following command:
node --harmony --harmony-proxies example/usage.js
References
License
MIT
Contributors
Showing top 3 contributors by commit count.
This article is auto-generated from gamestdio/timeline via the GitHub API.Last fetched: 6/28/2026
