vector fixes

beta.r3js.org
Theunis J. Botha 2016-11-23 12:44:57 +01:00
parent cae9d0034d
commit 50f04fd988
3 changed files with 14 additions and 59 deletions

View File

@ -131,43 +131,4 @@ GameLib.D3.Matrix4.prototype.lookAt = function (position, target, up) {
this.rows[2].z = z.z;
return this;
// te[ 0 ] = x.x; te[ 4 ] = y.x; te[ 8 ] = z.x;
// te[ 1 ] = x.y; te[ 5 ] = y.y; te[ 9 ] = z.y;
// te[ 2 ] = x.z; te[ 6 ] = y.z; te[ 10 ] = z.z;
// var matrix4 = new Matrix4();
//
// matrix4.rows[0] = side.negative();
// matrix4.rows[1] = _up;
// matrix4.rows[2] = forward;
//
// matrix4.setColumn(0, side.negative());
// matrix4.setColumn(1, _up);
// matrix4.setColumn(2, forward);
//return matrix4;
// return new Matrix4(
// new Vector4(
// side.x,
// side.y,
// side.z,
// side.negative().dot(position)
// ),
// new Vector4(
// _up.x,
// _up.y,
// _up.z,
// _up.negative().dot(position)
// ),
// new Vector4(
// forward.negative().x,
// forward.negative().y,
// forward.negative().z,
// forward.dot(position)
// )
// )
};

View File

@ -3,15 +3,21 @@ GameLib.D3.Vector2 = function Vector2(x, y) {
this.y = y || 0;
};
GameLib.D3.Vector2.prototype.copy = function() {
return new GameLib.D3.Vector2(
this.x,
this.y
);
GameLib.D3.Vector2.prototype.copy = function (v) {
if (!GameLib.D3.Utils.UndefinedOrNull(v)) {
this.x = v.x;
this.y = v.y;
return this;
} else {
return new GameLib.D3.Vector2(
this.x,
this.y
);
}
};
GameLib.D3.Vector2.prototype.equals = function(v) {
return !!(((this.x == v.x) &&
return (((this.x == v.x) &&
(this.y == v.y)) ||
((this.y == v.x) &&
(this.x == v.y)));
@ -60,18 +66,6 @@ GameLib.D3.Vector2.prototype.divide = function(v) {
}
};
GameLib.D3.Vector2.prototype.clone = function() {
return new GameLib.D3.Vector2(
this.x,
this.y
);
};
GameLib.D3.Vector2.prototype.copy = function(v) {
this.x = v.x;
this.y = v.y;
};
GameLib.D3.Vector2.prototype.set = function(x, y) {
this.x = x;
this.y = y;

View File

@ -301,7 +301,7 @@ GameLib.D3.Vector4.Points.prototype.average = function () {
);
};
GameLib.D3.Vector4.Points.prototype.negative = function () {
GameLib.D3.Vector4.Points.prototype.negate = function () {
for (var i = 0; i < this.vectors.length; i++) {
this.vectors[i].x *= -1;
@ -315,7 +315,7 @@ GameLib.D3.Vector4.Points.prototype.negative = function () {
GameLib.D3.Vector4.Points.prototype.toOrigin = function () {
var distanceFromOrigin = this.average().negative();
var distanceFromOrigin = this.average().negate();
for (var i = 0; i < this.vectors.length; i++) {
this.vectors[i].translate(distanceFromOrigin);