BabylonJS/Babylon.js · error · Error

Unsupported type: ${outputType}

Error message

Unsupported type: ${outputType}

What it means

CreateDecoderAsync takes an outputType parameter (EXROutputType) selecting the destination texture format; only Float (Float32Array) and HalfFloat (Uint16Array) are handled. Any other value reaches the switch default and throws. This is a caller-supplied option, not file data.

Source

Thrown at packages/dev/core/src/Materials/Textures/Loaders/EXR/exrLoader.decoder.ts:263

            // Fill initially with 1s for the alpha value if the texture is not RGBA, RGB values will be overwritten
            if (fillAlpha) {
                decoder.byteArray.fill(1, 0, size);
            }

            break;

        case EXROutputType.HalfFloat:
            decoder.byteArray = new Uint16Array(size);
            decoder.textureType = Constants.TEXTURETYPE_HALF_FLOAT;

            if (fillAlpha) {
                decoder.byteArray.fill(0x3c00, 0, size); // Uint16Array holds half float data, 0x3C00 is 1
            }

            break;

        default:
            throw new Error("Unsupported type: " + outputType);
    }

    let byteOffset = 0;
    for (const channel of header.channels) {
        if (decoder.decodeChannels[channel.name] !== undefined) {
            decoder.channelLineOffsets[channel.name] = byteOffset * decoder.width;
        }

        byteOffset += channel.pixelType * 2;
    }

    decoder.bytesPerLine = decoder.width * byteOffset;
    decoder.outLineWidth = decoder.width * decoder.outputChannels;

    if (header.lineOrder === "INCREASING_Y") {
        decoder.scanOrder = (y) => y;
    } else {
        decoder.scanOrder = (y) => decoder.height - 1 - y;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Pass EXROutputType.Float or EXROutputType.HalfFloat explicitly instead of a raw number
  2. Log/inspect the outputType value reaching CreateDecoderAsync to find where it goes wrong
  3. Ensure the enum import is from the same Babylon version as the loader
  4. Default to EXROutputType.HalfFloat when the value is not one of the two valid members

Example fix

// before
loader.load(url, { outputType: 2 as any });
// after
import { EXROutputType } from "...";
loader.load(url, { outputType: EXROutputType.Float });
Defensive patterns

Strategy: type-guard

Validate before calling

import { EXROutputType } from "@babylonjs/core";
function toOutputType(v: unknown): EXROutputType {
  return v === EXROutputType.Float || v === EXROutputType.HalfFloat ? v : EXROutputType.HalfFloat;
}

Type guard

function isEXROutputType(v: unknown): v is EXROutputType {
  return v === 0 || v === 1; // EXROutputType.Float | EXROutputType.HalfFloat
}

Try / catch

try {
  await loader.loadAsync(file, { outputType });
} catch (e) {
  if (/Unsupported type/.test(String(e))) {
    console.warn("bad outputType, retrying with HalfFloat");
    return loader.loadAsync(file, { outputType: EXROutputType.HalfFloat });
  }
  throw e;
}

Prevention

When it happens

Trigger: Raised in CreateDecoderAsync when the outputType argument passed through the EXR loading pipeline is neither EXROutputType.Float (0) nor EXROutputType.HalfFloat (1) — e.g. passing a raw number like 2, undefined, or a wrong enum from custom code.

Common situations: Custom loader integrations passing an invalid numeric type, typos mapping config values to EXROutputType, or stale code from an API version where the enum values changed.

Related errors


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