Generate HTML code to select mouse mode
rglMouse.RdThis generates an HTML select element to
choose among the mouse modes supported by rglwidget.
Usage
rglMouse(sceneId,
choices = c("trackball", "selecting",
"xAxis", "yAxis", "zAxis",
"polar", "zoom", "fov",
"none"),
labels = choices,
button = 1,
dev = cur3d(),
subscene = currentSubscene3d(dev),
default = par3d("mouseMode", dev = dev, subscene = subscene)[button + 1],
stayActive = FALSE,
height = 40,
...)Arguments
- sceneId
Either an
rglwidgetor theelementIdfrom one of them.- choices
Which mouse modes to support?
- labels
How to label each mouse mode.
Which mouse button is being controlled.
- dev
The RGL device used for defaults.
- subscene
Which subscene is being modified.
- default
What is the default entry to show in the control.
- stayActive
Whether a selection brush should stay active if the mouse mode is changed.
- height
The (relative) height of the item in the output display.
- ...
Additional arguments to pass to
htmltools::tags$select(), e.g.idorclass.
Details
A result of an rglwidget call can be passed
as the sceneId argument. This allows the widget
to be “piped” into the rglMouse call.
The widget will appear first, the selector next in
a tagList.
If the sceneId is a character string, it should be
the elementId of a separately constructed
rglwidget result.
Finally, the sceneId can be omitted. In this case
the rglMouse result needs to be passed into an
rglwidget call as part of the
controllers argument. This will place the selector before the
widget on the resulting display.
If the mouse mode is changed while brushing the scene,
by default the brush will be removed (and so the selection
will be cleared too). If this is not desired, set
stayActive = TRUE.
See also
The User Interaction in WebGL vignette gives more details.
Examples
if (interactive() || in_pkgdown_example()) {
open3d()
xyz <- matrix(rnorm(300), ncol = 3)
id <- plot3d(xyz, col = "red", type = "s")["data"]
par3d(mouseMode = "selecting")
share <- rglShared(id)
# This puts the selector below the widget.
rglwidget(shared = share, width = 300, height = 300) %>% rglMouse()
# This puts the selector above the widget.
rglMouse() %>% rglwidget(shared = share, width = 300, height = 300, controllers = .)
}