Matter-js is a 2D rigid body physics engine written in JavaScript for simulating realistic physical interactions, collisions, and dynamics in web browsers. It functions as a web physics simulation library that calculates motion, gravity, and constraints for objects rendered on a web canvas.
The library includes a built-in canvas physics visualizer to draw physical bodies, joints, and constraints for debugging and gameplay. It distinguishes itself through a plugin system that supports recursive dependency resolution and internal method patching to inject custom logic into the engine's execution chain.
The engine covers a broad range of simulation capabilities, including rigid body dynamics, environmental force simulation, and the management of complex composite shapes. It provides systems for collision detection and resolution using raycasting and bounding boxes, as well as constraint solving for physical joint connections. Additional tools include world state serialization, mouse-based object manipulation, and real-time performance monitoring.