When we export a scene via GLTF2Export.GLTFAsync, dynamic textures that are not in use by any exported nodes show up in the exported files (referenced in the GLTF and listed as png’s). Note: they might have been referenced by nodes that were filtered out using the shouldExportNode options filter.
Is there a way to filter unneeded dynamic textures out of the exported GLTF?
Currently, the exporter exports all materials in scene, pulling all referenced textures with them, then links the material to each exported mesh, but it should be fairly straightforward to add a method that allows the user to exclude materials from the scene similar to: IExportOptions - Babylon.js Documentation where we export the scene contents by default, and let the user manually define which meshes should be ignored.
Otherwise the alternative is to dispose of the materials with textures that you don’t need exported, which isn’t super ideal if you want to use them later.
Having a need of exporting select meshes, i found myself hacking away as i’ve had no time to look at the source yet.
final result was this process;
Export to babylon data string
Create new empty scene & import babylon data string
Export new scene to gltf or glb
so for me at least, the ability to export an array of meshes & their connected materials & textures would be great
Either way, it’s no problem if you guys don’t feel it’s worth including in source, i’ll get around to a local fix eventually
Sorry for hi-jacking the thread
those snippets should definitely give you what you need regarding mesh selection at export, no need to go through the scene serializer if you can avoid it. The materals/texture removal will need some additional feature work, but I don’t quite have the time to take that on right now.
But I definitely agree a couple switches like “IncludeChildren” and “IgnoreUnused” to add to the export options would be really useful