Quellcode durchsuchen

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

Mr.doob vor 8 Jahren
Ursprung
Commit
e5b6981c95
2 geänderte Dateien mit 28 neuen und 22 gelöschten Zeilen
  1. 13 13
      examples/js/loaders/GLTFLoader.js
  2. 15 9
      examples/webgl_loader_gltf.html

+ 13 - 13
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 );
 
 			} );
 

+ 15 - 9
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 );