Migrating from trimesh
triwarp's object API is deliberately trimesh-shaped —
triwarp.mesh.Trimesh mirrors trimesh.Trimesh's property names wherever
the underlying quantity is the same — so most of this migration is a mechanical swap of tm for
tw, plus the one structural difference that runs through the whole library: everything is a
wp.array, not a np.ndarray.
import trimesh as tm # before
import triwarp as tw # after
Mesh construction and I/O
Trimesh properties (same names, same meaning)
| trimesh |
triwarp |
mesh.area |
mesh.area |
mesh.is_watertight |
mesh.is_watertight |
mesh.euler_number |
mesh.euler_characteristic |
mesh.volume |
mesh.volume |
mesh.center_mass |
mesh.center_mass |
mesh.moment_inertia |
mesh.moment_inertia |
mesh.face_normals |
mesh.face_normals |
mesh.vertex_normals |
mesh.vertex_normals |
mesh.edges_unique |
mesh.edges_unique |
mesh.face_adjacency |
mesh.face_adjacency |
mesh.bounds, mesh.extents |
mesh.bounds, mesh.extents |
mesh.body_count |
mesh.body_count |
Every one of these is lazily computed and cached on first access, exactly like trimesh's own
@caching.cache_decorator properties — the difference is what comes back is a wp.array
(or a Python scalar for a reduction like area/volume), not a NumPy array.
Free functions (module-level, for pipelines that don't want the object)
What's different, not just renamed
- Face buffers are flat.
mesh.faces in trimesh is (n_faces, 3); the triwarp equivalent is
a flat (3 * n_faces,) buffer. Convert once at the boundary:
faces_flat = wp.array(faces_np.reshape(-1), dtype=wp.int32).
- No in-place mutation.
mesh.remove_duplicate_faces() and similar trimesh calls mutate the
object; triwarp functions always return new arrays (e.g.
repair.resolve_duplicated_faces).
isotropic_remesh is a superset of trimesh's subdivide_to_size. trimesh's crack-free
remesh.subdivide_to_size only splits; triwarp's
remesh.isotropic_remesh also collapses, flips, and smooths
toward a uniform target length — pass collapse=False, swap=False, smooth=False to get
split-only behavior matching trimesh's function, or use
remesh.subdivide_to_size directly, which triwarp also
ships.