What pluginExtension string should be used for draco compression with Base64 data in SceneLoader.AppendAsync?

I’m trying to load a glb with draco compression as a base64 encoded string and getting an error.

Unable to load from data:;base64,{the entire base64 string}: Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.

The documentation says " The pluginExtension parameter should be set when using base64 data urls in order to ensure the correct plugin is used to load the model."

I’m guessing/hoping that all I need to do is provide a string to use the draco plugin, however I can’t find any examples of what the pluginExtension string should be. I tried “draco” and “KHR_draco_mesh_compression”, but get an error message about the plugin not being found.

Unable to find a plugin to load KHR_draco_mesh_compression files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type

For context, this is to address an issue with the Khronos gltf-asset-auditor: Draco support · Issue #2 · KhronosGroup/gltf-asset-auditor · GitHub

The line of code that throws the error is

await SceneLoader.AppendAsync('', glb.getBase64String(), this.scene);

You can see in my comments (line 460-462) that before hitting the line with the error (line 463), the file was already successfully loaded with GltfFileLoader. It also runs properly through the gltf validator (line 458). The reason that it is being loaded as a base64 string is to streamline handling either gltf or glb files from either a web browser or node.js with null engine.

ping @bghgary

You should indicate that what is inside the base64 string is a gltf file by passing “.gltf” to AppendAsync:

await BABYLON.SceneLoader.AppendAsync('', glb.getBase64String(), this.scene, ".gltf");
1 Like

Thanks for the quick reply!

Unfortunately, passing ‘.gltf’ as the pluginExtension doesn’t seem to work in this case.

It may be an underlying issue with SceneLoader in the NodeJS + NullEngine context. I created a sample project to demonstrate the issue that I’m seeing.

I am able to load the draco compressed data with GLTFFileLoader, but not SceneLoader.AppendAsync. I’ll probably switch to GLTFFileLoader to fix the Asset Auditor issue, but I wanted to report my findings in case there is an underlying issue with SceneLoader or to learn if I’m just not using it properly.

I also created a playground to show that it does work in the browser: Babylon.js Playground

Try import "@babylonjs/loaders/glTF" instead of import "@babylonjs/loaders/glTF/2.0/glTFLoader.js". At least, that is what this doc says to do.

1 Like

This is a problem with Tools.GetAbsoluteUrl in a node environment. I updated to code to try to make it work which got past the first problem. Then it complained about XMLHttpRequest not being there. I polyfilled it, which got past that problem. But it still doesn’t work unfortunately. The code tries to load the Draco scripts into the environment but the code for loading scripts doesn’t work in a node environment. @MikeFesta If you can file a feature request on GitHub, we can look into more, but we are going to release 6.0 soon, so this may not happen quickly.

1 Like