我下面的代码只显示在触摸1个arkit对象开始功能。我希望用户能够在arkit场景视图中显示几个相同arkit对象。现在作为下一个被放置在另外一个被删除的用户可以放置一个图像,但一旦。
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
//Handle the shooting
guard let frame = sceneView.session.currentFrame else { return }
let camMatrix = SCNMatrix4(frame.camera.transform)
let direction = SCNVector3Make(-camMatrix.m31 * 5.0, -camMatrix.m32 * 10.0, -camMatrix.m33 * 5.0)
let position = SCNVector3Make(camMatrix.m41, camMatrix.m42, camMatrix.m43)
let scene = SCNScene(named: "art.scnassets/dontCare.scn")!
// Set the scene to the view
sceneView.scene = scene
}
傻米莉,每次你改变整个场景,而是将节点添加到sceneView.scene
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let frame = sceneView.session.currentFrame else { return }
let camMatrix = SCNMatrix4(frame.camera.transform)
let position = SCNVector3Make(camMatrix.m41, camMatrix.m42, camMatrix.m43)
let object = SCNScene(named: "art.scnassets/dontCare.scn")!.rootNode
object.position = position
sceneView.scene.rootNode.addChildNode(object)
}