Browse Source

Euler/Quaternion/Vector*: Introduced constructor default values

Mr.doob 5 năm trước cách đây
mục cha
commit
84bad2e75d
5 tập tin đã thay đổi với 22 bổ sung22 xóa
  1. 5 5
      src/math/Euler.js
  2. 5 5
      src/math/Quaternion.js
  3. 3 3
      src/math/Vector2.js
  4. 4 4
      src/math/Vector3.js
  5. 5 5
      src/math/Vector4.js

+ 5 - 5
src/math/Euler.js

@@ -12,12 +12,12 @@ import { MathUtils } from './MathUtils.js';
 const _matrix = new Matrix4();
 const _quaternion = new Quaternion();
 
-function Euler( x, y, z, order ) {
+function Euler( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {
 
-	this._x = x || 0;
-	this._y = y || 0;
-	this._z = z || 0;
-	this._order = order || Euler.DefaultOrder;
+	this._x = x;
+	this._y = y;
+	this._z = z;
+	this._order = order;
 
 }
 

+ 5 - 5
src/math/Quaternion.js

@@ -7,12 +7,12 @@
 
 import { MathUtils } from './MathUtils.js';
 
-function Quaternion( x, y, z, w ) {
+function Quaternion( x = 0, y = 0, z = 0, w = 1 ) {
 
-	this._x = x || 0;
-	this._y = y || 0;
-	this._z = z || 0;
-	this._w = ( w !== undefined ) ? w : 1;
+	this._x = x;
+	this._y = y;
+	this._z = z;
+	this._w = w;
 
 }
 

+ 3 - 3
src/math/Vector2.js

@@ -5,10 +5,10 @@
  * @author zz85 / http://www.lab4games.net/zz85/blog
  */
 
-function Vector2( x, y ) {
+function Vector2( x = 0, y = 0 ) {
 
-	this.x = x || 0;
-	this.y = y || 0;
+	this.x = x;
+	this.y = y;
 
 }
 

+ 4 - 4
src/math/Vector3.js

@@ -13,11 +13,11 @@ import { Quaternion } from './Quaternion.js';
 const _vector = new Vector3();
 const _quaternion = new Quaternion();
 
-function Vector3( x, y, z ) {
+function Vector3( x = 0, y = 0, z = 0 ) {
 
-	this.x = x || 0;
-	this.y = y || 0;
-	this.z = z || 0;
+	this.x = x;
+	this.y = y;
+	this.z = z;
 
 }
 

+ 5 - 5
src/math/Vector4.js

@@ -6,12 +6,12 @@
  * @author WestLangley / http://github.com/WestLangley
  */
 
-function Vector4( x, y, z, w ) {
+function Vector4( x = 0, y = 0, z = 0, w = 1 ) {
 
-	this.x = x || 0;
-	this.y = y || 0;
-	this.z = z || 0;
-	this.w = ( w !== undefined ) ? w : 1;
+	this.x = x;
+	this.y = y;
+	this.z = z;
+	this.w = w;
 
 }