@@ -755,33 +755,35 @@ private IStdUVGen _exportUV(IStdUVGen uvGen, BabylonTexture babylonTexture)
755755
756756 var offset = new BabylonVector3 ( babylonTexture . uOffset , - babylonTexture . vOffset , 0 ) ;
757757 var scale = new BabylonVector3 ( babylonTexture . uScale , babylonTexture . vScale , 1 ) ;
758- var rotation = new BabylonQuaternion ( ) ;
758+ var rotationEuler = new BabylonVector3 ( uvGen . GetUAng ( 0 ) , uvGen . GetVAng ( 0 ) , uvGen . GetWAng ( 0 ) ) ;
759+ var rotation = BabylonQuaternion . FromEulerAngles ( rotationEuler . X , rotationEuler . Y , rotationEuler . Z ) ;
759760 var pivotCenter = new BabylonVector3 ( - 0.5f , - 0.5f , 0 ) ;
760761 var transformMatrix = Tools . ComputeTextureTransformMatrix ( pivotCenter , offset , rotation , scale ) ;
761762
762- transformMatrix . decompose ( scale , rotation , offset ) ;
763+ transformMatrix . decompose ( scale , rotation , offset ) ;
764+ var texTransformRotationEuler = rotation . toEulerAngles ( ) ;
765+
763766 babylonTexture . uOffset = - offset . X ;
764767 babylonTexture . vOffset = - offset . Y ;
765768 babylonTexture . uScale = scale . X ;
766769 babylonTexture . vScale = - scale . Y ;
767770 babylonTexture . uRotationCenter = 0.0f ;
768771 babylonTexture . vRotationCenter = 0.0f ;
769772 babylonTexture . invertY = false ;
773+ babylonTexture . uAng = texTransformRotationEuler . X ;
774+ babylonTexture . vAng = texTransformRotationEuler . Y ;
775+ babylonTexture . wAng = texTransformRotationEuler . Z ;
770776
771777 if ( Path . GetExtension ( babylonTexture . name ) . ToLower ( ) == ".dds" )
772778 {
773779 babylonTexture . vScale *= - 1 ; // Need to invert Y-axis for DDS texture
774780 }
775781
776- babylonTexture . uAng = uvGen . GetUAng ( 0 ) ;
777- babylonTexture . vAng = uvGen . GetVAng ( 0 ) ;
778- babylonTexture . wAng = uvGen . GetWAng ( 0 ) ;
779-
780-
781- // TODO - rotation and scale
782- if ( babylonTexture . wAng != 0f && ( babylonTexture . uScale != 1f || babylonTexture . vScale != 1f ) )
782+ if ( babylonTexture . wAng != 0f
783+ && ( babylonTexture . uScale != 1f || babylonTexture . vScale != 1f )
784+ && ( Math . Abs ( babylonTexture . uScale ) - Math . Abs ( babylonTexture . vScale ) ) > float . Epsilon )
783785 {
784- RaiseWarning ( "Rotation and tiling (scale) on a texture are only supported separatly . You can use the map UV of the mesh for those transformation ." , 3 ) ;
786+ RaiseWarning ( "Rotation and non-uniform tiling (scale) on a texture is not supported as it will cause texture shearing . You can use the map UV of the mesh for those transformations ." , 3 ) ;
785787 }
786788
787789
0 commit comments