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
- A sit camera needs no permission
- Set an eye offset and a focus offset on the prim; the viewer uses them when an avatar sits there
llSetLinkCameradoes the same for any prim in the linkset
- A scripted camera takes over the view
- Parameters set the camera position, focus, distance, lag and thresholds, and can lock either point in place
- They stay in effect until
cleared - Vehicles, follow cameras and cutscenes are built this way
- A script can also force mouselook
- Reading the camera needs
PERMISSION_TRACK_CAMERAPosition,rotation, field of view and aspect ratio- For example to aim along the view or place a HUD element in the world
- Permissions are
requestedand arrive inrun_time_permissions - Camera scripts are usually paired with control capture, so the user can steer while the script drives the view
Functions and events
void | llSetCameraEyeOffset(vector offset) |
void | llSetCameraAtOffset(vector offset) |
void | llSetLinkCamera(integer link, vector eye, vector at) |
void | llSetCameraParams(list rules) |
void | llClearCameraParams() |
void | llForceMouselook(integer mouselook) |
vector | llGetCameraPos() |
rotation | llGetCameraRot() |
float | llGetCameraFOV() |
float | llGetCameraAspect() |
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
void | llSetCameraEyeOffset(vector offset)Sets the eye offset vector (in local coordinates) where a seated avatar's camera is positioned. |
void | llSetCameraAtOffset(vector offset)Sets the target offset vector (in local coordinates) that a seated avatar's camera will look at. |
void | llSetLinkCamera(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. |
void | llSitTarget(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. |
void | llSetCameraParams(list rules)Sets multiple camera parameters simultaneously using the list of rules. Requires the PERMISSION_CONTROL_CAMERA runtime permission. |
void | llClearCameraParams()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). |
void | llForceMouselook(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. |
vector | llGetCameraPos()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. |
rotation | llGetCameraRot()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. |
float | llGetCameraFOV()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. |
float | llGetCameraAspect()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. |
vector | llWorldPosToHUD(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. |
void | llRequestPermissions(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. |
event | run_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
llRequestPermissions— the two camera permissionsPERMISSION_CONTROL_CAMERA— control the agent’s camera; the agent must be sitting on or attached to the object, and it is revoked on standing up or detachingPERMISSION_TRACK_CAMERA— track the agent’s camera position and rotation
llSetCameraParams— rules list of camera parametersCAMERA_ACTIVE— turns scripted control of the camera on or offCAMERA_POSITIONandCAMERA_FOCUS— camera position and focus in region coordinatesCAMERA_POSITION_LOCKEDandCAMERA_FOCUS_LOCKED— lock either point so it does not moveCAMERA_DISTANCE— how far away the camera wants to be from its targetCAMERA_PITCH— aim straight ahead versus straight down, at the same distanceCAMERA_FOCUS_OFFSET— focus position relative to the targetCAMERA_BEHINDNESS_ANGLEandCAMERA_BEHINDNESS_LAG— how the camera follows changes in target rotationCAMERA_POSITION_LAGandCAMERA_FOCUS_LAG— how much the camera lags as it moves and aimsCAMERA_POSITION_THRESHOLDandCAMERA_FOCUS_THRESHOLD— spheres within which target motion is ignored
Reference
Section titled “Reference”Constant groups CameraParam 14ScriptPermission 13
Related
Section titled “Related”See also Feature InputFeature AvatarsCategory CameraSL Wiki LSL CameraSL Wiki FollowCam