trimesh.scene package¶
Submodules¶
trimesh.scene.cameras module¶

class
trimesh.scene.cameras.
Camera
(name=None, resolution=None, focal=None, fov=None, scene=None, transform=None)¶ Bases:
object
 Attributes
K
Get the intrinsic matrix for the Camera object.
focal
Get the focal length in pixels for the camera.
fov
Get the field of view in degrees.
resolution
Get the camera resolution in pixels.
scene
Get a reference to the scene that this camera is in.
transform
Get the (4, 4) homogenous transformation from the world frame to this camera object.
Methods
to_rays
()Convert a trimesh.scene.Camera object to ray origins and direction vectors.

K
¶ Get the intrinsic matrix for the Camera object.
 Returns
 K(3, 3) float
Intrinsic matrix for camera

focal
¶ Get the focal length in pixels for the camera.
 Returns
 focal(2,) float
Focal length in pixels

fov
¶ Get the field of view in degrees.
 Returns
 fov(2,) float
XY field of view in degrees

resolution
¶ Get the camera resolution in pixels.
 Returns
 resolution (2,) float
Camera resolution in pixels

scene
¶ Get a reference to the scene that this camera is in.
 Returns
 sceneNone, or trimesh.Scene
Scene where this camera is attached

to_rays
()¶ Convert a trimesh.scene.Camera object to ray origins and direction vectors. Will return one ray per pixel, as set in camera.resolution.
 Returns
 origins(n, 3) float
Ray origins in space
 vectors(n, 3) float
Ray direction unit vectors
 angles(n, 2) float
Ray spherical coordinate angles in radians

transform
¶ Get the (4, 4) homogenous transformation from the world frame to this camera object.
 Returns
 transform(4, 4) float
Transform from world to camera

trimesh.scene.cameras.
camera_to_rays
(camera)¶ Convert a trimesh.scene.Camera object to ray origins and direction vectors. Will return one ray per pixel, as set in camera.resolution.
 Parameters
 cameratrimesh.scene.Camera
Camera with transform defined
 Returns
 origins(n, 3) float
Ray origins in space
 vectors(n, 3) float
Ray direction unit vectors
 angles(n, 2) float
Ray spherical coordinate angles in radians

trimesh.scene.cameras.
look_at
(points, fov, rotation=None, distance=None, center=None)¶ Generate transform for a camera to keep a list of points in the camera’s field of view.
 Parameters
 points(n, 3) float
Points in space
 fov(2,) float
Field of view, in DEGREES
 rotationNone, or (4, 4) float
Rotation matrix for initial rotation
 centerNone, or (3,) float
Center of field of view.
 Returns
 transform(4, 4) float
Transformation matrix with points in view
trimesh.scene.lighting module¶
lighting.py¶
Hold basic information about lights.
Forked from the light model in pyrender: https://github.com/mmatl/pyrender

class
trimesh.scene.lighting.
DirectionalLight
(name=None, color=None, intensity=None, radius=None)¶ Bases:
trimesh.scene.lighting.Light
Directional lights are light sources that act as though they are infinitely far away and emit light in the direction of the local z axis. This light type inherits the orientation of the node that it belongs to; position and scale are ignored except for their effect on the inherited node orientation. Because it is at an infinite distance, the light is not attenuated. Its intensity is defined in lumens per metre squared, or lux (lm/m2).
 Attributes
 namestr, optional
Name of the light.
 color(4,) unit8
RGBA value for the light’s color in linear space.
 intensityfloat
Brightness of light. The units that this is defined in depend on the type of light. point and spot lights use luminous intensity in candela (lm/sr), while directional lights use illuminance in lux (lm/m2).
 radiusfloat
Cutoff distance at which light’s intensity may be considered to have reached zero. Supported only for point and spot lights, must be > 0. If None, the radius is assumed to be infinite.

class
trimesh.scene.lighting.
Light
(name=None, color=None, intensity=None, radius=None)¶ Bases:
abc.ABC
Base class for all light objects.
 Attributes
 namestr, optional
Name of the light.
 color(4,) uint8
RGBA value for the light’s color in linear space.
 intensityfloat
Brightness of light. The units that this is defined in depend on the type of light: point and spot lights use luminous intensity in candela (lm/sr) while directional lights use illuminance in lux (lm/m2).
 radiusfloat
Cutoff distance at which light’s intensity may be considered to have reached zero. Supported only for point and spot lights Must be > 0.0 If None, the radius is assumed to be infinite.

color
¶

intensity
¶

radius
¶

class
trimesh.scene.lighting.
PointLight
(name=None, color=None, intensity=None, radius=None)¶ Bases:
trimesh.scene.lighting.Light
Point lights emit light in all directions from their position in space; rotation and scale are ignored except for their effect on the inherited node position. The brightness of the light attenuates in a physically correct manner as distance increases from the light’s position (i.e. brightness goes like the inverse square of the distance). Point light intensity is defined in candela, which is lumens per square radian (lm/sr).
 Attributes
 namestr, optional
Name of the light.
 color(4,) uint8
RGBA value for the light’s color in linear space.
 intensityfloat
Brightness of light. The units that this is defined in depend on the type of light. point and spot lights use luminous intensity in candela (lm/sr), while directional lights use illuminance in lux (lm/m2).
 radiusfloat
Cutoff distance at which light’s intensity may be considered to have reached zero. Supported only for point and spot lights, must be > 0. If None, the radius is assumed to be infinite.

class
trimesh.scene.lighting.
SpotLight
(name=None, color=None, intensity=None, radius=None, innerConeAngle=0.0, outerConeAngle=0.7853981633974483)¶ Bases:
trimesh.scene.lighting.Light
Spot lights emit light in a cone in the direction of the local z axis. The angle and falloff of the cone is defined using two numbers, the innerConeAngle and outerConeAngle. As with point lights, the brightness also attenuates in a physically correct manner as distance increases from the light’s position (i.e. brightness goes like the inverse square of the distance). Spot light intensity refers to the brightness inside the innerConeAngle (and at the location of the light) and is defined in candela, which is lumens per square radian (lm/sr). A spot light’s position and orientation are inherited from its node transform. Inherited scale does not affect cone shape, and is ignored except for its effect on position and orientation.
 Attributes
 namestr, optional
Name of the light.
 color(4,) uint8
RGBA value for the light’s color in linear space.
 intensityfloat
Brightness of light. The units that this is defined in depend on the type of light. point and spot lights use luminous intensity in candela (lm/sr), while directional lights use illuminance in lux (lm/m2).
 radiusfloat
Cutoff distance at which light’s intensity may be considered to have reached zero. Supported only for point and spot lights, must be > 0. If None, the radius is assumed to be infinite.
 innerConeAnglefloat
Angle, in radians, from centre of spotlight where falloff begins. Must be greater than or equal to 0 and less than outerConeAngle.
 outerConeAnglefloat
Angle, in radians, from centre of spotlight where falloff ends. Must be greater than innerConeAngle and less than or equal to PI / 2.0.

innerConeAngle
¶

outerConeAngle
¶

trimesh.scene.lighting.
autolight
(scene)¶ Generate a list of lights for a scene that looks decent.
 Parameters
 scenetrimesh.Scene
Scene with geometry
 Returns
 lights[Light]
List of light objects
 transforms(len(lights), 4, 4) float
Transformation matrices for light positions.
trimesh.scene.scene module¶

class
trimesh.scene.scene.
Scene
(geometry=None, base_frame='world', metadata={}, graph=None, camera=None, lights=None)¶ Bases:
trimesh.parent.Geometry
A simple scene graph which can be rendered directly via pyglet/openGL or through other endpoints such as a raytracer. Meshes are added by name, which can then be moved by updating transform in the transform tree.
 Attributes
bounding_box
An axis aligned bounding box for the current mesh.
bounding_box_oriented
An oriented bounding box for the current mesh.
bounding_cylinder
A minimum volume bounding cylinder for the current mesh.
bounding_primitive
The minimum volume primitive (box, sphere, or cylinder) that bounds the mesh.
bounding_sphere
A minimum volume bounding sphere for the current mesh.
bounds
Return the overall bounding box of the scene.
bounds_corners
A list of points that represent the corners of the AABB of every geometry in the scene.
camera
Get the single camera for the scene.
centroid
Return the center of the bounding box for the scene.
convex_hull
The convex hull of the whole scene
duplicate_nodes
Return a sequence of node keys of identical meshes.
extents
Return the axis aligned box size of the current scene.
geometry_identifiers
Look up geometries by identifier MD5
is_empty
Does the scene have anything in it.
is_valid
Is every geometry connected to the root node.
lights
Get a list of the lights in the scene.
scale
The approximate scale of the mesh
triangles
Return a correctly transformed polygon soup of the current scene.
triangles_node
Which node of self.graph does each triangle come from.
units
Get the units for every model in the scene, and raise a ValueError if there are mixed units.
Methods
add_geometry
(geometry[, node_name, …])Add a geometry to the scene.
apply_scale
(scaling)Scale the mesh equally on all axis.
apply_translation
(translation)Translate the current mesh.
convert_units
(desired[, guess])If geometry has units defined convert them to new units.
copy
()Return a deep copy of the current scene
dump
()Append all meshes in scene to a list of meshes.
explode
([vector, origin])Explode a scene around a point and vector.
export
([file_type])Export a snapshot of the current scene.
md5
()MD5 of scene which will change when meshes or transforms are changed
rezero
()Move the current scene so that the AABB of the whole scene is centered at the origin.
save_image
([resolution])Get a PNG image of a scene.
scaled
(scale)Return a copy of the current scene, with meshes and scene transforms scaled to the requested factor.
set_camera
([angles, distance, center, …])Create a camera object for self.camera, and add a transform to self.graph for it.
show
([viewer])Display the current scene.
apply_transform

add_geometry
(geometry, node_name=None, geom_name=None, parent_node_name=None, transform=None)¶ Add a geometry to the scene.
If the mesh has multiple transforms defined in its metadata, they will all be copied into the TransformForest of the current scene automatically.
 Parameters
 geometryTrimesh, Path2D, Path3D PointCloud or list
Geometry to initially add to the scene
 base_framestr or hashable
Name of base frame
 metadatadict
Any metadata about the scene
 graphTransformForest or None
A passed transform graph to use
 Returns
 node_namestr
Name of node in self.graph

apply_transform
(transform)¶

bounds
¶ Return the overall bounding box of the scene.
 Returns
 bounds: (2,3) float points for min, max corner

bounds_corners
¶ A list of points that represent the corners of the AABB of every geometry in the scene.
This can be useful if you want to take the AABB in a specific frame.
 Returns
 corners: (n, 3) float, points in space

camera
¶ Get the single camera for the scene. If not manually set one will abe automatically generated.
 Returns
 cameratrimesh.scene.Camera
Camera object defined for the scene

centroid
¶ Return the center of the bounding box for the scene.
 Returns
 centroid: (3) float point for center of bounding box

convert_units
(desired, guess=False)¶ If geometry has units defined convert them to new units.
Returns a new scene with geometries and transforms scaled.
 Parameters
 desiredstr
Desired final unit system: ‘inches’, ‘mm’, etc.
 guessbool
Is the converter allowed to guess scale when models don’t have it specified in their metadata.
 Returns
 scaledtrimesh.Scene
Copy of scene with scaling applied and units set for every model

convex_hull
¶ The convex hull of the whole scene
 Returns
 hull: Trimesh object, convex hull of all meshes in scene

copy
()¶ Return a deep copy of the current scene
 Returns
 copiedtrimesh.Scene
Copy of the current scene

dump
()¶ Append all meshes in scene to a list of meshes.
 Returns
 dumped: (n,) list, of Trimesh objects transformed to their
location the scene.graph

duplicate_nodes
¶ Return a sequence of node keys of identical meshes.
Will combine meshes duplicated by copying in space with different keys in self.geometry, as well as meshes repeated by self.nodes.
 Returns
 duplicates: (m) sequence of keys to self.nodes that represent
identical geometry

explode
(vector=None, origin=None)¶ Explode a scene around a point and vector.
 Parameters
 vector(3,) float or float
Explode radially around a direction vector or spherically
 origin(3,) float
Point to explode around

export
(file_type=None)¶ Export a snapshot of the current scene.
 Parameters
 file_type: what encoding to use for meshes
ie: dict, dict64, stl
 Returns
 export: dict with keys:
meshes: list of meshes, encoded as per file_type transforms: edge list of transforms, eg:
((u, v, {‘matrix’ : np.eye(4)}))

extents
¶ Return the axis aligned box size of the current scene.
 Returns
 extents: (3,) float, bounding box sides length

geometry_identifiers
¶ Look up geometries by identifier MD5
 Returns
 identifiers: dict, identifier md5: key in self.geometry

is_empty
¶ Does the scene have anything in it.
 Returns
 is_empty: bool, True if nothing is in the scene

is_valid
¶ Is every geometry connected to the root node.
 Returns
 is_validbool
Does every geometry have a transform

lights
¶ Get a list of the lights in the scene. If nothing is set it will generate some automatically.
 Returns
 lights[trimesh.scene.lighting.Light]
Lights in the scene.

md5
()¶ MD5 of scene which will change when meshes or transforms are changed
 Returns
 hashed: str, MD5 hash of scene

rezero
()¶ Move the current scene so that the AABB of the whole scene is centered at the origin.
Does this by changing the base frame to a new, offset base frame.

save_image
(resolution=(1024, 768), **kwargs)¶ Get a PNG image of a scene.
 Parameters
 resolution: (2,) int, resolution to render image
 **kwargs: passed to SceneViewer constructor
 Returns
 png: bytes, render of scene in PNG form

scale
¶ The approximate scale of the mesh
 Returns
 scale: float, the mean of the bounding box edge lengths

scaled
(scale)¶ Return a copy of the current scene, with meshes and scene transforms scaled to the requested factor.
 Parameters
 scalefloat
Factor to scale meshes and transforms
 Returns
 scaledtrimesh.Scene
A copy of the current scene but scaled

set_camera
(angles=None, distance=None, center=None, resolution=None, fov=None)¶ Create a camera object for self.camera, and add a transform to self.graph for it.
If arguments are not passed sane defaults will be figured out which show the mesh roughly centered.
 Parameters
 angles(3,) float
Initial euler angles in radians
 distancefloat
Distance from centroid
 center(3,) float
Point camera should be center on
 cameraCamera object
Object that stores camera parameters

show
(viewer=None, **kwargs)¶ Display the current scene.
 Parameters
 viewer: str ‘gl’: open a pyglet window
str,’notebook’: return ipython.display.HTML None: automatically pick based on whether or not
we are in an ipython notebook
 smoothbool
Turn on or off automatic smooth shading

triangles
¶ Return a correctly transformed polygon soup of the current scene.
 Returns
 triangles: (n,3,3) float, triangles in space

triangles_node
¶ Which node of self.graph does each triangle come from.
 Returns
 triangles_index(len(self.triangles),)
Node name for each triangle

units
¶ Get the units for every model in the scene, and raise a ValueError if there are mixed units.
 Returns
 unitsstr
Units for every model in the scene

trimesh.scene.scene.
append_scenes
(iterable, common=['world'])¶ Concatenate multiple scene objects into one scene.
 Parameters
 iterable(n,) Trimesh or Scene
Geometries that should be appended
 common(n,) str
Nodes that shouldn’t be remapped
 Returns
 resulttrimesh.Scene
Scene containing all geometry

trimesh.scene.scene.
split_scene
(geometry)¶ Given a geometry, list of geometries, or a Scene return them as a single Scene object.
 Parameters
 geometrysplittable
 Returns
 scene: trimesh.Scene
trimesh.scene.transforms module¶

class
trimesh.scene.transforms.
EnforcedForest
(*args, **kwargs)¶ Bases:
networkx.classes.digraph.DiGraph
A subclass of networkx.DiGraph that will raise an error if an edge is added which would make the DiGraph not a forest or tree.
 Attributes
 name
Methods
add_cycle
(nodes, **attr)Add a cycle.
add_edge
(u, v, *args, **kwargs)Add an edge between u and v.
add_edges_from
(*args, **kwargs)Add all the edges in ebunch.
add_node
(n[, attr_dict])Add a single node n and update node attributes.
add_nodes_from
(nodes, **attr)Add multiple nodes.
add_path
(*args, **kwargs)Add a path.
add_star
(nodes, **attr)Add a star.
add_weighted_edges_from
(ebunch[, weight])Add all the edges in ebunch as weighted edges with specified weights.
adjacency_iter
()Return an iterator of (node, adjacency dict) tuples for all nodes.
adjacency_list
()Return an adjacency list representation of the graph.
adjlist_dict_factory
alias of
builtins.dict
clear
()Remove all nodes and edges from the graph.
copy
()Return a copy of the graph.
degree
([nbunch, weight])Return the degree of a node or nodes.
degree_iter
([nbunch, weight])Return an iterator for (node, degree).
edge_attr_dict_factory
alias of
builtins.dict
edges
([nbunch, data, default])Return a list of edges.
edges_iter
([nbunch, data, default])Return an iterator over the edges.
get_edge_data
(u, v[, default])Return the attribute dictionary associated with edge (u,v).
has_edge
(u, v)Return True if the edge (u,v) is in the graph.
has_node
(n)Return True if the graph contains the node n.
has_predecessor
(u, v)Return True if node u has predecessor v.
has_successor
(u, v)Return True if node u has successor v.
in_degree
([nbunch, weight])Return the indegree of a node or nodes.
in_degree_iter
([nbunch, weight])Return an iterator for (node, indegree).
in_edges
([nbunch, data])Return a list of the incoming edges.
in_edges_iter
([nbunch, data])Return an iterator over the incoming edges.
is_directed
()Return True if graph is directed, False otherwise.
is_multigraph
()Return True if graph is a multigraph, False otherwise.
nbunch_iter
([nbunch])Return an iterator of nodes contained in nbunch that are also in the graph.
neighbors
(n)Return a list of successor nodes of n.
neighbors_iter
(n)Return an iterator over successor nodes of n.
node_dict_factory
alias of
builtins.dict
nodes
([data])Return a list of the nodes in the graph.
nodes_iter
([data])Return an iterator over the nodes.
nodes_with_selfloops
()Return a list of nodes with self loops.
number_of_edges
([u, v])Return the number of edges between two nodes.
number_of_nodes
()Return the number of nodes in the graph.
number_of_selfloops
()Return the number of selfloop edges.
order
()Return the number of nodes in the graph.
out_degree
([nbunch, weight])Return the outdegree of a node or nodes.
out_degree_iter
([nbunch, weight])Return an iterator for (node, outdegree).
out_edges
([nbunch, data, default])Return a list of edges.
out_edges_iter
([nbunch, data, default])Return an iterator over the edges.
predecessors
(n)Return a list of predecessor nodes of n.
predecessors_iter
(n)Return an iterator over predecessor nodes of n.
remove_edge
(*args, **kwargs)Remove the edge between u and v.
remove_edges_from
(*args, **kwargs)Remove all edges specified in ebunch.
remove_node
(n)Remove node n.
remove_nodes_from
(nbunch)Remove multiple nodes.
reverse
([copy])Return the reverse of the graph.
selfloop_edges
([data, default])Return a list of selfloop edges.
size
([weight])Return the number of edges.
subgraph
(nbunch)Return the subgraph induced on nodes in nbunch.
successors
(n)Return a list of successor nodes of n.
successors_iter
(n)Return an iterator over successor nodes of n.
to_directed
()Return a directed copy of the graph.
to_undirected
([reciprocal])Return an undirected representation of the digraph.
disconnect_path
get_edge_data_direction
shortest_path_undirected

add_edge
(u, v, *args, **kwargs)¶ Add an edge between u and v.
The nodes u and v will be automatically added if they are not already in the graph.
Edge attributes can be specified with keywords or by providing a dictionary with key/value pairs. See examples below.
 Parameters
 u, vnodes
Nodes can be, for example, strings or numbers. Nodes must be hashable (and not None) Python objects.
 attr_dictdictionary, optional (default= no attributes)
Dictionary of edge attributes. Key/value pairs will update existing data associated with the edge.
 attrkeyword arguments, optional
Edge data (or labels or objects) can be assigned using keyword arguments.
See also
add_edges_from
add a collection of edges
Notes
Adding an edge that already exists updates the edge data.
Many NetworkX algorithms designed for weighted graphs use as the edge weight a numerical value assigned to a keyword which by default is ‘weight’.
Examples
The following all add the edge e=(1,2) to graph G:
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> e = (1,2) >>> G.add_edge(1, 2) # explicit twonode form >>> G.add_edge(*e) # single edge as tuple of two nodes >>> G.add_edges_from( [(1,2)] ) # add edges from iterable container
Associate data to edges using keywords:
>>> G.add_edge(1, 2, weight=3) >>> G.add_edge(1, 3, weight=7, capacity=15, length=342.7)

add_edges_from
(*args, **kwargs)¶ Add all the edges in ebunch.
 Parameters
 ebunchcontainer of edges
Each edge given in the container will be added to the graph. The edges must be given as as 2tuples (u,v) or 3tuples (u,v,d) where d is a dictionary containing edge data.
 attr_dictdictionary, optional (default= no attributes)
Dictionary of edge attributes. Key/value pairs will update existing data associated with each edge.
 attrkeyword arguments, optional
Edge data (or labels or objects) can be assigned using keyword arguments.
See also
add_edge
add a single edge
add_weighted_edges_from
convenient way to add weighted edges
Notes
Adding the same edge twice has no effect but any edge data will be updated when each duplicate edge is added.
Edge attributes specified in edges take precedence over attributes specified generally.
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_edges_from([(0,1),(1,2)]) # using a list of edge tuples >>> e = zip(range(0,3),range(1,4)) >>> G.add_edges_from(e) # Add the path graph 0123
Associate data to edges
>>> G.add_edges_from([(1,2),(2,3)], weight=3) >>> G.add_edges_from([(3,4),(1,4)], label='WN2898')

add_path
(*args, **kwargs)¶ Add a path.
 Parameters
 nodesiterable container
A container of nodes. A path will be constructed from the nodes (in order) and added to the graph.
 attrkeyword arguments, optional (default= no attributes)
Attributes to add to every edge in path.
See also
add_star
,add_cycle
Examples
>>> G=nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_path([0,1,2,3]) >>> G.add_path([10,11,12],weight=7)

disconnect_path
(path)¶

get_edge_data_direction
(u, v)¶

remove_edge
(*args, **kwargs)¶ Remove the edge between u and v.
 Parameters
 u, vnodes
Remove the edge between nodes u and v.
 Raises
 NetworkXError
If there is not an edge between u and v.
See also
remove_edges_from
remove a collection of edges
Examples
>>> G = nx.Graph() # or DiGraph, etc >>> G.add_path([0,1,2,3]) >>> G.remove_edge(0,1) >>> e = (1,2) >>> G.remove_edge(*e) # unpacks e from an edge tuple >>> e = (2,3,{'weight':7}) # an edge with attribute data >>> G.remove_edge(*e[:2]) # select first part of edge tuple

remove_edges_from
(*args, **kwargs)¶ Remove all edges specified in ebunch.
 Parameters
 ebunch: list or container of edge tuples
Each edge given in the list or container will be removed from the graph. The edges can be:
2tuples (u,v) edge between u and v.
3tuples (u,v,k) where k is ignored.
See also
remove_edge
remove a single edge
Notes
Will fail silently if an edge in ebunch is not in the graph.
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_path([0,1,2,3]) >>> ebunch=[(1,2),(2,3)] >>> G.remove_edges_from(ebunch)

shortest_path_undirected
(u, v)¶

class
trimesh.scene.transforms.
TransformForest
(base_frame='world')¶ Bases:
object
 Attributes
nodes
A list of every node in the graph.
nodes_geometry
The nodes in the scene graph with geometry attached.
Methods
copy
()Return a copy of the current TransformForest
from_edgelist
(edges[, strict])Load transform data from an edge list into the current scene graph.
get
(frame_to[, frame_from])Get the transform from one frame to another, assuming they are connected in the transform tree.
load
(edgelist)Load transform data from an edge list into the current scene graph.
show
()Plot the graph layout of the scene.
Export the current transforms as a list of edge tuples, with each tuple having the format: (node_a, node_b, {metadata})
to_flattened
([base_frame])Export the current transform graph as a flattened
to_gltf
(scene)Export a transforms as the ‘nodes’ section of a GLTF dict.
update
(frame_to[, frame_from])Update a transform in the tree.
clear
md5
to_svg

clear
()¶

copy
()¶ Return a copy of the current TransformForest
 Returns
 copied: TransformForest

from_edgelist
(edges, strict=True)¶ Load transform data from an edge list into the current scene graph.
 Parameters
 edgelist(n,) tuples
(node_a, node_b, {key: value})
 strictbool
If true, raise a ValueError when a malformed edge is passed in a tuple.

get
(frame_to, frame_from=None)¶ Get the transform from one frame to another, assuming they are connected in the transform tree.
If the frames are not connected a NetworkXNoPath error will be raised.
 frame_tohashable
Node name, usually a string (eg ‘mesh_0’)
 frame_fromhashable
Node name, usually a string (eg ‘world’). If None it will be set to self.base_frame
 Returns
 transform(4, 4) float
Homogenous transformation matrix

load
(edgelist)¶ Load transform data from an edge list into the current scene graph.
 Parameters
 edgelist(n,) tuples
(node_a, node_b, {key: value})

md5
()¶

nodes
¶ A list of every node in the graph.
 Returns
 nodes: (n,) array, of node names

nodes_geometry
¶ The nodes in the scene graph with geometry attached.
 Returns
 nodes_geometry: (m,) array, of node names

show
()¶ Plot the graph layout of the scene.

to_edgelist
()¶ Export the current transforms as a list of edge tuples, with each tuple having the format: (node_a, node_b, {metadata})
 Returns
 edgelist: (n,) list of tuples

to_flattened
(base_frame=None)¶ Export the current transform graph as a flattened

to_gltf
(scene)¶ Export a transforms as the ‘nodes’ section of a GLTF dict. Flattens tree.
 Returns
 gltfdict
 with keys:
‘nodes’: list of dicts

to_svg
()¶

update
(frame_to, frame_from=None, **kwargs)¶ Update a transform in the tree.
 frame_fromhashable object
Usually a string (eg ‘world’). If left as None it will be set to self.base_frame
 frame_tohashable object
Usually a string (eg ‘mesh_0’)
 matrix(4,4) float
Homogenous transformation matrix
 quaternion(4,) float
Quaternion ordered [w, x, y, z]
 axis(3,) float
Axis of rotation
 anglefloat
Angle of rotation, in radians
 translation(3,) float
Distance to translate
 geometryhashable
Geometry object name, e.g. ‘mesh_0’

trimesh.scene.transforms.
kwargs_to_matrix
(**kwargs)¶ Turn a set of keyword arguments into a transformation matrix.

trimesh.scene.transforms.
path_to_edges
(path)¶ Turn an (n) path into a (2(n1)) set of edges