donmccurdy/glTF-Transform

Add Merge Materials

zhaoyuanmeng opened this issue · 3 comments

Optimize materials by finding and removing identical duplicates. If multiple materials have the same properties, only one will be kept.

I have a very large bim5 data imported into glb data, because bim5 builds too many objects, causing the browser to load too slowly, want to achieve the same material batch operation to reduce draw call, thank you

Hi! I think that the dedup() and join() functions will together do what you're after.

Examples:

import { dedup, flatten, join } from '@gltf-transform/functions';

await document.transform(
  dedup(),
  flatten(),
  join()
);
gltf-transform optimize input.glb output.glb --no-compress

Thank you. I'll have a try!