Class

SCNCamera

A set of camera attributes that can be attached to a node to provide a point of view for displaying the scene.

Overview

To display a scene, you must designate a node whose camera property contains a camera object as the point of view.

The SCNNode object containing a camera defines a point of view—that is, the position and orientation of the camera. A camera’s direction of view is always along the negative z-axis of the node’s local coordinate system. To point the camera at different parts of your scene, use the position, rotation, or transform property of the node containing it. (Alternatively, to ensure that a camera always points at a particular element of your scene even when that element moves, attach a SCNLookAtConstraint object to the node containing the camera.)

An SCNCamera object itself defines the shape and, in part, the appearance of the rendered scene as seen from its point of view. By default, a camera defines a perspective projection, whose field of view (FOV) and near and far visibility limits you control using the properties listed in Adjusting Camera Perspective and illustrated below. You can also use the properties listed in Adding Depth of Field and Blur Effects to set a focal length for the camera, causing parts of the scene to appear more or less blurry depending on their distance from the point of view.

Figure 1

Camera properties for perspective projection

Topics

Creating a Camera

init(mdlCamera: MDLCamera)

Creates a camera from the specified Model I/O camera object.

Managing Camera Attributes

var name: String?

A name associated with the camera object.

Adjusting Camera Perspective

var zNear: Double

The camera's near depth limit. Animatable.

var zFar: Double

The camera’s far depth limit. Animatable.

var yFov: Double

The camera’s field of view, in degrees, on the vertical axis. Animatable.

Deprecated
var xFov: Double

The camera's field of view, in degrees, on the horizontal axis. Animatable.

Deprecated
var automaticallyAdjustsZRange: Bool

A Boolean value that determines whether the camera automatically adjusts its zNear and zFar depth limits.

Managing the Camera Projection

var usesOrthographicProjection: Bool

A Boolean value that determines whether the camera uses an orthographic projection.

var orthographicScale: Double

Specifies the camera’s magnification factor when using an orthographic projection.

Choosing Nodes to Be Visible to the Camera

var categoryBitMask: Int

A mask that defines which categories this camera belongs to.

Adding Depth of Field and Blur Effects

var focalDistance: CGFloat

The distance from the camera at which objects appear in sharp focus. Animatable.

Deprecated
var focalSize: CGFloat

The width of the distance range at which objects appear in sharp focus. Animatable.

Deprecated
var focalBlurRadius: CGFloat

The maximum amount of blurring, in pixels, applied to areas outside the camera’s depth of field. Animatable.

Deprecated
var aperture: CGFloat

A factor that determines the transition between in-focus and out-of-focus areas. Animatable.

Deprecated
var motionBlurIntensity: CGFloat

A factor that determines the intensity of motion blur effects. Animatable.

Adding High Dynamic Range Effects

var wantsHDR: Bool

A Boolean value that determines whether SceneKit applies High Dynamic Range (HDR) postprocessing effects to a scene.

var exposureOffset: CGFloat

A logarithmic bias that adjusts the results of SceneKit’s tone mapping operation, brightening or darkening the visible scene.

var averageGray: CGFloat

The luminance level to use as the midpoint of a tone mapping curve.

var whitePoint: CGFloat

The luminance level to use as the upper end of a tone mapping curve.

var minimumExposure: CGFloat

The minimum exposure value to use in tone mapping.

var maximumExposure: CGFloat

The minimum exposure value to use in tone mapping.

Adding Automatic HDR Exposure Adaptation

var wantsExposureAdaptation: Bool

A Boolean value that determines whether SceneKit automatically adjusts the exposure level.

var exposureAdaptationBrighteningSpeedFactor: CGFloat

The relative duration of automatically animated exposure transitions from dark to bright areas.

var exposureAdaptationDarkeningSpeedFactor: CGFloat

The relative duration of automatically animated exposure transitions from bright to dark areas.

Adjusting Rendered Colors

var contrast: CGFloat

An adjustment factor to apply to the overall visual contrast of the rendered scene.

var saturation: CGFloat

An adjustment factor to apply to the overall color saturation of the rendered scene.

var colorGrading: SCNMaterialProperty

A texture for applying color grading effects to the entire rendered scene.

Adding Stylistic Visual Effects

var bloomIntensity: CGFloat

The magnitude of bloom effect to apply to highlights in the rendered scene. Animatable.

var bloomThreshold: CGFloat

The brightness threshold at which to apply a bloom effect to highlights in the rendered scene. Animatable.

var bloomBlurRadius: CGFloat

The radius, in pixels, for the blurring portion of the bloom effect applied to highlights in the rendered scene. Animatable.

var colorFringeIntensity: CGFloat

The blend factor for fading the color fringing effect applied to the rendered scene.

var colorFringeStrength: CGFloat

The magnitude of color fringing effect to apply to the rendered scene.

var vignettingIntensity: CGFloat

The magnitude of vignette (darkening around edges) effect to apply to the rendered scene.

var vignettingPower: CGFloat

The amount of the rendered scene to darken with a vignette effect.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software