NSDKCamera
Single camera API for both modes. Holds either ARCamera (live) or PlaybackCamera (playback)...
Declaration
final class NSDKCameraSummary
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
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
| Name | Type | Summary |
|---|---|---|
| var backing | Backing | The underlying camera (live or playback). Use this to call ARCamera- or PlaybackCamera-specific APIs. |
| var effectiveRenderingOrientation | UIInterfaceOrientation | 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 eulerAngles | simd_float3 | The camera's orientation as Euler angles (pitch, yaw, roll) in radians. |
| var exposureDuration | TimeInterval | Camera exposure duration in seconds. |
| var exposureOffset | Float | Camera exposure offset in EV. |
| var imageResolution | CGSize | The camera image resolution in pixels. |
| var intrinsics | simd_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 projectionMatrix | simd_float4x4 | Default projection matrix (no far clipping). |
| var trackingState | ARCamera.TrackingState | The camera's tracking state. |
| var transform | simd_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
| Name | Type | Summary |
|---|---|---|
| displayOrientedTransform | simd_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). |
| projectionMatrix | simd_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). |
| projectPoint | CGPoint | 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. |
| viewMatrix | simd_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. |
| viewportRect | CGRect | 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
| Name | Type | Summary |
|---|---|---|
| Backing | Backing | 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: |
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.