Sort Vector3[] by clockwise order

I have an array of Vector3 points that are the edges of a mesh. I want to draw a line around the mesh using a LineRenderer, and to do that I need to get the edges in the correct, clockwise order. If not, the LineRenderer just draws the line cross the mesh in random directions between different edges.

I realize that a Vector3 is in 3D space and Clockwise is 2D space. So I need to do it from a specific direction. I want to do it by looking down from Y-axis.

I found Vector3.Angle () but it does not take a direction, and the angle can never be more than 180 degrees. So points to the left, and to the right of the center might have the same angle. So the function can not be used to sort the points in the way I want.

I’d love to get a few code examples or suggestions of functions that I can use to do this.

Looks like this is a two parter.

Part 1) Project 3D points onto 2D space: If all you need is looking at it along the y-axis, then you can simply discard the y-component and use (x, z) as your 2D points. For generalized direction, you’d have to project the point onto the plane - I won’t be going into that.

Part 2) There is no unique solution to connecting dots in clockwise (or counterclockwise) order unless the dots are convex (or if you’re willing to disregard dots that make it non-convex, aka concave). If so, then there are algorithms (see https://miconvexhull.codeplex.com/) that accomplish this.

Euler Angles could be a solution…
transform.eulerangles.z will return 360 degree angle between the Z-rotation of transform and 0 degree world space…