# panda3d.core.Spotlight¶

class Spotlight

Bases: LightLensNode

A light originating from a single point in space, and shining in a particular direction, with a cone-shaped falloff.

The Spotlight frustum is defined using a Lens, so it can have any of the properties that a camera lens can have.

Note that the class is named Spotlight instead of SpotLight, because “spotlight” is a single English word, instead of two words.

Inheritance diagram

__init__(name: str) → None
setExponent(exponent: float) → None

Sets the exponent that controls the amount of light falloff from the center of the spotlight. The light is attenuated by the cosine of the angle between the direction of the light and the direction of the point being lighted, raised to the power of this exponent. Thus, higher exponents result in a more focused light source, regardless of the field-of-view of the lens.

setSpecularColor(color: LColor) → None

Sets the color of specular highlights generated by the light.

clearSpecularColor() → None

Clears a custom specular color setting, meaning that the specular color will now come from the color.

setAttenuation(attenuation: LVecBase3) → None

Sets the terms of the attenuation equation for the light. These are, in order, the constant, linear, and quadratic terms based on the distance from the point to the vertex.

getMaxDistance() → float

Returns the maximum distance at which the light has any effect, as previously specified by set_max_distance.

setMaxDistance(max_distance: float) → None

Sets the radius of the light’s sphere of influence. Beyond this distance, the light may be attenuated to zero, if this is supported by the shader.

static makeSpot(pixel_width: int, full_radius: float, fg: LColor, bg: LColor) → Texture

Returns a newly-generated Texture that renders a circular spot image as might be cast from the spotlight. This may be projected onto target geometry (for instance, via NodePath.projectTexture()) instead of actually enabling the light itself, as a cheesy way to make a high- resolution spot appear on the geometry.

pixel_width specifies the height and width of the new texture in pixels, full_radius is a value in the range 0..1 that indicates the relative size of the fully bright center spot, and fg and bg are the colors of the interior and exterior of the spot, respectively.

Return type

Texture

static getClassType() → TypeHandle
Return type

TypeHandle

property exponent
Getter

Returns the exponent that controls the amount of light falloff from the center of the spotlight. See setExponent().

Setter

Sets the exponent that controls the amount of light falloff from the center of the spotlight. The light is attenuated by the cosine of the angle between the direction of the light and the direction of the point being lighted, raised to the power of this exponent. Thus, higher exponents result in a more focused light source, regardless of the field-of-view of the lens.

Return type

float

property specular_color
Getter

Returns the color of specular highlights generated by the light. This is usually the same as get_color().

Setter

Sets the color of specular highlights generated by the light.

Return type

LColor

property attenuation
Getter

Returns the terms of the attenuation equation for the light. These are, in order, the constant, linear, and quadratic terms based on the distance from the point to the vertex.

Setter

Sets the terms of the attenuation equation for the light. These are, in order, the constant, linear, and quadratic terms based on the distance from the point to the vertex.

Return type

LVecBase3

property max_distance
Getter

Returns the maximum distance at which the light has any effect, as previously specified by set_max_distance.

Setter

Sets the radius of the light’s sphere of influence. Beyond this distance, the light may be attenuated to zero, if this is supported by the shader.

Return type

float