Name is defined in GLTF spec as Any top-level glTF object MAY have a name string property for this purpose. These property values are not guaranteed to be unique as they are intended to contain values created when the asset was authored.
In some exported GLTF files, name can exist in both textures and images like:
When using Babylon.js internal GLTFLoader, the name of loaded texture is set like this:
And name of GLTF’s texture or image is lost.
Playground Example
The file is silghtly modified from BoxTextured.gltf from glTF-Sample-Models.
Proposal
Add an option, statically or instance-bound, to make GLTFLoader prefer to use original texture or image name as name of loaded texture whenever possible, which could has false by default to keep backwards compatibility with existing code.
We need to consider that a glTF texture is not a Babylon texture.
Here is how the mapping goes:
glTF textureInfo → Babylon.js Texture
glTF texture → Babylon.js InternalTexture
glTF image → no equivalent
glTF textureInfo is not a top-level glTF object with a name. Multiple glTF textureInfo can point to the same glTF texture. Multiple glTF texture can point to the same glTF image.
Maybe storing a name on the Babylon.js InternalTexture would work?
@bghgary I’m facing a similar topic and so I’m very interested in the state of this feature request.
Is the state visible somewhere in the forum entry?
If not, could you please give me a personal update?
This thread died after my post, so we haven’t done anything with this. If we want this done, it would be good to file a feature request on GitHub and we will see if we can sneak some time to do it.
I don’t know what you mean by data or pointer. If you want to access the glTF JSON object, this is available with the onParsedObservable.
@bghgary thx a lot for the response.
Seems like onParsedObservable is all I need anyway.
I saw that the gltf texture path is stored in the Babylon.js textures _internalMetadata, so I should be able to reconstruct the original file name from there.