Problems with GLTF2Exporter from @babylonjs/serializers

Hi, I’m having trouble using the es6 serializer module “@babylonjs/serializers”

Firstly, I’m getting a type mismatch error between the scene object between the serializers and core modules;

TS2345: Argument of type 'import(".../app/node_modules/@babylonjs/core/scene").Scene' is not assignable to parameter of type 'import(".../app/node_modules/@babylonjs/serializers/node_modules/@babylonjs/core/scene").Scene'.
Types of property '_inputManager' are incompatible.
Type 'import(".../app/node_modules/@babylonjs/core/Inputs/scene.inputManager").InputManager' is not assignable to type 'import(".../app/node_modules/@babylonjs/serializers/node_modules/@babylonjs/core/Inputs/scene.inputManager").InputManager'.

Secondly, if I use //@ts-ignore as a temporary fix - it produces a file, but it doesn’t contain any geometry. Which I suppose I could have anticipated.

I get a load of console logger messages saying that each material is not supported, even though they are just PBRMaterials and StandardMaterials.

Upon opening the downloaded file, it appears that it has saved the object transform data for the various meshes/transformNodes in the scene, but no geometry.

If I use GLBAsync it produces a glb with only the transform data, if I use GLTFAsync it produces a gltf file with the transform data and an empty .bin file.

I can’t post my whole file as it’s part of a massive project, but I’m not doing anything particularly unusual I think;

import {GLTF2Export} from '@babylonjs/serializers/glTF'
... lots of code...
ExportScene(){
    // @ts-ignore
    GLTF2Export.GLBAsync(this.scene,'test').then(res=>{
      res.downloadFiles()
    })
  }

So, typescript errors, materials not recognised, and no geometry

Any ideas / pointers? Is there something else I should be importing that’s being missed?

.../app/node_modules/@babylonjs/serializers/node_modules/@babylonjs/core/scene seems suspicious, with a leading triple dots and a node_modules inside another node_modules directory… I think there’s a problem with your setup. Maybe @sebavan will know more.

Sorry I manually truncated the paths on my error output for the sake of clarity… obvs didn’t work out how I planned. Here’s the full output;

ERROR in /Users/martinalcock/sites/3DViewPro/app/src/editor/Editor.ts
./src/editor/Editor.ts
[tsl] ERROR in /Users/martinalcock/sites/3DViewPro/app/src/editor/Editor.ts(170,26)
      TS2345: Argument of type 'import("/Users/martinalcock/sites/3DViewPro/app/node_modules/@babylonjs/core/scene").Scene' is not assignable to parameter of type 'import("/Users/martinalcock/sites/3DViewPro/app/node_modules/@babylonjs/serializers/node_modules/@babylonjs/core/scene").Scene'.
  Types of property '_inputManager' are incompatible.
    Type 'import("/Users/martinalcock/sites/3DViewPro/app/node_modules/@babylonjs/core/Inputs/scene.inputManager").InputManager' is not assignable to type 'import("/Users/martinalcock/sites/3DViewPro/app/node_modules/@babylonjs/serializers/node_modules/@babylonjs/core/Inputs/scene.inputManager").InputManager'.
      Types have separate declarations of a private property '_alreadyAttached'.

It looks like you might have inconsistent version of the babylon libraries. Could you check that you have all of them at the same version ?

Yeah they’re all set to 4.2. I’ll try clearing node modules and reinstalling everything see if that helps

Martin Alcock
0780 941 2211

Would be great if you could share in a github project somehow ?

I’ll try and build a minimal example project this evening and share it

1 Like

Hmm… So I built out a really minimal example, while keeping things as similar as possible… and it works!

That doesn’t really help my main project I guess, but it’s a start I suppose.

I’ve tried clearing out my node_modules folder and re-running npm install, but no joy

I guess I’ll just keep digging :confused:

so probably smthg unsupported in your scene from the serializers

I deleted node_modules and package-lock.json and reinstalled… and it works!

I just have a weird typescript error around EventEmitters to solve now that I didn’t have previously, but that’s outside the scope of this forum. Thanks for your patience!

I’ll go away and see if I can solve my remaining problems

2 Likes