Removing __root__ from Nodes hierarchy in .glb file

Hello there,

I have imported a .glb file and by default a _ root _node is included with the export. Now following this tutorial closely Demystifying Animation Groups - YouTube, I am trying to use the setParent(null) trick to remove the _ root _ node, but I have run into a few problems and have some questions.

  1. setParent doesn’t seem to be a method for a Node object anymore, at least I can’t find it in the documentation. I tried to use getChildMeshes() instead, but the “actual” root node after _ root _ is a TransformNode, so I think it implicitly skipped and doing getChildMeshes()[0], just leaves me with the first mesh of my model and not the Transform node (which is the actual root of my model) . s this intended or can I somehow still call setParent(null) on a node, which will leave the Transform node structure of my project as it is.

I hope this question is clear and thank you for any help provided.

Sorry the question isn’t 100% clear to me yet, do you have a minimal example you can share with your .glb file? Are you using typescript? If so then you might find you can use a type predicate to narrow Node | TransformNode to TransformNode that has the setParent method?

Yes I am using TypeScript, but I am still a beginner so I didn’t know that you could narrow the type like that, but that fixed my problem and I was able to remove _ _ root _ _ as intended thx:smile:

Maybe a follow up to this, it seems the animation of my model runs a lot smoother now, does removing the _ _ root _ _ have something to do with that?

Also, is there any guidance on setting up a minimal example? I know there is the Babylon Playground, but right now I am running a vue project with a separate classes for my objects, is the createScene() function all I need?

Thanks again!

Searching for “vue” on the forum here gives out quite a few examples :slight_smile: A Vue into 3D with Babylon JS - Demos and projects - Babylon.js

1 Like