提交 0c6219b4 编写于 作者: B Ben Nolan

* Made vector methods chainable

  * Added getCenter to Face4
上级 5ce7a10b
......@@ -22,6 +22,13 @@ THREE.Face4.prototype = {
return 'THREE.Face4 ( ' + this.a + ', ' + this.b + ', ' + this.c + ' ' + this.d + ' )';
},
getCenter : function(){
return this.a.clone().addSelf(this.b).addSelf(this.c).addSelf(this.d).divideScalar(4);
}
}
......@@ -30,6 +30,8 @@ THREE.Vector2.prototype = {
this.x += v.x;
this.y += v.y;
return this;
},
......@@ -45,6 +47,8 @@ THREE.Vector2.prototype = {
this.x -= v.x;
this.y -= v.y;
return this;
},
sub: function ( v1, v2 ) {
......@@ -59,6 +63,8 @@ THREE.Vector2.prototype = {
this.x *= s;
this.y *= s;
return this;
},
unit: function () {
......
......@@ -44,6 +44,8 @@ THREE.Vector3.prototype = {
this.y += v.y;
this.z += v.z;
return this;
},
addScalar: function ( s ) {
......@@ -52,6 +54,8 @@ THREE.Vector3.prototype = {
this.y += s;
this.z += s;
return this;
},
sub: function( v1, v2 ) {
......@@ -68,6 +72,8 @@ THREE.Vector3.prototype = {
this.y -= v.y;
this.z -= v.z;
return this;
},
cross: function ( v1, v2 ) {
......@@ -86,6 +92,8 @@ THREE.Vector3.prototype = {
this.y = tz * v.x - tx * v.z;
this.z = tx * v.y - ty * v.x;
return this;
},
multiplySelf: function ( v ) {
......@@ -94,6 +102,8 @@ THREE.Vector3.prototype = {
this.y *= v.y;
this.z *= v.z;
return this;
},
multiplyScalar: function ( s ) {
......@@ -102,6 +112,8 @@ THREE.Vector3.prototype = {
this.y *= s;
this.z *= s;
return this;
},
divideScalar: function ( s ) {
......@@ -110,6 +122,8 @@ THREE.Vector3.prototype = {
this.y /= s;
this.z /= s;
return this;
},
dot: function ( v ) {
......@@ -149,6 +163,8 @@ THREE.Vector3.prototype = {
this.y = - this.y;
this.z = - this.z;
return this;
},
normalize: function () {
......
......@@ -48,6 +48,8 @@ THREE.Vector4.prototype = {
this.z += v.z;
this.w += v.w;
return this;
},
sub: function ( v1, v2 ) {
......@@ -66,6 +68,8 @@ THREE.Vector4.prototype = {
this.z -= v.z;
this.w -= v.w;
return this;
},
clone: function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册