Scene |
public (Vector2 startPositionScreen, Vector2 endPositionScreen) Line3DTo2D( Vector3 startPositionWorld, Vector3 endPositionWorld, bool adjustByDpiScale = false )
Converts a 3D line that is defined by startPositionWorld and endPositionWorld to a line on the screen that is defined by startPositionScreen and endPositionScreen.
This method correctly handles the case when the 3D line crosses the camera near plane (goes behind the camera). In this case the line needs to be cropped at the camera near plane.
The matrix to convert 3D point to 2D point is calculated from the used Ab4d.Camera. The matrix value is cached and is only recalculated when the camera is changed or when the size of the view is changed.
If the matrix to convert 3D point to 2D point cannot be calculated (for example if the size of this SceneView is not set), the returned points will be Vector2(float.NaN, float.NaN). To check if the conversion can be done you can call CanConvertPoint3DTo2D method before calling this method.
To use Line3DTo2D method without creating the SceneView, then you can use the static Line3DTo2D(Vector3, Vector3, Camera, Single, Single).