If you're new to Python
A VPython tutorial
Pictures of 3D objects
What's new in VPython 6
Composite Objects with frame
You can group objects together to make a composite object that can be moved and rotated as though it were a single object. Create a frame object, and associate objects with that frame:
f = frame()
By default, frame() has a position of (0,0,0) and axis in the x direction (1,0,0). The cylinder and sphere are created within the frame. When any of the frame attributes are changed (pos, x, y, z, axis, or up), the composite object is reoriented and repositioned.
You can make all the objects in a frame invisible or visible by setting the frame's visible attribute.
Another frame attribute is objects, which is a list of currently visible objects contained in the frame (the list does not include objects that are currently invisible, not lights, which are found in scene.lights). If you want to make all the objects in a frame be red, do the following (assume the frame is named f):
for obj in f.objects:
If you use this method to make all the objects invisible, the f.objects list will be empty. If you need a list containing all the objects, both visible and invisible, you need to maintain your own list of objects.
If ball is an object in a frame, ball.pos is the position local to the frame, not the actual position in "world space". There are two frame functions for translating between frame and world coordinates. Suppose the name of the frame is f, frame_pos is a position within that frame, and world_pos is the corresponding position in world coordinates:
world_pos = f.frame_to_world(frame_pos)
frame_pos = f.world_to_frame(world_pos)