Learn R Programming

rayrender (version 0.42.0)

preview_camera: Preview Camera

Description

Previews a scene-attached camera without writing image files.

Usage

preview_camera(
  scene,
  camera = NULL,
  width = 800,
  height = 800,
  fps = 24,
  samples = 1,
  ...
)

Value

Invisibly returns the rendered preview result.

Arguments

scene

Scene containing cameras.

camera

Default `NULL`. Camera name or `ray_camera` object to preview.

width

Default `800`. Preview width, in pixels.

height

Default `800`. Preview height, in pixels.

fps

Default `24`. Intended preview frame rate for animated cameras.

samples

Default `1`. Number of samples per pixel for the preview.

...

Additional arguments passed to `render_scene()`.

Examples

Run this code
if (FALSE) { # interactive() || identical(Sys.getenv("IN_PKGDOWN"), "true")
#Zooming over the R logo
motion = generate_camera_motion(
  positions = list(c(0, 1, -10), c(0, 1, -2), c(0, 1, 10)),
  lookats = list(c(0, 0, 0), c(0, 0.5, 0), c(0, 0, 0)),
  fovs = c(60, 45, 90),
  frames = 24,
  type = "linear",
  damp_motion = TRUE,
  closed = TRUE
)

scene = generate_ground(material=diffuse(color="grey20")) |>
  add_object(obj_model(r_obj())) |>
  add_object(sphere(y=10,x=-10,z=-5,material=light(intensity=100))) |>
  add_camera(camera(name = "flythrough", motion = motion))

preview_camera(scene, camera = "flythrough", width = 400, height = 400)
}

Run the code above in your browser using DataLab