|
@@ -6,96 +6,80 @@ import { MathUtils } from './MathUtils.js';
|
|
|
const _matrix = new Matrix4();
|
|
|
const _quaternion = new Quaternion();
|
|
|
|
|
|
-function Euler( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {
|
|
|
+class Euler {
|
|
|
|
|
|
- this._x = x;
|
|
|
- this._y = y;
|
|
|
- this._z = z;
|
|
|
- this._order = order;
|
|
|
+ constructor( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {
|
|
|
|
|
|
-}
|
|
|
-
|
|
|
-Euler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];
|
|
|
-
|
|
|
-Euler.DefaultOrder = 'XYZ';
|
|
|
-
|
|
|
-Object.defineProperties( Euler.prototype, {
|
|
|
-
|
|
|
- x: {
|
|
|
-
|
|
|
- get: function () {
|
|
|
-
|
|
|
- return this._x;
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- set: function ( value ) {
|
|
|
+ this._x = x;
|
|
|
+ this._y = y;
|
|
|
+ this._z = z;
|
|
|
+ this._order = order;
|
|
|
|
|
|
- this._x = value;
|
|
|
- this._onChangeCallback();
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ static RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];
|
|
|
|
|
|
- },
|
|
|
+ static DefaultOrder = 'XYZ';
|
|
|
|
|
|
- y: {
|
|
|
+ get x() {
|
|
|
|
|
|
- get: function () {
|
|
|
+ return this._x;
|
|
|
|
|
|
- return this._y;
|
|
|
+ }
|
|
|
|
|
|
- },
|
|
|
+ set x( value ) {
|
|
|
|
|
|
- set: function ( value ) {
|
|
|
+ this._x = value;
|
|
|
+ this._onChangeCallback();
|
|
|
|
|
|
- this._y = value;
|
|
|
- this._onChangeCallback();
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ get y() {
|
|
|
|
|
|
- },
|
|
|
+ return this._y;
|
|
|
|
|
|
- z: {
|
|
|
+ }
|
|
|
|
|
|
- get: function () {
|
|
|
+ set y( value ) {
|
|
|
|
|
|
- return this._z;
|
|
|
+ this._y = value;
|
|
|
+ this._onChangeCallback();
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- set: function ( value ) {
|
|
|
+ get z() {
|
|
|
|
|
|
- this._z = value;
|
|
|
- this._onChangeCallback();
|
|
|
+ return this._z;
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- },
|
|
|
+ set z( value ) {
|
|
|
|
|
|
- order: {
|
|
|
+ this._z = value;
|
|
|
+ this._onChangeCallback();
|
|
|
|
|
|
- get: function () {
|
|
|
+ }
|
|
|
|
|
|
- return this._order;
|
|
|
+ get order() {
|
|
|
|
|
|
- },
|
|
|
+ return this._order;
|
|
|
|
|
|
- set: function ( value ) {
|
|
|
+ }
|
|
|
|
|
|
- this._order = value;
|
|
|
- this._onChangeCallback();
|
|
|
+ set order( value ) {
|
|
|
|
|
|
- }
|
|
|
+ this._order = value;
|
|
|
+ this._onChangeCallback();
|
|
|
|
|
|
}
|
|
|
|
|
|
-} );
|
|
|
+ get isEuler() {
|
|
|
|
|
|
-Object.assign( Euler.prototype, {
|
|
|
+ return true;
|
|
|
|
|
|
- isEuler: true,
|
|
|
+ }
|
|
|
|
|
|
- set: function ( x, y, z, order ) {
|
|
|
+ set( x, y, z, order ) {
|
|
|
|
|
|
this._x = x;
|
|
|
this._y = y;
|
|
@@ -106,15 +90,15 @@ Object.assign( Euler.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- clone: function () {
|
|
|
+ clone() {
|
|
|
|
|
|
return new this.constructor( this._x, this._y, this._z, this._order );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- copy: function ( euler ) {
|
|
|
+ copy( euler ) {
|
|
|
|
|
|
this._x = euler._x;
|
|
|
this._y = euler._y;
|
|
@@ -125,9 +109,9 @@ Object.assign( Euler.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setFromRotationMatrix: function ( m, order, update ) {
|
|
|
+ setFromRotationMatrix( m, order, update ) {
|
|
|
|
|
|
const clamp = MathUtils.clamp;
|
|
|
|
|
@@ -262,23 +246,23 @@ Object.assign( Euler.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setFromQuaternion: function ( q, order, update ) {
|
|
|
+ setFromQuaternion( q, order, update ) {
|
|
|
|
|
|
_matrix.makeRotationFromQuaternion( q );
|
|
|
|
|
|
return this.setFromRotationMatrix( _matrix, order, update );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setFromVector3: function ( v, order ) {
|
|
|
+ setFromVector3( v, order ) {
|
|
|
|
|
|
return this.set( v.x, v.y, v.z, order || this._order );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- reorder: function ( newOrder ) {
|
|
|
+ reorder( newOrder ) {
|
|
|
|
|
|
// WARNING: this discards revolution information -bhouston
|
|
|
|
|
@@ -286,15 +270,15 @@ Object.assign( Euler.prototype, {
|
|
|
|
|
|
return this.setFromQuaternion( _quaternion, newOrder );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- equals: function ( euler ) {
|
|
|
+ equals( euler ) {
|
|
|
|
|
|
return ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- fromArray: function ( array ) {
|
|
|
+ fromArray( array ) {
|
|
|
|
|
|
this._x = array[ 0 ];
|
|
|
this._y = array[ 1 ];
|
|
@@ -305,9 +289,9 @@ Object.assign( Euler.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- toArray: function ( array, offset ) {
|
|
|
+ toArray( array, offset ) {
|
|
|
|
|
|
if ( array === undefined ) array = [];
|
|
|
if ( offset === undefined ) offset = 0;
|
|
@@ -319,9 +303,9 @@ Object.assign( Euler.prototype, {
|
|
|
|
|
|
return array;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- toVector3: function ( optionalResult ) {
|
|
|
+ toVector3( optionalResult ) {
|
|
|
|
|
|
if ( optionalResult ) {
|
|
|
|
|
@@ -333,19 +317,19 @@ Object.assign( Euler.prototype, {
|
|
|
|
|
|
}
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- _onChange: function ( callback ) {
|
|
|
+ _onChange( callback ) {
|
|
|
|
|
|
this._onChangeCallback = callback;
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- _onChangeCallback: function () {}
|
|
|
+ _onChangeCallback() {}
|
|
|
|
|
|
-} );
|
|
|
+}
|
|
|
|
|
|
|
|
|
export { Euler };
|