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)
}
このView Controllerを閉じてセッションを再起動しようとすると、カメラが表示されなくなります。誰かがこれで私を助ける方法を知っていますか? ありがとう