Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change hand color #22

Closed
pjanik opened this issue Jun 8, 2016 · 3 comments
Closed

Change hand color #22

pjanik opened this issue Jun 8, 2016 · 3 comments

Comments

@pjanik
Copy link

pjanik commented Jun 8, 2016

Is there an easy way to do it?
Function that sets bone color seems like an overkill. Also, if I set HSL value, it doesn't seem to be correct anyway (try to set red in HSL space).
I've looked at the source code and I can't see how I can provide material option that would overwrite color.

@pehrlich
Copy link
Contributor

pehrlich commented Jun 8, 2016

See the README: materialOptions gives control of the material configuration, like this:

(window.controller = new Leap.Controller)
  .use('riggedHand', {
    materialOptions: {
      color: new THREE.Color(0xff0000)
    }
  })
  .connect()

See Plunkr: https://plnkr.co/edit/7fkhnY?p=info

Note that you may want to change the material wholly. I recommend taking a look at this PR, which shows how to put in a custom shader experimentally: #11

Specifically, you can subscribe to the riggedHand.meshAdded event and replace the material:

   .on('riggedHand.meshAdded', function(handMesh){
         console.log('mesh added', arguments);
         handMesh.material =  new THREE.ShaderMaterial({
             uniforms: uniforms,
             vertexShader: document.getElementById('vertexShader').innerHTML,
             fragmentShader: document.getElementById('fragmentShader').innerHTML
         });
         handMesh.skinning = true;
    })

@pjanik
Copy link
Author

pjanik commented Jun 9, 2016

For some reason I was assuming that materialOptions had to be a static, JSON-like hash (e.g. accepting color: 0xff0000, but not the THREE object). I would consider adding color example to readme, as probably it's one of the most popular things that people might want to customize.

Thanks a lot!

@pjanik pjanik closed this as completed Jun 9, 2016
@pehrlich
Copy link
Contributor

done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants