Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

csg_box

CSG Box


Description

CSG Box

Usage

csg_box(x = 0, y = 0, z = 0, width = c(1, 1, 1), corner_radius = 0)

Arguments

x

Default '0'. An x-coordinate on the box.

y

Default '0'. A y-coordinate on the box.

z

Default '0'. A z-coordinate on the box

width

Default 'c(1,1,1)'. Length-3 vector describing the x/y/z widths of the box

corner_radius

Default '0'. Radius if rounded box.

Value

List describing the box in the scene.

Examples

#Generate a box
generate_ground(material=diffuse(checkercolor="grey20")) %>% 
  add_object(csg_object(csg_box(), material=glossy(color="#FF69B4"))) %>%
  add_object(sphere(y=5,x=5,radius=3,material=light(intensity=5))) %>%  
  render_scene(clamp_value=10,lookfrom=c(7,3,7))
  
#Change the width
generate_ground(material=diffuse(checkercolor="grey20")) %>% 
  add_object(csg_object(csg_box(width = c(2,1,0.5)), material=glossy(color="#FF69B4"))) %>%
  add_object(sphere(y=5,x=5,radius=3,material=light(intensity=5))) %>%  
  render_scene(clamp_value=10,lookfrom=c(7,3,7))

#Subtract two boxes to make stairs
generate_ground(material=diffuse(checkercolor="grey20")) %>% 
  add_object(csg_object(csg_combine(
    csg_box(),
    csg_box(x=0.5,y=0.5,width=c(1,1,1.1)),operation="subtract"),
   material=glossy(color="#FF69B4"))) %>%
  add_object(sphere(y=5,x=5,radius=3,material=light(intensity=5))) %>%  
  render_scene(clamp_value=10,lookfrom=c(7,3,7),fov=13)

rayrender

Build and Raytrace 3D Scenes

v0.21.2
GPL-3
Authors
Tyler Morgan-Wall [aut, cph, cre] (<https://orcid.org/0000-0002-3131-3814>), Syoyo Fujita [ctb, cph], Melissa O'Neill [ctb, cph], Vilya Harvey [ctb, cph]
Initial release
2021-04-01

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.