2 years ago

#50260

test-img

Hopoduck

threejs change object and animating

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?

three.js

webgl

gltf

fbx

0 Answers

Your Answer

Accepted video resources