提交 934d122a 编写于 作者: M Mr.doob

Merge pull request #7939 from takahirox/MMDLoader

Update MMDLoader Animation
......@@ -2618,7 +2618,6 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
var animation = {
name: name === undefined ? THREE.Math.generateUUID() : name,
fps: 30,
length: 0.0,
hierarchy: []
};
......@@ -2633,8 +2632,6 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
}
var maxTime = 0.0;
for ( var i = 0; i < orderedMotions.length; i++ ) {
var array = orderedMotions[ i ];
......@@ -2651,16 +2648,8 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
}
if ( keys.length > 0 ) {
maxTime = Math.max( keys[ keys.length - 1 ].time, maxTime );
}
}
animation.length = maxTime;
for ( var i = 0; i < orderedMotions.length; i++ ) {
var bone = bones[ i ];
......@@ -2676,7 +2665,13 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
}
mesh.geometry.animations.push( THREE.AnimationClip.parseAnimation( animation, mesh.geometry.bones ) );
var clip = THREE.AnimationClip.parseAnimation( animation, mesh.geometry.bones );
if ( clip !== null ) {
mesh.geometry.animations.push( clip );
}
};
......@@ -2692,7 +2687,6 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
var morphAnimation = {
fps: 30,
length: 0.0,
hierarchy: []
};
......@@ -2702,8 +2696,6 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
}
var maxTime = 0.0;
for ( var i = 0; i < orderedMorphs.length; i++ ) {
var array = orderedMorphs[ i ];
......@@ -2718,20 +2710,6 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
}
if ( keys.length > 0 ) {
maxTime = Math.max( keys[ keys.length - 1 ].time, maxTime );
}
}
morphAnimation.length = maxTime;
if ( mesh.geometry.morphAnimations === undefined ) {
mesh.geometry.morphAnimations = [];
}
var tracks = [];
......@@ -2750,7 +2728,19 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) {
}
mesh.geometry.morphAnimations.push( new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name + 'Morph', -1, tracks ) );
var clip = new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name + 'Morph', -1, tracks );
if ( clip !== null ) {
if ( mesh.geometry.morphAnimations === undefined ) {
mesh.geometry.morphAnimations = [];
}
mesh.geometry.morphAnimations.push( clip );
}
};
......@@ -3221,7 +3211,6 @@ THREE.MMDLoader.VectorKeyframeTrackEx = function ( name, times, values, interpol
THREE.MMDLoader.VectorKeyframeTrackEx.prototype = Object.create( THREE.VectorKeyframeTrack.prototype );
THREE.MMDLoader.VectorKeyframeTrackEx.prototype.constructor = THREE.MMDLoader.VectorKeyframeTrackEx;
THREE.MMDLoader.VectorKeyframeTrackEx.prototype.TimeBufferType = Float64Array;
THREE.MMDLoader.VectorKeyframeTrackEx.prototype.ValueBufferType = Float64Array;
THREE.MMDLoader.NumberKeyframeTrackEx = function ( name, times, values, interpolation ) {
......@@ -3232,7 +3221,6 @@ THREE.MMDLoader.NumberKeyframeTrackEx = function ( name, times, values, interpol
THREE.MMDLoader.NumberKeyframeTrackEx.prototype = Object.create( THREE.NumberKeyframeTrack.prototype );
THREE.MMDLoader.NumberKeyframeTrackEx.prototype.constructor = THREE.MMDLoader.NumberKeyframeTrackEx;
THREE.MMDLoader.NumberKeyframeTrackEx.prototype.TimeBufferType = Float64Array;
THREE.MMDLoader.NumberKeyframeTrackEx.prototype.ValueBufferType = Float64Array;
THREE.MMDLoader.DataView = function ( buffer, littleEndian ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册