UNPKG

osr-emu

Version:

A web-based graphical emulator for open source strokers.

1 lines 8.22 MB
var n={d:(v,f)=>{for(var t in f)n.o(f,t)&&!n.o(v,t)&&Object.defineProperty(v,t,{enumerable:!0,get:f[t]})},o:(n,v)=>Object.prototype.hasOwnProperty.call(n,v)},v={};n.d(v,{L:()=>Vo,Z:()=>Wo});const f=0,t=1,e=2,i=0,r=1,s=2,o=3;function a(){}Object.assign(a.prototype,{addEventListener:function(n,v){void 0===this._listeners&&(this._listeners={});const f=this._listeners;void 0===f[n]&&(f[n]=[]),-1===f[n].indexOf(v)&&f[n].push(v)},hasEventListener:function(n,v){if(void 0===this._listeners)return!1;const f=this._listeners;return void 0!==f[n]&&-1!==f[n].indexOf(v)},removeEventListener:function(n,v){if(void 0===this._listeners)return;const f=this._listeners[n];if(void 0!==f){const n=f.indexOf(v);-1!==n&&f.splice(n,1)}},dispatchEvent:function(n){if(void 0===this._listeners)return;const v=this._listeners[n.type];if(void 0!==v){n.target=this;const f=v.slice(0);for(let v=0,t=f.length;v<t;v++)f[v].call(this,n);n.target=null}}});const l=[];for(let n=0;n<256;n++)l[n]=(n<16?"0":"")+n.toString(16);let c=1234567;const h={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){const n=4294967295*Math.random()|0,v=4294967295*Math.random()|0,f=4294967295*Math.random()|0,t=4294967295*Math.random()|0;return(l[255&n]+l[n>>8&255]+l[n>>16&255]+l[n>>24&255]+"-"+l[255&v]+l[v>>8&255]+"-"+l[v>>16&15|64]+l[v>>24&255]+"-"+l[63&f|128]+l[f>>8&255]+"-"+l[f>>16&255]+l[f>>24&255]+l[255&t]+l[t>>8&255]+l[t>>16&255]+l[t>>24&255]).toUpperCase()},clamp:function(n,v,f){return Math.max(v,Math.min(f,n))},euclideanModulo:function(n,v){return(n%v+v)%v},mapLinear:function(n,v,f,t,e){return t+(n-v)*(e-t)/(f-v)},inverseLerp:function(n,v,f){return n!==v?(f-n)/(v-n):0},lerp:function(n,v,f){return(1-f)*n+f*v},damp:function(n,v,f,t){return h.lerp(n,v,1-Math.exp(-f*t))},pingpong:function(n,v=1){return v-Math.abs(h.euclideanModulo(n,2*v)-v)},smoothstep:function(n,v,f){return n<=v?0:n>=f?1:(n=(n-v)/(f-v))*n*(3-2*n)},smootherstep:function(n,v,f){return n<=v?0:n>=f?1:(n=(n-v)/(f-v))*n*n*(n*(6*n-15)+10)},randInt:function(n,v){return n+Math.floor(Math.random()*(v-n+1))},randFloat:function(n,v){return n+Math.random()*(v-n)},randFloatSpread:function(n){return n*(.5-Math.random())},seededRandom:function(n){return void 0!==n&&(c=n%2147483647),c=16807*c%2147483647,(c-1)/2147483646},degToRad:function(n){return n*h.DEG2RAD},radToDeg:function(n){return n*h.RAD2DEG},isPowerOfTwo:function(n){return 0==(n&n-1)&&0!==n},ceilPowerOfTwo:function(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))},floorPowerOfTwo:function(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))},setQuaternionFromProperEuler:function(n,v,f,t,e){const i=Math.cos,r=Math.sin,s=i(f/2),o=r(f/2),a=i((v+t)/2),l=r((v+t)/2),c=i((v-t)/2),h=r((v-t)/2),u=i((t-v)/2),d=r((t-v)/2);switch(e){case"XYX":n.set(s*l,o*c,o*h,s*a);break;case"YZY":n.set(o*h,s*l,o*c,s*a);break;case"ZXZ":n.set(o*c,o*h,s*l,s*a);break;case"XZX":n.set(s*l,o*d,o*u,s*a);break;case"YXY":n.set(o*u,s*l,o*d,s*a);break;case"ZYZ":n.set(o*d,o*u,s*l,s*a);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+e)}}};class u{constructor(n=0,v=0){this.x=n,this.y=v}get width(){return this.x}set width(n){this.x=n}get height(){return this.y}set height(n){this.y=n}set(n,v){return this.x=n,this.y=v,this}setScalar(n){return this.x=n,this.y=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setComponent(n,v){switch(n){case 0:this.x=v;break;case 1:this.y=v;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y)}copy(n){return this.x=n.x,this.y=n.y,this}add(n,v){return void 0!==v?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(n,v)):(this.x+=n.x,this.y+=n.y,this)}addScalar(n){return this.x+=n,this.y+=n,this}addVectors(n,v){return this.x=n.x+v.x,this.y=n.y+v.y,this}addScaledVector(n,v){return this.x+=n.x*v,this.y+=n.y*v,this}sub(n,v){return void 0!==v?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(n,v)):(this.x-=n.x,this.y-=n.y,this)}subScalar(n){return this.x-=n,this.y-=n,this}subVectors(n,v){return this.x=n.x-v.x,this.y=n.y-v.y,this}multiply(n){return this.x*=n.x,this.y*=n.y,this}multiplyScalar(n){return this.x*=n,this.y*=n,this}divide(n){return this.x/=n.x,this.y/=n.y,this}divideScalar(n){return this.multiplyScalar(1/n)}applyMatrix3(n){const v=this.x,f=this.y,t=n.elements;return this.x=t[0]*v+t[3]*f+t[6],this.y=t[1]*v+t[4]*f+t[7],this}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this}clamp(n,v){return this.x=Math.max(n.x,Math.min(v.x,this.x)),this.y=Math.max(n.y,Math.min(v.y,this.y)),this}clampScalar(n,v){return this.x=Math.max(n,Math.min(v,this.x)),this.y=Math.max(n,Math.min(v,this.y)),this}clampLength(n,v){const f=this.length();return this.divideScalar(f||1).multiplyScalar(Math.max(n,Math.min(v,f)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return 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}negate(){return this.x=-this.x,this.y=-this.y,this}dot(n){return this.x*n.x+this.y*n.y}cross(n){return this.x*n.y-this.y*n.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(n){return Math.sqrt(this.distanceToSquared(n))}distanceToSquared(n){const v=this.x-n.x,f=this.y-n.y;return v*v+f*f}manhattanDistanceTo(n){return Math.abs(this.x-n.x)+Math.abs(this.y-n.y)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,v){return this.x+=(n.x-this.x)*v,this.y+=(n.y-this.y)*v,this}lerpVectors(n,v,f){return this.x=n.x+(v.x-n.x)*f,this.y=n.y+(v.y-n.y)*f,this}equals(n){return n.x===this.x&&n.y===this.y}fromArray(n,v=0){return this.x=n[v],this.y=n[v+1],this}toArray(n=[],v=0){return n[v]=this.x,n[v+1]=this.y,n}fromBufferAttribute(n,v,f){return void 0!==f&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=n.getX(v),this.y=n.getY(v),this}rotateAround(n,v){const f=Math.cos(v),t=Math.sin(v),e=this.x-n.x,i=this.y-n.y;return this.x=e*f-i*t+n.x,this.y=e*t+i*f+n.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}u.prototype.isVector2=!0;class d{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(n,v,f,t,e,i,r,s,o){const a=this.elements;return a[0]=n,a[1]=t,a[2]=r,a[3]=v,a[4]=e,a[5]=s,a[6]=f,a[7]=i,a[8]=o,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(n){const v=this.elements,f=n.elements;return v[0]=f[0],v[1]=f[1],v[2]=f[2],v[3]=f[3],v[4]=f[4],v[5]=f[5],v[6]=f[6],v[7]=f[7],v[8]=f[8],this}extractBasis(n,v,f){return n.setFromMatrix3Column(this,0),v.setFromMatrix3Column(this,1),f.setFromMatrix3Column(this,2),this}setFromMatrix4(n){const v=n.elements;return this.set(v[0],v[4],v[8],v[1],v[5],v[9],v[2],v[6],v[10]),this}multiply(n){return this.multiplyMatrices(this,n)}premultiply(n){return this.multiplyMatrices(n,this)}multiplyMatrices(n,v){const f=n.elements,t=v.elements,e=this.elements,i=f[0],r=f[3],s=f[6],o=f[1],a=f[4],l=f[7],c=f[2],h=f[5],u=f[8],d=t[0],p=t[3],m=t[6],g=t[1],y=t[4],x=t[7],_=t[2],b=t[5],w=t[8];return e[0]=i*d+r*g+s*_,e[3]=i*p+r*y+s*b,e[6]=i*m+r*x+s*w,e[1]=o*d+a*g+l*_,e[4]=o*p+a*y+l*b,e[7]=o*m+a*x+l*w,e[2]=c*d+h*g+u*_,e[5]=c*p+h*y+u*b,e[8]=c*m+h*x+u*w,this}multiplyScalar(n){const v=this.elements;return v[0]*=n,v[3]*=n,v[6]*=n,v[1]*=n,v[4]*=n,v[7]*=n,v[2]*=n,v[5]*=n,v[8]*=n,this}determinant(){const n=this.elements,v=n[0],f=n[1],t=n[2],e=n[3],i=n[4],r=n[5],s=n[6],o=n[7],a=n[8];return v*i*a-v*r*o-f*e*a+f*r*s+t*e*o-t*i*s}invert(){const n=this.elements,v=n[0],f=n[1],t=n[2],e=n[3],i=n[4],r=n[5],s=n[6],o=n[7],a=n[8],l=a*i-r*o,c=r*s-a*e,h=o*e-i*s,u=v*l+f*c+t*h;if(0===u)return this.set(0,0,0,0,0,0,0,0,0);const d=1/u;return n[0]=l*d,n[1]=(t*o-a*f)*d,n[2]=(r*f-t*i)*d,n[3]=c*d,n[4]=(a*v-t*s)*d,n[5]=(t*e-r*v)*d,n[6]=h*d,n[7]=(f*s-o*v)*d,n[8]=(i*v-f*e)*d,this}transpose(){let n;const v=this.elements;return n=v[1],v[1]=v[3],v[3]=n,n=v[2],v[2]=v[6],v[6]=n,n=v[5],v[5]=v[7],v[7]=n,this}getNormalMatrix(n){return this.setFromMatrix4(n).invert().transpose()}transposeIntoArray(n){const v=this.elements;return n[0]=v[0],n[1]=v[3],n[2]=v[6],n[3]=v[1],n[4]=v[4],n[5]=v[7],n[6]=v[2],n[7]=v[5],n[8]=v[8],this}setUvTransform(n,v,f,t,e,i,r){const s=Math.cos(e),o=Math.sin(e);return this.set(f*s,f*o,-f*(s*i+o*r)+i+n,-t*o,t*s,-t*(-o*i+s*r)+r+v,0,0,1),this}scale(n,v){const f=this.elements;return f[0]*=n,f[3]*=n,f[6]*=n,f[1]*=v,f[4]*=v,f[7]*=v,this}rotate(n){const v=Math.cos(n),f=Math.sin(n),t=this.elements,e=t[0],i=t[3],r=t[6],s=t[1],o=t[4],a=t[7];return t[0]=v*e+f*s,t[3]=v*i+f*o,t[6]=v*r+f*a,t[1]=-f*e+v*s,t[4]=-f*i+v*o,t[7]=-f*r+v*a,this}translate(n,v){const f=this.elements;return f[0]+=n*f[2],f[3]+=n*f[5],f[6]+=n*f[8],f[1]+=v*f[2],f[4]+=v*f[5],f[7]+=v*f[8],this}equals(n){const v=this.elements,f=n.elements;for(let n=0;n<9;n++)if(v[n]!==f[n])return!1;return!0}fromArray(n,v=0){for(let f=0;f<9;f++)this.elements[f]=n[f+v];return this}toArray(n=[],v=0){const f=this.elements;return n[v]=f[0],n[v+1]=f[1],n[v+2]=f[2],n[v+3]=f[3],n[v+4]=f[4],n[v+5]=f[5],n[v+6]=f[6],n[v+7]=f[7],n[v+8]=f[8],n}clone(){return(new this.constructor).fromArray(this.elements)}}let p;d.prototype.isMatrix3=!0;const m={getDataURL:function(n){if(/^data:/i.test(n.src))return n.src;if("undefined"==typeof HTMLCanvasElement)return n.src;let v;if(n instanceof HTMLCanvasElement)v=n;else{void 0===p&&(p=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),p.width=n.width,p.height=n.height;const f=p.getContext("2d");n instanceof ImageData?f.putImageData(n,0,0):f.drawImage(n,0,0,n.width,n.height),v=p}return v.width>2048||v.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",n),v.toDataURL("image/jpeg",.6)):v.toDataURL("image/png")}};let g=0;class y extends a{constructor(n=y.DEFAULT_IMAGE,v=y.DEFAULT_MAPPING,f=1001,t=1001,e=1006,i=1008,r=1023,s=1009,o=1,a=3e3){super(),Object.defineProperty(this,"id",{value:g++}),this.uuid=h.generateUUID(),this.name="",this.image=n,this.mipmaps=[],this.mapping=v,this.wrapS=f,this.wrapT=t,this.magFilter=e,this.minFilter=i,this.anisotropy=o,this.format=r,this.internalFormat=null,this.type=s,this.offset=new u(0,0),this.repeat=new u(1,1),this.center=new u(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new d,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=a,this.version=0,this.onUpdate=null}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(n){return this.name=n.name,this.image=n.image,this.mipmaps=n.mipmaps.slice(0),this.mapping=n.mapping,this.wrapS=n.wrapS,this.wrapT=n.wrapT,this.magFilter=n.magFilter,this.minFilter=n.minFilter,this.anisotropy=n.anisotropy,this.format=n.format,this.internalFormat=n.internalFormat,this.type=n.type,this.offset.copy(n.offset),this.repeat.copy(n.repeat),this.center.copy(n.center),this.rotation=n.rotation,this.matrixAutoUpdate=n.matrixAutoUpdate,this.matrix.copy(n.matrix),this.generateMipmaps=n.generateMipmaps,this.premultiplyAlpha=n.premultiplyAlpha,this.flipY=n.flipY,this.unpackAlignment=n.unpackAlignment,this.encoding=n.encoding,this}toJSON(n){const v=void 0===n||"string"==typeof n;if(!v&&void 0!==n.textures[this.uuid])return n.textures[this.uuid];const f={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const t=this.image;if(void 0===t.uuid&&(t.uuid=h.generateUUID()),!v&&void 0===n.images[t.uuid]){let v;if(Array.isArray(t)){v=[];for(let n=0,f=t.length;n<f;n++)t[n].isDataTexture?v.push(x(t[n].image)):v.push(x(t[n]))}else v=x(t);n.images[t.uuid]={uuid:t.uuid,url:v}}f.image=t.uuid}return v||(n.textures[this.uuid]=f),f}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(n){if(300!==this.mapping)return n;if(n.applyMatrix3(this.matrix),n.x<0||n.x>1)switch(this.wrapS){case 1e3:n.x=n.x-Math.floor(n.x);break;case 1001:n.x=n.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(n.x)%2)?n.x=Math.ceil(n.x)-n.x:n.x=n.x-Math.floor(n.x)}if(n.y<0||n.y>1)switch(this.wrapT){case 1e3:n.y=n.y-Math.floor(n.y);break;case 1001:n.y=n.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(n.y)%2)?n.y=Math.ceil(n.y)-n.y:n.y=n.y-Math.floor(n.y)}return this.flipY&&(n.y=1-n.y),n}set needsUpdate(n){!0===n&&this.version++}}function x(n){return"undefined"!=typeof HTMLImageElement&&n instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&n instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&n instanceof ImageBitmap?m.getDataURL(n):n.data?{data:Array.prototype.slice.call(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}y.DEFAULT_IMAGE=void 0,y.DEFAULT_MAPPING=300,y.prototype.isTexture=!0;class _{constructor(n=0,v=0,f=0,t=1){this.x=n,this.y=v,this.z=f,this.w=t}get width(){return this.z}set width(n){this.z=n}get height(){return this.w}set height(n){this.w=n}set(n,v,f,t){return this.x=n,this.y=v,this.z=f,this.w=t,this}setScalar(n){return this.x=n,this.y=n,this.z=n,this.w=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setZ(n){return this.z=n,this}setW(n){return this.w=n,this}setComponent(n,v){switch(n){case 0:this.x=v;break;case 1:this.y=v;break;case 2:this.z=v;break;case 3:this.w=v;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(n){return this.x=n.x,this.y=n.y,this.z=n.z,this.w=void 0!==n.w?n.w:1,this}add(n,v){return void 0!==v?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(n,v)):(this.x+=n.x,this.y+=n.y,this.z+=n.z,this.w+=n.w,this)}addScalar(n){return this.x+=n,this.y+=n,this.z+=n,this.w+=n,this}addVectors(n,v){return this.x=n.x+v.x,this.y=n.y+v.y,this.z=n.z+v.z,this.w=n.w+v.w,this}addScaledVector(n,v){return this.x+=n.x*v,this.y+=n.y*v,this.z+=n.z*v,this.w+=n.w*v,this}sub(n,v){return void 0!==v?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(n,v)):(this.x-=n.x,this.y-=n.y,this.z-=n.z,this.w-=n.w,this)}subScalar(n){return this.x-=n,this.y-=n,this.z-=n,this.w-=n,this}subVectors(n,v){return this.x=n.x-v.x,this.y=n.y-v.y,this.z=n.z-v.z,this.w=n.w-v.w,this}multiply(n){return this.x*=n.x,this.y*=n.y,this.z*=n.z,this.w*=n.w,this}multiplyScalar(n){return this.x*=n,this.y*=n,this.z*=n,this.w*=n,this}applyMatrix4(n){const v=this.x,f=this.y,t=this.z,e=this.w,i=n.elements;return this.x=i[0]*v+i[4]*f+i[8]*t+i[12]*e,this.y=i[1]*v+i[5]*f+i[9]*t+i[13]*e,this.z=i[2]*v+i[6]*f+i[10]*t+i[14]*e,this.w=i[3]*v+i[7]*f+i[11]*t+i[15]*e,this}divideScalar(n){return this.multiplyScalar(1/n)}setAxisAngleFromQuaternion(n){this.w=2*Math.acos(n.w);const v=Math.sqrt(1-n.w*n.w);return v<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=n.x/v,this.y=n.y/v,this.z=n.z/v),this}setAxisAngleFromRotationMatrix(n){let v,f,t,e;const i=.01,r=.1,s=n.elements,o=s[0],a=s[4],l=s[8],c=s[1],h=s[5],u=s[9],d=s[2],p=s[6],m=s[10];if(Math.abs(a-c)<i&&Math.abs(l-d)<i&&Math.abs(u-p)<i){if(Math.abs(a+c)<r&&Math.abs(l+d)<r&&Math.abs(u+p)<r&&Math.abs(o+h+m-3)<r)return this.set(1,0,0,0),this;v=Math.PI;const n=(o+1)/2,s=(h+1)/2,g=(m+1)/2,y=(a+c)/4,x=(l+d)/4,_=(u+p)/4;return n>s&&n>g?n<i?(f=0,t=.707106781,e=.707106781):(f=Math.sqrt(n),t=y/f,e=x/f):s>g?s<i?(f=.707106781,t=0,e=.707106781):(t=Math.sqrt(s),f=y/t,e=_/t):g<i?(f=.707106781,t=.707106781,e=0):(e=Math.sqrt(g),f=x/e,t=_/e),this.set(f,t,e,v),this}let g=Math.sqrt((p-u)*(p-u)+(l-d)*(l-d)+(c-a)*(c-a));return Math.abs(g)<.001&&(g=1),this.x=(p-u)/g,this.y=(l-d)/g,this.z=(c-a)/g,this.w=Math.acos((o+h+m-1)/2),this}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this.z=Math.min(this.z,n.z),this.w=Math.min(this.w,n.w),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this.z=Math.max(this.z,n.z),this.w=Math.max(this.w,n.w),this}clamp(n,v){return this.x=Math.max(n.x,Math.min(v.x,this.x)),this.y=Math.max(n.y,Math.min(v.y,this.y)),this.z=Math.max(n.z,Math.min(v.z,this.z)),this.w=Math.max(n.w,Math.min(v.w,this.w)),this}clampScalar(n,v){return this.x=Math.max(n,Math.min(v,this.x)),this.y=Math.max(n,Math.min(v,this.y)),this.z=Math.max(n,Math.min(v,this.z)),this.w=Math.max(n,Math.min(v,this.w)),this}clampLength(n,v){const f=this.length();return this.divideScalar(f||1).multiplyScalar(Math.max(n,Math.min(v,f)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return 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.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(n){return this.x*n.x+this.y*n.y+this.z*n.z+this.w*n.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,v){return this.x+=(n.x-this.x)*v,this.y+=(n.y-this.y)*v,this.z+=(n.z-this.z)*v,this.w+=(n.w-this.w)*v,this}lerpVectors(n,v,f){return this.x=n.x+(v.x-n.x)*f,this.y=n.y+(v.y-n.y)*f,this.z=n.z+(v.z-n.z)*f,this.w=n.w+(v.w-n.w)*f,this}equals(n){return n.x===this.x&&n.y===this.y&&n.z===this.z&&n.w===this.w}fromArray(n,v=0){return this.x=n[v],this.y=n[v+1],this.z=n[v+2],this.w=n[v+3],this}toArray(n=[],v=0){return n[v]=this.x,n[v+1]=this.y,n[v+2]=this.z,n[v+3]=this.w,n}fromBufferAttribute(n,v,f){return void 0!==f&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=n.getX(v),this.y=n.getY(v),this.z=n.getZ(v),this.w=n.getW(v),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}_.prototype.isVector4=!0;class b extends a{constructor(n,v,f){super(),this.width=n,this.height=v,this.depth=1,this.scissor=new _(0,0,n,v),this.scissorTest=!1,this.viewport=new _(0,0,n,v),f=f||{},this.texture=new y(void 0,f.mapping,f.wrapS,f.wrapT,f.magFilter,f.minFilter,f.format,f.type,f.anisotropy,f.encoding),this.texture.image={},this.texture.image.width=n,this.texture.image.height=v,this.texture.image.depth=1,this.texture.generateMipmaps=void 0!==f.generateMipmaps&&f.generateMipmaps,this.texture.minFilter=void 0!==f.minFilter?f.minFilter:1006,this.depthBuffer=void 0===f.depthBuffer||f.depthBuffer,this.stencilBuffer=void 0!==f.stencilBuffer&&f.stencilBuffer,this.depthTexture=void 0!==f.depthTexture?f.depthTexture:null}setTexture(n){n.image={width:this.width,height:this.height,depth:this.depth},this.texture=n}setSize(n,v,f=1){this.width===n&&this.height===v&&this.depth===f||(this.width=n,this.height=v,this.depth=f,this.texture.image.width=n,this.texture.image.height=v,this.texture.image.depth=f,this.dispose()),this.viewport.set(0,0,n,v),this.scissor.set(0,0,n,v)}clone(){return(new this.constructor).copy(this)}copy(n){return this.width=n.width,this.height=n.height,this.depth=n.depth,this.viewport.copy(n.viewport),this.texture=n.texture.clone(),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}b.prototype.isWebGLRenderTarget=!0;(class extends b{constructor(n,v,f){super(n,v,f),this.samples=4}copy(n){return super.copy.call(this,n),this.samples=n.samples,this}}).prototype.isWebGLMultisampleRenderTarget=!0;class w{constructor(n=0,v=0,f=0,t=1){this._x=n,this._y=v,this._z=f,this._w=t}static slerp(n,v,f,t){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),f.slerpQuaternions(n,v,t)}static slerpFlat(n,v,f,t,e,i,r){let s=f[t+0],o=f[t+1],a=f[t+2],l=f[t+3];const c=e[i+0],h=e[i+1],u=e[i+2],d=e[i+3];if(0===r)return n[v+0]=s,n[v+1]=o,n[v+2]=a,void(n[v+3]=l);if(1===r)return n[v+0]=c,n[v+1]=h,n[v+2]=u,void(n[v+3]=d);if(l!==d||s!==c||o!==h||a!==u){let n=1-r;const v=s*c+o*h+a*u+l*d,f=v>=0?1:-1,t=1-v*v;if(t>Number.EPSILON){const e=Math.sqrt(t),i=Math.atan2(e,v*f);n=Math.sin(n*i)/e,r=Math.sin(r*i)/e}const e=r*f;if(s=s*n+c*e,o=o*n+h*e,a=a*n+u*e,l=l*n+d*e,n===1-r){const n=1/Math.sqrt(s*s+o*o+a*a+l*l);s*=n,o*=n,a*=n,l*=n}}n[v]=s,n[v+1]=o,n[v+2]=a,n[v+3]=l}static multiplyQuaternionsFlat(n,v,f,t,e,i){const r=f[t],s=f[t+1],o=f[t+2],a=f[t+3],l=e[i],c=e[i+1],h=e[i+2],u=e[i+3];return n[v]=r*u+a*l+s*h-o*c,n[v+1]=s*u+a*c+o*l-r*h,n[v+2]=o*u+a*h+r*c-s*l,n[v+3]=a*u-r*l-s*c-o*h,n}get x(){return this._x}set x(n){this._x=n,this._onChangeCallback()}get y(){return this._y}set y(n){this._y=n,this._onChangeCallback()}get z(){return this._z}set z(n){this._z=n,this._onChangeCallback()}get w(){return this._w}set w(n){this._w=n,this._onChangeCallback()}set(n,v,f,t){return this._x=n,this._y=v,this._z=f,this._w=t,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(n){return this._x=n.x,this._y=n.y,this._z=n.z,this._w=n.w,this._onChangeCallback(),this}setFromEuler(n,v){if(!n||!n.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const f=n._x,t=n._y,e=n._z,i=n._order,r=Math.cos,s=Math.sin,o=r(f/2),a=r(t/2),l=r(e/2),c=s(f/2),h=s(t/2),u=s(e/2);switch(i){case"XYZ":this._x=c*a*l+o*h*u,this._y=o*h*l-c*a*u,this._z=o*a*u+c*h*l,this._w=o*a*l-c*h*u;break;case"YXZ":this._x=c*a*l+o*h*u,this._y=o*h*l-c*a*u,this._z=o*a*u-c*h*l,this._w=o*a*l+c*h*u;break;case"ZXY":this._x=c*a*l-o*h*u,this._y=o*h*l+c*a*u,this._z=o*a*u+c*h*l,this._w=o*a*l-c*h*u;break;case"ZYX":this._x=c*a*l-o*h*u,this._y=o*h*l+c*a*u,this._z=o*a*u-c*h*l,this._w=o*a*l+c*h*u;break;case"YZX":this._x=c*a*l+o*h*u,this._y=o*h*l+c*a*u,this._z=o*a*u-c*h*l,this._w=o*a*l-c*h*u;break;case"XZY":this._x=c*a*l-o*h*u,this._y=o*h*l-c*a*u,this._z=o*a*u+c*h*l,this._w=o*a*l+c*h*u;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+i)}return!1!==v&&this._onChangeCallback(),this}setFromAxisAngle(n,v){const f=v/2,t=Math.sin(f);return this._x=n.x*t,this._y=n.y*t,this._z=n.z*t,this._w=Math.cos(f),this._onChangeCallback(),this}setFromRotationMatrix(n){const v=n.elements,f=v[0],t=v[4],e=v[8],i=v[1],r=v[5],s=v[9],o=v[2],a=v[6],l=v[10],c=f+r+l;if(c>0){const n=.5/Math.sqrt(c+1);this._w=.25/n,this._x=(a-s)*n,this._y=(e-o)*n,this._z=(i-t)*n}else if(f>r&&f>l){const n=2*Math.sqrt(1+f-r-l);this._w=(a-s)/n,this._x=.25*n,this._y=(t+i)/n,this._z=(e+o)/n}else if(r>l){const n=2*Math.sqrt(1+r-f-l);this._w=(e-o)/n,this._x=(t+i)/n,this._y=.25*n,this._z=(s+a)/n}else{const n=2*Math.sqrt(1+l-f-r);this._w=(i-t)/n,this._x=(e+o)/n,this._y=(s+a)/n,this._z=.25*n}return this._onChangeCallback(),this}setFromUnitVectors(n,v){let f=n.dot(v)+1;return f<Number.EPSILON?(f=0,Math.abs(n.x)>Math.abs(n.z)?(this._x=-n.y,this._y=n.x,this._z=0,this._w=f):(this._x=0,this._y=-n.z,this._z=n.y,this._w=f)):(this._x=n.y*v.z-n.z*v.y,this._y=n.z*v.x-n.x*v.z,this._z=n.x*v.y-n.y*v.x,this._w=f),this.normalize()}angleTo(n){return 2*Math.acos(Math.abs(h.clamp(this.dot(n),-1,1)))}rotateTowards(n,v){const f=this.angleTo(n);if(0===f)return this;const t=Math.min(1,v/f);return this.slerp(n,t),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(n){return this._x*n._x+this._y*n._y+this._z*n._z+this._w*n._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let n=this.length();return 0===n?(this._x=0,this._y=0,this._z=0,this._w=1):(n=1/n,this._x=this._x*n,this._y=this._y*n,this._z=this._z*n,this._w=this._w*n),this._onChangeCallback(),this}multiply(n,v){return void 0!==v?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(n,v)):this.multiplyQuaternions(this,n)}premultiply(n){return this.multiplyQuaternions(n,this)}multiplyQuaternions(n,v){const f=n._x,t=n._y,e=n._z,i=n._w,r=v._x,s=v._y,o=v._z,a=v._w;return this._x=f*a+i*r+t*o-e*s,this._y=t*a+i*s+e*r-f*o,this._z=e*a+i*o+f*s-t*r,this._w=i*a-f*r-t*s-e*o,this._onChangeCallback(),this}slerp(n,v){if(0===v)return this;if(1===v)return this.copy(n);const f=this._x,t=this._y,e=this._z,i=this._w;let r=i*n._w+f*n._x+t*n._y+e*n._z;if(r<0?(this._w=-n._w,this._x=-n._x,this._y=-n._y,this._z=-n._z,r=-r):this.copy(n),r>=1)return this._w=i,this._x=f,this._y=t,this._z=e,this;const s=1-r*r;if(s<=Number.EPSILON){const n=1-v;return this._w=n*i+v*this._w,this._x=n*f+v*this._x,this._y=n*t+v*this._y,this._z=n*e+v*this._z,this.normalize(),this._onChangeCallback(),this}const o=Math.sqrt(s),a=Math.atan2(o,r),l=Math.sin((1-v)*a)/o,c=Math.sin(v*a)/o;return this._w=i*l+this._w*c,this._x=f*l+this._x*c,this._y=t*l+this._y*c,this._z=e*l+this._z*c,this._onChangeCallback(),this}slerpQuaternions(n,v,f){this.copy(n).slerp(v,f)}equals(n){return n._x===this._x&&n._y===this._y&&n._z===this._z&&n._w===this._w}fromArray(n,v=0){return this._x=n[v],this._y=n[v+1],this._z=n[v+2],this._w=n[v+3],this._onChangeCallback(),this}toArray(n=[],v=0){return n[v]=this._x,n[v+1]=this._y,n[v+2]=this._z,n[v+3]=this._w,n}fromBufferAttribute(n,v){return this._x=n.getX(v),this._y=n.getY(v),this._z=n.getZ(v),this._w=n.getW(v),this}_onChange(n){return this._onChangeCallback=n,this}_onChangeCallback(){}}w.prototype.isQuaternion=!0;class M{constructor(n=0,v=0,f=0){this.x=n,this.y=v,this.z=f}set(n,v,f){return void 0===f&&(f=this.z),this.x=n,this.y=v,this.z=f,this}setScalar(n){return this.x=n,this.y=n,this.z=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setZ(n){return this.z=n,this}setComponent(n,v){switch(n){case 0:this.x=v;break;case 1:this.y=v;break;case 2:this.z=v;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(n){return this.x=n.x,this.y=n.y,this.z=n.z,this}add(n,v){return void 0!==v?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(n,v)):(this.x+=n.x,this.y+=n.y,this.z+=n.z,this)}addScalar(n){return this.x+=n,this.y+=n,this.z+=n,this}addVectors(n,v){return this.x=n.x+v.x,this.y=n.y+v.y,this.z=n.z+v.z,this}addScaledVector(n,v){return this.x+=n.x*v,this.y+=n.y*v,this.z+=n.z*v,this}sub(n,v){return void 0!==v?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(n,v)):(this.x-=n.x,this.y-=n.y,this.z-=n.z,this)}subScalar(n){return this.x-=n,this.y-=n,this.z-=n,this}subVectors(n,v){return this.x=n.x-v.x,this.y=n.y-v.y,this.z=n.z-v.z,this}multiply(n,v){return void 0!==v?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(n,v)):(this.x*=n.x,this.y*=n.y,this.z*=n.z,this)}multiplyScalar(n){return this.x*=n,this.y*=n,this.z*=n,this}multiplyVectors(n,v){return this.x=n.x*v.x,this.y=n.y*v.y,this.z=n.z*v.z,this}applyEuler(n){return n&&n.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(E.setFromEuler(n))}applyAxisAngle(n,v){return this.applyQuaternion(E.setFromAxisAngle(n,v))}applyMatrix3(n){const v=this.x,f=this.y,t=this.z,e=n.elements;return this.x=e[0]*v+e[3]*f+e[6]*t,this.y=e[1]*v+e[4]*f+e[7]*t,this.z=e[2]*v+e[5]*f+e[8]*t,this}applyNormalMatrix(n){return this.applyMatrix3(n).normalize()}applyMatrix4(n){const v=this.x,f=this.y,t=this.z,e=n.elements,i=1/(e[3]*v+e[7]*f+e[11]*t+e[15]);return this.x=(e[0]*v+e[4]*f+e[8]*t+e[12])*i,this.y=(e[1]*v+e[5]*f+e[9]*t+e[13])*i,this.z=(e[2]*v+e[6]*f+e[10]*t+e[14])*i,this}applyQuaternion(n){const v=this.x,f=this.y,t=this.z,e=n.x,i=n.y,r=n.z,s=n.w,o=s*v+i*t-r*f,a=s*f+r*v-e*t,l=s*t+e*f-i*v,c=-e*v-i*f-r*t;return this.x=o*s+c*-e+a*-r-l*-i,this.y=a*s+c*-i+l*-e-o*-r,this.z=l*s+c*-r+o*-i-a*-e,this}project(n){return this.applyMatrix4(n.matrixWorldInverse).applyMatrix4(n.projectionMatrix)}unproject(n){return this.applyMatrix4(n.projectionMatrixInverse).applyMatrix4(n.matrixWorld)}transformDirection(n){const v=this.x,f=this.y,t=this.z,e=n.elements;return this.x=e[0]*v+e[4]*f+e[8]*t,this.y=e[1]*v+e[5]*f+e[9]*t,this.z=e[2]*v+e[6]*f+e[10]*t,this.normalize()}divide(n){return this.x/=n.x,this.y/=n.y,this.z/=n.z,this}divideScalar(n){return this.multiplyScalar(1/n)}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this.z=Math.min(this.z,n.z),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this.z=Math.max(this.z,n.z),this}clamp(n,v){return this.x=Math.max(n.x,Math.min(v.x,this.x)),this.y=Math.max(n.y,Math.min(v.y,this.y)),this.z=Math.max(n.z,Math.min(v.z,this.z)),this}clampScalar(n,v){return this.x=Math.max(n,Math.min(v,this.x)),this.y=Math.max(n,Math.min(v,this.y)),this.z=Math.max(n,Math.min(v,this.z)),this}clampLength(n,v){const f=this.length();return this.divideScalar(f||1).multiplyScalar(Math.max(n,Math.min(v,f)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return 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.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(n){return this.x*n.x+this.y*n.y+this.z*n.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,v){return this.x+=(n.x-this.x)*v,this.y+=(n.y-this.y)*v,this.z+=(n.z-this.z)*v,this}lerpVectors(n,v,f){return this.x=n.x+(v.x-n.x)*f,this.y=n.y+(v.y-n.y)*f,this.z=n.z+(v.z-n.z)*f,this}cross(n,v){return void 0!==v?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(n,v)):this.crossVectors(this,n)}crossVectors(n,v){const f=n.x,t=n.y,e=n.z,i=v.x,r=v.y,s=v.z;return this.x=t*s-e*r,this.y=e*i-f*s,this.z=f*r-t*i,this}projectOnVector(n){const v=n.lengthSq();if(0===v)return this.set(0,0,0);const f=n.dot(this)/v;return this.copy(n).multiplyScalar(f)}projectOnPlane(n){return S.copy(this).projectOnVector(n),this.sub(S)}reflect(n){return this.sub(S.copy(n).multiplyScalar(2*this.dot(n)))}angleTo(n){const v=Math.sqrt(this.lengthSq()*n.lengthSq());if(0===v)return Math.PI/2;const f=this.dot(n)/v;return Math.acos(h.clamp(f,-1,1))}distanceTo(n){return Math.sqrt(this.distanceToSquared(n))}distanceToSquared(n){const v=this.x-n.x,f=this.y-n.y,t=this.z-n.z;return v*v+f*f+t*t}manhattanDistanceTo(n){return Math.abs(this.x-n.x)+Math.abs(this.y-n.y)+Math.abs(this.z-n.z)}setFromSpherical(n){return this.setFromSphericalCoords(n.radius,n.phi,n.theta)}setFromSphericalCoords(n,v,f){const t=Math.sin(v)*n;return this.x=t*Math.sin(f),this.y=Math.cos(v)*n,this.z=t*Math.cos(f),this}setFromCylindrical(n){return this.setFromCylindricalCoords(n.radius,n.theta,n.y)}setFromCylindricalCoords(n,v,f){return this.x=n*Math.sin(v),this.y=f,this.z=n*Math.cos(v),this}setFromMatrixPosition(n){const v=n.elements;return this.x=v[12],this.y=v[13],this.z=v[14],this}setFromMatrixScale(n){const v=this.setFromMatrixColumn(n,0).length(),f=this.setFromMatrixColumn(n,1).length(),t=this.setFromMatrixColumn(n,2).length();return this.x=v,this.y=f,this.z=t,this}setFromMatrixColumn(n,v){return this.fromArray(n.elements,4*v)}setFromMatrix3Column(n,v){return this.fromArray(n.elements,3*v)}equals(n){return n.x===this.x&&n.y===this.y&&n.z===this.z}fromArray(n,v=0){return this.x=n[v],this.y=n[v+1],this.z=n[v+2],this}toArray(n=[],v=0){return n[v]=this.x,n[v+1]=this.y,n[v+2]=this.z,n}fromBufferAttribute(n,v,f){return void 0!==f&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=n.getX(v),this.y=n.getY(v),this.z=n.getZ(v),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}M.prototype.isVector3=!0;const S=new M,E=new w;class T{constructor(n=new M(1/0,1/0,1/0),v=new M(-1/0,-1/0,-1/0)){this.min=n,this.max=v}set(n,v){return this.min.copy(n),this.max.copy(v),this}setFromArray(n){let v=1/0,f=1/0,t=1/0,e=-1/0,i=-1/0,r=-1/0;for(let s=0,o=n.length;s<o;s+=3){const o=n[s],a=n[s+1],l=n[s+2];o<v&&(v=o),a<f&&(f=a),l<t&&(t=l),o>e&&(e=o),a>i&&(i=a),l>r&&(r=l)}return this.min.set(v,f,t),this.max.set(e,i,r),this}setFromBufferAttribute(n){let v=1/0,f=1/0,t=1/0,e=-1/0,i=-1/0,r=-1/0;for(let s=0,o=n.count;s<o;s++){const o=n.getX(s),a=n.getY(s),l=n.getZ(s);o<v&&(v=o),a<f&&(f=a),l<t&&(t=l),o>e&&(e=o),a>i&&(i=a),l>r&&(r=l)}return this.min.set(v,f,t),this.max.set(e,i,r),this}setFromPoints(n){this.makeEmpty();for(let v=0,f=n.length;v<f;v++)this.expandByPoint(n[v]);return this}setFromCenterAndSize(n,v){const f=L.copy(v).multiplyScalar(.5);return this.min.copy(n).sub(f),this.max.copy(n).add(f),this}setFromObject(n){return this.makeEmpty(),this.expandByObject(n)}clone(){return(new this.constructor).copy(this)}copy(n){return this.min.copy(n.min),this.max.copy(n.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(n){return void 0===n&&(console.warn("THREE.Box3: .getCenter() target is now required"),n=new M),this.isEmpty()?n.set(0,0,0):n.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(n){return void 0===n&&(console.warn("THREE.Box3: .getSize() target is now required"),n=new M),this.isEmpty()?n.set(0,0,0):n.subVectors(this.max,this.min)}expandByPoint(n){return this.min.min(n),this.max.max(n),this}expandByVector(n){return this.min.sub(n),this.max.add(n),this}expandByScalar(n){return this.min.addScalar(-n),this.max.addScalar(n),this}expandByObject(n){n.updateWorldMatrix(!1,!1);const v=n.geometry;void 0!==v&&(null===v.boundingBox&&v.computeBoundingBox(),R.copy(v.boundingBox),R.applyMatrix4(n.matrixWorld),this.union(R));const f=n.children;for(let n=0,v=f.length;n<v;n++)this.expandByObject(f[n]);return this}containsPoint(n){return!(n.x<this.min.x||n.x>this.max.x||n.y<this.min.y||n.y>this.max.y||n.z<this.min.z||n.z>this.max.z)}containsBox(n){return this.min.x<=n.min.x&&n.max.x<=this.max.x&&this.min.y<=n.min.y&&n.max.y<=this.max.y&&this.min.z<=n.min.z&&n.max.z<=this.max.z}getParameter(n,v){return void 0===v&&(console.warn("THREE.Box3: .getParameter() target is now required"),v=new M),v.set((n.x-this.min.x)/(this.max.x-this.min.x),(n.y-this.min.y)/(this.max.y-this.min.y),(n.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(n){return!(n.max.x<this.min.x||n.min.x>this.max.x||n.max.y<this.min.y||n.min.y>this.max.y||n.max.z<this.min.z||n.min.z>this.max.z)}intersectsSphere(n){return this.clampPoint(n.center,L),L.distanceToSquared(n.center)<=n.radius*n.radius}intersectsPlane(n){let v,f;return n.normal.x>0?(v=n.normal.x*this.min.x,f=n.normal.x*this.max.x):(v=n.normal.x*this.max.x,f=n.normal.x*this.min.x),n.normal.y>0?(v+=n.normal.y*this.min.y,f+=n.normal.y*this.max.y):(v+=n.normal.y*this.max.y,f+=n.normal.y*this.min.y),n.normal.z>0?(v+=n.normal.z*this.min.z,f+=n.normal.z*this.max.z):(v+=n.normal.z*this.max.z,f+=n.normal.z*this.min.z),v<=-n.constant&&f>=-n.constant}intersectsTriangle(n){if(this.isEmpty())return!1;this.getCenter(z),B.subVectors(this.max,z),P.subVectors(n.a,z),C.subVectors(n.b,z),I.subVectors(n.c,z),D.subVectors(C,P),N.subVectors(I,C),O.subVectors(P,I);let v=[0,-D.z,D.y,0,-N.z,N.y,0,-O.z,O.y,D.z,0,-D.x,N.z,0,-N.x,O.z,0,-O.x,-D.y,D.x,0,-N.y,N.x,0,-O.y,O.x,0];return!!U(v,P,C,I,B)&&(v=[1,0,0,0,1,0,0,0,1],!!U(v,P,C,I,B)&&(F.crossVectors(D,N),v=[F.x,F.y,F.z],U(v,P,C,I,B)))}clampPoint(n,v){return void 0===v&&(console.warn("THREE.Box3: .clampPoint() target is now required"),v=new M),v.copy(n).clamp(this.min,this.max)}distanceToPoint(n){return L.copy(n).clamp(this.min,this.max).sub(n).length()}getBoundingSphere(n){return void 0===n&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(n.center),n.radius=.5*this.getSize(L).length(),n}intersect(n){return this.min.max(n.min),this.max.min(n.max),this.isEmpty()&&this.makeEmpty(),this}union(n){return this.min.min(n.min),this.max.max(n.max),this}applyMatrix4(n){return this.isEmpty()||(A[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(n),A[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(n),A[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(n),A[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(n),A[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(n),A[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(n),A[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(n),A[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(n),this.setFromPoints(A)),this}translate(n){return this.min.add(n),this.max.add(n),this}equals(n){return n.min.equals(this.min)&&n.max.equals(this.max)}}T.prototype.isBox3=!0;const A=[new M,new M,new M,new M,new M,new M,new M,new M],L=new M,R=new T,P=new M,C=new M,I=new M,D=new M,N=new M,O=new M,z=new M,B=new M,F=new M,H=new M;function U(n,v,f,t,e){for(let i=0,r=n.length-3;i<=r;i+=3){H.fromArray(n,i);const r=e.x*Math.abs(H.x)+e.y*Math.abs(H.y)+e.z*Math.abs(H.z),s=v.dot(H),o=f.dot(H),a=t.dot(H);if(Math.max(-Math.max(s,o,a),Math.min(s,o,a))>r)return!1}return!0}const k=new T,G=new M,V=new M,W=new M;class j{constructor(n=new M,v=-1){this.center=n,this.radius=v}set(n,v){return this.center.copy(n),this.radius=v,this}setFromPoints(n,v){const f=this.center;void 0!==v?f.copy(v):k.setFromPoints(n).getCenter(f);let t=0;for(let v=0,e=n.length;v<e;v++)t=Math.max(t,f.distanceToSquared(n[v]));return this.radius=Math.sqrt(t),this}copy(n){return this.center.copy(n.center),this.radius=n.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(n){return n.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(n){return n.distanceTo(this.center)-this.radius}intersectsSphere(n){const v=this.radius+n.radius;return n.center.distanceToSquared(this.center)<=v*v}intersectsBox(n){return n.intersectsSphere(this)}intersectsPlane(n){return Math.abs(n.distanceToPoint(this.center))<=this.radius}clampPoint(n,v){const f=this.center.distanceToSquared(n);return void 0===v&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),v=new M),v.copy(n),f>this.radius*this.radius&&(v.sub(this.center).normalize(),v.multiplyScalar(this.radius).add(this.center)),v}getBoundingBox(n){return void 0===n&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),n=new T),this.isEmpty()?(n.makeEmpty(),n):(n.set(this.center,this.center),n.expandByScalar(this.radius),n)}applyMatrix4(n){return this.center.applyMatrix4(n),this.radius=this.radius*n.getMaxScaleOnAxis(),this}translate(n){return this.center.add(n),this}expandByPoint(n){W.subVectors(n,this.center);const v=W.lengthSq();if(v>this.radius*this.radius){const n=Math.sqrt(v),f=.5*(n-this.radius);this.center.add(W.multiplyScalar(f/n)),this.radius+=f}return this}union(n){return V.subVectors(n.center,this.center).normalize().multiplyScalar(n.radius),this.expandByPoint(G.copy(n.center).add(V)),this.expandByPoint(G.copy(n.center).sub(V)),this}equals(n){return n.center.equals(this.center)&&n.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const q=new M,X=new M,Y=new M,Z=new M,J=new M,Q=new M,K=new M;class ${constructor(n=new M,v=new M(0,0,-1)){this.origin=n,this.direction=v}set(n,v){return this.origin.copy(n),this.direction.copy(v),this}copy(n){return this.origin.copy(n.origin),this.direction.copy(n.direction),this}at(n,v){return void 0===v&&(console.warn("THREE.Ray: .at() target is now required"),v=new M),v.copy(this.direction).multiplyScalar(n).add(this.origin)}lookAt(n){return this.direction.copy(n).sub(this.origin).normalize(),this}recast(n){return this.origin.copy(this.at(n,q)),this}closestPointToPoint(n,v){void 0===v&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),v=new M),v.subVectors(n,this.origin);const f=v.dot(this.direction);return f<0?v.copy(this.origin):v.copy(this.direction).multiplyScalar(f).add(this.origin)}distanceToPoint(n){return Math.sqrt(this.distanceSqToPoint(n))}distanceSqToPoint(n){const v=q.subVectors(n,this.origin).dot(this.direction);return v<0?this.origin.distanceToSquared(n):(q.copy(this.direction).multiplyScalar(v).add(this.origin),q.distanceToSquared(n))}distanceSqToSegment(n,v,f,t){X.copy(n).add(v).multiplyScalar(.5),Y.copy(v).sub(n).normalize(),Z.copy(this.origin).sub(X);const e=.5*n.distanceTo(v),i=-this.direction.dot(Y),r=Z.dot(this.direction),s=-Z.dot(Y),o=Z.lengthSq(),a=Math.abs(1-i*i);let l,c,h,u;if(a>0)if(l=i*s-r,c=i*r-s,u=e*a,l>=0)if(c>=-u)if(c<=u){const n=1/a;l*=n,c*=n,h=l*(l+i*c+2*r)+c*(i*l+c+2*s)+o}else c=e,l=Math.max(0,-(i*c+r)),h=-l*l+c*(c+2*s)+o;else c=-e,l=Math.max(0,-(i*c+r)),h=-l*l+c*(c+2*s)+o;else c<=-u?(l=Math.max(0,-(-i*e+r)),c=l>0?-e:Math.min(Math.max(-e,-s),e),h=-l*l+c*(c+2*s)+o):c<=u?(l=0,c=Math.min(Math.max(-e,-s),e),h=c*(c+2*s)+o):(l=Math.max(0,-(i*e+r)),c=l>0?e:Math.min(Math.max(-e,-s),e),h=-l*l+c*(c+2*s)+o);else c=i>0?-e:e,l=Math.max(0,-(i*c+r)),h=-l*l+c*(c+2*s)+o;return f&&f.copy(this.direction).multiplyScalar(l).add(this.origin),t&&t.copy(Y).multiplyScalar(c).add(X),h}intersectSphere(n,v){q.subVectors(n.center,this.origin);const f=q.dot(this.direction),t=q.dot(q)-f*f,e=n.radius*n.radius;if(t>e)return null;const i=Math.sqrt(e-t),r=f-i,s=f+i;return r<0&&s<0?null:r<0?this.at(s,v):this.at(r,v)}intersectsSphere(n){return this.distanceSqToPoint(n.center)<=n.radius*n.radius}distanceToPlane(n){const v=n.normal.dot(this.direction);if(0===v)return 0===n.distanceToPoint(this.origin)?0:null;const f=-(this.origin.dot(n.normal)+n.constant)/v;return f>=0?f:null}intersectPlane(n,v){const f=this.distanceToPlane(n);return null===f?null:this.at(f,v)}intersectsPlane(n){const v=n.distanceToPoint(this.origin);if(0===v)return!0;return n.normal.dot(this.direction)*v<0}intersectBox(n,v){let f,t,e,i,r,s;const o=1/this.direction.x,a=1/this.direction.y,l=1/this.direction.z,c=this.origin;return o>=0?(f=(n.min.x-c.x)*o,t=(n.max.x-c.x)*o):(f=(n.max.x-c.x)*o,t=(n.min.x-c.x)*o),a>=0?(e=(n.min.y-c.y)*a,i=(n.max.y-c.y)*a):(e=(n.max.y-c.y)*a,i=(n.min.y-c.y)*a),f>i||e>t?null:((e>f||f!=f)&&(f=e),(i<t||t!=t)&&(t=i),l>=0?(r=(n.min.z-c.z)*l,s=(n.max.z-c.z)*l):(r=(n.max.z-c.z)*l,s=(n.min.z-c.z)*l),f>s||r>t?null:((r>f||f!=f)&&(f=r),(s<t||t!=t)&&(t=s),t<0?null:this.at(f>=0?f:t,v)))}intersectsBox(n){return null!==this.intersectBox(n,q)}intersectTriangle(n,v,f,t,e){J.subVectors(v,n),Q.subVectors(f,n),K.crossVectors(J,Q);let i,r=this.direction.dot(K);if(r>0){if(t)return null;i=1}else{if(!(r<0))return null;i=-1,r=-r}Z.subVectors(this.origin,n);const s=i*this.direction.dot(Q.crossVectors(Z,Q));if(s<0)return null;const o=i*this.direction.dot(J.cross(Z));if(o<0)return null;if(s+o>r)return null;const a=-i*Z.dot(K);return a<0?null:this.at(a/r,e)}applyMatrix4(n){return this.origin.applyMatrix4(n),this.direction.transformDirection(n),this}equals(n){return n.origin.equals(this.origin)&&n.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class nn{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(n,v,f,t,e,i,r,s,o,a,l,c,h,u,d,p){const m=this.elements;return m[0]=n,m[4]=v,m[8]=f,m[12]=t,m[1]=e,m[5]=i,m[9]=r,m[13]=s,m[2]=o,m[6]=a,m[10]=l,m[14]=c,m[3]=h,m[7]=u,m[11]=d,m[15]=p,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new nn).fromArray(this.elements)}copy(n){const v=this.elements,f=n.elements;return v[0]=f[0],v[1]=f[1],v[2]=f[2],v[3]=f[3],v[4]=f[4],v[5]=f[5],v[6]=f[6],v[7]=f[7],v[8]=f[8],v[9]=f[9],v[10]=f[10],v[11]=f[11],v[12]=f[12],v[13]=f[13],v[14]=f[14],v[15]=f[15],this}copyPosition(n){const v=this.elements,f=n.elements;return v[12]=f[12],v[13]=f[13],v[14]=f[14],this}setFromMatrix3(n){const v=n.elements;return this.set(v[0],v[3],v[6],0,v[1],v[4],v[7],0,v[2],v[5],v[8],0,0,0,0,1),this}extractBasis(n,v,f){return n.setFromMatrixColumn(this,0),v.setFromMatrixColumn(this,1),f.setFromMatrixColumn(this,2),this}makeBasis(n,v,f){return this.set(n.x,v.x,f.x,0,n.y,v.y,f.y,0,n.z,v.z,f.z,0,0,0,0,1),this}extractRotation(n){const v=this.elements,f=n.elements,t=1/vn.setFromMatrixColumn(n,0).length(),e=1/vn.setFromMatrixColumn(n,1).length(),i=1/vn.setFromMatrixColumn(n,2).length();return v[0]=f[0]*t,v[1]=f[1]*t,v[2]=f[2]*t,v[3]=0,v[4]=f[4]*e,v[5]=f[5]*e,v[6]=f[6]*e,v[7]=0,v[8]=f[8]*i,v[9]=f[9]*i,v[10]=f[10]*i,v[11]=0,v[12]=0,v[13]=0,v[14]=0,v[15]=1,this}makeRotationFromEuler(n){n&&n.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const v=this.elements,f=n.x,t=n.y,e=n.z,i=Math.cos(f),r=Math.sin(f),s=Math.cos(t),o=Math.sin(t),a=Math.cos(e),l=Math.sin(e);if("XYZ"===n.order){const n=i*a,f=i*l,t=r*a,e=r*l;v[0]=s*a,v[4]=-s*l,v[8]=o,v[1]=f+t*o,v[5]=n-e*o,v[9]=-r*s,v[2]=e-n*o,v[6]=t+f*o,v[10]=i*s}else if("YXZ"===n.order){const n=s*a,f=s*l,t=o*a,e=o*l;v[0]=n+e*r,v[4]=t*r-f,v[8]=i*o,v[1]=i*l,v[5]=i*a,v[9]=-r,v[2]=f*r-t,v[6]=e+n*r,v[10]=i*s}else if("ZXY"===n.order){const n=s*a,f=s*l,t=o*a,e=o*l;v[0]=n-e*r,v[4]=-i*l,v[8]=t+f*r,v[1]=f+t*r,v[5]=i*a,v[9]=e-n*r,v[2]=-i*o,v[6]=r,v[10]=i*s}else if("ZYX"===n.order){const n=i*a,f=i*l,t=r*a,e=r*l;v[0]=s*a,v[4]=t*o-f,v[8]=n*o+e,v[1]=s*l,v[5]=e*o+n,v[9]=f*o-t,v[2]=-o,v[6]=r*s,v[10]=i*s}else if("YZX"===n.order){const n=i*s,f=i*o,t=r*s,e=r*o;v[0]=s*a,v[4]=e-n*l,v[8]=t*l+f,v[1]=l,v[5]=i*a,v[9]=-r*a,v[2]=-o*a,v[6]=f*l+t,v[10]=n-e*l}else if("XZY"===n.order){const n=i*s,f=i*o,t=r*s,e=r*o;v[0]=s*a,v[4]=-l,v[8]=o*a,v[1]=n*l+e,v[5]=i*a,v[9]=f*l-t,v[2]=t*l-f,v[6]=r*a,v[10]=e*l+n}return v[3]=0,v[7]=0,v[11]=0,v[12]=0,v[13]=0,v[14]=0,v[15]=1,this}makeRotationFromQuaternion(n){return this.compose(tn,n,en)}lookAt(n,v,f){const t=this.elements;return on.subVectors(n,v),0===on.lengthSq()&&(on.z=1),on.normalize(),rn.crossVectors(f,on),0===rn.lengthSq()&&(1===Math.abs(f.z)?on.x+=1e-4:on.z+=1e-4,on.normalize(),rn.crossVectors(f,on)),rn.normalize(),sn.crossVectors(on,rn),t[0]=rn.x,t[4]=sn.x,t[8]=on.x,t[1]=rn.y,t[5]=sn.y,t[9]=on.y,t[2]=rn.z,t[6]=sn.z,t[10]=on.z,this}multiply(n,v){return void 0!==v?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(n,v)):this.multiplyMatrices(this,n)}premultiply(n){return this.multiplyMatrices(n,this)}multiplyMatrices(n,v){const f=n.elements,t=v.elements,e=this.elements,i=f[0],r=f[4],s=f[8],o=f[12],a=f[1],l=f[5],c=f[9],h=f[13],u=f[2],d=f[6],p=f[10],m=f[14],g=f[3],y=f[7],x=f[11],_=f[15],b=t[0],w=t[4],M=t[8],S=t[12],E=t[1],T=t[5],A=t[9],L=t[13],R=t[2],P=t[6],C=t[10],I=t[14],D=t[3],N=t[7],O=t[11],z=t[15];return e[0]=i*b+r*E+s*R+o*D,e[4]=i*w+r*T+s*P+o*N,e[8]=i*M+r*A+s*C+o*O,e[12]=i*S+r*L+s*I+o*z,e[1]=a*b+l*E+c*R+h*D,e[5]=a*w+l*T+c*P+h*N,e[9]=a*M+l*A+c*C+h*O,e[13]=a*S+l*L+c*I+h*z,e[2]=u*b+d*E+p*R+m*D,e[6]=u*w+d*T+p*P+m*N,e[10]=u*M+d*A+p*C+m*O,e[14]=u*S+d*L+p*I+m*z,e[3]=g*b+y*E+x*R+_*D,e[7]=g*w+y*T+x*P+_*N,e[11]=g*M+y*A+x*C+_*O,e[15]=g*S+y*L+x*I+_*z,this}multiplyScalar(n){const v=this.elements;return v[0]*=n,v[4]*=n,v[8]*=n,v[12]*=n,v[1]*=n,v[5]*=n,v[9]*=n,v[13]*=n,v[2]*=n,v[6]*=n,v[10]*=n,v[14]*=n,v[3]*=n,v[7]*=n,v[11]*=n,v[15]*=n,this}determinant(){const n=this.elements,v=n[0],f=n[4],t=n[8],e=n[12],i=n[1],r=n[5],s=n[9],o=n[13],a=n[2],l=n[6],c=n[10],h=n[14];return n[3]*(+e*s*l