Camera
In order to view a scene, you need a camera. The Camera
component enables an Entity to render a scene. You can use the entity’s position and rotation to control the camera.
A scene can have multiple cameras, for example to render from different points of view.
Usage
A Camera
is a component, so you attach it to an Entity
in the same way you would attach a Render
component.
import { Camera } from '@playcanvas/react/components'
<Entity>
<Camera fov={28} clearColor="rebeccapurple" />
</Entity>
Learn more about the Camera Component in the PlayCanvas documentation.
type
The type
prop determines the type of camera. It accepts one of the following values from PlayCanvas:
PERSPECTIVE
- The camera will use a perspective projectionORTHOGRAPHIC
- The camera will use an orthographic projection
Default: PERSPECTIVE
fov
The fov
prop determines the field of view of the camera. This is the angle between the camera’s forward direction and the top/bottom of the screen.
Type: number
Default: 60
near
The near
prop determines the near clipping plane of the camera. This is the distance from the camera to the near clipping plane.
Type: number
Default: 0.1
far
The far
prop determines the far clipping plane of the camera. This is the distance from the camera to the far clipping plane.
Type: number
Default: 1000
aspectRatio
The aspectRatio
prop determines the aspect ratio of the camera. This is the ratio of the width to the height of the screen.
Type: number
Default: 16 / 9
Additional Props
Any additional props will be passed to the PlayCanvas CameraComponent
class directly. See the docs for more information.