Skip to content

Wind effect on vrm models #1134

Answered by ke456-png
tejasnayak25 asked this question in Help
Dec 14, 2022 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

Overriding the "VRMSpringBoneJointSettings.gravityDir" can be used to create a wind-like effect.

const clock = new THREE.Clock();
clock.start();

const windDir = new THREE.Vector3( 0, - 1, - 1 );
const applyWind = ( vrm, t ) => {
  const windPower = ( Math.sin( t * Math.PI / 3 ) + 1 ) / 2;
  vrm.springBoneManager.joints.forEach( e => {
    e.settings.gravityDir = windDir;
    e.settings.gravityPower = windPower;
  } );
};

function animate() {
  requestAnimationFrame( animate );
  // update vrm components
  if ( currentVrm ) {
    applyWind( currentVrm, clock.elapsedTime );
    currentVrm.update( clock.getDelta() );
  }
  // render
  renderer.render( scene, camera );
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@tejasnayak25
Comment options

@tejasnayak25
Comment options

Answer selected by tejasnayak25
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1133 on December 14, 2022 06:54.