Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

matter-js

liabru262.4kMIT0.20.0TypeScript support: definitely-typed

a 2D rigid body physics engine for the web

javascript, canvas, html5, physics, physics engine, game engine, rigid body physics

readme

Matter.js

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

brm.io/matter-js

DemosGalleryFeaturesPluginsInstallUsageExamplesDocsWikiReferencesLicense

Demos


See how others are using matter.js physics

Features

  • Rigid bodies
  • Compound bodies
  • Composite bodies
  • Concave and convex hulls
  • Physical properties (mass, area, density etc.)
  • Restitution (elastic and inelastic collisions)
  • Collisions (broad-phase, mid-phase and narrow-phase)
  • Stable stacking and resting
  • Conservation of momentum
  • Friction and resistance
  • Events
  • Constraints
  • Gravity
  • Sleeping and static bodies
  • Plugins
  • Rounded corners (chamfering)
  • Views (translate, zoom)
  • Collision queries (raycasting, region tests)
  • Time scaling (slow-mo, speed-up)
  • Canvas renderer (supports vectors and textures)
  • MatterTools for creating, testing and debugging worlds
  • World state serialisation (requires resurrect.js)
  • Cross-browser and Node.js support (Chrome, Firefox, Safari, IE8+)
  • Mobile-compatible (touch, responsive)
  • An original JavaScript physics implementation (not a port)

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.

changelog

0.20.0 (2024-06-23)

  • added event passive options to Matter.Mouse, closes #930, closes #976 (e888f3c), closes #930 #976
  • added arrow key navigation of examples in development demo (45cad77)
  • added body removal to Example.remove (1209e88)
  • added Constraint.currentLength, closes #1184 (812f8af), closes #1184
  • added doc and warning for Bodies.trapezioid slope parameter range, closes #1075 (7ea5bc1), closes #1075
  • added docs for body.chamfer property, closes #1059 (5ed985d), closes #1059
  • added engine beforeSolve event, closes #1173 (8dd0e99), closes #1173
  • added event.timestamp and event.delta to collision events, closes #368 (2af54d5), closes #368
  • added Example.renderResize (b88c82f)
  • added Example.stress4 (0f0ac93)
  • added Example.substep (205aaa5)
  • added high delta warning to Matter.Engine (72e6e89)
  • added local pairs functions in Pairs.update (e9da32c)
  • added new Matter.Runner with default fixed timestep (3e61951)
  • added pixel ratio scaling to render debug stats (7ec38a1)
  • added render.options.wireframeStrokeStyle, closes #406 (401553d), closes #406
  • added Render.setSize, closes #955, closes #595 (fc05839), closes #955 #595
  • added repeats and updates options to test tools (6142991)
  • added updates per frame to Matter.Render debug (a5b5767)
  • changed Composte.removeComposite and Composte.removeBody to reset body.sleepCounter (6d10c3d)
  • changed Pair.id format to use shorter ids (5b6f30b)
  • fixed collision events for sleeping pairs, closes #1077 (51f49ce), closes #1077
  • fixed missing mouse.sourceEvents.mousewheel, closes #1146 (272049a), closes #1146
  • fixed Body.setStatic when applied multiple times, closes #641 (9655785), closes #641
  • fixed compare tool layer order in demo testbed (a3e801a) (0cc4d96)
  • fixed Runner.stop docs re. runner.enabled, closes #586, closes #1054 (2ecc563), closes #586 #1054
  • improved Example.substep comments (8046341)
  • improved Matter.Runner (b8a1563) (7206600)
  • improved Matter.Runner docs (283cd96) (dc693e7) (6e302a8)
  • improved test comparison report (962fba5) (2cc1c1c)
  • improved body.parts docs (013698b) (411af06), closes #600 (c1f9584), closes #600
  • optimised Collision._findSupports (653a110)
  • optimised Collision.collides (6f8a54b)
  • optimised contacts and supports memory and gc use (97d502e)
  • optimised pairs and collisions memory and gc use (f9208df)
  • optimised Resolver.solvePosition (89963f7)
  • optimised Resolver.solveVelocity (182ba90)
  • preserve pair.contacts order (e891d37)
  • reduced canvas hit testing in demo when using matter-tools (da99acb)
  • removed redundant runner.isFixed from examples (aba0e9e)
  • removed Collision._projectToAxis (4c56e5b)
  • removed pair.confirmedActive (72bc203)
  • renamed Composites function xx and yy params, closes #1095 (6bda7e8), closes #1095
  • updated development demo render options (0b131a4)
  • updated benchmark tests (e668c02)

0.19.0 (2023-02-16)

See the release readme for further information.

  • added readme note about vue watchers (035481c)
  • added readonly body.deltaTime (0784a5b)
  • added speed setters to Body.set (3ff6ff4)
  • added support for Matter.Runner and Matter.Render in tests (7d7bad0)
  • added updateVelocity argument to Body.setPosition, Body.setAngle, Body.translate, Body.rotate (db8b73f)
  • changed engine collisionStart event to trigger after resolving and after updating body velocities (70600a8)
  • changed examples to be delta independent (d7e4f58)
  • deprecated render.controller property (04d229e)
  • derived velocity from position in setters (b6de9ed)
  • fixed issues with engine event.delta (6f5af77)
  • handle null constraint points in Constraint.pointAWorld and Constraint.pointBWorld (e414464)
  • improved Body.applyForce docs (3a8264c)
  • improved delta factors in resolver and constraint stiffness (9dc6be7)
  • improved Matter.Body docs for functions and properties including readonly (85a9eb2)
  • improved Matter.Engine docs (50fc8f2)
  • improved slingshot example constraint (c6a1a6d)
  • improved delta consistency (87af8a1)
  • improved Example.newtonsCradle (b2bd492)
  • removed render element warning (459425b)
  • removed unused delta params (a572968)
  • updated body docs (6bb2855)
  • updated body velocity properties after resolving (d52f7e6)
  • updated Example.manipulation (5ddac71)
  • updated Example.ragdoll (ec38638)
  • updated Example.staticFriction and Example.timeScale (11d5e73)
  • updated Matter.Body docs (db780c3)
  • updated timing improvements (10a2a07)
  • used Body.getVelocity in Matter.Render (bf90bdd)
  • used speed getter in Matter.Sleeping and Matter.Render (6579dfd)

0.18.0 (2021-12-15)

0.17.1 (2021-04-14)

  • deprecate Engine.run alias replaced by Runner.run (5817046)

0.17.0 (2021-04-11)

  • add Common.setDecomp and Common.getDecomp (313c150)
  • add demo build config and refactor demo (653a647)
  • add docs for all Matter.Render options (ec3eecc)
  • add title to all examples (f4d72ba)
  • added Common.deprecated (ffa3193)
  • added Common.warnOnce (6957dbf)
  • added Date.now fallback to Common.now, closes #739 (c06c107), closes #739
  • added debug stats and performance monitoring to Matter.Render (119881b)
  • added doc watch script (164456b)
  • added docs for additional engine timing and render properties (8017bdb)
  • added Example.stats (9915007)
  • added lastDelta and lastElapsed to engine.timing (6dc703f)
  • build demo (0816454)
  • change all examples to use Composite.add instead of the alias World.add (a3f298f)
  • changed engine.broadphase to engine.grid (b74e400)
  • changed Example.views to use render events (3ac3498)
  • changed world.gravity to engine.gravity (6abb3b7)
  • deprecated Composites.car and added to car example (cd9c5d4)
  • deprecated Composites.newtonsCradle and added to newtonsCradle example (9ad980b)
  • deprecated Composites.softBody and added to softBody and cloth examples (818f354)
  • improve Render.debug (1753bf0)
  • migrate Matter.World to the equivalent Matter.Composite (5dbec9b)
  • remove deprecated backwards compatibility engine events from Matter.Runner (76bf80e)
  • remove deprecated backwards compatibility render integration from Matter.Engine (1aa8ed0)
  • remove deprecated backwards compatibility render integration from Matter.Runner (6805f85)
  • remove deprecated Matter.Metrics (63a9e98)
  • remove deprecated Matter.RenderPixi (08a515b)
  • remove unused render shadow function (e49834d)
  • run all examples in browser tests (5734bfd)
  • set render showDebug option on examples stress and stress2 (f2ef3aa)
  • update matter-tools (f8d366a)

0.16.1 (2021-01-31)

  • add log capture and reporting in tests (7bfd3c2)
  • add matter-wrap as dev dependency (ef7c4c6)
  • catch missing plugin require in examples (1ba1255)
  • change example matter-wrap require precedence (aa1e4e7)
  • change perf threshold in test (7b00354)
  • change test worker decomp require (5e746b0)
  • disable jest cache (8ee0ebb)
  • enable useful dev server features (839f7d9)
  • fix decomp require and improve warning message (e87f64a)
  • fix dev server externals (1f2f9fe)
  • fix named require in test (92080ff)
  • improve CI speed (1af64eb)
  • improve docs for Bodies.fromVertices (2ade78f)
  • improve stack examples with exact contact (522f4e8)
  • improve test report log (b5326f8)

0.16.0 (2021-01-17)

  • added removeDuplicatePoints option from poly-decomp 0.3.0 to Bodies.fromVertices (#639, 947cb97, a9694e6)
  • added support for > and >= operators in plugin version ranges (0792716)
  • added support for example versioning in tests (31d0ace)
  • added version targets for examples (142b7de)
  • added warning check on browser tests (12377cc)
  • changed svg and terrain example to use fetch (5551cd5)
  • changed deprecated comments to avoid confusion (1e73cab)
  • fixed poly-decomp external require (882e07c)
  • removed bower.json (f71d4c0)
  • removed unused dev dependency run-sequence (be592fd)
  • updated dev dependencies (151eb30)
  • updated matter-tools (5c66458)
  • updated matter-tools (33e8fe8)
  • updated demo matter-tools (a694ae5)
  • updated demo pathseg (9c5325b)
  • updated readme (3089b41)

0.15.0 (2020-12-24)

  • add window global, stub require and handle bad values in test tools (497ac80)
  • added Body.setCentre, closes #684, closes #461, closes #679 (2ec247b), closes #684 #461 #679
  • added browser tests (ceb7cd5)
  • Added build comparison tools and tests (b7c938a)
  • added check for window in Common.now (9ef9d02)
  • added comparison output file option to test tools (45aae25)
  • Added config and test files to lint (21e4ea6)
  • added Constraint.pointAWorld and Constraint.pointBWorld (3c32969)
  • added examples to dev server bundle and commit built examples (fe80478)
  • added module export to examples (f9ea799)
  • added overlap metric to test tools (3fd674d)
  • added release scripts (341c247)
  • added tag push to release task (060283b)
  • added timing to engine snapshot (e0cdbb8)
  • Added watch content base to dev server (f471d4e)
  • added webpack build script (046013e)
  • changed alpha build configuration (182c84a)
  • changed demo to auto populate examples with sourceLink and init (5b0d34b)
  • changed demo to serve without sub-directory (823bbc0)
  • changed docs build config (864452d)
  • changed example tests to use jest (104d319)
  • fix decomp import in Bodies.fromVertices (94e9614)
  • fix decomp require (0af1645)
  • fix issues with render pixel ratio, closes #686, closes #687 (d577477), closes #686 #687
  • fix lint (5a0079d)
  • fix lint issues (9ca21c1)
  • fix path to build in test worker (fcdb4fa)
  • fix preversion script (c368c14)
  • fix terrain example module export (4a967ec)
  • Fix typo in docs (c486635)
  • fixed plugins in compare (82bb415)
  • implemented threaded comparison testing (285d70d)
  • Optimized Body's hidden class (b3220cf)
  • Optimized Events.trigger method when no event is emitted (b17cb48)
  • remove gulp (6a28090)
  • remove old demo libs (13c7eb5)
  • removed unused gulp release tasks (e5a7311)
  • removed yuidocjs dev dependency (ee848d2)
  • Set loose build version on dev server (1fcf292)
  • update build script (90abab6)
  • update default render theme (d258411)
  • update demo and example render styles (6dd5ec5)
  • update dependencies (e1e058c) (5f5b8a1)
  • update examples build config and scripts (69afb11)
  • update package lock (ac3da07)
  • updated build scripts (6b698ea)
  • updated ci (288b9cd)
  • updated docs (50cf171)
  • updated readme (ea5c012) (61b1963)

0.14.2 (2018-06-11)

  • added missing polyfill warning to Svg.pathToVertices (511de5b)
  • fix Composite.bounds global issue, closes #627, closes #544 (f7f77b4), closes #627 #544
  • fix docs for Vector.angle, closes #471 (db30d79), closes #471
  • Fixed constraint pointB documentation (0b5ce1d)
  • fixed require for external libraries, closes #629, closes #559, closes #593, closes #365, closes #62 (0cf97f5), closes #629 #559 #593 #365 #629
  • remove browserify-shim (e3c176e)
  • updated pathseg library, closes #548, closes #602, closes #424 (1e5758f), closes #548 #602 #424

0.14.1 (2018-01-10)

  • fix Common.isElement on node, closes #535 (ec38eeb), closes #535

0.14.0 (2017-11-30)

  • added .eslintignore (2279e15)
  • added examples build task (6108a31)
  • added missing docs for Matter.World aliases (841bf97)
  • added Query.collides, closes #478 (6593a72), closes #478
  • change examples to render using a fixed resolution (0895d81)
  • Do not warn on missing render.element if the canvas is already parented (because it was passed in at (a529ec9)
  • fix point argument of Body.scale, closes #428 (894c1ef), closes #428
  • fix Body.scale for compound bodies (50a89d0)
  • fix centroid for static compound bodies, closes #483 (ece66e6), closes #483
  • fix Common.isElement, closes #501, closes #507, closes #459, closes #468, closes #517 (18a0845), closes #501 #507 #459 #468 #517
  • fix inertia change in Body.setMass, closes #378 (f7d1877), closes #378
  • fix Vertices.chamfer radius argument, closes #467 (3bceef4), closes #467
  • improved docs for constraints on compound bodies, closes #442 (3307760), closes #442
  • moved all private functions to module namespaces (64be5a5)
  • moved private Matter.Engine functions on to namespace, closes #523 (9eae36f), closes #523
  • remove spelling mistake (e5c4b47)

0.13.0 (2017-07-06)

  • added Composite.bounds (79ffcf8)
  • added constraint damping (44c4d1f)
  • added constraint.render.type and constraint.render.anchor (0952516)
  • added Example.constraints (b93c08f)
  • added Example.doublePendulum (a7aa47d)
  • added Examples.ragdoll (48611c5)
  • added optional output argument to Vector.rotate (59d62be)
  • added rotation point parameter to Body.rotate, closes #410 (749ed50), closes #410
  • added second pass for constraint solving (f49d053)
  • change constraint solve order (a5bd6b2)
  • changed lint rules (d1fbe95)
  • fix constraint.angularStiffness (ab0283b)
  • fix Example.collisionFiltering rendering (74a7cfc)
  • fix lint errors (774d8bc)
  • fix soft body stiffness (1bae2de)
  • fixed Common.now (2b76c4c)
  • fixed constraint torque calculation (a8d1950)
  • fixed constraint torque calculation (068fdc0)
  • fixed Examples.compound constraint offset (e6babf0)
  • fixed various constraints in examples (ac67ef8)
  • fixed various problems with constraints (26a60e4)
  • implemented constraint warming (daf26af)
  • improved Example.car using pin constraint (130e6b3)
  • improved Example.catapult using pin constraint (0e15099)
  • improved Example.chains using pin constraint (9d2f0ff)
  • improved Examples.bridge (b277b39)
  • improved Examples.bridge (b6e5973)
  • improved position resolver (71998a0)
  • improved spring and pin rendering (837c43b)
  • refactored Common.isElement (295cffe)
  • removed Common.shadeColor (d63b0c2)
  • tweaked Example.doublePendulum (4894008)
  • update alpha build (fe9b05d)
  • update alpha build (b874f4d)
  • update alpha build (08aa3f2)
  • update readme and remove redundant plugins (2560a68)
  • Update README.md (4168d3c)
  • updated license and contributing (d2af721)
  • updated readme (26c1200)
  • upgraded matter-tools (477f2d7)
  • upgraded matter-wrap (c9294eb)

0.12.0 (2017-02-02)

  • add poly-decamp require shim (c72a9d0)
  • added body.plugin, composite.plugin, constraint.plugin, engine.plugin properties (b353393)
  • added Render.lookAt (47443b3)
  • added Render.startViewTransform and Render.endViewTransform (c8e5d5c)
  • change Matter.MouseConstraint to use engine beforeUpdate event, closes #73 (ffb128c), closes #73
  • changed default render styles (719ad64)
  • changed plugins to use body.plugin (3fdf343)
  • fix Body.setStatic(body, false), closes #187 (a815ce4), closes #187
  • fix build temporarily (805ff2a)
  • fix lint (0ce686d)
  • fix lint (714b8ae)
  • fix Render.grid (dd83386)
  • fix test npm script (6285df9)
  • fix v8 optimisation issues (86c4a61)
  • Fixes #220 (74de894), closes #220
  • improved demo and examples (1a40f27)
  • improved demo and examples (ace1a9f)
  • improved demo and examples (8cdbb38)
  • Update to latest poly-decomp.js API (3d8f88e)
  • updated alpha build (6c19f0b)
  • updated dependencies (8c140bd)
  • updated matter-tools (def8d22)

0.11.1 (2016-11-09)

  • added derequire to build (ded796c)

0.11.0 (2016-11-04)

  • add logo to readme (d54dec3)
  • added docs for Matter.Plugin with tweaks (3883981)
  • added Example.attractors (758bbe8)
  • added Matter.before, Matter.after, Common.chainPathBefore, Common.chainPathAfter, Common.get, Common (50ad7ca)
  • added Matter.Plugin initial implementation (e84c537)
  • added note in docs about vertices order (ad033f5)
  • added plugin status logging (51b7b1d)
  • added plugins matter-attractors, matter-gravity, matter-world-wrap, removed test plugins (59bfa0b)
  • change plugins to use best practices (37d4258)
  • change travis node version to latest stable (ee33686)
  • changed naming approach for prerelease versions (83ae546)
  • fix build flags (29d182c)
  • fix build task for travis (6aa3661)
  • fix gravity reset in demo (c00df81)
  • fix gulp build version replacement (faf6bec)
  • fix Matter.Mouse when element does not have fixed dimensions, closes #73 (1340159), closes #73
  • fix release tasks (549983d)
  • fix requestAnimationFrame polyfill for Matter.Runner, closes #252 (7c8f6ce), closes #252
  • fix tests (54e7d9c)
  • fixed Body.create with no options (0e5a457)
  • fixed issue with Matter.RenderPixi not being cleared when bodies removed, closes #218 (4972af8), closes #218
  • fixed various Matter.Plugin issues (05d0961)
  • improve docs (9856e3c)
  • improved logging (d4d64ed)
  • Limit packaging extraneous files (3accec6)
  • Merge branch 'jackismissing-master' (3452465)
  • Merge branch 'master' of https://github.com/jackismissing/matter-js into jackismissing-master (ba19130)
  • Merge branch 'plugins' (60d0839)
  • Merge pull request #1 from jackismissing/jackismissing-patch-1 (46a2bf6)
  • Merge pull request #244 from MarkHerhold/master (3449ca5)
  • refactor plugin system (8da170f)
  • refactored plugins (b4a3453)
  • remove and ignore all test refs (7a7187a)
  • RenderPixi.js - added missing dependencies (aec19ae)
  • update Matter.Plugin docs (6f8b705)
  • updated edge build (1d05499)
  • updated edge build (0bdaece)
  • updated readme (a408854)
  • updated readme (4da2e25)
  • updated readme (9ccc028)
  • updated readme (faf534a)
  • updated readme (5ca9aca)
  • updated readme (e3e9080)
  • updated readme (c4cce9e)
  • updated readme (4b5837e)
  • updated readme (098f224)

0.10.0 (2016-05-01)

  • added release:push:docs task (04cbd1d)
  • decouple Matter.Render from Matter.Engine (de823eb)
  • decouple Matter.RenderPixi (72f90b9)
  • deprecated Matter.RenderPixi (e8c899a)
  • deprecated Matter.RenderPixi (a6b97cd)
  • fix tests (f59e220)
  • fix tests (c26684e)
  • Merge branch 'decouple-renderer' (31067c9)

0.9.3 (2016-04-19)

  • added readonly to docs for type property, closes #235 (afd7531), closes #235
  • Engine uses provided world; fixes issue #230 (158c404), closes #230
  • fix issue with removed bodies causing collisions (23a773a)
  • fix Matter.Engine.create docs to show element param is optional (e2e7c0b)
  • handle missing options in Engine.create (f36fe2c)
  • improved release tasks (e13d2d2)
  • Merge branch 'master' of github.com:liabru/matter-js (d373172)
  • Merge pull request #237 from iamjoshua/master (b724959), closes #230
  • set release task to default to patch (9d396fe)
  • updated edge build (7eb9ac7)

0.9.2 (2016-04-07)

  • Add permeability example and doc entry (6e7add1)
  • Add permeable objects (1573359)
  • Change permeable name to sensors, add isSensor to Pair (28084b0)
  • Document World bounds and Grid bucket size. (5054c97)
  • fix Body.scale for circles, closes #234 (f428d6b), closes #234
  • Fix the out-of-bounds check in grid broadphase (a20a9fb)
  • Merge pull request #224 from brollb/223-bounds-ignored-in-renderer (1944f6a), closes #223
  • Merge pull request #231 from Rantanen/patch-1 (b6f6a03)
  • Merge pull request #232 from Rantanen/docs (79fa57e)
  • Merged sensors from Misiur-master (e1a52d5)
  • Update README.md (a5b535d)
  • Update README.md (a31ab39)
  • Updated hasBounds default value. Fixes #223 (053ea76), closes #223
  • updated test refs (93ba111)

0.9.1 (2016-02-15)

  • added default for delta parameter in Engine.update, closes #200 (490d232), closes #200
  • added docs for body.render.opacity (adcb610)
  • added SVGPathSeg polyfill, closes #196 (8fcb893), closes #196
  • Adding the opacity attribute to be able to draw semi-transarent sprites (5b755a1)
  • allow passing of pixi objects to Matter.RenderPixi at creation, closes #193 (dbdabcc), closes #193
  • change main reference in package.json (633c305)
  • Changed bounds checking MIN_VALUE to -MAX_VALUE. Fixes #202 (dd5e260), closes #202
  • fix issue with Bodies.circle label option, closes #195 (e7e8c26), closes #195
  • fix lint issue (b4e875b)
  • fixed build issue (bb3d43f)
  • fixed rendering of angle indicators (aaffee3)
  • fixed rendering of compound bodies (99dd6c5)
  • fixes to body opacity rendering (8ac06b2)
  • Merge branch 'master' of https://github.com/ma1069/matter-js into ma1069-master (c99e6af)
  • Merge pull request #199 from kevinboudot/master (34fa27a)
  • remove redundant console.log from gulpfile (b5006e3)
  • Update README.md (1bfb758)
  • updated edge build (cc80837)
  • updated test refs (cfdc0b3)
  • updated test refs (4d65dd1)

0.9.0 (2016-01-16)

release summary

  • improved documentation
  • improved performance
  • improved stability
  • improved accuracy
  • improved friction
  • improved sleeping
  • improved constraints
  • improved examples

  • added concave body support

  • added compound body support
  • added collision filters
  • added Matter.Body property setters
  • added Matter.Sleeping events
  • added Matter.Composite events
  • added Matter.Composite transforms
  • added Matter.MouseConstraint events
  • added Matter.Render events
  • added Matter.Runner
  • added support for nodejs
  • added support for high dpi rendering
  • added multiple examples
  • added automated tests

  • migrated from grunt to gulp

  • migrated to browserify
  • migrated to pixi.js v3

  • fixed multiple issues (see commit log)

commit log

  • Add Pixi DisplayObjectContainer to allow view bounds in webGL (97f0f8d)
  • added beforeRender and afterRender events to Matter.Render (aa48322)
  • added body sleepStart and sleepEnd events, closes #91 (bc26469), closes #91
  • added Body.nextCategory (d249165)
  • added Body.set (235b6c8)
  • added Body.setMass, Body.setDensity, Body.setInertia (ca978fa)
  • added Body.setPosition, Body.setAngle, Body.setVelocity, Body.setAngularVelocity (7ed28f7)
  • added Body.setVertices and Vector.clone (b6dbb25)
  • added building and contributing to readme (9a59e34)
  • added collisionFilter support to MouseConstraint (cee8d55)
  • added composite events (2841522)
  • added composite events example to Demo.events (296d47e)
  • added Composite.translate, Composite.rotate, Composite.scale (4c4962f)
  • added compound support to Query.ray (10e5d0f)
  • added constraint to Demo.compound (87fbf51)
  • added CONTRIBUTING.md (7c936d5)
  • added CONTRIBUTING.md (261c794)
  • added Demo.compositeManipulation (4051823)
  • added Demo.compound (b7bf5d6)
  • added Demo.concave, added Bodies.fromVertices, added Vertices.isConvex, fixed compound properties (0b8efa5)
  • added Demo.manipulation (0a453a2)
  • added Demo.setManualControl (203252a)
  • added Demo.slingshot (3043baa)
  • added Demo.staticFriction (4491dfd)
  • added Demo.svg, Demo.compoundStack, Demo.concave (17589bc)
  • added Demo.terrain (3132d70)
  • added docs (200fcbe)
  • added docs for engine.timing.isFixed (e22ceeb)
  • added drag events to MouseConstraint, closes #45 (c254c8d), closes #45
  • added early out in Constraint.postSolveAll, pass body.velocity when updating bounds (8210dbe)
  • added internal edge flagging to Bodies.fromVertices (ca75fde)
  • added Matter.Svg.pathToPoints (7822ead)
  • added Matter.version (e0a6de0)
  • added Matter.World extends Matter.Composite to docs (b3921fb)
  • added minimum area check to Bodies.fromVertices (bf11ee5)
  • added missing dependency to Render.js (df5f16c)
  • added mouse constraint collision mask example to demo (440e9d2)
  • added Mouse.create warning for omitted element (af83e27)
  • added MouseConstraint.create warning for omitted element (b6603ca)
  • added node demo tests (71c1ae8)
  • added options to Metrics.create (1b7e27d)
  • added Query.point (98ea7c7)
  • added release tasks (5479fbc)
  • added Render.create warning for omitted element (0583cdb)
  • added render.options.showMousePosition (e191d44)
  • added Render.showInternalEdges, added rendering bounds + axes + positions for compounds, fixed rende (5ab2bf3)
  • added Render.vertexNumbers, Render.bodyConvexHulls (9c139ed)
  • added Runner.create and Runner.tick (5c69f2e)
  • added source link to demo (1e756d3)
  • added sprite offsets relative to centre of mass, closes #153 (3de9d00), closes #153
  • added startdrag and enddrag events to Demo.events (7c75614)
  • added support for compound bodies in MouseConstraint (d6829bf)
  • added support for hidpi rendering (4746eb9)
  • added support for multiple vertices input in Bodies.fromVertices (e8205f8)
  • added support for sprite scale in RenderPixi, closes #54 (8dea166), closes #54
  • added testDemo to grunt test (08c5648)
  • added time scaling to Sleeping (0ae2d02)
  • added Vector.create (b327a40)
  • Allow for negative force to bring a body out of sleeping state. (d585e80)
  • appease jshint (89140ae)
  • appease jshint (18a2627)
  • change browser tests to use JSON.stringify (75af920)
  • change gravity scale to variable rather than a constant (a38b227)
  • change main to edge build (9d0e82b)
  • change travis to only lint rather than full test (until tests are finished and documented) (ce478cb)
  • change world.bounds to Infinity, remove world bounds check from Engine, closes #67 (8b5192d), closes #67
  • changed Body._initProperties to use Body.setVertices (2d04389)
  • changed bower main to build/matter.js (7412335)
  • changed certain Matter.Composite methods to private in docs (8aa148d)
  • changed Common.log to use console.warn (c220f41)
  • changed default minimum area in Bodies.fromVertices (998ab33)
  • changed demo to use Matter.Runner and Matter.Render events (a1d4748)
  • changed friction impulse limiting approach (de4784c)
  • changed Grid.create to accept an options object (eedd1f2)
  • changed jquery reference (matter-tools) to local copy (0849773)
  • changed Math.random to Common.random and use a seeded RNG (0a46cb2)
  • changed Mouse.create to return as a plain object (eaa9767)
  • changed Render.bodyIds to show all parts (3ed8034)
  • changed Sleeping constants to be public (module level) (7eadea9)
  • changed vertex number render fillstyle (bc88406)
  • changed Vertices.create and Vertices.fromPath to create and return a new array rather than apply in- (e3e462e)
  • cleanup (5888ffc)
  • cleanup Svg.pathToPoints (8bf3278)
  • cleanup Svg.pathToVertices (7db3d28)
  • demo tweaks (d55c700)
  • demo tweaks (22445c7)
  • disabled angle indicators on some demos (74bc8ae)
  • don't calculate gravity force if there is no actual gravity (e54802c)
  • dont draw offscreen constraints. Set visible flag on offscreen sprites (e263ecb)
  • Ensure passed canvas abides by render options (0b51dd6)
  • expose demo instance externally (a9122ed)
  • fix angle indicators for compound bodies (8031090)
  • fix bug in Composites.stack when skipping bodies (b34669e)
  • fix bug when using timing.isFixed, closes #44 (0933620), closes #44
  • fix concat dependency (84a22ba)
  • fix demo for tests (5e6b22b)
  • fix Demo.reset to fully reset ids (500d566)
  • fix Demo.stress stability (d0fdd29)
  • Fix for travis (05f1c46)
  • fix grunt for travis (d405910)
  • fix grunt for travis (f55d806)
  • fix gulp issues (4173e70)
  • fix gulp issues (3bd556d)
  • fix handling of engine.render (c46e915)
  • fix issue in Render.inspector on Chrome (86fcfcd)
  • fix issue of undefined body.parts in constructor (9d3755a)
  • fix issue when Bodies.trapezoid slope === 1, closes #138 (449774c), closes #138
  • fix issue with mouse when changing renderers, closes #96 (796faeb), closes #96
  • fix issue with Render.debug when no timing passed, closes #171 and #176 (087fab2), closes #171 #176
  • fix jshint (b0f72ab)
  • fix lint issue (9a599f1)
  • fix Matter.Demo for node (2de1161)
  • fix Matter.Demo for node (06eea3e)
  • fix Matter.Runner for node (ad55b85)
  • fix mobile demo, remove dev.html, fix debug info rendering (9d5c27a)
  • fix orientation event bug in DemoMobile (f770a7c)
  • fix pair properties for compounds (b8f3784)
  • fix runner for tests, limit precision of refs (352bfd6)
  • fix standalone option (de16529)
  • fix support for nodejs (b669ea0)
  • fix tests (eccf0a7)
  • fix travis (3ce6c3a)
  • fix travis issue (131ed5e)
  • fix undefined variables, added jshint checks, closes #102 (536e55f), closes #102
  • fixed Body.rotate (c5212e1)
  • fixed Body.setVertices (73ded98)
  • fixed bug in constraints for compounds (13fcb4b)
  • fixed bug in Demo.reset that was creating multiple MouseConstraint (8204d97)
  • fixed build tasks (69ff33f)
  • fixed build tasks, closes #161 (d1b8705), closes #161
  • fixed chaining for some Matter.Vertices methods (8746185)
  • fixed collision detection issue, closes #12 (3e48825), closes #12
  • fixed collision incident and reference body mapping (757fffa)
  • fixed collision rendering (bc9a051)
  • fixed Common.now, closes #55 (8555c0c), closes #55
  • fixed compound body stability, improved position resolver (e01dd22)
  • fixed critical inertia calculation issue, a potential breaking change, so Body._inertiaScale added t (9a55b0c)
  • fixed Example.timescale (19656cd)
  • fixed friction in Demo.manipulation (95ae911)
  • fixed gulp shell task args (c2b0f30)
  • fixed incorrect bounds issue when passing angle in Body.create (810bd26)
  • fixed issue with Body.applyForce torque, closes #64 (3f9364c), closes #64
  • fixed issue with docs (3a16f90)
  • fixed issue with MouseConstraint.create, closes #185 (dff0e30), closes #185
  • fixed issues with friction stability (1db98a3)
  • Fixed missed variable declaration. (a940d96)
  • fixed options pass through on Bodies.fromVertices (eb29367)
  • fixed Query.ray, Number.MIN_VALUE seems to cause SAT.collides to fail (ccbb98b)
  • fixed RenderPixi for compound bodies (6679b9c)
  • fixed SAT overlap calculation for containment case (685f2bd)
  • fixed scaling on RenderPixi view bounds (c1964e2)
  • fixed support finding logic (bc7dfc7)
  • fixed Vertices.fromPath when parsing scientific notation (dae684d)
  • fixes for compound bodies (87f9065)
  • formatting merge (d4cbdbb)
  • further work on compound implementation (d2f79b4)
  • hide axis indicator on compound bodies (6a26696)
  • ignoring .idea (066a416)
  • implemented automated browser tests (a88b3ba)
  • implemented compound bodies, added Body.setParts (f554d6c)
  • implemented static compound bodies (90adf14)
  • implemented temporary vector pool (7a477f2)
  • improve Composite.car (5ff2182)
  • improved collision detection for compounds (84d9f59)
  • improved Demo.manipulation (e186ccd)
  • improved docs (2317f02)
  • improved docs (2e6afd4)
  • improved examples (6e1f8e9)
  • improved friction, added body.frictionStatic (937c7bf)
  • improved traction for Composites.car (95eddb0)
  • increased tollerance on internal edge finding (40905e8)
  • initial work on browser tests (6a88256)
  • initial work on compound bodies (243fce4)
  • Make background:'transparent' work like canvas renderer (f9123f9)
  • Merge branch 'browser-tests' (a6b82c1)
  • Merge branch 'collision-filters' of https://github.com/GustavCarlson/matter-js into GustavCarlson-co (3a32bda)
  • Merge branch 'GustavCarlson-collision-filters' (a58fe2a)
  • Merge branch 'master' into runner-improve (a48d219)
  • Merge branch 'master' into topic/addBounds (a461fc7)
  • Merge branch 'master' of github.com:liabru/matter-js (4067108)
  • Merge branch 'master' of https://github.com/rfoligno/matter-js into rfoligno-master (41b4b7f)
  • Merge branch 'master' of https://github.com/schahriar/matter-js into schahriar-master (2510cdf)
  • Merge branch 'no-gravity-optim' of https://github.com/BlackDice/matter-js into BlackDice-no-gravity- (1b8574a)
  • Merge branch 'node-tests' into browserify (6e0e7e4)
  • Merge branch 'pr/60' (42dc72d)
  • Merge branch 'pr/95' (eed9167)
  • Merge branch 'runner-improve' into browserify (9e3438f)
  • Merge pull request #30 from mrspeaker/master (e95e328)
  • Merge pull request #31 from mrspeaker/topic/addBounds (6652bb4)
  • Merge pull request #51 from tumult/pair_refreshes_from_body_values (7c1efb6)
  • Merge remote-tracking branch 'origin/pr/33' (c6a9414)
  • merge tumult:old_ie_fixes + tweaks (6e1ab9a)
  • migrated from grunt to gulp, jshint to eslint (19bb655)
  • Missing argument whose default is 1. (61855ab)
  • More fine-grained collision filtering in the style of Box2D (dd4fc65)
  • move /tests to /test (ad403ae)
  • move Demo.* to Example.* (b722012)
  • move license in build (9ba8a2a)
  • move require statements below module export (99c3bb3)
  • moved collision events into Engine.update, changed collisionStart to trigger before collisions resol (69b1d05)
  • moved Engine.run to Matter.Runner (6911395)
  • moved engine.timing properties, tick events and Engine.render into Matter.Runner module (dcdc43d)
  • pass width and height options to Pixi webGL renderer (a9278fc)
  • publish to npm (a12fbcb)
  • refactor Bodies.fromVertices (4a2c6e7)
  • refactor Demo.create (c0b24da)
  • refactor Demo.init (fb76605)
  • remove constraint torque clamp (6f89250)
  • removed Body.resetForcesAll, removed Body.applyGravityAll, removed Body.updateAll (9aa0945)
  • removed collision.supportCorrected instead using bodyB.position, added render.options.showSeparation (2b6a8d3)
  • removed complexity check in Bodies.fromVertices, enforce clockwise sort (2d1ef0d)
  • removed Detector.bruteForce (e04de5f)
  • removed engine.broadphase.current, removed engine.broadphase.instance, changed engine.broadphase to (6dd0c05)
  • removed engine.input, removed Engine mouse events, added MouseConstraint mouse events (fb5d899)
  • removed line width change from Body.setStatic (04955bb)
  • removed Matter.Metrics from release builds (now dev only) (968bba2)
  • removed old build (a068bec)
  • removed redundant property (14392b4)
  • removed Render.clear (redundant) (0a15d7d)
  • removed Render.setBackground (now use render.options) (01bc813)
  • removed unused vars from examples (0bff037)
  • removed version number from edge build name (e6b998e)
  • render normals pointing out of static bodies (d082b3a)
  • skip presolve when impulse 0 (296059c)
  • skip unnecessary loops in Composites.mesh, closes #85 (0a73a64), closes #85
  • Some fixes in pixi.js v3 update (96735dd)
  • Spellchecking (940976a)
  • Spellchecking (c2e0c23)
  • Spellchecking (cd5d401)
  • Spellchecking (611a429)
  • Spellchecking (723ddcf)
  • Spellchecking (65d5d93)
  • Spellchecking (3127654)
  • tweak jshint (71df1b9)
  • tweaks to collision filtering (5060c76)
  • tweaks to Matter.Runner (ce474da)
  • Update JSDoc (25ab2a3)
  • Update JSDoc (18e0642)
  • Update JSDoc (71ef6c2)
  • Update JSDoc (10a46b7)
  • Update JSDoc (5b87f47)
  • Update JSDoc (d17eb6c)
  • Update JSDoc (aa3eabc)
  • update node version for travis (e698b6b)
  • updated browser test refs (1810f93)
  • updated browser test refs (ae32d63)
  • updated browser test refs (31fb748)
  • updated contributing notes (8b89e87)
  • updated docs for collisionFilter (9f10f88)
  • updated edge build (2fa1570)
  • updated edge build (02ab198)
  • updated edge build (37a86cd)
  • updated edge build (cd00353)
  • updated edge build (37ccc84)
  • updated edge build (bf3f986)
  • updated edge build (16733ad)
  • updated edge build (2f2d416)
  • updated edge build (5770013)
  • updated edge build (43fd2e3)
  • updated edge build (fbb7c1a)
  • updated edge build (d6cbd07)
  • updated edge build (9561d5d)
  • updated edge build (a80fbc1)
  • updated edge build (5b2b060)
  • updated edge build (d22b1b4)
  • updated edge build (2ab20b0)
  • updated edge build (f2635ab)
  • updated matter-tools (c969767)
  • updated matter-tools (4ecad0f)
  • updated node test refs (b1e6a45)
  • Updated pixi.js to v3 (419d2ad)
  • updated readme (137580c)
  • updated readme (f4f3bf7)
  • updated readme (d2dcc77)
  • updated readme (2806fd3)
  • updated readme (3e5abab)
  • updated readme (8f2f8ee)
  • updated readme (6cd00b1)
  • updated test refs (b79ece2)
  • updated test refs (1a55259)
  • updated test refs (110aea8)
  • updated test refs (729e2bf)
  • upgraded pixi.js to v3.0.6 (d03145e)
  • use actual canvas size for default render bounds (c3129b8)
  • use browserify (00251e5)
  • use build folder for demo (fa47d5c)
  • use different port for test server, fix test precision limiter (c1f71b9)
  • Use own Common.indexOf method for IE 6-8 compatibility (b91af36)
  • When updating pairs use current values from bodies as they may have changed (f0e7491)

Matter.js Changelog

brm.io/matter-js


0.8.0-alpha - 2014-05-05

Release Highlights

  • added Views demo
  • added Time Scaling demo
  • added Rounded Corners (Chamfering) demo
  • added Raycasting demo
  • added Query module, including raycasting
  • added 3 useful new Composite methods
  • added support for mouse wheel, mouse scaling and offsets
  • added Body.scale for scaling bodies on the fly
  • added Body.timeScale for slowing down bodies per-body
  • added Body.setStatic for correctly setting static
  • added Vertices.chamfer for rounding corners of any set of vertices
  • added integration of chamfer to body factories
  • added engine.timing.isFixed option to disable dynamic timing
  • added render.bounds for translating and scaling views
  • easier use of Engine.update and Engine.render for those using custom game loops
  • fixed issues with time scaling
  • fixed error in calculation of centre of mass
  • removed Matter.Gui in preparation for the MatterTools project launch

Added

  • added Demo.views
  • added Demo.timescale
  • added Demo.rounded
  • added Demo.raycasting
  • added demo support for hash + '-inspect' to start the MatterTools inspector
  • added Composite.rebase
  • added Composite.move
  • added Composite.get
  • added Matter.Query
  • added Query.ray
  • added Query.region
  • added Bounds.translate
  • added Bounds.shift
  • added Mouse.setScale
  • added Mouse.setPosition
  • added mouse.absolute
  • added mouse.wheelDelta
  • added mouse.offset
  • added Body.setStatic
  • added Body.scale
  • added body.timeScale
  • added Vector.angle
  • added Vertices.chamfer for rounding corners
  • added Engine.render
  • added engine.timing.isFixed option
  • added render.bounds for translating and scaling views
  • added Common.nextId
  • added body.label
  • added constraint.label
  • added composite.label

Changed

  • changed engine.timing.timestamp to be simulation based rather than wall-clock based
  • changed correction to now be optional in Engine.update (defaults to 1)
  • changed Events.on to return callback
  • changed Events.off to accept callbacks for removal
  • changed vertices in Bounds.create to optional
  • changed engine.timeScale to engine.timing.timeScale
  • moved Matter.Inspector and Matter.Gui to the MatterTools project
  • moved event documentation to end of file for clarity
  • moved respective engine event triggers into Engine.update and Engine.render

Removed

  • removed body.render.path (redundant)
  • removed Body.nextId
  • removed Constraint.nextId
  • removed Composite.nextId
  • removed Body.updateProperties (now a private method)

Fixed

  • fixed issues with timing.timeScale
  • fixed constraints now account for timeScale
  • fixed Vertices.centre calculation to get correct centre of mass

0.7.0-alpha - 2014-04-01

Release Highlights

  • added six new demos
    • all demos are now mobile friendly
  • added new event system
    • engine, mouse and collision events
  • added sprite texture rendering support
  • added WebGL renderer (pixi.js)
  • improved Composite (and World)
    • batch adding
    • type agnostic adding
    • body removal
  • major performance increases all round
    • collision detection caching
    • batched rendering
    • improved pair management
    • memory leaks fixed
  • stability improvements
    • bodies rest better due to collision caching
    • bodies sleep better
    • constraints are much less volatile
  • fixes for a number of issues (see fixes)

Added

  • added demos
    • sprites
    • events
    • catapult
    • cloth
    • soft body
    • bridge
  • added collision caching and reuse for improved performance
    • added metrics for collision reuse
  • added Events module (Issue #8)
    • engine events
    • mouse events
    • collision events
  • added composite functions, including
    • batch adding (Composite.add / World.add)
    • type agnostic adding (Composite.add / World.add)
    • body removal (Composite.remove / World.remove)
  • added factory functions
    • constraint meshing (Composites.mesh)
    • soft body factory (Composites.softBody)
  • added RenderPixi, a pixi.js WebGL renderer
    • added Gui option to switch renderer
    • added Mouse.setElement
  • added render.visible flag to Body and Constraint (Issue #10)
  • added id to Constraint and Composite
  • added type names to Body, Constraint, Composite
  • added Common functions
    • Common.colorToNumber
    • Common.log
    • Common.clone
  • added jsdoc annotations
  • added travis-ci integration
  • added yuidoc build tasks
  • added multiple build modes to Gruntfile (dev, release, edge)
  • added repository to package.json, so Browserify may be used
  • added CHANGELOG.md

Changed

  • renamed module Manager to Pairs
  • changed Composite to be tree-based
  • changed timestep to be smoothed over 1s for stability
  • changed default constraintIterations to 2 for stability
  • changed demo to use the new composite functions
  • changed right click to now remove bodies in the demos
  • changed Common.now to use high-resolution timing
  • changed MouseConstraint to reference a single constraint rather than a list
  • changed Constraint to now use a render property
  • changed Metrics to only track FPS by default, use the extended flag for full metrics

Removed

  • removed the default in MouseConstraint, you must now instantiate one manually

Fixed

  • fixed a memory leak in Grid
  • fixed a memory leak in Manager
  • fixed debug text now uses Metrics correctly
  • fixed issues regarding passing custom Render modules (Issue #7)
  • fixed issue in Common.extend with null properties
  • fixed issue with sleeping, now ignores inactive pairs
  • fixed issues with Body.applyForce (Issue #7)

0.5.0-alpha - 2014-02-28

  • initial release