add spot constructor

This commit is contained in:
Nick Fisher
2024-09-19 13:44:17 +08:00
parent 3f9db33340
commit 257c4b29f2

View File

@@ -38,13 +38,14 @@ class DirectLight {
this.sunHaloSize = 10.0, this.sunHaloSize = 10.0,
this.sunHaloFallof = 80.0, this.sunHaloFallof = 80.0,
}); });
DirectLight.point({
DirectLight.point({
double color = 6500, double color = 6500,
double intensity = 100000, double intensity = 100000,
bool castShadows = false, bool castShadows = false,
Vector3? position, Vector3? position,
double falloffRadius = 1.0, double falloffRadius = 1.0,
}) : this( }) : this(
type: LightType.POINT, type: LightType.POINT,
color: color, color: color,
intensity: intensity, intensity: intensity,
@@ -52,9 +53,9 @@ DirectLight.point({
position: position ?? Vector3(0, 1, 0), position: position ?? Vector3(0, 1, 0),
direction: Vector3.zero(), direction: Vector3.zero(),
falloffRadius: falloffRadius, falloffRadius: falloffRadius,
); );
DirectLight.sun({ DirectLight.sun({
double color = 6500, double color = 6500,
double intensity = 100000, double intensity = 100000,
bool castShadows = true, bool castShadows = true,
@@ -62,7 +63,7 @@ DirectLight.sun({
double sunAngularRadius = 0.545, double sunAngularRadius = 0.545,
double sunHaloSize = 10.0, double sunHaloSize = 10.0,
double sunHaloFalloff = 80.0, double sunHaloFalloff = 80.0,
}) : this( }) : this(
type: LightType.DIRECTIONAL, type: LightType.DIRECTIONAL,
color: color, color: color,
intensity: intensity, intensity: intensity,
@@ -72,5 +73,26 @@ DirectLight.sun({
sunAngularRadius: sunAngularRadius, sunAngularRadius: sunAngularRadius,
sunHaloSize: sunHaloSize, sunHaloSize: sunHaloSize,
sunHaloFallof: sunHaloFalloff, sunHaloFallof: sunHaloFalloff,
); );
DirectLight.spot({
double color = 6500,
double intensity = 100000,
bool castShadows = true,
Vector3? position,
Vector3? direction,
double falloffRadius = 1.0,
double spotLightConeInner = pi / 8,
double spotLightConeOuter = pi / 4,
}) : this(
type: LightType.SPOT,
color: color,
intensity: intensity,
castShadows: castShadows,
position: position ?? Vector3(0, 1, 0),
direction: direction ?? Vector3(0, -1, 0),
falloffRadius: falloffRadius,
spotLightConeInner: spotLightConeInner,
spotLightConeOuter: spotLightConeOuter,
);
} }