Declaration

Overview

An SCNNode object by itself has no visible content when the scene containing it is rendered—it represents only a coordinate space transform (position, orientation, and scale) relative to its parent node. To construct a scene, you use a hierarchy of nodes to create its structure, then add lights, cameras, and geometry to nodes to create visible content.

Nodes Determine the Structure of a Scene

The hierarchy of nodes, or scene graph, in a scene defines both the organization of its contents and your ability to present and manipulate those contents using SceneKit. You may create a node hierarchy programmatically using SceneKit, load one from a file created using 3D authoring tools, or combine the two approaches. SceneKit provides many utilities for organizing and searching the scene graph—for details, see the methods in Managing the Node Hierarchy and Searching the Node Hierarchy.

The rootNode object in a scene defines the coordinate system of the world rendered by SceneKit. Each child node you add to this root node creates its own coordinate system, which is in turn inherited by its own children. You determine the transformation between coordinate systems using the node’s position, rotation, and scale properties properties (or directly using its transform property).

You use a hierarchy of nodes and transformations to model the contents of your scene in a way that suits the needs of your app. For example, if your app presents an animated view of a solar system, you can construct a node hierarchy that models celestial bodies relative to one another: Each planet can be a node, with its orbit and its current position in that orbit defined in the coordinate system of the sun. A planet node defines its own coordinate space, useful both for specifying the planet’s rotation and the orbits of its moons (each of which is a child node of its planet). With this scene hierarchy, you can easily add realistic animation to the scene—animating both the revolution of a moon around its planet and the planet around the sun will combine the animations so that the moon follows the planet.

A Node’s Attachments Define Visual Content and Behavior

The node hierarchy determines the spatial and logical structure of a scene, but not its visible contents. You add 2D and 3D objects to a scene by attaching SCNGeometry objects to nodes. (Geometries, in turn, have attached SCNMaterial objects that determine their appearance.) To shade the geometries in a scene with light and shadow effects, add nodes with attached SCNLight objects. To control the viewpoint from which the scene appears when rendered, add nodes with attached SCNCamera objects.

To add physics-based behaviors and special effects to SceneKit content, use other types of node attachments. For example, an SCNPhysicsBody object defines a node’s characteristics for physics simulation, and an SCNPhysicsField object applies forces to physics bodies in an area around the node. An SCNParticleSystem object attached to a node renders particle effects such as fire, rain, or falling leaves in the space defined by a node.

To improve performance, SceneKit can share attachments between multiple nodes. For example, in a racing game that includes many identical cars, the scene graph would contain many nodes—one to position and animate each car—but all car nodes would reference the same geometry object.

Conforms To

See Also

Scene Structure

A scene graph node that serves as a placeholder for content to be loaded from a separate scene file.

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.