Capping extruded shape not working?

Hi, I am new to babylon.js and this forum.

Currently I am trying to cap an extruded shape. The cap is being added, but it is not correct. Can you please check and let me know if that’s a bug, or just me doing something wrong?

Hi @oli and welcome to the forum. The issue is that the shape you are extruding is concave and the capping method does not work with concave shapes.

You can combine ExtrudeShape and CreatePolygon to get what you want

If you do not want the final mesh to be open you can just use ExtrudePolygon


Thank you very much for this quick answer and even coding the example solution to the problem. Exactly what I needed!

The two solutions you provided have a very different visual appearance - especially visible in that little “rounded” corner of the shape. While the solution based on ExtrudeShape is very smooth (actually smoother than it is defined), the solution based on ExtrudePolygon is not smoothed at all (it shows the true shape as defined).

Now, what I would like to have is a solid which allows boolean operations with other solids, but with a smooth surface like the one provided by ExtrudeShape. Is that possible? And if so - how?

The issue here is the formation of a mesh and whether vertices are shared or not. In the ExtrudeShape vertices are shared, in the ExtrudePolygon they are not. See Vertex Normals - Babylon.js Documentation

In this PG (playground) the extrusion has been converted to a flat shaded mesh and so has a similar appearance to the one created using ExtrudePolygon.

Can this be reversed? It can using


However this does not really help you since if you apply it to the ExtrudePolygon shape it also forces the cap and the side edges to share vertices which alters the appearance of the shape due to how the normals effect lighting

So the best case for you seems to be to use ExtrudeShape and Polygon for the caps.

Have you seen GitHub - CraigFeldspar/BabylonCSG: Constructive Solid Geometry in BABYLON.js


Thanks again for your quick answer and the demos. Now there is only one (maybe stupid, but important) question left: When I have the extrusion (made with MeshBuilder.ExtrudeShape) and the 2 caps (made with MeshBuilder.CreatePolygon) - I “visually” have a smooth solid extrusion, but actually it is 3 meshes. How can I combine those 3 meshes to make it 1 - which I then use to create a CSG (using CSG.FromMesh)?

You can merge the meshes


Yesss! :slight_smile: Now it’s 100% how I need it. Thank you very much for your support!


Holly Molly !!! @JohnK I love reading your answers !!!


omg… ive been looking for this for days…
thanks very much

1 Like