-
Notifications
You must be signed in to change notification settings - Fork 111
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
fix: mixamoのモーション仕様変更への対応 #1032
Conversation
mixamoのモーションをNormalizedBone用に変換し、アニメーショントラックに格納する処理を追加 ローカル軸が正規化されていないrigにバインドされたアニメーションでもvrmに適用できるようになったため、 新旧どちらのFBXファイルにおいても同様にアニメーションの再生ができる。 #889 (comment)
packages/three-vrm-core/examples/humanoidAnimation/loadMixamoAnimation.js
Outdated
Show resolved
Hide resolved
packages/three-vrm-core/examples/humanoidAnimation/loadMixamoAnimation.js
Outdated
Show resolved
Hide resolved
packages/three-vrm/examples/humanoidAnimation/loadMixamoAnimation.js
Outdated
Show resolved
Hide resolved
targetRotation | ||
.fromArray( flatQuaternion ) | ||
.premultiply( parentRestWorldRotation ); | ||
|
||
retargetRotation | ||
.copy( targetRotation ) | ||
.multiply( restRotationInverse ) | ||
.toArray( flatQuaternion ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
結局やりたいのは、
親のレスト時ワールド回転 * トラックの回転 * レスト時ワールド回転の逆
ですかね?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一時変数 _quatA
がお嫌いでなければ、僕だったらこう書きます:
_quatA
.fromArray( flatQuaternion )
.premultiply( parentRestWorldRotation )
.multiply( restRotationInverse );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
premultiplyと .multiplyを連結すると混乱するので避けていました。
冗長なコピーで変数名を変えているのもその流れでした。
たしかに、コメントで式を書いてしまって処理部分をコンパクトにしてしまうのも良いですね
// 親のレスト時ワールド回転 * トラックの回転 * レスト時ワールド回転の逆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
premultiplyとmultiply連結するとだいぶキモいのはそれはそうですね。
ただ、自分は変数が多いほうが混乱しました。
が、これはあくまでもThree.jsのコーディングに慣れたエンジニアの意見なので、ただの1サンプルです。
.fromArray( flatQuaternion ) | ||
.premultiply( parentRestWorldRotation ); | ||
_quatA.fromArray( flatQuaternion ); | ||
|
||
retargetRotation | ||
.copy( targetRotation ) | ||
.multiply( restRotationInverse ) | ||
.toArray( flatQuaternion ); | ||
// 親のレスト時ワールド回転 * トラックの回転 * レスト時ワールド回転の逆 | ||
_quatA | ||
.premultiply( parentRestWorldRotation ) | ||
.multiply( restRotationInverse ); | ||
|
||
flatQuaternion.map( ( v, index ) => track.values[ index + i ] = v ); | ||
_quatA.toArray( flatQuaternion ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
回転部分の処理を連結しました
Array変換の部分は分けました
flatQuaternion.forEach( ( v, index ) => { | ||
|
||
track.values[ index + i ] = v; | ||
|
||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MapからforEachに変更しました
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good
mixamoのモーションをNormalizedBone用に変換し、アニメーショントラックに格納する処理を追加
ローカル軸が正規化されていないrigにバインドされたアニメーションでもvrmに適用できるようになったため、
新旧どちらのFBXファイルにおいても同様にアニメーションの再生ができる。
#889 (comment)