我下面的代码仅在 touches started 函数中显示 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
}