Hi,
the “Tags” concept from Babylon.js is a very central piece for our Combeenation configurators for marking and grouping meshes and materials.
However the API for tag handling leaves some room for improvement I would say.
Whilst we could easily create a wrapper around it to adapt it to our needs, I’ll pitch some of my thoughts here, as other projects could benefit as well.
Availability and Typescript support
Seems like there are 2 ways of using tags:
Tags.HasTags(obj)obj.hasTags()
The second approach is definitely the more intuitive one.
However the _tags property and all the functions (e.g. hasTags) are not available as typing, since they are injected on runtime via the Tags.EnableFor function.
From an API user perspective I’d suggest to create an interface with all these functions and automatically enable tags for all Node types.
I like to compare tags with metadata, and metadata are available for all Node types as well.
One would lose the optimization strategy of lazy loading the tags content, but I’d say that the advantages outweigh.
Set / remove all tags
The API provides some neat functions for adding and removing tags to the existing tags object, but if I want to wipe or exchange the whole tags object, it gets a bit clunky, as I need to get the tags first before I can add them as parameter of the Tags.RemoveTags function.
Depending on the outcome of the topic above, one could just provide setter and getter for the _tags object itself, making a full overwrite possible very easily.
Format
It’s quite hard to understand if one is working with tags as string, object or array.
I’d say a representation as array would make the most sense though.
I haven’t figured out why the object format has been chosen, as the props are always true.
There is no API to set a tag to false and I’d say one would just use the Tags.RemoveTagFrom function in this case.
Getting tags as array is a bit tricky concerning compatibility though, but maybe the new tags getter could help out here.
Convenience functions for asset container
Scene function scene.getMeshesByTags or scene.getMaterialsByTags are really cool.
However we work a lot with a AssetContainer, as it’s the representation of an uploaded model on our platform.
So could we add these functions for asset containers as well?

