Mesh3D
A 3D triangle mesh as specified by its per-mesh and per-vertex properties.
See also archetypes.Asset3D.
If there are multiple archetypes.InstancePoses3D instances logged to the same entity as a mesh,
an instance of the mesh will be drawn for each transform.
For transparency ordering, as well as back face culling (disabled by default), front faces are assumed to be those with counter clockwise triangle winding order (this is the same as in the GLTF specification).
Fields fields
Required required
vertex_positions:Position3D
Recommended recommended
triangle_indices:TriangleIndicesvertex_normals:Vector3D
Optional optional
vertex_colors:Colorvertex_texcoords:Texcoord2Dalbedo_factor:AlbedoFactorface_rendering:MeshFaceRenderingalbedo_texture_buffer:ImageBufferalbedo_texture_format:ImageFormatclass_ids:ClassId
Can be shown in can-be-shown-in
- Spatial3DView
- Spatial2DView (if logged above active projection)
- DataframeView
API reference links api-reference-links
Examples examples
Simple indexed 3D mesh simple-indexed-3d-mesh
"""Log a simple colored triangle."""
import rerun as rr
rr.init("rerun_example_mesh3d_indexed", spawn=True)
rr.log(
"triangle",
rr.Mesh3D(
vertex_positions=[[0.0, 1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
vertex_normals=[0.0, 0.0, 1.0],
vertex_colors=[[0, 0, 255], [0, 255, 0], [255, 0, 0]],
triangle_indices=[2, 1, 0],
),
)
3D mesh with instancing 3d-mesh-with-instancing
"""Log a simple 3D mesh with several instance pose transforms which instantiate the mesh several times and will not affect its children (known as mesh instancing)."""
import rerun as rr
rr.init("rerun_example_mesh3d_instancing", spawn=True)
rr.set_time("frame", sequence=0)
rr.log(
"shape",
rr.Mesh3D(
vertex_positions=[[1, 1, 1], [-1, -1, 1], [-1, 1, -1], [1, -1, -1]],
triangle_indices=[[0, 2, 1], [0, 3, 1], [0, 3, 2], [1, 3, 2]],
vertex_colors=[[255, 0, 0], [0, 255, 0], [0, 0, 255], [255, 255, 0]],
),
)
# This box will not be affected by its parent's instance poses!
rr.log(
"shape/box",
rr.Boxes3D(half_sizes=[[5.0, 5.0, 5.0]]),
)
for i in range(100):
rr.set_time("frame", sequence=i)
rr.log(
"shape",
rr.InstancePoses3D(
translations=[[2, 0, 0], [0, 2, 0], [0, -2, 0], [-2, 0, 0]],
rotation_axis_angles=rr.RotationAxisAngle([0, 0, 1], rr.Angle(deg=i * 2)),
),
)
Update specific parts of a 3D mesh over time update-specific-parts-of-a-3d-mesh-over-time
"""Log a simple colored triangle, then update its vertices' positions each frame."""
import numpy as np
import rerun as rr
rr.init("rerun_example_mesh3d_partial_updates", spawn=True)
vertex_positions = np.array([[-1.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]], dtype=np.float32)
# Log the initial state of our triangle
rr.set_time("frame", sequence=0)
rr.log(
"triangle",
rr.Mesh3D(
vertex_positions=vertex_positions,
vertex_normals=[0.0, 0.0, 1.0],
vertex_colors=[[255, 0, 0], [0, 255, 0], [0, 0, 255]],
),
)
# Only update its vertices' positions each frame:
for i in range(1, 300):
factor = np.abs(np.sin(i * 0.04))
rr.set_time("frame", sequence=i)
rr.log("triangle", rr.Mesh3D.from_fields(vertex_positions=vertex_positions * factor))


