Since that’s the case, why not add the texture index in gltf after the texture name?
Sorry, I missed this message before for some reason.
Babylon.js caches the InternalTextures using its url
property, meaning there will not be two InternalTexture with the same url
.
Doesn’t the current url
property of the InternalTexture
object suit your needs? If not, can you explain in more detail what doesn’t work?
To try to make it unique? The glTF texture index will also not be unique since multiple glTF textureInfos are pointing to the same glTF texture. glTF textureInfos do not have indices since it is not in a separate array.
As mentioned in my previous comment, accessing the url only seems to work for gltf files, but it returns ...#imageN
for glbs.
I have updated my PG example to show you what I need.
“DESIRED TEXTURE NAME”: can be extracted from the parsed gltf data
“ACTUAL URL VALUE”: (internal)texture url value, that has no relation to the original file name
…so I’d just store this “DESIRED TEXTURE NAME” somewhere in the internal texture, probably in the _internalMetadata.gltf
.
Thanks for the PG, now it makes sense. I was thinking you were asking about the glTF texture name and not glTF image name. I think this can be stored on the Babylon InternalTexture. I was originally saying Babylon InternalTexture maps to glTF texture, but Babylon InternalTexture actually maps more closely to a glTF image.
I think we should do two things:
- Add a flag to set the glTF texture name or glTF image name or glTF url file name on the Babylon Texture object, noting that the name is not necessarily going to be unique.
- Set the
label
property of the Babylon InternalTexture to the glTF image name.
I think this will solve all the scenarios? Please give a thumbs up if this works.
You can try it
Here is the PR: Improve handling of texture names in glTF loader by bghgary · Pull Request #15709 · BabylonJS/Babylon.js (github.com)
Once the snapshot build is ready, can people try it and see if it works correctly for the scenarios?
thx a lot @bghgary
Works fine for me in general
Unfortunately the “label” value is not serialized, so this information won’t be available for .babylon files.
This is a bit of an issue as we are storing each 3d model upload as .babylon files on our platform. Also .babylon scene exports from the playground or sandbox won’t have this information set on their textures.
Do you think there is a way to serialize this data?
@Evgeni_Popov I think you added the label
property. Any objection to serializing this?
No objection, it was added at first only for debugging purpose, but we can use it as a general label if we want.
I’ve updated the PR to serialize the label. Let me know if it’s working properly for you.
@bghgary just tested it, works fine for me
Great, thanks for testing! It is now merged.