render_triangles: Render raw triangles without index buffer

View source: R/render.R

render_trianglesR Documentation

Render raw triangles without index buffer

Description

Renders triangle geometry where positions and colours are given as flat arrays with 3 vertices per triangle (no index buffer). Useful for voxel renderings, misc3d isosurfaces, and other dynamically generated geometry.

Usage

render_triangles(positions, colors, camera, options = render_options())

Arguments

positions

Nx3 numeric matrix of vertex positions, where N is a multiple of 3 (3 per triangle).

colors

Nx4 numeric matrix of RGBA colours (0-1 scale).

camera

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

options

Render options from render_options().

Value

An image list with width, height, pixels.

Examples

# Render a single red triangle from raw vertices
positions <- matrix(c(0, 0, 0, 1, 0, 0, 0.5, 1, 0), ncol = 3, byrow = TRUE)
colors <- matrix(c(1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1), ncol = 4, byrow = TRUE)
cam <- camera_auto(positions)
img <- render_triangles(positions, colors, cam)


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