mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-30 10:20:52 -05:00
added event.timestamp and event.delta to collision events, closes #368
This commit is contained in:
parent
96557859f9
commit
2af54d51cd
1 changed files with 21 additions and 6 deletions
|
@ -149,8 +149,13 @@ var Body = require('../body/Body');
|
|||
Sleeping.afterCollisions(pairs.list);
|
||||
|
||||
// trigger collision events
|
||||
if (pairs.collisionStart.length > 0)
|
||||
Events.trigger(engine, 'collisionStart', { pairs: pairs.collisionStart });
|
||||
if (pairs.collisionStart.length > 0) {
|
||||
Events.trigger(engine, 'collisionStart', {
|
||||
pairs: pairs.collisionStart,
|
||||
timestamp: timing.timestamp,
|
||||
delta: delta
|
||||
});
|
||||
}
|
||||
|
||||
// iteratively resolve position between collisions
|
||||
var positionDamping = Common.clamp(20 / engine.positionIterations, 0, 1);
|
||||
|
@ -178,11 +183,21 @@ var Body = require('../body/Body');
|
|||
Engine._bodiesUpdateVelocities(allBodies);
|
||||
|
||||
// trigger collision events
|
||||
if (pairs.collisionActive.length > 0)
|
||||
Events.trigger(engine, 'collisionActive', { pairs: pairs.collisionActive });
|
||||
if (pairs.collisionActive.length > 0) {
|
||||
Events.trigger(engine, 'collisionActive', {
|
||||
pairs: pairs.collisionActive,
|
||||
timestamp: timing.timestamp,
|
||||
delta: delta
|
||||
});
|
||||
}
|
||||
|
||||
if (pairs.collisionEnd.length > 0)
|
||||
Events.trigger(engine, 'collisionEnd', { pairs: pairs.collisionEnd });
|
||||
if (pairs.collisionEnd.length > 0) {
|
||||
Events.trigger(engine, 'collisionEnd', {
|
||||
pairs: pairs.collisionEnd,
|
||||
timestamp: timing.timestamp,
|
||||
delta: delta
|
||||
});
|
||||
}
|
||||
|
||||
// clear force buffers
|
||||
Engine._bodiesClearForces(allBodies);
|
||||
|
|
Loading…
Reference in a new issue