mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
added Composite.rebase
This commit is contained in:
parent
cb7cb9583a
commit
964898bea2
1 changed files with 20 additions and 0 deletions
|
@ -396,4 +396,24 @@ var Composite = {};
|
|||
return compositeA;
|
||||
};
|
||||
|
||||
/**
|
||||
* Assigns new ids for all objects in the composite, recursively
|
||||
* @method rebase
|
||||
* @param {composite} composite
|
||||
* @return {composite} Returns composite
|
||||
*/
|
||||
Composite.rebase = function(composite) {
|
||||
var objects = Composite.allBodies(composite)
|
||||
.concat(Composite.allConstraints(composite))
|
||||
.concat(Composite.allComposites(composite));
|
||||
|
||||
for (var i = 0; i < objects.length; i++) {
|
||||
objects[i].id = Common.nextId();
|
||||
}
|
||||
|
||||
Composite.setModified(composite, true, true, false);
|
||||
|
||||
return composite;
|
||||
};
|
||||
|
||||
})();
|
Loading…
Reference in a new issue