Class PerspectiveCamera

Perspective camera class.

Fields

PerspectiveCamera.m_projection Projection matrix.
PerspectiveCamera.m_inv_projection Inverse projection matrix.
PerspectiveCamera.m_view View matrix.
PerspectiveCamera.center Position where the camera is looking at.
PerspectiveCamera.eye Position of the camera.
PerspectiveCamera.up Normalized up vector, how the camera is oriented.

Methods

PerspectiveCamera:init (fov, aspect, nclip, fclip) The public constructor.
PerspectiveCamera:update_view_matrix () Updating the view matrix.
PerspectiveCamera:screen_point_to_ray (x, y, viewport) Get a ray going from camera through screen point.
PerspectiveCamera:world_to_screen_point (x, y, z) Transform position from world space into screen space.
PerspectiveCamera:get_direction () Get direction.


Fields

PerspectiveCamera.m_projection
Projection matrix.
PerspectiveCamera.m_inv_projection
Inverse projection matrix.
  • m_inv_projection mat4
PerspectiveCamera.m_view
View matrix.
  • m_view mat4 readonly
PerspectiveCamera.center
Position where the camera is looking at.
PerspectiveCamera.eye
Position of the camera.
PerspectiveCamera.up
Normalized up vector, how the camera is oriented.

Methods

PerspectiveCamera:init (fov, aspect, nclip, fclip)
The public constructor.

Parameters:

  • fov number Field of view of the Camera, in degrees.
  • aspect number The aspect ratio.
  • nclip number The distance of the near clipping plane from the the Camera.
  • fclip number The distance of the far clipping plane from the Camera.
PerspectiveCamera:update_view_matrix ()
Updating the view matrix.
PerspectiveCamera:screen_point_to_ray (x, y, viewport)
Get a ray going from camera through screen point.

Parameters:

  • x number screen position x
  • y number screen position y
  • viewport table (optional) viewport rectangle (x, y, w, h)

Returns:

    table that containing {position = vec3, direction = vec3}
PerspectiveCamera:world_to_screen_point (x, y, z)
Transform position from world space into screen space.

Parameters:

  • x number screen position x or vec3
  • y number screen position y
  • z number screen position z

Returns:

    vec2 object
PerspectiveCamera:get_direction ()
Get direction.

Returns:

    vec3 object
generated by LDoc 1.4.6 Last updated 2023-03-21 17:41:24