Members
-
Enum representing a Y up camera
-
Enum representing a Z up camera
-
The aperture of the camera. When changed fires a RS.Camera#event:aperture-changed event.
-
The clip max of the view frustum. When changed fires a RS.Camera#event:clip_max-changed event
-
The clip min of the view frustum. When changed fires a RS.Camera#event:clip_min-changed event
-
The look direction vector of the camera.
-
The half field of view of the camera in radians. When changed fires a RS.Camera#event:aperture-changed event
-
The focal length of the camera. When changed fires a RS.Camera#event:focal-changed event.
-
Whether to follow the target point or not. When
true
the camera will always look at the target point, whenfalse
it can be rotated away. When set totrue
will fire a RS.Camera#event:transform-changed event.- Default Value:
- true
-
The position of the camera in world space.
-
The matrix of the transform. When set fires a RS.Camera#event:transform-changed event
-
Whether the camera is orthographic or perspective. When changed fires a RS.Camera#event:orthographic-changed event
-
The right direction vector of the camera.
-
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.
-
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.
-
transform RS.Transform_target
-
The transform of the camera. When changed fires a RS.Camera#event:transform-changed event and a RS.Camera#event:target_point-changed event.
-
The actual up direction vector of the camera.
Methods
-
clone ()RS.Camera
-
Returns a copy of this Camera.
Returns:
Type Description RS.Camera -
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:
-
Elevates the camera and the target point
Name Type Description vertical
Number The amount to move the camera up the up vector.
Fires:
-
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
-
Frames the camera around a set of points such that all points provided are visible within the camera frame.
Name Type Default Description fit_points
RS.Vector3 An array of RS.Vector3 points that the camera will be framed around.
aspect
Number The aspect ratio of the camera frame.
preserve_orientation
Boolean true optional When true the camera will keep pointing in the same direction, if false it will rotate to look at the center of the points.
Fires:
-
Forces the camera to be horizontal.
Fires:
-
Makes the camera look at the current target point whether it is following it or not.
Name Type Default Description reset_up_vector
Boolean true optional if
true
then the camera roll will be reset.Fires:
-
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.
level_camera
Boolean true optional if
true
then orbit around the nominal up direction so the camera remains level. Iffalse
then rotates around the cameras current Y axis.Fires:
-
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 Default Description point
RS.Vector3 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 false optional If
true
the target point will also rotate around the point.level_camera
Boolean true optional if
true
then orbit around the nominal up direction so the camera remains level. Iffalse
then rotates around the cameras current Y axis.Fires:
-
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:
-
Projects a world space point into the camera focal plane. The X and Y coordinates will be in camera space and the Z coordinate will contain the correct depth value.
Name Type Description point
RS.Vector4 The point to transform.
result
RS.Vector4 Receives the result of the transform.
Returns:
Type Description RS.Vector4 The projected point. -
Projects a world space point to a pixel coordinate. X/Y origin will be at the bottom left and Z coordinate will contain the correct depth value.
Name Type Description point
RS.Vector4 The point to transform.
resolution
RS.Vector2 The image resolution to project to.
pixel_aspect_ratio
Number optional If provided the pixel aspect ratio to use, otherwise use 1. This would typically only be provided if non-square pixels are used.
result
RS.Vector4 Receives the result of the transform.
Returns:
Type Description RS.Vector4 The projected point. Examples
// Project point <1,2,3> to Full HD resolution. const point = camera.project_point_to_pixel(new RS.Vector4(1,2,3), { x: 1920, y: 1080 }, new RS.Vector4()));
// Project point <1,2,3> to Full HD resolution with rectangular pixels that have a 3:2 aspect ratio. const point = camera.project_point_to_pixel(new RS.Vector4(1,2,3), { x: 1920, y: 1080 }, 3/2, new RS.Vector4()));
-
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. If
false`` then only thedirection_axis
rotation will be applied.Fires:
-
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:
-
Sets this camera from another.
Name Type Description camera
RS.Camera the camera to set from or an object with the same properties.
Fires:
-
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:
-
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:
-
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:
-
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:
-
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:
-
Transforms a world space direction into camera space.
Name Type Description point
RS.Vector4 The point to transform.
result
RS.Vector4 Receives the result of the transform.
Returns:
Type Description RS.Vector4 The transformed direction -
Transforms a camera space direction into world space.
Name Type Description direction
RS.Vector4 The direction to transform.
result
RS.Vector4 Receives the result of the transform.
Returns:
Type Description RS.Vector4 The transformed direction -
Transforms a world space point into camera space.
Name Type Description point
RS.Vector4 The point to transform.
result
RS.Vector4 Receives the result of the transform.
Returns:
Type Description RS.Vector4 The transformed point -
Transforms a camera space point into world space.
Name Type Description point
RS.Vector4 The point to transform.
result
RS.Vector4 Receives the result of the transform.
Returns:
Type Description RS.Vector4 The transformed 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 event.
Fired when the camera changes aperture
-
Clip max changed event.
Fired when the camera clip max changes
-
Clip max changed event.
Fired when the camera clip max changes
-
Focal changed event.
Fired when the camera changes focal
-
Orthographic changed event.
Fired when the camera changes between orthographic and perspective
-
Target point changed event.
Fired when the camera target point
-
Transform changed event.
Fired whenever the underlying transform changes
-
Up direction changed event.
Fired when the camera up direction changes.