clock-manager
TypeScript icon, indicating that this package has built-in type declarations

0.0.0 • Public • Published

clock-manager

Latest NPM release MIT License

demos

Usage

$ npm install --save clock-manager

1. make an instance and start it

const clock = new ClockManager();
clock.start();

2. update in your requestAnimationFrames

You can get deltaTime and elapsedTime then.

( anim() {
 
    requestAnimationFrame( anim );
    clock.update();
    const delta = clock.deltaTime;
    const elapsed = clock.elapsedTime;
    updateSOmething( delta );
    renderSomething();
 
} )();

even in a separate place

function renderSomething() {
 
    const updatedDelta = clock.deltaTime;
 
}

other features

  • clock.start() : start / restart.
  • clock.stop() : stop the clock.
  • clock.elapsedTime( number ) : time travel like, rewind and forward.
  • clock.update() : update clock for the delta frame. this is usually executed in the beginning of requestAnimationFrame.

and getters:

  • clock.deltaTime
  • clock.elapsedTime

Package Sidebar

Install

npm i clock-manager

Weekly Downloads

0

Version

0.0.0

License

MIT

Unpacked Size

14.4 kB

Total Files

19

Last publish

Collaborators

  • yomotsu