Matterjs physics

From bidewio/better-openclaw · View interactive version

Matterjs physics is an AI agent skill from the GitHub repository bidewio/better-openclaw. Implement 2D physics interactions with Matter.js — Engine/World setup, Render/Runner configuration, adding bodies and constraints, mouse interaction, and SPA cleanup patterns.

How to use this skill

Skill file

Matter.js — 2D Physics Skill

When to use

Minimal setup

<script>
  const { Engine, Render, Runner, Bodies, Composite } = Matter;
  const engine = Engine.create();
  const render = Render.create({
    element: document.body, engine,
    options: { width: 800, height: 600, wireframes: false }
  });
  Runner.run(Runner.create(), 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>

Mouse interaction

const { Mouse, MouseConstraint } = Matter;
const mouse = Mouse.create(render.canvas);
const mc = MouseConstraint.create(engine, { mouse });
Composite.add(engine.world, mc);
render.mouse = mouse;

Common patterns

Cleanup (SPA)

Tips for AI Agents

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.