@@ -532,30 +532,116 @@ THREE.Matrix4.prototype = {
532
532
533
533
} ,
534
534
535
- setRotationFromEuler : function ( v ) {
535
+ setRotationFromEuler : function ( v , order ) {
536
536
537
537
var x = v . x , y = v . y , z = v . z ,
538
538
a = Math . cos ( x ) , b = Math . sin ( x ) ,
539
539
c = Math . cos ( y ) , d = Math . sin ( y ) ,
540
- e = Math . cos ( z ) , f = Math . sin ( z ) ,
541
- ad = a * d , bd = b * d ;
540
+ e = Math . cos ( z ) , f = Math . sin ( z ) ;
542
541
543
- this . n11 = c * e ;
544
- this . n12 = - c * f ;
545
- this . n13 = d ;
542
+ switch ( order ) {
543
+ case 'YXZ' :
544
+ var ce = c * e , cf = c * f , de = d * e , df = d * f ;
546
545
547
- this . n21 = bd * e + a * f ;
548
- this . n22 = - bd * f + a * e ;
549
- this . n23 = - b * c ;
546
+ this . n11 = ce + df * b ;
547
+ this . n12 = de * b - cf ;
548
+ this . n13 = a * d ;
550
549
551
- this . n31 = - ad * e + b * f ;
552
- this . n32 = ad * f + b * e ;
553
- this . n33 = a * c ;
550
+ this . n21 = a * f ;
551
+ this . n22 = a * e ;
552
+ this . n23 = - b ;
553
+
554
+ this . n31 = cf * b - de ;
555
+ this . n32 = df + ce * b ;
556
+ this . n33 = a * c ;
557
+ break ;
558
+
559
+ case 'ZXY' :
560
+ var ce = c * e , cf = c * f , de = d * e , df = d * f ;
561
+
562
+ this . n11 = ce - df * b ;
563
+ this . n12 = - a * f ;
564
+ this . n13 = de + cf * b ;
565
+
566
+ this . n21 = cf + de * b ;
567
+ this . n22 = a * e ;
568
+ this . n23 = df - ce * b ;
569
+
570
+ this . n31 = - a * d ;
571
+ this . n32 = b ;
572
+ this . n33 = a * c ;
573
+ break ;
574
+
575
+ case 'ZYX' :
576
+ var ae = a * e , af = a * f , be = b * e , bf = b * f ;
577
+
578
+ this . n11 = c * e ;
579
+ this . n12 = be * d - af ;
580
+ this . n13 = ae * d + bf ;
581
+
582
+ this . n21 = c * f ;
583
+ this . n22 = bf * d + ae ;
584
+ this . n23 = af * d - be ;
585
+
586
+ this . n31 = - d ;
587
+ this . n32 = b * c ;
588
+ this . n33 = a * c ;
589
+ break ;
590
+
591
+ case 'YZX' :
592
+ var ac = a * c , ad = a * d , bc = b * c , bd = b * d ;
593
+
594
+ this . n11 = c * e ;
595
+ this . n12 = bd - ac * f ;
596
+ this . n13 = bc * f + ad ;
597
+
598
+ this . n21 = f ;
599
+ this . n22 = a * e ;
600
+ this . n23 = - b * e ;
601
+
602
+ this . n31 = - d * e ;
603
+ this . n32 = ad * f + bc ;
604
+ this . n33 = ac - bd * f ;
605
+ break ;
606
+
607
+ case 'XZY' :
608
+ var ac = a * c , ad = a * d , bc = b * c , bd = b * d ;
609
+
610
+ this . n11 = c * e ;
611
+ this . n12 = - f ;
612
+ this . n13 = d * e ;
613
+
614
+ this . n21 = ac * f + bd ;
615
+ this . n22 = a * e ;
616
+ this . n23 = ad * f - bc ;
617
+
618
+ this . n31 = bc * f - ad ;
619
+ this . n32 = b * e ;
620
+ this . n33 = bd * f + ac ;
621
+ break ;
622
+
623
+ default : // 'XYZ'
624
+ var ae = a * e , af = a * f , be = b * e , bf = b * f ;
625
+
626
+ this . n11 = c * e ;
627
+ this . n12 = - c * f ;
628
+ this . n13 = d ;
629
+
630
+ this . n21 = af + be * d ;
631
+ this . n22 = ae - bf * d ;
632
+ this . n23 = - b * c ;
633
+
634
+ this . n31 = bf - ae * d ;
635
+ this . n32 = be + af * d ;
636
+ this . n33 = a * c ;
637
+ break ;
638
+ }
554
639
555
640
return this ;
556
641
557
642
} ,
558
643
644
+
559
645
setRotationFromQuaternion : function ( q ) {
560
646
561
647
var x = q . x , y = q . y , z = q . z , w = q . w ,
0 commit comments