mirror of
https://github.com/photonstorm/phaser
synced 2024-11-28 07:31:11 +00:00
Vec3 and Vec4 can now take a Vec2, 3 or 4 as a valid type of the add, sub, mult and divide methods
This commit is contained in:
parent
d6fe678966
commit
809593ea34
2 changed files with 21 additions and 21 deletions
|
@ -32,7 +32,7 @@ var Vector3 = new Class({
|
|||
{
|
||||
this.x = src.x;
|
||||
this.y = src.y;
|
||||
this.z = src.z;
|
||||
this.z = src.z || 0;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -59,7 +59,7 @@ var Vector3 = new Class({
|
|||
{
|
||||
this.x += v.x;
|
||||
this.y += v.y;
|
||||
this.z += v.z;
|
||||
this.z += v.z || 0;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -68,7 +68,7 @@ var Vector3 = new Class({
|
|||
{
|
||||
this.x -= v.x;
|
||||
this.y -= v.y;
|
||||
this.z -= v.z;
|
||||
this.z -= v.z || 0;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -77,7 +77,7 @@ var Vector3 = new Class({
|
|||
{
|
||||
this.x *= v.x;
|
||||
this.y *= v.y;
|
||||
this.z *= v.z;
|
||||
this.z *= v.z || 1;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -95,7 +95,7 @@ var Vector3 = new Class({
|
|||
{
|
||||
this.x /= v.x;
|
||||
this.y /= v.y;
|
||||
this.z /= v.z;
|
||||
this.z /= v.z || 1;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -113,7 +113,7 @@ var Vector3 = new Class({
|
|||
{
|
||||
var dx = v.x - this.x;
|
||||
var dy = v.y - this.y;
|
||||
var dz = v.z - this.z;
|
||||
var dz = v.z - this.z || 0;
|
||||
|
||||
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
},
|
||||
|
@ -122,7 +122,7 @@ var Vector3 = new Class({
|
|||
{
|
||||
var dx = v.x - this.x;
|
||||
var dy = v.y - this.y;
|
||||
var dz = v.z - this.z;
|
||||
var dz = v.z - this.z || 0;
|
||||
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
},
|
||||
|
|
|
@ -34,8 +34,8 @@ var Vector4 = new Class({
|
|||
{
|
||||
this.x = src.x;
|
||||
this.y = src.y;
|
||||
this.z = src.z;
|
||||
this.w = src.w;
|
||||
this.z = src.z || 0;
|
||||
this.w = src.w || 0;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -64,8 +64,8 @@ var Vector4 = new Class({
|
|||
{
|
||||
this.x += v.x;
|
||||
this.y += v.y;
|
||||
this.z += v.z;
|
||||
this.w += v.w;
|
||||
this.z += v.z || 0;
|
||||
this.w += v.w || 0;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -74,8 +74,8 @@ var Vector4 = new Class({
|
|||
{
|
||||
this.x -= v.x;
|
||||
this.y -= v.y;
|
||||
this.z -= v.z;
|
||||
this.w -= v.w;
|
||||
this.z -= v.z || 0;
|
||||
this.w -= v.w || 0;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -157,8 +157,8 @@ var Vector4 = new Class({
|
|||
{
|
||||
this.x *= v.x;
|
||||
this.y *= v.y;
|
||||
this.z *= v.z;
|
||||
this.w *= v.w;
|
||||
this.z *= v.z || 1;
|
||||
this.w *= v.w || 1;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -167,8 +167,8 @@ var Vector4 = new Class({
|
|||
{
|
||||
this.x /= v.x;
|
||||
this.y /= v.y;
|
||||
this.z /= v.z;
|
||||
this.w /= v.w;
|
||||
this.z /= v.z || 1;
|
||||
this.w /= v.w || 1;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -177,8 +177,8 @@ var Vector4 = new Class({
|
|||
{
|
||||
var dx = v.x - this.x;
|
||||
var dy = v.y - this.y;
|
||||
var dz = v.z - this.z;
|
||||
var dw = v.w - this.w;
|
||||
var dz = v.z - this.z || 0;
|
||||
var dw = v.w - this.w || 0;
|
||||
|
||||
return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw);
|
||||
},
|
||||
|
@ -187,8 +187,8 @@ var Vector4 = new Class({
|
|||
{
|
||||
var dx = v.x - this.x;
|
||||
var dy = v.y - this.y;
|
||||
var dz = v.z - this.z;
|
||||
var dw = v.w - this.w;
|
||||
var dz = v.z - this.z || 0;
|
||||
var dw = v.w - this.w || 0;
|
||||
|
||||
return dx * dx + dy * dy + dz * dz + dw * dw;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue