I have a rectangular matter.js body and I only want to chamfer the top-left and top-right corners, but not the bottom. How will I do that?
Bodies.rectangle(x, y, w, h, { chamfer: 5 }) // chamfers all corners :(
The method Bodies.rectangle calls Vertices.chamfer as found on these lines of code, and it expects that the chamfer property be an object. However, if you pass a single number it will apply the same chamfer number to all of the vertices as seen here.
Reading over the documentation, we found that:
The radius parameter is a single number or an array to specify the radius for each vertex.
For a rectangle, the vertices are clockwise starting from the top left. After all, to chamfer only the top left and top right corners, the code should be:
Bodies.rectangle(x, y, w, h, {
chamfer: {
radius: [5,5,0,0]
}
})