logo
HemisphericLight

lighting

HemisphericLight

Free

Install with the CLI:

bjs download HemisphericLight

HemisphericLight

Ambient sky/ground light — a single hemispheric source that fills a scene with soft, two-toned light.

What it does

HemisphericLight is data-only: it holds a direction, an intensity, and three colors (sky/diffuse, ground, specular), and serializes them. HemisphericLightSystem reads that data and drives the renderer adapter — on attach it calls createHemisphericLight and stores the opaque handle on the component, and on detach it calls disposeLight and clears the handle. Each frame it watches intensity for changes coming from outside the System (a debug panel, gameplay code) and pushes them through updateLightIntensity, so live tuning takes effect without recreating the light. The System emits hemisphericlight.created when a light spawns and hemisphericlight.intensity.changed when intensity is mutated after creation.

Use it in a scene

A scene is just data — a list of entities, each with its components. At startup the SceneLoader turns this JSON into a live world; edit the file and reload to rebuild it.

Fastest path

bjs download scene HemisphericLight

Pulls this exact scene into your project and runs it — no copy-paste. Add --all to grab the components and assets it needs too.

Or build it from scratch with the bjs CLI:

  1. 1Scaffold a project
    npm create @babylonjsmarket/arcade@latest my-game

    World, renderer, and dev server — ready to run.

  2. 2Install dependencies
    cd my-game && npm install
  3. 3Add HemisphericLight
    bjs download HemisphericLight

    Copies its source into src/ so the scene resolves.

    First time? Run bjs login once.

  4. 4Paste the scene into src/scenes/arcade-room.ts and run
    npm run dev

    SceneLoader builds the world from the JSON; reload to rebuild.

JSON
{
  "Sun": {
    "components": {
      "HemisphericLight": {
        "direction": [0, 1, 0],
        "intensity": 0.8,
        "diffuse": [1, 1, 1],
        "groundColor": [0.2, 0.2, 0.2]
      }
    }
  }
}

Props

  • direction ([x,y,z], default [0, 1, 0]) — the sky direction; the constructor normalizes it (a zero vector falls back to [0, 1, 0]). The diffuse color comes from this direction, the ground color from the opposite side.
  • intensity (number, default 0.3) — overall brightness. This is the field the System watches for live changes.
  • diffuse ([r,g,b], default [1, 1, 1]) — the sky color lighting surfaces facing direction.
  • groundColor ([r,g,b], default [0.2, 0.2, 0.2]) — the color lighting surfaces facing away from direction, simulating bounce from below.
  • specular ([r,g,b], default [0, 0, 0]) — specular highlight tint; [0, 0, 0] leaves surfaces matte.

Events

  • Emits hemisphericlight.created (HemisphericLightEvents.CREATED) when a light is first created, with { entityId, intensity }.
  • Emits hemisphericlight.intensity.changed (HemisphericLightEvents.INTENSITY_CHANGED) when intensity is mutated after creation, with { entityId, intensity }. It does not fire for the initial value.

Dependencies

None. HemisphericLight drives the renderer directly and reads no sibling components, so it stands alone on an otherwise bare entity. To see it you need geometry to light (MeshPrimitive or Mesh) and a camera (ArcCamera) on other entities, but the light itself has no required siblings.

Notes

  • The light's full color/direction setup is sent once at createHemisphericLight. After that only intensity is reconciled per frame — changing diffuse, groundColor, specular, or direction on a live component will not re-push to the renderer.
  • The intensity watch uses a WeakMap keyed by the component, so the per-light baseline survives without holding the component alive. The threshold is 0.001, so sub-millis nudges are ignored.
  • Removing the entity disposes the renderer light and resets initialized, so the same component can be re-attached and will recreate its light cleanly.
  • Multiple hemispheric lights stack; intensity 0.3 is a low ambient fill meant to sit under a directional key light, not to light a scene on its own.

More like this

AiPilot
Animation
ArcCamera
Asteroid
Bullet
CameraFollow
DirectionalLight
EnemySpawner
EnvironmentTexture
Flash
FreighterCar
FreighterChain
FreighterHead
GameConfig
Health
Jump
KeyboardInput
KeyboardMover
LensFlare
Lifetime
LineOfSight
MachineGun
Mesh
MeshPrimitive
Missile
MissileLauncher
MissionDirector
MouseInput
Movement
NebulaSky
Obstacle
ObstacleField
OilBlob
Parts
Physics
PlayerInput
PlayerWalkAnimator
Renderable
RespawnTimer
RoadTreadmill
RoundReset
Score
Shadow
ShipDamageFX
ShipLoadout
SkeletonAnimator
Skybox
SmokeScreen
SpaceDust
SpaceShooterBullet
SpaceShooterFX
SpaceShooterHealth
SpaceShooterScore
ToneMapping
TwinStickEnemy
WaveDirector
Waypoint
WaypointTrack

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search