GLTF + GLB Exporter outputs empty files

Hello Babylon Forum!

I have been trying to export a scene as gltf, and it seems like no matter what way I try, the gltf exporter decides to export empty files. I have tried with various meshes, both low and high poly, as well as trying to export to glb. All attempts return either blank files or a bunch of errors that stuff is empty. The source files load fine into any DCC, and they load fine into Babylon. I have tried with every combo of urls, naming, gltf validation pre-import, etc. and nothing seems to point to why the meshes arent exporting. Lights and camera export just fine. Not seeing any errors in the console on export, both on playground and in local code.

Any thoughts as to how to solve this one?
Thank you in advance!

GLB: Babylon.js Playground



1 Like

Hello and welcome to the Babylon community! The NullEngine creation was the culprit here, it exports fine without it: Export GLB Test | Babylon.js Playground ( Were you trying to use the NullEngine to reduce the resolution of the textures?

Wild, thanks for figuring that one out! I believe the original goal was to limit the texture resolution, as the textures we were pulling were 4k. The null engine part is kind of a bummer, I was hoping to use Babylon headless on a server without spinning up a full webdriver. Let me play with this for a bit to make sure it works locally for the entire setup.

Hmm I was remembering that a similar subject came up about using NullEngine to export GLTF, and apparently it should work: Null Engine export as gltf - Questions - Babylon.js ( Maybe it’s a specific Null Engine export option that’s the problem? @bghgary can you take a look at this? :thinking:

The original PGs call createNullScene which creates a null engine and an scene with just one light and one camera. The code then proceeds to export this scene. There are no meshes because there are no meshes. :slight_smile: The new PG that @carolhmj posted no longer calls createNullScene and scene is now the main one created at the top of the PG. I don’t think null engine has anything to do with it.


Hey! I appreciate you swooping in to help out as well. Solid catch, I think I slightly misunderstood how to the whole scene got put back together haha :sweat_smile: So after trying to add the meshes into the scene created by my null engine setup, the exported file is still blank. I am checking every step of the process, and the array of meshes I have chosen all get added to the scene, but for whatever reason they don’t seem to export. I searched the forum to see if adding meshes in a for-loop has caused problems, but couldn’t find anything.
This is how I have it set up so far, please let me know how else I can help articulate the issue I am running into. Thank you for all the help so far!

(custom type MeshWithUrl to add a url field on the AbstractMesh Object)
export const exportModels = (models: Array<MeshWithUrl>) => {
  // creates a scene from null engine and returns the scene+engine.
  let { scene } = createNullScene()

  // loop over each model in our array of meshes 
  for (const mesh of models) {
  // ISceneSerializableComponent was the only interface I could find that fit? 
  // Regardless, typed or not doesn't change the behavior.
    let serialMeshObj = {} as ISceneSerializableComponent

    let url = mesh.url

    let parsedMesh = Mesh.Parse(serialMeshObj, scene, url)

    // note: have tried with both recursive=true and false.
    scene.addMesh(parsedMesh, true)

    // just to quickly check its not empty.
    console.log(scene.meshes.length !== 0)

  GLTF2Export.GLTFAsync(scene, 'Mech')
    .then((gltf: GLTFData) => {
      let gltfInfo = gltf.glTFFiles
      console.log(gltfInfo) // checking to make sure there is actual stuff being written. 
    .catch((errWhy) => console.error('error exporting mesh: ', errWhy))

Here is a PG with a null engine:

Note that null engines will not export textures since it requires a webgl context to do it.


I appreciate all the help here, this has been fantastic info for moving our project along. Thank you!

1 Like