Skip to content

Hemisphere Light

Updated

Sky color from above, ground color from below.

Type
ent-hemisphere-light
Script class
HemisphereLightEntity
Family
Lights

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:

  • color is the sky colour, the light that comes from above.
  • groundColor is the ground colour, the light bounced up from below. Match it to the floor: green for grass, warm grey for stone.
  • intensity is the brightness, from 0 to 100.
  1. 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.
  2. Set color close to the sky and groundColor close to the ground.
  3. Lower intensity until the sun still reads as the main light.
  4. Add a Signal Emitter if other scripts need to know when it changes.

Goal: tint the fill for a grassy meadow under a clear sky.

MeadowFill.jx
#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 setProps call changes all three props at once.

Goal: when another script emits time/night, the sky fill blends to dark blue over five seconds, and time/day blends it back.

DayNightFill.jx
#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 factor t from 0 to 1, and blend writes the mixed colours and intensity with one setProps.
  • { ...fill.props } copies the current values, so a change of mind halfway blends on from where the light is.

Goal: raise a room’s hemisphere fill when its Light Probe volume has no usable bake, so the room is never too dark.

FallbackFill.jx
#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 });
}
  • isBaked is true once 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 intensity recompiles nothing.
  • Rotating the entity tilts the sky-to-ground gradient. Leave it unrotated unless you want that effect.
  • To switch it off, set intensity to 0 rather than disabling the entity, which recompiles every lit material.

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-transform Required One Position, rotation and scale of the entity, with optional editor-only per-axis locks.
Hemisphere Light comp-hemisphere-light 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"

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.

Run it in the browser, read its scripts, and download it as an XR Creator project.

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.

HemisphereLightEntity.jx
#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 });
}