Lens Scripting API

    Class InteractionComponent

    Enables invoking touch interactions with a BaseMeshVisual rendered to specific Camera.

    Sometimes touch events within lens may collide with Snapchat touch events. To avoid this use Touch Blocking.

    // Pass in a MeshVisual
    // @input Component.BaseMeshVisual myMeshVisual

    // Get a reference to the InteractionComponent
    var interactionComponent = script.getComponent("Component.InteractionComponent");

    // Sets the MeshVisual to handle touches
    interactionComponent.addMeshVisual(script.myMeshVisual);

    // Allow certain touch types to be passed to Snapchat
    interactionComponent.addTouchBlockingException("TouchTypeDoubleTap");
    //@input Component.InteractionComponent interactionComponent

    // Subscribe to the onTap event
    var onTapEvent = script.interactionComponent.onTap.add(function(tapEventArgs){
    print("onTap!");
    });

    // Unsubscribe from the onTap event
    script.interactionComponent.onTap.remove(onTapEvent);

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    Properties

    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    isFilteredByDepth: boolean

    When enabled, interaction events will be invoked only on the"closest" object, where order is defined by distance from camera and camera render order.

    isFocused: boolean

    Returns whether the user is currently gazing at the object on wearable devices, and when the user is touching on mobile devices.

    isSelected: boolean

    Returns whether the user is currently selecting and gazing at an object on wearable devices, or touching it on mobile devices.

    onFocusEnd: event1<FocusEndEventArgs, void>

    On mobile devices, this is triggered when the user releases their touch. On wearable devices, this is triggered when the user looks away from the current object.

    onFocusStart: event1<FocusStartEventArgs, void>

    On mobile devices, this is triggered when the user starts touching. On wearable devices, this is triggered when the user gazes on the current object.

    onSelectEnd: event1<SelectEndEventArgs, void>

    On mobile devices, this is triggered when the user releases their touch. On wearable devices, this is triggered when the user stops touching the current object.

    onSelectStart: event1<SelectStartEventArgs, void>

    On mobile devices, this is triggered when the user starts touching the current object. On wearable devices, this is triggered when the user touches the touchpad while focusing on an object.

    onTap: event1<TapEventArgs, void>

    Triggered when the user taps on the screen.

    onTouchEnd: event1<TouchEndEventArgs, void>

    Triggered when a touch event ends.

    onTouchMove: event1<TouchMoveEventArgs, void>

    Triggered when a touch position on the screen is moved.

    onTouchStart: event1<TouchStartEventArgs, void>

    Triggered when a touch event starts--either on the screen or on a touchpad. On wearables with touchpad, the coordinate returned are based on the touchpad and not the screen.

    onTriggerPrimary: event1<TriggerPrimaryEventArgs, void>

    Gets called when the user triggers the primary input on their device. For example touch on touch screens.

    sceneObject: SceneObject

    The scene object this component is on.

    uniqueIdentifier: string

    Methods

    • Adds a MeshVisual as a target for interaction detection.

      Parameters

      Returns void

    • Adds a touch type that this component will ignore.

      Parameters

      • exception: string

      Returns void

    • Destroys the component.

      Returns void

    • Returns the minimum bounding box size used for detecting touches. Value range is from [0-1], relative to screen width.

      Returns number

    • Returns the name of this object's type.

      Returns string

    • 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

    • Removes a MeshVisual as a target for interaction detection.

      Parameters

      Returns void

    • Sets the camera that will be used for interaction detection.

      Parameters

      Returns void

    • Sets the minimum bounding box size used for detecting touches. Value range is from [0-1], relative to screen width.

      Parameters

      • value: number

      Returns void

    MMNEPVFCICPMFPCPTTAAATR