Option name | Type | Description |
---|---|---|
x | String | |
y | String | |
z | String |
Vector object to store and handle three related floating point values
function Vector(x, y, z) {
this.x = parseFloat(x);
this.y = parseFloat(y);
this.z = parseFloat(z);
}
Precision used in rounding during serialization/deserialization
Vector.PRECISION = 2;
Get the serailized JSON representation of the object
Vector.prototype.toJSON = function toJSON() {
return [this.x.toFixed(Vector.PRECISION), this.y.toFixed(Vector.PRECISION), this.z.toFixed(Vector.PRECISION)];
};
Option name | Type | Description |
---|---|---|
x | Array |
Creates a Vector object from a previously serialized JSON array
Vector.deserialize = function(val) {
return new Vector(val[0], val[1], val[2]);
};