|
@@ -4,19 +4,23 @@ 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 ) {
|
|
|
|
|
|
-}
|
|
|
+ this.x = x;
|
|
|
+ this.y = y;
|
|
|
+ this.z = z;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
-Object.assign( Vector3.prototype, {
|
|
|
+ get isVector3() {
|
|
|
|
|
|
- isVector3: true,
|
|
|
+ return true;
|
|
|
|
|
|
- set: function ( x, y, z ) {
|
|
|
+ }
|
|
|
+
|
|
|
+ set( x, y, z ) {
|
|
|
|
|
|
if ( z === undefined ) z = this.z; // sprite.scale.set(x,y)
|
|
|
|
|
@@ -26,9 +30,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setScalar: function ( scalar ) {
|
|
|
+ setScalar( scalar ) {
|
|
|
|
|
|
this.x = scalar;
|
|
|
this.y = scalar;
|
|
@@ -36,33 +40,33 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setX: function ( x ) {
|
|
|
+ setX( x ) {
|
|
|
|
|
|
this.x = x;
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setY: function ( y ) {
|
|
|
+ setY( y ) {
|
|
|
|
|
|
this.y = y;
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setZ: function ( z ) {
|
|
|
+ setZ( z ) {
|
|
|
|
|
|
this.z = z;
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setComponent: function ( index, value ) {
|
|
|
+ setComponent( index, value ) {
|
|
|
|
|
|
switch ( index ) {
|
|
|
|
|
@@ -75,9 +79,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- getComponent: function ( index ) {
|
|
|
+ getComponent( index ) {
|
|
|
|
|
|
switch ( index ) {
|
|
|
|
|
@@ -88,15 +92,15 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
}
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- clone: function () {
|
|
|
+ clone() {
|
|
|
|
|
|
return new this.constructor( this.x, this.y, this.z );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- copy: function ( v ) {
|
|
|
+ copy( v ) {
|
|
|
|
|
|
this.x = v.x;
|
|
|
this.y = v.y;
|
|
@@ -104,9 +108,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- add: function ( v, w ) {
|
|
|
+ add( v, w ) {
|
|
|
|
|
|
if ( w !== undefined ) {
|
|
|
|
|
@@ -121,9 +125,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- addScalar: function ( s ) {
|
|
|
+ addScalar( s ) {
|
|
|
|
|
|
this.x += s;
|
|
|
this.y += s;
|
|
@@ -131,9 +135,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- addVectors: function ( a, b ) {
|
|
|
+ addVectors( a, b ) {
|
|
|
|
|
|
this.x = a.x + b.x;
|
|
|
this.y = a.y + b.y;
|
|
@@ -141,9 +145,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- addScaledVector: function ( v, s ) {
|
|
|
+ addScaledVector( v, s ) {
|
|
|
|
|
|
this.x += v.x * s;
|
|
|
this.y += v.y * s;
|
|
@@ -151,9 +155,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- sub: function ( v, w ) {
|
|
|
+ sub( v, w ) {
|
|
|
|
|
|
if ( w !== undefined ) {
|
|
|
|
|
@@ -168,9 +172,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- subScalar: function ( s ) {
|
|
|
+ subScalar( s ) {
|
|
|
|
|
|
this.x -= s;
|
|
|
this.y -= s;
|
|
@@ -178,9 +182,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- subVectors: function ( a, b ) {
|
|
|
+ subVectors( a, b ) {
|
|
|
|
|
|
this.x = a.x - b.x;
|
|
|
this.y = a.y - b.y;
|
|
@@ -188,9 +192,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- multiply: function ( v, w ) {
|
|
|
+ multiply( v, w ) {
|
|
|
|
|
|
if ( w !== undefined ) {
|
|
|
|
|
@@ -205,9 +209,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- multiplyScalar: function ( scalar ) {
|
|
|
+ multiplyScalar( scalar ) {
|
|
|
|
|
|
this.x *= scalar;
|
|
|
this.y *= scalar;
|
|
@@ -215,9 +219,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- multiplyVectors: function ( a, b ) {
|
|
|
+ multiplyVectors( a, b ) {
|
|
|
|
|
|
this.x = a.x * b.x;
|
|
|
this.y = a.y * b.y;
|
|
@@ -225,9 +229,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- applyEuler: function ( euler ) {
|
|
|
+ applyEuler( euler ) {
|
|
|
|
|
|
if ( ! ( euler && euler.isEuler ) ) {
|
|
|
|
|
@@ -237,15 +241,15 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this.applyQuaternion( _quaternion.setFromEuler( euler ) );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- applyAxisAngle: function ( axis, angle ) {
|
|
|
+ applyAxisAngle( 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 e = m.elements;
|
|
@@ -256,15 +260,15 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- applyNormalMatrix: function ( m ) {
|
|
|
+ applyNormalMatrix( m ) {
|
|
|
|
|
|
return this.applyMatrix3( m ).normalize();
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- applyMatrix4: function ( m ) {
|
|
|
+ applyMatrix4( m ) {
|
|
|
|
|
|
const x = this.x, y = this.y, z = this.z;
|
|
|
const e = m.elements;
|
|
@@ -277,9 +281,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- applyQuaternion: function ( q ) {
|
|
|
+ applyQuaternion( q ) {
|
|
|
|
|
|
const x = this.x, y = this.y, z = this.z;
|
|
|
const qx = q.x, qy = q.y, qz = q.z, qw = q.w;
|
|
@@ -299,21 +303,21 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- project: function ( camera ) {
|
|
|
+ project( camera ) {
|
|
|
|
|
|
return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- unproject: function ( camera ) {
|
|
|
+ unproject( camera ) {
|
|
|
|
|
|
return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- transformDirection: function ( m ) {
|
|
|
+ transformDirection( m ) {
|
|
|
|
|
|
// input: THREE.Matrix4 affine matrix
|
|
|
// vector interpreted as a direction
|
|
@@ -327,9 +331,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this.normalize();
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- divide: function ( v ) {
|
|
|
+ divide( v ) {
|
|
|
|
|
|
this.x /= v.x;
|
|
|
this.y /= v.y;
|
|
@@ -337,15 +341,15 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- divideScalar: function ( scalar ) {
|
|
|
+ divideScalar( scalar ) {
|
|
|
|
|
|
return this.multiplyScalar( 1 / scalar );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- min: function ( v ) {
|
|
|
+ min( v ) {
|
|
|
|
|
|
this.x = Math.min( this.x, v.x );
|
|
|
this.y = Math.min( this.y, v.y );
|
|
@@ -353,9 +357,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- max: function ( v ) {
|
|
|
+ max( v ) {
|
|
|
|
|
|
this.x = Math.max( this.x, v.x );
|
|
|
this.y = Math.max( this.y, v.y );
|
|
@@ -363,9 +367,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- clamp: function ( min, max ) {
|
|
|
+ clamp( min, max ) {
|
|
|
|
|
|
// assumes min < max, componentwise
|
|
|
|
|
@@ -375,9 +379,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- clampScalar: function ( minVal, maxVal ) {
|
|
|
+ clampScalar( minVal, maxVal ) {
|
|
|
|
|
|
this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
|
|
|
this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
|
|
@@ -385,17 +389,17 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- clampLength: function ( min, max ) {
|
|
|
+ clampLength( min, max ) {
|
|
|
|
|
|
const length = this.length();
|
|
|
|
|
|
return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- floor: function () {
|
|
|
+ floor() {
|
|
|
|
|
|
this.x = Math.floor( this.x );
|
|
|
this.y = Math.floor( this.y );
|
|
@@ -403,9 +407,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- ceil: function () {
|
|
|
+ ceil() {
|
|
|
|
|
|
this.x = Math.ceil( this.x );
|
|
|
this.y = Math.ceil( this.y );
|
|
@@ -413,9 +417,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- round: function () {
|
|
|
+ round() {
|
|
|
|
|
|
this.x = Math.round( this.x );
|
|
|
this.y = Math.round( this.y );
|
|
@@ -423,9 +427,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- roundToZero: function () {
|
|
|
+ roundToZero() {
|
|
|
|
|
|
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 );
|
|
@@ -433,9 +437,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- negate: function () {
|
|
|
+ negate() {
|
|
|
|
|
|
this.x = - this.x;
|
|
|
this.y = - this.y;
|
|
@@ -443,47 +447,47 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- dot: function ( v ) {
|
|
|
+ dot( v ) {
|
|
|
|
|
|
return this.x * v.x + this.y * v.y + this.z * v.z;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
// TODO lengthSquared?
|
|
|
|
|
|
- lengthSq: function () {
|
|
|
+ lengthSq() {
|
|
|
|
|
|
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 );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- manhattanLength: function () {
|
|
|
+ manhattanLength() {
|
|
|
|
|
|
return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- normalize: function () {
|
|
|
+ normalize() {
|
|
|
|
|
|
return this.divideScalar( this.length() || 1 );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setLength: function ( length ) {
|
|
|
+ setLength( length ) {
|
|
|
|
|
|
return this.normalize().multiplyScalar( length );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- lerp: function ( v, alpha ) {
|
|
|
+ lerp( v, alpha ) {
|
|
|
|
|
|
this.x += ( v.x - this.x ) * alpha;
|
|
|
this.y += ( v.y - this.y ) * alpha;
|
|
@@ -491,9 +495,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- lerpVectors: function ( v1, v2, alpha ) {
|
|
|
+ lerpVectors( v1, v2, alpha ) {
|
|
|
|
|
|
this.x = v1.x + ( v2.x - v1.x ) * alpha;
|
|
|
this.y = v1.y + ( v2.y - v1.y ) * alpha;
|
|
@@ -501,9 +505,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- cross: function ( v, w ) {
|
|
|
+ cross( v, w ) {
|
|
|
|
|
|
if ( w !== undefined ) {
|
|
|
|
|
@@ -514,9 +518,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this.crossVectors( this, v );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- crossVectors: function ( a, b ) {
|
|
|
+ crossVectors( a, b ) {
|
|
|
|
|
|
const ax = a.x, ay = a.y, az = a.z;
|
|
|
const bx = b.x, by = b.y, bz = b.z;
|
|
@@ -527,9 +531,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- projectOnVector: function ( v ) {
|
|
|
+ projectOnVector( v ) {
|
|
|
|
|
|
const denominator = v.lengthSq();
|
|
|
|
|
@@ -539,26 +543,26 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this.copy( v ).multiplyScalar( scalar );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- projectOnPlane: function ( planeNormal ) {
|
|
|
+ projectOnPlane( planeNormal ) {
|
|
|
|
|
|
_vector.copy( this ).projectOnVector( planeNormal );
|
|
|
|
|
|
return this.sub( _vector );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- reflect: function ( normal ) {
|
|
|
+ reflect( normal ) {
|
|
|
|
|
|
// reflect incident vector off plane orthogonal to normal
|
|
|
// normal is assumed to have unit length
|
|
|
|
|
|
return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- angleTo: function ( v ) {
|
|
|
+ angleTo( v ) {
|
|
|
|
|
|
const denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
|
|
|
|
|
@@ -570,35 +574,35 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return Math.acos( MathUtils.clamp( theta, - 1, 1 ) );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- distanceTo: function ( v ) {
|
|
|
+ distanceTo( 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;
|
|
|
|
|
|
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 );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setFromSpherical: function ( s ) {
|
|
|
+ setFromSpherical( s ) {
|
|
|
|
|
|
return this.setFromSphericalCoords( s.radius, s.phi, s.theta );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setFromSphericalCoords: function ( radius, phi, theta ) {
|
|
|
+ setFromSphericalCoords( radius, phi, theta ) {
|
|
|
|
|
|
const sinPhiRadius = Math.sin( phi ) * radius;
|
|
|
|
|
@@ -608,15 +612,15 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setFromCylindrical: function ( c ) {
|
|
|
+ setFromCylindrical( c ) {
|
|
|
|
|
|
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.y = y;
|
|
@@ -624,9 +628,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setFromMatrixPosition: function ( m ) {
|
|
|
+ setFromMatrixPosition( m ) {
|
|
|
|
|
|
const e = m.elements;
|
|
|
|
|
@@ -636,9 +640,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setFromMatrixScale: function ( m ) {
|
|
|
+ setFromMatrixScale( m ) {
|
|
|
|
|
|
const sx = this.setFromMatrixColumn( m, 0 ).length();
|
|
|
const sy = this.setFromMatrixColumn( m, 1 ).length();
|
|
@@ -650,27 +654,27 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setFromMatrixColumn: function ( m, index ) {
|
|
|
+ setFromMatrixColumn( m, index ) {
|
|
|
|
|
|
return this.fromArray( m.elements, index * 4 );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setFromMatrix3Column: function ( m, index ) {
|
|
|
+ setFromMatrix3Column( m, index ) {
|
|
|
|
|
|
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 ) );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- fromArray: function ( array, offset ) {
|
|
|
+ fromArray( array, offset ) {
|
|
|
|
|
|
if ( offset === undefined ) offset = 0;
|
|
|
|
|
@@ -680,9 +684,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- toArray: function ( array, offset ) {
|
|
|
+ toArray( array, offset ) {
|
|
|
|
|
|
if ( array === undefined ) array = [];
|
|
|
if ( offset === undefined ) offset = 0;
|
|
@@ -693,9 +697,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return array;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- fromBufferAttribute: function ( attribute, index, offset ) {
|
|
|
+ fromBufferAttribute( attribute, index, offset ) {
|
|
|
|
|
|
if ( offset !== undefined ) {
|
|
|
|
|
@@ -709,9 +713,9 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- random: function () {
|
|
|
+ random() {
|
|
|
|
|
|
this.x = Math.random();
|
|
|
this.y = Math.random();
|
|
@@ -721,7 +725,6 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
}
|
|
|
|
|
|
-} );
|
|
|
-
|
|
|
+};
|
|
|
|
|
|
export { Vector3 };
|