{"record":{"id":"90ed3da251cf51aa","repo":"BabylonJS/Babylon.js","slug":"fbxfileloader-unsupported-data-type","errorCode":null,"errorMessage":"FBXFileLoader: unsupported data type","messagePattern":"FBXFileLoader: unsupported data type","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/FBX/fbxFileLoader.pure.ts","lineNumber":228,"sourceCode":"\r\n        return container;\r\n    }\r\n\r\n    // ── Parsing ────────────────────────────────────────────────────────────\r\n\r\n    private _parse(data: unknown): FBXDocument {\r\n        if (data instanceof ArrayBuffer) {\r\n            return this._parseFromArrayBuffer(data);\r\n        }\r\n        if (ArrayBuffer.isView(data)) {\r\n            const view = data as ArrayBufferView;\r\n            const buffer = view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength) as ArrayBuffer;\r\n            return this._parseFromArrayBuffer(buffer);\r\n        }\r\n        if (typeof data === \"string\") {\r\n            return parseAsciiFBX(data);\r\n        }\r\n        throw new Error(\"FBXFileLoader: unsupported data type\");\r\n    }\r\n\r\n    private _parseFromArrayBuffer(buffer: ArrayBuffer): FBXDocument {\r\n        // Check magic bytes to determine binary vs ASCII\r\n        const headerBytes = new Uint8Array(buffer, 0, Math.min(21, buffer.byteLength));\r\n        const header = String.fromCharCode(...headerBytes);\r\n\r\n        if (header.startsWith(FBX_BINARY_MAGIC)) {\r\n            return parseBinaryFBX(buffer);\r\n        }\r\n\r\n        // Try ASCII\r\n        const text = new TextDecoder(\"utf-8\").decode(buffer);\r\n        if (text.trimStart().startsWith(FBX_ASCII_MAGIC)) {\r\n            return parseAsciiFBX(text);\r\n        }\r\n\r\n        throw new Error(\"FBXFileLoader: unrecognized FBX format\");\r","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/FBX/fbxFileLoader.pure.ts#L210-L246","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst res = await fetch('model.fbx');\nconst blob = await res.blob();\nloader.parse(blob); // throws: unsupported data type\n// after\nconst res = await fetch('model.fbx');\nconst buffer = await res.arrayBuffer();\nloader.parse(buffer); // binary or ASCII FBX detected by magic bytes","handlingStrategy":"type-guard","validationCode":"function toLoaderInput(data) {\n  if (data instanceof ArrayBuffer) return data;\n  if (ArrayBuffer.isView(data)) {\n    const view = data;\n    return view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength);\n  }\n  if (typeof data === 'string') return data;\n  if (typeof Blob !== 'undefined' && data instanceof Blob) return data.arrayBuffer();\n  throw new TypeError('FBX input must be ArrayBuffer, typed view, or ASCII string');\n}","typeGuard":"function isFbxLoaderInput(data: unknown): data is ArrayBuffer | string {\n  return data instanceof ArrayBuffer || typeof data === 'string';\n}","tryCatchPattern":"try {\n  loader.parse(data);\n} catch (e) {\n  if (e instanceof Error && e.message === 'FBXFileLoader: unsupported data type') {\n    console.error('Pass ArrayBuffer for binary FBX or a string for ASCII FBX; got', typeof data);\n  } else throw e;\n}","preventionTips":["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"],"tags":["fbx","type-error","loader","parsing"],"backgroundTag":"unsupported-input-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}