API reference
API reference
Select your platform
No SDKs available
No versions available

ProjectionLight Class

Extends ComponentBase
Modifiers: final
Projects light whose color is derived from the averaged color of a Panel's rendered content. When attached to an entity that also has a Panel component, the system reads the panel texture's mipmap chain to extract the dominant color, smooths it over frames using exponential decay, and drives a dynamic SceneLight.
The light is positioned at the entity's Transform. The panel to sample from defaults to the same entity, but can reference a different entity via sourcePanel.
Supports temporal jitter sampling: each frame samples at a different offset within a low mip level to improve temporal color quality.
Example:
// Attach to a panel entity for automatic ambient light
Entity.create(listOf(
    Panel(...),
    Transform(Pose(Vector3(0f, 1f, -2f))),
    ProjectionLight(
        intensity = 1.5f,
        range = 5.0f,
        smoothingSpeed = 0.15f,
    )
))

Signature

class ProjectionLight constructor(sourcePanel: Entity = Entity.nullEntity(), lightType: LightType = LightType.POINT, intensity: Float = 1.0f, range: Float = 5.0f, smoothingSpeed: Float = 0.15f, jitterEnabled: Boolean = true, sampleMipLevel: Int = -1, enabled: Boolean = true, useGpuSampling: Boolean = false) : ComponentBase

Constructors

ProjectionLight ( sourcePanel , lightType , intensity , range , smoothingSpeed , jitterEnabled , sampleMipLevel , enabled , useGpuSampling )
Signature
constructor(sourcePanel: Entity = Entity.nullEntity(), lightType: LightType = LightType.POINT, intensity: Float = 1.0f, range: Float = 5.0f, smoothingSpeed: Float = 0.15f, jitterEnabled: Boolean = true, sampleMipLevel: Int = -1, enabled: Boolean = true, useGpuSampling: Boolean = false)
Parameters
sourcePanel: Entity  Entity with the Panel to sample color from (defaults to self)
lightType: LightType  Type of light to create (POINT or SPOT)
intensity: Float  Light intensity multiplier
range: Float  Attenuation range in world units
smoothingSpeed: Float  Exponential decay speed (0.0=frozen, 1.0=instant). Default 0.15
jitterEnabled: Boolean  Whether to jitter sample position across frames
sampleMipLevel: Int  Which mip level to sample from (-1 = auto-select highest)
enabled: Boolean  Whether the projection light is active
useGpuSampling: Boolean

Properties

cachable : BuildConfig.COMPONENTCACHE_LEVEL >= 2
[Get][Set]
Signature
open override var cachable: BuildConfig.COMPONENTCACHE_LEVEL >= 2
enabled : Boolean
[Get][Set]
Whether the projection light is active
Signature
var enabled: Boolean
entID : Long
[Get][Set]
Signature
var entID: Long
intensity : Float
[Get][Set]
Light intensity multiplier
Signature
var intensity: Float
jitterEnabled : Boolean
[Get][Set]
Whether to jitter sample position across frames
Signature
var jitterEnabled: Boolean
lightType : LightType
[Get][Set]
Type of light to create
Signature
var lightType: LightType
range : Float
[Get][Set]
Attenuation range in world units
Signature
var range: Float
recycled : Boolean
[Get][Set]
Signature
var recycled: Boolean
sampleMipLevel : Int
[Get][Set]
Mip level to sample (-1 = auto highest)
Signature
var sampleMipLevel: Int
smoothingSpeed : Float
[Get][Set]
Exponential decay speed for color smoothing
Signature
var smoothingSpeed: Float
sourcePanel : Entity
[Get][Set]
Entity with Panel to sample. Defaults to self (Entity.nullEntity())
Signature
var sourcePanel: Entity
timeStamp : Long
[Get][Set]
Signature
var timeStamp: Long
useGpuSampling : Boolean
[Get][Set]
When true, passes the panel texture directly to the lighting shader for GPU-side color extraction via mipmap downsampling, eliminating CPU readback
Signature
var useGpuSampling: Boolean

Methods

companion ()
Gets the companion object for this component.
The companion object provides metadata about the component.
Signature
open override fun companion(): ComponentCompanion
Returns
ComponentCompanion  The component's companion object
Throws
RuntimeException  If the companion is not implemented
getComponentDataAttributeType ( key )
Gets the attribute type for the specified key.
Signature
fun getComponentDataAttributeType(key: Int): AttributePrimitive?
Parameters
key: Int  The integer key to look up
Returns
AttributePrimitive?  The attribute primitive type, or null if the key doesn't exist
getComponentDataAttributeType ( keyString )
Gets the attribute type for the specified string key.
Signature
fun getComponentDataAttributeType(keyString: String): AttributePrimitive?
Parameters
keyString: String  The string key to look up
Returns
AttributePrimitive?  The attribute primitive type
Throws
IllegalArgumentException  If the key doesn't exist
getComponentDataKey ( key )
Gets the integer key associated with the specified string key.
Signature
fun getComponentDataKey(key: String): Int?
Parameters
key: String  The string key to look up
Returns
Int?  The integer key, or null if the string key doesn't exist
getComponentDataValue ( key )
Gets the value for the specified key.
Signature
fun getComponentDataValue(key: Int): Any?
Parameters
key: Int  The integer key to look up
Returns
Any?  The value associated with the key, or null if the key doesn't exist
getComponentDataValue ( keyString )
Gets the value for the specified string key.
Signature
fun getComponentDataValue(keyString: String): Any?
Parameters
keyString: String  The string key to look up
Returns
Any?  The value associated with the key, or null if the key doesn't exist
Throws
IllegalArgumentException  If the key doesn't exist
getEnumClass ( key )
Gets the enum class associated with the specified string key.
Signature
fun getEnumClass(key: String): Class<out Enum<*>>?
Parameters
key: String  The string key to look up
Returns
Class?  The enum class, or null if the key doesn't exist or is not an enum
hasComponentData ( key )
Checks if this component has data for the specified key.
Signature
fun hasComponentData(key: Int): Boolean
Parameters
key: Int  The integer key to check
Returns
Boolean  True if the component has data for the key, false otherwise
hasComponentData ( keyString )
Checks if this component has data for the specified string key.
Signature
fun hasComponentData(keyString: String): Boolean
Parameters
keyString: String  The string key to check
Returns
Boolean  True if the component has data for the key, false otherwise
read ( e , cachable )
Reads component data from the specified entity.
Signature
fun read(e: Entity, cachable: Boolean)
Parameters
e: Entity  The entity to read data from
cachable: Boolean  Whether the component's data should be cached
recycle ()
Recycles this component by returning it to its pool.
If the component has a pool assigned, it will be returned to that pool for reuse.
Signature
fun recycle()
reset ()
Resets the component to its default state.
This method is called when a component is recycled to clear any state. Subclasses should override this method to reset their specific state.
Signature
open fun reset()
setComponentDataValue ( key , value )
Sets the value for the specified key.
Signature
fun setComponentDataValue(key: Int, value: Any): Boolean
Parameters
key: Int  The integer key to set
value: Any  The value to set
Returns
Boolean  True if the value was set successfully, false otherwise
setComponentDataValue ( keyString , value )
Sets the value for the specified string key.
Signature
fun setComponentDataValue(keyString: String, value: Any): Boolean
Parameters
keyString: String  The string key to set
value: Any  The value to set
Returns
Boolean  True if the key exists and the value was set, false otherwise
setPool ( pool , entID )
Sets the component pool and entity ID for this component.
This is used for component recycling to track which pool the component belongs to and which entity it was associated with.
Signature
fun setPool(pool: ComponentPool<*>, entID: Long)
Parameters
pool: ComponentPool  The component pool this component belongs to
entID: Long  The ID of the entity this component is associated with
toString ()
Signature
open override fun toString(): String
Returns
String
typeID ()
Returns the unique type ID of this component.
Each component type must have a unique ID for identification in the entity-component system.
Signature
open override fun typeID(): Int
Returns
Int  The unique type ID for this component
write ( e )
Writes this component's data to the specified entity.
Signature
fun write(e: Entity)
Parameters
e: Entity  The entity to write this component's data to

Companion Object

Properties

attributeKeys_ : IntArray
[Get]
Signature
val attributeKeys_: IntArray
attributeNames_ : Array
[Get]
Signature
val attributeNames_: Array<String>
attributeTypeCounts_ : IntArray
[Get]
Signature
val attributeTypeCounts_: IntArray
attributeTypes_ : IntArray
[Get]
Signature
val attributeTypes_: IntArray
attrMetaData_ : Map
[Get]
Signature
val attrMetaData_: Map
createDefaultInstance : Function0
[Get]
Signature
open override val createDefaultInstance: () -> ProjectionLight
enabledData : BooleanAttributeData
[Get]
Signature
val enabledData: BooleanAttributeData
enabledId :
[Get]
Signature
val enabledId: 
enumClassesMap_ : Map
[Get]
Signature
val enumClassesMap_: Map<Int, Class<out Enum<*>>>
id :
[Get]
Signature
open override val id: 
intensityData : FloatAttributeData
[Get]
Signature
val intensityData: FloatAttributeData
intensityId :
[Get]
Signature
val intensityId: 
jitterEnabledData : BooleanAttributeData
[Get]
Signature
val jitterEnabledData: BooleanAttributeData
jitterEnabledId :
[Get]
Signature
val jitterEnabledId: 
keyStringToKeyIntMap_ : Map
[Get]
Signature
val keyStringToKeyIntMap_: Map<String, Int>
lightTypeData : EnumAttributeData
[Get]
Signature
val lightTypeData: EnumAttributeData
lightTypeId :
[Get]
Signature
val lightTypeId: 
rangeData : FloatAttributeData
[Get]
Signature
val rangeData: FloatAttributeData
rangeId :
[Get]
Signature
val rangeId: 
sampleMipLevelData : IntAttributeData
[Get]
Signature
val sampleMipLevelData: IntAttributeData
sampleMipLevelId :
[Get]
Signature
val sampleMipLevelId: 
smoothingSpeedData : FloatAttributeData
[Get]
Signature
val smoothingSpeedData: FloatAttributeData
smoothingSpeedId :
[Get]
Signature
val smoothingSpeedId: 
sourcePanelData : EntityAttributeData
[Get]
Signature
val sourcePanelData: EntityAttributeData
sourcePanelId :
[Get]
Signature
val sourcePanelId: 
useGpuSamplingData : BooleanAttributeData
[Get]
Signature
val useGpuSamplingData: BooleanAttributeData
useGpuSamplingId :
[Get]
Signature
val useGpuSamplingId: 

Methods

attributeCount ()
Signature
open override fun attributeCount(): Int
Returns
Int
attributeKeys ()
Signature
open override fun attributeKeys(): IntArray
Returns
IntArray
attributeMetaData ()
Returns
Map
attributeNames ()
Signature
open override fun attributeNames(): Array<String>
Returns
Array
attributeTypeCounts ()
Signature
open override fun attributeTypeCounts(): IntArray
Returns
IntArray
attributeTypes ()
Signature
open override fun attributeTypes(): IntArray
Returns
IntArray
dependents ()
Signature
open fun dependents(): IntArray
Returns
IntArray
enumClassesMap ()
Signature
open override fun enumClassesMap(): Map<Int, Class<out Enum<*>>>
Returns
Map
keyStringToKeyIntMap ( keyString )
Signature
open override fun keyStringToKeyIntMap(keyString: String): Int?
Parameters
keyString: String
Returns
Int?
keyToIndex ( key )
Signature
open override fun keyToIndex(key: Int): Int
Parameters
key: Int
Returns
Int