Mesh3D
Represents a 3D triangle mesh defined by vertex positions and optional triangle indices, vertex normals, and vertex colors. This datatype is used for 3D assets and geometry within the Telekinesis ecosystem.
Field
Required
| Field | Type | Description |
|---|---|---|
vertex_positions | ArrayLike | Vertex positions; shape (N, 3), dtype float32. |
Optional
| Field | Type | Description |
|---|---|---|
triangle_indices | ArrayLike | Triangle indices (vertex indices per face); shape (M, 3), dtype int32. |
vertex_normals | ArrayLike | Vertex normals; shape (N, 3), dtype float32. |
vertex_colors | Rgba32ArrayLike | Vertex colors; length 1 or N, dtype uint8, shape (N, 4) or (1, 4). |
Example
From the datatypes examples:
python
import numpy as np
from datatypes import datatypes
from loguru import logger
# ------------------------------------------------
# 1. Create Mesh3D instance
# ------------------------------------------------
vertex_positions = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0]], dtype=np.float32)
triangle_indices = np.array([[0, 1, 2]], dtype=np.int32)
vertex_normals = np.array([[0, 0, 1], [0, 0, 1], [0, 0, 1]], dtype=np.float32)
vertex_colors = np.array(
[[255, 0, 0, 255], [0, 255, 0, 255], [0, 0, 255, 255]], dtype=np.uint8
)
mesh_3d = datatypes.Mesh3D(
vertex_positions, triangle_indices, vertex_normals, vertex_colors
)
# ------------------------------------------------
# 2. Access mesh attributes
# ------------------------------------------------
logger.info("Mesh3D vertex_positions shape={}", mesh_3d.vertex_positions.shape)
logger.info("Mesh3D triangle_indices shape={}", mesh_3d.triangle_indices.shape)
logger.info("Mesh3D vertex_normals shape={}", mesh_3d.vertex_normals.shape)
logger.info("Mesh3D vertex_colors shape={}", mesh_3d.vertex_colors.shape if mesh_3d.vertex_colors is not None else None)
