I'm trying to raycast using RealityKit from the camera's current position.
func session(_ session: ARSession, didUpdate frame: ARFrame) {
if let results = arView?.scene.raycast(origin: frame.camera.transform, direction: frame.camera.eulerAngles),
results.count > 0 {
if let distance = results.first?.distance,
Since there is little documentation on this, I'm struggling to translate the camera's transform into a raycast.
The following works as expected:
if let entities = arView?.entities(at: screenCenter), entities.count > 0 {
print("entities: \(entities)")
But I cannot calculate the distance from the camera.