Home

   Overview of Python & VPython

  "Welcome to VPython" tutorial

  Introductory Videos

  Pictures of 3D objects

  

  

  

  VPython 7 web site
  VPython license

Lighting
material etc

You can light a scene with distant lights (which act like point-like lamps far from the scene) and/or local lights (point-like lamps near the scene, like the yellow light shown above). For a distant light you specify its direction from the origin. For a local light you specify its location in the scene.

There is a list of all distant and local light objects, scene.lights. By default, scene.lights is this list:

[distant_light(direction=vector( 0.22,  0.44,  0.88),       color=color.gray(0.8)),
 distant_light(direction=vector(-0.88, -0.22, -0.44),       color=color.gray(0.3))]

You can get rid of these default lights by setting the list to empty with scene.lights = [].

You can turn a light on or off by setting visible to True or False.

In addition to these default distant lights, there is default ambient lighting in the form of scene.ambient=color.gray(0.2). The color of light objects and the amount of scene.ambient must be specified with some care, because if the total lighting intensity exceeds 1 anywhere in the scene the results are unpredictable.

The following statement creates a local yellow light whose position is at (x,y,z), and if you continually update lamp.pos, the light will move. You may wish to place a sphere or box with emissive=True at the same location so that the lamp looks like a glowing lamp.

lamp = local_light(pos=vector(x,y,z),
                      color=color.yellow)

A distant red light located in the direction (x,y,z) from the origin is created like this:

distant_light(direction=vector(x,y,z), color=color.red)