BabylonJS/Babylon.js · error
When using ArrayBufferView to load data the file extension m
Error message
When using ArrayBufferView to load data the file extension must be provided.
What it means
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.
Source
Thrown at packages/dev/core/src/Loading/sceneLoader.ts:677
onProgress(event);
} catch (error) {
Logger.Warn("Error in onProgress callback: " + getErrorMessage(error));
}
};
}
async function loadDataAsync(
fileInfo: IFileInfo,
scene: Scene,
onProgress: ((event: ISceneLoaderProgressEvent) => void) | undefined,
pluginExtension: Nullable<string>,
name: string,
pluginOptions: PluginOptions
): Promise<LoadedPluginData> {
const directLoad = getDirectLoad(fileInfo.url);
if (fileInfo.rawData && !pluginExtension) {
throw new Error("When using ArrayBufferView to load data the file extension must be provided.");
}
const fileExtension = !directLoad && !pluginExtension ? getFilenameExtension(fileInfo.url) : "";
let registeredPlugin = pluginExtension
? getPluginForExtension(pluginExtension, true)
: directLoad
? getPluginForDirectLoad(fileInfo.url)
: getPluginForExtension(fileExtension, false);
if (!registeredPlugin && fileExtension) {
if (fileInfo.url && !fileInfo.url.startsWith("blob:")) {
// Fetching head content to get the mime type
const response = await _FetchAsync(fileInfo.url, { method: "HEAD", responseHeaders: ["Content-Type"] });
const mimeType = response.headerValues ? response.headerValues["Content-Type"] : "";
if (mimeType) {
registeredPlugin = getPluginForMimeType(mimeType);
}
View on GitHub (pinned to 0592b347b8)
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.
Example fix
// before
await BABYLON.SceneLoader.LoadDataAsync("", arrayBuffer, scene, null, "", ""); // throws
// after
await BABYLON.SceneLoader.LoadDataAsync("", arrayBuffer, scene, null, "glb", ""); Defensive patterns
Strategy: validation
Validate before calling
function assertLoadArgs(data: unknown, pluginExtension?: string | null): void {
if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
if (!pluginExtension) throw new Error("pluginExtension is required when loading raw binary data");
}
} Type guard
function isRawData(d: unknown): d is ArrayBufferView {
return d !== null && typeof d === "object" && (ArrayBuffer.isView(d) || d instanceof ArrayBuffer);
} Try / catch
try {
await BABYLON.SceneLoader.LoadDataAsync("", buffer, scene, null, "glb", "");
} catch (e) {
if ((e as Error).message.includes("ArrayBufferView")) {
console.error("Supply a pluginExtension (e.g. 'glb') when passing raw buffers", e);
}
} Prevention
- 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.
When it happens
Trigger: Calling SceneLoader.LoadDataAsync (or ImportMeshAsync with file data) passing an ArrayBufferView as data and omitting the pluginExtension parameter.
Common situations: 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.
Related errors
- Loading from ArrayBufferView can not be used with plugins th
- No scene available to import mesh to
- Cannot load file: a valid scene filename or root url was not
- No scene available to append to
- No plugin or fallback for ${pluginExtension ?? fileInfo.url}
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/e8562ab765def40a.
Report an issue: GitHub.