1- import { MathUtils } from './MathUtils.js' ;
2-
31/**
42 * @author bhouston / http://clara.io
53 * @author WestLangley / http://github.com/WestLangley
@@ -10,61 +8,63 @@ import { MathUtils } from './MathUtils.js';
108 * The azimuthal angle (theta) is measured from the positive z-axis.
119 */
1210
13- function Spherical ( radius , phi , theta ) {
11+ import { MathUtils } from './MathUtils.js' ;
1412
15- this . radius = ( radius !== undefined ) ? radius : 1.0 ;
16- this . phi = ( phi !== undefined ) ? phi : 0 ; // polar angle
17- this . theta = ( theta !== undefined ) ? theta : 0 ; // azimuthal angle
13+ class Spherical {
1814
19- return this ;
15+ constructor ( radius = 1 , phi = 0 , theta = 0 ) {
2016
21- }
17+ this . radius = radius ;
18+ this . phi = phi ; // polar angle
19+ this . theta = theta ; // azimuthal angle
20+
21+ return this ;
2222
23- Object . assign ( Spherical . prototype , {
23+ }
2424
25- set : function ( radius , phi , theta ) {
25+ set ( radius , phi , theta ) {
2626
2727 this . radius = radius ;
2828 this . phi = phi ;
2929 this . theta = theta ;
3030
3131 return this ;
3232
33- } ,
33+ }
3434
35- clone : function ( ) {
35+ clone ( ) {
3636
3737 return new this . constructor ( ) . copy ( this ) ;
3838
39- } ,
39+ }
4040
41- copy : function ( other ) {
41+ copy ( other ) {
4242
4343 this . radius = other . radius ;
4444 this . phi = other . phi ;
4545 this . theta = other . theta ;
4646
4747 return this ;
4848
49- } ,
49+ }
5050
5151 // restrict phi to be betwee EPS and PI-EPS
52- makeSafe : function ( ) {
52+ makeSafe ( ) {
5353
5454 const EPS = 0.000001 ;
5555 this . phi = Math . max ( EPS , Math . min ( Math . PI - EPS , this . phi ) ) ;
5656
5757 return this ;
5858
59- } ,
59+ }
6060
61- setFromVector3 : function ( v ) {
61+ setFromVector3 ( v ) {
6262
6363 return this . setFromCartesianCoords ( v . x , v . y , v . z ) ;
6464
65- } ,
65+ }
6666
67- setFromCartesianCoords : function ( x , y , z ) {
67+ setFromCartesianCoords ( x , y , z ) {
6868
6969 this . radius = Math . sqrt ( x * x + y * y + z * z ) ;
7070
@@ -84,7 +84,6 @@ Object.assign( Spherical.prototype, {
8484
8585 }
8686
87- } ) ;
88-
87+ }
8988
9089export { Spherical } ;
0 commit comments