提交 4f4bf136 编写于 作者: T Takahiro 提交者: Mr.doob

Clean Up MMDLoader morph animation (#8964)

上级 c2a5c1f3
......@@ -2694,15 +2694,15 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
}
if ( mesh.geometry.animations === undefined ) {
var clip = THREE.AnimationClip.parseAnimation( animation, mesh.geometry.bones );
mesh.geometry.animations = [];
if ( clip !== null ) {
}
if ( mesh.geometry.animations === undefined ) {
var clip = THREE.AnimationClip.parseAnimation( animation, mesh.geometry.bones );
mesh.geometry.animations = [];
if ( clip !== null ) {
}
mesh.geometry.animations.push( clip );
......@@ -2747,6 +2747,8 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
}
// TODO: should we use THREE.AnimationClip.CreateFromMorphTargetSequence() instead?
var tracks = [];
for ( var i = 0; i < orderedMorphs.length; i++ ) {
......@@ -2767,13 +2769,13 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
if ( clip !== null ) {
if ( mesh.geometry.morphAnimations === undefined ) {
if ( mesh.geometry.animations === undefined ) {
mesh.geometry.morphAnimations = [];
mesh.geometry.animations = [];
}
mesh.geometry.morphAnimations.push( clip );
mesh.geometry.animations.push( clip );
}
......@@ -4139,45 +4141,48 @@ THREE.MMDHelper.prototype = {
setAnimation: function ( mesh ) {
if ( mesh.geometry.animations !== undefined || mesh.geometry.morphAnimations !== undefined ) {
if ( mesh.geometry.animations !== undefined ) {
mesh.mixer = new THREE.AnimationMixer( mesh );
}
if ( mesh.geometry.animations !== undefined ) {
var foundAnimation = false;
var foundMorphAnimation = false;
for ( var i = 0; i < mesh.geometry.animations.length; i++ ) {
var action = mesh.mixer.clipAction( mesh.geometry.animations[ i ] );
var clip = mesh.geometry.animations[ i ];
if ( i === 0 ) {
var action = mesh.mixer.clipAction( clip );
action.play();
if ( clip.tracks[ 0 ].name.indexOf( '.morphTargetInfluences' ) === 0 ) {
}
if ( ! foundMorphAnimation ) {
}
action.play();
foundMorphAnimation = true;
mesh.ikSolver = new THREE.CCDIKSolver( mesh );
}
if ( mesh.geometry.grants !== undefined ) {
} else {
mesh.grantSolver = new THREE.MMDGrantSolver( mesh );
if ( ! foundAnimation ) {
}
action.play();
foundAnimation = true;
}
}
if ( mesh.geometry.morphAnimations !== undefined ) {
}
}
for ( var i = 0; i < mesh.geometry.morphAnimations.length; i++ ) {
if ( foundAnimation ) {
var action = mesh.mixer.clipAction( mesh.geometry.morphAnimations[ i ] );
mesh.ikSolver = new THREE.CCDIKSolver( mesh );
if ( i === 0 ) {
if ( mesh.geometry.grants !== undefined ) {
action.play();
mesh.grantSolver = new THREE.MMDGrantSolver( mesh );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册