{"size": 2656, "ext": "js", "max_stars_repo_path": "src/core/Vector3.js", "max_stars_repo_name": "D1plo1d/three.js", "max_stars_repo_stars_event_min_datetime": "2015-10-18T17:21:19.000Z", "max_stars_repo_stars_event_max_datetime": "2015-10-18T17:21:19.000Z", "max_issues_repo_path": "src/core/Vector3.js", "max_issues_repo_name": "D1plo1d/three.js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/core/Vector3.js", "max_forks_repo_name": "D1plo1d/three.js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 14.1276595745, "max_line_length": 76, "alphanum_fraction": 0.5071536145}
/**
 * @author mr.doob / http://mrdoob.com/
 * @author kile / http://kile.stravaganza.org/
 */

THREE.Vector3 = function ( x, y, z ) {

	this.x = x || 0;
	this.y = y || 0;
	this.z = z || 0;

	this.setScalar = function ( s ) {

		this.x = s;
		this.y = s;
		this.z = s;
		return this;

	};

	this.set = function ( x, y, z ) {

		this.x = x;
		this.y = y;
		this.z = z;
		return this;

	};

	this.copy = function ( v ) {

		this.x = v.x;
		this.y = v.y;
		this.z = v.z;
		return this;

	};

	this.add = function( v1, v2 ) {

		this.x = v1.x + v2.x;
		this.y = v1.y + v2.y;
		this.z = v1.z + v2.z;
		return this;

	};

	this.addSelf = function ( v ) {

		this.x += v.x;
		this.y += v.y;
		this.z += v.z;
		return this;

	};

	this.addScalar = function ( s ) {

		this.x += s;
		this.y += s;
		this.z += s;
		return this;

	};

	this.sub = function( v1, v2 ) {

		this.x = v1.x - v2.x;
		this.y = v1.y - v2.y;
		this.z = v1.z - v2.z;
		return this;

	};

	this.subSelf = function ( v ) {

		this.x -= v.x;
		this.y -= v.y;
		this.z -= v.z;
		return this;

	};

	this.cross = function ( v1, v2 ) {

		this.x = v1.y * v2.z - v1.z * v2.y;
		this.y = v1.z * v2.x - v1.x * v2.z;
		this.z = v1.x * v2.y - v1.y * v2.x;
		return this;

	};

	this.crossSelf = function ( v ) {

		var tx = this.x, ty = this.y, tz = this.z;

		this.x = ty * v.z - tz * v.y;
		this.y = tz * v.x - tx * v.z;
		this.z = tx * v.y - ty * v.x;
		return this;

	};

	this.multiplySelf = function ( v ) {

		this.x *= v.x;
		this.y *= v.y;
		this.z *= v.z;
		return this;

	};

	this.multiplyScalar = function ( s ) {

		this.x *= s;
		this.y *= s;
		this.z *= s;
		return this;

	};

	this.dot = function ( v ) {

		return this.x * v.x + this.y * v.y + this.z * v.z;

	};

	this.distanceTo = function ( v ) {

		return Math.sqrt( this.distanceToSquared( v ) );

	};

	this.distanceToSquared = function ( v ) {

		var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
		return dx * dx + dy * dy + dz * dz;

	};

	this.length = function () {

		return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );

	};

	this.lengthSq = function () {

		return this.x * this.x + this.y * this.y + this.z * this.z;

	};

	this.negate = function () {

		this.x = - this.x;
		this.y = - this.y;
		this.z = - this.z;

	};

	this.normalize = function () {

		if (this.length() > 0) {

			this.multiplyScalar( 1 / this.length() );

		} else {

			this.multiplyScalar( 0 );

		}

	};

	this.clone = function () {

		return new THREE.Vector3( this.x, this.y, this.z );

	};

	this.toString = function () {

		return 'THREE.Vector3 ( ' + this.x + ', ' + this.y + ', ' + this.z + ' )';

	};

};
