Skip to content

mesh.py

rerun.log.mesh

def log_mesh(entity_path, positions, *, indices=None, normals=None, albedo_factor=None, vertex_colors=None, timeless=False)

Log a raw 3D mesh by specifying its vertex positions, and optionally indices, normals and albedo factor.

You can also use [rerun.log_mesh_file] to log .gltf, .glb, .obj, etc.

Example:
# A simple red triangle:
rerun.log_mesh(
    "world/mesh",
    positions = [
        [0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0],
        [0.0, 1.0, 0.0]
    ],
    indices = [0, 1, 2],
    normals = [
        [0.0, 0.0, 1.0],
        [0.0, 0.0, 1.0],
        [0.0, 0.0, 1.0]
    ],
    albedo_factor = [1.0, 0.0, 0.0],
)

Parameters:

Name Type Description Default
entity_path str

Path to the mesh in the space hierarchy

required
positions Any

An array of 3D points. If no indices are specified, then each triplet of positions is interpreted as a triangle.

required
indices Optional[Any]

If specified, is a flattened array of indices that describe the mesh's triangles, i.e. its length must be divisible by 3.

None
normals Optional[Any]

If specified, is a (potentially flattened) array of 3D vectors that describe the normal for each vertex, i.e. the total number of elements must be divisible by 3 and more importantly, len(normals) should be equal to len(positions).

None
albedo_factor Optional[Any]

Optional color multiplier of the mesh using RGB or unmuliplied RGBA in linear 0-1 space.

None
vertex_colors Optional[Colors]

Optional array of RGB(a) vertex colors

None
timeless bool

If true, the mesh will be timeless (default: False)

False

def log_meshes(entity_path, position_buffers, *, vertex_color_buffers, index_buffers, normal_buffers, albedo_factors, timeless=False)

Log multiple raw 3D meshes by specifying their different buffers and albedo factors.

To learn more about how the data within these buffers is interpreted and laid out, refer to the documentation for [rerun.log_mesh].

Parameters:

Name Type Description Default
entity_path str

Path to the mesh in the space hierarchy

required
position_buffers Sequence[npt.ArrayLike]

A sequence of position buffers, one for each mesh.

required
vertex_color_buffers Sequence[Optional[Colors]]

An optional sequence of vertex color buffers, one for each mesh.

required
index_buffers Sequence[Optional[npt.ArrayLike]]

An optional sequence of index buffers, one for each mesh.

required
normal_buffers Sequence[Optional[npt.ArrayLike]]

An optional sequence of normal buffers, one for each mesh.

required
albedo_factors Sequence[Optional[npt.ArrayLike]]

An optional sequence of albedo factors, one for each mesh.

required
timeless bool

If true, the mesh will be timeless (default: False)

False