Browse Source

Merge pull request #19997 from yomotsu/move-to-es6-classes/math

math: move to es6 classes
Mr.doob 5 years ago
parent
commit
ff37eaa703
7 changed files with 682 additions and 757 deletions
  1. 67 89
      src/math/Euler.js
  2. 56 57
      src/math/Matrix3.js
  3. 93 93
      src/math/Matrix4.js
  4. 92 117
      src/math/Quaternion.js
  5. 115 128
      src/math/Vector2.js
  6. 150 151
      src/math/Vector3.js
  7. 109 122
      src/math/Vector4.js

+ 67 - 89
src/math/Euler.js

@@ -3,99 +3,70 @@ import { Vector3 } from './Vector3.js';
 import { Matrix4 } from './Matrix4.js';
 import { Matrix4 } from './Matrix4.js';
 import { MathUtils } from './MathUtils.js';
 import { MathUtils } from './MathUtils.js';
 
 
-const _matrix = new Matrix4();
-const _quaternion = new Quaternion();
-
-function Euler( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {
-
-	this._x = x;
-	this._y = y;
-	this._z = z;
-	this._order = order;
-
-}
-
-Euler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];
-
-Euler.DefaultOrder = 'XYZ';
-
-Object.defineProperties( Euler.prototype, {
-
-	x: {
-
-		get: function () {
-
-			return this._x;
-
-		},
+class Euler {
 
 
-		set: function ( value ) {
+	constructor( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {
 
 
-			this._x = value;
-			this._onChangeCallback();
-
-		}
-
-	},
-
-	y: {
-
-		get: function () {
+		this._x = x;
+		this._y = y;
+		this._z = z;
+		this._order = order;
 
 
-			return this._y;
+	}
 
 
-		},
+	get x() {
 
 
-		set: function ( value ) {
+		return this._x;
 
 
-			this._y = value;
-			this._onChangeCallback();
+	}
 
 
-		}
+	set x( value ) {
 
 
-	},
+		this._x = value;
+		this._onChangeCallback();
 
 
-	z: {
+	}
 
 
-		get: function () {
+	get y() {
 
 
-			return this._z;
+		return this._y;
 
 
-		},
+	}
 
 
-		set: function ( value ) {
+	set y( value ) {
 
 
-			this._z = value;
-			this._onChangeCallback();
+		this._y = value;
+		this._onChangeCallback();
 
 
-		}
+	}
 
 
-	},
+	get z() {
 
 
-	order: {
+		return this._z;
 
 
-		get: function () {
+	}
 
 
-			return this._order;
+	set z( value ) {
 
 
-		},
+		this._z = value;
+		this._onChangeCallback();
 
 
-		set: function ( value ) {
+	}
 
 
-			this._order = value;
-			this._onChangeCallback();
+	get order() {
 
 
-		}
+		return this._order;
 
 
 	}
 	}
 
 
-} );
+	set order( value ) {
 
 
-Object.assign( Euler.prototype, {
+		this._order = value;
+		this._onChangeCallback();
 
 
-	isEuler: true,
+	}
 
 
-	set: function ( x, y, z, order ) {
+	set( x, y, z, order ) {
 
 
 		this._x = x;
 		this._x = x;
 		this._y = y;
 		this._y = y;
@@ -106,15 +77,15 @@ Object.assign( Euler.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clone: function () {
+	clone() {
 
 
 		return new this.constructor( this._x, this._y, this._z, this._order );
 		return new this.constructor( this._x, this._y, this._z, this._order );
 
 
-	},
+	}
 
 
-	copy: function ( euler ) {
+	copy( euler ) {
 
 
 		this._x = euler._x;
 		this._x = euler._x;
 		this._y = euler._y;
 		this._y = euler._y;
@@ -125,9 +96,9 @@ Object.assign( Euler.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromRotationMatrix: function ( m, order, update ) {
+	setFromRotationMatrix( m, order, update ) {
 
 
 		const clamp = MathUtils.clamp;
 		const clamp = MathUtils.clamp;
 
 
@@ -262,23 +233,23 @@ Object.assign( Euler.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromQuaternion: function ( q, order, update ) {
+	setFromQuaternion( q, order, update ) {
 
 
 		_matrix.makeRotationFromQuaternion( q );
 		_matrix.makeRotationFromQuaternion( q );
 
 
 		return this.setFromRotationMatrix( _matrix, order, update );
 		return this.setFromRotationMatrix( _matrix, order, update );
 
 
-	},
+	}
 
 
-	setFromVector3: function ( v, order ) {
+	setFromVector3( v, order ) {
 
 
 		return this.set( v.x, v.y, v.z, order || this._order );
 		return this.set( v.x, v.y, v.z, order || this._order );
 
 
-	},
+	}
 
 
-	reorder: function ( newOrder ) {
+	reorder( newOrder ) {
 
 
 		// WARNING: this discards revolution information -bhouston
 		// WARNING: this discards revolution information -bhouston
 
 
@@ -286,15 +257,15 @@ Object.assign( Euler.prototype, {
 
 
 		return this.setFromQuaternion( _quaternion, newOrder );
 		return this.setFromQuaternion( _quaternion, newOrder );
 
 
-	},
+	}
 
 
-	equals: function ( euler ) {
+	equals( euler ) {
 
 
 		return ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );
 		return ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );
 
 
-	},
+	}
 
 
-	fromArray: function ( array ) {
+	fromArray( array ) {
 
 
 		this._x = array[ 0 ];
 		this._x = array[ 0 ];
 		this._y = array[ 1 ];
 		this._y = array[ 1 ];
@@ -305,9 +276,9 @@ Object.assign( Euler.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	toArray: function ( array, offset ) {
+	toArray( array, offset ) {
 
 
 		if ( array === undefined ) array = [];
 		if ( array === undefined ) array = [];
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
@@ -319,9 +290,9 @@ Object.assign( Euler.prototype, {
 
 
 		return array;
 		return array;
 
 
-	},
+	}
 
 
-	toVector3: function ( optionalResult ) {
+	toVector3( optionalResult ) {
 
 
 		if ( optionalResult ) {
 		if ( optionalResult ) {
 
 
@@ -333,19 +304,26 @@ Object.assign( Euler.prototype, {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	_onChange: function ( callback ) {
+	_onChange( callback ) {
 
 
 		this._onChangeCallback = callback;
 		this._onChangeCallback = callback;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
+
+	_onChangeCallback() {}
 
 
-	_onChangeCallback: function () {}
+}
 
 
-} );
+Euler.DefaultOrder = 'XYZ';
+Euler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];
+Euler.prototype.isEuler = true;
+
+const _matrix = new Matrix4();
+const _quaternion = new Quaternion();
 
 
 
 
 export { Euler };
 export { Euler };

+ 56 - 57
src/math/Matrix3.js

@@ -1,26 +1,24 @@
-function Matrix3() {
+class Matrix3 {
 
 
-	this.elements = [
+	constructor() {
 
 
-		1, 0, 0,
-		0, 1, 0,
-		0, 0, 1
+		this.elements = [
 
 
-	];
-
-	if ( arguments.length > 0 ) {
+			1, 0, 0,
+			0, 1, 0,
+			0, 0, 1
 
 
-		console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );
+		];
 
 
-	}
+		if ( arguments.length > 0 ) {
 
 
-}
+			console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );
 
 
-Object.assign( Matrix3.prototype, {
+		}
 
 
-	isMatrix3: true,
+	}
 
 
-	set: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {
+	set( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -30,9 +28,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	identity: function () {
+	identity() {
 
 
 		this.set(
 		this.set(
 
 
@@ -44,15 +42,15 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clone: function () {
+	clone() {
 
 
 		return new this.constructor().fromArray( this.elements );
 		return new this.constructor().fromArray( this.elements );
 
 
-	},
+	}
 
 
-	copy: function ( m ) {
+	copy( m ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 		const me = m.elements;
 		const me = m.elements;
@@ -63,9 +61,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	extractBasis: function ( xAxis, yAxis, zAxis ) {
+	extractBasis( xAxis, yAxis, zAxis ) {
 
 
 		xAxis.setFromMatrix3Column( this, 0 );
 		xAxis.setFromMatrix3Column( this, 0 );
 		yAxis.setFromMatrix3Column( this, 1 );
 		yAxis.setFromMatrix3Column( this, 1 );
@@ -73,9 +71,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromMatrix4: function ( m ) {
+	setFromMatrix4( m ) {
 
 
 		const me = m.elements;
 		const me = m.elements;
 
 
@@ -89,21 +87,21 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiply: function ( m ) {
+	multiply( m ) {
 
 
 		return this.multiplyMatrices( this, m );
 		return this.multiplyMatrices( this, m );
 
 
-	},
+	}
 
 
-	premultiply: function ( m ) {
+	premultiply( m ) {
 
 
 		return this.multiplyMatrices( m, this );
 		return this.multiplyMatrices( m, this );
 
 
-	},
+	}
 
 
-	multiplyMatrices: function ( a, b ) {
+	multiplyMatrices( a, b ) {
 
 
 		const ae = a.elements;
 		const ae = a.elements;
 		const be = b.elements;
 		const be = b.elements;
@@ -131,9 +129,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiplyScalar: function ( s ) {
+	multiplyScalar( s ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -143,9 +141,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	determinant: function () {
+	determinant() {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -155,9 +153,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
 		return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
 
 
-	},
+	}
 
 
-	getInverse: function ( matrix, throwOnDegenerate ) {
+	getInverse( matrix, throwOnDegenerate ) {
 
 
 		if ( throwOnDegenerate !== undefined ) {
 		if ( throwOnDegenerate !== undefined ) {
 
 
@@ -196,9 +194,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	transpose: function () {
+	transpose() {
 
 
 		let tmp;
 		let tmp;
 		const m = this.elements;
 		const m = this.elements;
@@ -209,15 +207,15 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	getNormalMatrix: function ( matrix4 ) {
+	getNormalMatrix( matrix4 ) {
 
 
 		return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();
 		return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();
 
 
-	},
+	}
 
 
-	transposeIntoArray: function ( r ) {
+	transposeIntoArray( r ) {
 
 
 		const m = this.elements;
 		const m = this.elements;
 
 
@@ -233,9 +231,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) {
+	setUvTransform( tx, ty, sx, sy, rotation, cx, cy ) {
 
 
 		const c = Math.cos( rotation );
 		const c = Math.cos( rotation );
 		const s = Math.sin( rotation );
 		const s = Math.sin( rotation );
@@ -246,9 +244,9 @@ Object.assign( Matrix3.prototype, {
 			0, 0, 1
 			0, 0, 1
 		);
 		);
 
 
-	},
+	}
 
 
-	scale: function ( sx, sy ) {
+	scale( sx, sy ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -257,9 +255,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	rotate: function ( theta ) {
+	rotate( theta ) {
 
 
 		const c = Math.cos( theta );
 		const c = Math.cos( theta );
 		const s = Math.sin( theta );
 		const s = Math.sin( theta );
@@ -279,9 +277,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	translate: function ( tx, ty ) {
+	translate( tx, ty ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -290,9 +288,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	equals: function ( matrix ) {
+	equals( matrix ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 		const me = matrix.elements;
 		const me = matrix.elements;
@@ -305,9 +303,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return true;
 		return true;
 
 
-	},
+	}
 
 
-	fromArray: function ( array, offset ) {
+	fromArray( array, offset ) {
 
 
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
 
 
@@ -319,9 +317,9 @@ Object.assign( Matrix3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	toArray: function ( array, offset ) {
+	toArray( array, offset ) {
 
 
 		if ( array === undefined ) array = [];
 		if ( array === undefined ) array = [];
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
@@ -344,7 +342,8 @@ Object.assign( Matrix3.prototype, {
 
 
 	}
 	}
 
 
-} );
+}
 
 
+Matrix3.prototype.isMatrix3 = true;
 
 
 export { Matrix3 };
 export { Matrix3 };

+ 93 - 93
src/math/Matrix4.js

@@ -1,37 +1,27 @@
 import { Vector3 } from './Vector3.js';
 import { Vector3 } from './Vector3.js';
 
 
-const _v1 = new Vector3();
-const _m1 = new Matrix4();
-const _zero = new Vector3( 0, 0, 0 );
-const _one = new Vector3( 1, 1, 1 );
-const _x = new Vector3();
-const _y = new Vector3();
-const _z = new Vector3();
-
-function Matrix4() {
+class Matrix4 {
 
 
-	this.elements = [
+	constructor() {
 
 
-		1, 0, 0, 0,
-		0, 1, 0, 0,
-		0, 0, 1, 0,
-		0, 0, 0, 1
+		this.elements = [
 
 
-	];
-
-	if ( arguments.length > 0 ) {
+			1, 0, 0, 0,
+			0, 1, 0, 0,
+			0, 0, 1, 0,
+			0, 0, 0, 1
 
 
-		console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );
+		];
 
 
-	}
+		if ( arguments.length > 0 ) {
 
 
-}
+			console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );
 
 
-Object.assign( Matrix4.prototype, {
+		}
 
 
-	isMatrix4: true,
+	}
 
 
-	set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
+	set( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -42,9 +32,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	identity: function () {
+	identity() {
 
 
 		this.set(
 		this.set(
 
 
@@ -57,15 +47,15 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clone: function () {
+	clone() {
 
 
 		return new Matrix4().fromArray( this.elements );
 		return new Matrix4().fromArray( this.elements );
 
 
-	},
+	}
 
 
-	copy: function ( m ) {
+	copy( m ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 		const me = m.elements;
 		const me = m.elements;
@@ -77,9 +67,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	copyPosition: function ( m ) {
+	copyPosition( m ) {
 
 
 		const te = this.elements, me = m.elements;
 		const te = this.elements, me = m.elements;
 
 
@@ -89,9 +79,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	extractBasis: function ( xAxis, yAxis, zAxis ) {
+	extractBasis( xAxis, yAxis, zAxis ) {
 
 
 		xAxis.setFromMatrixColumn( this, 0 );
 		xAxis.setFromMatrixColumn( this, 0 );
 		yAxis.setFromMatrixColumn( this, 1 );
 		yAxis.setFromMatrixColumn( this, 1 );
@@ -99,9 +89,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	makeBasis: function ( xAxis, yAxis, zAxis ) {
+	makeBasis( xAxis, yAxis, zAxis ) {
 
 
 		this.set(
 		this.set(
 			xAxis.x, yAxis.x, zAxis.x, 0,
 			xAxis.x, yAxis.x, zAxis.x, 0,
@@ -112,9 +102,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	extractRotation: function ( m ) {
+	extractRotation( m ) {
 
 
 		// this method does not support reflection matrices
 		// this method does not support reflection matrices
 
 
@@ -147,9 +137,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	makeRotationFromEuler: function ( euler ) {
+	makeRotationFromEuler( euler ) {
 
 
 		if ( ! ( euler && euler.isEuler ) ) {
 		if ( ! ( euler && euler.isEuler ) ) {
 
 
@@ -275,15 +265,15 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	makeRotationFromQuaternion: function ( q ) {
+	makeRotationFromQuaternion( q ) {
 
 
 		return this.compose( _zero, q, _one );
 		return this.compose( _zero, q, _one );
 
 
-	},
+	}
 
 
-	lookAt: function ( eye, target, up ) {
+	lookAt( eye, target, up ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -328,9 +318,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiply: function ( m, n ) {
+	multiply( m, n ) {
 
 
 		if ( n !== undefined ) {
 		if ( n !== undefined ) {
 
 
@@ -341,15 +331,15 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this.multiplyMatrices( this, m );
 		return this.multiplyMatrices( this, m );
 
 
-	},
+	}
 
 
-	premultiply: function ( m ) {
+	premultiply( m ) {
 
 
 		return this.multiplyMatrices( m, this );
 		return this.multiplyMatrices( m, this );
 
 
-	},
+	}
 
 
-	multiplyMatrices: function ( a, b ) {
+	multiplyMatrices( a, b ) {
 
 
 		const ae = a.elements;
 		const ae = a.elements;
 		const be = b.elements;
 		const be = b.elements;
@@ -387,9 +377,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiplyScalar: function ( s ) {
+	multiplyScalar( s ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -400,9 +390,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	determinant: function () {
+	determinant() {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -450,9 +440,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		);
 		);
 
 
-	},
+	}
 
 
-	transpose: function () {
+	transpose() {
 
 
 		const te = this.elements;
 		const te = this.elements;
 		let tmp;
 		let tmp;
@@ -467,9 +457,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setPosition: function ( x, y, z ) {
+	setPosition( x, y, z ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -489,9 +479,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	getInverse: function ( m, throwOnDegenerate ) {
+	getInverse( m, throwOnDegenerate ) {
 
 
 		if ( throwOnDegenerate !== undefined ) {
 		if ( throwOnDegenerate !== undefined ) {
 
 
@@ -541,9 +531,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	scale: function ( v ) {
+	scale( v ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 		const x = v.x, y = v.y, z = v.z;
 		const x = v.x, y = v.y, z = v.z;
@@ -555,9 +545,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	getMaxScaleOnAxis: function () {
+	getMaxScaleOnAxis() {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -567,9 +557,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );
 		return Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );
 
 
-	},
+	}
 
 
-	makeTranslation: function ( x, y, z ) {
+	makeTranslation( x, y, z ) {
 
 
 		this.set(
 		this.set(
 
 
@@ -582,9 +572,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	makeRotationX: function ( theta ) {
+	makeRotationX( theta ) {
 
 
 		const c = Math.cos( theta ), s = Math.sin( theta );
 		const c = Math.cos( theta ), s = Math.sin( theta );
 
 
@@ -599,9 +589,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	makeRotationY: function ( theta ) {
+	makeRotationY( theta ) {
 
 
 		const c = Math.cos( theta ), s = Math.sin( theta );
 		const c = Math.cos( theta ), s = Math.sin( theta );
 
 
@@ -616,9 +606,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	makeRotationZ: function ( theta ) {
+	makeRotationZ( theta ) {
 
 
 		const c = Math.cos( theta ), s = Math.sin( theta );
 		const c = Math.cos( theta ), s = Math.sin( theta );
 
 
@@ -633,9 +623,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	makeRotationAxis: function ( axis, angle ) {
+	makeRotationAxis( axis, angle ) {
 
 
 		// Based on http://www.gamedev.net/reference/articles/article1199.asp
 		// Based on http://www.gamedev.net/reference/articles/article1199.asp
 
 
@@ -654,11 +644,11 @@ Object.assign( Matrix4.prototype, {
 
 
 		);
 		);
 
 
-		 return this;
+		return this;
 
 
-	},
+	}
 
 
-	makeScale: function ( x, y, z ) {
+	makeScale( x, y, z ) {
 
 
 		this.set(
 		this.set(
 
 
@@ -671,9 +661,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	makeShear: function ( x, y, z ) {
+	makeShear( x, y, z ) {
 
 
 		this.set(
 		this.set(
 
 
@@ -686,9 +676,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	compose: function ( position, quaternion, scale ) {
+	compose( position, quaternion, scale ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -722,9 +712,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	decompose: function ( position, quaternion, scale ) {
+	decompose( position, quaternion, scale ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 
 
@@ -767,9 +757,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	makePerspective: function ( left, right, top, bottom, near, far ) {
+	makePerspective( left, right, top, bottom, near, far ) {
 
 
 		if ( far === undefined ) {
 		if ( far === undefined ) {
 
 
@@ -793,9 +783,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	makeOrthographic: function ( left, right, top, bottom, near, far ) {
+	makeOrthographic( left, right, top, bottom, near, far ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 		const w = 1.0 / ( right - left );
 		const w = 1.0 / ( right - left );
@@ -813,9 +803,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	equals: function ( matrix ) {
+	equals( matrix ) {
 
 
 		const te = this.elements;
 		const te = this.elements;
 		const me = matrix.elements;
 		const me = matrix.elements;
@@ -828,9 +818,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return true;
 		return true;
 
 
-	},
+	}
 
 
-	fromArray: function ( array, offset ) {
+	fromArray( array, offset ) {
 
 
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
 
 
@@ -842,9 +832,9 @@ Object.assign( Matrix4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	toArray: function ( array, offset ) {
+	toArray( array, offset ) {
 
 
 		if ( array === undefined ) array = [];
 		if ( array === undefined ) array = [];
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
@@ -875,7 +865,17 @@ Object.assign( Matrix4.prototype, {
 
 
 	}
 	}
 
 
-} );
+}
+
+Matrix4.prototype.isMatrix4 = true;
+
+const _v1 = new Vector3();
+const _m1 = new Matrix4();
+const _zero = new Vector3( 0, 0, 0 );
+const _one = new Vector3( 1, 1, 1 );
+const _x = new Vector3();
+const _y = new Vector3();
+const _z = new Vector3();
 
 
 
 
 export { Matrix4 };
 export { Matrix4 };

+ 92 - 117
src/math/Quaternion.js

@@ -1,23 +1,23 @@
 import { MathUtils } from './MathUtils.js';
 import { MathUtils } from './MathUtils.js';
 
 
-function Quaternion( x = 0, y = 0, z = 0, w = 1 ) {
+class Quaternion {
 
 
-	this._x = x;
-	this._y = y;
-	this._z = z;
-	this._w = w;
+	constructor( x = 0, y = 0, z = 0, w = 1 ) {
 
 
-}
+		this._x = x;
+		this._y = y;
+		this._z = z;
+		this._w = w;
 
 
-Object.assign( Quaternion, {
+	}
 
 
-	slerp: function ( qa, qb, qm, t ) {
+	static slerp( qa, qb, qm, t ) {
 
 
 		return qm.copy( qa ).slerp( qb, t );
 		return qm.copy( qa ).slerp( qb, t );
 
 
-	},
+	}
 
 
-	slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
+	static slerpFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
 
 
 		// fuzz-free, array-based Quaternion SLERP operation
 		// fuzz-free, array-based Quaternion SLERP operation
 
 
@@ -75,9 +75,9 @@ Object.assign( Quaternion, {
 		dst[ dstOffset + 2 ] = z0;
 		dst[ dstOffset + 2 ] = z0;
 		dst[ dstOffset + 3 ] = w0;
 		dst[ dstOffset + 3 ] = w0;
 
 
-	},
+	}
 
 
-	multiplyQuaternionsFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) {
+	static multiplyQuaternionsFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) {
 
 
 		const x0 = src0[ srcOffset0 ];
 		const x0 = src0[ srcOffset0 ];
 		const y0 = src0[ srcOffset0 + 1 ];
 		const y0 = src0[ srcOffset0 + 1 ];
@@ -98,85 +98,59 @@ Object.assign( Quaternion, {
 
 
 	}
 	}
 
 
-} );
-
-Object.defineProperties( Quaternion.prototype, {
+	get x() {
 
 
-	x: {
-
-		get: function () {
-
-			return this._x;
-
-		},
-
-		set: function ( value ) {
-
-			this._x = value;
-			this._onChangeCallback();
-
-		}
+		return this._x;
 
 
-	},
-
-	y: {
-
-		get: function () {
-
-			return this._y;
-
-		},
-
-		set: function ( value ) {
-
-			this._y = value;
-			this._onChangeCallback();
+	}
 
 
-		}
+	set x( value ) {
 
 
-	},
+		this._x = value;
+		this._onChangeCallback();
 
 
-	z: {
+	}
 
 
-		get: function () {
+	get y() {
 
 
-			return this._z;
+		return this._y;
 
 
-		},
+	}
 
 
-		set: function ( value ) {
+	set y( value ) {
 
 
-			this._z = value;
-			this._onChangeCallback();
+		this._y = value;
+		this._onChangeCallback();
 
 
-		}
+	}
 
 
-	},
+	get z() {
 
 
-	w: {
+		return this._z;
 
 
-		get: function () {
+	}
 
 
-			return this._w;
+	set z( value ) {
 
 
-		},
+		this._z = value;
+		this._onChangeCallback();
 
 
-		set: function ( value ) {
+	}
 
 
-			this._w = value;
-			this._onChangeCallback();
+	get w() {
 
 
-		}
+		return this._w;
 
 
 	}
 	}
 
 
-} );
+	set w( value ) {
 
 
-Object.assign( Quaternion.prototype, {
+		this._w = value;
+		this._onChangeCallback();
 
 
-	isQuaternion: true,
+	}
 
 
-	set: function ( x, y, z, w ) {
+	set( x, y, z, w ) {
 
 
 		this._x = x;
 		this._x = x;
 		this._y = y;
 		this._y = y;
@@ -187,15 +161,15 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clone: function () {
+	clone() {
 
 
 		return new this.constructor( this._x, this._y, this._z, this._w );
 		return new this.constructor( this._x, this._y, this._z, this._w );
 
 
-	},
+	}
 
 
-	copy: function ( quaternion ) {
+	copy( quaternion ) {
 
 
 		this._x = quaternion.x;
 		this._x = quaternion.x;
 		this._y = quaternion.y;
 		this._y = quaternion.y;
@@ -206,9 +180,9 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromEuler: function ( euler, update ) {
+	setFromEuler( euler, update ) {
 
 
 		if ( ! ( euler && euler.isEuler ) ) {
 		if ( ! ( euler && euler.isEuler ) ) {
 
 
@@ -286,9 +260,9 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromAxisAngle: function ( axis, angle ) {
+	setFromAxisAngle( axis, angle ) {
 
 
 		// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
 		// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
 
 
@@ -305,9 +279,9 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromRotationMatrix: function ( m ) {
+	setFromRotationMatrix( m ) {
 
 
 		// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
 		// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
 
 
@@ -363,9 +337,9 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromUnitVectors: function ( vFrom, vTo ) {
+	setFromUnitVectors( vFrom, vTo ) {
 
 
 		// assumes direction vectors vFrom and vTo are normalized
 		// assumes direction vectors vFrom and vTo are normalized
 
 
@@ -406,15 +380,15 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this.normalize();
 		return this.normalize();
 
 
-	},
+	}
 
 
-	angleTo: function ( q ) {
+	angleTo( q ) {
 
 
 		return 2 * Math.acos( Math.abs( MathUtils.clamp( this.dot( q ), - 1, 1 ) ) );
 		return 2 * Math.acos( Math.abs( MathUtils.clamp( this.dot( q ), - 1, 1 ) ) );
 
 
-	},
+	}
 
 
-	rotateTowards: function ( q, step ) {
+	rotateTowards( q, step ) {
 
 
 		const angle = this.angleTo( q );
 		const angle = this.angleTo( q );
 
 
@@ -426,23 +400,23 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	identity: function () {
+	identity() {
 
 
 		return this.set( 0, 0, 0, 1 );
 		return this.set( 0, 0, 0, 1 );
 
 
-	},
+	}
 
 
-	inverse: function () {
+	inverse() {
 
 
 		// quaternion is assumed to have unit length
 		// quaternion is assumed to have unit length
 
 
 		return this.conjugate();
 		return this.conjugate();
 
 
-	},
+	}
 
 
-	conjugate: function () {
+	conjugate() {
 
 
 		this._x *= - 1;
 		this._x *= - 1;
 		this._y *= - 1;
 		this._y *= - 1;
@@ -452,27 +426,27 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	dot: function ( v ) {
+	dot( v ) {
 
 
 		return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
 		return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
 
 
-	},
+	}
 
 
-	lengthSq: function () {
+	lengthSq() {
 
 
 		return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
 		return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
 
 
-	},
+	}
 
 
-	length: function () {
+	length() {
 
 
 		return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );
 		return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );
 
 
-	},
+	}
 
 
-	normalize: function () {
+	normalize() {
 
 
 		let l = this.length();
 		let l = this.length();
 
 
@@ -498,9 +472,9 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiply: function ( q, p ) {
+	multiply( q, p ) {
 
 
 		if ( p !== undefined ) {
 		if ( p !== undefined ) {
 
 
@@ -511,15 +485,15 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this.multiplyQuaternions( this, q );
 		return this.multiplyQuaternions( this, q );
 
 
-	},
+	}
 
 
-	premultiply: function ( q ) {
+	premultiply( q ) {
 
 
 		return this.multiplyQuaternions( q, this );
 		return this.multiplyQuaternions( q, this );
 
 
-	},
+	}
 
 
-	multiplyQuaternions: function ( a, b ) {
+	multiplyQuaternions( a, b ) {
 
 
 		// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
 		// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
 
 
@@ -535,9 +509,9 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	slerp: function ( qb, t ) {
+	slerp( qb, t ) {
 
 
 		if ( t === 0 ) return this;
 		if ( t === 0 ) return this;
 		if ( t === 1 ) return this.copy( qb );
 		if ( t === 1 ) return this.copy( qb );
@@ -605,15 +579,15 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	equals: function ( quaternion ) {
+	equals( quaternion ) {
 
 
 		return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );
 		return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );
 
 
-	},
+	}
 
 
-	fromArray: function ( array, offset ) {
+	fromArray( array, offset ) {
 
 
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
 
 
@@ -626,9 +600,9 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	toArray: function ( array, offset ) {
+	toArray( array, offset ) {
 
 
 		if ( array === undefined ) array = [];
 		if ( array === undefined ) array = [];
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
@@ -640,9 +614,9 @@ Object.assign( Quaternion.prototype, {
 
 
 		return array;
 		return array;
 
 
-	},
+	}
 
 
-	fromBufferAttribute: function ( attribute, index ) {
+	fromBufferAttribute( attribute, index ) {
 
 
 		this._x = attribute.getX( index );
 		this._x = attribute.getX( index );
 		this._y = attribute.getY( index );
 		this._y = attribute.getY( index );
@@ -651,19 +625,20 @@ Object.assign( Quaternion.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	_onChange: function ( callback ) {
+	_onChange( callback ) {
 
 
 		this._onChangeCallback = callback;
 		this._onChangeCallback = callback;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	_onChangeCallback: function () {}
+	_onChangeCallback() {}
 
 
-} );
+}
 
 
+Quaternion.prototype.isQuaternion = true;
 
 
 export { Quaternion };
 export { Quaternion };

+ 115 - 128
src/math/Vector2.js

@@ -1,85 +1,71 @@
-function Vector2( x = 0, y = 0 ) {
+class Vector2 {
 
 
-	this.x = x;
-	this.y = y;
+	constructor( x = 0, y = 0 ) {
 
 
-}
-
-Object.defineProperties( Vector2.prototype, {
-
-	"width": {
-
-		get: function () {
-
-			return this.x;
-
-		},
-
-		set: function ( value ) {
-
-			this.x = value;
+		this.x = x;
+		this.y = y;
 
 
-		}
+	}
 
 
-	},
+	get width() {
 
 
-	"height": {
+		return this.x;
 
 
-		get: function () {
+	}
 
 
-			return this.y;
+	set width( value ) {
 
 
-		},
+		this.x = value;
 
 
-		set: function ( value ) {
+	}
 
 
-			this.y = value;
+	get height() {
 
 
-		}
+		return this.y;
 
 
 	}
 	}
 
 
-} );
+	set height( value ) {
 
 
-Object.assign( Vector2.prototype, {
+		this.y = value;
 
 
-	isVector2: true,
+	}
 
 
-	set: function ( x, y ) {
+	set( x, y ) {
 
 
 		this.x = x;
 		this.x = x;
 		this.y = y;
 		this.y = y;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setScalar: function ( scalar ) {
+	setScalar( scalar ) {
 
 
 		this.x = scalar;
 		this.x = scalar;
 		this.y = scalar;
 		this.y = scalar;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setX: function ( x ) {
+	setX( x ) {
 
 
 		this.x = x;
 		this.x = x;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setY: function ( y ) {
+	setY( y ) {
 
 
 		this.y = y;
 		this.y = y;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setComponent: function ( index, value ) {
+	setComponent( index, value ) {
 
 
 		switch ( index ) {
 		switch ( index ) {
 
 
@@ -91,9 +77,9 @@ Object.assign( Vector2.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	getComponent: function ( index ) {
+	getComponent( index ) {
 
 
 		switch ( index ) {
 		switch ( index ) {
 
 
@@ -103,24 +89,24 @@ Object.assign( Vector2.prototype, {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	clone: function () {
+	clone() {
 
 
 		return new this.constructor( this.x, this.y );
 		return new this.constructor( this.x, this.y );
 
 
-	},
+	}
 
 
-	copy: function ( v ) {
+	copy( v ) {
 
 
 		this.x = v.x;
 		this.x = v.x;
 		this.y = v.y;
 		this.y = v.y;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	add: function ( v, w ) {
+	add( v, w ) {
 
 
 		if ( w !== undefined ) {
 		if ( w !== undefined ) {
 
 
@@ -134,36 +120,36 @@ Object.assign( Vector2.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	addScalar: function ( s ) {
+	addScalar( s ) {
 
 
 		this.x += s;
 		this.x += s;
 		this.y += s;
 		this.y += s;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	addVectors: function ( a, b ) {
+	addVectors( a, b ) {
 
 
 		this.x = a.x + b.x;
 		this.x = a.x + b.x;
 		this.y = a.y + b.y;
 		this.y = a.y + b.y;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	addScaledVector: function ( v, s ) {
+	addScaledVector( v, s ) {
 
 
 		this.x += v.x * s;
 		this.x += v.x * s;
 		this.y += v.y * s;
 		this.y += v.y * s;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	sub: function ( v, w ) {
+	sub( v, w ) {
 
 
 		if ( w !== undefined ) {
 		if ( w !== undefined ) {
 
 
@@ -177,60 +163,60 @@ Object.assign( Vector2.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	subScalar: function ( s ) {
+	subScalar( s ) {
 
 
 		this.x -= s;
 		this.x -= s;
 		this.y -= s;
 		this.y -= s;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	subVectors: function ( a, b ) {
+	subVectors( a, b ) {
 
 
 		this.x = a.x - b.x;
 		this.x = a.x - b.x;
 		this.y = a.y - b.y;
 		this.y = a.y - b.y;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiply: function ( v ) {
+	multiply( v ) {
 
 
 		this.x *= v.x;
 		this.x *= v.x;
 		this.y *= v.y;
 		this.y *= v.y;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiplyScalar: function ( scalar ) {
+	multiplyScalar( scalar ) {
 
 
 		this.x *= scalar;
 		this.x *= scalar;
 		this.y *= scalar;
 		this.y *= scalar;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	divide: function ( v ) {
+	divide( v ) {
 
 
 		this.x /= v.x;
 		this.x /= v.x;
 		this.y /= v.y;
 		this.y /= v.y;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	divideScalar: function ( scalar ) {
+	divideScalar( scalar ) {
 
 
 		return this.multiplyScalar( 1 / scalar );
 		return this.multiplyScalar( 1 / scalar );
 
 
-	},
+	}
 
 
-	applyMatrix3: function ( m ) {
+	applyMatrix3( m ) {
 
 
 		const x = this.x, y = this.y;
 		const x = this.x, y = this.y;
 		const e = m.elements;
 		const e = m.elements;
@@ -240,27 +226,27 @@ Object.assign( Vector2.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	min: function ( v ) {
+	min( v ) {
 
 
 		this.x = Math.min( this.x, v.x );
 		this.x = Math.min( this.x, v.x );
 		this.y = Math.min( this.y, v.y );
 		this.y = Math.min( this.y, v.y );
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	max: function ( v ) {
+	max( v ) {
 
 
 		this.x = Math.max( this.x, v.x );
 		this.x = Math.max( this.x, v.x );
 		this.y = Math.max( this.y, v.y );
 		this.y = Math.max( this.y, v.y );
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clamp: function ( min, max ) {
+	clamp( min, max ) {
 
 
 		// assumes min < max, componentwise
 		// assumes min < max, componentwise
 
 
@@ -269,107 +255,107 @@ Object.assign( Vector2.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clampScalar: function ( minVal, maxVal ) {
+	clampScalar( minVal, maxVal ) {
 
 
 		this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
 		this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
 		this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
 		this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clampLength: function ( min, max ) {
+	clampLength( min, max ) {
 
 
 		const length = this.length();
 		const length = this.length();
 
 
 		return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
 		return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
 
 
-	},
+	}
 
 
-	floor: function () {
+	floor() {
 
 
 		this.x = Math.floor( this.x );
 		this.x = Math.floor( this.x );
 		this.y = Math.floor( this.y );
 		this.y = Math.floor( this.y );
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	ceil: function () {
+	ceil() {
 
 
 		this.x = Math.ceil( this.x );
 		this.x = Math.ceil( this.x );
 		this.y = Math.ceil( this.y );
 		this.y = Math.ceil( this.y );
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	round: function () {
+	round() {
 
 
 		this.x = Math.round( this.x );
 		this.x = Math.round( this.x );
 		this.y = Math.round( this.y );
 		this.y = Math.round( this.y );
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	roundToZero: function () {
+	roundToZero() {
 
 
 		this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
 		this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
 		this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
 		this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	negate: function () {
+	negate() {
 
 
 		this.x = - this.x;
 		this.x = - this.x;
 		this.y = - this.y;
 		this.y = - this.y;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	dot: function ( v ) {
+	dot( v ) {
 
 
 		return this.x * v.x + this.y * v.y;
 		return this.x * v.x + this.y * v.y;
 
 
-	},
+	}
 
 
-	cross: function ( v ) {
+	cross( v ) {
 
 
 		return this.x * v.y - this.y * v.x;
 		return this.x * v.y - this.y * v.x;
 
 
-	},
+	}
 
 
-	lengthSq: function () {
+	lengthSq() {
 
 
 		return this.x * this.x + this.y * this.y;
 		return this.x * this.x + this.y * this.y;
 
 
-	},
+	}
 
 
-	length: function () {
+	length() {
 
 
 		return Math.sqrt( this.x * this.x + this.y * this.y );
 		return Math.sqrt( this.x * this.x + this.y * this.y );
 
 
-	},
+	}
 
 
-	manhattanLength: function () {
+	manhattanLength() {
 
 
 		return Math.abs( this.x ) + Math.abs( this.y );
 		return Math.abs( this.x ) + Math.abs( this.y );
 
 
-	},
+	}
 
 
-	normalize: function () {
+	normalize() {
 
 
 		return this.divideScalar( this.length() || 1 );
 		return this.divideScalar( this.length() || 1 );
 
 
-	},
+	}
 
 
-	angle: function () {
+	angle() {
 
 
 		// computes the angle in radians with respect to the positive x-axis
 		// computes the angle in radians with respect to the positive x-axis
 
 
@@ -377,58 +363,58 @@ Object.assign( Vector2.prototype, {
 
 
 		return angle;
 		return angle;
 
 
-	},
+	}
 
 
-	distanceTo: function ( v ) {
+	distanceTo( v ) {
 
 
 		return Math.sqrt( this.distanceToSquared( v ) );
 		return Math.sqrt( this.distanceToSquared( v ) );
 
 
-	},
+	}
 
 
-	distanceToSquared: function ( v ) {
+	distanceToSquared( v ) {
 
 
 		const dx = this.x - v.x, dy = this.y - v.y;
 		const dx = this.x - v.x, dy = this.y - v.y;
 		return dx * dx + dy * dy;
 		return dx * dx + dy * dy;
 
 
-	},
+	}
 
 
-	manhattanDistanceTo: function ( v ) {
+	manhattanDistanceTo( v ) {
 
 
 		return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
 		return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
 
 
-	},
+	}
 
 
-	setLength: function ( length ) {
+	setLength( length ) {
 
 
 		return this.normalize().multiplyScalar( length );
 		return this.normalize().multiplyScalar( length );
 
 
-	},
+	}
 
 
-	lerp: function ( v, alpha ) {
+	lerp( v, alpha ) {
 
 
 		this.x += ( v.x - this.x ) * alpha;
 		this.x += ( v.x - this.x ) * alpha;
 		this.y += ( v.y - this.y ) * alpha;
 		this.y += ( v.y - this.y ) * alpha;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	lerpVectors: function ( v1, v2, alpha ) {
+	lerpVectors( v1, v2, alpha ) {
 
 
 		this.x = v1.x + ( v2.x - v1.x ) * alpha;
 		this.x = v1.x + ( v2.x - v1.x ) * alpha;
 		this.y = v1.y + ( v2.y - v1.y ) * alpha;
 		this.y = v1.y + ( v2.y - v1.y ) * alpha;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	equals: function ( v ) {
+	equals( v ) {
 
 
 		return ( ( v.x === this.x ) && ( v.y === this.y ) );
 		return ( ( v.x === this.x ) && ( v.y === this.y ) );
 
 
-	},
+	}
 
 
-	fromArray: function ( array, offset ) {
+	fromArray( array, offset ) {
 
 
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
 
 
@@ -437,9 +423,9 @@ Object.assign( Vector2.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	toArray: function ( array, offset ) {
+	toArray( array, offset ) {
 
 
 		if ( array === undefined ) array = [];
 		if ( array === undefined ) array = [];
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
@@ -449,9 +435,9 @@ Object.assign( Vector2.prototype, {
 
 
 		return array;
 		return array;
 
 
-	},
+	}
 
 
-	fromBufferAttribute: function ( attribute, index, offset ) {
+	fromBufferAttribute( attribute, index, offset ) {
 
 
 		if ( offset !== undefined ) {
 		if ( offset !== undefined ) {
 
 
@@ -464,9 +450,9 @@ Object.assign( Vector2.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	rotateAround: function ( center, angle ) {
+	rotateAround( center, angle ) {
 
 
 		const c = Math.cos( angle ), s = Math.sin( angle );
 		const c = Math.cos( angle ), s = Math.sin( angle );
 
 
@@ -478,9 +464,9 @@ Object.assign( Vector2.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	random: function () {
+	random() {
 
 
 		this.x = Math.random();
 		this.x = Math.random();
 		this.y = Math.random();
 		this.y = Math.random();
@@ -489,7 +475,8 @@ Object.assign( Vector2.prototype, {
 
 
 	}
 	}
 
 
-} );
+}
 
 
+Vector2.prototype.isVector2 = true;
 
 
 export { Vector2 };
 export { Vector2 };

+ 150 - 151
src/math/Vector3.js

@@ -1,22 +1,17 @@
 import { MathUtils } from './MathUtils.js';
 import { MathUtils } from './MathUtils.js';
 import { Quaternion } from './Quaternion.js';
 import { Quaternion } from './Quaternion.js';
 
 
-const _vector = new Vector3();
-const _quaternion = new Quaternion();
-
-function Vector3( x = 0, y = 0, z = 0 ) {
+class Vector3 {
 
 
-	this.x = x;
-	this.y = y;
-	this.z = z;
+	constructor( x = 0, y = 0, z = 0 ) {
 
 
-}
-
-Object.assign( Vector3.prototype, {
+		this.x = x;
+		this.y = y;
+		this.z = z;
 
 
-	isVector3: true,
+	}
 
 
-	set: function ( x, y, z ) {
+	set( x, y, z ) {
 
 
 		if ( z === undefined ) z = this.z; // sprite.scale.set(x,y)
 		if ( z === undefined ) z = this.z; // sprite.scale.set(x,y)
 
 
@@ -26,9 +21,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setScalar: function ( scalar ) {
+	setScalar( scalar ) {
 
 
 		this.x = scalar;
 		this.x = scalar;
 		this.y = scalar;
 		this.y = scalar;
@@ -36,33 +31,33 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setX: function ( x ) {
+	setX( x ) {
 
 
 		this.x = x;
 		this.x = x;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setY: function ( y ) {
+	setY( y ) {
 
 
 		this.y = y;
 		this.y = y;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setZ: function ( z ) {
+	setZ( z ) {
 
 
 		this.z = z;
 		this.z = z;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setComponent: function ( index, value ) {
+	setComponent( index, value ) {
 
 
 		switch ( index ) {
 		switch ( index ) {
 
 
@@ -75,9 +70,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	getComponent: function ( index ) {
+	getComponent( index ) {
 
 
 		switch ( index ) {
 		switch ( index ) {
 
 
@@ -88,15 +83,15 @@ Object.assign( Vector3.prototype, {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	clone: function () {
+	clone() {
 
 
 		return new this.constructor( this.x, this.y, this.z );
 		return new this.constructor( this.x, this.y, this.z );
 
 
-	},
+	}
 
 
-	copy: function ( v ) {
+	copy( v ) {
 
 
 		this.x = v.x;
 		this.x = v.x;
 		this.y = v.y;
 		this.y = v.y;
@@ -104,9 +99,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	add: function ( v, w ) {
+	add( v, w ) {
 
 
 		if ( w !== undefined ) {
 		if ( w !== undefined ) {
 
 
@@ -121,9 +116,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	addScalar: function ( s ) {
+	addScalar( s ) {
 
 
 		this.x += s;
 		this.x += s;
 		this.y += s;
 		this.y += s;
@@ -131,9 +126,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	addVectors: function ( a, b ) {
+	addVectors( a, b ) {
 
 
 		this.x = a.x + b.x;
 		this.x = a.x + b.x;
 		this.y = a.y + b.y;
 		this.y = a.y + b.y;
@@ -141,9 +136,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	addScaledVector: function ( v, s ) {
+	addScaledVector( v, s ) {
 
 
 		this.x += v.x * s;
 		this.x += v.x * s;
 		this.y += v.y * s;
 		this.y += v.y * s;
@@ -151,9 +146,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	sub: function ( v, w ) {
+	sub( v, w ) {
 
 
 		if ( w !== undefined ) {
 		if ( w !== undefined ) {
 
 
@@ -168,9 +163,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	subScalar: function ( s ) {
+	subScalar( s ) {
 
 
 		this.x -= s;
 		this.x -= s;
 		this.y -= s;
 		this.y -= s;
@@ -178,9 +173,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	subVectors: function ( a, b ) {
+	subVectors( a, b ) {
 
 
 		this.x = a.x - b.x;
 		this.x = a.x - b.x;
 		this.y = a.y - b.y;
 		this.y = a.y - b.y;
@@ -188,9 +183,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiply: function ( v, w ) {
+	multiply( v, w ) {
 
 
 		if ( w !== undefined ) {
 		if ( w !== undefined ) {
 
 
@@ -205,9 +200,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiplyScalar: function ( scalar ) {
+	multiplyScalar( scalar ) {
 
 
 		this.x *= scalar;
 		this.x *= scalar;
 		this.y *= scalar;
 		this.y *= scalar;
@@ -215,9 +210,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiplyVectors: function ( a, b ) {
+	multiplyVectors( a, b ) {
 
 
 		this.x = a.x * b.x;
 		this.x = a.x * b.x;
 		this.y = a.y * b.y;
 		this.y = a.y * b.y;
@@ -225,9 +220,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	applyEuler: function ( euler ) {
+	applyEuler( euler ) {
 
 
 		if ( ! ( euler && euler.isEuler ) ) {
 		if ( ! ( euler && euler.isEuler ) ) {
 
 
@@ -237,15 +232,15 @@ Object.assign( Vector3.prototype, {
 
 
 		return this.applyQuaternion( _quaternion.setFromEuler( euler ) );
 		return this.applyQuaternion( _quaternion.setFromEuler( euler ) );
 
 
-	},
+	}
 
 
-	applyAxisAngle: function ( axis, angle ) {
+	applyAxisAngle( axis, angle ) {
 
 
 		return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );
 		return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );
 
 
-	},
+	}
 
 
-	applyMatrix3: function ( m ) {
+	applyMatrix3( m ) {
 
 
 		const x = this.x, y = this.y, z = this.z;
 		const x = this.x, y = this.y, z = this.z;
 		const e = m.elements;
 		const e = m.elements;
@@ -256,15 +251,15 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	applyNormalMatrix: function ( m ) {
+	applyNormalMatrix( m ) {
 
 
 		return this.applyMatrix3( m ).normalize();
 		return this.applyMatrix3( m ).normalize();
 
 
-	},
+	}
 
 
-	applyMatrix4: function ( m ) {
+	applyMatrix4( m ) {
 
 
 		const x = this.x, y = this.y, z = this.z;
 		const x = this.x, y = this.y, z = this.z;
 		const e = m.elements;
 		const e = m.elements;
@@ -277,9 +272,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	applyQuaternion: function ( q ) {
+	applyQuaternion( q ) {
 
 
 		const x = this.x, y = this.y, z = this.z;
 		const x = this.x, y = this.y, z = this.z;
 		const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
 		const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
@@ -299,21 +294,21 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	project: function ( camera ) {
+	project( camera ) {
 
 
 		return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );
 		return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );
 
 
-	},
+	}
 
 
-	unproject: function ( camera ) {
+	unproject( camera ) {
 
 
 		return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );
 		return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );
 
 
-	},
+	}
 
 
-	transformDirection: function ( m ) {
+	transformDirection( m ) {
 
 
 		// input: THREE.Matrix4 affine matrix
 		// input: THREE.Matrix4 affine matrix
 		// vector interpreted as a direction
 		// vector interpreted as a direction
@@ -327,9 +322,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this.normalize();
 		return this.normalize();
 
 
-	},
+	}
 
 
-	divide: function ( v ) {
+	divide( v ) {
 
 
 		this.x /= v.x;
 		this.x /= v.x;
 		this.y /= v.y;
 		this.y /= v.y;
@@ -337,15 +332,15 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	divideScalar: function ( scalar ) {
+	divideScalar( scalar ) {
 
 
 		return this.multiplyScalar( 1 / scalar );
 		return this.multiplyScalar( 1 / scalar );
 
 
-	},
+	}
 
 
-	min: function ( v ) {
+	min( v ) {
 
 
 		this.x = Math.min( this.x, v.x );
 		this.x = Math.min( this.x, v.x );
 		this.y = Math.min( this.y, v.y );
 		this.y = Math.min( this.y, v.y );
@@ -353,9 +348,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	max: function ( v ) {
+	max( v ) {
 
 
 		this.x = Math.max( this.x, v.x );
 		this.x = Math.max( this.x, v.x );
 		this.y = Math.max( this.y, v.y );
 		this.y = Math.max( this.y, v.y );
@@ -363,9 +358,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clamp: function ( min, max ) {
+	clamp( min, max ) {
 
 
 		// assumes min < max, componentwise
 		// assumes min < max, componentwise
 
 
@@ -375,9 +370,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clampScalar: function ( minVal, maxVal ) {
+	clampScalar( minVal, maxVal ) {
 
 
 		this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
 		this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
 		this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
 		this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
@@ -385,17 +380,17 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clampLength: function ( min, max ) {
+	clampLength( min, max ) {
 
 
 		const length = this.length();
 		const length = this.length();
 
 
 		return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
 		return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
 
 
-	},
+	}
 
 
-	floor: function () {
+	floor() {
 
 
 		this.x = Math.floor( this.x );
 		this.x = Math.floor( this.x );
 		this.y = Math.floor( this.y );
 		this.y = Math.floor( this.y );
@@ -403,9 +398,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	ceil: function () {
+	ceil() {
 
 
 		this.x = Math.ceil( this.x );
 		this.x = Math.ceil( this.x );
 		this.y = Math.ceil( this.y );
 		this.y = Math.ceil( this.y );
@@ -413,9 +408,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	round: function () {
+	round() {
 
 
 		this.x = Math.round( this.x );
 		this.x = Math.round( this.x );
 		this.y = Math.round( this.y );
 		this.y = Math.round( this.y );
@@ -423,9 +418,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	roundToZero: function () {
+	roundToZero() {
 
 
 		this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
 		this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
 		this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
 		this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
@@ -433,9 +428,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	negate: function () {
+	negate() {
 
 
 		this.x = - this.x;
 		this.x = - this.x;
 		this.y = - this.y;
 		this.y = - this.y;
@@ -443,47 +438,47 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	dot: function ( v ) {
+	dot( v ) {
 
 
 		return this.x * v.x + this.y * v.y + this.z * v.z;
 		return this.x * v.x + this.y * v.y + this.z * v.z;
 
 
-	},
+	}
 
 
 	// TODO lengthSquared?
 	// TODO lengthSquared?
 
 
-	lengthSq: function () {
+	lengthSq() {
 
 
 		return this.x * this.x + this.y * this.y + this.z * this.z;
 		return this.x * this.x + this.y * this.y + this.z * this.z;
 
 
-	},
+	}
 
 
-	length: function () {
+	length() {
 
 
 		return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
 		return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
 
 
-	},
+	}
 
 
-	manhattanLength: function () {
+	manhattanLength() {
 
 
 		return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
 		return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
 
 
-	},
+	}
 
 
-	normalize: function () {
+	normalize() {
 
 
 		return this.divideScalar( this.length() || 1 );
 		return this.divideScalar( this.length() || 1 );
 
 
-	},
+	}
 
 
-	setLength: function ( length ) {
+	setLength( length ) {
 
 
 		return this.normalize().multiplyScalar( length );
 		return this.normalize().multiplyScalar( length );
 
 
-	},
+	}
 
 
-	lerp: function ( v, alpha ) {
+	lerp( v, alpha ) {
 
 
 		this.x += ( v.x - this.x ) * alpha;
 		this.x += ( v.x - this.x ) * alpha;
 		this.y += ( v.y - this.y ) * alpha;
 		this.y += ( v.y - this.y ) * alpha;
@@ -491,9 +486,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	lerpVectors: function ( v1, v2, alpha ) {
+	lerpVectors( v1, v2, alpha ) {
 
 
 		this.x = v1.x + ( v2.x - v1.x ) * alpha;
 		this.x = v1.x + ( v2.x - v1.x ) * alpha;
 		this.y = v1.y + ( v2.y - v1.y ) * alpha;
 		this.y = v1.y + ( v2.y - v1.y ) * alpha;
@@ -501,9 +496,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	cross: function ( v, w ) {
+	cross( v, w ) {
 
 
 		if ( w !== undefined ) {
 		if ( w !== undefined ) {
 
 
@@ -514,9 +509,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this.crossVectors( this, v );
 		return this.crossVectors( this, v );
 
 
-	},
+	}
 
 
-	crossVectors: function ( a, b ) {
+	crossVectors( a, b ) {
 
 
 		const ax = a.x, ay = a.y, az = a.z;
 		const ax = a.x, ay = a.y, az = a.z;
 		const bx = b.x, by = b.y, bz = b.z;
 		const bx = b.x, by = b.y, bz = b.z;
@@ -527,9 +522,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	projectOnVector: function ( v ) {
+	projectOnVector( v ) {
 
 
 		const denominator = v.lengthSq();
 		const denominator = v.lengthSq();
 
 
@@ -539,26 +534,26 @@ Object.assign( Vector3.prototype, {
 
 
 		return this.copy( v ).multiplyScalar( scalar );
 		return this.copy( v ).multiplyScalar( scalar );
 
 
-	},
+	}
 
 
-	projectOnPlane: function ( planeNormal ) {
+	projectOnPlane( planeNormal ) {
 
 
 		_vector.copy( this ).projectOnVector( planeNormal );
 		_vector.copy( this ).projectOnVector( planeNormal );
 
 
 		return this.sub( _vector );
 		return this.sub( _vector );
 
 
-	},
+	}
 
 
-	reflect: function ( normal ) {
+	reflect( normal ) {
 
 
 		// reflect incident vector off plane orthogonal to normal
 		// reflect incident vector off plane orthogonal to normal
 		// normal is assumed to have unit length
 		// normal is assumed to have unit length
 
 
 		return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
 		return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
 
 
-	},
+	}
 
 
-	angleTo: function ( v ) {
+	angleTo( v ) {
 
 
 		const denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
 		const denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
 
 
@@ -570,35 +565,35 @@ Object.assign( Vector3.prototype, {
 
 
 		return Math.acos( MathUtils.clamp( theta, - 1, 1 ) );
 		return Math.acos( MathUtils.clamp( theta, - 1, 1 ) );
 
 
-	},
+	}
 
 
-	distanceTo: function ( v ) {
+	distanceTo( v ) {
 
 
 		return Math.sqrt( this.distanceToSquared( v ) );
 		return Math.sqrt( this.distanceToSquared( v ) );
 
 
-	},
+	}
 
 
-	distanceToSquared: function ( v ) {
+	distanceToSquared( v ) {
 
 
 		const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
 		const dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
 
 
 		return dx * dx + dy * dy + dz * dz;
 		return dx * dx + dy * dy + dz * dz;
 
 
-	},
+	}
 
 
-	manhattanDistanceTo: function ( v ) {
+	manhattanDistanceTo( v ) {
 
 
 		return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
 		return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
 
 
-	},
+	}
 
 
-	setFromSpherical: function ( s ) {
+	setFromSpherical( s ) {
 
 
 		return this.setFromSphericalCoords( s.radius, s.phi, s.theta );
 		return this.setFromSphericalCoords( s.radius, s.phi, s.theta );
 
 
-	},
+	}
 
 
-	setFromSphericalCoords: function ( radius, phi, theta ) {
+	setFromSphericalCoords( radius, phi, theta ) {
 
 
 		const sinPhiRadius = Math.sin( phi ) * radius;
 		const sinPhiRadius = Math.sin( phi ) * radius;
 
 
@@ -608,15 +603,15 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromCylindrical: function ( c ) {
+	setFromCylindrical( c ) {
 
 
 		return this.setFromCylindricalCoords( c.radius, c.theta, c.y );
 		return this.setFromCylindricalCoords( c.radius, c.theta, c.y );
 
 
-	},
+	}
 
 
-	setFromCylindricalCoords: function ( radius, theta, y ) {
+	setFromCylindricalCoords( radius, theta, y ) {
 
 
 		this.x = radius * Math.sin( theta );
 		this.x = radius * Math.sin( theta );
 		this.y = y;
 		this.y = y;
@@ -624,9 +619,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromMatrixPosition: function ( m ) {
+	setFromMatrixPosition( m ) {
 
 
 		const e = m.elements;
 		const e = m.elements;
 
 
@@ -636,9 +631,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromMatrixScale: function ( m ) {
+	setFromMatrixScale( m ) {
 
 
 		const sx = this.setFromMatrixColumn( m, 0 ).length();
 		const sx = this.setFromMatrixColumn( m, 0 ).length();
 		const sy = this.setFromMatrixColumn( m, 1 ).length();
 		const sy = this.setFromMatrixColumn( m, 1 ).length();
@@ -650,27 +645,27 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setFromMatrixColumn: function ( m, index ) {
+	setFromMatrixColumn( m, index ) {
 
 
 		return this.fromArray( m.elements, index * 4 );
 		return this.fromArray( m.elements, index * 4 );
 
 
-	},
+	}
 
 
-	setFromMatrix3Column: function ( m, index ) {
+	setFromMatrix3Column( m, index ) {
 
 
 		return this.fromArray( m.elements, index * 3 );
 		return this.fromArray( m.elements, index * 3 );
 
 
-	},
+	}
 
 
-	equals: function ( v ) {
+	equals( v ) {
 
 
 		return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
 		return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
 
 
-	},
+	}
 
 
-	fromArray: function ( array, offset ) {
+	fromArray( array, offset ) {
 
 
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
 
 
@@ -680,9 +675,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	toArray: function ( array, offset ) {
+	toArray( array, offset ) {
 
 
 		if ( array === undefined ) array = [];
 		if ( array === undefined ) array = [];
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
@@ -693,9 +688,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return array;
 		return array;
 
 
-	},
+	}
 
 
-	fromBufferAttribute: function ( attribute, index, offset ) {
+	fromBufferAttribute( attribute, index, offset ) {
 
 
 		if ( offset !== undefined ) {
 		if ( offset !== undefined ) {
 
 
@@ -709,9 +704,9 @@ Object.assign( Vector3.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	random: function () {
+	random() {
 
 
 		this.x = Math.random();
 		this.x = Math.random();
 		this.y = Math.random();
 		this.y = Math.random();
@@ -721,7 +716,11 @@ Object.assign( Vector3.prototype, {
 
 
 	}
 	}
 
 
-} );
+}
+
+Vector3.prototype.isVector3 = true;
 
 
+const _vector = new Vector3();
+const _quaternion = new Quaternion();
 
 
 export { Vector3 };
 export { Vector3 };

+ 109 - 122
src/math/Vector4.js

@@ -1,53 +1,39 @@
-function Vector4( x = 0, y = 0, z = 0, w = 1 ) {
+class Vector4 {
 
 
-	this.x = x;
-	this.y = y;
-	this.z = z;
-	this.w = w;
+	constructor( x = 0, y = 0, z = 0, w = 1 ) {
 
 
-}
-
-Object.defineProperties( Vector4.prototype, {
-
-	"width": {
-
-		get: function () {
-
-			return this.z;
-
-		},
-
-		set: function ( value ) {
-
-			this.z = value;
+		this.x = x;
+		this.y = y;
+		this.z = z;
+		this.w = w;
 
 
-		}
+	}
 
 
-	},
+	get width() {
 
 
-	"height": {
+		return this.z;
 
 
-		get: function () {
+	}
 
 
-			return this.w;
+	set width( value ) {
 
 
-		},
+		this.z = value;
 
 
-		set: function ( value ) {
+	}
 
 
-			this.w = value;
+	get height() {
 
 
-		}
+		return this.w;
 
 
 	}
 	}
 
 
-} );
+	set height( value ) {
 
 
-Object.assign( Vector4.prototype, {
+		this.w = value;
 
 
-	isVector4: true,
+	}
 
 
-	set: function ( x, y, z, w ) {
+	set( x, y, z, w ) {
 
 
 		this.x = x;
 		this.x = x;
 		this.y = y;
 		this.y = y;
@@ -56,9 +42,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setScalar: function ( scalar ) {
+	setScalar( scalar ) {
 
 
 		this.x = scalar;
 		this.x = scalar;
 		this.y = scalar;
 		this.y = scalar;
@@ -67,41 +53,41 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setX: function ( x ) {
+	setX( x ) {
 
 
 		this.x = x;
 		this.x = x;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setY: function ( y ) {
+	setY( y ) {
 
 
 		this.y = y;
 		this.y = y;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setZ: function ( z ) {
+	setZ( z ) {
 
 
 		this.z = z;
 		this.z = z;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setW: function ( w ) {
+	setW( w ) {
 
 
 		this.w = w;
 		this.w = w;
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setComponent: function ( index, value ) {
+	setComponent( index, value ) {
 
 
 		switch ( index ) {
 		switch ( index ) {
 
 
@@ -115,9 +101,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	getComponent: function ( index ) {
+	getComponent( index ) {
 
 
 		switch ( index ) {
 		switch ( index ) {
 
 
@@ -129,15 +115,15 @@ Object.assign( Vector4.prototype, {
 
 
 		}
 		}
 
 
-	},
+	}
 
 
-	clone: function () {
+	clone() {
 
 
 		return new this.constructor( this.x, this.y, this.z, this.w );
 		return new this.constructor( this.x, this.y, this.z, this.w );
 
 
-	},
+	}
 
 
-	copy: function ( v ) {
+	copy( v ) {
 
 
 		this.x = v.x;
 		this.x = v.x;
 		this.y = v.y;
 		this.y = v.y;
@@ -146,9 +132,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	add: function ( v, w ) {
+	add( v, w ) {
 
 
 		if ( w !== undefined ) {
 		if ( w !== undefined ) {
 
 
@@ -164,9 +150,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	addScalar: function ( s ) {
+	addScalar( s ) {
 
 
 		this.x += s;
 		this.x += s;
 		this.y += s;
 		this.y += s;
@@ -175,9 +161,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	addVectors: function ( a, b ) {
+	addVectors( a, b ) {
 
 
 		this.x = a.x + b.x;
 		this.x = a.x + b.x;
 		this.y = a.y + b.y;
 		this.y = a.y + b.y;
@@ -186,9 +172,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	addScaledVector: function ( v, s ) {
+	addScaledVector( v, s ) {
 
 
 		this.x += v.x * s;
 		this.x += v.x * s;
 		this.y += v.y * s;
 		this.y += v.y * s;
@@ -197,9 +183,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	sub: function ( v, w ) {
+	sub( v, w ) {
 
 
 		if ( w !== undefined ) {
 		if ( w !== undefined ) {
 
 
@@ -215,9 +201,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	subScalar: function ( s ) {
+	subScalar( s ) {
 
 
 		this.x -= s;
 		this.x -= s;
 		this.y -= s;
 		this.y -= s;
@@ -226,9 +212,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	subVectors: function ( a, b ) {
+	subVectors( a, b ) {
 
 
 		this.x = a.x - b.x;
 		this.x = a.x - b.x;
 		this.y = a.y - b.y;
 		this.y = a.y - b.y;
@@ -237,9 +223,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	multiplyScalar: function ( scalar ) {
+	multiplyScalar( scalar ) {
 
 
 		this.x *= scalar;
 		this.x *= scalar;
 		this.y *= scalar;
 		this.y *= scalar;
@@ -248,9 +234,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	applyMatrix4: function ( m ) {
+	applyMatrix4( m ) {
 
 
 		const x = this.x, y = this.y, z = this.z, w = this.w;
 		const x = this.x, y = this.y, z = this.z, w = this.w;
 		const e = m.elements;
 		const e = m.elements;
@@ -262,15 +248,15 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	divideScalar: function ( scalar ) {
+	divideScalar( scalar ) {
 
 
 		return this.multiplyScalar( 1 / scalar );
 		return this.multiplyScalar( 1 / scalar );
 
 
-	},
+	}
 
 
-	setAxisAngleFromQuaternion: function ( q ) {
+	setAxisAngleFromQuaternion( q ) {
 
 
 		// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
 		// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
 
 
@@ -296,9 +282,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	setAxisAngleFromRotationMatrix: function ( m ) {
+	setAxisAngleFromRotationMatrix( m ) {
 
 
 		// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
 		// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
 
 
@@ -426,9 +412,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	min: function ( v ) {
+	min( v ) {
 
 
 		this.x = Math.min( this.x, v.x );
 		this.x = Math.min( this.x, v.x );
 		this.y = Math.min( this.y, v.y );
 		this.y = Math.min( this.y, v.y );
@@ -437,9 +423,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	max: function ( v ) {
+	max( v ) {
 
 
 		this.x = Math.max( this.x, v.x );
 		this.x = Math.max( this.x, v.x );
 		this.y = Math.max( this.y, v.y );
 		this.y = Math.max( this.y, v.y );
@@ -448,9 +434,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clamp: function ( min, max ) {
+	clamp( min, max ) {
 
 
 		// assumes min < max, componentwise
 		// assumes min < max, componentwise
 
 
@@ -461,9 +447,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clampScalar: function ( minVal, maxVal ) {
+	clampScalar( minVal, maxVal ) {
 
 
 		this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
 		this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
 		this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
 		this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
@@ -472,17 +458,17 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	clampLength: function ( min, max ) {
+	clampLength( min, max ) {
 
 
 		const length = this.length();
 		const length = this.length();
 
 
 		return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
 		return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
 
 
-	},
+	}
 
 
-	floor: function () {
+	floor() {
 
 
 		this.x = Math.floor( this.x );
 		this.x = Math.floor( this.x );
 		this.y = Math.floor( this.y );
 		this.y = Math.floor( this.y );
@@ -491,9 +477,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	ceil: function () {
+	ceil() {
 
 
 		this.x = Math.ceil( this.x );
 		this.x = Math.ceil( this.x );
 		this.y = Math.ceil( this.y );
 		this.y = Math.ceil( this.y );
@@ -502,9 +488,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	round: function () {
+	round() {
 
 
 		this.x = Math.round( this.x );
 		this.x = Math.round( this.x );
 		this.y = Math.round( this.y );
 		this.y = Math.round( this.y );
@@ -513,9 +499,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	roundToZero: function () {
+	roundToZero() {
 
 
 		this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
 		this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
 		this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
 		this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
@@ -524,9 +510,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	negate: function () {
+	negate() {
 
 
 		this.x = - this.x;
 		this.x = - this.x;
 		this.y = - this.y;
 		this.y = - this.y;
@@ -535,45 +521,45 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	dot: function ( v ) {
+	dot( v ) {
 
 
 		return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
 		return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
 
 
-	},
+	}
 
 
-	lengthSq: function () {
+	lengthSq() {
 
 
 		return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
 		return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
 
 
-	},
+	}
 
 
-	length: function () {
+	length() {
 
 
 		return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
 		return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
 
 
-	},
+	}
 
 
-	manhattanLength: function () {
+	manhattanLength() {
 
 
 		return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );
 		return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );
 
 
-	},
+	}
 
 
-	normalize: function () {
+	normalize() {
 
 
 		return this.divideScalar( this.length() || 1 );
 		return this.divideScalar( this.length() || 1 );
 
 
-	},
+	}
 
 
-	setLength: function ( length ) {
+	setLength( length ) {
 
 
 		return this.normalize().multiplyScalar( length );
 		return this.normalize().multiplyScalar( length );
 
 
-	},
+	}
 
 
-	lerp: function ( v, alpha ) {
+	lerp( v, alpha ) {
 
 
 		this.x += ( v.x - this.x ) * alpha;
 		this.x += ( v.x - this.x ) * alpha;
 		this.y += ( v.y - this.y ) * alpha;
 		this.y += ( v.y - this.y ) * alpha;
@@ -582,9 +568,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	lerpVectors: function ( v1, v2, alpha ) {
+	lerpVectors( v1, v2, alpha ) {
 
 
 		this.x = v1.x + ( v2.x - v1.x ) * alpha;
 		this.x = v1.x + ( v2.x - v1.x ) * alpha;
 		this.y = v1.y + ( v2.y - v1.y ) * alpha;
 		this.y = v1.y + ( v2.y - v1.y ) * alpha;
@@ -593,15 +579,15 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	equals: function ( v ) {
+	equals( v ) {
 
 
 		return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );
 		return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );
 
 
-	},
+	}
 
 
-	fromArray: function ( array, offset ) {
+	fromArray( array, offset ) {
 
 
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
 
 
@@ -612,9 +598,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	toArray: function ( array, offset ) {
+	toArray( array, offset ) {
 
 
 		if ( array === undefined ) array = [];
 		if ( array === undefined ) array = [];
 		if ( offset === undefined ) offset = 0;
 		if ( offset === undefined ) offset = 0;
@@ -626,9 +612,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return array;
 		return array;
 
 
-	},
+	}
 
 
-	fromBufferAttribute: function ( attribute, index, offset ) {
+	fromBufferAttribute( attribute, index, offset ) {
 
 
 		if ( offset !== undefined ) {
 		if ( offset !== undefined ) {
 
 
@@ -643,9 +629,9 @@ Object.assign( Vector4.prototype, {
 
 
 		return this;
 		return this;
 
 
-	},
+	}
 
 
-	random: function () {
+	random() {
 
 
 		this.x = Math.random();
 		this.x = Math.random();
 		this.y = Math.random();
 		this.y = Math.random();
@@ -656,7 +642,8 @@ Object.assign( Vector4.prototype, {
 
 
 	}
 	}
 
 
-} );
+}
 
 
+Vector4.prototype.isVector4 = true;
 
 
 export { Vector4 };
 export { Vector4 };