Note: Subtract operations aren't commutative: the second object is subtracted from the first.

csg_combine(object1, object2, operation = "union", radius = 0.5)

## Arguments

object1

First CSG object

object2

Second CSG object

operation

Default union. Can be union, subtract, intersection, blend, subtractblend, or mix.

Default 0.5. Blending radius.

## Value

List describing the combined csg object in the scene.

## Examples

if(run_documentation()) {
#Combine two spheres:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
csg_sphere(x=-0.4,z=-0.4),
csg_sphere(x=0.4,z=0.4), operation="union"),
material=glossy(color="dodgerblue4"))) %>%
render_scene(clamp_value=10,fov=20,lookfrom=c(-3,5,10))
}

if(run_documentation()) {
#Subtract one sphere from another:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
csg_sphere(x=-0.4,z=-0.4),
csg_sphere(x=0.4,z=0.4), operation="subtract"),
material=glossy(color="dodgerblue4"))) %>%
render_scene(clamp_value=10,fov=20,lookfrom=c(-3,5,10))
}

if(run_documentation()) {
#Get the intersection of two spheres:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
csg_sphere(x=-0.4,z=-0.4),
csg_sphere(x=0.4,z=0.4), operation="intersection"),
material=glossy(color="dodgerblue4"))) %>%
render_scene(clamp_value=10,fov=20,lookfrom=c(-3,5,10))
}

if(run_documentation()) {
#Get the blended union of two spheres:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
csg_sphere(x=-0.4,z=-0.4),
csg_sphere(x=0.4,z=0.4), operation="blend"),
material=glossy(color="dodgerblue4"))) %>%
render_scene(clamp_value=10,fov=20,lookfrom=c(-3,5,10))
}

if(run_documentation()) {
#Get the blended subtraction of two spheres:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
csg_sphere(x=-0.4,z=-0.4),
csg_sphere(x=0.4,z=0.4), operation="subtractblend"),
material=glossy(color="dodgerblue4"))) %>%
render_scene(clamp_value=10,fov=20,lookfrom=c(-3,5,10))
}

if(run_documentation()) {
generate_ground(material=diffuse(checkercolor="grey20")) %>%
csg_sphere(x=-0.4,z=-0.4),
material=glossy(color="dodgerblue4"))) %>%
render_scene(clamp_value=10,fov=20,lookfrom=c(-3,5,10))
}

if(run_documentation()) {
generate_ground(material=diffuse(checkercolor="grey20")) %>%
csg_sphere(x=-0.4,z=-0.4),
material=glossy(color="dodgerblue4"))) %>%
render_scene(clamp_value=10,fov=20,lookfrom=c(-3,5,10))
}

if(run_documentation()) {
#Get the mixture of various objects:
generate_ground(material=diffuse(checkercolor="grey20")) %>%
csg_sphere(),
csg_box(), operation="mix"),
material=glossy(color="dodgerblue4"))) %>%