matterjs
できること
このスキルは、ブラウザ用の2D物理ライブラリであるMatter.jsを設定し、動く最初のシーンを用意する作業をエージェントに支援します。ページに、落ちる物やドラッグ操作などの物理効果が欲しいWeb開発者向けです。
使う場面
- ✓Webページの物体を、簡単な物理エンジンで落ちたり跳ねたり衝突させたいとき。
- ✓キャンバスのシーンで、訪問者がマウスで物体をドラッグできるようにしたいとき。
- ✓シングルページアプリで、物理シーンを正しく片付ける必要があるとき。
スキルのリンク
https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/matterjs/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のWebページに、落ちる箱の物理シーンを追加し、マウスでドラッグできるようにしてもらえますか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、エンジン、レンダラー、ランナーを作り、ワールドに床と図形を加えます。マウスの操作は、頼まれた場合だけ加えます。ページが切り替わったときにシーンを停止する方法も説明します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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?
よくある質問
使うには物理の知識が必要ですか?
いいえ。スキルは、段階的に変えられる最小限の動く設定を示します。
Reactで使えますか?
はい。プレーンなHTML、React、キャンバスだけの設定を扱い、最初にどれを使うかを尋ねます。
頼んでいない機能は追加されますか?
いいえ。マウスの操作や拘束は、頼まれたときだけ追加されます。
詳細
作者による元の説明
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
人気
- GitHubのスター
- 7.2k
- ランキング
- #13449
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
3d-cloth-material
7.2kThree.js で、糸の織り、柔らかい光沢、自然な襞、裾、縫い目を持つ、本物の織物らしい布を作るようエージェントを支援します。
3d-falling-leaves
7.2k3D のシーンに、回転し、風に流され、カメラの動きに合わせて再利用される、本物らしい落ち葉を加えるようエージェントを支援します。
3d-four-seasons
7.2k3D のシーンに、春、夏、秋、冬の見た目を加え、シーン全体を作り直さずに、茂み、光、空、雪を変えるようエージェントを支援します。
3d-high-poly-models
7.2k滑らかな形と自然な縁をもつ、詳細な3Dモデルを作り、その後、Web で快適に動く軽いバージョンを準備するようエージェントを支援します。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。