# HitTestResult

Artifact: [androidx.xr.scenecore:scenecore](https://developer.android.com/jetpack/androidx/releases/xr-scenecore) [View Source](https://cs.android.com/search?q=file:androidx/xr/scenecore/HitTestResult.kt+class:androidx.xr.scenecore.HitTestResult) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
public final class HitTestResult
```

<br />

*** ** * ** ***

Specifies an intersection between a ray and the Scene.

This can be obtained by running `https://developer.android.com/reference/androidx/xr/scenecore/ScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` and related methods.

## Summary

| ### Nested types |
|---|
| `public static class https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult.SurfaceType` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult#HitTestResult(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3,kotlin.Int,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 hitPosition, https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 surfaceNormal, int surfaceType, float distance )` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float` | `https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult#getDistance()()` the distance from the origin to the hit location. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` | `https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult#getHitPosition()()` the `https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` position of the intersection between a ray and the Scene. |
| `final https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` | `https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult#getSurfaceNormal()()` The normal of the surface of the Entity or surface that was hit, or null if the normal could not be computed. |
| `final int` | `https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult#getSurfaceType()()` the `https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult.SurfaceType` that was hit. |
| `int` | `https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult#hashCode()()` |

## Public constructors

### HitTestResult

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public HitTestResult(
    @NonNull Vector3 hitPosition,
    Vector3 surfaceNormal,
    int surfaceType,
    float distance
)
```

## Public methods

### equals

```
public boolean equals(Object other)
```

### getDistance

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @FloatRange(from = 0.0) float getDistance()
```

the distance from the origin to the hit location.

### getHitPosition

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull Vector3 getHitPosition()
```

the `https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` position of the intersection between a ray and the Scene.

### getSurfaceNormal

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final Vector3 getSurfaceNormal()
```

The normal of the surface of the Entity or surface that was hit, or null if the normal could not be computed.

### getSurfaceType

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final int getSurfaceType()
```

the `https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult.SurfaceType` that was hit.

### hashCode

```
public int hashCode()
```