Skip to content
lsl.devlsl.devLSL Dev

Camera

Each avatar has one camera, controlled by the viewer. Scripts can suggest a default view when someone sits, take over the camera with permission, or read where the camera is.

Scripts never own the camera. They ask, and the viewer applies it. Two permissions are involved: PERMISSION_CONTROL_CAMERA to set camera parameters and PERMISSION_TRACK_CAMERA to read the camera position and rotation.

PERMISSION_CONTROL_CAMERA is automatically granted for attached or sat-on objects, so HUDs, seats and vehicles get it without a prompt.

Concepts

Functions and events

voidllSetCameraEyeOffset(vector offset)
voidllSetCameraAtOffset(vector offset)
voidllSetLinkCamera(integer link, vector eye, vector at)
voidllSetCameraParams(list rules)
voidllClearCameraParams()
voidllForceMouselook(integer mouselook)
vectorllGetCameraPos()
rotationllGetCameraRot()
floatllGetCameraFOV()
floatllGetCameraAspect()

Sit camera

The simplest camera control: offsets stored on the prim and used by the viewer when an avatar sits on it.

FollowCam

A wiki page on following cameras built with llSetCameraParams.

Scripting Details

voidllSetCameraEyeOffset(vector offset)
Sets the eye offset vector (in local coordinates) where a seated avatar's camera is positioned.
voidllSetCameraAtOffset(vector offset)
Sets the target offset vector (in local coordinates) that a seated avatar's camera will look at.
voidllSetLinkCamera(integer link, vector eye, vector at)
Sets the camera eye position offset eye and looking-at position offset at for avatars who sit on the linked prim link.
voidllSitTarget(vector offset, rotation rot)
Sets the sit target position (offset) and rotation (rot) relative to the prim's position and orientation. Clears the sit target if offset is ZERO_VECTOR.
voidllSetCameraParams(list rules)
Sets multiple camera parameters simultaneously using the list of rules. Requires the PERMISSION_CONTROL_CAMERA runtime permission.
voidllClearCameraParams()
Resets all camera parameters to default values and turns off scripted camera control. Requires the PERMISSION_CONTROL_CAMERA runtime permission (automatically granted for attached or sat-on objects).
voidllForceMouselook(integer mouselook)
Sets whether any avatar sitting on this prim is forced into mouselook mode. Setting mouselook to TRUE forces the mode; FALSE (default) allows the avatar to keep their current camera mode.
vectorllGetCameraPos()
Returns a vector representing the camera's current position in region coordinates of the agent who granted PERMISSION_TRACK_CAMERA. Returns ZERO_VECTOR if permissions are not granted.
rotationllGetCameraRot()
Returns a rotation representing the camera's current orientation of the agent who granted PERMISSION_TRACK_CAMERA. Returns ZERO_ROTATION if permissions are not granted.
floatllGetCameraFOV()
Returns a float representing the camera's current field of view (FOV) in radians of the agent who granted PERMISSION_TRACK_CAMERA. Returns 0.0 if permissions are not granted.
floatllGetCameraAspect()
Returns a float representing the camera's current aspect ratio (width/height) of the agent who granted PERMISSION_TRACK_CAMERA. Returns 0.0 if permissions are not granted.
vectorllWorldPosToHUD(vector world_pos)
Returns the local position vector that places the center of the HUD object directly over the world coordinate world_pos as viewed by the current camera. Requires the PERMISSION_TRACK_CAMERA runtime permission.
voidllRequestPermissions(key agent, integer permissions)
Requests permissions (a bitfield specified by permissions) from the agent in the same region, calling run_time_permissions if granted. This call does not pause script execution.
eventrun_time_permissions(integer perm)
Triggered when an agent grants or denies runtime permissions requested by llRequestPermissions. Passes the active integer permissions bitfield perm (returns 0 if no permissions are currently granted).

Additional

Constant groups CameraParam 14ScriptPermission 13

See also Feature InputFeature AvatarsCategory CameraSL Wiki LSL CameraSL Wiki FollowCam