Skip to content

yomotsu/clock-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published