Contents

unproject(_:ontoPlane:relativeToCamera:)

Unproject a 2D point from the view onto a plane in 3D world coordinates.

Declaration

@MainActor @preconcurrency func unproject(_ point: CGPoint, ontoPlane planeTransform: float4x4, relativeToCamera: Bool) -> SIMD3<Float>?

Parameters

  • point:

    A point in the view’s coordinate system.

  • planeTransform:

    The transform used to define the coordinate system of the plane. The coordinate system’s positive y-axis is assumed to be the normal of the plane.

  • relativeToCamera:

    If the plane transform is relative to camera space or world space.

Return Value

3D position in world coordinates or nil if unprojection is not possible.

Discussion

A 2D point in the view’s coordinate space can refer to any point along a line segment in the 3D coordinate space. Unprojecting gets the 3D position of the point along this line segment that intersects the provided plane.

See Also

Mapping between coordinate spaces