logo
SpotLight

lighting

SpotLight

Free

Install with the CLI:

bjs download SpotLight

SpotLight

An aimed cone of light, like a ceiling can-light over one machine.

What it does

SpotLightSystem creates a spot light through the renderer adapter when the component attaches and disposes it when it goes. Position and intensity are checked each frame, so you can move or dim a live light. A spot is a local accent, so range is bounded by default; an unbounded one would leak down a whole hall.

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 SpotLight

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 SpotLight
    bjs download SpotLight

    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
{
  "entities": {
    "Spot": {
      "components": {
        "SpotLight": {
          "position": [0, 4, 0],
          "direction": [0, -1, 0],
          "angle": 1.0,
          "exponent": 2,
          "intensity": 2,
          "diffuse": [0.6, 0.8, 1],
          "range": 10
        }
      }
    }
  }
}

Props

  • position ([x, y, z], default [0, 3, 0]) — where the cone starts.
  • direction ([x, y, z], default [0, -1, 0]) — where it points.
  • angle (radians, default π/3) — the whole cone width, not half.
  • exponent (number, default 2) — edge hardness; higher is a crisper circle.
  • intensity (number) — brightness.
  • diffuse, specular ([r, g, b]) — light and highlight colour.
  • range (number, default 10) — distance where the light stops.

Events

  • emits spotlight.created — the light exists.
  • emits spotlight.intensity.changed — brightness moved.
  • emits spotlight.moved — position moved.

Dependencies

None.

More like this

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search