phaserjs / phaserjs/phaser

PhysicsEditor verticies wrong - MatterJS Physics

Open
#4,963 10 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🧱 Physics
Dominant language
JavaScript
Stars
40.3k
Forks
7.2k
PR merge metrics
No merged PRs in 30d

Description

Version

  • Phaser Version: 3.22
  • Operating system: Windows / Linux (tried on both)
  • Browser: N/A

Description

Shapes created with PhysicsEditor are not parsed properly by Phaser. It has something

Example Test Code

https://codepen.io/nvitaterna/pen/RwNqqKN

Additional Information

PhysicsEditor exports the verticies in a 2D array. When this is flattened then re-wrapped (to satisfy Phaser's vertex sorting function) another array it gets the proper shape:

playerShipJson.playerShip3_blue.fixtures[0].vertices = [playerShipJson.playerShip3_blue.fixtures[0].vertices.reduce((a, b) => a.concat(b), [])];

I am new to using Matter.js but I believe I am following the docs properly in the way I have this set up.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodePen reproduction and inspect how playerShipJson.playerShip3_blue.fixtures[0].vertices is passed to Matter.js. Compare the PhysicsEditor-exported 2D vertex array with the flattened and re-wrapped workaround described in the issue. Done means the exported shape is parsed correctly without that workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.