@specy/liquid-glass
Version:
A Three.js powered library to make apple's liquid with glass effect
1 lines • 950 kB
JavaScript
"use strict";var mu=Object.defineProperty;var oC=Object.getOwnPropertyDescriptor;var cC=Object.getOwnPropertyNames;var lC=Object.prototype.hasOwnProperty;var uC=(n,A)=>{for(var e in A)mu(n,e,{get:A[e],enumerable:!0})},hC=(n,A,e,t)=>{if(A&&typeof A=="object"||typeof A=="function")for(let r of cC(A))!lC.call(n,r)&&r!==e&&mu(n,r,{get:()=>A[r],enumerable:!(t=oC(A,r))||t.enumerable});return n};var fC=n=>hC(mu({},"__esModule",{value:!0}),n);var VR={};uC(VR,{LiquidGlass:()=>pu,PaintLayerCache:()=>Jr,PillGeometry:()=>_i,takeElementScreenshot:()=>AC});module.exports=fC(VR);var Po="177";var pp=0,eh=1,gp=2;var th=1,Bp=2,jt=3,Cn=0,tt=1,An=2,Fn=0,Ur=1,nh=2,rh=3,ih=4,mp=5,Kn=100,wp=101,Cp=102,vp=103,Up=104,yp=200,Fp=201,Ep=202,xp=203,so=204,ao=205,Qp=206,_p=207,Sp=208,Mp=209,bp=210,Ip=211,Tp=212,Hp=213,Lp=214,Oo=0,No=1,Ko=2,yr=3,Go=4,Vo=5,ko=6,zo=7,sh=0,Rp=1,Dp=2,En=0,Pp=1,Op=2,Np=3,Kp=4,Gp=5,Vp=6,kp=7;var ah=300,Sr=301,Mr=302,Wo=303,Xo=304,bs=306,oo=1e3,Kt=1001,co=1002,Et=1003,zp=1004;var Is=1005;var Gt=1006,Jo=1007;var Wn=1008;var en=1009,oh=1010,ch=1011,wi=1012,Yo=1013,Xn=1014,tn=1015,Ci=1016,Zo=1017,qo=1018,vi=1020,lh=35902,uh=1021,hh=1022,Qt=1023,ci=1026,Ui=1027,fh=1028,$o=1029,dh=1030,jo=1031;var Ac=1033,Ts=33776,Hs=33777,Ls=33778,Rs=33779,ec=35840,tc=35841,nc=35842,rc=35843,ic=36196,sc=37492,ac=37496,oc=37808,cc=37809,lc=37810,uc=37811,hc=37812,fc=37813,dc=37814,pc=37815,gc=37816,Bc=37817,mc=37818,wc=37819,Cc=37820,vc=37821,Ds=36492,Uc=36494,yc=36495,ph=36283,Fc=36284,Ec=36285,xc=36286;var as=2300,lo=2301,io=2302,zu=2400,Wu=2401,Xu=2402;var Wp=3200,Xp=3201;var gh=0,Jp=1,xn="",pt="srgb",Fr="srgb-linear",os="linear",ce="srgb";var wr=7680;var Ju=519,Yp=512,Zp=513,qp=514,Bh=515,$p=516,jp=517,Ag=518,eg=519,Yu=35044;var mh="300 es",Zt=2e3,cs=2001;var vn=class{addEventListener(A,e){this._listeners===void 0&&(this._listeners={});let t=this._listeners;t[A]===void 0&&(t[A]=[]),t[A].indexOf(e)===-1&&t[A].push(e)}hasEventListener(A,e){let t=this._listeners;return t===void 0?!1:t[A]!==void 0&&t[A].indexOf(e)!==-1}removeEventListener(A,e){let t=this._listeners;if(t===void 0)return;let r=t[A];if(r!==void 0){let i=r.indexOf(e);i!==-1&&r.splice(i,1)}}dispatchEvent(A){let e=this._listeners;if(e===void 0)return;let t=e[A.type];if(t!==void 0){A.target=this;let r=t.slice(0);for(let i=0,s=r.length;i<s;i++)r[i].call(this,A);A.target=null}}},Xe=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];var wu=Math.PI/180,uo=180/Math.PI;function yi(){let n=Math.random()*4294967295|0,A=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0;return(Xe[n&255]+Xe[n>>8&255]+Xe[n>>16&255]+Xe[n>>24&255]+"-"+Xe[A&255]+Xe[A>>8&255]+"-"+Xe[A>>16&15|64]+Xe[A>>24&255]+"-"+Xe[e&63|128]+Xe[e>>8&255]+"-"+Xe[e>>16&255]+Xe[e>>24&255]+Xe[t&255]+Xe[t>>8&255]+Xe[t>>16&255]+Xe[t>>24&255]).toLowerCase()}function YA(n,A,e){return Math.max(A,Math.min(e,n))}function dC(n,A){return(n%A+A)%A}function Cu(n,A,e){return(1-e)*n+e*A}function ji(n,A){switch(A.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function st(n,A){switch(A.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}var wA=class n{constructor(A=0,e=0){n.prototype.isVector2=!0,this.x=A,this.y=e}get width(){return this.x}set width(A){this.x=A}get height(){return this.y}set height(A){this.y=A}set(A,e){return this.x=A,this.y=e,this}setScalar(A){return this.x=A,this.y=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setComponent(A,e){switch(A){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+A)}return this}getComponent(A){switch(A){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+A)}}clone(){return new this.constructor(this.x,this.y)}copy(A){return this.x=A.x,this.y=A.y,this}add(A){return this.x+=A.x,this.y+=A.y,this}addScalar(A){return this.x+=A,this.y+=A,this}addVectors(A,e){return this.x=A.x+e.x,this.y=A.y+e.y,this}addScaledVector(A,e){return this.x+=A.x*e,this.y+=A.y*e,this}sub(A){return this.x-=A.x,this.y-=A.y,this}subScalar(A){return this.x-=A,this.y-=A,this}subVectors(A,e){return this.x=A.x-e.x,this.y=A.y-e.y,this}multiply(A){return this.x*=A.x,this.y*=A.y,this}multiplyScalar(A){return this.x*=A,this.y*=A,this}divide(A){return this.x/=A.x,this.y/=A.y,this}divideScalar(A){return this.multiplyScalar(1/A)}applyMatrix3(A){let e=this.x,t=this.y,r=A.elements;return this.x=r[0]*e+r[3]*t+r[6],this.y=r[1]*e+r[4]*t+r[7],this}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this}clamp(A,e){return this.x=YA(this.x,A.x,e.x),this.y=YA(this.y,A.y,e.y),this}clampScalar(A,e){return this.x=YA(this.x,A,e),this.y=YA(this.y,A,e),this}clampLength(A,e){let t=this.length();return this.divideScalar(t||1).multiplyScalar(YA(t,A,e))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(A){return this.x*A.x+this.y*A.y}cross(A){return this.x*A.y-this.y*A.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}angleTo(A){let e=Math.sqrt(this.lengthSq()*A.lengthSq());if(e===0)return Math.PI/2;let t=this.dot(A)/e;return Math.acos(YA(t,-1,1))}distanceTo(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){let e=this.x-A.x,t=this.y-A.y;return e*e+t*t}manhattanDistanceTo(A){return Math.abs(this.x-A.x)+Math.abs(this.y-A.y)}setLength(A){return this.normalize().multiplyScalar(A)}lerp(A,e){return this.x+=(A.x-this.x)*e,this.y+=(A.y-this.y)*e,this}lerpVectors(A,e,t){return this.x=A.x+(e.x-A.x)*t,this.y=A.y+(e.y-A.y)*t,this}equals(A){return A.x===this.x&&A.y===this.y}fromArray(A,e=0){return this.x=A[e],this.y=A[e+1],this}toArray(A=[],e=0){return A[e]=this.x,A[e+1]=this.y,A}fromBufferAttribute(A,e){return this.x=A.getX(e),this.y=A.getY(e),this}rotateAround(A,e){let t=Math.cos(e),r=Math.sin(e),i=this.x-A.x,s=this.y-A.y;return this.x=i*t-s*r+A.x,this.y=i*r+s*t+A.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Un=class{constructor(A=0,e=0,t=0,r=1){this.isQuaternion=!0,this._x=A,this._y=e,this._z=t,this._w=r}static slerpFlat(A,e,t,r,i,s,a){let o=t[r+0],c=t[r+1],l=t[r+2],u=t[r+3],h=i[s+0],d=i[s+1],g=i[s+2],B=i[s+3];if(a===0){A[e+0]=o,A[e+1]=c,A[e+2]=l,A[e+3]=u;return}if(a===1){A[e+0]=h,A[e+1]=d,A[e+2]=g,A[e+3]=B;return}if(u!==B||o!==h||c!==d||l!==g){let p=1-a,f=o*h+c*d+l*g+u*B,U=f>=0?1:-1,y=1-f*f;if(y>Number.EPSILON){let S=Math.sqrt(y),F=Math.atan2(S,f*U);p=Math.sin(p*F)/S,a=Math.sin(a*F)/S}let m=a*U;if(o=o*p+h*m,c=c*p+d*m,l=l*p+g*m,u=u*p+B*m,p===1-a){let S=1/Math.sqrt(o*o+c*c+l*l+u*u);o*=S,c*=S,l*=S,u*=S}}A[e]=o,A[e+1]=c,A[e+2]=l,A[e+3]=u}static multiplyQuaternionsFlat(A,e,t,r,i,s){let a=t[r],o=t[r+1],c=t[r+2],l=t[r+3],u=i[s],h=i[s+1],d=i[s+2],g=i[s+3];return A[e]=a*g+l*u+o*d-c*h,A[e+1]=o*g+l*h+c*u-a*d,A[e+2]=c*g+l*d+a*h-o*u,A[e+3]=l*g-a*u-o*h-c*d,A}get x(){return this._x}set x(A){this._x=A,this._onChangeCallback()}get y(){return this._y}set y(A){this._y=A,this._onChangeCallback()}get z(){return this._z}set z(A){this._z=A,this._onChangeCallback()}get w(){return this._w}set w(A){this._w=A,this._onChangeCallback()}set(A,e,t,r){return this._x=A,this._y=e,this._z=t,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(A){return this._x=A.x,this._y=A.y,this._z=A.z,this._w=A.w,this._onChangeCallback(),this}setFromEuler(A,e=!0){let t=A._x,r=A._y,i=A._z,s=A._order,a=Math.cos,o=Math.sin,c=a(t/2),l=a(r/2),u=a(i/2),h=o(t/2),d=o(r/2),g=o(i/2);switch(s){case"XYZ":this._x=h*l*u+c*d*g,this._y=c*d*u-h*l*g,this._z=c*l*g+h*d*u,this._w=c*l*u-h*d*g;break;case"YXZ":this._x=h*l*u+c*d*g,this._y=c*d*u-h*l*g,this._z=c*l*g-h*d*u,this._w=c*l*u+h*d*g;break;case"ZXY":this._x=h*l*u-c*d*g,this._y=c*d*u+h*l*g,this._z=c*l*g+h*d*u,this._w=c*l*u-h*d*g;break;case"ZYX":this._x=h*l*u-c*d*g,this._y=c*d*u+h*l*g,this._z=c*l*g-h*d*u,this._w=c*l*u+h*d*g;break;case"YZX":this._x=h*l*u+c*d*g,this._y=c*d*u+h*l*g,this._z=c*l*g-h*d*u,this._w=c*l*u-h*d*g;break;case"XZY":this._x=h*l*u-c*d*g,this._y=c*d*u-h*l*g,this._z=c*l*g+h*d*u,this._w=c*l*u+h*d*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(A,e){let t=e/2,r=Math.sin(t);return this._x=A.x*r,this._y=A.y*r,this._z=A.z*r,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(A){let e=A.elements,t=e[0],r=e[4],i=e[8],s=e[1],a=e[5],o=e[9],c=e[2],l=e[6],u=e[10],h=t+a+u;if(h>0){let d=.5/Math.sqrt(h+1);this._w=.25/d,this._x=(l-o)*d,this._y=(i-c)*d,this._z=(s-r)*d}else if(t>a&&t>u){let d=2*Math.sqrt(1+t-a-u);this._w=(l-o)/d,this._x=.25*d,this._y=(r+s)/d,this._z=(i+c)/d}else if(a>u){let d=2*Math.sqrt(1+a-t-u);this._w=(i-c)/d,this._x=(r+s)/d,this._y=.25*d,this._z=(o+l)/d}else{let d=2*Math.sqrt(1+u-t-a);this._w=(s-r)/d,this._x=(i+c)/d,this._y=(o+l)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(A,e){let t=A.dot(e)+1;return t<Number.EPSILON?(t=0,Math.abs(A.x)>Math.abs(A.z)?(this._x=-A.y,this._y=A.x,this._z=0,this._w=t):(this._x=0,this._y=-A.z,this._z=A.y,this._w=t)):(this._x=A.y*e.z-A.z*e.y,this._y=A.z*e.x-A.x*e.z,this._z=A.x*e.y-A.y*e.x,this._w=t),this.normalize()}angleTo(A){return 2*Math.acos(Math.abs(YA(this.dot(A),-1,1)))}rotateTowards(A,e){let t=this.angleTo(A);if(t===0)return this;let r=Math.min(1,e/t);return this.slerp(A,r),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(A){return this._x*A._x+this._y*A._y+this._z*A._z+this._w*A._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 A=this.length();return A===0?(this._x=0,this._y=0,this._z=0,this._w=1):(A=1/A,this._x=this._x*A,this._y=this._y*A,this._z=this._z*A,this._w=this._w*A),this._onChangeCallback(),this}multiply(A){return this.multiplyQuaternions(this,A)}premultiply(A){return this.multiplyQuaternions(A,this)}multiplyQuaternions(A,e){let t=A._x,r=A._y,i=A._z,s=A._w,a=e._x,o=e._y,c=e._z,l=e._w;return this._x=t*l+s*a+r*c-i*o,this._y=r*l+s*o+i*a-t*c,this._z=i*l+s*c+t*o-r*a,this._w=s*l-t*a-r*o-i*c,this._onChangeCallback(),this}slerp(A,e){if(e===0)return this;if(e===1)return this.copy(A);let t=this._x,r=this._y,i=this._z,s=this._w,a=s*A._w+t*A._x+r*A._y+i*A._z;if(a<0?(this._w=-A._w,this._x=-A._x,this._y=-A._y,this._z=-A._z,a=-a):this.copy(A),a>=1)return this._w=s,this._x=t,this._y=r,this._z=i,this;let o=1-a*a;if(o<=Number.EPSILON){let d=1-e;return this._w=d*s+e*this._w,this._x=d*t+e*this._x,this._y=d*r+e*this._y,this._z=d*i+e*this._z,this.normalize(),this}let c=Math.sqrt(o),l=Math.atan2(c,a),u=Math.sin((1-e)*l)/c,h=Math.sin(e*l)/c;return this._w=s*u+this._w*h,this._x=t*u+this._x*h,this._y=r*u+this._y*h,this._z=i*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(A,e,t){return this.copy(A).slerp(e,t)}random(){let A=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),t=Math.random(),r=Math.sqrt(1-t),i=Math.sqrt(t);return this.set(r*Math.sin(A),r*Math.cos(A),i*Math.sin(e),i*Math.cos(e))}equals(A){return A._x===this._x&&A._y===this._y&&A._z===this._z&&A._w===this._w}fromArray(A,e=0){return this._x=A[e],this._y=A[e+1],this._z=A[e+2],this._w=A[e+3],this._onChangeCallback(),this}toArray(A=[],e=0){return A[e]=this._x,A[e+1]=this._y,A[e+2]=this._z,A[e+3]=this._w,A}fromBufferAttribute(A,e){return this._x=A.getX(e),this._y=A.getY(e),this._z=A.getZ(e),this._w=A.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(A){return this._onChangeCallback=A,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},R=class n{constructor(A=0,e=0,t=0){n.prototype.isVector3=!0,this.x=A,this.y=e,this.z=t}set(A,e,t){return t===void 0&&(t=this.z),this.x=A,this.y=e,this.z=t,this}setScalar(A){return this.x=A,this.y=A,this.z=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setZ(A){return this.z=A,this}setComponent(A,e){switch(A){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+A)}return this}getComponent(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(){return new this.constructor(this.x,this.y,this.z)}copy(A){return this.x=A.x,this.y=A.y,this.z=A.z,this}add(A){return this.x+=A.x,this.y+=A.y,this.z+=A.z,this}addScalar(A){return this.x+=A,this.y+=A,this.z+=A,this}addVectors(A,e){return this.x=A.x+e.x,this.y=A.y+e.y,this.z=A.z+e.z,this}addScaledVector(A,e){return this.x+=A.x*e,this.y+=A.y*e,this.z+=A.z*e,this}sub(A){return this.x-=A.x,this.y-=A.y,this.z-=A.z,this}subScalar(A){return this.x-=A,this.y-=A,this.z-=A,this}subVectors(A,e){return this.x=A.x-e.x,this.y=A.y-e.y,this.z=A.z-e.z,this}multiply(A){return this.x*=A.x,this.y*=A.y,this.z*=A.z,this}multiplyScalar(A){return this.x*=A,this.y*=A,this.z*=A,this}multiplyVectors(A,e){return this.x=A.x*e.x,this.y=A.y*e.y,this.z=A.z*e.z,this}applyEuler(A){return this.applyQuaternion(Jd.setFromEuler(A))}applyAxisAngle(A,e){return this.applyQuaternion(Jd.setFromAxisAngle(A,e))}applyMatrix3(A){let e=this.x,t=this.y,r=this.z,i=A.elements;return this.x=i[0]*e+i[3]*t+i[6]*r,this.y=i[1]*e+i[4]*t+i[7]*r,this.z=i[2]*e+i[5]*t+i[8]*r,this}applyNormalMatrix(A){return this.applyMatrix3(A).normalize()}applyMatrix4(A){let e=this.x,t=this.y,r=this.z,i=A.elements,s=1/(i[3]*e+i[7]*t+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*t+i[8]*r+i[12])*s,this.y=(i[1]*e+i[5]*t+i[9]*r+i[13])*s,this.z=(i[2]*e+i[6]*t+i[10]*r+i[14])*s,this}applyQuaternion(A){let e=this.x,t=this.y,r=this.z,i=A.x,s=A.y,a=A.z,o=A.w,c=2*(s*r-a*t),l=2*(a*e-i*r),u=2*(i*t-s*e);return this.x=e+o*c+s*u-a*l,this.y=t+o*l+a*c-i*u,this.z=r+o*u+i*l-s*c,this}project(A){return this.applyMatrix4(A.matrixWorldInverse).applyMatrix4(A.projectionMatrix)}unproject(A){return this.applyMatrix4(A.projectionMatrixInverse).applyMatrix4(A.matrixWorld)}transformDirection(A){let e=this.x,t=this.y,r=this.z,i=A.elements;return this.x=i[0]*e+i[4]*t+i[8]*r,this.y=i[1]*e+i[5]*t+i[9]*r,this.z=i[2]*e+i[6]*t+i[10]*r,this.normalize()}divide(A){return this.x/=A.x,this.y/=A.y,this.z/=A.z,this}divideScalar(A){return this.multiplyScalar(1/A)}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this.z=Math.min(this.z,A.z),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this.z=Math.max(this.z,A.z),this}clamp(A,e){return this.x=YA(this.x,A.x,e.x),this.y=YA(this.y,A.y,e.y),this.z=YA(this.z,A.z,e.z),this}clampScalar(A,e){return this.x=YA(this.x,A,e),this.y=YA(this.y,A,e),this.z=YA(this.z,A,e),this}clampLength(A,e){let t=this.length();return this.divideScalar(t||1).multiplyScalar(YA(t,A,e))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(A){return this.x*A.x+this.y*A.y+this.z*A.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(A){return this.normalize().multiplyScalar(A)}lerp(A,e){return this.x+=(A.x-this.x)*e,this.y+=(A.y-this.y)*e,this.z+=(A.z-this.z)*e,this}lerpVectors(A,e,t){return this.x=A.x+(e.x-A.x)*t,this.y=A.y+(e.y-A.y)*t,this.z=A.z+(e.z-A.z)*t,this}cross(A){return this.crossVectors(this,A)}crossVectors(A,e){let t=A.x,r=A.y,i=A.z,s=e.x,a=e.y,o=e.z;return this.x=r*o-i*a,this.y=i*s-t*o,this.z=t*a-r*s,this}projectOnVector(A){let e=A.lengthSq();if(e===0)return this.set(0,0,0);let t=A.dot(this)/e;return this.copy(A).multiplyScalar(t)}projectOnPlane(A){return vu.copy(this).projectOnVector(A),this.sub(vu)}reflect(A){return this.sub(vu.copy(A).multiplyScalar(2*this.dot(A)))}angleTo(A){let e=Math.sqrt(this.lengthSq()*A.lengthSq());if(e===0)return Math.PI/2;let t=this.dot(A)/e;return Math.acos(YA(t,-1,1))}distanceTo(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){let e=this.x-A.x,t=this.y-A.y,r=this.z-A.z;return e*e+t*t+r*r}manhattanDistanceTo(A){return Math.abs(this.x-A.x)+Math.abs(this.y-A.y)+Math.abs(this.z-A.z)}setFromSpherical(A){return this.setFromSphericalCoords(A.radius,A.phi,A.theta)}setFromSphericalCoords(A,e,t){let r=Math.sin(e)*A;return this.x=r*Math.sin(t),this.y=Math.cos(e)*A,this.z=r*Math.cos(t),this}setFromCylindrical(A){return this.setFromCylindricalCoords(A.radius,A.theta,A.y)}setFromCylindricalCoords(A,e,t){return this.x=A*Math.sin(e),this.y=t,this.z=A*Math.cos(e),this}setFromMatrixPosition(A){let e=A.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(A){let e=this.setFromMatrixColumn(A,0).length(),t=this.setFromMatrixColumn(A,1).length(),r=this.setFromMatrixColumn(A,2).length();return this.x=e,this.y=t,this.z=r,this}setFromMatrixColumn(A,e){return this.fromArray(A.elements,e*4)}setFromMatrix3Column(A,e){return this.fromArray(A.elements,e*3)}setFromEuler(A){return this.x=A._x,this.y=A._y,this.z=A._z,this}setFromColor(A){return this.x=A.r,this.y=A.g,this.z=A.b,this}equals(A){return A.x===this.x&&A.y===this.y&&A.z===this.z}fromArray(A,e=0){return this.x=A[e],this.y=A[e+1],this.z=A[e+2],this}toArray(A=[],e=0){return A[e]=this.x,A[e+1]=this.y,A[e+2]=this.z,A}fromBufferAttribute(A,e){return this.x=A.getX(e),this.y=A.getY(e),this.z=A.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let A=Math.random()*Math.PI*2,e=Math.random()*2-1,t=Math.sqrt(1-e*e);return this.x=t*Math.cos(A),this.y=e,this.z=t*Math.sin(A),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},vu=new R,Jd=new Un,WA=class n{constructor(A,e,t,r,i,s,a,o,c){n.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],A!==void 0&&this.set(A,e,t,r,i,s,a,o,c)}set(A,e,t,r,i,s,a,o,c){let l=this.elements;return l[0]=A,l[1]=r,l[2]=a,l[3]=e,l[4]=i,l[5]=o,l[6]=t,l[7]=s,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(A){let e=this.elements,t=A.elements;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this}extractBasis(A,e,t){return A.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),t.setFromMatrix3Column(this,2),this}setFromMatrix4(A){let e=A.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(A){return this.multiplyMatrices(this,A)}premultiply(A){return this.multiplyMatrices(A,this)}multiplyMatrices(A,e){let t=A.elements,r=e.elements,i=this.elements,s=t[0],a=t[3],o=t[6],c=t[1],l=t[4],u=t[7],h=t[2],d=t[5],g=t[8],B=r[0],p=r[3],f=r[6],U=r[1],y=r[4],m=r[7],S=r[2],F=r[5],x=r[8];return i[0]=s*B+a*U+o*S,i[3]=s*p+a*y+o*F,i[6]=s*f+a*m+o*x,i[1]=c*B+l*U+u*S,i[4]=c*p+l*y+u*F,i[7]=c*f+l*m+u*x,i[2]=h*B+d*U+g*S,i[5]=h*p+d*y+g*F,i[8]=h*f+d*m+g*x,this}multiplyScalar(A){let e=this.elements;return e[0]*=A,e[3]*=A,e[6]*=A,e[1]*=A,e[4]*=A,e[7]*=A,e[2]*=A,e[5]*=A,e[8]*=A,this}determinant(){let A=this.elements,e=A[0],t=A[1],r=A[2],i=A[3],s=A[4],a=A[5],o=A[6],c=A[7],l=A[8];return e*s*l-e*a*c-t*i*l+t*a*o+r*i*c-r*s*o}invert(){let A=this.elements,e=A[0],t=A[1],r=A[2],i=A[3],s=A[4],a=A[5],o=A[6],c=A[7],l=A[8],u=l*s-a*c,h=a*o-l*i,d=c*i-s*o,g=e*u+t*h+r*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let B=1/g;return A[0]=u*B,A[1]=(r*c-l*t)*B,A[2]=(a*t-r*s)*B,A[3]=h*B,A[4]=(l*e-r*o)*B,A[5]=(r*i-a*e)*B,A[6]=d*B,A[7]=(t*o-c*e)*B,A[8]=(s*e-t*i)*B,this}transpose(){let A,e=this.elements;return A=e[1],e[1]=e[3],e[3]=A,A=e[2],e[2]=e[6],e[6]=A,A=e[5],e[5]=e[7],e[7]=A,this}getNormalMatrix(A){return this.setFromMatrix4(A).invert().transpose()}transposeIntoArray(A){let e=this.elements;return A[0]=e[0],A[1]=e[3],A[2]=e[6],A[3]=e[1],A[4]=e[4],A[5]=e[7],A[6]=e[2],A[7]=e[5],A[8]=e[8],this}setUvTransform(A,e,t,r,i,s,a){let o=Math.cos(i),c=Math.sin(i);return this.set(t*o,t*c,-t*(o*s+c*a)+s+A,-r*c,r*o,-r*(-c*s+o*a)+a+e,0,0,1),this}scale(A,e){return this.premultiply(Uu.makeScale(A,e)),this}rotate(A){return this.premultiply(Uu.makeRotation(-A)),this}translate(A,e){return this.premultiply(Uu.makeTranslation(A,e)),this}makeTranslation(A,e){return A.isVector2?this.set(1,0,A.x,0,1,A.y,0,0,1):this.set(1,0,A,0,1,e,0,0,1),this}makeRotation(A){let e=Math.cos(A),t=Math.sin(A);return this.set(e,-t,0,t,e,0,0,0,1),this}makeScale(A,e){return this.set(A,0,0,0,e,0,0,0,1),this}equals(A){let e=this.elements,t=A.elements;for(let r=0;r<9;r++)if(e[r]!==t[r])return!1;return!0}fromArray(A,e=0){for(let t=0;t<9;t++)this.elements[t]=A[t+e];return this}toArray(A=[],e=0){let t=this.elements;return A[e]=t[0],A[e+1]=t[1],A[e+2]=t[2],A[e+3]=t[3],A[e+4]=t[4],A[e+5]=t[5],A[e+6]=t[6],A[e+7]=t[7],A[e+8]=t[8],A}clone(){return new this.constructor().fromArray(this.elements)}},Uu=new WA;function wh(n){for(let A=n.length-1;A>=0;--A)if(n[A]>=65535)return!0;return!1}function ls(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function tg(){let n=ls("canvas");return n.style.display="block",n}var Yd={};function Er(n){n in Yd||(Yd[n]=!0,console.warn(n))}function ng(n,A,e){return new Promise(function(t,r){function i(){switch(n.clientWaitSync(A,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(i,e);break;default:t()}}setTimeout(i,e)})}function rg(n){let A=n.elements;A[2]=.5*A[2]+.5*A[3],A[6]=.5*A[6]+.5*A[7],A[10]=.5*A[10]+.5*A[11],A[14]=.5*A[14]+.5*A[15]}function ig(n){let A=n.elements;A[11]===-1?(A[10]=-A[10]-1,A[14]=-A[14]):(A[10]=-A[10],A[14]=-A[14]+1)}var Zd=new WA().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),qd=new WA().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pC(){let n={enabled:!0,workingColorSpace:Fr,spaces:{},convert:function(r,i,s){return this.enabled===!1||i===s||!i||!s||(this.spaces[i].transfer===ce&&(r.r=wn(r.r),r.g=wn(r.g),r.b=wn(r.b)),this.spaces[i].primaries!==this.spaces[s].primaries&&(r.applyMatrix3(this.spaces[i].toXYZ),r.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===ce&&(r.r=oi(r.r),r.g=oi(r.g),r.b=oi(r.b))),r},workingToColorSpace:function(r,i){return this.convert(r,this.workingColorSpace,i)},colorSpaceToWorking:function(r,i){return this.convert(r,i,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===xn?os:this.spaces[r].transfer},getLuminanceCoefficients:function(r,i=this.workingColorSpace){return r.fromArray(this.spaces[i].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,i,s){return r.copy(this.spaces[i].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,i){return Er("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,i)},toWorkingColorSpace:function(r,i){return Er("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,i)}},A=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],t=[.3127,.329];return n.define({[Fr]:{primaries:A,whitePoint:t,transfer:os,toXYZ:Zd,fromXYZ:qd,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:pt},outputColorSpaceConfig:{drawingBufferColorSpace:pt}},[pt]:{primaries:A,whitePoint:t,transfer:ce,toXYZ:Zd,fromXYZ:qd,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:pt}}}),n}var te=pC();function wn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function oi(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var Zr,ho=class{static getDataURL(A,e="image/png"){if(/^data:/i.test(A.src)||typeof HTMLCanvasElement>"u")return A.src;let t;if(A instanceof HTMLCanvasElement)t=A;else{Zr===void 0&&(Zr=ls("canvas")),Zr.width=A.width,Zr.height=A.height;let r=Zr.getContext("2d");A instanceof ImageData?r.putImageData(A,0,0):r.drawImage(A,0,0,A.width,A.height),t=Zr}return t.toDataURL(e)}static sRGBToLinear(A){if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap){let e=ls("canvas");e.width=A.width,e.height=A.height;let t=e.getContext("2d");t.drawImage(A,0,0,A.width,A.height);let r=t.getImageData(0,0,A.width,A.height),i=r.data;for(let s=0;s<i.length;s++)i[s]=wn(i[s]/255)*255;return t.putImageData(r,0,0),e}else if(A.data){let e=A.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(wn(e[t]/255)*255):e[t]=wn(e[t]);return{data:e,width:A.width,height:A.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),A}},gC=0,li=class{constructor(A=null){this.isSource=!0,Object.defineProperty(this,"id",{value:gC++}),this.uuid=yi(),this.data=A,this.dataReady=!0,this.version=0}getSize(A){let e=this.data;return e instanceof HTMLVideoElement?A.set(e.videoWidth,e.videoHeight):e!==null?A.set(e.width,e.height,e.depth||0):A.set(0,0,0),A}set needsUpdate(A){A===!0&&this.version++}toJSON(A){let e=A===void 0||typeof A=="string";if(!e&&A.images[this.uuid]!==void 0)return A.images[this.uuid];let t={uuid:this.uuid,url:""},r=this.data;if(r!==null){let i;if(Array.isArray(r)){i=[];for(let s=0,a=r.length;s<a;s++)r[s].isDataTexture?i.push(yu(r[s].image)):i.push(yu(r[s]))}else i=yu(r);t.url=i}return e||(A.images[this.uuid]=t),t}};function yu(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?ho.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var BC=0,Fu=new R,ot=class n extends vn{constructor(A=n.DEFAULT_IMAGE,e=n.DEFAULT_MAPPING,t=Kt,r=Kt,i=Gt,s=Wn,a=Qt,o=en,c=n.DEFAULT_ANISOTROPY,l=xn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:BC++}),this.uuid=yi(),this.name="",this.source=new li(A),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=t,this.wrapT=r,this.magFilter=i,this.minFilter=s,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=o,this.offset=new wA(0,0),this.repeat=new wA(1,1),this.center=new wA(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new WA,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(A&&A.depth&&A.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Fu).x}get height(){return this.source.getSize(Fu).y}get depth(){return this.source.getSize(Fu).z}get image(){return this.source.data}set image(A=null){this.source.data=A}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(A,e){this.updateRanges.push({start:A,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(A){return this.name=A.name,this.source=A.source,this.mipmaps=A.mipmaps.slice(0),this.mapping=A.mapping,this.channel=A.channel,this.wrapS=A.wrapS,this.wrapT=A.wrapT,this.magFilter=A.magFilter,this.minFilter=A.minFilter,this.anisotropy=A.anisotropy,this.format=A.format,this.internalFormat=A.internalFormat,this.type=A.type,this.offset.copy(A.offset),this.repeat.copy(A.repeat),this.center.copy(A.center),this.rotation=A.rotation,this.matrixAutoUpdate=A.matrixAutoUpdate,this.matrix.copy(A.matrix),this.generateMipmaps=A.generateMipmaps,this.premultiplyAlpha=A.premultiplyAlpha,this.flipY=A.flipY,this.unpackAlignment=A.unpackAlignment,this.colorSpace=A.colorSpace,this.renderTarget=A.renderTarget,this.isRenderTargetTexture=A.isRenderTargetTexture,this.isArrayTexture=A.isArrayTexture,this.userData=JSON.parse(JSON.stringify(A.userData)),this.needsUpdate=!0,this}setValues(A){for(let e in A){let t=A[e];if(t===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let r=this[e];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}r&&t&&r.isVector2&&t.isVector2||r&&t&&r.isVector3&&t.isVector3||r&&t&&r.isMatrix3&&t.isMatrix3?r.copy(t):this[e]=t}}toJSON(A){let e=A===void 0||typeof A=="string";if(!e&&A.textures[this.uuid]!==void 0)return A.textures[this.uuid];let t={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(A).uuid,mapping:this.mapping,channel:this.channel,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,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(t.userData=this.userData),e||(A.textures[this.uuid]=t),t}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(A){if(this.mapping!==ah)return A;if(A.applyMatrix3(this.matrix),A.x<0||A.x>1)switch(this.wrapS){case oo:A.x=A.x-Math.floor(A.x);break;case Kt:A.x=A.x<0?0:1;break;case co:Math.abs(Math.floor(A.x)%2)===1?A.x=Math.ceil(A.x)-A.x:A.x=A.x-Math.floor(A.x);break}if(A.y<0||A.y>1)switch(this.wrapT){case oo:A.y=A.y-Math.floor(A.y);break;case Kt:A.y=A.y<0?0:1;break;case co:Math.abs(Math.floor(A.y)%2)===1?A.y=Math.ceil(A.y)-A.y:A.y=A.y-Math.floor(A.y);break}return this.flipY&&(A.y=1-A.y),A}set needsUpdate(A){A===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(A){A===!0&&this.pmremVersion++}};ot.DEFAULT_IMAGE=null;ot.DEFAULT_MAPPING=ah;ot.DEFAULT_ANISOTROPY=1;var ye=class n{constructor(A=0,e=0,t=0,r=1){n.prototype.isVector4=!0,this.x=A,this.y=e,this.z=t,this.w=r}get width(){return this.z}set width(A){this.z=A}get height(){return this.w}set height(A){this.w=A}set(A,e,t,r){return this.x=A,this.y=e,this.z=t,this.w=r,this}setScalar(A){return this.x=A,this.y=A,this.z=A,this.w=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setZ(A){return this.z=A,this}setW(A){return this.w=A,this}setComponent(A,e){switch(A){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+A)}return this}getComponent(A){switch(A){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: "+A)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(A){return this.x=A.x,this.y=A.y,this.z=A.z,this.w=A.w!==void 0?A.w:1,this}add(A){return this.x+=A.x,this.y+=A.y,this.z+=A.z,this.w+=A.w,this}addScalar(A){return this.x+=A,this.y+=A,this.z+=A,this.w+=A,this}addVectors(A,e){return this.x=A.x+e.x,this.y=A.y+e.y,this.z=A.z+e.z,this.w=A.w+e.w,this}addScaledVector(A,e){return this.x+=A.x*e,this.y+=A.y*e,this.z+=A.z*e,this.w+=A.w*e,this}sub(A){return this.x-=A.x,this.y-=A.y,this.z-=A.z,this.w-=A.w,this}subScalar(A){return this.x-=A,this.y-=A,this.z-=A,this.w-=A,this}subVectors(A,e){return this.x=A.x-e.x,this.y=A.y-e.y,this.z=A.z-e.z,this.w=A.w-e.w,this}multiply(A){return this.x*=A.x,this.y*=A.y,this.z*=A.z,this.w*=A.w,this}multiplyScalar(A){return this.x*=A,this.y*=A,this.z*=A,this.w*=A,this}applyMatrix4(A){let e=this.x,t=this.y,r=this.z,i=this.w,s=A.elements;return this.x=s[0]*e+s[4]*t+s[8]*r+s[12]*i,this.y=s[1]*e+s[5]*t+s[9]*r+s[13]*i,this.z=s[2]*e+s[6]*t+s[10]*r+s[14]*i,this.w=s[3]*e+s[7]*t+s[11]*r+s[15]*i,this}divide(A){return this.x/=A.x,this.y/=A.y,this.z/=A.z,this.w/=A.w,this}divideScalar(A){return this.multiplyScalar(1/A)}setAxisAngleFromQuaternion(A){this.w=2*Math.acos(A.w);let e=Math.sqrt(1-A.w*A.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=A.x/e,this.y=A.y/e,this.z=A.z/e),this}setAxisAngleFromRotationMatrix(A){let e,t,r,i,o=A.elements,c=o[0],l=o[4],u=o[8],h=o[1],d=o[5],g=o[9],B=o[2],p=o[6],f=o[10];if(Math.abs(l-h)<.01&&Math.abs(u-B)<.01&&Math.abs(g-p)<.01){if(Math.abs(l+h)<.1&&Math.abs(u+B)<.1&&Math.abs(g+p)<.1&&Math.abs(c+d+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let y=(c+1)/2,m=(d+1)/2,S=(f+1)/2,F=(l+h)/4,x=(u+B)/4,M=(g+p)/4;return y>m&&y>S?y<.01?(t=0,r=.707106781,i=.707106781):(t=Math.sqrt(y),r=F/t,i=x/t):m>S?m<.01?(t=.707106781,r=0,i=.707106781):(r=Math.sqrt(m),t=F/r,i=M/r):S<.01?(t=.707106781,r=.707106781,i=0):(i=Math.sqrt(S),t=x/i,r=M/i),this.set(t,r,i,e),this}let U=Math.sqrt((p-g)*(p-g)+(u-B)*(u-B)+(h-l)*(h-l));return Math.abs(U)<.001&&(U=1),this.x=(p-g)/U,this.y=(u-B)/U,this.z=(h-l)/U,this.w=Math.acos((c+d+f-1)/2),this}setFromMatrixPosition(A){let e=A.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this.z=Math.min(this.z,A.z),this.w=Math.min(this.w,A.w),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this.z=Math.max(this.z,A.z),this.w=Math.max(this.w,A.w),this}clamp(A,e){return this.x=YA(this.x,A.x,e.x),this.y=YA(this.y,A.y,e.y),this.z=YA(this.z,A.z,e.z),this.w=YA(this.w,A.w,e.w),this}clampScalar(A,e){return this.x=YA(this.x,A,e),this.y=YA(this.y,A,e),this.z=YA(this.z,A,e),this.w=YA(this.w,A,e),this}clampLength(A,e){let t=this.length();return this.divideScalar(t||1).multiplyScalar(YA(t,A,e))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(A){return this.x*A.x+this.y*A.y+this.z*A.z+this.w*A.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(A){return this.normalize().multiplyScalar(A)}lerp(A,e){return this.x+=(A.x-this.x)*e,this.y+=(A.y-this.y)*e,this.z+=(A.z-this.z)*e,this.w+=(A.w-this.w)*e,this}lerpVectors(A,e,t){return this.x=A.x+(e.x-A.x)*t,this.y=A.y+(e.y-A.y)*t,this.z=A.z+(e.z-A.z)*t,this.w=A.w+(e.w-A.w)*t,this}equals(A){return A.x===this.x&&A.y===this.y&&A.z===this.z&&A.w===this.w}fromArray(A,e=0){return this.x=A[e],this.y=A[e+1],this.z=A[e+2],this.w=A[e+3],this}toArray(A=[],e=0){return A[e]=this.x,A[e+1]=this.y,A[e+2]=this.z,A[e+3]=this.w,A}fromBufferAttribute(A,e){return this.x=A.getX(e),this.y=A.getY(e),this.z=A.getZ(e),this.w=A.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},fo=class extends vn{constructor(A=1,e=1,t={}){super(),t=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Gt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},t),this.isRenderTarget=!0,this.width=A,this.height=e,this.depth=t.depth,this.scissor=new ye(0,0,A,e),this.scissorTest=!1,this.viewport=new ye(0,0,A,e);let r={width:A,height:e,depth:t.depth},i=new ot(r);this.textures=[];let s=t.count;for(let a=0;a<s;a++)this.textures[a]=i.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(t),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=t.depthTexture,this.samples=t.samples,this.multiview=t.multiview}_setTextureOptions(A={}){let e={minFilter:Gt,generateMipmaps:!1,flipY:!1,internalFormat:null};A.mapping!==void 0&&(e.mapping=A.mapping),A.wrapS!==void 0&&(e.wrapS=A.wrapS),A.wrapT!==void 0&&(e.wrapT=A.wrapT),A.wrapR!==void 0&&(e.wrapR=A.wrapR),A.magFilter!==void 0&&(e.magFilter=A.magFilter),A.minFilter!==void 0&&(e.minFilter=A.minFilter),A.format!==void 0&&(e.format=A.format),A.type!==void 0&&(e.type=A.type),A.anisotropy!==void 0&&(e.anisotropy=A.anisotropy),A.colorSpace!==void 0&&(e.colorSpace=A.colorSpace),A.flipY!==void 0&&(e.flipY=A.flipY),A.generateMipmaps!==void 0&&(e.generateMipmaps=A.generateMipmaps),A.internalFormat!==void 0&&(e.internalFormat=A.internalFormat);for(let t=0;t<this.textures.length;t++)this.textures[t].setValues(e)}get texture(){return this.textures[0]}set texture(A){this.textures[0]=A}set depthTexture(A){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),A!==null&&(A.renderTarget=this),this._depthTexture=A}get depthTexture(){return this._depthTexture}setSize(A,e,t=1){if(this.width!==A||this.height!==e||this.depth!==t){this.width=A,this.height=e,this.depth=t;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=A,this.textures[r].image.height=e,this.textures[r].image.depth=t,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,A,e),this.scissor.set(0,0,A,e)}clone(){return new this.constructor().copy(this)}copy(A){this.width=A.width,this.height=A.height,this.depth=A.depth,this.scissor.copy(A.scissor),this.scissorTest=A.scissorTest,this.viewport.copy(A.viewport),this.textures.length=0;for(let e=0,t=A.textures.length;e<t;e++){this.textures[e]=A.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let r=Object.assign({},A.textures[e].image);this.textures[e].source=new li(r)}return this.depthBuffer=A.depthBuffer,this.stencilBuffer=A.stencilBuffer,this.resolveDepthBuffer=A.resolveDepthBuffer,this.resolveStencilBuffer=A.resolveStencilBuffer,A.depthTexture!==null&&(this.depthTexture=A.depthTexture.clone()),this.samples=A.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},qt=class extends fo{constructor(A=1,e=1,t={}){super(A,e,t),this.isWebGLRenderTarget=!0}},us=class extends ot{constructor(A=null,e=1,t=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:A,width:e,height:t,depth:r},this.magFilter=Et,this.minFilter=Et,this.wrapR=Kt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(A){this.layerUpdates.add(A)}clearLayerUpdates(){this.layerUpdates.clear()}};var po=class extends ot{constructor(A=null,e=1,t=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:A,width:e,height:t,depth:r},this.magFilter=Et,this.minFilter=Et,this.wrapR=Kt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Gn=class{constructor(A=new R(1/0,1/0,1/0),e=new R(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=A,this.max=e}set(A,e){return this.min.copy(A),this.max.copy(e),this}setFromArray(A){this.makeEmpty();for(let e=0,t=A.length;e<t;e+=3)this.expandByPoint(Pt.fromArray(A,e));return this}setFromBufferAttribute(A){this.makeEmpty();for(let e=0,t=A.count;e<t;e++)this.expandByPoint(Pt.fromBufferAttribute(A,e));return this}setFromPoints(A){this.makeEmpty();for(let e=0,t=A.length;e<t;e++)this.expandByPoint(A[e]);return this}setFromCenterAndSize(A,e){let t=Pt.copy(e).multiplyScalar(.5);return this.min.copy(A).sub(t),this.max.copy(A).add(t),this}setFromObject(A,e=!1){return this.makeEmpty(),this.expandByObject(A,e)}clone(){return new this.constructor().copy(this)}copy(A){return this.min.copy(A.min),this.max.copy(A.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(A){return this.isEmpty()?A.set(0,0,0):A.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(A){return this.isEmpty()?A.set(0,0,0):A.subVectors(this.max,this.min)}expandByPoint(A){return this.min.min(A),this.max.max(A),this}expandByVector(A){return this.min.sub(A),this.max.add(A),this}expandByScalar(A){return this.min.addScalar(-A),this.max.addScalar(A),this}expandByObject(A,e=!1){A.updateWorldMatrix(!1,!1);let t=A.geometry;if(t!==void 0){let i=t.getAttribute("position");if(e===!0&&i!==void 0&&A.isInstancedMesh!==!0)for(let s=0,a=i.count;s<a;s++)A.isMesh===!0?A.getVertexPosition(s,Pt):Pt.fromBufferAttribute(i,s),Pt.applyMatrix4(A.matrixWorld),this.expandByPoint(Pt);else A.boundingBox!==void 0?(A.boundingBox===null&&A.computeBoundingBox(),Pa.copy(A.boundingBox)):(t.boundingBox===null&&t.computeBoundingBox(),Pa.copy(t.boundingBox)),Pa.applyMatrix4(A.matrixWorld),this.union(Pa)}let r=A.children;for(let i=0,s=r.length;i<s;i++)this.expandByObject(r[i],e);return this}containsPoint(A){return A.x>=this.min.x&&A.x<=this.max.x&&A.y>=this.min.y&&A.y<=this.max.y&&A.z>=this.min.z&&A.z<=this.max.z}containsBox(A){return this.min.x<=A.min.x&&A.max.x<=this.max.x&&this.min.y<=A.min.y&&A.max.y<=this.max.y&&this.min.z<=A.min.z&&A.max.z<=this.max.z}getParameter(A,e){return e.set((A.x-this.min.x)/(this.max.x-this.min.x),(A.y-this.min.y)/(this.max.y-this.min.y),(A.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(A){return A.max.x>=this.min.x&&A.min.x<=this.max.x&&A.max.y>=this.min.y&&A.min.y<=this.max.y&&A.max.z>=this.min.z&&A.min.z<=this.max.z}intersectsSphere(A){return this.clampPoint(A.center,Pt),Pt.distanceToSquared(A.center)<=A.radius*A.radius}intersectsPlane(A){let e,t;return A.normal.x>0?(e=A.normal.x*this.min.x,t=A.normal.x*this.max.x):(e=A.normal.x*this.max.x,t=A.normal.x*this.min.x),A.normal.y>0?(e+=A.normal.y*this.min.y,t+=A.normal.y*this.max.y):(e+=A.normal.y*this.max.y,t+=A.normal.y*this.min.y),A.normal.z>0?(e+=A.normal.z*this.min.z,t+=A.normal.z*this.max.z):(e+=A.normal.z*this.max.z,t+=A.normal.z*this.min.z),e<=-A.constant&&t>=-A.constant}intersectsTriangle(A){if(this.isEmpty())return!1;this.getCenter(As),Oa.subVectors(this.max,As),qr.subVectors(A.a,As),$r.subVectors(A.b,As),jr.subVectors(A.c,As),Hn.subVectors($r,qr),Ln.subVectors(jr,$r),pr.subVectors(qr,jr);let e=[0,-Hn.z,Hn.y,0,-Ln.z,Ln.y,0,-pr.z,pr.y,Hn.z,0,-Hn.x,Ln.z,0,-Ln.x,pr.z,0,-pr.x,-Hn.y,Hn.x,0,-Ln.y,Ln.x,0,-pr.y,pr.x,0];return!Eu(e,qr,$r,jr,Oa)||(e=[1,0,0,0,1,0,0,0,1],!Eu(e,qr,$r,jr,Oa))?!1:(Na.crossVectors(Hn,Ln),e=[Na.x,Na.y,Na.z],Eu(e,qr,$r,jr,Oa))}clampPoint(A,e){return e.copy(A).clamp(this.min,this.max)}distanceToPoint(A){return this.clampPoint(A,Pt).distanceTo(A)}getBoundingSphere(A){return this.isEmpty()?A.makeEmpty():(this.getCenter(A.center),A.radius=this.getSize(Pt).length()*.5),A}intersect(A){return this.min.max(A.min),this.max.min(A.max),this.isEmpty()&&this.makeEmpty(),this}union(A){return this.min.min(A.min),this.max.max(A.max),this}applyMatrix4(A){return this.isEmpty()?this:(dn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(A),dn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(A),dn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(A),dn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(A),dn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(A),dn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(A),dn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(A),dn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(A),this.setFromPoints(dn),this)}translate(A){return this.min.add(A),this.max.add(A),this}equals(A){return A.min.equals(this.min)&&A.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(A){return this.min.fromArray(A.min),this.max.fromArray(A.max),this}},dn=[new R,new R,new R,new R,new R,new R,new R,new R],Pt=new R,Pa=new Gn,qr=new R,$r=new R,jr=new R,Hn=new R,Ln=new R,pr=new R,As=new R,Oa=new R,Na=new R,gr=new R;function Eu(n,A,e,t,r){for(let i=0,s=n.length-3;i<=s;i+=3){gr.fromArray(n,i);let a=r.x*Math.abs(gr.x)+r.y*Math.abs(gr.y)+r.z*Math.abs(gr.z),o=A.dot(gr),c=e.dot(gr),l=t.dot(gr);if(Math.max(-Math.max(o,c,l),Math.min(o,c,l))>a)return!1}return!0}var mC=new Gn,es=new R,xu=new R,ui=class{constructor(A=new R,e=-1){this.isSphere=!0,this.center=A,this.radius=e}set(A,e){return this.center.copy(A),this.radius=e,this}setFromPoints(A,e){let t=this.center;e!==void 0?t.copy(e):mC.setFromPoints(A).getCenter(t);let r=0;for(let i=0,s=A.length;i<s;i++)r=Math.max(r,t.distanceToSquared(A[i]));return this.radius=Math.sqrt(r),this}copy(A){return this.center.copy(A.center),this.radius=A.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(A){return A.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(A){return A.distanceTo(this.center)-this.radius}intersectsSphere(A){let e=this.radius+A.radius;return A.center.distanceToSquared(this.center)<=e*e}intersectsBox(A){return A.intersectsSphere(this)}intersectsPlane(A){return Math.abs(A.distanceToPoint(this.center))<=this.radius}clampPoint(A,e){let t=this.center.distanceToSquared(A);return e.copy(A),t>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(A){return this.isEmpty()?(A.makeEmpty(),A):(A.set(this.center,this.center),A.expandByScalar(this.radius),A)}applyMatrix4(A){return this.center.applyMatrix4(A),this.radius=this.radius*A.getMaxScaleOnAxis(),this}translate(A){return this.center.add(A),this}expandByPoint(A){if(this.isEmpty())return this.center.copy(A),this.radius=0,this;es.subVectors(A,this.center);let e=es.lengthSq();if(e>this.radius*this.radius){let t=Math.sqrt(e),r=(t-this.radius)*.5;this.center.addScaledVector(es,r/t),this.radius+=r}return this}union(A){return A.isEmpty()?this:this.isEmpty()?(this.copy(A),this):(this.center.equals(A.center)===!0?this.radius=Math.max(this.radius,A.radius):(xu.subVectors(A.center,this.center).setLength(A.radius),this.expandByPoint(es.copy(A.center).add(xu)),this.expandByPoint(es.copy(A.center).sub(xu))),this)}equals(A){return A.center.equals(this.center)&&A.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(A){return this.radius=A.radius,this.center.fromArray(A.center),this}},pn=new R,Qu=new R,Ka=new R,Rn=new R,_u=new R,Ga=new R,Su=new R,go=class{constructor(A=new R,e=new R(0,0,-1)){this.origin=A,this.direction=e}set(A,e){return this.origin.copy(A),this.direction.copy(e),this}copy(A){return this.origin.copy(A.origin),this.direction.copy(A.direction),this}at(A,e){return e.copy(this.origin).addScaledVector(this.direction,A)}lookAt(A){return this.direction.copy(A).sub(this.origin).normalize(),this}recast(A){return this.origin.copy(this.at(A,pn)),this}closestPointToPoint(A,e){e.subVec