update
parent
b8be655261
commit
1b53eb912e
15
game-lib.js
15
game-lib.js
|
@ -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) {
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue