html5 javascript physics engine
Matter.js is a 2D physics engine for the web
- Source Code at GitHub
- License MIT
- Documentation
- Changelog
- Development Version (0.8.0 alpha)
197 kb, uncompressed - Minified Version (0.8.0 alpha)
53kb, minified - Edge Version (master)
latest features, may not be stable
Demo
See the full demo for more things to try
Mobile Demo
Try the mobile demo on your mobile device.
Touch and drag to interact, tilt and turn to control gravity.
Install
Download the latest release and include the script in your web page.
You can also install using the package managers Bower and NPM.
For the latest features try the edge version (master) (it may not be fully stable).
<script src="matter-0.8.0.js" type="text/javascript"></script>
bower install matter-js
npm install matter-js
Usage
See the Getting started wiki page for a minimal usage example.
Check out the demo page for more examples and then refer to Demo.js to see how they work.
Some of the demos are also available on codepen, where you can easily experiment with them.
Documentation
See the Matter.js API Docs (v0.8.0)
If you're using the edge version (master) see the API Docs (master).
Features
- Physical properties (mass, area, density etc.)
- Rigid bodies of any convex polygon
- Stable stacking and resting
- Restitution (elastic and inelastic collisions)
- Conservation of momentum
- Friction and resistance
- Constraints
- Gravity
- Composite bodies
- Sleeping and static bodies
- Events
- Collisions (broad, mid and narrow-phase)
- Time scaling (slow-mo, speed-up)
- Canvas renderer (supports vectors and textures)
- WebGL renderer (requires pixi.js)
- World state serialisation (requires resurrect.js)
- MatterTools for creating and testing worlds
- Cross-browser (Chrome, Firefox, Safari, IE8+)
- Mobile-compatible (touch, responsive)
- Original JavaScript physics implementation
Implementation and References
The technical details are in the readme over at GitHub.
For references, see my post on Game physics for beginners.
Changelog and Status
To see what's new or changed in the latest version, see the Changelog
Matter.js is currently only alpha status, meaning the API is still in development and may change occasionally. The library is reasonably stable as-is, but it is not yet feature complete. As the project is open source, contributions are welcome!
Issues
Report issues over at GitHub.
Follow
I'll be posting updates on twitter over at @liabru
License
Matter.js is licensed under The MIT License (MIT)
Copyright (c) 2014 liabru
This license is also supplied with the release and source code.
As stated in the license, absolutely no warranty is provided.