Lens Scripting API

    Defines API for Interactor type

    Hierarchy (View Summary, Expand)

    Implements

    Index

    Constructors

    Properties

    _currentDragVector: vec3 = null
    _dragProvider: DragProvider = ...
    _drawDebug: boolean = false
    _maxRaycastDistance: number = 500
    _planecastDragProvider: DragProvider = ...
    _previousStartPoint: vec3 = null
    api: Record<string, any>

    Generic object accessible by other instances of ScriptComponent. Use this object to store references to properties and methods that need to be accessible from other ScriptComponents.

    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    indirectDragThreshold: number = 3.0
    indirectTargetingVolumeMultiplier: number = 1

    A multiplier applied to spherecast radii when using indirect targeting. Larger values create wider targeting areas, making it easier to target objects at the expense of precision. Smaller values provide more precise targeting.

    interactionManager: InteractionManager = ...
    name: string
    onCurrentInteractableChanged: PublicApi<Interactable> = ...

    Called whenever the Interactor changes the target Interactable

    onTriggerCanceled: PublicApi<Interactable> = ...

    Called whenever the Interactor is lost and was in a triggered state (regardless of if there is a target or not).

    onTriggerEnd: PublicApi<Interactable> = ...

    Called whenever the Interactor exits the triggered state (regardless of if there is a target or not).

    onTriggerStart: PublicApi<Interactable> = ...

    Called whenever the Interactor enters the triggered state (regardless of if there is a target or not).

    onTriggerUpdate: PublicApi<Interactable> = ...

    Called whenever the Interactor remains in the triggered state (regardless of if there is a target or not).

    sceneObject: SceneObject

    The scene object this component is on.

    spherecastDistanceThresholds: number[] = ...

    Defines distance offsets (in cm) from the ray origin for performing sphere casts. Each value creates a sphere cast starting point at [ray origin + (direction * offset)]. Used in sequence with spherecastRadii, with the system trying progressively larger sphere casts until a target is found. Helps improve targeting of small or distant objects. Must have the same array length as spherecastRadii.

    sphereCastEnabled: boolean = false
    spherecastRadii: number[] = ...

    Defines the radii (in cm) used for progressive spherecasting when raycast fails to hit a target. Used in sequence with spherecastDistanceThresholds to perform increasingly larger sphere casts until a target is found. Smaller radii provide more precise targeting while larger radii help target small or distant objects. Must have the same array length as spherecastDistanceThresholds.

    uniqueIdentifier: string
    updatePriority: number

    Accessors

    • get distanceToTarget(): number

      Returns number

      in favor of using targetHitInfo Returns the distance to the current target in cm

    • get dragType(): DragType

      Used to define the type of drag vector that the interactor is invoking. By default, interactor drag vectors will be as SixDof drags.

      Returns DragType

    • get drawDebug(): boolean

      Returns boolean

      if the Interactor is currently drawing a debug gizmo of collider/raycasts in the scene.

    • set drawDebug(debug: boolean): void

      Set if the Interactor is should draw a debug gizmo of collider/raycasts in the scene.

      Parameters

      • debug: boolean

      Returns void

    • get endedInsideInteractable(): boolean

      Returns true if the interaction ended inside the Interactable it started in. Updated when an interaction ends.

      Returns boolean

    • get interactionStrength(): number

      Returns a normalized value from 0-1, where 0 is the lowest strength and 1 the highest. Returns null if the strength cannot be computed.

      Returns number

    • get maxRaycastDistance(): number

      Returns the maximum raycast length for world targeting in cm

      Returns number

    • get planecastDragVector(): vec3

      Returns vec3

      the drag vector projected onto the plane defined by the current Interactable's forward and origin

    • get targetHitPosition(): vec3

      Returns vec3

      in favor of using targetHitInfo Returns the point at which the interactor intersected the current target

    Methods

    • Returns void

    • Clears the current Interactable, used when an Interactable is deleted at runtime

      Returns void

    • Returns void

    • Projects the direct collider's position onto the plane defined by the Interactable's forward vector / origin

      Parameters

      • interactable: Interactable

        the Interactable used to define the plane of intersection

      Returns vec3

      the direct collider's position projected onto the plane

    • Parameters

      Returns void

    • Returns true if the interactor is active

      Returns boolean

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if the interactor is actively targeting

      Returns boolean

    • Process the new currentTrigger and compare to previousTrigger to see what event to propagate.

      Returns void

    • Calculates the intersection of the Interactor's indirect raycast and the plane defined by the Interactable's forward vector / origin

      Parameters

      • interactable: Interactable

        the Interactable used to define the plane of intersection

      Returns vec3

      the intersection point of the indirect raycast and plane

    • Disables or enables the input powering this interactor

      Parameters

      • enabled: boolean

        whether the input powering the interactor should be enabled

      Returns void

    • Returns void

    • Updates the targeting and trigger state of the interactor

      Returns void

    MMNEPVFCICPMFPCPTTAAATR