Learn R Programming

rayrender (version 0.42.0)

add_camera: Add Camera

Description

Adds a camera to a `ray_scene`.

Usage

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

Value

A modified `ray_scene`.

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.

Examples

Run this code
if (FALSE) { # interactive() || identical(Sys.getenv("IN_PKGDOWN"), "true")
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)
}

Run the code above in your browser using DataLab