Write HTML/Javascript code to control a WebGL display.

These functions write out HTML code to control WebGL displays on the same page.

subsetSlider(subsets, labels = names(subsets), 
             fullset = Reduce(union, subsets),
             subscenes = currentSubscene3d(), prefixes = "",
             accumulate = FALSE, ...)
subsetSetter(subsets, subscenes = currentSubscene3d(), prefixes = "", 
			 fullset = Reduce(union, subsets),
                         accumulate = FALSE)
clipplaneSlider(a=NULL, b=NULL, c=NULL, d=NULL, 
                plane = 1, clipplaneids, prefixes = "", 
                labels = signif(values[,1],3), ...)
toggleButton(subset, subscenes = currentSubscene3d(), prefixes = "", 
             label = deparse(substitute(subset)), 
             id = paste0(basename(tempfile("input"))), name = id)

A list of vectors of object identifiers; the slider or setter will choose among them.


Labels to display corresponding to each subset. If NULL, numeric labels will be shown.


Objects in the subscene which are not in fullset will not be touched.


The subscenes to be controlled.


The prefixes of the WebGL scenes to be controlled.


If TRUE, the subsets will accumulate (by union) as the value increases.


The id of the input control that will be generated.


The name of the input control that will be generated.


Arguments to pass to propertySlider.


The parameter values to change. Leave as NULL to hold the parameter constant.

plane, clipplaneids

The identifier of the particular clipplane to modify.


The subset that the button should toggle.


The button label.


subsetSlider and clipplaneSlider generate an HTML5 slider control with a text label. To display no text, set the labels to blanks in the ... argument.

subsetSetter is a low-level function to produce the Javascript code used by subsetSlider. This code will not touch objects in the subscene if they are not in fullset. fullset defaults to the union of all the object ids mentioned in subsets, so by default if an id is not mentioned in one of the subsets, it will not be controlled by the slider.

toggleButton generates a button that toggles the presence of objects within a subscene. If the first entry in subset is in the subscene, all are deleted, otherwise all are added.

clipplaneSlider allows a clipping plane to be moved to a sequence of positions. Any non-NULL entries among a, b, c, d should be vectors; the slider will set those parameters of the selected clipping plane to corresponding values as the slider is moved.


subsetSetter returns a length-one character vector of class "propertySetter".

The other functions use cat to write their output and invisibly return the id of the control that was generated.

See Also

playwidget and toggleWidget for a newer, preferred method of inserting controls into a scene.

Older functions include writeWebGL. See propertySlider and propertySetter for lower level, more flexible functions.

  • subsetSlider
  • subsetSetter
  • clipplaneSlider
  • toggleButton
  subsets <- list(1:3, 1:4, 1:5)
  subsetSlider(subsets = subsets)
  clipplaneSlider(d = seq(0, 1, len=20), clipplaneid = 123)
# }
Documentation reproduced from package rgl, version 0.100.50, License: GPL

Community examples

Looks like there are no examples yet.