Howto to traverse scene nodes?

Hi,
Is there an existing function that traverse a whole gltf loaded scene.?
I need to hide nodes based on their name.

Regards
S.Ancelot

you can use rootNote.getChildren() to get a list of children, or getChildMeshes() to get meshes

The API:

and

Both allow you to get the direct descendants or all of them, which can allow you to build your own tree or get all of the root’s children. You can also define a predicate to filter what node will be included.

2 Likes

You can also traverse scene.rootNodes / scene.transformNodes / scene.meshes depending on your needs.

1 Like

Hummm… rootNodes is empty in contianerAssset !

sorry, rootNode was just an arbitraty name of, well, the root node of your model :slight_smile: If your model is loaded, the first mesh that is returned from loadMesh or from the assets container is usually the root node, which is the parent of all others.
If you want to share a playground with your attempts we can explain better

No, I was talking about this variable, that is empty after loading the containerasset
AssetContainer | Babylon.js Documentation (babylonjs.com)

want to show your scene in the playground? will be easier to explain why it is empty.

1 Like