如何在 ARKit 上插入一个垂直保持的 SCNScene?我无法进行拘留并将物体垂直插入。
override func viewDidLoad() {
super.viewDidLoad()
// Set the view's delegate
sceneView?.delegate = self
// Show statistics such as fps and timing information
sceneView?.showsStatistics = true
// Create a new scene
let scene = SCNScene(named: "art.scnassets/tabellone.scn")
sceneView?.debugOptions = [SCNDebugOptions.showFeaturePoints]
// Set the scene to the view
sceneView?.scene = scene!
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Create a session configuration
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = .vertical
configuration.isLightEstimationEnabled = true
// Run the view's session
sceneView?.session.run(configuration)
}
最佳答案
您需要一个合适的垂直表面来进行追踪。纯色墙(上面没有可区分的特征)是非常糟糕的例子(您可以在左图中看到这样的垂直表面)。跟踪垂直表面最稳健的方法是光线充足砖墙,或带有图片的墙,或带有可区分图案的墙等。
所以右图是跟踪和垂直平面检测的很好的例子。
如果您想探索如何将 3D 对象放置到检测到的平面上,请查看 Apple 的 Handling 3D Interaction and UI Controls in AR项目。
希望这对您有所帮助。
关于swift - 如何在 ARKit 中使用垂直检测?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53524822/