matter-js-rs 0.1.1

A Rust port of Matter.js, the 2D rigid body physics engine
Documentation
  • Coverage
  • 2%
    5 out of 250 items documented0 out of 108 items with examples
  • Size
  • Source code size: 605.15 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 11.38 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 32s Average build duration of successful builds.
  • all releases: 46s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gsenden

matter-js-rs

A Rust port of Matter.js, the 2D rigid body physics engine.

Why?

  • Pure Rust — use Matter.js physics in any Rust project, no JavaScript runtime needed
  • WASM build — drop-in replacement for Matter.js in the browser
  • Bit-exact compatibility — verified against Matter.js output (IEEE 754 f64 precision)

Compatibility

matter-js-rs Matter.js
0.1.x 0.20.x

Demo

Live demo — interactive physics scenes running in the browser via WASM.

Features

  • Geometry — Vec2, Vertices, Bounds, Axes
  • Body — Verlet integration, forces, collisions, static bodies
  • Composite — Body/constraint container with recursive traversal
  • Collision — SAT detection, contacts, pairs, broadphase (AABB sweep)
  • Constraint — Distance/spring constraints, Gauss-Siedel solver
  • Engine — Full simulation loop, resolver, collision events
  • Factory — Rectangle, circle, polygon, trapezoid builders
  • WASM — wasm-bindgen bindings with TypeScript types

Usage

use matter_js_rs::engine::Engine;

let mut engine = Engine::default();
engine.update(1000.0 / 60.0);

Project structure

matter-js-rs/
├── src/            # Physics engine library
├── wasm/           # WASM binding (thin wrapper)
└── testdata/       # Reference data generated from Matter.js

Building

cargo build --workspace
cargo test --workspace

Regenerating test data

cd testdata
npm install
node generate.js

Acknowledgements

This project is a port of Matter.js by Liam Brummitt, licensed under the MIT License.

License

Licensed under either of

at your option.