mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-23 09:26:51 -05:00
added engine beforeSolve event, closes #1173
This commit is contained in:
parent
812f8af1be
commit
8dd0e99b79
1 changed files with 14 additions and 1 deletions
|
@ -72,7 +72,7 @@ var Body = require('../body/Body');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the simulation forward in time by `delta` milliseconds.
|
* Moves the simulation forward in time by `delta` milliseconds.
|
||||||
* Triggers `beforeUpdate` and `afterUpdate` events.
|
* Triggers `beforeUpdate`, `beforeSolve` and `afterUpdate` events.
|
||||||
* Triggers `collisionStart`, `collisionActive` and `collisionEnd` events.
|
* Triggers `collisionStart`, `collisionActive` and `collisionEnd` events.
|
||||||
* @method update
|
* @method update
|
||||||
* @param {engine} engine
|
* @param {engine} engine
|
||||||
|
@ -128,6 +128,8 @@ var Body = require('../body/Body');
|
||||||
Engine._bodiesUpdate(allBodies, delta);
|
Engine._bodiesUpdate(allBodies, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Events.trigger(engine, 'beforeSolve', event);
|
||||||
|
|
||||||
// update all constraints (first pass)
|
// update all constraints (first pass)
|
||||||
Constraint.preSolveAll(allBodies);
|
Constraint.preSolveAll(allBodies);
|
||||||
for (i = 0; i < engine.constraintIterations; i++) {
|
for (i = 0; i < engine.constraintIterations; i++) {
|
||||||
|
@ -327,6 +329,17 @@ var Body = require('../body/Body');
|
||||||
* @param {string} event.name The name of the event
|
* @param {string} event.name The name of the event
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired after bodies updated based on their velocity and forces, but before any collision detection, constraints and resolving etc.
|
||||||
|
*
|
||||||
|
* @event beforeSolve
|
||||||
|
* @param {object} event An event object
|
||||||
|
* @param {number} event.timestamp The engine.timing.timestamp of the event
|
||||||
|
* @param {number} event.delta The delta time in milliseconds value used in the update
|
||||||
|
* @param {engine} event.source The source object of the event
|
||||||
|
* @param {string} event.name The name of the event
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired after engine update and all collision events
|
* Fired after engine update and all collision events
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue