I need a fps limiter to reduce the speed to 30 fps. The jitter is especially noticeable on smartphones, except on my PC. But it has nothing to do with the 30fps, since my movements are slow and everything is smooth on the PC. The graphics performance of smartphones is also sufficient. What am I doing wrong here?
- With some jitter on 30 and 60fps on smartphones
animate(currentTime) {
const elapsed = currentTime - this.lastFrameTime;
if (elapsed >= this.timeFpsMax) {
this.lastFrameTime = currentTime - (elapsed % this.timeFpsMax);
const deltaTime = this.timeFpsMax / 1000;
this.mixer.update(deltaTime);
this.stats.begin();
this.composer.render();
this.stats.end();
}
}
- With some jitter on 30 and 60fps on smartphones
animate(currentTime) {
const now = currentTime / 1000;
let deltaTime = now - lastTime;
lastTime = now;
deltaTime = Math.min(deltaTime, 0.1);
accumulator += deltaTime;
while (accumulator >= fixedTimeStep) {
this.mixer.update(fixedTimeStep);
accumulator -= fixedTimeStep;
needsRender = true;
}
if (needsRender) {
this.stats.begin();
this.composer.render();
this.stats.end();
needsRender = false;
}
}
- No Jitter (60fps)
animate(currentTime) {
this.mixer.update(this.clock.getDelta());
this.stats.begin();
this.composer.render();
this.stats.end();
}
Thanks…