rglMouse.Rd
This generates an HTML select
element to
choose among the mouse modes supported by rglwidget
.
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,
...)
Either an rglwidget
or the elementId
from one of them.
Which mouse modes to support?
How to label each mouse mode.
Which mouse button is being controlled.
The RGL device used for defaults.
Which subscene is being modified.
What is the default entry to show in the control.
Whether a selection brush should stay active if the mouse mode is changed.
The (relative) height of the item in the output display.
Additional arguments to pass to htmltools::tags$select()
, e.g. id
or class
.
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
.
A browsable value to put in a web page.
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 = .)
}