I am using ARKit to detect walls at runtime, I use a hit test of type .estimatedVerticalPlane when some point of the screen is touched. I am trying to apply Y rotation to node corresponding to the detected plane orientation.
I want to compute the rotation in :
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
}
How to deduce the anchorNodeOrientation to apply given the wall orientation, this post explains it well for a hit test type that provide an ARAnchor but for estimatedVerticalPlane it is nil. (ARKit 1.5 how to get the rotation of a vertical plane).
Also when I do : po hitTestResult.worldTransform on the debugger it prints a rotation for worldTransform 91 degrees etc but I cannot retrieve it from the transform.