---
title: PerspectiveCameraComponent
framework: realitykit
role: symbol
role_heading: Structure
path: realitykit/perspectivecameracomponent
---

# PerspectiveCameraComponent

A component that defines a virtual camera and its controls.

## Declaration

```swift
struct PerspectiveCameraComponent
```

## Overview

Overview Each scene requires a camera that defines the viewpoint from which RealityKit renders the scene. In RealityKit, the default camera is a perspective camera, which simulates the way real cameras and human vision work. Entities that are farther away from the camera render smaller. For an alternative camera solution, see OrthographicCameraComponent. To create a perspective camera, add this component to an entity. let cameraEntity = Entity()

// Place the camera 2 meters along the z-axis, // looking at the scene origin. let cameraPosition: SIMD3<Float> = [0, 0, 2] cameraEntity.look(at: .zero, from: cameraPosition, relativeTo: nil)

cameraEntity.components.set(PerspectiveCameraComponent()) A PerspectiveCameraComponent defines the camera settings for a perspective camera, such as the fieldOfViewInDegrees. The entity’s transform defines the camera entity’s viewpoint and direction. The direction it points is along the entity’s negative z-axis. In AR scenarios, the system provides the camera automatically; however, in non-AR scenarios, the app needs to set the camera. If the app doesn’t provide a camera, the system uses the default perspective camera.

## Topics

### Creating a camera component

- [init(near:far:fieldOfViewInDegrees:)](realitykit/perspectivecameracomponent/init(near:far:fieldofviewindegrees:).md)
- [init(near:far:fieldOfViewInDegrees:fieldOfViewOrientation:)](realitykit/perspectivecameracomponent/init(near:far:fieldofviewindegrees:fieldofvieworientation:).md)

### Setting focal points

- [far](realitykit/perspectivecameracomponent/far.md)
- [near](realitykit/perspectivecameracomponent/near.md)

### Setting the field of view

- [fieldOfViewInDegrees](realitykit/perspectivecameracomponent/fieldofviewindegrees.md)
- [fieldOfViewOrientation](realitykit/perspectivecameracomponent/fieldofvieworientation.md)

## Relationships

### Conforms To

- [Component](realitykit/component.md)
- [Equatable](swift/equatable.md)

## See Also

### Cameras

- [OrthographicCameraComponent](realitykit/orthographiccameracomponent.md)
- [CameraFieldOfViewOrientation](realitykit/camerafieldofvieworientation.md)
- [ProjectiveTransformCameraComponent](realitykit/projectivetransformcameracomponent.md)
- [PerspectiveCamera](realitykit/perspectivecamera.md)
