Hemisphere Light
Updated
Sky color from above, ground color from below.
- Type
ent-hemisphere-light- Script class
HemisphereLightEntity- Family
- Lights
Overview
Section titled “Overview”A Hemisphere Light lights the scene with a sky colour from above that blends into a ground colour from below. Surfaces facing up take the sky colour, surfaces facing down take the ground colour, and everything in between gets a mix. It gives shapes a sense of up and down without any shadow cost, which makes it the cheapest outdoor fill.
Its settings live in its required Hemisphere Light component (comp-hemisphere-light). Its “up” is the entity’s world up axis: moving the entity changes nothing, rotating it tilts the gradient. It casts no shadows. In the editor it shows an icon in its colour; play builds none.
Use it as the base fill of an outdoor scene, under a Directional Light that plays the sun. Prefer it to an Ambient Light, which lights every side the same and flattens shapes. Indoors, baked Light Probes give a room its own bounced light, and a low Hemisphere Light can stand in where no bake exists.
The props:
coloris the sky colour, the light that comes from above.groundColoris the ground colour, the light bounced up from below. Match it to the floor: green for grass, warm grey for stone.intensityis the brightness, from0to100.
Set it up
Section titled “Set it up”- Add a Hemisphere Light entity to the scene (see Scenes and hierarchy). Its position does not matter; leave its rotation at zero so “up” is the world’s up.
- Set
colorclose to the sky andgroundColorclose to the ground. - Lower
intensityuntil the sun still reads as the main light. - Add a Signal Emitter if other scripts need to know when it changes.
Examples
Section titled “Examples”Match the fill to the ground
Section titled “Match the fill to the ground”Goal: tint the fill for a grassy meadow under a clear sky.
#pragma lifecycle(startup)
function startup() { const fill = findEntity('Sky Fill').getComponent(HemisphereLightComponent); fill.setProps({ color: '#cfe6ff', groundColor: '#4a6b2a', intensity: 0.6 });}getComponent(HemisphereLightComponent)returns the light’s component.- A pale blue sky colour and a grass-green ground colour make the undersides of objects pick up a subtle green, as they would outdoors.
- One
setPropscall changes all three props at once.
Blend from day to night
Section titled “Blend from day to night”Goal: when another script emits time/night, the sky fill blends to dark blue over five seconds, and time/day blends it back.
#pragma lifecycle(startup)
const DAY = { color: '#cfe6ff', groundColor: '#5a5040', intensity: 0.8 };const NIGHT = { color: '#1c2a4a', groundColor: '#0d0d14', intensity: 0.3 };
let fill;let tween = null;
function blend(from, to, t) { const sky = new THREE.Color(from.color).lerp(new THREE.Color(to.color), t); const ground = new THREE.Color(from.groundColor).lerp(new THREE.Color(to.groundColor), t); fill.setProps({ color: '#' + sky.getHexString(), groundColor: '#' + ground.getHexString(), intensity: from.intensity + (to.intensity - from.intensity) * t, });}
function goTo(target) { if (tween) tween.stop(); const from = { ...fill.props }; tween = Tween.value(0, 1, (t) => blend(from, target, t), { duration: 5, ease: Ease.InOutSine });}
function startup() { fill = findEntity('Sky Fill').getComponent(HemisphereLightComponent); on('time/night', () => goTo(NIGHT)); on('time/day', () => goTo(DAY));}THREE.Color(...).lerp(other, t)mixes two colours;getHexString()returns it as hex without the#, which the script adds back.Tween.value(0, 1, …)drives a blend factortfrom 0 to 1, andblendwrites the mixed colours and intensity with onesetProps.{ ...fill.props }copies the current values, so a change of mind halfway blends on from where the light is.
A stronger fill when a room is not baked
Section titled “A stronger fill when a room is not baked”Goal: raise a room’s hemisphere fill when its Light Probe volume has no usable bake, so the room is never too dark.
#pragma lifecycle(startup)
function startup() { const probe = findEntity('Kitchen Probe').getComponent(LightProbeComponent); const fill = findEntity('Kitchen Fill').getComponent(HemisphereLightComponent); fill.setProps({ intensity: probe.isBaked ? 0.15 : 0.7 });}isBakedistrueonce the volume’s data was baked for its current box and quality.- With a bake, the fill adds only a touch; without one, it lights the room enough to see.
- The light already exists, so changing its
intensityrecompiles nothing.
- Rotating the entity tilts the sky-to-ground gradient. Leave it unrotated unless you want that effect.
- To switch it off, set
intensityto0rather than disabling the entity, which recompiles every lit material.
Components
Section titled “Components”What a new Hemisphere Light is made of. Required components are always present and cannot be removed; the others can. Per entity says whether an entity can hold one of that component or several. Layer, Lock and Enable are on every placed entity, and Transform holds its position, rotation and scale.
| Component | Type | Role | Per entity | What it does |
|---|---|---|---|---|
| Layer | comp-layer |
Required | One | Puts the entity on a render/raycast layer so cameras and rays can include or skip it. |
| Lock | comp-lock |
Required | One | Editor-only flag that stops the entity from being selected or moved. |
| Enable | comp-enable |
Required | One | Turns the entity and its children on or off: hides them and stops their behavior. |
| Transform | comp- |
Required | One | Position, rotation and scale of the entity, with optional editor-only per-axis locks. |
| Hemisphere Light | comp- |
Required | One | Sky color from above, ground color from below. |
You can also add 6 optional components, such as Animation Graph, Animation Timeline, Motion Path Controller, Networkable, Networkable Trait, Signal Emitter.
The settings of a new entity, as the runtime creates it. Change them in the Properties panel of XR Creator, or from a script with getComponent(…).setProps({ … }).
| Prop | Default | Range |
|---|---|---|
color |
"#ffffff" |
|
intensity |
1 |
0 ≤ x ≤ 100 |
groundColor |
"#444444" |
Events
Section titled “Events”With a Signal Emitter on the entity, these events reach scripts as { entityId, eventType, data }. Compare eventType with the EventType constants.
HemisphereLight::change
Like every entity, it also reports: Transform::change (and position-change, rotation-change, scale-change), Enable::change, Layer::change and Lock::change.
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
One Hemisphere Light lights everything: tops take its sky colour, undersides its ground colour, with no direction and no shadows. The script steps it through noon, sunset and night.
Watch the tops and undersides of the shapes change colour with each mood. Drag to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”Find the entity by its name, check its class, and work with its components. Name the entity in the Hierarchy first; this example expects My Hemisphere Light.
#pragma lifecycle(startup)
function startup() { // Find the entity by the name it has in the Hierarchy. const entity = findEntity('My Hemisphere Light'); if (!(entity instanceof HemisphereLightEntity)) return;
// Its Hemisphere Light component holds the settings listed under Props. const component = entity.getComponent(HemisphereLightComponent); log('intensity is', component.props.intensity); component.setProps({ intensity: 1.5 });}