mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-26 13:49:01 -05:00
rename internal Common._timeUnit to Common._baseDelta
This commit is contained in:
parent
36575b3438
commit
dc46472720
6 changed files with 7 additions and 7 deletions
|
@ -759,7 +759,7 @@ var Axes = require('../geometry/Axes');
|
||||||
correction = Body._timeCorrection ? deltaTime / (body.deltaTime || deltaTime) : 1;
|
correction = Body._timeCorrection ? deltaTime / (body.deltaTime || deltaTime) : 1;
|
||||||
|
|
||||||
// from the previous step
|
// from the previous step
|
||||||
var frictionAir = 1 - body.frictionAir * (deltaTime / Common._timeUnit),
|
var frictionAir = 1 - body.frictionAir * (deltaTime / Common._baseDelta),
|
||||||
velocityPrevX = (body.position.x - body.positionPrev.x) * correction,
|
velocityPrevX = (body.position.x - body.positionPrev.x) * correction,
|
||||||
velocityPrevY = (body.position.y - body.positionPrev.y) * correction;
|
velocityPrevY = (body.position.y - body.positionPrev.y) * correction;
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ var Bounds = require('../geometry/Bounds');
|
||||||
contactShare,
|
contactShare,
|
||||||
positionImpulse,
|
positionImpulse,
|
||||||
positionDampen = Resolver._positionDampen * (damping || 1),
|
positionDampen = Resolver._positionDampen * (damping || 1),
|
||||||
slopDampen = Common.clamp(delta / Common._timeUnit, 0, 1),
|
slopDampen = Common.clamp(delta / Common._baseDelta, 0, 1),
|
||||||
pairsLength = pairs.length;
|
pairsLength = pairs.length;
|
||||||
|
|
||||||
// find impulses required to resolve penetration
|
// find impulses required to resolve penetration
|
||||||
|
@ -226,7 +226,7 @@ var Bounds = require('../geometry/Bounds');
|
||||||
* @param {number} delta
|
* @param {number} delta
|
||||||
*/
|
*/
|
||||||
Resolver.solveVelocity = function(pairs, delta) {
|
Resolver.solveVelocity = function(pairs, delta) {
|
||||||
var timeScale = delta / Common._timeUnit,
|
var timeScale = delta / Common._baseDelta,
|
||||||
timeScaleSquared = timeScale * timeScale,
|
timeScaleSquared = timeScale * timeScale,
|
||||||
timeScaleCubed = timeScaleSquared * timeScale,
|
timeScaleCubed = timeScaleSquared * timeScale,
|
||||||
restingThresh = -Resolver._restingThresh * timeScale,
|
restingThresh = -Resolver._restingThresh * timeScale,
|
||||||
|
|
|
@ -113,7 +113,7 @@ var Common = require('../core/Common');
|
||||||
* @param {number} delta
|
* @param {number} delta
|
||||||
*/
|
*/
|
||||||
Constraint.solveAll = function(constraints, delta) {
|
Constraint.solveAll = function(constraints, delta) {
|
||||||
var timeScale = Common.clamp(delta / Common._timeUnit, 0, 1);
|
var timeScale = Common.clamp(delta / Common._baseDelta, 0, 1);
|
||||||
|
|
||||||
// Solve fixed constraints first.
|
// Solve fixed constraints first.
|
||||||
for (var i = 0; i < constraints.length; i += 1) {
|
for (var i = 0; i < constraints.length; i += 1) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ module.exports = Common;
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
Common._timeUnit = 1000 / 60;
|
Common._baseDelta = 1000 / 60;
|
||||||
Common._nextId = 0;
|
Common._nextId = 0;
|
||||||
Common._seed = 0;
|
Common._seed = 0;
|
||||||
Common._nowStartTime = +(new Date());
|
Common._nowStartTime = +(new Date());
|
||||||
|
|
|
@ -88,7 +88,7 @@ var Body = require('../body/Body');
|
||||||
timestamp = timing.timestamp,
|
timestamp = timing.timestamp,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
delta = typeof delta !== 'undefined' ? delta : Common._timeUnit;
|
delta = typeof delta !== 'undefined' ? delta : Common._baseDelta;
|
||||||
delta *= timing.timeScale;
|
delta *= timing.timeScale;
|
||||||
|
|
||||||
// increment timestamp
|
// increment timestamp
|
||||||
|
|
|
@ -25,7 +25,7 @@ var Common = require('./Common');
|
||||||
* @param {number} delta
|
* @param {number} delta
|
||||||
*/
|
*/
|
||||||
Sleeping.update = function(bodies, delta) {
|
Sleeping.update = function(bodies, delta) {
|
||||||
var timeScale = delta / Common._timeUnit,
|
var timeScale = delta / Common._baseDelta,
|
||||||
motionSleepThreshold = Sleeping._motionSleepThreshold;
|
motionSleepThreshold = Sleeping._motionSleepThreshold;
|
||||||
|
|
||||||
// update bodies sleeping status
|
// update bodies sleeping status
|
||||||
|
|
Loading…
Reference in a new issue