1.0.3 • Published 5 months ago
animation-frame-loop v1.0.3
Animation Frame Loop
A small package to keep track of frame related things, most notably deltaTime. Useful when creating animations that need to be consistent with varying frame counts.
Installation
Install using Yarn or NPM, or any other package manager you might prefer.
yarn add animation-frame-loop
npm install animation-frame-loop
Usage
import { AnimationFrameLoop } from "animation-frame-loop"
const loop = new AnimationFrameLoop(({ deltaTime, totalElapsedTime, currentFps }) => {
// Do your thing
})
// Destroy the loop when you're done
loop.destroy()
deltaTime
provides the time between the previous and the current frame.
totalElapsedTime
provides the total time the loop has run for
currentFps
provides the frames per second for the current second.
.destroy()
can be called to destroy the loop, stopping the callback from being called.