Browse Source

fix name in morph target undefined

Lewy Blue 7 years ago
parent
commit
56827c86f2
1 changed files with 11 additions and 5 deletions
  1. 11 5
      examples/js/loaders/FBXLoader.js

+ 11 - 5
examples/js/loaders/FBXLoader.js

@@ -99,7 +99,7 @@ THREE.FBXLoader = ( function () {
 
 
 			}
 			}
 
 
-			//console.log( FBXTree );
+			console.log( fbxTree );
 
 
 			var textureLoader = new THREE.TextureLoader( this.manager ).setPath( resourceDirectory ).setCrossOrigin( this.crossOrigin );
 			var textureLoader = new THREE.TextureLoader( this.manager ).setPath( resourceDirectory ).setCrossOrigin( this.crossOrigin );
 
 
@@ -774,6 +774,8 @@ THREE.FBXLoader = ( function () {
 
 
 				} );
 				} );
 
 
+				console.log('rawMorphTarget', rawMorphTarget);
+
 				rawMorphTargets.push( rawMorphTarget );
 				rawMorphTargets.push( rawMorphTarget );
 
 
 			}
 			}
@@ -2001,7 +2003,9 @@ THREE.FBXLoader = ( function () {
 			if ( morphTarget === null ) return;
 			if ( morphTarget === null ) return;
 
 
 			parentGeo.morphAttributes.position = [];
 			parentGeo.morphAttributes.position = [];
-			parentGeo.morphAttributes.normal = [];
+			// parentGeo.morphAttributes.normal = []; // not implemented
+
+
 
 
 			var self = this;
 			var self = this;
 			morphTarget.rawTargets.forEach( function ( rawTarget ) {
 			morphTarget.rawTargets.forEach( function ( rawTarget ) {
@@ -2010,7 +2014,7 @@ THREE.FBXLoader = ( function () {
 
 
 				if ( morphGeoNode !== undefined ) {
 				if ( morphGeoNode !== undefined ) {
 
 
-					self.genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform );
+					self.genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform, rawTarget.name );
 
 
 				}
 				}
 
 
@@ -2022,7 +2026,7 @@ THREE.FBXLoader = ( function () {
 		// in FBXTree.Objects.Geometry, however it can only have attributes for position, normal
 		// in FBXTree.Objects.Geometry, however it can only have attributes for position, normal
 		// and a special attribute Index defining which vertices of the original geometry are affected
 		// and a special attribute Index defining which vertices of the original geometry are affected
 		// Normal and position attributes only have data for the vertices that are affected by the morph
 		// Normal and position attributes only have data for the vertices that are affected by the morph
-		genMorphGeometry: function ( parentGeo, parentGeoNode, morphGeoNode, preTransform ) {
+		genMorphGeometry: function ( parentGeo, parentGeoNode, morphGeoNode, preTransform, name ) {
 
 
 			var morphGeo = new THREE.BufferGeometry();
 			var morphGeo = new THREE.BufferGeometry();
 			if ( morphGeoNode.attrName ) morphGeo.name = morphGeoNode.attrName;
 			if ( morphGeoNode.attrName ) morphGeo.name = morphGeoNode.attrName;
@@ -2056,7 +2060,7 @@ THREE.FBXLoader = ( function () {
 			var morphBuffers = this.genBuffers( morphGeoInfo );
 			var morphBuffers = this.genBuffers( morphGeoInfo );
 
 
 			var positionAttribute = new THREE.Float32BufferAttribute( morphBuffers.vertex, 3 );
 			var positionAttribute = new THREE.Float32BufferAttribute( morphBuffers.vertex, 3 );
-			positionAttribute.name = morphGeoNode.attrName;
+			positionAttribute.name = name || morphGeoNode.attrName;
 
 
 			preTransform.applyToBufferAttribute( positionAttribute );
 			preTransform.applyToBufferAttribute( positionAttribute );
 
 
@@ -2701,6 +2705,8 @@ THREE.FBXLoader = ( function () {
 
 
 			} );
 			} );
 
 
+			console.log('rawTracks', rawTracks.morphName);
+
 			var morphNum = sceneGraph.getObjectByName( rawTracks.modelName ).morphTargetDictionary[ rawTracks.morphName ];
 			var morphNum = sceneGraph.getObjectByName( rawTracks.modelName ).morphTargetDictionary[ rawTracks.morphName ];
 
 
 			return new THREE.NumberKeyframeTrack( rawTracks.modelName + '.morphTargetInfluences[' + morphNum + ']', curves.times, values );
 			return new THREE.NumberKeyframeTrack( rawTracks.modelName + '.morphTargetInfluences[' + morphNum + ']', curves.times, values );