Learn R Programming

rayshader (version 0.35.7)

save_obj: Save OBJ

Description

Writes the textured 3D rayshader visualization to an OBJ file.

Usage

save_obj(
  filename,
  save_texture = TRUE,
  water_index_refraction = 1,
  manifold_geometry = FALSE,
  all_face_fields = FALSE,
  save_shadow = FALSE
)

Arguments

filename

String with the filename. If `.obj` is not at the end of the string, it will be appended automatically.

save_texture

Default `TRUE`. If the texture should be saved along with the geometry.

water_index_refraction

Default `1`. The index of refraction for the rendered water.

manifold_geometry

Default `FALSE`. If `TRUE`, this will take the additional step of making the mesh manifold.

all_face_fields

Default `FALSE`. If `TRUE`, all OBJ face fields (v/vn/vt) will always be written.

save_shadow

Default `FALSE`. If `TRUE`, this saves a plane with the shadow texture below the model.

Examples

Run this code
if(interactive()) {
filename_obj = tempfile(fileext = ".obj")

#Save model of volcano
if(rayshader:::run_documentation()) {
volcano %>%
 sphere_shade() %>%
 plot_3d(volcano, zscale = 2)

save_obj(filename_obj)
}

#Save model of volcano without texture
if(rayshader:::run_documentation()) {
save_obj(filename_obj, save_texture = FALSE)
}

#Make water have realistic index of refraction
if(rayshader:::run_documentation()) {
montereybay %>%
 sphere_shade() %>%
 plot_3d(montereybay, zscale = 50)
 
save_obj(filename_obj, water_index_refraction = 1.5)
}
}

Run the code above in your browser using DataLab