When no light source is provided the 3d scene is lit from the top left, this function allows you to specify different numbers of light sources at different positions - not yet fully implemented.

light3js(
  data3js,
  position = NULL,
  intensity = 1,
  type = "directional",
  col = "white"
)

Arguments

data3js

The data3js object

position

Position of the light source in x, y, z coords, see details.

intensity

Light intensity

type

Type of light, either "point", "directional" or "ambient", see details.

col

Light color

Value

Returns an updated data3js object

Details

If light position is "directional", the default light will appear to come from the direction of the position argument but from an infinite distance. If "point" the light will appear to emanate from that position in coordinate space light a light bulb. If "ambient" any position argument is ignored and the light will light all aspects of the scene evenly from no particular position.

See also

Examples

# Set up a plot
p0 <- plot3js(
  x = 1:4,
  y = c(2,1,3,4),
  z = c(3,2,4,1),
  xlim = c(0, 5),
  ylim = c(0, 5),
  zlim = c(0, 5),
  size = 20,
  col = c("white", "blue", "red", "green"),
  grid_col = "grey40",
  background = "black"
)

# Light scene intensely from above
p <- light3js(
  p0,
  position = c(0, 1, 0)
)
r3js(p, zoom = 2)
# Light scene positionally from the middle of the plot p <- light3js( p0, position = c(2.5, 2.5, 2.5), type = "point" ) r3js(p, zoom = 2)
# Light scene ambiently with a yellow light p <- light3js( p0, intensity = 0.3, type = "ambient", col = "yellow" ) r3js(p, zoom = 2)