ok timer good
This commit is contained in:
parent
763e8d35f6
commit
712ce5dbdd
1 changed files with 7 additions and 3 deletions
10
index.html
10
index.html
|
@ -79,6 +79,10 @@
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
const fps = 30;
|
||||||
|
|
||||||
|
var minDt = 1 / fps;
|
||||||
|
|
||||||
var header = document.getElementById("header");
|
var header = document.getElementById("header");
|
||||||
var awdog = document.getElementById("awdog");
|
var awdog = document.getElementById("awdog");
|
||||||
|
|
||||||
|
@ -99,9 +103,9 @@
|
||||||
let dt = (timestamp - prevTime) / 1000;
|
let dt = (timestamp - prevTime) / 1000;
|
||||||
prevTime = timestamp;
|
prevTime = timestamp;
|
||||||
|
|
||||||
if (dt < 0.025) { // fps limiter (40fps)
|
if (dt < minDt) { // fps limiter
|
||||||
await new Promise(r => setTimeout(r, 0.025 - dt));
|
await new Promise(r => setTimeout(r, minDt - dt));
|
||||||
dt = 0.025;
|
dt = minDt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// petting shake
|
// petting shake
|
||||||
|
|
Reference in a new issue