API reference
API reference
Select your platform
No SDKs available
No versions available

HitInfo

HitInfo

class HitInfo(val entity: Entity?, val sceneObjectHandle: Long, val nodeId: Int, val meshElementId: Int, val distance: Float, val point: Vector3, val normal: Vector3, val textureCoordinate: Vector2)
Contains information about a ray intersection hit in a 3D scene.
When performing ray casting or intersection testing in a 3D scene, HitInfo objects are returned to provide detailed information about where and how the ray intersected with scene geometry.
HitInfo objects are typically obtained from methods like Scene.lineSegmentIntersect or Scene.rayArcIntersect, and are included in button event arguments like ButtonClickEventArgs and ButtonDownEventArgs.
Example usage:
// Perform a ray cast from the controller position in the forward direction
val hitInfo = scene.lineSegmentIntersect(
    dataModel,
    controllerPosition,
    controllerPosition + (controllerForward * maxDistance)
)

// Check if something was hit
if (hitInfo != null) {
    // Access hit information
    val hitEntity = hitInfo.entity
    val hitPoint = hitInfo.point
    val hitNormal = hitInfo.normal
    val hitDistance = hitInfo.distance

    // Perform actions based on the hit
    if (hitEntity != null) {
        // Interact with the hit entity
    }
}

Constructors

NameSummary
HitInfo
constructor(entity: Entity?, sceneObjectHandle: Long, nodeId: Int, meshElementId: Int, distance: Float, point: Vector3, normal: Vector3, textureCoordinate: Vector2)

Properties

NameSummary
distance
val distance: Float

The distance from the ray origin to the hit point
entity
val entity: Entity?

The entity that was hit, or null if no entity is associated with the SceneObject
meshElementId
val meshElementId: Int

The ID of the mesh element (e.g., triangle) that was hit
nodeId
val nodeId: Int

The ID of the node in the SceneObject that was hit
normal
val normal: Vector3

The surface normal at the hit point in world space
point
val point: Vector3

The 3D position of the hit point in world space
sceneObjectHandle
val sceneObjectHandle: Long

The handle of the SceneObject that was hit
textureCoordinate
val textureCoordinate: Vector2

The UV texture coordinate at the hit point
Did you find this page helpful?
Thumbs up icon
Thumbs down icon