{"id":13444215,"url":"https://github.com/mikedh/trimesh","last_synced_at":"2026-04-24T01:04:59.974Z","repository":{"id":9773977,"uuid":"11745275","full_name":"mikedh/trimesh","owner":"mikedh","description":"Python library for loading and using triangular meshes.","archived":false,"fork":false,"pushed_at":"2025-05-13T20:14:19.000Z","size":30172,"stargazers_count":3236,"open_issues_count":459,"forks_count":610,"subscribers_count":49,"default_branch":"main","last_synced_at":"2025-05-13T21:30:27.247Z","etag":null,"topics":["geometry","mesh","python","triangular-meshes"],"latest_commit_sha":null,"homepage":"https://trimesh.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikedh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-07-29T17:25:42.000Z","updated_at":"2025-05-13T19:21:43.000Z","dependencies_parsed_at":"2023-09-28T22:29:53.988Z","dependency_job_id":"bb4b94f5-8389-4042-88b6-a75e7f86fb73","html_url":"https://github.com/mikedh/trimesh","commit_stats":{"total_commits":4013,"total_committers":180,"mean_commits":"22.294444444444444","dds":0.5041116371791676,"last_synced_commit":"0ca40121a2c32e461b72f54e541c0d1b15cfeaa0"},"previous_names":[],"tags_count":464,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikedh%2Ftrimesh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikedh%2Ftrimesh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikedh%2Ftrimesh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikedh%2Ftrimesh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikedh","download_url":"https://codeload.github.com/mikedh/trimesh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036807,"owners_count":22003651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geometry","mesh","python","triangular-meshes"],"created_at":"2024-07-31T03:02:22.113Z","updated_at":"2026-01-07T21:19:16.141Z","avatar_url":"https://github.com/mikedh.png","language":"Python","funding_links":[],"categories":["Python","GamePlay","Python Libraries","CAD \u0026 Geometry","Subject-Specific Modelling","Meshing"],"sub_categories":["HUD","Verified vs declared","Manipulation, Processing and Comparison of Surface Meshes","Triangular and tetrahedral meshing"],"readme":"[![trimesh](https://trimesh.org/_static/images/logotype-a.svg)](http://trimesh.org)\n\n-----------\n[![Github Actions](https://github.com/mikedh/trimesh/workflows/Release%20Trimesh/badge.svg)](https://github.com/mikedh/trimesh/actions) [![codecov](https://codecov.io/gh/mikedh/trimesh/branch/main/graph/badge.svg?token=4PVRQXyl2h)](https://codecov.io/gh/mikedh/trimesh)  [![Docker Image Version (latest by date)](https://img.shields.io/docker/v/trimesh/trimesh?label=docker\u0026sort=semver)](https://hub.docker.com/r/trimesh/trimesh/tags) [![PyPI version](https://badge.fury.io/py/trimesh.svg)](https://badge.fury.io/py/trimesh)\n\n\nTrimesh is a pure Python 3.8+ library for loading and using [triangular meshes](https://en.wikipedia.org/wiki/Triangle_mesh) with an emphasis on watertight surfaces. The goal of the library is to provide a full featured and well tested Trimesh object which allows for easy manipulation and analysis, in the style of the Polygon object in the [Shapely library](https://github.com/Toblerity/Shapely).\n\nThe API is mostly stable, but this should not be relied on and is not guaranteed: install a specific version if you plan on deploying something using `trimesh`.\n\nPull requests are appreciated and responded to promptly! If you'd like to contribute, here a quick [development and contributing guide.](https://trimesh.org/contributing.html)\n\n\n## Basic Installation\n\nKeeping `trimesh` easy to install is a core goal, thus the *only* hard dependency is [`numpy`](http://www.numpy.org/). Installing other packages adds functionality but is not required. For the easiest install with just `numpy`:\n\n```bash\npip install trimesh\n```\n\nThe minimal install can load many supported formats (STL, PLY, OBJ, GLTF/GLB) into `numpy.ndarray` values. More functionality is available when [soft dependencies are installed](https://trimesh.org/install#dependency-overview), including convex hulls (`scipy`), graph operations (`networkx`), fast ray queries (`embreex`), vector path handling (`shapely` and `rtree`), XML formats like 3DXML/XAML/3MF (`lxml`), preview windows (`pyglet`), faster cache checks (`xxhash`), etc.\n\nTo install `trimesh` with the soft dependencies that generally install cleanly from binaries on Linux x86_64, MacOS ARM, and Windows x86_64 using `pip`:\n```bash\npip install trimesh[easy]\n```\n\nIf you are supporting a different platform or are freezing dependencies for an application we recommend you do not use extras, i.e. depend on `trimesh scipy` versus `trimesh[easy]`. Further information is available in the [advanced installation documentation](https://trimesh.org/install.html).\n\n## Quick Start\n\nHere is an example of loading a mesh from file and colorizing its faces ([nicely formatted notebook version](https://trimesh.org/quick_start.html) of this example.\n\n```python\nimport numpy as np\nimport trimesh\n\n# attach to logger so trimesh messages will be printed to console\ntrimesh.util.attach_to_log()\n\n# mesh objects can be created from existing faces and vertex data\nmesh = trimesh.Trimesh(vertices=[[0, 0, 0], [0, 0, 1], [0, 1, 0]],\n                       faces=[[0, 1, 2]])\n\n# by default, Trimesh will do a light processing, which will\n# remove any NaN values and merge vertices that share position\n# if you want to not do this on load, you can pass `process=False`\nmesh = trimesh.Trimesh(vertices=[[0, 0, 0], [0, 0, 1], [0, 1, 0]],\n                       faces=[[0, 1, 2]],\n                       process=False)\n\n# some formats like `glb` represent multiple meshes with multiple instances\n# and `load_mesh` will concatenate irreversibly, load it as a Scene\n# if you need instance information:\n#   `scene = trimesh.load_scene('models/CesiumMilkTruck.glb')`\nmesh = trimesh.load_mesh('models/CesiumMilkTruck.glb')\n\n# is the current mesh watertight?\nmesh.is_watertight\n\n# what's the euler number for the mesh?\nmesh.euler_number\n\n# the convex hull is another Trimesh object that is available as a property\n# lets compare the volume of our mesh with the volume of its convex hull\nprint(mesh.volume / mesh.convex_hull.volume)\n\n# since the mesh is watertight it means there is a volume\n# with a center of mass calculated from a surface integral approach\n# which we can set as the origin for our mesh. It's perfectly fine to\n# alter the vertices directly:\n#   mesh.vertices -= mesh.center_mass\n# although this will completely clear the cache including face normals\n# as we don't know that they're still valid. Using the translation\n# method will try to save cached values that are still valid:\nmesh.apply_translation(-mesh.center_mass)\n\n\n# what's the (3, 3) moment of inertia for the mesh?\nmesh.moment_inertia\n\n# if there are multiple bodies in the mesh we can split the mesh by\n# connected components of face adjacency\n# since this example mesh is a single watertight body we get a list of one mesh\nmesh.split()\n\n# facets are groups of coplanar adjacent faces\n# set each facet to a random color\n# colors are 8 bit RGBA by default (n, 4) np.uint8\nfor facet in mesh.facets:\n    mesh.visual.face_colors[facet] = trimesh.visual.random_color()\n\n# preview mesh in an opengl window if you installed pyglet and scipy with pip\nmesh.show()\n\n# transform method can be passed a (4, 4) matrix and will cleanly apply the transform\nmesh.apply_transform(trimesh.transformations.random_rotation_matrix())\n\n# axis aligned bounding box is available\nmesh.bounding_box.extents\n\n# a minimum volume oriented bounding box also available\n# primitives are subclasses of Trimesh objects which automatically generate\n# faces and vertices from data stored in the 'primitive' attribute\nmesh.bounding_box_oriented.primitive.extents\nmesh.bounding_box_oriented.primitive.transform\n\n# show the mesh appended with its oriented bounding box\n# the bounding box is a trimesh.primitives.Box object, which subclasses\n# Trimesh and lazily evaluates to fill in vertices and faces when requested\n# (press w in viewer to see triangles)\n(mesh + mesh.bounding_box_oriented).show()\n\n# bounding spheres and bounding cylinders of meshes are also\n# available, and will be the minimum volume version of each\n# except in certain degenerate cases, where they will be no worse\n# than a least squares fit version of the primitive.\nprint(mesh.bounding_box_oriented.volume,\n      mesh.bounding_cylinder.volume,\n      mesh.bounding_sphere.volume)\n\n```\n\n## Features\n\n* Import meshes from binary/ASCII STL, Wavefront OBJ, ASCII OFF, binary/ASCII PLY, GLTF/GLB 2.0, 3MF, XAML, 3DXML, etc.\n* Export meshes as GLB/GLTF, binary STL, binary PLY, ASCII OFF, OBJ, COLLADA, etc.\n* Import and export 2D or 3D vector paths with DXF or SVG files\n* Preview meshes using an OpenGL `pyglet` window, or in-line in jupyter or marimo notebooks using `three.js`\n* Automatic hashing from a subclassed numpy array for change tracking using MD5, zlib CRC, or xxhash, and internal caching of expensive values.\n* Calculate face adjacencies, face angles, vertex defects, convex hulls, etc.\n* Calculate cross sections for a 2D outline, or slice a mesh for a 3D remainder mesh, i.e. slicing for 3D-printing.\n* Split mesh based on face connectivity using networkx, or scipy.sparse\n* Calculate mass properties, including volume, center of mass, moment of inertia, principal components of inertia, etc. \n* Repair simple problems with triangle winding, normals, and quad/triangle holes\n* Compute rotation/translation/tessellation invariant identifier and find duplicate meshes\n* Check if a mesh is watertight, convex, etc.\n* Sample the surface of a mesh\n* Ray-mesh queries including location, triangle index, etc.\n* Boolean operations on meshes (intersection, union, difference) using Manifold3D or Blender.\n* Voxelize watertight meshes\n* Smooth watertight meshes using Laplacian smoothing algorithms (Classic, Taubin, Humphrey)\n* Subdivide faces of a mesh\n* Approximate minimum volume oriented bounding boxes and spheres for meshes.\n* Calculate nearest point on mesh surface and signed distance\n* Primitive objects (Box, Cylinder, Sphere, Extrusion) which are subclassed Trimesh objects and have all the same features (inertia, viewers, etc)\n* Simple scene graph and transform tree which can be rendered (pyglet window, three.js in a jupyter/marimo notebook or exported.\n* Many utility functions, like transforming points, unitizing vectors, aligning vectors, tracking numpy arrays for changes, grouping rows, etc.\n\n## Additional Notes\n\n- Check out some cool stuff people have done in the [GitHub network](https://github.com/mikedh/trimesh/network/dependents).\n- Generally `trimesh` API changes should have a one-year period of [printing a `warnings.DeprecationWarning`](https://trimesh.org/contributing.html#deprecations) although that's not always possible (i.e. the pyglet2 viewer rewrite that's been back-burnered for several years.) \n- Docker containers are available on Docker Hub as [`trimesh/trimesh`](https://hub.docker.com/r/trimesh/trimesh/tags) and there's a [container guide](https://trimesh.org/docker.html) in the docs.\n- If you're choosing which format to use, you may want to try [GLB](https://trimesh.org/formats.html) as a fast modern option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikedh%2Ftrimesh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikedh%2Ftrimesh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikedh%2Ftrimesh/lists"}