Closed xiaodaigh closed 5 years ago
You don't need a function for that, you can simply put it into the for
loop.
library(rayshader)
library(av)
elmat1 = matrix(0, 500, 500)
elmat1[200:400, 200:400] = 971.0
for(sunangle in 1:360) {
elmat1 %>%
sphere_shade %>%
add_shadow(ray_shade(elmat1,zscale=3,maxsearch = 300, sunangle = sunangle),0.5) %>%
plot_3d(elmat1,zscale=10,fov=0,theta=0,zoom=0.75, phi=25, windowsize = c(1000,800))
render_snapshot(filename=paste0("frame",sunangle))
rgl::rgl.clear()
}
png_files <- sprintf("frame%d.png", 1: 360)
av::av_encode_video(png_files, 'output.mp4', framerate = 10)
utils::browseURL('output.mp4')
Feel free to ask any more questions here if you have them
I see on the front page where the sun rotates around. However do I make the same animation where the sun rotates around the square pole I have set up below??
In the above I envision a
addplot_to_gif()
function to build up a gif where each frame is a plot with a differentsunangle
.