save_obj: Save OBJ

View source: R/save_obj.R

save_objR Documentation

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

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

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

save_obj(filename_obj)
}

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

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

tylermorganwall/rayshader documentation built on May 18, 2024, 5:31 p.m.