|
@@ -3,7 +3,6 @@
|
|
* @author alteredq / http://alteredqualia.com/
|
|
* @author alteredq / http://alteredqualia.com/
|
|
* @author WestLangley / http://github.com/WestLangley
|
|
* @author WestLangley / http://github.com/WestLangley
|
|
* @author bhouston / http://exocortex.com
|
|
* @author bhouston / http://exocortex.com
|
|
- * @author Hasan Kamal-Al-Deen / [email protected]
|
|
|
|
*/
|
|
*/
|
|
|
|
|
|
THREE.Quaternion = function( x, y, z, w ) {
|
|
THREE.Quaternion = function( x, y, z, w ) {
|
|
@@ -322,55 +321,6 @@ THREE.Quaternion.prototype = {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- toEuler: function ( order, optionalTarget ) {
|
|
|
|
-
|
|
|
|
- var result = optionalTarget || new THREE.Vector3();
|
|
|
|
-
|
|
|
|
- var qx = this.x,
|
|
|
|
- qy = this.y,
|
|
|
|
- qz = this.z,
|
|
|
|
- qw = this.w;
|
|
|
|
- var sqx = qx*qx,
|
|
|
|
- sqy = qy*qy,
|
|
|
|
- sqz = qz*qz,
|
|
|
|
- sqw = qw*qw;
|
|
|
|
-
|
|
|
|
- if ( order === undefined || order === 'XYZ' ) {
|
|
|
|
-
|
|
|
|
- var test = qw*qy - qx*qz;
|
|
|
|
-
|
|
|
|
- if (test > 0.4999) {
|
|
|
|
-
|
|
|
|
- result.x = 0;
|
|
|
|
- result.y = 90;
|
|
|
|
- result.z = -2 * Math.atan2(qx, qw);
|
|
|
|
-
|
|
|
|
- } else if (test < -0.4999) {
|
|
|
|
-
|
|
|
|
- result.x = 0;
|
|
|
|
- result.y = -90;
|
|
|
|
- result.z = 2 * Math.atan2(qx, qw);
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
-
|
|
|
|
- result.x = Math.atan2(2 * (qw*qx + qy*qz), sqw - sqx - sqy + sqz);
|
|
|
|
- result.y = Math.asin(2 * (qw*qy - qx*qz));
|
|
|
|
- result.z = Math.atan2(2 * (qx*qy + qw*qz), sqw + sqx - sqy - sqz);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
-
|
|
|
|
- // TODO: support more Euler orders.
|
|
|
|
- throw new Error( "Euler order not supported: " + order );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return result;
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
slerpSelf: function ( qb, t ) {
|
|
slerpSelf: function ( qb, t ) {
|
|
|
|
|
|
var x = this.x, y = this.y, z = this.z, w = this.w;
|
|
var x = this.x, y = this.y, z = this.z, w = this.w;
|