我正在使用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的命中测试类型,但对于estimateVerticalPlane它是零。 (ARKit 1.5 how to get the rotation of a vertical plane)。
当我这样做:po调试器上的hitTestResult.worldTransform时,它会为worldTransform 91度等打印一个旋转,但我无法从变换中检索它。