mirror of
https://github.com/liabru/matter-js.git
synced 2025-02-07 19:06:26 -05:00
added Common.nextId, removed Body.nextId, removed Constraint.nextId, removed Composite.nextId
This commit is contained in:
parent
23a0fce2c0
commit
cb7cb9583a
4 changed files with 16 additions and 36 deletions
|
@ -9,8 +9,7 @@ var Body = {};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var _nextId = 0,
|
var _nextGroupId = 1;
|
||||||
_nextGroupId = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description to be written.
|
* Description to be written.
|
||||||
|
@ -20,7 +19,7 @@ var Body = {};
|
||||||
*/
|
*/
|
||||||
Body.create = function(options) {
|
Body.create = function(options) {
|
||||||
var defaults = {
|
var defaults = {
|
||||||
id: Body.nextId(),
|
id: Common.nextId(),
|
||||||
type: 'body',
|
type: 'body',
|
||||||
label: 'Body',
|
label: 'Body',
|
||||||
angle: 0,
|
angle: 0,
|
||||||
|
@ -62,15 +61,6 @@ var Body = {};
|
||||||
return body;
|
return body;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Description
|
|
||||||
* @method nextId
|
|
||||||
* @return {Number} Unique bodyID
|
|
||||||
*/
|
|
||||||
Body.nextId = function() {
|
|
||||||
return _nextId++;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description
|
* Description
|
||||||
* @method nextGroupId
|
* @method nextGroupId
|
||||||
|
|
|
@ -11,8 +11,6 @@ var Composite = {};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var _nextId = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description
|
* Description
|
||||||
* @method create
|
* @method create
|
||||||
|
@ -21,7 +19,7 @@ var Composite = {};
|
||||||
*/
|
*/
|
||||||
Composite.create = function(options) {
|
Composite.create = function(options) {
|
||||||
return Common.extend({
|
return Common.extend({
|
||||||
id: Composite.nextId(),
|
id: Common.nextId(),
|
||||||
type: 'composite',
|
type: 'composite',
|
||||||
parent: null,
|
parent: null,
|
||||||
isModified: false,
|
isModified: false,
|
||||||
|
@ -32,15 +30,6 @@ var Composite = {};
|
||||||
}, options);
|
}, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the next unique compositeID
|
|
||||||
* @method nextId
|
|
||||||
* @return {Number} Unique compositeID
|
|
||||||
*/
|
|
||||||
Composite.nextId = function() {
|
|
||||||
return _nextId++;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the composite's `isModified` flag.
|
* Sets the composite's `isModified` flag.
|
||||||
* If `updateParents` is true, all parents will be set (default: false).
|
* If `updateParents` is true, all parents will be set (default: false).
|
||||||
|
|
|
@ -18,8 +18,7 @@ var Constraint = {};
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var _minLength = 0.000001,
|
var _minLength = 0.000001,
|
||||||
_minDifference = 0.001,
|
_minDifference = 0.001;
|
||||||
_nextId = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description
|
* Description
|
||||||
|
@ -53,7 +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.id = constraint.id || Common.nextId();
|
||||||
constraint.label = constraint.label || 'Constraint';
|
constraint.label = constraint.label || 'Constraint';
|
||||||
constraint.type = 'constraint';
|
constraint.type = 'constraint';
|
||||||
constraint.stiffness = constraint.stiffness || 1;
|
constraint.stiffness = constraint.stiffness || 1;
|
||||||
|
@ -256,13 +255,4 @@ var Constraint = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the next unique constraintId
|
|
||||||
* @method nextId
|
|
||||||
* @return {Number} Unique constraintId
|
|
||||||
*/
|
|
||||||
Constraint.nextId = function() {
|
|
||||||
return _nextId++;
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
})();
|
|
@ -8,6 +8,8 @@ var Common = {};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
Common._nextId = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description
|
* Description
|
||||||
* @method extend
|
* @method extend
|
||||||
|
@ -267,4 +269,13 @@ var Common = {};
|
||||||
console.log('%c [Matter] ' + type + ': ' + message, style);
|
console.log('%c [Matter] ' + type + ': ' + message, style);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next unique sequential ID
|
||||||
|
* @method nextId
|
||||||
|
* @return {Number} Unique sequential ID
|
||||||
|
*/
|
||||||
|
Common.nextId = function() {
|
||||||
|
return Common._nextId++;
|
||||||
|
};
|
||||||
|
|
||||||
})();
|
})();
|
Loading…
Add table
Reference in a new issue