SpotLight (JavaFX 19)
Description: declaration: module: javafx.graphics, package: javafx.scene, class: SpotLight

Module javafx.graphics
Package javafx.scene

# Class SpotLight

java.lang.Object
javafx.scene.Node
javafx.scene.LightBase
javafx.scene.PointLight
javafx.scene.SpotLight

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`.

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

Since:
  17
See Also:
  - `PhongMaterial`

- ## Property Summary

  Properties
  Type
  Property
  Description
  `final ObjectProperty<Point3D>`
  `direction`
  The direction vector of the spotlight.
  `final DoubleProperty`
  `falloff`
  The intensity falloff factor of the spotlight's outer cone.
  `final DoubleProperty`
  `innerAngle`
  The angle of the spotlight's inner cone, in degrees.
  `final DoubleProperty`
  `outerAngle`
  The angle of the spotlight's outer cone, in degrees (as shown in the class doc image).

  ### Properties declared in class javafx.scene.PointLight

  `constantAttenuation, linearAttenuation, maxRange, quadraticAttenuation`

  ### Properties declared in class javafx.scene.LightBase

  `color, lightOn`

  ### Properties declared in class javafx.scene.Node

  `accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible`

- ## Field Summary

  ### Fields declared in class javafx.scene.Node

  `BASELINE_OFFSET_SAME_AS_HEIGHT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SpotLight()`
  Creates a new instance of `SpotLight` class with a default `Color.WHITE` light source.
  `SpotLight(Color color)`
  Creates a new instance of `SpotLight` class using the specified color.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final ObjectProperty<Point3D>`
  `directionProperty()`
  The direction vector of the spotlight.
  `final DoubleProperty`
  `falloffProperty()`
  The intensity falloff factor of the spotlight's outer cone.
  `final Point3D`
  `getDirection()`
  Gets the value of the property direction.
  `final double`
  `getFalloff()`
  Gets the value of the property falloff.
  `final double`
  `getInnerAngle()`
  Gets the value of the property innerAngle.
  `final double`
  `getOuterAngle()`
  Gets the value of the property outerAngle.
  `final DoubleProperty`
  `innerAngleProperty()`
  The angle of the spotlight's inner cone, in degrees.
  `final DoubleProperty`
  `outerAngleProperty()`
  The angle of the spotlight's outer cone, in degrees (as shown in the class doc image).
  `final void`
  `setDirection(Point3D value)`
  Sets the value of the property direction.
  `final void`
  `setFalloff(double value)`
  Sets the value of the property falloff.
  `final void`
  `setInnerAngle(double value)`
  Sets the value of the property innerAngle.
  `final void`
  `setOuterAngle(double value)`
  Sets the value of the property outerAngle.

  ### Methods declared in class javafx.scene.PointLight

  `constantAttenuationProperty, getConstantAttenuation, getLinearAttenuation, getMaxRange, getQuadraticAttenuation, linearAttenuationProperty, maxRangeProperty, quadraticAttenuationProperty, setConstantAttenuation, setLinearAttenuation, setMaxRange, setQuadraticAttenuation`

  ### Methods declared in class javafx.scene.LightBase

  `colorProperty, getColor, getExclusionScope, getScope, isLightOn, lightOnProperty, setColor, setLightOn`

  ### Methods declared in class javafx.scene.Node

  `accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBaselineOffset, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClassCssMetaData, getClip, getContentBias, getCssMetaData, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isResizable, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookup, lookupAll, managedProperty, maxHeight, maxWidth, minHeight, minWidth, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, prefHeight, prefWidth, pressedProperty, pseudoClassStateChanged, queryAccessibleAttribute, relocate, removeEventFilter, removeEventHandler, requestFocus, resize, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty`

  ### Methods declared in class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods declared in interface javafx.css.Styleable

  `getStyleableNode`

- ## Property Details

  - ### direction

    public final ObjectProperty<Point3D> directionProperty
    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)`
    See Also:
      - `getDirection()`
      - `setDirection(Point3D)`

  - ### innerAngle

    public final DoubleProperty innerAngleProperty
    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
    See Also:
      - `getInnerAngle()`
      - `setInnerAngle(double)`

  - ### outerAngle

    public final DoubleProperty outerAngleProperty
    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
    See Also:
      - `getOuterAngle()`
      - `setOuterAngle(double)`

  - ### falloff

    public final DoubleProperty falloffProperty
    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
    See Also:
      - `getFalloff()`
      - `setFalloff(double)`

- ## Constructor Details

  - ### SpotLight

    public SpotLight()
    Creates a new instance of `SpotLight` class with a default `Color.WHITE` light source.

  - ### SpotLight

    public SpotLight(Color color)
    Creates a new instance of `SpotLight` class using the specified color.
    Parameters:
      `color` - the color of the light source

- ## Method Details

  - ### setDirection

    public final void setDirection(Point3D value)
    Sets the value of the property direction.
    Property description:
      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)`

  - ### getDirection

    public final Point3D getDirection()
    Gets the value of the property direction.
    Property description:
      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)`

  - ### directionProperty

    public final ObjectProperty<Point3D> directionProperty()
    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)`
    See Also:
      - `getDirection()`
      - `setDirection(Point3D)`

  - ### setInnerAngle

    public final void setInnerAngle(double value)
    Sets the value of the property innerAngle.
    Property description:
      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

  - ### getInnerAngle

    public final double getInnerAngle()
    Gets the value of the property innerAngle.
    Property description:
      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

  - ### innerAngleProperty

    public final DoubleProperty innerAngleProperty()
    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
    See Also:
      - `getInnerAngle()`
      - `setInnerAngle(double)`

  - ### setOuterAngle

    public final void setOuterAngle(double value)
    Sets the value of the property outerAngle.
    Property description:
      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

  - ### getOuterAngle

    public final double getOuterAngle()
    Gets the value of the property outerAngle.
    Property description:
      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

  - ### outerAngleProperty

    public final DoubleProperty outerAngleProperty()
    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
    See Also:
      - `getOuterAngle()`
      - `setOuterAngle(double)`

  - ### setFalloff

    public final void setFalloff(double value)
    Sets the value of the property falloff.
    Property description:
      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

  - ### getFalloff

    public final double getFalloff()
    Gets the value of the property falloff.
    Property description:
      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

  - ### falloffProperty

    public final DoubleProperty falloffProperty()
    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
    See Also:
      - `getFalloff()`
      - `setFalloff(double)`