1

My character is wearing glasses and I want to replace them with glasses of a different model. The replacement part was successful, but the animation of the glasses part works strangely. Animation used mixamo.com.

    const glasses = this.resources.items.glasses2.children.filter((m) => m instanceof Mesh)[0]//.scene.children[0].children[1];
    this.char3.instance.traverse((m) => {
      if (m.name === 'glasses') {
        m.geometry.dispose();
        m.geometry = glasses.geometry.clone();
        m.geometry.scale(0.000263, 0.000263, 0.000263);
        m.geometry.translate(-0.03, -0.05, 0.02);
        m.geometry.needsUpdate = true;
        m.material = [glasses.material[0].clone(), glasses.material[1].clone()]
        m.material.needsUpdate = true;
        m.updateMatrix();
      }
    })

working img

error img

The direction of movement seems to be opposite. Is that right? If yes, how do I fix it?

Hopoduck
  • 21
  • 3
  • Maybe the glasses are attached to the wrong bone in the model? I'm just guessing. It looks like maybe they're following an upper-back bone or something, instead of a head bone. – emackey Jan 14 '22 at 14:42
  • @emackey Thank you. I think you're right. I only changed the geometry and material from glasses. Why is that? – Hopoduck Jan 17 '22 at 01:23
  • At first, I tried to change only the geometry that Mesh kept the shape, but I changed the direction due to the above error. There is skeleton in the model, and the mesh was added as a child to the corresponding headbone to make it work. it works well. – Hopoduck Jan 17 '22 at 03:12

0 Answers0