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

GLTFLoader: Reverted animations to clips rename. See 9aab3c6b.

上级 d908b3e9
...@@ -54,14 +54,14 @@ THREE.GLTFLoader = ( function () { ...@@ -54,14 +54,14 @@ THREE.GLTFLoader = ( function () {
} ); } );
parser.parse( function ( scene, cameras, clips ) { parser.parse( function ( scene, cameras, animations ) {
console.timeEnd( 'GLTFLoader' ); console.timeEnd( 'GLTFLoader' );
var glTF = { var glTF = {
"scene": scene, "scene": scene,
"cameras": cameras, "cameras": cameras,
"clips": clips "animations": animations
}; };
callback( glTF ); callback( glTF );
...@@ -243,7 +243,8 @@ THREE.GLTFLoader = ( function () { ...@@ -243,7 +243,8 @@ THREE.GLTFLoader = ( function () {
/* ANIMATION */ /* ANIMATION */
function createClip( name, interps ) { function createAnimation( name, interps ) {
var tracks = []; var tracks = [];
for ( var i = 0, len = interps.length; i < len; i ++ ) { for ( var i = 0, len = interps.length; i < len; i ++ ) {
...@@ -265,9 +266,11 @@ THREE.GLTFLoader = ( function () { ...@@ -265,9 +266,11 @@ THREE.GLTFLoader = ( function () {
interp.values, interp.values,
interp.type interp.type
) ); ) );
} }
return new THREE.AnimationClip( name, undefined, tracks ); return new THREE.AnimationClip( name, undefined, tracks );
} }
/*********************************/ /*********************************/
...@@ -609,7 +612,7 @@ THREE.GLTFLoader = ( function () { ...@@ -609,7 +612,7 @@ THREE.GLTFLoader = ( function () {
"scenes", "scenes",
"cameras", "cameras",
"clips" "animations"
] ).then( function ( dependencies ) { ] ).then( function ( dependencies ) {
...@@ -624,16 +627,15 @@ THREE.GLTFLoader = ( function () { ...@@ -624,16 +627,15 @@ THREE.GLTFLoader = ( function () {
} }
var clips = []; var animations = [];
for ( var name in dependencies.clips ) { for ( var name in dependencies.animations ) {
var clip = dependencies.clips[ name ]; animations.push( dependencies.animations[ name ] );
clips.push( clip );
} }
callback( scene, cameras, clips); callback( scene, cameras, animations );
}.bind( this ) ); }.bind( this ) );
...@@ -1246,9 +1248,7 @@ THREE.GLTFLoader = ( function () { ...@@ -1246,9 +1248,7 @@ THREE.GLTFLoader = ( function () {
}; };
GLTFParser.prototype.loadAnimations = function () {
GLTFParser.prototype.loadClips = function () {
var scope = this; var scope = this;
...@@ -1298,7 +1298,7 @@ THREE.GLTFLoader = ( function () { ...@@ -1298,7 +1298,7 @@ THREE.GLTFLoader = ( function () {
} }
return createClip( "animation_" + animationId, interps ); return createAnimation( "animation_" + animationId, interps );
} ); } );
......
...@@ -314,19 +314,25 @@ ...@@ -314,19 +314,25 @@
} }
if (gltf.clips && gltf.clips.length) { var animations = gltf.animations;
mixer = new THREE.AnimationMixer(object); if ( animations && animations.length ) {
mixer = new THREE.AnimationMixer( object );
for ( var i = 0; i < animations.length; i ++ ) {
var animation = animations[ i ];
var i, len = gltf.clips.length;
for (i = 0; i < len; i++) {
var clip = gltf.clips[i];
// There's .3333 seconds junk at the tail of the Monster animation that // There's .3333 seconds junk at the tail of the Monster animation that
// keeps it from looping cleanly. Clip it at 3 seconds // keeps it from looping cleanly. Animation it at 3 seconds
if (sceneInfo.animationTime) if ( sceneInfo.animationTime )
clip.duration = sceneInfo.animationTime; animation.duration = sceneInfo.animationTime;
mixer.clipAction(clip).play();
mixer.clipAction( animation ).play();
} }
} }
scene.add( object ); scene.add( object );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册