I can't find a good explanation of what a SCNCamera
is and it's purpose. This is Apple's definition:
A set of camera attributes that can be attached to a node to provide a point of view for displaying the scene.
This definition isn't clear because I set up the scene and added a SCNNode
without attaching a SCNCamera
to it. The point of view from the device's camera shows the SCNNode
at the location I positioned it at with no problem and the scene is displayed fine.
What is the difference between the device's camera and a SCNCamera
?
What is the benefit of attaching a SCNCamera
to a SCNNode
vs not using one?
If I have multiple SCNNodes
(all detached no hierarchy amongst each other) does each node need it's own SCNCamera
?
If I have multiple SCNNodes
in a hierarchy
(parent node with child nodes) does each node need it's own SCNCamera
or does just the parent node?
lazy var sceneView: ARSCNView = {
let sceneView = ARSCNView()
sceneView.translatesAutoresizingMaskIntoConstraints = false
sceneView.delegate = self
return sceneView
}()
let configuration = ARWorldTrackingConfiguration()
override func viewDidLoad() {
super.viewDidLoad()
// pin sceneView to the view
let material = SCNMaterial()
material.diffuse.contents = UIImage(named: "earth")
let plane = SCNPlane(width: 0.33, height: 0.33)
plane.materials = [material]
plane.firstMaterial?.isDoubleSided = true
let myNode = SCNNode(geometry: plane)
myNode.name = "earth"
myNode.position = SCNVector3(0.0, 0.6, -0.9)
sceneView.scene.rootNode.addChildNode(myNode)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
sceneView.session.run(configuration, options: [])
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillAppear(animated)
sceneView.session.pause()
sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}