DragSensor
- Last UpdatedFeb 19, 2025
- 3 minute read
The DragSensor node is used to handle drag interaction made with the mouse or with a touchscreen against one of the two 2D directions x or y.
-
The sensor can be enabled and disabled, and you can define whether to use inertia.
-
When dragging, at every frame step, the sensor returns on its addValue parameter, the difference between the previous and the new dragging position.
-
It is not possible to use a Dragsensor to directly drive a SFLOAT field. It must pass through a totalizer, such as a range node.
-
The steps to rotate a mesh using a DragSensor are: dragsensor > range > mesh.
Platform support
This node is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-Portable WASM platforms.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Full support |
Full support |
Full support |
Full support |
Full support |
|
|
|
|
|
|
Code example
This is a code example for the DragSensor node.
<Dragsensor name="drag" axis="x" inertia="0.3" />
Position
The DragSensor node must be inside a context node, such as Context or Global.
DragSensor fields
These are the fields for DragSensor node. Only the node-specific fields are indicated, not fields obtained by inheritance.
Field inheritance: NodeBase > DragSensor
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
accelerationFactor |
sfloat |
Optional |
0.5 |
Available only when type is Inertia. Customizes the inertial behavior. |
|
active |
sbool |
Optional |
true |
Detects whether the sensor is active. |
|
addValue |
sfloat |
Read only |
Not set |
Returns the position variation after each step. |
|
axis |
sstring |
Optional |
x |
Specifies x or y axis. |
|
decelerationFactor |
sfloat |
Optional |
0.5 |
Available only when type is Inertia. Customizes the inertial behavior. |
|
dragActive |
sbool |
Read only |
Not set |
True when the user is dragging the sensor, otherwise false. |
|
inertia |
sfloat |
Optional |
0 |
Available only when type is Inertia. Sets the inertia that contrasts the dragging. |
|
scale |
sfloat |
Optional |
1 |
Modifies the sensor sensibility. |
|
type |
senum |
Optional |
TOUCH |
Accepts two values for type:
|
|
useVirtualMouse |
sbool |
Optional |
False |
When set to True, the DragSensor will keep getting updated by physical movement of the mouse, even when the mouse cursor is locked by the global.mouseLock parameter. |