我如何初始化 ARSCNView
var sceneView: ARSCNView?
override func viewDidLoad() {
super.viewDidLoad()
if ARConfiguration.isSupported{
sceneView = ARSCNView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height))
view.addSubview(sceneView!)
sceneView!.delegate = self
// Show statistics such as fps and timing information
sceneView!.showsStatistics = false
// Create a new scene
let scene = SCNScene(named: "totens.scnassets/Main.scn")!
// Set the scene to the view
sceneView!.scene = scene
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
guard let referenceImages = ARReferenceImage.referenceImages(inGroupNamed: "TotensImages", bundle: nil) else { return }
let configuration = ARImageTrackingConfiguration()
configuration.trackingImages = referenceImages
let options: ARSession.RunOptions = [.removeExistingAnchors]
sceneView!.session.run(configuration, options: options)
}
当关闭此视图控制器并尝试重新启动会话时,相机停止出现。有人知道如何帮助我吗?谢谢