Skip to content

Commit 21a6458

Browse files
committed
Added new collision pair type defs
1 parent 294ca71 commit 21a6458

5 files changed

Lines changed: 46 additions & 3 deletions

File tree

src/physics/matter-js/events/COLLISION_ACTIVE_EVENT.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* @typedef {object} Phaser.Physics.Matter.Events.CollisionActiveEvent
99
*
10-
* @property {array} pairs - A list of all affected pairs in the collision.
10+
* @property {Phaser.Types.Physics.Matter.MatterCollisionData[]} pairs - A list of all affected pairs in the collision.
1111
* @property {number} timestamp - The Matter Engine `timing.timestamp` value for the event.
1212
* @property {any} source - The source object of the event.
1313
* @property {string} name - The name of the event.

src/physics/matter-js/events/COLLISION_END_EVENT.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* @typedef {object} Phaser.Physics.Matter.Events.CollisionEndEvent
99
*
10-
* @property {array} pairs - A list of all affected pairs in the collision.
10+
* @property {Phaser.Types.Physics.Matter.MatterCollisionData[]} pairs - A list of all affected pairs in the collision.
1111
* @property {number} timestamp - The Matter Engine `timing.timestamp` value for the event.
1212
* @property {any} source - The source object of the event.
1313
* @property {string} name - The name of the event.

src/physics/matter-js/events/COLLISION_START_EVENT.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* @typedef {object} Phaser.Physics.Matter.Events.CollisionStartEvent
99
*
10-
* @property {array} pairs - A list of all affected pairs in the collision.
10+
* @property {Phaser.Types.Physics.Matter.MatterCollisionData[]} pairs - A list of all affected pairs in the collision.
1111
* @property {number} timestamp - The Matter Engine `timing.timestamp` value for the event.
1212
* @property {any} source - The source object of the event.
1313
* @property {string} name - The name of the event.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @typedef {object} Phaser.Types.Physics.Matter.MatterCollisionData
3+
* @since 3.22.0
4+
*
5+
* @property {boolean} collided - Have the pair collided or not?
6+
* @property {MatterJS.Body} bodyA - A reference to the first body involved in the collision.
7+
* @property {MatterJS.Body} bodyB - A reference to the second body involved in the collision.
8+
* @property {MatterJS.Body} axisBody - A reference to the dominant axis body.
9+
* @property {number} axisNumber - The index of the dominant collision axis vector (edge normal)
10+
* @property {number} depth - The depth of the collision on the minimum overlap.
11+
* @property {MatterJS.Body} parentA - A reference to the parent of Body A, or to Body A itself if it has no parent.
12+
* @property {MatterJS.Body} parentB - A reference to the parent of Body B, or to Body B itself if it has no parent.
13+
* @property {vector} normal - The collision normal, facing away from Body A.
14+
* @property {vector} tangent - The tangent of the collision normal.
15+
* @property {vector} penetration - The penetration distances between the two bodies.
16+
* @property {vector[]} supports - An array of support points, either exactly one or two points.
17+
* @property {number} inverseMass - The resulting inverse mass from the collision.
18+
* @property {number} friction - The resulting friction from the collision.
19+
* @property {number} frictionStatic - The resulting static friction from the collision.
20+
* @property {number} restitution - The resulting restitution from the collision.
21+
* @property {number} slop - The resulting slop from the collision.
22+
*/
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @typedef {object} Phaser.Types.Physics.Matter.MatterCollisionPair
3+
* @since 3.22.0
4+
*
5+
* @property {string} id - The unique auto-generated collision pair id. A combination of the body A and B IDs.
6+
* @property {MatterJS.Body} bodyA - A reference to the first body involved in the collision.
7+
* @property {MatterJS.Body} bodyB - A reference to the second body involved in the collision.
8+
* @property {array} activeContacts - An array containing all of the active contacts between bodies A and B.
9+
* @property {number} separation - The amount of separation that occured between bodies A and B.
10+
* @property {boolean} isActive - Is the collision still active or not?
11+
* @property {boolean} confirmedActive - Has Matter determined the collision are being active yet?
12+
* @property {boolean} isSensor - Is either body A or B a sensor?
13+
* @property {number} timeCreated - The timestamp when the collision pair was created.
14+
* @property {number} timeUpdated - The timestamp when the collision pair was most recently updated.
15+
* @property {Phaser.Types.Physics.Matter.MatterCollisionData} collision - The collision data object.
16+
* @property {number} inverseMass - The resulting inverse mass from the collision.
17+
* @property {number} friction - The resulting friction from the collision.
18+
* @property {number} frictionStatic - The resulting static friction from the collision.
19+
* @property {number} restitution - The resulting restitution from the collision.
20+
* @property {number} slop - The resulting slop from the collision.
21+
*/

0 commit comments

Comments
 (0)