- iOS 8.0+
- macOS 10.10+
- tvOS 9.0+
- watchOS 2.0+
SK3DNode objects to incorporate 3D SceneKit content into a SpriteKit-based game. When SpriteKit renders the node, the SceneKit scene is animated and rendered first. Then this rendered image is composited into the SpriteKit scene. Use the
scn property to specify the SceneKit scene to be rendered.
SceneKit content rendered in SpriteKit is automatically assigned a camera and, since
autoenables defaults to
true, lights. That means you require very little code to add simple 3D primitives to your scene. Listing 1 shows how to create a simple scene containing a torus and display it in a SpriteKit scene.
After node is added to a
SKScene, the 3D torus is visible:
SK3DNode creates a default camera automatically, you can create your own camera for precise control over how the 3D content is rendered. Listing 2 shows how you can create a 3D node with an explicitly created camera that looks at the first object in the SceneKit scene's node tree.
You can create many instances of
SK3DNode each sharing the same SceneKit scene but each with an independent point of view. By updating the position of each 3D node's point of view, you can create code that simulates a top-down, one-point perspective view. Listing 3 shows a example of how to do this by enumerating over all the nodes named
3dnode in the
update method of a
Figure 2 illustrates how this code gives the impression of perspective inside SpriteKit: