0

My goal is to attach separate objects (eg: wearable items) to an animated model, so that the bound objects are controlled by the models animation.

I have found these, but all seems outdated.

I experimenting with a character imported from blender that is skinned & rigged & animated.

My problem is: As I add a new mesh to a specific bone of the model (the commented out part in the code), the current animation clip is switched to the first one (t-pose), and the skinning get broken (model turns white). However the object is connects to the bone, and moves with it.

const {scene, animations} = await Utils.loadModel('model/someName.gltf');
const model = scene.children[0];

const material = new THREE.MeshBasicMaterial();
material.alphaTest = 0.5;
material.skinning = true;

model.traverse((child) => {     
    if (child.material) {
        material.map = child.material.map;
        child.material = material;
        child.material.needsUpdate = true;
    }
    if (child.isBone && child.name === 'RightHand') {
        // child.add(createMesh());
    }
});

gScene.add(model);

It dosen't work correctly, even if a simple cube is added, but it would be nice if I could add boots to a character, that is moves as its foot.

Tamás Katona
  • 683
  • 7
  • 13
  • What you're describing should work fine, but there isn't enough information here for us to reproduce the problem and find out why it isn't working in your example. Can you create a demo? Is the child mesh being attached and appearing in the wrong place, or not appearing at all? Do you see any errors in the JS console? What does "doesn't work correctly" mean? – Don McCurdy Jan 19 '19 at 22:00
  • Actually your response helped me, cuz' as i made the demo, i rewrote some parts and main problem disappeared. But I still haven't figured it out how should i move the blue shoe with the leg. There is a DEMO link, press 'w' to play the walk cycle Is that possible ?, should i add same bones as in the leg ? https://github.com/tomo0613/3d-animated-char-test – Tamás Katona Jan 20 '19 at 17:36

1 Answers1

0

Looks like I have found a solution.

I updated the demo (It's only a PoC) https://github.com/tomo0613/3d-animated-char-test

first (in blender):

  • add bones to the shoe that should move with the character. (i guess these should heave the same bones [positions, rotations, sizes]; there are differences in the demo)

then is JS code:

  • add the shoe (entire mesh) as a child mesh to the leg bone.
  • before every render, copy the characters bone properties to the shoe bone properties [position & quaternion]

I'm still curious, is there any intended /or better way doing this.?

Tamás Katona
  • 683
  • 7
  • 13