render_spheres: Render multiple spheres from point data

View source: R/mesh_utils.R

render_spheresR Documentation

Render multiple spheres from point data

Description

Generates a merged sphere mesh from a set of center points, radii, and colors, then renders it with the given camera and options.

Usage

render_spheres(
  centers,
  radii,
  colors,
  camera,
  options = render_options(),
  segments = 16L
)

Arguments

centers

Nx3 numeric matrix of sphere centre coordinates.

radii

Numeric vector of sphere radii (length N, or 1 recycled to N).

colors

Nx4 numeric matrix of RGBA colours (0-1 scale), or a single colour recycled to N.

camera

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

options

Render options from render_options().

segments

Number of latitude/longitude segments per sphere (default 16).

Value

An image list with width, height, pixels.

Examples

centers <- matrix(c(0, 2, 4, 0, 0, 0, 0, 0, 0), ncol = 3)
img <- render_spheres(centers, radii = 0.5,
                      colors = c(1, 0, 0, 1),
                      camera = camera_auto(centers))
tmp_file <- tempfile(fileext = ".png")
write_png(img, tmp_file)


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