[注意:这个问题是在 iOS11/High Sierra 预发布期间针对 ARKit 测试版编写的。仅出于历史兴趣而保留]
当我将 ARWorldTrackingSessionConfiguration.worldAlignment
设置为 .gravityAndHeading
时,我发现世界原点的位置和方向不稳定。
场景打开后原点位置稳定。但是轴通常绕 Y 轴旋转 180 度或 90 度。
我还缺少其他设置吗?我运行的是 2017 iPad(vanilla,不是 Pro)和 Xcode 9 beta 2。我已经在这个 iPad 上测试了几个指南针应用程序,它们给了我正确的结果,所以我相信硬件工作正常。
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()
// debug options
let debugOptions: SCNDebugOptions = [ARSCNDebugOptions.showFeaturePoints,ARSCNDebugOptions.showWorldOrigin]
sceneView.debugOptions = debugOptions
// Set the scene to the view
sceneView.scene = scene
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Create a session configuration
let configuration = ARWorldTrackingSessionConfiguration()
configuration.worldAlignment = .gravityAndHeading
configuration.planeDetection = .horizontal
// Run the view's session
sceneView.session.run(configuration)
}
这里有一些示例(在所有示例中我都面朝南)。
正 X 和 Z 指向西和北(不正确,180 度异相):
正 X 和 Z 指向东南东和西南南(接近正确):
正 X 和 Z 指向东和南(正确),但原点偏移了几米:
正 X 和 Z 指向南和西(90 度异相):
来自.gravityAndHeading
documentation:
The y-axis matches the direction of gravity as detected by the device's motion sensing hardware; that is, the vector (0,-1,0) points downward.
The x- and z-axes match the longitude and latitude directions as measured by Location Services. The vector (0,0,-1) points to true north and the vector (-1,0,0) points west. (That is, the positive x-, y-, and z-axes point east, up, and south, respectively.)
最佳答案
我意识到这是一个旧线程,但是即使发布了 ARKit 2 并且我在 iPhone 8 上使用 iOS 12、Xcode 10.1,我仍然得到不一致的世界起源。在某些情况下,蓝线应指向南,但实际上指向东或西。
我确实通过使用位置管理器标题尝试了 Sander 的建议,但这仍然不能 100% 保证我得到正确的开始方向。
谁有其他建议?
关于ios - ARSessionConfiguration.WorldAlignment = .gravityAndHeading 不稳定的世界原点/对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44896627/