Browse Source

Merge pull request #12411 from looeee/FBXLoader_rotation_order_warning

FBXLoader: added warning for unsupported rotation orders
Mr.doob 7 years ago
parent
commit
9a41ff35f2
1 changed files with 31 additions and 7 deletions
  1. 31 7
      examples/js/loaders/FBXLoader.js

+ 31 - 7
examples/js/loaders/FBXLoader.js

@@ -1906,6 +1906,36 @@
 	// parse the model node for transform details and apply them to the model
 	// parse the model node for transform details and apply them to the model
 	function setModelTransforms( FBXTree, model, modelNode, connections, sceneGraph ) {
 	function setModelTransforms( FBXTree, model, modelNode, connections, sceneGraph ) {
 
 
+		// http://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_class_fbx_euler_html
+		if ( 'RotationOrder' in modelNode.properties ) {
+
+			var enums = [
+				'XYZ', // default
+				'XZY',
+				'YZX',
+				'ZXY',
+				'YXZ',
+				'ZYX',
+				'SphericXYZ',
+			];
+
+			var value = parseInt( modelNode.properties.RotationOrder.value, 10 );
+
+			if ( value > 0 && value < 6 ) {
+
+				// model.rotation.order = enums[ value ];
+
+				// Note: Euler order other than XYZ is currently not supported, so just display a warning for now
+				console.warn( 'THREE.FBXLoader: unsupported Euler Order: %s. Currently only XYZ order is supported. Animations and rotations may be incorrect.', enums[ value ] );
+
+			} else if ( value === 6 ) {
+
+				console.warn( 'THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect.' );
+
+			}
+
+		}
+
 		if ( 'Lcl_Translation' in modelNode.properties ) {
 		if ( 'Lcl_Translation' in modelNode.properties ) {
 
 
 			model.position.fromArray( modelNode.properties.Lcl_Translation.value );
 			model.position.fromArray( modelNode.properties.Lcl_Translation.value );
@@ -1941,7 +1971,7 @@
 		}
 		}
 
 
 		// rotated pivots - note: rotation must be applied before translation here
 		// rotated pivots - note: rotation must be applied before translation here
-		if ( 'GeometricRotation' in modelNode.properties  ) {
+		if ( 'GeometricRotation' in modelNode.properties ) {
 
 
 			var array = modelNode.properties.GeometricRotation.value.map( THREE.Math.degToRad );
 			var array = modelNode.properties.GeometricRotation.value.map( THREE.Math.degToRad );
 
 
@@ -3950,12 +3980,6 @@
 
 
 	}
 	}
 
 
-	function parseVector3( property ) {
-
-		return new THREE.Vector3().fromArray( property.value );
-
-	}
-
 	function parseColor( property ) {
 	function parseColor( property ) {
 
 
 		var color = new THREE.Color();
 		var color = new THREE.Color();