Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
28 lines (28 sloc)
942 Bytes
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
#' 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 | |
#' | |
#' @examples | |
#' #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"))) | |
#' \donttest{ | |
#' render_scene(scene,parallel=TRUE) | |
#' } | |
add_object = function(scene, objects = NULL) { | |
if(is.null(objects)) { | |
return(scene) | |
} | |
newscene = rbind(scene,objects) | |
if(!is.null(attr(objects,"cornell")) || !is.null(attr(scene,"cornell"))) { | |
attr(newscene,"cornell") = TRUE | |
} | |
return(newscene) | |
} |