Skip to content

Commit

Permalink
added engine beforeSolve event, closes #1173
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Mar 18, 2023
1 parent 812f8af commit 8dd0e99
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 8dd0e99

Please sign in to comment.