0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

added engine beforeSolve event, closes #1173

This commit is contained in:
liabru 2023-03-18 11:07:20 +00:00
parent 812f8af1be
commit 8dd0e99b79

View file

@ -72,7 +72,7 @@ var Body = require('../body/Body');
/**
* 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.
* @method update
* @param {engine} engine
@ -128,6 +128,8 @@ var Body = require('../body/Body');
Engine._bodiesUpdate(allBodies, delta);
}
Events.trigger(engine, 'beforeSolve', event);
// update all constraints (first pass)
Constraint.preSolveAll(allBodies);
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
*/
/**
* 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
*