@@ -6,96 +6,80 @@ import { MathUtils } from './MathUtils.js';
66const _matrix = new Matrix4 ( ) ;
77const _quaternion = new Quaternion ( ) ;
88
9- function Euler ( x = 0 , y = 0 , z = 0 , order = Euler . DefaultOrder ) {
9+ class Euler {
1010
11- this . _x = x ;
12- this . _y = y ;
13- this . _z = z ;
14- this . _order = order ;
11+ constructor ( x = 0 , y = 0 , z = 0 , order = Euler . DefaultOrder ) {
1512
16- }
17-
18- Euler . RotationOrders = [ 'XYZ' , 'YZX' , 'ZXY' , 'XZY' , 'YXZ' , 'ZYX' ] ;
19-
20- Euler . DefaultOrder = 'XYZ' ;
21-
22- Object . defineProperties ( Euler . prototype , {
23-
24- x : {
25-
26- get : function ( ) {
27-
28- return this . _x ;
29-
30- } ,
31-
32- set : function ( value ) {
13+ this . _x = x ;
14+ this . _y = y ;
15+ this . _z = z ;
16+ this . _order = order ;
3317
34- this . _x = value ;
35- this . _onChangeCallback ( ) ;
18+ }
3619
37- }
20+ static RotationOrders = [ 'XYZ' , 'YZX' , 'ZXY' , 'XZY' , 'YXZ' , 'ZYX' ] ;
3821
39- } ,
22+ static DefaultOrder = 'XYZ' ;
4023
41- y : {
24+ get x ( ) {
4225
43- get : function ( ) {
26+ return this . _x ;
4427
45- return this . _y ;
28+ }
4629
47- } ,
30+ set x ( value ) {
4831
49- set : function ( value ) {
32+ this . _x = value ;
33+ this . _onChangeCallback ( ) ;
5034
51- this . _y = value ;
52- this . _onChangeCallback ( ) ;
35+ }
5336
54- }
37+ get y ( ) {
5538
56- } ,
39+ return this . _y ;
5740
58- z : {
41+ }
5942
60- get : function ( ) {
43+ set y ( value ) {
6144
62- return this . _z ;
45+ this . _y = value ;
46+ this . _onChangeCallback ( ) ;
6347
64- } ,
48+ }
6549
66- set : function ( value ) {
50+ get z ( ) {
6751
68- this . _z = value ;
69- this . _onChangeCallback ( ) ;
52+ return this . _z ;
7053
71- }
54+ }
7255
73- } ,
56+ set z ( value ) {
7457
75- order : {
58+ this . _z = value ;
59+ this . _onChangeCallback ( ) ;
7660
77- get : function ( ) {
61+ }
7862
79- return this . _order ;
63+ get order ( ) {
8064
81- } ,
65+ return this . _order ;
8266
83- set : function ( value ) {
67+ }
8468
85- this . _order = value ;
86- this . _onChangeCallback ( ) ;
69+ set order ( value ) {
8770
88- }
71+ this . _order = value ;
72+ this . _onChangeCallback ( ) ;
8973
9074 }
9175
92- } ) ;
76+ get isEuler ( ) {
9377
94- Object . assign ( Euler . prototype , {
78+ return true ;
9579
96- isEuler : true ,
80+ }
9781
98- set : function ( x , y , z , order ) {
82+ set ( x , y , z , order ) {
9983
10084 this . _x = x ;
10185 this . _y = y ;
@@ -106,15 +90,15 @@ Object.assign( Euler.prototype, {
10690
10791 return this ;
10892
109- } ,
93+ }
11094
111- clone : function ( ) {
95+ clone ( ) {
11296
11397 return new this . constructor ( this . _x , this . _y , this . _z , this . _order ) ;
11498
115- } ,
99+ }
116100
117- copy : function ( euler ) {
101+ copy ( euler ) {
118102
119103 this . _x = euler . _x ;
120104 this . _y = euler . _y ;
@@ -125,9 +109,9 @@ Object.assign( Euler.prototype, {
125109
126110 return this ;
127111
128- } ,
112+ }
129113
130- setFromRotationMatrix : function ( m , order , update ) {
114+ setFromRotationMatrix ( m , order , update ) {
131115
132116 const clamp = MathUtils . clamp ;
133117
@@ -262,39 +246,39 @@ Object.assign( Euler.prototype, {
262246
263247 return this ;
264248
265- } ,
249+ }
266250
267- setFromQuaternion : function ( q , order , update ) {
251+ setFromQuaternion ( q , order , update ) {
268252
269253 _matrix . makeRotationFromQuaternion ( q ) ;
270254
271255 return this . setFromRotationMatrix ( _matrix , order , update ) ;
272256
273- } ,
257+ }
274258
275- setFromVector3 : function ( v , order ) {
259+ setFromVector3 ( v , order ) {
276260
277261 return this . set ( v . x , v . y , v . z , order || this . _order ) ;
278262
279- } ,
263+ }
280264
281- reorder : function ( newOrder ) {
265+ reorder ( newOrder ) {
282266
283267 // WARNING: this discards revolution information -bhouston
284268
285269 _quaternion . setFromEuler ( this ) ;
286270
287271 return this . setFromQuaternion ( _quaternion , newOrder ) ;
288272
289- } ,
273+ }
290274
291- equals : function ( euler ) {
275+ equals ( euler ) {
292276
293277 return ( euler . _x === this . _x ) && ( euler . _y === this . _y ) && ( euler . _z === this . _z ) && ( euler . _order === this . _order ) ;
294278
295- } ,
279+ }
296280
297- fromArray : function ( array ) {
281+ fromArray ( array ) {
298282
299283 this . _x = array [ 0 ] ;
300284 this . _y = array [ 1 ] ;
@@ -305,9 +289,9 @@ Object.assign( Euler.prototype, {
305289
306290 return this ;
307291
308- } ,
292+ }
309293
310- toArray : function ( array , offset ) {
294+ toArray ( array , offset ) {
311295
312296 if ( array === undefined ) array = [ ] ;
313297 if ( offset === undefined ) offset = 0 ;
@@ -319,9 +303,9 @@ Object.assign( Euler.prototype, {
319303
320304 return array ;
321305
322- } ,
306+ }
323307
324- toVector3 : function ( optionalResult ) {
308+ toVector3 ( optionalResult ) {
325309
326310 if ( optionalResult ) {
327311
@@ -333,19 +317,19 @@ Object.assign( Euler.prototype, {
333317
334318 }
335319
336- } ,
320+ }
337321
338- _onChange : function ( callback ) {
322+ _onChange ( callback ) {
339323
340324 this . _onChangeCallback = callback ;
341325
342326 return this ;
343327
344- } ,
328+ }
345329
346- _onChangeCallback : function ( ) { }
330+ _onChangeCallback ( ) { }
347331
348- } ) ;
332+ }
349333
350334
351335export { Euler } ;
0 commit comments