Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hello! I saw this feature in the Pandako extension (A3F). You can try using his code.


let MakeUniqueMaterial = function(Obj3D) {
if (!Obj3D.userData.A3F) {
Obj3D.userData.A3F = {};
}
if (!Obj3D.userData.A3F.UniqueMaterial) {
Obj3D.userData.A3F.UniqueMaterial = true;
//
Obj3D.addEventListener("removed", gdjs._A3F.DisposeUniqueMaterial);
//
const CopyMat = {};
Obj3D.traverse((Child) => {
if (Child.material) {
if (Array.isArray(Child.material)) {
for (let i = 0; i < Child.material.length; i++) {
if (!CopyMat[Child.material[i].uuid]) {
CopyMat[Child.material[i].uuid] = Child.material[i].clone();
}
Child.material[i] = CopyMat[Child.material[i].uuid];
}
} else {
if (!CopyMat[Child.material.uuid]) {
CopyMat[Child.material.uuid] = Child.material.clone();
}
Child.material = CopyMat[Child.material.uuid];
}
}
});
}

};