본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)7.2k · #13449

matterjs

하는 일

이 스킬은 브라우저용 2D 물리 라이브러리인 Matter.js를 설정하고 작동하는 기본 장면을 만들도록 에이전트를 돕습니다. 페이지에서 떨어지는 물체, 드래그 상호작용, 기타 물리 효과를 원하는 웹 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓웹 페이지의 물체가 간단한 물리 엔진으로 떨어지고 튀기거나 부딪히게 하고 싶을 때.
  • ✓방문자가 캔버스 장면에서 마우스로 물체를 끌게 하고 싶을 때.
  • ✓단일 페이지 앱에서 물리 장면을 올바르게 정리해야 하는 경우.

스킬 링크

https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/matterjs/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/matterjs/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 웹 페이지에 떨어지는 상자들의 물리 장면을 추가해 주세요. 사람들이 마우스로 끌 수 있어야 합니다.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 엔진, 렌더러, 러너를 만들고, 월드에 바닥과 도형을 추가합니다. 요청하면 마우스 조작도 추가합니다. 페이지가 바뀔 때 장면을 끄는 방법도 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Matter.js Skill

Workflow

  1. Confirm environment (plain HTML, React, or canvas-only) and rendering approach (Matter.Render for debug vs custom renderer).
  2. Provide a minimal Engine/World/Render/Runner setup and add bodies.
  3. Add interactions (mouse constraint) or constraints only if requested.
  4. 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 a canvas you create yourself.
  • Set render.options.wireframes = false for solid rendering.
  • Use Runner.run(runner, engine) for a simple loop, or call Engine.update in 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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬