Skip to main content
API Reference NSDK

NSDKCamera

Single camera API for both modes. Holds either ARCamera (live) or PlaybackCamera (playback)...

Declaration

final class NSDKCamera

Summary

Single camera API for both modes. Holds either ARCamera (live) or PlaybackCamera (playback) and exposes transform, viewMatrix, projectionMatrix, viewportRect, etc. Relation to Apple AR: Wraps Apple's ARCamera in live mode; wraps our PlaybackCamera in playback. Callers use NSDKCamera and don't branch. Create via NSDKCamera(arCamera:) or NSDKCamera(playbackCamera:).


Constructors

Constructor

init(arCamera: ARCamera)

Summary

Creates an NSDKCamera that delegates to Apple's ARCamera (live session).
Use when the app is using a live ARSession and you have a current ARFrame's camera.


Overload

init(playbackCamera: PlaybackCamera)

Summary

Creates an NSDKCamera that delegates to PlaybackCamera (playback session).
Use when playing back a recorded dataset; pass the frame's camera from PlaybackFrame.camera.


Properties

NameTypeSummary
var backingBacking
The underlying camera (live or playback). Use this to call ARCamera- or PlaybackCamera-specific APIs.
var effectiveRenderingOrientationUIInterfaceOrientation
When in playback, the orientation the frame was recorded in. When in live, returns nil.
View and projection matrices use the orientation passed by the caller so rendering can follow the device.
var eulerAnglessimd_float3
The camera's orientation as Euler angles (pitch, yaw, roll) in radians.
var exposureDurationTimeInterval
Camera exposure duration in seconds.
var exposureOffsetFloat
Camera exposure offset in EV.
var imageResolutionCGSize
The camera image resolution in pixels.
var intrinsicssimd_float3x3
The camera intrinsics matrix (3×3) in row-major layout: [fx, 0, 0; 0, fy, 0; cx, cy, 1].
Use for unprojecting image coordinates to camera rays or building projection matrices.
var projectionMatrixsimd_float4x4
Default projection matrix (no far clipping).
var trackingStateARCamera.TrackingState
The camera's tracking state.
var transformsimd_float4x4
The 4×4 transformation matrix of the camera in world coordinates (camera-to-world).
Same convention as ARCamera.transform; use for placing virtual content relative to the camera.

Methods

NameTypeSummary
displayOrientedTransformsimd_float4x4
Returns the camera transform adjusted for the given display orientation (Z-axis rotation applied).
Use when you need the camera pose in the same coordinate frame as the on-screen image (e.g. for overlay alignment).
projectionMatrixsimd_float4x4
Returns a projection matrix for the given orientation and viewport size, with optional near/far clipping.
Pass the same orientation and viewport size used for the view matrix so that 3D content projects correctly.
zFar > 0 uses a finite far plane; zFar <= 0 yields an infinite far plane (e.g. for skyboxes).
projectPointCGPoint
Projects a 3D point in world space into 2D viewport coordinates (origin top-left, in pixels).
Returns (-1, -1) if the point is behind the camera. Use with the same orientation and viewport size as rendering.
viewMatrixsimd_float4x4
Returns the view matrix (world-to-camera) for the given interface orientation.
Pass the current device orientation (e.g. from the window scene) so that rendering follows the device when rotated.
For both live and playback, the returned matrix matches the display-oriented camera transform.
viewportRectCGRect
Returns the viewport rect to use when rendering into the given drawable size.
- Live: returns the full drawable (origin zero, size = drawableSize).
- Playback: returns an aspect-fill rect so the camera image aligns with the rendered content; pass displayOrientation (current device orientation) so the viewport fits correctly in portrait and landscape.

Nested Types

Enums

NameTypeSummary
BackingBacking
The underlying camera: either a live ARCamera or a playback PlaybackCamera.
Switch on this when you need to call APIs that are specific to one type (e.g. recordedOrientation on PlaybackCamera).
Example:
switch camera.backing {
case .ar(let arCamera):
// ARCamera-specific APIs
case .playback(let playbackCamera):
let orientation = playbackCamera.recordedOrientation
}