You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/core/Engine.js
+14-5Lines changed: 14 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,7 @@ var Body = require('../body/Body');
71
71
};
72
72
73
73
/**
74
-
* Moves the simulation forward in time by `delta` ms.
74
+
* Moves the simulation forward in time by `delta` milliseconds.
75
75
* Triggers `beforeUpdate` and `afterUpdate` events.
76
76
* Triggers `collisionStart`, `collisionActive` and `collisionEnd` events.
77
77
* @method update
@@ -244,7 +244,9 @@ var Body = require('../body/Body');
244
244
};
245
245
246
246
/**
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
+
*
248
250
* @method _bodiesApplyGravity
249
251
* @private
250
252
* @param {body[]} bodies
@@ -264,7 +266,7 @@ var Body = require('../body/Body');
264
266
if(body.isStatic||body.isSleeping)
265
267
continue;
266
268
267
-
// apply gravity
269
+
// add the resultant force of gravity
268
270
body.force.y+=body.mass*gravity.y*gravityScale;
269
271
body.force.x+=body.mass*gravity.x*gravityScale;
270
272
}
@@ -500,7 +502,14 @@ var Body = require('../body/Body');
500
502
*/
501
503
502
504
/**
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`).
504
513
*
505
514
* @property gravity
506
515
* @type object
@@ -523,7 +532,7 @@ var Body = require('../body/Body');
523
532
*/
524
533
525
534
/**
526
-
* The gravity scale factor.
535
+
* The magnitude of the gravitational acceleration.
0 commit comments