mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
fixed Body.setVertices
This commit is contained in:
parent
874618520b
commit
73ded98a67
1 changed files with 9 additions and 3 deletions
|
@ -95,6 +95,8 @@ var Body = {};
|
|||
Body.setVertices(body, body.vertices);
|
||||
Body.setStatic(body, body.isStatic);
|
||||
Sleeping.set(body, body.isSleeping);
|
||||
Vertices.rotate(body.vertices, body.angle, body.position);
|
||||
Axes.rotate(body.axes, body.angle);
|
||||
|
||||
// allow options to override the automatically calculated properties
|
||||
body.axes = options.axes || body.axes;
|
||||
|
@ -151,7 +153,11 @@ var Body = {};
|
|||
*/
|
||||
Body.setVertices = function(body, vertices) {
|
||||
// change vertices
|
||||
if (vertices[0].body === body) {
|
||||
body.vertices = vertices;
|
||||
} else {
|
||||
body.vertices = Vertices.create(vertices, body);
|
||||
}
|
||||
|
||||
// update properties
|
||||
body.axes = Axes.fromVertices(body.vertices);
|
||||
|
@ -169,8 +175,8 @@ var Body = {};
|
|||
|
||||
// update geometry
|
||||
Vertices.translate(body.vertices, body.position);
|
||||
Vertices.rotate(body.vertices, body.angle, body.position);
|
||||
Axes.rotate(body.axes, body.angle);
|
||||
Bounds.update(body.bounds, body.vertices, body.velocity);
|
||||
};
|
||||
Bounds.update(body.bounds, body.vertices, body.velocity);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue