A multi-core friendly C++ rigid body physics and collision detection library for games and VR applications.
liabru/matter-js
A 2D rigid body physics engine for the web, written in JavaScript and running in browsers and Node.js.
- Stars
- 18,600
- Forks
- 2,000
- Open issues
- 280
- Last commit
- last month
What is it?
Matter.js is a 2D rigid body physics engine written in JavaScript for the web. It handles collisions, gravity, friction, restitution and constraints, so developers can add believable physical motion to canvas-based games, interactive graphics and simulations without writing their own physics code.
The engine supports rigid, compound and concave bodies, including shapes built from SVG paths and terrain. It provides collision queries such as raycasting and region tests, time scaling for slow-motion effects, views with zoom and translation, and a canvas renderer that can draw vectors and textures. Bodies can be put to sleep when resting, and world state can be serialised with the help of resurrect.js.
Matter.js runs in Chrome, Firefox, Safari and IE8+, as well as in Node.js. It is installable through npm or Yarn, can be included with a single script tag, and has a plugin system along with a broad set of demos and an API reference.
Key features
- 01Rigid, compound and concave bodies with collision detection
- 02Gravity, friction, restitution and constraints
- 03Raycasting and region queries for collision checks
- 04Canvas renderer supporting vector shapes and textures
- 05Time scaling, views with zoom, and sleeping bodies
- 06Plugin system, runs in browsers and Node.js
Use cases
- Building 2D physics games such as slingshot or stacking puzzles in the browser
- Adding interactive physical motion to canvas-based web animations
- Running headless physics simulations in Node.js
- Prototyping mechanical systems like bridges, cars or pendulums
Quick start
- 1
Install the package from npm
npm install matter-js - 2
Follow the Getting started wiki page for a minimal usage example
Things to know
- The README labels the alpha build from master as experimental.
In collections
Topics
FAQ
- What is matter-js?
- A 2D rigid body physics engine for the web, written in JavaScript and running in browsers and Node.js. Matter.js is a 2D rigid body physics engine written in JavaScript for the web. It handles collisions, gravity, friction, restitution and constraints, so developers can add believable physical motion to canvas-based games, interactive graphics and simulations without writing their own physics code.
- Is matter-js free to use? What license does it have?
- matter-js is open source under the MIT license. Check the license terms before using it in commercial products.
- Is matter-js still maintained?
- Updated within 6 months. The last commit to matter-js was on Sep 30, 2026.
- What can I use matter-js for?
- Building 2D physics games such as slingshot or stacking puzzles in the browser Adding interactive physical motion to canvas-based web animations Running headless physics simulations in Node.js Prototyping mechanical systems like bridges, cars or pendulums
- How do I install matter-js?
- Install the package from npm: npm install matter-js Follow the Getting started wiki page for a minimal usage example
- Where can I get matter-js?
- The source code and installation instructions are on GitHub: https://github.com/liabru/matter-js
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
An ECS-driven 2D and 3D physics engine built specifically for the Bevy game engine in Rust.
A JavaScript/TypeScript rewrite of the Box2D 2D physics engine for HTML5 game development.
A general-purpose physics engine for fast, accurate simulation of articulated bodies in contact, widely used in robotics and machine learning research.
Rust-based 2D and 3D physics engines for games, animation, and robotics, with C, Python, JavaScript, and Bevy bindings.
Bullet Physics SDK, a C++ library for real-time collision detection and multi-physics simulation used in games, VR, robotics and machine learning.