matterjs
What it does
This skill helps the agent set up Matter.js, a 2D physics library for browsers, with a working starter scene. It is for web developers who want falling objects, drag interactions, or other physics effects on a page.
When to use it
- ✓When you want objects on a web page to fall, bounce, or collide with a simple physics engine.
- ✓When you want the visitor to drag objects with the mouse in a canvas scene.
- ✓When you need to clean up a physics scene correctly in a single page app.
Skill link
https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/matterjs/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Can you help me add a falling-boxes physics scene to my web page that people can drag with the mouse?”
5 new skills a week. 1 minute to read.
How it works
The agent creates an engine, a renderer and a runner, adds a ground and some shapes to the world, and then adds a mouse control if you ask for it. It also explains how to shut the scene down when a page changes.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Matter.js Skill
Workflow
- Confirm environment (plain HTML, React, or canvas-only) and rendering approach (Matter.Render for debug vs custom renderer).
- Provide a minimal Engine/World/Render/Runner setup and add bodies.
- Add interactions (mouse constraint) or constraints only if requested.
- Share cleanup steps for SPA or teardown scenarios.
Minimal setup
<script>
const { Engine, Render, Runner, Bodies, Composite } = Matter;
const engine = Engine.create();
const render = Render.create({
element: document.body,
engine: engine,
options: {
width: 800,
height: 600,
wireframes: false
}
});
const runner = Runner.create();
Runner.run(runner, engine);
Render.run(render);
const ground = Bodies.rectangle(400, 610, 810, 60, { isStatic: true });
const box = Bodies.rectangle(400, 200, 80, 80);
Composite.add(engine.world, [ground, box]);
</script>
Common patterns
- Use
Composite.add(engine.world, [...])to add bodies to the world. - Use
Render.create({ element, engine })to create a canvas automatically, or pass acanvasyou create yourself. - Set
render.options.wireframes = falsefor solid rendering. - Use
Runner.run(runner, engine)for a simple loop, or callEngine.updatein your own loop if you need custom timing.
Mouse interaction (optional)
const { Mouse, MouseConstraint } = Matter;
const mouse = Mouse.create(render.canvas);
const mouseConstraint = MouseConstraint.create(engine, { mouse });
Composite.add(engine.world, mouseConstraint);
render.mouse = mouse;
Cleanup checklist (SPA)
- Stop the runner with
Runner.stop(runner). - Remove the render canvas from the DOM.
- Clear engine and world if needed.
Questions to ask when specs are missing
- What viewport size and scaling should the canvas use?
- Are we using Matter.Render or a custom renderer?
- Do you want mouse/touch drag interaction?
- Should the simulation loop be paused when offscreen?
FAQ
Do I need to know physics to use it?
No. The skill gives a minimal working setup that you can change step by step.
Can it work with React?
Yes. The skill covers plain HTML, React, and canvas-only setups, and it asks which one you use first.
Does it add anything when I do not ask for it?
No. Mouse interaction and constraints are only added when you request them.
Details
Original description by the author
Use when implementing 2D physics interactions with Matter.js, including Engine/World setup, Render/Runner configuration, adding bodies and constraints, and scroll/interaction-friendly canvas scenes.
repo: MengTo/Skills
Popularity
- GitHub stars
- 7.2k
- Ranking position
- #13449
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
3d-cloth-material
7.2kHelps your agent build realistic woven fabric in Three.js, with thread weave, soft sheen, natural folds, hems and seams.
3d-falling-leaves
7.2kHelps your agent add realistic falling leaves to a 3D scene, with leaves that tumble, drift with the wind and recycle as the camera moves.
3d-four-seasons
7.2kHelps your agent add spring, summer, fall and winter looks to a 3D scene, changing foliage, light, sky and snow without rebuilding it.
3d-high-poly-models
7.2kHelps your agent build detailed 3D models with smooth shapes and believable edges, then prepare lighter versions that run well on the web.
Similar skills
angular-developer
280kHelps your agent create Angular code and give project structure advice. Useful for starting new projects, creating code parts, or improving performance and accessibility.
frontend-a11y
280kHelps your agent make web interfaces accessible to everyone. It ensures websites and apps work well with screen readers and keyboard navigation.
frontend-patterns
280kHas your agent apply modern patterns in frontend development. It optimizes performance, manages state, and follows best practices in React and Next.js.