mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-13 16:18:50 -05:00
improve Matter.Engine docs
This commit is contained in:
parent
85a9eb2df5
commit
50fc8f2047
1 changed files with 14 additions and 5 deletions
|
@ -71,7 +71,7 @@ var Body = require('../body/Body');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the simulation forward in time by `delta` ms.
|
* Moves the simulation forward in time by `delta` milliseconds.
|
||||||
* Triggers `beforeUpdate` and `afterUpdate` events.
|
* Triggers `beforeUpdate` and `afterUpdate` events.
|
||||||
* Triggers `collisionStart`, `collisionActive` and `collisionEnd` events.
|
* Triggers `collisionStart`, `collisionActive` and `collisionEnd` events.
|
||||||
* @method update
|
* @method update
|
||||||
|
@ -244,7 +244,9 @@ var Body = require('../body/Body');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a mass dependant force to all given bodies.
|
* Applies gravitational acceleration to all `bodies`.
|
||||||
|
* This models a [uniform gravitational field](https://en.wikipedia.org/wiki/Gravity_of_Earth), similar to near the surface of a planet.
|
||||||
|
*
|
||||||
* @method _bodiesApplyGravity
|
* @method _bodiesApplyGravity
|
||||||
* @private
|
* @private
|
||||||
* @param {body[]} bodies
|
* @param {body[]} bodies
|
||||||
|
@ -264,7 +266,7 @@ var Body = require('../body/Body');
|
||||||
if (body.isStatic || body.isSleeping)
|
if (body.isStatic || body.isSleeping)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// apply gravity
|
// add the resultant force of gravity
|
||||||
body.force.y += body.mass * gravity.y * gravityScale;
|
body.force.y += body.mass * gravity.y * gravityScale;
|
||||||
body.force.x += body.mass * gravity.x * gravityScale;
|
body.force.x += body.mass * gravity.x * gravityScale;
|
||||||
}
|
}
|
||||||
|
@ -500,7 +502,14 @@ var Body = require('../body/Body');
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The gravity to apply on all bodies in `engine.world`.
|
* An optional gravitational acceleration applied to all bodies in `engine.world` on every update.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* To disable set the `scale` component to `0`.
|
||||||
|
*
|
||||||
|
* This is split into three components for ease of use:
|
||||||
|
* a normalised direction (`x` and `y`) and magnitude (`scale`).
|
||||||
*
|
*
|
||||||
* @property gravity
|
* @property gravity
|
||||||
* @type object
|
* @type object
|
||||||
|
@ -523,7 +532,7 @@ var Body = require('../body/Body');
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The gravity scale factor.
|
* The magnitude of the gravitational acceleration.
|
||||||
*
|
*
|
||||||
* @property gravity.scale
|
* @property gravity.scale
|
||||||
* @type object
|
* @type object
|
||||||
|
|
Loading…
Reference in a new issue