Pass:getViewRay

Edit

Returns a world space ray for a pixel in the Pass's canvas. This is useful for interacting with objects with the mouse. This uses the current pose and projection of the camera, previously set using Pass:setViewPose and Pass:setProjection.

x, y, z, dx, dy, dz = Pass:getViewRay(x, y, view)

Arguments

NameTypeDefaultDescription
xnumber The x coordinate of the pixel.
ynumber The y coordinate of the pixel.
viewnumber1 The view (camera) to get the ray for.

Returns

NameTypeDescription
xnumber The x coordinate of the origin of the ray (on the near plane of the camera).
ynumber The y coordinate of the origin of the ray (on the near plane of the camera).
znumber The z coordinate of the origin of the ray (on the near plane of the camera).
dxnumber The x component of the ray's direction (normalized).
dynumber The y component of the ray's direction (normalized).
dznumber The z component of the ray's direction (normalized).

Notes

The upper-left of the canvas is located at (0,0).

See also