main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
419 bytes
|
Line | |
---|
1 | const times = [];
|
---|
2 | let fps;
|
---|
3 |
|
---|
4 | export function fpsCounterLoop() {
|
---|
5 | window.requestAnimationFrame(() => {
|
---|
6 | let cont = document.getElementById("fpsCounter");
|
---|
7 | const now = performance.now();
|
---|
8 | while (times.length > 0 && times[0] <= now - 1000) {
|
---|
9 | times.shift();
|
---|
10 | }
|
---|
11 | times.push(now);
|
---|
12 | fps = times.length;
|
---|
13 | cont.innerText = `FPS: ${fps}`;
|
---|
14 | //console.log("FPS: " + fps)
|
---|
15 | fpsCounterLoop();
|
---|
16 | });
|
---|
17 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.