screenToWorld

fun screenToWorld(screenPoint: Point2D, viewportWidth: Int, viewportHeight: Int, z: Double = 0.0): Point

Unproject a 2D screen point back to 3D world coordinates on a given plane.

The inverse projection is not unique — a screen point corresponds to a line in 3D space. This method returns the intersection of that line with the horizontal plane at the specified Z height.

Return

The 3D world point on the specified Z plane

Parameters

screenPoint

The 2D screen position

viewportWidth

The viewport width in pixels

viewportHeight

The viewport height in pixels

z

The Z plane to project onto (default: 0.0)