This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#JWST OBJ file located at www.tylermw.com/webb.zip | |
#Parse OBJ MTL file to read and write red color for highlighted component | |
mtl_file = readLines("jwebb.mtl") | |
kd_entries = (grepl("Kd",mtl_file,fixed=T)) | |
kd_ind = which(grepl("Kd",mtl_file,fixed=T)) | |
#Set all to white | |
mtl_file[kd_entries] = "Kd 1.000000 1.000000 1.000000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rayshader) | |
montereybay2 = montereybay | |
montereybay2[montereybay2<0] = 0 | |
for(i in 1:720) { | |
montereybay2 %>% | |
sphere_shade() %>% | |
add_water(detect_water(montereybay2), color="lightblue") |> | |
add_shadow(cloud_shade(montereybay2,zscale=50, sun_altitude = 90, seed=10, attenuation_coef = 1, time=i, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rayrender) | |
#Generate CSG branches | |
branches0 = csg_cone(end=c(0,0.5,0)) %>% | |
csg_combine(csg_cone(start=c(0,0.25,0),end=c(0,0.75,0), radius=0.75), operation="blend", radius = 0.7)%>% | |
csg_scale(1.25) | |
branches1 = csg_cone(end=c(0,0.5,0)) %>% | |
csg_combine(csg_cone(start=c(0,0.25,0),end=c(0,0.75,0), radius=0.75), operation="blend", radius = 0.7) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(geojsonsf) | |
library(sf) | |
library(rayrender) | |
#Data source: https://github.com/telegeography/www.submarinecablemap.com | |
cables = geojson_sf("cable-geo.json") | |
cablescene = list() | |
counter = 1 | |
for(i in 1:length(cables$geometry)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rayshader) | |
library(rayrender) | |
popdata = raster::raster("gpw_v4_population_density_rev11_2020_15_min.tif") | |
population_mat = rayshader:::flipud(raster_to_matrix(popdata)) | |
above1 = population_mat > 1 | |
above5 = population_mat > 5 | |
above10 = population_mat > 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rayvertex) | |
text3d_mesh("A long time ago in a rayverse far,",color=c(75, 213, 238)/255) %>% | |
add_shape(text3d_mesh("far, away...",color=c(75, 213, 238)/255,position=c(-5,-1,0))) %>% | |
rasterize_scene(fov=120,lookat=c(0,-0.5,0),lookfrom=c(0,-0.5,5), | |
filename="start") | |
for(i in 1:(24*6)) { | |
png::readPNG(glue::glue("start.png")) %>% | |
png::writePNG(glue::glue("starwarsvertex{i}.png")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#You can find the surface textures at the link below: | |
#http://www.shadedrelief.com/natural3/pages/extra.html | |
#The background is just starfield image—any will do. | |
#Note: this uses the latest version of rayrender (0.21.4) on github | |
library(rayrender) | |
for(i in 1:360) { | |
group_objects(cylinder(angle=c(90,90,0), material=diffuse(image_texture = "8081_earthmap10k.jpg", | |
bump_texture = "8081_earthbump10k.jpg", bump_intensity = 100), | |
radius=12, capped = FALSE, length = 6) %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(deSolve) | |
library(rayrender) | |
parameters = c(a = 0.2, b = 4, c = 8, d = 1) | |
state = c(X = 1, Y = 0, Z = 1) | |
Lorenz = function(t, state, parameters) { | |
with(as.list(c(state, parameters)), { | |
dX = -Y^2 - Z^2 - a*X + a*c | |
dY = X * Y - b * X * Z - Y + d | |
dZ = b * X * Y + X * Z - Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rayshader) | |
library(crayon) | |
ivory <- make_style("ivory") | |
bgMaroon <- make_style(rgb(0.2,0.2,0.2,0), bg = TRUE) | |
fancy <- combine_styles(ivory, bgMaroon) | |
cat(fancy("This will have some fancy colors"), "\n") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rayrender) | |
#CSG Pig Elements | |
leg_scene = list(csg_cylinder(start = c(1,-0.6,0.5), end = c(1,1.,0.5), radius=0.25+0.01), | |
csg_cylinder(start = c(-1,-0.6,0.5), end = c(-1,1.,0.5), radius=0.25+0.01), | |
csg_cylinder(start = c(1,-0.6,-0.5), end = c(1,1.,-0.5), radius=0.25+0.01), | |
csg_cylinder(start = c(-1,-0.6,-0.5), end = c(-1,1.,-0.5), radius=0.25+0.01)) | |
eye_scene = list(csg_sphere(x = 2, y = 2.5, z = 0.3, radius=0.25+0.01), | |
csg_sphere(x = 2, y = 2.5, z = -0.3, radius=0.25+0.01+0.01), | |
csg_sphere(x = 2.2, y = 2.5, z = 0.3, radius=0.1+0.01), |