0

I want to know how to manipulate the bones of a json / collada file exported from Blender. Been trying to do this for a while to no avail.

I want to be able to use sliders (through dat.gui) to rotate each bone

Can anyone point me in the right direction or help?

I want to end up with a human model, where i can manipulate each bone / limb with the dat.gui sliders

Matttampa
  • 1
  • 1

1 Answers1

0

As stated in the Dat.GUI docs, you should create the gui like this:

var gui = new dat.GUI();
document.body.appendChild( gui.domElement );

function addBoneSliders(bone) {
  var folder = gui.addFolder( bone.name );

  folder.add( bone.rotation, 'x' );
  folder.add( bone.rotation, 'y' );
  folder.add( bone.rotation, 'z' );
}

and, in your loader callback

collada.scene.traverse( function ( child ) {
  if ( child instanceof THREE.Bone ) {
    addBoneSliders( child );
  }
});

I haven't tested it but it should work.

vincent
  • 1,525
  • 12
  • 18
  • Hey, thanks for the reply. Could you show me how this might work? I can't seem to implement it into my own code without errors or a white screen. Thanks again – Matttampa Mar 11 '16 at 10:43
  • @vincent if the bone is named leg.L and leg.R, how to address them in the bone.name? – June Wang Sep 09 '18 at 18:35
  • @JuneWang not sure to understand. if the collada object you get has a name attribute, then you just have to check this in the test statement (and add both legs sliders) – vincent Sep 11 '18 at 12:12