firtoz / react-three-renderer

Render into a three.js canvas using React.
https://toxicfork.github.com/react-three-renderer-example/
MIT License
1.49k stars 155 forks source link

Support morphTarget and morphTargetInfluences #209

Open shampliu opened 6 years ago

toxicFork commented 6 years ago

Relevant: https://threejs.org/docs/index.html#api/objects/Mesh.morphTargetDictionary

johnmarinelli commented 6 years ago

Hey, I'd like to work on this if nobody has started already. I have been trying to implement the THREE.js Hemisphere Lights example (https://threejs.org/examples/?q=hemisp#webgl_lights_hemisphere) and ran into a morphTargetInfluences error. Right now the only solution I've come up with is to manually scene.add(mesh).

Here is the code from the example -

var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 20, morphTargets: true, vertexColors: THREE.FaceColors, flatShading: true } );
var mesh = new THREE.Mesh( geometry, material );

var s = 0.35;
mesh.scale.set( s, s, s );
mesh.position.y = 15;
mesh.rotation.y = -1;
mesh.castShadow = true;
mesh.receiveShadow = true;

scene.add( mesh );

var mixer = new THREE.AnimationMixer( mesh );
mixer.clipAction( geometry.animations[ 0 ] ).setDuration( 1 ).play();
mixers.push( mixer );

@toxicFork If you haven't started on this already, let me know and I'll see what I can do. If you have any pointers or ideas, I'd be happy to hear them as well. Right now I'm not sure how to decouple the AnimationMixer from the element.

toxicFork commented 6 years ago

Thank you for offering your help, it will be greatly appreciated!!

On Thu, Jan 18, 2018, 09:53 John Marinelli notifications@github.com wrote:

Hey, I'd like to work on this if nobody has started already. I have been trying to implement the THREE.js Hemisphere Lights example ( https://threejs.org/examples/?q=hemisp#webgl_lights_hemisphere) and ran into a morphTargetInfluences error. Right now the only solution I've come up with is to manually scene.add(mesh).

Here is the code from the example -

var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 20, morphTargets: true, vertexColors: THREE.FaceColors, flatShading: true } ); var mesh = new THREE.Mesh( geometry, material );

              var s = 0.35;
              mesh.scale.set( s, s, s );
              mesh.position.y = 15;
              mesh.rotation.y = -1;

              mesh.castShadow = true;
              mesh.receiveShadow = true;

              scene.add( mesh );

              var mixer = new THREE.AnimationMixer( mesh );
              mixer.clipAction( geometry.animations[ 0 ] ).setDuration( 1 ).play();
              mixers.push( mixer );

@toxicFork https://github.com/toxicfork If you haven't started on this already, let me know and I'll see what I can do. If you have any pointers or ideas, I'd be happy to hear them as well. Right now I'm not sure how to decouple the AnimationMixer from the element.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/toxicFork/react-three-renderer/issues/209#issuecomment-358595064, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0iLZnqb3SI25BJdCCd31UhAxYMoRrLks5tLxSDgaJpZM4RXHY6 .