Lens Scripting API
    Preparing search index...

    Interactor implementation used for touch bases interactions to interact with Interactable components with the mouse cursor in preview window of Lens Studio

    There are no events for mouse hover in Lens Studio so this class uses some technics to achieve both hover and trigger events.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    _currentDragVector: vec3 = null
    _dragProvider: DragProvider = ...
    _drawDebug: boolean = false
    _isHoveringCurrentInteractable: boolean = null
    _maxRaycastDistance: number = 500
    _planecastDragProvider: DragProvider = ...
    _previousStartPoint: vec3 = null
    _wasHoveringCurrentInteractable: boolean = 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 = 10.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 = ...
    isEnabledInHierarchy: boolean

    Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.

    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 SceneObject 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 activeTargetingMode(): TargetingMode

      Returns the targeting mode used to obtain the targeted interactable

      Returns TargetingMode

    • get currentDragVector(): vec3

      Returns the current vector associated to a dragging movement since the last frame, and null if not dragging

      Returns vec3

    • set currentDragVector(dragVector: vec3): void

      Parameters

      Returns void

    • get currentInteractable(): Interactable

      Returns the current targeted interactable or null.

      Returns Interactable

    • set currentInteractable(interactable: Interactable): void

      Parameters

      Returns void

    • get deltaStartPosition(): vec3

      Returns the delta start position from previous frame

      Returns vec3

    • get direction(): vec3

      Returns the direction the interactor's ray is pointing toward.

      Returns vec3

    • 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 endPoint(): vec3

      Returns the point where the interactor's ray ends.

      Returns vec3

    • get hoveredInteractables(): Interactable[]

      Returns a list of Interactables that the Interactor is hovering (targeting ray intersects w/ Interactable's collider).

      Returns Interactable[]

    • 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 isHoveringCurrentInteractable(): boolean

      Returns true if the Interactor is hovering the current Interactable in the current frame.

      Returns boolean

    • get isTriggering(): boolean

      Returns if the Interactor is in some generic triggering state in the current frame.

      Returns boolean

    • get maxRaycastDistance(): number

      Returns the maximum raycast length for world targeting in cm

      Returns number

    • get orientation(): quat

      Returns the orientation of the interactor

      Returns quat

    • get planecastDragVector(): vec3

      Returns vec3

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

    • get planecastPoint(): vec3

      Returns vec3

    • get previousDragVector(): vec3

      Returns the nullable drag vector, computed in the previous frame

      Returns vec3

    • set previousDragVector(dragVector: vec3): void

      Parameters

      Returns void

    • get previousInteractable(): Interactable

      Returns the previous targeted interactable or null.

      Returns Interactable

    • set previousInteractable(interactable: Interactable): void

      Parameters

      Returns void

    • get startPoint(): vec3

      Returns the point where the interactor's ray starts.

      Returns vec3

    • get targetHitInfo(): InteractableHitInfo

      Returns the InteractableHitInfo describing the intersection with the current target This includes information such as the intersection position/normal, the Interactable, the collider, etc

      Returns InteractableHitInfo

    • get targetHitPosition(): vec3

      Returns vec3

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

    • get wasHoveringCurrentInteractable(): boolean

      Returns true if the Interactor was hovering the current Interactable in the previous frame.

      Returns boolean

    • get wasTriggering(): boolean

      Returns if the Interactor was in some generic triggering state in the previous frame.

      Returns boolean

    Methods

    • 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

    • Returns true if the Interactor is hovering over the given Interactable. An Interactor can hover over multiple overlapping Interactables at once, but only the most deeply nested Interactable will receive the official onHover events.

      This is useful for creating custom behaviors when receiving onHoverEnter/Exit events during trigger.

      Parameters

      Returns boolean

    • Returns true if the Interactor is hovering over the given Interactable or any of its Interactable descendants. An Interactor can hover over multiple overlapping Interactables at once, but only the most deeply nested Interactable will receive the official onHover events.

      This is useful for creating custom behaviors when receiving onHoverEnter/Exit events during trigger.

      Parameters

      Returns boolean

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

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Returns true if the interactor is actively targeting

      Returns boolean

    • Returns void

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

      Parameters

      • interactable: Interactable

        the Interactable used to define the plane of intersection

      • position: vec3

        the world position to project onto the plane

      Returns vec3

      the direct collider's position projected onto the plane

    • 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

      Returns void

    • Updates the targeting and trigger state of the interactor

      Returns void