![]() | |
Mesh |
public static Vector3[] Convert2DShapeTo3DPositions( Vector2[] shape2DPositions, Base3DPlaneTypes targetPlane, bool isShapeYUp, CoordinateSystems sceneCoordinateSystem = CoordinateSystems.YUpRightHanded )
Project2DShapeTo3DPositions converts the 2D shape positions to 3D positions on the specified plane.
For example, when targetPlane is set to XY, then the conversion is done by setting Z to zero (Vector2(x,y) => Vector3(x,y,0)).
The method can also invert the Y value based on the isShapeYUp and coordinateSystem parameters.
Inverting the Y value the order of positions is preserved. This is important because the order of positions determines the orientation of the triangles - the front face of the triangle (set to Material property) is shown when the positions are in the counter-clockwise direction; the back face (set to BackMaterial property) is shown on the clockwise oriented triangles.
For example, when converting to XZ plane and when isShapeYUp is true (Y axis is pointing up in a 2D coordinate system of the shape) and coordinateSystem is YUpRightHanded (default), then the 3D X axis is pointing to the right, and 3D Z axis is pointing towards the viewer. To put the 2D shape to the XZ plane, we need to invert the Y value to preserve the shape.
But when converting to XY plane, the Y axis is pointing up in both 2D and 3D coordinate systems, so we do not need to invert the Y value.
Similarly, when the coordinate system is YUpLeftHanded or ZUpLeftHanded, we would need to invert the Y value (compared to YUpRightHanded and ZUpLeftHanded coordinate systems).