ExtrudePolygon with Smooth Curve?

Hi there,
I’m trying to extrude a mesh with a set of points. ExtrudePolygon worked well, but instead of polyline, I’d like to build a smooth curve of the top of the shape.
For example:
https://www.babylonjs-playground.com/#MCJYB5#1

Thank you very much!

https://doc.babylonjs.com/how_to/parametric_shapes#paths

https://doc.babylonjs.com/how_to/how_to_use_curve3

Hi,
Thanks for your reply. Could you be more specific?
I’m new to this. Sorry if this sounds a stupid question.

You should build a Bezier curve, then get its points and then use points to extrude.

Hi @Notruilin and welcome to the forum from me. Here is an example using your data https://www.babylonjs-playground.com/#MCJYB5#3

First point is to make sure shape points are in counter clockwise order. For polygon2 your line points start at (0, 0, 2) and end at (10, 0, 2) and so your catermull points to close the shape need to go from (10, 0, 2) round to (0, 0, 2). Since your catermull points would be in clockwise order when added after the linePoints I reversed them in line 37 to generate all the points need for the polygon. I add them after the linePoints on line 39.

So allPoints is now the array of all the points in the correct order needed to form the shape for the extruded polygon.

1 Like

Thanks! :smile:

Got it! I forgot the clockwise order. Thank you so much! :smile: