render_scene: Render multiple meshes to an image

View source: R/render.R

render_sceneR Documentation

Render multiple meshes to an image

Description

Renders a list of meshes as a single scene using the scimesh software renderer. Each element can be a scimesh mesh descriptor or an rgl-style mesh (with vb/it); rgl meshes are transparently converted.

Usage

render_scene(meshes, camera, options = render_options())

Arguments

meshes

A list of mesh descriptors. Each element is a list with components vertices (Nx3 matrix), triangles (Mx3 integer matrix), and optionally colors, face_colors, normals, and default_color. Elements may also be rgl-style lists (with vb and it), which are converted automatically.

camera

A camera list from camera() or camera_auto().

options

A render options list from render_options().

Value

A list with components width, height, and pixels (raw vector of RGBA values).

Examples

# Render two cubes side by side
cube1 <- generate_cuboid(c(-1.5, 0, 0), c(0.8, 0.8, 0.8), c(1, 0, 0, 1))
cube2 <- generate_cuboid(c( 1.5, 0, 0), c(0.8, 0.8, 0.8), c(0, 0, 1, 1))
cam <- camera_auto(list(cube1, cube2), direction = c(1, 1, 1))
img <- render_scene(list(cube1, cube2), cam,
    render_options(width = 800, height = 600, background_color = c(1, 1, 1, 1)))
tmp_file <- tempfile(fileext = ".png")
write_png(img, tmp_file)

# Render multiple meshes together
scimesh_cube <- generate_cuboid(c(-1, 0, 0), c(0.5, 0.5, 0.5))
sphere <- generate_sphere(c(1, 0, 0), radius = 0.5, color = c(0, 1, 0, 1))
cam <- camera_auto(list(scimesh_cube, sphere), direction = c(1, 1, 1))
img <- render_scene(list(scimesh_cube, sphere), cam,
    render_options(width = 400, height = 300, background_color = c(1, 1, 1, 1)))


scimesh documentation built on Aug. 9, 2026, 9:07 a.m.