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.