# 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)
Run the code above in your browser using DataLab