rglMouse: Generate HTML code to select mouse mode.

Description Usage Arguments Details Value Author(s) Examples

View source: R/rglMouse.R

Description

This generates an HTML select element to choose among the mouse modes supported by rglwidget.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
if (interactive()) {
  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 = .) 
}

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 

rgl documentation built on Feb. 1, 2021, 3:01 a.m.