Class: Camera

RS~Camera

The Camera class allows simple camera manipulation. Events are emitted whenever underlying properties are changed to allow the user to update RealityServer® or other system componenets as necessary.

new Camera ()

Creates a perspective Y up camera with a 90 degree field of view.

Members

RS.Camera.Y_UP static

Enum representing a Y up camera

RS.Camera.Z_UP static

Enum representing a Y up camera

aperture Number

The aperture of the camera. When changed fires a RS.Camera#event:aperture-changed event.

clip_max

The clip max of the view frustum. When changed fires a RS.Camera#event:clip_max-changed event

clip_min

The clip min of the view frustum. When changed fires a RS.Camera#event:clip_min-changed event

direction RS.Vector3 readonly

The look direction vector of the camera.

field_of_view Number

The half field of view of the camera in radians. When changed fires a RS.Camera#event:aperture-changed event

focal Number

The focal length of the camera. When changed fires a RS.Camera#event:focal-changed event.

follow_target_point Boolean

Whether to follow the target point or not. When true the camera will always look at the target point, when false it can be rotated away. When set to true will fire a RS.Camera#event:transform-changed event.

Default Value:
  • true

location RS.Vector3 readonly

The position of the camera in world space.

matrix RS.Matrix4x4

The matrix of the transform. When set fires a RS.Camera#event:transform-changed event

orthographic Boolean

Whether the camera is orthographic or perspective. When changed fires a RS.Camera#event:orthographic-changed event

The right direction vector of the camera.

scene_up_direction Number

The nominal up direction of the camera. Can be either RS.Camera.Y_UP or RS.Camera.Z_UP. When set the camera will rotate to match the new up direction and fires a RS.Camera#event:up_direction-changed and RS.Camera#event:transform-changed event.

target_point RS.Vector3

The target point of the camera. When set fires a RS.Camera#event:target_point-changed event. If the camera is following the target point then it is rotated to look at the target point and fires a RS.Camera#event:transform-changed event.

The transform of the camera. When changed fires a RS.Camera#event:transform-changed event and a RS.Camera#event:target_point-changed event.

up RS.Vector3 readonly

The actual up direction vector of the camera.

Methods

clone ()RS.Camera

Returns a copy of this Camera.

Returns:
Type Description
RS.Camera

dolly (depth, shift_target_point)

Dollies the camera.

Name Type Default Description
depth Number

The amount to move along the direction vector.

shift_target_point Boolean false optional

If true then dollies the target as well.

Fires:

elevate (vertical)

Elevates the camera and the target point

Name Type Description
vertical Number

The amount to move the camera up the up vector.

Fires:

equal (rhs)

Compares this camera to another. The camera are equal if the aperture, focal length, field of view and matrix are the same.

Name Type Description
rhs RS.Camera

the camera to compare

level_camera ()

Forces the camera to be horizontal.

Fires:

orbit (vertical_axis, horizontal_axis, orbit_point)

Orbits the camera. This method orbits using the initial up and right reference vectors.

Name Type Default Description
vertical_axis Number

The amount to orbit around the up vector in radians.

horizontal_axis Number

The amount to orbit aroung the right vector in radians.

orbit_point RS.Vector3 null optional

The point to orbit around, if provided then this becomes the new target point.

Fires:

orbit_around_point (vertical_axis, horizontal_axis, shift_target_point)

Orbits the camera around a point in world space. This method acts much like the standard orbit function however if you choose to orbit around a different point than the target point you can also rotate the target point as well.

Name Type Description
{RS.Vector3>

point The point to orbit around, this will NOT change the target point.

vertical_axis Number

The amount to rotate around the up vector in radians.

horizontal_axis Number

The amount to rorate aroung the right vector in radians.

shift_target_point Boolean optional

If true the target point will also rotate around the point.

Fires:

pan (horizontal, vertical, shift_target_point)

Pans the camera.

Name Type Default Description
horizontal Number

The amount to pan in the right direction.

vertical Number

The amount to pan in the up direction.

shift_target_point Boolean true optional

If true then pans the target as well.

Fires:

rotate (vertical_axis, horizontal_axis, direction_axis, shift_target_point)

Rotates the camera around itself.

Name Type Default Description
vertical_axis Number

Amount to rotate around the up vector in radians.

horizontal_axis Number

Amount to rotate around the right vector in radians.

direction_axis Number

Amount to rotate around the direction vector in radians (roll).

shift_target_point Boolean true optional

If true`` the target point will also rotate around the point. Iffalse`` then only the direction_axis rotation will be applied.

Fires:

rotate_around_axis (axis, angle, in_camera_space, rotate_target_point)

Rotates the camera around a given axis.

Name Type Default Description
axis RS.Vector3

the axis to rotate around.

angle Number

the amount to rotate by in radians.

in_camera_space Boolean false optional

if true then the axis is in camera space, otherwise world.

rotate_target_point Boolean optional

if true then the target point is rotated by the same amount. Otherwise we keep looking at the current target point only.

Fires:

set_from_camera (camera)

Sets this camera from another.

Name Type Description
camera RS.Camera

the camera to set from or an object with the same properties.

Fires:

set_from_object (camera)

Sets the camera data from either an object with appropriate properties or from another Camera instance.

Name Type Description
camera RS.Camera

the camera to set from or an object with the same properties

Fires:

set_location (location, shift_target_point)

Moves the camera to a given location.

Name Type Default Description
location RS.Vector3

The position to move to.

shift_target_point Boolean true optional

If true then the target point is moved to be at the same relative location as previously. Otherwise the transform will look at the old target point after translation.

Fires:

set_target_point (target_point, reset_up_vector)

Sets the target point of the camera and, if following the target point, makes the camera look at it.

Name Type Default Description
target_point RS.Vector3

The new target point.

reset_up_vector Boolean true optional

if true, and following the target point, then the camera roll will be reset.

Fires:

spin (vertical_axis)

Spins the camera by rotating around the up vector of the camera. This also rotate the target point.

Name Type Description
vertical_axis Number

The amount, in radians, to spin.

Fires:

tilt (horizontal_axis)

Tilts the camera by rotating around the right vector of the camera. This also rotate the target point.

Name Type Description
horizontal_axis Number

The amount, in radians, to tilt.

Fires:

transform_direction (point, result)

Transforms a direction into camera space.

Name Type Description
point RS.Vector4

The point to tranform.

result RS.Vector4

Receives the result of the transform.

transform_direction_to_world (point, result)

Transforms a direction from camera space into world space.

Name Type Description
point RS.Vector4

The point to tranform.

result RS.Vector4

Receives the result of the transform.

transform_point (point, result)

Transforms a point into camera space.

Name Type Description
point RS.Vector4

The point to tranform.

result RS.Vector4

Receives the result of the transform.

translate (move, shift_target_point)

Moves the camera by the given amount

Name Type Default Description
move RS.Vector3

The vector to move along.

shift_target_point Boolean true optional

If true then the target point is moved as well, otherwise the camera will look at the old target point after translation.

Fires:

Events

aperture-changed

Aperture changed event.

Fired when the camera changes aperture

clip_max-changed

Clip max changed event.

Fired when the camera clip max changes

clip_min-changed

Clip max changed event.

Fired when the camera clip max changes

focal-changed

Focal changed event.

Fired when the camera changes focal

orthographic-changed

Orthographic changed event.

Fired when the camera changes between orthographic and perspective

target_point-changed

Target point changed event.

Fired when the camera target point

transform-changed

Transform changed event.

Fired whenever the underlying transform changes

up_direction-changed

Up direction changed event.

Fired when the camera up direction changes.