Lens Scripting API
    Preparing search index...

    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.sceneObject.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)

    Index

    Properties

    enabled: boolean

    If disabled, the Component will stop enacting its behavior.

    isEnabledInHierarchy: boolean

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

    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.

    onDoubleTap: event1<DoubleTapEventArgs, void>

    Triggered when the user double taps on the screen.

    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.

    onHover: event1<HoverEventArgs, void>

    Gets called when hover events are passed to the lens.

    onHoverEnd: event1<HoverEndEventArgs, void>

    Gets called when hover events are finished.

    onHoverStart: event1<HoverStartEventArgs, void>

    Gets called when hover event is initially triggered.

    onLongPressEnd: event1<LongPressEndEventArgs, void>

    Triggered when the user ends a tap and hold.

    onLongPressStart: event1<LongPressStartEventArgs, void>

    Triggered when the user begins to tap and hold.

    onPanEnd: event1<PanEndEventArgs, void>

    Triggered when the pan ends.

    onPanMove: event1<PanMoveEventArgs, void>

    Triggered when the user is panning.

    onPanStart: event1<PanStartEventArgs, void>

    Triggered when the user starts to pan across the screen.

    onPinchEnd: event1<PinchEndEventArgs, void>

    Triggered when the user ends the pinch.

    onPinchMove: event1<PinchMoveEventArgs, void>

    Triggered when the user is pinching the screen.

    onPinchStart: event1<PinchStartEventArgs, void>

    Triggered when the user pinches the screen.

    onScroll: event1<ScrollEventArgs, void>

    Gets called when user scrolls on screen.

    onScrollEnd: event1<ScrollEndEventArgs, void>

    Gets called when scroll ends.

    onScrollStart: event1<ScrollStartEventArgs, void>

    Gets called when scroll begins.

    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 SceneObject 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