Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorder dedupe property types #663

Merged
merged 2 commits into from
Dec 21, 2022
Merged

Conversation

robertlong
Copy link
Contributor

By deduping meshes after textures and materials you're more likely to be able to deduplicate more meshes.

@donmccurdy
Copy link
Owner

Thanks @robertlong! I think the unit tests for this feature predate the addition of material deduplication (in f69517b), and the unit test expects mesh deduplication to fail for two materials that differ only in name:

test('@gltf-transform/functions::dedup | meshes', async (t) => {
const io = new NodeIO();
const doc = await io.read(path.join(__dirname, 'in/many-cubes.gltf'));
const root = doc.getRoot();
t.equal(root.listMeshes().length, 501, 'begins with duplicate meshes');
dedup({ propertyTypes: [PropertyType.ACCESSOR] })(doc);
t.equal(root.listMeshes().length, 501, 'has no effect when disabled');
// Put unique materials on two meshes to prevent merging.
root.listMeshes()[0].listPrimitives()[0].setMaterial(doc.createMaterial('A'));
root.listMeshes()[1].listPrimitives()[0].setMaterial(doc.createMaterial('B'));
dedup()(doc);
t.equal(root.listMeshes().length, 3, 'prunes duplicate meshes');
t.end();
});

Do mind updating the test to ensure that (1) meshes sharing materials that differ only in name WILL be deduplicated, and (2) meshes sharing materials that are meaningfully different WILL NOT be deduplicated?

@donmccurdy donmccurdy added feature New enhancement or request package:functions labels Aug 18, 2022
@donmccurdy donmccurdy added this to the v2.4 milestone Aug 18, 2022
@robertlong
Copy link
Contributor Author

Sounds good, I'm also noticing that there's a bug de-duping materials+meshes in Third Room right now so I'm looking into that first

@donmccurdy
Copy link
Owner

@robertlong Would it be ok for me to merge this? Or do you think the bug in Third Room is related to this change?

@robertlong
Copy link
Contributor Author

The bug was unrelated. This should be safe to merge 👍

@donmccurdy
Copy link
Owner

Ok, thank you!

@donmccurdy donmccurdy merged commit 0bea58e into donmccurdy:main Dec 21, 2022
@donmccurdy donmccurdy modified the milestones: v2.4, v2.5 Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New enhancement or request package:functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants