This is a function to produce actions in a web display. A playwidget or Shiny input control (e.g. a sliderInput control) sets a value which controls attributes of a selection of vertices.

vertexControl(value = 0, values = NULL, vertices = 1, attributes,
              objid, param = seq_len(NROW(values)) - 1, interp = TRUE)



The value to use for input (typically input$value in a Shiny app.) Not needed with playwidget.


A matrix of values, each row corresponding to an input value.


Which vertices are being controlled? Specify vertices as a number from 1 to the number of vertices in the objid.


A vector of attributes of a vertex, from c("x", "y", "z", "red", "green", "blue", "alpha", "nx", "ny", "nz", "radii", "ox", "oy", "oz", "ts", "tt", "offset"). See Details.


A single RGL object id.


Parameter values corresponding to each row of values.


Whether to interpolate between rows of values.


This function modifies attributes of vertices in a single object. The attributes are properties of each vertex in a scene; not all are applicable to all objects. In order, they are: coordinates of the vertex "x", "y", "z", color of the vertex "red", "green", "blue", "alpha", normal at the vertex "nx", "ny", "nz", radius of a sphere at the vertex "radius", origin within a texture "ox", "oy" and perhaps "oz", texture coordinates "ts", "tt".

Planes are handled specially. The coefficients a, b, c in the planes3d or clipplanes3d specification are controlled using "nx", "ny", "nz", and d is handled as "offset". The vertices argument is interpreted as the indices of the planes when these attributes are set.

If only one attribute of one vertex is specified, values may be given as a vector and will be treated as a one-column matrix. Otherwise values must be given as a matrix with ncol(values) == max(length(vertices), length(attributes)). The vertices and attributes vectors will be recycled to the same length, and entries from column j of values will be applied to vertex vertices[j], attribute attributes[j].

The value argument is translated into a row (or two rows if interp = TRUE) of values by finding its location in param.


A list of class "rglControl" of cleaned up parameter values, to be used in an RGL widget.


Duncan Murdoch


  saveopts <- options(rgl.useNULL = TRUE)

  theta <- seq(0, 6*pi, len=100)
  xyz <- cbind(sin(theta), cos(theta), theta)
  plot3d(xyz, type="l")
id <- spheres3d(xyz[1,,drop=FALSE], col="red") widget <- rglwidget(width=500, height=300) %>% playwidget(vertexControl(values=xyz, attributes=c("x", "y", "z"), objid = id, param=1:100), start = 1, stop = 100, rate=10) if (interactive() || in_pkgdown_example()) widget