According to this article by apple Ray-Casting and Hit-Testing. I should use ray casting provided by RealityKit to detect the surfaces instead of hit testing provided by ARKit as apple says
but the hit-testing functions remain present for compatibility
. However,I can't find a way to know the extent of the surface detected by the raycast query.
So according to this code:
func startRayCasting() {
guard let raycastQuery = arView.makeRaycastQuery(from: arView.center,
allowing: .estimatedPlane,
alignment: .vertical) else {
return
}
guard let result = arView.session.raycast(raycastQuery).first else {
return
}
let transformation = Transform(matrix: result.worldTransform)
let plane = Plane(color: .green, transformation: transformation)
plane.transform = transformation
let raycastAnchor = AnchorEntity(raycastResult: result)
raycastAnchor.addChild(plane)
arView.scene.addAnchor(raycastAnchor)
}
I would expect that the plane I am creating would get the size and position of the plane detected. However this does not happen.
So my question is, Is ray casting suitable for detecting the surfaces size and location. Or its just for checking the 2d point location on a surface.