Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fix frame skip problem on Android Chrome
//MIT
SceneManager.update = function() {
try {
this.tickStart();
if (Utils.isMobileDevice()) {
this.updateInputData();
}
this.updateMain();
this.tickEnd();
} catch (e) {
this.catchException(e);
}
};
SceneManager.updateMain = function() {
if (Utils.isMobileDevice()) {
this.changeScene();
this.updateScene();
} else {
var newTime = this._getTimeInMs();
var fTime = (newTime - this._currentTime) / 1000;
if (fTime > 0.25) fTime = 0.25;
this._currentTime = newTime;
this._accumulator += fTime;
while (this._accumulator >= this._deltaTime) {
this.updateInputData();
this.changeScene();
this.updateScene();
this._accumulator -= this._deltaTime;
}
}
this.renderScene();
this.requestUpdate();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment