def 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
    ------------
    result : trimesh.Scene
       Scene containing all geometry
    """
    if isinstance(iterable, Scene):
        return iterable

    # save geometry in dict
    geometry = {}
    # save transforms as edge tuples
    edges = []

    # nodes which shouldn't be remapped
    common = set(common)
    # nodes which are consumed and need to be remapped
    consumed = set()

    def node_remap(node):
        """
        Remap node to new name if necessary

        Parameters
        -------------
        node : hashable
           Node name in original scene

        Returns
        -------------
        name : hashable
           Node name in concatenated scene
        """

        # if we've already remapped a node use it
        if node in map_node:
            return map_node[node]

        # if a node is consumed and isn't one of the nodes
        # we're going to hold common between scenes remap it
        if node not in common and node in consumed:
            name = str(node) + '-' + util.unique_id().upper()
            map_node[node] = name
            node = name

        # keep track of which nodes have been used
        # in the current scene
        current.add(node)
        return node

    # loop through every geometry
    for s in iterable:
        # allow Trimesh/Path2D geometry to be passed
        if hasattr(s, 'scene'):
            s = s.scene()
        # if we don't have a scene raise an exception
        if not isinstance(s, Scene):
            raise ValueError('{} is not a scene!'.format(
                type(s).__name__))

        # remap geometries if they have been consumed
        map_geom = {}
        for k, v in s.geometry.items():
            # if a geometry already exists add a UUID to the name
            if k in geometry:
                name = str(k) + '-' + util.unique_id().upper()
            else:
                name = k
            # store name mapping
            map_geom[k] = name
            # store geometry with new name
            geometry[name] = v

        # remap nodes and edges so duplicates won't
        # stomp all over each other
        map_node = {}
        # the nodes used in this scene
        current = set()
        for a, b, attr in s.graph.to_edgelist():
            # remap node names from local names
            a, b = node_remap(a), node_remap(b)
            # remap geometry keys
            # if key is not in map_geom it means one of the scenes
            # referred to geometry that doesn't exist
            # rather than crash here we ignore it as the user
            # possibly intended to add in geometries back later
            if 'geometry' in attr and attr['geometry'] in map_geom:
                attr['geometry'] = map_geom[attr['geometry']]
            # save the new edge
            edges.append((a, b, attr))
        # mark nodes from current scene as consumed
        consumed.update(current)

    # add all data to a new scene
    result = Scene()
    result.graph.from_edgelist(edges)
    result.geometry.update(geometry)

    return result
def append_scenes ( iterable , common = [ 'world' ] ) : if isinstance ( iterable , Scene ) : return iterable geometry = { } edges = [ ] common = set ( common ) consumed = set ( ) def node_remap ( node ) : if node in map_node : return map_node [ node ] if node not in common and node in consumed : name = str ( node ) + '-' + util . unique_id ( ) . upper ( ) map_node [ node ] = name node = name current . add ( node ) return node for s in iterable : if hasattr ( s , 'scene' ) : s = s . scene ( ) if not isinstance ( s , Scene ) : raise ValueError ( '{} is not a scene!' . format ( type ( s ) . __name__ ) ) map_geom = { } for k , v in s . geometry . items ( ) : if k in geometry : name = str ( k ) + '-' + util . unique_id ( ) . upper ( ) else : name = k map_geom [ k ] = name geometry [ name ] = v map_node = { } current = set ( ) for a , b , attr in s . graph . to_edgelist ( ) : a , b = node_remap ( a ) , node_remap ( b ) if 'geometry' in attr and attr [ 'geometry' ] in map_geom : attr [ 'geometry' ] = map_geom [ attr [ 'geometry' ] ] edges . append ( ( a , b , attr ) ) consumed . update ( current ) result = Scene ( ) result . graph . from_edgelist ( edges ) result . geometry . update ( geometry ) return result
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
    ------------
    result : trimesh.Scene
       Scene containing all geometry