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:
parent
c9294ebe6e
commit
79ffcf891e
1 changed files with 18 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue