Not sure if I should post here or in the general question so please excuse me if you think this is not the right section.
I’m working on an architectural visualization tool and exporting my model from 3dsmax to gltf with the Babylon exporter. I’d like to use tags so I can easily find objects in Babylon.
I tagged a few objects in 3dsmax as “unit”. The 3d loads fine in Babylon but when I call scene.getMeshesByTags(“unit”); it returns an empty array.
I opened my gltf file and it seems like the tag is properly exported there on the objects I tagged: “extras”:{“tag”:“unit”}}.
I tried to create a box within babylonjs and tagged it with the addTags function. If I use getMeshesByTags after that it does find my box so I’m thinking there might be a problem with my gltf.
Has anyone tried to use tags with gltf from 3dsmax and did you run into any troubles?
Hi @christopheC. Are you importing your glTF asset into Babylon.js and trying to filter on tags, or are you importing a .babylon asset. If the former, I am not sure if the glTF loader handles extras data as tags or not. @bghgary may be able to confirm this.
Have you tried importing a .babylon file to see if that works ?
No, the loader does not load extras without user code. There is not a 1-to-1 mapping between the glTF hierarchy and Babylon, so this is up to the user to handle it in a loader extension. I can show how this is done in a playground if I can get an asset with tags.
@kcoley yes I’m importing my gltf into babylon.js and trying to filter on tags. I also thought that it could be a tag support issue from gltf vs babylon files but I also tried to export as babylon file format and didn’t have more luck.
@bghgary I was trying to put together an example in the playground but I can’t get the gltf to load my file in the playground. I think it’s a problem with the server I’m using to host my file… I need to look more into that.
Anyways, I have saved out a file with tags that you can use for testing purposes. It’s not the one I’m using in my project as it would be too big. There are 4 geometries in that file, two of them are tagged “Unit” and they are the ones I’d like to get with getMeshesByTags.
I saved it as gltf and babylon if you’d like to see the difference. https://we.tl/t-JIGIbEMjnA
@christopheC looks like the exporter is exporting the tags as “tag” instead of “tags” in the babylon file, which is a bug. I’ll work on a fix for that.
digging up an old topic. I’m still using tags with gltf but it does seem like tags either don’t export or at not recognized in Babylon if the object has a multi material with multiple Ids in 3dsmax assigned to it. Is that the correct behavior?
that doesn’t sound like proper behavior. I would expect an object with tags should export with the tags regardless of the type of material used for it. Can you share a scene that reproduces this?
Sorry i disappeared for a bit and just used a workaround to make my app work. Now that I have more time I can share with you a playground scene. https://playground.babylonjs.com/#CNQ1YU
I created two boxes in 3dsmax, one with a multi sub material element (2 IDs) and one with a regular material. When going through objects only the one with the regular material returns something when I call BABYLON.Tags.HasTags()
Also, I always have to use the tagsExtension for tags to work, is that going to always be the case and is just a trick for me or will this eventually be implemented in Babylonjs?
Ah, I see. it looks like when we import the multi material mesh, we split it into two separate primitives, while the tags are on the parent transform node:
Which is technically correct, but I don’t know if this is ideal… @bghgary do you have any thoughts regarding this? Do we want to propagate the tags to the primitives?
currently we have a glTF mesh containing tag data in its extras.
On export, that glTF mesh is split into multiple primitives, which are represented as Babylon Meshes while the extras data only lives on the parent TransformNode.
Our API doesn’t seem to elegantly expose a way to query all TransformNode derived objects in scene by tag.
Currently, @christopheC is querying all imported meshes in scene for the supplied tag , which doesn’t result in retrieving the split meshes.
Currently, i can see our possible solutions by either: 1) we can spotfix this by propagating our extras data to the primitives when we need to split them by material
or
2) we provide a “get node/TransformNode by Tag” that would support such a usecase.
Ultimately i think we’re running into a situation where babylon’s concept of a mesh isn’t quite equvalent to glTF’s concept of a mesh.