Hiding Blender's Empty and children (isEnabled problem)


I’m importing a very simple glb when one sphere is the child of an empty.

In the great Scene Explorer, I noticed that when I select the empty (C1), I can turn isEnabled false to make it disappear (including its child).

I searched found this example for hiding/showing action:

I replicated lines [66;68] and it works for the spheres but not for the empty… or maybe the empty disappears but not its child.

scene.meshes[0].setEnabled(false) // works only for meshes

So, I know it is possible (I did it in the Scene Explorer) but I am currently not been able to do it.

Any idea?

well can you repro in the PG? it should work

– see comments —

I get “root” when using scene.meshes[0].name but I get “CubeA” and “CubeB” when doing scene.meshes[1 or 2].name. Looks like “root” and other meshes are on the same level… weird.

However, scene.meshes[0].setEnabled(false) hides everything.

For now, the only way I access C1 (the empty parent of CubeB (subdivided Blue Cube)) and hide it is by doing this: scene.meshes[0]._children[0].setEnabled(false) I was told that I shouldn’t use private variables (_children) but I can’t find an alternative.

Any ideas?

why not relying on scene.getTransformNodeById in this case, it will actually ensure you will have the correct one ?

Thank you! It works!

There’s still something strange (or that I don’t understand) in the scene hierarchy but using getTransformNodeByID solves it.


I updated your playground to use Seb’s solution so that future people can see what it looks like. Thanks for helping to contribute to Babylon documentation!



Thank you. I made a little change to make use of the variable you declared (nameOfTransformNode).



Great catch! Sorry for missing that.