Skip to content

Scene

Some settings live on the scene rather than on a single object the skybox, fog, gravity, and the post-processing stack. They are stored on a singleton entity so you can read and mutate them from any Behaviour.

PageWhat it covers
EnvironmentSkybox (gradient / color / image), fog (linear / exponential), and physics gravity.
PostprocessingBloom, vignette, depth-of-field, tone mapping, and other full-screen effects.

Pattern

Both components follow the same access pattern from a script:

ts
import { Behaviour, Environment, Postprocessing } from "@relu-interactives/spatial-ecs";

export default class TweakScene extends Behaviour {
  init() {
    // 1. Find the singleton entity that owns the component.
    const [entityId] = this.world.query(Environment);
    if (entityId === undefined) return;

    // 2. Read the component instance.
    const env = this.world.getComponent(entityId, Environment);
    if (!env) return;

    // 3. Mutate `env.values` — sync systems pick the change up next frame.
    env.values.fog.type = "linear";
    env.values.fog.color = "#88aaff";
    env.values.fog.linear.near = 5;
    env.values.fog.linear.far = 60;
  }
}

The same shape works for Postprocessing — see each page for the full set of authorable values.