Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

as.mesh3d.rglId

Convert object in plot to RGL mesh object


Description

This method attempts to read the attributes of objects in the rgl display and construct a mesh3d object to approximate them.

Usage

## S3 method for class 'rglId'
as.mesh3d(x, type = NA, subscene = NA, ...)

Arguments

x

A vector of RGL identifiers of objects in the specified subscene.

type

A vector of names of types of shapes to convert. Other shapes will be ignored.

subscene

Which subscene to look in; the default NA specifies the current subscene.

...

Ignored.

Details

This function attempts to construct a triangle mesh to approximate one or more objects from the current display. It can only handle objects of types from c("triangles", "quads", "planes", "surface").

Since this method only produces triangular meshes, they won't necessarily be an exact match to the original object.

If the generic as.mesh3d is called with no x argument, this method will be called with x set to the ids in the current scene.

Value

A triangular mesh object.

Author(s)

Duncan Murdoch

See Also

as.triangles3d.rglId for extracting the triangles, clipMesh3d to apply complex clipping to a mesh object.

Examples

# volcano example taken from "persp"
#
data(volcano)

z <- 2 * volcano        # Exaggerate the relief

x <- 10 * (1:nrow(z))   # 10 meter spacing (S to N)
y <- 10 * (1:ncol(z))   # 10 meter spacing (E to W)

zlim <- range(y)
zlen <- zlim[2] - zlim[1] + 1

colorlut <- terrain.colors(zlen) # height color lookup table

col <- colorlut[ z - zlim[1] + 1 ] # assign colors to heights for each point

open3d(useNULL = TRUE)
surface3d(x, y, z, color = col)
m <- as.mesh3d()
close3d()

open3d()
shade3d(m)

rgl

3D Visualization Using OpenGL

v0.106.8
GPL
Authors
Duncan Murdoch [aut, cre], Daniel Adler [aut], Oleg Nenadic [ctb], Simon Urbanek [ctb], Ming Chen [ctb], Albrecht Gebhardt [ctb], Ben Bolker [ctb], Gabor Csardi [ctb], Adam Strzelecki [ctb], Alexander Senger [ctb], The R Core Team [ctb, cph], Dirk Eddelbuettel [ctb], The authors of Shiny [cph], The authors of knitr [cph], Jeroen Ooms [ctb], Yohann Demont [ctb], Joshua Ulrich [ctb], Xavier Fernandez i Marin [ctb], George Helffrich [ctb], Ivan Krylov [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.