GLTF2 exporter ignores childless nodes in the scene hierarchy
See original GitHub issueBug
The GLTF2 Exporter seems to be ignoring any Mesh
or TransformNode
that does not have children in the scene hierarchy before exporting/serializing the scene.
Here is the line of code that seems to be responsible for this behaviour: https://github.com/BabylonJS/Babylon.js/blob/v4.0.0/serializers/src/glTF/2.0/glTFExporter.ts#L1342
Problem
This can be troublesome as sometimes it is useful to have an empty transform that stores a location (for example a spawn point for a prefab instance, a player, etc) or an orientation, etc. I’m not sure if this is something that is necessary because of the way the GLTF specs are, if it is I would be glad to know more about this subject.
Notes
The repro code in the Babylon Playground creates two sets of Mesh
and TransformNode
instances. If you export them and reimport them in the Babylon Sandbox for example, you will noticed in the Inspector that the nodes without children have been ignored at export-time.
These instructions can also be found in the repro playground:
NOTE: To export to GLB:
1- Select the GEAR icon in the Babylon Inspector toolbar above
2- Select Inspector in the displayed menu
3- In the Inspector panel that should have opened to the right, select the WRENCH icon.
4- In the SCENE EXPORT section, select Export to GLB
5- Load the downloaded file in https://sandbox.babylonjs.com/ by dragging it in the middle of the scene.
6- Open the Babylon Inspector at the bottom of the window
7- Expand the + Nodes section
8- Notice that only meshes and transform nodes that have children haven been exported
Versions
Tested in BabylonJS 4.0.3, seems to also be occurring in latest version (master branch).
Playground
- Bug repro on playground
Expected result
Exported scene should have all the meshes and transform nodes regardless of if they have children or not?
Current result
Any Mesh or TransformNode without children will be ignored when exporting to GLB
Workaround
It seems like an easy workaround would be to add a temporary child mesh to the meshes we wish to preserve.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (10 by maintainers)
Top GitHub Comments
Well this is more a bug so no worries for backward compat
@osmanzeki fancy doing a PR to fix it?