mesh_to_rgl: Convert a scimesh mesh to rgl tmesh3d format

View source: R/mesh_utils.R

mesh_to_rglR Documentation

Convert a scimesh mesh to rgl tmesh3d format

Description

Builds an rgl-compatible triangular mesh from a scimesh mesh descriptor so that the result can be used with rgl::shade3d() or other rgl functions.

Usage

mesh_to_rgl(mesh, color = NULL, face_color = NULL)

Arguments

mesh

A scimesh mesh descriptor list with vertices (Nx3 matrix) and triangles (Mx3 integer matrix, 1-based).

color

Optional per-vertex colour, either a single length-4 RGBA vector (applied to all vertices) or an Nx4 matrix.

face_color

Optional per-face colour (Mx4 matrix).

Value

A list with components vb (4xN homogeneous coordinates), it (3xM 1-based index matrix), and optionally normals and mat (material), suitable for use with rgl's tmesh3d() and shade3d().

Examples

mesh <- generate_cuboid(c(0, 0, 0), c(1, 1, 1))
rgl_mesh <- mesh_to_rgl(mesh)
str(rgl_mesh)


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