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

Adjust animation with reference to hips height #1074

Merged
merged 2 commits into from
Oct 4, 2022

Conversation

ke456-png
Copy link
Contributor

@ke456-png ke456-png commented Oct 3, 2022

Description

examples/humanoidAniamtion でVRMごとの身長差を考慮するように修正します

VRMのhipsの高さとmixamoのFBXのhipsのYの比によって、
hipsの位置のアニメーションの値を変更します。

これによって、足の長いVRMや短いVRMでも地面に足がついた状態でアニメーションするようになります。

Adjust with reference to waist height

VRMのhipsの高さとmixamoのFBXのhipsのYの比によって、
hipsの位置のアニメーションの値を変更します。

これによって、足の長いVRMや短いVRMでも地面に足がついた状態でアニメーションするようになります。
Comment on lines +24 to +28
const motionHipsHeight = asset.getObjectByName( 'mixamorigHips' ).position.y;
const vrmHipsY = vrm.humanoid?.getNormalizedBoneNode( 'hips' ).getWorldPosition( _vec3 ).y;
const vrmRootY = vrm.scene.getWorldPosition( _vec3 ).y;
const vrmHipsHeight = Math.abs( vrmHipsY - vrmRootY );
const hipsPositionScale = vrmHipsHeight / motionHipsHeight;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VRMは位置を変更している可能性があるためvrm.sceneとの差をとっています。

mixamoのFBXからはy座標をそのままとっています。

@ke456-png ke456-png requested a review from 0b5vr October 3, 2022 06:38
@ke456-png ke456-png marked this pull request as ready for review October 3, 2022 06:38
@ke456-png ke456-png self-assigned this Oct 3, 2022
@ke456-png ke456-png changed the title Adjust animation with reference to waist height Adjust animation with reference to hips height Oct 3, 2022

tracks.push( new THREE.VectorKeyframeTrack( `${nodeName}.${propertyName}`, track.times, value ) );
const value = track.values.map( ( v, i ) => ( vrm.meta?.metaVersion === '0' && i % 3 !== 1 ? - v : v ) * hipsPositionScale );
tracks.push( new THREE.VectorKeyframeTrack( `${vrmNodeName}.${propertyName}`, track.times, value ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここの nodeName の変更はシンプルにわざわざ別変数にする意味がなかったということですかね

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

はい、その通りです

@0b5vr
Copy link
Contributor

0b5vr commented Oct 3, 2022

コード見る感じ良さそうです。動作確認してみます

Copy link
Contributor

@0b5vr 0b5vr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

動作も良好。good

@ke456-png ke456-png merged commit 1a89850 into dev Oct 4, 2022
@ke456-png ke456-png deleted the fix/example-humanoid-motion branch October 4, 2022 02:26
@0b5vr 0b5vr added this to the next milestone Oct 4, 2022
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

Successfully merging this pull request may close these issues.

Oversize / undersize VRM models are moved from origin when playing an animation
2 participants