diff --git a/math/testing/matrix_test.js b/math/testing/matrix_test.js index 3b59a2280..741432caa 100644 --- a/math/testing/matrix_test.js +++ b/math/testing/matrix_test.js @@ -20,11 +20,11 @@ function testXmatrixMultiplyByVector() { // multiplying the matrix by the vector should result in the vector since the // matrix is the identity - vector = X.matrix.multiplyByVector(matrix, vector.x, vector.y, vector.z); + vector = X.matrix.multiplyByVector(matrix, vector.xx, vector.yy, vector.zz); - assertEquals(baseline.x, vector.x); - assertEquals(baseline.y, vector.y); - assertEquals(baseline.z, vector.z); + assertEquals(baseline.xx, vector.xx); + assertEquals(baseline.yy, vector.yy); + assertEquals(baseline.zz, vector.zz); } diff --git a/math/testing/vector_test.js b/math/testing/vector_test.js index 863d78af1..9bc263916 100644 --- a/math/testing/vector_test.js +++ b/math/testing/vector_test.js @@ -13,9 +13,9 @@ function testXvectorNormalize() { // scaling with (1/magnitude = 0.2672612419124244) // should result in // x=0.2672612419124244, y=0.5345224838248488, z=0.8017837257372732 - assertEquals(0.2672612419124244, vector.x); - assertEquals(0.5345224838248488, vector.y); - assertEquals(0.8017837257372732, vector.z); + assertEquals(0.2672612419124244, vector.xx); + assertEquals(0.5345224838248488, vector.yy); + assertEquals(0.8017837257372732, vector.zz); } @@ -27,9 +27,9 @@ function testXvectorNormalizeWithZeroMagnitude() { // normalize the vector vector.normalize(); - assertEquals(0, vector.x); - assertEquals(0, vector.y); - assertEquals(0, vector.z); + assertEquals(0, vector.xx); + assertEquals(0, vector.yy); + assertEquals(0, vector.zz); } diff --git a/math/vector.js b/math/vector.js index eb85e8869..b13bacf45 100644 --- a/math/vector.js +++ b/math/vector.js @@ -67,6 +67,48 @@ X.vector.cross = goog.math.Vec3.cross; X.vector.distance = goog.math.Vec3.distance; X.vector.lerp = goog.math.Vec3.lerp; +// now we need to make sure we can access the x,y,z +// components of a goog.math.Vec3 which might be renamed +// during the compilation. we don't want to modify the goog.math.Vec3 +// class so this is the easiest workaround. +/** + * Get the x component of this vector. + * + * @return {number} The x component of this vector. + * @public + */ +X.vector.prototype.__defineGetter__('xx', function() { + + return this.x; + +}); + + +/** + * Get the y component of this vector. + * + * @return {number} The y component of this vector. + * @public + */ +X.vector.prototype.__defineGetter__('yy', function() { + + return this.y; + +}); + + +/** + * Get the z component of this vector. + * + * @return {number} The z component of this vector. + * @public + */ +X.vector.prototype.__defineGetter__('zz', function() { + + return this.z; + +}); + goog.exportSymbol('X.vector', X.vector); goog.exportSymbol('X.vector.prototype.clone', X.vector.prototype.clone);