GestureSensor
- Last UpdatedJul 03, 2025
- 4 minute read
The GestureSensor node enables multi-touch or single touch gesture recognition in applications.
-
Single touch events can be managed using the Mouse and DragSensor nodes.
Platform support
This node is partially supported on XR-Windows, XR-Portable Windows, XR-P-IOS, XR-P-AND, and XR-P-WASM.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Partial support |
Partial support |
Partial support |
Partial support |
Partial support |
|
|
|
|
|
|
Gesture support
Gesture recognition is deeply dependent on target hardware, so not all the gestures and modes supported by the node are available in all supported target devices. The gestures shared among multiple targets have been implemented in a way to provide the same values for the same action; therefore helping the creation of platform independent behaviors.
Gestures and fields
Depending on the nature of the gesture, there are different type of fields available providing details around the detected gesture. This enables the developer to manage gestures with maximum flexibility. Not all gestures are supported in all target platforms.
|
Gesture |
Event |
State |
Value |
Speed |
Position |
Direction |
Supported by |
|---|---|---|---|---|---|---|---|
|
Two fingers tap |
X |
XR-WIN, XR-P-WIN |
|||||
|
Press and tap |
X |
XR-WIN, XR-P-WIN |
|||||
|
Pan |
X |
X |
X |
X |
XR-WIN, XR-P-WIN, XR-P-IOS, XR-P-AND, XR-P-WASM |
||
|
Rotate |
X |
X |
X |
X |
X |
XR-WIN, XR-P-WIN, XR-P-IOS, XR-P-AND, XR-P-WASM |
|
|
Zoom |
X |
X |
X |
X |
X |
XR-WIN, XR-P-WIN, XR-P-IOS, XR-P-AND, XR-P-WASM |
|
|
Swipe |
X |
X |
XR-WIN, XR-P-WIN, XR-P-IOS, XR-P-AND, XR-P-WASM |
Code example
This is a code example for the GestureSensor node that captures multi-touch events.
<!-- declarations -->
<GestureSensor name="gs"/>
<Rect2D name="aRect" size="32 32" position="0 0" center="-16 -16" />
<!-- routing -->
<route from="gs.isPanning" to="crt_panRect.execute" />
<!-- Coroutine that performs the panning of the rect -->
<Coroutine name="crt_panRect">
<local name="x" type="sfloat" value="[@aRect.position.x]" />
<local name="y" type="sfloat" value="[@aRect.position.y]" />
<wait condition="[@gs.isPanning]" >
<set name="x" value="#[@%x%]+[@gs.panSpeed.x]#" />
<set name="y" value="#[@%y%]+[@gs.panSpeed.y]#" />
<set name="aRect.position" value="[@%x%] [@%y%]" />
</wait>
</Coroutine>
GestureSensor fields
These are the fields for GestureSensor node. Only the node-specific fields are indicated, not fields obtained by inheritance.
Field inheritance: NodeBase > GestureSensor
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
active |
sbool |
Optional |
true |
Enables sensor to trace gestures. |
|
down_swipe |
sevent |
Read only |
Internally calculated |
A down_swipe event is raised when a down swipe gesture is detected. |
|
isPanning |
sbool |
Read only |
Internally calculated |
Sets to true while pan gesture is active. |
|
isRotating |
sbool |
Read only |
Internally calculated |
Sets to true while rotation gesture is active. |
|
isZooming |
sbool |
Read only |
Internally calculated |
Set to true while zoom gesture is active. |
|
left_swipe |
sevent |
Read only |
Internally calculated |
A left_swipe event is raised when a left swipe gesture is detected. |
|
mode |
senum |
Optional |
gesture |
This field is available only on XR-Win. If set to gesture, the sensor will recognize gesture events from the operating system. If set to cvp3dvs, the gestures are controlled directly by the CVP3DVSBroker and the fields isZooming, zoom, isRotating, and rotate will reflect the values from the json-rpc calls received by the broker itself. If set to touch, it receives finger touch positions in touchPoints field. Note that when mode is set to touch, the application stops receiving gestures from the OS and it cannot be reverted at runtime. |
|
pan |
svec2 |
Read only |
Internally calculated |
Position relative to the gesture start position |
|
panSpeed |
svec2 |
Read only |
Internally calculated |
The distance, in pixels per second, horizontally and vertically. |
|
pressAndTap |
sbool |
Read only |
Internally calculated |
Detects the press and tap gesture. |
|
right_swipe |
sevent |
Read only |
Internally calculated |
A right_swipe event is raised when right swipe gesture is detected. |
|
rotate |
sfloat |
Read only |
Internally calculated |
The current rotation value expressed in radiants.
|
|
rotationPosition |
svec2 |
Read only |
Internally calculated |
Center of the rotation which is the stationary point when the rotate gesture is being carried out in pixels. |
|
rotateSpeed |
sfloat |
Read only |
Internally calculated |
Radians per second. |
|
supported |
sbool |
Read only |
Internally calculated |
Returns if multi-touch gesture recognition is supported by the hardware. Always return true on iOS and Android. |
|
touchPoints |
dstring |
Read only |
Internally calculated |
Detects the finger touch on the screen, returns touchID, and its position. Works only when mode is set to touch. Example: {23=145 161}{24=243 108} |
|
twoFingerDown |
sbool |
Read only |
Internally calculated |
Set to true while a gesture is active and it is performed with two fingers. |
|
twoFingerTap |
sevent |
Read only |
Internally calculated |
Detects two fingers tap gesture and raises event. |
|
up_swipe |
sevent |
Read only |
Internally calculated |
An up_swipe event is raised when an up swipe gesture is detected. |
|
zoom |
sfloat |
Read only |
Internally calculated |
The current zoom value. Range is 0 to infinite. It is the pinch gesture using first two fingers. As the distance between the two fingers increases, the zoom value increases proportionally. Similarly, the zoom value decreases as distance between fingers decreases. |
|
zoomPosition |
svec2 |
Read only |
Internally calculated |
Center of the Zoom-in/out in pixels |
|
zoomSpeed |
sfloat |
Read only |
Internally calculated |
Scale factors(zoom value) per second. |