Functions to retrieve, save, restore, list and remove rgl viewpoints; see Details for additional information.
Usage
addviewpoint3d(name, view = getview3d())
setviewpoint3d(name = "default")
lsviewpoints3d(...)
rmviewpoints3d(...)
getviewpoints3d()
getview3d()
setview3d(view)Value
addviewpoint3d() is called for its side effect of storing view under
name; it invisibly returns view.
setviewpoint3d() is called for its side effect of restoring a stored
viewpoint to the current rgl subscene; it invisibly returns the corresponding view.
lsviewpoints3d() returns a character vector with the names of the
stored viewpoints.
rmviewpoints3d() is called for its side effect of removing one or more
stored viewpoints.
getviewpoints3d() returns a named list with all the stored viewpoints.
getview3d() returns a list with the components zoom, userMatrix
and userProjection (see rgl::par3d()).
setview3d() is called mainly for its side effect of setting the
viewpoint of the current rgl subscene (see rgl::par3d()); it returns the
value returned by par3d().
Details
addviewpoint3d() stores view under name,
silently overwriting any viewpoint previously stored under the same name.
By default view is the current viewpoint, as returned by getview3d().
setviewpoint3d() looks up the viewpoint stored under name and applies
it to the current rgl subscene via setview3d().
lsviewpoints3d() returns the names of all the viewpoints currently
stored.
rmviewpoints3d() Deletes one or more saved viewpoints by name.
If called without arguments, it deletes all of them, always retaining
the "default" viewpoint.
getviewpoints3d() returns a named list with all the viewpoints
currently stored, one entry per name.
getview3d() retrieves the parameters that define the current viewpoint
of the current rgl subscene (zoom, user matrix and user projection), so
that they can be saved and restored later with setview3d().
setview3d() applies to the current rgl subscene a viewpoint previously
obtained with getview3d() (this is also what setviewpoint3d() uses
internally to restore a stored viewpoint).
Examples
library(rgl)
open3d()
# Alternatively, use `new3d()` to clear the current device or open a new one.
# It also saves the default viewpoint under the name "default"
shade3d(volcanom, col = "lightgreen")
3D plot
# ... rotate, zoom or pan the scene interactively ...
# Save the current viewpoint under the name "myview"
addviewpoint3d("myview")
# ... rotate, zoom or pan the scene interactively ...
# Restore the default viewpoint
setviewpoint3d()
# Restore the saved viewpoint
setviewpoint3d("myview")
# Names of the stored viewpoints
lsviewpoints3d()
#> [1] "default" "myview"
# All stored viewpoints, as a named list
views <- getviewpoints3d()
# Remove all stored viewpoints
rmviewpoints3d()
lsviewpoints3d()
#> [1] "default"