Dragging sensors are a special kind of sensors that not only track users
motion but also move the objects within the same group as the sensor. There
are three type of dragging sensors:
PlaneSensor:
lets the user move objects in the XY plane.
CylinderSensor:
Maps the movement to the surface of a conceptual cylinder.
SphereSensor:
Maps the movement to the surface of a conceptual sphere.
The above sensors all share the following fields:
enabled defines the status of the sensor
offset indicates the initial position of the shapes within the
group, a zero offset will mean that the shapes will be moved from
their original position, whereas an offset different from zero will
indicate that dragging starts at the original position plus the specified
offset. The offset value is ignored if autoOffset is
TRUE. Note that the type of the offset field varies with the type
of the sensor.
autoOffset specifies if the browser should track the current
position or do all dragging operations relative to the original position.
Only relevant for the second and subsequent draggings. If autoOffset
is TRUE then the second dragging will start where the first one ended,
if FALSE then the shapes will return to their original position each time
a new dragging operation begins.
The following events are common to all the sensors:
isActive indicates whether a dragging operation is being done.
The isActive will output TRUE if the user has the mouse pressed
over a shape within the same group as the sensor, and FALSE otherwise.
trackPoint_changed provides the actual coordinates in the surface
defined by the sensor
rotation_changed (SphereSensor and CylinderSensor) and translation_changed
(PlaneSensor) provides the relative orientation or translation being made.
In order to actually move the shapes you should place the shapes inside
a Transform
node. The Transform node should be in the same group as the sensor.
You then need to route this events to fields in a Transform
group. See the examples provided for each sensor.
Note that, for all sensors, the sensor should NOT be placed inside the
same Transform group as the shapes that one wishes to move. The following
examples provide an example of the difference in behavior for the different
positions of the sensor within the file:
When the Sensor is placed inside the Transform things don't work as expected.
The reason for this strange behavior is that the sensors coordinate system
is being altered as the shape is dragged because the coordinate system
for the sensor is the same as the shape. Placing the sensor outside the
transform solves the problem.
If using multiple sensors in the same group it is up to you to specify
which does what, they will all generate events when any of the shapes within
the group is affected.
If using multiple drag sensors in nested groups then the inner group sensors
grab the users action and the outer group sensors will ignore it.