在我的一个 iOS 应用程序开发项目中,每当我尝试在 ARSCNView 上推送视图时。该应用程序在下面冻结是我的代码。如果您知道相同的问题,请提出适当的解决方案。
sceneView
-> 在控制器上推送视图时让应用程序冻结
let session = ARSession()
var sessionConfig: ARSessionConfiguration = ARWorldTrackingSessionConfiguration()
var use3DOFTracking = false {
didSet {
if use3DOFTracking {
sessionConfig = ARSessionConfiguration()
}
sessionConfig.isLightEstimationEnabled = true
session.run(sessionConfig)
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.setupScene()
setupSession()
}
override func viewWillAppear(_ animated: Bool) {
self.tabBarController?.tabBar.isHidden = false
session.run(sessionConfig, options: [.resetTracking, .removeExistingAnchors])
}
override func viewDidDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
session.pause()
}
func setupScene() {
sceneView.delegate = self
sceneView.session = session
sceneView.antialiasingMode = .multisampling4X
sceneView.automaticallyUpdatesLighting = false
sceneView.preferredFramesPerSecond = 60
sceneView.contentScaleFactor = 1.3
//sceneView.showsStatistics = true
enableEnvironmentMapWithIntensity(25.0)
if let camera = sceneView.pointOfView?.camera {
camera.wantsHDR = true
camera.wantsExposureAdaptation = true
camera.exposureOffset = -1
camera.minimumExposure = -1
}
}
func setupSession() {
if let worldSessionConfig = sessionConfig as? ARWorldTrackingSessionConfiguration {
worldSessionConfig.planeDetection = .horizontal
session.run(worldSessionConfig, options: [.resetTracking, .removeExistingAnchors])
}
}