matter-js README

The project's README from github.com/liabru/matter-js. As one markdown file: README.md.

Matter.js

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

brm.io/matter-js

Demos ・ Gallery ・ Features ・ Plugins ・ Install ・ Usage ・ Examples ・ Docs ・ Wiki ・ References ・ License

Demos


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.

matter-js (liabru/matter-js)

Searching Database…

18.5K ·GitHub
What is this?Matter.js is a JavaScript 2D rigid body physics engine for the web — a physics simulation you drop into web pages and Node.js apps.
Is it a physics library I call from my own code, or more of a ready-made game engine?It's a library you drive from your own JavaScript, not a full game engine. It ships a canvas renderer, but the docs show how to plug it into your own game and rendering loops.
How do I add it to a web project?Install with npm or Yarn (npm install matter-js), or download a stable release and include the script in your page. There are no runtime dependencies to set up first.
Any gotchas when running it inside modern bundlers and frameworks?Yes: default bundler and framework configs can hurt real-time performance, especially in development. The README specifically calls out Webpack sourcemaps and Vue.js watchers as having a large impact.
Does it only run in the browser, or can I use it on the server and on mobile too?Both browsers and Node.js are supported — Chrome, Firefox, Safari and even IE8+ — and it is mobile-compatible with touch and responsive support.
What does the physics simulation actually cover?Rigid, compound and composite bodies, concave and convex hulls, restitution, friction, constraints, gravity, sleeping and static bodies, collision queries like raycasting and region tests, and time scaling for slow-motion effects.
Is it a port of another physics engine?No — the README points out it is an original JavaScript implementation, not a port.
Can I extend the engine with plugins?Yes, it has a plugin system. The README links guides on using and creating plugins, a list of existing plugins, and a matter-plugin-boilerplate starter.
What is MatterTools?A set of tools bundled with the engine for creating, testing and debugging physics worlds.
Creator
liabru
Size
22.3 MB
Stars
18.5K
Updated
CommitSep 30
Age
12y
Commits · 90 Days