【发布时间】:2020-06-01 23:18:56
【问题描述】:
我无法很好地解释SCNCamera 是什么以及它的用途。这是Apple's definition:
一组相机属性,可以附加到节点以提供 用于显示场景的视角。
这个定义不清楚,因为我设置了场景并添加了SCNNode,而没有附加SCNCamera。从设备摄像头的角度来看,SCNNode 在我放置的位置没有问题,并且场景显示良好。
设备的摄像头和SCNCamera有什么区别?
将SCNCamera 附加到SCNNode 与不使用有什么好处?
如果我有多个SCNNodes(彼此之间没有层次结构),每个节点是否都需要它自己的SCNCamera?
如果我在hierarchy(带有子节点的父节点)中有多个SCNNodes,每个节点都需要它自己的SCNCamera 还是只需要父节点?
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])
}
【问题讨论】:
标签: ios swift arkit scnnode scncamera