Build browser-based games with realistic object physics and collisions.
Create interactive animations where objects fall, bounce, and stack naturally.
Develop visual experiments and simulations like Newton's cradle or cloth dynamics.
Add physics-based interactions to web pages and interactive art projects.
Matter.js is a JavaScript library for simulating 2D physics in web browsers and in Node.js. Physics simulation means the library calculates how objects move, collide, bounce, and fall under the influence of gravity, allowing developers to create games, interactive animations, and visual experiments where objects behave like they would in the real world. The library supports rigid bodies (solid objects that don't deform), compound bodies (complex shapes built from simpler ones), concave and convex shapes, physical properties such as mass and density, friction, air resistance, and collision detection. It also handles constraints (like ropes or joints connecting objects), sleeping (pausing simulation for objects that have stopped moving to save processing power), raycasting (detecting what a ray of light would hit), and time scaling (slowing down or speeding up the simulation). There is a built-in canvas renderer that draws the simulation as 2D graphics, and the library works across major browsers as well as on mobile devices via touch input. Matter.js can be installed via npm or included directly in a webpage via a script tag. The engine can be extended through a plugin system. The project includes a large set of demo scenes, things like Newton's cradle, a wrecking ball, cloth simulation, and various stacking challenges, both as code examples and as a live demo gallery.
Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.