diff --git a/src/body/Composite.js b/src/body/Composite.js index ee15d93..885669c 100644 --- a/src/body/Composite.js +++ b/src/body/Composite.js @@ -532,6 +532,24 @@ var Body = require('./Body'); 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