Clear shapes, lights, bbox

clear3d( type = c("shapes", "bboxdeco", "material"), defaults, subscene = 0 ) 
pop3d( type = "shapes", id = 0, tag = NULL)
ids3d( type = "shapes", subscene = NA, tags = FALSE )



Select subtype(s):


shape stack


light stack


bounding box


user viewpoint


model viewpoint


material properties


scene background


subscene list


all of the above


default values to use after clearing


which subscene to work with. NA means the current one, 0 means the whole scene


vector of ID numbers of items to remove


override id with objects matching these tag material properties


logical; whether to return tag column.


RGL holds several lists of objects in each scene. There are lists for shapes, lights, bounding box decorations, subscenes, etc. clear3d clears the specified stack, or restores the defaults for the bounding box (not visible) or viewpoint. With id = 0 pop3d removes the last added node on the list (except for subscenes: there it removes the active subscene). The id argument may be used to specify arbitrary item(s) to remove; if id != 0, the type argument is ignored.

clear3d may also be used to clear material properties back to their defaults.

clear3d has an optional defaults argument, which defaults to r3dDefaults. Only the materials component of this argument is currently used by clear3d.

ids3d returns a dataframe containing the IDs in the currently active subscene by default, or a specified subscene, or if subscene = 0, in the whole rgl window along with an indicator of their type and if tags = TRUE, the tag value for each.

Note that clearing the light stack leaves the scene in darkness; it should normally be followed by a call to light3d.

See also

rgl, bbox3d, light3d, open3d to open a new window.


  x <- rnorm(100)
  y <- rnorm(100)
  z <- rnorm(100)
  p <- plot3d(x, y, z, type = 's', tag = "plot")
#>     id    type
#> 1 1801 spheres
#> 2 1803    text
#> 3 1804    text
#> 4 1805    text
  lines3d(x, y, z)

  ids3d(tags = TRUE)
#>     id      type  tag
#> 1 1801   spheres plot
#> 2 1803      text plot
#> 3 1804      text plot
#> 4 1805      text plot
#> 5 1806 linestrip     
  if (interactive() && !rgl.useNULL() && !in_pkgdown_example()) {
    readline("Hit enter to change spheres")
    pop3d(id = p["data"])
    spheres3d(x, y, z, col = "red", radius = 1/5)