Skip to content

Commit

Permalink
Merge pull request #20472 from linbingquan/dev-cleanup-math
Browse files Browse the repository at this point in the history
Math: Covert to ES6 default value.
  • Loading branch information
mrdoob authored Oct 8, 2020
2 parents b47af3a + c1f7d74 commit 4b1a71a
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 64 deletions.
9 changes: 2 additions & 7 deletions src/math/Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,7 @@ class Color {

}

fromArray( array, offset ) {

if ( offset === undefined ) offset = 0;
fromArray( array, offset = 0 ) {

this.r = array[ offset ];
this.g = array[ offset + 1 ];
Expand All @@ -561,10 +559,7 @@ class Color {

}

toArray( array, offset ) {

if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
toArray( array = [], offset = 0 ) {

array[ offset ] = this.r;
array[ offset + 1 ] = this.g;
Expand Down
5 changes: 1 addition & 4 deletions src/math/Euler.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,7 @@ class Euler {

}

toArray( array, offset ) {

if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
toArray( array = [], offset = 0 ) {

array[ offset ] = this._x;
array[ offset + 1 ] = this._y;
Expand Down
10 changes: 2 additions & 8 deletions src/math/Matrix3.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ class Matrix3 {

}

fromArray( array, offset ) {

if ( offset === undefined ) offset = 0;
fromArray( array, offset = 0 ) {

for ( let i = 0; i < 9; i ++ ) {

Expand All @@ -321,10 +319,7 @@ class Matrix3 {

}

toArray( array, offset ) {

if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
toArray( array = [], offset = 0 ) {

const te = this.elements;

Expand All @@ -346,5 +341,4 @@ class Matrix3 {

}


export { Matrix3 };
10 changes: 2 additions & 8 deletions src/math/Matrix4.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,9 +822,7 @@ class Matrix4 {

}

fromArray( array, offset ) {

if ( offset === undefined ) offset = 0;
fromArray( array, offset = 0 ) {

for ( let i = 0; i < 16; i ++ ) {

Expand All @@ -836,10 +834,7 @@ class Matrix4 {

}

toArray( array, offset ) {

if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
toArray( array = [], offset = 0 ) {

const te = this.elements;

Expand Down Expand Up @@ -877,5 +872,4 @@ const _x = /*@__PURE__*/ new Vector3();
const _y = /*@__PURE__*/ new Vector3();
const _z = /*@__PURE__*/ new Vector3();


export { Matrix4 };
10 changes: 2 additions & 8 deletions src/math/Quaternion.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,7 @@ class Quaternion {

}

fromArray( array, offset ) {

if ( offset === undefined ) offset = 0;
fromArray( array, offset = 0 ) {

this._x = array[ offset ];
this._y = array[ offset + 1 ];
Expand All @@ -604,10 +602,7 @@ class Quaternion {

}

toArray( array, offset ) {

if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
toArray( array = [], offset = 0 ) {

array[ offset ] = this._x;
array[ offset + 1 ] = this._y;
Expand Down Expand Up @@ -641,5 +636,4 @@ class Quaternion {

}


export { Quaternion };
9 changes: 2 additions & 7 deletions src/math/SphericalHarmonics3.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ class SphericalHarmonics3 {

}

fromArray( array, offset ) {

if ( offset === undefined ) offset = 0;
fromArray( array, offset = 0 ) {

const coefficients = this.coefficients;

Expand All @@ -201,10 +199,7 @@ class SphericalHarmonics3 {

}

toArray( array, offset ) {

if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
toArray( array = [], offset = 0 ) {

const coefficients = this.coefficients;

Expand Down
9 changes: 2 additions & 7 deletions src/math/Vector2.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,7 @@ class Vector2 {

}

fromArray( array, offset ) {

if ( offset === undefined ) offset = 0;
fromArray( array, offset = 0 ) {

this.x = array[ offset ];
this.y = array[ offset + 1 ];
Expand All @@ -427,10 +425,7 @@ class Vector2 {

}

toArray( array, offset ) {

if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
toArray( array = [], offset = 0 ) {

array[ offset ] = this.x;
array[ offset + 1 ] = this.y;
Expand Down
9 changes: 2 additions & 7 deletions src/math/Vector3.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,7 @@ class Vector3 {

}

fromArray( array, offset ) {

if ( offset === undefined ) offset = 0;
fromArray( array, offset = 0 ) {

this.x = array[ offset ];
this.y = array[ offset + 1 ];
Expand All @@ -679,10 +677,7 @@ class Vector3 {

}

toArray( array, offset ) {

if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
toArray( array = [], offset = 0 ) {

array[ offset ] = this.x;
array[ offset + 1 ] = this.y;
Expand Down
10 changes: 2 additions & 8 deletions src/math/Vector4.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,7 @@ class Vector4 {

}

fromArray( array, offset ) {

if ( offset === undefined ) offset = 0;
fromArray( array, offset = 0 ) {

this.x = array[ offset ];
this.y = array[ offset + 1 ];
Expand All @@ -602,10 +600,7 @@ class Vector4 {

}

toArray( array, offset ) {

if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
toArray( array = [], offset = 0 ) {

array[ offset ] = this.x;
array[ offset + 1 ] = this.y;
Expand Down Expand Up @@ -646,5 +641,4 @@ class Vector4 {

}


export { Vector4 };

0 comments on commit 4b1a71a

Please sign in to comment.