mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-30 10:20:52 -05:00
fixed Body.setStatic when applied multiple times, closes #641
This commit is contained in:
parent
b88c82fb1d
commit
96557859f9
1 changed files with 13 additions and 10 deletions
|
@ -260,18 +260,19 @@ var Axes = require('../geometry/Axes');
|
|||
Body.setStatic = function(body, isStatic) {
|
||||
for (var i = 0; i < body.parts.length; i++) {
|
||||
var part = body.parts[i];
|
||||
part.isStatic = isStatic;
|
||||
|
||||
if (isStatic) {
|
||||
part._original = {
|
||||
restitution: part.restitution,
|
||||
friction: part.friction,
|
||||
mass: part.mass,
|
||||
inertia: part.inertia,
|
||||
density: part.density,
|
||||
inverseMass: part.inverseMass,
|
||||
inverseInertia: part.inverseInertia
|
||||
};
|
||||
if (!part.isStatic) {
|
||||
part._original = {
|
||||
restitution: part.restitution,
|
||||
friction: part.friction,
|
||||
mass: part.mass,
|
||||
inertia: part.inertia,
|
||||
density: part.density,
|
||||
inverseMass: part.inverseMass,
|
||||
inverseInertia: part.inverseInertia
|
||||
};
|
||||
}
|
||||
|
||||
part.restitution = 0;
|
||||
part.friction = 1;
|
||||
|
@ -296,6 +297,8 @@ var Axes = require('../geometry/Axes');
|
|||
|
||||
part._original = null;
|
||||
}
|
||||
|
||||
part.isStatic = isStatic;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue