Created
October 25, 2021 23:56
-
-
Save MrMagicPenguin/db149a701f6e36fade56349884756238 to your computer and use it in GitHub Desktop.
Remove duplicate materials from objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Document} from "@gltf-transform/core"; | |
export default function DedupMaterials(document) { | |
const root = document.getRoot() | |
const root_mats = root.listMaterials() | |
root_mats.forEach((mat) =>{ | |
if (mat.getName() === root_mats[0].getName() && mat !== root_mats[0]){ | |
mat.detach() | |
mat.dispose() | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment