const DEGRESS_TO_RADIANS=Math.PI/180,RADIANS_TO_DEGRESS=180/Math.PI;class MathUtils{static normalizeDegress(t){if(t<0){for(;t<-360;)t+=360;t=360-t}else for(;t>360;)t-=360;return t}}class Quaternion{x=0;y=0;z=0;w=0;Quaternion(t=0,s=0,i=0,h=1){this.x=t,this.y=s,this.z=i,this.w=h}fromEuler(t){const s=t.x,i=t.y,h=t.z,r=Math.cos,e=Math.sin,n=r(s/2),o=r(i/2),y=r(h/2),a=e(s/2),x=e(i/2),u=e(h/2);this.x=a*o*y+n*x*u,this.y=n*x*y-a*o*u,this.z=n*o*u+a*x*y,this.w=n*o*y-a*x*u}}class Vector2{x=0;y=0;constructor(t=0,s=0){this.x=t,this.y=s}toAngle(t,s){return this.x=t,this.y=0,this.rotate(s),this}set(t=this.x,s=this.y){return this.x=t,this.y=s,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}dot(t){return this.x*t.x+this.y*t.y}equals(t){return this.x==t.x&&this.y==t.y}distance(t,s){return Math.sqrt(Math.pow(this.x-t,2)+Math.pow(this.y-s,2))}getDegress(){return Math.atan2(this.y,this.x)*RADIANS_TO_DEGRESS}rotateRad(t){let s=Math.cos(t),i=Math.sin(t),h=this.x*s+this.y*i,r=this.x*i-this.y*s;return this.x=h,this.y=r,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}normalizeOne(){let t=Math.sqrt(this.x*this.x+this.y*this.y),s=0!=this.x?this.x/t:0,i=0!=this.y?this.y/t:0;return new Vector2(s,i)}normalize(){return this.divideScalar(this.length()||1)}divideScalar(t){return this.multiplyScalar(1/t)}length(){return Math.sqrt(this.x*this.x*(this.y*this.y))}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}multiply(t){return this.x*=t.x,this.y*=t.y,this}divide(t){return this.x/=t.x,this.y/=t.y,this}rotate(t,s=ZERO_VEC2){return this.x-=s.x,this.y-=s.y,this.rotateRad(t*DEGRESS_TO_RADIANS),this.x+=s.x,this.y+=s.y,this}clone(){return new Vector2(this.x,this.y)}}class Vector3{x=0;y=0;z=0;_q=new Quaternion;constructor(t=0,s=0,i=0){"object"==typeof t?(this.x=null!=t.x?t.x:0,this.y=null!=t.y?t.y:0,this.z=null!=t.z?t.z:0):"number"==typeof t&&(this.x=t,this.y=s,this.z=i)}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}linearLerp(t,s){return new Vector3(this.x+(t.x-this.x)*s,this.y+(t.y-this.y)*s,this.z+(t.z-this.z)*s)}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}equals(t){return this.x==t.x&&this.y==t.y&&this.z==t.z}distance(t,s){const i=this.x-t.x,h=this.y-t.y,r=this.z-t.z;return s?Math.sqrt(Math.pow(i,2)+Math.pow(r,2)):Math.sqrt(Math.pow(i,2)+Math.pow(h,2)+Math.pow(r,2))}distanceEuclidian(t,s){const i=this.x-t.x,h=this.y-t.y,r=this.z-t.z;return s?i*i+r*r:i*i+h*h+r*r}set(t,s,i){return this.x=t,this.y=s,this.z=i,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}normalize(){return this.divideScalar(this.length()||1)}normalizeOne(){return new Vector3(clamp(this.x,-1,1),clamp(this.y,-1,1),clamp(this.z,-1,1))}divideScalar(t){return this.multiplyScalar(1/t)}length(){return Math.sqrt(this.x*this.x*(this.y*this.y)+this.z*this.z)}toAngle(t,s){let i=new Vector2;return i.toAngle(-t,s.y),this.x=i.x,this.z=i.y,i.toAngle(-t,s.x),this.y=i.y,this}rotateByEuler(t){this._q.fromEuler(t);const s=this.x,i=this.y,h=this.z,r=this._q.x,e=this._q.y,n=this._q.z,o=this._q.w,y=o*s+e*h-n*i,a=o*i+n*s-r*h,x=o*h+r*i-e*s,u=-r*s-e*n*h;return this.x=y*o+u*-r+a*-n-x*-e,this.y=a*o+u*-e+x*-r-y*-n,this.z=x*o+u*-n+y*-e-a*-r,this}applyDegress2D(t,s=ZERO_VEC3){return this.x-=s.x,this.y-=s.y,this.z-=s.z,this.rotateByEuler(new Vector3(t.x*DEGRESS_TO_RADIANS,t.y*DEGRESS_TO_RADIANS,0)),this.x+=s.x,this.y+=s.y,this.z+=s.z,this}clone(){return new Vector3(this.x,this.y,this.z)}}const ZERO_VEC2=new Vector2(0,0),ZERO_VEC3=new Vector3(0,0);function createFovPositions(t,s,i,h,r,e){let n=[],o=i/(h-1),y=r-i/2;for(let i=0;i<=e;i++)for(let r=1;r<=s;r++)for(let s=0;s<=h;s++){let h=(y+s*o)*(Math.PI/180),e=t.x+r*Math.cos(h),a=t.z+r*Math.sin(h);n.push({x:e,y:t.y+i,z:a})}return n}function createVolumeArea(t,s){const i=new Vector2(0,1).rotate(s);return new Vector3(t.x*i.x,t.y,t.z*i.y)}function clamp(t,s,i){return Math.min(Math.max(t,s),i)}function lerp(t,s,i){return t+(s-t)*i}export{Vector2,Vector3,MathUtils,Quaternion,clamp,lerp,createFovPositions,createVolumeArea};