InteractionComponent
ClassEnables invoking touch interactions with a BaseMeshVisual rendered to specific Camera.
- Available on all platforms
Since Lens Scripting v141
Index
Properties
- enabled
- isBeingDestroyed
- isEnabledInHierarchy
- isFilteredByDepth
- isFocused
- isSelected
- onDoubleTap
- onFocusEnd
- onFocusStart
- onHover
- onHoverEnd
- onHoverStart
- onLongPressEnd
- onLongPressStart
- onPanEnd
- onPanMove
- onPanStart
- onPinchEnd
- onPinchMove
- onPinchStart
- onScroll
- onScrollEnd
- onScrollStart
- onSelectEnd
- onSelectStart
- onTap
- onTouchEnd
- onTouchMove
- onTouchStart
- onTriggerPrimary
- sceneObject
- uniqueIdentifier
Methods
Remarks
Sometimes touch events within lens may collide with Snapchat touch events. To avoid this use Touch Blocking.
Example
// Pass in a MeshVisual
// @input Component.BaseMeshVisual myMeshVisual
// Get a reference to the InteractionComponent
var interactionComponent = script.sceneObject.getComponent(InteractionComponent.getTypeName());
// 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);
Extends
Properties
enabled
enabled:
boolean
If disabled, the Component will stop enacting its behavior.
Default Value
true
Inherited from
isBeingDestroyed
readonlyisBeingDestroyed:boolean
Returns true if this Component is currently being destroyed. Becomes true as soon as
destruction begins via Component#destroy or destruction of its owning SceneObject,
before any OnDestroyEvent callbacks fire.
Since
Lens Scripting Version 364
Example
if (!script.isBeingDestroyed) {
// Component is still fully alive
}
Inherited from
isEnabledInHierarchy
readonlyisEnabledInHierarchy:boolean
Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.
Inherited from
Component.isEnabledInHierarchy
isFilteredByDepth
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.
Since
Lens Scripting Version 195
Default Value
true
isFocused
readonlyisFocused:boolean
Returns whether the user is currently gazing at the object on wearable devices, and when the user is touching on mobile devices.
Since
Lens Scripting Version 148
isSelected
readonlyisSelected:boolean
Returns whether the user is currently selecting and gazing at an object on wearable devices, or touching it on mobile devices.
Since
Lens Scripting Version 148
onDoubleTap
readonlyonDoubleTap:event1<DoubleTapEventArgs,void>
Triggered when the user double taps on the screen.
Since
Lens Scripting Version 193
onFocusEnd
readonlyonFocusEnd: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.
Since
Lens Scripting Version 148
onFocusStart
readonlyonFocusStart: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.
Since
Lens Scripting Version 148
onHover
readonlyonHover:event1<HoverEventArgs,void>
Gets called when hover events are passed to the lens.
Since
Lens Scripting Version 324
onHoverEnd
readonlyonHoverEnd:event1<HoverEndEventArgs,void>
Gets called when hover events are finished.
Since
Lens Scripting Version 324
onHoverStart
readonlyonHoverStart:event1<HoverStartEventArgs,void>
Gets called when hover event is initially triggered.
Since
Lens Scripting Version 324
onLongPressEnd
readonlyonLongPressEnd:event1<LongPressEndEventArgs,void>
Triggered when the user ends a tap and hold.
Since
Lens Scripting Version 327
onLongPressStart
readonlyonLongPressStart:event1<LongPressStartEventArgs,void>
Triggered when the user begins to tap and hold.
Since
Lens Scripting Version 327
onPanEnd
readonlyonPanEnd:event1<PanEndEventArgs,void>
Triggered when the pan ends.
Since
Lens Scripting Version 327
onPanMove
readonlyonPanMove:event1<PanMoveEventArgs,void>
Triggered when the user is panning.
Since
Lens Scripting Version 327
onPanStart
readonlyonPanStart:event1<PanStartEventArgs,void>
Triggered when the user starts to pan across the screen.
Since
Lens Scripting Version 327
onPinchEnd
readonlyonPinchEnd:event1<PinchEndEventArgs,void>
Triggered when the user ends the pinch.
Since
Lens Scripting Version 327
onPinchMove
readonlyonPinchMove:event1<PinchMoveEventArgs,void>
Triggered when the user is pinching the screen.
Since
Lens Scripting Version 327
onPinchStart
readonlyonPinchStart:event1<PinchStartEventArgs,void>
Triggered when the user pinches the screen.
Since
Lens Scripting Version 327
onScroll
readonlyonScroll:event1<ScrollEventArgs,void>
Gets called when user scrolls on screen.
Since
Lens Scripting Version 141
onScrollEnd
readonlyonScrollEnd:event1<ScrollEndEventArgs,void>
Gets called when scroll ends.
Since
Lens Scripting Version 141
onScrollStart
readonlyonScrollStart:event1<ScrollStartEventArgs,void>
Gets called when scroll begins.
Since
Lens Scripting Version 141
onSelectEnd
readonlyonSelectEnd: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.
Since
Lens Scripting Version 148
onSelectStart
readonlyonSelectStart: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.
Since
Lens Scripting Version 148
onTap
readonlyonTap:event1<TapEventArgs,void>
Triggered when the user taps on the screen.
Since
Lens Scripting Version 148
onTouchEnd
readonlyonTouchEnd:event1<TouchEndEventArgs,void>
Triggered when a touch event ends.
Since
Lens Scripting Version 148
onTouchMove
readonlyonTouchMove:event1<TouchMoveEventArgs,void>
Triggered when a touch position on the screen is moved.
Since
Lens Scripting Version 148
onTouchStart
readonlyonTouchStart: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.
Since
Lens Scripting Version 148
onTriggerPrimary
readonlyonTriggerPrimary:event1<TriggerPrimaryEventArgs,void>
Gets called when the user triggers the primary input on their device. For example touch on touch screens.
Since
Lens Scripting Version 148
sceneObject
readonlysceneObject:SceneObject
The SceneObject this component is on.
Inherited from
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
addMeshVisual()
addMeshVisual(
meshVisual):void
Adds a MeshVisual as a target for interaction detection.
Parameters
| Parameter | Type |
|---|---|
meshVisual | BaseMeshVisual |
Returns
void
Since
Lens Scripting Version 141
addTouchBlockingException()
addTouchBlockingException(
exception):void
Adds a touch type that this component will ignore.
Parameters
| Parameter | Type |
|---|---|
exception | string |
Returns
void
Since
Lens Scripting Version 141
destroy()
destroy():
void
Destroys the component.
Returns
void
Inherited from
getMinimumTouchSize()
getMinimumTouchSize():
number
Returns the minimum bounding box size used for detecting touches. Value range is from [0-1], relative to screen width.
Returns
number
Since
Lens Scripting Version 141
getSceneObject()
getSceneObject():
SceneObject
Returns the SceneObject the component is attached to.
Returns
Inherited from
getTransform()
getTransform():
Transform
Returns the Transform this component is attached to.
Returns
Inherited from
getTypeName()
staticgetTypeName():TypeName<InteractionComponent>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<InteractionComponent>
Since
Lens Scripting Version 141
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
removeMeshVisual()
removeMeshVisual(
meshVisual):void
Removes a MeshVisual as a target for interaction detection.
Parameters
| Parameter | Type |
|---|---|
meshVisual | BaseMeshVisual |
Returns
void
Since
Lens Scripting Version 141
setCamera()
setCamera(
camera):void
Sets the camera that will be used for interaction detection.
Parameters
| Parameter | Type |
|---|---|
camera | Camera |
Returns
void
Since
Lens Scripting Version 141
setMinimumTouchSize()
setMinimumTouchSize(
value):void
Sets the minimum bounding box size used for detecting touches. Value range is from [0-1], relative to screen width.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Since
Lens Scripting Version 141
See also
- Touch And Interactions guide.
- Touch Blocking guide.