Chapter 8. SceneKit
SceneKit is a simple framework for creating, configuring, and rendering a 3D scene in real time. SceneKit’s designed for all kinds of 3D rendering situations, ranging from visualization of data to games. If you want to make a 3D game but don’t want to spend ages learning how to deal with low-level OpenGL or Metal code, SceneKit’s a great way to get started.
8.1 Setting Up for SceneKit
You want to set up your game to use SceneKit for rendering graphics.
Open your application’s storyboard, and locate the view controller that you want to use to present the 3D content in your game.
Select the view, and go to the Identity inspector. Change the class to
Next, go to your view controller’s source code. At the top of the file, you need to import the
The simplest way to ensure that SceneKit is working properly is to make your
SCNView show a background color. In the implementation of
viewDidLoad, add the following code:
SCNView is responsible for drawing 3D content in your game. While you don’t often work directly with the view, it’s a necessary first step to make sure that you’ve got a view and that it’s working. Once you have it, you can move on to bigger and brighter things.
8.2 Creating a SceneKit Scene
You want to manage your 3D objects by grouping them into scenes.