Package javafx.scene

Class SpotLight

java.lang.Object
All Implemented Interfaces:
Styleable, EventTarget

public class SpotLight extends PointLight
A light source that radiates light in a cone in a specific direction away from itself. The direction is defined by the direction vector property.

In addition to the attenuation factors that control the light intensity over distance, a SpotLight has a light-cone attenuation factor, spot, that is determined by 3 properties:

  • innerAngle: the angle of the inner cone (see image below)
  • outerAngle: the angle of the outer cone (see image below)
  • falloff: the factor that controls the light's intensity drop inside the outer cone
The valid ranges for these properties are 0 <= innerAngle <= outerAngle <= 180 and falloff >= 0; values outside either of these ranges can produce unexpected results.

The angle of a point to the light is defined as the angle between its vector to the light's position and the direction of the light. For such an angle theta, if

  • theta < innerAngle then spot = 1
  • theta > outerAngle then spot = 0
  • innerAngle <= theta <= outerAngle then
    spot = pow((cos(theta) - cos(outer)) / (cos(inner) - cos(outer)), falloff)
    which represents a drop in intensity from the inner angle to the outer angle.
As a result, 0 <= spot <= 1. The overall intensity of the light is I = lambert * atten * spot.

SpotLights can represent point-like light sources with directionality. Flashlights and floodlights are common light sources that can be simulated with this light type.

Image of the Spotlight

Since:
17
See Also: