spatialgeometry.SceneGroup
- class SceneGroup(initlist: Iterable[SceneNode] | None = None, **kwargs)[source]
Bases:
SceneNode,UserListAn ordered, list-like collection of
SceneNodeobjects (nodes can be nested groups, shapes, or any otherSceneNodesubclass) that itself behaves like a singleSceneNode.- Parameters:
initlist – Initial elements to populate the group with.
A
SceneGroupis itself aSceneNodeso its elements can be collectively, parented or nested like any other node in the scene graph. This class inherits fromcollections.UserListso it behaves like a Python list, but it is not a subclass oflistso it can be subclassed itself.Every element’s
scene_parentis kept pointing at the group – adding an element (via the constructor,append,extend,insert, or item assignment) sets it, and removing one (remove,pop,clear,del) clears it back toNone. This is what makes moving the group move its elements with it.The reverse holds too, and isn’t just a side effect –
append()is nothing more thanitem.scene_parent = self, so setting any node’sscene_parentto aSceneGroupdirectly (with noappendcall at all) equally makes it a member of that group’s list. List membership and scene-graph parentage are the same relationship, not two things kept in sync – there’s no way for them to disagree.>>> from spatialgeometry import SceneGroup, Cuboid, Sphere >>> from spatialmath import SE3 >>> group = SceneGroup() >>> print(len(group)) 0 >>> group.append(Cuboid([1,2,3])) >>> group.append(Sphere(1, pose=SE3.Trans(1,0,0))) >>> print(len(group)) 2
- Parameters:
pose – Local reference frame of this node relative to its parent in the scene graph (or the world frame if it has no parent), defaults to the identity transform.
scene_parent – Parent node of this node in the scene graph.
scene_children – Child nodes of this node in the scene graph.
- append(item: SceneNode) None[source]
Add
itemto the end of the group and set itsscene_parentto this group.
- extend(other: Iterable[SceneNode]) None[source]
Add every element of
otherto the end of the group, setting each one’sscene_parentto this group.
- insert(i: int, item: SceneNode) None[source]
Insert
itemat positioniand set itsscene_parentto this group.