public final class ARHitResult

  1. Object
  2. ARHitResult
One intersection returned by ARSession#hitTest(float, float): the world pose where the ray from the screen point met real-world geometry. Call #createAnchor() to place content at the hit.

Nested types

enum ARHitResult.TypeThe kind of real-world geometry the hit ray intersected.

Constructors

public ARHitResult(ARPose pose, float distance, ARHitResult.Type type, ARPlane plane, Object nativeHandle)Creates a hit result.

Methods

public ARPose getPose()The world pose of the intersection.
public float getDistance()The distance from the camera to the hit in meters.
public ARHitResult.Type getType()The kind of geometry the ray intersected.
public ARPlane getPlane()The plane that was hit, or null for non-plane hits.
public Object getNativeHandle()The opaque platform token backing this hit.
public ARAnchor createAnchor()Creates an anchor at this hit, letting the platform anchor to the exact native raycast result when available.

Inherited methods

Constructor details

ARHitResult

public ARHitResult(ARPose pose, float distance, ARHitResult.Type type, ARPlane plane, Object nativeHandle)
Creates a hit result. Intended for platform implementations and tests; applications receive hit results from ARSession#hitTest(float, float).

Parameters

pose ARPose
the world pose of the intersection, local Y along the surface normal
distance float
the distance from the camera in meters
type ARHitResult.Type
the kind of geometry hit
plane ARPlane
the plane that was hit, or null for non-plane hits
nativeHandle Object
an opaque platform token that lets #createAnchor() anchor to the exact native hit, or null

Method details

getPose

public ARPose getPose()
The world pose of the intersection. Local Y points along the surface normal.

getDistance

public float getDistance()
The distance from the camera to the hit in meters.

getType

public ARHitResult.Type getType()
The kind of geometry the ray intersected.

getPlane

public ARPlane getPlane()
The plane that was hit, or null for non-plane hits.

getNativeHandle

public Object getNativeHandle()
The opaque platform token backing this hit. Intended for platform implementations.

createAnchor

public ARAnchor createAnchor()
Creates an anchor at this hit, letting the platform anchor to the exact native raycast result when available.

Returns

the new anchor, registered with the session