Skip to content

Instantly share code, notes, and snippets.

@xiaodaigh
Created March 12, 2019 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiaodaigh/dd9ad8632bb780ed01f156c3921762c1 to your computer and use it in GitHub Desktop.
Save xiaodaigh/dd9ad8632bb780ed01f156c3921762c1 to your computer and use it in GitHub Desktop.
3d sun around a pole
library(rayshader)
library(av)
elmat1 = matrix(0, 500, 500)
elmat1[200:400, 200:400] = 971.0
sunangle = 33
for(sunangle in 140: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()
print(glue::glue("{sunangle} $()"))
}
png_files <- list.files(pattern="*.png")
#sprintf("frame%d.png", 1: 360)
av::av_encode_video(png_files, 'output.mp4', framerate = 10)
utils::browseURL('output.mp4')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment