我将使用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如何获取垂直平面的旋转)。
此外,当我在调试器上执行:po hitTestResult.worldTransform时,它会打印出worldTransform 91度等的旋转,但我无法从变换中检索它。