pyvista.Light#

class Light(
position=None,
focal_point=None,
color=None,
light_type='scene light',
intensity=None,
positional=None,
cone_angle=None,
show_actor=False,
exponent=None,
shadow_attenuation=None,
attenuation_values=None,
)[source]#

Light class.

Parameters:
positionsequence[float], optional

The position of the light. The interpretation of the position depends on the type of the light and whether the light has a transformation matrix. See also the position property.

focal_pointsequence[float], optional

The focal point of the light. The interpretation of the focal point depends on the type of the light and whether the light has a transformation matrix. See also the focal_point property.

colorColorLike, optional

The color of the light. The ambient, diffuse and specular colors will all be set to this color on creation.

light_typestr | int, default: ‘scene light’

The type of the light. If a string, one of 'headlight', 'camera light' or 'scene light'. If an int, one of 1, 2 or 3, respectively. The class constants Light.HEADLIGHT, Light.CAMERA_LIGHT and Light.SCENE_LIGHT are also available, respectively.

  • A headlight is attached to the camera, looking at its focal point along the axis of the camera.

  • A camera light also moves with the camera, but it can occupy a general position with respect to it.

  • A scene light is stationary with respect to the scene, as it does not follow the camera. This is the default.

intensityfloat, optional

The brightness of the light (between 0 and 1).

positionalbool, optional

Set if the light is positional.

The default is a directional light, i.e. an infinitely distant point source. A positional light with a cone angle of at least 90 degrees acts like a spherical point source. A positional light with a cone angle that is less than 90 degrees is known as a spotlight.

cone_anglefloat, optional

Cone angle of a positional light in degrees.

show_actorbool, default: False

Show an actor for a spotlight that depicts the geometry of the beam.

exponentfloat, optional

The exponent of the cosine used for spotlights. See also the exponent property.

shadow_attenuationfloat, optional

The value of shadow attenuation.

By default a light will be completely blocked when in shadow. By setting this value to less than 1.0 you can control how much light is attenuated when in shadow. Note that changing the attenuation_values of the light can make it pass through objects even if its shadow attenuation is 1.

attenuation_valuessequence, optional

Quadratic attenuation constants.

The values are a 3-length sequence which specifies the constant, linear and quadratic constants in this order. These parameters only have an effect for positional lights.

Examples

Create a light at (10, 10, 10) and set its diffuse color to red.

>>> import pyvista as pv
>>> light = pv.Light(position=(10, 10, 10))
>>> light.diffuse_color = 1.0, 0.0, 0.0

Create a positional light at (0, 0, 3) with a cone angle of 30, exponent of 20, and a visible actor.

>>> light = pv.Light(
...     position=(0, 0, 3),
...     show_actor=True,
...     positional=True,
...     cone_angle=30,
...     exponent=20,
... )

Methods

Light.add_renderer(renderer)

Attach a renderer to this light.

Light.copy([deep])

Return a shallow or a deep copy of the light.

Light.from_vtk(vtk_light)

Create a light from a vtk.vtkLight, resulting in a copy.

Light.hide_actor()

Hide the actor for a positional light that depicts the geometry of the beam.

Light.set_camera_light()

Set the light to be a camera light.

Light.set_direction_angle(elev, azim)

Set the position and focal point of a directional light.

Light.set_headlight()

Set the light to be a headlight.

Light.set_scene_light()

Set the light to be a scene light.

Light.show_actor()

Show an actor for a spotlight that depicts the geometry of the beam.

Light.switch_off()

Switch off the light.

Light.switch_on()

Switch on the light.

Attributes

Light.ambient_color

Return or set the ambient color of the light.

Light.attenuation_values

Return or set the quadratic attenuation constants.

Light.cone_angle

Return or set the cone angle of a positional light.

Light.diffuse_color

Return or set the diffuse color of the light.

Light.exponent

Return or set the exponent of the cosine used for spotlights.

Light.focal_point

Return the focal point of the light.

Light.intensity

Return or set the brightness of the light (between 0 and 1).

Light.is_camera_light

Return whether the light is a camera light.

Light.is_headlight

Return whether the light is a headlight.

Light.is_scene_light

Return whether the light is a scene light.

Light.light_type

Return or set the light type.

Light.on

Return or set whether the light is on.

Light.position

Return the position of the light.

Light.positional

Return or set whether the light is positional.

Light.renderers

Return the renderers associated with this light.

Light.shadow_attenuation

Return or set the value of shadow attenuation.

Light.specular_color

Return or set the specular color of the light.

Light.transform_matrix

Return (if any) or set the transformation matrix of the light.

Light.world_focal_point

Return the world space focal point of the light.

Light.world_position

Return the world space position of the light.