Parenting GLTF/GLB content with a Transformation Node instead a Regular/Mesh Node

Hi there:

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]:

image

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?

Thanks for your time.

That is actually a pretty good question, @bghgary ???

It’s time for a history lesson. :slight_smile:

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.

It’s not exactly direct, but it’s somewhat close.

PG: Babylon.js Playground

Hi there, @bghgary:

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?

Best regards.

1 Like

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.

Hi there, @bghgary:

Ok, I see.

Certainly in that case is only a matter of being picky about the “look” of the node-tree, mainly when you’re using a lot the Inspector.

Thanks for your time.

1 Like