Skip to contents

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

Usage

fshade3d(
  x,
  f,
  meshColor = c("faces", "vertices"),
  col = hcld.colors(nlevels(f)),
  legend = TRUE,
  legend.type = c("s", "c", "p", "l"),
  legend.zoom = 0.6,
  legend.width = 0.2,
  legend.size = 4,
  legend.dim = 0.2,
  legend.lab = NULL,
  lab.dist = 2.5,
  lab.rev = 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()).

col

vector of colors associated with each level of f (defaults to hcld.colors(nlevels(f))).

legend

logical; if TRUE (default), the active rgl device is splitted into two subscenes, drawing the 3D mesh object in one and the categorical legend in the other (see fplot3d()). if FALSE only the (coloured) mesh is drawn and the arguments related to the legend are ignored (fplot3d() is not called).

legend.type

character; symbol/object used to represent each level in the legend (see type in fplot3d()): "s" for spheres (default), "c" for cubes, "p" for points, or "l" for (horizontal) line segments.

legend.zoom

zoom factor applied to the legend subscene/panel.

legend.width

relative size of the legend symbols (spheres, cubes or line segments), as a fraction of the corresponding dimension of the legend subscene.

legend.size

point size, if type = "p", or line width, if type = "l" (in pixels; see size and lwd graphical parameters in rgl::par3d(); ignored in all other cases).

legend.dim

relative dimension of the legend panel, as a fraction of the full width (or height) of the device.

legend.lab

label for the axis of the color legend, defaults to a description of f.

lab.dist

distance between the legend symbols and their text labels, as a multiple of the symbol size (legend.width).

lab.rev

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

...

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

Value

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

Examples

library(rgl)
open3d() # Alternatively, use `new3d()` to clear the current device or open a new one
z_tri <- vb2tri3d(volcanom, volcanom$vb[3, ])
fz_tri <- cut(z_tri, 5)
fshade3d(volcanom, fz_tri, legend.dim = 0.3, lab.rev = TRUE)