Contents

OrthographicCameraComponent

A component that defines an orthographic virtual camera and its settings.

Declaration

struct OrthographicCameraComponent

Overview

Each scene requires a camera that defines the viewpoint from which RealityKit renders the scene. The orthographic camera renders the entities in the scene without the perspective of depth, meaning faraway objects don’t look smaller.

To create an orthographic camera, add this component to an entity.

Perspective camera

Orthographic camera

[Image]

[Image]

You can add an OrthographicCameraComponent to an entity’s component set, and orient that entity so that it looks at a specific target using Entity/look(at:from:upVector:relativeTo:).

// Create an entity to hold the camera component.
let cameraEntity = Entity()

// Create an orthographic camera component and add it to the camera entity.
cameraEntity.components.set(OrthographicCameraComponent())

// Set the entity's position and orientation to look at the subject.
let cameraPosition: SIMD3<Float> = [0, 1, 3]

// The subject in this case is the origin.
let target: SIMD3<Float> = .zero
cameraEntity.look(at: target, from: cameraPosition, relativeTo: nil)

// Add the camera entity to your scene.
content.add(cameraEntity)

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

Setting focal points

Setting the camera scale

See Also

Cameras