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,
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.- color
ColorLike
,optional
The color of the light. The ambient, diffuse and specular colors will all be set to this color on creation.
- light_type
str
|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 constantsLight.HEADLIGHT
,Light.CAMERA_LIGHT
andLight.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.
- intensity
float
,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_angle
float
,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.
- exponent
float
,optional
The exponent of the cosine used for spotlights. See also the
exponent
property.- shadow_attenuation
float
,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.
- positionsequence[
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.Hide the actor for a positional light that depicts the geometry of the beam.
Set the light to be a camera light.
Light.set_direction_angle
(elev, azim)Set the position and focal point of a directional light.
Set the light to be a headlight.
Set the light to be a scene light.
Show an actor for a spotlight that depicts the geometry of the beam.
Switch off the light.
Switch on the light.
Attributes
Return or set the ambient color of the light.
Return or set the quadratic attenuation constants.
Return or set the cone angle of a positional light.
Return or set the diffuse color of the light.
Return or set the exponent of the cosine used for spotlights.
Return the focal point of the light.
Return or set the brightness of the light (between 0 and 1).
Return whether the light is a camera light.
Return whether the light is a headlight.
Return whether the light is a scene light.
Return or set the light type.
Return or set whether the light is on.
Return the position of the light.
Return or set whether the light is positional.
Return the renderers associated with this light.
Return or set the value of shadow attenuation.
Return or set the specular color of the light.
Return (if any) or set the transformation matrix of the light.
Return the world space focal point of the light.
Return the world space position of the light.