Exporting multiple meshes changes their parent

Hi, I am trying to export a model, that has over 200 meshes. 202 of these meshes have one empty unity 3D object as a parent. But when i export it, and try to access the parents children, I only get half of the meshes (only the odd ones). After some investigation i found the rest of the meshes (the even ones), under a Group type object with same name. Is this intended or a bug ? And if it is intended, how do i know, what parent will be the second half of the meshes have (ussually the even ones)?

Hi Vydymil,

The behavior you’re experiencing during the export of multiple meshes, where meshes appear under a “Group” object rather than their intended parent, may not necessarily be a bug. It’s common for exporters to optimize or change the hierarchy to ensure compatibility with the output format.

To understand more about how this hierarchy is managed and which parent your even-numbered meshes are assigned to, you can check the export options and settings in your export script, particularly the filtering of objects and how they are grouped.

In the GltfExport class, look into the export method where it manages the objects to be exported:

// Example where filtering of parents may occur
objectsToExport.forEach(obj => {
    exportScene.children.push(obj);
});

This section can be adjusted if needed to ensure your desired hierarchy is respected.

To predict or control what parent the remaining meshes will receive, you’d likely need to implement logic within your export routine that maintains the original hierarchy based on the indices of meshes during the export process.

For additional assistance, consulting the exported files directly or debugging how the export routine handles parent mappings can provide more targeted insights.

If you continue to have issues, consider checking for updates or known issues in the official documentation or changelogs related to hierarchy management during exports which may provide more guidance (see the documentation).

Feel free to ask if you need any specific adjustments to your code or further clarifications!

3 replies left
thread_mLWZRxwDuX8XQFRqSWBPJvJr
Reply to this message to continue the conversation

Hi this is how multimaterial objects (youll see all objects that become a group have multiple materials in unity) get built in the three.js GLTFLoader and is normal behaviour.

What you can do to make sure to get the correct objects is to query for the Renderer components and then get their gameObject reference (that is the Object3D)

Okay, thanks for the info.