A structural element of a scene graph, representing a position and transform in a 3D coordinate space, to which you can attach geometry, lights, cameras, or other displayable content.
- iOS 8.0+
- macOS 10.8+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
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.
root 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
scale properties properties (or directly using its
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
To add physics-based behaviors and special effects to SceneKit content, use other types of node attachments. For example, an
SCNPhysics object defines a node’s characteristics for physics simulation, and an
SCNPhysics object applies forces to physics bodies in an area around the node. An
SCNParticle 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.