Skip to content

Instantly share code, notes, and snippets.

@xiaodaigh xiaodaigh/ok.r
Created Mar 12, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.