beta.r3js.org
polygonboutique 2016-10-07 10:21:50 +02:00
parent b8be655261
commit 1b53eb912e
1 changed files with 16 additions and 1 deletions

View File

@ -1172,6 +1172,7 @@ GameLib.D3.Physics.World = function(
this.worldObject = new CANNON.World();
this.worldObject.gravity.set(this.gravity.x, this.gravity.y, this.gravity.z);
this.worldObject.broadphase = new CANNON.NaiveBroadphase();
//this.worldObject.broadphase = new CANNON.SAPBroadphase();
this.worldObject.solver.iterations = 10;
}
};
@ -2825,7 +2826,21 @@ GameLib.D3.Physics.World.prototype.Step = function(
timeStep
) {
if(this.engineType == GameLib.D3.Physics.Engine.TYPE_CANNON) {
this.worldObject.step(timeStep);
var now = performance.now() / 1000;
if(!this.lastCallTime){
// last call time not saved, cant guess elapsed time. Take a simple step.
this.worldObject.step(timeStep);
this.lastCallTime = now;
return;
}
var timeSinceLastCall = now - this.lastCallTime;
this.worldObject.step(timeStep, timeSinceLastCall);
this.lastCallTime = now;
}
};