0.0.0 • Published 7 years ago
clock-manager v0.0.0
clock-manager
demos
Usage
$ npm install --save clock-manager1. 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.deltaTimeclock.elapsedTime
0.0.0
7 years ago