I noticed my file already imports some kind of loaders package. Trying to import only the loader I wanted didn’t seem to work. After I moved on from that I found extension and the dataurl were the only issues.
Adding extension like above did help! Documentation does not make this clear.
https://doc.babylonjs.com/typedoc/classes/BABYLON.SceneLoader#LoadAssetContainerAsync
Perhaps samples do
Also I had to form the dataurl by hand to get it to load. Node’s createDataURL doesnt seem to work properly here?
import * as BABYLON from "babylonjs";
import "babylonjs-loaders";
import { readFile } from "fs/promises";
// ...
const environmentModel = await readFile(
"./thelocalfilepath.glb",
);
const envFileb64 = Buffer.from(environmentModel).toString("base64");
const envFileDataURL = "data:model/gltf-binary;base64," + envFileb64;
console.log("envFileDataURL", envFileDataURL.toString().slice(0, 40));
const container = await BABYLON.SceneLoader.LoadAssetContainerAsync(
envFileDataURL,
undefined,
scene,
undefined,
".gltf",
);