File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -275,19 +275,23 @@ var Axes = require('../geometry/Axes');
275275 } ;
276276
277277 /**
278- * Sets the mass of the body. Inverse mass and density are automatically updated to reflect the change.
278+ * Sets the mass of the body. Inverse mass, density and inertia are automatically updated to reflect the change.
279279 * @method setMass
280280 * @param {body } body
281281 * @param {number } mass
282282 */
283283 Body . setMass = function ( body , mass ) {
284+ var moment = body . inertia / ( body . mass / 6 ) ;
285+ body . inertia = moment * ( mass / 6 ) ;
286+ body . inverseInertia = 1 / body . inertia ;
287+
284288 body . mass = mass ;
285289 body . inverseMass = 1 / body . mass ;
286290 body . density = body . mass / body . area ;
287291 } ;
288292
289293 /**
290- * Sets the density of the body. Mass is automatically updated to reflect the change.
294+ * Sets the density of the body. Mass and inertia are automatically updated to reflect the change.
291295 * @method setDensity
292296 * @param {body } body
293297 * @param {number } density
You can’t perform that action at this time.
0 commit comments