The objects received from TopSolid are not always loaded in the same order, which is problematic to rebuild the tree.
On the link, try to reload the page multiple times and you will see that the Ensembles tree order changes. Or look at the order in the console
I don’t think I fully understand the situation, but regardless in which orders objects come in, the viewer will always respect the original hierarchy when building it’s tree. If you need a particular structure/hierarchy, you will have to create one at host-app level.
But maybe if you explain why the order of the object is important for your particular use case perhaps we could assist in less obvious ways
Why order is important to us:
In TopSolid, there is an important BIM concept called sets. An entity (point, axis, sketch, etc.) can belong to one set, no set or several sets. Sets can also contain sub-sets, sub-sub-sets and so on. They form a tree in TopSolid that we want to reproduce in the viewer. @ahmedwael94 sent me these sets (the top-level ones) from TopSolid at the same level as the entities, with an isSet property so that I could find them in the world tree. They don’t contain the entities directly, but references to the entities. (so that if a sketch belongs to several sets, you only send it once).
Then I rebuild everything from the children of these sets.