SceneKit basics and working with nodes
Like SpriteKit, SceneKit is based on the concept of nodes. SpriteKit objects are children of the SKNode
class, while SceneKit objects are children of the SCNNode
class.
The preceding image is the SceneGraph hierarchy from Apple's SceneKit introduction. As we see, SceneKit has various nodes that branch off from the SCNScene
class. These include the generic SCNNode
for lights, geometry, and the camera.
Nodes are a tree data structure that can have other nodes added to them and have information of other nodes in the structure. As seen in the preceding graph, it's shown with the childNode[]
array and parent properties. Spatial information, such as position, scale, and orientation, can be received from these properties. This is what makes nodes unique to other parent-child structuring in object-oriented design (OOD).
In SpriteKit, we'd typically add a node to our scene or to another node within our scene via the addChild()
function. In SceneKit...