BabylonJS/Babylon.js · error · Error

${extensionContext}: Invalid area light type (${light.type})

Error message

${extensionContext}: Invalid area light type (${light.type})

What it means

The EXT_lights_area glTF extension loader throws this when a KHR/EXT area light declares a type other than the supported ones (e.g. only 'rectangle' is supported, mapped to RectAreaLight). An unknown light.type string falls into the default branch and aborts node loading.

Source

Thrown at packages/dev/loaders/src/glTF/2.0/Extensions/EXT_lights_area.pure.ts:95

                switch (light.type) {
                    case EXTLightsArea_LightType.RECT: {
                        const width = light.rect?.aspect !== undefined ? light.rect.aspect * size : size;
                        const height = size;
                        const babylonRectAreaLight = new RectAreaLight(name, Vector3.Zero(), width, height, this._loader.babylonScene);
                        babylonLight = babylonRectAreaLight;
                        break;
                    }
                    case EXTLightsArea_LightType.DISK: {
                        // For disk lights, we'll use a rectangle light with the same area to approximate the disk light
                        // In the future, this could be extended to support actual disk area lights
                        const newSize = Math.sqrt(size * size * 0.25 * Math.PI); // Area of the disk
                        const babylonRectAreaLight = new RectAreaLight(name, Vector3.Zero(), newSize, newSize, this._loader.babylonScene);
                        babylonLight = babylonRectAreaLight;
                        break;
                    }
                    default: {
                        this._loader.babylonScene._blockEntityCollection = false;
                        throw new Error(`${extensionContext}: Invalid area light type (${light.type})`);
                    }
                }

                babylonLight._parentContainer = this._loader._assetContainer;
                this._loader.babylonScene._blockEntityCollection = false;
                light._babylonLight = babylonLight;

                babylonLight.falloffType = Light.FALLOFF_GLTF;
                babylonLight.diffuse = light.color ? Color3.FromArray(light.color) : Color3.White();
                babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity;

                // glTF EXT_lights_area specifies lights face down -Z, but Babylon.js area lights face down +Z
                // Create a parent transform node with 180-degree rotation around Y axis to flip the direction
                const lightParentNode = new BabylonTransformNode(`${name}_orientation`, this._loader.babylonScene);
                lightParentNode.rotationQuaternion = Quaternion.RotationAxis(Vector3.Up(), Math.PI);
                lightParentNode.parent = babylonMesh;
                babylonLight.parent = lightParentNode;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Change the light type in the glTF to 'rectangle' (the only supported type)
  2. Remove the area light extension entry or the node if the light is not essential
  3. Re-export with a tool version aligned to the rectangle-only support
  4. Patch the asset JSON: replace the unsupported type value

Example fix

// before (asset glTF)
"lights": [{ "type": "sphere", ... }]
// after
"lights": [{ "type": "rectangle", ... }]
Defensive patterns

Strategy: validation

Validate before calling

const light = node.extensions?.EXT_lights_video?.lights?.[i];
if (light && light.type !== 'rectangle') {
  throw new Error(`Unsupported area light type: ${light.type}`);
}

Type guard

function isSupportedAreaLight(l: { type: string }): boolean {
  return l.type === 'rectangle';
}

Try / catch

try {
  await BABYLON.SceneLoader.LoadAsync('./', 'scene.gltf', engine);
} catch (e) {
  if (e instanceof Error && e.message.includes('Invalid area light type')) {
    console.error('Convert area lights to rectangle type or strip the extension');
  } else throw e;
}

Prevention

When it happens

Trigger: Loading a glTF 2.0 asset whose EXT_lights_video/area extension node has light.type set to something other than 'rectangle' (e.g. 'disc', 'sphere', or a typo like 'rect').

Common situations: Assets exported by tools writing newer/unofficial area light variants; hand-edited glTF changing the type string; mismatch between exporter extension version and loader support.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/61459ead2cf506cc. Report an issue: GitHub.