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.