Adds a camera to a `ray_scene`.

add_camera(scene, camera, name = NULL, active = TRUE, replace = FALSE)

Arguments

scene

Scene to modify.

camera

Camera created with `camera()`.

name

Default `NULL`. Optional name that overrides `camera$name`.

active

Default `TRUE`. Whether to set this camera as the active scene camera.

replace

Default `FALSE`. Whether to replace an existing camera with the same name.

Value

A modified `ray_scene`.

Examples

scene = generate_ground(material=diffuse(color="grey20")) |>
  add_object(sphere()) |>
  add_camera(camera(
    name = "main",
    lookfrom = c(0, 1, -10),
    lookat = c(0, 0, 0),
    fov = 35
  ))

render_scene(scene, samples = 16)