Reinventing frame rate measuring.
This commit is contained in:
parent
a7ecbf9d2e
commit
d4f3ac969f
@ -2,7 +2,7 @@ import FrameRateMeasuredEvent from "./events/FrameRateMeasuredEvent.js";
|
||||
|
||||
export default class FrameRateMeasurer
|
||||
{
|
||||
constructor(rounds = 100)
|
||||
constructor(rounds = 30)
|
||||
{
|
||||
this.rounds = rounds;
|
||||
this.round = 0;
|
||||
|
13
js/module.js
13
js/module.js
@ -10,6 +10,7 @@ import FrameRateMeasurer from "./FrameRateMeasurer.js";
|
||||
import GraphicSet from "./GraphicSet.js";
|
||||
import ImageLoader from "./ImageLoader.js";
|
||||
import Level from "./Level.js";
|
||||
import InterfaceEvent from "./events/InterfaceEvent.js";
|
||||
|
||||
function MainLoop(timestamp)
|
||||
{
|
||||
@ -186,8 +187,14 @@ window.addEventListener(
|
||||
gisela = new Gisela();
|
||||
architecture.setMovableToTargetPosition(gisela);
|
||||
|
||||
fps = 60;
|
||||
frameDuration = 1000 / fps;
|
||||
window.requestAnimationFrame(MainLoop);
|
||||
window.addEventListener(
|
||||
InterfaceEvent.FRAME_RATE_MEASURED,
|
||||
(event) => {
|
||||
console.log(event);
|
||||
fps = event.frameRate;
|
||||
frameDuration = 1000 / fps;
|
||||
window.requestAnimationFrame(MainLoop);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue
Block a user