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 m | 10 m | 100 m | 1 Km |
---|---|---|---|---|
0.001 | 7.2e-5 | 0.0043 | 0.4624 | 48.58 |
0.01 | 6.9e-6 | 0.0001 | 0.0430 | 4.62 |
0.1 | 3.6e-7 | 7.0e-5 | 0.0072 | 0.43 |
1.0 | 0 | 3.8e-6 | 0.0007 | 0.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
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
lookAtCameraManipulator()
lookAtCameraManipulator(
cameraManipulator
):void
Parameters
• cameraManipulator: CameraManipulator
Returns
void
Defined in
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
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
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.