SpotLightComponent

@MainThread
class SpotLightComponent : Component

A Component that emits conical light along the entity's forward (-Z) axis.

This component creates a directional light source with controllable spread (like a flashlight or stage spotlight), supporting advanced features including light color and intensity, shadow casting and clipping plane configuration.

Key properties:

  • Direction: Inherited from entity's transform (uses -Z axis).

  • Color & Intensity: Fully customizable light appearance with color and intensity.

  • Angular Falloff: Controlled via innerAngle (full intensity) and outerAngle (falloff edge).

  • Distance Attenuation: Light intensity diminishes over attenuationRadius.

  • Shadow Casting: Configurable through castsShadowEnabled and related shadow properties.

To receive lighting effects, the Entity must use a Material that supports lighting. For example, PhysicallyBasedMaterial respond to lighting, while UnlitMaterial does not.

Angular behavior:

Code sample:

val spotlightEntity = Entity().apply{
components.set(SpotLightComponent(
color = Color4(1f, 0.95f, 0.9f, 1f),
intensity = 10000f, // Measured in lumens
attenuationRadius = 10f, // Measured in meters
innerAngle = 15f, // Measured in degrees
outerAngle = 30f, // Measured in degrees
castsShadowEnabled = true,
))
components[SpotLightComponent::class.java]!!.apply {
shadowFaceCullingMode = ShadowFaceCullingMode.BACK
shadowClippingPlaneType = ShadowClippingPlaneType.Auto
}
}

Performance Notes:

  • Shadow casting impacts rendering performance.

  • Wider angles (outerAngle) increase shaded area complexity.

  • Multiple active spotlights require careful optimization.

Related components:

Constructors

Link copied to clipboard
constructor(color: Color4, intensity: Float, attenuationRadius: Float, innerAngle: Float, outerAngle: Float)
constructor(color: Color4, intensity: Float, attenuationRadius: Float, innerAngle: Float, outerAngle: Float, castsShadowEnabled: Boolean)

Properties

Link copied to clipboard

The radius of the light's attenuation.

Link copied to clipboard
var castsShadowEnabled: Boolean

Weather the light casts shadows.

Link copied to clipboard

The color of the light.

Link copied to clipboard
var innerAngle: Float

The inner cone angle of the spotlight, measured in degrees.

Link copied to clipboard
var intensity: Float

The intensity of the light, measured in lumen.

Link copied to clipboard
var outerAngle: Float

The outer angle of the spotlight, measured in degrees.

Link copied to clipboard

The shadow clipping plane type of the light.

Link copied to clipboard

The culling behavior for shadow rendering.

Functions

Link copied to clipboard
open override fun clone(): Component

Creates and returns a copy of this Component instance.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String