BabylonJS/Babylon.js · error

Unexpected array type: ${type}

Error message

Unexpected array type: ${type}

What it means

parseArrayProperty dispatches on the property type string (e.g. 'float[]', 'int64[]') and throws when it encounters an array type it has no reader for. It indicates an FBX array property type code outside the set of supported element types.

Source

Thrown at packages/dev/loaders/src/FBX/parsers/fbxBinaryParser.ts:245

    let value: Float32Array | Float64Array | Int32Array | Uint8Array;
    switch (type) {
        case "float32[]":
            value = new Float32Array(arrayBuffer);
            break;
        case "float64[]":
            value = new Float64Array(arrayBuffer);
            break;
        case "int32[]":
            value = new Int32Array(arrayBuffer);
            break;
        case "boolean[]":
            value = arrayData;
            break;
        case "int64[]":
            value = readInt64ArrayData(arrayData);
            break;
        default:
            throw new Error(`Unexpected array type: ${type}`);
    }

    return {
        property: { type, value },
        nextOffset: offset + compressedLength,
    };
}

function ensureRange(bytes: Uint8Array, offset: number, byteLength: number, limit: number, context: string): void {
    if (offset < 0 || byteLength < 0 || offset + byteLength > limit || offset + byteLength > bytes.byteLength) {
        throw new Error(`${context}: unexpected end of input`);
    }
}

function readUint64AsNumber(view: DataView, offset: number): number {
    const low = view.getUint32(offset, true);
    const high = view.getUint32(offset + 4, true);
    return high * 0x100000000 + low;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Check which type string the error reports and extend the switch in parseArrayProperty with a reader for it
  2. Re-export the asset so all array properties use standard types (float[], int[], double[], int64[], etc.)
  3. Update the loaders package if a newer version added support for that array type
  4. Validate the FBX file with a reference tool to confirm the type code is legitimate

Example fix

// before
default:
  throw new Error(`Unexpected array type: ${type}`);
// after
case "uint64[]":
  value = readUint64ArrayData(arrayData);
  break;
default:
  throw new Error(`Unexpected array type: ${type}`);
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_ARRAY_TYPES = new Set(['float[]','int[]','double[]','int64[]','bool[]','byte[]']);
if (!SUPPORTED_ARRAY_TYPES.has(type)) throw new Error(`Unsupported FBX array type: ${type}`);

Type guard

function isSupportedArrayType(t: string): t is SupportedArrayType {
  return ['float[]','int[]','double[]','int64[]','bool[]','byte[]'].includes(t);
}

Try / catch

try {
  const { property } = parseProperty(bytes, offset);
} catch (e) {
  if ((e as Error).message.startsWith('Unexpected array type')) {
    console.warn('Skipping unsupported FBX array property'); return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: Parsing an FBX file containing an array property with an unhandled type string reaching the switch default — i.e., a type code the parser's parseProperty mapped to an array but no case exists for (e.g. a newly introduced or exotic FBX element type, or a mistyped/malformed type field in the record).

Common situations: Files exported with unusual FBX versions or proprietary extensions containing new array type codes; hand-crafted FBX binary data; a parser that is out of date relative to the FBX spec coverage needed.

Related errors


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