Functions to set the mouse button actions for an rgl subscene
(the current one on the active device by default).
setmouse3d() sets the 'rgl' built-in mouse button modes (via rgl::par3d()).
pan3d() configures the callback functions of a mouse button so
that dragging it pans the subscene of an (opened) rgl device.
dbltrack3d() installs, on the given mouse button of an rgl (sub)scene,
the standard "trackball" rotation behavior (as that of parameter mouseMode
of rgl::par3d()), extended so that double-clicking resets the
viewpoint to "default" values.
Usage
setmouse3d(
none = "none",
left = "trackball",
right = "zoom",
middle = "fov",
wheel = "pull",
dev = cur3d(),
subscene = currentSubscene3d(dev)
)
pan3d(
button,
dev = cur3d(),
subscene = currentSubscene3d(dev),
message = FALSE
)
dbltrack3d(
button = 1,
max.interval = 0.4,
capture.now = FALSE,
message = FALSE,
dev = cur3d(),
subscene = currentSubscene3d(dev)
)Arguments
- none, left, right, middle, wheel
actions for the corresponding mouse button; see parameter
mouseModeofrgl::par3d().- dev
rgl device on which the mouse actions are configured. Defaults to the active device (see
rgl::cur3d()).- subscene
subscene on which the mouse actions are configured. Defaults to the device's active subscene (see
rgl::currentSubscene3d()).mouse button on which panning is configured. Use 1 for left, 2 for right, 3 for middle, 4 for wheel, and 0 to set this action when no button is pressed.
- message
whether to print a message confirming the configured button, device and subscene.
- max.interval
maximum time, in seconds, between two clicks for them to be treated as a double-click.
- capture.now
logical; if
FALSE(default) the "default" viewpoint is restored on double-click (seesetviewpoint3d()). IfTRUEthe "reset" viewpoint is set to the values in effect whendbltrack3d()is called.
Value
setmouse3d() invisibly returns the resulting mouseMode vector.
pan3d() is called for its side effect (registers the mouse callbacks); it
optionally prints a message confirming the configured button, device and
subscene.
dbltrack3d() is called for its side effect (registers the mouse callbacks); it
optionally prints a message confirming the configured button, device and
subscene.
Details
pan3d() is based on the function of the same name included as an example
in the documentation of rgl::rgl.setMouseCallbacks().
dbltrack3d() reimplements the standard trackball rotation (following the
mouseCallbacks demo shipped with rgl, demo(mouseCallbacks, package = "rgl")) so that it can measure the
time elapsed since the previous click; if this is below max.interval,
the click is treated as a double-click and the view is reset instead of
starting a new rotation.