You can use trimesh.load
to load your glTF file. Note that the return type depends on the filetype of your model file. For glTF files it will return an instance of trimesh.Scene
. The scene has all sorts of attributes like the camera, lights but also geometries. This is because glTF files can contain more that just model data. Each geometry is an instance of trimesh.Trimesh
, which is the base class for geometries and has a edges_sparse
property which represents the adjacency matrix of the model.
To put it all together:
scene = trimesh.load("some_file.glb")
geometries = list(scene.geometry.values())
geometry = geometries[0]
adjacency_matrix = geometry.edges_sparse
It's a bit tedious to figure this out using the documentation. I tend to look at the source code or turn on the debugger in my IDE: