How to change order of children in parent BABYLON.Node?

Long story short, how can I change the order of the children in a parent node.
I have BABYLON.Node#getChildren() and BABYLON.Node#_children and I am currently doing

bNode.parent=bModuleParent;
bNodeParent._children.splice(position, 0, bNode);
bNodeParent._children.pop();

First line sets the parent. Second the third change the order of the children in the parent. But I am looking for something more “public” to do this change. Order of nodes for me is important as source document is coming from one system and continuing to another.

Unfortunately we are not exposing it beause the engine makes some assumption regarding the list and it is not recommended to change the order.

That being said, why not having your own list on a mesh? You can just add a new array on the mesh and store the children the way you want

Will this list be exported in this order in GLTF?
I need to Load, Change Order, Save. Load again and be in the same order

Or I could have the order as a property of the metadata, but it would be much cleaner to use the Babylon order

I forgot to mention i am not changing the children of the mesh. I am changing children of a Node that is just a node. Not a mesh.

Well so in this case your solution is the best :slight_smile:

Thanks @Deltakosh.

Just to confirm that I understand correctly :slight_smile: since I have two solutions in my mind.

  1. Using babylon _children order for keeping the order of the nodes -> much cleaner for me as the order is already there. But I need to have “public” access to property “_children” and to have an understanding that it is ok to use this order and that it will be exported in this order in GLTF and babylon format.

  2. Use a custom metadata property that I will put in the “.metadata” that would give me the order.

I would pick 2 if that works for you