Environments - rogerscg/era-engine GitHub Wiki

Environments are a utility used within ERA for defining and creating the stage for your game or visual. Things such as lighting, skyboxes, and background color are loaded in when given a file:

{
  "skybox": {
    "directory": "/path/to/skybox/",
    "file": "skybox_prefix",
    "extension": "png"
  },
  "background": "ffffff",
  "lights": {
    "ambient": [
      {
        "color": "ffffff",
        "intensity": 0.5
      }
    ],
    "directional": [
      {
        "x": 100,
        "y": 500,
        "z": 100,
        "color": "ffffff",
        "intensity": 0.5
      }
    ]
  }
}

Using this file, we create the environment at loading time:

const environment = await new Environment().loadFromFile('environment.json');
scene.add(environment);

Skyboxes

Within the Environment class, we load in a Skybox object, an ERA-defined class that loads a set of 6 images and stitches them together to form a skybox. When providing images for a skybox, they should be in the format of:
skybox_${suffix}

where suffix is any of ['ft', 'bk', 'up', 'dn', 'rt', 'lf'].