Browse Source

Merge pull request #12480 from looeee/FBXLoader_check_rotation_axis_is_defined_per_frame

FBXLoader check rotation axis is defined per frame
Mr.doob 7 years ago
parent
commit
8eec4878b3
1 changed files with 21 additions and 4 deletions
  1. 21 4
      examples/js/loaders/FBXLoader.js

+ 21 - 4
examples/js/loaders/FBXLoader.js

@@ -3700,6 +3700,8 @@
 
 
 		if ( animationNode === undefined ) return key;
 		if ( animationNode === undefined ) return key;
 
 
+		euler.setFromQuaternion( bone.quaternion, 'ZYX', false );
+
 		try {
 		try {
 
 
 			if ( hasCurve( animationNode, 'T' ) && hasKeyOnFrame( animationNode.T, frame ) ) {
 			if ( hasCurve( animationNode, 'T' ) && hasKeyOnFrame( animationNode.T, frame ) ) {
@@ -3710,11 +3712,26 @@
 
 
 			if ( hasCurve( animationNode, 'R' ) && hasKeyOnFrame( animationNode.R, frame ) ) {
 			if ( hasCurve( animationNode, 'R' ) && hasKeyOnFrame( animationNode.R, frame ) ) {
 
 
-				var rotationX = animationNode.R.curves.x.values[ frame ];
-				var rotationY = animationNode.R.curves.y.values[ frame ];
-				var rotationZ = animationNode.R.curves.z.values[ frame ];
+				// Only update the euler's values if rotation is defined for the axis on this frame
+				if ( animationNode.R.curves.x.values[ frame ] ) {
+
+					euler.x = animationNode.R.curves.x.values[ frame ];
+
+				}
+
+				if ( animationNode.R.curves.y.values[ frame ] ) {
+
+					euler.y = animationNode.R.curves.y.values[ frame ];
+
+				}
+
+				if ( animationNode.R.curves.z.values[ frame ] ) {
+
+					euler.z = animationNode.R.curves.z.values[ frame ];
+
+				}
 
 
-				quaternion.setFromEuler( euler.set( rotationX, rotationY, rotationZ, 'ZYX' ) );
+				quaternion.setFromEuler( euler );
 				key.rot = quaternion.toArray();
 				key.rot = quaternion.toArray();
 
 
 			}
 			}