mirror of
https://github.com/liabru/matter-js.git
synced 2025-03-10 00:06:42 -04:00
added Body.setStatic
This commit is contained in:
parent
1f11af9edb
commit
8acfdb7f38
1 changed files with 13 additions and 3 deletions
|
@ -108,15 +108,25 @@ var Body = {};
|
||||||
Axes.rotate(body.axes, body.angle);
|
Axes.rotate(body.axes, body.angle);
|
||||||
Bounds.update(body.bounds, body.vertices, body.velocity);
|
Bounds.update(body.bounds, body.vertices, body.velocity);
|
||||||
|
|
||||||
if (body.isStatic) {
|
Body.setStatic(body, body.isStatic);
|
||||||
|
Sleeping.set(body, body.isSleeping);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the body as static, including isStatic flag and setting mass and inertia to Infinity
|
||||||
|
* @method setStatic
|
||||||
|
* @param {bool} isStatic
|
||||||
|
*/
|
||||||
|
Body.setStatic = function(body, isStatic) {
|
||||||
|
body.isStatic = isStatic;
|
||||||
|
|
||||||
|
if (isStatic) {
|
||||||
body.restitution = 0;
|
body.restitution = 0;
|
||||||
body.friction = 1;
|
body.friction = 1;
|
||||||
body.mass = body.inertia = body.density = Infinity;
|
body.mass = body.inertia = body.density = Infinity;
|
||||||
body.inverseMass = body.inverseInertia = 0;
|
body.inverseMass = body.inverseInertia = 0;
|
||||||
body.render.lineWidth = 1;
|
body.render.lineWidth = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sleeping.set(body, body.isSleeping);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue