When I import a GLTF/GLB asset in my scene by means of BABYLON.SceneLoader.ImportMeshAsync, the importer automatically put all the contents under a regular/mesh node (named “root”) retrievable by result.meshes[0]:
The case is that I find more “semantic” to use there a Transformation Node, isn’t it? I mean the aforementioned root nodes being transform nodes.
Also, talking now about functionality, a TransformNode: “… can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent …” (abstract from Docs).
Any advice about not doing so?
How can I change programmatically, in a direct way, the root nodes to Transform Nodes?
TL;DR: Yes, it should be a TransformNode. Can we change it? Not practically. It will break too many contracts.
Transform nodes were introduced relatively late compared to SceneLoader, glTFLoader, etc. Before we introduced transform nodes, the only way to create a parent node to hold child nodes was to use an empty mesh. This is what we did for the glTF loader back then. We then decided that the first abstract mesh returned by the loader must be this root mesh.
Once we introduced transform nodes, there was a backwards compatibility issue. We couldn’t just change it to a transform node since the contract requires the first abstract mesh being returned to be the root node.
First, as always, thank you very much for your immediate response. That’s really appreciated.
About the history you are bringing here, your explanation is very illustrative of the difficulties involved in each software engineering effort, in terms to (try to) fulfill a future-proof design.
This said, what’s your opinion? Leaving peace of mind of using the “correct” node type aside, is it worth to switch to the transform node (with the aid of the code you’re providing) in terms of performing or not?
We can perhaps add a flag to do this or a helper function, but are you sure this is going to help? I haven’t seen any performance issues relating to this.