mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
added ids to constraints
This commit is contained in:
parent
e4445bc791
commit
abe379840d
1 changed files with 12 additions and 1 deletions
|
@ -17,7 +17,8 @@ var Constraint = {};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var _minLength = 0.000001;
|
var _minLength = 0.000001,
|
||||||
|
_nextId = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description
|
* Description
|
||||||
|
@ -51,6 +52,7 @@ var Constraint = {};
|
||||||
constraint.render = Common.extend(render, constraint.render);
|
constraint.render = Common.extend(render, constraint.render);
|
||||||
|
|
||||||
// option defaults
|
// option defaults
|
||||||
|
constraint.id = constraint.id || Constraint.nextId();
|
||||||
constraint.stiffness = constraint.stiffness || 1;
|
constraint.stiffness = constraint.stiffness || 1;
|
||||||
constraint.angularStiffness = constraint.angularStiffness || 0;
|
constraint.angularStiffness = constraint.angularStiffness || 0;
|
||||||
constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA;
|
constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA;
|
||||||
|
@ -221,4 +223,13 @@ var Constraint = {};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next unique constraintId
|
||||||
|
* @method nextId
|
||||||
|
* @return {Number} Unique constraintId
|
||||||
|
*/
|
||||||
|
Constraint.nextId = function() {
|
||||||
|
return _nextId++;
|
||||||
|
};
|
||||||
|
|
||||||
})();
|
})();
|
Loading…
Reference in a new issue