Installation
The only thing required to install trimesh
is
numpy.
All other dependencies are ‘soft,’ or trimesh will raise the exceptions (usually but not always an ImportError
) at runtime if a function is called that requires a package that isn’t installed. If you do the most basic install of trimesh
it will only install numpy
:
pip install trimesh
This will enable you to load most formats into numpy arrays: STL, PLY, OBJ, GLB, GLTF.
If you’d like most soft dependencies which should install cleanly on Mac, Windows, and Linux, you can use the easy
pip extra:
pip install trimesh[easy]
Or if you want the full experience, you can try the all
extra, where packages may only be available for Linux:
pip install trimesh[all]
Conda Packages
If you prefer a conda
environment, trimesh
is available on conda-forge
(trimesh-feedstock repo)
If you install Miniconda you can then run:
conda install -c conda-forge trimesh
Ubuntu-Debian Notes
Blender and openSCAD are soft dependencies used for boolean operations with subprocess, you can get them with apt
:
sudo apt-get install openscad blender
Dependency Overview
Trimesh has a lot of soft-required upstream packages. We try to make sure they’re active and big-ish. Here’s a quick summary of what they’re used for.
Package |
Description |
Alternatives |
Level |
---|---|---|---|
|
The base container for fast array types. |
|
|
|
Provides convex hulls ( |
Nothing comes to mind, it does a whole heck of a lot. |
|
|
Parse XML documents. We use this over the built-in ones as it was slightly faster, and there was a format implemented which was extremely annoying to handle without the ability to get parent nodes (which |
Standard library’s XML |
|
|
A nice-to-use pure Python graph library that’s faster than you’d think. It implements DFS, BFS, and the usual FAANG-interview-question algorithms. A lot of the commonly run stuff in trimesh has been re-written to use |
|
|
|
Bindings to |
|
|
|
Query ND rectangles with a spatial tree for a “broad phase” intersection. Used in polygon generation (“given N closed curves which curve contains the other curve?”) and as the broad-phase for the built-in-numpy slow ray query engine. |
|
|
|
Do network queries in |
|
|
|
Evaluate symbolic algebra |
|
|
|
Quickly hash arrays, used for our cache checking |
|
|
|
A serialization method that supports bytes-blobs. |
|
|
|
When we fail to decode text as UTF-8 we then check with chardet which guesses an encoding. This lets us load files even with weird encodings. |
|
|
|
Printing logs with colors. |
|
|
|
Reading raster images for textures, and rendering polygons into raster images. |
|
|
|
Parsing SVG path strings. |
|
|
|
Validating our exports for formats like GLTF. |
|
|
|
Parse |
|
|
|
OpenGL bindings for our simple debug viewer. |
|
|
|
Unwrap meshes to generate UV coordinates quickly and well. |
|
|
|
Do collision queries between meshes |
|
|
|
Provide a viewer with widgets. |
|
|
|
Load additional mesh formats. |
|
|
|
Used in voxel ops |
|
|
|
Triangulate 2D polygons |
|
|
|
Get current memory usage, useful for checking to see if we’re going to run out of memory instantiating a giant array |
|
|
|
A static code analyzer that replaces |
|
|
|
A code formatter which fixes whitespace issues automatically. |
|
|
|
A test runner. |
|
|
|
A plugin to calculate test coverage. |
|
|
|
A sampling based profiler for performance tweaking. |
|