Skip to content

Commit

Permalink
prevent newFPS ends in NaN though dividing by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
mullerlele authored Sep 15, 2016
1 parent ab224db commit a6b13f5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,13 @@ SceneJS_Engine.prototype.start = function () {

if (lastFrameTime > 0) {
elapsedFrameTime = frameTime - lastFrameTime;
newFPS = 1000 / elapsedFrameTime;
totalFPS += newFPS;
fpsSamples.push(newFPS);
if(elapsedFrameTime == 0) {
newFPS = 0;
} else {
newFPS = 1000 / elapsedFrameTime;
totalFPS += newFPS;
fpsSamples.push(newFPS);
}
if (fpsSamples.length >= numFPSSamples) {
totalFPS -= fpsSamples.shift();
}
Expand Down

0 comments on commit a6b13f5

Please sign in to comment.