【发布时间】:2018-10-06 08:18:50
【问题描述】:
我正在使用 ARKit 在运行时检测墙壁,当触摸屏幕的某个点时,我使用 .estimatedVerticalPlane 类型的命中测试。我正在尝试将 Y 旋转应用于与检测到的平面方向相对应的节点。
我想计算旋转:
private func computeYRotationForHitLocation(hitTestResult: ARHitTestResult) -> Float {
guard hitTestResult.type == .estimatedVerticalPlane else { return 0.0 }
// guard let planeAnchor = hitTestResult.anchor as? ARPlaneAnchor else { return 0.0 }
// guard let anchoredNode = sceneView.node(for: planeAnchor) else { return 0.0 }
let worldTransform = hitTestResult.worldTransform
let anchorNodeOrientation = ???
return .pi * anchorNodeOrientation.y
}
在给定墙壁方向的情况下,如何推断要应用的anchorNodeOrientation,这篇文章很好地解释了提供ARAnchor的命中测试类型,但对于estimatedVerticalPlane,它是nil。 (ARKit 1.5 how to get the rotation of a vertical plane)。
当我这样做时:在调试器上 po hitTestResult.worldTransform 它会打印 worldTransform 91 度等的旋转,但我无法从变换中检索它。
【问题讨论】: