Learn R Programming

r3js (version 0.0.2)

triangle3js: Add a triangle to a data3js object

Description

Add a triangle to a data3js object

Usage

triangle3js(data3js, vertices, col = "black", highlight, ...)

Value

Returns an updated data3js object

Arguments

data3js

The data3js object

vertices

An nx3 matrix of triangle vertices

col

Single color for the triangles or vector of vertex colors

highlight

highlight attributes (see highlight3js())

...

Additional attributes to pass to material3js()

See Also

Other plot components: arrows3js(), axis3js(), box3js(), grid3js(), legend3js(), light3js(), lines3js(), mtext3js(), points3js(), segments3js(), shape3js(), sphere3js(), surface3js(), text3js()

Examples

Run this code
# Draw some random triangles
M <- matrix(
  data = rnorm(36),
  ncol = 3,
  nrow = 12
)

p <- plot3js(
  xlim = range(M[,1]),
  ylim = range(M[,2]),
  zlim = range(M[,3]),
  label_axes = FALSE
)

p <- triangle3js(
  p,
  vertices = M,
  col = rainbow(nrow(M))
)

r3js(p, zoom = 2)

Run the code above in your browser using DataLab