Directional Light
Updated
Sun-like parallel light aimed by the entity’s rotation.
- Type
comp-directional-light- Script class
DirectionalLightComponent- Per entity
- One
- Version
- 1.1.0
Read about it in Lights: what it does, how to use it from a script, and examples.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
intensity |
0 ≤ x ≤ 200000 |
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
DirectionalLight::change
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
Pressing T moves the root's Day Sky on by a tenth of the day; the script turns the Sun directional light to the sky's sun direction and warms and dims it near the horizon.
Click the scene, then press T to advance the time of day and watch the shadows and light follow the sun. Drag to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(DirectionalLightComponent); if (component) log(component.props);}