0
0
Fork 0
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:
liabru 2014-04-29 17:34:45 +01:00
parent cb7cb9583a
commit 964898bea2

View file

@ -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;
};
})();