APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene

public Class SpotLight

extends PointLight
Class Inheritance
Imports
com.sun.javafx.scene.DirtyBits, .NodeHelper, .SpotLightHelper, com.sun.javafx.sg.prism.NGNode, .NGSpotLight, javafx.beans.property.DoubleProperty, .ObjectProperty, .SimpleObjectProperty, javafx.geometry.Point3D, javafx.scene.paint.Color, .PhongMaterial

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:

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

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
PhongMaterial

Field Summary

Modifier and TypeField and Description
private static final Point3D
private static final double
private static final double
private static final double
private ObjectProperty<Point3D>
direction

The direction vector of the spotlight.

private DoubleProperty
falloff

The intensity falloff factor of the spotlight's outer cone.

private DoubleProperty
innerAngle

The angle of the spotlight's inner cone, in degrees.

private DoubleProperty
outerAngle

The angle of the spotlight's outer cone, in degrees (as shown in the class doc image).

Constructor Summary

AccessConstructor and Description
public
SpotLight()

Creates a new instance of SpotLight class with a default Color.WHITE light source.

public
SpotLight(Color
the color of the light source
color
)

Creates a new instance of SpotLight class using the specified color.

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<Point3D>
private NGNode
private void
public final DoubleProperty
public final Point3D
public final double
public final double
public final double
public final DoubleProperty
public final DoubleProperty
public final void
public final void
setFalloff(double value)

public final void
setInnerAngle(double value)

public final void
setOuterAngle(double value)

Inherited from javafx.scene.PointLight:
constantAttenuationPropertygetConstantAttenuationgetLinearAttenuationgetMaxRangegetQuadraticAttenuationlinearAttenuationPropertymaxRangePropertyquadraticAttenuationPropertysetConstantAttenuationsetLinearAttenuationsetMaxRangesetQuadraticAttenuation

Field Detail

DEFAULT_DIRECTIONback to summary
private static final Point3D DEFAULT_DIRECTION
DEFAULT_FALLOFFback to summary
private static final double DEFAULT_FALLOFF
DEFAULT_INNER_ANGLEback to summary
private static final double DEFAULT_INNER_ANGLE
DEFAULT_OUTER_ANGLEback to summary
private static final double DEFAULT_OUTER_ANGLE
directionback to summary
private ObjectProperty<Point3D> direction

The direction vector of the spotlight. It can be rotated by setting a rotation transform on the SpotLight. The vector need not be normalized.

Default Value
Point3D(0, 0, 1)
falloffback to summary
private DoubleProperty falloff

The intensity falloff factor of the spotlight's outer cone. A point whose angle to the light is greater than the inner angle but less than the outer angle receives partial intensity governed by this factor. The larger the falloff, the sharper the drop in intensity from the inner cone. A falloff factor of 1 gives a linear drop in intensity, values greater than 1 give a convex drop, and values smaller than 1 give a concave drop. See the class doc for more information.

The valid range is 0 <= falloff; values outside of this range can produce unexpected results.

Default Value
1
innerAngleback to summary
private DoubleProperty innerAngle

The angle of the spotlight's inner cone, in degrees. A point whose angle to the light is less than this angle is not attenuated by the spotlight factor (spot = 1). At larger angles, the light intensity starts to drop. See the class doc for more information.

The valid range is 0 <= innerAngle <= outerAngle; values outside of this range can produce unexpected results.

Default Value
0
outerAngleback to summary
private DoubleProperty outerAngle

The angle of the spotlight's outer cone, in degrees (as shown in the class doc image). A point whose angle to the light is greater than this angle receives no light (spot = 0). A point whose angle to the light is less than the outer angle but greater than the inner angle receives partial intensity governed by the falloff factor. See the class doc for more information.

The valid range is innerAngle <= outerAngle <= 180; values outside of this range can produce unexpected results.

Default Value
30

Constructor Detail

SpotLightback to summary
public SpotLight()

Creates a new instance of SpotLight class with a default Color.WHITE light source.

SpotLightback to summary
public SpotLight(Color color)

Creates a new instance of SpotLight class using the specified color.

Parameters
color:Color

the color of the light source

Method Detail

directionPropertyback to summary
public final ObjectProperty<Point3D> directionProperty()
doCreatePeerback to summary
private NGNode doCreatePeer()

Hides javafx.scene.PointLight.doCreatePeer.

doUpdatePeerback to summary
private void doUpdatePeer()

Hides javafx.scene.PointLight.doUpdatePeer.

falloffPropertyback to summary
public final DoubleProperty falloffProperty()
getDirectionback to summary
public final Point3D getDirection()
getFalloffback to summary
public final double getFalloff()
getInnerAngleback to summary
public final double getInnerAngle()
getOuterAngleback to summary
public final double getOuterAngle()
innerAnglePropertyback to summary
public final DoubleProperty innerAngleProperty()
outerAnglePropertyback to summary
public final DoubleProperty outerAngleProperty()
setDirectionback to summary
public final void setDirection(Point3D value)
setFalloffback to summary
public final void setFalloff(double value)
setInnerAngleback to summary
public final void setInnerAngle(double value)
setOuterAngleback to summary
public final void setOuterAngle(double value)