Hello everyone.
I’m trying to apply A SimplifyModifier to an object, but when I applied the mesh goes crazy and gets all the materials removed.
Plus it does not apply any modifier to the mesh.
Pink avatar = Original
Black avatars = SimplifyModifier applied
This is how I’m trying to do it:
gltfLoader.load("avatar.gltf",(obj)=>{
const model = obj.scene;
model.traverse( ( child )=>{
if ( child.isMesh ) {
const modifier = new SimplifyModifier();
const count = Math.floor(child.geometry.attributes.position.count * 0.7);
child.geometry = modifier.modify(child.geometry, count);
child.material.envMap = envTexture;
}
});
});
What else have I tried?
- To create a
new THREE.Mesh()
with the simplified geometry, instead of replacing it and assigned it to the original structure. But same behaviour happens, it does not get modified and it becomes material-less. - I tried to apply this same modifier to a much simpler mesh, because I thought that it could be a problem using a SkinnedMesh. But same behaviour happens, it does not get modified and it becomes material-less.
What could I be doing wrong? Am I missing something?
Thank you in advance.