About this project

Matter.js is a JavaScript 2D rigid body physics engine for the web, described as an original implementation rather than a port. It is distributed via npm and Yarn (npm install matter-js) or as a script tag, and supports browsers and Node.js, including mobile touch and responsive layouts. Core capabilities listed by the project include rigid bodies, compound and composite bodies, concave and convex hulls, physical properties such as mass, area and density, restitution for elastic and inelastic collisions, multi-phase collision detection (broad, mid and narrow), stable stacking and resting, conservation of momentum, friction and resistance, events, constraints, gravity, sleeping and static bodies, rounded corners (chamfering), views with translate and zoom, collision queries such as raycasting and region tests, time scaling for slow motion or speed-up, and a canvas renderer supporting vectors and textures. The engine can be extended through plugins, with wiki pages covering using and creating plugins, a plugin list and a boilerplate repository. MatterTools is offered for creating, testing and debugging worlds, and world state serialisation is possible with resurrect.js. The README links to an extensive set of live demos covering mixed and solid shapes, concave SVG paths and terrain, compound bodies, Newton's cradle, wrecking ball, slingshot, rounded corners, views, time scaling, body and composite manipulation, raycasting, sprites, pyramid, car, catapult, reverse gravity, bridge, avalanche, soft bodies, cloth, events, collision filtering, chains, ball pool, stacks, restitution, friction variants, sleeping, beach balls, stress tests and sensors. A gallery lists sites and projects using the engine, including work by Patrick Heng, Nice and Serious, Goodness, New Company, Google, Nathan Gordon, Lab212, Photon Storm (Phaser), Jessica Walsh, Fuse, überdosis and sabato studio. Usage guidance points to wiki pages for getting started, running and rendering, plus tutorials, an examples directory containing the demo sources and additional CodePen examples. API documentation is hosted separately. Building requires Node.js and pnpm, followed by pnpm install and pnpm run start to launch a development server; contribution notes are in CONTRIBUTING.md. The project notes that bundlers and frameworks may reduce real-time performance with default configurations, particularly in development modes, citing Webpack sourcemap settings and Vue.js watchers as examples with linked issue discussions. Matter.js is licensed under the MIT License, copyright 2014 Liam Brummitt, with no warranty provided.