Skip to contents

Draws a triangular mesh (mesh3d) colored according to the levels of a factor f, automatically adding a categorical legend (via fplot3d()).

Usage

fshade3d(
  x,
  f,
  meshColor = c("faces", "vertices"),
  labels = levels(f),
  col = hcld.colors(length(labels)),
  legend.zoom = 1,
  legend.width = 0.1,
  legend.mar = 0.15,
  legend.lab = NULL,
  lab.dist = 3,
  lab.rev = FALSE,
  add = FALSE,
  ...
)

Arguments

x

triangular mesh (mesh3d object, see rgl::mesh3d()).

f

factor used to color the mesh. How its values are interpreted depends on meshColor.

meshColor

determines how color is applied to the mesh: "faces" or "vertices" (see rgl::shade3d()).

labels

legend labels (defaults to levels(f)).

col

vector of colors associated with each level of f (by default generated with col.pal).

legend.zoom

zoom factor applied to the legend subscene/panel

legend.width

relative size of the legend spheres, as a fraction of the corresponding dimension of the legend subscene.

legend.mar

relative width of the legend panel, as a fraction of the total device width.

legend.lab

legend title.

lab.dist

distance between the spheres and their text labels.

lab.rev

logical; if TRUE the order of the levels in the legend is reversed (by default they are shown from top to bottom).

add

logical; if TRUE the legend is not redrawn (useful for adding several meshes to an already existing legend).

...

additional arguments passed on to rgl::shade3d().

Value

Called for its side effect (draws the mesh and, unless add = TRUE, the legend on the active rgl device); invisibly returns the object identifiers.

Examples

library(rgl)
open3d()
z_tri <- vb2tri(volcanom, volcanom$vb[3, ])
fz_tri <- cut(z_tri, 5)
fshade3d(volcanom, fz_tri, legend.mar = 0.3, lab.dist = 15, lab.rev = TRUE)