{"record":{"id":"e8562ab765def40a","repo":"BabylonJS/Babylon.js","slug":"when-using-arraybufferview-to-load-data-the-file-e","errorCode":null,"errorMessage":"When using ArrayBufferView to load data the file extension must be provided.","messagePattern":"When using ArrayBufferView to load data the file extension must be provided\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Loading/sceneLoader.ts","lineNumber":677,"sourceCode":"            onProgress(event);\r\n        } catch (error) {\r\n            Logger.Warn(\"Error in onProgress callback: \" + getErrorMessage(error));\r\n        }\r\n    };\r\n}\r\n\r\nasync function loadDataAsync(\r\n    fileInfo: IFileInfo,\r\n    scene: Scene,\r\n    onProgress: ((event: ISceneLoaderProgressEvent) => void) | undefined,\r\n    pluginExtension: Nullable<string>,\r\n    name: string,\r\n    pluginOptions: PluginOptions\r\n): Promise<LoadedPluginData> {\r\n    const directLoad = getDirectLoad(fileInfo.url);\r\n\r\n    if (fileInfo.rawData && !pluginExtension) {\r\n        throw new Error(\"When using ArrayBufferView to load data the file extension must be provided.\");\r\n    }\r\n\r\n    const fileExtension = !directLoad && !pluginExtension ? getFilenameExtension(fileInfo.url) : \"\";\r\n\r\n    let registeredPlugin = pluginExtension\r\n        ? getPluginForExtension(pluginExtension, true)\r\n        : directLoad\r\n          ? getPluginForDirectLoad(fileInfo.url)\r\n          : getPluginForExtension(fileExtension, false);\r\n\r\n    if (!registeredPlugin && fileExtension) {\r\n        if (fileInfo.url && !fileInfo.url.startsWith(\"blob:\")) {\r\n            // Fetching head content to get the mime type\r\n            const response = await _FetchAsync(fileInfo.url, { method: \"HEAD\", responseHeaders: [\"Content-Type\"] });\r\n            const mimeType = response.headerValues ? response.headerValues[\"Content-Type\"] : \"\";\r\n            if (mimeType) {\r\n                registeredPlugin = getPluginForMimeType(mimeType);\r\n            }\r","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Loading/sceneLoader.ts#L659-L695","documentation":"When raw binary data (ArrayBufferView) is passed to SceneLoader.LoadDataAsync / ImportMeshAsync-style entry points, SceneLoader cannot infer which loader plugin to use because there is no filename or URL to inspect. The caller must supply an explicit pluginExtension (e.g. \"glb\", \"obj\") so the right plugin can be selected.","triggerScenarios":"Calling SceneLoader.LoadDataAsync (or ImportMeshAsync with file data) passing an ArrayBufferView as data and omitting the pluginExtension parameter.","commonSituations":"Loading scenes fetched manually via fetch()/XHR into ArrayBuffers; loading from IndexedDB or custom caches; migrating from URL-based loading to in-memory binary loading without updating the call signature.","solutions":["Pass the pluginExtension parameter (e.g. \"gltf\", \"glb\", \"obj\") matching the data format.","Convert the raw data to a Blob/File with a proper filename and load that instead.","If the data is base64, embed it in a data: URL so the extension can be derived."],"exampleFix":"// before\nawait BABYLON.SceneLoader.LoadDataAsync(\"\", arrayBuffer, scene, null, \"\", \"\"); // throws\n\n// after\nawait BABYLON.SceneLoader.LoadDataAsync(\"\", arrayBuffer, scene, null, \"glb\", \"\");","handlingStrategy":"validation","validationCode":"function assertLoadArgs(data: unknown, pluginExtension?: string | null): void {\n  if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {\n    if (!pluginExtension) throw new Error(\"pluginExtension is required when loading raw binary data\");\n  }\n}","typeGuard":"function isRawData(d: unknown): d is ArrayBufferView {\n  return d !== null && typeof d === \"object\" && (ArrayBuffer.isView(d) || d instanceof ArrayBuffer);\n}","tryCatchPattern":"try {\n  await BABYLON.SceneLoader.LoadDataAsync(\"\", buffer, scene, null, \"glb\", \"\");\n} catch (e) {\n  if ((e as Error).message.includes(\"ArrayBufferView\")) {\n    console.error(\"Supply a pluginExtension (e.g. 'glb') when passing raw buffers\", e);\n  }\n}","preventionTips":["Always pass an explicit pluginExtension when loading in-memory data.","Prefer loading via URL or File objects so the extension is inferred automatically.","Wrap raw-buffer loads in a helper that enforces the extension parameter."],"tags":["loading","scene-loader","validation","async"],"backgroundTag":"missing-file-extension","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}