Skip to content

Commit 9f2e4ff

Browse files
committed
feat: add constructor to DirectionalLight for color and direction
Added a new constructor to the DirectionalLight class that allows specifying the light's color and direction while using a default intensity of 1.0. This provides additional flexibility for initializing directional lights with fewer parameters.
1 parent 4e7a3d4 commit 9f2e4ff

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/main/java/engine/scene/light/DirectionalLight.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,25 @@ public DirectionalLight() {
4545
this(Color.WHITE, new Vector3f(0, 1, 0), 1.0f);
4646
}
4747

48+
/**
49+
* Creates a new DirectionalLight instance with the specified color and direction.
50+
*
51+
* <p>This constructor initializes the light with the given color and direction, and a default
52+
* intensity of 1.0. The provided direction vector is normalized during initialization to ensure
53+
* consistent light behavior.
54+
*
55+
* @param color The color of the light emitted by the directional light source. Represents the RGB
56+
* values of the light's color. This parameter cannot be null.
57+
* @param direction The direction of the light source. This vector determines the direction in
58+
* which the light rays travel. The provided vector is automatically normalized during
59+
* construction, ensuring the direction's magnitude is always 1. This parameter cannot be
60+
* null.
61+
* @throws IllegalArgumentException if the direction or color is null.
62+
*/
63+
public DirectionalLight(Color color, Vector3f direction) {
64+
this(color, direction, 1.0f);
65+
}
66+
4867
/**
4968
* Creates a new DirectionalLight instance.
5069
*

0 commit comments

Comments
 (0)