In the babylonjs documentation, I found an example that exclude one mesh in the export. What would be the best way to select multiple meshes to be excluded in the options array?
// Initializer code...
let skybox = scene.createDefaultSkybox(hdrTexture, true, 100, 0.3);
// scene setup code...
let options = {
shouldExportNode: function (node) {
return node !== skybox;
},
};
BABYLON.GLTF2Export.GLBAsync(scene, "fileName", options).then((glb) => {
glb.downloadFiles();
});
One way that’s pretty straightforward IMO is to create an array of excluded nodes and then just use indexOf() to test if the node should be exported like below.
let excludedNodes = [];
let options = {
shouldExportNode: function (node) {
return excludedNodes.indexOf(node) === -1;
}
};
Just one more question. When I export the scene excluding all meshes, there is a validation problem in my scenario and I see that still there are some cameras in it
{
“uri”: “fileName.glb”,
“mimeType”: “model/gltf-binary”,
“validatorVersion”: “2.0.0-dev.3.5”,
“validatedAt”: “2022-03-22T03:26:31.129Z”,
“issues”: {
“numErrors”: 2,
“numWarnings”: 0,
“numInfos”: 2,
“numHints”: 0,
“messages”: [
{
“code”: “TYPE_MISMATCH”,
“message”: “Type mismatch. Property value null is not a ‘number’.”,
“severity”: 0,
“pointer”: “/cameras/1/perspective/yfov”
},
{
“code”: “UNDEFINED_PROPERTY”,
“message”: “Property ‘yfov’ must be defined.”,
“severity”: 0,
“pointer”: “/cameras/1/perspective”
},
{
“code”: “UNUSED_OBJECT”,
“message”: “This object may be unused.”,
“severity”: 2,
“pointer”: “/cameras/0”
},
{
“code”: “UNUSED_OBJECT”,
“message”: “This object may be unused.”,
“severity”: 2,
“pointer”: “/cameras/1”
}
],
“truncated”: false
}
}
Hmm I’ve never tried exporting to gltf with everything excluded, IDK what’s up with the exported camera and errors, but @bghgary is the gltf guru to ask I think.
In this case I excluded everything from export but I cant dispose it because I need to post process it. I also excluded camera and light nodes.Is there any other thing to exclude beside nodes?