Matter.js Contact Point Object Explained

In Matter.js, collision handling relies on contact points to track and resolve physical interactions between colliding rigid bodies. When two bodies intersect, the engine generates contact pairs that contain an array of individual contact objects. This article breaks down the exact properties stored inside each contact point object in Matter.js, explaining how the engine uses these values to calculate collision responses, restitution, and friction.

The Structure of a Matter.js Contact Object

At its core, a contact point object in Matter.js is lightweight and instantiated via the internal Contact.create() method. Each contact object maintains three primary properties:

How Matter.js Utilizes Contact Points

During the narrow-phase collision detection stage, the engine determines the overlap geometry and extracts support vertices. For every active contact between two colliding bodies, a contact point object is created or updated and placed inside the contacts array of a collision Pair object (pair.contacts).

During the constraint resolution and integration phases, the physics engine iterates over these contacts. Instead of recalculating forces from scratch every step, Matter.js checks the stored normalImpulse and tangentImpulse. By persisting and updating these impulse values across engine ticks, the engine maintains stability in resting contacts, avoids jitter, and accurately simulates friction and bouncing behavior.