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
|
export default class FrameRateMeasurer
|
||||||
{
|
{
|
||||||
constructor(rounds = 100)
|
constructor(rounds = 30)
|
||||||
{
|
{
|
||||||
this.rounds = rounds;
|
this.rounds = rounds;
|
||||||
this.round = 0;
|
this.round = 0;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import FrameRateMeasurer from "./FrameRateMeasurer.js";
|
||||||
import GraphicSet from "./GraphicSet.js";
|
import GraphicSet from "./GraphicSet.js";
|
||||||
import ImageLoader from "./ImageLoader.js";
|
import ImageLoader from "./ImageLoader.js";
|
||||||
import Level from "./Level.js";
|
import Level from "./Level.js";
|
||||||
|
import InterfaceEvent from "./events/InterfaceEvent.js";
|
||||||
|
|
||||||
function MainLoop(timestamp)
|
function MainLoop(timestamp)
|
||||||
{
|
{
|
||||||
|
@ -186,8 +187,14 @@ window.addEventListener(
|
||||||
gisela = new Gisela();
|
gisela = new Gisela();
|
||||||
architecture.setMovableToTargetPosition(gisela);
|
architecture.setMovableToTargetPosition(gisela);
|
||||||
|
|
||||||
fps = 60;
|
window.addEventListener(
|
||||||
|
InterfaceEvent.FRAME_RATE_MEASURED,
|
||||||
|
(event) => {
|
||||||
|
console.log(event);
|
||||||
|
fps = event.frameRate;
|
||||||
frameDuration = 1000 / fps;
|
frameDuration = 1000 / fps;
|
||||||
window.requestAnimationFrame(MainLoop);
|
window.requestAnimationFrame(MainLoop);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
);
|
Loading…
Reference in New Issue