vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
475 stars 75 forks source link

[Feature request] Export image with its name rather than just the GLTF's name + number #220

Open MeltyPlayer opened 7 months ago

MeltyPlayer commented 7 months ago

One small issue I've noticed with SharpGLTF is that it exports satellite images as [GLTF name]_0.png, [GLTF name]_1.png, etc. rather than using the name passed into ImageBuilder.Name. I noticed that this is because of the following line in the export logic: https://github.com/vpenades/SharpGLTF/blob/ec39f0f7fb210f45a8bb68b75d32b41998f654bf/src/SharpGLTF.Core/Schema2/Serialization.WriteSettings.cs#L389

I was hoping to request that the actual name be used instead, only falling back to the number approach if the name(s) were null.

vpenades commented 7 months ago

This is not as trivial is it might look.

The reason because the library renames the images is because there's case scenarios (embedded images) where the texture file names are lost, and the library needs a unified way of handling texture names on export for all cases.

In fact, the code line you highlighted, and depending on the context, there is no guarantee to have texture file names at all.

it is doable for the use cases when texture names do exist, but it would require a case by case solution.