In the documentations it says that poly-decomp is only needed when the vertices are not convex. But when I try to create a shape with convex vertices it fails with this error:
Uncaught Error: Cannot find module 'poly-decomp'
The problem seems to be these lines:
https://github.com/liabru/matter-js/blob/61b19632491d447be5f46e027f4ae56c47f92c90/build/matter.js#L6736-L6738
The weird thing is that these lines are only present in the built file.
I found a workaround by looking into the source code of Bodies.fromVertices(I use Body.create({ vertices })) so it is not a problem for me at the moment but I was wondering if that was intended. I think it is not because after throwing error if poly-decomp is not loaded, the latter parts of the function still checks for availability of the module.
Snippet to reproduce the error:
let vertices = [
{ x: 100, y: 100 },
{ x: 150, y: 100 },
{ x: 100, y: 150 },
];
console.log(Matter.Vertices.isConvex(vertices)); // prints true
let body = Bodies.fromVertices(100, 100, vertices); // Gives the error
I think there's a known problem with how this is being required, for now are you able to include the module even if you don't use it?
Why is this marked as duplicate? Is there another issue that goes into more detail?
Possibly liabru/matter-js#559?
Sorry yes thanks I meant #559. I've just left a reply there with an update, so try using 0.15.0 and let me know how it goes if you can.
Most helpful comment
Possibly liabru/matter-js#559?