pygfx.objects.SpotLight
- class pygfx.objects.SpotLight(color='#ffffff', intensity=3, *, cast_shadow=False, distance=0, decay=0, angle=1.0471975511965976, penumbra=0, **kwargs)
Bases:
Light
Directional point light source.
A light that gets emitted from a single point in one direction, along a cone that increases in size the further from the light it gets.
- Parameters:
color (Color) – The color of the light emitted.
intensity (float) – The light intensity. A value of
3
corresponds to a well lit scene.cast_shadow (bool) – If True, the light can cast shadows. Otherwise it doesn’t.
distance (float) – The maximum distance at which objects are considered illuminated by the light. Limiting this may increase performance in large scenes. A value of
0
means that all objects are considered.decay (float) – The rate at which the light dims as it travels. A value of
0
means no decay. A decay of2
is physically correct.angle (float) – The central angle (in rad) of the light’s cone.
penumbra (float) – Percent of the spotlight cone that is attenuated due to penumbra. Takes values between zero and 1. Default is zero.
Notes
If this light is attached to a camera it’s direction will follow the camera view direction.
There are two booleans that control the behavior of shadow: cast_shadow on a Light, and receive_shadow on the illuminated object. Shadows will only be displayed if both are set to True.
When setting
decay
to a non-zero value you likely probably have to increase intensity (a lot) as light decays following an inverse-square profile.- property power
The light’s power. I.e. the luminous power of the light measured in lumens (lm). Changing the power will also change the light’s intensity.
- property distance
When distance is zero, light will attenuate according to inverse-square law to infinite distance. When distance is non-zero, light will attenuate the same way until near the distance cutoff, where it will then attenuate quickly and smoothly to 0. Inherently, cutoffs are not physically correct.
- property angle
The maximum extent of the spotlight, in radians, from its direction. Should be no more than Math.PI/2.
- property penumbra
Percent of the spotlight cone that is attenuated due to penumbra. Takes values between zero and 1.
- property decay
The amount the light dims along the distance of the light. A decay of 2 leads to physically realistic light falloff. Default is 0, which means the light does not decay.