text: import{_Math}from'./Math.js';import{Matrix4}from'./Matrix4.js';import{Quaternion}from'./Quaternion.js';function Vector3(a,b,c){this.x=a||0,this.y=b||0,this.z=c||0}Object.assign(Vector3.prototype,{isVector3:!0,set:function(a,b,c){return this.x=a,this.y=b,this.z=c,this},setScalar:function(a){return this.x=a,this.y=a,this.z=a,this},setX:function(a){return this.x=a,this},setY:function(a){return this.y=a,this},setZ:function(a){return this.z=a,this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw new Error('index is out of range: '+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error('index is out of range: '+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){return this.x=a.x,this.y=a.y,this.z=a.z,this},add:function(a,b){return void 0===b?(this.x+=a.x,this.y+=a.y,this.z+=a.z,this):(console.warn('THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.'),this.addVectors(a,b))},addScalar:function(a){return this.x+=a,this.y+=a,this.z+=a,this},addVectors:function(c,a){return this.x=c.x+a.x,this.y=c.y+a.y,this.z=c.z+a.z,this},addScaledVector:function(a,b){return this.x+=a.x*b,this.y+=a.y*b,this.z+=a.z*b,this},sub:function(a,b){return void 0===b?(this.x-=a.x,this.y-=a.y,this.z-=a.z,this):(console.warn('THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.'),this.subVectors(a,b))},subScalar:function(a){return this.x-=a,this.y-=a,this.z-=a,this},subVectors:function(c,a){return this.x=c.x-a.x,this.y=c.y-a.y,this.z=c.z-a.z,this},multiply:function(a,b){return void 0===b?(this.x*=a.x,this.y*=a.y,this.z*=a.z,this):(console.warn('THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.'),this.multiplyVectors(a,b))},multiplyScalar:function(a){return this.x*=a,this.y*=a,this.z*=a,this},multiplyVectors:function(c,a){return this.x=c.x*a.x,this.y=c.y*a.y,this.z=c.z*a.z,this},applyEuler:function(){var a=new Quaternion;return function(b){return!1===(b&&b.isEuler)&&console.error('THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.'),this.applyQuaternion(a.setFromEuler(b))}}(),applyAxisAngle:function(){var a=new Quaternion;return function(b,c){return this.applyQuaternion(a.setFromAxisAngle(b,c))}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z,f=a.elements;return this.x=f[0]*b+f[3]*c+f[6]*d,this.y=f[1]*b+f[4]*c+f[7]*d,this.z=f[2]*b+f[5]*c+f[8]*d,this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,f=a.elements;this.x=f[0]*b+f[4]*c+f[8]*d+f[12],this.y=f[1]*b+f[5]*c+f[9]*d+f[13],this.z=f[2]*b+f[6]*c+f[10]*d+f[14];var e=f[3]*b+f[7]*c+f[11]*d+f[15];return this.divideScalar(e)},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z,h=a.w,i=h*b+f*d-g*c,j=h*c+g*b-e*d,k=h*d+e*c-f*b,l=-e*b-f*c-g*d;return this.x=i*h+l*-e+j*-g-k*-f,this.y=j*h+l*-f+k*-e-i*-g,this.z=k*h+l*-g+i*-f-j*-e,this},project:function(){var a=new Matrix4;return function(b){return a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld)),this.applyMatrix4(a)}}(),unproject:function(){var a=new Matrix4;return function(b){return a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix)),this.applyMatrix4(a)}}(),transformDirection:function(a){var b=this.x,c=this.y,d=this.z,f=a.elements;return this.x=f[0]*b+f[4]*c+f[8]*d,this.y=f[1]*b+f[5]*c+f[9]*d,this.z=f[2]*b+f[6]*c+f[10]*d,this.normalize()},divide:function(a){return this.x/=a.x,this.y/=a.y,this.z/=a.z,this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){var b=Math.min;return this.x=b(this.x,a.x),this.y=b(this.y,a.y),this.z=b(this.z,a.z),this},max:function(a){var b=Math.max;return this.x=b(this.x,a.x),this.y=b(this.y,a.y),this.z=b(this.z,a.z),this},clamp:function(a,b){var c=Math.max,d=Math.min;return this.x=c(a.x,d(b.x,this.x)),this.y=c(a.y,d(b.y,this.y)),this.z=c(a.z,d(b.z,this.z)),this},clampScalar:function(){var a=new Vector3,b=new Vector3;return function(c,d){return a.set(c,c,c),b.set(d,d,d),this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){var a=Math.floor;return this.x=a(this.x),this.y=a(this.y),this.z=a(this.z),this},ceil:function(){var a=Math.ceil;return this.x=a(this.x),this.y=a(this.y),this.z=a(this.z),this},round:function(){var a=Math.round;return this.x=a(this.x),this.y=a(this.y),this.z=a(this.z),this},roundToZero:function(){var a=Math.ceil,b=Math.floor;return this.x=0>this.x?a(this.x):b(this.x),this.y=0>this.y?a(this.y):b(this.y),this.z=0>this.z?a(this.z):b(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){var a=Math.abs;return a(this.x)+a(this.y)+a(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){return this.x+=(a.x-this.x)*b,this.y+=(a.y-this.y)*b,this.z+=(a.z-this.z)*b,this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){if(void 0!==b)return console.warn('THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.'),this.crossVectors(a,b);var c=this.x,d=this.y,e=this.z;return this.x=d*a.z-e*a.y,this.y=e*a.x-c*a.z,this.z=c*a.y-d*a.x,this},crossVectors:function(c,a){var b=c.x,d=c.y,e=c.z,f=a.x,g=a.y,h=a.z;return this.x=d*h-e*g,this.y=e*f-b*h,this.z=b*g-d*f,this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(){var a=new Vector3;return function(b){return a.copy(this).projectOnVector(b),this.sub(a)}}(),reflect:function(){var a=new Vector3;return function(b){return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){var b=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(_Math.clamp(b,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y,d=this.z-a.z;return b*b+c*c+d*d},distanceToManhattan:function(a){var b=Math.abs;return b(this.x-a.x)+b(this.y-a.y)+b(this.z-a.z)},setFromSpherical:function(a){var b=Math.cos,c=Math.sin,d=c(a.phi)*a.radius;return this.x=d*c(a.theta),this.y=b(a.phi)*a.radius,this.z=d*b(a.theta),this},setFromCylindrical:function(a){return this.x=a.radius*Math.sin(a.theta),this.y=a.y,this.z=a.radius*Math.cos(a.theta),this},setFromMatrixPosition:function(a){return this.setFromMatrixColumn(a,3)},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),c=this.setFromMatrixColumn(a,1).length(),d=this.setFromMatrixColumn(a,2).length();return this.x=b,this.y=c,this.z=d,this},setFromMatrixColumn:function(a,b){return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){return void 0===b&&(b=0),this.x=a[b],this.y=a[b+1],this.z=a[b+2],this},toArray:function(a,b){return void 0===a&&(a=[]),void 0===b&&(b=0),a[b]=this.x,a[b+1]=this.y,a[b+2]=this.z,a},fromBufferAttribute:function(a,b,c){return void 0!==c&&console.warn('THREE.Vector3: offset has been removed from .fromBufferAttribute().'),this.x=a.getX(b),this.y=a.getY(b),this.z=a.getZ(b),this}});export{Vector3};