Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8258983

Add SpotLight to the selection of 3D light types

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Draft
    • Priority: P3
    • Resolution: Unresolved
    • Fix Version/s: openjfx17
    • Component/s: javafx
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Java API

      Description

      Summary

      Add a SpotLight to the JavaFX 3D API.

      Problem

      JavaFX contains only an AmbientLight and a PointLight. A SpotLight is a common light that isn't provided by JavaFX currently.

      Solution

      Add a SpotLight implementation.

      Specification

      /**
       * A {@code PointLight} that radiates light in a cone in a specific direction. The direction of the {@code SpotLight} is
       * defined by the {@link #directionProperty() direction} property.
       * <p>
       * The light cone is defined by 3 factors: an {@link #innerAngleProperty() inner angle}, an {@link #outerAngleProperty()
       * outer angle}, and a {@link #falloffProperty() falloff} factor. For a point whose angle to the light is {@code a}, if
       * {@code a < innerAngle} then that point receives maximum illumination, if {@code a > outerAngle} then that point
       * receives no illumination, and if {@code innerAngle <= a <= outerAngle} then the illumination is determined by the
       * formula
       * <pre>I = pow((cos(a) - cos(outer)) / (cos(inner) - cos(outer)), falloff)</pre>
       * which represents a drop in illumination from the inner angle to the outer angle. {@code falloff} determines the
       * behavior of the drop. The expect values are {@code 0 <= innerAngle <= outerAngle <= 180} and {@code falloff >= 0};
       * values outside this range give unexpected results.
       * <p>
       * <img src="doc-files/spotlight.png" alt="Image of the Spotlight">
       *
       * @since 17
       * @see PhongMaterial
       */
      public class SpotLight extends PointLight
      
      /**
       * The direction the spotlight is facing. The vector need not be normalized.
       *
       * @defaultValue {@code Point3D(0, 0, 1)}
       */
      private ObjectProperty<Point3D> direction;
      
      /**
       * The angle of the spotlight's inner cone. Surfaces whose angle to the light's origin is less than this angle
       * receive the full light's intensity. At larger angles, the light intensity starts to drop. The expected values are
       * between 0 and {@code outerAngle}; values outside this range give unexpected results.
       *
       * @defaultValue 0
       */
      private DoubleProperty innerAngle;
      
      /**
       * The angle of the spotlight's outer cone. Surfaces whose angle to the light's origin is greater than this angle
       * receive no light. At smaller angles, the light intensity starts to increase. The expected values are between
       * {@code innerAngle} and 180; values outside this range give unexpected results.
       *
       * @defaultValue 30
       */
      private DoubleProperty outerAngle;
      
      /**
       * The intensity falloff factor of the spotlight's outer cone. Surfaces whose angle to the light's origin is greater
       * than the inner angle but less than the outer angle receive 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. Negative
       * values give unexpected results.
       *
       * @defaultValue 1
       */
      private DoubleProperty falloff;

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              nlisker Nir Lisker
              Reporter:
              nlisker Nir Lisker
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated: