A component that defines a virtual camera with a custom projection matrix.
## Overview
Each scene requires a camera, which defines the viewpoint from which RealityKit renders the scene. The projective transform camera
renders the entities in the scene based on a custom user defined matrix.
For this component, define a matrix that is either of symmetric perspective or orthographic projection.
Define symmetric perspective matrices using reverse depth i.e., a matrix with near and far reversed.
To create a projective transform camera, add this component to an entity.
```swift
// Create a projective transform camera component with a custom matrix.
let projectiveTransform = ProjectiveTransform3DFloat(
fovY: Angle2DFloat(degrees: 90.0),
aspectRatio: 0.6,
nearZ: 0.01,
farZ: 1000.0,
reverseZ: true)
var projectiveCameraComponent = ProjectiveTransformCameraComponent(projectionMatrix: projectiveTransform.matrix)
// Create an entity with the camera component.
let cameraEntity = Entity(components: projectiveCameraComponent)
// Set the entity's position and orientation to look at the subject (the origin in this case).
let cameraPosition: SIMD3<Float> = [0, 1, 3]
let target: SIMD3<Float> = .zero
cameraEntity.look(at: target, from: cameraPosition, relativeTo: nil)
// Add the camera entity to your scene.
content.add(cameraEntity)
```
Creates a new custom matrix camera component with the given settings.
The matrix uses reverse depth.
- Parameters:
- projectionMatrix: The custom projection matrix the user wants to use.
get · iOS 18.0+
transform
TypeScript
get transform(): SDKHandle
Swift declaration
var transform: float4x4
The custom projection RealityKit applies to objects in the scene.
The value defaults to `4x4` zero matrix.
Swap the near and far values to use a reverse depth matrix.
set · iOS 18.0+
transform
TypeScript
set transform(value: SDKHandle)
Swift declaration
var transform: float4x4
The custom projection RealityKit applies to objects in the scene.
The value defaults to `4x4` zero matrix.
Swap the near and far values to use a reverse depth matrix.