| render_triangles | R Documentation |
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.
render_triangles(positions, colors, camera, options = render_options())
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 |
options |
Render options from |
An image list with width, height,
pixels.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.