THREE.Euler
用法 THREE.Euler( a , b , c , ‘xyz’ ); 表示将一个几何体绕x轴旋转a度,绕y轴旋转b度,绕z轴旋转c度;并且旋转的顺序是xyz ; 第三个参数旋转顺序可以是’XYZ’, ‘YZX’, ‘ZXY’, ‘XZY’, ‘YXZ’, ‘ZYX’
THREE.Euler = function ( x, y, z, order ) {
this ._x = x || 0 ;
this ._y = y || 0 ;
this ._z = z || 0 ;
this ._order = order || THREE.Euler.DefaultOrder;
};
原型上的方法
set( x , y , z , order )
set : function ( x, y, z, order ) {
this ._x = x;
this ._y = y;
this ._z = z;
this ._order = order || this ._order;
this .onChangeCallback();
return this ;
},
setFromRotationMatrix
setFromRotationMatrix: function ( m, order ) {
var clamp = THREE.Math.clamp;
var te = m.elements;
var m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ];
var m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ];
var m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];
order = order || this ._order;
if ( order === 'XYZ' ) {
this ._y = Math .asin( clamp( m13, - 1 , 1 ) );
if ( Math .abs( m13 ) < 0.99999 ) {
this ._x = Math .atan2( - m23, m33 );
this ._z = Math .atan2( - m12, m11 );
} else {
this ._x = Math .atan2( m32, m22 );
this ._z = 0 ;
}
} else if ( order === 'YXZ' ) {
this ._x = Math .asin( - clamp( m23, - 1 , 1 ) );
if ( Math .abs( m23 ) < 0.99999 ) {
this ._y = Math .atan2( m13, m33 );
this ._z = Math .atan2( m21, m22 );
} else {
this ._y = Math .atan2( - m31, m11 );
this ._z = 0 ;
}
} else if ( order === 'ZXY' ) {
this ._x = Math .asin( clamp( m32, - 1 , 1 ) );
if ( Math .abs( m32 ) < 0.99999 ) {
this ._y = Math .atan2( - m31, m33 );
this ._z = Math .atan2( - m12, m22 );
} else {
this ._y = 0 ;
this ._z = Math .atan2( m21, m11 );
}
} else if ( order === 'ZYX' ) {
this ._y = Math .asin( - clamp( m31, - 1 , 1 ) );
if ( Math .abs( m31 ) < 0.99999 ) {
this ._x = Math .atan2( m32, m33 );
this ._z = Math .atan2( m21, m11 );
} else {
this ._x = 0 ;
this ._z = Math .atan2( - m12, m22 );
}
} else if ( order === 'YZX' ) {
this ._z = Math .asin( clamp( m21, - 1 , 1 ) );
if ( Math .abs( m21 ) < 0.99999 ) {
this ._x = Math .atan2( - m23, m22 );
this ._y = Math .atan2( - m31, m11 );
} else {
this ._x = 0 ;
this ._y = Math .atan2( m13, m33 );
}
} else if ( order === 'XZY' ) {
this ._z = Math .asin( - clamp( m12, - 1 , 1 ) );
if ( Math .abs( m12 ) < 0.99999 ) {
this ._x = Math .atan2( m32, m22 );
this ._y = Math .atan2( m13, m11 );
} else {
this ._x = Math .atan2( - m23, m33 );
this ._y = 0 ;
}
} else {
console.warn( 'THREE.Euler: .setFromRotationMatrix() given unsupported order: ' + order )
}
this ._order = order;
this .onChangeCallback();
return this ;
},