Selaa lähdekoodia

Vector2|3|4: Use `Math.trunc()` in `roundToZero()`. (#26643)

* use `Math.trunc`

* ci re-run
ycw 1 vuosi sitten
vanhempi
commit
0c67b52ef2
3 muutettua tiedostoa jossa 9 lisäystä ja 9 poistoa
  1. 2 2
      src/math/Vector2.js
  2. 3 3
      src/math/Vector3.js
  3. 4 4
      src/math/Vector4.js

+ 2 - 2
src/math/Vector2.js

@@ -293,8 +293,8 @@ class Vector2 {
 
 	roundToZero() {
 
-		this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
-		this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
+		this.x = Math.trunc( this.x );
+		this.y = Math.trunc( this.y );
 
 		return this;
 

+ 3 - 3
src/math/Vector3.js

@@ -397,9 +397,9 @@ class Vector3 {
 
 	roundToZero() {
 
-		this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
-		this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
-		this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
+		this.x = Math.trunc( this.x );
+		this.y = Math.trunc( this.y );
+		this.z = Math.trunc( this.z );
 
 		return this;
 

+ 4 - 4
src/math/Vector4.js

@@ -502,10 +502,10 @@ class Vector4 {
 
 	roundToZero() {
 
-		this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
-		this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
-		this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
-		this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
+		this.x = Math.trunc( this.x );
+		this.y = Math.trunc( this.y );
+		this.z = Math.trunc( this.z );
+		this.w = Math.trunc( this.w );
 
 		return this;