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>
|
||||
|
||||
<script>
|
||||
const fps = 30;
|
||||
|
||||
var minDt = 1 / fps;
|
||||
|
||||
var header = document.getElementById("header");
|
||||
var awdog = document.getElementById("awdog");
|
||||
|
||||
|
@ -99,9 +103,9 @@
|
|||
let dt = (timestamp - prevTime) / 1000;
|
||||
prevTime = timestamp;
|
||||
|
||||
if (dt < 0.025) { // fps limiter (40fps)
|
||||
await new Promise(r => setTimeout(r, 0.025 - dt));
|
||||
dt = 0.025;
|
||||
if (dt < minDt) { // fps limiter
|
||||
await new Promise(r => setTimeout(r, minDt - dt));
|
||||
dt = minDt;
|
||||
}
|
||||
|
||||
// petting shake
|
||||
|
|
Reference in a new issue