0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

added Composite.bounds

This commit is contained in:
liabru 2017-07-06 21:51:23 +01:00
parent c9294ebe6e
commit 79ffcf891e

View file

@ -532,6 +532,24 @@ var Body = require('./Body');
return composite; return composite;
}; };
/**
* Returns the union of the bounds of all of the composite's bodies.
* @method bounds
* @param {composite} composite The composite.
* @returns {bounds} The composite bounds.
*/
Composite.bounds = function(composite) {
var bodies = Matter.Composite.allBodies(composite),
vertices = [];
for (var i = 0; i < bodies.length; i += 1) {
var body = bodies[i];
vertices.push(body.bounds.min, body.bounds.max);
}
return Matter.Bounds.create(vertices);
};
/* /*
* *
* Events Documentation * Events Documentation