Documentation / @ripl/3d / rayFromScreen
Function: rayFromScreen() ​
rayFromScreen(
x,y,viewProjection,viewport):Ray|null
Defined in: 3d/src/math/projection.ts:86
Builds the world-space ray passing through a screen-space point.
Unprojects the near and far planes and joins them, which works for both perspective and orthographic projections — an orthographic ray is parallel to the view direction rather than fanning from an eye point, and this recovers that without a special case.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
x | number | Screen-space x, in logical pixels. |
y | number | Screen-space y. |
viewProjection | Matrix4 | The view-projection matrix in use. |
viewport | Viewport | The viewport the point was measured in. |
Returns ​
Ray | null
The ray, or null when the view-projection matrix is singular.