Skip to content

Commit 50fc8f2

Browse files
committed
improve Matter.Engine docs
1 parent 85a9eb2 commit 50fc8f2

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/core/Engine.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ var Body = require('../body/Body');
7171
};
7272

7373
/**
74-
* Moves the simulation forward in time by `delta` ms.
74+
* Moves the simulation forward in time by `delta` milliseconds.
7575
* Triggers `beforeUpdate` and `afterUpdate` events.
7676
* Triggers `collisionStart`, `collisionActive` and `collisionEnd` events.
7777
* @method update
@@ -244,7 +244,9 @@ var Body = require('../body/Body');
244244
};
245245

246246
/**
247-
* Applies a mass dependant force to all given bodies.
247+
* Applies gravitational acceleration to all `bodies`.
248+
* This models a [uniform gravitational field](https://en.wikipedia.org/wiki/Gravity_of_Earth), similar to near the surface of a planet.
249+
*
248250
* @method _bodiesApplyGravity
249251
* @private
250252
* @param {body[]} bodies
@@ -264,7 +266,7 @@ var Body = require('../body/Body');
264266
if (body.isStatic || body.isSleeping)
265267
continue;
266268

267-
// apply gravity
269+
// add the resultant force of gravity
268270
body.force.y += body.mass * gravity.y * gravityScale;
269271
body.force.x += body.mass * gravity.x * gravityScale;
270272
}
@@ -500,7 +502,14 @@ var Body = require('../body/Body');
500502
*/
501503

502504
/**
503-
* The gravity to apply on all bodies in `engine.world`.
505+
* An optional gravitational acceleration applied to all bodies in `engine.world` on every update.
506+
*
507+
* This models a [uniform gravitational field](https://en.wikipedia.org/wiki/Gravity_of_Earth), similar to near the surface of a planet. For gravity in other contexts, disable this and apply forces as needed.
508+
*
509+
* To disable set the `scale` component to `0`.
510+
*
511+
* This is split into three components for ease of use:
512+
* a normalised direction (`x` and `y`) and magnitude (`scale`).
504513
*
505514
* @property gravity
506515
* @type object
@@ -523,7 +532,7 @@ var Body = require('../body/Body');
523532
*/
524533

525534
/**
526-
* The gravity scale factor.
535+
* The magnitude of the gravitational acceleration.
527536
*
528537
* @property gravity.scale
529538
* @type object

0 commit comments

Comments
 (0)