Comparing version
@@ -26,4 +26,12 @@ var util = require('util'); | ||
this.z = z; | ||
return this; | ||
}; | ||
Vec3.prototype.update = function(other) { | ||
this.x = other.x; | ||
this.y = other.y; | ||
this.z = other.z; | ||
return this; | ||
}; | ||
Vec3.prototype.floored = function() { | ||
@@ -30,0 +38,0 @@ return new Vec3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z)); |
{ | ||
"name": "vec3", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "3d vector math with good unit tests", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -54,2 +54,4 @@ # vec3 | ||
✓ volume | ||
✓ min | ||
✓ max | ||
@@ -56,0 +58,0 @@ |
@@ -159,3 +159,4 @@ var v = require('../') | ||
var v1 = new Vec3(12, 32, 46); | ||
v1.set(0, 10, 100); | ||
var v2 = v1.set(0, 10, 100); | ||
assert.strictEqual(v1, v2); | ||
assert.strictEqual(v1.x, 0); | ||
@@ -199,2 +200,14 @@ assert.strictEqual(v1.y, 10); | ||
}); | ||
it("update", function() { | ||
var v1 = new Vec3(-1, 0, 1); | ||
var v2 = new Vec3(10, -10, 1.1); | ||
var v3 = v1.update(v2); | ||
assert.strictEqual(v3, v1); | ||
assert.strictEqual(v1.x, 10); | ||
assert.strictEqual(v1.y, -10); | ||
assert.strictEqual(v1.z, 1.1); | ||
assert.strictEqual(v2.x, 10); | ||
assert.strictEqual(v2.y, -10); | ||
assert.strictEqual(v2.z, 1.1); | ||
}); | ||
}); |
10110
6.03%315
6.78%62
3.33%