Description Usage Arguments Details Value Examples
View source: R/write_covid_obj.R
This function writes out a custom 3D model of the COVID-19 virus, with colors specified by the user. The user can change the color of the main body, the color of the spike protein, and the color of an open spike protein.
1 2 3 4 5 6 | write_corona_obj(
filename = "covidcustom.obj",
color_membrane = "#a1cdf0",
color_spike = "#3432cf",
color_open_spike = "#d92bc5"
)
|
filename |
Default 'covidcustom.obj'. |
color_membrane |
Default '#a1cdf0'. Color of the main membrane (lipid layer) of the coronavirus. |
color_spike |
Default '#3432cf'. Color of the closed spike protein (crown) on the coronavirus. |
color_open_spike |
Default '#d92bc5'. Color of the open spike protein (crown) on the coronavirus. |
The base model was sourced from the NIH 3D Print Exchange.
Path to the file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | library(rayrender)
#Write a base version of the model and render it with rayrender, using vertex colors.
write_corona_obj("defaults.obj")
#Render the model:
obj_model("defaults.obj", vertex_colors = TRUE) %>%
add_object(sphere(y=10,z=10,x=10, material=light(color="lightblue",intensity=100))) %>%
add_object(sphere(y=10,z=10,x=-10, material=light(color="orange",intensity=100))) %>%
render_scene(parallel=TRUE, samples = 100, fov = 7, min_variance=0, focal_distance = 9.6,
width=800,height=800)
#Now write a custom version, recreating the "standard" grey and red COVID-19 visualization.
write_corona_obj("standard.obj",
color_membrane = "#a1cdf0",
color_spike = "#3432cf",
color_open_spike = "#d92bc5")
#Render the custom model:
obj_model("standard.obj", vertex_colors = TRUE) %>%
add_object(sphere(y=10,z=10,x=10, material=light(color="lightblue",intensity=100))) %>%
add_object(sphere(y=10,z=10,x=-10, material=light(color="orange",intensity=100))) %>%
render_scene(parallel=TRUE, samples = 100, fov = 7, min_variance=0, focal_distance = 9.6,
width=800,height=800)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.