From e5b6981c9535803e8781430768b64f125c70acfd Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Mon, 5 Dec 2016 15:20:46 -0800 Subject: [PATCH] GLTFLoader: Reverted animations to clips rename. See 9aab3c6b983a9876ee567c9370fb7987344ebcf1. --- examples/js/loaders/GLTFLoader.js | 26 +++++++++++++------------- examples/webgl_loader_gltf.html | 24 +++++++++++++++--------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index edd2db6242..c8cea3edd1 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -54,14 +54,14 @@ THREE.GLTFLoader = ( function () { } ); - parser.parse( function ( scene, cameras, clips ) { + parser.parse( function ( scene, cameras, animations ) { console.timeEnd( 'GLTFLoader' ); var glTF = { "scene": scene, "cameras": cameras, - "clips": clips + "animations": animations }; callback( glTF ); @@ -243,7 +243,8 @@ THREE.GLTFLoader = ( function () { /* ANIMATION */ - function createClip( name, interps ) { + function createAnimation( name, interps ) { + var tracks = []; for ( var i = 0, len = interps.length; i < len; i ++ ) { @@ -265,9 +266,11 @@ THREE.GLTFLoader = ( function () { interp.values, interp.type ) ); + } return new THREE.AnimationClip( name, undefined, tracks ); + } /*********************************/ @@ -609,7 +612,7 @@ THREE.GLTFLoader = ( function () { "scenes", "cameras", - "clips" + "animations" ] ).then( function ( dependencies ) { @@ -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 ]; - clips.push( clip ); + animations.push( dependencies.animations[ name ] ); } - callback( scene, cameras, clips); + callback( scene, cameras, animations ); }.bind( this ) ); @@ -1246,9 +1248,7 @@ THREE.GLTFLoader = ( function () { }; - - - GLTFParser.prototype.loadClips = function () { + GLTFParser.prototype.loadAnimations = function () { var scope = this; @@ -1298,7 +1298,7 @@ THREE.GLTFLoader = ( function () { } - return createClip( "animation_" + animationId, interps ); + return createAnimation( "animation_" + animationId, interps ); } ); diff --git a/examples/webgl_loader_gltf.html b/examples/webgl_loader_gltf.html index 2f372c78a8..c9fa9e68ae 100644 --- a/examples/webgl_loader_gltf.html +++ b/examples/webgl_loader_gltf.html @@ -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 - // keeps it from looping cleanly. Clip it at 3 seconds - if (sceneInfo.animationTime) - clip.duration = sceneInfo.animationTime; - mixer.clipAction(clip).play(); + // keeps it from looping cleanly. Animation it at 3 seconds + if ( sceneInfo.animationTime ) + animation.duration = sceneInfo.animationTime; + + mixer.clipAction( animation ).play(); + } + } scene.add( object ); -- GitLab