logo

Babylon.js Market

EnvironmentTexture

rendering

EnvironmentTexture

Free

Install with the CLI:

bjs download EnvironmentTexture

EnvironmentTexture

Image-based lighting from a prefiltered cubemap so PBR materials reflect a real environment.

What it does

EnvironmentTexture is data-only: it holds a cubemap url, a reflection level, and an optional named preset. A preset ('studio' today) fills both url and level from a built-in HDRI, so a scene can say { "preset": "studio" } and get the marketplace figure-render lighting without knowing the asset URL — an explicit url/level you also pass always wins. On first tick (or when the entity is added later) the System reads the component and calls setEnvironmentTexture(url, { level }) on the active renderer, which sets scene.environmentTexture on Babylon (or the PMREM equivalent elsewhere). From then on metallic balls, polished floors, and any other PBR meshes reflect the environment instead of rendering flat. It applies exactly once per component; on entity removal the System calls clearEnvironmentTexture() and resets its init flag, so re-adding the entity re-applies cleanly.

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.

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

    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
{
  "Env": {
    "components": {
      "EnvironmentTexture": {
        "preset": "studio",
        "level": 1.15
      }
    }
  }
}

Props

  • url (string, default '') — URL of the prefiltered cubemap (a Babylon .env, a Three .hdr + PMREM, etc.), one per renderer. Optional when you supply a preset. If it resolves to empty, the System no-ops and never touches the renderer.
  • level (number, default 1.0) — reflection strength multiplier; 1.0 is neutral, higher brightens the image-based lighting. Passed straight through to setEnvironmentTexture.
  • preset ('studio', optional, default unset) — named lighting setup that fills url + level. 'studio' = the neutral studio.env HDRI used by the marketplace figure-render pipeline (level 1.15). An explicit url/level overrides the preset's value.

Events

None. EnvironmentTexture is one-shot init — it drives the adapter's setEnvironmentTexture / clearEnvironmentTexture directly and emits nothing on the EventBus.

Dependencies

None. EnvironmentTexture needs no sibling component on its own entity. For the reflection to be visible you need PBR meshes in the scene with low roughness / metallic materials (a chrome sphere, a polished floor) — a fully rough surface reflects almost nothing.

Notes

  • It is applied once and never reconciled — changing url or level at runtime does not re-push to the renderer. To swap environments live, remove and re-add the entity (removal clears the texture and resets the init flag).
  • With no url and no preset, url stays '' and the System silently does nothing, so an empty component is a harmless no-op rather than an error.
  • Runtime state (the initialized flag) lives in a WeakMap keyed by the component, so it survives entity pooling without leaking.
  • On a renderer-less world the System is inert: adding the component and updating never throws and never applies a texture.
  • Pair it with a ToneMapping component for the full filmic look; on its own it only supplies the reflections and IBL, not the color grade.

More like this

AiPilot
Animation
ArcCamera
Asteroid
Bullet
CameraFollow
DirectionalLight
Enemy
EnemySpawner
FreighterCar
FreighterChain
FreighterHead
GameConfig
Health
HemisphericLight
Jump
KeyboardInput
KeyboardMover
Lifetime
LineOfSight
MachineGun
Mesh
MeshPrimitive
Missile
MissileLauncher
MissionDirector
Movement
Obstacle
ObstacleField
OilBlob
Parts
Physics
PlayerInput
PlayerWalkAnimator
Renderable
RespawnTimer
Score
Shadow
ShipLoadout
SkeletonAnimator
Skybox
SpaceDust
SpaceShooterBullet
SpaceShooterHealth
SpaceShooterScore
ToneMapping
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