Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rglMouse

Generate HTML code to select mouse mode


Description

This 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],
         stayActive = FALSE,
         height = 40,
         ...)

Arguments

sceneId

Either an rglwidget or the elementId from one of them.

choices

Which mouse modes to support?

labels

How to label each mouse mode.

button

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. id or class.

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.

Value

A browsable value to put in a web page.

Author(s)

Duncan Murdoch

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 = .) 
}

rgl

3D Visualization Using OpenGL

v0.106.8
GPL
Authors
Duncan Murdoch [aut, cre], Daniel Adler [aut], Oleg Nenadic [ctb], Simon Urbanek [ctb], Ming Chen [ctb], Albrecht Gebhardt [ctb], Ben Bolker [ctb], Gabor Csardi [ctb], Adam Strzelecki [ctb], Alexander Senger [ctb], The R Core Team [ctb, cph], Dirk Eddelbuettel [ctb], The authors of Shiny [cph], The authors of knitr [cph], Jeroen Ooms [ctb], Yohann Demont [ctb], Joshua Ulrich [ctb], Xavier Fernandez i Marin [ctb], George Helffrich [ctb], Ivan Krylov [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.