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

HitInfo Class

Modifiers: final
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
    }
}

Signature

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)

Constructors

HitInfo ( entity , sceneObjectHandle , nodeId , meshElementId , distance , point , normal , textureCoordinate )
Signature
constructor(entity: Entity?, sceneObjectHandle: Long, nodeId: Int, meshElementId: Int, distance: Float, point: Vector3, normal: Vector3, textureCoordinate: Vector2)
Parameters
entity: Entity?
  The entity that was hit, or null if no entity is associated with the SceneObject
sceneObjectHandle: Long
  The handle of the SceneObject that was hit
nodeId: Int
  The ID of the node in the SceneObject that was hit
meshElementId: Int
  The ID of the mesh element (e.g., triangle) that was hit
distance: Float
  The distance from the interactor (controller, etc.) to the hit point
point: Vector3
  The 3D position of the hit point in world space
normal: Vector3
  The surface normal at the hit point in world space
textureCoordinate: Vector2
  The UV texture coordinate at the hit point
Returns

Properties

distance : Float
[Get]
The distance from the interactor (controller, etc.) to the hit point
Signature
val distance: Float
entity : Entity?
[Get]
The entity that was hit, or null if no entity is associated with the SceneObject
Signature
val entity: Entity?
meshElementId : Int
[Get]
The ID of the mesh element (e.g., triangle) that was hit
Signature
val meshElementId: Int
nodeId : Int
[Get]
The ID of the node in the SceneObject that was hit
Signature
val nodeId: Int
normal : Vector3
[Get]
The surface normal at the hit point in world space
Signature
val normal: Vector3
point : Vector3
[Get]
The 3D position of the hit point in world space
Signature
val point: Vector3
sceneObjectHandle : Long
[Get]
The handle of the SceneObject that was hit
Signature
val sceneObjectHandle: Long
textureCoordinate : Vector2
[Get]
The UV texture coordinate at the hit point
Signature
val textureCoordinate: Vector2
Did you find this page helpful?