Skip to main content

Interface: RNFCamera

Camera represents the eye through which the scene is viewed.

A Camera has a position and orientation and controls the projection and exposure parameters.

Coordinate system

The camera coordinate system defines the view space. The camera points towards its -z axis and is oriented such that its top side is in the direction of +y, and its right side in the direction of +x.

Since the near and far planes are defined by the distance from the camera, their respective coordinates are -distance_near and -distance_far.

Clipping planes

The camera defines six clipping planes which together create a clipping volume. The geometry outside this volume is clipped.

The clipping volume can either be a box or a frustum depending on which projection is used, respectively Projection.ORTHO or Projection.PERSPECTIVE. The six planes are specified either directly or indirectly using setProjection or setLensProjection.

The six planes are:

  • left
  • right
  • bottom
  • top
  • near
  • far

To increase the depth-buffer precision, the far clipping plane is always assumed to be at infinity for rendering. That is, it is not used to clip geometry during rendering. However, it is used during the culling phase (objects entirely behind the far plane are culled).

Choosing the near plane distance

The near plane distance greatly affects the depth-buffer resolution.

Example: Precision at 1m, 10m, 100m and 1Km for various near distances assuming a 32-bit float depth-buffer

near (m)1 m10 m100 m1 Km
0.0017.2e-50.00430.462448.58
0.016.9e-60.00010.04304.62
0.13.6e-77.0e-50.00720.43
1.003.8e-60.00070.07

As can be seen in the table above, the depth-buffer precision drops rapidly with the distance to the camera.

Make sure to pick the highest near plane distance possible.

Exposure

The Camera is also used to set the scene's exposure, just like with a real camera. The lights intensity and the Camera exposure interact to produce the final scene's brightness.

See

View

Extends

  • PointerHolder

Properties

isValid

readonly isValid: boolean

Get if the refernce to the native pointer is still valid and strong.

If this is false, this object has been manually released with release() and all other methods on this object will throw an Error.

Inherited from

PointerHolder.isValid

Defined in

src/types/PointerHolder.ts:37

Methods

lookAt()

lookAt(eye, center, up): void

Parameters

eye: Float3

The position of the camera in space

center: Float3

The target position to look at

up: Float3

The up vector of the camera (Usually (0, 1, 0))

Returns

void

Defined in

src/types/Camera.ts:77


lookAtCameraManipulator()

lookAtCameraManipulator(cameraManipulator): void

Parameters

cameraManipulator: CameraManipulator

Returns

void

Defined in

src/types/Camera.ts:70


release()

release(): void

Manually release this reference to the native pointer. This will ensure that JS will no longer hold a strong reference, and memory can be safely cleaned up.

If the native pointer is still referenced elsewhere in native code, the underlying memory will not be deleted unless the other references are also released.

If this is not called, the memory will only be cleaned once the JS gabage collector decides to delete this object, which might be at any point in the future.

Calling release() is not required as the GC will destroy this object eventually anyways, but it is recommended to optimize memory usage.

After manually releasing a pointer, all future methods on this object will throw an Error.

Returns

void

Inherited from

PointerHolder.release

Defined in

src/types/PointerHolder.ts:30


setLensProjection()

setLensProjection(focalLengthInMillimeters, aspect, near, far): void

Utility to set the projection matrix from the focal length.

Parameters

focalLengthInMillimeters: number

lens's focal length in millimeters.focalLength > 0.

aspect: number

aspect ratio (You can use view.aspectRatio)

near: number

distance in world units from the camera to the near plane. near > 0.

far: number

distance in world units from the camera to the far plane. far > near.

Returns

void

Defined in

src/types/Camera.ts:86


setProjection()

setProjection(fov, aspect, near, far): void

Utility to set the projection matrix from the field-of-view.

Parameters

fov: number

aspect: number

aspect ratio width/height aspect > 0.

near: number

distance in world units from the camera to the near plane. \p near > 0.

far: number

distance in world units from the camera to the far plane. \p far > \p near.

Returns

void

See

Fov.

Defined in

src/types/Camera.ts:100