Hi all
Currently we use the command
BABYLON.GLTF2Export.GLTFAsync(scene, “marbleTower”).then((gltf) => { gltf.downloadFiles();
to export a mesh assuming that it is the only mesh in the scene.
If I have many meshes in my scene, can I filter/choose which mesh to export?
When exporting it also includes textures from the excluded mesh. Isn’t this unnecessary?
Also, in the options can I specify an array of meshes?
Finally, it seems OPTIONS is an exclusion, not an inclusion, ie: if I want to specify the gltf mesh to be exported doesn’t seem to work
let options = {
shouldExportNode: function(node) {
return node == fan;
}
Hey, just stumbled upon this asking the same question. My go to solution is to just parent everything you don’t want to a Node (mine is just called ‘exclude’), then just have return node !== exclude;
Regarding exporting materials not used by the exported objects, The playground you posted doesn’t appear to include those materials or their textures, either. Looking at the code it doesn’t seem apparent how this bug could happen, It definitely could have been fixed sometime along the way, however.
Feel free to update with a playground that does reproduce this, and I can take a closer look .
Hey @Drigax, this is something i’ve seen too.
unused materials/textures are exported, but not loaded.
Pre-export scene contains
mesh - plane
mesh - sphere
mat - grass material
mat - sphere material
tex - grass.png
plane.material = null;
exported only plane to gltf, using exluded geometry option
scene.gltf contains info about both materials and the texture, also downloads the grass.png file together with the gltf & bin files. scene.zip (736.8 KB)
I’m curious to see what the issue is. If I export a glb following the documentation I have the same material issues, whereas exporting from the Sandbox doesn’t seem to do that. Thanks for tackling this @Drigax