Browse Source

Merge pull request #7404 from bhouston/fix_animationHierarchyParser

Add support for loading SkinnedMeshes from SceneLoader + bug fix.
Mr.doob 9 years ago
parent
commit
fd21a82654
2 changed files with 19 additions and 6 deletions
  1. 4 4
      src/animation/AnimationClip.js
  2. 15 2
      src/loaders/ObjectLoader.js

+ 4 - 4
src/animation/AnimationClip.js

@@ -177,7 +177,7 @@ THREE.AnimationClip.parse = function( json ) {
 
 
 
 
 // parse the animation.hierarchy format
 // parse the animation.hierarchy format
-THREE.AnimationClip.parseAnimation = function( animation, bones, nodeName ) {
+THREE.AnimationClip.parseAnimation = function( animation, bones ) {
 
 
 	if ( ! animation ) {
 	if ( ! animation ) {
 		console.error( "  no animation in JSONLoader data" );
 		console.error( "  no animation in JSONLoader data" );
@@ -211,7 +211,7 @@ THREE.AnimationClip.parseAnimation = function( animation, bones, nodeName ) {
 	};
 	};
 
 
 	var tracks = [];
 	var tracks = [];
-
+	
 	var clipName = animation.name || 'default';
 	var clipName = animation.name || 'default';
 	var duration = animation.length || -1; // automatic length determination in AnimationClip.
 	var duration = animation.length || -1; // automatic length determination in AnimationClip.
 	var fps = animation.fps || 30;
 	var fps = animation.fps || 30;
@@ -259,7 +259,7 @@ THREE.AnimationClip.parseAnimation = function( animation, bones, nodeName ) {
 
 
 				}
 				}
 
 
-				tracks.push( new THREE.NumberKeyframeTrack( nodeName + '.morphTargetInfluence[' + morphTargetName + ']', keys ) );
+				tracks.push( new THREE.NumberKeyframeTrack( '.morphTargetInfluence[' + morphTargetName + ']', keys ) );
 
 
 			}
 			}
 
 
@@ -267,7 +267,7 @@ THREE.AnimationClip.parseAnimation = function( animation, bones, nodeName ) {
 
 
 		} else {
 		} else {
 
 
-			var boneName = nodeName + '.bones[' + bones[ h ].name + ']';
+			var boneName = '.bones[' + bones[ h ].name + ']';
 
 
 			// track contains positions...
 			// track contains positions...
 			var positionTrack = convertTrack( boneName + '.position', animationKeys, 'pos', THREE.VectorKeyframeTrack, function( animationKey ) {
 			var positionTrack = convertTrack( boneName + '.position', animationKeys, 'pos', THREE.VectorKeyframeTrack, function( animationKey ) {

+ 15 - 2
src/loaders/ObjectLoader.js

@@ -514,9 +514,22 @@ THREE.ObjectLoader.prototype = {
 
 
 					break;
 					break;
 
 
-				case 'Mesh':
+				case 'Mesh': {
 
 
-					object = new THREE.Mesh( getGeometry( data.geometry ), getMaterial( data.material ) );
+						var geometry = getGeometry( data.geometry );
+						
+						if( geometry.bones && geometry.bones.length > 0 ) {
+
+							object = new THREE.SkinnedMesh( geometry, getMaterial( data.material ) );
+
+						}
+						else {
+
+							object = new THREE.Mesh( geometry, getMaterial( data.material ) );	
+
+						}
+
+					}
 
 
 					break;
 					break;