Update: full solution: Loading asset data from local files in nodejs - #4 by NightSkies
Hi,
We’re using babylon engine on the serverside for some things. I’m having some issues loading glb files.
It errors out with this:
envFileDataURL blob:nodedata:a3f3a68d-5d54-4838-8679-45
BJS - [22:53:15]: Unable to find a plugin to load gltf files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes
(node:10468) [DEP0170] DeprecationWarning: The URL blob:nodedata:a3f3a68d-5d54-4838-8679-452f7e22c092 is invalid. Future versions of Node.js will throw an error.
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error
at XMLHttpRequest.send ( ... \node_modules\xhr2\lib\xhr2.js:281:19)
at e.send (webpack://BABYLON/../../../dev/core/src/Misc/webRequest.ts:178:19)
at retryLoop (webpack://BABYLON/../../../dev/core/src/Misc/fileTools.ts:678:21)
at requestFile (webpack://BABYLON/../../../dev/core/src/Misc/fileTools.ts:681:9)
at RequestFile (webpack://BABYLON/../../../dev/core/src/Misc/fileTools.ts:724:9)
at C (webpack://BABYLON/../../../dev/core/src/Misc/fileTools.ts:496:12)
at t._loadFile (webpack://BABYLON/../../../dev/core/src/scene.ts:5416:25)
at manifestChecked (webpack://BABYLON/../../../dev/core/src/Loading/sceneLoader.ts:737:25)
at Function._LoadData (webpack://BABYLON/../../../dev/core/src/Loading/sceneLoader.ts:759:13)
at Function._LoadAssetContainer (webpack://BABYLON/../../../dev/core/src/Loading/sceneLoader.ts:1531:28)
at webpack://BABYLON/../../../dev/core/src/Loading/sceneLoader.ts:1639:25
at new Promise (<anonymous>)
at Function.e.LoadAssetContainerAsync (webpack://BABYLON/../../../dev/core/src/Loading/sceneLoader.ts:1638:16)
...
Relevant code:
const environmentModel = await readFile(
"<local filesystem path to glb here, its reading successfully",
);
const envFileBlob = new Blob([environmentModel]);
// const envFile = new File([environmentModel], "baseModel.glb");
const envFileDataURL = URL.createObjectURL(envFileBlob);
console.log('envFileDataURL', envFileDataURL.slice(0, 40));
const container = await BABYLON.SceneLoader.LoadAssetContainerAsync(
envFileDataURL,
scene,
{ pluginExtension: "gltf" },
);
Perhaps I’m not properly forming the data URL (maybe must begin with data: …).
The relevant resources on this don’t seem focused on nodejs. Anyone have experience with this?
I tried this but it errors out with “FileReader not found” (is that referring to an HTML5 API?): Importing gltf ArrayBuffers from loaders.gl - #2 by br-matt
Thanks
Update: full solution: Loading asset data from local files in nodejs - #4 by NightSkies