R/add_object.R

Defines functions add_object

Documented in add_object

#' Add Object
#'
#' @param scene Tibble of pre-existing object locations and properties.
#' @param objects A tibble row or collection of rows representing each object.
#'
#' @return Tibble of object locations and properties.
#' @export
#'
#'@examplesIf interactive() || identical(Sys.getenv("IN_PKGDOWN"), "true")
#' #Generate the ground and add some objects
#' scene = generate_ground(depth=-0.5,material = diffuse(checkercolor="blue")) |>
#'   add_object(cube(x=0.7,
#'                   material=diffuse(noise=5,noisecolor="purple",color="black",noisephase=45),
#'                   angle=c(0,-30,0))) |>
#'   add_object(sphere(x=-0.7,radius=0.5,material=metal(color="gold")))
#' render_scene(scene,parallel=TRUE)
add_object = function(scene, objects = NULL) {
  if (is.null(objects)) {
    return(scene)
  }
  newscene = rbind(scene, objects)
  preserve_ray_scene_attrs(newscene, scene, objects)
}

Try the rayrender package in your browser

Any scripts or data that you put into this service are public.

rayrender documentation built on Sept. 16, 2026, 9:08 a.m.