- Select ref document -

Camera API documentation

version 1.2.162

Messages to control camera components and camera focus.

Messages

acquire_camera_focus

"acquire_camera_focus"

Post this message to a camera-component to activate it.

Several cameras can be active at the same time, but only the camera that was last activated will be used for rendering. When the camera is deactivated (see release_camera_focus), the previously activated camera will again be used for rendering automatically.

The reason it is called "camera focus" is the similarity to how acquiring input focus works (see acquire_input_focus).

Examples

In the examples, it is assumed that the instance of the script has a camera-component with id "camera".

msg.post("#camera", "acquire_camera_focus")

release_camera_focus

"release_camera_focus"

Post this message to a camera-component to deactivate it. The camera is then removed from the active cameras. See acquire_camera_focus for more information how the active cameras are used in rendering.

Examples

In the examples, it is assumed that the instance of the script has a camera-component with id "camera".

msg.post("#camera", "release_camera_focus")

set_camera

"set_camera", { aspect_ratio=…, fov=…, near_z=…, far_z=… }

Post this message to a camera-component to set its properties at run-time.

Fields

aspect_ratio

number aspect ratio of the screen (width divided by height)

fov

number field of view of the lens, measured as the angle in radians between the right and left edge

near_z

number position of the near clipping plane (distance from camera along relative z)

far_z

number position of the far clipping plane (distance from camera along relative z)

aspect_ratio

number aspect ratio of the screen (width divided by height)

fov

number field of view of the lens, measured as the angle in radians between the right and left edge

near_z

number position of the near clipping plane (distance from camera along relative z)

far_z

number position of the far clipping plane (distance from camera along relative z)

Examples

In the examples, it is assumed that the instance of the script has a camera-component with id "camera".

msg.post("#camera", "set_camera", {aspect_ratio = 16/9, fov = math.pi * 0.5, near_z = 0.1, far_z = 500})