import { createGameLoop } from 'game-loop-js'
const myGameLoop = function(deltaTime) {
// ...
};
// how to create a game loop with a targeted 60 FPS :
const gameLoop = createGameLoop(myGameLoop, 60);
// how to change the targeted FPS :
gameLoop.fps = 144;
// how to get the targeted FPS :
const targetFps = gameLoop.fps;
// how to register the loop :
// using three.js
renderer.setAnimationLoop( gameLoop.loop );
// -- or --
// using requestAnimationFrame
function animate( time ) {
gameLoop.loop( time );
requestAnimationFrame( animate );
}
requestAnimationFrame( animate );
<script type="text/javascript" src="/dist/bundle.umd.js"></script>
<script type="text/javascript">
const myGameLoop = function(deltaTime) {
// ...
};
const gameLoop = gameLoopJs.createGameLoop(myGameLoop);
function animate( time ) {
gameLoop.loop( time );
requestAnimationFrame( animate );
}
requestAnimationFrame( animate );
</script>