mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-30 10:20: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.setVertices(body, body.vertices);
|
||||||
Body.setStatic(body, body.isStatic);
|
Body.setStatic(body, body.isStatic);
|
||||||
Sleeping.set(body, body.isSleeping);
|
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
|
// allow options to override the automatically calculated properties
|
||||||
body.axes = options.axes || body.axes;
|
body.axes = options.axes || body.axes;
|
||||||
|
@ -151,7 +153,11 @@ var Body = {};
|
||||||
*/
|
*/
|
||||||
Body.setVertices = function(body, vertices) {
|
Body.setVertices = function(body, vertices) {
|
||||||
// change vertices
|
// change vertices
|
||||||
|
if (vertices[0].body === body) {
|
||||||
|
body.vertices = vertices;
|
||||||
|
} else {
|
||||||
body.vertices = Vertices.create(vertices, body);
|
body.vertices = Vertices.create(vertices, body);
|
||||||
|
}
|
||||||
|
|
||||||
// update properties
|
// update properties
|
||||||
body.axes = Axes.fromVertices(body.vertices);
|
body.axes = Axes.fromVertices(body.vertices);
|
||||||
|
@ -169,8 +175,8 @@ var Body = {};
|
||||||
|
|
||||||
// update geometry
|
// update geometry
|
||||||
Vertices.translate(body.vertices, body.position);
|
Vertices.translate(body.vertices, body.position);
|
||||||
Vertices.rotate(body.vertices, body.angle, body.position);
|
Bounds.update(body.bounds, body.vertices, body.velocity);
|
||||||
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