Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/world/World.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ var step_tmp1 = new Vec3();
*/
World.prototype.step = function(dt, timeSinceLastCalled, maxSubSteps){
maxSubSteps = maxSubSteps || 10;
timeSinceLastCalled = timeSinceLastCalled || 0;
if (typeof timeSinceLastCalled === 'undefined') timeSinceLastCalled = -1;

if(timeSinceLastCalled === 0){ // Fixed, simple stepping
if(timeSinceLastCalled === -1){ // Fixed, simple stepping
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or better yet, let's not define an exception value at all. Let's have:

if(typeof timeSinceLastCalled === 'undefined'){ // Fixed, simple stepping


this.internalStep(dt);

Expand All @@ -539,8 +539,10 @@ World.prototype.step = function(dt, timeSinceLastCalled, maxSubSteps){
this.accumulator -= dt;
substeps++;
}
// Get rid of excess simulation time
this.accumulator %= dt;

var t = (this.accumulator % dt) / dt;
var t = this.accumulator / dt;
for(var j=0; j !== this.bodies.length; j++){
var b = this.bodies[j];
b.previousPosition.lerp(b.position, t, b.interpolatedPosition);
Expand Down