Renderer · function

createEnvironment

A complete Environment, with every field at a value that means "nothing special".

Explained in Hello world.

function createEnvironment(overrides?: Partial<Environment>): Environment
import { createEnvironment } from '@driftengine/core';

Parameters

ParameterTypeDescription
overrides?Partial<Environment>

In depth

The engine had no way to make one of these, so every caller assembled the whole interface by hand — and the first caller that wanted a small, self-contained lit scene (a character portrait in a box on a menu) wrote a partial literal, cast it to Environment to satisfy the compiler, and put undefined into uniformMatrix4fv. The type had been describing the contract all along; nothing was helping anyone meet it.

So: a factory with a neutral baseline — no shadows, no point lights, an identity light matrix, no fog — and shallow overrides on top. A caller that forgets a field now gets the harmless value rather than a WebGL error, and a caller that needs the day's sky still assembles exactly what it did before.

Fresh arrays every call. Sharing one lightPositions between two environments is the kind of aliasing that shows up as one scene's lamps appearing in another's.