Home

Awesome

<img alt="Matter.js" src="https://brm.io/matter-js/img/matter-js.svg" width="300">

Matter.js is a JavaScript 2D rigid body physics engine for the web

brm.io/matter-js

DemosGalleryFeaturesPluginsInstallUsageExamplesDocsWikiReferencesLicense

Demos

<table> <tr> <td> <ul> <li><a href="https://brm.io/matter-js/demo/#mixed">Mixed Shapes</a></li> <li><a href="https://brm.io/matter-js/demo/#mixedSolid">Solid Shapes</a></li> <li><a href="https://brm.io/matter-js/demo/#svg">Concave SVG Paths</a></li> <li><a href="https://brm.io/matter-js/demo/#terrain">Concave Terrain</a></li> <li><a href="https://brm.io/matter-js/demo/#concave">Concave Bodies</a></li> <li><a href="https://brm.io/matter-js/demo/#compound">Compound Bodies</a></li> <li><a href="https://brm.io/matter-js/demo/#newtonsCradle">Newton's Cradle</a></li> <li><a href="https://brm.io/matter-js/demo/#wreckingBall">Wrecking Ball</a></li> <li><a href="https://brm.io/matter-js/demo/#slingshot">Slingshot Game</a></li> <li><a href="https://brm.io/matter-js/demo/#rounded">Rounded Corners</a></li> <li><a href="https://brm.io/matter-js/demo/#views">Views</a></li> <li><a href="https://brm.io/matter-js/demo/#timescale">Time Scaling</a></li> <li><a href="https://brm.io/matter-js/demo/#manipulation">Body Manipulation</a></li> <li><a href="https://brm.io/matter-js/demo/#compositeManipulation">Composite Manipulation</a></li> </ul> </td> <td> <ul> <li><a href="https://brm.io/matter-js/demo/#raycasting">Raycasting</a></li> <li><a href="https://brm.io/matter-js/demo/#sprites">Sprites</a></li> <li><a href="https://brm.io/matter-js/demo/#pyramid">Pyramid</a></li> <li><a href="https://brm.io/matter-js/demo/#car">Car</a></li> <li><a href="https://brm.io/matter-js/demo/#catapult">Catapult</a></li> <li><a href="https://brm.io/matter-js/demo/#gravity">Reverse Gravity</a></li> <li><a href="https://brm.io/matter-js/demo/#bridge">Bridge</a></li> <li><a href="https://brm.io/matter-js/demo/#avalanche">Avalanche</a></li> <li><a href="https://brm.io/matter-js/demo/#softBody">Basic Soft Bodies</a></li> <li><a href="https://brm.io/matter-js/demo/#cloth">Cloth</a></li> <li><a href="https://brm.io/matter-js/demo/#events">Events</a></li> <li><a href="https://brm.io/matter-js/demo/#collisionFiltering">Collision Filtering</a></li> <li><a href="https://brm.io/matter-js/demo/#chains">Chains</a></li> <li><a href="https://brm.io/matter-js/demo/#ballPool">Ball Pool</a></li> </ul> </td> <td> <ul> <li><a href="https://brm.io/matter-js/demo/#stack">Stack</a></li> <li><a href="https://brm.io/matter-js/demo/#circleStack">Circle Stack</a></li> <li><a href="https://brm.io/matter-js/demo/#compoundStack">Compound Stack</a></li> <li><a href="https://brm.io/matter-js/demo/#restitution">Restitution</a></li> <li><a href="https://brm.io/matter-js/demo/#friction">Friction</a></li> <li><a href="https://brm.io/matter-js/demo/#airFriction">Air Friction</a></li> <li><a href="https://brm.io/matter-js/demo/#staticFriction">Static Friction</a></li> <li><a href="https://brm.io/matter-js/demo/#sleeping">Sleeping</a></li> <li><a href="https://brm.io/matter-js/demo/#beachBalls">Beach Balls</a></li> <li><a href="https://brm.io/matter-js/demo/#stress">Stress 1</a></li> <li><a href="https://brm.io/matter-js/demo/#stress2">Stress 2</a></li> <li><a href="https://brm.io/matter-js/demo/#sensors">Sensors</a></li> </ul> <br> </td> </tr> </table>

Gallery

See how others are using matter.js physics

Features

Install

You can install using package managers npm and Yarn using:

npm install matter-js

Alternatively you can download a stable release or try the latest experimental alpha build (master) and include the script in your web page:

<script src="matter.js" type="text/javascript"></script>

Performance with other tools (e.g. Webpack, Vue etc.)

Bundlers and frameworks may reduce real-time performance when using their default configs, especially in development modes.

When using Webpack, the default sourcemap config can have a large impact, for a solution see issue.

When using Vue.js, watchers can have a large impact, for a solution see issue.

Usage

Visit the Getting started wiki page for a minimal usage example which should work in both browsers and Node.js.
Also see the Running and Rendering wiki pages, which show how to use your own game and rendering loops.

Tutorials

See the list of tutorials.

Examples

See the examples directory which contains the source for all demos.
There are even more examples on codepen.

Plugins

The engine can be extended through plugins, see these resources:

Documentation

See the API Documentation and the wiki

Building and Contributing

To build you must first install node.js, then run

npm install

This will install the required build dependencies, then run

npm run dev

to spawn a development server. For information on contributing see CONTRIBUTING.md.

Changelog

To see what's new or changed in the latest version, see the changelog.

References

See the wiki page on References.

License

Matter.js is licensed under The MIT License (MIT)
Copyright (c) 2014 Liam Brummitt

This license is also supplied with the release and source code.
As stated in the license, absolutely no warranty is provided.