logo
Fog

rendering

Fog

Free

Install with the CLI:

bjs download Fog

Fog

Scene-wide distance fog that you can change while the game runs.

What it does

There is one fog per scene. FogSystem sends the component's settings to the renderer adapter (setFog) when the component attaches and clears it when the component goes away. Every field is compared each frame, so a slider that moves density or a menu that flips enabled takes effect on the next frame with no extra wiring.

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 Fog

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

    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": {
    "Weather": {
      "components": {
        "Fog": { "mode": "exp2", "density": 0.08, "color": [0.6, 0.65, 0.7] }
      }
    }
  }
}

Props

  • mode (linear | exp | exp2, default exp2) — how fog thickens with distance.
  • color ([r, g, b], default black) — what far things fade to. Match the clear colour so the horizon melts away.
  • density (number, default 0.05) — thickness for the exp modes.
  • start, end (numbers, default 10 and 100) — where linear fog begins and goes solid.
  • enabled (boolean, default true) — off switch that keeps the settings.

Events

  • emits fog.applied { entityId, mode, density } — fog is on with the current settings.
  • emits fog.cleared { entityId } — fog was switched off.

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