BabylonJS/Babylon.js · error · Error
FBXFileLoader: unsupported data type
Error message
FBXFileLoader: unsupported data type
What it means
FBXFileLoader._parse accepts either an ArrayBuffer/TypedArray view (binary or ASCII FBX content) or a string (ASCII FBX). This error is thrown when the data passed to the loader is neither of those types, so the loader cannot determine how to parse it.
Source
Thrown at packages/dev/loaders/src/FBX/fbxFileLoader.pure.ts:228
return container;
}
// ── Parsing ────────────────────────────────────────────────────────────
private _parse(data: unknown): FBXDocument {
if (data instanceof ArrayBuffer) {
return this._parseFromArrayBuffer(data);
}
if (ArrayBuffer.isView(data)) {
const view = data as ArrayBufferView;
const buffer = view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength) as ArrayBuffer;
return this._parseFromArrayBuffer(buffer);
}
if (typeof data === "string") {
return parseAsciiFBX(data);
}
throw new Error("FBXFileLoader: unsupported data type");
}
private _parseFromArrayBuffer(buffer: ArrayBuffer): FBXDocument {
// Check magic bytes to determine binary vs ASCII
const headerBytes = new Uint8Array(buffer, 0, Math.min(21, buffer.byteLength));
const header = String.fromCharCode(...headerBytes);
if (header.startsWith(FBX_BINARY_MAGIC)) {
return parseBinaryFBX(buffer);
}
// Try ASCII
const text = new TextDecoder("utf-8").decode(buffer);
if (text.trimStart().startsWith(FBX_ASCII_MAGIC)) {
return parseAsciiFBX(text);
}
throw new Error("FBXFileLoader: unrecognized FBX format");
View on GitHub (pinned to 0592b347b8)
Solutions
- Convert the input before loading: for binary FBX pass an ArrayBuffer (e.g. await response.arrayBuffer()), for ASCII FBX pass the decoded string (await response.text())
- If you have a Blob, call await blob.arrayBuffer() before passing it to the loader
- If you have a Uint8Array, pass its buffer slice (view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength))
- If you have a Node Buffer, convert with buffer.buffer.slice(...) or buffer.toString('latin1') for ASCII FBX
- Log typeof data just before the call to confirm the runtime type matches the accepted inputs
Example fix
// before
const res = await fetch('model.fbx');
const blob = await res.blob();
loader.parse(blob); // throws: unsupported data type
// after
const res = await fetch('model.fbx');
const buffer = await res.arrayBuffer();
loader.parse(buffer); // binary or ASCII FBX detected by magic bytes Defensive patterns
Strategy: type-guard
Validate before calling
function toLoaderInput(data) {
if (data instanceof ArrayBuffer) return data;
if (ArrayBuffer.isView(data)) {
const view = data;
return view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength);
}
if (typeof data === 'string') return data;
if (typeof Blob !== 'undefined' && data instanceof Blob) return data.arrayBuffer();
throw new TypeError('FBX input must be ArrayBuffer, typed view, or ASCII string');
} Type guard
function isFbxLoaderInput(data: unknown): data is ArrayBuffer | string {
return data instanceof ArrayBuffer || typeof data === 'string';
} Try / catch
try {
loader.parse(data);
} catch (e) {
if (e instanceof Error && e.message === 'FBXFileLoader: unsupported data type') {
console.error('Pass ArrayBuffer for binary FBX or a string for ASCII FBX; got', typeof data);
} else throw e;
} Prevention
- Always fetch FBX assets via response.arrayBuffer() or response.text(), never response.json() or raw Blob
- Convert Uint8Array/Buffer views to a clean ArrayBuffer slice before parsing
- Never pass already-parsed objects back into the loader
- Type loader inputs as ArrayBuffer | string in your wrapper functions
When it happens
Trigger: Passing a Blob, JSON object, Uint8Array-like from another realm, a FileReader result that was never converted, or an already-parsed object to the FBX loading path (via doc -> _parse) instead of raw bytes or an ASCII string.
Common situations: Fetching an FBX with response handling that returns JSON/Blob instead of arrayBuffer or text, passing a parsed FBX document back into the loader, upgrading the loader and changing the input contract, or passing Node.js Buffer objects in non-browser environments without conversion.
Related errors
- `Unsupported const property type: '${type}'`
- Nothing else parsed so far
- Cannot transform value ${a}
- Cannot slerp value ${a}
- Invalid color type
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/90ed3da251cf51aa.
Report an issue: GitHub.