Strange cap when extrusion

Hey there !
I have a problem with the caps on an extruded figure !
https://www.babylonjs-playground.com/#0XX50N#4
Tried a lot of things wiht the extrudeShape properties but nothing seems to work. I still get artifacts… I’ve been working a lot on this figure because it is quite complicated to draw correctly.
Thanks !

@Evgeni_Popov or @JohnK might have way more valuable insights than me on this topic. I am lame with Geometry :wink:

The algorithm is working as expected, but does not generate what you want because the shape is concave:

To draw the cap, the barycenter of all the points is computed and triangles are drawn by taking this point as a pivot, as you can see in the picture.

For this to work, I think we would need to provide a way for the user to set its own barycenter points that would override the computed ones for the cap start / cap end…

3 Likes

Does it mean I have no solution to fix it ? Shall I modify the shape to be composed of 2 or 3 sub shapes ?

Okay I think I got a solution but I still need you help…
By duplicating the base shape I can get a “clean” mesh. But it’s doubled. Do you have any solution to cut this mesh in half ?
https://www.babylonjs-playground.com/#0XX50N#5

You can try to use a CSG intersect to keep only the upper part.

You can use ExtrudePolygon instead however it is more limited, the coords for the base shape need to be in (x, z) not (x, y), depth only no extrude path, some rotation and positioning may be needed and outside the playground you need to inject and earcut app see api