0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-03-10 00:06:42 -04:00

Merge branch 'pr/60'

[liabru] corrected some of the param types before merge

Conflicts:
	src/body/Body.js
	src/collision/Resolver.js
	src/render/Render.js
	src/render/RenderPixi.js
This commit is contained in:
liabru 2015-05-24 13:43:34 +01:00
commit 42dc72dabe
12 changed files with 40 additions and 33 deletions

View file

@ -22,7 +22,7 @@ var Body = {};
/** /**
* Creates a new rigid body model. The options parameter is an object that specifies any properties you wish to override the defaults. * Creates a new rigid body model. The options parameter is an object that specifies any properties you wish to override the defaults.
* All properties have default values, and many are pre-calculated automatically based on other properties. * All properties have default values, and many are pre-calculated automatically based on other properties.
* See the properites section below for detailed information on what you can pass via the `options` object. * See the properties section below for detailed information on what you can pass via the `options` object.
* @method create * @method create
* @param {} options * @param {} options
* @return {body} body * @return {body} body
@ -515,7 +515,7 @@ var Body = {};
velocityPrevX = body.position.x - body.positionPrev.x, velocityPrevX = body.position.x - body.positionPrev.x,
velocityPrevY = body.position.y - body.positionPrev.y; velocityPrevY = body.position.y - body.positionPrev.y;
// update velocity with verlet integration // update velocity with Verlet integration
body.velocity.x = (velocityPrevX * frictionAir * correction) + (body.force.x / body.mass) * deltaTimeSquared; body.velocity.x = (velocityPrevX * frictionAir * correction) + (body.force.x / body.mass) * deltaTimeSquared;
body.velocity.y = (velocityPrevY * frictionAir * correction) + (body.force.y / body.mass) * deltaTimeSquared; body.velocity.y = (velocityPrevY * frictionAir * correction) + (body.force.y / body.mass) * deltaTimeSquared;
@ -524,7 +524,7 @@ var Body = {};
body.position.x += body.velocity.x; body.position.x += body.velocity.x;
body.position.y += body.velocity.y; body.position.y += body.velocity.y;
// update angular velocity with verlet integration // update angular velocity with Verlet integration
body.angularVelocity = ((body.angle - body.anglePrev) * frictionAir * correction) + (body.torque / body.inertia) * deltaTimeSquared; body.angularVelocity = ((body.angle - body.anglePrev) * frictionAir * correction) + (body.torque / body.inertia) * deltaTimeSquared;
body.anglePrev = body.angle; body.anglePrev = body.angle;
body.angle += body.angularVelocity; body.angle += body.angularVelocity;
@ -668,7 +668,7 @@ var Body = {};
* *
* [{ x: 0, y: 0 }, { x: 25, y: 50 }, { x: 50, y: 0 }] * [{ x: 0, y: 0 }, { x: 25, y: 50 }, { x: 50, y: 0 }]
* *
* When passed via `Body.create`, the verticies are translated relative to `body.position` (i.e. world-space, and constantly updated by `Body.update` during simulation). * When passed via `Body.create`, the vertices are translated relative to `body.position` (i.e. world-space, and constantly updated by `Body.update` during simulation).
* The `Vector` objects are also augmented with additional properties required for efficient collision detection. * The `Vector` objects are also augmented with additional properties required for efficient collision detection.
* *
* Other properties such as `inertia` and `bounds` are automatically calculated from the passed vertices (unless provided via `options`). * Other properties such as `inertia` and `bounds` are automatically calculated from the passed vertices (unless provided via `options`).

View file

@ -308,7 +308,7 @@ var Composite = {};
* Removes all bodies, constraints and composites from the given composite * Removes all bodies, constraints and composites from the given composite
* Optionally clearing its children recursively * Optionally clearing its children recursively
* @method clear * @method clear
* @param {world} world * @param {composite} composite
* @param {boolean} keepStatic * @param {boolean} keepStatic
* @param {boolean} [deep=false] * @param {boolean} [deep=false]
*/ */

View file

@ -18,7 +18,7 @@ var World = {};
/** /**
* Creates a new world composite. The options parameter is an object that specifies any properties you wish to override the defaults. * Creates a new world composite. The options parameter is an object that specifies any properties you wish to override the defaults.
* See the properites section below for detailed information on what you can pass via the `options` object. * See the properties section below for detailed information on what you can pass via the `options` object.
* @method create * @method create
* @constructor * @constructor
* @param {} options * @param {} options

View file

@ -12,6 +12,7 @@ var Pair = {};
* Description * Description
* @method create * @method create
* @param {collision} collision * @param {collision} collision
* @param {number} timestamp
* @return {pair} A new pair * @return {pair} A new pair
*/ */
Pair.create = function(collision, timestamp) { Pair.create = function(collision, timestamp) {
@ -47,6 +48,7 @@ var Pair = {};
* @method update * @method update
* @param {pair} pair * @param {pair} pair
* @param {collision} collision * @param {collision} collision
* @param {number} timestamp
*/ */
Pair.update = function(pair, collision, timestamp) { Pair.update = function(pair, collision, timestamp) {
var contacts = pair.contacts, var contacts = pair.contacts,
@ -89,6 +91,7 @@ var Pair = {};
* @method setActive * @method setActive
* @param {pair} pair * @param {pair} pair
* @param {bool} isActive * @param {bool} isActive
* @param {number} timestamp
*/ */
Pair.setActive = function(pair, isActive, timestamp) { Pair.setActive = function(pair, isActive, timestamp) {
if (isActive) { if (isActive) {

View file

@ -31,6 +31,7 @@ var Pairs = {};
* @method update * @method update
* @param {object} pairs * @param {object} pairs
* @param {collision[]} collisions * @param {collision[]} collisions
* @param {number} timestamp
*/ */
Pairs.update = function(pairs, collisions, timestamp) { Pairs.update = function(pairs, collisions, timestamp) {
var pairsList = pairs.list, var pairsList = pairs.list,
@ -96,6 +97,7 @@ var Pairs = {};
* Description * Description
* @method removeOld * @method removeOld
* @param {object} pairs * @param {object} pairs
* @param {number} timestamp
*/ */
Pairs.removeOld = function(pairs, timestamp) { Pairs.removeOld = function(pairs, timestamp) {
var pairsList = pairs.list, var pairsList = pairs.list,
@ -133,9 +135,9 @@ var Pairs = {};
/** /**
* Clears the given pairs structure * Clears the given pairs structure
* @method create * @method clear
* @param {object} options
* @param {pairs} pairs * @param {pairs} pairs
* @return {pairs} pairs
*/ */
Pairs.clear = function(pairs) { Pairs.clear = function(pairs) {
pairs.table = {}; pairs.table = {};

View file

@ -216,6 +216,7 @@ var Resolver = {};
* Description * Description
* @method solveVelocity * @method solveVelocity
* @param {pair[]} pairs * @param {pair[]} pairs
* @param {number} timeScale
*/ */
Resolver.solveVelocity = function(pairs, timeScale) { Resolver.solveVelocity = function(pairs, timeScale) {
var timeScaleSquared = timeScale * timeScale, var timeScaleSquared = timeScale * timeScale,

View file

@ -9,10 +9,10 @@
* @class Constraint * @class Constraint
*/ */
// TODO: fix instabillity issues with torque // TODO: fix instability issues with torque
// TODO: linked constraints // TODO: linked constraints
// TODO: breakable constraints // TODO: breakable constraints
// TODO: collidable constraints // TODO: collision constraints
// TODO: allow constrained bodies to sleep // TODO: allow constrained bodies to sleep
// TODO: handle 0 length constraints properly // TODO: handle 0 length constraints properly
// TODO: impulse caching and warming // TODO: impulse caching and warming
@ -27,7 +27,7 @@ var Constraint = {};
/** /**
* Creates a new constraint. * Creates a new constraint.
* All properties have default values, and many are pre-calculated automatically based on other properties. * All properties have default values, and many are pre-calculated automatically based on other properties.
* See the properites section below for detailed information on what you can pass via the `options` object. * See the properties section below for detailed information on what you can pass via the `options` object.
* @method create * @method create
* @param {} options * @param {} options
* @return {constraint} constraint * @return {constraint} constraint
@ -200,8 +200,8 @@ var Constraint = {};
Sleeping.set(bodyA, false); Sleeping.set(bodyA, false);
// clamp to prevent instabillity // clamp to prevent instability
// TODO: solve this properlly // TODO: solve this properly
torque = Common.clamp(torque, -0.01, 0.01); torque = Common.clamp(torque, -0.01, 0.01);
// keep track of applied impulses for post solving // keep track of applied impulses for post solving
@ -220,8 +220,8 @@ var Constraint = {};
Sleeping.set(bodyB, false); Sleeping.set(bodyB, false);
// clamp to prevent instabillity // clamp to prevent instability
// TODO: solve this properlly // TODO: solve this properly
torque = Common.clamp(torque, -0.01, 0.01); torque = Common.clamp(torque, -0.01, 0.01);
// keep track of applied impulses for post solving // keep track of applied impulses for post solving
@ -382,7 +382,7 @@ var Constraint = {};
/** /**
* A `Number` that specifies the target resting length of the constraint. * A `Number` that specifies the target resting length of the constraint.
* It is calculated automatically in `Constraint.create` from intial positions of the `constraint.bodyA` and `constraint.bodyB`. * It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB`.
* *
* @property length * @property length
* @type number * @type number

View file

@ -15,7 +15,7 @@ var MouseConstraint = {};
/** /**
* Creates a new mouse constraint. * Creates a new mouse constraint.
* All properties have default values, and many are pre-calculated automatically based on other properties. * All properties have default values, and many are pre-calculated automatically based on other properties.
* See the properites section below for detailed information on what you can pass via the `options` object. * See the properties section below for detailed information on what you can pass via the `options` object.
* @method create * @method create
* @param {engine} engine * @param {engine} engine
* @param {} options * @param {} options
@ -118,7 +118,7 @@ var MouseConstraint = {};
* Triggers mouse constraint events * Triggers mouse constraint events
* @method _triggerEvents * @method _triggerEvents
* @private * @private
* @param {mouse} mouse * @param {mouse} mouseConstraint
*/ */
var _triggerEvents = function(mouseConstraint) { var _triggerEvents = function(mouseConstraint) {
var mouse = mouseConstraint.mouse, var mouse = mouseConstraint.mouse,

View file

@ -208,7 +208,7 @@ var Common = {};
/** /**
* Description * Description
* @method now * @method now
* @return {number} the current timestamp (high-res if avaliable) * @return {number} the current timestamp (high-res if available)
*/ */
Common.now = function() { Common.now = function() {
// http://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript // http://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript

View file

@ -19,7 +19,7 @@ var Engine = {};
/** /**
* Creates a new engine. The options parameter is an object that specifies any properties you wish to override the defaults. * Creates a new engine. The options parameter is an object that specifies any properties you wish to override the defaults.
* All properties have default values, and many are pre-calculated automatically based on other properties. * All properties have default values, and many are pre-calculated automatically based on other properties.
* See the properites section below for detailed information on what you can pass via the `options` object. * See the properties section below for detailed information on what you can pass via the `options` object.
* @method create * @method create
* @param {HTMLElement} element * @param {HTMLElement} element
* @param {object} [options] * @param {object} [options]
@ -200,8 +200,7 @@ var Engine = {};
/** /**
* Renders the world by calling its defined renderer `engine.render.controller`. Triggers `beforeRender` and `afterRender` events. * Renders the world by calling its defined renderer `engine.render.controller`. Triggers `beforeRender` and `afterRender` events.
* @method render * @method render
* @param {engine} engineA * @param {engine} engine
* @param {engine} engineB
*/ */
Engine.render = function(engine) { Engine.render = function(engine) {
// create an event object // create an event object
@ -511,8 +510,8 @@ var Engine = {};
/** /**
* A `Boolean` that specifies if the `Engine.run` game loop should use a fixed timestep (otherwise it is variable). * A `Boolean` that specifies if the `Engine.run` game loop should use a fixed timestep (otherwise it is variable).
* If timing is fixed, then the apparant simulation speed will change depending on the frame rate (but behaviour will be deterministic). * If timing is fixed, then the apparent simulation speed will change depending on the frame rate (but behaviour will be deterministic).
* If the timing is variable, then the apparant simulation speed will be constant (approximately, but at the cost of determininism). * If the timing is variable, then the apparent simulation speed will be constant (approximately, but at the cost of determininism).
* *
* @property timing.isFixed * @property timing.isFixed
* @type boolean * @type boolean
@ -522,7 +521,7 @@ var Engine = {};
/** /**
* A `Number` that specifies the time step between updates in milliseconds. * A `Number` that specifies the time step between updates in milliseconds.
* If `engine.timing.isFixed` is set to `true`, then `delta` is fixed. * If `engine.timing.isFixed` is set to `true`, then `delta` is fixed.
* If it is `false`, then `delta` can dynamically change to maintain the correct apparant simulation speed. * If it is `false`, then `delta` can dynamically change to maintain the correct apparent simulation speed.
* *
* @property timing.delta * @property timing.delta
* @type number * @type number

View file

@ -141,6 +141,7 @@ var Mouse = {};
* Sets the offset * Sets the offset
* @method setOffset * @method setOffset
* @param {mouse} mouse * @param {mouse} mouse
* @param {vector} offset
*/ */
Mouse.setOffset = function(mouse, offset) { Mouse.setOffset = function(mouse, offset) {
mouse.offset.x = offset.x; mouse.offset.x = offset.x;
@ -153,6 +154,7 @@ var Mouse = {};
* Sets the scale * Sets the scale
* @method setScale * @method setScale
* @param {mouse} mouse * @param {mouse} mouse
* @param {vector} scale
*/ */
Mouse.setScale = function(mouse, scale) { Mouse.setScale = function(mouse, scale) {
mouse.scale.x = scale.x; mouse.scale.x = scale.x;

View file

@ -17,7 +17,7 @@ var Render = {};
/** /**
* Creates a new renderer. The options parameter is an object that specifies any properties you wish to override the defaults. * Creates a new renderer. The options parameter is an object that specifies any properties you wish to override the defaults.
* All properties have default values, and many are pre-calculated automatically based on other properties. * All properties have default values, and many are pre-calculated automatically based on other properties.
* See the properites section below for detailed information on what you can pass via the `options` object. * See the properties section below for detailed information on what you can pass via the `options` object.
* @method create * @method create
* @param {object} [options] * @param {object} [options]
* @return {render} A new renderer * @return {render} A new renderer