@splinetool/runtime 0.9.70 → 0.9.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/runtime.cjs +52 -40
- package/build/runtime.js +52 -40
- package/package.json +1 -1
package/build/runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var wM=Object.create;var ap=Object.defineProperty;var SM=Object.getOwnPropertyDescriptor;var AM=Object.getOwnPropertyNames;var MM=Object.getPrototypeOf,_M=Object.prototype.hasOwnProperty;var TM=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),EM=(r,e)=>{for(var t in e)ap(r,t,{get:e[t],enumerable:!0})},CM=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of AM(e))!_M.call(r,i)&&i!==t&&ap(r,i,{get:()=>e[i],enumerable:!(n=SM(e,i))||n.enumerable});return r};var DM=(r,e,t)=>(t=r!=null?wM(MM(r)):{},CM(e||!r||!r.__esModule?ap(t,"default",{value:r,enumerable:!0}):t,r));var PA=TM((Hf,DA)=>{(function(r,e){typeof Hf=="object"&&typeof DA<"u"?e(Hf):typeof define=="function"&&define.amd?define(["exports"],e):e((r=typeof globalThis<"u"?globalThis:r||self).SVDJS={})})(Hf,function(r){"use strict";r.SVD=function(e,t,n,i,s){if(t=t===void 0||t,n=n===void 0||n,s=1e-64/(i=i||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var o,a,l,c,h,u,d,f,m,p,g,x,v=e[0].length,w=e.length;if(w<v)throw new TypeError("Invalid matrix: m < n");for(var b=[],S=[],M=[],_=t==="f"?w:v,y=p=d=0;y<w;y++)S[y]=new Array(_).fill(0);for(y=0;y<v;y++)M[y]=new Array(v).fill(0);var T,E=new Array(v).fill(0);for(y=0;y<w;y++)for(o=0;o<v;o++)S[y][o]=e[y][o];for(y=0;y<v;y++){for(b[y]=d,m=0,l=y+1,o=y;o<w;o++)m+=Math.pow(S[o][y],2);if(m<s)d=0;else for(f=(u=S[y][y])*(d=u<0?Math.sqrt(m):-Math.sqrt(m))-m,S[y][y]=u-d,o=l;o<v;o++){for(m=0,a=y;a<w;a++)m+=S[a][y]*S[a][o];for(u=m/f,a=y;a<w;a++)S[a][o]=S[a][o]+u*S[a][y]}for(E[y]=d,m=0,o=l;o<v;o++)m+=Math.pow(S[y][o],2);if(m<s)d=0;else{for(f=(u=S[y][y+1])*(d=u<0?Math.sqrt(m):-Math.sqrt(m))-m,S[y][y+1]=u-d,o=l;o<v;o++)b[o]=S[y][o]/f;for(o=l;o<w;o++){for(m=0,a=l;a<v;a++)m+=S[o][a]*S[y][a];for(a=l;a<v;a++)S[o][a]=S[o][a]+m*b[a]}}p<(g=Math.abs(E[y])+Math.abs(b[y]))&&(p=g)}if(n)for(y=v-1;0<=y;y--){if(d!==0){for(f=S[y][y+1]*d,o=l;o<v;o++)M[o][y]=S[y][o]/f;for(o=l;o<v;o++){for(m=0,a=l;a<v;a++)m+=S[y][a]*M[a][o];for(a=l;a<v;a++)M[a][o]=M[a][o]+m*M[a][y]}}for(o=l;o<v;o++)M[y][o]=0,M[o][y]=0;M[y][y]=1,d=b[y],l=y}if(t){if(t==="f")for(y=v;y<w;y++){for(o=v;o<w;o++)S[y][o]=0;S[y][y]=1}for(y=v-1;0<=y;y--){for(l=y+1,d=E[y],o=l;o<_;o++)S[y][o]=0;if(d!==0){for(f=S[y][y]*d,o=l;o<_;o++){for(m=0,a=l;a<w;a++)m+=S[a][y]*S[a][o];for(u=m/f,a=y;a<w;a++)S[a][o]=S[a][o]+u*S[a][y]}for(o=y;o<w;o++)S[o][y]=S[o][y]/d}else for(o=y;o<w;o++)S[o][y]=0;S[y][y]=S[y][y]+1}}for(i*=p,a=v-1;0<=a;a--)for(var C=0;C<50;C++){for(T=!1,l=a;0<=l;l--){if(Math.abs(b[l])<=i){T=!0;break}if(Math.abs(E[l-1])<=i)break}if(!T){for(h=0,c=l-(m=1),y=l;y<a+1&&(u=m*b[y],b[y]=h*b[y],!(Math.abs(u)<=i));y++)if(d=E[y],E[y]=Math.sqrt(u*u+d*d),h=d/(f=E[y]),m=-u/f,t)for(o=0;o<w;o++)g=S[o][c],x=S[o][y],S[o][c]=g*h+x*m,S[o][y]=-g*m+x*h}if(x=E[a],l===a){if(x<0&&(E[a]=-x,n))for(o=0;o<v;o++)M[o][a]=-M[o][a];break}for(p=E[l],u=(((g=E[a-1])-x)*(g+x)+((d=b[a-1])-(f=b[a]))*(d+f))/(2*f*g),d=Math.sqrt(u*u+1),u=((p-x)*(p+x)+f*(g/(u<0?u-d:u+d)-f))/p,y=l+(m=h=1);y<a+1;y++){if(d=b[y],g=E[y],f=m*d,d*=h,x=Math.sqrt(u*u+f*f),u=p*(h=u/(b[y-1]=x))+d*(m=f/x),d=-p*m+d*h,f=g*m,g*=h,n)for(o=0;o<v;o++)p=M[o][y-1],x=M[o][y],M[o][y-1]=p*h+x*m,M[o][y]=-p*m+x*h;if(x=Math.sqrt(u*u+f*f),u=(h=u/(E[y-1]=x))*d+(m=f/x)*g,p=-m*d+h*g,t)for(o=0;o<w;o++)g=S[o][y-1],x=S[o][y],S[o][y-1]=g*h+x*m,S[o][y]=-g*m+x*h}b[l]=0,b[a]=u,E[a]=p}for(y=0;y<v;y++)E[y]<i&&(E[y]=0);return{u:S,q:E,v:M}},r.VERSION="1.1.1",Object.defineProperty(r,"__esModule",{value:!0})})});var mo="141";var cr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},PM=0,wv=1,IM=2;var Bu=1,km=2,rc=3,zi=0,wn=1,hn=2,LM=1;var Ct=0,ls=1,Sv=2,Av=3,Mv=4,NM=5,Zo=100,RM=101,BM=102,_v=103,Tv=104,OM=200,FM=201,UM=202,zM=203,$0=204,ex=205,GM=206,kM=207,VM=208,HM=209,WM=210,jM=0,qM=1,XM=2,Wp=3,YM=4,QM=5,KM=6,ZM=7,Ou=0,JM=1,$M=2,Ui=0,e_=1,t_=2,n_=3,r_=4,i_=5,tx=300,us=301,ds=302,jp=303,qp=304,ya=306,ta=1e3,bn=1001,Xp=1002,Gt=1003,Ev=1004;var Cv=1005;var tt=1006,s_=1007;var xs=1008;var It=1009,o_=1010,a_=1011,nx=1012,l_=1013,Fi=1014,vr=1015,hc=1016,c_=1017,h_=1018,cs=1020,u_=1021,d_=1022,xr=1023,f_=1024,p_=1025,to=1026,fs=1027,m_=1028,g_=1029,y_=1030,v_=1031,x_=1033,lp=33776,cp=33777,hp=33778,up=33779,Dv=35840,Pv=35841,Iv=35842,Lv=35843,b_=36196,Nv=37492,Rv=37496,Bv=37808,Ov=37809,Fv=37810,Uv=37811,zv=37812,Gv=37813,kv=37814,Vv=37815,Hv=37816,Wv=37817,jv=37818,qv=37819,Xv=37820,Yv=37821,Qv=36492;var hu=2300,uu=2301,dp=2302,Kv=2400,Zv=2401,Jv=2402;var w_=2501;var lr=3e3,We=3001,An=3200,S_=3201,va=0,A_=1;var Oi="srgb",eo="srgb-linear";var fp=7680;var M_=519,Yp=35044;var $v="300 es",Qp=1035,Rt=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let i=this._listeners[e];if(i!==void 0){let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}},Cn=[];for(let r=0;r<256;r++)Cn[r]=(r<16?"0":"")+r.toString(16);var e0=1234567,sc=Math.PI/180,uc=180/Math.PI;function ci(){let r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Cn[r&255]+Cn[r>>8&255]+Cn[r>>16&255]+Cn[r>>24&255]+"-"+Cn[e&255]+Cn[e>>8&255]+"-"+Cn[e>>16&15|64]+Cn[e>>24&255]+"-"+Cn[t&63|128]+Cn[t>>8&255]+"-"+Cn[t>>16&255]+Cn[t>>24&255]+Cn[n&255]+Cn[n>>8&255]+Cn[n>>16&255]+Cn[n>>24&255]).toLowerCase()}function sn(r,e,t){return Math.max(e,Math.min(t,r))}function Vm(r,e){return(r%e+e)%e}function __(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function T_(r,e,t){return r!==e?(t-r)/(e-r):0}function oc(r,e,t){return(1-t)*r+t*e}function E_(r,e,t,n){return oc(r,e,1-Math.exp(-t*n))}function C_(r,e=1){return e-Math.abs(Vm(r,e*2)-e)}function D_(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function P_(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function I_(r,e){return r+Math.floor(Math.random()*(e-r+1))}function L_(r,e){return r+Math.random()*(e-r)}function N_(r){return r*(.5-Math.random())}function R_(r){r!==void 0&&(e0=r);let e=e0+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function B_(r){return r*sc}function O_(r){return r*uc}function Kp(r){return(r&r-1)===0&&r!==0}function F_(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function du(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function U_(r,e,t,n,i){let s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),h=o((e+n)/2),u=s((e-n)/2),d=o((e-n)/2),f=s((n-e)/2),m=o((n-e)/2);switch(i){case"XYX":r.set(a*h,l*u,l*d,a*c);break;case"YZY":r.set(l*d,a*h,l*u,a*c);break;case"ZXZ":r.set(l*u,l*d,a*h,a*c);break;case"XZX":r.set(a*h,l*m,l*f,a*c);break;case"YXY":r.set(l*f,a*h,l*m,a*c);break;case"ZYZ":r.set(l*m,l*f,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function z_(r,e){switch(e.constructor){case Float32Array:return r;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function G_(r,e){switch(e.constructor){case Float32Array:return r;case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}var Ge=Object.freeze({__proto__:null,DEG2RAD:sc,RAD2DEG:uc,generateUUID:ci,clamp:sn,euclideanModulo:Vm,mapLinear:__,inverseLerp:T_,lerp:oc,damp:E_,pingpong:C_,smoothstep:D_,smootherstep:P_,randInt:I_,randFloat:L_,randFloatSpread:N_,seededRandom:R_,degToRad:B_,radToDeg:O_,isPowerOfTwo:Kp,ceilPowerOfTwo:F_,floorPowerOfTwo:du,setQuaternionFromProperEuler:U_,normalize:G_,denormalize:z_}),B=class{constructor(e=0,t=0){this.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},qt=class{constructor(){this.isMatrix3=!0,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(e,t,n,i,s,o,a,l,c){let h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],p=i[0],g=i[3],x=i[6],v=i[1],w=i[4],b=i[7],S=i[2],M=i[5],_=i[8];return s[0]=o*p+a*v+l*S,s[3]=o*g+a*w+l*M,s[6]=o*x+a*b+l*_,s[1]=c*p+h*v+u*S,s[4]=c*g+h*w+u*M,s[7]=c*x+h*b+u*_,s[2]=d*p+f*v+m*S,s[5]=d*g+f*w+m*M,s[8]=d*x+f*b+m*_,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-n*s*h+n*a*l+i*s*c-i*o*l}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=h*o-a*c,d=a*l-h*s,f=c*s-o*l,m=t*u+n*d+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let p=1/m;return e[0]=u*p,e[1]=(i*c-h*n)*p,e[2]=(a*n-i*o)*p,e[3]=d*p,e[4]=(h*t-i*l)*p,e[5]=(i*s-a*t)*p,e[6]=f*p,e[7]=(n*l-c*t)*p,e[8]=(o*t-n*s)*p,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){let n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),i=this.elements,s=i[0],o=i[3],a=i[6],l=i[1],c=i[4],h=i[7];return i[0]=t*s+n*l,i[3]=t*o+n*c,i[6]=t*a+n*h,i[1]=-n*s+t*l,i[4]=-n*o+t*c,i[7]=-n*a+t*h,this}translate(e,t){let n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};function rx(r){for(let e=r.length-1;e>=0;--e)if(r[e]>65535)return!0;return!1}var k_={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Bh(r,e){return new k_[r](e)}function fu(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function no(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function cu(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}var pp={[Oi]:{[eo]:no},[eo]:{[Oi]:cu}},Or={legacyMode:!0,get workingColorSpace(){return eo},set workingColorSpace(r){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(r,e,t){if(this.legacyMode||e===t||!e||!t)return r;if(pp[e]&&pp[e][t]!==void 0){let n=pp[e][t];return r.r=n(r.r),r.g=n(r.g),r.b=n(r.b),r}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(r,e){return this.convert(r,this.workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this.workingColorSpace)}},ix={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ln={r:0,g:0,b:0},Fr={h:0,s:0,l:0},Oh={h:0,s:0,l:0};function mp(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}function Fh(r,e){return e.r=r.r,e.g=r.g,e.b=r.b,e}var Ae=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Oi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Or.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=eo){return this.r=e,this.g=t,this.b=n,Or.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=eo){if(e=Vm(e,1),t=sn(t,0,1),n=sn(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=mp(o,s,e+1/3),this.g=mp(o,s,e),this.b=mp(o,s,e-1/3)}return Or.toWorkingColorSpace(this,i),this}setStyle(e,t=Oi){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,Or.toWorkingColorSpace(this,t),n(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,Or.toWorkingColorSpace(this,t),n(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){let l=parseFloat(s[1])/360,c=parseInt(s[2],10)/100,h=parseInt(s[3],10)/100;return n(s[4]),this.setHSL(l,c,h,t)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=i[1],o=s.length;if(o===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,Or.toWorkingColorSpace(this,t),this;if(o===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,Or.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Oi){let n=ix[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=no(e.r),this.g=no(e.g),this.b=no(e.b),this}copyLinearToSRGB(e){return this.r=cu(e.r),this.g=cu(e.g),this.b=cu(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Oi){return Or.fromWorkingColorSpace(Fh(this,ln),e),sn(ln.r*255,0,255)<<16^sn(ln.g*255,0,255)<<8^sn(ln.b*255,0,255)<<0}getHexString(e=Oi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=eo){Or.fromWorkingColorSpace(Fh(this,ln),t);let n=ln.r,i=ln.g,s=ln.b,o=Math.max(n,i,s),a=Math.min(n,i,s),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let u=o-a;switch(c=h<=.5?u/(o+a):u/(2-o-a),o){case n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=eo){return Or.fromWorkingColorSpace(Fh(this,ln),t),e.r=ln.r,e.g=ln.g,e.b=ln.b,e}getStyle(e=Oi){return Or.fromWorkingColorSpace(Fh(this,ln),e),e!==Oi?`color(${e} ${ln.r} ${ln.g} ${ln.b})`:`rgb(${ln.r*255|0},${ln.g*255|0},${ln.b*255|0})`}offsetHSL(e,t,n){return this.getHSL(Fr),Fr.h+=e,Fr.s+=t,Fr.l+=n,this.setHSL(Fr.h,Fr.s,Fr.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Fr),e.getHSL(Oh);let n=oc(Fr.h,Oh.h,t),i=oc(Fr.s,Oh.s,t),s=oc(Fr.l,Oh.l,t);return this.setHSL(n,i,s),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};Ae.NAMES=ix;var Fo,pu=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Fo===void 0&&(Fo=fu("canvas")),Fo.width=e.width,Fo.height=e.height;let n=Fo.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Fo}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=fu("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=no(s[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(no(t[n]/255)*255):t[n]=no(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},mu=class{constructor(e=null){this.isSource=!0,this.uuid=ci(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(gp(i[o].image)):s.push(gp(i[o]))}else s=gp(i);n.url=s}return t||(e.images[this.uuid]=n),n}};function gp(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?pu.getDataURL(r):r.data?{data:Array.prototype.slice.call(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var V_=0,Bt=class extends Rt{constructor(e=Bt.DEFAULT_IMAGE,t=Bt.DEFAULT_MAPPING,n=bn,i=bn,s=tt,o=xs,a=xr,l=It,c=1,h=lr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:V_++}),this.uuid=ci(),this.name="",this.source=new mu(e),this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new B(0,0),this.repeat=new B(1,1),this.center=new B(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new qt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e){this.source.data=e}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(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,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};return JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==tx)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ta:e.x=e.x-Math.floor(e.x);break;case bn:e.x=e.x<0?0:1;break;case Xp:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case ta:e.y=e.y-Math.floor(e.y);break;case bn:e.y=e.y<0?0:1;break;case Xp:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}};Bt.DEFAULT_IMAGE=null;Bt.DEFAULT_MAPPING=tx;var qe=class{constructor(e=0,t=0,n=0,i=1){this.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s,l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],m=l[9],p=l[2],g=l[6],x=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-p)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+p)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let w=(c+1)/2,b=(f+1)/2,S=(x+1)/2,M=(h+d)/4,_=(u+p)/4,y=(m+g)/4;return w>b&&w>S?w<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(w),i=M/n,s=_/n):b>S?b<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(b),n=M/i,s=y/i):S<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(S),n=_/s,i=y/s),this.set(n,i,s,t),this}let v=Math.sqrt((g-m)*(g-m)+(u-p)*(u-p)+(d-h)*(d-h));return Math.abs(v)<.001&&(v=1),this.x=(g-m)/v,this.y=(u-p)/v,this.z=(d-h)/v,this.w=Math.acos((c+f+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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}},lt=class extends Rt{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new qe(0,0,e,t),this.scissorTest=!1,this.viewport=new qe(0,0,e,t);let i={width:e,height:t,depth:1};this.texture=new Bt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:tt,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new mu(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},gu=class extends Bt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Gt,this.minFilter=Gt,this.wrapR=bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Zp=class extends Bt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Gt,this.minFilter=Gt,this.wrapR=bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Xt=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerp(e,t,n,i){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),n.slerpQuaternions(e,t,i)}static slerpFlat(e,t,n,i,s,o,a){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3],d=s[o+0],f=s[o+1],m=s[o+2],p=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(a===1){e[t+0]=d,e[t+1]=f,e[t+2]=m,e[t+3]=p;return}if(u!==p||l!==d||c!==f||h!==m){let g=1-a,x=l*d+c*f+h*m+u*p,v=x>=0?1:-1,w=1-x*x;if(w>Number.EPSILON){let S=Math.sqrt(w),M=Math.atan2(S,x*v);g=Math.sin(g*M)/S,a=Math.sin(a*M)/S}let b=a*v;if(l=l*g+d*b,c=c*g+f*b,h=h*g+m*b,u=u*g+p*b,g===1-a){let S=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=S,c*=S,h*=S,u*=S}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,s,o){let a=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[o],d=s[o+1],f=s[o+2],m=s[o+3];return e[t]=a*m+h*u+l*f-c*d,e[t+1]=l*m+h*d+c*u-a*f,e[t+2]=c*m+h*f+a*d-l*u,e[t+3]=h*m-a*u-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");let n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(i/2),u=a(s/2),d=l(n/2),f=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"YZX":this._x=d*h*u+c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u-d*f*m;break;case"XZY":this._x=d*h*u-c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],u=t[10],d=n+a+u;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(o-i)*f}else if(n>a&&n>u){let f=2*Math.sqrt(1+n-a-u);this._w=(h-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+c)/f}else if(a>u){let f=2*Math.sqrt(1+a-n-u);this._w=(s-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+u-n-a);this._w=(o-i)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(sn(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return t!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-n*c,this._z=s*h+o*c+n*l-i*a,this._w=o*h-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,i=this._y,s=this._z,o=this._w,a=o*e._w+n*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let f=1-t;return this._w=f*o+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(l),h=Math.atan2(c,a),u=Math.sin((1-t)*h)/c,d=Math.sin(t*h)/c;return this._w=o*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},A=class{constructor(e=0,t=0,n=0){this.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(t0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(t0.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=l*t+o*i-a*n,h=l*n+a*t-s*i,u=l*i+s*n-o*t,d=-s*t-o*n-a*i;return this.x=c*l+d*-s+h*-a-u*-o,this.y=h*l+d*-o+u*-s-c*-a,this.z=u*l+d*-a+c*-o-h*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return t!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return yp.copy(this).projectOnVector(e),this.sub(yp)}reflect(e){return this.sub(yp.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(sn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},yp=new A,t0=new Xt,Sn=class{constructor(e=new A(1/0,1/0,1/0),t=new A(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=e.length;l<c;l+=3){let h=e[l],u=e[l+1],d=e[l+2];h<t&&(t=h),u<n&&(n=u),d<i&&(i=d),h>s&&(s=h),u>o&&(o=u),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=e.count;l<c;l++){let h=e.getX(l),u=e.getY(l),d=e.getZ(l);h<t&&(t=h),u<n&&(n=u),d<i&&(i=d),h>s&&(s=h),u>o&&(o=u),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Qs.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0)if(t&&n.attributes!=null&&n.attributes.position!==void 0){let s=n.attributes.position;for(let o=0,a=s.count;o<a;o++)Qs.fromBufferAttribute(s,o).applyMatrix4(e.matrixWorld),this.expandByPoint(Qs)}else n.boundingBox===null&&n.computeBoundingBox(),vp.copy(n.boundingBox),vp.applyMatrix4(e.matrixWorld),this.union(vp);let i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Qs),Qs.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter($l),Uh.subVectors(this.max,$l),Uo.subVectors(e.a,$l),zo.subVectors(e.b,$l),Go.subVectors(e.c,$l),es.subVectors(zo,Uo),ts.subVectors(Go,zo),Ks.subVectors(Uo,Go);let t=[0,-es.z,es.y,0,-ts.z,ts.y,0,-Ks.z,Ks.y,es.z,0,-es.x,ts.z,0,-ts.x,Ks.z,0,-Ks.x,-es.y,es.x,0,-ts.y,ts.x,0,-Ks.y,Ks.x,0];return!xp(t,Uo,zo,Go,Uh)||(t=[1,0,0,0,1,0,0,0,1],!xp(t,Uo,zo,Go,Uh))?!1:(zh.crossVectors(es,ts),t=[zh.x,zh.y,zh.z],xp(t,Uo,zo,Go,Uh))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Qs.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(Qs).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Pi=[new A,new A,new A,new A,new A,new A,new A,new A],Qs=new A,vp=new Sn,Uo=new A,zo=new A,Go=new A,es=new A,ts=new A,Ks=new A,$l=new A,Uh=new A,zh=new A,Zs=new A;function xp(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){Zs.fromArray(r,s);let a=i.x*Math.abs(Zs.x)+i.y*Math.abs(Zs.y)+i.z*Math.abs(Zs.z),l=e.dot(Zs),c=t.dot(Zs),h=n.dot(Zs);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var H_=new Sn,n0=new A,Gh=new A,bp=new A,Rn=class{constructor(e=new A,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):H_.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){bp.subVectors(e,this.center);let t=bp.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(bp.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return this.center.equals(e.center)===!0?Gh.set(0,0,1).multiplyScalar(e.radius):Gh.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(n0.copy(e.center).add(Gh)),this.expandByPoint(n0.copy(e.center).sub(Gh)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Ii=new A,wp=new A,kh=new A,ns=new A,Sp=new A,Vh=new A,Ap=new A,ro=class{constructor(e=new A,t=new A(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ii)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Ii.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ii.copy(this.direction).multiplyScalar(t).add(this.origin),Ii.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){wp.copy(e).add(t).multiplyScalar(.5),kh.copy(t).sub(e).normalize(),ns.copy(this.origin).sub(wp);let s=e.distanceTo(t)*.5,o=-this.direction.dot(kh),a=ns.dot(this.direction),l=-ns.dot(kh),c=ns.lengthSq(),h=Math.abs(1-o*o),u,d,f,m;if(h>0)if(u=o*l-a,d=o*a-l,m=s*h,u>=0)if(d>=-m)if(d<=m){let p=1/h;u*=p,d*=p,f=u*(u+o*d+2*a)+d*(o*u+d+2*l)+c}else d=s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-o*s+a)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(o*s+a)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=o>0?-s:s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(kh).multiplyScalar(d).add(wp),f}intersectSphere(e,t){Ii.subVectors(e.center,this.origin);let n=Ii.dot(this.direction),i=Ii.dot(Ii)-n*n,s=e.radius*e.radius;if(i>s)return null;let o=Math.sqrt(s-i),a=n-o,l=n+o;return a<0&&l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,o,a,l,c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),h>=0?(s=(e.min.y-d.y)*h,o=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,o=(e.min.y-d.y)*h),n>o||s>i||((s>n||n!==n)&&(n=s),(o<i||i!==i)&&(i=o),u>=0?(a=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Ii)!==null}intersectTriangle(e,t,n,i,s){Sp.subVectors(t,e),Vh.subVectors(n,e),Ap.crossVectors(Sp,Vh);let o=this.direction.dot(Ap),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ns.subVectors(this.origin,e);let l=a*this.direction.dot(Vh.crossVectors(ns,Vh));if(l<0)return null;let c=a*this.direction.dot(Sp.cross(ns));if(c<0||l+c>o)return null;let h=-a*ns.dot(Ap);return h<0?null:this.at(h/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Oe=class{constructor(){this.isMatrix4=!0,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(e,t,n,i,s,o,a,l,c,h,u,d,f,m,p,g){let x=this.elements;return x[0]=e,x[4]=t,x[8]=n,x[12]=i,x[1]=s,x[5]=o,x[9]=a,x[13]=l,x[2]=c,x[6]=h,x[10]=u,x[14]=d,x[3]=f,x[7]=m,x[11]=p,x[15]=g,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 Oe().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,i=1/ko.setFromMatrixColumn(e,0).length(),s=1/ko.setFromMatrixColumn(e,1).length(),o=1/ko.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");let t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){let d=o*h,f=o*u,m=a*h,p=a*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=f+m*c,t[5]=d-p*c,t[9]=-a*l,t[2]=p-d*c,t[6]=m+f*c,t[10]=o*l}else if(e.order==="YXZ"){let d=l*h,f=l*u,m=c*h,p=c*u;t[0]=d+p*a,t[4]=m*a-f,t[8]=o*c,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=f*a-m,t[6]=p+d*a,t[10]=o*l}else if(e.order==="ZXY"){let d=l*h,f=l*u,m=c*h,p=c*u;t[0]=d-p*a,t[4]=-o*u,t[8]=m+f*a,t[1]=f+m*a,t[5]=o*h,t[9]=p-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let d=o*h,f=o*u,m=a*h,p=a*u;t[0]=l*h,t[4]=m*c-f,t[8]=d*c+p,t[1]=l*u,t[5]=p*c+d,t[9]=f*c-m,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let d=o*l,f=o*c,m=a*l,p=a*c;t[0]=l*h,t[4]=p-d*u,t[8]=m*u+f,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=f*u+m,t[10]=d-p*u}else if(e.order==="XZY"){let d=o*l,f=o*c,m=a*l,p=a*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+p,t[5]=o*h,t[9]=f*u-m,t[2]=m*u-f,t[6]=a*h,t[10]=p*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(W_,e,j_)}lookAt(e,t,n){let i=this.elements;return or.subVectors(e,t),or.lengthSq()===0&&(or.z=1),or.normalize(),rs.crossVectors(n,or),rs.lengthSq()===0&&(Math.abs(n.z)===1?or.x+=1e-4:or.z+=1e-4,or.normalize(),rs.crossVectors(n,or)),rs.normalize(),Hh.crossVectors(or,rs),i[0]=rs.x,i[4]=Hh.x,i[8]=or.x,i[1]=rs.y,i[5]=Hh.y,i[9]=or.y,i[2]=rs.z,i[6]=Hh.z,i[10]=or.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],p=n[6],g=n[10],x=n[14],v=n[3],w=n[7],b=n[11],S=n[15],M=i[0],_=i[4],y=i[8],T=i[12],E=i[1],C=i[5],L=i[9],R=i[13],N=i[2],H=i[6],j=i[10],K=i[14],Y=i[3],z=i[7],F=i[11],V=i[15];return s[0]=o*M+a*E+l*N+c*Y,s[4]=o*_+a*C+l*H+c*z,s[8]=o*y+a*L+l*j+c*F,s[12]=o*T+a*R+l*K+c*V,s[1]=h*M+u*E+d*N+f*Y,s[5]=h*_+u*C+d*H+f*z,s[9]=h*y+u*L+d*j+f*F,s[13]=h*T+u*R+d*K+f*V,s[2]=m*M+p*E+g*N+x*Y,s[6]=m*_+p*C+g*H+x*z,s[10]=m*y+p*L+g*j+x*F,s[14]=m*T+p*R+g*K+x*V,s[3]=v*M+w*E+b*N+S*Y,s[7]=v*_+w*C+b*H+S*z,s[11]=v*y+w*L+b*j+S*F,s[15]=v*T+w*R+b*K+S*V,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],f=e[14],m=e[3],p=e[7],g=e[11],x=e[15];return m*(+s*l*u-i*c*u-s*a*d+n*c*d+i*a*f-n*l*f)+p*(+t*l*f-t*c*d+s*o*d-i*o*f+i*c*h-s*l*h)+g*(+t*c*u-t*a*f-s*o*u+n*o*f+s*a*h-n*c*h)+x*(-i*a*h-t*l*u+t*a*d+i*o*u-n*o*d+n*l*h)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],f=e[11],m=e[12],p=e[13],g=e[14],x=e[15],v=u*g*c-p*d*c+p*l*f-a*g*f-u*l*x+a*d*x,w=m*d*c-h*g*c-m*l*f+o*g*f+h*l*x-o*d*x,b=h*p*c-m*u*c+m*a*f-o*p*f-h*a*x+o*u*x,S=m*u*l-h*p*l-m*a*d+o*p*d+h*a*g-o*u*g,M=t*v+n*w+i*b+s*S;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let _=1/M;return e[0]=v*_,e[1]=(p*d*s-u*g*s-p*i*f+n*g*f+u*i*x-n*d*x)*_,e[2]=(a*g*s-p*l*s+p*i*c-n*g*c-a*i*x+n*l*x)*_,e[3]=(u*l*s-a*d*s-u*i*c+n*d*c+a*i*f-n*l*f)*_,e[4]=w*_,e[5]=(h*g*s-m*d*s+m*i*f-t*g*f-h*i*x+t*d*x)*_,e[6]=(m*l*s-o*g*s-m*i*c+t*g*c+o*i*x-t*l*x)*_,e[7]=(o*d*s-h*l*s+h*i*c-t*d*c-o*i*f+t*l*f)*_,e[8]=b*_,e[9]=(m*u*s-h*p*s-m*n*f+t*p*f+h*n*x-t*u*x)*_,e[10]=(o*p*s-m*a*s+m*n*c-t*p*c-o*n*x+t*a*x)*_,e[11]=(h*a*s-o*u*s-h*n*c+t*u*c+o*n*f-t*a*f)*_,e[12]=S*_,e[13]=(h*p*i-m*u*i+m*n*d-t*p*d-h*n*g+t*u*g)*_,e[14]=(m*a*i-o*p*i-m*n*l+t*p*l+o*n*g-t*a*g)*_,e[15]=(o*u*i-h*a*i+h*n*l-t*u*l-o*n*d+t*a*d)*_,this}scale(e){let t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,h=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+n,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,h=o+o,u=a+a,d=s*c,f=s*h,m=s*u,p=o*h,g=o*u,x=a*u,v=l*c,w=l*h,b=l*u,S=n.x,M=n.y,_=n.z;return i[0]=(1-(p+x))*S,i[1]=(f+b)*S,i[2]=(m-w)*S,i[3]=0,i[4]=(f-b)*M,i[5]=(1-(d+x))*M,i[6]=(g+v)*M,i[7]=0,i[8]=(m+w)*_,i[9]=(g-v)*_,i[10]=(1-(d+p))*_,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,s=ko.set(i[0],i[1],i[2]).length(),o=ko.set(i[4],i[5],i[6]).length(),a=ko.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Ur.copy(this);let c=1/s,h=1/o,u=1/a;return Ur.elements[0]*=c,Ur.elements[1]*=c,Ur.elements[2]*=c,Ur.elements[4]*=h,Ur.elements[5]*=h,Ur.elements[6]*=h,Ur.elements[8]*=u,Ur.elements[9]*=u,Ur.elements[10]*=u,t.setFromRotationMatrix(Ur),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o){o===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let a=this.elements,l=2*s/(t-e),c=2*s/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=c,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,i,s,o){let a=this.elements,l=1/(t-e),c=1/(n-i),h=1/(o-s),u=(t+e)*l,d=(n+i)*c,f=(o+s)*h;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},ko=new A,Ur=new Oe,W_=new A(0,0,0),j_=new A(1,1,1),rs=new A,Hh=new A,or=new A,r0=new Oe,i0=new Xt,br=class{constructor(e=0,t=0,n=0,i=br.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(sn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-sn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(sn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-sn(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(sn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-sn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return r0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(r0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return i0.setFromEuler(this),this.setFromQuaternion(i0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}};br.DefaultOrder="XYZ";br.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var dc=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},q_=0,s0=new A,Vo=new Xt,Li=new Oe,Wh=new A,ec=new A,X_=new A,Y_=new Xt,o0=new A(1,0,0),a0=new A(0,1,0),l0=new A(0,0,1),Q_={type:"added"},c0={type:"removed"},ct=class extends Rt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:q_++}),this.uuid=ci(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ct.DefaultUp.clone();let e=new A,t=new br,n=new Xt,i=new A(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Oe},normalMatrix:{value:new qt}}),this.matrix=new Oe,this.matrixWorld=new Oe,this.matrixAutoUpdate=ct.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new dc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Vo.setFromAxisAngle(e,t),this.quaternion.multiply(Vo),this}rotateOnWorldAxis(e,t){return Vo.setFromAxisAngle(e,t),this.quaternion.premultiply(Vo),this}rotateX(e){return this.rotateOnAxis(o0,e)}rotateY(e){return this.rotateOnAxis(a0,e)}rotateZ(e){return this.rotateOnAxis(l0,e)}translateOnAxis(e,t){return s0.copy(e).applyQuaternion(this.quaternion),this.position.add(s0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(o0,e)}translateY(e){return this.translateOnAxis(a0,e)}translateZ(e){return this.translateOnAxis(l0,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(Li.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Wh.copy(e):Wh.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),ec.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Li.lookAt(ec,Wh,this.up):Li.lookAt(Wh,ec,this.up),this.quaternion.setFromRotationMatrix(Li),i&&(Li.extractRotation(i.matrixWorld),Vo.setFromRotationMatrix(Li),this.quaternion.premultiply(Vo.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Q_)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(c0)),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){let t=this.children[e];t.parent=null,t.dispatchEvent(c0)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Li.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Li.multiply(e.parent.matrixWorld)),e.applyMatrix4(Li),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ec,e,X_),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ec,Y_,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){let u=l[c];s(e.shapes,u)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),u=o(e.shapes),d=o(e.skeletons),f=o(e.animations),m=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}};ct.DefaultUp=new A(0,1,0);ct.DefaultMatrixAutoUpdate=!0;var zr=new A,Ni=new A,Mp=new A,Ri=new A,Ho=new A,Wo=new A,h0=new A,_p=new A,Tp=new A,Ep=new A,Kn=class{constructor(e=new A,t=new A,n=new A){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),zr.subVectors(e,t),i.cross(zr);let s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){zr.subVectors(i,t),Ni.subVectors(n,t),Mp.subVectors(e,t);let o=zr.dot(zr),a=zr.dot(Ni),l=zr.dot(Mp),c=Ni.dot(Ni),h=Ni.dot(Mp),u=o*c-a*a;if(u===0)return s.set(-2,-1,-1);let d=1/u,f=(c*l-a*h)*d,m=(o*h-a*l)*d;return s.set(1-f-m,m,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ri),Ri.x>=0&&Ri.y>=0&&Ri.x+Ri.y<=1}static getUV(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,Ri),l.set(0,0),l.addScaledVector(s,Ri.x),l.addScaledVector(o,Ri.y),l.addScaledVector(a,Ri.z),l}static isFrontFacing(e,t,n,i){return zr.subVectors(n,t),Ni.subVectors(e,t),zr.cross(Ni).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return zr.subVectors(this.c,this.b),Ni.subVectors(this.a,this.b),zr.cross(Ni).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Kn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Kn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return Kn.getUV(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return Kn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Kn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,s=this.c,o,a;Ho.subVectors(i,n),Wo.subVectors(s,n),_p.subVectors(e,n);let l=Ho.dot(_p),c=Wo.dot(_p);if(l<=0&&c<=0)return t.copy(n);Tp.subVectors(e,i);let h=Ho.dot(Tp),u=Wo.dot(Tp);if(h>=0&&u<=h)return t.copy(i);let d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector(Ho,o);Ep.subVectors(e,s);let f=Ho.dot(Ep),m=Wo.dot(Ep);if(m>=0&&f<=m)return t.copy(s);let p=f*c-l*m;if(p<=0&&c>=0&&m<=0)return a=c/(c-m),t.copy(n).addScaledVector(Wo,a);let g=h*m-f*u;if(g<=0&&u-h>=0&&f-m>=0)return h0.subVectors(s,i),a=(u-h)/(u-h+(f-m)),t.copy(i).addScaledVector(h0,a);let x=1/(g+p+d);return o=p*x,a=d*x,t.copy(n).addScaledVector(Ho,o).addScaledVector(Wo,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},K_=0,un=class extends Rt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:K_++}),this.uuid=ci(),this.name="",this.type="Material",this.blending=ls,this.side=zi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=$0,this.blendDst=ex,this.blendEquation=Zo,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Wp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=M_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fp,this.stencilZFail=fp,this.stencilZPass=fp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===LM;continue}let i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ls&&(n.blending=this.blending),this.side!==zi&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}get vertexTangents(){return console.warn("THREE."+this.type+": .vertexTangents has been removed."),!1}set vertexTangents(e){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}};un.fromType=function(){return null};var hi=class extends un{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ou,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},rn=new A,jh=new B,Xe=class{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n===!0,this.usage=Yp,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),o=new Ae),t[n++]=o.r,t[n++]=o.g,t[n++]=o.b}return this}copyVector2sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),o=new B),t[n++]=o.x,t[n++]=o.y}return this}copyVector3sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),o=new A),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z}return this}copyVector4sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),o=new qe),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z,t[n++]=o.w}return this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)jh.fromBufferAttribute(this,t),jh.applyMatrix3(e),this.setXY(t,jh.x,jh.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)rn.fromBufferAttribute(this,t),rn.applyMatrix3(e),this.setXYZ(t,rn.x,rn.y,rn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)rn.fromBufferAttribute(this,t),rn.applyMatrix4(e),this.setXYZ(t,rn.x,rn.y,rn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)rn.fromBufferAttribute(this,t),rn.applyNormalMatrix(e),this.setXYZ(t,rn.x,rn.y,rn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)rn.fromBufferAttribute(this,t),rn.transformDirection(e),this.setXYZ(t,rn.x,rn.y,rn.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Yp&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}};var yu=class extends Xe{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var ps=class extends Xe{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Se=class extends Xe{constructor(e,t,n){super(new Float32Array(e),t,n)}};var Z_=0,yr=new Oe,Cp=new ct,jo=new A,ar=new Sn,tc=new Sn,xn=new A,Ie=class extends Rt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Z_++}),this.uuid=ci(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(rx(e)?ps:yu)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new qt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return yr.makeRotationFromQuaternion(e),this.applyMatrix4(yr),this}rotateX(e){return yr.makeRotationX(e),this.applyMatrix4(yr),this}rotateY(e){return yr.makeRotationY(e),this.applyMatrix4(yr),this}rotateZ(e){return yr.makeRotationZ(e),this.applyMatrix4(yr),this}translate(e,t,n){return yr.makeTranslation(e,t,n),this.applyMatrix4(yr),this}scale(e,t,n){return yr.makeScale(e,t,n),this.applyMatrix4(yr),this}lookAt(e){return Cp.lookAt(e),Cp.updateMatrix(),this.applyMatrix4(Cp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(jo).negate(),this.translate(jo.x,jo.y,jo.z),this}setFromPoints(e){let t=[];for(let n=0,i=e.length;n<i;n++){let s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Se(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Sn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new A(-1/0,-1/0,-1/0),new A(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let s=t[n];ar.setFromBufferAttribute(s),this.morphTargetsRelative?(xn.addVectors(this.boundingBox.min,ar.min),this.boundingBox.expandByPoint(xn),xn.addVectors(this.boundingBox.max,ar.max),this.boundingBox.expandByPoint(xn)):(this.boundingBox.expandByPoint(ar.min),this.boundingBox.expandByPoint(ar.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Rn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new A,1/0);return}if(e){let n=this.boundingSphere.center;if(ar.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];tc.setFromBufferAttribute(a),this.morphTargetsRelative?(xn.addVectors(ar.min,tc.min),ar.expandByPoint(xn),xn.addVectors(ar.max,tc.max),ar.expandByPoint(xn)):(ar.expandByPoint(tc.min),ar.expandByPoint(tc.max))}ar.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)xn.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(xn));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)xn.fromBufferAttribute(a,c),l&&(jo.fromBufferAttribute(e,c),xn.add(jo)),i=Math.max(i,n.distanceToSquared(xn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.array,i=t.position.array,s=t.normal.array,o=t.uv.array,a=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Xe(new Float32Array(4*a),4));let l=this.getAttribute("tangent").array,c=[],h=[];for(let E=0;E<a;E++)c[E]=new A,h[E]=new A;let u=new A,d=new A,f=new A,m=new B,p=new B,g=new B,x=new A,v=new A;function w(E,C,L){u.fromArray(i,E*3),d.fromArray(i,C*3),f.fromArray(i,L*3),m.fromArray(o,E*2),p.fromArray(o,C*2),g.fromArray(o,L*2),d.sub(u),f.sub(u),p.sub(m),g.sub(m);let R=1/(p.x*g.y-g.x*p.y);!isFinite(R)||(x.copy(d).multiplyScalar(g.y).addScaledVector(f,-p.y).multiplyScalar(R),v.copy(f).multiplyScalar(p.x).addScaledVector(d,-g.x).multiplyScalar(R),c[E].add(x),c[C].add(x),c[L].add(x),h[E].add(v),h[C].add(v),h[L].add(v))}let b=this.groups;b.length===0&&(b=[{start:0,count:n.length}]);for(let E=0,C=b.length;E<C;++E){let L=b[E],R=L.start,N=L.count;for(let H=R,j=R+N;H<j;H+=3)w(n[H+0],n[H+1],n[H+2])}let S=new A,M=new A,_=new A,y=new A;function T(E){_.fromArray(s,E*3),y.copy(_);let C=c[E];S.copy(C),S.sub(_.multiplyScalar(_.dot(C))).normalize(),M.crossVectors(y,C);let R=M.dot(h[E])<0?-1:1;l[E*4]=S.x,l[E*4+1]=S.y,l[E*4+2]=S.z,l[E*4+3]=R}for(let E=0,C=b.length;E<C;++E){let L=b[E],R=L.start,N=L.count;for(let H=R,j=R+N;H<j;H+=3)T(n[H+0]),T(n[H+1]),T(n[H+2])}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Xe(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);let i=new A,s=new A,o=new A,a=new A,l=new A,c=new A,h=new A,u=new A;if(e)for(let d=0,f=e.count;d<f;d+=3){let m=e.getX(d+0),p=e.getX(d+1),g=e.getX(d+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,p),o.fromBufferAttribute(t,g),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),a.fromBufferAttribute(n,m),l.fromBufferAttribute(n,p),c.fromBufferAttribute(n,g),a.add(h),l.add(h),c.add(h),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(p,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(e,t){if(!(e&&e.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);return}t===void 0&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));let n=this.attributes;for(let i in n){if(e.attributes[i]===void 0)continue;let o=n[i].array,a=e.attributes[i],l=a.array,c=a.itemSize*t,h=Math.min(l.length,o.length-c);for(let u=0,d=c;u<h;u++,d++)o[d]=l[u]}return this}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)xn.fromBufferAttribute(e,t),xn.normalize(),e.setXYZ(t,xn.x,xn.y,xn.z)}toNonIndexed(){function e(a,l){let c=a.array,h=a.itemSize,u=a.normalized,d=new c.constructor(l.length*h),f=0,m=0;for(let p=0,g=l.length;p<g;p++){a.isInterleavedBufferAttribute?f=l[p]*a.data.stride+a.offset:f=l[p]*h;for(let x=0;x<h;x++)d[m++]=c[f++]}return new Xe(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new Ie,n=this.index.array,i=this.attributes;for(let a in i){let l=i[a],c=e(l,n);t.setAttribute(a,c)}let s=this.morphAttributes;for(let a in s){let l=[],c=s[a];for(let h=0,u=c.length;h<u;h++){let d=c[h],f=e(d,n);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let i={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){let f=c[u];h.push(f.toJSON(e.data))}h.length>0&&(i[l]=h,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let i=e.attributes;for(let c in i){let h=i[c];this.setAttribute(c,h.clone(t))}let s=e.morphAttributes;for(let c in s){let h=[],u=s[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,h=o.length;c<h;c++){let u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,e.parameters!==void 0&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}},u0=new Oe,qo=new ro,Dp=new Rn,is=new A,ss=new A,os=new A,Pp=new A,Ip=new A,Lp=new A,qh=new A,Xh=new A,Yh=new A,Qh=new B,Kh=new B,Zh=new B,Np=new A,Jh=new A,Vt=class extends ct{constructor(e=new Ie,t=new hi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}raycast(e,t){let n=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0||(n.boundingSphere===null&&n.computeBoundingSphere(),Dp.copy(n.boundingSphere),Dp.applyMatrix4(s),e.ray.intersectsSphere(Dp)===!1)||(u0.copy(s).invert(),qo.copy(e.ray).applyMatrix4(u0),n.boundingBox!==null&&qo.intersectsBox(n.boundingBox)===!1))return;let o,a=n.index,l=n.attributes.position,c=n.morphAttributes.position,h=n.morphTargetsRelative,u=n.attributes.uv,d=n.attributes.uv2,f=n.groups,m=n.drawRange;if(a!==null)if(Array.isArray(i))for(let p=0,g=f.length;p<g;p++){let x=f[p],v=i[x.materialIndex],w=Math.max(x.start,m.start),b=Math.min(a.count,Math.min(x.start+x.count,m.start+m.count));for(let S=w,M=b;S<M;S+=3){let _=a.getX(S),y=a.getX(S+1),T=a.getX(S+2);o=$h(this,v,e,qo,l,c,h,u,d,_,y,T),o&&(o.faceIndex=Math.floor(S/3),o.face.materialIndex=x.materialIndex,t.push(o))}}else{let p=Math.max(0,m.start),g=Math.min(a.count,m.start+m.count);for(let x=p,v=g;x<v;x+=3){let w=a.getX(x),b=a.getX(x+1),S=a.getX(x+2);o=$h(this,i,e,qo,l,c,h,u,d,w,b,S),o&&(o.faceIndex=Math.floor(x/3),t.push(o))}}else if(l!==void 0)if(Array.isArray(i))for(let p=0,g=f.length;p<g;p++){let x=f[p],v=i[x.materialIndex],w=Math.max(x.start,m.start),b=Math.min(l.count,Math.min(x.start+x.count,m.start+m.count));for(let S=w,M=b;S<M;S+=3){let _=S,y=S+1,T=S+2;o=$h(this,v,e,qo,l,c,h,u,d,_,y,T),o&&(o.faceIndex=Math.floor(S/3),o.face.materialIndex=x.materialIndex,t.push(o))}}else{let p=Math.max(0,m.start),g=Math.min(l.count,m.start+m.count);for(let x=p,v=g;x<v;x+=3){let w=x,b=x+1,S=x+2;o=$h(this,i,e,qo,l,c,h,u,d,w,b,S),o&&(o.faceIndex=Math.floor(x/3),t.push(o))}}}};function J_(r,e,t,n,i,s,o,a){let l;if(e.side===wn?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,e.side!==hn,a),l===null)return null;Jh.copy(a),Jh.applyMatrix4(r.matrixWorld);let c=t.ray.origin.distanceTo(Jh);return c<t.near||c>t.far?null:{distance:c,point:Jh.clone(),object:r}}function $h(r,e,t,n,i,s,o,a,l,c,h,u){is.fromBufferAttribute(i,c),ss.fromBufferAttribute(i,h),os.fromBufferAttribute(i,u);let d=r.morphTargetInfluences;if(s&&d){qh.set(0,0,0),Xh.set(0,0,0),Yh.set(0,0,0);for(let m=0,p=s.length;m<p;m++){let g=d[m],x=s[m];g!==0&&(Pp.fromBufferAttribute(x,c),Ip.fromBufferAttribute(x,h),Lp.fromBufferAttribute(x,u),o?(qh.addScaledVector(Pp,g),Xh.addScaledVector(Ip,g),Yh.addScaledVector(Lp,g)):(qh.addScaledVector(Pp.sub(is),g),Xh.addScaledVector(Ip.sub(ss),g),Yh.addScaledVector(Lp.sub(os),g)))}is.add(qh),ss.add(Xh),os.add(Yh)}r.isSkinnedMesh&&(r.boneTransform(c,is),r.boneTransform(h,ss),r.boneTransform(u,os));let f=J_(r,e,t,n,is,ss,os,Np);if(f){a&&(Qh.fromBufferAttribute(a,c),Kh.fromBufferAttribute(a,h),Zh.fromBufferAttribute(a,u),f.uv=Kn.getUV(Np,is,ss,os,Qh,Kh,Zh,new B)),l&&(Qh.fromBufferAttribute(l,c),Kh.fromBufferAttribute(l,h),Zh.fromBufferAttribute(l,u),f.uv2=Kn.getUV(Np,is,ss,os,Qh,Kh,Zh,new B));let m={a:c,b:h,c:u,normal:new A,materialIndex:0};Kn.getNormal(is,ss,os,m.normal),f.face=m}return f}var Zn=class extends Ie{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};let a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],h=[],u=[],d=0,f=0;m("z","y","x",-1,-1,n,t,e,o,s,0),m("z","y","x",1,-1,n,t,-e,o,s,1),m("x","z","y",1,1,e,n,t,i,o,2),m("x","z","y",1,-1,e,n,-t,i,o,3),m("x","y","z",1,-1,e,t,n,i,s,4),m("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new Se(c,3)),this.setAttribute("normal",new Se(h,3)),this.setAttribute("uv",new Se(u,2));function m(p,g,x,v,w,b,S,M,_,y,T){let E=b/_,C=S/y,L=b/2,R=S/2,N=M/2,H=_+1,j=y+1,K=0,Y=0,z=new A;for(let F=0;F<j;F++){let V=F*C-R;for(let O=0;O<H;O++){let G=O*E-L;z[p]=G*v,z[g]=V*w,z[x]=N,c.push(z.x,z.y,z.z),z[p]=0,z[g]=0,z[x]=M>0?1:-1,h.push(z.x,z.y,z.z),u.push(O/_),u.push(1-F/y),K+=1}}for(let F=0;F<y;F++)for(let V=0;V<_;V++){let O=d+V+H*F,G=d+V+H*(F+1),W=d+(V+1)+H*(F+1),X=d+(V+1)+H*F;l.push(O,G,X),l.push(G,W,X),Y+=6}a.addGroup(f,Y,T),f+=Y,d+=K}}static fromJSON(e){return new Zn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function na(r){let e={};for(let t in r){e[t]={};for(let n in r[t]){let i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Nn(r){let e={};for(let t=0;t<r.length;t++){let n=na(r[t]);for(let i in n)e[i]=n[i]}return e}var Wr={clone:na,merge:Nn},$_=`void main() {
|
|
1
|
+
var wM=Object.create;var ap=Object.defineProperty;var SM=Object.getOwnPropertyDescriptor;var AM=Object.getOwnPropertyNames;var MM=Object.getPrototypeOf,_M=Object.prototype.hasOwnProperty;var TM=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),EM=(r,e)=>{for(var t in e)ap(r,t,{get:e[t],enumerable:!0})},CM=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of AM(e))!_M.call(r,i)&&i!==t&&ap(r,i,{get:()=>e[i],enumerable:!(n=SM(e,i))||n.enumerable});return r};var DM=(r,e,t)=>(t=r!=null?wM(MM(r)):{},CM(e||!r||!r.__esModule?ap(t,"default",{value:r,enumerable:!0}):t,r));var PA=TM((Hf,DA)=>{(function(r,e){typeof Hf=="object"&&typeof DA<"u"?e(Hf):typeof define=="function"&&define.amd?define(["exports"],e):e((r=typeof globalThis<"u"?globalThis:r||self).SVDJS={})})(Hf,function(r){"use strict";r.SVD=function(e,t,n,i,s){if(t=t===void 0||t,n=n===void 0||n,s=1e-64/(i=i||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var o,a,l,c,h,u,d,f,m,p,g,x,v=e[0].length,w=e.length;if(w<v)throw new TypeError("Invalid matrix: m < n");for(var b=[],S=[],M=[],_=t==="f"?w:v,y=p=d=0;y<w;y++)S[y]=new Array(_).fill(0);for(y=0;y<v;y++)M[y]=new Array(v).fill(0);var T,E=new Array(v).fill(0);for(y=0;y<w;y++)for(o=0;o<v;o++)S[y][o]=e[y][o];for(y=0;y<v;y++){for(b[y]=d,m=0,l=y+1,o=y;o<w;o++)m+=Math.pow(S[o][y],2);if(m<s)d=0;else for(f=(u=S[y][y])*(d=u<0?Math.sqrt(m):-Math.sqrt(m))-m,S[y][y]=u-d,o=l;o<v;o++){for(m=0,a=y;a<w;a++)m+=S[a][y]*S[a][o];for(u=m/f,a=y;a<w;a++)S[a][o]=S[a][o]+u*S[a][y]}for(E[y]=d,m=0,o=l;o<v;o++)m+=Math.pow(S[y][o],2);if(m<s)d=0;else{for(f=(u=S[y][y+1])*(d=u<0?Math.sqrt(m):-Math.sqrt(m))-m,S[y][y+1]=u-d,o=l;o<v;o++)b[o]=S[y][o]/f;for(o=l;o<w;o++){for(m=0,a=l;a<v;a++)m+=S[o][a]*S[y][a];for(a=l;a<v;a++)S[o][a]=S[o][a]+m*b[a]}}p<(g=Math.abs(E[y])+Math.abs(b[y]))&&(p=g)}if(n)for(y=v-1;0<=y;y--){if(d!==0){for(f=S[y][y+1]*d,o=l;o<v;o++)M[o][y]=S[y][o]/f;for(o=l;o<v;o++){for(m=0,a=l;a<v;a++)m+=S[y][a]*M[a][o];for(a=l;a<v;a++)M[a][o]=M[a][o]+m*M[a][y]}}for(o=l;o<v;o++)M[y][o]=0,M[o][y]=0;M[y][y]=1,d=b[y],l=y}if(t){if(t==="f")for(y=v;y<w;y++){for(o=v;o<w;o++)S[y][o]=0;S[y][y]=1}for(y=v-1;0<=y;y--){for(l=y+1,d=E[y],o=l;o<_;o++)S[y][o]=0;if(d!==0){for(f=S[y][y]*d,o=l;o<_;o++){for(m=0,a=l;a<w;a++)m+=S[a][y]*S[a][o];for(u=m/f,a=y;a<w;a++)S[a][o]=S[a][o]+u*S[a][y]}for(o=y;o<w;o++)S[o][y]=S[o][y]/d}else for(o=y;o<w;o++)S[o][y]=0;S[y][y]=S[y][y]+1}}for(i*=p,a=v-1;0<=a;a--)for(var C=0;C<50;C++){for(T=!1,l=a;0<=l;l--){if(Math.abs(b[l])<=i){T=!0;break}if(Math.abs(E[l-1])<=i)break}if(!T){for(h=0,c=l-(m=1),y=l;y<a+1&&(u=m*b[y],b[y]=h*b[y],!(Math.abs(u)<=i));y++)if(d=E[y],E[y]=Math.sqrt(u*u+d*d),h=d/(f=E[y]),m=-u/f,t)for(o=0;o<w;o++)g=S[o][c],x=S[o][y],S[o][c]=g*h+x*m,S[o][y]=-g*m+x*h}if(x=E[a],l===a){if(x<0&&(E[a]=-x,n))for(o=0;o<v;o++)M[o][a]=-M[o][a];break}for(p=E[l],u=(((g=E[a-1])-x)*(g+x)+((d=b[a-1])-(f=b[a]))*(d+f))/(2*f*g),d=Math.sqrt(u*u+1),u=((p-x)*(p+x)+f*(g/(u<0?u-d:u+d)-f))/p,y=l+(m=h=1);y<a+1;y++){if(d=b[y],g=E[y],f=m*d,d*=h,x=Math.sqrt(u*u+f*f),u=p*(h=u/(b[y-1]=x))+d*(m=f/x),d=-p*m+d*h,f=g*m,g*=h,n)for(o=0;o<v;o++)p=M[o][y-1],x=M[o][y],M[o][y-1]=p*h+x*m,M[o][y]=-p*m+x*h;if(x=Math.sqrt(u*u+f*f),u=(h=u/(E[y-1]=x))*d+(m=f/x)*g,p=-m*d+h*g,t)for(o=0;o<w;o++)g=S[o][y-1],x=S[o][y],S[o][y-1]=g*h+x*m,S[o][y]=-g*m+x*h}b[l]=0,b[a]=u,E[a]=p}for(y=0;y<v;y++)E[y]<i&&(E[y]=0);return{u:S,q:E,v:M}},r.VERSION="1.1.1",Object.defineProperty(r,"__esModule",{value:!0})})});var mo="141";var cr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},PM=0,wv=1,LM=2;var Bu=1,km=2,rc=3,zi=0,wn=1,hn=2,IM=1;var Ct=0,ls=1,Sv=2,Av=3,Mv=4,NM=5,Zo=100,RM=101,BM=102,_v=103,Tv=104,OM=200,FM=201,UM=202,zM=203,$0=204,ex=205,GM=206,kM=207,VM=208,HM=209,WM=210,jM=0,qM=1,XM=2,Wp=3,YM=4,QM=5,KM=6,ZM=7,Ou=0,JM=1,$M=2,Ui=0,e_=1,t_=2,n_=3,r_=4,i_=5,tx=300,us=301,ds=302,jp=303,qp=304,ya=306,ta=1e3,bn=1001,Xp=1002,Gt=1003,Ev=1004;var Cv=1005;var tt=1006,s_=1007;var xs=1008;var Lt=1009,o_=1010,a_=1011,nx=1012,l_=1013,Fi=1014,vr=1015,hc=1016,c_=1017,h_=1018,cs=1020,u_=1021,d_=1022,xr=1023,f_=1024,p_=1025,to=1026,fs=1027,m_=1028,g_=1029,y_=1030,v_=1031,x_=1033,lp=33776,cp=33777,hp=33778,up=33779,Dv=35840,Pv=35841,Lv=35842,Iv=35843,b_=36196,Nv=37492,Rv=37496,Bv=37808,Ov=37809,Fv=37810,Uv=37811,zv=37812,Gv=37813,kv=37814,Vv=37815,Hv=37816,Wv=37817,jv=37818,qv=37819,Xv=37820,Yv=37821,Qv=36492;var hu=2300,uu=2301,dp=2302,Kv=2400,Zv=2401,Jv=2402;var w_=2501;var lr=3e3,We=3001,An=3200,S_=3201,va=0,A_=1;var Oi="srgb",eo="srgb-linear";var fp=7680;var M_=519,Yp=35044;var $v="300 es",Qp=1035,Rt=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let i=this._listeners[e];if(i!==void 0){let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}},Cn=[];for(let r=0;r<256;r++)Cn[r]=(r<16?"0":"")+r.toString(16);var e0=1234567,sc=Math.PI/180,uc=180/Math.PI;function ci(){let r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Cn[r&255]+Cn[r>>8&255]+Cn[r>>16&255]+Cn[r>>24&255]+"-"+Cn[e&255]+Cn[e>>8&255]+"-"+Cn[e>>16&15|64]+Cn[e>>24&255]+"-"+Cn[t&63|128]+Cn[t>>8&255]+"-"+Cn[t>>16&255]+Cn[t>>24&255]+Cn[n&255]+Cn[n>>8&255]+Cn[n>>16&255]+Cn[n>>24&255]).toLowerCase()}function sn(r,e,t){return Math.max(e,Math.min(t,r))}function Vm(r,e){return(r%e+e)%e}function __(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function T_(r,e,t){return r!==e?(t-r)/(e-r):0}function oc(r,e,t){return(1-t)*r+t*e}function E_(r,e,t,n){return oc(r,e,1-Math.exp(-t*n))}function C_(r,e=1){return e-Math.abs(Vm(r,e*2)-e)}function D_(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function P_(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function L_(r,e){return r+Math.floor(Math.random()*(e-r+1))}function I_(r,e){return r+Math.random()*(e-r)}function N_(r){return r*(.5-Math.random())}function R_(r){r!==void 0&&(e0=r);let e=e0+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function B_(r){return r*sc}function O_(r){return r*uc}function Kp(r){return(r&r-1)===0&&r!==0}function F_(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function du(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function U_(r,e,t,n,i){let s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),h=o((e+n)/2),u=s((e-n)/2),d=o((e-n)/2),f=s((n-e)/2),m=o((n-e)/2);switch(i){case"XYX":r.set(a*h,l*u,l*d,a*c);break;case"YZY":r.set(l*d,a*h,l*u,a*c);break;case"ZXZ":r.set(l*u,l*d,a*h,a*c);break;case"XZX":r.set(a*h,l*m,l*f,a*c);break;case"YXY":r.set(l*f,a*h,l*m,a*c);break;case"ZYZ":r.set(l*m,l*f,a*h,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function z_(r,e){switch(e.constructor){case Float32Array:return r;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function G_(r,e){switch(e.constructor){case Float32Array:return r;case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}var Ge=Object.freeze({__proto__:null,DEG2RAD:sc,RAD2DEG:uc,generateUUID:ci,clamp:sn,euclideanModulo:Vm,mapLinear:__,inverseLerp:T_,lerp:oc,damp:E_,pingpong:C_,smoothstep:D_,smootherstep:P_,randInt:L_,randFloat:I_,randFloatSpread:N_,seededRandom:R_,degToRad:B_,radToDeg:O_,isPowerOfTwo:Kp,ceilPowerOfTwo:F_,floorPowerOfTwo:du,setQuaternionFromProperEuler:U_,normalize:G_,denormalize:z_}),B=class{constructor(e=0,t=0){this.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},qt=class{constructor(){this.isMatrix3=!0,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(e,t,n,i,s,o,a,l,c){let h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],p=i[0],g=i[3],x=i[6],v=i[1],w=i[4],b=i[7],S=i[2],M=i[5],_=i[8];return s[0]=o*p+a*v+l*S,s[3]=o*g+a*w+l*M,s[6]=o*x+a*b+l*_,s[1]=c*p+h*v+u*S,s[4]=c*g+h*w+u*M,s[7]=c*x+h*b+u*_,s[2]=d*p+f*v+m*S,s[5]=d*g+f*w+m*M,s[8]=d*x+f*b+m*_,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-n*s*h+n*a*l+i*s*c-i*o*l}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=h*o-a*c,d=a*l-h*s,f=c*s-o*l,m=t*u+n*d+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let p=1/m;return e[0]=u*p,e[1]=(i*c-h*n)*p,e[2]=(a*n-i*o)*p,e[3]=d*p,e[4]=(h*t-i*l)*p,e[5]=(i*s-a*t)*p,e[6]=f*p,e[7]=(n*l-c*t)*p,e[8]=(o*t-n*s)*p,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){let n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),i=this.elements,s=i[0],o=i[3],a=i[6],l=i[1],c=i[4],h=i[7];return i[0]=t*s+n*l,i[3]=t*o+n*c,i[6]=t*a+n*h,i[1]=-n*s+t*l,i[4]=-n*o+t*c,i[7]=-n*a+t*h,this}translate(e,t){let n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};function rx(r){for(let e=r.length-1;e>=0;--e)if(r[e]>65535)return!0;return!1}var k_={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Bh(r,e){return new k_[r](e)}function fu(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function no(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function cu(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}var pp={[Oi]:{[eo]:no},[eo]:{[Oi]:cu}},Or={legacyMode:!0,get workingColorSpace(){return eo},set workingColorSpace(r){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(r,e,t){if(this.legacyMode||e===t||!e||!t)return r;if(pp[e]&&pp[e][t]!==void 0){let n=pp[e][t];return r.r=n(r.r),r.g=n(r.g),r.b=n(r.b),r}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(r,e){return this.convert(r,this.workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this.workingColorSpace)}},ix={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ln={r:0,g:0,b:0},Fr={h:0,s:0,l:0},Oh={h:0,s:0,l:0};function mp(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}function Fh(r,e){return e.r=r.r,e.g=r.g,e.b=r.b,e}var Ae=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Oi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Or.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=eo){return this.r=e,this.g=t,this.b=n,Or.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=eo){if(e=Vm(e,1),t=sn(t,0,1),n=sn(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=mp(o,s,e+1/3),this.g=mp(o,s,e),this.b=mp(o,s,e-1/3)}return Or.toWorkingColorSpace(this,i),this}setStyle(e,t=Oi){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,Or.toWorkingColorSpace(this,t),n(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,Or.toWorkingColorSpace(this,t),n(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){let l=parseFloat(s[1])/360,c=parseInt(s[2],10)/100,h=parseInt(s[3],10)/100;return n(s[4]),this.setHSL(l,c,h,t)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=i[1],o=s.length;if(o===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,Or.toWorkingColorSpace(this,t),this;if(o===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,Or.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Oi){let n=ix[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=no(e.r),this.g=no(e.g),this.b=no(e.b),this}copyLinearToSRGB(e){return this.r=cu(e.r),this.g=cu(e.g),this.b=cu(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Oi){return Or.fromWorkingColorSpace(Fh(this,ln),e),sn(ln.r*255,0,255)<<16^sn(ln.g*255,0,255)<<8^sn(ln.b*255,0,255)<<0}getHexString(e=Oi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=eo){Or.fromWorkingColorSpace(Fh(this,ln),t);let n=ln.r,i=ln.g,s=ln.b,o=Math.max(n,i,s),a=Math.min(n,i,s),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let u=o-a;switch(c=h<=.5?u/(o+a):u/(2-o-a),o){case n:l=(i-s)/u+(i<s?6:0);break;case i:l=(s-n)/u+2;break;case s:l=(n-i)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=eo){return Or.fromWorkingColorSpace(Fh(this,ln),t),e.r=ln.r,e.g=ln.g,e.b=ln.b,e}getStyle(e=Oi){return Or.fromWorkingColorSpace(Fh(this,ln),e),e!==Oi?`color(${e} ${ln.r} ${ln.g} ${ln.b})`:`rgb(${ln.r*255|0},${ln.g*255|0},${ln.b*255|0})`}offsetHSL(e,t,n){return this.getHSL(Fr),Fr.h+=e,Fr.s+=t,Fr.l+=n,this.setHSL(Fr.h,Fr.s,Fr.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Fr),e.getHSL(Oh);let n=oc(Fr.h,Oh.h,t),i=oc(Fr.s,Oh.s,t),s=oc(Fr.l,Oh.l,t);return this.setHSL(n,i,s),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};Ae.NAMES=ix;var Fo,pu=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Fo===void 0&&(Fo=fu("canvas")),Fo.width=e.width,Fo.height=e.height;let n=Fo.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Fo}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=fu("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=no(s[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(no(t[n]/255)*255):t[n]=no(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},mu=class{constructor(e=null){this.isSource=!0,this.uuid=ci(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(gp(i[o].image)):s.push(gp(i[o]))}else s=gp(i);n.url=s}return t||(e.images[this.uuid]=n),n}};function gp(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?pu.getDataURL(r):r.data?{data:Array.prototype.slice.call(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var V_=0,Bt=class extends Rt{constructor(e=Bt.DEFAULT_IMAGE,t=Bt.DEFAULT_MAPPING,n=bn,i=bn,s=tt,o=xs,a=xr,l=Lt,c=1,h=lr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:V_++}),this.uuid=ci(),this.name="",this.source=new mu(e),this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new B(0,0),this.repeat=new B(1,1),this.center=new B(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new qt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e){this.source.data=e}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(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,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};return JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==tx)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ta:e.x=e.x-Math.floor(e.x);break;case bn:e.x=e.x<0?0:1;break;case Xp:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case ta:e.y=e.y-Math.floor(e.y);break;case bn:e.y=e.y<0?0:1;break;case Xp:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}};Bt.DEFAULT_IMAGE=null;Bt.DEFAULT_MAPPING=tx;var qe=class{constructor(e=0,t=0,n=0,i=1){this.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s,l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],m=l[9],p=l[2],g=l[6],x=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-p)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+p)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let w=(c+1)/2,b=(f+1)/2,S=(x+1)/2,M=(h+d)/4,_=(u+p)/4,y=(m+g)/4;return w>b&&w>S?w<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(w),i=M/n,s=_/n):b>S?b<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(b),n=M/i,s=y/i):S<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(S),n=_/s,i=y/s),this.set(n,i,s,t),this}let v=Math.sqrt((g-m)*(g-m)+(u-p)*(u-p)+(d-h)*(d-h));return Math.abs(v)<.001&&(v=1),this.x=(g-m)/v,this.y=(u-p)/v,this.z=(d-h)/v,this.w=Math.acos((c+f+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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}},lt=class extends Rt{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new qe(0,0,e,t),this.scissorTest=!1,this.viewport=new qe(0,0,e,t);let i={width:e,height:t,depth:1};this.texture=new Bt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:tt,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new mu(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},gu=class extends Bt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Gt,this.minFilter=Gt,this.wrapR=bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Zp=class extends Bt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Gt,this.minFilter=Gt,this.wrapR=bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Xt=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerp(e,t,n,i){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),n.slerpQuaternions(e,t,i)}static slerpFlat(e,t,n,i,s,o,a){let l=n[i+0],c=n[i+1],h=n[i+2],u=n[i+3],d=s[o+0],f=s[o+1],m=s[o+2],p=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(a===1){e[t+0]=d,e[t+1]=f,e[t+2]=m,e[t+3]=p;return}if(u!==p||l!==d||c!==f||h!==m){let g=1-a,x=l*d+c*f+h*m+u*p,v=x>=0?1:-1,w=1-x*x;if(w>Number.EPSILON){let S=Math.sqrt(w),M=Math.atan2(S,x*v);g=Math.sin(g*M)/S,a=Math.sin(a*M)/S}let b=a*v;if(l=l*g+d*b,c=c*g+f*b,h=h*g+m*b,u=u*g+p*b,g===1-a){let S=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=S,c*=S,h*=S,u*=S}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,s,o){let a=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[o],d=s[o+1],f=s[o+2],m=s[o+3];return e[t]=a*m+h*u+l*f-c*d,e[t+1]=l*m+h*d+c*u-a*f,e[t+2]=c*m+h*f+a*d-l*u,e[t+3]=h*m-a*u-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");let n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(i/2),u=a(s/2),d=l(n/2),f=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"YZX":this._x=d*h*u+c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u-d*f*m;break;case"XZY":this._x=d*h*u-c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],u=t[10],d=n+a+u;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(o-i)*f}else if(n>a&&n>u){let f=2*Math.sqrt(1+n-a-u);this._w=(h-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+c)/f}else if(a>u){let f=2*Math.sqrt(1+a-n-u);this._w=(s-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+u-n-a);this._w=(o-i)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(sn(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return t!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-n*c,this._z=s*h+o*c+n*l-i*a,this._w=o*h-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,i=this._y,s=this._z,o=this._w,a=o*e._w+n*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let f=1-t;return this._w=f*o+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(l),h=Math.atan2(c,a),u=Math.sin((1-t)*h)/c,d=Math.sin(t*h)/c;return this._w=o*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},A=class{constructor(e=0,t=0,n=0){this.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(t0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(t0.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=l*t+o*i-a*n,h=l*n+a*t-s*i,u=l*i+s*n-o*t,d=-s*t-o*n-a*i;return this.x=c*l+d*-s+h*-a-u*-o,this.y=h*l+d*-o+u*-s-c*-a,this.z=u*l+d*-a+c*-o-h*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return t!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return yp.copy(this).projectOnVector(e),this.sub(yp)}reflect(e){return this.sub(yp.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(sn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},yp=new A,t0=new Xt,Sn=class{constructor(e=new A(1/0,1/0,1/0),t=new A(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=e.length;l<c;l+=3){let h=e[l],u=e[l+1],d=e[l+2];h<t&&(t=h),u<n&&(n=u),d<i&&(i=d),h>s&&(s=h),u>o&&(o=u),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=e.count;l<c;l++){let h=e.getX(l),u=e.getY(l),d=e.getZ(l);h<t&&(t=h),u<n&&(n=u),d<i&&(i=d),h>s&&(s=h),u>o&&(o=u),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Qs.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0)if(t&&n.attributes!=null&&n.attributes.position!==void 0){let s=n.attributes.position;for(let o=0,a=s.count;o<a;o++)Qs.fromBufferAttribute(s,o).applyMatrix4(e.matrixWorld),this.expandByPoint(Qs)}else n.boundingBox===null&&n.computeBoundingBox(),vp.copy(n.boundingBox),vp.applyMatrix4(e.matrixWorld),this.union(vp);let i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Qs),Qs.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter($l),Uh.subVectors(this.max,$l),Uo.subVectors(e.a,$l),zo.subVectors(e.b,$l),Go.subVectors(e.c,$l),es.subVectors(zo,Uo),ts.subVectors(Go,zo),Ks.subVectors(Uo,Go);let t=[0,-es.z,es.y,0,-ts.z,ts.y,0,-Ks.z,Ks.y,es.z,0,-es.x,ts.z,0,-ts.x,Ks.z,0,-Ks.x,-es.y,es.x,0,-ts.y,ts.x,0,-Ks.y,Ks.x,0];return!xp(t,Uo,zo,Go,Uh)||(t=[1,0,0,0,1,0,0,0,1],!xp(t,Uo,zo,Go,Uh))?!1:(zh.crossVectors(es,ts),t=[zh.x,zh.y,zh.z],xp(t,Uo,zo,Go,Uh))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Qs.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(Qs).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Pi=[new A,new A,new A,new A,new A,new A,new A,new A],Qs=new A,vp=new Sn,Uo=new A,zo=new A,Go=new A,es=new A,ts=new A,Ks=new A,$l=new A,Uh=new A,zh=new A,Zs=new A;function xp(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){Zs.fromArray(r,s);let a=i.x*Math.abs(Zs.x)+i.y*Math.abs(Zs.y)+i.z*Math.abs(Zs.z),l=e.dot(Zs),c=t.dot(Zs),h=n.dot(Zs);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var H_=new Sn,n0=new A,Gh=new A,bp=new A,Rn=class{constructor(e=new A,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):H_.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){bp.subVectors(e,this.center);let t=bp.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(bp.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return this.center.equals(e.center)===!0?Gh.set(0,0,1).multiplyScalar(e.radius):Gh.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(n0.copy(e.center).add(Gh)),this.expandByPoint(n0.copy(e.center).sub(Gh)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Li=new A,wp=new A,kh=new A,ns=new A,Sp=new A,Vh=new A,Ap=new A,ro=class{constructor(e=new A,t=new A(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Li.copy(this.direction).multiplyScalar(t).add(this.origin),Li.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){wp.copy(e).add(t).multiplyScalar(.5),kh.copy(t).sub(e).normalize(),ns.copy(this.origin).sub(wp);let s=e.distanceTo(t)*.5,o=-this.direction.dot(kh),a=ns.dot(this.direction),l=-ns.dot(kh),c=ns.lengthSq(),h=Math.abs(1-o*o),u,d,f,m;if(h>0)if(u=o*l-a,d=o*a-l,m=s*h,u>=0)if(d>=-m)if(d<=m){let p=1/h;u*=p,d*=p,f=u*(u+o*d+2*a)+d*(o*u+d+2*l)+c}else d=s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-o*s+a)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(o*s+a)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=o>0?-s:s,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(kh).multiplyScalar(d).add(wp),f}intersectSphere(e,t){Li.subVectors(e.center,this.origin);let n=Li.dot(this.direction),i=Li.dot(Li)-n*n,s=e.radius*e.radius;if(i>s)return null;let o=Math.sqrt(s-i),a=n-o,l=n+o;return a<0&&l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,o,a,l,c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),h>=0?(s=(e.min.y-d.y)*h,o=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,o=(e.min.y-d.y)*h),n>o||s>i||((s>n||n!==n)&&(n=s),(o<i||i!==i)&&(i=o),u>=0?(a=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Li)!==null}intersectTriangle(e,t,n,i,s){Sp.subVectors(t,e),Vh.subVectors(n,e),Ap.crossVectors(Sp,Vh);let o=this.direction.dot(Ap),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ns.subVectors(this.origin,e);let l=a*this.direction.dot(Vh.crossVectors(ns,Vh));if(l<0)return null;let c=a*this.direction.dot(Sp.cross(ns));if(c<0||l+c>o)return null;let h=-a*ns.dot(Ap);return h<0?null:this.at(h/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Oe=class{constructor(){this.isMatrix4=!0,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(e,t,n,i,s,o,a,l,c,h,u,d,f,m,p,g){let x=this.elements;return x[0]=e,x[4]=t,x[8]=n,x[12]=i,x[1]=s,x[5]=o,x[9]=a,x[13]=l,x[2]=c,x[6]=h,x[10]=u,x[14]=d,x[3]=f,x[7]=m,x[11]=p,x[15]=g,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 Oe().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,i=1/ko.setFromMatrixColumn(e,0).length(),s=1/ko.setFromMatrixColumn(e,1).length(),o=1/ko.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");let t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(e.order==="XYZ"){let d=o*h,f=o*u,m=a*h,p=a*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=f+m*c,t[5]=d-p*c,t[9]=-a*l,t[2]=p-d*c,t[6]=m+f*c,t[10]=o*l}else if(e.order==="YXZ"){let d=l*h,f=l*u,m=c*h,p=c*u;t[0]=d+p*a,t[4]=m*a-f,t[8]=o*c,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=f*a-m,t[6]=p+d*a,t[10]=o*l}else if(e.order==="ZXY"){let d=l*h,f=l*u,m=c*h,p=c*u;t[0]=d-p*a,t[4]=-o*u,t[8]=m+f*a,t[1]=f+m*a,t[5]=o*h,t[9]=p-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let d=o*h,f=o*u,m=a*h,p=a*u;t[0]=l*h,t[4]=m*c-f,t[8]=d*c+p,t[1]=l*u,t[5]=p*c+d,t[9]=f*c-m,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let d=o*l,f=o*c,m=a*l,p=a*c;t[0]=l*h,t[4]=p-d*u,t[8]=m*u+f,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=f*u+m,t[10]=d-p*u}else if(e.order==="XZY"){let d=o*l,f=o*c,m=a*l,p=a*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+p,t[5]=o*h,t[9]=f*u-m,t[2]=m*u-f,t[6]=a*h,t[10]=p*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(W_,e,j_)}lookAt(e,t,n){let i=this.elements;return or.subVectors(e,t),or.lengthSq()===0&&(or.z=1),or.normalize(),rs.crossVectors(n,or),rs.lengthSq()===0&&(Math.abs(n.z)===1?or.x+=1e-4:or.z+=1e-4,or.normalize(),rs.crossVectors(n,or)),rs.normalize(),Hh.crossVectors(or,rs),i[0]=rs.x,i[4]=Hh.x,i[8]=or.x,i[1]=rs.y,i[5]=Hh.y,i[9]=or.y,i[2]=rs.z,i[6]=Hh.z,i[10]=or.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],p=n[6],g=n[10],x=n[14],v=n[3],w=n[7],b=n[11],S=n[15],M=i[0],_=i[4],y=i[8],T=i[12],E=i[1],C=i[5],I=i[9],R=i[13],N=i[2],H=i[6],j=i[10],K=i[14],Y=i[3],z=i[7],F=i[11],V=i[15];return s[0]=o*M+a*E+l*N+c*Y,s[4]=o*_+a*C+l*H+c*z,s[8]=o*y+a*I+l*j+c*F,s[12]=o*T+a*R+l*K+c*V,s[1]=h*M+u*E+d*N+f*Y,s[5]=h*_+u*C+d*H+f*z,s[9]=h*y+u*I+d*j+f*F,s[13]=h*T+u*R+d*K+f*V,s[2]=m*M+p*E+g*N+x*Y,s[6]=m*_+p*C+g*H+x*z,s[10]=m*y+p*I+g*j+x*F,s[14]=m*T+p*R+g*K+x*V,s[3]=v*M+w*E+b*N+S*Y,s[7]=v*_+w*C+b*H+S*z,s[11]=v*y+w*I+b*j+S*F,s[15]=v*T+w*R+b*K+S*V,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],f=e[14],m=e[3],p=e[7],g=e[11],x=e[15];return m*(+s*l*u-i*c*u-s*a*d+n*c*d+i*a*f-n*l*f)+p*(+t*l*f-t*c*d+s*o*d-i*o*f+i*c*h-s*l*h)+g*(+t*c*u-t*a*f-s*o*u+n*o*f+s*a*h-n*c*h)+x*(-i*a*h-t*l*u+t*a*d+i*o*u-n*o*d+n*l*h)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],f=e[11],m=e[12],p=e[13],g=e[14],x=e[15],v=u*g*c-p*d*c+p*l*f-a*g*f-u*l*x+a*d*x,w=m*d*c-h*g*c-m*l*f+o*g*f+h*l*x-o*d*x,b=h*p*c-m*u*c+m*a*f-o*p*f-h*a*x+o*u*x,S=m*u*l-h*p*l-m*a*d+o*p*d+h*a*g-o*u*g,M=t*v+n*w+i*b+s*S;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let _=1/M;return e[0]=v*_,e[1]=(p*d*s-u*g*s-p*i*f+n*g*f+u*i*x-n*d*x)*_,e[2]=(a*g*s-p*l*s+p*i*c-n*g*c-a*i*x+n*l*x)*_,e[3]=(u*l*s-a*d*s-u*i*c+n*d*c+a*i*f-n*l*f)*_,e[4]=w*_,e[5]=(h*g*s-m*d*s+m*i*f-t*g*f-h*i*x+t*d*x)*_,e[6]=(m*l*s-o*g*s-m*i*c+t*g*c+o*i*x-t*l*x)*_,e[7]=(o*d*s-h*l*s+h*i*c-t*d*c-o*i*f+t*l*f)*_,e[8]=b*_,e[9]=(m*u*s-h*p*s-m*n*f+t*p*f+h*n*x-t*u*x)*_,e[10]=(o*p*s-m*a*s+m*n*c-t*p*c-o*n*x+t*a*x)*_,e[11]=(h*a*s-o*u*s-h*n*c+t*u*c+o*n*f-t*a*f)*_,e[12]=S*_,e[13]=(h*p*i-m*u*i+m*n*d-t*p*d-h*n*g+t*u*g)*_,e[14]=(m*a*i-o*p*i-m*n*l+t*p*l+o*n*g-t*a*g)*_,e[15]=(o*u*i-h*a*i+h*n*l-t*u*l-o*n*d+t*a*d)*_,this}scale(e){let t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,h=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+n,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,h=o+o,u=a+a,d=s*c,f=s*h,m=s*u,p=o*h,g=o*u,x=a*u,v=l*c,w=l*h,b=l*u,S=n.x,M=n.y,_=n.z;return i[0]=(1-(p+x))*S,i[1]=(f+b)*S,i[2]=(m-w)*S,i[3]=0,i[4]=(f-b)*M,i[5]=(1-(d+x))*M,i[6]=(g+v)*M,i[7]=0,i[8]=(m+w)*_,i[9]=(g-v)*_,i[10]=(1-(d+p))*_,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,s=ko.set(i[0],i[1],i[2]).length(),o=ko.set(i[4],i[5],i[6]).length(),a=ko.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Ur.copy(this);let c=1/s,h=1/o,u=1/a;return Ur.elements[0]*=c,Ur.elements[1]*=c,Ur.elements[2]*=c,Ur.elements[4]*=h,Ur.elements[5]*=h,Ur.elements[6]*=h,Ur.elements[8]*=u,Ur.elements[9]*=u,Ur.elements[10]*=u,t.setFromRotationMatrix(Ur),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o){o===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let a=this.elements,l=2*s/(t-e),c=2*s/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=c,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,i,s,o){let a=this.elements,l=1/(t-e),c=1/(n-i),h=1/(o-s),u=(t+e)*l,d=(n+i)*c,f=(o+s)*h;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},ko=new A,Ur=new Oe,W_=new A(0,0,0),j_=new A(1,1,1),rs=new A,Hh=new A,or=new A,r0=new Oe,i0=new Xt,br=class{constructor(e=0,t=0,n=0,i=br.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(sn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-sn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(sn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-sn(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(sn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-sn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return r0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(r0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return i0.setFromEuler(this),this.setFromQuaternion(i0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}};br.DefaultOrder="XYZ";br.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var dc=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},q_=0,s0=new A,Vo=new Xt,Ii=new Oe,Wh=new A,ec=new A,X_=new A,Y_=new Xt,o0=new A(1,0,0),a0=new A(0,1,0),l0=new A(0,0,1),Q_={type:"added"},c0={type:"removed"},ct=class extends Rt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:q_++}),this.uuid=ci(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ct.DefaultUp.clone();let e=new A,t=new br,n=new Xt,i=new A(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Oe},normalMatrix:{value:new qt}}),this.matrix=new Oe,this.matrixWorld=new Oe,this.matrixAutoUpdate=ct.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new dc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Vo.setFromAxisAngle(e,t),this.quaternion.multiply(Vo),this}rotateOnWorldAxis(e,t){return Vo.setFromAxisAngle(e,t),this.quaternion.premultiply(Vo),this}rotateX(e){return this.rotateOnAxis(o0,e)}rotateY(e){return this.rotateOnAxis(a0,e)}rotateZ(e){return this.rotateOnAxis(l0,e)}translateOnAxis(e,t){return s0.copy(e).applyQuaternion(this.quaternion),this.position.add(s0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(o0,e)}translateY(e){return this.translateOnAxis(a0,e)}translateZ(e){return this.translateOnAxis(l0,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(Ii.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Wh.copy(e):Wh.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),ec.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ii.lookAt(ec,Wh,this.up):Ii.lookAt(Wh,ec,this.up),this.quaternion.setFromRotationMatrix(Ii),i&&(Ii.extractRotation(i.matrixWorld),Vo.setFromRotationMatrix(Ii),this.quaternion.premultiply(Vo.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Q_)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(c0)),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){let t=this.children[e];t.parent=null,t.dispatchEvent(c0)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Ii.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ii.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ii),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ec,e,X_),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ec,Y_,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){let u=l[c];s(e.shapes,u)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),u=o(e.shapes),d=o(e.skeletons),f=o(e.animations),m=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}};ct.DefaultUp=new A(0,1,0);ct.DefaultMatrixAutoUpdate=!0;var zr=new A,Ni=new A,Mp=new A,Ri=new A,Ho=new A,Wo=new A,h0=new A,_p=new A,Tp=new A,Ep=new A,Kn=class{constructor(e=new A,t=new A,n=new A){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),zr.subVectors(e,t),i.cross(zr);let s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){zr.subVectors(i,t),Ni.subVectors(n,t),Mp.subVectors(e,t);let o=zr.dot(zr),a=zr.dot(Ni),l=zr.dot(Mp),c=Ni.dot(Ni),h=Ni.dot(Mp),u=o*c-a*a;if(u===0)return s.set(-2,-1,-1);let d=1/u,f=(c*l-a*h)*d,m=(o*h-a*l)*d;return s.set(1-f-m,m,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ri),Ri.x>=0&&Ri.y>=0&&Ri.x+Ri.y<=1}static getUV(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,Ri),l.set(0,0),l.addScaledVector(s,Ri.x),l.addScaledVector(o,Ri.y),l.addScaledVector(a,Ri.z),l}static isFrontFacing(e,t,n,i){return zr.subVectors(n,t),Ni.subVectors(e,t),zr.cross(Ni).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return zr.subVectors(this.c,this.b),Ni.subVectors(this.a,this.b),zr.cross(Ni).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Kn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Kn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return Kn.getUV(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return Kn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Kn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,s=this.c,o,a;Ho.subVectors(i,n),Wo.subVectors(s,n),_p.subVectors(e,n);let l=Ho.dot(_p),c=Wo.dot(_p);if(l<=0&&c<=0)return t.copy(n);Tp.subVectors(e,i);let h=Ho.dot(Tp),u=Wo.dot(Tp);if(h>=0&&u<=h)return t.copy(i);let d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector(Ho,o);Ep.subVectors(e,s);let f=Ho.dot(Ep),m=Wo.dot(Ep);if(m>=0&&f<=m)return t.copy(s);let p=f*c-l*m;if(p<=0&&c>=0&&m<=0)return a=c/(c-m),t.copy(n).addScaledVector(Wo,a);let g=h*m-f*u;if(g<=0&&u-h>=0&&f-m>=0)return h0.subVectors(s,i),a=(u-h)/(u-h+(f-m)),t.copy(i).addScaledVector(h0,a);let x=1/(g+p+d);return o=p*x,a=d*x,t.copy(n).addScaledVector(Ho,o).addScaledVector(Wo,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},K_=0,un=class extends Rt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:K_++}),this.uuid=ci(),this.name="",this.type="Material",this.blending=ls,this.side=zi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=$0,this.blendDst=ex,this.blendEquation=Zo,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Wp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=M_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fp,this.stencilZFail=fp,this.stencilZPass=fp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===IM;continue}let i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ls&&(n.blending=this.blending),this.side!==zi&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}get vertexTangents(){return console.warn("THREE."+this.type+": .vertexTangents has been removed."),!1}set vertexTangents(e){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}};un.fromType=function(){return null};var hi=class extends un{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ou,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},rn=new A,jh=new B,Xe=class{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n===!0,this.usage=Yp,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),o=new Ae),t[n++]=o.r,t[n++]=o.g,t[n++]=o.b}return this}copyVector2sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),o=new B),t[n++]=o.x,t[n++]=o.y}return this}copyVector3sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),o=new A),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z}return this}copyVector4sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),o=new qe),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z,t[n++]=o.w}return this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)jh.fromBufferAttribute(this,t),jh.applyMatrix3(e),this.setXY(t,jh.x,jh.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)rn.fromBufferAttribute(this,t),rn.applyMatrix3(e),this.setXYZ(t,rn.x,rn.y,rn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)rn.fromBufferAttribute(this,t),rn.applyMatrix4(e),this.setXYZ(t,rn.x,rn.y,rn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)rn.fromBufferAttribute(this,t),rn.applyNormalMatrix(e),this.setXYZ(t,rn.x,rn.y,rn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)rn.fromBufferAttribute(this,t),rn.transformDirection(e),this.setXYZ(t,rn.x,rn.y,rn.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Yp&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}};var yu=class extends Xe{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var ps=class extends Xe{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Se=class extends Xe{constructor(e,t,n){super(new Float32Array(e),t,n)}};var Z_=0,yr=new Oe,Cp=new ct,jo=new A,ar=new Sn,tc=new Sn,xn=new A,Le=class extends Rt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Z_++}),this.uuid=ci(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(rx(e)?ps:yu)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new qt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return yr.makeRotationFromQuaternion(e),this.applyMatrix4(yr),this}rotateX(e){return yr.makeRotationX(e),this.applyMatrix4(yr),this}rotateY(e){return yr.makeRotationY(e),this.applyMatrix4(yr),this}rotateZ(e){return yr.makeRotationZ(e),this.applyMatrix4(yr),this}translate(e,t,n){return yr.makeTranslation(e,t,n),this.applyMatrix4(yr),this}scale(e,t,n){return yr.makeScale(e,t,n),this.applyMatrix4(yr),this}lookAt(e){return Cp.lookAt(e),Cp.updateMatrix(),this.applyMatrix4(Cp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(jo).negate(),this.translate(jo.x,jo.y,jo.z),this}setFromPoints(e){let t=[];for(let n=0,i=e.length;n<i;n++){let s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Se(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Sn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new A(-1/0,-1/0,-1/0),new A(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let s=t[n];ar.setFromBufferAttribute(s),this.morphTargetsRelative?(xn.addVectors(this.boundingBox.min,ar.min),this.boundingBox.expandByPoint(xn),xn.addVectors(this.boundingBox.max,ar.max),this.boundingBox.expandByPoint(xn)):(this.boundingBox.expandByPoint(ar.min),this.boundingBox.expandByPoint(ar.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Rn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new A,1/0);return}if(e){let n=this.boundingSphere.center;if(ar.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];tc.setFromBufferAttribute(a),this.morphTargetsRelative?(xn.addVectors(ar.min,tc.min),ar.expandByPoint(xn),xn.addVectors(ar.max,tc.max),ar.expandByPoint(xn)):(ar.expandByPoint(tc.min),ar.expandByPoint(tc.max))}ar.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)xn.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(xn));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)xn.fromBufferAttribute(a,c),l&&(jo.fromBufferAttribute(e,c),xn.add(jo)),i=Math.max(i,n.distanceToSquared(xn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.array,i=t.position.array,s=t.normal.array,o=t.uv.array,a=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Xe(new Float32Array(4*a),4));let l=this.getAttribute("tangent").array,c=[],h=[];for(let E=0;E<a;E++)c[E]=new A,h[E]=new A;let u=new A,d=new A,f=new A,m=new B,p=new B,g=new B,x=new A,v=new A;function w(E,C,I){u.fromArray(i,E*3),d.fromArray(i,C*3),f.fromArray(i,I*3),m.fromArray(o,E*2),p.fromArray(o,C*2),g.fromArray(o,I*2),d.sub(u),f.sub(u),p.sub(m),g.sub(m);let R=1/(p.x*g.y-g.x*p.y);!isFinite(R)||(x.copy(d).multiplyScalar(g.y).addScaledVector(f,-p.y).multiplyScalar(R),v.copy(f).multiplyScalar(p.x).addScaledVector(d,-g.x).multiplyScalar(R),c[E].add(x),c[C].add(x),c[I].add(x),h[E].add(v),h[C].add(v),h[I].add(v))}let b=this.groups;b.length===0&&(b=[{start:0,count:n.length}]);for(let E=0,C=b.length;E<C;++E){let I=b[E],R=I.start,N=I.count;for(let H=R,j=R+N;H<j;H+=3)w(n[H+0],n[H+1],n[H+2])}let S=new A,M=new A,_=new A,y=new A;function T(E){_.fromArray(s,E*3),y.copy(_);let C=c[E];S.copy(C),S.sub(_.multiplyScalar(_.dot(C))).normalize(),M.crossVectors(y,C);let R=M.dot(h[E])<0?-1:1;l[E*4]=S.x,l[E*4+1]=S.y,l[E*4+2]=S.z,l[E*4+3]=R}for(let E=0,C=b.length;E<C;++E){let I=b[E],R=I.start,N=I.count;for(let H=R,j=R+N;H<j;H+=3)T(n[H+0]),T(n[H+1]),T(n[H+2])}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Xe(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);let i=new A,s=new A,o=new A,a=new A,l=new A,c=new A,h=new A,u=new A;if(e)for(let d=0,f=e.count;d<f;d+=3){let m=e.getX(d+0),p=e.getX(d+1),g=e.getX(d+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,p),o.fromBufferAttribute(t,g),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),a.fromBufferAttribute(n,m),l.fromBufferAttribute(n,p),c.fromBufferAttribute(n,g),a.add(h),l.add(h),c.add(h),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(p,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),h.subVectors(o,s),u.subVectors(i,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(e,t){if(!(e&&e.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);return}t===void 0&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));let n=this.attributes;for(let i in n){if(e.attributes[i]===void 0)continue;let o=n[i].array,a=e.attributes[i],l=a.array,c=a.itemSize*t,h=Math.min(l.length,o.length-c);for(let u=0,d=c;u<h;u++,d++)o[d]=l[u]}return this}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)xn.fromBufferAttribute(e,t),xn.normalize(),e.setXYZ(t,xn.x,xn.y,xn.z)}toNonIndexed(){function e(a,l){let c=a.array,h=a.itemSize,u=a.normalized,d=new c.constructor(l.length*h),f=0,m=0;for(let p=0,g=l.length;p<g;p++){a.isInterleavedBufferAttribute?f=l[p]*a.data.stride+a.offset:f=l[p]*h;for(let x=0;x<h;x++)d[m++]=c[f++]}return new Xe(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new Le,n=this.index.array,i=this.attributes;for(let a in i){let l=i[a],c=e(l,n);t.setAttribute(a,c)}let s=this.morphAttributes;for(let a in s){let l=[],c=s[a];for(let h=0,u=c.length;h<u;h++){let d=c[h],f=e(d,n);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let i={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){let f=c[u];h.push(f.toJSON(e.data))}h.length>0&&(i[l]=h,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let i=e.attributes;for(let c in i){let h=i[c];this.setAttribute(c,h.clone(t))}let s=e.morphAttributes;for(let c in s){let h=[],u=s[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,h=o.length;c<h;c++){let u=o[c];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,e.parameters!==void 0&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}},u0=new Oe,qo=new ro,Dp=new Rn,is=new A,ss=new A,os=new A,Pp=new A,Lp=new A,Ip=new A,qh=new A,Xh=new A,Yh=new A,Qh=new B,Kh=new B,Zh=new B,Np=new A,Jh=new A,Vt=class extends ct{constructor(e=new Le,t=new hi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}raycast(e,t){let n=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0||(n.boundingSphere===null&&n.computeBoundingSphere(),Dp.copy(n.boundingSphere),Dp.applyMatrix4(s),e.ray.intersectsSphere(Dp)===!1)||(u0.copy(s).invert(),qo.copy(e.ray).applyMatrix4(u0),n.boundingBox!==null&&qo.intersectsBox(n.boundingBox)===!1))return;let o,a=n.index,l=n.attributes.position,c=n.morphAttributes.position,h=n.morphTargetsRelative,u=n.attributes.uv,d=n.attributes.uv2,f=n.groups,m=n.drawRange;if(a!==null)if(Array.isArray(i))for(let p=0,g=f.length;p<g;p++){let x=f[p],v=i[x.materialIndex],w=Math.max(x.start,m.start),b=Math.min(a.count,Math.min(x.start+x.count,m.start+m.count));for(let S=w,M=b;S<M;S+=3){let _=a.getX(S),y=a.getX(S+1),T=a.getX(S+2);o=$h(this,v,e,qo,l,c,h,u,d,_,y,T),o&&(o.faceIndex=Math.floor(S/3),o.face.materialIndex=x.materialIndex,t.push(o))}}else{let p=Math.max(0,m.start),g=Math.min(a.count,m.start+m.count);for(let x=p,v=g;x<v;x+=3){let w=a.getX(x),b=a.getX(x+1),S=a.getX(x+2);o=$h(this,i,e,qo,l,c,h,u,d,w,b,S),o&&(o.faceIndex=Math.floor(x/3),t.push(o))}}else if(l!==void 0)if(Array.isArray(i))for(let p=0,g=f.length;p<g;p++){let x=f[p],v=i[x.materialIndex],w=Math.max(x.start,m.start),b=Math.min(l.count,Math.min(x.start+x.count,m.start+m.count));for(let S=w,M=b;S<M;S+=3){let _=S,y=S+1,T=S+2;o=$h(this,v,e,qo,l,c,h,u,d,_,y,T),o&&(o.faceIndex=Math.floor(S/3),o.face.materialIndex=x.materialIndex,t.push(o))}}else{let p=Math.max(0,m.start),g=Math.min(l.count,m.start+m.count);for(let x=p,v=g;x<v;x+=3){let w=x,b=x+1,S=x+2;o=$h(this,i,e,qo,l,c,h,u,d,w,b,S),o&&(o.faceIndex=Math.floor(x/3),t.push(o))}}}};function J_(r,e,t,n,i,s,o,a){let l;if(e.side===wn?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,e.side!==hn,a),l===null)return null;Jh.copy(a),Jh.applyMatrix4(r.matrixWorld);let c=t.ray.origin.distanceTo(Jh);return c<t.near||c>t.far?null:{distance:c,point:Jh.clone(),object:r}}function $h(r,e,t,n,i,s,o,a,l,c,h,u){is.fromBufferAttribute(i,c),ss.fromBufferAttribute(i,h),os.fromBufferAttribute(i,u);let d=r.morphTargetInfluences;if(s&&d){qh.set(0,0,0),Xh.set(0,0,0),Yh.set(0,0,0);for(let m=0,p=s.length;m<p;m++){let g=d[m],x=s[m];g!==0&&(Pp.fromBufferAttribute(x,c),Lp.fromBufferAttribute(x,h),Ip.fromBufferAttribute(x,u),o?(qh.addScaledVector(Pp,g),Xh.addScaledVector(Lp,g),Yh.addScaledVector(Ip,g)):(qh.addScaledVector(Pp.sub(is),g),Xh.addScaledVector(Lp.sub(ss),g),Yh.addScaledVector(Ip.sub(os),g)))}is.add(qh),ss.add(Xh),os.add(Yh)}r.isSkinnedMesh&&(r.boneTransform(c,is),r.boneTransform(h,ss),r.boneTransform(u,os));let f=J_(r,e,t,n,is,ss,os,Np);if(f){a&&(Qh.fromBufferAttribute(a,c),Kh.fromBufferAttribute(a,h),Zh.fromBufferAttribute(a,u),f.uv=Kn.getUV(Np,is,ss,os,Qh,Kh,Zh,new B)),l&&(Qh.fromBufferAttribute(l,c),Kh.fromBufferAttribute(l,h),Zh.fromBufferAttribute(l,u),f.uv2=Kn.getUV(Np,is,ss,os,Qh,Kh,Zh,new B));let m={a:c,b:h,c:u,normal:new A,materialIndex:0};Kn.getNormal(is,ss,os,m.normal),f.face=m}return f}var Zn=class extends Le{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};let a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],h=[],u=[],d=0,f=0;m("z","y","x",-1,-1,n,t,e,o,s,0),m("z","y","x",1,-1,n,t,-e,o,s,1),m("x","z","y",1,1,e,n,t,i,o,2),m("x","z","y",1,-1,e,n,-t,i,o,3),m("x","y","z",1,-1,e,t,n,i,s,4),m("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new Se(c,3)),this.setAttribute("normal",new Se(h,3)),this.setAttribute("uv",new Se(u,2));function m(p,g,x,v,w,b,S,M,_,y,T){let E=b/_,C=S/y,I=b/2,R=S/2,N=M/2,H=_+1,j=y+1,K=0,Y=0,z=new A;for(let F=0;F<j;F++){let V=F*C-R;for(let O=0;O<H;O++){let G=O*E-I;z[p]=G*v,z[g]=V*w,z[x]=N,c.push(z.x,z.y,z.z),z[p]=0,z[g]=0,z[x]=M>0?1:-1,h.push(z.x,z.y,z.z),u.push(O/_),u.push(1-F/y),K+=1}}for(let F=0;F<y;F++)for(let V=0;V<_;V++){let O=d+V+H*F,G=d+V+H*(F+1),W=d+(V+1)+H*(F+1),X=d+(V+1)+H*F;l.push(O,G,X),l.push(G,W,X),Y+=6}a.addGroup(f,Y,T),f+=Y,d+=K}}static fromJSON(e){return new Zn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function na(r){let e={};for(let t in r){e[t]={};for(let n in r[t]){let i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Nn(r){let e={};for(let t=0;t<r.length;t++){let n=na(r[t]);for(let i in n)e[i]=n[i]}return e}var Wr={clone:na,merge:Nn},$_=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
3
|
}`,eT=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
@@ -37,7 +37,7 @@ var wM=Object.create;var ap=Object.defineProperty;var SM=Object.getOwnPropertyDe
|
|
|
37
37
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
38
38
|
|
|
39
39
|
}
|
|
40
|
-
`},i=new Zn(5,5,5),s=new dt({name:"CubemapFromEquirect",uniforms:na(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:wn,blending:Ct});s.uniforms.tEquirect.value=t;let o=new Vt(i,s),a=t.minFilter;return t.minFilter===xs&&(t.minFilter=tt),new Jp(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}},Rp=new A,tT=new A,nT=new qt,kn=class{constructor(e=new A(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=Rp.subVectors(n,t).cross(tT.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){let n=e.delta(Rp),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||nT.getNormalMatrix(e),i=this.coplanarPoint(Rp).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Qo=new Rn,eu=new A,fc=class{constructor(e=new kn,t=new kn,n=new kn,i=new kn,s=new kn,o=new kn){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){let t=this.planes,n=e.elements,i=n[0],s=n[1],o=n[2],a=n[3],l=n[4],c=n[5],h=n[6],u=n[7],d=n[8],f=n[9],m=n[10],p=n[11],g=n[12],x=n[13],v=n[14],w=n[15];return t[0].setComponents(a-i,u-l,p-d,w-g).normalize(),t[1].setComponents(a+i,u+l,p+d,w+g).normalize(),t[2].setComponents(a+s,u+c,p+f,w+x).normalize(),t[3].setComponents(a-s,u-c,p-f,w-x).normalize(),t[4].setComponents(a-o,u-h,p-m,w-v).normalize(),t[5].setComponents(a+o,u+h,p+m,w+v).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),Qo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Qo)}intersectsSprite(e){return Qo.center.set(0,0,0),Qo.radius=.7071067811865476,Qo.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qo)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(eu.x=i.normal.x>0?e.max.x:e.min.x,eu.y=i.normal.y>0?e.max.y:e.min.y,eu.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(eu)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function sx(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function rT(r,e){let t=e.isWebGL2,n=new WeakMap;function i(c,h){let u=c.array,d=c.usage,f=r.createBuffer();r.bindBuffer(h,f),r.bufferData(h,u,d),c.onUploadCallback();let m;if(u instanceof Float32Array)m=5126;else if(u instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)m=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else m=5123;else if(u instanceof Int16Array)m=5122;else if(u instanceof Uint32Array)m=5125;else if(u instanceof Int32Array)m=5124;else if(u instanceof Int8Array)m=5120;else if(u instanceof Uint8Array)m=5121;else if(u instanceof Uint8ClampedArray)m=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:f,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:c.version}}function s(c,h,u){let d=h.array,f=h.updateRange;r.bindBuffer(u,c),f.count===-1?r.bufferSubData(u,0,d):(t?r.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):r.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1)}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let h=n.get(c);h&&(r.deleteBuffer(h.buffer),n.delete(c))}function l(c,h){if(c.isGLBufferAttribute){let d=n.get(c);(!d||d.version<c.version)&&n.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);let u=n.get(c);u===void 0?n.set(c,i(c,h)):u.version<c.version&&(s(u.buffer,c,h),u.version=c.version)}return{get:o,remove:a,update:l}}var Gi=class extends
|
|
40
|
+
`},i=new Zn(5,5,5),s=new dt({name:"CubemapFromEquirect",uniforms:na(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:wn,blending:Ct});s.uniforms.tEquirect.value=t;let o=new Vt(i,s),a=t.minFilter;return t.minFilter===xs&&(t.minFilter=tt),new Jp(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}},Rp=new A,tT=new A,nT=new qt,kn=class{constructor(e=new A(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=Rp.subVectors(n,t).cross(tT.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){let n=e.delta(Rp),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||nT.getNormalMatrix(e),i=this.coplanarPoint(Rp).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Qo=new Rn,eu=new A,fc=class{constructor(e=new kn,t=new kn,n=new kn,i=new kn,s=new kn,o=new kn){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){let t=this.planes,n=e.elements,i=n[0],s=n[1],o=n[2],a=n[3],l=n[4],c=n[5],h=n[6],u=n[7],d=n[8],f=n[9],m=n[10],p=n[11],g=n[12],x=n[13],v=n[14],w=n[15];return t[0].setComponents(a-i,u-l,p-d,w-g).normalize(),t[1].setComponents(a+i,u+l,p+d,w+g).normalize(),t[2].setComponents(a+s,u+c,p+f,w+x).normalize(),t[3].setComponents(a-s,u-c,p-f,w-x).normalize(),t[4].setComponents(a-o,u-h,p-m,w-v).normalize(),t[5].setComponents(a+o,u+h,p+m,w+v).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),Qo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Qo)}intersectsSprite(e){return Qo.center.set(0,0,0),Qo.radius=.7071067811865476,Qo.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qo)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(eu.x=i.normal.x>0?e.max.x:e.min.x,eu.y=i.normal.y>0?e.max.y:e.min.y,eu.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(eu)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function sx(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function rT(r,e){let t=e.isWebGL2,n=new WeakMap;function i(c,h){let u=c.array,d=c.usage,f=r.createBuffer();r.bindBuffer(h,f),r.bufferData(h,u,d),c.onUploadCallback();let m;if(u instanceof Float32Array)m=5126;else if(u instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)m=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else m=5123;else if(u instanceof Int16Array)m=5122;else if(u instanceof Uint32Array)m=5125;else if(u instanceof Int32Array)m=5124;else if(u instanceof Int8Array)m=5120;else if(u instanceof Uint8Array)m=5121;else if(u instanceof Uint8ClampedArray)m=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:f,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:c.version}}function s(c,h,u){let d=h.array,f=h.updateRange;r.bindBuffer(u,c),f.count===-1?r.bufferSubData(u,0,d):(t?r.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):r.bufferSubData(u,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1)}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),n.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let h=n.get(c);h&&(r.deleteBuffer(h.buffer),n.delete(c))}function l(c,h){if(c.isGLBufferAttribute){let d=n.get(c);(!d||d.version<c.version)&&n.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);let u=n.get(c);u===void 0?n.set(c,i(c,h)):u.version<c.version&&(s(u.buffer,c,h),u.version=c.version)}return{get:o,remove:a,update:l}}var Gi=class extends Le{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let s=e/2,o=t/2,a=Math.floor(n),l=Math.floor(i),c=a+1,h=l+1,u=e/a,d=t/l,f=[],m=[],p=[],g=[];for(let x=0;x<h;x++){let v=x*d-o;for(let w=0;w<c;w++){let b=w*u-s;m.push(b,-v,0),p.push(0,0,1),g.push(w/a),g.push(1-x/l)}}for(let x=0;x<l;x++)for(let v=0;v<a;v++){let w=v+c*x,b=v+c*(x+1),S=v+1+c*(x+1),M=v+1+c*x;f.push(w,b,M),f.push(b,S,M)}this.setIndex(f),this.setAttribute("position",new Se(m,3)),this.setAttribute("normal",new Se(p,3)),this.setAttribute("uv",new Se(g,2))}static fromJSON(e){return new Gi(e.width,e.height,e.widthSegments,e.heightSegments)}},iT=`#ifdef USE_ALPHAMAP
|
|
41
41
|
diffuseColor.a *= texture2D( alphaMap, vUv ).g;
|
|
42
42
|
#endif`,sT=`#ifdef USE_ALPHAMAP
|
|
43
43
|
uniform sampler2D alphaMap;
|
|
@@ -523,12 +523,12 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
523
523
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
524
524
|
#endif`,DT=`#ifdef USE_EMISSIVEMAP
|
|
525
525
|
uniform sampler2D emissiveMap;
|
|
526
|
-
#endif`,PT="gl_FragColor = linearToOutputTexel( gl_FragColor );",
|
|
526
|
+
#endif`,PT="gl_FragColor = linearToOutputTexel( gl_FragColor );",LT=`vec4 LinearToLinear( in vec4 value ) {
|
|
527
527
|
return value;
|
|
528
528
|
}
|
|
529
529
|
vec4 LinearTosRGB( in vec4 value ) {
|
|
530
530
|
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
|
531
|
-
}`,
|
|
531
|
+
}`,IT=`#ifdef USE_ENVMAP
|
|
532
532
|
#ifdef ENV_WORLDPOS
|
|
533
533
|
vec3 cameraToFrag;
|
|
534
534
|
if ( isOrthographic ) {
|
|
@@ -1480,14 +1480,14 @@ float perspectiveDepthToViewZ( const in float invClipZ, const in float near, con
|
|
|
1480
1480
|
mvPosition = modelViewMatrix * mvPosition;
|
|
1481
1481
|
gl_Position = projectionMatrix * mvPosition;`,PE=`#ifdef DITHERING
|
|
1482
1482
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1483
|
-
#endif`,
|
|
1483
|
+
#endif`,LE=`#ifdef DITHERING
|
|
1484
1484
|
vec3 dithering( vec3 color ) {
|
|
1485
1485
|
float grid_position = rand( gl_FragCoord.xy );
|
|
1486
1486
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1487
1487
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1488
1488
|
return color + dither_shift_RGB;
|
|
1489
1489
|
}
|
|
1490
|
-
#endif`,
|
|
1490
|
+
#endif`,IE=`float roughnessFactor = roughness;
|
|
1491
1491
|
#ifdef USE_ROUGHNESSMAP
|
|
1492
1492
|
vec4 texelRoughness = texture2D( roughnessMap, vUv );
|
|
1493
1493
|
roughnessFactor *= texelRoughness.g;
|
|
@@ -2877,7 +2877,7 @@ void main() {
|
|
|
2877
2877
|
#include <tonemapping_fragment>
|
|
2878
2878
|
#include <encodings_fragment>
|
|
2879
2879
|
#include <fog_fragment>
|
|
2880
|
-
}`,
|
|
2880
|
+
}`,LC=`uniform float rotation;
|
|
2881
2881
|
uniform vec2 center;
|
|
2882
2882
|
#include <common>
|
|
2883
2883
|
#include <uv_pars_vertex>
|
|
@@ -2903,7 +2903,7 @@ void main() {
|
|
|
2903
2903
|
#include <logdepthbuf_vertex>
|
|
2904
2904
|
#include <clipping_planes_vertex>
|
|
2905
2905
|
#include <fog_vertex>
|
|
2906
|
-
}`,
|
|
2906
|
+
}`,IC=`uniform vec3 diffuse;
|
|
2907
2907
|
uniform float opacity;
|
|
2908
2908
|
#include <common>
|
|
2909
2909
|
#include <uv_pars_fragment>
|
|
@@ -2926,7 +2926,7 @@ void main() {
|
|
|
2926
2926
|
#include <tonemapping_fragment>
|
|
2927
2927
|
#include <encodings_fragment>
|
|
2928
2928
|
#include <fog_fragment>
|
|
2929
|
-
}`,$e={alphamap_fragment:iT,alphamap_pars_fragment:sT,alphatest_fragment:oT,alphatest_pars_fragment:aT,aomap_fragment:lT,aomap_pars_fragment:cT,begin_vertex:hT,beginnormal_vertex:uT,bsdfs:dT,iridescence_fragment:fT,bumpmap_pars_fragment:pT,clipping_planes_fragment:mT,clipping_planes_pars_fragment:gT,clipping_planes_pars_vertex:yT,clipping_planes_vertex:vT,color_fragment:xT,color_pars_fragment:bT,color_pars_vertex:wT,color_vertex:ST,common:AT,cube_uv_reflection_fragment:MT,defaultnormal_vertex:_T,displacementmap_pars_vertex:TT,displacementmap_vertex:ET,emissivemap_fragment:CT,emissivemap_pars_fragment:DT,encodings_fragment:PT,encodings_pars_fragment:IT,envmap_fragment:LT,envmap_common_pars_fragment:NT,envmap_pars_fragment:RT,envmap_pars_vertex:BT,envmap_physical_pars_fragment:qT,envmap_vertex:OT,fog_vertex:FT,fog_pars_vertex:UT,fog_fragment:zT,fog_pars_fragment:GT,gradientmap_pars_fragment:kT,lightmap_fragment:VT,lightmap_pars_fragment:HT,lights_lambert_vertex:WT,lights_pars_begin:jT,lights_toon_fragment:XT,lights_toon_pars_fragment:YT,lights_phong_fragment:QT,lights_phong_pars_fragment:KT,lights_physical_fragment:ZT,lights_physical_pars_fragment:JT,lights_fragment_begin:$T,lights_fragment_maps:eE,lights_fragment_end:tE,logdepthbuf_fragment:nE,logdepthbuf_pars_fragment:rE,logdepthbuf_pars_vertex:iE,logdepthbuf_vertex:sE,map_fragment:oE,map_pars_fragment:aE,map_particle_fragment:lE,map_particle_pars_fragment:cE,metalnessmap_fragment:hE,metalnessmap_pars_fragment:uE,morphcolor_vertex:dE,morphnormal_vertex:fE,morphtarget_pars_vertex:pE,morphtarget_vertex:mE,normal_fragment_begin:gE,normal_fragment_maps:yE,normal_pars_fragment:vE,normal_pars_vertex:xE,normal_vertex:bE,normalmap_pars_fragment:wE,clearcoat_normal_fragment_begin:SE,clearcoat_normal_fragment_maps:AE,clearcoat_pars_fragment:ME,iridescence_pars_fragment:_E,output_fragment:TE,packing:EE,premultiplied_alpha_fragment:CE,project_vertex:DE,dithering_fragment:PE,dithering_pars_fragment:IE,roughnessmap_fragment:LE,roughnessmap_pars_fragment:NE,shadowmap_pars_fragment:RE,shadowmap_pars_vertex:BE,shadowmap_vertex:OE,shadowmask_pars_fragment:FE,skinbase_vertex:UE,skinning_pars_vertex:zE,skinning_vertex:GE,skinnormal_vertex:kE,specularmap_fragment:VE,specularmap_pars_fragment:HE,tonemapping_fragment:WE,tonemapping_pars_fragment:jE,transmission_fragment:qE,transmission_pars_fragment:XE,uv_pars_fragment:YE,uv_pars_vertex:QE,uv_vertex:KE,uv2_pars_fragment:ZE,uv2_pars_vertex:JE,uv2_vertex:$E,worldpos_vertex:eC,background_vert:tC,background_frag:nC,cube_vert:rC,cube_frag:iC,depth_vert:sC,depth_frag:oC,distanceRGBA_vert:aC,distanceRGBA_frag:lC,equirect_vert:cC,equirect_frag:hC,linedashed_vert:uC,linedashed_frag:dC,meshbasic_vert:fC,meshbasic_frag:pC,meshlambert_vert:mC,meshlambert_frag:gC,meshmatcap_vert:yC,meshmatcap_frag:vC,meshnormal_vert:xC,meshnormal_frag:bC,meshphong_vert:wC,meshphong_frag:SC,meshphysical_vert:AC,meshphysical_frag:MC,meshtoon_vert:_C,meshtoon_frag:TC,points_vert:EC,points_frag:CC,shadow_vert:DC,shadow_frag:PC,sprite_vert:IC,sprite_frag:LC},me={common:{diffuse:{value:new Ae(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new qt},uv2Transform:{value:new qt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new B(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ae(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ae(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new qt}},sprite:{diffuse:{value:new Ae(16777215)},opacity:{value:1},center:{value:new B(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new qt}}},li={basic:{uniforms:Nn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:Nn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.fog,me.lights,{emissive:{value:new Ae(0)}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:Nn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Ae(0)},specular:{value:new Ae(1118481)},shininess:{value:30}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:Nn([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new Ae(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:Nn([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new Ae(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:Nn([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:Nn([me.points,me.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:Nn([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:Nn([me.common,me.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:Nn([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:Nn([me.sprite,me.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qt},t2D:{value:null}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},cube:{uniforms:Nn([me.envmap,{opacity:{value:1}}]),vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distanceRGBA:{uniforms:Nn([me.common,me.displacementmap,{referencePosition:{value:new A},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distanceRGBA_vert,fragmentShader:$e.distanceRGBA_frag},shadow:{uniforms:Nn([me.lights,me.fog,{color:{value:new Ae(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};li.physical={uniforms:Nn([li.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new B(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Ae(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new B},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Ae(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Ae(1,1,1)},specularColorMap:{value:null}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};function NC(r,e,t,n,i,s){let o=new Ae(0),a=i===!0?0:1,l,c,h=null,u=0,d=null;function f(p,g){let x=!1,v=g.isScene===!0?g.background:null;v&&v.isTexture&&(v=e.get(v));let w=r.xr,b=w.getSession&&w.getSession();b&&b.environmentBlendMode==="additive"&&(v=null),v===null?m(o,a):v&&v.isColor&&(m(v,1),x=!0),(r.autoClear||x)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),v&&(v.isCubeTexture||v.mapping===ya)?(c===void 0&&(c=new Vt(new Zn(1,1,1),new dt({name:"BackgroundCubeMaterial",uniforms:na(li.cube.uniforms),vertexShader:li.cube.vertexShader,fragmentShader:li.cube.fragmentShader,side:wn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,M,_){this.matrixWorld.copyPosition(_.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=v,c.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,(h!==v||u!==v.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,h=v,u=v.version,d=r.toneMapping),c.layers.enableAll(),p.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(l===void 0&&(l=new Vt(new Gi(2,2),new dt({name:"BackgroundMaterial",uniforms:na(li.background.uniforms),vertexShader:li.background.vertexShader,fragmentShader:li.background.fragmentShader,side:zi,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=v,v.matrixAutoUpdate===!0&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),(h!==v||u!==v.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,h=v,u=v.version,d=r.toneMapping),l.layers.enableAll(),p.unshift(l,l.geometry,l.material,0,0,null))}function m(p,g){t.buffers.color.setClear(p.r,p.g,p.b,g,s)}return{getClearColor:function(){return o},setClearColor:function(p,g=1){o.set(p),a=g,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(p){a=p,m(o,a)},render:f}}function RC(r,e,t,n){let i=r.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=g(null),c=l,h=!1;function u(N,H,j,K,Y){let z=!1;if(o){let F=p(K,j,H);c!==F&&(c=F,f(c.object)),z=x(N,K,j,Y),z&&v(N,K,j,Y)}else{let F=H.wireframe===!0;(c.geometry!==K.id||c.program!==j.id||c.wireframe!==F)&&(c.geometry=K.id,c.program=j.id,c.wireframe=F,z=!0)}Y!==null&&t.update(Y,34963),(z||h)&&(h=!1,y(N,H,j,K),Y!==null&&r.bindBuffer(34963,t.get(Y).buffer))}function d(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function f(N){return n.isWebGL2?r.bindVertexArray(N):s.bindVertexArrayOES(N)}function m(N){return n.isWebGL2?r.deleteVertexArray(N):s.deleteVertexArrayOES(N)}function p(N,H,j){let K=j.wireframe===!0,Y=a[N.id];Y===void 0&&(Y={},a[N.id]=Y);let z=Y[H.id];z===void 0&&(z={},Y[H.id]=z);let F=z[K];return F===void 0&&(F=g(d()),z[K]=F),F}function g(N){let H=[],j=[],K=[];for(let Y=0;Y<i;Y++)H[Y]=0,j[Y]=0,K[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:H,enabledAttributes:j,attributeDivisors:K,object:N,attributes:{},index:null}}function x(N,H,j,K){let Y=c.attributes,z=H.attributes,F=0,V=j.getAttributes();for(let O in V)if(V[O].location>=0){let W=Y[O],X=z[O];if(X===void 0&&(O==="instanceMatrix"&&N.instanceMatrix&&(X=N.instanceMatrix),O==="instanceColor"&&N.instanceColor&&(X=N.instanceColor)),W===void 0||W.attribute!==X||X&&W.data!==X.data)return!0;F++}return c.attributesNum!==F||c.index!==K}function v(N,H,j,K){let Y={},z=H.attributes,F=0,V=j.getAttributes();for(let O in V)if(V[O].location>=0){let W=z[O];W===void 0&&(O==="instanceMatrix"&&N.instanceMatrix&&(W=N.instanceMatrix),O==="instanceColor"&&N.instanceColor&&(W=N.instanceColor));let X={};X.attribute=W,W&&W.data&&(X.data=W.data),Y[O]=X,F++}c.attributes=Y,c.attributesNum=F,c.index=K}function w(){let N=c.newAttributes;for(let H=0,j=N.length;H<j;H++)N[H]=0}function b(N){S(N,0)}function S(N,H){let j=c.newAttributes,K=c.enabledAttributes,Y=c.attributeDivisors;j[N]=1,K[N]===0&&(r.enableVertexAttribArray(N),K[N]=1),Y[N]!==H&&((n.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](N,H),Y[N]=H)}function M(){let N=c.newAttributes,H=c.enabledAttributes;for(let j=0,K=H.length;j<K;j++)H[j]!==N[j]&&(r.disableVertexAttribArray(j),H[j]=0)}function _(N,H,j,K,Y,z){n.isWebGL2===!0&&(j===5124||j===5125)?r.vertexAttribIPointer(N,H,j,Y,z):r.vertexAttribPointer(N,H,j,K,Y,z)}function y(N,H,j,K){if(n.isWebGL2===!1&&(N.isInstancedMesh||K.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();let Y=K.attributes,z=j.getAttributes(),F=H.defaultAttributeValues;for(let V in z){let O=z[V];if(O.location>=0){let G=Y[V];if(G===void 0&&(V==="instanceMatrix"&&N.instanceMatrix&&(G=N.instanceMatrix),V==="instanceColor"&&N.instanceColor&&(G=N.instanceColor)),G!==void 0){let W=G.normalized,X=G.itemSize,q=t.get(G);if(q===void 0)continue;let se=q.buffer,Z=q.type,te=q.bytesPerElement;if(G.isInterleavedBufferAttribute){let k=G.data,le=k.stride,ce=G.offset;if(k.isInstancedInterleavedBuffer){for(let ae=0;ae<O.locationSize;ae++)S(O.location+ae,k.meshPerAttribute);N.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=k.meshPerAttribute*k.count)}else for(let ae=0;ae<O.locationSize;ae++)b(O.location+ae);r.bindBuffer(34962,se);for(let ae=0;ae<O.locationSize;ae++)_(O.location+ae,X/O.locationSize,Z,W,le*te,(ce+X/O.locationSize*ae)*te)}else{if(G.isInstancedBufferAttribute){for(let k=0;k<O.locationSize;k++)S(O.location+k,G.meshPerAttribute);N.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=G.meshPerAttribute*G.count)}else for(let k=0;k<O.locationSize;k++)b(O.location+k);r.bindBuffer(34962,se);for(let k=0;k<O.locationSize;k++)_(O.location+k,X/O.locationSize,Z,W,X*te,X/O.locationSize*k*te)}}else if(F!==void 0){let W=F[V];if(W!==void 0)switch(W.length){case 2:r.vertexAttrib2fv(O.location,W);break;case 3:r.vertexAttrib3fv(O.location,W);break;case 4:r.vertexAttrib4fv(O.location,W);break;default:r.vertexAttrib1fv(O.location,W)}}}}M()}function T(){L();for(let N in a){let H=a[N];for(let j in H){let K=H[j];for(let Y in K)m(K[Y].object),delete K[Y];delete H[j]}delete a[N]}}function E(N){if(a[N.id]===void 0)return;let H=a[N.id];for(let j in H){let K=H[j];for(let Y in K)m(K[Y].object),delete K[Y];delete H[j]}delete a[N.id]}function C(N){for(let H in a){let j=a[H];if(j[N.id]===void 0)continue;let K=j[N.id];for(let Y in K)m(K[Y].object),delete K[Y];delete j[N.id]}}function L(){R(),h=!0,c!==l&&(c=l,f(c.object))}function R(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:u,reset:L,resetDefaultState:R,dispose:T,releaseStatesOfGeometry:E,releaseStatesOfProgram:C,initAttributes:w,enableAttribute:b,disableUnusedAttributes:M}}function BC(r,e,t,n){let i=n.isWebGL2,s;function o(c){s=c}function a(c,h){r.drawArrays(s,c,h),t.update(h,s,1)}function l(c,h,u){if(u===0)return;let d,f;if(i)d=r,f="drawArraysInstanced";else if(d=e.get("ANGLE_instanced_arrays"),f="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[f](s,c,h,u),t.update(h,s,u)}this.setMode=o,this.render=a,this.renderInstances=l}function OC(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){let _=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(_.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(_){if(_==="highp"){if(r.getShaderPrecisionFormat(35633,36338).precision>0&&r.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";_="mediump"}return _==="mediump"&&r.getShaderPrecisionFormat(35633,36337).precision>0&&r.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&r instanceof WebGL2ComputeRenderingContext,a=t.precision!==void 0?t.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let c=o||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,u=r.getParameter(34930),d=r.getParameter(35660),f=r.getParameter(3379),m=r.getParameter(34076),p=r.getParameter(34921),g=r.getParameter(36347),x=r.getParameter(36348),v=r.getParameter(36349),w=d>0,b=o||e.has("OES_texture_float"),S=w&&b,M=o?r.getParameter(36183):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:h,maxTextures:u,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:g,maxVaryings:x,maxFragmentUniforms:v,vertexTextures:w,floatFragmentTextures:b,floatVertexTextures:S,maxSamples:M}}function FC(r){let e=this,t=null,n=0,i=!1,s=!1,o=new kn,a=new qt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d,f){let m=u.length!==0||d||n!==0||i;return i=d,t=h(u,f,0),n=u.length,m},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1,c()},this.setState=function(u,d,f){let m=u.clippingPlanes,p=u.clipIntersection,g=u.clipShadows,x=r.get(u);if(!i||m===null||m.length===0||s&&!g)s?h(null):c();else{let v=s?0:n,w=v*4,b=x.clippingState||null;l.value=b,b=h(m,d,w,f);for(let S=0;S!==w;++S)b[S]=t[S];x.clippingState=b,this.numIntersection=p?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,f,m){let p=u!==null?u.length:0,g=null;if(p!==0){if(g=l.value,m!==!0||g===null){let x=f+p*4,v=d.matrixWorldInverse;a.getNormalMatrix(v),(g===null||g.length<x)&&(g=new Float32Array(x));for(let w=0,b=f;w!==p;++w,b+=4)o.copy(u[w]).applyMatrix4(v,a),o.normal.toArray(g,b),g[b+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=p,e.numIntersection=0,g}}function UC(r){let e=new WeakMap;function t(o,a){return a===jp?o.mapping=us:a===qp&&(o.mapping=ds),o}function n(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){let a=o.mapping;if(a===jp||a===qp)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let c=new $p(l.height/2);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}var ia=class extends kr{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Jo=4,d0=[.125,.215,.35,.446,.526,.582],$s=20,Bp=new ia,f0=new Ae,Op=null,Js=(1+Math.sqrt(5))/2,Ko=1/Js,p0=[new A(1,1,1),new A(-1,1,1),new A(1,1,-1),new A(-1,1,-1),new A(0,Js,Ko),new A(0,Js,-Ko),new A(Ko,0,Js),new A(-Ko,0,Js),new A(Js,Ko,0),new A(-Js,Ko,0)],vu=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Op=this._renderer.getRenderTarget(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=y0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=g0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Op),e.scissorTest=!1,tu(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===us||e.mapping===ds?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Op=this._renderer.getRenderTarget();let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:tt,minFilter:tt,generateMipmaps:!1,type:hc,format:xr,encoding:lr,depthBuffer:!1},i=m0(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=m0(e,t,n);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=zC(s)),this._blurMaterial=GC(s,e,t)}return i}_compileMaterial(e){let t=new Vt(this._lodPlanes[0],e);this._renderer.compile(t,Bp)}_sceneToCubeUV(e,t,n,i){let a=new Zt(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(f0),h.toneMapping=Ui,h.autoClear=!1;let f=new hi({name:"PMREM.Background",side:wn,depthWrite:!1,depthTest:!1}),m=new Vt(new Zn,f),p=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,p=!0):(f.color.copy(f0),p=!0);for(let x=0;x<6;x++){let v=x%3;v===0?(a.up.set(0,l[x],0),a.lookAt(c[x],0,0)):v===1?(a.up.set(0,0,l[x]),a.lookAt(0,c[x],0)):(a.up.set(0,l[x],0),a.lookAt(0,0,c[x]));let w=this._cubeSize;tu(i,v*w,x>2?w:0,w,w),h.setRenderTarget(i),p&&h.render(m,a),h.render(e,a)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=d,h.autoClear=u,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===us||e.mapping===ds;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=y0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=g0());let s=i?this._cubemapMaterial:this._equirectMaterial,o=new Vt(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let l=this._cubeSize;tu(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Bp)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){let s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=p0[(i-1)%p0.length];this._blur(e,i-1,i,s,o)}t.autoClear=n}_blur(e,t,n,i,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",s),this._halfBlur(o,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,u=new Vt(this._lodPlanes[i],c),d=c.uniforms,f=this._sizeLods[n]-1,m=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*$s-1),p=s/m,g=isFinite(s)?1+Math.floor(h*p):$s;g>$s&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${$s}`);let x=[],v=0;for(let _=0;_<$s;++_){let y=_/p,T=Math.exp(-y*y/2);x.push(T),_===0?v+=T:_<g&&(v+=2*T)}for(let _=0;_<x.length;_++)x[_]=x[_]/v;d.envMap.value=e.texture,d.samples.value=g,d.weights.value=x,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);let{_lodMax:w}=this;d.dTheta.value=m,d.mipInt.value=w-n;let b=this._sizeLods[i],S=3*b*(i>w-Jo?i-w+Jo:0),M=4*(this._cubeSize-b);tu(t,S,M,3*b,2*b),l.setRenderTarget(t),l.render(u,Bp)}};function zC(r){let e=[],t=[],n=[],i=r,s=r-Jo+1+d0.length;for(let o=0;o<s;o++){let a=Math.pow(2,i);t.push(a);let l=1/a;o>r-Jo?l=d0[o-r+Jo-1]:o===0&&(l=0),n.push(l);let c=1/(a-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,p=3,g=2,x=1,v=new Float32Array(p*m*f),w=new Float32Array(g*m*f),b=new Float32Array(x*m*f);for(let M=0;M<f;M++){let _=M%3*2/3-1,y=M>2?0:-1,T=[_,y,0,_+2/3,y,0,_+2/3,y+1,0,_,y,0,_+2/3,y+1,0,_,y+1,0];v.set(T,p*m*M),w.set(d,g*m*M);let E=[M,M,M,M,M,M];b.set(E,x*m*M)}let S=new Ie;S.setAttribute("position",new Xe(v,p)),S.setAttribute("uv",new Xe(w,g)),S.setAttribute("faceIndex",new Xe(b,x)),e.push(S),i>Jo&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function m0(r,e,t){let n=new lt(r,e,t);return n.texture.mapping=ya,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function tu(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function GC(r,e,t){let n=new Float32Array($s),i=new A(0,1,0);return new dt({name:"SphericalGaussianBlur",defines:{n:$s,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Hm(),fragmentShader:`
|
|
2929
|
+
}`,$e={alphamap_fragment:iT,alphamap_pars_fragment:sT,alphatest_fragment:oT,alphatest_pars_fragment:aT,aomap_fragment:lT,aomap_pars_fragment:cT,begin_vertex:hT,beginnormal_vertex:uT,bsdfs:dT,iridescence_fragment:fT,bumpmap_pars_fragment:pT,clipping_planes_fragment:mT,clipping_planes_pars_fragment:gT,clipping_planes_pars_vertex:yT,clipping_planes_vertex:vT,color_fragment:xT,color_pars_fragment:bT,color_pars_vertex:wT,color_vertex:ST,common:AT,cube_uv_reflection_fragment:MT,defaultnormal_vertex:_T,displacementmap_pars_vertex:TT,displacementmap_vertex:ET,emissivemap_fragment:CT,emissivemap_pars_fragment:DT,encodings_fragment:PT,encodings_pars_fragment:LT,envmap_fragment:IT,envmap_common_pars_fragment:NT,envmap_pars_fragment:RT,envmap_pars_vertex:BT,envmap_physical_pars_fragment:qT,envmap_vertex:OT,fog_vertex:FT,fog_pars_vertex:UT,fog_fragment:zT,fog_pars_fragment:GT,gradientmap_pars_fragment:kT,lightmap_fragment:VT,lightmap_pars_fragment:HT,lights_lambert_vertex:WT,lights_pars_begin:jT,lights_toon_fragment:XT,lights_toon_pars_fragment:YT,lights_phong_fragment:QT,lights_phong_pars_fragment:KT,lights_physical_fragment:ZT,lights_physical_pars_fragment:JT,lights_fragment_begin:$T,lights_fragment_maps:eE,lights_fragment_end:tE,logdepthbuf_fragment:nE,logdepthbuf_pars_fragment:rE,logdepthbuf_pars_vertex:iE,logdepthbuf_vertex:sE,map_fragment:oE,map_pars_fragment:aE,map_particle_fragment:lE,map_particle_pars_fragment:cE,metalnessmap_fragment:hE,metalnessmap_pars_fragment:uE,morphcolor_vertex:dE,morphnormal_vertex:fE,morphtarget_pars_vertex:pE,morphtarget_vertex:mE,normal_fragment_begin:gE,normal_fragment_maps:yE,normal_pars_fragment:vE,normal_pars_vertex:xE,normal_vertex:bE,normalmap_pars_fragment:wE,clearcoat_normal_fragment_begin:SE,clearcoat_normal_fragment_maps:AE,clearcoat_pars_fragment:ME,iridescence_pars_fragment:_E,output_fragment:TE,packing:EE,premultiplied_alpha_fragment:CE,project_vertex:DE,dithering_fragment:PE,dithering_pars_fragment:LE,roughnessmap_fragment:IE,roughnessmap_pars_fragment:NE,shadowmap_pars_fragment:RE,shadowmap_pars_vertex:BE,shadowmap_vertex:OE,shadowmask_pars_fragment:FE,skinbase_vertex:UE,skinning_pars_vertex:zE,skinning_vertex:GE,skinnormal_vertex:kE,specularmap_fragment:VE,specularmap_pars_fragment:HE,tonemapping_fragment:WE,tonemapping_pars_fragment:jE,transmission_fragment:qE,transmission_pars_fragment:XE,uv_pars_fragment:YE,uv_pars_vertex:QE,uv_vertex:KE,uv2_pars_fragment:ZE,uv2_pars_vertex:JE,uv2_vertex:$E,worldpos_vertex:eC,background_vert:tC,background_frag:nC,cube_vert:rC,cube_frag:iC,depth_vert:sC,depth_frag:oC,distanceRGBA_vert:aC,distanceRGBA_frag:lC,equirect_vert:cC,equirect_frag:hC,linedashed_vert:uC,linedashed_frag:dC,meshbasic_vert:fC,meshbasic_frag:pC,meshlambert_vert:mC,meshlambert_frag:gC,meshmatcap_vert:yC,meshmatcap_frag:vC,meshnormal_vert:xC,meshnormal_frag:bC,meshphong_vert:wC,meshphong_frag:SC,meshphysical_vert:AC,meshphysical_frag:MC,meshtoon_vert:_C,meshtoon_frag:TC,points_vert:EC,points_frag:CC,shadow_vert:DC,shadow_frag:PC,sprite_vert:LC,sprite_frag:IC},me={common:{diffuse:{value:new Ae(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new qt},uv2Transform:{value:new qt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new B(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ae(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ae(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new qt}},sprite:{diffuse:{value:new Ae(16777215)},opacity:{value:1},center:{value:new B(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new qt}}},li={basic:{uniforms:Nn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:Nn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.fog,me.lights,{emissive:{value:new Ae(0)}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:Nn([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new Ae(0)},specular:{value:new Ae(1118481)},shininess:{value:30}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:Nn([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new Ae(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:Nn([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new Ae(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:Nn([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:Nn([me.points,me.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:Nn([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:Nn([me.common,me.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:Nn([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:Nn([me.sprite,me.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qt},t2D:{value:null}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},cube:{uniforms:Nn([me.envmap,{opacity:{value:1}}]),vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distanceRGBA:{uniforms:Nn([me.common,me.displacementmap,{referencePosition:{value:new A},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distanceRGBA_vert,fragmentShader:$e.distanceRGBA_frag},shadow:{uniforms:Nn([me.lights,me.fog,{color:{value:new Ae(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};li.physical={uniforms:Nn([li.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new B(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Ae(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new B},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Ae(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Ae(1,1,1)},specularColorMap:{value:null}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};function NC(r,e,t,n,i,s){let o=new Ae(0),a=i===!0?0:1,l,c,h=null,u=0,d=null;function f(p,g){let x=!1,v=g.isScene===!0?g.background:null;v&&v.isTexture&&(v=e.get(v));let w=r.xr,b=w.getSession&&w.getSession();b&&b.environmentBlendMode==="additive"&&(v=null),v===null?m(o,a):v&&v.isColor&&(m(v,1),x=!0),(r.autoClear||x)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),v&&(v.isCubeTexture||v.mapping===ya)?(c===void 0&&(c=new Vt(new Zn(1,1,1),new dt({name:"BackgroundCubeMaterial",uniforms:na(li.cube.uniforms),vertexShader:li.cube.vertexShader,fragmentShader:li.cube.fragmentShader,side:wn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,M,_){this.matrixWorld.copyPosition(_.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=v,c.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,(h!==v||u!==v.version||d!==r.toneMapping)&&(c.material.needsUpdate=!0,h=v,u=v.version,d=r.toneMapping),c.layers.enableAll(),p.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(l===void 0&&(l=new Vt(new Gi(2,2),new dt({name:"BackgroundMaterial",uniforms:na(li.background.uniforms),vertexShader:li.background.vertexShader,fragmentShader:li.background.fragmentShader,side:zi,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=v,v.matrixAutoUpdate===!0&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),(h!==v||u!==v.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,h=v,u=v.version,d=r.toneMapping),l.layers.enableAll(),p.unshift(l,l.geometry,l.material,0,0,null))}function m(p,g){t.buffers.color.setClear(p.r,p.g,p.b,g,s)}return{getClearColor:function(){return o},setClearColor:function(p,g=1){o.set(p),a=g,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(p){a=p,m(o,a)},render:f}}function RC(r,e,t,n){let i=r.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=g(null),c=l,h=!1;function u(N,H,j,K,Y){let z=!1;if(o){let F=p(K,j,H);c!==F&&(c=F,f(c.object)),z=x(N,K,j,Y),z&&v(N,K,j,Y)}else{let F=H.wireframe===!0;(c.geometry!==K.id||c.program!==j.id||c.wireframe!==F)&&(c.geometry=K.id,c.program=j.id,c.wireframe=F,z=!0)}Y!==null&&t.update(Y,34963),(z||h)&&(h=!1,y(N,H,j,K),Y!==null&&r.bindBuffer(34963,t.get(Y).buffer))}function d(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function f(N){return n.isWebGL2?r.bindVertexArray(N):s.bindVertexArrayOES(N)}function m(N){return n.isWebGL2?r.deleteVertexArray(N):s.deleteVertexArrayOES(N)}function p(N,H,j){let K=j.wireframe===!0,Y=a[N.id];Y===void 0&&(Y={},a[N.id]=Y);let z=Y[H.id];z===void 0&&(z={},Y[H.id]=z);let F=z[K];return F===void 0&&(F=g(d()),z[K]=F),F}function g(N){let H=[],j=[],K=[];for(let Y=0;Y<i;Y++)H[Y]=0,j[Y]=0,K[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:H,enabledAttributes:j,attributeDivisors:K,object:N,attributes:{},index:null}}function x(N,H,j,K){let Y=c.attributes,z=H.attributes,F=0,V=j.getAttributes();for(let O in V)if(V[O].location>=0){let W=Y[O],X=z[O];if(X===void 0&&(O==="instanceMatrix"&&N.instanceMatrix&&(X=N.instanceMatrix),O==="instanceColor"&&N.instanceColor&&(X=N.instanceColor)),W===void 0||W.attribute!==X||X&&W.data!==X.data)return!0;F++}return c.attributesNum!==F||c.index!==K}function v(N,H,j,K){let Y={},z=H.attributes,F=0,V=j.getAttributes();for(let O in V)if(V[O].location>=0){let W=z[O];W===void 0&&(O==="instanceMatrix"&&N.instanceMatrix&&(W=N.instanceMatrix),O==="instanceColor"&&N.instanceColor&&(W=N.instanceColor));let X={};X.attribute=W,W&&W.data&&(X.data=W.data),Y[O]=X,F++}c.attributes=Y,c.attributesNum=F,c.index=K}function w(){let N=c.newAttributes;for(let H=0,j=N.length;H<j;H++)N[H]=0}function b(N){S(N,0)}function S(N,H){let j=c.newAttributes,K=c.enabledAttributes,Y=c.attributeDivisors;j[N]=1,K[N]===0&&(r.enableVertexAttribArray(N),K[N]=1),Y[N]!==H&&((n.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](N,H),Y[N]=H)}function M(){let N=c.newAttributes,H=c.enabledAttributes;for(let j=0,K=H.length;j<K;j++)H[j]!==N[j]&&(r.disableVertexAttribArray(j),H[j]=0)}function _(N,H,j,K,Y,z){n.isWebGL2===!0&&(j===5124||j===5125)?r.vertexAttribIPointer(N,H,j,Y,z):r.vertexAttribPointer(N,H,j,K,Y,z)}function y(N,H,j,K){if(n.isWebGL2===!1&&(N.isInstancedMesh||K.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();let Y=K.attributes,z=j.getAttributes(),F=H.defaultAttributeValues;for(let V in z){let O=z[V];if(O.location>=0){let G=Y[V];if(G===void 0&&(V==="instanceMatrix"&&N.instanceMatrix&&(G=N.instanceMatrix),V==="instanceColor"&&N.instanceColor&&(G=N.instanceColor)),G!==void 0){let W=G.normalized,X=G.itemSize,q=t.get(G);if(q===void 0)continue;let se=q.buffer,Z=q.type,te=q.bytesPerElement;if(G.isInterleavedBufferAttribute){let k=G.data,le=k.stride,ce=G.offset;if(k.isInstancedInterleavedBuffer){for(let ae=0;ae<O.locationSize;ae++)S(O.location+ae,k.meshPerAttribute);N.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=k.meshPerAttribute*k.count)}else for(let ae=0;ae<O.locationSize;ae++)b(O.location+ae);r.bindBuffer(34962,se);for(let ae=0;ae<O.locationSize;ae++)_(O.location+ae,X/O.locationSize,Z,W,le*te,(ce+X/O.locationSize*ae)*te)}else{if(G.isInstancedBufferAttribute){for(let k=0;k<O.locationSize;k++)S(O.location+k,G.meshPerAttribute);N.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=G.meshPerAttribute*G.count)}else for(let k=0;k<O.locationSize;k++)b(O.location+k);r.bindBuffer(34962,se);for(let k=0;k<O.locationSize;k++)_(O.location+k,X/O.locationSize,Z,W,X*te,X/O.locationSize*k*te)}}else if(F!==void 0){let W=F[V];if(W!==void 0)switch(W.length){case 2:r.vertexAttrib2fv(O.location,W);break;case 3:r.vertexAttrib3fv(O.location,W);break;case 4:r.vertexAttrib4fv(O.location,W);break;default:r.vertexAttrib1fv(O.location,W)}}}}M()}function T(){I();for(let N in a){let H=a[N];for(let j in H){let K=H[j];for(let Y in K)m(K[Y].object),delete K[Y];delete H[j]}delete a[N]}}function E(N){if(a[N.id]===void 0)return;let H=a[N.id];for(let j in H){let K=H[j];for(let Y in K)m(K[Y].object),delete K[Y];delete H[j]}delete a[N.id]}function C(N){for(let H in a){let j=a[H];if(j[N.id]===void 0)continue;let K=j[N.id];for(let Y in K)m(K[Y].object),delete K[Y];delete j[N.id]}}function I(){R(),h=!0,c!==l&&(c=l,f(c.object))}function R(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:u,reset:I,resetDefaultState:R,dispose:T,releaseStatesOfGeometry:E,releaseStatesOfProgram:C,initAttributes:w,enableAttribute:b,disableUnusedAttributes:M}}function BC(r,e,t,n){let i=n.isWebGL2,s;function o(c){s=c}function a(c,h){r.drawArrays(s,c,h),t.update(h,s,1)}function l(c,h,u){if(u===0)return;let d,f;if(i)d=r,f="drawArraysInstanced";else if(d=e.get("ANGLE_instanced_arrays"),f="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[f](s,c,h,u),t.update(h,s,u)}this.setMode=o,this.render=a,this.renderInstances=l}function OC(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){let _=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(_.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(_){if(_==="highp"){if(r.getShaderPrecisionFormat(35633,36338).precision>0&&r.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";_="mediump"}return _==="mediump"&&r.getShaderPrecisionFormat(35633,36337).precision>0&&r.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&r instanceof WebGL2ComputeRenderingContext,a=t.precision!==void 0?t.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let c=o||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,u=r.getParameter(34930),d=r.getParameter(35660),f=r.getParameter(3379),m=r.getParameter(34076),p=r.getParameter(34921),g=r.getParameter(36347),x=r.getParameter(36348),v=r.getParameter(36349),w=d>0,b=o||e.has("OES_texture_float"),S=w&&b,M=o?r.getParameter(36183):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:h,maxTextures:u,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:g,maxVaryings:x,maxFragmentUniforms:v,vertexTextures:w,floatFragmentTextures:b,floatVertexTextures:S,maxSamples:M}}function FC(r){let e=this,t=null,n=0,i=!1,s=!1,o=new kn,a=new qt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d,f){let m=u.length!==0||d||n!==0||i;return i=d,t=h(u,f,0),n=u.length,m},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1,c()},this.setState=function(u,d,f){let m=u.clippingPlanes,p=u.clipIntersection,g=u.clipShadows,x=r.get(u);if(!i||m===null||m.length===0||s&&!g)s?h(null):c();else{let v=s?0:n,w=v*4,b=x.clippingState||null;l.value=b,b=h(m,d,w,f);for(let S=0;S!==w;++S)b[S]=t[S];x.clippingState=b,this.numIntersection=p?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,f,m){let p=u!==null?u.length:0,g=null;if(p!==0){if(g=l.value,m!==!0||g===null){let x=f+p*4,v=d.matrixWorldInverse;a.getNormalMatrix(v),(g===null||g.length<x)&&(g=new Float32Array(x));for(let w=0,b=f;w!==p;++w,b+=4)o.copy(u[w]).applyMatrix4(v,a),o.normal.toArray(g,b),g[b+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=p,e.numIntersection=0,g}}function UC(r){let e=new WeakMap;function t(o,a){return a===jp?o.mapping=us:a===qp&&(o.mapping=ds),o}function n(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){let a=o.mapping;if(a===jp||a===qp)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let c=new $p(l.height/2);return c.fromEquirectangularTexture(r,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}var ia=class extends kr{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Jo=4,d0=[.125,.215,.35,.446,.526,.582],$s=20,Bp=new ia,f0=new Ae,Op=null,Js=(1+Math.sqrt(5))/2,Ko=1/Js,p0=[new A(1,1,1),new A(-1,1,1),new A(1,1,-1),new A(-1,1,-1),new A(0,Js,Ko),new A(0,Js,-Ko),new A(Ko,0,Js),new A(-Ko,0,Js),new A(Js,Ko,0),new A(-Js,Ko,0)],vu=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Op=this._renderer.getRenderTarget(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=y0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=g0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Op),e.scissorTest=!1,tu(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===us||e.mapping===ds?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Op=this._renderer.getRenderTarget();let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:tt,minFilter:tt,generateMipmaps:!1,type:hc,format:xr,encoding:lr,depthBuffer:!1},i=m0(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=m0(e,t,n);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=zC(s)),this._blurMaterial=GC(s,e,t)}return i}_compileMaterial(e){let t=new Vt(this._lodPlanes[0],e);this._renderer.compile(t,Bp)}_sceneToCubeUV(e,t,n,i){let a=new Zt(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(f0),h.toneMapping=Ui,h.autoClear=!1;let f=new hi({name:"PMREM.Background",side:wn,depthWrite:!1,depthTest:!1}),m=new Vt(new Zn,f),p=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,p=!0):(f.color.copy(f0),p=!0);for(let x=0;x<6;x++){let v=x%3;v===0?(a.up.set(0,l[x],0),a.lookAt(c[x],0,0)):v===1?(a.up.set(0,0,l[x]),a.lookAt(0,c[x],0)):(a.up.set(0,l[x],0),a.lookAt(0,0,c[x]));let w=this._cubeSize;tu(i,v*w,x>2?w:0,w,w),h.setRenderTarget(i),p&&h.render(m,a),h.render(e,a)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=d,h.autoClear=u,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===us||e.mapping===ds;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=y0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=g0());let s=i?this._cubemapMaterial:this._equirectMaterial,o=new Vt(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let l=this._cubeSize;tu(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Bp)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){let s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=p0[(i-1)%p0.length];this._blur(e,i-1,i,s,o)}t.autoClear=n}_blur(e,t,n,i,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",s),this._halfBlur(o,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,u=new Vt(this._lodPlanes[i],c),d=c.uniforms,f=this._sizeLods[n]-1,m=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*$s-1),p=s/m,g=isFinite(s)?1+Math.floor(h*p):$s;g>$s&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${$s}`);let x=[],v=0;for(let _=0;_<$s;++_){let y=_/p,T=Math.exp(-y*y/2);x.push(T),_===0?v+=T:_<g&&(v+=2*T)}for(let _=0;_<x.length;_++)x[_]=x[_]/v;d.envMap.value=e.texture,d.samples.value=g,d.weights.value=x,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);let{_lodMax:w}=this;d.dTheta.value=m,d.mipInt.value=w-n;let b=this._sizeLods[i],S=3*b*(i>w-Jo?i-w+Jo:0),M=4*(this._cubeSize-b);tu(t,S,M,3*b,2*b),l.setRenderTarget(t),l.render(u,Bp)}};function zC(r){let e=[],t=[],n=[],i=r,s=r-Jo+1+d0.length;for(let o=0;o<s;o++){let a=Math.pow(2,i);t.push(a);let l=1/a;o>r-Jo?l=d0[o-r+Jo-1]:o===0&&(l=0),n.push(l);let c=1/(a-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,p=3,g=2,x=1,v=new Float32Array(p*m*f),w=new Float32Array(g*m*f),b=new Float32Array(x*m*f);for(let M=0;M<f;M++){let _=M%3*2/3-1,y=M>2?0:-1,T=[_,y,0,_+2/3,y,0,_+2/3,y+1,0,_,y,0,_+2/3,y+1,0,_,y+1,0];v.set(T,p*m*M),w.set(d,g*m*M);let E=[M,M,M,M,M,M];b.set(E,x*m*M)}let S=new Le;S.setAttribute("position",new Xe(v,p)),S.setAttribute("uv",new Xe(w,g)),S.setAttribute("faceIndex",new Xe(b,x)),e.push(S),i>Jo&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function m0(r,e,t){let n=new lt(r,e,t);return n.texture.mapping=ya,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function tu(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function GC(r,e,t){let n=new Float32Array($s),i=new A(0,1,0);return new dt({name:"SphericalGaussianBlur",defines:{n:$s,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Hm(),fragmentShader:`
|
|
2930
2930
|
|
|
2931
2931
|
precision mediump float;
|
|
2932
2932
|
precision mediump int;
|
|
@@ -3076,7 +3076,7 @@ void main() {
|
|
|
3076
3076
|
gl_Position = vec4( position, 1.0 );
|
|
3077
3077
|
|
|
3078
3078
|
}
|
|
3079
|
-
`}function kC(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let l=a.mapping,c=l===jp||l===qp,h=l===us||l===ds;if(c||h)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let u=e.get(a);return t===null&&(t=new vu(r)),u=c?t.fromEquirectangular(a,u):t.fromCubemap(a,u),e.set(a,u),u.texture}else{if(e.has(a))return e.get(a).texture;{let u=a.image;if(c&&u&&u.height>0||h&&u&&i(u)){t===null&&(t=new vu(r));let d=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function i(a){let l=0,c=6;for(let h=0;h<c;h++)a[h]!==void 0&&l++;return l===c}function s(a){let l=a.target;l.removeEventListener("dispose",s);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function VC(r){let e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){let i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function HC(r,e,t,n){let i={},s=new WeakMap;function o(u){let d=u.target;d.index!==null&&e.remove(d.index);for(let m in d.attributes)e.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete i[d.id];let f=s.get(d);f&&(e.remove(f),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(u,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,t.memory.geometries++),d}function l(u){let d=u.attributes;for(let m in d)e.update(d[m],34962);let f=u.morphAttributes;for(let m in f){let p=f[m];for(let g=0,x=p.length;g<x;g++)e.update(p[g],34962)}}function c(u){let d=[],f=u.index,m=u.attributes.position,p=0;if(f!==null){let v=f.array;p=f.version;for(let w=0,b=v.length;w<b;w+=3){let S=v[w+0],M=v[w+1],_=v[w+2];d.push(S,M,M,_,_,S)}}else{let v=m.array;p=m.version;for(let w=0,b=v.length/3-1;w<b;w+=3){let S=w+0,M=w+1,_=w+2;d.push(S,M,M,_,_,S)}}let g=new(rx(d)?ps:yu)(d,1);g.version=p;let x=s.get(u);x&&e.remove(x),s.set(u,g)}function h(u){let d=s.get(u);if(d){let f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return s.get(u)}return{get:a,update:l,getWireframeAttribute:h}}function WC(r,e,t,n){let i=n.isWebGL2,s;function o(d){s=d}let a,l;function c(d){a=d.type,l=d.bytesPerElement}function h(d,f){r.drawElements(s,f,a,d*l),t.update(f,s,1)}function u(d,f,m){if(m===0)return;let p,g;if(i)p=r,g="drawElementsInstanced";else if(p=e.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",p===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[g](s,f,a,d*l,m),t.update(f,s,m)}this.setMode=o,this.setIndex=c,this.render=h,this.renderInstances=u}function jC(r){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case 4:t.triangles+=a*(s/3);break;case 1:t.lines+=a*(s/2);break;case 3:t.lines+=a*(s-1);break;case 2:t.lines+=a*s;break;case 0:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function qC(r,e){return r[0]-e[0]}function XC(r,e){return Math.abs(e[1])-Math.abs(r[1])}function Fp(r,e){let t=1,n=e.isInterleavedBufferAttribute?e.data.array:e.array;n instanceof Int8Array?t=127:n instanceof Int16Array?t=32767:n instanceof Int32Array?t=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",n),r.divideScalar(t)}function YC(r,e,t){let n={},i=new Float32Array(8),s=new WeakMap,o=new qe,a=[];for(let c=0;c<8;c++)a[c]=[c,0];function l(c,h,u,d){let f=c.morphTargetInfluences;if(e.isWebGL2===!0){let m=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,p=m!==void 0?m.length:0,g=s.get(h);if(g===void 0||g.count!==p){let H=function(){R.dispose(),s.delete(h),h.removeEventListener("dispose",H)};g!==void 0&&g.texture.dispose();let w=h.morphAttributes.position!==void 0,b=h.morphAttributes.normal!==void 0,S=h.morphAttributes.color!==void 0,M=h.morphAttributes.position||[],_=h.morphAttributes.normal||[],y=h.morphAttributes.color||[],T=0;w===!0&&(T=1),b===!0&&(T=2),S===!0&&(T=3);let E=h.attributes.position.count*T,C=1;E>e.maxTextureSize&&(C=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);let L=new Float32Array(E*C*4*p),R=new gu(L,E,C,p);R.type=vr,R.needsUpdate=!0;let N=T*4;for(let j=0;j<p;j++){let K=M[j],Y=_[j],z=y[j],F=E*C*4*j;for(let V=0;V<K.count;V++){let O=V*N;w===!0&&(o.fromBufferAttribute(K,V),K.normalized===!0&&Fp(o,K),L[F+O+0]=o.x,L[F+O+1]=o.y,L[F+O+2]=o.z,L[F+O+3]=0),b===!0&&(o.fromBufferAttribute(Y,V),Y.normalized===!0&&Fp(o,Y),L[F+O+4]=o.x,L[F+O+5]=o.y,L[F+O+6]=o.z,L[F+O+7]=0),S===!0&&(o.fromBufferAttribute(z,V),z.normalized===!0&&Fp(o,z),L[F+O+8]=o.x,L[F+O+9]=o.y,L[F+O+10]=o.z,L[F+O+11]=z.itemSize===4?o.w:1)}}g={count:p,texture:R,size:new B(E,C)},s.set(h,g),h.addEventListener("dispose",H)}let x=0;for(let w=0;w<f.length;w++)x+=f[w];let v=h.morphTargetsRelative?1:1-x;d.getUniforms().setValue(r,"morphTargetBaseInfluence",v),d.getUniforms().setValue(r,"morphTargetInfluences",f),d.getUniforms().setValue(r,"morphTargetsTexture",g.texture,t),d.getUniforms().setValue(r,"morphTargetsTextureSize",g.size)}else{let m=f===void 0?0:f.length,p=n[h.id];if(p===void 0||p.length!==m){p=[];for(let b=0;b<m;b++)p[b]=[b,0];n[h.id]=p}for(let b=0;b<m;b++){let S=p[b];S[0]=b,S[1]=f[b]}p.sort(XC);for(let b=0;b<8;b++)b<m&&p[b][1]?(a[b][0]=p[b][0],a[b][1]=p[b][1]):(a[b][0]=Number.MAX_SAFE_INTEGER,a[b][1]=0);a.sort(qC);let g=h.morphAttributes.position,x=h.morphAttributes.normal,v=0;for(let b=0;b<8;b++){let S=a[b],M=S[0],_=S[1];M!==Number.MAX_SAFE_INTEGER&&_?(g&&h.getAttribute("morphTarget"+b)!==g[M]&&h.setAttribute("morphTarget"+b,g[M]),x&&h.getAttribute("morphNormal"+b)!==x[M]&&h.setAttribute("morphNormal"+b,x[M]),i[b]=_,v+=_):(g&&h.hasAttribute("morphTarget"+b)===!0&&h.deleteAttribute("morphTarget"+b),x&&h.hasAttribute("morphNormal"+b)===!0&&h.deleteAttribute("morphNormal"+b),i[b]=0)}let w=h.morphTargetsRelative?1:1-v;d.getUniforms().setValue(r,"morphTargetBaseInfluence",w),d.getUniforms().setValue(r,"morphTargetInfluences",i)}}return{update:l}}function QC(r,e,t,n){let i=new WeakMap;function s(l){let c=n.render.frame,h=l.geometry,u=e.get(l,h);return i.get(u)!==c&&(e.update(u),i.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),t.update(l.instanceMatrix,34962),l.instanceColor!==null&&t.update(l.instanceColor,34962)),u}function o(){i=new WeakMap}function a(l){let c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:o}}var ox=new Bt,ax=new gu,lx=new Zp,cx=new ra,v0=[],x0=[],b0=new Float32Array(16),w0=new Float32Array(9),S0=new Float32Array(4);function xa(r,e,t){let n=r[0];if(n<=0||n>0)return r;let i=e*t,s=v0[i];if(s===void 0&&(s=new Float32Array(i),v0[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function Vn(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Hn(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function Fu(r,e){let t=x0[e];t===void 0&&(t=new Int32Array(e),x0[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function KC(r,e){let t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function ZC(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Vn(t,e))return;r.uniform2fv(this.addr,e),Hn(t,e)}}function JC(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Vn(t,e))return;r.uniform3fv(this.addr,e),Hn(t,e)}}function $C(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Vn(t,e))return;r.uniform4fv(this.addr,e),Hn(t,e)}}function e2(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Vn(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),Hn(t,e)}else{if(Vn(t,n))return;S0.set(n),r.uniformMatrix2fv(this.addr,!1,S0),Hn(t,n)}}function t2(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Vn(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),Hn(t,e)}else{if(Vn(t,n))return;w0.set(n),r.uniformMatrix3fv(this.addr,!1,w0),Hn(t,n)}}function n2(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Vn(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),Hn(t,e)}else{if(Vn(t,n))return;b0.set(n),r.uniformMatrix4fv(this.addr,!1,b0),Hn(t,n)}}function r2(r,e){let t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function i2(r,e){let t=this.cache;Vn(t,e)||(r.uniform2iv(this.addr,e),Hn(t,e))}function s2(r,e){let t=this.cache;Vn(t,e)||(r.uniform3iv(this.addr,e),Hn(t,e))}function o2(r,e){let t=this.cache;Vn(t,e)||(r.uniform4iv(this.addr,e),Hn(t,e))}function a2(r,e){let t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function l2(r,e){let t=this.cache;Vn(t,e)||(r.uniform2uiv(this.addr,e),Hn(t,e))}function c2(r,e){let t=this.cache;Vn(t,e)||(r.uniform3uiv(this.addr,e),Hn(t,e))}function h2(r,e){let t=this.cache;Vn(t,e)||(r.uniform4uiv(this.addr,e),Hn(t,e))}function u2(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2D(e||ox,i)}function d2(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||lx,i)}function f2(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||cx,i)}function p2(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||ax,i)}function m2(r){switch(r){case 5126:return KC;case 35664:return ZC;case 35665:return JC;case 35666:return $C;case 35674:return e2;case 35675:return t2;case 35676:return n2;case 5124:case 35670:return r2;case 35667:case 35671:return i2;case 35668:case 35672:return s2;case 35669:case 35673:return o2;case 5125:return a2;case 36294:return l2;case 36295:return c2;case 36296:return h2;case 35678:case 36198:case 36298:case 36306:case 35682:return u2;case 35679:case 36299:case 36307:return d2;case 35680:case 36300:case 36308:case 36293:return f2;case 36289:case 36303:case 36311:case 36292:return p2}}function g2(r,e){r.uniform1fv(this.addr,e)}function y2(r,e){let t=xa(e,this.size,2);r.uniform2fv(this.addr,t)}function v2(r,e){let t=xa(e,this.size,3);r.uniform3fv(this.addr,t)}function x2(r,e){let t=xa(e,this.size,4);r.uniform4fv(this.addr,t)}function b2(r,e){let t=xa(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function w2(r,e){let t=xa(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function S2(r,e){let t=xa(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function A2(r,e){r.uniform1iv(this.addr,e)}function M2(r,e){r.uniform2iv(this.addr,e)}function _2(r,e){r.uniform3iv(this.addr,e)}function T2(r,e){r.uniform4iv(this.addr,e)}function E2(r,e){r.uniform1uiv(this.addr,e)}function C2(r,e){r.uniform2uiv(this.addr,e)}function D2(r,e){r.uniform3uiv(this.addr,e)}function P2(r,e){r.uniform4uiv(this.addr,e)}function I2(r,e,t){let n=e.length,i=Fu(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture2D(e[s]||ox,i[s])}function L2(r,e,t){let n=e.length,i=Fu(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture3D(e[s]||lx,i[s])}function N2(r,e,t){let n=e.length,i=Fu(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTextureCube(e[s]||cx,i[s])}function R2(r,e,t){let n=e.length,i=Fu(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture2DArray(e[s]||ax,i[s])}function B2(r){switch(r){case 5126:return g2;case 35664:return y2;case 35665:return v2;case 35666:return x2;case 35674:return b2;case 35675:return w2;case 35676:return S2;case 5124:case 35670:return A2;case 35667:case 35671:return M2;case 35668:case 35672:return _2;case 35669:case 35673:return T2;case 5125:return E2;case 36294:return C2;case 36295:return D2;case 36296:return P2;case 35678:case 36198:case 36298:case 36306:case 35682:return I2;case 35679:case 36299:case 36307:return L2;case 35680:case 36300:case 36308:case 36293:return N2;case 36289:case 36303:case 36311:case 36292:return R2}}var em=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=m2(t.type)}},tm=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=B2(t.type)}},nm=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let s=0,o=i.length;s!==o;++s){let a=i[s];a.setValue(e,t[a.id],n)}}},Up=/(\w+)(\])?(\[|\.)?/g;function A0(r,e){r.seq.push(e),r.map[e.id]=e}function O2(r,e,t){let n=r.name,i=n.length;for(Up.lastIndex=0;;){let s=Up.exec(n),o=Up.lastIndex,a=s[1],l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===i){A0(t,c===void 0?new em(a,r,e):new tm(a,r,e));break}else{let u=t.map[a];u===void 0&&(u=new nm(a),A0(t,u)),t=u}}}var ea=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,35718);for(let i=0;i<n;++i){let s=e.getActiveUniform(t,i),o=e.getUniformLocation(t,s.name);O2(s,o,this)}}setValue(e,t,n,i){let s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,o=t.length;s!==o;++s){let a=t[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,s=e.length;i!==s;++i){let o=e[i];o.id in t&&n.push(o)}return n}};function M0(r,e,t){let n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}var F2=0;function U2(r,e){let t=r.split(`
|
|
3079
|
+
`}function kC(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let l=a.mapping,c=l===jp||l===qp,h=l===us||l===ds;if(c||h)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let u=e.get(a);return t===null&&(t=new vu(r)),u=c?t.fromEquirectangular(a,u):t.fromCubemap(a,u),e.set(a,u),u.texture}else{if(e.has(a))return e.get(a).texture;{let u=a.image;if(c&&u&&u.height>0||h&&u&&i(u)){t===null&&(t=new vu(r));let d=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function i(a){let l=0,c=6;for(let h=0;h<c;h++)a[h]!==void 0&&l++;return l===c}function s(a){let l=a.target;l.removeEventListener("dispose",s);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function VC(r){let e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){let i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function HC(r,e,t,n){let i={},s=new WeakMap;function o(u){let d=u.target;d.index!==null&&e.remove(d.index);for(let m in d.attributes)e.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete i[d.id];let f=s.get(d);f&&(e.remove(f),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(u,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,t.memory.geometries++),d}function l(u){let d=u.attributes;for(let m in d)e.update(d[m],34962);let f=u.morphAttributes;for(let m in f){let p=f[m];for(let g=0,x=p.length;g<x;g++)e.update(p[g],34962)}}function c(u){let d=[],f=u.index,m=u.attributes.position,p=0;if(f!==null){let v=f.array;p=f.version;for(let w=0,b=v.length;w<b;w+=3){let S=v[w+0],M=v[w+1],_=v[w+2];d.push(S,M,M,_,_,S)}}else{let v=m.array;p=m.version;for(let w=0,b=v.length/3-1;w<b;w+=3){let S=w+0,M=w+1,_=w+2;d.push(S,M,M,_,_,S)}}let g=new(rx(d)?ps:yu)(d,1);g.version=p;let x=s.get(u);x&&e.remove(x),s.set(u,g)}function h(u){let d=s.get(u);if(d){let f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return s.get(u)}return{get:a,update:l,getWireframeAttribute:h}}function WC(r,e,t,n){let i=n.isWebGL2,s;function o(d){s=d}let a,l;function c(d){a=d.type,l=d.bytesPerElement}function h(d,f){r.drawElements(s,f,a,d*l),t.update(f,s,1)}function u(d,f,m){if(m===0)return;let p,g;if(i)p=r,g="drawElementsInstanced";else if(p=e.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",p===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[g](s,f,a,d*l,m),t.update(f,s,m)}this.setMode=o,this.setIndex=c,this.render=h,this.renderInstances=u}function jC(r){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case 4:t.triangles+=a*(s/3);break;case 1:t.lines+=a*(s/2);break;case 3:t.lines+=a*(s-1);break;case 2:t.lines+=a*s;break;case 0:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function qC(r,e){return r[0]-e[0]}function XC(r,e){return Math.abs(e[1])-Math.abs(r[1])}function Fp(r,e){let t=1,n=e.isInterleavedBufferAttribute?e.data.array:e.array;n instanceof Int8Array?t=127:n instanceof Int16Array?t=32767:n instanceof Int32Array?t=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",n),r.divideScalar(t)}function YC(r,e,t){let n={},i=new Float32Array(8),s=new WeakMap,o=new qe,a=[];for(let c=0;c<8;c++)a[c]=[c,0];function l(c,h,u,d){let f=c.morphTargetInfluences;if(e.isWebGL2===!0){let m=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,p=m!==void 0?m.length:0,g=s.get(h);if(g===void 0||g.count!==p){let H=function(){R.dispose(),s.delete(h),h.removeEventListener("dispose",H)};g!==void 0&&g.texture.dispose();let w=h.morphAttributes.position!==void 0,b=h.morphAttributes.normal!==void 0,S=h.morphAttributes.color!==void 0,M=h.morphAttributes.position||[],_=h.morphAttributes.normal||[],y=h.morphAttributes.color||[],T=0;w===!0&&(T=1),b===!0&&(T=2),S===!0&&(T=3);let E=h.attributes.position.count*T,C=1;E>e.maxTextureSize&&(C=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);let I=new Float32Array(E*C*4*p),R=new gu(I,E,C,p);R.type=vr,R.needsUpdate=!0;let N=T*4;for(let j=0;j<p;j++){let K=M[j],Y=_[j],z=y[j],F=E*C*4*j;for(let V=0;V<K.count;V++){let O=V*N;w===!0&&(o.fromBufferAttribute(K,V),K.normalized===!0&&Fp(o,K),I[F+O+0]=o.x,I[F+O+1]=o.y,I[F+O+2]=o.z,I[F+O+3]=0),b===!0&&(o.fromBufferAttribute(Y,V),Y.normalized===!0&&Fp(o,Y),I[F+O+4]=o.x,I[F+O+5]=o.y,I[F+O+6]=o.z,I[F+O+7]=0),S===!0&&(o.fromBufferAttribute(z,V),z.normalized===!0&&Fp(o,z),I[F+O+8]=o.x,I[F+O+9]=o.y,I[F+O+10]=o.z,I[F+O+11]=z.itemSize===4?o.w:1)}}g={count:p,texture:R,size:new B(E,C)},s.set(h,g),h.addEventListener("dispose",H)}let x=0;for(let w=0;w<f.length;w++)x+=f[w];let v=h.morphTargetsRelative?1:1-x;d.getUniforms().setValue(r,"morphTargetBaseInfluence",v),d.getUniforms().setValue(r,"morphTargetInfluences",f),d.getUniforms().setValue(r,"morphTargetsTexture",g.texture,t),d.getUniforms().setValue(r,"morphTargetsTextureSize",g.size)}else{let m=f===void 0?0:f.length,p=n[h.id];if(p===void 0||p.length!==m){p=[];for(let b=0;b<m;b++)p[b]=[b,0];n[h.id]=p}for(let b=0;b<m;b++){let S=p[b];S[0]=b,S[1]=f[b]}p.sort(XC);for(let b=0;b<8;b++)b<m&&p[b][1]?(a[b][0]=p[b][0],a[b][1]=p[b][1]):(a[b][0]=Number.MAX_SAFE_INTEGER,a[b][1]=0);a.sort(qC);let g=h.morphAttributes.position,x=h.morphAttributes.normal,v=0;for(let b=0;b<8;b++){let S=a[b],M=S[0],_=S[1];M!==Number.MAX_SAFE_INTEGER&&_?(g&&h.getAttribute("morphTarget"+b)!==g[M]&&h.setAttribute("morphTarget"+b,g[M]),x&&h.getAttribute("morphNormal"+b)!==x[M]&&h.setAttribute("morphNormal"+b,x[M]),i[b]=_,v+=_):(g&&h.hasAttribute("morphTarget"+b)===!0&&h.deleteAttribute("morphTarget"+b),x&&h.hasAttribute("morphNormal"+b)===!0&&h.deleteAttribute("morphNormal"+b),i[b]=0)}let w=h.morphTargetsRelative?1:1-v;d.getUniforms().setValue(r,"morphTargetBaseInfluence",w),d.getUniforms().setValue(r,"morphTargetInfluences",i)}}return{update:l}}function QC(r,e,t,n){let i=new WeakMap;function s(l){let c=n.render.frame,h=l.geometry,u=e.get(l,h);return i.get(u)!==c&&(e.update(u),i.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),t.update(l.instanceMatrix,34962),l.instanceColor!==null&&t.update(l.instanceColor,34962)),u}function o(){i=new WeakMap}function a(l){let c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:o}}var ox=new Bt,ax=new gu,lx=new Zp,cx=new ra,v0=[],x0=[],b0=new Float32Array(16),w0=new Float32Array(9),S0=new Float32Array(4);function xa(r,e,t){let n=r[0];if(n<=0||n>0)return r;let i=e*t,s=v0[i];if(s===void 0&&(s=new Float32Array(i),v0[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function Vn(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Hn(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function Fu(r,e){let t=x0[e];t===void 0&&(t=new Int32Array(e),x0[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function KC(r,e){let t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function ZC(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Vn(t,e))return;r.uniform2fv(this.addr,e),Hn(t,e)}}function JC(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Vn(t,e))return;r.uniform3fv(this.addr,e),Hn(t,e)}}function $C(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Vn(t,e))return;r.uniform4fv(this.addr,e),Hn(t,e)}}function e2(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Vn(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),Hn(t,e)}else{if(Vn(t,n))return;S0.set(n),r.uniformMatrix2fv(this.addr,!1,S0),Hn(t,n)}}function t2(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Vn(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),Hn(t,e)}else{if(Vn(t,n))return;w0.set(n),r.uniformMatrix3fv(this.addr,!1,w0),Hn(t,n)}}function n2(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(Vn(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),Hn(t,e)}else{if(Vn(t,n))return;b0.set(n),r.uniformMatrix4fv(this.addr,!1,b0),Hn(t,n)}}function r2(r,e){let t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function i2(r,e){let t=this.cache;Vn(t,e)||(r.uniform2iv(this.addr,e),Hn(t,e))}function s2(r,e){let t=this.cache;Vn(t,e)||(r.uniform3iv(this.addr,e),Hn(t,e))}function o2(r,e){let t=this.cache;Vn(t,e)||(r.uniform4iv(this.addr,e),Hn(t,e))}function a2(r,e){let t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function l2(r,e){let t=this.cache;Vn(t,e)||(r.uniform2uiv(this.addr,e),Hn(t,e))}function c2(r,e){let t=this.cache;Vn(t,e)||(r.uniform3uiv(this.addr,e),Hn(t,e))}function h2(r,e){let t=this.cache;Vn(t,e)||(r.uniform4uiv(this.addr,e),Hn(t,e))}function u2(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2D(e||ox,i)}function d2(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||lx,i)}function f2(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||cx,i)}function p2(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||ax,i)}function m2(r){switch(r){case 5126:return KC;case 35664:return ZC;case 35665:return JC;case 35666:return $C;case 35674:return e2;case 35675:return t2;case 35676:return n2;case 5124:case 35670:return r2;case 35667:case 35671:return i2;case 35668:case 35672:return s2;case 35669:case 35673:return o2;case 5125:return a2;case 36294:return l2;case 36295:return c2;case 36296:return h2;case 35678:case 36198:case 36298:case 36306:case 35682:return u2;case 35679:case 36299:case 36307:return d2;case 35680:case 36300:case 36308:case 36293:return f2;case 36289:case 36303:case 36311:case 36292:return p2}}function g2(r,e){r.uniform1fv(this.addr,e)}function y2(r,e){let t=xa(e,this.size,2);r.uniform2fv(this.addr,t)}function v2(r,e){let t=xa(e,this.size,3);r.uniform3fv(this.addr,t)}function x2(r,e){let t=xa(e,this.size,4);r.uniform4fv(this.addr,t)}function b2(r,e){let t=xa(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function w2(r,e){let t=xa(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function S2(r,e){let t=xa(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function A2(r,e){r.uniform1iv(this.addr,e)}function M2(r,e){r.uniform2iv(this.addr,e)}function _2(r,e){r.uniform3iv(this.addr,e)}function T2(r,e){r.uniform4iv(this.addr,e)}function E2(r,e){r.uniform1uiv(this.addr,e)}function C2(r,e){r.uniform2uiv(this.addr,e)}function D2(r,e){r.uniform3uiv(this.addr,e)}function P2(r,e){r.uniform4uiv(this.addr,e)}function L2(r,e,t){let n=e.length,i=Fu(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture2D(e[s]||ox,i[s])}function I2(r,e,t){let n=e.length,i=Fu(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture3D(e[s]||lx,i[s])}function N2(r,e,t){let n=e.length,i=Fu(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTextureCube(e[s]||cx,i[s])}function R2(r,e,t){let n=e.length,i=Fu(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture2DArray(e[s]||ax,i[s])}function B2(r){switch(r){case 5126:return g2;case 35664:return y2;case 35665:return v2;case 35666:return x2;case 35674:return b2;case 35675:return w2;case 35676:return S2;case 5124:case 35670:return A2;case 35667:case 35671:return M2;case 35668:case 35672:return _2;case 35669:case 35673:return T2;case 5125:return E2;case 36294:return C2;case 36295:return D2;case 36296:return P2;case 35678:case 36198:case 36298:case 36306:case 35682:return L2;case 35679:case 36299:case 36307:return I2;case 35680:case 36300:case 36308:case 36293:return N2;case 36289:case 36303:case 36311:case 36292:return R2}}var em=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=m2(t.type)}},tm=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=B2(t.type)}},nm=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let s=0,o=i.length;s!==o;++s){let a=i[s];a.setValue(e,t[a.id],n)}}},Up=/(\w+)(\])?(\[|\.)?/g;function A0(r,e){r.seq.push(e),r.map[e.id]=e}function O2(r,e,t){let n=r.name,i=n.length;for(Up.lastIndex=0;;){let s=Up.exec(n),o=Up.lastIndex,a=s[1],l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===i){A0(t,c===void 0?new em(a,r,e):new tm(a,r,e));break}else{let u=t.map[a];u===void 0&&(u=new nm(a),A0(t,u)),t=u}}}var ea=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,35718);for(let i=0;i<n;++i){let s=e.getActiveUniform(t,i),o=e.getUniformLocation(t,s.name);O2(s,o,this)}}setValue(e,t,n,i){let s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,o=t.length;s!==o;++s){let a=t[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,s=e.length;i!==s;++i){let o=e[i];o.id in t&&n.push(o)}return n}};function M0(r,e,t){let n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}var F2=0;function U2(r,e){let t=r.split(`
|
|
3080
3080
|
`),n=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=i;o<s;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
|
|
3081
3081
|
`)}function z2(r){switch(r){case lr:return["Linear","( value )"];case We:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",r),["Linear","( value )"]}}function _0(r,e,t){let n=r.getShaderParameter(e,35713),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";let s=/ERROR: 0:(\d+)/.exec(i);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
|
|
3082
3082
|
|
|
@@ -3102,11 +3102,11 @@ precision `+r.precision+" int;";return r.precision==="highp"?e+=`
|
|
|
3102
3102
|
`)+`
|
|
3103
3103
|
`+g,x=["#define varying in",t.glslVersion===$v?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===$v?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
|
|
3104
3104
|
`)+`
|
|
3105
|
-
`+x);let w=v+g+o,b=v+x+a,S=M0(i,35633,w),M=M0(i,35632,b);if(i.attachShader(p,S),i.attachShader(p,M),t.index0AttributeName!==void 0?i.bindAttribLocation(p,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(p,0,"position"),i.linkProgram(p),r.debug.checkShaderErrors){let T=i.getProgramInfoLog(p).trim(),E=i.getShaderInfoLog(S).trim(),C=i.getShaderInfoLog(M).trim(),
|
|
3105
|
+
`+x);let w=v+g+o,b=v+x+a,S=M0(i,35633,w),M=M0(i,35632,b);if(i.attachShader(p,S),i.attachShader(p,M),t.index0AttributeName!==void 0?i.bindAttribLocation(p,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(p,0,"position"),i.linkProgram(p),r.debug.checkShaderErrors){let T=i.getProgramInfoLog(p).trim(),E=i.getShaderInfoLog(S).trim(),C=i.getShaderInfoLog(M).trim(),I=!0,R=!0;if(i.getProgramParameter(p,35714)===!1){I=!1;let N=_0(i,S,"vertex"),H=_0(i,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(p,35715)+`
|
|
3106
3106
|
|
|
3107
3107
|
Program Info Log: `+T+`
|
|
3108
3108
|
`+N+`
|
|
3109
|
-
`+H)}else T!==""?console.warn("THREE.WebGLProgram: Program Info Log:",T):(E===""||C==="")&&(R=!1);R&&(this.diagnostics={runnable:L,programLog:T,vertexShader:{log:E,prefix:g},fragmentShader:{log:C,prefix:x}})}i.deleteShader(S),i.deleteShader(M);let _;this.getUniforms=function(){return _===void 0&&(_=new ea(i,p)),_};let y;return this.getAttributes=function(){return y===void 0&&(y=W2(i,p)),y},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(p),this.program=void 0},this.name=t.shaderName,this.id=F2++,this.cacheKey=e,this.usedTimes=1,this.program=p,this.vertexShader=S,this.fragmentShader=M,this}var nD=0,im=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){let t=this.shaderCache;if(t.has(e)===!1){let n=new sm(e);t.set(e,n)}return t.get(e)}},sm=class{constructor(e){this.id=nD++,this.code=e,this.usedTimes=0}};function rD(r,e,t,n,i,s,o){let a=new dc,l=new im,c=[],h=i.isWebGL2,u=i.logarithmicDepthBuffer,d=i.vertexTextures,f=i.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(y,T,E,C,L){let R=C.fog,N=L.geometry,H=y.isMeshStandardMaterial?C.environment:null,j=(y.isMeshStandardMaterial?t:e).get(y.envMap||H),K=!!j&&j.mapping===ya?j.image.height:null,Y=m[y.type];y.precision!==null&&(f=i.getMaxPrecision(y.precision),f!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",f,"instead."));let z=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,F=z!==void 0?z.length:0,V=0;N.morphAttributes.position!==void 0&&(V=1),N.morphAttributes.normal!==void 0&&(V=2),N.morphAttributes.color!==void 0&&(V=3);let O,G,W,X;if(Y){let le=li[Y];O=le.vertexShader,G=le.fragmentShader}else O=y.vertexShader,G=y.fragmentShader,l.update(y),W=l.getVertexShaderID(y),X=l.getFragmentShaderID(y);let q=r.getRenderTarget(),se=y.alphaTest>0,Z=y.clearcoat>0,te=y.iridescence>0;return{isWebGL2:h,shaderID:Y,shaderName:y.type,vertexShader:O,fragmentShader:G,defines:y.defines,customVertexShaderID:W,customFragmentShaderID:X,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:f,instancing:L.isInstancedMesh===!0,instancingColor:L.isInstancedMesh===!0&&L.instanceColor!==null,supportsVertexTextures:d,outputEncoding:q===null?r.outputEncoding:q.isXRRenderTarget===!0?q.texture.encoding:lr,map:!!y.map,matcap:!!y.matcap,envMap:!!j,envMapMode:j&&j.mapping,envMapCubeUVHeight:K,lightMap:!!y.lightMap,aoMap:!!y.aoMap,emissiveMap:!!y.emissiveMap,bumpMap:!!y.bumpMap,normalMap:!!y.normalMap,objectSpaceNormalMap:y.normalMapType===A_,tangentSpaceNormalMap:y.normalMapType===va,decodeVideoTexture:!!y.map&&y.map.isVideoTexture===!0&&y.map.encoding===We,clearcoat:Z,clearcoatMap:Z&&!!y.clearcoatMap,clearcoatRoughnessMap:Z&&!!y.clearcoatRoughnessMap,clearcoatNormalMap:Z&&!!y.clearcoatNormalMap,iridescence:te,iridescenceMap:te&&!!y.iridescenceMap,iridescenceThicknessMap:te&&!!y.iridescenceThicknessMap,displacementMap:!!y.displacementMap,roughnessMap:!!y.roughnessMap,metalnessMap:!!y.metalnessMap,specularMap:!!y.specularMap,specularIntensityMap:!!y.specularIntensityMap,specularColorMap:!!y.specularColorMap,opaque:y.transparent===!1&&y.blending===ls,alphaMap:!!y.alphaMap,alphaTest:se,gradientMap:!!y.gradientMap,sheen:y.sheen>0,sheenColorMap:!!y.sheenColorMap,sheenRoughnessMap:!!y.sheenRoughnessMap,transmission:y.transmission>0,transmissionMap:!!y.transmissionMap,thicknessMap:!!y.thicknessMap,combine:y.combine,vertexTangents:!!y.normalMap&&!!N.attributes.tangent,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!N.attributes.color&&N.attributes.color.itemSize===4,vertexUvs:!!y.map||!!y.bumpMap||!!y.normalMap||!!y.specularMap||!!y.alphaMap||!!y.emissiveMap||!!y.roughnessMap||!!y.metalnessMap||!!y.clearcoatMap||!!y.clearcoatRoughnessMap||!!y.clearcoatNormalMap||!!y.iridescenceMap||!!y.iridescenceThicknessMap||!!y.displacementMap||!!y.transmissionMap||!!y.thicknessMap||!!y.specularIntensityMap||!!y.specularColorMap||!!y.sheenColorMap||!!y.sheenRoughnessMap,uvsVertexOnly:!(!!y.map||!!y.bumpMap||!!y.normalMap||!!y.specularMap||!!y.alphaMap||!!y.emissiveMap||!!y.roughnessMap||!!y.metalnessMap||!!y.clearcoatNormalMap||!!y.iridescenceMap||!!y.iridescenceThicknessMap||y.transmission>0||!!y.transmissionMap||!!y.thicknessMap||!!y.specularIntensityMap||!!y.specularColorMap||y.sheen>0||!!y.sheenColorMap||!!y.sheenRoughnessMap)&&!!y.displacementMap,fog:!!R,useFog:y.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:!!y.flatShading,sizeAttenuation:y.sizeAttenuation,logarithmicDepthBuffer:u,skinning:L.isSkinnedMesh===!0,morphTargets:N.morphAttributes.position!==void 0,morphNormals:N.morphAttributes.normal!==void 0,morphColors:N.morphAttributes.color!==void 0,morphTargetsCount:F,morphTextureStride:V,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:y.dithering,shadowMapEnabled:r.shadowMap.enabled&&E.length>0,shadowMapType:r.shadowMap.type,toneMapping:y.toneMapped?r.toneMapping:Ui,physicallyCorrectLights:r.physicallyCorrectLights,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===hn,flipSided:y.side===wn,useDepthPacking:!!y.depthPacking,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionDerivatives:y.extensions&&y.extensions.derivatives,extensionFragDepth:y.extensions&&y.extensions.fragDepth,extensionDrawBuffers:y.extensions&&y.extensions.drawBuffers,extensionShaderTextureLOD:y.extensions&&y.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:y.customProgramCacheKey()}}function g(y){let T=[];if(y.shaderID?T.push(y.shaderID):(T.push(y.customVertexShaderID),T.push(y.customFragmentShaderID)),y.defines!==void 0)for(let E in y.defines)T.push(E),T.push(y.defines[E]);return y.isRawShaderMaterial===!1&&(x(T,y),v(T,y),T.push(r.outputEncoding)),T.push(y.customProgramCacheKey),T.join()}function x(y,T){y.push(T.precision),y.push(T.outputEncoding),y.push(T.envMapMode),y.push(T.envMapCubeUVHeight),y.push(T.combine),y.push(T.vertexUvs),y.push(T.fogExp2),y.push(T.sizeAttenuation),y.push(T.morphTargetsCount),y.push(T.morphAttributeCount),y.push(T.numDirLights),y.push(T.numPointLights),y.push(T.numSpotLights),y.push(T.numHemiLights),y.push(T.numRectAreaLights),y.push(T.numDirLightShadows),y.push(T.numPointLightShadows),y.push(T.numSpotLightShadows),y.push(T.shadowMapType),y.push(T.toneMapping),y.push(T.numClippingPlanes),y.push(T.numClipIntersection),y.push(T.depthPacking)}function v(y,T){a.disableAll(),T.isWebGL2&&a.enable(0),T.supportsVertexTextures&&a.enable(1),T.instancing&&a.enable(2),T.instancingColor&&a.enable(3),T.map&&a.enable(4),T.matcap&&a.enable(5),T.envMap&&a.enable(6),T.lightMap&&a.enable(7),T.aoMap&&a.enable(8),T.emissiveMap&&a.enable(9),T.bumpMap&&a.enable(10),T.normalMap&&a.enable(11),T.objectSpaceNormalMap&&a.enable(12),T.tangentSpaceNormalMap&&a.enable(13),T.clearcoat&&a.enable(14),T.clearcoatMap&&a.enable(15),T.clearcoatRoughnessMap&&a.enable(16),T.clearcoatNormalMap&&a.enable(17),T.iridescence&&a.enable(18),T.iridescenceMap&&a.enable(19),T.iridescenceThicknessMap&&a.enable(20),T.displacementMap&&a.enable(21),T.specularMap&&a.enable(22),T.roughnessMap&&a.enable(23),T.metalnessMap&&a.enable(24),T.gradientMap&&a.enable(25),T.alphaMap&&a.enable(26),T.alphaTest&&a.enable(27),T.vertexColors&&a.enable(28),T.vertexAlphas&&a.enable(29),T.vertexUvs&&a.enable(30),T.vertexTangents&&a.enable(31),T.uvsVertexOnly&&a.enable(32),T.fog&&a.enable(33),y.push(a.mask),a.disableAll(),T.useFog&&a.enable(0),T.flatShading&&a.enable(1),T.logarithmicDepthBuffer&&a.enable(2),T.skinning&&a.enable(3),T.morphTargets&&a.enable(4),T.morphNormals&&a.enable(5),T.morphColors&&a.enable(6),T.premultipliedAlpha&&a.enable(7),T.shadowMapEnabled&&a.enable(8),T.physicallyCorrectLights&&a.enable(9),T.doubleSided&&a.enable(10),T.flipSided&&a.enable(11),T.useDepthPacking&&a.enable(12),T.dithering&&a.enable(13),T.specularIntensityMap&&a.enable(14),T.specularColorMap&&a.enable(15),T.transmission&&a.enable(16),T.transmissionMap&&a.enable(17),T.thicknessMap&&a.enable(18),T.sheen&&a.enable(19),T.sheenColorMap&&a.enable(20),T.sheenRoughnessMap&&a.enable(21),T.decodeVideoTexture&&a.enable(22),T.opaque&&a.enable(23),y.push(a.mask)}function w(y){let T=m[y.type],E;if(T){let C=li[T];E=Wr.clone(C.uniforms)}else E=y.uniforms;return E}function b(y,T){let E;for(let C=0,L=c.length;C<L;C++){let R=c[C];if(R.cacheKey===T){E=R,++E.usedTimes;break}}return E===void 0&&(E=new tD(r,T,y,s),c.push(E)),E}function S(y){if(--y.usedTimes===0){let T=c.indexOf(y);c[T]=c[c.length-1],c.pop(),y.destroy()}}function M(y){l.remove(y)}function _(){l.dispose()}return{getParameters:p,getProgramCacheKey:g,getUniforms:w,acquireProgram:b,releaseProgram:S,releaseShaderCache:M,programs:c,dispose:_}}function iD(){let r=new WeakMap;function e(s){let o=r.get(s);return o===void 0&&(o={},r.set(s,o)),o}function t(s){r.delete(s)}function n(s,o,a){r.get(s)[o]=a}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function sD(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function P0(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function I0(){let r=[],e=0,t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function o(u,d,f,m,p,g){let x=r[e];return x===void 0?(x={id:u.id,object:u,geometry:d,material:f,groupOrder:m,renderOrder:u.renderOrder,z:p,group:g},r[e]=x):(x.id=u.id,x.object=u,x.geometry=d,x.material=f,x.groupOrder=m,x.renderOrder=u.renderOrder,x.z=p,x.group=g),e++,x}function a(u,d,f,m,p,g){let x=o(u,d,f,m,p,g);f.transmission>0?n.push(x):f.transparent===!0?i.push(x):t.push(x)}function l(u,d,f,m,p,g){let x=o(u,d,f,m,p,g);f.transmission>0?n.unshift(x):f.transparent===!0?i.unshift(x):t.unshift(x)}function c(u,d){t.length>1&&t.sort(u||sD),n.length>1&&n.sort(d||P0),i.length>1&&i.sort(d||P0)}function h(){for(let u=e,d=r.length;u<d;u++){let f=r[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:a,unshift:l,finish:h,sort:c}}function oD(){let r=new WeakMap;function e(n,i){let s;return r.has(n)===!1?(s=new I0,r.set(n,[s])):i>=r.get(n).length?(s=new I0,r.get(n).push(s)):s=r.get(n)[i],s}function t(){r=new WeakMap}return{get:e,dispose:t}}function aD(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new A,color:new Ae};break;case"SpotLight":t={position:new A,direction:new A,color:new Ae,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new A,color:new Ae,distance:0,decay:0};break;case"HemisphereLight":t={direction:new A,skyColor:new Ae,groundColor:new Ae};break;case"RectAreaLight":t={color:new Ae,position:new A,halfWidth:new A,halfHeight:new A};break}return r[e.id]=t,t}}}function lD(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}var cD=0;function hD(r,e){return(e.castShadow?1:0)-(r.castShadow?1:0)}function uD(r,e){let t=new aD,n=lD(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let h=0;h<9;h++)i.probe.push(new A);let s=new A,o=new Oe,a=new Oe;function l(h,u){let d=0,f=0,m=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let p=0,g=0,x=0,v=0,w=0,b=0,S=0,M=0;h.sort(hD);let _=u!==!0?Math.PI:1;for(let T=0,E=h.length;T<E;T++){let C=h[T],L=C.color,R=C.intensity,N=C.distance,H=C.shadow&&C.shadow.map?C.shadow.map.texture:null;if(C.isAmbientLight)d+=L.r*R*_,f+=L.g*R*_,m+=L.b*R*_;else if(C.isLightProbe)for(let j=0;j<9;j++)i.probe[j].addScaledVector(C.sh.coefficients[j],R);else if(C.isDirectionalLight){let j=t.get(C);if(j.color.copy(C.color).multiplyScalar(C.intensity*_),C.castShadow){let K=C.shadow,Y=n.get(C);Y.shadowBias=K.bias,Y.shadowNormalBias=K.normalBias,Y.shadowRadius=K.radius,Y.shadowMapSize=K.mapSize,i.directionalShadow[p]=Y,i.directionalShadowMap[p]=H,i.directionalShadowMatrix[p]=C.shadow.matrix,b++}i.directional[p]=j,p++}else if(C.isSpotLight){let j=t.get(C);if(j.position.setFromMatrixPosition(C.matrixWorld),j.color.copy(L).multiplyScalar(R*_),j.distance=N,j.coneCos=Math.cos(C.angle),j.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),j.decay=C.decay,C.castShadow){let K=C.shadow,Y=n.get(C);Y.shadowBias=K.bias,Y.shadowNormalBias=K.normalBias,Y.shadowRadius=K.radius,Y.shadowMapSize=K.mapSize,i.spotShadow[x]=Y,i.spotShadowMap[x]=H,i.spotShadowMatrix[x]=C.shadow.matrix,M++}i.spot[x]=j,x++}else if(C.isRectAreaLight){let j=t.get(C);j.color.copy(L).multiplyScalar(R),j.halfWidth.set(C.width*.5,0,0),j.halfHeight.set(0,C.height*.5,0),i.rectArea[v]=j,v++}else if(C.isPointLight){let j=t.get(C);if(j.color.copy(C.color).multiplyScalar(C.intensity*_),j.distance=C.distance,j.decay=C.decay,C.castShadow){let K=C.shadow,Y=n.get(C);Y.shadowBias=K.bias,Y.shadowNormalBias=K.normalBias,Y.shadowRadius=K.radius,Y.shadowMapSize=K.mapSize,Y.shadowCameraNear=K.camera.near,Y.shadowCameraFar=K.camera.far,i.pointShadow[g]=Y,i.pointShadowMap[g]=H,i.pointShadowMatrix[g]=C.shadow.matrix,S++}i.point[g]=j,g++}else if(C.isHemisphereLight){let j=t.get(C);j.skyColor.copy(C.color).multiplyScalar(R*_),j.groundColor.copy(C.groundColor).multiplyScalar(R*_),i.hemi[w]=j,w++}}v>0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=me.LTC_FLOAT_1,i.rectAreaLTC2=me.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=me.LTC_HALF_1,i.rectAreaLTC2=me.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=m;let y=i.hash;(y.directionalLength!==p||y.pointLength!==g||y.spotLength!==x||y.rectAreaLength!==v||y.hemiLength!==w||y.numDirectionalShadows!==b||y.numPointShadows!==S||y.numSpotShadows!==M)&&(i.directional.length=p,i.spot.length=x,i.rectArea.length=v,i.point.length=g,i.hemi.length=w,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=S,i.pointShadowMap.length=S,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=S,i.spotShadowMatrix.length=M,y.directionalLength=p,y.pointLength=g,y.spotLength=x,y.rectAreaLength=v,y.hemiLength=w,y.numDirectionalShadows=b,y.numPointShadows=S,y.numSpotShadows=M,i.version=cD++)}function c(h,u){let d=0,f=0,m=0,p=0,g=0,x=u.matrixWorldInverse;for(let v=0,w=h.length;v<w;v++){let b=h[v];if(b.isDirectionalLight){let S=i.directional[d];S.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(x),d++}else if(b.isSpotLight){let S=i.spot[m];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(x),S.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(x),m++}else if(b.isRectAreaLight){let S=i.rectArea[p];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(x),a.identity(),o.copy(b.matrixWorld),o.premultiply(x),a.extractRotation(o),S.halfWidth.set(b.width*.5,0,0),S.halfHeight.set(0,b.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),p++}else if(b.isPointLight){let S=i.point[f];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(x),f++}else if(b.isHemisphereLight){let S=i.hemi[g];S.direction.setFromMatrixPosition(b.matrixWorld),S.direction.transformDirection(x),g++}}}return{setup:l,setupView:c,state:i}}function L0(r,e){let t=new uD(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function o(u){n.push(u)}function a(u){i.push(u)}function l(u){t.setup(n,u)}function c(u){t.setupView(n,u)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:l,setupLightsView:c,pushLight:o,pushShadow:a}}function dD(r,e){let t=new WeakMap;function n(s,o=0){let a;return t.has(s)===!1?(a=new L0(r,e),t.set(s,[a])):o>=t.get(s).length?(a=new L0(r,e),t.get(s).push(a)):a=t.get(s)[o],a}function i(){t=new WeakMap}return{get:n,dispose:i}}var xu=class extends un{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=An,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},bu=class extends un{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new A,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},fD=`void main() {
|
|
3109
|
+
`+H)}else T!==""?console.warn("THREE.WebGLProgram: Program Info Log:",T):(E===""||C==="")&&(R=!1);R&&(this.diagnostics={runnable:I,programLog:T,vertexShader:{log:E,prefix:g},fragmentShader:{log:C,prefix:x}})}i.deleteShader(S),i.deleteShader(M);let _;this.getUniforms=function(){return _===void 0&&(_=new ea(i,p)),_};let y;return this.getAttributes=function(){return y===void 0&&(y=W2(i,p)),y},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(p),this.program=void 0},this.name=t.shaderName,this.id=F2++,this.cacheKey=e,this.usedTimes=1,this.program=p,this.vertexShader=S,this.fragmentShader=M,this}var nD=0,im=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){let t=this.shaderCache;if(t.has(e)===!1){let n=new sm(e);t.set(e,n)}return t.get(e)}},sm=class{constructor(e){this.id=nD++,this.code=e,this.usedTimes=0}};function rD(r,e,t,n,i,s,o){let a=new dc,l=new im,c=[],h=i.isWebGL2,u=i.logarithmicDepthBuffer,d=i.vertexTextures,f=i.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(y,T,E,C,I){let R=C.fog,N=I.geometry,H=y.isMeshStandardMaterial?C.environment:null,j=(y.isMeshStandardMaterial?t:e).get(y.envMap||H),K=!!j&&j.mapping===ya?j.image.height:null,Y=m[y.type];y.precision!==null&&(f=i.getMaxPrecision(y.precision),f!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",f,"instead."));let z=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,F=z!==void 0?z.length:0,V=0;N.morphAttributes.position!==void 0&&(V=1),N.morphAttributes.normal!==void 0&&(V=2),N.morphAttributes.color!==void 0&&(V=3);let O,G,W,X;if(Y){let le=li[Y];O=le.vertexShader,G=le.fragmentShader}else O=y.vertexShader,G=y.fragmentShader,l.update(y),W=l.getVertexShaderID(y),X=l.getFragmentShaderID(y);let q=r.getRenderTarget(),se=y.alphaTest>0,Z=y.clearcoat>0,te=y.iridescence>0;return{isWebGL2:h,shaderID:Y,shaderName:y.type,vertexShader:O,fragmentShader:G,defines:y.defines,customVertexShaderID:W,customFragmentShaderID:X,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:f,instancing:I.isInstancedMesh===!0,instancingColor:I.isInstancedMesh===!0&&I.instanceColor!==null,supportsVertexTextures:d,outputEncoding:q===null?r.outputEncoding:q.isXRRenderTarget===!0?q.texture.encoding:lr,map:!!y.map,matcap:!!y.matcap,envMap:!!j,envMapMode:j&&j.mapping,envMapCubeUVHeight:K,lightMap:!!y.lightMap,aoMap:!!y.aoMap,emissiveMap:!!y.emissiveMap,bumpMap:!!y.bumpMap,normalMap:!!y.normalMap,objectSpaceNormalMap:y.normalMapType===A_,tangentSpaceNormalMap:y.normalMapType===va,decodeVideoTexture:!!y.map&&y.map.isVideoTexture===!0&&y.map.encoding===We,clearcoat:Z,clearcoatMap:Z&&!!y.clearcoatMap,clearcoatRoughnessMap:Z&&!!y.clearcoatRoughnessMap,clearcoatNormalMap:Z&&!!y.clearcoatNormalMap,iridescence:te,iridescenceMap:te&&!!y.iridescenceMap,iridescenceThicknessMap:te&&!!y.iridescenceThicknessMap,displacementMap:!!y.displacementMap,roughnessMap:!!y.roughnessMap,metalnessMap:!!y.metalnessMap,specularMap:!!y.specularMap,specularIntensityMap:!!y.specularIntensityMap,specularColorMap:!!y.specularColorMap,opaque:y.transparent===!1&&y.blending===ls,alphaMap:!!y.alphaMap,alphaTest:se,gradientMap:!!y.gradientMap,sheen:y.sheen>0,sheenColorMap:!!y.sheenColorMap,sheenRoughnessMap:!!y.sheenRoughnessMap,transmission:y.transmission>0,transmissionMap:!!y.transmissionMap,thicknessMap:!!y.thicknessMap,combine:y.combine,vertexTangents:!!y.normalMap&&!!N.attributes.tangent,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!N.attributes.color&&N.attributes.color.itemSize===4,vertexUvs:!!y.map||!!y.bumpMap||!!y.normalMap||!!y.specularMap||!!y.alphaMap||!!y.emissiveMap||!!y.roughnessMap||!!y.metalnessMap||!!y.clearcoatMap||!!y.clearcoatRoughnessMap||!!y.clearcoatNormalMap||!!y.iridescenceMap||!!y.iridescenceThicknessMap||!!y.displacementMap||!!y.transmissionMap||!!y.thicknessMap||!!y.specularIntensityMap||!!y.specularColorMap||!!y.sheenColorMap||!!y.sheenRoughnessMap,uvsVertexOnly:!(!!y.map||!!y.bumpMap||!!y.normalMap||!!y.specularMap||!!y.alphaMap||!!y.emissiveMap||!!y.roughnessMap||!!y.metalnessMap||!!y.clearcoatNormalMap||!!y.iridescenceMap||!!y.iridescenceThicknessMap||y.transmission>0||!!y.transmissionMap||!!y.thicknessMap||!!y.specularIntensityMap||!!y.specularColorMap||y.sheen>0||!!y.sheenColorMap||!!y.sheenRoughnessMap)&&!!y.displacementMap,fog:!!R,useFog:y.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:!!y.flatShading,sizeAttenuation:y.sizeAttenuation,logarithmicDepthBuffer:u,skinning:I.isSkinnedMesh===!0,morphTargets:N.morphAttributes.position!==void 0,morphNormals:N.morphAttributes.normal!==void 0,morphColors:N.morphAttributes.color!==void 0,morphTargetsCount:F,morphTextureStride:V,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:y.dithering,shadowMapEnabled:r.shadowMap.enabled&&E.length>0,shadowMapType:r.shadowMap.type,toneMapping:y.toneMapped?r.toneMapping:Ui,physicallyCorrectLights:r.physicallyCorrectLights,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===hn,flipSided:y.side===wn,useDepthPacking:!!y.depthPacking,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionDerivatives:y.extensions&&y.extensions.derivatives,extensionFragDepth:y.extensions&&y.extensions.fragDepth,extensionDrawBuffers:y.extensions&&y.extensions.drawBuffers,extensionShaderTextureLOD:y.extensions&&y.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:y.customProgramCacheKey()}}function g(y){let T=[];if(y.shaderID?T.push(y.shaderID):(T.push(y.customVertexShaderID),T.push(y.customFragmentShaderID)),y.defines!==void 0)for(let E in y.defines)T.push(E),T.push(y.defines[E]);return y.isRawShaderMaterial===!1&&(x(T,y),v(T,y),T.push(r.outputEncoding)),T.push(y.customProgramCacheKey),T.join()}function x(y,T){y.push(T.precision),y.push(T.outputEncoding),y.push(T.envMapMode),y.push(T.envMapCubeUVHeight),y.push(T.combine),y.push(T.vertexUvs),y.push(T.fogExp2),y.push(T.sizeAttenuation),y.push(T.morphTargetsCount),y.push(T.morphAttributeCount),y.push(T.numDirLights),y.push(T.numPointLights),y.push(T.numSpotLights),y.push(T.numHemiLights),y.push(T.numRectAreaLights),y.push(T.numDirLightShadows),y.push(T.numPointLightShadows),y.push(T.numSpotLightShadows),y.push(T.shadowMapType),y.push(T.toneMapping),y.push(T.numClippingPlanes),y.push(T.numClipIntersection),y.push(T.depthPacking)}function v(y,T){a.disableAll(),T.isWebGL2&&a.enable(0),T.supportsVertexTextures&&a.enable(1),T.instancing&&a.enable(2),T.instancingColor&&a.enable(3),T.map&&a.enable(4),T.matcap&&a.enable(5),T.envMap&&a.enable(6),T.lightMap&&a.enable(7),T.aoMap&&a.enable(8),T.emissiveMap&&a.enable(9),T.bumpMap&&a.enable(10),T.normalMap&&a.enable(11),T.objectSpaceNormalMap&&a.enable(12),T.tangentSpaceNormalMap&&a.enable(13),T.clearcoat&&a.enable(14),T.clearcoatMap&&a.enable(15),T.clearcoatRoughnessMap&&a.enable(16),T.clearcoatNormalMap&&a.enable(17),T.iridescence&&a.enable(18),T.iridescenceMap&&a.enable(19),T.iridescenceThicknessMap&&a.enable(20),T.displacementMap&&a.enable(21),T.specularMap&&a.enable(22),T.roughnessMap&&a.enable(23),T.metalnessMap&&a.enable(24),T.gradientMap&&a.enable(25),T.alphaMap&&a.enable(26),T.alphaTest&&a.enable(27),T.vertexColors&&a.enable(28),T.vertexAlphas&&a.enable(29),T.vertexUvs&&a.enable(30),T.vertexTangents&&a.enable(31),T.uvsVertexOnly&&a.enable(32),T.fog&&a.enable(33),y.push(a.mask),a.disableAll(),T.useFog&&a.enable(0),T.flatShading&&a.enable(1),T.logarithmicDepthBuffer&&a.enable(2),T.skinning&&a.enable(3),T.morphTargets&&a.enable(4),T.morphNormals&&a.enable(5),T.morphColors&&a.enable(6),T.premultipliedAlpha&&a.enable(7),T.shadowMapEnabled&&a.enable(8),T.physicallyCorrectLights&&a.enable(9),T.doubleSided&&a.enable(10),T.flipSided&&a.enable(11),T.useDepthPacking&&a.enable(12),T.dithering&&a.enable(13),T.specularIntensityMap&&a.enable(14),T.specularColorMap&&a.enable(15),T.transmission&&a.enable(16),T.transmissionMap&&a.enable(17),T.thicknessMap&&a.enable(18),T.sheen&&a.enable(19),T.sheenColorMap&&a.enable(20),T.sheenRoughnessMap&&a.enable(21),T.decodeVideoTexture&&a.enable(22),T.opaque&&a.enable(23),y.push(a.mask)}function w(y){let T=m[y.type],E;if(T){let C=li[T];E=Wr.clone(C.uniforms)}else E=y.uniforms;return E}function b(y,T){let E;for(let C=0,I=c.length;C<I;C++){let R=c[C];if(R.cacheKey===T){E=R,++E.usedTimes;break}}return E===void 0&&(E=new tD(r,T,y,s),c.push(E)),E}function S(y){if(--y.usedTimes===0){let T=c.indexOf(y);c[T]=c[c.length-1],c.pop(),y.destroy()}}function M(y){l.remove(y)}function _(){l.dispose()}return{getParameters:p,getProgramCacheKey:g,getUniforms:w,acquireProgram:b,releaseProgram:S,releaseShaderCache:M,programs:c,dispose:_}}function iD(){let r=new WeakMap;function e(s){let o=r.get(s);return o===void 0&&(o={},r.set(s,o)),o}function t(s){r.delete(s)}function n(s,o,a){r.get(s)[o]=a}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function sD(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function P0(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function L0(){let r=[],e=0,t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function o(u,d,f,m,p,g){let x=r[e];return x===void 0?(x={id:u.id,object:u,geometry:d,material:f,groupOrder:m,renderOrder:u.renderOrder,z:p,group:g},r[e]=x):(x.id=u.id,x.object=u,x.geometry=d,x.material=f,x.groupOrder=m,x.renderOrder=u.renderOrder,x.z=p,x.group=g),e++,x}function a(u,d,f,m,p,g){let x=o(u,d,f,m,p,g);f.transmission>0?n.push(x):f.transparent===!0?i.push(x):t.push(x)}function l(u,d,f,m,p,g){let x=o(u,d,f,m,p,g);f.transmission>0?n.unshift(x):f.transparent===!0?i.unshift(x):t.unshift(x)}function c(u,d){t.length>1&&t.sort(u||sD),n.length>1&&n.sort(d||P0),i.length>1&&i.sort(d||P0)}function h(){for(let u=e,d=r.length;u<d;u++){let f=r[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:a,unshift:l,finish:h,sort:c}}function oD(){let r=new WeakMap;function e(n,i){let s;return r.has(n)===!1?(s=new L0,r.set(n,[s])):i>=r.get(n).length?(s=new L0,r.get(n).push(s)):s=r.get(n)[i],s}function t(){r=new WeakMap}return{get:e,dispose:t}}function aD(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new A,color:new Ae};break;case"SpotLight":t={position:new A,direction:new A,color:new Ae,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new A,color:new Ae,distance:0,decay:0};break;case"HemisphereLight":t={direction:new A,skyColor:new Ae,groundColor:new Ae};break;case"RectAreaLight":t={color:new Ae,position:new A,halfWidth:new A,halfHeight:new A};break}return r[e.id]=t,t}}}function lD(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}var cD=0;function hD(r,e){return(e.castShadow?1:0)-(r.castShadow?1:0)}function uD(r,e){let t=new aD,n=lD(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let h=0;h<9;h++)i.probe.push(new A);let s=new A,o=new Oe,a=new Oe;function l(h,u){let d=0,f=0,m=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let p=0,g=0,x=0,v=0,w=0,b=0,S=0,M=0;h.sort(hD);let _=u!==!0?Math.PI:1;for(let T=0,E=h.length;T<E;T++){let C=h[T],I=C.color,R=C.intensity,N=C.distance,H=C.shadow&&C.shadow.map?C.shadow.map.texture:null;if(C.isAmbientLight)d+=I.r*R*_,f+=I.g*R*_,m+=I.b*R*_;else if(C.isLightProbe)for(let j=0;j<9;j++)i.probe[j].addScaledVector(C.sh.coefficients[j],R);else if(C.isDirectionalLight){let j=t.get(C);if(j.color.copy(C.color).multiplyScalar(C.intensity*_),C.castShadow){let K=C.shadow,Y=n.get(C);Y.shadowBias=K.bias,Y.shadowNormalBias=K.normalBias,Y.shadowRadius=K.radius,Y.shadowMapSize=K.mapSize,i.directionalShadow[p]=Y,i.directionalShadowMap[p]=H,i.directionalShadowMatrix[p]=C.shadow.matrix,b++}i.directional[p]=j,p++}else if(C.isSpotLight){let j=t.get(C);if(j.position.setFromMatrixPosition(C.matrixWorld),j.color.copy(I).multiplyScalar(R*_),j.distance=N,j.coneCos=Math.cos(C.angle),j.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),j.decay=C.decay,C.castShadow){let K=C.shadow,Y=n.get(C);Y.shadowBias=K.bias,Y.shadowNormalBias=K.normalBias,Y.shadowRadius=K.radius,Y.shadowMapSize=K.mapSize,i.spotShadow[x]=Y,i.spotShadowMap[x]=H,i.spotShadowMatrix[x]=C.shadow.matrix,M++}i.spot[x]=j,x++}else if(C.isRectAreaLight){let j=t.get(C);j.color.copy(I).multiplyScalar(R),j.halfWidth.set(C.width*.5,0,0),j.halfHeight.set(0,C.height*.5,0),i.rectArea[v]=j,v++}else if(C.isPointLight){let j=t.get(C);if(j.color.copy(C.color).multiplyScalar(C.intensity*_),j.distance=C.distance,j.decay=C.decay,C.castShadow){let K=C.shadow,Y=n.get(C);Y.shadowBias=K.bias,Y.shadowNormalBias=K.normalBias,Y.shadowRadius=K.radius,Y.shadowMapSize=K.mapSize,Y.shadowCameraNear=K.camera.near,Y.shadowCameraFar=K.camera.far,i.pointShadow[g]=Y,i.pointShadowMap[g]=H,i.pointShadowMatrix[g]=C.shadow.matrix,S++}i.point[g]=j,g++}else if(C.isHemisphereLight){let j=t.get(C);j.skyColor.copy(C.color).multiplyScalar(R*_),j.groundColor.copy(C.groundColor).multiplyScalar(R*_),i.hemi[w]=j,w++}}v>0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=me.LTC_FLOAT_1,i.rectAreaLTC2=me.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=me.LTC_HALF_1,i.rectAreaLTC2=me.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=m;let y=i.hash;(y.directionalLength!==p||y.pointLength!==g||y.spotLength!==x||y.rectAreaLength!==v||y.hemiLength!==w||y.numDirectionalShadows!==b||y.numPointShadows!==S||y.numSpotShadows!==M)&&(i.directional.length=p,i.spot.length=x,i.rectArea.length=v,i.point.length=g,i.hemi.length=w,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=S,i.pointShadowMap.length=S,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=S,i.spotShadowMatrix.length=M,y.directionalLength=p,y.pointLength=g,y.spotLength=x,y.rectAreaLength=v,y.hemiLength=w,y.numDirectionalShadows=b,y.numPointShadows=S,y.numSpotShadows=M,i.version=cD++)}function c(h,u){let d=0,f=0,m=0,p=0,g=0,x=u.matrixWorldInverse;for(let v=0,w=h.length;v<w;v++){let b=h[v];if(b.isDirectionalLight){let S=i.directional[d];S.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(x),d++}else if(b.isSpotLight){let S=i.spot[m];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(x),S.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(x),m++}else if(b.isRectAreaLight){let S=i.rectArea[p];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(x),a.identity(),o.copy(b.matrixWorld),o.premultiply(x),a.extractRotation(o),S.halfWidth.set(b.width*.5,0,0),S.halfHeight.set(0,b.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),p++}else if(b.isPointLight){let S=i.point[f];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(x),f++}else if(b.isHemisphereLight){let S=i.hemi[g];S.direction.setFromMatrixPosition(b.matrixWorld),S.direction.transformDirection(x),g++}}}return{setup:l,setupView:c,state:i}}function I0(r,e){let t=new uD(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function o(u){n.push(u)}function a(u){i.push(u)}function l(u){t.setup(n,u)}function c(u){t.setupView(n,u)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:l,setupLightsView:c,pushLight:o,pushShadow:a}}function dD(r,e){let t=new WeakMap;function n(s,o=0){let a;return t.has(s)===!1?(a=new I0(r,e),t.set(s,[a])):o>=t.get(s).length?(a=new I0(r,e),t.get(s).push(a)):a=t.get(s)[o],a}function i(){t=new WeakMap}return{get:n,dispose:i}}var xu=class extends un{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=An,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},bu=class extends un{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new A,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},fD=`void main() {
|
|
3110
3110
|
gl_Position = vec4( position, 1.0 );
|
|
3111
3111
|
}`,pD=`uniform sampler2D shadow_pass;
|
|
3112
3112
|
uniform vec2 resolution;
|
|
@@ -3134,10 +3134,10 @@ void main() {
|
|
|
3134
3134
|
squared_mean = squared_mean / samples;
|
|
3135
3135
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3136
3136
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3137
|
-
}`;function mD(r,e,t){let n=new fc,i=new B,s=new B,o=new qe,a=new xu({depthPacking:S_}),l=new bu,c={},h=t.maxTextureSize,u={0:wn,1:zi,2:hn},d=new dt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new B},radius:{value:4}},vertexShader:fD,fragmentShader:pD}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new Ie;m.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Vt(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Bu,this.render=function(b,S,M){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let _=r.getRenderTarget(),y=r.getActiveCubeFace(),T=r.getActiveMipmapLevel(),E=r.state;E.setBlending(Ct),E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);for(let C=0,L=b.length;C<L;C++){let R=b[C],N=R.shadow;if(N===void 0){console.warn("THREE.WebGLShadowMap:",R,"has no shadow.");continue}if(N.autoUpdate===!1&&N.needsUpdate===!1)continue;i.copy(N.mapSize);let H=N.getFrameExtents();if(i.multiply(H),s.copy(N.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/H.x),i.x=s.x*H.x,N.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/H.y),i.y=s.y*H.y,N.mapSize.y=s.y)),N.map===null&&!N.isPointLightShadow&&this.type===rc&&(N.map=new lt(i.x,i.y),N.map.texture.name=R.name+".shadowMap",N.mapPass=new lt(i.x,i.y),N.camera.updateProjectionMatrix()),N.map===null){let K={minFilter:Gt,magFilter:Gt,format:xr};N.map=new lt(i.x,i.y,K),N.map.texture.name=R.name+".shadowMap",N.camera.updateProjectionMatrix()}r.setRenderTarget(N.map),r.clear();let j=N.getViewportCount();for(let K=0;K<j;K++){let Y=N.getViewport(K);o.set(s.x*Y.x,s.y*Y.y,s.x*Y.z,s.y*Y.w),E.viewport(o),N.updateMatrices(R,K),n=N.getFrustum(),w(S,M,N.camera,R,this.type)}!N.isPointLightShadow&&this.type===rc&&x(N,M),N.needsUpdate=!1}g.needsUpdate=!1,r.setRenderTarget(_,y,T)};function x(b,S){let M=e.update(p);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,r.setRenderTarget(b.mapPass),r.clear(),r.renderBufferDirect(S,null,M,d,p,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,r.setRenderTarget(b.map),r.clear(),r.renderBufferDirect(S,null,M,f,p,null)}function v(b,S,M,_,y,T){let E=null,C=M.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0?E=C:E=M.isPointLight===!0?l:a,r.localClippingEnabled&&S.clipShadows===!0&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0){let L=E.uuid,R=S.uuid,N=c[L];N===void 0&&(N={},c[L]=N);let H=N[R];H===void 0&&(H=E.clone(),N[R]=H),E=H}return E.visible=S.visible,E.wireframe=S.wireframe,T===rc?E.side=S.shadowSide!==null?S.shadowSide:S.side:E.side=S.shadowSide!==null?S.shadowSide:u[S.side],E.alphaMap=S.alphaMap,E.alphaTest=S.alphaTest,E.clipShadows=S.clipShadows,E.clippingPlanes=S.clippingPlanes,E.clipIntersection=S.clipIntersection,E.displacementMap=S.displacementMap,E.displacementScale=S.displacementScale,E.displacementBias=S.displacementBias,E.wireframeLinewidth=S.wireframeLinewidth,E.linewidth=S.linewidth,M.isPointLight===!0&&E.isMeshDistanceMaterial===!0&&(E.referencePosition.setFromMatrixPosition(M.matrixWorld),E.nearDistance=_,E.farDistance=y),E}function w(b,S,M,_,y){if(b.visible===!1)return;if(b.layers.test(S.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&y===rc)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,b.matrixWorld);let C=e.update(b),L=b.material;if(Array.isArray(L)){let R=C.groups;for(let N=0,H=R.length;N<H;N++){let j=R[N],K=L[j.materialIndex];if(K&&K.visible){let Y=v(b,K,_,M.near,M.far,y);r.renderBufferDirect(M,null,C,Y,b,j)}}}else if(L.visible){let R=v(b,L,_,M.near,M.far,y);r.renderBufferDirect(M,null,C,R,b,null)}}let E=b.children;for(let C=0,L=E.length;C<L;C++)w(E[C],S,M,_,y)}}function gD(r,e,t){let n=t.isWebGL2;function i(){let U=!1,xe=new qe,Me=null,Qe=new qe(0,0,0,0);return{setMask:function(Ne){Me!==Ne&&!U&&(r.colorMask(Ne,Ne,Ne,Ne),Me=Ne)},setLocked:function(Ne){U=Ne},setClear:function(Ne,Ke,be,Ze,rt){rt===!0&&(Ne*=Ze,Ke*=Ze,be*=Ze),xe.set(Ne,Ke,be,Ze),Qe.equals(xe)===!1&&(r.clearColor(Ne,Ke,be,Ze),Qe.copy(xe))},reset:function(){U=!1,Me=null,Qe.set(-1,0,0,0)}}}function s(){let U=!1,xe=null,Me=null,Qe=null;return{setTest:function(Ne){Ne?X(2929):q(2929)},setMask:function(Ne){xe!==Ne&&!U&&(r.depthMask(Ne),xe=Ne)},setFunc:function(Ne){if(Me!==Ne){if(Ne)switch(Ne){case jM:r.depthFunc(512);break;case qM:r.depthFunc(519);break;case XM:r.depthFunc(513);break;case Wp:r.depthFunc(515);break;case YM:r.depthFunc(514);break;case QM:r.depthFunc(518);break;case KM:r.depthFunc(516);break;case ZM:r.depthFunc(517);break;default:r.depthFunc(515)}else r.depthFunc(515);Me=Ne}},setLocked:function(Ne){U=Ne},setClear:function(Ne){Qe!==Ne&&(r.clearDepth(Ne),Qe=Ne)},reset:function(){U=!1,xe=null,Me=null,Qe=null}}}function o(){let U=!1,xe=null,Me=null,Qe=null,Ne=null,Ke=null,be=null,Ze=null,rt=null;return{setTest:function(gt){U||(gt?X(2960):q(2960))},setMask:function(gt){xe!==gt&&!U&&(r.stencilMask(gt),xe=gt)},setFunc:function(gt,wt,Qn){(Me!==gt||Qe!==wt||Ne!==Qn)&&(r.stencilFunc(gt,wt,Qn),Me=gt,Qe=wt,Ne=Qn)},setOp:function(gt,wt,Qn){(Ke!==gt||be!==wt||Ze!==Qn)&&(r.stencilOp(gt,wt,Qn),Ke=gt,be=wt,Ze=Qn)},setLocked:function(gt){U=gt},setClear:function(gt){rt!==gt&&(r.clearStencil(gt),rt=gt)},reset:function(){U=!1,xe=null,Me=null,Qe=null,Ne=null,Ke=null,be=null,Ze=null,rt=null}}}let a=new i,l=new s,c=new o,h={},u={},d=new WeakMap,f=[],m=null,p=!1,g=null,x=null,v=null,w=null,b=null,S=null,M=null,_=!1,y=null,T=null,E=null,C=null,L=null,R=r.getParameter(35661),N=!1,H=0,j=r.getParameter(7938);j.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(j)[1]),N=H>=1):j.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),N=H>=2);let K=null,Y={},z=r.getParameter(3088),F=r.getParameter(2978),V=new qe().fromArray(z),O=new qe().fromArray(F);function G(U,xe,Me){let Qe=new Uint8Array(4),Ne=r.createTexture();r.bindTexture(U,Ne),r.texParameteri(U,10241,9728),r.texParameteri(U,10240,9728);for(let Ke=0;Ke<Me;Ke++)r.texImage2D(xe+Ke,0,6408,1,1,0,6408,5121,Qe);return Ne}let W={};W[3553]=G(3553,3553,1),W[34067]=G(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),X(2929),l.setFunc(Wp),de(!1),ge(wv),X(2884),ce(Ct);function X(U){h[U]!==!0&&(r.enable(U),h[U]=!0)}function q(U){h[U]!==!1&&(r.disable(U),h[U]=!1)}function se(U,xe){return u[U]!==xe?(r.bindFramebuffer(U,xe),u[U]=xe,n&&(U===36009&&(u[36160]=xe),U===36160&&(u[36009]=xe)),!0):!1}function Z(U,xe){let Me=f,Qe=!1;if(U)if(Me=d.get(xe),Me===void 0&&(Me=[],d.set(xe,Me)),U.isWebGLMultipleRenderTargets){let Ne=U.texture;if(Me.length!==Ne.length||Me[0]!==36064){for(let Ke=0,be=Ne.length;Ke<be;Ke++)Me[Ke]=36064+Ke;Me.length=Ne.length,Qe=!0}}else Me[0]!==36064&&(Me[0]=36064,Qe=!0);else Me[0]!==1029&&(Me[0]=1029,Qe=!0);Qe&&(t.isWebGL2?r.drawBuffers(Me):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Me))}function te(U){return m!==U?(r.useProgram(U),m=U,!0):!1}let k={[Zo]:32774,[RM]:32778,[BM]:32779};if(n)k[_v]=32775,k[Tv]=32776;else{let U=e.get("EXT_blend_minmax");U!==null&&(k[_v]=U.MIN_EXT,k[Tv]=U.MAX_EXT)}let le={[OM]:0,[FM]:1,[UM]:768,[$0]:770,[WM]:776,[VM]:774,[GM]:772,[zM]:769,[ex]:771,[HM]:775,[kM]:773};function ce(U,xe,Me,Qe,Ne,Ke,be,Ze){if(U===Ct){p===!0&&(q(3042),p=!1);return}if(p===!1&&(X(3042),p=!0),U!==NM){if(U!==g||Ze!==_){if((x!==Zo||b!==Zo)&&(r.blendEquation(32774),x=Zo,b=Zo),Ze)switch(U){case ls:r.blendFuncSeparate(1,771,1,771);break;case Sv:r.blendFunc(1,1);break;case Av:r.blendFuncSeparate(0,769,0,1);break;case Mv:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case ls:r.blendFuncSeparate(770,771,1,771);break;case Sv:r.blendFunc(770,1);break;case Av:r.blendFuncSeparate(0,769,0,1);break;case Mv:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}v=null,w=null,S=null,M=null,g=U,_=Ze}return}Ne=Ne||xe,Ke=Ke||Me,be=be||Qe,(xe!==x||Ne!==b)&&(r.blendEquationSeparate(k[xe],k[Ne]),x=xe,b=Ne),(Me!==v||Qe!==w||Ke!==S||be!==M)&&(r.blendFuncSeparate(le[Me],le[Qe],le[Ke],le[be]),v=Me,w=Qe,S=Ke,M=be),g=U,_=null}function ae(U,xe){U.side===hn?q(2884):X(2884);let Me=U.side===wn;xe&&(Me=!Me),de(Me),U.blending===ls&&U.transparent===!1?ce(Ct):ce(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.premultipliedAlpha),l.setFunc(U.depthFunc),l.setTest(U.depthTest),l.setMask(U.depthWrite),a.setMask(U.colorWrite);let Qe=U.stencilWrite;c.setTest(Qe),Qe&&(c.setMask(U.stencilWriteMask),c.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),c.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),Ee(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?X(32926):q(32926)}function de(U){y!==U&&(U?r.frontFace(2304):r.frontFace(2305),y=U)}function ge(U){U!==PM?(X(2884),U!==T&&(U===wv?r.cullFace(1029):U===IM?r.cullFace(1028):r.cullFace(1032))):q(2884),T=U}function fe(U){U!==E&&(N&&r.lineWidth(U),E=U)}function Ee(U,xe,Me){U?(X(32823),(C!==xe||L!==Me)&&(r.polygonOffset(xe,Me),C=xe,L=Me)):q(32823)}function De(U){U?X(3089):q(3089)}function ye(U){U===void 0&&(U=33984+R-1),K!==U&&(r.activeTexture(U),K=U)}function Re(U,xe){K===null&&ye();let Me=Y[K];Me===void 0&&(Me={type:void 0,texture:void 0},Y[K]=Me),(Me.type!==U||Me.texture!==xe)&&(r.bindTexture(U,xe||W[U]),Me.type=U,Me.texture=xe)}function mt(){let U=Y[K];U!==void 0&&U.type!==void 0&&(r.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}function P(){try{r.compressedTexImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function D(){try{r.texSubImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function J(){try{r.texSubImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ue(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function pe(){try{r.texStorage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ce(){try{r.texStorage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Fe(){try{r.texImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function re(){try{r.texImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Be(U){V.equals(U)===!1&&(r.scissor(U.x,U.y,U.z,U.w),V.copy(U))}function Le(U){O.equals(U)===!1&&(r.viewport(U.x,U.y,U.z,U.w),O.copy(U))}function ve(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},K=null,Y={},u={},d=new WeakMap,f=[],m=null,p=!1,g=null,x=null,v=null,w=null,b=null,S=null,M=null,_=!1,y=null,T=null,E=null,C=null,L=null,V.set(0,0,r.canvas.width,r.canvas.height),O.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:X,disable:q,bindFramebuffer:se,drawBuffers:Z,useProgram:te,setBlending:ce,setMaterial:ae,setFlipSided:de,setCullFace:ge,setLineWidth:fe,setPolygonOffset:Ee,setScissorTest:De,activeTexture:ye,bindTexture:Re,unbindTexture:mt,compressedTexImage2D:P,texImage2D:Fe,texImage3D:re,texStorage2D:pe,texStorage3D:Ce,texSubImage2D:D,texSubImage3D:J,compressedTexSubImage2D:ue,scissor:Be,viewport:Le,reset:ve}}function yD(r,e,t,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,h=i.maxTextureSize,u=i.maxSamples,d=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,f=/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(P,D){return x?new OffscreenCanvas(P,D):fu("canvas")}function w(P,D,J,ue){let pe=1;if((P.width>ue||P.height>ue)&&(pe=ue/Math.max(P.width,P.height)),pe<1||D===!0)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap){let Ce=D?du:Math.floor,Fe=Ce(pe*P.width),re=Ce(pe*P.height);p===void 0&&(p=v(Fe,re));let Be=J?v(Fe,re):p;return Be.width=Fe,Be.height=re,Be.getContext("2d").drawImage(P,0,0,Fe,re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+P.width+"x"+P.height+") to ("+Fe+"x"+re+")."),Be}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+P.width+"x"+P.height+")."),P;return P}function b(P){return Kp(P.width)&&Kp(P.height)}function S(P){return a?!1:P.wrapS!==bn||P.wrapT!==bn||P.minFilter!==Gt&&P.minFilter!==tt}function M(P,D){return P.generateMipmaps&&D&&P.minFilter!==Gt&&P.minFilter!==tt}function _(P){r.generateMipmap(P)}function y(P,D,J,ue,pe=!1){if(a===!1)return D;if(P!==null){if(r[P]!==void 0)return r[P];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let Ce=D;return D===6403&&(J===5126&&(Ce=33326),J===5131&&(Ce=33325),J===5121&&(Ce=33321)),D===33319&&(J===5126&&(Ce=33328),J===5131&&(Ce=33327),J===5121&&(Ce=33323)),D===6408&&(J===5126&&(Ce=34836),J===5131&&(Ce=34842),J===5121&&(Ce=ue===We&&pe===!1?35907:32856),J===32819&&(Ce=32854),J===32820&&(Ce=32855)),(Ce===33325||Ce===33326||Ce===33327||Ce===33328||Ce===34842||Ce===34836)&&e.get("EXT_color_buffer_float"),Ce}function T(P,D,J){return M(P,J)===!0||P.isFramebufferTexture&&P.minFilter!==Gt&&P.minFilter!==tt?Math.log2(Math.max(D.width,D.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?D.mipmaps.length:1}function E(P){return P===Gt||P===Ev||P===Cv?9728:9729}function C(P){let D=P.target;D.removeEventListener("dispose",C),R(D),D.isVideoTexture&&m.delete(D)}function L(P){let D=P.target;D.removeEventListener("dispose",L),H(D)}function R(P){let D=n.get(P);if(D.__webglInit===void 0)return;let J=P.source,ue=g.get(J);if(ue){let pe=ue[D.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&N(P),Object.keys(ue).length===0&&g.delete(J)}n.remove(P)}function N(P){let D=n.get(P);r.deleteTexture(D.__webglTexture);let J=P.source,ue=g.get(J);delete ue[D.__cacheKey],o.memory.textures--}function H(P){let D=P.texture,J=n.get(P),ue=n.get(D);if(ue.__webglTexture!==void 0&&(r.deleteTexture(ue.__webglTexture),o.memory.textures--),P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++)r.deleteFramebuffer(J.__webglFramebuffer[pe]),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer[pe]);else{if(r.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&r.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let pe=0;pe<J.__webglColorRenderbuffer.length;pe++)J.__webglColorRenderbuffer[pe]&&r.deleteRenderbuffer(J.__webglColorRenderbuffer[pe]);J.__webglDepthRenderbuffer&&r.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(P.isWebGLMultipleRenderTargets)for(let pe=0,Ce=D.length;pe<Ce;pe++){let Fe=n.get(D[pe]);Fe.__webglTexture&&(r.deleteTexture(Fe.__webglTexture),o.memory.textures--),n.remove(D[pe])}n.remove(D),n.remove(P)}let j=0;function K(){j=0}function Y(){let P=j;return P>=l&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+l),j+=1,P}function z(P){let D=[];return D.push(P.wrapS),D.push(P.wrapT),D.push(P.magFilter),D.push(P.minFilter),D.push(P.anisotropy),D.push(P.internalFormat),D.push(P.format),D.push(P.type),D.push(P.generateMipmaps),D.push(P.premultiplyAlpha),D.push(P.flipY),D.push(P.unpackAlignment),D.push(P.encoding),D.join()}function F(P,D){let J=n.get(P);if(P.isVideoTexture&&Re(P),P.isRenderTargetTexture===!1&&P.version>0&&J.__version!==P.version){let ue=P.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(J,P,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,J.__webglTexture)}function V(P,D){let J=n.get(P);if(P.version>0&&J.__version!==P.version){Z(J,P,D);return}t.activeTexture(33984+D),t.bindTexture(35866,J.__webglTexture)}function O(P,D){let J=n.get(P);if(P.version>0&&J.__version!==P.version){Z(J,P,D);return}t.activeTexture(33984+D),t.bindTexture(32879,J.__webglTexture)}function G(P,D){let J=n.get(P);if(P.version>0&&J.__version!==P.version){te(J,P,D);return}t.activeTexture(33984+D),t.bindTexture(34067,J.__webglTexture)}let W={[ta]:10497,[bn]:33071,[Xp]:33648},X={[Gt]:9728,[Ev]:9984,[Cv]:9986,[tt]:9729,[s_]:9985,[xs]:9987};function q(P,D,J){if(J?(r.texParameteri(P,10242,W[D.wrapS]),r.texParameteri(P,10243,W[D.wrapT]),(P===32879||P===35866)&&r.texParameteri(P,32882,W[D.wrapR]),r.texParameteri(P,10240,X[D.magFilter]),r.texParameteri(P,10241,X[D.minFilter])):(r.texParameteri(P,10242,33071),r.texParameteri(P,10243,33071),(P===32879||P===35866)&&r.texParameteri(P,32882,33071),(D.wrapS!==bn||D.wrapT!==bn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(P,10240,E(D.magFilter)),r.texParameteri(P,10241,E(D.minFilter)),D.minFilter!==Gt&&D.minFilter!==tt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let ue=e.get("EXT_texture_filter_anisotropic");if(D.type===vr&&e.has("OES_texture_float_linear")===!1||a===!1&&D.type===hc&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||n.get(D).__currentAnisotropy)&&(r.texParameterf(P,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,i.getMaxAnisotropy())),n.get(D).__currentAnisotropy=D.anisotropy)}}function se(P,D){let J=!1;P.__webglInit===void 0&&(P.__webglInit=!0,D.addEventListener("dispose",C));let ue=D.source,pe=g.get(ue);pe===void 0&&(pe={},g.set(ue,pe));let Ce=z(D);if(Ce!==P.__cacheKey){pe[Ce]===void 0&&(pe[Ce]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,J=!0),pe[Ce].usedTimes++;let Fe=pe[P.__cacheKey];Fe!==void 0&&(pe[P.__cacheKey].usedTimes--,Fe.usedTimes===0&&N(D)),P.__cacheKey=Ce,P.__webglTexture=pe[Ce].texture}return J}function Z(P,D,J){let ue=3553;D.isDataArrayTexture&&(ue=35866),D.isData3DTexture&&(ue=32879);let pe=se(P,D),Ce=D.source;if(t.activeTexture(33984+J),t.bindTexture(ue,P.__webglTexture),Ce.version!==Ce.__currentVersion||pe===!0){r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let Fe=S(D)&&b(D.image)===!1,re=w(D.image,Fe,!1,h);re=mt(D,re);let Be=b(re)||a,Le=s.convert(D.format,D.encoding),ve=s.convert(D.type),U=y(D.internalFormat,Le,ve,D.encoding,D.isVideoTexture);q(ue,D,Be);let xe,Me=D.mipmaps,Qe=a&&D.isVideoTexture!==!0,Ne=Ce.__currentVersion===void 0||pe===!0,Ke=T(D,re,Be);if(D.isDepthTexture)U=6402,a?D.type===vr?U=36012:D.type===Fi?U=33190:D.type===cs?U=35056:U=33189:D.type===vr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===to&&U===6402&&D.type!==nx&&D.type!==Fi&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Fi,ve=s.convert(D.type)),D.format===fs&&U===6402&&(U=34041,D.type!==cs&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=cs,ve=s.convert(D.type))),Ne&&(Qe?t.texStorage2D(3553,1,U,re.width,re.height):t.texImage2D(3553,0,U,re.width,re.height,0,Le,ve,null));else if(D.isDataTexture)if(Me.length>0&&Be){Qe&&Ne&&t.texStorage2D(3553,Ke,U,Me[0].width,Me[0].height);for(let be=0,Ze=Me.length;be<Ze;be++)xe=Me[be],Qe?t.texSubImage2D(3553,be,0,0,xe.width,xe.height,Le,ve,xe.data):t.texImage2D(3553,be,U,xe.width,xe.height,0,Le,ve,xe.data);D.generateMipmaps=!1}else Qe?(Ne&&t.texStorage2D(3553,Ke,U,re.width,re.height),t.texSubImage2D(3553,0,0,0,re.width,re.height,Le,ve,re.data)):t.texImage2D(3553,0,U,re.width,re.height,0,Le,ve,re.data);else if(D.isCompressedTexture){Qe&&Ne&&t.texStorage2D(3553,Ke,U,Me[0].width,Me[0].height);for(let be=0,Ze=Me.length;be<Ze;be++)xe=Me[be],D.format!==xr?Le!==null?Qe?t.compressedTexSubImage2D(3553,be,0,0,xe.width,xe.height,Le,xe.data):t.compressedTexImage2D(3553,be,U,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Qe?t.texSubImage2D(3553,be,0,0,xe.width,xe.height,Le,ve,xe.data):t.texImage2D(3553,be,U,xe.width,xe.height,0,Le,ve,xe.data)}else if(D.isDataArrayTexture)Qe?(Ne&&t.texStorage3D(35866,Ke,U,re.width,re.height,re.depth),t.texSubImage3D(35866,0,0,0,0,re.width,re.height,re.depth,Le,ve,re.data)):t.texImage3D(35866,0,U,re.width,re.height,re.depth,0,Le,ve,re.data);else if(D.isData3DTexture)Qe?(Ne&&t.texStorage3D(32879,Ke,U,re.width,re.height,re.depth),t.texSubImage3D(32879,0,0,0,0,re.width,re.height,re.depth,Le,ve,re.data)):t.texImage3D(32879,0,U,re.width,re.height,re.depth,0,Le,ve,re.data);else if(D.isFramebufferTexture){if(Ne)if(Qe)t.texStorage2D(3553,Ke,U,re.width,re.height);else{let be=re.width,Ze=re.height;for(let rt=0;rt<Ke;rt++)t.texImage2D(3553,rt,U,be,Ze,0,Le,ve,null),be>>=1,Ze>>=1}}else if(Me.length>0&&Be){Qe&&Ne&&t.texStorage2D(3553,Ke,U,Me[0].width,Me[0].height);for(let be=0,Ze=Me.length;be<Ze;be++)xe=Me[be],Qe?t.texSubImage2D(3553,be,0,0,Le,ve,xe):t.texImage2D(3553,be,U,Le,ve,xe);D.generateMipmaps=!1}else Qe?(Ne&&t.texStorage2D(3553,Ke,U,re.width,re.height),t.texSubImage2D(3553,0,0,0,Le,ve,re)):t.texImage2D(3553,0,U,Le,ve,re);M(D,Be)&&_(ue),Ce.__currentVersion=Ce.version,D.onUpdate&&D.onUpdate(D)}P.__version=D.version}function te(P,D,J){if(D.image.length!==6)return;let ue=se(P,D),pe=D.source;if(t.activeTexture(33984+J),t.bindTexture(34067,P.__webglTexture),pe.version!==pe.__currentVersion||ue===!0){r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let Ce=D.isCompressedTexture||D.image[0].isCompressedTexture,Fe=D.image[0]&&D.image[0].isDataTexture,re=[];for(let be=0;be<6;be++)!Ce&&!Fe?re[be]=w(D.image[be],!1,!0,c):re[be]=Fe?D.image[be].image:D.image[be],re[be]=mt(D,re[be]);let Be=re[0],Le=b(Be)||a,ve=s.convert(D.format,D.encoding),U=s.convert(D.type),xe=y(D.internalFormat,ve,U,D.encoding),Me=a&&D.isVideoTexture!==!0,Qe=pe.__currentVersion===void 0||ue===!0,Ne=T(D,Be,Le);q(34067,D,Le);let Ke;if(Ce){Me&&Qe&&t.texStorage2D(34067,Ne,xe,Be.width,Be.height);for(let be=0;be<6;be++){Ke=re[be].mipmaps;for(let Ze=0;Ze<Ke.length;Ze++){let rt=Ke[Ze];D.format!==xr?ve!==null?Me?t.compressedTexSubImage2D(34069+be,Ze,0,0,rt.width,rt.height,ve,rt.data):t.compressedTexImage2D(34069+be,Ze,xe,rt.width,rt.height,0,rt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Me?t.texSubImage2D(34069+be,Ze,0,0,rt.width,rt.height,ve,U,rt.data):t.texImage2D(34069+be,Ze,xe,rt.width,rt.height,0,ve,U,rt.data)}}}else{Ke=D.mipmaps,Me&&Qe&&(Ke.length>0&&Ne++,t.texStorage2D(34067,Ne,xe,re[0].width,re[0].height));for(let be=0;be<6;be++)if(Fe){Me?t.texSubImage2D(34069+be,0,0,0,re[be].width,re[be].height,ve,U,re[be].data):t.texImage2D(34069+be,0,xe,re[be].width,re[be].height,0,ve,U,re[be].data);for(let Ze=0;Ze<Ke.length;Ze++){let gt=Ke[Ze].image[be].image;Me?t.texSubImage2D(34069+be,Ze+1,0,0,gt.width,gt.height,ve,U,gt.data):t.texImage2D(34069+be,Ze+1,xe,gt.width,gt.height,0,ve,U,gt.data)}}else{Me?t.texSubImage2D(34069+be,0,0,0,ve,U,re[be]):t.texImage2D(34069+be,0,xe,ve,U,re[be]);for(let Ze=0;Ze<Ke.length;Ze++){let rt=Ke[Ze];Me?t.texSubImage2D(34069+be,Ze+1,0,0,ve,U,rt.image[be]):t.texImage2D(34069+be,Ze+1,xe,ve,U,rt.image[be])}}}M(D,Le)&&_(34067),pe.__currentVersion=pe.version,D.onUpdate&&D.onUpdate(D)}P.__version=D.version}function k(P,D,J,ue,pe){let Ce=s.convert(J.format,J.encoding),Fe=s.convert(J.type),re=y(J.internalFormat,Ce,Fe,J.encoding);n.get(D).__hasExternalTextures||(pe===32879||pe===35866?t.texImage3D(pe,0,re,D.width,D.height,D.depth,0,Ce,Fe,null):t.texImage2D(pe,0,re,D.width,D.height,0,Ce,Fe,null)),t.bindFramebuffer(36160,P),ye(D)?d.framebufferTexture2DMultisampleEXT(36160,ue,pe,n.get(J).__webglTexture,0,De(D)):r.framebufferTexture2D(36160,ue,pe,n.get(J).__webglTexture,0),t.bindFramebuffer(36160,null)}function le(P,D,J){if(r.bindRenderbuffer(36161,P),D.depthBuffer&&!D.stencilBuffer){let ue=33189;if(J||ye(D)){let pe=D.depthTexture;pe&&pe.isDepthTexture&&(pe.type===vr?ue=36012:pe.type===Fi&&(ue=33190));let Ce=De(D);ye(D)?d.renderbufferStorageMultisampleEXT(36161,Ce,ue,D.width,D.height):r.renderbufferStorageMultisample(36161,Ce,ue,D.width,D.height)}else r.renderbufferStorage(36161,ue,D.width,D.height);r.framebufferRenderbuffer(36160,36096,36161,P)}else if(D.depthBuffer&&D.stencilBuffer){let ue=De(D);J&&ye(D)===!1?r.renderbufferStorageMultisample(36161,ue,35056,D.width,D.height):ye(D)?d.renderbufferStorageMultisampleEXT(36161,ue,35056,D.width,D.height):r.renderbufferStorage(36161,34041,D.width,D.height),r.framebufferRenderbuffer(36160,33306,36161,P)}else{let ue=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let pe=0;pe<ue.length;pe++){let Ce=ue[pe],Fe=s.convert(Ce.format,Ce.encoding),re=s.convert(Ce.type),Be=y(Ce.internalFormat,Fe,re,Ce.encoding),Le=De(D);J&&ye(D)===!1?r.renderbufferStorageMultisample(36161,Le,Be,D.width,D.height):ye(D)?d.renderbufferStorageMultisampleEXT(36161,Le,Be,D.width,D.height):r.renderbufferStorage(36161,Be,D.width,D.height)}}r.bindRenderbuffer(36161,null)}function ce(P,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,P),!(D.depthTexture&&D.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(D.depthTexture).__webglTexture||D.depthTexture.image.width!==D.width||D.depthTexture.image.height!==D.height)&&(D.depthTexture.image.width=D.width,D.depthTexture.image.height=D.height,D.depthTexture.needsUpdate=!0),F(D.depthTexture,0);let ue=n.get(D.depthTexture).__webglTexture,pe=De(D);if(D.depthTexture.format===to)ye(D)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,pe):r.framebufferTexture2D(36160,36096,3553,ue,0);else if(D.depthTexture.format===fs)ye(D)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,pe):r.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function ae(P){let D=n.get(P),J=P.isWebGLCubeRenderTarget===!0;if(P.depthTexture&&!D.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");ce(D.__webglFramebuffer,P)}else if(J){D.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)t.bindFramebuffer(36160,D.__webglFramebuffer[ue]),D.__webglDepthbuffer[ue]=r.createRenderbuffer(),le(D.__webglDepthbuffer[ue],P,!1)}else t.bindFramebuffer(36160,D.__webglFramebuffer),D.__webglDepthbuffer=r.createRenderbuffer(),le(D.__webglDepthbuffer,P,!1);t.bindFramebuffer(36160,null)}function de(P,D,J){let ue=n.get(P);D!==void 0&&k(ue.__webglFramebuffer,P,P.texture,36064,3553),J!==void 0&&ae(P)}function ge(P){let D=P.texture,J=n.get(P),ue=n.get(D);P.addEventListener("dispose",L),P.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=r.createTexture()),ue.__version=D.version,o.memory.textures++);let pe=P.isWebGLCubeRenderTarget===!0,Ce=P.isWebGLMultipleRenderTargets===!0,Fe=b(P)||a;if(pe){J.__webglFramebuffer=[];for(let re=0;re<6;re++)J.__webglFramebuffer[re]=r.createFramebuffer()}else{if(J.__webglFramebuffer=r.createFramebuffer(),Ce)if(i.drawBuffers){let re=P.texture;for(let Be=0,Le=re.length;Be<Le;Be++){let ve=n.get(re[Be]);ve.__webglTexture===void 0&&(ve.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&P.samples>0&&ye(P)===!1){let re=Ce?D:[D];J.__webglMultisampledFramebuffer=r.createFramebuffer(),J.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,J.__webglMultisampledFramebuffer);for(let Be=0;Be<re.length;Be++){let Le=re[Be];J.__webglColorRenderbuffer[Be]=r.createRenderbuffer(),r.bindRenderbuffer(36161,J.__webglColorRenderbuffer[Be]);let ve=s.convert(Le.format,Le.encoding),U=s.convert(Le.type),xe=y(Le.internalFormat,ve,U,Le.encoding),Me=De(P);r.renderbufferStorageMultisample(36161,Me,xe,P.width,P.height),r.framebufferRenderbuffer(36160,36064+Be,36161,J.__webglColorRenderbuffer[Be])}r.bindRenderbuffer(36161,null),P.depthBuffer&&(J.__webglDepthRenderbuffer=r.createRenderbuffer(),le(J.__webglDepthRenderbuffer,P,!0)),t.bindFramebuffer(36160,null)}}if(pe){t.bindTexture(34067,ue.__webglTexture),q(34067,D,Fe);for(let re=0;re<6;re++)k(J.__webglFramebuffer[re],P,D,36064,34069+re);M(D,Fe)&&_(34067),t.unbindTexture()}else if(Ce){let re=P.texture;for(let Be=0,Le=re.length;Be<Le;Be++){let ve=re[Be],U=n.get(ve);t.bindTexture(3553,U.__webglTexture),q(3553,ve,Fe),k(J.__webglFramebuffer,P,ve,36064+Be,3553),M(ve,Fe)&&_(3553)}t.unbindTexture()}else{let re=3553;(P.isWebGL3DRenderTarget||P.isWebGLArrayRenderTarget)&&(a?re=P.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(re,ue.__webglTexture),q(re,D,Fe),k(J.__webglFramebuffer,P,D,36064,re),M(D,Fe)&&_(re),t.unbindTexture()}P.depthBuffer&&ae(P)}function fe(P){let D=b(P)||a,J=P.isWebGLMultipleRenderTargets===!0?P.texture:[P.texture];for(let ue=0,pe=J.length;ue<pe;ue++){let Ce=J[ue];if(M(Ce,D)){let Fe=P.isWebGLCubeRenderTarget?34067:3553,re=n.get(Ce).__webglTexture;t.bindTexture(Fe,re),_(Fe),t.unbindTexture()}}}function Ee(P){if(a&&P.samples>0&&ye(P)===!1){let D=P.isWebGLMultipleRenderTargets?P.texture:[P.texture],J=P.width,ue=P.height,pe=16384,Ce=[],Fe=P.stencilBuffer?33306:36096,re=n.get(P),Be=P.isWebGLMultipleRenderTargets===!0;if(Be)for(let Le=0;Le<D.length;Le++)t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Le,36161,null),t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Le,3553,null,0);t.bindFramebuffer(36008,re.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,re.__webglFramebuffer);for(let Le=0;Le<D.length;Le++){Ce.push(36064+Le),P.depthBuffer&&Ce.push(Fe);let ve=re.__ignoreDepthValues!==void 0?re.__ignoreDepthValues:!1;if(ve===!1&&(P.depthBuffer&&(pe|=256),P.stencilBuffer&&(pe|=1024)),Be&&r.framebufferRenderbuffer(36008,36064,36161,re.__webglColorRenderbuffer[Le]),ve===!0&&(r.invalidateFramebuffer(36008,[Fe]),r.invalidateFramebuffer(36009,[Fe])),Be){let U=n.get(D[Le]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,U,0)}r.blitFramebuffer(0,0,J,ue,0,0,J,ue,pe,9728),f&&r.invalidateFramebuffer(36008,Ce)}if(t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,null),Be)for(let Le=0;Le<D.length;Le++){t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Le,36161,re.__webglColorRenderbuffer[Le]);let ve=n.get(D[Le]).__webglTexture;t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Le,3553,ve,0)}t.bindFramebuffer(36009,re.__webglMultisampledFramebuffer)}}function De(P){return Math.min(u,P.samples)}function ye(P){let D=n.get(P);return a&&P.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function Re(P){let D=o.render.frame;m.get(P)!==D&&(m.set(P,D),P.update())}function mt(P,D){let J=P.encoding,ue=P.format,pe=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||P.format===Qp||J!==lr&&(J===We?a===!1?e.has("EXT_sRGB")===!0&&ue===xr?(P.format=Qp,P.minFilter=tt,P.generateMipmaps=!1):D=pu.sRGBToLinear(D):(ue!==xr||pe!==It)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",J)),D}this.allocateTextureUnit=Y,this.resetTextureUnits=K,this.setTexture2D=F,this.setTexture2DArray=V,this.setTexture3D=O,this.setTextureCube=G,this.rebindTextures=de,this.setupRenderTarget=ge,this.updateRenderTargetMipmap=fe,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=k,this.useMultisampledRTT=ye}function vD(r,e,t){let n=t.isWebGL2;function i(s,o=null){let a;if(s===It)return 5121;if(s===c_)return 32819;if(s===h_)return 32820;if(s===o_)return 5120;if(s===a_)return 5122;if(s===nx)return 5123;if(s===l_)return 5124;if(s===Fi)return 5125;if(s===vr)return 5126;if(s===hc)return n?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===u_)return 6406;if(s===xr)return 6408;if(s===f_)return 6409;if(s===p_)return 6410;if(s===to)return 6402;if(s===fs)return 34041;if(s===m_)return 6403;if(s===d_)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===Qp)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===g_)return 36244;if(s===y_)return 33319;if(s===v_)return 33320;if(s===x_)return 36249;if(s===lp||s===cp||s===hp||s===up)if(o===We)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===lp)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===cp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===hp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===up)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===lp)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===cp)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===hp)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===up)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Dv||s===Pv||s===Iv||s===Lv)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Dv)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Pv)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Iv)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Lv)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===b_)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Nv||s===Rv)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Nv)return o===We?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Rv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Bv||s===Ov||s===Fv||s===Uv||s===zv||s===Gv||s===kv||s===Vv||s===Hv||s===Wv||s===jv||s===qv||s===Xv||s===Yv)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Bv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Ov)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Fv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Uv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===zv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Gv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===kv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Vv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Hv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Wv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===jv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===qv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Xv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Yv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Qv)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Qv)return o===We?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===cs?n?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var om=class extends Zt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},as=class extends ct{constructor(){super(),this.isGroup=!0,this.type="Group"}},xD={type:"move"},ac=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new as,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new as,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new as,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(a!==null&&(i=t.getPose(e.targetRaySpace,n),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(xD))),c&&e.hand){o=!0;for(let p of e.hand.values()){let g=t.getJointPose(p,n);if(c.joints[p.jointName]===void 0){let v=new as;v.matrixAutoUpdate=!1,v.visible=!1,c.joints[p.jointName]=v,c.add(v)}let x=c.joints[p.jointName];g!==null&&(x.matrix.fromArray(g.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.jointRadius=g.radius),x.visible=g!==null}let h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}},wr=class extends Bt{constructor(e,t,n,i,s,o,a,l,c,h){if(h=h!==void 0?h:to,h!==to&&h!==fs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===to&&(n=Fi),n===void 0&&h===fs&&(n=cs),super(null,i,s,o,a,l,h,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Gt,this.minFilter=l!==void 0?l:Gt,this.flipY=!1,this.generateMipmaps=!1}},am=class extends Rt{constructor(e,t){super();let n=this,i=null,s=1,o=null,a="local-floor",l=null,c=null,h=null,u=null,d=null,f=null,m=t.getContextAttributes(),p=null,g=null,x=[],v=new Map,w=new Zt;w.layers.enable(1),w.viewport=new qe;let b=new Zt;b.layers.enable(2),b.viewport=new qe;let S=[w,b],M=new om;M.layers.enable(1),M.layers.enable(2);let _=null,y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let F=x[z];return F===void 0&&(F=new ac,x[z]=F),F.getTargetRaySpace()},this.getControllerGrip=function(z){let F=x[z];return F===void 0&&(F=new ac,x[z]=F),F.getGripSpace()},this.getHand=function(z){let F=x[z];return F===void 0&&(F=new ac,x[z]=F),F.getHandSpace()};function T(z){let F=v.get(z.inputSource);F!==void 0&&F.dispatchEvent({type:z.type,data:z.inputSource})}function E(){i.removeEventListener("select",T),i.removeEventListener("selectstart",T),i.removeEventListener("selectend",T),i.removeEventListener("squeeze",T),i.removeEventListener("squeezestart",T),i.removeEventListener("squeezeend",T),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",C),v.forEach(function(z,F){z!==void 0&&z.disconnect(F)}),v.clear(),_=null,y=null,e.setRenderTarget(p),d=null,u=null,h=null,i=null,g=null,Y.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(z){s=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(z){a=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(z){l=z},this.getBaseLayer=function(){return u!==null?u:d},this.getBinding=function(){return h},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(z){if(i=z,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",T),i.addEventListener("selectstart",T),i.addEventListener("selectend",T),i.addEventListener("squeeze",T),i.addEventListener("squeezestart",T),i.addEventListener("squeezeend",T),i.addEventListener("end",E),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let F={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,F),i.updateRenderState({baseLayer:d}),g=new lt(d.framebufferWidth,d.framebufferHeight,{format:xr,type:It,encoding:e.outputEncoding})}else{let F=null,V=null,O=null;m.depth&&(O=m.stencil?35056:33190,F=m.stencil?fs:to,V=m.stencil?cs:Fi);let G={colorFormat:e.outputEncoding===We?35907:32856,depthFormat:O,scaleFactor:s};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(G),i.updateRenderState({layers:[u]}),g=new lt(u.textureWidth,u.textureHeight,{format:xr,type:It,depthTexture:new wr(u.textureWidth,u.textureHeight,V,void 0,void 0,void 0,void 0,void 0,void 0,F),stencilBuffer:m.stencil,encoding:e.outputEncoding,samples:m.antialias?4:0});let W=e.properties.get(g);W.__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(1),l=null,o=await i.requestReferenceSpace(a),Y.setContext(i),Y.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function C(z){let F=i.inputSources;for(let V=0;V<F.length;V++){let O=F[V].handedness==="right"?1:0;v.set(F[V],x[O])}for(let V=0;V<z.removed.length;V++){let O=z.removed[V],G=v.get(O);G&&(G.dispatchEvent({type:"disconnected",data:O}),v.delete(O))}for(let V=0;V<z.added.length;V++){let O=z.added[V],G=v.get(O);G&&G.dispatchEvent({type:"connected",data:O})}}let L=new A,R=new A;function N(z,F,V){L.setFromMatrixPosition(F.matrixWorld),R.setFromMatrixPosition(V.matrixWorld);let O=L.distanceTo(R),G=F.projectionMatrix.elements,W=V.projectionMatrix.elements,X=G[14]/(G[10]-1),q=G[14]/(G[10]+1),se=(G[9]+1)/G[5],Z=(G[9]-1)/G[5],te=(G[8]-1)/G[0],k=(W[8]+1)/W[0],le=X*te,ce=X*k,ae=O/(-te+k),de=ae*-te;F.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(de),z.translateZ(ae),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert();let ge=X+ae,fe=q+ae,Ee=le-de,De=ce+(O-de),ye=se*q/fe*ge,Re=Z*q/fe*ge;z.projectionMatrix.makePerspective(Ee,De,ye,Re,ge,fe)}function H(z,F){F===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(F.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(i===null)return;M.near=b.near=w.near=z.near,M.far=b.far=w.far=z.far,(_!==M.near||y!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),_=M.near,y=M.far);let F=z.parent,V=M.cameras;H(M,F);for(let G=0;G<V.length;G++)H(V[G],F);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),z.position.copy(M.position),z.quaternion.copy(M.quaternion),z.scale.copy(M.scale),z.matrix.copy(M.matrix),z.matrixWorld.copy(M.matrixWorld);let O=z.children;for(let G=0,W=O.length;G<W;G++)O[G].updateMatrixWorld(!0);V.length===2?N(M,w,b):M.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(u!==null)return u.fixedFoveation;if(d!==null)return d.fixedFoveation},this.setFoveation=function(z){u!==null&&(u.fixedFoveation=z),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=z)};let j=null;function K(z,F){if(c=F.getViewerPose(l||o),f=F,c!==null){let O=c.views;d!==null&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let G=!1;O.length!==M.cameras.length&&(M.cameras.length=0,G=!0);for(let W=0;W<O.length;W++){let X=O[W],q=null;if(d!==null)q=d.getViewport(X);else{let Z=h.getViewSubImage(u,X);q=Z.viewport,W===0&&(e.setRenderTargetTextures(g,Z.colorTexture,u.ignoreDepthValues?void 0:Z.depthStencilTexture),e.setRenderTarget(g))}let se=S[W];se===void 0&&(se=new Zt,se.layers.enable(W),se.viewport=new qe,S[W]=se),se.matrix.fromArray(X.transform.matrix),se.projectionMatrix.fromArray(X.projectionMatrix),se.viewport.set(q.x,q.y,q.width,q.height),W===0&&M.matrix.copy(se.matrix),G===!0&&M.cameras.push(se)}}let V=i.inputSources;for(let O=0;O<x.length;O++){let G=V[O],W=v.get(G);W!==void 0&&W.update(G,F,l||o)}j&&j(z,F),f=null}let Y=new sx;Y.setAnimationLoop(K),this.setAnimationLoop=function(z){j=z},this.dispose=function(){}}};function bD(r,e){function t(p,g){p.fogColor.value.copy(g.color),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function n(p,g,x,v,w){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),h(p,g)):g.isMeshPhongMaterial?(i(p,g),c(p,g)):g.isMeshStandardMaterial?(i(p,g),u(p,g),g.isMeshPhysicalMaterial&&d(p,g,w)):g.isMeshMatcapMaterial?(i(p,g),f(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,x,v):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===wn&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===wn&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x=e.get(g).envMap;if(x&&(p.envMap.value=x,p.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let b=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let w;g.aoMap?w=g.aoMap:g.lightMap&&(w=g.lightMap),w!==void 0&&(w.isWebGLRenderTarget&&(w=w.texture),w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uv2Transform.value.copy(w.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,x,v){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*x,p.scale.value=v*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let w;g.map?w=g.map:g.alphaMap&&(w=g.alphaMap),w!==void 0&&(w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uvTransform.value.copy(w.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function c(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function h(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function u(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function d(p,g,x){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===wn&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=x.texture,p.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function f(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function wD(){let r=fu("canvas");return r.style.display="block",r}function Wm(r={}){this.isWebGLRenderer=!0;let e=r.canvas!==void 0?r.canvas:wD(),t=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",c=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,h;t!==null?h=t.getContextAttributes().alpha:h=r.alpha!==void 0?r.alpha:!1;let u=null,d=null,f=[],m=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=lr,this.physicallyCorrectLights=!1,this.toneMapping=Ui,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});let p=this,g=!1,x=0,v=0,w=null,b=-1,S=null,M=new qe,_=new qe,y=null,T=e.width,E=e.height,C=1,L=null,R=null,N=new qe(0,0,T,E),H=new qe(0,0,T,E),j=!1,K=new fc,Y=!1,z=!1,F=null,V=new Oe,O=new B,G=new A,W={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function X(){return w===null?C:1}let q=t;function se(I,$){for(let ie=0;ie<I.length;ie++){let ne=I[ie],he=e.getContext(ne,$);if(he!==null)return he}return null}try{let I={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${mo}`),e.addEventListener("webglcontextlost",U,!1),e.addEventListener("webglcontextrestored",xe,!1),e.addEventListener("webglcontextcreationerror",Me,!1),q===null){let $=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&$.shift(),q=se($,I),q===null)throw se($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}q.getShaderPrecisionFormat===void 0&&(q.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(I){throw console.error("THREE.WebGLRenderer: "+I.message),I}let Z,te,k,le,ce,ae,de,ge,fe,Ee,De,ye,Re,mt,P,D,J,ue,pe,Ce,Fe,re,Be;function Le(){Z=new VC(q),te=new OC(q,Z,r),Z.init(te),re=new vD(q,Z,te),k=new gD(q,Z,te),le=new jC(q),ce=new iD,ae=new yD(q,Z,k,ce,te,re,le),de=new UC(p),ge=new kC(p),fe=new rT(q,te),Be=new RC(q,Z,fe,te),Ee=new HC(q,fe,le,Be),De=new QC(q,Ee,fe,le),pe=new YC(q,te,ae),D=new FC(ce),ye=new rD(p,de,ge,Z,te,Be,D),Re=new bD(p,ce),mt=new oD,P=new dD(Z,te),ue=new NC(p,de,k,De,h,o),J=new mD(p,De,te),Ce=new BC(q,Z,le,te),Fe=new WC(q,Z,le,te),le.programs=ye.programs,p.capabilities=te,p.extensions=Z,p.properties=ce,p.renderLists=mt,p.shadowMap=J,p.state=k,p.info=le}Le();let ve=new am(p,q);this.xr=ve,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){let I=Z.get("WEBGL_lose_context");I&&I.loseContext()},this.forceContextRestore=function(){let I=Z.get("WEBGL_lose_context");I&&I.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(I){I!==void 0&&(C=I,this.setSize(T,E,!1))},this.getSize=function(I){return I.set(T,E)},this.setSize=function(I,$,ie){if(ve.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=I,E=$,e.width=Math.floor(I*C),e.height=Math.floor($*C),ie!==!1&&(e.style.width=I+"px",e.style.height=$+"px"),this.setViewport(0,0,I,$)},this.getDrawingBufferSize=function(I){return I.set(T*C,E*C).floor()},this.setDrawingBufferSize=function(I,$,ie){T=I,E=$,C=ie,e.width=Math.floor(I*ie),e.height=Math.floor($*ie),this.setViewport(0,0,I,$)},this.getCurrentViewport=function(I){return I.copy(M)},this.getViewport=function(I){return I.copy(N)},this.setViewport=function(I,$,ie,ne){I.isVector4?N.set(I.x,I.y,I.z,I.w):N.set(I,$,ie,ne),k.viewport(M.copy(N).multiplyScalar(C).floor())},this.getScissor=function(I){return I.copy(H)},this.setScissor=function(I,$,ie,ne){I.isVector4?H.set(I.x,I.y,I.z,I.w):H.set(I,$,ie,ne),k.scissor(_.copy(H).multiplyScalar(C).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(I){k.setScissorTest(j=I)},this.setOpaqueSort=function(I){L=I},this.setTransparentSort=function(I){R=I},this.getClearColor=function(I){return I.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(I=!0,$=!0,ie=!0){let ne=0;I&&(ne|=16384),$&&(ne|=256),ie&&(ne|=1024),q.clear(ne)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",U,!1),e.removeEventListener("webglcontextrestored",xe,!1),e.removeEventListener("webglcontextcreationerror",Me,!1),mt.dispose(),P.dispose(),ce.dispose(),de.dispose(),ge.dispose(),De.dispose(),Be.dispose(),ye.dispose(),ve.dispose(),ve.removeEventListener("sessionstart",rt),ve.removeEventListener("sessionend",gt),F&&(F.dispose(),F=null),wt.stop()};function U(I){I.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let I=le.autoReset,$=J.enabled,ie=J.autoUpdate,ne=J.needsUpdate,he=J.type;Le(),le.autoReset=I,J.enabled=$,J.autoUpdate=ie,J.needsUpdate=ne,J.type=he}function Me(I){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",I.statusMessage)}function Qe(I){let $=I.target;$.removeEventListener("dispose",Qe),Ne($)}function Ne(I){Ke(I),ce.remove(I)}function Ke(I){let $=ce.get(I).programs;$!==void 0&&($.forEach(function(ie){ye.releaseProgram(ie)}),I.isShaderMaterial&&ye.releaseShaderCache(I))}this.renderBufferDirect=function(I,$,ie,ne,he,Je){$===null&&($=W);let et=he.isMesh&&he.matrixWorld.determinant()<0,st=vM(I,$,ie,ne,he);k.setMaterial(ne,et);let it=ie.index,Et=ie.attributes.position;if(it===null){if(Et===void 0||Et.count===0)return}else if(it.count===0)return;let ut=1;ne.wireframe===!0&&(it=Ee.getWireframeAttribute(ie),ut=2),Be.setup(he,ne,st,ie,it);let yt,Wt=Ce;it!==null&&(yt=fe.get(it),Wt=Fe,Wt.setIndex(yt));let Ys=it!==null?it.count:Et.count,Ro=ie.drawRange.start*ut,Bo=ie.drawRange.count*ut,ri=Je!==null?Je.start*ut:0,St=Je!==null?Je.count*ut:1/0,Oo=Math.max(Ro,ri),nn=Math.min(Ys,Ro+Bo,ri+St)-1,ii=Math.max(0,nn-Oo+1);if(ii!==0){if(he.isMesh)ne.wireframe===!0?(k.setLineWidth(ne.wireframeLinewidth*X()),Wt.setMode(1)):Wt.setMode(4);else if(he.isLine){let $i=ne.linewidth;$i===void 0&&($i=1),k.setLineWidth($i*X()),he.isLineSegments?Wt.setMode(1):he.isLineLoop?Wt.setMode(2):Wt.setMode(3)}else he.isPoints?Wt.setMode(0):he.isSprite&&Wt.setMode(4);if(he.isInstancedMesh)Wt.renderInstances(Oo,ii,he.count);else if(ie.isInstancedBufferGeometry){let $i=Math.min(ie.instanceCount,ie._maxInstanceCount);Wt.renderInstances(Oo,ii,$i)}else Wt.render(Oo,ii)}},this.compile=function(I,$){d=P.get(I),d.init(),m.push(d),I.traverseVisible(function(ie){ie.isLight&&ie.layers.test($.layers)&&(d.pushLight(ie),ie.castShadow&&d.pushShadow(ie))}),d.setupLights(p.physicallyCorrectLights),I.traverse(function(ie){let ne=ie.material;if(ne)if(Array.isArray(ne))for(let he=0;he<ne.length;he++){let Je=ne[he];ip(Je,I,ie)}else ip(ne,I,ie)}),m.pop(),d=null};let be=null;function Ze(I){be&&be(I)}function rt(){wt.stop()}function gt(){wt.start()}let wt=new sx;wt.setAnimationLoop(Ze),typeof self<"u"&&wt.setContext(self),this.setAnimationLoop=function(I){be=I,ve.setAnimationLoop(I),I===null?wt.stop():wt.start()},ve.addEventListener("sessionstart",rt),ve.addEventListener("sessionend",gt),this.render=function(I,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;I.autoUpdate===!0&&I.updateMatrixWorld(),$.parent===null&&$.updateMatrixWorld(),ve.enabled===!0&&ve.isPresenting===!0&&(ve.cameraAutoUpdate===!0&&ve.updateCamera($),$=ve.getCamera()),I.isScene===!0&&I.onBeforeRender(p,I,$,w),d=P.get(I,m.length),d.init(),m.push(d),V.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),K.setFromProjectionMatrix(V),z=this.localClippingEnabled,Y=D.init(this.clippingPlanes,z,$),u=mt.get(I,f.length),u.init(),f.push(u),Qn(I,$,0,p.sortObjects),u.finish(),p.sortObjects===!0&&u.sort(L,R),Y===!0&&D.beginShadows();let ie=d.state.shadowsArray;if(J.render(ie,I,$),Y===!0&&D.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(u,I),d.setupLights(p.physicallyCorrectLights),$.isArrayCamera){let ne=$.cameras;for(let he=0,Je=ne.length;he<Je;he++){let et=ne[he];Nh(u,I,et,et.viewport)}}else Nh(u,I,$);w!==null&&(ae.updateMultisampleRenderTarget(w),ae.updateRenderTargetMipmap(w)),I.isScene===!0&&I.onAfterRender(p,I,$),Be.resetDefaultState(),b=-1,S=null,m.pop(),m.length>0?d=m[m.length-1]:d=null,f.pop(),f.length>0?u=f[f.length-1]:u=null};function Qn(I,$,ie,ne){if(I.visible===!1)return;if(I.layers.test($.layers)){if(I.isGroup)ie=I.renderOrder;else if(I.isLOD)I.autoUpdate===!0&&I.update($);else if(I.isLight)d.pushLight(I),I.castShadow&&d.pushShadow(I);else if(I.isSprite){if(!I.frustumCulled||K.intersectsSprite(I)){ne&&G.setFromMatrixPosition(I.matrixWorld).applyMatrix4(V);let et=De.update(I),st=I.material;st.visible&&u.push(I,et,st,ie,G.z,null)}}else if((I.isMesh||I.isLine||I.isPoints)&&(I.isSkinnedMesh&&I.skeleton.frame!==le.render.frame&&(I.skeleton.update(),I.skeleton.frame=le.render.frame),!I.frustumCulled||K.intersectsObject(I))){ne&&G.setFromMatrixPosition(I.matrixWorld).applyMatrix4(V);let et=De.update(I),st=I.material;if(Array.isArray(st)){let it=et.groups;for(let Et=0,ut=it.length;Et<ut;Et++){let yt=it[Et],Wt=st[yt.materialIndex];Wt&&Wt.visible&&u.push(I,et,Wt,ie,G.z,yt)}}else st.visible&&u.push(I,et,st,ie,G.z,null)}}let Je=I.children;for(let et=0,st=Je.length;et<st;et++)Qn(Je[et],$,ie,ne)}function Nh(I,$,ie,ne){let he=I.opaque,Je=I.transmissive,et=I.transparent;d.setupLightsView(ie),Je.length>0&&No(he,$,ie),ne&&k.viewport(M.copy(ne)),he.length>0&&Rh(he,$,ie),Je.length>0&&Rh(Je,$,ie),et.length>0&&Rh(et,$,ie),k.buffers.depth.setTest(!0),k.buffers.depth.setMask(!0),k.buffers.color.setMask(!0),k.setPolygonOffset(!1)}function No(I,$,ie){let ne=te.isWebGL2;F===null&&(F=new lt(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")?hc:It,minFilter:xs,samples:ne&&s===!0?4:0})),p.getDrawingBufferSize(O),ne?F.setSize(O.x,O.y):F.setSize(du(O.x),du(O.y));let he=p.getRenderTarget();p.setRenderTarget(F),p.clear();let Je=p.toneMapping;p.toneMapping=Ui,Rh(I,$,ie),p.toneMapping=Je,ae.updateMultisampleRenderTarget(F),ae.updateRenderTargetMipmap(F),p.setRenderTarget(he)}function Rh(I,$,ie){let ne=$.isScene===!0?$.overrideMaterial:null;for(let he=0,Je=I.length;he<Je;he++){let et=I[he],st=et.object,it=et.geometry,Et=ne===null?et.material:ne,ut=et.group;st.layers.test(ie.layers)&&yM(st,$,ie,it,Et,ut)}}function yM(I,$,ie,ne,he,Je){I.onBeforeRender(p,$,ie,ne,he,Je),I.modelViewMatrix.multiplyMatrices(ie.matrixWorldInverse,I.matrixWorld),I.normalMatrix.getNormalMatrix(I.modelViewMatrix),he.onBeforeRender(p,$,ie,ne,I,Je),he.transparent===!0&&he.side===hn?(he.side=wn,he.needsUpdate=!0,p.renderBufferDirect(ie,$,ne,he,I,Je),he.side=zi,he.needsUpdate=!0,p.renderBufferDirect(ie,$,ne,he,I,Je),he.side=hn):p.renderBufferDirect(ie,$,ne,he,I,Je),I.onAfterRender(p,$,ie,ne,he,Je)}function ip(I,$,ie){$.isScene!==!0&&($=W);let ne=ce.get(I),he=d.state.lights,Je=d.state.shadowsArray,et=he.state.version,st=ye.getParameters(I,he.state,Je,$,ie),it=ye.getProgramCacheKey(st),Et=ne.programs;ne.environment=I.isMeshStandardMaterial?$.environment:null,ne.fog=$.fog,ne.envMap=(I.isMeshStandardMaterial?ge:de).get(I.envMap||ne.environment),Et===void 0&&(I.addEventListener("dispose",Qe),Et=new Map,ne.programs=Et);let ut=Et.get(it);if(ut!==void 0){if(ne.currentProgram===ut&&ne.lightsStateVersion===et)return bv(I,st),ut}else st.uniforms=ye.getUniforms(I),I.onBuild(ie,st,p),I.onBeforeCompile(st,p),ut=ye.acquireProgram(st,it),Et.set(it,ut),ne.uniforms=st.uniforms;let yt=ne.uniforms;(!I.isShaderMaterial&&!I.isRawShaderMaterial||I.clipping===!0)&&(yt.clippingPlanes=D.uniform),bv(I,st),ne.needsLights=bM(I),ne.lightsStateVersion=et,ne.needsLights&&(yt.ambientLightColor.value=he.state.ambient,yt.lightProbe.value=he.state.probe,yt.directionalLights.value=he.state.directional,yt.directionalLightShadows.value=he.state.directionalShadow,yt.spotLights.value=he.state.spot,yt.spotLightShadows.value=he.state.spotShadow,yt.rectAreaLights.value=he.state.rectArea,yt.ltc_1.value=he.state.rectAreaLTC1,yt.ltc_2.value=he.state.rectAreaLTC2,yt.pointLights.value=he.state.point,yt.pointLightShadows.value=he.state.pointShadow,yt.hemisphereLights.value=he.state.hemi,yt.directionalShadowMap.value=he.state.directionalShadowMap,yt.directionalShadowMatrix.value=he.state.directionalShadowMatrix,yt.spotShadowMap.value=he.state.spotShadowMap,yt.spotShadowMatrix.value=he.state.spotShadowMatrix,yt.pointShadowMap.value=he.state.pointShadowMap,yt.pointShadowMatrix.value=he.state.pointShadowMatrix);let Wt=ut.getUniforms(),Ys=ea.seqWithValue(Wt.seq,yt);return ne.currentProgram=ut,ne.uniformsList=Ys,ut}function bv(I,$){let ie=ce.get(I);ie.outputEncoding=$.outputEncoding,ie.instancing=$.instancing,ie.skinning=$.skinning,ie.morphTargets=$.morphTargets,ie.morphNormals=$.morphNormals,ie.morphColors=$.morphColors,ie.morphTargetsCount=$.morphTargetsCount,ie.numClippingPlanes=$.numClippingPlanes,ie.numIntersection=$.numClipIntersection,ie.vertexAlphas=$.vertexAlphas,ie.vertexTangents=$.vertexTangents,ie.toneMapping=$.toneMapping}function vM(I,$,ie,ne,he){$.isScene!==!0&&($=W),ae.resetTextureUnits();let Je=$.fog,et=ne.isMeshStandardMaterial?$.environment:null,st=w===null?p.outputEncoding:w.isXRRenderTarget===!0?w.texture.encoding:lr,it=(ne.isMeshStandardMaterial?ge:de).get(ne.envMap||et),Et=ne.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,ut=!!ne.normalMap&&!!ie.attributes.tangent,yt=!!ie.morphAttributes.position,Wt=!!ie.morphAttributes.normal,Ys=!!ie.morphAttributes.color,Ro=ne.toneMapped?p.toneMapping:Ui,Bo=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,ri=Bo!==void 0?Bo.length:0,St=ce.get(ne),Oo=d.state.lights;if(Y===!0&&(z===!0||I!==S)){let si=I===S&&ne.id===b;D.setState(ne,I,si)}let nn=!1;ne.version===St.__version?(St.needsLights&&St.lightsStateVersion!==Oo.state.version||St.outputEncoding!==st||he.isInstancedMesh&&St.instancing===!1||!he.isInstancedMesh&&St.instancing===!0||he.isSkinnedMesh&&St.skinning===!1||!he.isSkinnedMesh&&St.skinning===!0||St.envMap!==it||ne.fog===!0&&St.fog!==Je||St.numClippingPlanes!==void 0&&(St.numClippingPlanes!==D.numPlanes||St.numIntersection!==D.numIntersection)||St.vertexAlphas!==Et||St.vertexTangents!==ut||St.morphTargets!==yt||St.morphNormals!==Wt||St.morphColors!==Ys||St.toneMapping!==Ro||te.isWebGL2===!0&&St.morphTargetsCount!==ri)&&(nn=!0):(nn=!0,St.__version=ne.version);let ii=St.currentProgram;nn===!0&&(ii=ip(ne,$,he));let $i=!1,Zl=!1,sp=!1,zn=ii.getUniforms(),Jl=St.uniforms;if(k.useProgram(ii.program)&&($i=!0,Zl=!0,sp=!0),ne.id!==b&&(b=ne.id,Zl=!0),$i||S!==I){if(zn.setValue(q,"projectionMatrix",I.projectionMatrix),te.logarithmicDepthBuffer&&zn.setValue(q,"logDepthBufFC",2/(Math.log(I.far+1)/Math.LN2)),S!==I&&(S=I,Zl=!0,sp=!0),ne.isShaderMaterial||ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshStandardMaterial||ne.envMap){let si=zn.map.cameraPosition;si!==void 0&&si.setValue(q,G.setFromMatrixPosition(I.matrixWorld))}(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial)&&zn.setValue(q,"isOrthographic",I.isOrthographicCamera===!0),(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial||ne.isShadowMaterial||he.isSkinnedMesh)&&zn.setValue(q,"viewMatrix",I.matrixWorldInverse)}if(he.isSkinnedMesh){zn.setOptional(q,he,"bindMatrix"),zn.setOptional(q,he,"bindMatrixInverse");let si=he.skeleton;si&&(te.floatVertexTextures?(si.boneTexture===null&&si.computeBoneTexture(),zn.setValue(q,"boneTexture",si.boneTexture,ae),zn.setValue(q,"boneTextureSize",si.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let op=ie.morphAttributes;return(op.position!==void 0||op.normal!==void 0||op.color!==void 0&&te.isWebGL2===!0)&&pe.update(he,ie,ne,ii),(Zl||St.receiveShadow!==he.receiveShadow)&&(St.receiveShadow=he.receiveShadow,zn.setValue(q,"receiveShadow",he.receiveShadow)),Zl&&(zn.setValue(q,"toneMappingExposure",p.toneMappingExposure),St.needsLights&&xM(Jl,sp),Je&&ne.fog===!0&&Re.refreshFogUniforms(Jl,Je),Re.refreshMaterialUniforms(Jl,ne,C,E,F),ea.upload(q,St.uniformsList,Jl,ae)),ne.isShaderMaterial&&ne.uniformsNeedUpdate===!0&&(ea.upload(q,St.uniformsList,Jl,ae),ne.uniformsNeedUpdate=!1),ne.isSpriteMaterial&&zn.setValue(q,"center",he.center),zn.setValue(q,"modelViewMatrix",he.modelViewMatrix),zn.setValue(q,"normalMatrix",he.normalMatrix),zn.setValue(q,"modelMatrix",he.matrixWorld),ii}function xM(I,$){I.ambientLightColor.needsUpdate=$,I.lightProbe.needsUpdate=$,I.directionalLights.needsUpdate=$,I.directionalLightShadows.needsUpdate=$,I.pointLights.needsUpdate=$,I.pointLightShadows.needsUpdate=$,I.spotLights.needsUpdate=$,I.spotLightShadows.needsUpdate=$,I.rectAreaLights.needsUpdate=$,I.hemisphereLights.needsUpdate=$}function bM(I){return I.isMeshLambertMaterial||I.isMeshToonMaterial||I.isMeshPhongMaterial||I.isMeshStandardMaterial||I.isShadowMaterial||I.isShaderMaterial&&I.lights===!0}this.getActiveCubeFace=function(){return x},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(I,$,ie){ce.get(I.texture).__webglTexture=$,ce.get(I.depthTexture).__webglTexture=ie;let ne=ce.get(I);ne.__hasExternalTextures=!0,ne.__hasExternalTextures&&(ne.__autoAllocateDepthBuffer=ie===void 0,ne.__autoAllocateDepthBuffer||Z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ne.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(I,$){let ie=ce.get(I);ie.__webglFramebuffer=$,ie.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(I,$=0,ie=0){w=I,x=$,v=ie;let ne=!0;if(I){let it=ce.get(I);it.__useDefaultFramebuffer!==void 0?(k.bindFramebuffer(36160,null),ne=!1):it.__webglFramebuffer===void 0?ae.setupRenderTarget(I):it.__hasExternalTextures&&ae.rebindTextures(I,ce.get(I.texture).__webglTexture,ce.get(I.depthTexture).__webglTexture)}let he=null,Je=!1,et=!1;if(I){let it=I.texture;(it.isData3DTexture||it.isDataArrayTexture)&&(et=!0);let Et=ce.get(I).__webglFramebuffer;I.isWebGLCubeRenderTarget?(he=Et[$],Je=!0):te.isWebGL2&&I.samples>0&&ae.useMultisampledRTT(I)===!1?he=ce.get(I).__webglMultisampledFramebuffer:he=Et,M.copy(I.viewport),_.copy(I.scissor),y=I.scissorTest}else M.copy(N).multiplyScalar(C).floor(),_.copy(H).multiplyScalar(C).floor(),y=j;if(k.bindFramebuffer(36160,he)&&te.drawBuffers&&ne&&k.drawBuffers(I,he),k.viewport(M),k.scissor(_),k.setScissorTest(y),Je){let it=ce.get(I.texture);q.framebufferTexture2D(36160,36064,34069+$,it.__webglTexture,ie)}else if(et){let it=ce.get(I.texture),Et=$||0;q.framebufferTextureLayer(36160,36064,it.__webglTexture,ie||0,Et)}b=-1},this.readRenderTargetPixels=function(I,$,ie,ne,he,Je,et){if(!(I&&I.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let st=ce.get(I).__webglFramebuffer;if(I.isWebGLCubeRenderTarget&&et!==void 0&&(st=st[et]),st){k.bindFramebuffer(36160,st);try{let it=I.texture,Et=it.format,ut=it.type;if(Et!==xr&&re.convert(Et)!==q.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let yt=ut===hc&&(Z.has("EXT_color_buffer_half_float")||te.isWebGL2&&Z.has("EXT_color_buffer_float"));if(ut!==It&&re.convert(ut)!==q.getParameter(35738)&&!(ut===vr&&(te.isWebGL2||Z.has("OES_texture_float")||Z.has("WEBGL_color_buffer_float")))&&!yt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=I.width-ne&&ie>=0&&ie<=I.height-he&&q.readPixels($,ie,ne,he,re.convert(Et),re.convert(ut),Je)}finally{let it=w!==null?ce.get(w).__webglFramebuffer:null;k.bindFramebuffer(36160,it)}}},this.copyFramebufferToTexture=function(I,$,ie=0){let ne=Math.pow(2,-ie),he=Math.floor($.image.width*ne),Je=Math.floor($.image.height*ne);ae.setTexture2D($,0),q.copyTexSubImage2D(3553,ie,0,0,I.x,I.y,he,Je),k.unbindTexture()},this.copyTextureToTexture=function(I,$,ie,ne=0){let he=$.image.width,Je=$.image.height,et=re.convert(ie.format),st=re.convert(ie.type);ae.setTexture2D(ie,0),q.pixelStorei(37440,ie.flipY),q.pixelStorei(37441,ie.premultiplyAlpha),q.pixelStorei(3317,ie.unpackAlignment),$.isDataTexture?q.texSubImage2D(3553,ne,I.x,I.y,he,Je,et,st,$.image.data):$.isCompressedTexture?q.compressedTexSubImage2D(3553,ne,I.x,I.y,$.mipmaps[0].width,$.mipmaps[0].height,et,$.mipmaps[0].data):q.texSubImage2D(3553,ne,I.x,I.y,et,st,$.image),ne===0&&ie.generateMipmaps&&q.generateMipmap(3553),k.unbindTexture()},this.copyTextureToTexture3D=function(I,$,ie,ne,he=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Je=I.max.x-I.min.x+1,et=I.max.y-I.min.y+1,st=I.max.z-I.min.z+1,it=re.convert(ne.format),Et=re.convert(ne.type),ut;if(ne.isData3DTexture)ae.setTexture3D(ne,0),ut=32879;else if(ne.isDataArrayTexture)ae.setTexture2DArray(ne,0),ut=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}q.pixelStorei(37440,ne.flipY),q.pixelStorei(37441,ne.premultiplyAlpha),q.pixelStorei(3317,ne.unpackAlignment);let yt=q.getParameter(3314),Wt=q.getParameter(32878),Ys=q.getParameter(3316),Ro=q.getParameter(3315),Bo=q.getParameter(32877),ri=ie.isCompressedTexture?ie.mipmaps[0]:ie.image;q.pixelStorei(3314,ri.width),q.pixelStorei(32878,ri.height),q.pixelStorei(3316,I.min.x),q.pixelStorei(3315,I.min.y),q.pixelStorei(32877,I.min.z),ie.isDataTexture||ie.isData3DTexture?q.texSubImage3D(ut,he,$.x,$.y,$.z,Je,et,st,it,Et,ri.data):ie.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),q.compressedTexSubImage3D(ut,he,$.x,$.y,$.z,Je,et,st,it,ri.data)):q.texSubImage3D(ut,he,$.x,$.y,$.z,Je,et,st,it,Et,ri),q.pixelStorei(3314,yt),q.pixelStorei(32878,Wt),q.pixelStorei(3316,Ys),q.pixelStorei(3315,Ro),q.pixelStorei(32877,Bo),he===0&&ne.generateMipmaps&&q.generateMipmap(ut),k.unbindTexture()},this.initTexture=function(I){ae.setTexture2D(I,0),k.unbindTexture()},this.resetState=function(){x=0,v=0,w=null,k.reset(),Be.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var lm=class extends Wm{};lm.prototype.isWebGL1Renderer=!0;var sa=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ae(e),this.near=t,this.far=n}clone(){return new sa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Wn=class extends ct{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}},wu=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Yp,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ci()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ci()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ci()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Gn=new A,io=class{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i===!0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.applyMatrix4(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.applyNormalMatrix(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.transformDirection(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new Xe(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new io(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},cm=class extends un{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};var hm=class extends Xe{constructor(e,t,n,i=1){typeof n=="number"&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};var Jn=class extends un{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ae(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},N0=new A,R0=new A,B0=new Oe,zp=new ro,nu=new Rn,so=class extends ct{constructor(e=new Ie,t=new Jn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)N0.fromBufferAttribute(t,i-1),R0.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=N0.distanceTo(R0);e.setAttribute("lineDistance",new Se(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),nu.copy(n.boundingSphere),nu.applyMatrix4(i),nu.radius+=s,e.ray.intersectsSphere(nu)===!1)return;B0.copy(i).invert(),zp.copy(e.ray).applyMatrix4(B0);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new A,h=new A,u=new A,d=new A,f=this.isLineSegments?2:1,m=n.index,g=n.attributes.position;if(m!==null){let x=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let w=x,b=v-1;w<b;w+=f){let S=m.getX(w),M=m.getX(w+1);if(c.fromBufferAttribute(g,S),h.fromBufferAttribute(g,M),zp.distanceSqToSegment(c,h,d,u)>l)continue;d.applyMatrix4(this.matrixWorld);let y=e.ray.origin.distanceTo(d);y<e.near||y>e.far||t.push({distance:y,point:u.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{let x=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let w=x,b=v-1;w<b;w+=f){if(c.fromBufferAttribute(g,w),h.fromBufferAttribute(g,w+1),zp.distanceSqToSegment(c,h,d,u)>l)continue;d.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(d);M<e.near||M>e.far||t.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},O0=new A,F0=new A,ms=class extends so{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)O0.fromBufferAttribute(t,i),F0.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+O0.distanceTo(F0);e.setAttribute("lineDistance",new Se(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var um=class extends un{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};var Sr=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),i=0,s=n.length,o;t?o=t:o=e*n[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let h=n[i],d=n[i+1]-h,f=(o-h)/d;return(i+f)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new B:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new A,i=[],s=[],o=[],a=new A,l=new Oe;for(let f=0;f<=e;f++){let m=f/e;i[f]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let c=Number.MAX_VALUE,h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(sn(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(sn(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},oo=class extends Sr{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let n=t||new B,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},dm=class extends oo{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function jm(){let r=0,e=0,t=0,n=0;function i(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,u){let d=(o-s)/c-(a-s)/(c+h)+(a-o)/h,f=(a-o)/h-(l-o)/(h+u)+(l-a)/u;d*=h,f*=h,i(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return r+e*s+t*o+n*a}}}var ru=new A,Gp=new jm,kp=new jm,Vp=new jm,fm=class extends Sr{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new A){let n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(ru.subVectors(i[0],i[1]).add(i[0]),c=ru);let u=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(ru.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=ru),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(c.distanceToSquared(u),f),p=Math.pow(u.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(h),f);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),Gp.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,m,p,g),kp.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,m,p,g),Vp.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,m,p,g)}else this.curveType==="catmullrom"&&(Gp.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),kp.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Vp.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(Gp.calc(l),kp.calc(l),Vp.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new A().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function U0(r,e,t,n,i){let s=(n-e)*.5,o=(i-t)*.5,a=r*r,l=r*a;return(2*t-2*n+s+o)*l+(-3*t+3*n-2*s-o)*a+s*r+t}function SD(r,e){let t=1-r;return t*t*e}function AD(r,e){return 2*(1-r)*r*e}function MD(r,e){return r*r*e}function lc(r,e,t,n){return SD(r,e)+AD(r,t)+MD(r,n)}function _D(r,e){let t=1-r;return t*t*t*e}function TD(r,e){let t=1-r;return 3*t*t*r*e}function ED(r,e){return 3*(1-r)*r*r*e}function CD(r,e){return r*r*r*e}function cc(r,e,t,n,i){return _D(r,e)+TD(r,t)+ED(r,n)+CD(r,i)}var $n=class extends Sr{constructor(e=new B,t=new B,n=new B,i=new B){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new B){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(cc(e,i.x,s.x,o.x,a.x),cc(e,i.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},pm=class extends Sr{constructor(e=new A,t=new A,n=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new A){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(cc(e,i.x,s.x,o.x,a.x),cc(e,i.y,s.y,o.y,a.y),cc(e,i.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},er=class extends Sr{constructor(e=new B,t=new B){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new B){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let n=t||new B;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},pc=class extends Sr{constructor(e=new A,t=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new A){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Vr=class extends Sr{constructor(e=new B,t=new B,n=new B){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new B){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(lc(e,i.x,s.x,o.x),lc(e,i.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},mm=class extends Sr{constructor(e=new A,t=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new A){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(lc(e,i.x,s.x,o.x),lc(e,i.y,s.y,o.y),lc(e,i.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},oa=class extends Sr{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new B){let n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(U0(a,l.x,c.x,h.x,u.x),U0(a,l.y,c.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new B().fromArray(i))}return this}},DD=Object.freeze({__proto__:null,ArcCurve:dm,CatmullRomCurve3:fm,CubicBezierCurve:$n,CubicBezierCurve3:pm,EllipseCurve:oo,LineCurve:er,LineCurve3:pc,QuadraticBezierCurve:Vr,QuadraticBezierCurve3:mm,SplineCurve:oa}),gm=class extends Sr{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new er(t,e))}getPoint(e,t){let n=e*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){let h=l[c];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(new DD[i.type]().fromJSON(i))}return this}},mc=class extends gm{constructor(e){super(),this.type="Path",this.currentPoint=new B,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new er(this.currentPoint.clone(),new B(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let s=new Vr(this.currentPoint.clone(),new B(e,t),new B(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){let a=new $n(this.currentPoint.clone(),new B(e,t),new B(n,i),new B(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new oa(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,l){let c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,n,i,s,o,a,l),this}absellipse(e,t,n,i,s,o,a,l){let c=new oo(e,t,n,i,s,o,a,l);if(this.curves.length>0){let u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);let h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},aa=class extends Ie{constructor(e=[new B(0,.5),new B(.5,0),new B(0,-.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=sn(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],h=1/t,u=new A,d=new B,f=new A,m=new A,p=new A,g=0,x=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,x=e[v+1].y-e[v].y,f.x=x*1,f.y=-g,f.z=x*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(p.x,p.y,p.z);break;default:g=e[v+1].x-e[v].x,x=e[v+1].y-e[v].y,f.x=x*1,f.y=-g,f.z=x*0,m.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(m)}for(let v=0;v<=t;v++){let w=n+v*h*i,b=Math.sin(w),S=Math.cos(w);for(let M=0;M<=e.length-1;M++){u.x=e[M].x*b,u.y=e[M].y,u.z=e[M].x*S,o.push(u.x,u.y,u.z),d.x=v/t,d.y=M/(e.length-1),a.push(d.x,d.y);let _=l[3*M+0]*b,y=l[3*M+1],T=l[3*M+0]*S;c.push(_,y,T)}}for(let v=0;v<t;v++)for(let w=0;w<e.length-1;w++){let b=w+v*e.length,S=b,M=b+e.length,_=b+e.length+1,y=b+1;s.push(S,M,y),s.push(_,y,M)}this.setIndex(s),this.setAttribute("position",new Se(o,3)),this.setAttribute("uv",new Se(a,2)),this.setAttribute("normal",new Se(c,3))}static fromJSON(e){return new aa(e.points,e.segments,e.phiStart,e.phiLength)}};var ao=class extends Ie{constructor(e=1,t=1,n=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;i=Math.floor(i),s=Math.floor(s);let h=[],u=[],d=[],f=[],m=0,p=[],g=n/2,x=0;v(),o===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new Se(u,3)),this.setAttribute("normal",new Se(d,3)),this.setAttribute("uv",new Se(f,2));function v(){let b=new A,S=new A,M=0,_=(t-e)/n;for(let y=0;y<=s;y++){let T=[],E=y/s,C=E*(t-e)+e;for(let L=0;L<=i;L++){let R=L/i,N=R*l+a,H=Math.sin(N),j=Math.cos(N);S.x=C*H,S.y=-E*n+g,S.z=C*j,u.push(S.x,S.y,S.z),b.set(H,_,j).normalize(),d.push(b.x,b.y,b.z),f.push(R,1-E),T.push(m++)}p.push(T)}for(let y=0;y<i;y++)for(let T=0;T<s;T++){let E=p[T][y],C=p[T+1][y],L=p[T+1][y+1],R=p[T][y+1];h.push(E,C,R),h.push(C,L,R),M+=6}c.addGroup(x,M,0),x+=M}function w(b){let S=m,M=new B,_=new A,y=0,T=b===!0?e:t,E=b===!0?1:-1;for(let L=1;L<=i;L++)u.push(0,g*E,0),d.push(0,E,0),f.push(.5,.5),m++;let C=m;for(let L=0;L<=i;L++){let N=L/i*l+a,H=Math.cos(N),j=Math.sin(N);_.x=T*j,_.y=g*E,_.z=T*H,u.push(_.x,_.y,_.z),d.push(0,E,0),M.x=H*.5+.5,M.y=j*.5*E+.5,f.push(M.x,M.y),m++}for(let L=0;L<i;L++){let R=S+L,N=C+L;b===!0?h.push(N,N+1,R):h.push(N+1,N,R),y+=3}c.addGroup(x,y,b===!0?1:2),x+=y}}static fromJSON(e){return new ao(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},la=class extends ao{constructor(e=1,t=1,n=8,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new la(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ca=class extends Ie{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};let s=[],o=[];a(i),c(n),h(),this.setAttribute("position",new Se(s,3)),this.setAttribute("normal",new Se(s.slice(),3)),this.setAttribute("uv",new Se(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let w=new A,b=new A,S=new A;for(let M=0;M<t.length;M+=3)f(t[M+0],w),f(t[M+1],b),f(t[M+2],S),l(w,b,S,v)}function l(v,w,b,S){let M=S+1,_=[];for(let y=0;y<=M;y++){_[y]=[];let T=v.clone().lerp(b,y/M),E=w.clone().lerp(b,y/M),C=M-y;for(let L=0;L<=C;L++)L===0&&y===M?_[y][L]=T:_[y][L]=T.clone().lerp(E,L/C)}for(let y=0;y<M;y++)for(let T=0;T<2*(M-y)-1;T++){let E=Math.floor(T/2);T%2===0?(d(_[y][E+1]),d(_[y+1][E]),d(_[y][E])):(d(_[y][E+1]),d(_[y+1][E+1]),d(_[y+1][E]))}}function c(v){let w=new A;for(let b=0;b<s.length;b+=3)w.x=s[b+0],w.y=s[b+1],w.z=s[b+2],w.normalize().multiplyScalar(v),s[b+0]=w.x,s[b+1]=w.y,s[b+2]=w.z}function h(){let v=new A;for(let w=0;w<s.length;w+=3){v.x=s[w+0],v.y=s[w+1],v.z=s[w+2];let b=g(v)/2/Math.PI+.5,S=x(v)/Math.PI+.5;o.push(b,1-S)}m(),u()}function u(){for(let v=0;v<o.length;v+=6){let w=o[v+0],b=o[v+2],S=o[v+4],M=Math.max(w,b,S),_=Math.min(w,b,S);M>.9&&_<.1&&(w<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,w){let b=v*3;w.x=e[b+0],w.y=e[b+1],w.z=e[b+2]}function m(){let v=new A,w=new A,b=new A,S=new A,M=new B,_=new B,y=new B;for(let T=0,E=0;T<s.length;T+=9,E+=6){v.set(s[T+0],s[T+1],s[T+2]),w.set(s[T+3],s[T+4],s[T+5]),b.set(s[T+6],s[T+7],s[T+8]),M.set(o[E+0],o[E+1]),_.set(o[E+2],o[E+3]),y.set(o[E+4],o[E+5]),S.copy(v).add(w).add(b).divideScalar(3);let C=g(S);p(M,E+0,v,C),p(_,E+2,w,C),p(y,E+4,b,C)}}function p(v,w,b,S){S<0&&v.x===1&&(o[w]=v.x-1),b.x===0&&b.z===0&&(o[w]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function x(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new ca(e.vertices,e.indices,e.radius,e.details)}},ha=class extends ca{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ha(e.radius,e.detail)}},cz=new A,hz=new A,uz=new A,dz=new Kn;var Gr=class extends mc{constructor(e){super(e),this.uuid=ci(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(new mc().fromJSON(i))}return this}},PD={triangulate:function(r,e,t=2){let n=e&&e.length,i=n?e[0]*t:r.length,s=ux(r,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,h,u,d,f;if(n&&(s=BD(r,e,s,t)),r.length>80*t){a=c=r[0],l=h=r[1];for(let m=t;m<i;m+=t)u=r[m],d=r[m+1],u<a&&(a=u),d<l&&(l=d),u>c&&(c=u),d>h&&(h=d);f=Math.max(c-a,h-l),f=f!==0?1/f:0}return gc(s,o,t,a,l,f),o}};function ux(r,e,t,n,i){let s,o;if(i===qD(r,e,t,n)>0)for(s=e;s<t;s+=n)o=z0(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=z0(s,r[s],r[s+1],o);return o&&Uu(o,o.next)&&(vc(o),o=o.next),o}function gs(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(Uu(t,t.next)||kt(t.prev,t,t.next)===0)){if(vc(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function gc(r,e,t,n,i,s,o){if(!r)return;!o&&s&&GD(r,n,i,s);let a=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?LD(r,n,i,s):ID(r)){e.push(l.i/t),e.push(r.i/t),e.push(c.i/t),vc(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=ND(gs(r),e,t),gc(r,e,t,n,i,s,2)):o===2&&RD(r,e,t,n,i,s):gc(gs(r),e,t,n,i,s,1);break}}}function ID(r){let e=r.prev,t=r,n=r.next;if(kt(e,t,n)>=0)return!1;let i=r.next.next;for(;i!==r.prev;){if($o(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&kt(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function LD(r,e,t,n){let i=r.prev,s=r,o=r.next;if(kt(i,s,o)>=0)return!1;let a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,c=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,h=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,u=ym(a,l,e,t,n),d=ym(c,h,e,t,n),f=r.prevZ,m=r.nextZ;for(;f&&f.z>=u&&m&&m.z<=d;){if(f!==r.prev&&f!==r.next&&$o(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&kt(f.prev,f,f.next)>=0||(f=f.prevZ,m!==r.prev&&m!==r.next&&$o(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&kt(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;f&&f.z>=u;){if(f!==r.prev&&f!==r.next&&$o(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&kt(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;m&&m.z<=d;){if(m!==r.prev&&m!==r.next&&$o(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&kt(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function ND(r,e,t){let n=r;do{let i=n.prev,s=n.next.next;!Uu(i,s)&&dx(i,n,n.next,s)&&yc(i,s)&&yc(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),vc(n),vc(n.next),n=r=s),n=n.next}while(n!==r);return gs(n)}function RD(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&HD(o,a)){let l=fx(o,a);o=gs(o,o.next),l=gs(l,l.next),gc(o,e,t,n,i,s),gc(l,e,t,n,i,s);return}a=a.next}o=o.next}while(o!==r)}function BD(r,e,t,n){let i=[],s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*n,l=s<o-1?e[s+1]*n:r.length,c=ux(r,a,l,n,!1),c===c.next&&(c.steiner=!0),i.push(VD(c));for(i.sort(OD),s=0;s<i.length;s++)FD(i[s],t),t=gs(t,t.next);return t}function OD(r,e){return r.x-e.x}function FD(r,e){if(e=UD(r,e),e){let t=fx(e,r);gs(e,e.next),gs(t,t.next)}}function UD(r,e){let t=e,n=r.x,i=r.y,s=-1/0,o;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){let d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>s){if(s=d,d===n){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(n===s)return o;let a=o,l=o.x,c=o.y,h=1/0,u;t=o;do n>=t.x&&t.x>=l&&n!==t.x&&$o(i<c?n:s,i,l,c,i<c?s:n,i,t.x,t.y)&&(u=Math.abs(i-t.y)/(n-t.x),yc(t,r)&&(u<h||u===h&&(t.x>o.x||t.x===o.x&&zD(o,t)))&&(o=t,h=u)),t=t.next;while(t!==a);return o}function zD(r,e){return kt(r.prev,r,e.prev)<0&&kt(e.next,r,r.next)<0}function GD(r,e,t,n){let i=r;do i.z===null&&(i.z=ym(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,kD(i)}function kD(r){let e,t,n,i,s,o,a,l,c=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<c&&(a++,n=n.nextZ,!!n);e++);for(l=c;a>0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(o>1);return r}function ym(r,e,t,n,i){return r=32767*(r-t)*i,e=32767*(e-n)*i,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function VD(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function $o(r,e,t,n,i,s,o,a){return(i-o)*(e-a)-(r-o)*(s-a)>=0&&(r-o)*(n-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(i-o)*(n-a)>=0}function HD(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!WD(r,e)&&(yc(r,e)&&yc(e,r)&&jD(r,e)&&(kt(r.prev,r,e.prev)||kt(r,e.prev,e))||Uu(r,e)&&kt(r.prev,r,r.next)>0&&kt(e.prev,e,e.next)>0)}function kt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Uu(r,e){return r.x===e.x&&r.y===e.y}function dx(r,e,t,n){let i=su(kt(r,e,t)),s=su(kt(r,e,n)),o=su(kt(t,n,r)),a=su(kt(t,n,e));return!!(i!==s&&o!==a||i===0&&iu(r,t,e)||s===0&&iu(r,n,e)||o===0&&iu(t,r,n)||a===0&&iu(t,e,n))}function iu(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function su(r){return r>0?1:r<0?-1:0}function WD(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&dx(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function yc(r,e){return kt(r.prev,r,r.next)<0?kt(r,e,r.next)>=0&&kt(r,r.prev,e)>=0:kt(r,e,r.prev)<0||kt(r,r.next,e)<0}function jD(r,e){let t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function fx(r,e){let t=new vm(r.i,r.x,r.y),n=new vm(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function z0(r,e,t,n){let i=new vm(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function vc(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function vm(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qD(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var hs=class{static area(e){let t=e.length,n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return hs.area(e)<0}static triangulateShape(e,t){let n=[],i=[],s=[];G0(e),k0(n,e);let o=e.length;t.forEach(G0);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,k0(n,t[l]);let a=PD.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function G0(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function k0(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var ua=class extends ca{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ua(e.radius,e.detail)}};var da=class extends Ie{constructor(e=new Gr([new B(0,.5),new B(-.5,-.5),new B(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let n=[],i=[],s=[],o=[],a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(n),this.setAttribute("position",new Se(i,3)),this.setAttribute("normal",new Se(s,3)),this.setAttribute("uv",new Se(o,2));function c(h){let u=i.length/3,d=h.extractPoints(t),f=d.shape,m=d.holes;hs.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,x=m.length;g<x;g++){let v=m[g];hs.isClockWise(v)===!0&&(m[g]=v.reverse())}let p=hs.triangulateShape(f,m);for(let g=0,x=m.length;g<x;g++){let v=m[g];f=f.concat(v)}for(let g=0,x=f.length;g<x;g++){let v=f[g];i.push(v.x,v.y,0),s.push(0,0,1),o.push(v.x,v.y)}for(let g=0,x=p.length;g<x;g++){let v=p[g],w=v[0]+u,b=v[1]+u,S=v[2]+u;n.push(w,b,S),l+=3}}}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return XD(t,e)}static fromJSON(e,t){let n=[];for(let i=0,s=e.shapes.length;i<s;i++){let o=t[e.shapes[i]];n.push(o)}return new da(n,e.curveSegments)}};function XD(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){let i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}var lo=class extends Ie{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),c=0,h=[],u=new A,d=new A,f=[],m=[],p=[],g=[];for(let x=0;x<=n;x++){let v=[],w=x/n,b=0;x==0&&o==0?b=.5/t:x==n&&l==Math.PI&&(b=-.5/t);for(let S=0;S<=t;S++){let M=S/t;u.x=-e*Math.cos(i+M*s)*Math.sin(o+w*a),u.y=e*Math.cos(o+w*a),u.z=e*Math.sin(i+M*s)*Math.sin(o+w*a),m.push(u.x,u.y,u.z),d.copy(u).normalize(),p.push(d.x,d.y,d.z),g.push(M+b,1-w),v.push(c++)}h.push(v)}for(let x=0;x<n;x++)for(let v=0;v<t;v++){let w=h[x][v+1],b=h[x][v],S=h[x+1][v],M=h[x+1][v+1];(x!==0||o>0)&&f.push(w,b,M),(x!==n-1||l<Math.PI)&&f.push(b,S,M)}this.setIndex(f),this.setAttribute("position",new Se(m,3)),this.setAttribute("normal",new Se(p,3)),this.setAttribute("uv",new Se(g,2))}static fromJSON(e){return new lo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var fa=class extends Ie{constructor(e=1,t=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],l=[],c=[],h=[],u=new A,d=new A,f=new A,m=new A,p=new A,g=new A,x=new A;for(let w=0;w<=n;++w){let b=w/n*s*Math.PI*2;v(b,s,o,e,f),v(b+.01,s,o,e,m),g.subVectors(m,f),x.addVectors(m,f),p.crossVectors(g,x),x.crossVectors(p,g),p.normalize(),x.normalize();for(let S=0;S<=i;++S){let M=S/i*Math.PI*2,_=-t*Math.cos(M),y=t*Math.sin(M);u.x=f.x+(_*x.x+y*p.x),u.y=f.y+(_*x.y+y*p.y),u.z=f.z+(_*x.z+y*p.z),l.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),c.push(d.x,d.y,d.z),h.push(w/n),h.push(S/i)}}for(let w=1;w<=n;w++)for(let b=1;b<=i;b++){let S=(i+1)*(w-1)+(b-1),M=(i+1)*w+(b-1),_=(i+1)*w+b,y=(i+1)*(w-1)+b;a.push(S,M,y),a.push(M,_,y)}this.setIndex(a),this.setAttribute("position",new Se(l,3)),this.setAttribute("normal",new Se(c,3)),this.setAttribute("uv",new Se(h,2));function v(w,b,S,M,_){let y=Math.cos(w),T=Math.sin(w),E=S/b*w,C=Math.cos(E);_.x=M*(2+C)*.5*y,_.y=M*(2+C)*T*.5,_.z=M*Math.sin(E)*.5}}static fromJSON(e){return new fa(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};var xm=class extends un{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ae(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},bm=class extends dt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Su=class extends un{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ae(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},wm=class extends Su{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new B(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return sn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ae(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new Ae(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ae(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Sm=class extends un{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ae(16777215),this.specular=new Ae(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ou,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Am=class extends un{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ae(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Mm=class extends un{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},_m=class extends un{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ou,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Tm=class extends un{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ae(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},Em=class extends Jn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}},YD={ShadowMaterial:xm,SpriteMaterial:cm,RawShaderMaterial:bm,ShaderMaterial:dt,PointsMaterial:um,MeshPhysicalMaterial:wm,MeshStandardMaterial:Su,MeshPhongMaterial:Sm,MeshToonMaterial:Am,MeshNormalMaterial:Mm,MeshLambertMaterial:_m,MeshDepthMaterial:xu,MeshDistanceMaterial:bu,MeshBasicMaterial:hi,MeshMatcapMaterial:Tm,LineDashedMaterial:Em,LineBasicMaterial:Jn,Material:un};un.fromType=function(r){return new YD[r]};var cn={arraySlice:function(r,e,t){return cn.isTypedArray(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)},convertArray:function(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)},isTypedArray:function(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)},getKeyframeOrder:function(r){function e(i,s){return r[i]-r[s]}let t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n},sortedArray:function(r,e,t){let n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i},flattenJSON:function(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)},subclip:function(r,e,t,n,i=30){let s=r.clone();s.name=e;let o=[];for(let l=0;l<s.tracks.length;++l){let c=s.tracks[l],h=c.getValueSize(),u=[],d=[];for(let f=0;f<c.times.length;++f){let m=c.times[f]*i;if(!(m<t||m>=n)){u.push(c.times[f]);for(let p=0;p<h;++p)d.push(c.values[f*h+p])}}u.length!==0&&(c.times=cn.convertArray(u,c.times.constructor),c.values=cn.convertArray(d,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(r,e=0,t=r,n=30){n<=0&&(n=30);let i=t.tracks.length,s=e/n;for(let o=0;o<i;++o){let a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;let c=r.tracks.find(function(x){return x.name===a.name&&x.ValueTypeName===l});if(c===void 0)continue;let h=0,u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let d=0,f=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);let m=a.times.length-1,p;if(s<=a.times[0]){let x=h,v=u-h;p=cn.arraySlice(a.values,x,v)}else if(s>=a.times[m]){let x=m*u+h,v=x+u-h;p=cn.arraySlice(a.values,x,v)}else{let x=a.createInterpolant(),v=h,w=u-h;x.evaluate(s),p=cn.arraySlice(x.resultBuffer,v,w)}l==="quaternion"&&new Xt().fromArray(p).normalize().conjugate().toArray(p);let g=c.times.length;for(let x=0;x<g;++x){let v=x*f+d;if(l==="quaternion")Xt.multiplyQuaternionsFlat(c.values,v,p,0,c.values,v);else{let w=f-d*2;for(let b=0;b<w;++b)c.values[v+b]-=p[b]}}}return r.blendMode=w_,r}},pa=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let o;t:{r:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break r;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break e}o=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Cm=class extends pa{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Kv,endingEnd:Kv}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Zv:s=e,a=2*t-n;break;case Jv:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Zv:o=e,l=2*n-t;break;case Jv:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}let c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=o*h}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,m=(n-t)/(i-t),p=m*m,g=p*m,x=-d*g+2*d*p-d*m,v=(1+d)*g+(-1.5-2*d)*p+(-.5+d)*m+1,w=(-1-f)*g+(1.5+f)*p+.5*m,b=f*g-f*p;for(let S=0;S!==a;++S)s[S]=x*o[h+S]+v*o[c+S]+w*o[l+S]+b*o[u+S];return s}},Dm=class extends pa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=(n-t)/(i-t),u=1-h;for(let d=0;d!==a;++d)s[d]=o[c+d]*u+o[l+d]*h;return s}},Pm=class extends pa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},Hr=class{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=cn.convertArray(t,this.TimeBufferType),this.values=cn.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:cn.convertArray(e.times,Array),values:cn.convertArray(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Pm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Dm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Cm(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case hu:t=this.InterpolantFactoryMethodDiscrete;break;case uu:t=this.InterpolantFactoryMethodLinear;break;case dp:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return hu;case this.InterpolantFactoryMethodLinear:return uu;case this.InterpolantFactoryMethodSmooth:return dp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=cn.arraySlice(n,s,o),this.values=cn.arraySlice(this.values,s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&cn.isTypedArray(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=cn.arraySlice(this.times),t=cn.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===dp,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=e[a],h=e[a+1];if(c!==h&&(a!==1||c!==e[0]))if(i)l=!0;else{let u=a*n,d=u-n,f=u+n;for(let m=0;m!==n;++m){let p=t[u+m];if(p!==t[d+m]||p!==t[f+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let u=a*n,d=o*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=cn.arraySlice(e,0,o),this.values=cn.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this}clone(){let e=cn.arraySlice(this.times,0),t=cn.arraySlice(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Hr.prototype.TimeBufferType=Float32Array;Hr.prototype.ValueBufferType=Float32Array;Hr.prototype.DefaultInterpolation=uu;var co=class extends Hr{};co.prototype.ValueTypeName="bool";co.prototype.ValueBufferType=Array;co.prototype.DefaultInterpolation=hu;co.prototype.InterpolantFactoryMethodLinear=void 0;co.prototype.InterpolantFactoryMethodSmooth=void 0;var Im=class extends Hr{};Im.prototype.ValueTypeName="color";var Lm=class extends Hr{};Lm.prototype.ValueTypeName="number";var Nm=class extends pa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t),c=e*a;for(let h=c+a;c!==h;c+=4)Xt.slerpFlat(s,0,o,c-a,o,c,l);return s}},xc=class extends Hr{InterpolantFactoryMethodLinear(e){return new Nm(this.times,this.values,this.getValueSize(),e)}};xc.prototype.ValueTypeName="quaternion";xc.prototype.DefaultInterpolation=uu;xc.prototype.InterpolantFactoryMethodSmooth=void 0;var ho=class extends Hr{};ho.prototype.ValueTypeName="string";ho.prototype.ValueBufferType=Array;ho.prototype.DefaultInterpolation=hu;ho.prototype.InterpolantFactoryMethodLinear=void 0;ho.prototype.InterpolantFactoryMethodSmooth=void 0;var Rm=class extends Hr{};Rm.prototype.ValueTypeName="vector";var V0={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},uo=class{constructor(e,t,n){let i=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){let f=c[u],m=c[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return m}return null}}},QD=new uo,ys=class{constructor(e){this.manager=e!==void 0?e:QD,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},Bi={},vs=class extends ys{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=V0.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Bi[e]!==void 0){Bi[e].push({onLoad:t,onProgress:n,onError:i});return}Bi[e]=[],Bi[e].push({onLoad:t,onProgress:n,onError:i});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let h=Bi[e],u=c.body.getReader(),d=c.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0,p=0,g=new ReadableStream({start(x){v();function v(){u.read().then(({done:w,value:b})=>{if(w)x.close();else{p+=b.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let M=0,_=h.length;M<_;M++){let y=h[M];y.onProgress&&y.onProgress(S)}x.enqueue(b),v()}})}}});return new Response(g)}else throw Error(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a===void 0)return c.text();{let u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{V0.add(e,c);let h=Bi[e];delete Bi[e];for(let u=0,d=h.length;u<d;u++){let f=h[u];f.onLoad&&f.onLoad(c)}}).catch(c=>{let h=Bi[e];if(h===void 0)throw this.manager.itemError(e),c;delete Bi[e];for(let u=0,d=h.length;u<d;u++){let f=h[u];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var ma=class extends ct{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ae(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},fo=class extends ma{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ct.DefaultUp),this.updateMatrix(),this.groundColor=new Ae(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},H0=new Oe,W0=new A,j0=new A,bc=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new B(512,512),this.map=null,this.mapPass=null,this.matrix=new Oe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new fc,this._frameExtents=new B(1,1),this._viewportCount=1,this._viewports=[new qe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;W0.setFromMatrixPosition(e.matrixWorld),t.position.copy(W0),j0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(j0),t.updateMatrixWorld(),H0.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(H0),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Bm=class extends bc{constructor(){super(new Zt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=uc*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Au=class extends ma{constructor(e,t,n=0,i=Math.PI/3,s=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ct.DefaultUp),this.updateMatrix(),this.target=new ct,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.shadow=new Bm}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},q0=new Oe,nc=new A,Hp=new A,Om=class extends bc{constructor(){super(new Zt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new B(4,2),this._viewportCount=6,this._viewports=[new qe(2,1,1,1),new qe(0,1,1,1),new qe(3,1,1,1),new qe(1,1,1,1),new qe(3,0,1,1),new qe(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),nc.setFromMatrixPosition(e.matrixWorld),n.position.copy(nc),Hp.copy(n.position),Hp.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Hp),n.updateMatrixWorld(),i.makeTranslation(-nc.x,-nc.y,-nc.z),q0.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(q0)}},Mu=class extends ma{constructor(e,t,n=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Om}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Fm=class extends bc{constructor(){super(new ia(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},_u=class extends ma{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ct.DefaultUp),this.updateMatrix(),this.target=new ct,this.shadow=new Fm}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var Um=class extends Ie{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){let e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},ga=class extends ys{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new vs(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){let t={},n={};function i(f,m){if(t[m]!==void 0)return t[m];let g=f.interleavedBuffers[m],x=s(f,g.buffer),v=Bh(g.type,x),w=new wu(v,g.stride);return w.uuid=g.uuid,t[m]=w,w}function s(f,m){if(n[m]!==void 0)return n[m];let g=f.arrayBuffers[m],x=new Uint32Array(g).buffer;return n[m]=x,x}let o=e.isInstancedBufferGeometry?new Um:new Ie,a=e.data.index;if(a!==void 0){let f=Bh(a.type,a.array);o.setIndex(new Xe(f,1))}let l=e.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=i(e.data,m.data);p=new io(g,m.itemSize,m.offset,m.normalized)}else{let g=Bh(m.type,m.array),x=m.isInstancedBufferAttribute?hm:Xe;p=new x(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(f,p)}let c=e.data.morphAttributes;if(c)for(let f in c){let m=c[f],p=[];for(let g=0,x=m.length;g<x;g++){let v=m[g],w;if(v.isInterleavedBufferAttribute){let b=i(e.data,v.data);w=new io(b,v.itemSize,v.offset,v.normalized)}else{let b=Bh(v.type,v.array);w=new Xe(b,v.itemSize,v.normalized)}v.name!==void 0&&(w.name=v.name),p.push(w)}o.morphAttributes[f]=p}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let f=0,m=u.length;f!==m;++f){let p=u[f];o.addGroup(p.start,p.count,p.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let f=new A;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new Rn(f,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}};var Tu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=X0(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=X0();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function X0(){return(typeof performance>"u"?Date:performance).now()}var qm="\\[\\]\\.:\\/",KD=new RegExp("["+qm+"]","g"),Xm="[^"+qm+"]",ZD="[^"+qm.replace("\\.","")+"]",JD=/((?:WC+[\/:])*)/.source.replace("WC",Xm),$D=/(WCOD+)?/.source.replace("WCOD",ZD),eP=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Xm),tP=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Xm),nP=new RegExp("^"+JD+$D+eP+tP+"$"),rP=["material","materials","bones"],zm=class{constructor(e,t,n){let i=n||At.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},At=class{constructor(e,t,n){this.path=t,this.parsedPath=n||At.parseTrackName(t),this.node=At.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new At.Composite(e,t,n):new At(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(KD,"")}static parseTrackName(e){let t=nP.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);rP.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=At.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[i];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};At.Composite=zm;At.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};At.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};At.prototype.GetterByBindingType=[At.prototype._getValue_direct,At.prototype._getValue_array,At.prototype._getValue_arrayElement,At.prototype._getValue_toArray];At.prototype.SetterByBindingTypeAndVersioning=[[At.prototype._setValue_direct,At.prototype._setValue_direct_setNeedsUpdate,At.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[At.prototype._setValue_array,At.prototype._setValue_array_setNeedsUpdate,At.prototype._setValue_array_setMatrixWorldNeedsUpdate],[At.prototype._setValue_arrayElement,At.prototype._setValue_arrayElement_setNeedsUpdate,At.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[At.prototype._setValue_fromArray,At.prototype._setValue_fromArray_setNeedsUpdate,At.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var we=class{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new we(this.value.clone===void 0?this.value:this.value.clone())}};var Eu=class{constructor(e,t,n=0,i=1/0){this.ray=new ro(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new dc,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return Gm(e,this,n,t),n.sort(Y0),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Gm(e[i],this,n,t);return n.sort(Y0),n}};function Y0(r,e){return r.distance-e.distance}function Gm(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)Gm(i[s],e,t,!0)}}var wc=class{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(sn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var Q0=new A,ou=new A,Cu=class{constructor(e=new A,t=new A){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Q0.subVectors(e,this.start),ou.subVectors(this.end,this.start);let n=ou.dot(ou),s=ou.dot(Q0)/n;return t&&(s=sn(s,0,1)),s}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},K0=new A,Du=class extends ct{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;let n=new Ie,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let c=o/l*Math.PI*2,h=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}n.setAttribute("position",new Se(i,3));let s=new Jn({fog:!1,toneMapped:!1});this.cone=new ms(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),K0.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(K0),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Pu=class extends Vt{constructor(e,t,n){let i=new lo(t,4,2),s=new hi({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var Z0=new A,au=new A,J0=new A,Iu=class extends ct{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,t===void 0&&(t=1);let i=new Ie;i.setAttribute("position",new Se([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Jn({fog:!1,toneMapped:!1});this.lightPlane=new so(i,s),this.add(this.lightPlane),i=new Ie,i.setAttribute("position",new Se([0,0,0,0,0,1],3)),this.targetLine=new so(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){Z0.setFromMatrixPosition(this.light.matrixWorld),au.setFromMatrixPosition(this.light.target.matrixWorld),J0.subVectors(au,Z0),this.lightPlane.lookAt(au),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(au),this.targetLine.scale.z=J0.length()}},lu=new A,jt=new kr,Ar=class extends ms{constructor(e){let t=new Ie,n=new Jn({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={},a=new Ae(16755200),l=new Ae(16711680),c=new Ae(43775),h=new Ae(16777215),u=new Ae(3355443);d("n1","n2",a),d("n2","n4",a),d("n4","n3",a),d("n3","n1",a),d("f1","f2",a),d("f2","f4",a),d("f4","f3",a),d("f3","f1",a),d("n1","f1",a),d("n2","f2",a),d("n3","f3",a),d("n4","f4",a),d("p","n1",l),d("p","n2",l),d("p","n3",l),d("p","n4",l),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c),d("c","t",h),d("p","c",u),d("cn1","cn2",u),d("cn3","cn4",u),d("cf1","cf2",u),d("cf3","cf4",u);function d(m,p,g){f(m,g),f(p,g)}function f(m,p){i.push(0,0,0),s.push(p.r,p.g,p.b),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}t.setAttribute("position",new Se(i,3)),t.setAttribute("color",new Se(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){let e=this.geometry,t=this.pointMap,n=1,i=1;jt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Kt("c",t,e,jt,0,0,-1),Kt("t",t,e,jt,0,0,1),Kt("n1",t,e,jt,-n,-i,-1),Kt("n2",t,e,jt,n,-i,-1),Kt("n3",t,e,jt,-n,i,-1),Kt("n4",t,e,jt,n,i,-1),Kt("f1",t,e,jt,-n,-i,1),Kt("f2",t,e,jt,n,-i,1),Kt("f3",t,e,jt,-n,i,1),Kt("f4",t,e,jt,n,i,1),Kt("u1",t,e,jt,n*.7,i*1.1,-1),Kt("u2",t,e,jt,-n*.7,i*1.1,-1),Kt("u3",t,e,jt,0,i*2,-1),Kt("cf1",t,e,jt,-n,0,1),Kt("cf2",t,e,jt,n,0,1),Kt("cf3",t,e,jt,0,-i,1),Kt("cf4",t,e,jt,0,i,1),Kt("cn1",t,e,jt,-n,0,-1),Kt("cn2",t,e,jt,n,0,-1),Kt("cn3",t,e,jt,0,-i,-1),Kt("cn4",t,e,jt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Kt(r,e,t,n,i,s,o){lu.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],lu.x,lu.y,lu.z)}}var po=class extends ms{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Ie;s.setIndex(new Xe(n,1)),s.setAttribute("position",new Se(i,3)),super(s,new Jn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}};var Lu=class extends ms{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Ie;i.setAttribute("position",new Se(t,3)),i.setAttribute("color",new Se(n,3));let s=new Jn({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){let i=new Ae,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Nu=class{constructor(){this.type="ShapePath",this.color=new Ae,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new mc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,o){return this.currentPath.bezierCurveTo(e,t,n,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function n(v){let w=[];for(let b=0,S=v.length;b<S;b++){let M=v[b],_=new Gr;_.curves=M.curves,w.push(_)}return w}function i(v,w){let b=w.length,S=!1;for(let M=b-1,_=0;_<b;M=_++){let y=w[M],T=w[_],E=T.x-y.x,C=T.y-y.y;if(Math.abs(C)>Number.EPSILON){if(C<0&&(y=w[_],E=-E,T=w[M],C=-C),v.y<y.y||v.y>T.y)continue;if(v.y===y.y){if(v.x===y.x)return!0}else{let L=C*(v.x-y.x)-E*(v.y-y.y);if(L===0)return!0;if(L<0)continue;S=!S}}else{if(v.y!==y.y)continue;if(T.x<=v.x&&v.x<=y.x||y.x<=v.x&&v.x<=T.x)return!0}}return S}let s=hs.isClockWise,o=this.subPaths;if(o.length===0)return[];if(t===!0)return n(o);let a,l,c,h=[];if(o.length===1)return l=o[0],c=new Gr,c.curves=l.curves,h.push(c),h;let u=!s(o[0].getPoints());u=e?!u:u;let d=[],f=[],m=[],p=0,g;f[p]=void 0,m[p]=[];for(let v=0,w=o.length;v<w;v++)l=o[v],g=l.getPoints(),a=s(g),a=e?!a:a,a?(!u&&f[p]&&p++,f[p]={s:new Gr,p:g},f[p].s.curves=l.curves,u&&p++,m[p]=[]):m[p].push({h:l,p:g[0]});if(!f[0])return n(o);if(f.length>1){let v=!1,w=0;for(let b=0,S=f.length;b<S;b++)d[b]=[];for(let b=0,S=f.length;b<S;b++){let M=m[b];for(let _=0;_<M.length;_++){let y=M[_],T=!0;for(let E=0;E<f.length;E++)i(y.p,f[E].p)&&(b!==E&&w++,T?(T=!1,d[E].push(y)):v=!0);T&&d[b].push(y)}}w>0&&v===!1&&(m=d)}let x;for(let v=0,w=f.length;v<w;v++){c=f[v].s,h.push(c),x=m[v];for(let b=0,S=x.length;b<S;b++)c.holes.push(x[b].h)}return h}};var px=new ArrayBuffer(4),fz=new Float32Array(px),pz=new Uint32Array(px),oi=new Uint32Array(512),ai=new Uint32Array(512);for(let r=0;r<256;++r){let e=r-127;e<-27?(oi[r]=0,oi[r|256]=32768,ai[r]=24,ai[r|256]=24):e<-14?(oi[r]=1024>>-e-14,oi[r|256]=1024>>-e-14|32768,ai[r]=-e-1,ai[r|256]=-e-1):e<=15?(oi[r]=e+15<<10,oi[r|256]=e+15<<10|32768,ai[r]=13,ai[r|256]=13):e<128?(oi[r]=31744,oi[r|256]=64512,ai[r]=24,ai[r|256]=24):(oi[r]=31744,oi[r|256]=64512,ai[r]=13,ai[r|256]=13)}var mx=new Uint32Array(2048),Sc=new Uint32Array(64),iP=new Uint32Array(64);for(let r=1;r<1024;++r){let e=r<<13,t=0;for(;(e&8388608)===0;)e<<=1,t-=8388608;e&=-8388609,t+=947912704,mx[r]=e|t}for(let r=1024;r<2048;++r)mx[r]=939524096+(r-1024<<13);for(let r=1;r<31;++r)Sc[r]=r<<23;Sc[31]=1199570944;Sc[32]=2147483648;for(let r=33;r<63;++r)Sc[r]=2147483648+(r-32<<23);Sc[63]=3347054592;for(let r=1;r<64;++r)r!==32&&(iP[r]=1024);var Ru=class extends lt{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:mo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=mo);var ba=".",Ac=Symbol("target"),Ym=Symbol("unsubscribe");function Mc(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function gx(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var hr=Array.isArray;function go(r){return typeof r=="symbol"}var sP={after:(r,e)=>hr(r)?r.slice(e.length):e===""?r:r.slice(e.length+1),concat:(r,e)=>hr(r)?(r=[...r],e&&r.push(e),r):e&&e.toString!==void 0?(r!==""&&(r+=ba),go(e)?r+e.toString():r+e):r,initial:r=>{if(hr(r))return r.slice(0,-1);if(r==="")return r;let e=r.lastIndexOf(ba);return e===-1?"":r.slice(0,e)},last:r=>{if(hr(r))return r[r.length-1]||"";if(r==="")return r;let e=r.lastIndexOf(ba);return e===-1?r:r.slice(e+1)},walk:(r,e)=>{if(hr(r))for(let t of r)e(t);else if(r!==""){let t=0,n=r.indexOf(ba);if(n===-1)e(r);else for(;t<r.length;)n===-1&&(n=r.length),e(r.slice(t,n)),t=n+1,n=r.indexOf(ba,t)}},get(r,e){return this.walk(e,t=>{r&&(r=r[t])}),r}},jn=sP;function Qm(r){return typeof r=="object"&&typeof r.next=="function"}function Km(r,e,t,n,i){let s=r.next;if(e.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],e,o.value[0],n),o.value[1]=i(o.value[1],e,o.value[0],n)),o};else if(e.name==="values"){let o=t[Ac].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,e,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,e,o.value,n)),o};return r}function zu(r,e,t){return r.isUnsubscribed||e.ignoreSymbols&&go(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var _c=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),n=t.get(e);return n===void 0&&(n={},t.set(e,n)),n}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let n=this._getProperties(e),i=n[t];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(e,t),n[t]=i),i}getProxy(e,t,n,i){if(this.isUnsubscribed)return e;let s=e[i],o=s||e;this._pathCache.set(o,t);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(e,n):e,this._proxyCache.set(o,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,jn.get(t,this.getPath(e)))}defineProperty(e,t,n){return Reflect.defineProperty(e,t,n)?(this.isUnsubscribed||(this._getProperties(e)[t]=n),!0):!1}setProperty(e,t,n,i,s){if(!this._equals(s,n)||!(t in e)){let o=this._getOwnPropertyDescriptor(e,t);return o!==void 0&&"set"in o?Reflect.set(e,t,n,i):Reflect.set(e,t,n)}return!0}deleteProperty(e,t,n){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(e);i&&(delete i[t],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(e,t,n){let i=this._getOwnPropertyDescriptor(t,n);return e!==void 0&&i!==void 0&&Object.is(e.value,i.value)&&(e.writable||!1)===(i.writable||!1)&&(e.enumerable||!1)===(i.enumerable||!1)&&(e.configurable||!1)===(i.configurable||!1)&&e.get===i.get&&e.set===i.set}isGetInvariant(e,t){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function wa(r){return toString.call(r)==="[object Object]"}function Sa(){return!0}function bs(r,e){return r.length!==e.length||r.some((t,n)=>e[n]!==t)}var Gu=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var oP=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Zm={push:Sa,pop:Sa,shift:Sa,unshift:Sa,copyWithin:bs,reverse:bs,sort:bs,splice:bs,flat:bs,fill:bs},yx=new Set([...Gu,...oP,...Object.keys(Zm)]);function Aa(r,e){if(r.size!==e.size)return!0;for(let t of r)if(!e.has(t))return!0;return!1}var Jm=["keys","values","entries"],$m=new Set(["has","toString"]),eg={add:Aa,clear:Aa,delete:Aa,forEach:Aa},vx=new Set([...$m,...Object.keys(eg),...Jm]);function Ma(r,e){if(r.size!==e.size)return!0;let t;for(let[n,i]of r)if(t=e.get(n),t!==i||t===void 0&&!e.has(n))return!0;return!1}var aP=new Set([...$m,"get"]),tg={set:Ma,clear:Ma,delete:Ma,forEach:Ma},xx=new Set([...aP,...Object.keys(tg),...Jm]);var Mn=class{constructor(e,t,n,i){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return Gu.has(e)}_shallowClone(e){let t=e;if(wa(e))t={...e};else if(hr(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(n=>this._shallowClone(n)));else if(e instanceof Map){t=new Map;for(let[n,i]of e.entries())t.set(n,this._shallowClone(i))}return this._clonedCache.add(t),t}preferredThisArg(e,t,n,i){return e?(hr(i)?this._onIsChanged=Zm[t]:i instanceof Set?this._onIsChanged=eg[t]:i instanceof Map&&(this._onIsChanged=tg[t]),i):n}update(e,t,n){let i=jn.after(e,this._path);if(t!=="length"){let s=this.clone;jn.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:t,previous:n}),s&&s[t]&&(s[t]=n)}this._isChanged=!0}undo(e){let t;for(let n=this._changes.length-1;n!==-1;n--)t=this._changes[n],jn.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var _a=class extends Mn{static isHandledMethod(e){return yx.has(e)}};var Tc=class extends Mn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var Ta=class extends Mn{static isHandledMethod(e){return vx.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}};var Ea=class extends Mn{static isHandledMethod(e){return xx.has(e)}undo(e){for(let[t,n]of this.clone.entries())e.set(t,n);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};var Ec=class extends Mn{constructor(e,t,n,i){super(void 0,t,n,i),this._arg1=n[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}};var Cc=class extends Mn{constructor(e,t,n,i){super(void 0,t,n,i),this._weakKey=n[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}};var jr=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return wa(e)||hr(e)||Mc(e)}static isHandledMethod(e,t){return wa(e)?Mn.isHandledMethod(t):hr(e)?_a.isHandledMethod(t):e instanceof Set?Ta.isHandledMethod(t):e instanceof Map?Ea.isHandledMethod(t):Mc(e)}get isCloning(){return this._stack.length>0}start(e,t,n){let i=Mn;hr(e)?i=_a:e instanceof Date?i=Tc:e instanceof Set?i=Ta:e instanceof Map?i=Ea:e instanceof WeakSet?i=Ec:e instanceof WeakMap&&(i=Cc),this._stack.push(new i(e,t,n,this._hasOnValidate))}update(e,t,n){this._stack[this._stack.length-1].update(e,t,n)}preferredThisArg(e,t,n){let{name:i}=e,s=jr.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,t,n)}isChanged(e,t,n){return this._stack[this._stack.length-1].isChanged(e,t,n)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var lP={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},ng=(r,e,t={})=>{t={...lP,...t};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=t,l=new _c(i),c=typeof t.onValidate=="function",h=new jr(c),u=(v,w,b,S,M)=>!c||h.isCloning||t.onValidate(jn.concat(l.getPath(v),w),b,S,M)===!0,d=(v,w,b,S)=>{!zu(l,t,w)&&!(o&&l.isDetached(v,r))&&f(l.getPath(v),w,b,S)},f=(v,w,b,S,M)=>{h.isCloning?h.update(v,w,S):e(jn.concat(v,w),b,S,M)},m=v=>v&&(v[n]||v),p=(v,w,b,S)=>gx(v)||b==="constructor"||s&&!jr.isHandledMethod(w,b)||zu(l,t,b)||l.isGetInvariant(w,b)||o&&l.isDetached(w,r)?v:(S===void 0&&(S=l.getPath(w)),l.getProxy(v,jn.concat(S,b),g,n)),g={get(v,w,b){if(go(w)){if(w===n||w===Ac)return v;if(w===Ym&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Mc(v)?Reflect.get(v,w):Reflect.get(v,w,b);return p(S,v,w)},set(v,w,b,S){b=m(b);let M=v[n]||v,_=M[w];if(i(_,b)&&w in v)return!0;let y=u(v,w,b,_);return y&&l.setProperty(M,w,b,S,_)?(d(v,w,v[w],_),!0):!y},defineProperty(v,w,b){if(!l.isSameDescriptor(b,v,w)){let S=v[w];u(v,w,b.value,S)&&l.defineProperty(v,w,b,S)&&d(v,w,b.value,S)}return!0},deleteProperty(v,w){if(!Reflect.has(v,w))return!0;let b=Reflect.get(v,w),S=u(v,w,void 0,b);return S&&l.deleteProperty(v,w,b)?(d(v,w,void 0,b),!0):!S},apply(v,w,b){let S=w[n]||w;if(l.isUnsubscribed)return Reflect.apply(v,S,b);if((a===!1||a!==!0&&!a.includes(v.name))&&jr.isHandledType(S)){let M=jn.initial(l.getPath(v)),_=jr.isHandledMethod(S,v.name);h.start(S,M,b);let y=Reflect.apply(v,h.preferredThisArg(v,w,S),_?b.map(C=>m(C)):b),T=h.isChanged(S,i),E=h.stop();if(jr.isHandledType(y)&&_&&(w instanceof Map&&v.name==="get"&&(M=jn.concat(M,b[0])),y=l.getProxy(y,M,g)),T){let C={name:v.name,args:b,result:y},L=h.isCloning?jn.initial(M):M,R=h.isCloning?jn.last(M):"";u(jn.get(r,L),R,S,E,C)?f(L,R,S,E,C):h.undo(S)}return(w instanceof Map||w instanceof Set)&&Qm(y)?Km(y,v,w,M,p):y}return Reflect.apply(v,w,b)}},x=l.getProxy(r,t.pathAsArray?[]:"",g);return e=e.bind(x),c&&(t.onValidate=t.onValidate.bind(x)),x};ng.target=r=>r&&r[Ac]||r;ng.unsubscribe=r=>r[Ym]||r;var rg=ng;var cP=typeof global=="object"&&global&&global.Object===Object&&global,ku=cP;var hP=typeof self=="object"&&self&&self.Object===Object&&self,uP=ku||hP||Function("return this")(),Yt=uP;var dP=Yt.Symbol,qn=dP;var bx=Object.prototype,fP=bx.hasOwnProperty,pP=bx.toString,Dc=qn?qn.toStringTag:void 0;function mP(r){var e=fP.call(r,Dc),t=r[Dc];try{r[Dc]=void 0;var n=!0}catch{}var i=pP.call(r);return n&&(e?r[Dc]=t:delete r[Dc]),i}var wx=mP;var gP=Object.prototype,yP=gP.toString;function vP(r){return yP.call(r)}var Sx=vP;var xP="[object Null]",bP="[object Undefined]",Ax=qn?qn.toStringTag:void 0;function wP(r){return r==null?r===void 0?bP:xP:Ax&&Ax in Object(r)?wx(r):Sx(r)}var ur=wP;function SP(r){return r!=null&&typeof r=="object"}var Bn=SP;var AP="[object Symbol]";function MP(r){return typeof r=="symbol"||Bn(r)&&ur(r)==AP}var ws=MP;function _P(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var Vu=_P;var TP=Array.isArray,Dn=TP;var EP=1/0,Mx=qn?qn.prototype:void 0,_x=Mx?Mx.toString:void 0;function Tx(r){if(typeof r=="string")return r;if(Dn(r))return Vu(r,Tx)+"";if(ws(r))return _x?_x.call(r):"";var e=r+"";return e=="0"&&1/r==-EP?"-0":e}var Ex=Tx;var CP=/\s/;function DP(r){for(var e=r.length;e--&&CP.test(r.charAt(e)););return e}var Cx=DP;var PP=/^\s+/;function IP(r){return r&&r.slice(0,Cx(r)+1).replace(PP,"")}var Dx=IP;function LP(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var Jt=LP;var Px=0/0,NP=/^[-+]0x[0-9a-f]+$/i,RP=/^0b[01]+$/i,BP=/^0o[0-7]+$/i,OP=parseInt;function FP(r){if(typeof r=="number")return r;if(ws(r))return Px;if(Jt(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Jt(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=Dx(r);var t=RP.test(r);return t||BP.test(r)?OP(r.slice(2),t?2:8):NP.test(r)?Px:+r}var ig=FP;function UP(r){return r}var Hu=UP;var zP="[object AsyncFunction]",GP="[object Function]",kP="[object GeneratorFunction]",VP="[object Proxy]";function HP(r){if(!Jt(r))return!1;var e=ur(r);return e==GP||e==kP||e==zP||e==VP}var Ca=HP;var WP=Yt["__core-js_shared__"],Wu=WP;var Ix=function(){var r=/[^.]+$/.exec(Wu&&Wu.keys&&Wu.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function jP(r){return!!Ix&&Ix in r}var Lx=jP;var qP=Function.prototype,XP=qP.toString;function YP(r){if(r!=null){try{return XP.call(r)}catch{}try{return r+""}catch{}}return""}var ki=YP;var QP=/[\\^$.*+?()[\]{}|]/g,KP=/^\[object .+?Constructor\]$/,ZP=Function.prototype,JP=Object.prototype,$P=ZP.toString,eI=JP.hasOwnProperty,tI=RegExp("^"+$P.call(eI).replace(QP,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function nI(r){if(!Jt(r)||Lx(r))return!1;var e=Ca(r)?tI:KP;return e.test(ki(r))}var Nx=nI;function rI(r,e){return r?.[e]}var Rx=rI;function iI(r,e){var t=Rx(r,e);return Nx(t)?t:void 0}var tr=iI;var sI=tr(Yt,"WeakMap"),ju=sI;var Bx=Object.create,oI=function(){function r(){}return function(e){if(!Jt(e))return{};if(Bx)return Bx(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),Ox=oI;function aI(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var Fx=aI;function lI(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var qu=lI;var cI=800,hI=16,uI=Date.now;function dI(r){var e=0,t=0;return function(){var n=uI(),i=hI-(n-t);if(t=n,i>0){if(++e>=cI)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var Ux=dI;function fI(r){return function(){return r}}var zx=fI;var pI=function(){try{var r=tr(Object,"defineProperty");return r({},"",{}),r}catch{}}(),Da=pI;var mI=Da?function(r,e){return Da(r,"toString",{configurable:!0,enumerable:!1,value:zx(e),writable:!0})}:Hu,Gx=mI;var gI=Ux(Gx),Xu=gI;function yI(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var kx=yI;var vI=9007199254740991,xI=/^(?:0|[1-9]\d*)$/;function bI(r,e){var t=typeof r;return e=e??vI,!!e&&(t=="number"||t!="symbol"&&xI.test(r))&&r>-1&&r%1==0&&r<e}var Yu=bI;function wI(r,e,t){e=="__proto__"&&Da?Da(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var Pa=wI;function SI(r,e){return r===e||r!==r&&e!==e}var Ss=SI;var AI=Object.prototype,MI=AI.hasOwnProperty;function _I(r,e,t){var n=r[e];(!(MI.call(r,e)&&Ss(n,t))||t===void 0&&!(e in r))&&Pa(r,e,t)}var Qu=_I;function TI(r,e,t,n){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],l=n?n(t[a],r[a],a,t,r):void 0;l===void 0&&(l=r[a]),i?Pa(t,a,l):Qu(t,a,l)}return t}var Mr=TI;var Vx=Math.max;function EI(r,e,t){return e=Vx(e===void 0?r.length-1:e,0),function(){for(var n=arguments,i=-1,s=Vx(n.length-e,0),o=Array(s);++i<s;)o[i]=n[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=n[i];return a[e]=t(o),Fx(r,this,a)}}var Ku=EI;function CI(r,e){return Xu(Ku(r,e,Hu),r+"")}var Hx=CI;var DI=9007199254740991;function PI(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=DI}var Zu=PI;function II(r){return r!=null&&Zu(r.length)&&!Ca(r)}var As=II;function LI(r,e,t){if(!Jt(t))return!1;var n=typeof e;return(n=="number"?As(t)&&Yu(e,t.length):n=="string"&&e in t)?Ss(t[e],r):!1}var Wx=LI;function NI(r){return Hx(function(e,t){var n=-1,i=t.length,s=i>1?t[i-1]:void 0,o=i>2?t[2]:void 0;for(s=r.length>3&&typeof s=="function"?(i--,s):void 0,o&&Wx(t[0],t[1],o)&&(s=i<3?void 0:s,i=1),e=Object(e);++n<i;){var a=t[n];a&&r(e,a,n,s)}return e})}var jx=NI;var RI=Object.prototype;function BI(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||RI;return r===t}var Ia=BI;function OI(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var qx=OI;var FI="[object Arguments]";function UI(r){return Bn(r)&&ur(r)==FI}var sg=UI;var Xx=Object.prototype,zI=Xx.hasOwnProperty,GI=Xx.propertyIsEnumerable,kI=sg(function(){return arguments}())?sg:function(r){return Bn(r)&&zI.call(r,"callee")&&!GI.call(r,"callee")},yo=kI;function VI(){return!1}var Yx=VI;var Zx=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Qx=Zx&&typeof module=="object"&&module&&!module.nodeType&&module,HI=Qx&&Qx.exports===Zx,Kx=HI?Yt.Buffer:void 0,WI=Kx?Kx.isBuffer:void 0,jI=WI||Yx,La=jI;var qI="[object Arguments]",XI="[object Array]",YI="[object Boolean]",QI="[object Date]",KI="[object Error]",ZI="[object Function]",JI="[object Map]",$I="[object Number]",eL="[object Object]",tL="[object RegExp]",nL="[object Set]",rL="[object String]",iL="[object WeakMap]",sL="[object ArrayBuffer]",oL="[object DataView]",aL="[object Float32Array]",lL="[object Float64Array]",cL="[object Int8Array]",hL="[object Int16Array]",uL="[object Int32Array]",dL="[object Uint8Array]",fL="[object Uint8ClampedArray]",pL="[object Uint16Array]",mL="[object Uint32Array]",Lt={};Lt[aL]=Lt[lL]=Lt[cL]=Lt[hL]=Lt[uL]=Lt[dL]=Lt[fL]=Lt[pL]=Lt[mL]=!0;Lt[qI]=Lt[XI]=Lt[sL]=Lt[YI]=Lt[oL]=Lt[QI]=Lt[KI]=Lt[ZI]=Lt[JI]=Lt[$I]=Lt[eL]=Lt[tL]=Lt[nL]=Lt[rL]=Lt[iL]=!1;function gL(r){return Bn(r)&&Zu(r.length)&&!!Lt[ur(r)]}var Jx=gL;function yL(r){return function(e){return r(e)}}var Na=yL;var $x=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pc=$x&&typeof module=="object"&&module&&!module.nodeType&&module,vL=Pc&&Pc.exports===$x,og=vL&&ku.process,xL=function(){try{var r=Pc&&Pc.require&&Pc.require("util").types;return r||og&&og.binding&&og.binding("util")}catch{}}(),Vi=xL;var eb=Vi&&Vi.isTypedArray,bL=eb?Na(eb):Jx,Ju=bL;var wL=Object.prototype,SL=wL.hasOwnProperty;function AL(r,e){var t=Dn(r),n=!t&&yo(r),i=!t&&!n&&La(r),s=!t&&!n&&!i&&Ju(r),o=t||n||i||s,a=o?qx(r.length,String):[],l=a.length;for(var c in r)(e||SL.call(r,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Yu(c,l)))&&a.push(c);return a}var $u=AL;function ML(r,e){return function(t){return r(e(t))}}var ed=ML;var _L=ed(Object.keys,Object),tb=_L;var TL=Object.prototype,EL=TL.hasOwnProperty;function CL(r){if(!Ia(r))return tb(r);var e=[];for(var t in Object(r))EL.call(r,t)&&t!="constructor"&&e.push(t);return e}var nb=CL;function DL(r){return As(r)?$u(r):nb(r)}var Ra=DL;function PL(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var rb=PL;var IL=Object.prototype,LL=IL.hasOwnProperty;function NL(r){if(!Jt(r))return rb(r);var e=Ia(r),t=[];for(var n in r)n=="constructor"&&(e||!LL.call(r,n))||t.push(n);return t}var ib=NL;function RL(r){return As(r)?$u(r,!0):ib(r)}var ui=RL;var BL=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,OL=/^\w*$/;function FL(r,e){if(Dn(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||ws(r)?!0:OL.test(r)||!BL.test(r)||e!=null&&r in Object(e)}var sb=FL;var UL=tr(Object,"create"),Hi=UL;function zL(){this.__data__=Hi?Hi(null):{},this.size=0}var ob=zL;function GL(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var ab=GL;var kL="__lodash_hash_undefined__",VL=Object.prototype,HL=VL.hasOwnProperty;function WL(r){var e=this.__data__;if(Hi){var t=e[r];return t===kL?void 0:t}return HL.call(e,r)?e[r]:void 0}var lb=WL;var jL=Object.prototype,qL=jL.hasOwnProperty;function XL(r){var e=this.__data__;return Hi?e[r]!==void 0:qL.call(e,r)}var cb=XL;var YL="__lodash_hash_undefined__";function QL(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Hi&&e===void 0?YL:e,this}var hb=QL;function Ba(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Ba.prototype.clear=ob;Ba.prototype.delete=ab;Ba.prototype.get=lb;Ba.prototype.has=cb;Ba.prototype.set=hb;var ag=Ba;function KL(){this.__data__=[],this.size=0}var ub=KL;function ZL(r,e){for(var t=r.length;t--;)if(Ss(r[t][0],e))return t;return-1}var Ms=ZL;var JL=Array.prototype,$L=JL.splice;function e3(r){var e=this.__data__,t=Ms(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():$L.call(e,t,1),--this.size,!0}var db=e3;function t3(r){var e=this.__data__,t=Ms(e,r);return t<0?void 0:e[t][1]}var fb=t3;function n3(r){return Ms(this.__data__,r)>-1}var pb=n3;function r3(r,e){var t=this.__data__,n=Ms(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var mb=r3;function Oa(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Oa.prototype.clear=ub;Oa.prototype.delete=db;Oa.prototype.get=fb;Oa.prototype.has=pb;Oa.prototype.set=mb;var _s=Oa;var i3=tr(Yt,"Map"),Ts=i3;function s3(){this.size=0,this.__data__={hash:new ag,map:new(Ts||_s),string:new ag}}var gb=s3;function o3(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var yb=o3;function a3(r,e){var t=r.__data__;return yb(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Es=a3;function l3(r){var e=Es(this,r).delete(r);return this.size-=e?1:0,e}var vb=l3;function c3(r){return Es(this,r).get(r)}var xb=c3;function h3(r){return Es(this,r).has(r)}var bb=h3;function u3(r,e){var t=Es(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var wb=u3;function Fa(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Fa.prototype.clear=gb;Fa.prototype.delete=vb;Fa.prototype.get=xb;Fa.prototype.has=bb;Fa.prototype.set=wb;var Ic=Fa;var d3="Expected a function";function lg(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(d3);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=t.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return t.cache=s.set(i,o)||s,o};return t.cache=new(lg.Cache||Ic),t}lg.Cache=Ic;var Sb=lg;var f3=500;function p3(r){var e=Sb(r,function(n){return t.size===f3&&t.clear(),n}),t=e.cache;return e}var Ab=p3;var m3=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,g3=/\\(\\)?/g,y3=Ab(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(m3,function(t,n,i,s){e.push(i?s.replace(g3,"$1"):n||t)}),e}),Mb=y3;function v3(r){return r==null?"":Ex(r)}var _b=v3;function x3(r,e){return Dn(r)?r:sb(r,e)?[r]:Mb(_b(r))}var Ua=x3;var b3=1/0;function w3(r){if(typeof r=="string"||ws(r))return r;var e=r+"";return e=="0"&&1/r==-b3?"-0":e}var td=w3;function S3(r,e){e=Ua(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[td(e[t++])];return t&&t==n?r:void 0}var Tb=S3;function A3(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var za=A3;var Eb=qn?qn.isConcatSpreadable:void 0;function M3(r){return Dn(r)||yo(r)||!!(Eb&&r&&r[Eb])}var Cb=M3;function Db(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=Cb),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?Db(a,e-1,t,n,i):za(i,a):n||(i[i.length]=a)}return i}var Pb=Db;function _3(r){var e=r==null?0:r.length;return e?Pb(r,1):[]}var Ib=_3;function T3(r){return Xu(Ku(r,void 0,Ib),r+"")}var Lb=T3;var E3=ed(Object.getPrototypeOf,Object),Ga=E3;var C3="[object Object]",D3=Function.prototype,P3=Object.prototype,Nb=D3.toString,I3=P3.hasOwnProperty,L3=Nb.call(Object);function N3(r){if(!Bn(r)||ur(r)!=C3)return!1;var e=Ga(r);if(e===null)return!0;var t=I3.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Nb.call(t)==L3}var nd=N3;function R3(r,e,t){var n=-1,i=r.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+e];return s}var Rb=R3;function B3(){this.__data__=new _s,this.size=0}var Bb=B3;function O3(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var Ob=O3;function F3(r){return this.__data__.get(r)}var Fb=F3;function U3(r){return this.__data__.has(r)}var Ub=U3;var z3=200;function G3(r,e){var t=this.__data__;if(t instanceof _s){var n=t.__data__;if(!Ts||n.length<z3-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new Ic(n)}return t.set(r,e),this.size=t.size,this}var zb=G3;function ka(r){var e=this.__data__=new _s(r);this.size=e.size}ka.prototype.clear=Bb;ka.prototype.delete=Ob;ka.prototype.get=Fb;ka.prototype.has=Ub;ka.prototype.set=zb;var rd=ka;function k3(r,e){return r&&Mr(e,Ra(e),r)}var Gb=k3;function V3(r,e){return r&&Mr(e,ui(e),r)}var kb=V3;var jb=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vb=jb&&typeof module=="object"&&module&&!module.nodeType&&module,H3=Vb&&Vb.exports===jb,Hb=H3?Yt.Buffer:void 0,Wb=Hb?Hb.allocUnsafe:void 0;function W3(r,e){if(e)return r.slice();var t=r.length,n=Wb?Wb(t):new r.constructor(t);return r.copy(n),n}var id=W3;function j3(r,e){for(var t=-1,n=r==null?0:r.length,i=0,s=[];++t<n;){var o=r[t];e(o,t,r)&&(s[i++]=o)}return s}var qb=j3;function q3(){return[]}var sd=q3;var X3=Object.prototype,Y3=X3.propertyIsEnumerable,Xb=Object.getOwnPropertySymbols,Q3=Xb?function(r){return r==null?[]:(r=Object(r),qb(Xb(r),function(e){return Y3.call(r,e)}))}:sd,Va=Q3;function K3(r,e){return Mr(r,Va(r),e)}var Yb=K3;var Z3=Object.getOwnPropertySymbols,J3=Z3?function(r){for(var e=[];r;)za(e,Va(r)),r=Ga(r);return e}:sd,od=J3;function $3(r,e){return Mr(r,od(r),e)}var Qb=$3;function eN(r,e,t){var n=e(r);return Dn(r)?n:za(n,t(r))}var ad=eN;function tN(r){return ad(r,Ra,Va)}var Kb=tN;function nN(r){return ad(r,ui,od)}var ld=nN;var rN=tr(Yt,"DataView"),cd=rN;var iN=tr(Yt,"Promise"),hd=iN;var sN=tr(Yt,"Set"),ud=sN;var Zb="[object Map]",oN="[object Object]",Jb="[object Promise]",$b="[object Set]",ew="[object WeakMap]",tw="[object DataView]",aN=ki(cd),lN=ki(Ts),cN=ki(hd),hN=ki(ud),uN=ki(ju),vo=ur;(cd&&vo(new cd(new ArrayBuffer(1)))!=tw||Ts&&vo(new Ts)!=Zb||hd&&vo(hd.resolve())!=Jb||ud&&vo(new ud)!=$b||ju&&vo(new ju)!=ew)&&(vo=function(r){var e=ur(r),t=e==oN?r.constructor:void 0,n=t?ki(t):"";if(n)switch(n){case aN:return tw;case lN:return Zb;case cN:return Jb;case hN:return $b;case uN:return ew}return e});var Ha=vo;var dN=Object.prototype,fN=dN.hasOwnProperty;function pN(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&fN.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var nw=pN;var mN=Yt.Uint8Array,cg=mN;function gN(r){var e=new r.constructor(r.byteLength);return new cg(e).set(new cg(r)),e}var Wa=gN;function yN(r,e){var t=e?Wa(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var rw=yN;var vN=/\w*$/;function xN(r){var e=new r.constructor(r.source,vN.exec(r));return e.lastIndex=r.lastIndex,e}var iw=xN;var sw=qn?qn.prototype:void 0,ow=sw?sw.valueOf:void 0;function bN(r){return ow?Object(ow.call(r)):{}}var aw=bN;function wN(r,e){var t=e?Wa(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var dd=wN;var SN="[object Boolean]",AN="[object Date]",MN="[object Map]",_N="[object Number]",TN="[object RegExp]",EN="[object Set]",CN="[object String]",DN="[object Symbol]",PN="[object ArrayBuffer]",IN="[object DataView]",LN="[object Float32Array]",NN="[object Float64Array]",RN="[object Int8Array]",BN="[object Int16Array]",ON="[object Int32Array]",FN="[object Uint8Array]",UN="[object Uint8ClampedArray]",zN="[object Uint16Array]",GN="[object Uint32Array]";function kN(r,e,t){var n=r.constructor;switch(e){case PN:return Wa(r);case SN:case AN:return new n(+r);case IN:return rw(r,t);case LN:case NN:case RN:case BN:case ON:case FN:case UN:case zN:case GN:return dd(r,t);case MN:return new n;case _N:case CN:return new n(r);case TN:return iw(r);case EN:return new n;case DN:return aw(r)}}var lw=kN;function VN(r){return typeof r.constructor=="function"&&!Ia(r)?Ox(Ga(r)):{}}var fd=VN;var HN="[object Map]";function WN(r){return Bn(r)&&Ha(r)==HN}var cw=WN;var hw=Vi&&Vi.isMap,jN=hw?Na(hw):cw,uw=jN;var qN="[object Set]";function XN(r){return Bn(r)&&Ha(r)==qN}var dw=XN;var fw=Vi&&Vi.isSet,YN=fw?Na(fw):dw,pw=YN;var QN=1,KN=2,ZN=4,mw="[object Arguments]",JN="[object Array]",$N="[object Boolean]",eR="[object Date]",tR="[object Error]",gw="[object Function]",nR="[object GeneratorFunction]",rR="[object Map]",iR="[object Number]",yw="[object Object]",sR="[object RegExp]",oR="[object Set]",aR="[object String]",lR="[object Symbol]",cR="[object WeakMap]",hR="[object ArrayBuffer]",uR="[object DataView]",dR="[object Float32Array]",fR="[object Float64Array]",pR="[object Int8Array]",mR="[object Int16Array]",gR="[object Int32Array]",yR="[object Uint8Array]",vR="[object Uint8ClampedArray]",xR="[object Uint16Array]",bR="[object Uint32Array]",Dt={};Dt[mw]=Dt[JN]=Dt[hR]=Dt[uR]=Dt[$N]=Dt[eR]=Dt[dR]=Dt[fR]=Dt[pR]=Dt[mR]=Dt[gR]=Dt[rR]=Dt[iR]=Dt[yw]=Dt[sR]=Dt[oR]=Dt[aR]=Dt[lR]=Dt[yR]=Dt[vR]=Dt[xR]=Dt[bR]=!0;Dt[tR]=Dt[gw]=Dt[cR]=!1;function pd(r,e,t,n,i,s){var o,a=e&QN,l=e&KN,c=e&ZN;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!Jt(r))return r;var h=Dn(r);if(h){if(o=nw(r),!a)return qu(r,o)}else{var u=Ha(r),d=u==gw||u==nR;if(La(r))return id(r,a);if(u==yw||u==mw||d&&!i){if(o=l||d?{}:fd(r),!a)return l?Qb(r,kb(o,r)):Yb(r,Gb(o,r))}else{if(!Dt[u])return i?r:{};o=lw(r,u,a)}}s||(s=new rd);var f=s.get(r);if(f)return f;s.set(r,o),pw(r)?r.forEach(function(g){o.add(pd(g,e,t,g,r,s))}):uw(r)&&r.forEach(function(g,x){o.set(x,pd(g,e,t,x,r,s))});var m=c?l?ld:Kb:l?ui:Ra,p=h?void 0:m(r);return kx(p||r,function(g,x){p&&(x=g,g=r[x]),Qu(o,x,pd(g,e,t,x,r,s))}),o}var md=pd;var wR=1,SR=4;function AR(r){return md(r,wR|SR)}var Lc=AR;function MR(r){return function(e,t,n){for(var i=-1,s=Object(e),o=n(e),a=o.length;a--;){var l=o[r?a:++i];if(t(s[l],l,s)===!1)break}return e}}var vw=MR;var _R=vw(),xw=_R;var TR=function(){return Yt.Date.now()},gd=TR;var ER="Expected a function",CR=Math.max,DR=Math.min;function PR(r,e,t){var n,i,s,o,a,l,c=0,h=!1,u=!1,d=!0;if(typeof r!="function")throw new TypeError(ER);e=ig(e)||0,Jt(t)&&(h=!!t.leading,u="maxWait"in t,s=u?CR(ig(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function f(M){var _=n,y=i;return n=i=void 0,c=M,o=r.apply(y,_),o}function m(M){return c=M,a=setTimeout(x,e),h?f(M):o}function p(M){var _=M-l,y=M-c,T=e-_;return u?DR(T,s-y):T}function g(M){var _=M-l,y=M-c;return l===void 0||_>=e||_<0||u&&y>=s}function x(){var M=gd();if(g(M))return v(M);a=setTimeout(x,p(M))}function v(M){return a=void 0,d&&n?f(M):(n=i=void 0,o)}function w(){a!==void 0&&clearTimeout(a),c=0,n=l=i=a=void 0}function b(){return a===void 0?o:v(gd())}function S(){var M=gd(),_=g(M);if(n=arguments,i=this,l=M,_){if(a===void 0)return m(l);if(u)return clearTimeout(a),a=setTimeout(x,e),f(l)}return a===void 0&&(a=setTimeout(x,e)),o}return S.cancel=w,S.flush=b,S}var Nc=PR;function IR(r,e,t){(t!==void 0&&!Ss(r[e],t)||t===void 0&&!(e in r))&&Pa(r,e,t)}var Rc=IR;function LR(r){return Bn(r)&&As(r)}var bw=LR;function NR(r,e){if(!(e==="constructor"&&typeof r[e]=="function")&&e!="__proto__")return r[e]}var Bc=NR;function RR(r){return Mr(r,ui(r))}var ww=RR;function BR(r,e,t,n,i,s,o){var a=Bc(r,t),l=Bc(e,t),c=o.get(l);if(c){Rc(r,t,c);return}var h=s?s(a,l,t+"",r,e,o):void 0,u=h===void 0;if(u){var d=Dn(l),f=!d&&La(l),m=!d&&!f&&Ju(l);h=l,d||f||m?Dn(a)?h=a:bw(a)?h=qu(a):f?(u=!1,h=id(l,!0)):m?(u=!1,h=dd(l,!0)):h=[]:nd(l)||yo(l)?(h=a,yo(a)?h=ww(a):(!Jt(a)||Ca(a))&&(h=fd(l))):u=!1}u&&(o.set(l,h),i(h,l,n,s,o),o.delete(l)),Rc(r,t,h)}var Sw=BR;function Aw(r,e,t,n,i){r!==e&&xw(e,function(s,o){if(i||(i=new rd),Jt(s))Sw(r,e,o,t,Aw,n,i);else{var a=n?n(Bc(r,o),s,o+"",r,e,i):void 0;a===void 0&&(a=s),Rc(r,o,a)}},ui)}var Mw=Aw;function OR(r){var e=r==null?0:r.length;return e?r[e-1]:void 0}var _w=OR;function FR(r,e){return e.length<2?r:Tb(r,Rb(e,0,-1))}var Tw=FR;var UR=jx(function(r,e,t){Mw(r,e,t)}),xo=UR;function zR(r,e){return e=Ua(e,r),r=Tw(r,e),r==null||delete r[td(_w(e))]}var Ew=zR;function GR(r){return nd(r)?void 0:r}var Cw=GR;var kR=1,VR=2,HR=4,WR=Lb(function(r,e){var t={};if(r==null)return t;var n=!1;e=Vu(e,function(s){return s=Ua(s,r),n||(n=s.length>1),s}),Mr(r,ld(r),t),n&&(t=md(t,kR|VR|HR,Cw));for(var i=e.length;i--;)Ew(t,e[i]);return t}),ja=WR;var jR=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),qR=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),XR=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Oc&&"ontouchend"in document,YR=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,QR=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,KR=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,e=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(e)},ZR=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},Q6=jR(),Oc=qR(),Cs=XR(),Dw=YR(),yd=QR(),Pw=KR(),K6=Number(ZR());function Iw(r){return Array.isArray(r)?r:[r]}function Fc(r){return Oc?r.metaKey:r.ctrlKey}var Ds;(t=>{t.all=["PerspectiveCamera","OrthographicCamera"];function e(n){return t.all.includes(n)}t.is=e})(Ds||(Ds={}));var bo;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(bo||(bo={}));var Wi;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}t.lerp=e})(Wi||(Wi={}));var on;(i=>{function r(s,o){return s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]}i.isEqual=r;function e(s,o){return[s[0]+o[0],s[1]+o[1],s[2]+o[2]]}i.add=e;function t(s,o){return[s[0]-o[0],s[1]-o[1],s[2]-o[2]]}i.sub=t;function n(s,o,a){return[s[0]+(o[0]-s[0])*a,s[1]+(o[1]-s[1])*a,s[2]+(o[2]-s[2])*a]}i.lerp=n})(on||(on={}));var Uc;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}t.lerp=e})(Uc||(Uc={}));var di;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=e;function t(s){return s??i.identity}i.simplify=t;function n(s,o){let a=o.slice(0);for(var l=0,c=o.length;l<c;l+=3){let h=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/h,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/h,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/h}return a}i.applyMatrix4=n})(di||(di={}));var dn;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function n(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=n;function i(c){return{r:c.r,g:c.g,b:c.b}}l.clone=i;function s(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=s;function o(c,h){return c.r===h.r&&c.g===h.g&&c.b===h.b}l.equals=o;function a(c,h,u){return{r:c.r+(h.r-c.r)*u,g:c.g+(h.g-c.g)*u,b:c.b+(h.b-c.b)*u}}l.lerp=a})(dn||(dn={}));var On;(o=>{o.white={...dn.white,a:1};function e(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}o.from0to1=e;function t(a,l){return{...dn.fromHex(a),a:l}}o.fromHexAndA=t;function n(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}o.toRgb255a1=n;function i(a,l){return dn.equals(a,l)&&a.a===l.a}o.equals=i;function s(a,l,c){return{r:a.r+(l.r-a.r)*c,g:a.g+(l.g-a.g)*c,b:a.b+(l.b-a.b)*c,a:a.a+(l.a-a.a)*c}}o.lerp=s})(On||(On={}));var vd;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(vd||(vd={}));var xd;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(xd||(xd={}));var bd;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(bd||(bd={}));var wd;(e=>{function r(t,n=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*n,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+n)),useCenter:!0}}}e.defaultData=r})(wd||(wd={}));var _r=class{modifyById(e,t){let n=this;if(n[e]===void 0)throw new Error("not expected");{let s={...n,[e]:t};return Object.setPrototypeOf(s,_r.prototype),s}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let n=t[e.id],i;n===void 0?i={type:2,id:e.id}:i={type:1,id:e.id,data:n};let{id:s,data:o}=e,a={...t,[s]:o};return Object.setPrototypeOf(a,_r.prototype),{data:a,actual:e,reverse:i}}else if(e.type===2){let{id:n}=e,i=t[n];if(i===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,_r.prototype),delete s[n],{data:s,actual:e,reverse:{type:1,id:n,data:i}}}}throw new Error("illegal arg")}};function zc(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let e=Object.getOwnPropertyNames(r);for(let t of e){let n=r[t];n&&typeof n=="object"&&zc(n)}return Object.freeze(r)}function Lw(r,e){let t=0;for(;t<r.length&&t<e.length;){if(r[t]<e[t])return-1;if(r[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==r.length?1:0}var Sd=class extends Error{};function fi(r,e,t){if(r===void 0?e===void 0?(r=0,e=10):r=e-10:e===void 0&&(e=r+10),r>e){let s=r;r=e,e=s}let n=[],i=1/(t+1);for(let s=0;s<t;s++){let o=r+(e-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function Ad(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function Nw(){return typeof process<"u"}function Rw(r,e){for(let t of r)e(t.id,t.data),Rw(t.children,e)}function Bw(r,e){e(r.id,r.data);for(let t of r.children)Bw(t,e)}var Tr=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Tr.prototype)}deepFreeze(){let t=0;for(;t<this.length;)zc(this[t]),t++}fillCaches0(t,n){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,n);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}isDescendantOf(t,n){for(;t;){let i=this.parent(t);if(i===n)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}get(t){return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,n){if(t===null)this.traverse(n);else{let i=this.get(t);i&&Bw(i,n)}}traverse(t){Rw(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this.parent(t),o=this.childrenArray(s),a=o.findIndex(h=>h.id===t);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(t,n){let i=t,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let c=s.findIndex(h=>h.id===l);if(c<0)throw new Error;s=[...s],s[c]={...s[c],children:a}}Object.setPrototypeOf(s,Tr.prototype);let o=s;return o.fillCaches(),o}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}}checkDuplicatedIdRec({id:t,children:n}){if(this.get(t)!==void 0)return!0;for(let i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:n,fi:i,id:s,data:o,children:a}=t;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(t))return null;{let l=n,c=this.childrenArray(l),h={fi:i,id:s,data:o,children:a};return c=[...c,h],c.sort((d,f)=>d.fi-f.fi),t.localIndex=c.indexOf(h),{data:this.modifyArrayBy(l,c),actual:t,reverse:{type:8,id:s}}}}deleteOp(t){let{id:n}=t;if(this.get(n)===null)return null;{let i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(c=>c.id===n);t.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:t,reverse:{type:7,...a,parent:i}}}}moveOp(t){let{parent:n,fi:i,id:s}=t;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Sd("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),c=l.findIndex(f=>f.id===s);l=[...l];let h=l.splice(c,1)[0],u=this.modifyArrayBy(o,l);o=n,l=u.childrenArray(o);let d=h.fi;return h={...h,fi:i},l=[...l,h],l.sort((f,m)=>f.fi-m.fi),t.localIndex=l.indexOf(h),u=u.modifyArrayBy(o,l),{data:u,actual:t,reverse:{type:9,parent:a,fi:d,id:s}}}previous(t,n){if(n===null){let s=this.childrenArray(t);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(t)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)+1;if(s<i.length)return i[s].id;if(n)return this.traverseSortNext(n)}}sortNext(t){let n=this.childrenArray(t);return n.length>0?n[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let n=this.childrenArray(t);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):t}sortPrevious(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(t){let n=[];for(let i of t){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>Lw(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(t){var n=t;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(t,n,i){return this.insertAfterHelper(t,this.previous(t,n),i)}insertAfterHelper(t,n,i){let s=this.childrenArray(t);if(n===null){if(s.length===0)return fi(0,i,i);{let o=s[0].fi;return fi(o-i,o,i)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==t)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return fi(l,l+i,i)}else return fi(o.fi,a.fi,i)}}};var Md;(e=>{function r(t,n){if(Array.isArray(t)){let i=n.props,s={},o=[...t],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=o[c],o[c]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...t},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let c=i[l];c===void 0?delete o[l]:o[l]=c,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}e.runOp=r})(Md||(Md={}));var Ht=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Ht.prototype)}deepFreeze(){let t=0;for(;t<this.length;)zc(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(c=>c.id===t);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(t){Object.setPrototypeOf(t,Ht.prototype);let n=t;return Nw()||n.fillCaches(),n}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}}addOp(t){let{fi:n,id:i,data:s}=t,o=this,a={fi:n,id:i,data:s};return o=[...o,a],o.sort((c,h)=>c.fi-h.fi),t.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:n}=t,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;t.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...o}}}moveOp(t){let{fi:n,id:i}=t,s=this;s=[...s];let o=s.findIndex(h=>h.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((h,u)=>h.fi-u.fi),t.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:t,reverse:{type:6,fi:a,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===t)return n;n=i.id}return null}insertBeforeHelper(t,n){return this.insertAfterHelper(this.previous(t),n)}insertAfterHelper(t,n){let i=this;if(t===null){if(i.length===0)return fi(0,n,n);{let s=i[0].fi;return fi(s-n,s,n)}}else{let s=this.get(t);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return fi(a,a+n,n)}else return fi(s.fi,o.fi,n)}}};var Ow=Symbol(),Td=Symbol(),qa=class{reportOp(e,t){let n=this;if(t===null)return;n._current=t.data;let i=[];for(;!(n instanceof _d);){let s=n._path,o=n._current;if(s!==""&&i.splice(0,0,s),n=n._parent,n===null)return;n.update(s,o)}n.push(i,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let n=t[Td];n&&n(),delete this._children[e]}}}},ug=class extends qa{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,Md.runOp(this._current,e))}},dg=class extends qa{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,_r.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},Fw={get(r,e){if(e===Td)return()=>{r._parent=null};if(e===Ow)return r._current;let{_current:t,_children:n}=r;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t[e],o=Ed(r,e,s);return o!==s?(n===void 0&&(n={},r._children=n),n[e]=o,o):s},has(r,e){return e in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,e){let t=r._current,n=Reflect.getOwnPropertyDescriptor(t,e);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:t[e]}}},JR={...Fw,set(r,e,t){let n={type:0,props:{[e]:mg(t)??t}};return r.deleteChildren(e),r.runOp(n),!0},deleteProperty(r,e){let t={type:0,props:{[e]:void 0}};return r.deleteChildren(e),r.runOp(t),!0}},$R={...Fw,set(r,e,t){return t===void 0?this.deleteProperty(r,e):(r.deleteChildren(e),r.runOp({type:1,id:e,data:t})),!0},deleteProperty(r,e){return r.runOp({type:2,id:e}),!0}},Xa=class extends qa{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Td]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,n)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Ed(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}add(e,t,n,i,s){this.runOp({type:7,parent:e,fi:t,id:n,data:i,children:s})}move(e,t,n){this.runOp({type:9,parent:e,fi:t,id:n})}insertAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}insertBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}moveAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}moveBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Ya=class extends qa{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Td]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let n=0;n<t;n++){let i=this._current[n].id;e(this.data(this._current[n].id),i)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Ed(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,n){this.runOp({type:4,fi:e,id:t,data:n})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}insertBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}moveAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}moveBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function hg(r,e,t){if(r.length>0){let n=r[r.length-1];if(n.type===0&&e.type===0&&Cd.equal(n.path,t)){Object.assign(n.props,e.props);return}}r.push({...e,path:t})}var _d=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,n,i){hg(this.ts,t,e),hg(this.actual,n,e),hg(this.reverse,i,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Ed(r,e,t){return t instanceof Tr?new Xa(r,e,t):t instanceof Ht?new Ya(r,e,t):t instanceof _r?new Proxy(new dg(r,e,t),$R):t!==null&&typeof t=="object"?Ad(t)?t:new Proxy(new ug(r,e,t),JR):t}function fg(r){let e=new _d(r);return[Ed(e,"",r),e]}function pg(r,e){let[t,n]=fg(r);return e(t),n.result()}function mg(r){return r instanceof Xa||r instanceof Ya?r._current:r!==null&&typeof r=="object"?r[Ow]:r}var Cd;(n=>{function r(i,s){if(s.length===i.length)for(var o=0;o<i.length;){if(i[o]!==s[o])return!1;o+=1}else return!1;return!0}n.equal=r;function e(i,s,o){let a=t(o,i);if(a!==void 0&&typeof a=="object"&&a!==null){let l={...s};return Object.keys(a).forEach(c=>{delete l[c]}),l}else return s}n.removeOverridden=e;function t(i,s,o=0){if(s.length<=o)return i;if((i instanceof Tr||i instanceof Xa)&&typeof s[o]=="string")return t(i.data(s[o]),s,o+1);if((i instanceof Ht||i instanceof Ya)&&typeof s[o]=="string")return t(i.data(s[o]),s,o+1);if(typeof s[o]=="number"&&Array.isArray(i))return t(i[s[o]],s,o+1);if(typeof s[o]=="string"&&typeof i=="object")return t(i[s[o]],s,o+1)}n.zoom=t})(Cd||(Cd={}));var Dd=class{},Gc=class extends Dd{constructor(t){super();this.id=t}},kc=class extends Dd{constructor(t){super();this.data=t}};var yg;try{yg=new TextDecoder}catch{}var Pe,Is,Q=0;var jw=[],vg=jw,xg=0,nr={},vt,Ps,Er=0,pi=0,dr,ji,Xn=[],Mt,Uw={useRecords:!1,mapsAsObjects:!0},Vc=class{},wg=new Vc;wg.name="MessagePack 0xC1";var Qa=!1,mi=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Pe)return Kw(()=>(Id(),this?this.unpack(e,t):mi.prototype.unpack.call(Uw,e,t)));Is=t>-1?t:e.length,Q=0,xg=0,pi=0,Ps=null,vg=jw,dr=null,Pe=e;try{Mt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw Pe=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof mi){if(nr=this,this.structures)return vt=this.structures,Pd();(!vt||vt.length>0)&&(vt=[])}else nr=Uw,(!vt||vt.length>0)&&(vt=[]);return Pd()}unpackMultiple(e,t){let n,i=0;try{Qa=!0;let s=e.length,o=this?this.unpack(e,s):Rd.unpack(e,s);if(t){for(t(o);Q<s;)if(i=Q,t(Pd())===!1)return}else{for(n=[o];Q<s;)i=Q,n.push(Pd());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Qa=!1,Id()}}_mergeStructures(e,t){e=e||[];for(let n=0,i=e.length;n<i;n++){let s=e[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let i=e[n],s=t[n];s&&(i&&((e.restoreStructures||(e.restoreStructures=[]))[n]=i),e[n]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Pd(){try{if(!nr.trusted&&!Qa){let e=vt.sharedLength||0;e<vt.length&&(vt.length=e)}let r=Qt();if(Q==Is)vt.restoreStructures&&zw(),vt=null,Pe=null,ji&&(ji=null);else if(Q>Is){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!Qa)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw vt.restoreStructures&&zw(),Id(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function zw(){for(let r in vt.restoreStructures)vt[r]=vt.restoreStructures[r];vt.restoreStructures=null}function Qt(){let r=Pe[Q++];if(r<160)if(r<128){if(r<64)return r;{let e=vt[r&63]||nr.getStructures&&qw()[r&63];return e?(e.read||(e.read=Sg(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,nr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[Yw()]=Qt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Qt(),Qt());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Qt();return e}else if(r<192){let e=r-160;if(pi>=Q)return Ps.slice(Q-Er,(Q+=e)-Er);if(pi==0&&Is<140){let t=e<16?Ag(e):Xw(e);if(t!=null)return t}return bg(e)}else{let e;switch(r){case 192:return null;case 193:return dr?(e=Qt(),e>0?dr[1].slice(dr.position1,dr.position1+=e):dr[0].slice(dr.position0,dr.position0-=e)):wg;case 194:return!1;case 195:return!0;case 196:return gg(Pe[Q++]);case 197:return e=Mt.getUint16(Q),Q+=2,gg(e);case 198:return e=Mt.getUint32(Q),Q+=4,gg(e);case 199:return wo(Pe[Q++]);case 200:return e=Mt.getUint16(Q),Q+=2,wo(e);case 201:return e=Mt.getUint32(Q),Q+=4,wo(e);case 202:if(e=Mt.getFloat32(Q),nr.useFloat32>2){let t=Nd[(Pe[Q]&127)<<1|Pe[Q+1]>>7];return Q+=4,(t*e+(e>0?.5:-.5)>>0)/t}return Q+=4,e;case 203:return e=Mt.getFloat64(Q),Q+=8,e;case 204:return Pe[Q++];case 205:return e=Mt.getUint16(Q),Q+=2,e;case 206:return e=Mt.getUint32(Q),Q+=4,e;case 207:return nr.int64AsNumber?(e=Mt.getUint32(Q)*4294967296,e+=Mt.getUint32(Q+4)):e=Mt.getBigUint64(Q),Q+=8,e;case 208:return Mt.getInt8(Q++);case 209:return e=Mt.getInt16(Q),Q+=2,e;case 210:return e=Mt.getInt32(Q),Q+=4,e;case 211:return nr.int64AsNumber?(e=Mt.getInt32(Q)*4294967296,e+=Mt.getUint32(Q+4)):e=Mt.getBigInt64(Q),Q+=8,e;case 212:if(e=Pe[Q++],e==114)return Ww(Pe[Q++]&63);{let t=Xn[e];if(t)return t.read?(Q++,t.read(Qt())):t.noBuffer?(Q++,t()):t(Pe.subarray(Q,++Q));throw new Error("Unknown extension "+e)}case 213:return e=Pe[Q],e==114?(Q++,Ww(Pe[Q++]&63,Pe[Q++])):wo(2);case 214:return wo(4);case 215:return wo(8);case 216:return wo(16);case 217:return e=Pe[Q++],pi>=Q?Ps.slice(Q-Er,(Q+=e)-Er):tB(e);case 218:return e=Mt.getUint16(Q),Q+=2,pi>=Q?Ps.slice(Q-Er,(Q+=e)-Er):nB(e);case 219:return e=Mt.getUint32(Q),Q+=4,pi>=Q?Ps.slice(Q-Er,(Q+=e)-Er):rB(e);case 220:return e=Mt.getUint16(Q),Q+=2,kw(e);case 221:return e=Mt.getUint32(Q),Q+=4,kw(e);case 222:return e=Mt.getUint16(Q),Q+=2,Vw(e);case 223:return e=Mt.getUint32(Q),Q+=4,Vw(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}var eB=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Sg(r,e){function t(){if(t.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>eB.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Qt);return r.highByte===0&&(r.read=Gw(e,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=Qt()}return n}return t.count=0,r.highByte===0?Gw(e,t):t}var Gw=(r,e)=>function(){let t=Pe[Q++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),i=vt[n]||qw()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=Sg(i,r)),i.read()};function qw(){let r=Kw(()=>(Pe=null,nr.getStructures()));return vt=nr._mergeStructures(r,vt)}var bg=Ld,tB=Ld,nB=Ld,rB=Ld;function Ld(r){let e;if(r<16&&(e=Ag(r)))return e;if(r>64&&yg)return yg.decode(Pe.subarray(Q,Q+=r));let t=Q+r,n=[];for(e="";Q<t;){let i=Pe[Q++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Pe[Q++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Pe[Q++]&63,o=Pe[Q++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Pe[Q++]&63,o=Pe[Q++]&63,a=Pe[Q++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(i);n.length>=4096&&(e+=_n.apply(String,n),n.length=0)}return n.length>0&&(e+=_n.apply(String,n)),e}function kw(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Qt();return e}function Vw(r){if(nr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[Yw()]=Qt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Qt(),Qt());return e}}var _n=String.fromCharCode;function Xw(r){let e=Q,t=new Array(r);for(let n=0;n<r;n++){let i=Pe[Q++];if((i&128)>0){Q=e;return}t[n]=i}return _n.apply(String,t)}function Ag(r){if(r<4)if(r<2){if(r===0)return"";{let e=Pe[Q++];if((e&128)>1){Q-=1;return}return _n(e)}}else{let e=Pe[Q++],t=Pe[Q++];if((e&128)>0||(t&128)>0){Q-=2;return}if(r<3)return _n(e,t);let n=Pe[Q++];if((n&128)>0){Q-=3;return}return _n(e,t,n)}else{let e=Pe[Q++],t=Pe[Q++],n=Pe[Q++],i=Pe[Q++];if((e&128)>0||(t&128)>0||(n&128)>0||(i&128)>0){Q-=4;return}if(r<6){if(r===4)return _n(e,t,n,i);{let s=Pe[Q++];if((s&128)>0){Q-=5;return}return _n(e,t,n,i,s)}}else if(r<8){let s=Pe[Q++],o=Pe[Q++];if((s&128)>0||(o&128)>0){Q-=6;return}if(r<7)return _n(e,t,n,i,s,o);let a=Pe[Q++];if((a&128)>0){Q-=7;return}return _n(e,t,n,i,s,o,a)}else{let s=Pe[Q++],o=Pe[Q++],a=Pe[Q++],l=Pe[Q++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){Q-=8;return}if(r<10){if(r===8)return _n(e,t,n,i,s,o,a,l);{let c=Pe[Q++];if((c&128)>0){Q-=9;return}return _n(e,t,n,i,s,o,a,l,c)}}else if(r<12){let c=Pe[Q++],h=Pe[Q++];if((c&128)>0||(h&128)>0){Q-=10;return}if(r<11)return _n(e,t,n,i,s,o,a,l,c,h);let u=Pe[Q++];if((u&128)>0){Q-=11;return}return _n(e,t,n,i,s,o,a,l,c,h,u)}else{let c=Pe[Q++],h=Pe[Q++],u=Pe[Q++],d=Pe[Q++];if((c&128)>0||(h&128)>0||(u&128)>0||(d&128)>0){Q-=12;return}if(r<14){if(r===12)return _n(e,t,n,i,s,o,a,l,c,h,u,d);{let f=Pe[Q++];if((f&128)>0){Q-=13;return}return _n(e,t,n,i,s,o,a,l,c,h,u,d,f)}}else{let f=Pe[Q++],m=Pe[Q++];if((f&128)>0||(m&128)>0){Q-=14;return}if(r<15)return _n(e,t,n,i,s,o,a,l,c,h,u,d,f,m);let p=Pe[Q++];if((p&128)>0){Q-=15;return}return _n(e,t,n,i,s,o,a,l,c,h,u,d,f,m,p)}}}}}function gg(r){return nr.copyBuffers?Uint8Array.prototype.slice.call(Pe,Q,Q+=r):Pe.subarray(Q,Q+=r)}function wo(r){let e=Pe[Q++];if(Xn[e])return Xn[e](Pe.subarray(Q,Q+=r));throw new Error("Unknown extension type "+e)}var Hw=new Array(4096);function Yw(){let r=Pe[Q++];if(r>=160&&r<192){if(r=r-160,pi>=Q)return Ps.slice(Q-Er,(Q+=r)-Er);if(!(pi==0&&Is<180))return bg(r)}else return Q--,Qt();let e=(r<<5^(r>1?Mt.getUint16(Q):r>0?Pe[Q]:0))&4095,t=Hw[e],n=Q,i=Q+r-3,s,o=0;if(t&&t.bytes==r){for(;n<i;){if(s=Mt.getUint32(n),s!=t[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Pe[n++],s!=t[o++]){n=1879048192;break}if(n===i)return Q=n,t.string;i-=3,n=Q}for(t=[],Hw[e]=t,t.bytes=r;n<i;)s=Mt.getUint32(n),t.push(s),n+=4;for(i+=3;n<i;)s=Pe[n++],t.push(s);let a=r<16?Ag(r):Xw(r);return a!=null?t.string=a:t.string=bg(r)}var Ww=(r,e)=>{var t=Qt();let n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let i=vt[r];return i&&i.isShared&&((vt.restoreStructures||(vt.restoreStructures=[]))[r]=i),vt[r]=t,t.read=Sg(t,n),t.read()},Qw=typeof self=="object"?self:global;Xn[0]=()=>{};Xn[0].noBuffer=!0;Xn[101]=()=>{let r=Qt();return(Qw[r[0]]||Error)(r[1])};Xn[105]=r=>{let e=Mt.getUint32(Q-4);ji||(ji=new Map);let t=Pe[Q],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let i={target:n};ji.set(e,i);let s=Qt();return i.used?Object.assign(n,s):(i.target=s,s)};Xn[112]=r=>{let e=Mt.getUint32(Q-4),t=ji.get(e);return t.used=!0,t.target};Xn[115]=()=>new Set(Qt());var Mg=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");Xn[116]=r=>{let e=r[0],t=Mg[e];if(!t)throw new Error("Could not find typed array for code "+e);return new Qw[t](Uint8Array.prototype.slice.call(r,1).buffer)};Xn[120]=()=>{let r=Qt();return new RegExp(r[0],r[1])};Xn[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=Q;Q+=e-4,dr=[Qt(),Qt()],dr.position0=0,dr.position1=0;let n=Q;Q=t;try{return Qt()}finally{Q=n}};Xn[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function Kw(r){let e=Is,t=Q,n=xg,i=Er,s=pi,o=Ps,a=vg,l=ji,c=dr,h=new Uint8Array(Pe.slice(0,Is)),u=vt,d=vt.slice(0,vt.length),f=nr,m=Qa,p=r();return Is=e,Q=t,xg=n,Er=i,pi=s,Ps=o,vg=a,ji=l,dr=c,Pe=h,Qa=m,vt=u,vt.splice(0,vt.length,...d),nr=f,Mt=new DataView(Pe.buffer,Pe.byteOffset,Pe.byteLength),p}function Id(){Pe=null,ji=null,vt=null}function Zw(r){r.unpack?Xn[r.type]=r.unpack:Xn[r.type]=r}var Nd=new Array(147);for(let r=0;r<256;r++)Nd[r]=+("1e"+Math.floor(45.15-r*.30103));var Rd=new mi({useRecords:!1}),iB=Rd.unpack,sB=Rd.unpackMultiple,oB=Rd.unpack,Bd={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},aB=new Float32Array(1),Cj=new Uint8Array(aB.buffer,0,4);var Od;try{Od=new TextEncoder}catch{}var Fd,Tg,Ud=typeof Buffer<"u",_g=Ud?Buffer.allocUnsafeSlow:Uint8Array,tS=Ud?Buffer:Uint8Array,Jw=Ud?4294967296:2144337920,oe,$t,ee=0,gi,yi=null,lB=/[\u0080-\uFFFF]/,Hc=Symbol("record-id"),So=class extends mi{constructor(e){super(e),this.offset=0;let t,n,i,s,o,a,l=0,c=tS.prototype.utf8Write?function(y,T,E){return oe.utf8Write(y,T,E)}:Od&&Od.encodeInto?function(y,T){return Od.encodeInto(y,oe.subarray(T)).written}:!1,h=this;e||(e={});let u=e&&e.sequential,d=e.structures||e.saveStructures,f=e.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=d?32:64),u&&!e.saveStructures&&(this.structures=[]);let p=f>32||m+f>64,g=f+64,x=f+m+64;if(x>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],w=0,b=0;this.pack=this.encode=function(y,T){if(oe||(oe=new _g(8192),$t=new DataView(oe.buffer,0,8192),ee=0),gi=oe.length-10,gi-ee<2048?(oe=new _g(oe.length),$t=new DataView(oe.buffer,0,oe.length),gi=oe.length-10,ee=0):ee=ee+7&2147483640,n=ee,a=h.structuredClone?new Map:null,h.bundleStrings?(yi=["",""],oe[ee++]=214,oe[ee++]=98,yi.position=ee-n,ee+=4):yi=null,i=h.structures,i){i.uninitialized&&(i=h._mergeStructures(h.getStructures()));let E=i.sharedLength||0;if(E>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let C=0;C<E;C++){let L=i[C];if(!L)continue;let R,N=i.transitions;for(let H=0,j=L.length;H<j;H++){let K=L[H];R=N[K],R||(R=N[K]=Object.create(null)),N=R}N[Hc]=C+64}l=E}u||(i.nextId=E+64)}s&&(s=!1),o=i||[];try{if(S(y),yi){$t.setUint32(yi.position+n,ee-yi.position-n);let E=yi;yi=null,S(E[0]),S(E[1])}if(h.offset=ee,a&&a.idsToInsert){ee+=a.idsToInsert.length*6,ee>gi&&_(ee),h.offset=ee;let E=hB(oe.subarray(n,ee),a.idsToInsert);return a=null,E}return T&rS?(oe.start=n,oe.end=ee,oe):oe.subarray(n,ee)}finally{if(i){if(b<10&&b++,w>1e4)i.transitions=null,b=0,w=0,v.length>0&&(v=[]);else if(v.length>0&&!u){for(let E=0,C=v.length;E<C;E++)v[E][Hc]=0;v=[]}if(s&&h.saveStructures){let E=i.sharedLength||f;i.length>E&&(i=i.slice(0,E));let C=oe.subarray(n,ee);return h.saveStructures(i,l)===!1?(h._mergeStructures(h.getStructures()),h.pack(y)):(l=E,C)}}T&yB&&(ee=n)}};let S=y=>{ee>gi&&(oe=_(ee));var T=typeof y,E;if(T==="string"){let C=y.length;if(yi&&C>=8&&C<4096){let N=lB.test(y);yi[N?0:1]+=y,oe[ee++]=193,S(N?-C:C);return}let L;C<32?L=1:C<256?L=2:C<65536?L=3:L=5;let R=C*3;if(ee+R>gi&&(oe=_(ee+R)),C<64||!c){let N,H,j,K=ee+L;for(N=0;N<C;N++)H=y.charCodeAt(N),H<128?oe[K++]=H:H<2048?(oe[K++]=H>>6|192,oe[K++]=H&63|128):(H&64512)===55296&&((j=y.charCodeAt(N+1))&64512)===56320?(H=65536+((H&1023)<<10)+(j&1023),N++,oe[K++]=H>>18|240,oe[K++]=H>>12&63|128,oe[K++]=H>>6&63|128,oe[K++]=H&63|128):(oe[K++]=H>>12|224,oe[K++]=H>>6&63|128,oe[K++]=H&63|128);E=K-ee-L}else E=c(y,ee+L,R);E<32?oe[ee++]=160|E:E<256?(L<2&&oe.copyWithin(ee+2,ee+1,ee+1+E),oe[ee++]=217,oe[ee++]=E):E<65536?(L<3&&oe.copyWithin(ee+3,ee+2,ee+2+E),oe[ee++]=218,oe[ee++]=E>>8,oe[ee++]=E&255):(L<5&&oe.copyWithin(ee+5,ee+3,ee+3+E),oe[ee++]=219,$t.setUint32(ee,E),ee+=4),ee+=E}else if(T==="number")if(y>>>0===y)y<64?oe[ee++]=y:y<256?(oe[ee++]=204,oe[ee++]=y):y<65536?(oe[ee++]=205,oe[ee++]=y>>8,oe[ee++]=y&255):(oe[ee++]=206,$t.setUint32(ee,y),ee+=4);else if(y>>0===y)y>=-32?oe[ee++]=256+y:y>=-128?(oe[ee++]=208,oe[ee++]=y+256):y>=-32768?(oe[ee++]=209,$t.setInt16(ee,y),ee+=2):(oe[ee++]=210,$t.setInt32(ee,y),ee+=4);else{let C;if((C=this.useFloat32)>0&&y<4294967296&&y>=-2147483648){oe[ee++]=202,$t.setFloat32(ee,y);let L;if(C<4||(L=y*Nd[(oe[ee]&127)<<1|oe[ee+1]>>7])>>0===L){ee+=4;return}else ee--}oe[ee++]=203,$t.setFloat64(ee,y),ee+=8}else if(T==="object")if(!y)oe[ee++]=192;else{if(a){let L=a.get(y);if(L){if(!L.id){let R=a.idsToInsert||(a.idsToInsert=[]);L.id=R.push(L)}oe[ee++]=214,oe[ee++]=112,$t.setUint32(ee,L.id),ee+=4;return}else a.set(y,{offset:ee-n})}let C=y.constructor;if(C===Object)M(y,!0);else if(C===Array){E=y.length,E<16?oe[ee++]=144|E:E<65536?(oe[ee++]=220,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=221,$t.setUint32(ee,E),ee+=4);for(let L=0;L<E;L++)S(y[L])}else if(C===Map){E=y.size,E<16?oe[ee++]=128|E:E<65536?(oe[ee++]=222,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=223,$t.setUint32(ee,E),ee+=4);for(let[L,R]of y)S(L),S(R)}else{for(let L=0,R=Fd.length;L<R;L++){let N=Tg[L];if(y instanceof N){let H=Fd[L];if(H.write){H.type&&(oe[ee++]=212,oe[ee++]=H.type,oe[ee++]=0),S(H.write.call(this,y));return}let j=oe,K=$t,Y=ee;oe=null;let z;try{z=H.pack.call(this,y,F=>(oe=j,j=null,ee+=F,ee>gi&&_(ee),{target:oe,targetView:$t,position:ee-F}),S)}finally{j&&(oe=j,$t=K,ee=Y,gi=oe.length-10)}z&&(z.length+ee>gi&&_(z.length+ee),ee=cB(z,oe,ee,H.type));return}}M(y,!y.hasOwnProperty)}}else if(T==="boolean")oe[ee++]=y?195:194;else if(T==="bigint"){if(y<BigInt(1)<<BigInt(63)&&y>=-(BigInt(1)<<BigInt(63)))oe[ee++]=211,$t.setBigInt64(ee,y);else if(y<BigInt(1)<<BigInt(64)&&y>0)oe[ee++]=207,$t.setBigUint64(ee,y);else if(this.largeBigIntToFloat)oe[ee++]=203,$t.setFloat64(ee,Number(y));else throw new RangeError(y+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ee+=8}else if(T==="undefined")this.encodeUndefinedAsNil?oe[ee++]=192:(oe[ee++]=212,oe[ee++]=0,oe[ee++]=0);else if(T==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},M=this.useRecords===!1?this.variableMapSize?y=>{let T=Object.keys(y),E=T.length;E<16?oe[ee++]=128|E:E<65536?(oe[ee++]=222,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=223,$t.setUint32(ee,E),ee+=4);let C;for(let L=0;L<E;L++)S(C=T[L]),S(y[C])}:(y,T)=>{oe[ee++]=222;let E=ee-n;ee+=2;let C=0;for(let L in y)(T||y.hasOwnProperty(L))&&(S(L),S(y[L]),C++);oe[E+++n]=C>>8,oe[E+n]=C&255}:y=>{let T=Object.keys(y),E,C=o.transitions||(o.transitions=Object.create(null)),L=0;for(let N=0,H=T.length;N<H;N++){let j=T[N];E=C[j],E||(E=C[j]=Object.create(null),L++),C=E}let R=C[Hc];if(R)R>=96&&p?(oe[ee++]=((R-=96)&31)+96,oe[ee++]=R>>5):oe[ee++]=R;else{R=o.nextId,R||(R=64),R<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(R=o.nextOwnId,R<x||(R=g),o.nextOwnId=R+1):(R>=x&&(R=g),o.nextId=R+1);let N=T.highByte=R>=96&&p?R-96>>5:-1;C[Hc]=R,o[R-64]=T,R<g?(T.isShared=!0,o.sharedLength=R-63,s=!0,N>=0?(oe[ee++]=(R&31)+96,oe[ee++]=N):oe[ee++]=R):(N>=0?(oe[ee++]=213,oe[ee++]=114,oe[ee++]=(R&31)+96,oe[ee++]=N):(oe[ee++]=212,oe[ee++]=114,oe[ee++]=R),L&&(w+=b*L),v.length>=m&&(v.shift()[Hc]=0),v.push(C),S(T))}for(let N=0,H=T.length;N<H;N++)S(y[T[N]])},_=y=>{let T;if(y>16777216){if(y-n>Jw)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(Jw,Math.round(Math.max((y-n)*(y>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(y-n<<2,oe.length-1)>>12)+1<<12;let E=new _g(T);return $t=new DataView(E.buffer,0,T),oe.copy?oe.copy(E,0,n,y):E.set(oe.slice(n,y)),ee-=n,n=0,gi=E.length-10,oe=E}}useBuffer(e){oe=e,$t=new DataView(oe.buffer,oe.byteOffset,oe.byteLength),ee=0}};Tg=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Vc];Fd=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=e(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=e(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:i,targetView:s,position:o}=e(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=e(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){let n=Array.from(r),{target:i,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),t(n)}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),t([r.source,r.flags])}},{pack(r,e){this.structuredClone?$w(r,16,e):eS(Ud?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==tS&&this.structuredClone?$w(r,Mg.indexOf(t.name),e):eS(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function $w(r,e,t,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=t(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=t(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=t(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=e,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function eS(r,e){let t=r.byteLength;var n,i;if(t<256){var{target:n,position:i}=e(t+2);n[i++]=196,n[i++]=t}else if(t<65536){var{target:n,position:i}=e(t+3);n[i++]=197,n[i++]=t>>8,n[i++]=t&255}else{var{target:n,position:i,targetView:s}=e(t+5);n[i++]=198,s.setUint32(i,t),i+=4}n.set(r,i)}function cB(r,e,t,n){let i=r.length;switch(i){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:i<256?(e[t++]=199,e[t++]=i):i<65536?(e[t++]=200,e[t++]=i>>8,e[t++]=i&255):(e[t++]=201,e[t++]=i>>24,e[t++]=i>>16&255,e[t++]=i>>8&255,e[t++]=i&255)}return e[t++]=n,e.set(r,t),t+=i,t}function hB(r,e){let t,n=e.length*6,i=r.length-n;for(e.sort((s,o)=>s.offset>o.offset?1:-1);t=e.pop();){let s=t.offset,o=t.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function Ao(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");Tg.unshift(r.Class),Fd.unshift(r)}Zw(r)}var nS=new So({useRecords:!1}),uB=nS.pack,dB=nS.pack;var{NEVER:fB,ALWAYS:pB,DECIMAL_ROUND:mB,DECIMAL_FIT:gB}=Bd,rS=512,yB=1024;var iS=new So({structuredClone:!0});Ao({Class:_r.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,_r.prototype),r}});Ao({Class:Ht.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Ht.prototype),r}});Ao({Class:Tr.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Tr.prototype),r}});Ao({Class:Gc.prototype.constructor,type:4,write(r){return r.id},read(r){return new Gc(r)}});Ao({Class:kc.prototype.constructor,type:5,write(r){return r.data},read(r){return new kc(r)}});function vB(r){var e=0;if(r.length===0)return e;for(let t=0;t<r.length;t++){let n=r[t];e=(e<<5)-e+n,e=e&e}return e}function Eg(r){if(Ad(r))return r;if(Array.isArray(r))return r.map(Eg);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=Eg(r[t]);return Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else return r}var zd;(n=>{function r(i){return iS.pack(i)}n.serialize=r;function e(i){return iS.unpack(i)}n.deserialize=e;function t(i){return vB(r(Eg(i))).toString()}n.checksum=t})(zd||(zd={}));var Gd;(t=>{t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(n){return t.all.includes(n)}t.is=e})(Gd||(Gd={}));var kd;(t=>{function r(n){return e(n)}t.defaultData=r;function e(n){if(n==="PointLight")return{type:n,color:On.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5,helper:!0};if(n==="SpotLight")return{type:n,color:On.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,helper:!0,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:On.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,helper:!0,shadowRadius:1};throw new Error("not implemented")}})(kd||(kd={}));var Cg;(t=>{t.defaultData={castShadow:!0,receiveShadow:!0};function e(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}t.equals=e})(Cg||(Cg={}));var Dg;(t=>{t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}t.equals=e})(Dg||(Dg={}));var Vd;(e=>e.defaultData={...Dg.defaultData,...Cg.defaultData,cloner:null,booleanExclude:null})(Vd||(Vd={}));var Pg=(i=>(i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.Center=3]="Center",i[i.Justify=4]="Justify",i))(Pg||{}),Ig=(n=>(n[n.Top=1]="Top",n[n.Center=2]="Center",n[n.Bottom=3]="Bottom",n))(Ig||{}),Lg=(n=>(n[n.None=1]="None",n[n.Upper=2]="Upper",n[n.Lower=3]="Lower",n))(Lg||{}),Hd;(e=>e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:On.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(Hd||(Hd={}));var sS=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"];var Ka;(n=>{function r(i,s){return i==="light"&&s?e(s):t(i)}n.defaultData=r;function e(i){switch(i){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:dn.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...dn.fromHex(6710886),a:1},colorB:{...dn.fromHex(6710886),a:1},colorC:{...dn.fromHex(16777215),a:1},colorD:{...dn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:On.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:On.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:On.fromHexAndA(0,1),contourColor:On.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(Ka||(Ka={}));var qr;(a=>{function r(l){return!l.layers.some(h=>{if(h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")return!0})&&!t(l)}a.isMergable=r;function e(l){let c="";return l.layers.forEach(h=>{Object.entries(h.data).forEach(([u,d])=>{c+=`${u}${d}`,Array.isArray(d)?d.forEach(f=>c+=`${f}`):typeof d=="object"?Object.values(d).forEach(f=>{typeof f=="number"?c+=`${f.toFixed(4)}`:c+=`${f}`}):c+=`${d}`})}),c}a.getHash=e;function t(l){let c=0;for(let h of l.layers)"alpha"in h.data&&h.data.type!=="light"&&h.data.type!=="fresnel"&&(c+=(1-c)*h.data.alpha);return c<1}a.isTransparent=t;function n(){return{layers:new Ht}}a.defaultEmptyData=n;function i(l="layer1",c="layer2"){return s("phong",l,c)}a.defaultData=i;function s(l,c="layer1",h="layer2"){let u=new Ht;return u.push({fi:0,data:Ka.defaultData("light",l),id:c}),u.push({fi:1,data:Ka.defaultData("color"),id:h}),{layers:u}}a.defaultTwoLayerData=s;function o(l,c="basic",h="layer1",u="layer2"){let d=Ka.defaultData("texture");Object.assign(d.texture,{image:l});let f=new Ht;return f.push({fi:0,data:d,id:h}),f.push({fi:1,data:Ka.defaultData("light",c),id:u}),{layers:f}}a.defaultTwoLayerTextureData=o})(qr||(qr={}));var Za;(e=>{function r(){return{points:new Ht,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=r})(Za||(Za={}));var Wd;(e=>{function r(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=r})(Wd||(Wd={}));var Wc;(e=>{function r(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="VectorGeometry")return{width:1,height:1,type:t,subdivisions:12,shape:Za.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="BooleanGeometry")return{type:t,operation:2,width:0,height:0,depth:0,phongAngle:35};throw new Error("not implemented")}e.defaultData=r})(Wc||(Wc={}));var jc;(i=>{i.identity={...vd.identity,hiddenMatrix:di.identity};function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=e;function t(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=t;function n(s,o){return{position:on.isEqual(s.position,o.position)?null:o.position,rotation:on.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:on.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:di.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=n})(jc||(jc={}));var qi;(e=>e.defaultData={states:new Ht,events:new Ht,visible:!0,raycastLock:!1,...jc.identity})(qi||(qi={}));var oS;(e=>e.defaultData={type:"Empty",...qi.defaultData})(oS||(oS={}));var jd;(e=>e.defaultData={type:"Mesh",...qi.defaultData,...Vd.defaultData})(jd||(jd={}));var aS;(e=>e.defaultData={type:"TextFrame",...qi.defaultData,...Hd.defaultData})(aS||(aS={}));var qd;(e=>e.defaultData={...qi.defaultData,...jc.identity,...bo.defaultData})(qd||(qd={}));var lS;(e=>{function r(t){return{...qi.defaultData,...kd.defaultData(t)}}e.defaultData=r})(lS||(lS={}));var cS;(n=>(n.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:di.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new Ht,events:new Ht,...bo.defaultData},n.defaultMeshObject={name:"Rectangle",...qi.defaultData,...jd.defaultData,geometry:Wc.defaultData("RectangleGeometry"),material:qr.defaultTwoLayerData("basic","layer1","layer2")},n.defaultBooleanObject={name:"Boolean",...qi.defaultData,...jd.defaultData,geometry:Wc.defaultData("BooleanGeometry"),material:qr.defaultTwoLayerData("phong","layer1","layer2")}))(cS||(cS={}));var qc;(t=>{function r(n,i){if(i===void 0)return n;let s={...n};return"material"in s&&"material"in i&&i.material&&(s.material=pg(s.material,o=>{if(typeof o!="string")for(let[a,l]of Object.entries(i.material.layers)){let c=o.layers.data(a);c&&xo(c,l)}}).data),s.materials&&i.materials&&(s.materials=pg(s.materials,o=>{for(let a=0;a<s.materials.length;a++){let l=i.materials[a];if(typeof l!="string")for(let[c,h]of Object.entries(l.layers)){let u=o[a]?.layers?.data(c);u&&xo(u,h)}}}).data),s}t.patchMaterialState=r;function e(n,i){if(i===void 0)return n;let s={...n};if(Object.assign(s,jc.merge(s,i)),Ds.is(n.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let o=i;o.orthographic?.zoom!==void 0&&(s.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(s.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(s.targetOffset=o.targetOffset)}else if(n.type==="Mesh")s.geometry={...s.geometry},Object.assign(s.geometry,i.geometry),s=r(s,i);else if(Gd.is(n.type)){let o=i;s.intensity!==void 0&&(s.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?s.color=o.color:s.color=dn.clone(o.color))}return s}t.patch=e})(qc||(qc={}));function uS(r,e=!1){let t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Ie,c=0;for(let h=0;h<r.length;++h){let u=r[h],d=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in u.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(u.attributes[f]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in u.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(u.morphAttributes[f])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(u.userData),e){let f;if(t)f=u.index.count;else if(u.attributes.position!==void 0)f=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,f,h),c+=f}}if(t){let h=0,u=[];for(let d=0;d<r.length;++d){let f=r[d].index;for(let m=0;m<f.count;++m)u.push(f.getX(m)+h);h+=r[d].attributes.position.count}l.setIndex(u)}for(let h in s){let u=hS(s[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(let h in o){let u=o[h][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let d=0;d<u;++d){let f=[];for(let p=0;p<o[h].length;++p)f.push(o[h][p][d]);let m=hS(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}return l}function hS(r){let e,t,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=l.array.length}let s=new e(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new Xe(s,t,n)}var Ng={type:"change"},dS={type:"changeZoom"},xB={type:"changePan"},Ja={type:"start"},Xc={type:"end"},Rg=new Xt,bB=new B,wB=2*Math.PI,SB=1e-8,AB=.01,fS=2,Bg=.125,pS=2,Og=1,Fg=1,Ug=.1;var Xd=class extends Rt{constructor(t,n){super();this.object=t;this.domElement=n;this.enabled=!0;this.useKeyEvents=!0;this.enableDamping=!1;this.enableZoom=!0;this.enableRotate=!0;this.enablePan=!0;this.autoRotate=!1;this.rotationLimitsMode=0;this.panLimitsMode=0;this.rotationSoftLimit=2;this.panSoftLimit=2;this.hoverRotatePanMode=0;this.zoomLimitsEnabled=!1;this.preventScroll=!0;this.mouseButtons=[0,5];this.mouseButtonsPlay=[3,4,5];this.touches=[null,cr.DOLLY_ROTATE,cr.PAN];this.offset=new A;this.eye=new A;this.lastPosition=new A;this.lastQuaternion=new Xt;this.current=new B;this.overShoot=new B;this.overRatio=new B;this.spherical=new wc;this.sphericalDelta=new wc;this.panOffset=new A;this.panLeftV=new A;this.panUpV=new A;this.panV=new A;this.rotateStart=new B;this.rotateEnd=new B;this.rotateDelta=new B;this.panStart=new B;this.panEnd=new B;this.panDelta=new B;this.dollyStart=new B;this.dollyEnd=new B;this.dollyDelta=new B;this.rotationRangeFactor=new B;this.panRangeFactor=new B;this.state=-1;this.zoomChanged=!1;this.isPointerDown=!1;this.isFirstHover=!0;this.isThetaFlipped=!1;this.prevScale=0;this.scale=1;this.gesture=!1;this.timer=-1;this.timerHover=-1;this.minDistance=0;this.maxDistance=1/0;this.minZoom=0;this.maxZoom=1/0;this.minPhi=0;this.maxPhi=Math.PI;this.minTheta=-1/0;this.maxTheta=1/0;this.minH=0;this.maxH=Math.PI;this.minV=-1/0;this.maxV=1/0;this.autoRotateClockwise=!0;this.isPanOverShoot=!1;this.isRotateOverShoot=!1;this.update=()=>{let t=this.object.position;this.offset.copy(t).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(Rg.copy(this.object.quaternion).invert()),this.panOffset.applyQuaternion(Rg),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(this.object.quaternion),this.panOffset.applyQuaternion(this.object.quaternion)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-Bg),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),t.copy(this.target).add(this.offset);let n=this.spherical.phi%wB;return this.eye.copy(this.offset).normalize(),this.object.up.copy(ct.DefaultUp).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),n>0&&n>Math.PI||n<0&&n>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0?(this.sphericalDelta.theta*=1-Bg,this.sphericalDelta.phi*=1-Bg):this.sphericalDelta.set(0,0,0),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>AB||8*(1-this.lastQuaternion.dot(this.object.quaternion))>SB?(this.dispatchEvent(Ng),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)};this.onPointerDown=t=>{this.enabled!==!1&&(this.isPointerDown=!0,ft.length===0&&(this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)),_B(t),t.pointerType==="touch"?this.onPointerDownTouch(t):this.onPointerDownMouse(t))};this.onPointerMove=t=>{this.enabled!==!1&&(t.pointerType==="touch"?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t))};this.onPointerUp=t=>{gS(t),this.isPointerDown=!1,ft.length===0&&(this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)),this.dispatchEvent(Xc),this.state=-1};this.onPointerCancel=t=>{gS(t)};this.onPointerDownMouse=t=>{let n;switch(this.useKeyEvents?n=this.mouseButtons[t.button]:n=this.mouseButtonsPlay[t.button],n){case 0:if(t.altKey===!0&&!t.shiftKey&&!Fc(t)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(Fc(t)||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(Fc(t)||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Ja)};this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}};this.onPointerDownTouch=t=>{switch(yS(t),this.touches[ft.length-1]){case cr.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case cr.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case cr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case cr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Ja)};this.onPointerMoveTouch=t=>{switch(yS(t),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}};this.dispatchEndDebounced=Nc(()=>this.dispatchEvent(Xc),33);this.onMouseWheel=t=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||((this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth||this.preventScroll)&&t.preventDefault(),this.dispatchEvent(Ja),this.handleMouseWheel(t),this.dispatchEndDebounced())};this.onGesture=t=>{if(this.enabled!==!1)if(t.preventDefault(),t.type==="gesturechange"){if(this.enableZoom===!1)return;this.dispatchEvent(Ja),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update()}else this.dispatchEvent(Xc)};this.onContextMenu=t=>{this.enabled!==!1&&t.preventDefault()};this.onTouchMove=t=>{(t.touches.length>1||this.preventScroll)&&t.preventDefault()};this.onTouchEnd=t=>{t.preventDefault()};this.onKeyDown=t=>{this.enabled!==!1&&(this.key=t.key)};this.onKeyUp=()=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&this.onPointerUp(ft[0]))};this.onPointerHover=t=>{if(!(yd||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot)){if(window.clearTimeout(this.timerHover),this.isPointerDown=!0,this.isFirstHover){let n={clientX:window.innerWidth/2,clientY:window.innerHeight/2};this.hoverRotatePanMode===2?this.handleMouseDownPan(n):this.hoverRotatePanMode===1&&this.handleMouseDownRotate(n),this.isFirstHover=!1}this.hoverRotatePanMode===2?this.handleMouseMovePan(t,Ug):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(t,Ug),this.timerHover=window.setTimeout(()=>{this.isPointerDown=!1},30)}};this.object=t,this.domElement=n,this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.connect(),this.update()}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ng),this.isFirstHover=!0,this.update(),this.state=-1}resetTo(t,n,i){this.target.copy(t),this.object.position.copy(n),this.object.zoom=i,this.object.updateProjectionMatrix(),this.dispatchEvent(Ng),this.update(),this.state=-1}fromJSON(t){this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.isFirstHover=!0,this.hoverRotatePanMode!==0&&this.domElement.addEventListener("pointermove",this.onPointerHover),Ug=(t.hoverRotatePanStrength/100)**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/t.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,fS=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let i=this.object.getTarget().applyQuaternion(Rg.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+i.y,this.maxV=t.panVerticalOffset.max+i.y,this.minH=-t.panHorizontalOffset.min+i.x,this.maxH=t.panHorizontalOffset.max+i.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=Ls(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=Ls(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=Ls(this.spherical.theta-t.rotationHorizontalOffset.min),this.maxTheta=Ls(this.spherical.theta+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,this.preventScroll=t.preventScroll,t.orbitTouches===1&&(this.touches[0]=cr.ROTATE),t.panTouches===1&&(this.touches[0]=cr.PAN),t.orbitTouches===2&&(this.touches[1]=cr.DOLLY_ROTATE),t.panTouches===2&&(this.touches[1]=cr.DOLLY_PAN),t.orbitTouches===3&&(this.touches[2]=cr.ROTATE),t.panTouches===3&&(this.touches[2]=cr.PAN)}connect(){this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),Cs||(this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture)),this.domElement.addEventListener("touchmove",this.onTouchMove),this.domElement.addEventListener("touchend",this.onTouchEnd)}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),Cs||(this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture)),this.domElement.removeEventListener("touchmove",this.onTouchMove),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,n,i,s,o,a,l,c){this.overShoot.set(0,0);let h,u,d;t instanceof A?(h=t.x,u=t.y,this.current.set(this.target.x,this.target.y),d=!0):(h=t.theta,u=t.phi,this.current.set(Ls(this.spherical.theta),Ls(this.spherical.phi)),d=!1),i===0&&(this.current.x+=h,this.current.y+=u),(n===3||n===2)&&(!d&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x),s===o&&(h=0)),(n===3||n===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<l&&(this.overShoot.y=l-this.current.y),a===l&&(u=0)),d||(this.overShoot.x=Ls(this.overShoot.x),this.overShoot.y=Ls(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(c),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=mS(Math.abs(this.overRatio.x)),this.overRatio.y=mS(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9||this.overRatio.y>.9)?this.isPointerDown=!1:(h*this.overShoot.x<0&&(h*=1-this.overRatio.x),u*this.overShoot.y<0&&(u*=1-this.overRatio.y)):i===2&&(!d&&(this.overRatio.x>.002||this.overRatio.y>.002)||d&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(h=this.overShoot.x*.05,u=this.overShoot.y*.05,d?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):d?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(h+=this.overShoot.x,u+=this.overShoot.y),t instanceof A?(t.x=h,t.y=u):(t.theta=h,t.phi=u)}setEnableDampingSpeed(t){this.enableDamping=t,Og=t===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*fS}getZoomScale(){return Math.pow(.95,pS)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,n){this.panLeftV.setFromMatrixColumn(n,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,n){this.panUpV.setFromMatrixColumn(n,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,n){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrix),this.panUp(2*n*o/i.clientHeight,this.object.matrix)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this.panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix));this.dispatchEvent(xB)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(dS)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(dS)}zoomOut(t=this.getZoomScale()){this.dispatchEvent(Ja),this.dollyOut(t),this.dispatchEvent(Xc)}zoomIn(t=this.getZoomScale()){this.dispatchEvent(Ja),this.dollyIn(t),this.dispatchEvent(Xc)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,n=1){this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Og*n).rotateAround(bB,-this.object.angleOffsetFromUp);let i=this.domElement;this.rotateLeft(2*Math.PI*this.rotateDelta.x/i.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/i.clientHeight),this.rotateStart.copy(this.rotateEnd),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,n=1){this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(Fg*n),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd),this.update()}handleMouseWheel(t){if(Dw===!1&&Fc(t)===!1&&MB(t)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(Fg),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1)return;t.deltaY===0?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if(ft.length===2){let t=.5*(ft[0].pageX+ft[1].pageX),n=.5*(ft[0].pageY+ft[1].pageY);this.rotateStart.set(t,n)}else this.rotateStart.set(ft[0].pageX,ft[0].pageY)}handleTouchStartPan(){if(ft.length===2){let t=.5*(ft[0].pageX+ft[1].pageX),n=.5*(ft[0].pageY+ft[1].pageY);this.panStart.set(t,n)}else this.panStart.set(ft[0].pageX,ft[0].pageY)}handleTouchStartDolly(){let t=ft[0].pageX-ft[1].pageX,n=ft[0].pageY-ft[1].pageY,i=Math.sqrt(t*t+n*n);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(ft.length===2){let i=zg(t),s=.5*(t.pageX+i.x),o=.5*(t.pageY+i.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==ft[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Og);let n=this.domElement;n&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/n.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/n.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(ft.length===2){let n=zg(t),i=.5*(t.pageX+n.x),s=.5*(t.pageY+n.y);this.panEnd.set(i,s)}else{if(t.pointerId!==ft[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(Fg),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let n=zg(t),i=t.pageX-n.x,s=t.pageY-n.y,o=Math.sqrt(i*i+s*s);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,pS)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}};function Ls(r){let e=Math.PI*2;for(;r<=-Math.PI;)r+=e;for(;r>Math.PI;)r-=e;return r}function mS(r){return 1-Math.pow(1-r,4)}function MB(r){return r.wheelDeltaY===0||r.deltaY===0?Oc&&r.shiftKey&&Math.abs(r.wheelDeltaX)>=120?!1:r.wheelDeltaX?r.wheelDeltaX===-3*r.deltaX:r.deltaMode===0:r.wheelDeltaY?r.wheelDeltaY===-3*r.deltaY:r.deltaMode===0}var ft=[],Yd={};function _B(r){ft.push(r)}function gS(r){delete Yd[r.pointerId];for(let e=0;e<ft.length;e++)if(ft[e].pointerId===r.pointerId){ft.splice(e,1);return}}function yS(r){let e=Yd[r.pointerId];e===void 0&&(e=new B,Yd[r.pointerId]=e),e.set(r.pageX,r.pageY)}function zg(r){let e=r.pointerId===ft[0].pointerId?ft[1]:ft[0];return Yd[e.pointerId]}var Ns=class extends Eu{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,n=[]){return e.forEach(i=>{i.visible&&this.intersectObject(i,t,n)}),n}createRaycastLineHelper(){let e=new Jn({color:65280,linewidth:10}),t=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new A().addVectors(t,n.multiplyScalar(i)),o=new Ie;return o.setFromPoints([t,s]),new so(o,e)}};var xS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},r.parameters),n=t.width/2,i=t.radiusTop??n,s=t.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:h,cornerRadius:u,cornerSegments:d,hollow:f}=r.parameters,m;return u||f?m=new Yc(c,h,n,i,s,o,a,l*Math.PI/180,u,u,d,f):m=new ao(c,h,n,i,s,o,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:{...r,type:"CylinderGeometry"}})}};function Rs(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function vS(r){return new B(r.y,-r.x)}var Yc=class extends Ie{constructor(e,t,n,i,s,o,a,l,c,h,u,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,h=0);let m=[],p=[],g=[],x=[],v=0,w=n/2,b=new A,S=new A;f&&e==0&&(e=c),f&&t==0&&(t=h);let M=new B(e,w),_=new B(t,-w),y=null,T=null,E=null,C=null,L=M.clone().sub(_),R=0,N=0,H=0;d>0&&(R=Math.min(e,t)*(1-d),N=e-R,H=t-R);let j=M.clone();j.x-=R;let K=Math.PI-L.angle(),Y=L.angle(),z=Math.tan(Y/2),F=Math.tan(K/2),V=z+F,O=d?V:F,G=d?V:z;if(c=Math.min(c,(e-N)/O,L.length()/V),h=Math.min(h,(t-H)/G,L.length()/V),c>0){let te=c/z;y=M.clone().sub(new B(te,c)),d&&(E=y.clone(),E.x-=R-V*c),M.sub(L.clone().setLength(te))}if(h>0){let te=h/F;T=_.clone().sub(new B(te,-h)),_.add(L.clone().setLength(te)),d&&(C=T.clone(),C.x-=R-V*h,j.sub(L.clone().setLength(te)))}L=M.clone().sub(_);let W=L.length()<.5,X=[];for(let te=0;te<=i;te++){let k=[],le=te/i,ce=le*l+a,ae=new B(Math.sin(ce),Math.cos(ce));C&&T?(q(k,le,ae,K,h,C,-1,!0),q(k,le,ae,Y,h,T,-1,!1)):T?(se(k,ae,T.x,0,-1),q(k,le,ae,Y,h,T,-1,!1)):o||se(k,ae,t,H,-1);let de=vS(L).normalize();if(Rs(de,ae,b),!W)for(let ge=0;ge<=s;ge++){let fe=ge/s,Ee=L.clone().multiplyScalar(fe).add(_);Rs(Ee,ae,S),p.push(S.x,S.y,S.z),g.push(b.x,b.y,b.z),x.push(le,.5+S.y/n),k.push(v++)}if(E&&y?(q(k,le,ae,K,c,y,1,!1),q(k,le,ae,Y,c,E,1,!0)):y?(q(k,le,ae,K,c,y,1,!1),se(k,ae,y.x,0,1)):o||se(k,ae,e,N,1),d&&!W){let ge=vS(L).multiplyScalar(-1).normalize();Rs(ge,ae,b);for(let fe=0;fe<=s;fe++){let Ee=fe/s,De=L.clone().multiplyScalar(-Ee).add(j);Rs(De,ae,S),p.push(S.x,S.y,S.z),g.push(b.x,b.y,b.z),x.push(le,.5+S.y/n),k.push(v++)}}d&&!o&&k.push(k[0]),X.push(k)}for(let te=0;te<X.length-1;te++)for(let k=0;k<X[0].length-1;k++){if(o&&d&&k==s)continue;let le=X[te][k],ce=X[te+1][k],ae=X[te+1][k+1],de=X[te][k+1],ge=p[ae*3+0],fe=p[ae*3+2];m.push(le,ce,de),(ge!=0||fe!=0)&&m.push(ce,ae,de)}l<Math.PI*2&&(Z(-1,X[0],a),Z(1,X[X.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Se(p,3)),this.setAttribute("normal",new Se(g,3)),this.setAttribute("uv",new Se(x,2));function q(te,k,le,ce,ae,de,ge,fe){for(let Ee=0;Ee<u+1;Ee++){let De=Ee/u,ye=ge<0?De:1-De;fe&&(ye-=1),ye*=ce;let Re=new B(Math.sin(ye),Math.cos(ye)*ge),mt=Re.clone().multiplyScalar(ae).add(de);Rs(mt,le,S),p.push(S.x,S.y,S.z),Rs(Re,le,b),g.push(b.x,b.y,b.z),x.push(k,.5+S.y/n),te.push(v++)}}function se(te,k,le,ce,ae){let de=new A,ge=new B,fe=[le,ce];ae<0&&fe.reverse();for(let Ee of fe)ge.set(Ee,w*ae),Rs(ge,k,de),p.push(de.x,de.y,de.z),g.push(0,ae,0),x.push(.5,.5),te.push(v++)}function Z(te,k,le){let ce=new B(Math.sin(le),Math.cos(le)),ae=new B(-Math.cos(le),Math.sin(le)),de=new A,ge=te<0?(De,ye,Re)=>m.push(De,ye,Re):(De,ye,Re)=>m.push(De,Re,ye),fe=new B((e+t+N+H)/4,0);Rs(fe,ce,de),p.push(de.x,de.y,de.z),g.push(ae.x,0,ae.y),x.push(.5,.5);let Ee=v++;for(let De of k){let ye=p.slice(De*3,De*3+3);p.push(...ye),g.push(ae.x,0,ae.y);let Re=x.slice(De*2,De*2+2);x.push(...Re),v++}for(let De=Ee+1;De<v-1;De++)ge(Ee,De,De+1);ge(Ee,v-1,Ee+1)}}};var bS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:h,cornerSegments:u}=r.parameters,d;return c>0||h>0||l<360?d=new Yc(0,e/2,n,i,s,o,a,l*Math.PI/180,c,h,u,0,!0):d=new la(e/2,n,i,s,o),d.scale(1,1,t/e),Object.assign(d,{userData:{...r,type:"ConeGeometry"}})}};var wS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,c;return a==0?c=new Zn(e,t,n,i,s,o):c=new Vg(e,t,n,i,s,o,a,l),Object.assign(c,{userData:{...r,type:"CubeGeometry"}})}},kg=Math.PI/2,Vg=class extends Ie{constructor(e=1,t=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let c=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,e/2,t/2,n/2);let h=[],u=[],d=[],f=[],m=0,p=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,s,4),g("x","y","z",-1,-1,e,t,-n,i,s,5),a>0&&(x("z","y","x",-1,-1,1,n,t,e,o,0),x("z","y","x",1,-1,-1,n,t,e,o,1),x("z","y","x",-1,1,-1,n,t,e,o,1),x("z","y","x",1,1,1,n,t,e,o,0),x("x","y","z",-1,-1,-1,e,t,n,i,0),x("x","y","z",1,-1,1,e,t,n,i,1),x("x","y","z",-1,1,1,e,t,n,i,0),x("x","y","z",1,1,-1,e,t,n,i,1),x("y","x","z",-1,-1,1,t,e,n,s,0),x("y","x","z",1,-1,-1,t,e,n,s,1),x("y","x","z",1,1,1,t,e,n,s,1),x("y","x","z",-1,1,-1,t,e,n,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new Se(u,3)),this.setAttribute("normal",new Se(d,3)),this.setAttribute("uv",new Se(f,2));function g(w,b,S,M,_,y,T,E,C,L,R){let N=(y-2*a)/C,H=(T-2*a)/L,j=y/2-a,K=T/2-a,Y=E/2,z=C+1,F=L+1,V=0,O=0,G=new A;for(let W=0;W<F;W++){let X=W*H-K;for(let q=0;q<z;q++){let se=q*N-j;G[w]=se*M,G[b]=X*_,G[S]=Y,u.push(G.x,G.y,G.z),G[w]=0,G[b]=0,G[S]=E>0?1:-1,d.push(G.x,G.y,G.z),f.push(q/C),f.push(1-W/L),V+=1}}for(let W=0;W<L;W++)for(let X=0;X<C;X++){let q=m+X+z*W,se=m+X+z*(W+1),Z=m+(X+1)+z*(W+1),te=m+(X+1)+z*W;h.push(q,se,te),h.push(se,Z,te),O+=6}c.addGroup(p,O,R),p+=O,m+=V}function x(w,b,S,M,_,y,T,E,C,L,R){let N=(T-2*a)/L,H=T/2-a,j=E/2-a,K=C/2,Y=L+1,z=0,F=0,V=new A,O=new A;for(let G=0;G<l+1;G++){let W=G/l*kg,X=Math.sin(W)*a,q=(1-Math.cos(W))*a,se=Math.sin(W),Z=Math.cos(W);V[b]=(j+X)*_,V[S]=(K-q)*y,O[w]=0,O[b]=se*Math.sign(V[b]),O[S]=Z*Math.sign(V[S]);for(let te=0;te<Y;te++){let k=te*N-H;V[w]=k*M,u.push(V.x,V.y,V.z),d.push(O.x,O.y,O.z),f.push(te/L),f.push(0),z+=1}}for(let G=0;G<l;G++)for(let W=0;W<L;W++){let X=m+W+Y*G,q=m+W+Y*(G+1),se=m+(W+1)+Y*(G+1),Z=m+(W+1)+Y*G;h.push(X,q,Z),h.push(q,se,Z),F+=6}c.addGroup(p,F,R),p+=F,m+=z}function v(w,b,S){let M=new A,_=new A(e/2,t/2,n/2);_.subScalar(a);let y=[],T=w*b*S>0?(C,L,R)=>h.push(C,L,R):(C,L,R)=>h.push(C,R,L);for(let C=0;C<=l;C++){let L=[],R=kg*(1-C/l),N=Math.cos(R),H=Math.sin(R),j=0;for(let K=0;K<=C;K++){let Y=Math.cos(j),z=Math.sin(j);M.x=N*Y,M.y=H,M.z=N*z;let F=_.clone().addScaledVector(M,a);u.push(w*F.x,b*F.y,S*F.z),d.push(w*M.x,b*M.y,S*M.z),f.push(0,0),L.push(m++),j+=kg/C}y.push(L)}let E=y.length-1;for(let C=0;C<E;C++){let L=y[C],R=y[C+1],N=L.length-1;T(L[0],R[1],R[0]);for(let H=1;H<=N;H++)T(L[H-1],L[H],R[H]),T(L[H],R[H+1],R[H])}}}};var Bs=class extends Ie{constructor(e=[],t=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];h(),u(),this.setAttribute("position",new Se(a,3)),this.setAttribute("normal",new Se(c,3)),this.setAttribute("uv",new Se(l,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],m=new A,p=m.clone(),g=new Kn,x=s*i,v=i-x,w=o+1,b=new A,S=(z,F)=>b.subVectors(z,F).normalize(),M=(z,F)=>Array(z).fill(void 0).map(F),_=M(e.length/3,(z,F)=>new A().fromArray(e,F*3).setLength(i)),y=[],T=1e6;for(let z=0;z<_.length;z++){let F=_[z],V=[],O,G,W,X=1e10,q=-1;for(;(q=t.indexOf(z,q+1))!=-1;){let k=q-q%3;O=t[k+(q+1)%3],G=t[k+(q+2)%3],W=F.distanceToSquared(_[O]),X=Math.min(X,W),V.push([O,G,W])}X+=1e-6;let se=[],Z=0,te=V.length;for(let k=0;k<te;k++){[O,G,W]=V[Z];let le=y[O]?.includes(z)==!0;W<=X&&se.push(O+ +le*T),Z=V.findIndex(ce=>ce[0]==G)}y.push(se)}let E=[];{let z=0,F=0,V,O,G=f==3;for(let W=0;W<=o;W++){V=W*(W+1)/2,O=(W+1)*(W+2)/2;for(let X=0;X<o-W;X++)[z,F]=[V+X+W+2,O+X+W+3],E.push(V,O,...G?[F,V]:[z,O],F,z),[V,O]=[z,F];E.push(V,O,V+o+2)}}let C=m.clone(),L=m.clone(),R=m.clone(),N=m.clone(),H=m.clone(),j=[],K=M(_.length,()=>M(f,()=>m.clone()));for(let z=0;z<_.length;z++){m.copy(_[z]).normalize(),C.copy(m).multiplyScalar(v);let F=y[z];for(let se=0;se<F.length;se++){let Z=F[se],te=F[(se+1)%f];g.setFromPointsAndIndices(_,z,Z%T,te%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,K[z][se])}let V=[],O=[],G=[],W=new A;o==0&&[...K[z]].reduce((se,Z)=>se.add(Z),W).multiplyScalar(1/f);for(let se=0;se<f;se++){let Z=[],te=(se-1+f)%f,k=K[z][te],le=K[z][se];m.copy(k).sub(C),p.copy(le).sub(C);let ce=C.angleTo(m),ae=m.angleTo(p),de=Math.cos(ce)*x;o==0?L.copy(W):L.copy(C).setLength(v+de),O.push(de);let ge=[L,k,le];for(let fe=0;fe<2;fe++){let Ee=ge[fe],De=ge[fe+1];N.subVectors(Ee,C),H.subVectors(De,C),R.crossVectors(N,H).normalize();for(let ye=0;ye<w;ye++){let Re=[ce,ae][fe]*ye/w;m.copy(N).applyAxisAngle(R,Re).add(C),V.push(m.clone()),fe&&(S(m,C),Z.push([ye==0?Ee:m.clone(),b.clone()]))}fe&&(S(De,C),Z.push([De,b.clone()]))}G.push(Z)}j.push(G);let X=2*w,q=2;for(let se=0;se<f;se++){let Z=X*se,te=X*((se+1)%f),k=[V[Z]];for(let ce=1;ce<w;ce++){N=V[Z+ce],H=V[te+ce],k.push(N);for(let ae=1,de=ce-q+1;ae<=de;ae++)m.lerpVectors(N,H,ae/(de+1)),m.sub(C).setLength(O[se]).add(C),k.push(m.clone());k.push(H)}for(let ce=0;ce<w;ce++)k.push(V[ce+w+Z]);k.push(V[te+w]);let le=E.map(ce=>k[ce]);a.push(...le.map(ce=>[ce.x,ce.y,ce.z]).flat()),c.push(...le.map(ce=>(S(ce,C),[b.x,b.y,b.z])).flat())}}let Y=[];for(let z=0;z<y.length;z++)for(let F=0;F<f;F++){let V=y[z][F];if(V<T){let O=y[V].findIndex(X=>X%T==z),G=j[z][F],W=j[V][O];for(let X=0;X<w;X++){let q=G[X],se=W[w-X],Z=G[X+1],te=W[w-(X+1)];[q,se,Z,Z,se,te].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),c.push(k[1].x,k[1].y,k[1].z)})}Y.push(G[0][0],W[w][0],G[w][0],W[0][0])}}for(;Y.length;){let z,F,V,O;[z,F]=Y.splice(0,2);let G=[z];for(;z!=F;)G.push(F),V=Y.indexOf(F),O=V%2,F=Y.splice(V-O,2)[1-O];b.subVectors(G[0],G[1]).cross(m.subVectors(G[0],G[2])).normalize();let W=b.dot(G[0])<0;W&&b.negate();for(let X=1;X<=G.length-2;X++)[G[X+ +W],G[X+1-+W],G[0]].forEach(q=>{a.push(q.x,q.y,q.z),c.push(b.x,b.y,b.z)})}}function u(){let d=new A;for(let _=0;_<a.length;_+=3){d.x=a[_+0],d.y=a[_+1],d.z=a[_+2];let y=S(d)/2/Math.PI+.5,T=M(d)/Math.PI+.5;l.push(y,1-T)}let f=new A,m=new A,p=new A,g=new A,x=new B,v=new B,w=new B,b=(_,y,T,E)=>{E<0&&_.x===1&&(l[y]=_.x-1),T.x===0&&T.z===0&&(l[y]=E/2/Math.PI+.5)};for(let _=0,y=0;_<a.length;_+=9,y+=6){f.set(a[_+0],a[_+1],a[_+2]),m.set(a[_+3],a[_+4],a[_+5]),p.set(a[_+6],a[_+7],a[_+8]),x.set(l[y+0],l[y+1]),v.set(l[y+2],l[y+3]),w.set(l[y+4],l[y+5]),g.copy(f).add(m).add(p).divideScalar(3);let T=S(g);b(x,y+0,f,T),b(v,y+2,m,T),b(w,y+4,p,T)}for(let _=0;_<l.length;_+=6){let y=l[_+0],T=l[_+2],E=l[_+4],C=Math.max(y,T,E),L=Math.min(y,T,E);C>.9&&L<.1&&(y<.2&&(l[_+0]+=1),T<.2&&(l[_+2]+=1),E<.2&&(l[_+4]+=1))}function S(_){return Math.atan2(_.z,-_.x)}function M(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(e){return new Bs(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};var SS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new Qc(e*.5,s,o):new ha(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},Qc=class extends Bs{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,e,t,n),this.type=l}static fromJSON(e){return new Qc(e.radius,e.corner,e.cornerSides)}};var Kc=1e-12,el=class{constructor(e){this.position=new B;this.startPosition=new B;this.uuid=Ge.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new el(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},tl=class extends el{constructor(t){super(t.position);this.parent=t}copy(t){return super.copy(t),this}clone(){return new tl(this.parent).copy(this)}},Xr=class extends el{constructor(t,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=t,this.controls.push(new tl(this),new tl(this))}static create(t,n){let i=new Xr(t,new B(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(t){let n=this.controls.indexOf(t);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(t,n=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new Xr(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[t,n]}computeNormals(t=new B,n=new B){let[i,s]=this.computeTangents();return i&&s&&(AS(i,t),AS(s,n)),[t,n]}computeTangent(t=new B){let[n,i]=this.computeTangents();return n&&i&&t.copy(n).add(i).normalize(),t}computeNormal(t=new B){let[n,i]=this.computeNormals();return t.copy(n).add(i).normalize(),t}};function AS(r,e=new B){let t=r.length();return e.set(-r.y/t,r.x/t)}var Wg=r=>r,nl=new B,Qd=new B,TB=new B,EB=new B,CB=new B,DB=new B,_S=new A,TS=new A;function ES(r){let e=new B;e.addVectors(r.v0,nl.subVectors(r.v1,r.v0).multiplyScalar(2/3));let t=new B;return t.addVectors(r.v2,Qd.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new $n(r.v0,e,t,r.v2)}function Zc(r,e,t=Number.EPSILON){return Math.abs(r-e)<t}function PB(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function IB(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function jg(r,e,t){let n=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function CS(r,e,t){return MS(r,e)&&MS(e,t)&&Hg(r.position,e.position,t.position)}function Hg(r,e,t){return nl.copy(e).sub(r).cross(Qd.copy(t).sub(r))===0}function DS(r,e,t,n,i){let s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),o=(r.y+e.y)/2,a=(r.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(r.y-e.y)/s,c=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-r.x)/s;return n.set(a+l,o+c),i.set(a-l,o-c),[n,i]}function PS(r,e,t){let n=r.distanceTo(t),i=e.distanceTo(t);return n<i?e:r}function IS(r,e,t,n,i,s){let o=e.x-r.x,a=e.y-r.y,l=t.x-r.x,c=t.y-r.y,h=Math.sqrt((o+l)*(o+l)+(a+c)*(a+c)),u;return jg(e,r,t)>Math.PI&&(h*=-1),Zc(c,a)?u=(a+c)*(n/h-.5)*8/3/(o-l):u=(o+l)*(n/h-.5)*8/3/(c-a),i.set(e.x-u*a,e.y+u*o),s.set(t.x+u*c,t.y-u*l),[i,s]}function qg(r,e){return r.position.equals(r.controls[1].position)&&e.position.equals(e.controls[0].position)}function MS(r,e){return Hg(r.position,r.controls[1].position,e.position)&&Hg(r.position,e.controls[0].position,e.position)}function LS(r,e,t,n,i=.5){let s=nl.subVectors(e,r).multiplyScalar(i).add(r),o=Qd.subVectors(t,e).multiplyScalar(i).add(e),a=TB.subVectors(n,t).multiplyScalar(i).add(t),l=s,c=EB.subVectors(o,s).multiplyScalar(i).add(s),h=CB.subVectors(a,o).multiplyScalar(i).add(o),u=a,d=DB.subVectors(h,c).multiplyScalar(i).add(c);return[r.x,r.y,l.x,l.y,c.x,c.y,d.x,d.y,h.x,h.y,u.x,u.y,n.x,n.y]}function NS(r,e,t=12,n=!0){let i=TS.set(0,0,0),s,o=0,a=[];for(let l=0;l<e.length;l++){let c=Wg(e[l]),h=nl,u=Os(c,t);a.push(u);for(let d=0;d<=u;d++)if(c instanceof $n||c instanceof Vr||c instanceof er){if(c.getPoint(d/u,h),i.set(h.x,h.y,0),s!==void 0&&IB(s,i))continue;s===void 0&&(s=_S),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function RS(r,e,t,n=12,i=!0){let s=TS.set(0,0,0),o=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let c,h=Wg(e[l]),u=nl,d=Os(h,n);a.push(d);for(let f=0;f<=d;f++)if(h instanceof $n||h instanceof Vr||h instanceof er){if(h.getPoint(f/d,u),s.set(u.x,u.y,0),c?.equals(s))continue;c===void 0?c=_S:(r.setXYZ(o,c.x,c.y,c.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),c.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function Xg(r,e=12,t=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(t&&o.roundedCurveCorner!==void 0){let l=Os(o.roundedCurveCorner,e)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Os(o.curveAfter,e)),n.push(a)}return r.length>0&&t&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=Os(r[0].roundedCurveCorner,e)*.5),n}function Os(r,e=12){return r&&r instanceof oo?e*2:r&&(r instanceof er||r instanceof pc)?1:r&&r instanceof oa?e*r.points.length:e}function BS(r,e,t=12,n=!0){let i,s=0;for(let o=0;o<e.length;o++){let a=Wg(e[o]),l=Os(a,t),c=nl;for(let h=0;h<=l;h++)if(a instanceof $n||a instanceof Vr||a instanceof er){if(a.getPoint(h/l,c),i!==void 0&&PB(i,c,Kc))continue;i===void 0&&(i=Qd),i.copy(c),r.push(c.x,c.y),s++}}return Zc(r[0],r[r.length-2],Kc)&&Zc(r[1],r[r.length-1],Kc)&&(r.pop(),r.pop()),n&&s>1&&!(Zc(r[s-1],r[1],Kc)&&Zc(r[s-2],r[0],Kc))&&(r.push(r[0],r[1]),s++),r}var Yg=new B,LB=new B,NB=new B,RB=new B,BB=new B,OB=new B,pt=class extends Gr{constructor(t=100,n=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Rt;this.plane=new kn(new A(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ge.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=t,this._height=n}static createFromState(t,n,i){let s=new pt;return s.isClosed=t.isClosed,s.points=t.points.map(o=>Xr.create(o.id,o.data)),typeof t.roundness=="number"&&(s.roundness=t.roundness),s.shapeHoles=t.shapeHoles.map(o=>pt.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let n=0,i=this.points.length;n<i;n++)this.points[n].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(t){let n=this.points.length,i=this.points.findIndex(s=>s.uuid===t);if(i<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],c=l.points.length-1,h=l.getPointIndexById(t);if(h<0)s+=c;else return h+s}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0)for(let n=0,i=this.shapeHoles.length;n<i;n++){let s=this.shapeHoles[n],o=t-this.points.length;if(o<=s.points.length-1)return s.points[o]}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let n=this.points.indexOf(t);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(t);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...t]}applySize(t,n){t===0&&(t=.001),n===0&&(n=.001),this._width=t,this._height=n}applyScale(t,n){let i=Yg.set(t,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(t,n);this._update(!1)}createPoint(t,n=0,i=Ge.generateUUID()){let s;t instanceof B?s=t:s=new B(t,n);let o=new Xr(i,s);return o.roundness=this.roundness,o}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,n){this.points.splice(n,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===t)return s}for(let n=0,i=this.shapeHoles.length;n<i;n++){let o=this.shapeHoles[n].getPointByUuid(t);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let n=this.points.indexOf(t);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(t){let n=this.points.find(i=>i.uuid===t);n&&this.removePoint(n)}update(t=!0){for(let n=0,i=this.shapeHoles.length;n<i;n++)this.shapeHoles[n].update(!1);this._update(t)}extractShapePointsToBuffer(t,n=12,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return NS(t,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=Xg(this.points,t,!1),this.roundedCurveDivisions=Xg(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,n,i=12){return RS(t,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(t,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),BS(t,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(t,n=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Os(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=t-o;a<0&&(a+=s.reduce((l,c)=>l+c,0));for(let l=0,c=s.length;l<c;l++){let h=s[l];if(a<i+h)return[l,(a-i+1)/h];i+=h}return[0,1]}getCurveT(t,n,i){let s=this.points[t],o=this.points[t>=this.points.length-1?0:t+1],a=this.curveDivisions,l=a[t];if(qg(s,o)){let u=s.position.distanceTo(o.position);return s.position.distanceTo(Yg.set(i.x,i.y))/u}let c=0;for(let u=0;u<t;u++)c+=a[u];return(n-c)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(t,n){qg(n,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,n.curveAfter=i;let s=i.clone();t.roundedCurveBefore=s,n.roundedCurveAfter=s,t.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(t=!0){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i];if(i===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[i-1];this._applyCurveForPoint(o,a)}}let n=this.getLastPoint();if(n?.curveAfter&&(n.curveAfter=void 0),this.isClosed){let i=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(i,s)}if(this.points.length>2){let i=0;for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s],l=this.points[s-1]??this.points[this.points.length-1],c=this.points[s+1]??this.points[0],h=a.roundness,u=l&&c&&CS(l,a,c);if(!a.controlsMoved()&&h>0&&!u){let d=a.curveBefore,f=a.curveAfter;if(d===void 0||f===void 0)continue;let m=a.roundedCurveBefore,p=a.roundedCurveAfter,g=d.getLength(),x=f.getLength(),v=Math.min(h,g*.499),w=Math.min(h,x*.499),b=Math.min(v,w),S=1-b/g,M=b/x,_=d.getPointAt(S,Yg),y=f.getPointAt(M,LB);this._subSplitCurve(d,m,S,_,void 0),this._subSplitCurve(f,p,M,void 0,y);let T;if(this.useCubicForRoundedCorners){let E=jg(_,a.position,y)/2,C=Math.tan(E)*_.distanceTo(a.position),[L,R]=DS(_,y,C,NB,RB),N=PS(L,R,a.position),[H,j]=IS(N,_,y,C,BB,OB);T=new $n(_.clone(),H.clone(),j.clone(),y.clone())}else T=new Vr(_.clone(),a.position.clone(),y.clone());a.roundedCurveCorner=T,this.roundedCurves.splice(s+i,0,T),i++}}}t&&this.eventDispatcher?.dispatchEvent({type:"update"})}_subSplitCurve(t,n,i,s,o){if(t instanceof er)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=t,l=n,c=a.getUtoTmapping(i,0),h=LS(a.v0,a.v1,a.v2,a.v3,c);return s!==void 0&&(l.v0.set(h[0],h[1]),l.v1.set(h[2],h[3]),l.v2.set(h[4],h[5]),l.v3.set(h[6],h[7])),o!==void 0&&(l.v0.set(h[6],h[7]),l.v1.set(h[8],h[9]),l.v2.set(h[10],h[11]),l.v3.set(h[12],h[13])),l}return n}clone(){let t=new pt(this._width,this._height);return t.points=this.points.map(n=>n.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(n=>n.clone()),t}toJSON(){return{points:this.points.reduce((t,n)=>t.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let n=t.points.length/7;for(let i=0;i<n;i++){let s=i*7,o=t.points[s+0],a=t.points[s+1],l=t.points[s+2],c=t.points[s+3],h=t.points[s+4],u=t.points[s+5],d=t.points[s+6],f=new Xr(Ge.generateUUID(),new B(o,a));f.controls[0].position.set(l,c),f.controls[1].position.set(h,u),f.roundness=d,this.points.push(f)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let s=new pt;return s.fromJSON(i),s}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t){let n=(s,o)=>{o instanceof $n&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof Vr&&(s[a]=ES(s[a]));for(a=0,l=s.length;a<l;a++){let u=s[a],d=a>0?s[a-1]:null,f;u instanceof $n?(f=this.createPoint(u.v0),f.controls[1].position.copy(u.v1)):u instanceof er&&(f=this.createPoint(u.v1)),f!==void 0&&(d!==null&&n(f,d),o.push(f))}let c=s[s.length-1],h=!1;return c instanceof $n?c.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(c.v2),h=!0):c instanceof er&&c.v2.equals(o[0].position)&&(h=!0),this.isClosed=h,o};return this.points=i(t.curves),t instanceof Gr&&(this.shapeHoles=t.holes.map(s=>{let o=new pt;return o.fromShape(s),o})),this.update(),this}};var Kg=Math.PI*2;function Qg({x:r,y:e},t,n,i,s){return{x:r*t+i,y:e*n+s}}function FB(r,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+e),o=Math.sin(r+e);return[{x:n-i*t,y:i+n*t},{x:s+o*t,y:o-s*t},{x:s,y:o}]}function OS(r,e,t,n){let i=r*n-e*t<0?-1:1,s=Math.min(1,Math.max(-1,r*t+e*n));return i*Math.acos(s)}function UB(r,e,t,n,i,s,o,a,l,c){let h=Math.pow(i,2),u=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),m=h*u-h*f-u*d;m<0&&(m=0),m/=h*f+u*d,m=Math.sqrt(m)*(l===c?-1:1);let p=m*i/s*a,g=m*-s/i*o,x=p+(r+t)/2,v=g+(e+n)/2,w=(o-p)/i,b=(a-g)/s,S=(-o-p)/i,M=(-a-g)/s,_=OS(1,0,w,b),y=OS(w,b,S,M);return!c&&y>0&&(y-=Kg),c&&y<0&&(y+=Kg),{centerx:x,centery:v,ang1:_,ang2:y}}function FS({px:r,py:e,cx:t,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let c=(r-t)/2,h=(e-n)/2;if(c===0&&h===0)return[];i=Math.abs(i),s=Math.abs(s);let u=Math.pow(c,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);u>1&&(i*=Math.sqrt(u),s*=Math.sqrt(u));let d=UB(r,e,t,n,i,s,c,h,o,a),{ang1:f,ang2:m}=d,{centerx:p,centery:g}=d,x=Math.abs(m)/(Kg/4);Math.abs(1-x)<1e-7&&(x=1);let v=Math.max(Math.ceil(x),1);m/=v;for(let w=0;w<v;w++)l.push(FB(f,m)),f+=m;return l.map(w=>{let{x:b,y:S}=Qg(w[0],i,s,p,g),{x:M,y:_}=Qg(w[1],i,s,p,g),{x:y,y:T}=Qg(w[2],i,s,p,g);return{x1:b,y1:S,x2:M,y2:_,x:y,y:T}})}var Ot;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ot||(Ot={}));var fn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(fn||(fn={}));function Ve(r,e){if(!r)throw e||"Assertion Failed!"}var Ue=function(){function r(){}return r.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},r.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},r.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},r.edgeGoesLeft=function(e){return r.vertLeq(e.Dst,e.Org)},r.edgeGoesRight=function(e){return r.vertLeq(e.Org,e.Dst)},r.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},r.edgeEval=function(e,t,n){Ve(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?i<s?t.t-e.t+(e.t-n.t)*(i/(i+s)):t.t-n.t+(n.t-e.t)*(s/(i+s)):0},r.edgeSign=function(e,t,n){Ve(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?(t.t-n.t)*i+(t.t-e.t)*s:0},r.transEval=function(e,t,n){Ve(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?i<s?t.s-e.s+(e.s-n.s)*(i/(i+s)):t.s-n.s+(n.s-e.s)*(s/(i+s)):0},r.transSign=function(e,t,n){Ve(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?(t.s-n.s)*i+(t.s-e.s)*s:0},r.vertCCW=function(e,t,n){return e.s*(t.t-n.t)+t.s*(n.t-e.t)+n.s*(e.t-t.t)>=0},r.interpolate=function(e,t,n,i){return e=e<0?0:e,n=n<0?0:n,e<=n?n===0?(t+i)/2:t+(i-t)*(e/(e+n)):i+(t-i)*(n/(e+n))},r.intersect=function(e,t,n,i,s){var o,a,l;r.vertLeq(e,t)||(l=e,e=t,t=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.vertLeq(n,t)?r.vertLeq(t,i)?(o=r.edgeEval(e,n,t),a=r.edgeEval(n,t,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,t.s)):(o=r.edgeSign(e,n,t),a=-r.edgeSign(e,i,t),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+t.s)/2,r.transLeq(e,t)||(l=e,e=t,t=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.transLeq(n,t)?r.transLeq(t,i)?(o=r.transEval(e,n,t),a=r.transEval(n,t,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,t.t)):(o=r.transSign(e,n,t),a=-r.transSign(e,i,t),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+t.t)/2},r}(),Jc=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),Kd=function(){function r(e){this.side=e,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),r}(),rl=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return r}(),US=function(){function r(){var e=new rl,t=new Jc,n=new Kd(0),i=new Kd(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=e,this.fHead=t,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(e){var t=new Kd(0),n=new Kd(1);e.Sym.side<e.side&&(e=e.Sym);var i=e.Sym.next;return n.next=i,i.Sym.next=t,t.next=e,e.Sym.next=n,t.Sym=n,t.Onext=t,t.Lnext=n,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,n.Sym=t,n.Onext=n,n.Lnext=t,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,t},r.prototype.splice_=function(e,t){var n=e.Onext,i=t.Onext;n.Sym.Lnext=t,i.Sym.Lnext=e,e.Onext=i,t.Onext=n},r.prototype.makeVertex_=function(e,t,n){var i=e;Ve(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t;var o=t;do o.Org=i,o=o.Onext;while(o!==t)},r.prototype.makeFace_=function(e,t,n){var i=e;Ve(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t,i.trail=null,i.marked=!1,i.inside=n.inside;var o=t;do o.Lface=i,o=o.Lnext;while(o!==t)},r.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,n=e.Sym.next;t.Sym.next=n,n.Sym.next=t},r.prototype.killVertex_=function(e,t){var n=e.anEdge,i=n;do i.Org=t,i=i.Onext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.killFace_=function(e,t){var n=e.anEdge,i=n;do i.Lface=t,i=i.Lnext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var e=new rl,t=new rl,n=new Jc,i=this.makeEdge_(this.eHead);return this.makeVertex_(e,i,this.vHead),this.makeVertex_(t,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(e,t){var n=!1,i=!1;if(e!==t){if(t.Org!==e.Org&&(i=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!i){var s=new rl;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!n){var o=new Jc;this.makeFace_(o,t,e.Lface),e.Lface.anEdge=e}}},r.prototype.delete=function(e){var t=e.Sym,n=!1;if(e.Lface!==e.Rface&&(n=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!n){var i=new Jc;this.makeFace_(i,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},r.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),n=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var i=new rl;return this.makeVertex_(i,n,t.Org),t.Lface=n.Lface=e.Lface,t},r.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),n=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,n),e.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=e.Rface,n.winding=e.winding,n.Sym.winding=e.Sym.winding,n.idx=e.idx,n.Sym.idx=e.Sym.idx,n},r.prototype.connect=function(e,t){var n=!1,i=this.makeEdge_(e),s=i.Sym;if(t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(i,e.Lnext),this.splice_(s,t),i.Org=e.Dst,s.Org=t.Org,i.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!n){var o=new Jc;this.makeFace_(o,i,e.Lface)}return i},r.prototype.zapFace=function(e){var t=e.anEdge,n,i,s,o,a;i=t.Lnext;do n=i,i=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=t);o=e.prev,a=e.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(e){var t=e.anEdge,n=0;do n++,t=t.Lnext;while(t!==e.anEdge);return n},r.prototype.mergeConvexFaces=function(e){var t,n,i,s,o,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(n=t.anEdge,o=n.Org;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(s.Lface),a+l-2<=e&&Ue.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&Ue.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var e=this.fHead,t=this.vHead,n=this.eHead,i,s,o,a,l,c;for(s=e,s=e;(i=s.next)!==e;s=i){Ve(i.prev===s),l=i.anEdge;do Ve(l.Sym!==l),Ve(l.Sym.Sym===l),Ve(l.Lnext.Onext.Sym===l),Ve(l.Onext.Sym.Lnext===l),Ve(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(Ve(i.prev===s&&i.anEdge===null),a=t,a=t;(o=a.next)!==t;a=o){Ve(o.prev===a),l=o.anEdge;do Ve(l.Sym!==l),Ve(l.Sym.Sym===l),Ve(l.Lnext.Onext.Sym===l),Ve(l.Onext.Sym.Lnext===l),Ve(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(Ve(o.prev===a&&o.anEdge===null),c=n,c=n;(l=c.next)!==n;c=l)Ve(l.Sym.next===c.Sym),Ve(l.Sym!==l),Ve(l.Sym.Sym===l),Ve(l.Org!==null),Ve(l.Dst!==null),Ve(l.Lnext.Onext.Sym===l),Ve(l.Onext.Sym.Lnext===l);Ve(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},r}(),zS=function(){function r(){this.handle=null}return r}(),GS=function(){function r(){this.key=null,this.node=0}return r}(),zB=function(){function r(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var n=0;n<e+1;n++)this.nodes[n]=new zS,this.handles[n]=new GS;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e<<1,o<this.size&&this.leq(n[t[o+1].handle].key,n[t[o].handle].key)&&++o,Ve(o<=this.max),s=t[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.floatUp_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e>>1,s=t[o].handle,o===0||this.leq(n[s].key,n[i].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(e){var t,n;if(t=++this.size,t*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new zS;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new GS}return this.freeList===0?n=t:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[t].handle=n,this.handles[n].node=t,this.handles[n].key=e,this.initialized&&this.floatUp_(t),n},r.prototype.extractMin=function(){var e=this.nodes,t=this.handles,n=e[1].handle,i=t[n].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[n].key=null,t[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),i},r.prototype.delete=function(e){var t=this.nodes,n=this.handles,i;Ve(e>=1&&e<=this.max&&n[e].key!==null),i=n[e].node,t[i].handle=t[this.size].handle,n[t[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[t[i>>1].handle].key,n[t[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[e].key=null,n[e].node=this.freeList,this.freeList=e},r}(),Zg=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),kS=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),GB=function(){function r(e,t){this.frame=e,this.leq=t,this.head=new kS,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(e){return this.insertBefore(this.head,e)},r.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},r.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var n=new kS;return n.key=t,n.next=e.next,e.next.prev=n,n.prev=e,e.next=n,n},r.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},r}(),kB=function(){function r(){}return r.regionBelow=function(e){return e.nodeUp.prev.key},r.regionAbove=function(e){return e.nodeUp.next.key},r.debugEvent=function(e){},r.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.edgeLeq=function(e,t,n){var i=e.event,s=t.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?Ue.vertLeq(s.Org,o.Org)?Ue.edgeSign(o.Dst,s.Org,o.Org)<=0:Ue.edgeSign(s.Dst,o.Org,s.Org)>=0:Ue.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return Ue.edgeSign(s.Dst,i,s.Org)>=0;var a=Ue.edgeEval(s.Dst,i,s.Org),l=Ue.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(e,t){t.fixUpperEdge&&Ve(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},r.fixUpperEdge=function(e,t,n){Ve(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=n,n.activeRegion=t},r.topLeftRegion=function(e,t){var n=t.eUp.Org,i;do t=r.regionAbove(t);while(t.eUp.Org===n);if(t.fixUpperEdge){if(i=e.mesh.connect(r.regionBelow(t).eUp.Sym,t.eUp.Lnext),i===null)return null;r.fixUpperEdge(e,t,i),t=r.regionAbove(t)}return t},r.topRightRegion=function(e){var t=e.eUp.Dst;do e=r.regionAbove(e);while(e.eUp.Dst===t);return e},r.addRegionBelow=function(e,t,n){var i=new Zg;return i.eUp=n,i.nodeUp=e.dict.insertBefore(t.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(e,t){switch(e.windingRule){case Ot.ODD:return(t&1)!==0;case Ot.NONZERO:return t!==0;case Ot.POSITIVE:return t>0;case Ot.NEGATIVE:return t<0;case Ot.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(e,t){t.windingNumber=r.regionAbove(t).windingNumber+t.eUp.winding,t.inside=r.isWindingInside(e,t.windingNumber)},r.finishRegion=function(e,t){var n=t.eUp,i=n.Lface;i.inside=t.inside,i.anEdge=n,r.deleteRegion(e,t)},r.finishLeftRegions=function(e,t,n){for(var i,s=null,o=t,a=t.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(e,o);break}i=e.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(e,s,i)}a.Onext!==i&&(e.mesh.splice(i.Oprev,i),e.mesh.splice(a,i)),r.finishRegion(e,o),a=s.eUp,o=s}return a},r.addRightEdges=function(e,t,n,i,s,o){var a,l,c,h,u=!0;c=n;do Ve(Ue.vertLeq(c.Org,c.Dst)),r.addRegionBelow(e,t,c.Sym),c=c.Onext;while(c!==i);for(s===null&&(s=r.regionBelow(t).eUp.Rprev),l=t,h=s;a=r.regionBelow(l),c=a.eUp.Sym,c.Org===h.Org;)c.Onext!==h&&(e.mesh.splice(c.Oprev,c),e.mesh.splice(h.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=r.isWindingInside(e,a.windingNumber),l.dirty=!0,!u&&r.checkForRightSplice(e,l)&&(r.addWinding(c,h),r.deleteRegion(e,l),e.mesh.delete(h)),u=!1,l=a,h=c;l.dirty=!0,Ve(l.windingNumber-c.winding===a.windingNumber),o&&r.walkDirtyRegions(e,l)},r.spliceMergeVertices=function(e,t,n){e.mesh.splice(t,n)},r.vertexWeights=function(e,t,n){var i=Ue.vertL1dist(t,e),s=Ue.vertL1dist(n,e),o=.5*s/(i+s),a=.5*i/(i+s);e.coords[0]+=o*t.coords[0]+a*n.coords[0],e.coords[1]+=o*t.coords[1]+a*n.coords[1],e.coords[2]+=o*t.coords[2]+a*n.coords[2]},r.getIntersectData=function(e,t,n,i,s,o){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,r.vertexWeights(t,n,i),r.vertexWeights(t,s,o)},r.checkForRightSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp;if(Ue.vertLeq(i.Org,s.Org)){if(Ue.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;Ue.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(e.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(e,s.Oprev,i)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(i,s.Oprev),t.dirty=n.dirty=!0)}else{if(Ue.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o;if(Ve(!Ue.vertEq(i.Dst,s.Dst)),Ue.vertLeq(i.Dst,s.Dst)){if(Ue.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,o=e.mesh.splitEdge(i),e.mesh.splice(s.Sym,o),o.Lface.inside=t.inside}else{if(Ue.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;t.dirty=n.dirty=!0,o=e.mesh.splitEdge(s),e.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=t.inside}return!0},r.checkForIntersect=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,c=s.Dst,h,u,d=new rl,f,m;if(Ve(!Ue.vertEq(c,l)),Ve(Ue.edgeSign(l,e.event,o)<=0),Ve(Ue.edgeSign(c,e.event,a)>=0),Ve(o!==e.event&&a!==e.event),Ve(!t.fixUpperEdge&&!n.fixUpperEdge),o===a||(h=Math.min(o.t,l.t),u=Math.max(a.t,c.t),h>u))return!1;if(Ue.vertLeq(o,a)){if(Ue.edgeSign(c,o,a)>0)return!1}else if(Ue.edgeSign(l,a,o)<0)return!1;return r.debugEvent(e),Ue.intersect(l,o,c,a,d),Ve(Math.min(o.t,l.t)<=d.t),Ve(d.t<=Math.max(a.t,c.t)),Ve(Math.min(c.s,l.s)<=d.s),Ve(d.s<=Math.max(a.s,o.s)),Ue.vertLeq(d,e.event)&&(d.s=e.event.s,d.t=e.event.t),f=Ue.vertLeq(o,a)?o:a,Ue.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),Ue.vertEq(d,o)||Ue.vertEq(d,a)?(r.checkForRightSplice(e,t),!1):!Ue.vertEq(l,e.event)&&Ue.edgeSign(l,e.event,d)>=0||!Ue.vertEq(c,e.event)&&Ue.edgeSign(c,e.event,d)<=0?c===e.event?(e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Sym,i),t=r.topLeftRegion(e,t),i=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),n),r.addRightEdges(e,t,i.Oprev,i,i,!0),!0):l===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(i.Lnext,s.Oprev),n=t,t=r.topRightRegion(t),m=r.regionBelow(t).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(e,n,null),r.addRightEdges(e,t,s.Onext,i.Rprev,m,!0),!0):(Ue.edgeSign(l,e.event,d)>=0&&(r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),i.Org.s=e.event.s,i.Org.t=e.event.t),Ue.edgeSign(c,e.event,d)<=0&&(t.dirty=n.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(i.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=e.pq.insert(i.Org),r.getIntersectData(e,i.Org,o,l,a,c),r.regionAbove(t).dirty=t.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(e,t){for(var n=r.regionBelow(t),i,s;;){for(;n.dirty;)t=n,n=r.regionBelow(n);if(!t.dirty&&(n=t,t=r.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,i=t.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(e,t)&&(n.fixUpperEdge?(r.deleteRegion(e,n),e.mesh.delete(s),n=r.regionBelow(t),s=n.eUp):t.fixUpperEdge&&(r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n),i=t.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!t.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===e.event||s.Dst===e.event)){if(r.checkForIntersect(e,t))return}else r.checkForRightSplice(e,t);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n))}},r.connectRightVertex=function(e,t,n){var i,s=n.Onext,o=r.regionBelow(t),a=t.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(e,t),Ue.vertEq(a.Org,e.event)&&(e.mesh.splice(s.Oprev,a),t=r.topLeftRegion(e,t),s=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),o),c=!0),Ue.vertEq(l.Org,e.event)&&(e.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(e,o,null),c=!0),c){r.addRightEdges(e,t,n.Onext,s,s,!0);return}Ue.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=e.mesh.connect(n.Lprev,i),r.addRightEdges(e,t,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(e,t)},r.connectLeftDegenerate=function(e,t,n){var i,s,o,a,l;if(i=t.eUp,Ue.vertEq(i.Org,n)){Ve(!1),r.spliceMergeVertices(e,i,n.anEdge);return}if(!Ue.vertEq(i.Dst,n)){e.mesh.splitEdge(i.Sym),t.fixUpperEdge&&(e.mesh.delete(i.Onext),t.fixUpperEdge=!1),e.mesh.splice(n.anEdge,i),r.sweepEvent(e,n);return}Ve(!1),t=r.topRightRegion(t),l=r.regionBelow(t),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(Ve(s!==o),r.deleteRegion(e,l),e.mesh.delete(o),o=s.Oprev),e.mesh.splice(n.anEdge,o),Ue.edgeGoesLeft(s)||(s=null),r.addRightEdges(e,t,o.Onext,a,s,!0)},r.connectLeftVertex=function(e,t){var n,i,s,o,a,l,c=new Zg;if(c.eUp=t.anEdge.Sym,n=e.dict.search(c).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,Ue.edgeSign(o.Dst,t,o.Org)===0){r.connectLeftDegenerate(e,n,t);return}if(s=Ue.vertLeq(a.Dst,o.Dst)?n:i,n.inside||s.fixUpperEdge){if(s===n)l=e.mesh.connect(t.anEdge.Sym,o.Lnext);else{var h=e.mesh.connect(a.Dnext,t.anEdge);l=h.Sym}s.fixUpperEdge?r.fixUpperEdge(e,s,l):r.computeWinding(e,r.addRegionBelow(e,n,l)),r.sweepEvent(e,t)}else r.addRightEdges(e,n,t.anEdge,t.anEdge,null,!0)}},r.sweepEvent=function(e,t){e.event=t,r.debugEvent(e);for(var n=t.anEdge;n.activeRegion===null;)if(n=n.Onext,n===t.anEdge){r.connectLeftVertex(e,t);return}var i=r.topLeftRegion(e,n.activeRegion);Ve(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(e,s,null);a.Onext===o?r.connectRightVertex(e,i,a):r.addRightEdges(e,i,a.Onext,o,o,!0)},r.addSentinel=function(e,t,n,i){var s=new Zg,o=e.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=t,o.Dst.t=i,e.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},r.initEdgeDict=function(e){e.dict=new GB(e,r.edgeLeq);var t=e.bmax[0]-e.bmin[0],n=e.bmax[1]-e.bmin[1],i=e.bmin[0]-t,s=e.bmax[0]+t,o=e.bmin[1]-n,a=e.bmax[1]+n;r.addSentinel(e,i,s,o),r.addSentinel(e,i,s,a)},r.doneEdgeDict=function(e){for(var t,n=0;(t=e.dict.min().key)!==null;)t.sentinel||(Ve(t.fixUpperEdge),Ve(++n===1)),Ve(t.windingNumber===0),r.deleteRegion(e,t)},r.removeDegenerateEdges=function(e){var t,n,i,s=e.mesh.eHead;for(t=s.next;t!==s;t=n)n=t.next,i=t.Lnext,Ue.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(r.spliceMergeVertices(e,i,t),e.mesh.delete(t),t=i,i=t.Lnext),i.Lnext===t&&(i!==t&&((i===n||i===n.Sym)&&(n=n.next),e.mesh.delete(i)),(t===n||t===n.Sym)&&(n=n.next),e.mesh.delete(t))},r.initPriorityQ=function(e){var t,n,i,s=0;for(i=e.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,t=e.pq=new zB(s,Ue.vertLeq),i=e.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=t.insert(n);return n!==i?!1:(t.init(),!0)},r.donePriorityQ=function(e){e.pq=null},r.removeDegenerateFaces=function(e,t){var n,i,s;for(n=t.fHead.next;n!==t.fHead;n=i)i=n.next,s=n.anEdge,Ve(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),e.mesh.delete(s));return!0},r.computeInterior=function(e,t){t===void 0&&(t=!0);var n,i;if(r.removeDegenerateEdges(e),!r.initPriorityQ(e))return!1;for(r.initEdgeDict(e);(n=e.pq.extractMin())!==null;){for(;i=e.pq.min(),!(i===null||!Ue.vertEq(i,n));)i=e.pq.extractMin(),r.spliceMergeVertices(e,n.anEdge,i.anEdge);r.sweepEvent(e,n)}return e.event=e.dict.min().key.eUp.Org,r.debugEvent(e),r.doneEdgeDict(e),r.donePriorityQ(e),r.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},r}(),VB=function(){function r(){this.mesh=new US,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=Ot.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return r.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},r.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},r.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},r.prototype.computeNormal_=function(e){var t,n,i,s,o,a,l=[0,0,0],c=[0,0,0],h=[0,0,0],u=[0,0,0],d=[0,0,0],f=[null,null,null],m=[null,null,null],p=this.mesh.vHead;t=p.next;for(var g=0;g<3;++g)s=t.coords[g],c[g]=s,m[g]=t,l[g]=s,f[g]=t;for(t=p.next;t!==p;t=t.next)for(var x=0;x<3;++x)s=t.coords[x],s<c[x]&&(c[x]=s,m[x]=t),s>l[x]&&(l[x]=s,f[x]=t);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,n=m[v],i=f[v],h[0]=n.coords[0]-i.coords[0],h[1]=n.coords[1]-i.coords[1],h[2]=n.coords[2]-i.coords[2],t=p.next;t!==p;t=t.next)u[0]=t.coords[0]-i.coords[0],u[1]=t.coords[1]-i.coords[1],u[2]=t.coords[2]-i.coords[2],d[0]=h[1]*u[2]-h[2]*u[1],d[1]=h[2]*u[0]-h[0]*u[2],d[2]=h[0]*u[1]-h[1]*u[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,e[0]=d[0],e[1]=d[1],e[2]=d[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(h)]=1)},r.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,n=this.mesh.vHead,i,s=0,o=e.next;o!==e;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(t=n.next;t!==n;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},r.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],n,i,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),n=this.sUnit,i=this.tUnit;var o=this.longAxis_(t);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=t[o]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,c=e.next;c!==e;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},r.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.prototype.tessellateMonoRegion_=function(e,t){var n,i;if(n=t.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;Ue.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;Ue.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(Ue.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(Ue.edgeGoesLeft(i.Lnext)||Ue.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=e.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(Ue.edgeGoesRight(n.Lprev)||Ue.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=e.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=e.connect(i.Lnext,i),i=s.Sym;return!0},r.prototype.tessellateInterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)if(t=n.next,n.inside&&!this.tessellateMonoRegion_(e,n))return!1;return!0},r.prototype.discardExterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)t=n.next,n.inside||e.zapFace(n)},r.prototype.setWindingNumber_=function(e,t,n){for(var i,s=e.eHead.next;s!==e.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:n?e.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},r.prototype.outputPolymesh_=function(e,t,n,i){var s,o=0,a=0,l;n>3&&e.mergeConvexFaces(n);for(var c=e.vHead.next;c!==e.vHead;c=c.next)c.n=-1;for(var h=e.fHead.next;h!==e.fHead;h=h.next)if(h.n=-1,!!h.inside){s=h.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==h.anEdge);if(l>n)throw"Face vertex greater that support polygon";h.n=o,++o}this.elementCount=o,t===fn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=e.vHead.next;c!==e.vHead;c=c.next)if(c.n!==-1){var u=c.n*i;this.vertices[u+0]=c.coords[0],this.vertices[u+1]=c.coords[1],i>2&&(this.vertices[u+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,h=e.fHead.next;h!==e.fHead;h=h.next)if(!!h.inside){s=h.anEdge,l=0;do{var c=s.Org;this.elements[d++]=c.n,l++,s=s.Lnext}while(s!==h.anEdge);for(var f=l;f<n;++f)this.elements[d++]=-1;if(t===fn.CONNECTED_POLYGONS){s=h.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==h.anEdge);for(var m=l;m<n;++m)this.elements[d++]=-1}}},r.prototype.outputContours_=function(e,t){var n,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,h=0;s=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=0,i=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],t>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==i);this.elements[h++]=s,this.elements[h++]=o,s+=o}},r.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new US),e<2&&(e=2),e>3&&(e=3);for(var n=null,i=0;i<t.length;i+=e)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=t[i+0],n.Org.coords[1]=t[i+1],e>2?n.Org.coords[2]=t[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(e,t,n,i,s,o){if(e===void 0&&(e=Ot.ODD),t===void 0&&(t=fn.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),kB.computeInterior(this,o);var a=this.mesh;return t===fn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),t===fn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,t,n,i),!0},r}();function Mo(r){var e=r.windingRule,t=e===void 0?Ot.ODD:e,n=r.elementType,i=n===void 0?fn.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,c=r.normal,h=c===void 0?[0,0,1]:c,u=r.contours,d=u===void 0?[]:u,f=r.strict,m=f===void 0?!0:f,p=r.debug,g=p===void 0?!1:p;if(!d&&m)throw new Error("Contours can't be empty");if(!!d){var x=new VB;r.edgeCreateCallback&&(x.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(x.vertexIdCallback=r.vertexIdCallback);for(var v=0;v<d.length;v++)x.addContour(l||2,d[v]);return x.tesselate(t,i,o,l,h,m),{vertices:x.vertices,vertexIndices:x.vertexIndices,vertexCount:x.vertexCount,elements:x.elements,elementCount:x.elementCount,mesh:g?x.mesh:void 0}}}var Pq=Ot.ODD,Iq=Ot.NONZERO,Lq=Ot.POSITIVE,Nq=Ot.NEGATIVE,Rq=Ot.ABS_GEQ_TWO,Bq=fn.POLYGONS,Oq=fn.CONNECTED_POLYGONS,Fq=fn.BOUNDARY_CONTOURS;var il=class extends Ie{constructor(t,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=Ot.ODD;this.elementType=fn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=t,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:Ot.ODD,elementType:fn.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,h,u;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,x=s[g+0],v=s[g+1];if(h!==void 0&&x!==h&&(l=!1),u!==void 0&&v!==u&&(c=!1),h=x,u=v,!l&&!c)break}!l&&!c&&(a=Mo({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Xe(new Float32Array(d*3),3),this._normalAttribute=new Xe(new Float32Array(d*3),3),this._uvAttribute=new Xe(new Float32Array(d*2),2),this._indexAttribute=new Xe(new Uint32Array(f*3),1),a){let m=1/0,p=-1/0,g=1/0,x=-1/0;for(let b=0,S=d;b<S;b++){let M=b*2,_=a.vertices[M+0],y=a.vertices[M+1];_<m&&(m=_),_>p&&(p=_),y<g&&(g=y),y>x&&(x=y)}let v=p-m,w=x-g;for(let b=0,S=d;b<S;b++){let M=b*2,_=a.vertices[M+0],y=a.vertices[M+1],T=(_-m)/v,E=(y-g)/w;this._positionAttribute.setXYZ(b,_,y,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,T,E)}for(let b=0,S=f;b<S;b++){let M=b*3,_=a.elements[M+0],y=a.elements[M+1],T=a.elements[M+2];this._indexAttribute.setX(M+0,_),this._indexAttribute.setX(M+1,y),this._indexAttribute.setX(M+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let t=new il(this._shape,this._curveSegments);return t.userData=Lc(this.userData),t}};var Zd=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let n=e*Zd.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*i,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let n=e*Zd.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*e);o+=3*e;let l=new Float32Array(i,o*s,3*e);o+=3*e;let c=new Float32Array(i,o*s,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=c,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let i=this.capacity;for(;t>i;)i*=2;this.realloc(i)}let n=this.size;return this.size=t,n}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},$c=Zd;$c.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Jg=(r,e)=>([t,n])=>(n<t&&(n+=e),(r>=t?r:r+e)<=n),sl=class extends Ie{constructor(t,n,i=0,s=12,o=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=t,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let a=this._shape.extractShapePointsToFlatArray([],s),l=this._shape.shapeHoles.map(_=>{let y=_.extractShapePointsToFlatArray([],s),T=[];for(let E=y.length-1;E>=1;E-=2){let C=y[E-1],L=y[E-0];T.push(C,L)}return T}),c=Mo({windingRule:Ot.ODD,elementType:fn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]}),h=Mo({windingRule:Ot.ODD,elementType:fn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]});if(!c)throw new Error("error generating geometry");let u=c.elementCount;if(h){c.elementCount+=h.elementCount;for(let _=0;_<h.elements.length;_++){let y=h.elements[_],T=_%2===0?c.vertexCount:0;c.elements.push(y+T)}for(let _=0;_<h.vertexIndices.length;_++){let y=h.vertexIndices[_],T=c.vertexCount;c.vertexIndices.push(y+T)}for(let _=0;_<h.vertices.length;_++){let y=h.vertices[_];c.vertices.push(y)}}let d=1/0,f=-1/0,m=1/0,p=-1/0;for(let _=0,y=c.vertexCount;_<y;_++){let T=_*2,E=c.vertices[T+0],C=c.vertices[T+1];E<d&&(d=E),E>f&&(f=E),C<m&&(m=C),C>p&&(p=C)}this._minX=d,this._minY=m,this._width=f-d,this._height=p-m;let g=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new $c(g);let x=[],v=[];for(let _=c.elementCount-1;_>=0;_--){let y=_>=u,T=_*2,E=c.elements[T+0],C=c.elements[T+1],L=E+C,R={start:E,count:C,normals:[],continuous:[],concave:[]},N=E,H=L-1,j=E+1,K=this._shape.roundedCurves.length;do{let V=N-E,O=c.vertices[H*2+0],G=c.vertices[H*2+1],W=c.vertices[N*2+0],X=c.vertices[N*2+1],q=c.vertices[j*2+0],se=c.vertices[j*2+1],Z=W-O,te=X-G,k=Math.sqrt(Z*Z+te*te);Z/=k,te/=k;let le=W-q,ce=X-se,ae=Math.sqrt(le*le+ce*ce);le/=ae,ce/=ae,R.normals[V*2+0]=-ce,R.normals[V*2+1]=le,R.concave[V]=Z*ce-te*le>0;let de=c.vertexIndices[N];if(Array.isArray(de))R.continuous[V]=!1;else{let[ge,fe]=this._shape.getCurveIndexFromVertexId(de-1,!0);if(fe>0&&fe<1)R.continuous[V]=!0;else{let Ee=fe===1?ge+1:ge-1;Ee=(Ee+K)%K;let De=fe===1?0:1,ye=this._shape.roundedCurves[ge].getTangent(fe),Re=this._shape.roundedCurves[Ee].getTangent(De);R.continuous[V]=ye.dot(Re)>.95}}y&&(R.normals[V*2+0]*=-1,R.normals[V*2+1]*=-1),[H,N,j]=[N,j,j+1],j>=L&&(j-=C)}while(j!==E+1);let Y=[];Y.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(E*2,L*2),vertexCount:C,vertexIndices:new Array(C).fill(!0).map((V,O)=>[O,O]),elements:[0,C],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(E*2,L*2)});for(let V=1;V<=this._bevelSegments;V++){let O=V/this._bevelSegments*Math.PI/2,G=(1-Math.cos(O))*this._bevelSize,W=[],X=[],q=[],se=[],Z=0;for(let k=0;k<C;k++){let le=k*2,ce=(k-1+C)%C*2,ae=c.vertices[R.start*2+le+0],de=c.vertices[R.start*2+le+1],ge=-R.normals[ce+0]*G,fe=-R.normals[ce+1]*G,Ee=-R.normals[le+0]*G,De=-R.normals[le+1]*G;if(R.concave[k]||!R.concave[k]&&y){let ye=Math.atan2(fe,ge),Re=Math.atan2(De,Ee);Re>ye&&(Re-=Math.PI*2);let mt=Re-ye;if(R.continuous[k]||y){let P=ye+mt/2,D=Math.cos(P)*G,J=Math.sin(P)*G;W[2*Z+0]=ae+D*(y?-1:1),W[2*Z+1]=de+J*(y?-1:1),se[Z]=k,Z++}else{let P=Math.max(1,Math.floor(s/4*Math.abs(mt)/Math.PI));for(let D=0;D<=P;D++){let J=ye+mt*(D/P),ue=Math.cos(J)*G,pe=Math.sin(J)*G;W[2*Z+0]=ae+ue,W[2*Z+1]=de+pe,se[Z]=k,Z++}}}else W[2*Z+0]=ae+ge,W[2*Z+1]=de+fe,se[Z]=k,X[k]=Z,Z++,W[2*Z+0]=ae,W[2*Z+1]=de,se[Z]=k,Z++,W[2*Z+0]=ae+Ee,W[2*Z+1]=de+De,se[Z]=k,q[k]=Z,Z++}let te=Mo({windingRule:Ot.POSITIVE,elementType:fn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[W],edgeCreateCallback:k=>{let ce=k.Org.idx,ae=se[ce],de=se[(ce+1)%se.length];k.idx=[ae,de],k.Sym.idx=[de,ae]},vertexIdCallback:k=>{let le=k.Lprev.idx;return[le?le[1]:0,k.idx[0]]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!te.vertexCount)break;for(let k=0;k<te.vertexIndices.length;k++){let[le,ce]=te.vertexIndices[k];if(le===ce)continue;let ae=ce;ce<le&&(ae+=C);for(let de=le;de<ae;de++){let ge=de%C,fe=(de+1)%C;if(!R.continuous[ge]||!R.continuous[fe]){te.vertexIndices[k]=[le,ge],te.vertexIndices.splice(k+1,0,[fe,ce]),te.vertices.splice((k+1)*2,0,te.vertices[k*2],te.vertices[k*2+1]);break}}}Y.push({bevelI:V,angle:O,size:G,boundary:te,reverseMap:se,insetPoints:W})}let z=(V,O,G)=>{let W=0,X=V.boundary.vertexIndices.length;for(;W<X&&G(V.boundary.vertexIndices[O]);)O=(O+1)%X,W++;return W},F=x.length;for(let V=1;V<Y.length;V++){let O=Y[V-1],G=Y[V],W=O.boundary.vertexIndices.length,X=G.boundary.vertexIndices.length;if(!W||!X)break;let q=R.concave.length,se=0,Z=Jg(se,C);for(;!O.boundary.vertexIndices.filter(Z).length||!G.boundary.vertexIndices.filter(Z).length;)se++,Z=Jg(se,C);let te=O.boundary.vertexIndices.findIndex(Z),k=G.boundary.vertexIndices.findIndex(Z);do te=(te+1)%W;while(Z(O.boundary.vertexIndices[te]));do k=(k+1)%X;while(Z(G.boundary.vertexIndices[k]));se=(se+1)%C;let le=se,ce=this.buildBevelVert(R,O,(te-1+W)%W),ae=this.buildBevelVert(R,G,(k-1+X)%X),de=ce,ge=ae,fe,Ee,De=!1;do{Z=Jg(se,C);let ye=z(O,te,Z),Re=z(G,k,Z),mt=De;if(De=!1,ye&&!Re){for(let P=0;P<ye;P++)fe=this.buildBevelVert(R,O,(te+P)%W,P/(ye-1)),x.push(de.topN,fe.topP,ge.topN),x.push(fe.bottomP,de.bottomN,ge.bottomN),de=fe;De=!0}else if(!ye&&Re)for(let P=0;P<Re;P++)Ee=this.buildBevelVert(R,G,(k+P)%X,P/(Re-1)),x.push(ge.topN,de.topP,Ee.topP),x.push(de.bottomP,ge.bottomN,Ee.bottomP),ge=Ee;else if(ye&&Re)if(fe=this.buildBevelVert(R,O,te,0),Ee=this.buildBevelVert(R,G,k,0),mt?(x.push(de.topN,Ee.topP,ge.topN),x.push(de.topN,fe.topP,Ee.topP),x.push(Ee.bottomP,de.bottomN,ge.bottomN),x.push(Ee.bottomP,fe.bottomP,de.bottomN)):(x.push(ge.topN,de.topN,fe.topP),x.push(ge.topN,fe.topP,Ee.topP),x.push(fe.bottomP,de.bottomN,ge.bottomN),x.push(fe.bottomP,ge.bottomN,Ee.bottomP)),de=fe,ge=Ee,ye===Re)for(let P=1;P<ye;P++)fe=this.buildBevelVert(R,O,(te+P)%W,P/(ye-1)),Ee=this.buildBevelVert(R,G,(k+P)%X,P/(Re-1)),x.push(de.topN,fe.topP,ge.topN),x.push(ge.topN,fe.topP,Ee.topP),x.push(fe.bottomP,de.bottomN,ge.bottomN),x.push(fe.bottomP,ge.bottomN,Ee.bottomP),de=fe,ge=Ee;else if(ye>Re){let P=ye/Re,D=0;for(let J=1;J<ye;J++)fe=this.buildBevelVert(R,O,(te+J)%W,J/(ye-1)),x.push(de.topN,fe.topP,ge.topN),x.push(fe.bottomP,de.bottomN,ge.bottomN),de=fe,J>(D+1)*P&&(D++,Ee=this.buildBevelVert(R,G,(k+D)%X,D/(Re-1)),x.push(ge.topN,fe.topP,Ee.topP),x.push(fe.bottomP,ge.bottomN,Ee.bottomP),ge=Ee)}else{let P=Re/ye,D=0;for(let J=1;J<Re;J++)Ee=this.buildBevelVert(R,G,(k+J)%X,J/(Re-1)),x.push(ge.topN,fe.topP,Ee.topP),x.push(fe.bottomP,ge.bottomN,Ee.bottomP),ge=Ee,J>(D+1)*P&&(D++,fe=this.buildBevelVert(R,O,(te+D)%W,D/(ye-1)),x.push(de.topN,fe.topP,ge.topN),x.push(fe.bottomP,de.bottomN,ge.bottomN),de=fe)}te=(te+ye)%W,k=(k+Re)%X,se=(se+1)%q}while(se!==le)}{let V=Y[0];for(let O=0,G=V.boundary.vertexCount;O<G;O++){let W=this.buildBevelVert(R,V,O),X=this.buildBevelVert(R,V,(O+1)%G);x.push(X.topP,W.topN,W.bottomN),x.push(X.topP,W.bottomN,X.bottomP)}}if(y){let V=[];for(let O=x.length-1;O>=F+2;O-=3){let G=x[O-2],W=x[O-1],X=x[O-0];V.push(X,W,G)}x.splice(F,x.length-F,...V)}if(y){let V=[];for(let O=Y[Y.length-1].boundary.vertices.length-1;O>=1;O-=2){let G=Y[Y.length-1].boundary.vertices[O-1],W=Y[Y.length-1].boundary.vertices[O-0];V.push(G,W)}v.push(V)}if(!y){let V=Y[Y.length-1],O=Mo({windingRule:Y.length>1?Ot.POSITIVE:Ot.ODD,elementType:fn.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...v]});if(!O)throw new Error("Error generating geometry for surface");l.length===0&&Object.assign(this,{capStartIndex:x.length});for(let G=0;G<O.elementCount*3;G+=3){let W=this.buildSurfaceVert(O,O.elements[G+0]),X=this.buildSurfaceVert(O,O.elements[G+1]),q=this.buildSurfaceVert(O,O.elements[G+2]);x.push(W.top,X.top,q.top),x.push(q.bottom,X.bottom,W.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Xe(Uint32Array.from(x),1),b=new Xe(this._buffer.positions,3),S=new Xe(this._buffer.normals,3),M=new Xe(this._buffer.uvs,2);b.needsUpdate=!0,S.needsUpdate=!0,M.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",S),this.setAttribute("uv",M),this.setIndex(w)}buildSurfaceVert(t,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=t.vertices[n*2+0],o=t.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,c=this._buffer.get(2),h=c*3,u=c*2,d={top:c+0,bottom:c+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=o,this._buffer.positions[h+2]=this._depth,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[u+0]=a,this._buffer.uvs[u+1]=l,this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=o,this._buffer.positions[h+5]=0,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[u+2]=a,this._buffer.uvs[u+3]=l,this.vertexCache[i]=d,d}buildBevelVert(t,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],c,h,u,d;a!==l?(h=a,c=l,d=!1,u=t.continuous[h]&&t.continuous[c]):(c=a,h=(c-1+t.count)%t.count,d=t.concave[c]&&n.bevelI>0,u=t.continuous[c]||d);let f=Math.cos(n.angle),m=Math.sin(n.angle),p=i*2,g=c*2,x=h*2,v=n.boundary.vertices[p+0],w=n.boundary.vertices[p+1],b=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,M=(w-this._minY)/this._height,_=t.normals[g+0],y=t.normals[g+1],T=t.normals[x+0],E=t.normals[x+1];if(d){let H=T-_,j=E-y;_=_+H*(1-s),y=y+j*(1-s);let K=Math.sqrt(_*_+y*y);_/=K,y/=K}let C=this._buffer.get(u?2:4),L=C*3,R=C*2,N={i,fi:c,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[L+0]=v,this._buffer.positions[L+1]=w,this._buffer.positions[L+2]=this._depth-b,this._buffer.normals[L+0]=_*f,this._buffer.normals[L+1]=y*f,this._buffer.normals[L+2]=m,this._buffer.uvs[R+0]=S,this._buffer.uvs[R+1]=M,this._buffer.positions[L+3]=v,this._buffer.positions[L+4]=w,this._buffer.positions[L+5]=b,this._buffer.normals[L+3]=_*f,this._buffer.normals[L+4]=y*f,this._buffer.normals[L+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=S,u||(C+=2,L+=6,R+=4,N.topP=C+0,N.bottomP=C+1,this._buffer.positions[L+0]=v,this._buffer.positions[L+1]=w,this._buffer.positions[L+2]=this._depth-b,this._buffer.normals[L+0]=T*f,this._buffer.normals[L+1]=E*f,this._buffer.normals[L+2]=m,this._buffer.uvs[R+0]=S,this._buffer.uvs[R+1]=M,this._buffer.positions[L+3]=v,this._buffer.positions[L+4]=w,this._buffer.positions[L+5]=b,this._buffer.normals[L+3]=T*f,this._buffer.normals[L+4]=E*f,this._buffer.normals[L+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=S),this.vertexCache[o]=N,N}clone(){let t=new sl(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=Lc(this.userData),t}};var Pn=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??0),o=r.shape??e?.shape,a=o?.roundness??t.roundness;o!==void 0&&(o instanceof pt?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new pt(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update(!1));let l=o??new pt(n,i);return{parameters:Object.assign(t,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:e,extrudeBevelSize:t,extrudeBevelSegments:n,subdivisions:i,roundness:s}=r.parameters;r.shape.roundness=s;let o;return e<=0?o=new il(r.shape,i):o=new sl(r.shape,e,t,i,n),Object.assign(o,{userData:{...r,type:"VectorGeometry"}})}};var HS=Math.PI*2,WS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof pt?r.shape:new pt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,c=r.shape,h=e*.5,u=t*.5,d=HB(c,h,u,i*Math.PI/180,n,s);c.isClosed=!0,c.update();let f=Pn.create({shape:c,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function HB(r,e,t,n,i,s){if(n>=HS)return i>30||i%4===0?(jB(r,e,t,s),Math.round(i/4)):VS(r,n,i,e,t,s);let o={x:0,y:t},a=n+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},c=FS({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?WB(r,o.x,o.y,c,i,e,t,s):VS(r,n,i,e,t,s)}function WB(r,e,t,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(ol(e,t));for(let c=0,h=n.length;c<h;c++){let u=n[c],d=r.points[c],f=ol(u.x,u.y);d.controls[1].position.set(u.x1,u.y1),f.controls[0].position.set(u.x2,u.y2),r.addPoint(f)}return a>0?jS(r,s,o,a):r.addPoint(ol(0,0)),l}function VS(r,e,t,n,i,s){let o=-e/t;for(let a=0;a<=t;a++){let l=o*a,c=Math.sin(l)*n,h=Math.cos(l)*i;r.addPoint(ol(c,h))}return e<HS?s>0?jS(r,n,i,s):r.addPoint(ol(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&qS(r,n,i,s)),1}function jB(r,e,t,n=0,i=0,s=0){let o=.5522847498,a=e*o,l=t*o;r.addPoint(Jd(i-e,s,i-e,s-l,i-e,s+l)),r.addPoint(Jd(i,s+t,i-a,s+t,i+a,s+t)),r.addPoint(Jd(i+e,s,i+e,s+l,i+e,s-l)),r.addPoint(Jd(i,s-t,i+a,s-t,i-a,s-t)),n>0&&qS(r,e,t,n)}function ol(r,e){return new Xr(Ge.generateUUID(),new B(r,e))}function Jd(r,e,t,n,i,s){let o=ol(r,e);return o.controls[0].position.set(t,n),o.controls[1].position.set(i,s),o}function jS(r,e,t,n){XS(r,e,t,n).forEach(s=>r.addPoint(s))}function qS(r,e,t,n){let i=XS(r,e,t,n),s=new pt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function XS(r,e,t,n){let i=n*e/100,s=i*(Math.abs(t)/Math.abs(e)),o=new B(i/e,s/t),a=r.points.map(l=>{let c=l.clone();return c.uuid=Ge.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(o);let c=l.controls[0].position.clone().multiply(o),h=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(h),l.controls[1].position.copy(c)}),a}var YS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??n),s=Math.abs(t.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(t,{width:n,height:i,depth:s,radius:o,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(r){let{width:e,height:t,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:h,cornerSegments:u}=r.parameters,d=new eh(!1,e,t,n,i,s,o,a,l,c,h,u);return Object.assign(d,{userData:{...r,type:"HelixGeometry"}})}},eh=class extends Ie{constructor(e=!0,t=1,n=1,i=1,s=1,o=1,a=1,l=1,c=1,h=1,u=1,d=1){super();let f=e&&o===1;f&&(d=0),u>100&&(u=100);let m=()=>new A,p=new A,g=m(),x=m(),v=m(),w,b,S,M,_,y,T,E,C=m(),L=m(),R=m(),N=m(),H=m(),j=m(),K=m(),Y=m(),z=n-2*l+.001,F=z/o,V=Math.ceil(a*o),O=V+1,G=z/V,W=-z/2,X=h+1,q=2*Math.PI/h,se=Math.PI/2/d,Z=.01,te=Math.min((1-u/100)*l,l-Z),k=l-te,le=0,ce=2,ae=d*ce+ce,de=X*ae/ce,ge=de+X*O,fe=X*(O+ae),[Ee,De,ye]=[3,3,2].map(ve=>Array(fe*ve).fill(0)),Re=[],mt=s-l;function P(ve,U){let xe=Math.PI/2;y=U*G,E=2*Math.PI*(y%F)/F+xe,y+=W,T=Math.sin(E)*mt,_=Math.cos(E)*mt,e?ve.set(_,T,y):ve.set(_,y,T)}P(p,-1e-10),P(g,0),C.copy(p),P(p,1);let D=p.distanceTo(g),J=k+te,ue=D*V+2*J,pe=te,Ce=ue-J;for(let ve=0;ve<=V;ve++){P(x,ve),Y.subVectors(x,C).normalize(),C.copy(x),j.copy(x).setComponent(+e+1,0).normalize(),K.crossVectors(Y,j).normalize();let U=ve===0,xe=ve===V,Me=U?3*Math.PI/2:se,Qe=U?pe:Ce,Ne=U?X:ge,Ke=U?0:fe-X,be=Y.clone().multiplyScalar(U?-k:k).add(x),Ze=Y.clone().multiplyScalar(U?-1:1).normalize();for(let rt=0;rt<X;rt++){let gt=rt*q;if(L.addVectors(p.copy(j).multiplyScalar(l*Math.cos(gt)),g.copy(K).multiplyScalar(l*Math.sin(gt))),R.copy(L).normalize(),U||xe){f||(le=Ke+rt,[0,1,2].forEach(wt=>{Ee[le*3+wt]=be.getComponent(wt),De[le*3+wt]=Ze.getComponent(wt)}),ye[le*2]=+xe,ye[le*2+1]=rt/h),g.copy(R).multiplyScalar(te),v.addVectors(x,g);for(let wt=0;wt<d;wt++){let Qn=wt*se+Me;N.addVectors(p.copy(Y).multiplyScalar(k*Math.sin(Qn)),g.copy(R).multiplyScalar(k*Math.cos(Qn))),H.copy(N).normalize(),g.addVectors(v,N),N.normalize(),le=Ne+wt*X+rt,[0,1,2].forEach(No=>{Ee[le*3+No]=g.getComponent(No),De[le*3+No]=H.getComponent(No)});let Nh=+U+Math.sin(Qn);ye[le*2]=(Qe+k*Nh)/ue,ye[le*2+1]=rt/h}}g.addVectors(x,L),le=de+ve*X+rt,[0,1,2].forEach(wt=>{Ee[le*3+wt]=g.getComponent(wt),De[le*3+wt]=R.getComponent(wt)}),ye[le*2]=(J+ve*D)/ue,ye[le*2+1]=rt/h}}let Fe=O+2*d+ce,re=1,[Be,Le]=f?[re,re+O-1]:[0,Fe-1];for(let ve=Be;ve<=Le-1;ve++){let U=f&&ve===Le-1;for(let xe=0;xe<X-1;xe++)w=ve*X+xe,b=w+1,S=(U?xe:w)+X,M=(U?xe+1:b)+X,ve===0?Re.push(b,M,S):ve===Fe-2?Re.push(w,b,S):Re.push(w,b,S,b,M,S)}this.setIndex(Re),this.setAttribute("position",new Se(Ee,3)),this.setAttribute("normal",new Se(De,3)),this.setAttribute("uv",new Se(ye,2))}};var QS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new th(e*.5,s,o):new ua(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},th=class extends Bs{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,e,t,n),this.type=a}static fromJSON(e){return new th(e.radius,e.corner,e.cornerSides)}};var KS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){(r.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let t=Object.assign({},e?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{points:e,segments:t,verticalSegments:n}=r.parameters,i=new Gr;i.moveTo(e[0].x,e[0].y),i.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new aa(i.extractPoints(n).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var vi=new Oe,$g=new ct,$d=new A,Fs=class extends Rt{constructor(){super(),this.uuid=Ge.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new qt().getNormalMatrix(e);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(e);for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];s.normal.applyMatrix3(t).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return vi.makeRotationX(e),this.applyMatrix4(vi),this}rotateY(e){return vi.makeRotationY(e),this.applyMatrix4(vi),this}rotateZ(e){return vi.makeRotationZ(e),this.applyMatrix4(vi),this}translate(e,t,n){return vi.makeTranslation(e,t,n),this.applyMatrix4(vi),this}scale(e,t,n){return vi.makeScale(e,t,n),this.applyMatrix4(vi),this}lookAt(e){return $g.lookAt(e),$g.updateMatrix(),this.applyMatrix4($g.matrix),this}fromBufferGeometry(e){let t=this,n=e.index!==null?e.index:void 0,i=e.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,c=i.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)t.vertices.push(new A().fromBufferAttribute(s,d)),a!==void 0&&t.colors.push(new Ae().fromBufferAttribute(a,d));function h(d,f,m,p){let g=a===void 0?[]:[t.colors[d].clone(),t.colors[f].clone(),t.colors[m].clone()],x=o===void 0?[]:[new A().fromBufferAttribute(o,d),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,m)],v=new al(d,f,m,x,g,p);t.faces.push(v),l!==void 0&&t.faceVertexUvs[0].push([new B().fromBufferAttribute(l,d),new B().fromBufferAttribute(l,f),new B().fromBufferAttribute(l,m)]),c!==void 0&&t.faceVertexUvs[1].push([new B().fromBufferAttribute(c,d),new B().fromBufferAttribute(c,f),new B().fromBufferAttribute(c,m)])}let u=e.groups;if(u.length>0)for(let d=0;d<u.length;d++){let f=u[d],m=f.start,p=f.count;for(let g=m,x=m+p;g<x;g+=3)n!==void 0?h(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):h(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let d=0;d<n.count;d+=3)h(n.getX(d),n.getX(d+1),n.getX(d+2));else for(let d=0;d<s.count;d+=3)h(d,d+1,d+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($d).negate(),this.translate($d.x,$d.y,$d.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,n=t===0?1:1/t,i=new Oe;return i.set(n,0,0,-n*e.x,0,n,0,-n*e.y,0,0,n,-n*e.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let e=new A,t=new A;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];e.subVectors(l,a),t.subVectors(o,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let n=0,i=this.vertices.length;n<i;n++)t[n]=new A;if(e){let n=new A,i=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],c=this.vertices[a.b],h=this.vertices[a.c];n.subVectors(h,c),i.subVectors(l,c),n.cross(i),t[a.a].add(n),t[a.b].add(n),t[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let n=0,i=this.vertices.length;n<i;n++)t[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(t[s.a]),o[1].copy(t[s.b]),o[2].copy(t[s.c])):(o[0]=t[s.a].clone(),o[1]=t[s.b].clone(),o[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let n=this.faces[e],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let e=new Fs;e.faces=this.faces;for(let t=0,n=this.morphTargets.length;t<n;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,o=this.morphNormals[t].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let c=new A,h={a:new A,b:new A,c:new A};s.push(c),o.push(h)}}let i=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],c=i.vertexNormals[s];l.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}}for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Sn),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Rn),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,n=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let i,s=this.vertices.length,o=this.vertices,a=e.vertices,l=this.faces,c=e.faces,h=this.colors,u=e.colors;t!==void 0&&(i=new qt().getNormalMatrix(t));for(let d=0,f=a.length;d<f;d++){let p=a[d].clone();t!==void 0&&p.applyMatrix4(t),o.push(p)}for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone());for(let d=0,f=c.length;d<f;d++){let m=c[d],p,g,x=m.vertexNormals,v=m.vertexColors,w=new al(m.a+s,m.b+s,m.c+s);w.normal.copy(m.normal),i!==void 0&&w.normal.applyMatrix3(i).normalize();for(let b=0,S=x.length;b<S;b++)p=x[b].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),w.vertexNormals.push(p);w.color.copy(m.color);for(let b=0,S=v.length;b<S;b++)g=v[b],w.vertexColors.push(g.clone());w.materialIndex=m.materialIndex+n,l.push(w)}for(let d=0,f=e.faceVertexUvs.length;d<f;d++){let m=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,g=m.length;p<g;p++){let x=m[p],v=[];for(let w=0,b=x.length;w<b;w++)v.push(x[w].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},n=[],i=[],s=Math.pow(10,e);for(let l=0,c=this.vertices.length;l<c;l++){let h=this.vertices[l],u=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[u]===void 0?(t[u]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[t[u]]}let o=[];for(let l=0,c=this.faces.length;l<c;l++){let h=this.faces[l];h.a=i[h.a],h.b=i[h.b],h.c=i[h.c];let u=[h.a,h.b,h.c];for(let d=0;d<3;d++)if(u[d]===u[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let c=o[l];this.faces.splice(c,1);for(let h=0,u=this.faceVertexUvs.length;h<u;h++)this.faceVertexUvs[h].splice(c,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(e){this.vertices=[];for(let t=0,n=e.length;t<n;t++){let i=e[t];this.vertices.push(new A(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let l=0;l<t;l++)e[l]._id=l;function n(l,c){return l.materialIndex-c.materialIndex}e.sort(n);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===t&&(o=[]),s&&s.length===t&&(a=[]);for(let l=0;l<t;l++){let c=e[l]._id;o&&o.push(i[c]),a&&a.push(s[c])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(e[p]=m[p]);return e}let t=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];t.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],c={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,x=!1,v=this.faceVertexUvs[0][m]!==void 0,w=p.normal.length()>0,b=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,M=p.vertexColors.length>0,_=0;if(_=h(_,0,0),_=h(_,1,g),_=h(_,2,x),_=h(_,3,v),_=h(_,4,w),_=h(_,5,b),_=h(_,6,S),_=h(_,7,M),n.push(_),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let y=this.faceVertexUvs[0][m];n.push(f(y[0]),f(y[1]),f(y[2]))}if(w&&n.push(u(p.normal)),b){let y=p.vertexNormals;n.push(u(y[0]),u(y[1]),u(y[2]))}if(S&&n.push(d(p.color)),M){let y=p.vertexColors;n.push(d(y[0]),d(y[1]),d(y[2]))}}function h(m,p,g){return g?m|1<<p:m&~(1<<p)}function u(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(m.x,m.y,m.z)),s[p]}function d(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function f(m){let p=m.x.toString()+m.y.toString();return c[p]!==void 0||(c[p]=l.length/2,l.push(m.x,m.y)),c[p]}return e.data={},e.data.vertices=t,e.data.normals=i,o.length>0&&(e.data.colors=o),l.length>0&&(e.data.uvs=[l]),e.data.faces=n,e}clone(){return new Fs().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let d=0,f=t.length;d<f;d++)this.vertices.push(t[d].clone());let n=e.colors;for(let d=0,f=n.length;d<f;d++)this.colors.push(n[d].clone());let i=e.faces;for(let d=0,f=i.length;d<f;d++)this.faces.push(i[d].clone());for(let d=0,f=e.faceVertexUvs.length;d<f;d++){let m=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,g=m.length;p<g;p++){let x=m[p],v=[];for(let w=0,b=x.length;w<b;w++){let S=x[w];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let s=e.morphTargets;for(let d=0,f=s.length;d<f;d++){let m={};if(m.name=s[d].name,s[d].vertices!==void 0){m.vertices=[];for(let p=0,g=s[d].vertices.length;p<g;p++)m.vertices.push(s[d].vertices[p].clone())}if(s[d].normals!==void 0){m.normals=[];for(let p=0,g=s[d].normals.length;p<g;p++)m.normals.push(s[d].normals[p].clone())}this.morphTargets.push(m)}let o=e.morphNormals;for(let d=0,f=o.length;d<f;d++){let m={};if(o[d].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[d].vertexNormals.length;p<g;p++){let x=o[d].vertexNormals[p],v={};v.a=x.a.clone(),v.b=x.b.clone(),v.c=x.c.clone(),m.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[d].faceNormals.length;p<g;p++)m.faceNormals.push(o[d].faceNormals[p].clone())}this.morphNormals.push(m)}let a=e.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=e.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let c=e.lineDistances;for(let d=0,f=c.length;d<f;d++)this.lineDistances.push(c[d]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new ey().fromGeometry(this),t=new Ie,n=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",new Xe(n,3).copyVector3sArray(e.vertices)),e.normals.length>0){let i=new Float32Array(e.normals.length*3);t.setAttribute("normal",new Xe(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let i=new Float32Array(e.colors.length*3);t.setAttribute("color",new Xe(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let i=new Float32Array(e.uvs.length*2);t.setAttribute("uv",new Xe(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let i=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",new Xe(i,2).copyVector2sArray(e.uvs2))}t.groups=e.groups;for(let i in e.morphTargets){let s=[],o=e.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let c=o[a],h=new Se(c.data.length*3,3);h.name=c.name,s.push(h.copyVector3sArray(c.data))}t.morphAttributes[i]=s}if(e.skinIndices.length>0){let i=new Se(e.skinIndices.length*4,4);t.setAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){let i=new Se(e.skinWeights.length*4,4);t.setAttribute("skinWeight",i.copyVector4sArray(e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new Ie,n=e.geometry;if(e.isPoints||e.isLine){let i=new Se(n.vertices.length*3,3),s=new Se(n.colors.length*3,3);if(t.setAttribute("position",i.copyVector3sArray(n.vertices)),t.setAttribute("color",s.copyColorsArray(n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Se(n.lineDistances.length,1);t.setAttribute("lineDistance",o.copyArray(n.lineDistances))}n.boundingSphere!==null&&(t.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(t.boundingBox=n.boundingBox.clone())}else e.isMesh&&(t=n.toBufferGeometry());return t}};Fs.prototype.isGeometry=!0;var ey=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],n,i,s,o=e.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,t.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,t.push(n)),this.groups=t}fromGeometry(e){let t=e.faces,n=e.vertices,i=e.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=e.morphTargets,l=a.length,c;if(l>0){c=[];for(let x=0;x<l;x++)c[x]={name:a[x].name,data:[]};this.morphTargets.position=c}let h=e.morphNormals,u=h.length,d;if(u>0){d=[];for(let x=0;x<u;x++)d[x]={name:h[x].name,data:[]};this.morphTargets.normal=d}let f=e.skinIndices,m=e.skinWeights,p=f.length===n.length,g=m.length===n.length;n.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let x=0;x<t.length;x++){let v=t[x];this.vertices.push(n[v.a],n[v.b],n[v.c]);let w=v.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=v.normal;this.normals.push(S,S,S)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=i[0][x];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",x),this.uvs.push(new B,new B,new B))}if(o===!0){let S=i[1][x];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",x),this.uvs2.push(new B,new B,new B))}for(let S=0;S<l;S++){let M=a[S].vertices;c[S].data.push(M[v.a],M[v.b],M[v.c])}for(let S=0;S<u;S++){let M=h[S].vertexNormals[x];d[S].data.push(M.a,M.b,M.c)}p&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},al=class{constructor(e,t,n,i,s,o=0){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Ae,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};var qB=["a","b","c"];function XB(r,e){switch(e){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function ty(r,e,t){let n=Math.min(r,e),i=Math.max(r,e),s=n+"_"+i;return t.get(s)}function ny(r,e,t,n,i,s){let o=Math.min(r,e),a=Math.max(r,e),l=o+"_"+a,c;if(n.has(l))c=n.get(l);else{let h=t[o],u=t[a];c={a:h,b:u,newEdge:null,faces:[]},n.set(l,c)}c.faces.push(i),s[r].edges.push(c),s[e].edges.push(c)}function YB(r,e,t,n){let i,s,o;for(i=0,s=r.length;i<s;i++)t[i]={edges:[]};for(i=0,s=e.length;i<s;i++)o=e[i],ny(o.a,o.b,r,n,o,t),ny(o.b,o.c,r,n,o,t),ny(o.c,o.a,r,n,o,t)}function ef(r,e,t,n,i){r.push(new al(e,t,n,void 0,void 0,i))}function ll(r,e){return Math.abs(e-r)/2+Math.min(r,e)}function tf(r,e,t,n){r.push([e.clone(),t.clone(),n.clone()])}var nf=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Ie?e=new Fs().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new A,n,i,s,o,a,l=e.vertices,c=e.faces,h=e.faceVertexUvs[0],u=h!==void 0&&h.length>0,d=[],f=new Map;YB(l,c,d,f);let m=[],p,g,x,v,w,b,S;for(let Z of Array.from(f.keys())){for(g=f.get(Z),x=new A,w=3/8,b=1/8,S=g.faces.length,S!=2&&(w=.5,b=0,S!=1),x.addVectors(g.a,g.b).multiplyScalar(w),t.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(p=l[XB(v,qB[a])],!(p!==g.a&&p!==g.b));a++);p&&t.add(p)}t.multiplyScalar(b),x.add(t),g.newEdge=m.length,m.push(x)}let M,_,y,T,E,C,L,R=[];for(i=0,s=l.length;i<s;i++){for(C=l[i],E=d[i].edges,n=E.length,n==3?M=3/16:n>3&&(M=3/(8*n)),_=1-n*Number(M),y=M,n<=2&&(n==2?(_=3/4,y=1/8):n==1||n==0),L=C.clone().multiplyScalar(_),t.set(0,0,0),o=0;o<n;o++)T=E[o],p=T.a!==C?T.a:T.b,t.add(p);t.multiplyScalar(Number(y)),L.add(t),R.push(L)}let N=R.concat(m),H=R.length,j,K,Y,z=[],F=[],V,O,G,W,X=new B,q=new B,se=new B;for(i=0,s=c.length;i<s;i++)v=c[i],j=Number(ty(v.a,v.b,f).newEdge)+H,K=Number(ty(v.b,v.c,f).newEdge)+H,Y=Number(ty(v.c,v.a,f).newEdge)+H,ef(z,j,K,Y,v.materialIndex),ef(z,v.a,j,Y,v.materialIndex),ef(z,v.b,K,j,v.materialIndex),ef(z,v.c,Y,K,v.materialIndex),u&&(V=h[i],O=V[0],G=V[1],W=V[2],X.set(ll(O.x,G.x),ll(O.y,G.y)),q.set(ll(G.x,W.x),ll(G.y,W.y)),se.set(ll(O.x,W.x),ll(O.y,W.y)),tf(F,X,q,se),tf(F,O,X,se),tf(F,G,q,X),tf(F,W,se,q));e.vertices=N,e.faces=z,u&&(e.faceVertexUvs[0]=F)}};var pn=new A,ZS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=r.geometry??e?.geometry??new Ie().copy(new Zn(100,100,100)),n;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(pn),n={width:pn.x,height:pn.y,depth:pn.z,subdivisions:0}):n=e.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:t}}static build(r){let{width:e,height:t,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new Ie().copy(new Zn(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(pn)):pn.set(o.width,o.height,o.depth),(e!==pn.x||t!==pn.y||n!==pn.z)&&s.scale(pn.x===0?1:e/pn.x,pn.y===0?1:t/pn.y,pn.z===0?1:n/pn.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new nf(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,e,t){new ga(t).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(pn);let o=100/pn.x;Object.assign(s.parameters,{width:100,height:pn.y*o,depth:pn.z*o}),e(this.build(s))})}};var JS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof pt?r.shape:new pt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,c=e*.5,h=t*.5,u=0,d=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let g=f*p,x=u+Math.sin(g)*c,v=d+Math.cos(g)*h;l.addPoint(l.createPoint(x,v))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=i;l.roundness=i,l.update();let m=Pn.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...r,type:"PolygonGeometry"}})}};var $S=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,c=new iy(e*.5,t,i,s,o,a,l);return c.scale(1,1,n/e),Object.assign(c,{userData:{...r,type:"PyramidGeometry"}})}};function nh(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function ry(r,e,t,n,i,s){let o=e.clone().sub(r),a=t.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let c=o.add(a).normalize();s.copy(r).addScaledVector(c,n/Math.sin(l/2))}else{let c=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(c)),s.addScaledVector(a,n/Math.sin(c))}}function QB(r,e,t){let n=r.clone().sub(e),i=t.clone().sub(e);return n.projectOnVector(i),n.add(e)}var iy=class extends Ie{constructor(e=.5,t=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],c=[],h=[],u=[],d=0,f=t/2,m=Math.PI/n,p=e*Math.cos(Math.PI/n),g=2*Math.PI/n,x=(n-2)*Math.PI/n,v=Math.PI-x,w=new A(0,-f,0),b=new A(0,f,0),S=new B(e,-f),M=new B(p,-f),_=new B(0,b.y).sub(M),y=new B(0,b.y).sub(S),T=new B(_.y,-_.x).normalize(),E=new B(y.y,-y.x).normalize(),L=e*Math.cos(Math.PI/n)*Math.tan((Math.PI-_.angle())/2)-1e-8;o=Math.min(o,L);let R;{let F=new A(T.x,T.y,0),V=new A(Math.cos(g)*F.x,F.y,Math.sin(g)*F.x);R=F.angleTo(V)}let N=o/Math.tan((Math.PI-_.angle())/2),H=o/Math.tan((Math.PI-R)/2),j=new A;if(!s){c.push(w.x,w.y,w.z),h.push(0,-1,0),u.push(0,0);let F=d++,V=[],O=S.clone(),G=N/Math.cos(Math.PI/n);O.x-=G;for(let W=0;W<n;W++){let X=W/n*Math.PI*2+m,q=new B(Math.sin(X),Math.cos(X));nh(O,q,j),c.push(j.x,j.y,j.z),h.push(0,-1,0),u.push(0,0),V.push(d++)}for(let W=0;W<V.length;W++)l.push(V[W],F,V[(W+1)%V.length])}let K=[];{let F=new A,V=new A,O=new A,G=new A,W=new A,X=new A;for(let q=0;q<n;q++){let se=q/n*Math.PI*2+m,Z=(q+.5)/n*Math.PI*2+m,te=(q+1)/n*Math.PI*2+m,k=new B(Math.sin(se),Math.cos(se)),le=new B(Math.sin(Z),Math.cos(Z)),ce=new B(Math.sin(te),Math.cos(te));nh(S,k,V),nh(S,ce,O),nh(T,le,F),ry(b,V,O,H,H,G),c.push(G.x,G.y,G.z),ry(V,b,O,H,N,W),c.push(W.x,W.y,W.z),ry(O,V,b,N,H,X),c.push(X.x,X.y,X.z),h.push(F.x,F.y,F.z),h.push(F.x,F.y,F.z),h.push(F.x,F.y,F.z),u.push(0,0),u.push(0,0),u.push(0,0);let ae=d++,de=d++,ge=d++;if(l.push(ae,de,ge),o>0){{let De=V.clone().add(O).multiplyScalar(.5),ye=b.clone().sub(De).normalize(),mt=w.clone().sub(De).normalize().add(ye).normalize().multiplyScalar(-1),P=X.clone().sub(W);Y(De,P,mt,_.angle())}let fe,Ee;{let De=new A;nh(E,ce,De);let ye=X.clone().add(G).multiplyScalar(.5);ye=QB(ye,O,b);let Re=X.clone().sub(G);[fe,Ee]=Y(ye,Re,De,R,G.y)}{let De=fe,ye=De.clone().setY(0).normalize(),Re=new A(0,-1,0),mt=ye.clone().cross(Re);z(De,ye,Re,mt)}K.concat(Ee);{let De=_.angle(),ye=Math.PI-De,Re=b.clone();Re.y-=o/Math.sin(De-Math.PI/2);let mt=new A,P=[];for(let J=0;J<a;J++){let ue=[],pe=Math.PI/2-ye*J/a,Ce=Math.cos(pe),Fe=Math.sin(pe),re=Z;for(let Be=0;Be<=J;Be++){let Le=Math.cos(re),ve=Math.sin(re);F.x=Ce*ve,F.y=Fe,F.z=Ce*Le,mt.copy(Re).addScaledVector(F,o),c.push(mt.x,mt.y,mt.z),h.push(F.x,F.y,F.z),u.push(0,0),ue.push(d++),re+=Math.PI*2/J/n}P.push(ue)}Ee.reverse(),P.push(Ee);let D=P.length-1;for(let J=0;J<D;J++){let ue=P[J],pe=P[J+1],Ce=ue.length-1;l.push(pe[1],ue[0],pe[0]);for(let Fe=1;Fe<=Ce;Fe++)l.push(ue[Fe],ue[Fe-1],pe[Fe]),l.push(pe[Fe+1],ue[Fe],pe[Fe])}}}}}this.setIndex(l),this.setAttribute("position",new Se(c,3)),this.setAttribute("normal",new Se(h,3)),this.setAttribute("uv",new Se(u,2));function Y(F,V,O,G,W){let X=-G/2,q=(Math.PI-G)/2,se=V.clone().normalize().cross(O);F.addScaledVector(O,-o/Math.sin(q));let Z=new A,te=new A,k=1,le=d,ce=[];for(let ae=0;ae<=a;ae++){let de=X+ae/a*G;te.set(0,0,0),te.addScaledVector(se,Math.sin(de)),te.addScaledVector(O,Math.cos(de));for(let ge=0;ge<=k;ge++){let fe=ge/k-.5;if(Z.copy(F),Z.addScaledVector(V,fe),Z.addScaledVector(te,o),W!=null){let Ee=Math.max(0,Z.y-W);Z.addScaledVector(V,-Ee/V.y)}c.push(Z.x,Z.y,Z.z),h.push(te.x,te.y,te.z),u.push(0,0),ge===0&&ce.push(d),d++}}for(let ae=0;ae<a;ae++)for(let de=0;de<k;de++){let ge=le+de+(k+1)*ae,fe=ge+(k+1),Ee=fe+1,De=ge+1;l.push(ge,fe,De),l.push(fe,Ee,De)}return[F.clone().addScaledVector(V,.5),ce]}function z(F,V,O,G){let W=Math.PI/2,X=y.angle()-W,q=[],se=new A,Z=new A;for(let k=0;k<=a;k++){let le=[],ce=k/a;for(let ae=0;ae<=k;ae++){let ge=((k?ae/k:0)-.5)*v,fe=Math.cos(ge),Ee=Math.sin(ge),De=Math.atan(Math.tan(X)*fe),ye=(W+De)*ce,Re=Math.cos(ye),mt=Math.sin(ye);se.set(0,0,0),se.addScaledVector(V,mt*fe),se.addScaledVector(O,Re),se.addScaledVector(G,mt*Ee),Z.copy(F).addScaledVector(se,o),c.push(Z.x,Z.y,Z.z),h.push(se.x,se.y,se.z),u.push(0,0),le.push(d++)}q.push(le)}let te=q.length-1;for(let k=0;k<te;k++){let le=q[k],ce=q[k+1],ae=le.length-1;l.push(le[0],ce[1],ce[0]);for(let de=1;de<=ae;de++)l.push(le[de-1],le[de],ce[de]),l.push(le[de],ce[de+1],ce[de])}}}};var e1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(e?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof pt?r.shape:new pt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)}),ui:n}}static build(r){let e=r.shape,{width:t,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,c={x:t*.5,y:n*.5},h={x:-c.x,y:-c.y},u={x:c.x,y:c.y};function d(b,S,M){return S>t&&M>n?Math.min(b*t/S,b*n/M):S>t?b*t/S:M>n?b*n/M:b}let f=[];f[0]=i[0]===0?0:d(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:d(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:d(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:d(i[3],i[3]+i[0],i[3]+i[2]);let m=h.x,p=u.x,g=u.y,x=h.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(p,g)),e.addPoint(e.createPoint(p,x)),e.addPoint(e.createPoint(m,x)),e.isClosed=!0;let v=!0;for(let b=0,S=e.points.length;b<S;b++)e.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(v=!1);v&&(e.roundness=f[0]),e.useCubicForRoundedCorners=s!==1,e.update();let w=Pn.create({shape:e,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...r,type:"RectangleGeometry"}})}};var t1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e=100,height:t=e,depth:n=e,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:c}=r.parameters,h=new lo(.5*e,i,s,o,a,l,c);return h.scale(1,t/e,n/e),Object.assign(h,{userData:{...r,type:"SphereGeometry"}})}};var n1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:0})}}static build(r){let{width:e=100,height:t=e,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new Gi(e,t,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var r1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new sy(e,t,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},sy=class extends Ie{constructor(e=1,t=1,n=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],h=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-h,i),i*=Math.PI/180;let u=[],d=Math.PI/2,f=(Z=0,te=0,k=0)=>new A(Z,te,k),m=f(),p=f(),[g,x,v]=[t/2,e/2,n/2],w=-x,b=+x,[S,M,_]=[f(w,-g,+v),f(w,-g,-v),f(w,+g,-v)],y=(Z,te=!1)=>Math.sin(Z-Math.PI/(1+ +te)),T=(Z,te=!1)=>Math.cos(Z-Math.PI/(1+ +te));_.y=Math.sin(i)*t-g;let E=Math.cos(i)*t-v,C=S.z-h;i<=d?(_.z=Math.min(E,C),_.z==C&&(_.y-=(E-C)/Math.tan(d-i))):M.z=Math.min(M.z-E-v,S.z-h),m.subVectors(S,M),p.subVectors(_,M);let L=Math.min(m.length(),p.length())*s/100,R=L*Math.tan(i/2),N=L/Math.cos(i/2),H=m.clone().normalize().add(p.normalize()).setLength(N).add(M);m.set(0,y(i,!0),T(i,!0)),u.push([_,m.clone()]);let j=(Math.PI-i)/o;for(let Z=0;Z<=o;Z++){let te=d+i+Z*j;m.set(0,Math.sin(te)*R,Math.cos(te)*R),m.add(H),p.set(0,y(te),T(te)),u.push([m.clone(),p.clone()])}u.push([S,f(0,1,0)]);let K=Math.sin(j/2)*R*2,Y=u.length-1,z=u[0][0].distanceTo(u[1][0]),F=u[Y-1][0].distanceTo(u[Y][0]),V=z+K*o+F;u[0].push(1);for(let Z=0;Z<=o;Z++)u[Z+1].push(1-(z+Z*K)/V);u[Y].push(0);let[O,G,W]=u[0],X,q,se;for(let Z=1;Z<u.length;Z++)[X,q,se]=u[Z],a.push(w,O.y,O.z,w,X.y,X.z,b,O.y,O.z,b,O.y,O.z,w,X.y,X.z,b,X.y,X.z),l.push(0,G.y,G.z,0,q.y,q.z,0,G.y,G.z,0,G.y,G.z,0,q.y,q.z,0,q.y,q.z),c.push(0,W,0,se,1,W,1,W,0,se,1,se),[O,G,W]=[X,q,se];this.setAttribute("position",new Se(a,3)),this.setAttribute("normal",new Se(l,3)),this.setAttribute("uv",new Se(c,2))}};var i1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof pt?r.shape:new pt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=r.parameters,h=r.shape,u=e*.5,d=t*.5,f=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,x=u*n/100,v=d*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let b=0;b<i;b++){let S=p*b,M=f+Math.sin(S)*u,_=m+Math.cos(S)*d;h.addPoint(h.createPoint(M,_))}}else for(let b=0;b<i;b++){let S=f+Math.cos(g)*u,M=m+Math.sin(g)*d;h.addPoint(h.createPoint(S,M)),g+=p,S=f+Math.cos(g)*x,M=m+Math.sin(g)*v,b<=i,h.addPoint(h.createPoint(S,M)),g+=p}h.isClosed=!0;for(let b=0,S=h.points.length;b<S;b++)h.points[b].roundness=s;h.roundness=s,h.update();let w=Pn.create({shape:h,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...r,type:"StarGeometry"}})}};var rf=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t}=r.parameters,n=new Gi(e,t);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var s1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??t.width*.25);return{parameters:Object.assign(t,{width:n,height:i,depth:s})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,c=KB(e,t,n,e*.5,o,s,0,0,i,a,l);return c.scale(1,t/e,1),Object.assign(c,{userData:{...r,type:"TorusGeometry"}})}};function KB(r,e,t,n,i,s,o,a,l,c,h){return[e,t]=[t,e],o=e/2,i/=2*Math.PI,i==1&&(c=0),new eh(!0,r,e,t,n,i,s,o,a,l,c,h)}var o1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),tube:t.tube??t.width*.125})}}static build(r){let{width:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=e*.5;a!==t&&(a-=t);let l=new fa(a,t,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var a1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof pt?r.shape:new pt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e=100,height:t,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.shape,c=e*.5,h=t*.5;a?(l.addPoint(l.createPoint(-c,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))):(l.addPoint(l.createPoint(0,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=n;l.roundness=n,l.update();let u=Pn.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(u,{userData:{...r,type:"TriangleGeometry"}})}};var ZB,sf=new Promise(r=>{ZB=r});var In=class extends Ae{constructor(t,n,i,s){super(t,n,i);this.isColorA=!0;this.a=s}setRGBA(t,n,i,s){super.setRGB(t,n,i),this.a=s}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}};function Ft(r,e){let t;if(typeof r=="string"){let n=e?.getColor(r);n?t=n:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new In(0,0,0,0))}else return"a"in r?new In(r.r,r.g,r.b,r.a):new In(r.r,r.g,r.b,1);return t}var Us=r=>"isEntity"in r,Ut=r=>"isAbstractMesh"in r,bt=r=>r!==null&&r.isBooleanMesh,l1=r=>r.objectType==="CombinedCamera",c1=r=>Us(r)&&(r.objectType==="LightDirectional"||r.objectType==="LightSpot"||r.objectType==="LightPoint");var oy=r=>r.objectType==="EmptyObject",Xi=r=>"objectHelper"in r;function ay(r,e){let t=!1;e.position&&(r.position.fromArray(e.position),t=!0),e.rotation&&(r.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,r.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in r&&(t=!0,r.hiddenMatrix.fromArray(e.hiddenMatrix??di.identity)),t&&(r.updateMatrix(),bt(r.parent)&&Ut(r)&&r.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&r.updateWorldMatrix(!1,!0),r.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(r.isUpVectorFlipped=e.isUpVectorFlipped),r.updateUp())}function JB(r,e){ay(r,e),e.name!==void 0&&(r.name=e.name),e.visible!==void 0&&(r.isEntity?r.visibility=e.visible:r.visible=e.visible)}function h1(r,e,t){JB(r,e),e.color!==void 0&&(r.color=Ft(e.color,t)),e.intensity!==void 0&&(r.intensity=e.intensity),e.shadows!==void 0&&!(r instanceof fo)&&(r.castShadow=e.shadows),r.shadow&&!(r instanceof fo)&&e.depth!==void 0&&(r.shadow.camera.far=e.depth,r.shadow.needsUpdate=!0),e.helper!==void 0&&Xi(r)&&(r.enableHelper=e.helper,r.gizmos.shadowmap.visible=e.helper)}function u1(r,e){r.shadow.camera.right=e/2,r.shadow.camera.left=-e/2,r.shadow.camera.top=e/2,r.shadow.camera.bottom=-e/2,r.shadow.needsUpdate=!0}var cl=new Sn,xi=new A,bi=new A,hl=new Oe,f1=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],$B=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],eO=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function tO(r,e,t=0,n=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let h=t;h<n;h++){let u=e.getX(h),d=e.getY(h),f=e.getZ(h);u<i&&(i=u),d<s&&(s=d),f<o&&(o=f),u>a&&(a=u),d>l&&(l=d),f>c&&(c=f)}return r.min.set(i,s,o),r.max.set(a,l,c),r}var d1=(r,e,t,n)=>{if(Ut(r)){let i=r.geometry.userData.parameters,s=r.geometry.getAttribute("position");r.geometry.userData.type==="SubdivGeometry"?xi.copy(r.originalGeometry.boundingSphere.center):s!==void 0&&(tO(cl,s,r.geometry.drawRange.start,r.geometry.drawRange.count<1/0?r.geometry.drawRange.count:s.count),cl.getCenter(xi)),r.forceComputeSize?cl.getSize(bi).multiplyScalar(.5):bi.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}else if(Xi(r)&&n===!0){let i=r.geometryHelper.getAttribute("position");cl.setFromArray(i.array),cl.getCenter(xi),cl.getSize(bi).multiplyScalar(.5)}else xi.setScalar(0),bi.setScalar(0);hl.copy(e).multiply(r.matrixWorld),bi.x===0&&bi.y===0&&bi.z===0?t.push(new A(xi.x,xi.y,xi.z).applyMatrix4(hl)):f1.forEach(i=>{t.push(i.clone().multiply(bi).add(xi).applyMatrix4(hl))})},rh=class extends Sn{constructor(){super(...arguments);this.matrix=new Oe;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(n=>n.clone()),this.faces=t.faces.map(n=>n.clone()),this.edges=t.edges.map(n=>n.clone()),this.centerEdges=t.centerEdges.map(n=>n.clone()),this}setFromObjectSize(t,n=!1){t.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new Oe().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,n)}expandByObjectSize(t,n,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&d1(o,n,s,t.enableHelper===!0)}):d1(t,n,s,t.enableHelper===!0),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(hl.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(bi).multiplyScalar(.5),this.getCenter(xi),hl.copy(this.matrix).setPosition(xi),this.vertices=f1.map(t=>t.clone().multiply(bi).applyMatrix4(hl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=$B.map(([t,n])=>new Cu(this.vertices[t],this.vertices[n])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=eO.map(([t,n])=>this.vertices[t].clone().add(this.vertices[n]).multiplyScalar(.5))}};var of=r=>class extends r{hasEntityChild(){return this.children.some(t=>Us(t))}isDescendantOf(t){t instanceof ct&&(t=t.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===t)return!0;n=n.parent}return!1}attach(t,n){this.updateWorldMatrix(!0,!1);let i=new Oe().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Us(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),n!==void 0&&(this.children.pop(),this.children.splice(n,0,t)),this}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}};var Cr=r=>"isEntity"in r,p1=r=>"isAbstractMesh"in r,Dr=r=>class extends of(r){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Oe;this._singleBBox=new rh;this._recursiveBBox=new rh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(n){this.visible=n;for(let i of this.children)Cr(i)&&i.traverseEntity(s=>{Xi(s)&&s.visible&&(s.objectHelper.visible=n)})}get visibility(){return this.visible}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(n=>{Cr(n)&&(n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(n=>{n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0})}traverseEntity(n){n(this);for(let i of this.children)Cr(i)&&i.traverseEntity(n)}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}shallowClone(n){return new this.constructor().shallowCopy(this,n)}shallowCopy(n,i=!0){if(super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),i===!0)for(let s of n.children)Cr(s)&&this.add(s.shallowClone());return this}clone(n){return new this.constructor().copy(this,n)}copy(n,i=!0){if(super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),i===!0)for(let s of n.children)Cr(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let n=new Oe,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),n.copy(this.matrixWorld).invert(),n.multiply(i);for(let s of this.children)Cr(s)&&s.hiddenMatrix.premultiply(n)}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ja(i,n)}fromObjectTransformState(n){return n.position&&this.position.fromArray(n.position),n.rotation&&this.rotation.fromArray(n.rotation),n.scale&&this.scale.fromArray(n.scale),n.hiddenMatrix&&this.hiddenMatrix.fromArray(n.hiddenMatrix),this.updateMatrix(),this}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return ja(i,n)}fromState(n,i){return n.name&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.type!=="OrthographicCamera"&&n.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),n.visible!==void 0&&(this.visibility=n.visible),this.fromObjectTransformState(n),this}};var ih=class extends ct{constructor(t,n={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=wd.defaultData(i.toArray(),s),xo(this.parameters,n),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let t of this.children)t.material=this.object.material}refreshClonerMasks(){for(let t of this.children)t.layers.mask=this.object.layers.mask}setHideBase(t){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let n of this.object.material)n.visible=!0;if(t){let n=this.object.material;for(let i of this.children)i.material=n}else for(let n of this.children)n.material=this.object.material}for(let n of this.object.material)n.visible=!t}else{if(this.children.length>0)if(this.object.material.visible=!0,t){let n=this.object.material;for(let i of this.children)i.material=n}else for(let n of this.children)n.material=this.object.material;this.object.material.visible=!t}this.parameters.hideBase=t}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let n=0,i=t-this.children.length;n<i;++n){let s=this.object.shallowClone(!1);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let n=0,i=this.children.length-t;n<i;++n)this.remove(this.children[0])}_updateRadial(t){let n=t.radial,i=n.start*Ge.DEG2RAD,s=n.end*Ge.DEG2RAD,o=i-s,a=new br(n.rotation[0]*Ge.DEG2RAD,n.rotation[1]*Ge.DEG2RAD,n.rotation[2]*Ge.DEG2RAD),l;switch(n.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[c,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=n.scale[0],h.scale.y=n.scale[1],h.scale.z=n.scale[2],h.position.setScalar(0);let u=o/t.count*c-i;switch(n.axis){case"x":h.rotation.set(0,u,0);break;case"y":h.rotation.set(0,0,u);break;case"z":h.rotation.set(u,0,0);break}h.translateOnAxis(l,n.radius),h.position.x+=n.position[0],h.position.y+=n.position[1],h.position.z+=n.position[2],n.alignment===!0?(h.rotation.x+=a.x,h.rotation.y+=a.y,h.rotation.z+=a.z):h.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let n=t.linear,i=new br(n.rotation[0]*Ge.DEG2RAD,n.rotation[1]*Ge.DEG2RAD,n.rotation[2]*Ge.DEG2RAD);for(let[s,o]of this.children.entries())o.hiddenMatrix.identity(),o.scale.x=1+(n.scale[0]-1)*s,o.scale.y=1+(n.scale[1]-1)*s,o.scale.z=1+(n.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=n.position[0]*s,o.position.y=n.position[1]*s,o.position.z=n.position[2]*s}_updateGrid(t){let n=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let h=this.children[n++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=i.size[0]*a-o.x,h.position.y=i.size[1]*l-o.y,h.position.z=i.size[2]*c-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[n++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),xo(this.parameters,t),this.update(),this}};var zt=class{constructor(e,t,n,i){this.next=void 0;this.uniforms={};this.textures={};this.defines={};if(this.id=e,this.uuid=t,n){this.type=n.type;for(let s in n)s!=="type"&&s!=="calpha"&&(this.uniforms[`f${this.id}_${s}`]=n[s]);for(let s in i)this.defines[s]=i[s]}}copy(e){this.id=e.id,this.type=e.type,this.defines={...e.defines};for(let t in e.uniforms)this.getName(t)==="transmissionSamplerMap"||this.getName(t)==="transmissionDepthMap"||this.getName(t)==="normalMap"||this.getName(t)==="depthMap"||(this.uniforms[t]?this.uniforms[t].copy(e.uniforms[t]):this.uniforms[t]=e.uniforms[t].clone());return this}clone(){return new zt(this.id).copy(this)}copyUniforms(e){for(let t in this.uniforms){let n=this.getName(t);n!==void 0&&e.uniforms[`f${e.id}_${n}`]&&n!=="transmissionDepthMap"&&n!=="transmissionSamplerMap"&&this.uniforms[t].copy(e.uniforms[`f${e.id}_${n}`])}return this}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let n=`f${this.id}_${e}`;this.hasValueByKey(n)&&t!==void 0&&(this.uniforms[n].value=t)}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getValues(){let e={type:this.type};for(let t in this.uniforms){let n=this.getName(t);if(n===void 0)continue;let s=this.uniforms[`f${this.id}_${n}`].value;s!==void 0&&(Array.isArray(s)?e[n]=s.map(o=>o.clone?o.clone():o):e[n]=s.clone?s.clone():s)}return e}getName(e){let n=/f\d+_(.*)/.exec(e);if(n&&n.length>1)return n[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let n=this.getName(t);n&&e.push(n)}return e}isEqual(e){for(let t in e.uniforms){let n=e.getName(t);if(!n)return!1;let i=this.getValue(n),s=e.uniforms[t].value;if(s.value instanceof Bt){if(i.image!==s.image)return!1}else if(Array.isArray(s)){let o=i;for(let a=0,l=o.length;a<l;++a)if(o[a]!==s[a])return!1}else{let o=i;if(o.equals){if(!o.equals(s))return!1}else if(i!==s)return!1}}return!0}dispose(){}};function m1(r){let e=r instanceof zt?r.type:r;return e==="texture"||e==="displace_map"||e==="matcap"}var ke=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Ge.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n??{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n??{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t??this.getType(e,t);let i=e.getNodeData(n??this);return e.analyzing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,s,o){return""}generate(e,t,n,i,s){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,n;for(t in this)n=this[t],n instanceof ke&&(e+='"'+t+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)t=this.hashProperties[i],n=this[t],e+='"'+t+'":"'+String(n)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}};var ze=class extends ke{constructor(t,n){super(t);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(t,n,i,s){if(n=n??this.getType(t),this.getShared(t,n)){let o=this.getUnique(t,n);o&&this.uuid===void 0&&(this.uuid=Ge.generateUUID()),i=t.getUUID(i??this.getUUID(),!o);let a=t.getNodeData(i),l=a.output||this.getType(t);if(t.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(t,a,n),this.generate(t,n,i)):super.build(t,n,i);if(o)return a.name=a.name||super.build(t,n,i),a.name;if(!this.getLabel()&&(!this.getShared(t,l)||t.context.ignoreCache||a.deps===1))return super.build(t,n,i);i=this.getUUID(!1);let c=this.getTemp(t,i);if(c)return t.format(c,l,n);{c=super.generate(t,n,i,a.output,s);let h=this.generate(t,l,i);return t.addNodeCode(c+" = "+h+";"),t.format(c,l,n)}}return super.build(t,n,i)}getShared(t,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(t,n){return this.unique}setLabel(t){return this.label=t,this}getLabel(){return this.label}getUUID(t){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(t,n){n=n||this.uuid;let i=t.getVars()[n];return i?i.name:void 0}generate(t,n,i,s,o){return this.getShared(t,n)||console.error("TempNode is not shared"),i=i??this.uuid,t.getTempVar(i,s??this.getType(t),o,this.getLabel()).name}};var Pt=class extends ze{constructor(t,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(t,n);this.readonly=!1}setReadonly(t){return this.readonly=t,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(t,n,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(t,n,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,n))}copy(t){return super.copy(t),this.readonly=t.readonly,this}};var xt=class extends Pt{constructor(t=0,n,i,s){super("c");this.nodeType="Color";this.value=t instanceof In?t:new In(t||0,n,i,s)}setRGBA(t){this.value.setRGBA(t.r,t.g,t.b,t.a)}generate(t,n,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let h=this.alpha.build(t,"f");t.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${h};`)}return c?this.generateReadonly(t,n,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,n))}generateReadonly(t,n,i,s,o,a){return t.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",s,n)}};var _e=class extends Pt{constructor(t){super("f");this.nodeType="Float";this.value=t??0}generateReadonly(t,n,i,s,o,a){return t.format(this.value+(this.value%1?"":".0"),s,n)}copy(t){return super.copy(t),this.value=t.value,this}};var nt=class extends Pt{constructor(t){super("i");this.nodeType="Int";this.value=Math.floor(t??0)}generateReadonly(t,n,i,s,o,a){return t.format(this.value.toString(),s,n)}copy(t){return super.copy(t),this.value=t.value,this}};var zs=class extends Pt{constructor(t){super("b");this.nodeType="Bool";this.value=t??!1}generateReadonly(t,n,i,s){return t.format(this.value?"true":"false",s,n)}copy(t){return super.copy(t),this.value=t.value,this}};var mn=class extends Pt{constructor(t=0,n){super("v2");this.nodeType="Vector2";this.value=t instanceof B?t:new B(t,n)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}generateReadonly(t,n,i,s,o,a){return t.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var Tn=class extends Pt{constructor(t=0,n,i){super("v3");this.nodeType="Vector3";this.value=t instanceof A?t:new A(t,n,i)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}get z(){return this.value.z}set z(t){this.value.z=t}generateReadonly(t,n,i,s,o,a){return t.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var Pr=class extends Pt{constructor(t){super("v4");this.nodeType="Vector4";this.value=t instanceof In?t:new In(t.r,t.g,t.b,t.a)}generateReadonly(t,n,i,s,o,a){return t.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var Yr=class extends Pt{constructor(t=1,n){super("v4[]");this.nodeType="Vector4Array";this.size=t,this.value=Array.isArray(n)?n:n instanceof qe?new Array(t).fill(n):new Array(t).fill(new qe(0))}copy(t){return super.copy(t),this.value=t.value.map(n=>n.clone()),this}};var gn=class extends Pt{constructor(t=1,n){super("f[]");this.nodeType="FloatArray";this.size=t,this.value=Array.isArray(n)?n:typeof n=="number"?new Array(t).fill(n):new Array(t).fill(0)}copy(t){return super.copy(t),this.size=t.size,this.value=[...t.value],this}};var ly=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=n!==void 0?n:!0,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},yn=new ly;var ul=class extends ze{constructor(t){super("v2",{shared:!1});this.nodeType="UV";this.index=t??0}generate(t,n){t.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=t.isShader("vertex")?"uv"+i:"vUv"+i;return t.format(s,this.getType(t),n)}copy(t){return super.copy(t),this.index=t.index,this}};yn.addKeyword("uv",function(){return new ul});yn.addKeyword("uv2",function(){return new ul(1)});var nO=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,g1=/[a-z_0-9]+/gi,Te=class extends ze{constructor(t,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(t,n,i,s)}getShared(t,n){return!this.isMethod}getType(t){return t.getTypeByFormat(this.type)}getInputByName(t){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}}getIncludeByName(t){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===t)return this.includes[n]}}generate(t,n,i,s,o){let a,l=0,c=this.src;if(this.includes)for(let u=0;u<this.includes.length;u++)t.include(this.includes[u],this);for(let u in this.extensions)t.extensions[u]=!0;let h=[];for(;a=g1.exec(this.src);)h.push(a);for(let u=0;u<h.length;u++){let d=h[u],f=d[0],m=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&m&&yn.containsKeyword(f)){let g=this.keywords[f];if(!g){let x=yn.getKeywordData(f);x.cache&&(g=t.keywords[f]),g=g||yn.getKeyword(f,t),x.cache&&(t.keywords[f]=g)}p=g.build(t)}f!==p&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+p+c.substring(d.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&yn.contains(p)&&t.include(yn.get(p))}return n==="source"?c:this.isMethod?(this.isInterface||t.include(this,void 0,c),this.name):t.format("( "+c+" )",this.getType(t),n)}parse(t,n,i,s){if(this.src=t||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=nO.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(g1);if(a){let l=0;for(;l<a.length;){let c=a[l++],h;c==="in"||c==="out"||c==="inout"?h=a[l++]:(h=c,c="");let u=a[l++];this.inputs.push({name:u,type:h,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(t){return super.copy(t),this.isMethod=t.isMethod,this.useKeywords=t.useKeywords,t.type!==void 0&&(this.type=t.type),this.parse(t.src,t.includes,t.extensions,t.keywords),this}};var _o=class extends ze{constructor(t=new ke,n){super("v4");this.nodeType="ColorSpace";this.factor=new ke;this.input=t,this.method=n??_o.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(t){switch(t){case lr:return["Linear"];case We:return["sRGB"];default:return[]}}generate(t,n){let i=this.input.build(t,"v4"),s=this.getType(t),o=_o.Nodes[this.method],a=t.include(o);if(a===_o.LINEAR_TO_LINEAR)return t.format(i,s,n);if(o.inputs?.length===2){let l=this.factor.build(t,"f");return t.format(a+"( "+i+", "+l+" )",s,n)}else return t.format(a+"( "+i+" )",s,n)}fromEncoding(t){let n=_o.getEncodingComponents(t);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(t){let n=_o.getEncodingComponents(t);this.method=n[0]+"ToLinear",this.factor=n[1]}copy(t){return super.copy(t),this.input.copy(t.input),this.method=t.method,this.factor.copy(t.factor),this}},Yn=_o;Yn.Nodes={LinearToLinear:new Te(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3137
|
+
}`;function mD(r,e,t){let n=new fc,i=new B,s=new B,o=new qe,a=new xu({depthPacking:S_}),l=new bu,c={},h=t.maxTextureSize,u={0:wn,1:zi,2:hn},d=new dt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new B},radius:{value:4}},vertexShader:fD,fragmentShader:pD}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new Le;m.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new Vt(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Bu,this.render=function(b,S,M){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let _=r.getRenderTarget(),y=r.getActiveCubeFace(),T=r.getActiveMipmapLevel(),E=r.state;E.setBlending(Ct),E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);for(let C=0,I=b.length;C<I;C++){let R=b[C],N=R.shadow;if(N===void 0){console.warn("THREE.WebGLShadowMap:",R,"has no shadow.");continue}if(N.autoUpdate===!1&&N.needsUpdate===!1)continue;i.copy(N.mapSize);let H=N.getFrameExtents();if(i.multiply(H),s.copy(N.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/H.x),i.x=s.x*H.x,N.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/H.y),i.y=s.y*H.y,N.mapSize.y=s.y)),N.map===null&&!N.isPointLightShadow&&this.type===rc&&(N.map=new lt(i.x,i.y),N.map.texture.name=R.name+".shadowMap",N.mapPass=new lt(i.x,i.y),N.camera.updateProjectionMatrix()),N.map===null){let K={minFilter:Gt,magFilter:Gt,format:xr};N.map=new lt(i.x,i.y,K),N.map.texture.name=R.name+".shadowMap",N.camera.updateProjectionMatrix()}r.setRenderTarget(N.map),r.clear();let j=N.getViewportCount();for(let K=0;K<j;K++){let Y=N.getViewport(K);o.set(s.x*Y.x,s.y*Y.y,s.x*Y.z,s.y*Y.w),E.viewport(o),N.updateMatrices(R,K),n=N.getFrustum(),w(S,M,N.camera,R,this.type)}!N.isPointLightShadow&&this.type===rc&&x(N,M),N.needsUpdate=!1}g.needsUpdate=!1,r.setRenderTarget(_,y,T)};function x(b,S){let M=e.update(p);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,r.setRenderTarget(b.mapPass),r.clear(),r.renderBufferDirect(S,null,M,d,p,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,r.setRenderTarget(b.map),r.clear(),r.renderBufferDirect(S,null,M,f,p,null)}function v(b,S,M,_,y,T){let E=null,C=M.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0?E=C:E=M.isPointLight===!0?l:a,r.localClippingEnabled&&S.clipShadows===!0&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0){let I=E.uuid,R=S.uuid,N=c[I];N===void 0&&(N={},c[I]=N);let H=N[R];H===void 0&&(H=E.clone(),N[R]=H),E=H}return E.visible=S.visible,E.wireframe=S.wireframe,T===rc?E.side=S.shadowSide!==null?S.shadowSide:S.side:E.side=S.shadowSide!==null?S.shadowSide:u[S.side],E.alphaMap=S.alphaMap,E.alphaTest=S.alphaTest,E.clipShadows=S.clipShadows,E.clippingPlanes=S.clippingPlanes,E.clipIntersection=S.clipIntersection,E.displacementMap=S.displacementMap,E.displacementScale=S.displacementScale,E.displacementBias=S.displacementBias,E.wireframeLinewidth=S.wireframeLinewidth,E.linewidth=S.linewidth,M.isPointLight===!0&&E.isMeshDistanceMaterial===!0&&(E.referencePosition.setFromMatrixPosition(M.matrixWorld),E.nearDistance=_,E.farDistance=y),E}function w(b,S,M,_,y){if(b.visible===!1)return;if(b.layers.test(S.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&y===rc)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,b.matrixWorld);let C=e.update(b),I=b.material;if(Array.isArray(I)){let R=C.groups;for(let N=0,H=R.length;N<H;N++){let j=R[N],K=I[j.materialIndex];if(K&&K.visible){let Y=v(b,K,_,M.near,M.far,y);r.renderBufferDirect(M,null,C,Y,b,j)}}}else if(I.visible){let R=v(b,I,_,M.near,M.far,y);r.renderBufferDirect(M,null,C,R,b,null)}}let E=b.children;for(let C=0,I=E.length;C<I;C++)w(E[C],S,M,_,y)}}function gD(r,e,t){let n=t.isWebGL2;function i(){let U=!1,xe=new qe,Me=null,Qe=new qe(0,0,0,0);return{setMask:function(Ne){Me!==Ne&&!U&&(r.colorMask(Ne,Ne,Ne,Ne),Me=Ne)},setLocked:function(Ne){U=Ne},setClear:function(Ne,Ke,be,Ze,rt){rt===!0&&(Ne*=Ze,Ke*=Ze,be*=Ze),xe.set(Ne,Ke,be,Ze),Qe.equals(xe)===!1&&(r.clearColor(Ne,Ke,be,Ze),Qe.copy(xe))},reset:function(){U=!1,Me=null,Qe.set(-1,0,0,0)}}}function s(){let U=!1,xe=null,Me=null,Qe=null;return{setTest:function(Ne){Ne?X(2929):q(2929)},setMask:function(Ne){xe!==Ne&&!U&&(r.depthMask(Ne),xe=Ne)},setFunc:function(Ne){if(Me!==Ne){if(Ne)switch(Ne){case jM:r.depthFunc(512);break;case qM:r.depthFunc(519);break;case XM:r.depthFunc(513);break;case Wp:r.depthFunc(515);break;case YM:r.depthFunc(514);break;case QM:r.depthFunc(518);break;case KM:r.depthFunc(516);break;case ZM:r.depthFunc(517);break;default:r.depthFunc(515)}else r.depthFunc(515);Me=Ne}},setLocked:function(Ne){U=Ne},setClear:function(Ne){Qe!==Ne&&(r.clearDepth(Ne),Qe=Ne)},reset:function(){U=!1,xe=null,Me=null,Qe=null}}}function o(){let U=!1,xe=null,Me=null,Qe=null,Ne=null,Ke=null,be=null,Ze=null,rt=null;return{setTest:function(gt){U||(gt?X(2960):q(2960))},setMask:function(gt){xe!==gt&&!U&&(r.stencilMask(gt),xe=gt)},setFunc:function(gt,wt,Qn){(Me!==gt||Qe!==wt||Ne!==Qn)&&(r.stencilFunc(gt,wt,Qn),Me=gt,Qe=wt,Ne=Qn)},setOp:function(gt,wt,Qn){(Ke!==gt||be!==wt||Ze!==Qn)&&(r.stencilOp(gt,wt,Qn),Ke=gt,be=wt,Ze=Qn)},setLocked:function(gt){U=gt},setClear:function(gt){rt!==gt&&(r.clearStencil(gt),rt=gt)},reset:function(){U=!1,xe=null,Me=null,Qe=null,Ne=null,Ke=null,be=null,Ze=null,rt=null}}}let a=new i,l=new s,c=new o,h={},u={},d=new WeakMap,f=[],m=null,p=!1,g=null,x=null,v=null,w=null,b=null,S=null,M=null,_=!1,y=null,T=null,E=null,C=null,I=null,R=r.getParameter(35661),N=!1,H=0,j=r.getParameter(7938);j.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(j)[1]),N=H>=1):j.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),N=H>=2);let K=null,Y={},z=r.getParameter(3088),F=r.getParameter(2978),V=new qe().fromArray(z),O=new qe().fromArray(F);function G(U,xe,Me){let Qe=new Uint8Array(4),Ne=r.createTexture();r.bindTexture(U,Ne),r.texParameteri(U,10241,9728),r.texParameteri(U,10240,9728);for(let Ke=0;Ke<Me;Ke++)r.texImage2D(xe+Ke,0,6408,1,1,0,6408,5121,Qe);return Ne}let W={};W[3553]=G(3553,3553,1),W[34067]=G(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),c.setClear(0),X(2929),l.setFunc(Wp),de(!1),ge(wv),X(2884),ce(Ct);function X(U){h[U]!==!0&&(r.enable(U),h[U]=!0)}function q(U){h[U]!==!1&&(r.disable(U),h[U]=!1)}function se(U,xe){return u[U]!==xe?(r.bindFramebuffer(U,xe),u[U]=xe,n&&(U===36009&&(u[36160]=xe),U===36160&&(u[36009]=xe)),!0):!1}function Z(U,xe){let Me=f,Qe=!1;if(U)if(Me=d.get(xe),Me===void 0&&(Me=[],d.set(xe,Me)),U.isWebGLMultipleRenderTargets){let Ne=U.texture;if(Me.length!==Ne.length||Me[0]!==36064){for(let Ke=0,be=Ne.length;Ke<be;Ke++)Me[Ke]=36064+Ke;Me.length=Ne.length,Qe=!0}}else Me[0]!==36064&&(Me[0]=36064,Qe=!0);else Me[0]!==1029&&(Me[0]=1029,Qe=!0);Qe&&(t.isWebGL2?r.drawBuffers(Me):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Me))}function te(U){return m!==U?(r.useProgram(U),m=U,!0):!1}let k={[Zo]:32774,[RM]:32778,[BM]:32779};if(n)k[_v]=32775,k[Tv]=32776;else{let U=e.get("EXT_blend_minmax");U!==null&&(k[_v]=U.MIN_EXT,k[Tv]=U.MAX_EXT)}let le={[OM]:0,[FM]:1,[UM]:768,[$0]:770,[WM]:776,[VM]:774,[GM]:772,[zM]:769,[ex]:771,[HM]:775,[kM]:773};function ce(U,xe,Me,Qe,Ne,Ke,be,Ze){if(U===Ct){p===!0&&(q(3042),p=!1);return}if(p===!1&&(X(3042),p=!0),U!==NM){if(U!==g||Ze!==_){if((x!==Zo||b!==Zo)&&(r.blendEquation(32774),x=Zo,b=Zo),Ze)switch(U){case ls:r.blendFuncSeparate(1,771,1,771);break;case Sv:r.blendFunc(1,1);break;case Av:r.blendFuncSeparate(0,769,0,1);break;case Mv:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case ls:r.blendFuncSeparate(770,771,1,771);break;case Sv:r.blendFunc(770,1);break;case Av:r.blendFuncSeparate(0,769,0,1);break;case Mv:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}v=null,w=null,S=null,M=null,g=U,_=Ze}return}Ne=Ne||xe,Ke=Ke||Me,be=be||Qe,(xe!==x||Ne!==b)&&(r.blendEquationSeparate(k[xe],k[Ne]),x=xe,b=Ne),(Me!==v||Qe!==w||Ke!==S||be!==M)&&(r.blendFuncSeparate(le[Me],le[Qe],le[Ke],le[be]),v=Me,w=Qe,S=Ke,M=be),g=U,_=null}function ae(U,xe){U.side===hn?q(2884):X(2884);let Me=U.side===wn;xe&&(Me=!Me),de(Me),U.blending===ls&&U.transparent===!1?ce(Ct):ce(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.premultipliedAlpha),l.setFunc(U.depthFunc),l.setTest(U.depthTest),l.setMask(U.depthWrite),a.setMask(U.colorWrite);let Qe=U.stencilWrite;c.setTest(Qe),Qe&&(c.setMask(U.stencilWriteMask),c.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),c.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),Ee(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?X(32926):q(32926)}function de(U){y!==U&&(U?r.frontFace(2304):r.frontFace(2305),y=U)}function ge(U){U!==PM?(X(2884),U!==T&&(U===wv?r.cullFace(1029):U===LM?r.cullFace(1028):r.cullFace(1032))):q(2884),T=U}function fe(U){U!==E&&(N&&r.lineWidth(U),E=U)}function Ee(U,xe,Me){U?(X(32823),(C!==xe||I!==Me)&&(r.polygonOffset(xe,Me),C=xe,I=Me)):q(32823)}function De(U){U?X(3089):q(3089)}function ye(U){U===void 0&&(U=33984+R-1),K!==U&&(r.activeTexture(U),K=U)}function Re(U,xe){K===null&&ye();let Me=Y[K];Me===void 0&&(Me={type:void 0,texture:void 0},Y[K]=Me),(Me.type!==U||Me.texture!==xe)&&(r.bindTexture(U,xe||W[U]),Me.type=U,Me.texture=xe)}function mt(){let U=Y[K];U!==void 0&&U.type!==void 0&&(r.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}function P(){try{r.compressedTexImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function D(){try{r.texSubImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function J(){try{r.texSubImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ue(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function pe(){try{r.texStorage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ce(){try{r.texStorage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Fe(){try{r.texImage2D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function re(){try{r.texImage3D.apply(r,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Be(U){V.equals(U)===!1&&(r.scissor(U.x,U.y,U.z,U.w),V.copy(U))}function Ie(U){O.equals(U)===!1&&(r.viewport(U.x,U.y,U.z,U.w),O.copy(U))}function ve(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),h={},K=null,Y={},u={},d=new WeakMap,f=[],m=null,p=!1,g=null,x=null,v=null,w=null,b=null,S=null,M=null,_=!1,y=null,T=null,E=null,C=null,I=null,V.set(0,0,r.canvas.width,r.canvas.height),O.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),c.reset()}return{buffers:{color:a,depth:l,stencil:c},enable:X,disable:q,bindFramebuffer:se,drawBuffers:Z,useProgram:te,setBlending:ce,setMaterial:ae,setFlipSided:de,setCullFace:ge,setLineWidth:fe,setPolygonOffset:Ee,setScissorTest:De,activeTexture:ye,bindTexture:Re,unbindTexture:mt,compressedTexImage2D:P,texImage2D:Fe,texImage3D:re,texStorage2D:pe,texStorage3D:Ce,texSubImage2D:D,texSubImage3D:J,compressedTexSubImage2D:ue,scissor:Be,viewport:Ie,reset:ve}}function yD(r,e,t,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,h=i.maxTextureSize,u=i.maxSamples,d=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,f=/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(P,D){return x?new OffscreenCanvas(P,D):fu("canvas")}function w(P,D,J,ue){let pe=1;if((P.width>ue||P.height>ue)&&(pe=ue/Math.max(P.width,P.height)),pe<1||D===!0)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap){let Ce=D?du:Math.floor,Fe=Ce(pe*P.width),re=Ce(pe*P.height);p===void 0&&(p=v(Fe,re));let Be=J?v(Fe,re):p;return Be.width=Fe,Be.height=re,Be.getContext("2d").drawImage(P,0,0,Fe,re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+P.width+"x"+P.height+") to ("+Fe+"x"+re+")."),Be}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+P.width+"x"+P.height+")."),P;return P}function b(P){return Kp(P.width)&&Kp(P.height)}function S(P){return a?!1:P.wrapS!==bn||P.wrapT!==bn||P.minFilter!==Gt&&P.minFilter!==tt}function M(P,D){return P.generateMipmaps&&D&&P.minFilter!==Gt&&P.minFilter!==tt}function _(P){r.generateMipmap(P)}function y(P,D,J,ue,pe=!1){if(a===!1)return D;if(P!==null){if(r[P]!==void 0)return r[P];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let Ce=D;return D===6403&&(J===5126&&(Ce=33326),J===5131&&(Ce=33325),J===5121&&(Ce=33321)),D===33319&&(J===5126&&(Ce=33328),J===5131&&(Ce=33327),J===5121&&(Ce=33323)),D===6408&&(J===5126&&(Ce=34836),J===5131&&(Ce=34842),J===5121&&(Ce=ue===We&&pe===!1?35907:32856),J===32819&&(Ce=32854),J===32820&&(Ce=32855)),(Ce===33325||Ce===33326||Ce===33327||Ce===33328||Ce===34842||Ce===34836)&&e.get("EXT_color_buffer_float"),Ce}function T(P,D,J){return M(P,J)===!0||P.isFramebufferTexture&&P.minFilter!==Gt&&P.minFilter!==tt?Math.log2(Math.max(D.width,D.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?D.mipmaps.length:1}function E(P){return P===Gt||P===Ev||P===Cv?9728:9729}function C(P){let D=P.target;D.removeEventListener("dispose",C),R(D),D.isVideoTexture&&m.delete(D)}function I(P){let D=P.target;D.removeEventListener("dispose",I),H(D)}function R(P){let D=n.get(P);if(D.__webglInit===void 0)return;let J=P.source,ue=g.get(J);if(ue){let pe=ue[D.__cacheKey];pe.usedTimes--,pe.usedTimes===0&&N(P),Object.keys(ue).length===0&&g.delete(J)}n.remove(P)}function N(P){let D=n.get(P);r.deleteTexture(D.__webglTexture);let J=P.source,ue=g.get(J);delete ue[D.__cacheKey],o.memory.textures--}function H(P){let D=P.texture,J=n.get(P),ue=n.get(D);if(ue.__webglTexture!==void 0&&(r.deleteTexture(ue.__webglTexture),o.memory.textures--),P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let pe=0;pe<6;pe++)r.deleteFramebuffer(J.__webglFramebuffer[pe]),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer[pe]);else{if(r.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&r.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let pe=0;pe<J.__webglColorRenderbuffer.length;pe++)J.__webglColorRenderbuffer[pe]&&r.deleteRenderbuffer(J.__webglColorRenderbuffer[pe]);J.__webglDepthRenderbuffer&&r.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(P.isWebGLMultipleRenderTargets)for(let pe=0,Ce=D.length;pe<Ce;pe++){let Fe=n.get(D[pe]);Fe.__webglTexture&&(r.deleteTexture(Fe.__webglTexture),o.memory.textures--),n.remove(D[pe])}n.remove(D),n.remove(P)}let j=0;function K(){j=0}function Y(){let P=j;return P>=l&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+l),j+=1,P}function z(P){let D=[];return D.push(P.wrapS),D.push(P.wrapT),D.push(P.magFilter),D.push(P.minFilter),D.push(P.anisotropy),D.push(P.internalFormat),D.push(P.format),D.push(P.type),D.push(P.generateMipmaps),D.push(P.premultiplyAlpha),D.push(P.flipY),D.push(P.unpackAlignment),D.push(P.encoding),D.join()}function F(P,D){let J=n.get(P);if(P.isVideoTexture&&Re(P),P.isRenderTargetTexture===!1&&P.version>0&&J.__version!==P.version){let ue=P.image;if(ue===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ue.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(J,P,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,J.__webglTexture)}function V(P,D){let J=n.get(P);if(P.version>0&&J.__version!==P.version){Z(J,P,D);return}t.activeTexture(33984+D),t.bindTexture(35866,J.__webglTexture)}function O(P,D){let J=n.get(P);if(P.version>0&&J.__version!==P.version){Z(J,P,D);return}t.activeTexture(33984+D),t.bindTexture(32879,J.__webglTexture)}function G(P,D){let J=n.get(P);if(P.version>0&&J.__version!==P.version){te(J,P,D);return}t.activeTexture(33984+D),t.bindTexture(34067,J.__webglTexture)}let W={[ta]:10497,[bn]:33071,[Xp]:33648},X={[Gt]:9728,[Ev]:9984,[Cv]:9986,[tt]:9729,[s_]:9985,[xs]:9987};function q(P,D,J){if(J?(r.texParameteri(P,10242,W[D.wrapS]),r.texParameteri(P,10243,W[D.wrapT]),(P===32879||P===35866)&&r.texParameteri(P,32882,W[D.wrapR]),r.texParameteri(P,10240,X[D.magFilter]),r.texParameteri(P,10241,X[D.minFilter])):(r.texParameteri(P,10242,33071),r.texParameteri(P,10243,33071),(P===32879||P===35866)&&r.texParameteri(P,32882,33071),(D.wrapS!==bn||D.wrapT!==bn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(P,10240,E(D.magFilter)),r.texParameteri(P,10241,E(D.minFilter)),D.minFilter!==Gt&&D.minFilter!==tt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let ue=e.get("EXT_texture_filter_anisotropic");if(D.type===vr&&e.has("OES_texture_float_linear")===!1||a===!1&&D.type===hc&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||n.get(D).__currentAnisotropy)&&(r.texParameterf(P,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,i.getMaxAnisotropy())),n.get(D).__currentAnisotropy=D.anisotropy)}}function se(P,D){let J=!1;P.__webglInit===void 0&&(P.__webglInit=!0,D.addEventListener("dispose",C));let ue=D.source,pe=g.get(ue);pe===void 0&&(pe={},g.set(ue,pe));let Ce=z(D);if(Ce!==P.__cacheKey){pe[Ce]===void 0&&(pe[Ce]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,J=!0),pe[Ce].usedTimes++;let Fe=pe[P.__cacheKey];Fe!==void 0&&(pe[P.__cacheKey].usedTimes--,Fe.usedTimes===0&&N(D)),P.__cacheKey=Ce,P.__webglTexture=pe[Ce].texture}return J}function Z(P,D,J){let ue=3553;D.isDataArrayTexture&&(ue=35866),D.isData3DTexture&&(ue=32879);let pe=se(P,D),Ce=D.source;if(t.activeTexture(33984+J),t.bindTexture(ue,P.__webglTexture),Ce.version!==Ce.__currentVersion||pe===!0){r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let Fe=S(D)&&b(D.image)===!1,re=w(D.image,Fe,!1,h);re=mt(D,re);let Be=b(re)||a,Ie=s.convert(D.format,D.encoding),ve=s.convert(D.type),U=y(D.internalFormat,Ie,ve,D.encoding,D.isVideoTexture);q(ue,D,Be);let xe,Me=D.mipmaps,Qe=a&&D.isVideoTexture!==!0,Ne=Ce.__currentVersion===void 0||pe===!0,Ke=T(D,re,Be);if(D.isDepthTexture)U=6402,a?D.type===vr?U=36012:D.type===Fi?U=33190:D.type===cs?U=35056:U=33189:D.type===vr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===to&&U===6402&&D.type!==nx&&D.type!==Fi&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=Fi,ve=s.convert(D.type)),D.format===fs&&U===6402&&(U=34041,D.type!==cs&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=cs,ve=s.convert(D.type))),Ne&&(Qe?t.texStorage2D(3553,1,U,re.width,re.height):t.texImage2D(3553,0,U,re.width,re.height,0,Ie,ve,null));else if(D.isDataTexture)if(Me.length>0&&Be){Qe&&Ne&&t.texStorage2D(3553,Ke,U,Me[0].width,Me[0].height);for(let be=0,Ze=Me.length;be<Ze;be++)xe=Me[be],Qe?t.texSubImage2D(3553,be,0,0,xe.width,xe.height,Ie,ve,xe.data):t.texImage2D(3553,be,U,xe.width,xe.height,0,Ie,ve,xe.data);D.generateMipmaps=!1}else Qe?(Ne&&t.texStorage2D(3553,Ke,U,re.width,re.height),t.texSubImage2D(3553,0,0,0,re.width,re.height,Ie,ve,re.data)):t.texImage2D(3553,0,U,re.width,re.height,0,Ie,ve,re.data);else if(D.isCompressedTexture){Qe&&Ne&&t.texStorage2D(3553,Ke,U,Me[0].width,Me[0].height);for(let be=0,Ze=Me.length;be<Ze;be++)xe=Me[be],D.format!==xr?Ie!==null?Qe?t.compressedTexSubImage2D(3553,be,0,0,xe.width,xe.height,Ie,xe.data):t.compressedTexImage2D(3553,be,U,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Qe?t.texSubImage2D(3553,be,0,0,xe.width,xe.height,Ie,ve,xe.data):t.texImage2D(3553,be,U,xe.width,xe.height,0,Ie,ve,xe.data)}else if(D.isDataArrayTexture)Qe?(Ne&&t.texStorage3D(35866,Ke,U,re.width,re.height,re.depth),t.texSubImage3D(35866,0,0,0,0,re.width,re.height,re.depth,Ie,ve,re.data)):t.texImage3D(35866,0,U,re.width,re.height,re.depth,0,Ie,ve,re.data);else if(D.isData3DTexture)Qe?(Ne&&t.texStorage3D(32879,Ke,U,re.width,re.height,re.depth),t.texSubImage3D(32879,0,0,0,0,re.width,re.height,re.depth,Ie,ve,re.data)):t.texImage3D(32879,0,U,re.width,re.height,re.depth,0,Ie,ve,re.data);else if(D.isFramebufferTexture){if(Ne)if(Qe)t.texStorage2D(3553,Ke,U,re.width,re.height);else{let be=re.width,Ze=re.height;for(let rt=0;rt<Ke;rt++)t.texImage2D(3553,rt,U,be,Ze,0,Ie,ve,null),be>>=1,Ze>>=1}}else if(Me.length>0&&Be){Qe&&Ne&&t.texStorage2D(3553,Ke,U,Me[0].width,Me[0].height);for(let be=0,Ze=Me.length;be<Ze;be++)xe=Me[be],Qe?t.texSubImage2D(3553,be,0,0,Ie,ve,xe):t.texImage2D(3553,be,U,Ie,ve,xe);D.generateMipmaps=!1}else Qe?(Ne&&t.texStorage2D(3553,Ke,U,re.width,re.height),t.texSubImage2D(3553,0,0,0,Ie,ve,re)):t.texImage2D(3553,0,U,Ie,ve,re);M(D,Be)&&_(ue),Ce.__currentVersion=Ce.version,D.onUpdate&&D.onUpdate(D)}P.__version=D.version}function te(P,D,J){if(D.image.length!==6)return;let ue=se(P,D),pe=D.source;if(t.activeTexture(33984+J),t.bindTexture(34067,P.__webglTexture),pe.version!==pe.__currentVersion||ue===!0){r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let Ce=D.isCompressedTexture||D.image[0].isCompressedTexture,Fe=D.image[0]&&D.image[0].isDataTexture,re=[];for(let be=0;be<6;be++)!Ce&&!Fe?re[be]=w(D.image[be],!1,!0,c):re[be]=Fe?D.image[be].image:D.image[be],re[be]=mt(D,re[be]);let Be=re[0],Ie=b(Be)||a,ve=s.convert(D.format,D.encoding),U=s.convert(D.type),xe=y(D.internalFormat,ve,U,D.encoding),Me=a&&D.isVideoTexture!==!0,Qe=pe.__currentVersion===void 0||ue===!0,Ne=T(D,Be,Ie);q(34067,D,Ie);let Ke;if(Ce){Me&&Qe&&t.texStorage2D(34067,Ne,xe,Be.width,Be.height);for(let be=0;be<6;be++){Ke=re[be].mipmaps;for(let Ze=0;Ze<Ke.length;Ze++){let rt=Ke[Ze];D.format!==xr?ve!==null?Me?t.compressedTexSubImage2D(34069+be,Ze,0,0,rt.width,rt.height,ve,rt.data):t.compressedTexImage2D(34069+be,Ze,xe,rt.width,rt.height,0,rt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Me?t.texSubImage2D(34069+be,Ze,0,0,rt.width,rt.height,ve,U,rt.data):t.texImage2D(34069+be,Ze,xe,rt.width,rt.height,0,ve,U,rt.data)}}}else{Ke=D.mipmaps,Me&&Qe&&(Ke.length>0&&Ne++,t.texStorage2D(34067,Ne,xe,re[0].width,re[0].height));for(let be=0;be<6;be++)if(Fe){Me?t.texSubImage2D(34069+be,0,0,0,re[be].width,re[be].height,ve,U,re[be].data):t.texImage2D(34069+be,0,xe,re[be].width,re[be].height,0,ve,U,re[be].data);for(let Ze=0;Ze<Ke.length;Ze++){let gt=Ke[Ze].image[be].image;Me?t.texSubImage2D(34069+be,Ze+1,0,0,gt.width,gt.height,ve,U,gt.data):t.texImage2D(34069+be,Ze+1,xe,gt.width,gt.height,0,ve,U,gt.data)}}else{Me?t.texSubImage2D(34069+be,0,0,0,ve,U,re[be]):t.texImage2D(34069+be,0,xe,ve,U,re[be]);for(let Ze=0;Ze<Ke.length;Ze++){let rt=Ke[Ze];Me?t.texSubImage2D(34069+be,Ze+1,0,0,ve,U,rt.image[be]):t.texImage2D(34069+be,Ze+1,xe,ve,U,rt.image[be])}}}M(D,Ie)&&_(34067),pe.__currentVersion=pe.version,D.onUpdate&&D.onUpdate(D)}P.__version=D.version}function k(P,D,J,ue,pe){let Ce=s.convert(J.format,J.encoding),Fe=s.convert(J.type),re=y(J.internalFormat,Ce,Fe,J.encoding);n.get(D).__hasExternalTextures||(pe===32879||pe===35866?t.texImage3D(pe,0,re,D.width,D.height,D.depth,0,Ce,Fe,null):t.texImage2D(pe,0,re,D.width,D.height,0,Ce,Fe,null)),t.bindFramebuffer(36160,P),ye(D)?d.framebufferTexture2DMultisampleEXT(36160,ue,pe,n.get(J).__webglTexture,0,De(D)):r.framebufferTexture2D(36160,ue,pe,n.get(J).__webglTexture,0),t.bindFramebuffer(36160,null)}function le(P,D,J){if(r.bindRenderbuffer(36161,P),D.depthBuffer&&!D.stencilBuffer){let ue=33189;if(J||ye(D)){let pe=D.depthTexture;pe&&pe.isDepthTexture&&(pe.type===vr?ue=36012:pe.type===Fi&&(ue=33190));let Ce=De(D);ye(D)?d.renderbufferStorageMultisampleEXT(36161,Ce,ue,D.width,D.height):r.renderbufferStorageMultisample(36161,Ce,ue,D.width,D.height)}else r.renderbufferStorage(36161,ue,D.width,D.height);r.framebufferRenderbuffer(36160,36096,36161,P)}else if(D.depthBuffer&&D.stencilBuffer){let ue=De(D);J&&ye(D)===!1?r.renderbufferStorageMultisample(36161,ue,35056,D.width,D.height):ye(D)?d.renderbufferStorageMultisampleEXT(36161,ue,35056,D.width,D.height):r.renderbufferStorage(36161,34041,D.width,D.height),r.framebufferRenderbuffer(36160,33306,36161,P)}else{let ue=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let pe=0;pe<ue.length;pe++){let Ce=ue[pe],Fe=s.convert(Ce.format,Ce.encoding),re=s.convert(Ce.type),Be=y(Ce.internalFormat,Fe,re,Ce.encoding),Ie=De(D);J&&ye(D)===!1?r.renderbufferStorageMultisample(36161,Ie,Be,D.width,D.height):ye(D)?d.renderbufferStorageMultisampleEXT(36161,Ie,Be,D.width,D.height):r.renderbufferStorage(36161,Be,D.width,D.height)}}r.bindRenderbuffer(36161,null)}function ce(P,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,P),!(D.depthTexture&&D.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(D.depthTexture).__webglTexture||D.depthTexture.image.width!==D.width||D.depthTexture.image.height!==D.height)&&(D.depthTexture.image.width=D.width,D.depthTexture.image.height=D.height,D.depthTexture.needsUpdate=!0),F(D.depthTexture,0);let ue=n.get(D.depthTexture).__webglTexture,pe=De(D);if(D.depthTexture.format===to)ye(D)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ue,0,pe):r.framebufferTexture2D(36160,36096,3553,ue,0);else if(D.depthTexture.format===fs)ye(D)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ue,0,pe):r.framebufferTexture2D(36160,33306,3553,ue,0);else throw new Error("Unknown depthTexture format")}function ae(P){let D=n.get(P),J=P.isWebGLCubeRenderTarget===!0;if(P.depthTexture&&!D.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");ce(D.__webglFramebuffer,P)}else if(J){D.__webglDepthbuffer=[];for(let ue=0;ue<6;ue++)t.bindFramebuffer(36160,D.__webglFramebuffer[ue]),D.__webglDepthbuffer[ue]=r.createRenderbuffer(),le(D.__webglDepthbuffer[ue],P,!1)}else t.bindFramebuffer(36160,D.__webglFramebuffer),D.__webglDepthbuffer=r.createRenderbuffer(),le(D.__webglDepthbuffer,P,!1);t.bindFramebuffer(36160,null)}function de(P,D,J){let ue=n.get(P);D!==void 0&&k(ue.__webglFramebuffer,P,P.texture,36064,3553),J!==void 0&&ae(P)}function ge(P){let D=P.texture,J=n.get(P),ue=n.get(D);P.addEventListener("dispose",I),P.isWebGLMultipleRenderTargets!==!0&&(ue.__webglTexture===void 0&&(ue.__webglTexture=r.createTexture()),ue.__version=D.version,o.memory.textures++);let pe=P.isWebGLCubeRenderTarget===!0,Ce=P.isWebGLMultipleRenderTargets===!0,Fe=b(P)||a;if(pe){J.__webglFramebuffer=[];for(let re=0;re<6;re++)J.__webglFramebuffer[re]=r.createFramebuffer()}else{if(J.__webglFramebuffer=r.createFramebuffer(),Ce)if(i.drawBuffers){let re=P.texture;for(let Be=0,Ie=re.length;Be<Ie;Be++){let ve=n.get(re[Be]);ve.__webglTexture===void 0&&(ve.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&P.samples>0&&ye(P)===!1){let re=Ce?D:[D];J.__webglMultisampledFramebuffer=r.createFramebuffer(),J.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,J.__webglMultisampledFramebuffer);for(let Be=0;Be<re.length;Be++){let Ie=re[Be];J.__webglColorRenderbuffer[Be]=r.createRenderbuffer(),r.bindRenderbuffer(36161,J.__webglColorRenderbuffer[Be]);let ve=s.convert(Ie.format,Ie.encoding),U=s.convert(Ie.type),xe=y(Ie.internalFormat,ve,U,Ie.encoding),Me=De(P);r.renderbufferStorageMultisample(36161,Me,xe,P.width,P.height),r.framebufferRenderbuffer(36160,36064+Be,36161,J.__webglColorRenderbuffer[Be])}r.bindRenderbuffer(36161,null),P.depthBuffer&&(J.__webglDepthRenderbuffer=r.createRenderbuffer(),le(J.__webglDepthRenderbuffer,P,!0)),t.bindFramebuffer(36160,null)}}if(pe){t.bindTexture(34067,ue.__webglTexture),q(34067,D,Fe);for(let re=0;re<6;re++)k(J.__webglFramebuffer[re],P,D,36064,34069+re);M(D,Fe)&&_(34067),t.unbindTexture()}else if(Ce){let re=P.texture;for(let Be=0,Ie=re.length;Be<Ie;Be++){let ve=re[Be],U=n.get(ve);t.bindTexture(3553,U.__webglTexture),q(3553,ve,Fe),k(J.__webglFramebuffer,P,ve,36064+Be,3553),M(ve,Fe)&&_(3553)}t.unbindTexture()}else{let re=3553;(P.isWebGL3DRenderTarget||P.isWebGLArrayRenderTarget)&&(a?re=P.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(re,ue.__webglTexture),q(re,D,Fe),k(J.__webglFramebuffer,P,D,36064,re),M(D,Fe)&&_(re),t.unbindTexture()}P.depthBuffer&&ae(P)}function fe(P){let D=b(P)||a,J=P.isWebGLMultipleRenderTargets===!0?P.texture:[P.texture];for(let ue=0,pe=J.length;ue<pe;ue++){let Ce=J[ue];if(M(Ce,D)){let Fe=P.isWebGLCubeRenderTarget?34067:3553,re=n.get(Ce).__webglTexture;t.bindTexture(Fe,re),_(Fe),t.unbindTexture()}}}function Ee(P){if(a&&P.samples>0&&ye(P)===!1){let D=P.isWebGLMultipleRenderTargets?P.texture:[P.texture],J=P.width,ue=P.height,pe=16384,Ce=[],Fe=P.stencilBuffer?33306:36096,re=n.get(P),Be=P.isWebGLMultipleRenderTargets===!0;if(Be)for(let Ie=0;Ie<D.length;Ie++)t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Ie,36161,null),t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Ie,3553,null,0);t.bindFramebuffer(36008,re.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,re.__webglFramebuffer);for(let Ie=0;Ie<D.length;Ie++){Ce.push(36064+Ie),P.depthBuffer&&Ce.push(Fe);let ve=re.__ignoreDepthValues!==void 0?re.__ignoreDepthValues:!1;if(ve===!1&&(P.depthBuffer&&(pe|=256),P.stencilBuffer&&(pe|=1024)),Be&&r.framebufferRenderbuffer(36008,36064,36161,re.__webglColorRenderbuffer[Ie]),ve===!0&&(r.invalidateFramebuffer(36008,[Fe]),r.invalidateFramebuffer(36009,[Fe])),Be){let U=n.get(D[Ie]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,U,0)}r.blitFramebuffer(0,0,J,ue,0,0,J,ue,pe,9728),f&&r.invalidateFramebuffer(36008,Ce)}if(t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,null),Be)for(let Ie=0;Ie<D.length;Ie++){t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Ie,36161,re.__webglColorRenderbuffer[Ie]);let ve=n.get(D[Ie]).__webglTexture;t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Ie,3553,ve,0)}t.bindFramebuffer(36009,re.__webglMultisampledFramebuffer)}}function De(P){return Math.min(u,P.samples)}function ye(P){let D=n.get(P);return a&&P.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function Re(P){let D=o.render.frame;m.get(P)!==D&&(m.set(P,D),P.update())}function mt(P,D){let J=P.encoding,ue=P.format,pe=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||P.format===Qp||J!==lr&&(J===We?a===!1?e.has("EXT_sRGB")===!0&&ue===xr?(P.format=Qp,P.minFilter=tt,P.generateMipmaps=!1):D=pu.sRGBToLinear(D):(ue!==xr||pe!==Lt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",J)),D}this.allocateTextureUnit=Y,this.resetTextureUnits=K,this.setTexture2D=F,this.setTexture2DArray=V,this.setTexture3D=O,this.setTextureCube=G,this.rebindTextures=de,this.setupRenderTarget=ge,this.updateRenderTargetMipmap=fe,this.updateMultisampleRenderTarget=Ee,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=k,this.useMultisampledRTT=ye}function vD(r,e,t){let n=t.isWebGL2;function i(s,o=null){let a;if(s===Lt)return 5121;if(s===c_)return 32819;if(s===h_)return 32820;if(s===o_)return 5120;if(s===a_)return 5122;if(s===nx)return 5123;if(s===l_)return 5124;if(s===Fi)return 5125;if(s===vr)return 5126;if(s===hc)return n?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===u_)return 6406;if(s===xr)return 6408;if(s===f_)return 6409;if(s===p_)return 6410;if(s===to)return 6402;if(s===fs)return 34041;if(s===m_)return 6403;if(s===d_)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===Qp)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===g_)return 36244;if(s===y_)return 33319;if(s===v_)return 33320;if(s===x_)return 36249;if(s===lp||s===cp||s===hp||s===up)if(o===We)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===lp)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===cp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===hp)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===up)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===lp)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===cp)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===hp)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===up)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Dv||s===Pv||s===Lv||s===Iv)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Dv)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Pv)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Lv)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Iv)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===b_)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Nv||s===Rv)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Nv)return o===We?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Rv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Bv||s===Ov||s===Fv||s===Uv||s===zv||s===Gv||s===kv||s===Vv||s===Hv||s===Wv||s===jv||s===qv||s===Xv||s===Yv)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Bv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Ov)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===Fv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Uv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===zv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Gv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===kv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Vv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Hv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Wv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===jv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===qv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Xv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Yv)return o===We?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Qv)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Qv)return o===We?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===cs?n?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var om=class extends Zt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},as=class extends ct{constructor(){super(),this.isGroup=!0,this.type="Group"}},xD={type:"move"},ac=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new as,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new as,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new as,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(a!==null&&(i=t.getPose(e.targetRaySpace,n),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(xD))),c&&e.hand){o=!0;for(let p of e.hand.values()){let g=t.getJointPose(p,n);if(c.joints[p.jointName]===void 0){let v=new as;v.matrixAutoUpdate=!1,v.visible=!1,c.joints[p.jointName]=v,c.add(v)}let x=c.joints[p.jointName];g!==null&&(x.matrix.fromArray(g.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.jointRadius=g.radius),x.visible=g!==null}let h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}},wr=class extends Bt{constructor(e,t,n,i,s,o,a,l,c,h){if(h=h!==void 0?h:to,h!==to&&h!==fs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===to&&(n=Fi),n===void 0&&h===fs&&(n=cs),super(null,i,s,o,a,l,h,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Gt,this.minFilter=l!==void 0?l:Gt,this.flipY=!1,this.generateMipmaps=!1}},am=class extends Rt{constructor(e,t){super();let n=this,i=null,s=1,o=null,a="local-floor",l=null,c=null,h=null,u=null,d=null,f=null,m=t.getContextAttributes(),p=null,g=null,x=[],v=new Map,w=new Zt;w.layers.enable(1),w.viewport=new qe;let b=new Zt;b.layers.enable(2),b.viewport=new qe;let S=[w,b],M=new om;M.layers.enable(1),M.layers.enable(2);let _=null,y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let F=x[z];return F===void 0&&(F=new ac,x[z]=F),F.getTargetRaySpace()},this.getControllerGrip=function(z){let F=x[z];return F===void 0&&(F=new ac,x[z]=F),F.getGripSpace()},this.getHand=function(z){let F=x[z];return F===void 0&&(F=new ac,x[z]=F),F.getHandSpace()};function T(z){let F=v.get(z.inputSource);F!==void 0&&F.dispatchEvent({type:z.type,data:z.inputSource})}function E(){i.removeEventListener("select",T),i.removeEventListener("selectstart",T),i.removeEventListener("selectend",T),i.removeEventListener("squeeze",T),i.removeEventListener("squeezestart",T),i.removeEventListener("squeezeend",T),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",C),v.forEach(function(z,F){z!==void 0&&z.disconnect(F)}),v.clear(),_=null,y=null,e.setRenderTarget(p),d=null,u=null,h=null,i=null,g=null,Y.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(z){s=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(z){a=z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(z){l=z},this.getBaseLayer=function(){return u!==null?u:d},this.getBinding=function(){return h},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(z){if(i=z,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",T),i.addEventListener("selectstart",T),i.addEventListener("selectend",T),i.addEventListener("squeeze",T),i.addEventListener("squeezestart",T),i.addEventListener("squeezeend",T),i.addEventListener("end",E),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let F={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,F),i.updateRenderState({baseLayer:d}),g=new lt(d.framebufferWidth,d.framebufferHeight,{format:xr,type:Lt,encoding:e.outputEncoding})}else{let F=null,V=null,O=null;m.depth&&(O=m.stencil?35056:33190,F=m.stencil?fs:to,V=m.stencil?cs:Fi);let G={colorFormat:e.outputEncoding===We?35907:32856,depthFormat:O,scaleFactor:s};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(G),i.updateRenderState({layers:[u]}),g=new lt(u.textureWidth,u.textureHeight,{format:xr,type:Lt,depthTexture:new wr(u.textureWidth,u.textureHeight,V,void 0,void 0,void 0,void 0,void 0,void 0,F),stencilBuffer:m.stencil,encoding:e.outputEncoding,samples:m.antialias?4:0});let W=e.properties.get(g);W.__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(1),l=null,o=await i.requestReferenceSpace(a),Y.setContext(i),Y.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function C(z){let F=i.inputSources;for(let V=0;V<F.length;V++){let O=F[V].handedness==="right"?1:0;v.set(F[V],x[O])}for(let V=0;V<z.removed.length;V++){let O=z.removed[V],G=v.get(O);G&&(G.dispatchEvent({type:"disconnected",data:O}),v.delete(O))}for(let V=0;V<z.added.length;V++){let O=z.added[V],G=v.get(O);G&&G.dispatchEvent({type:"connected",data:O})}}let I=new A,R=new A;function N(z,F,V){I.setFromMatrixPosition(F.matrixWorld),R.setFromMatrixPosition(V.matrixWorld);let O=I.distanceTo(R),G=F.projectionMatrix.elements,W=V.projectionMatrix.elements,X=G[14]/(G[10]-1),q=G[14]/(G[10]+1),se=(G[9]+1)/G[5],Z=(G[9]-1)/G[5],te=(G[8]-1)/G[0],k=(W[8]+1)/W[0],le=X*te,ce=X*k,ae=O/(-te+k),de=ae*-te;F.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(de),z.translateZ(ae),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert();let ge=X+ae,fe=q+ae,Ee=le-de,De=ce+(O-de),ye=se*q/fe*ge,Re=Z*q/fe*ge;z.projectionMatrix.makePerspective(Ee,De,ye,Re,ge,fe)}function H(z,F){F===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(F.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(i===null)return;M.near=b.near=w.near=z.near,M.far=b.far=w.far=z.far,(_!==M.near||y!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),_=M.near,y=M.far);let F=z.parent,V=M.cameras;H(M,F);for(let G=0;G<V.length;G++)H(V[G],F);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),z.position.copy(M.position),z.quaternion.copy(M.quaternion),z.scale.copy(M.scale),z.matrix.copy(M.matrix),z.matrixWorld.copy(M.matrixWorld);let O=z.children;for(let G=0,W=O.length;G<W;G++)O[G].updateMatrixWorld(!0);V.length===2?N(M,w,b):M.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return M},this.getFoveation=function(){if(u!==null)return u.fixedFoveation;if(d!==null)return d.fixedFoveation},this.setFoveation=function(z){u!==null&&(u.fixedFoveation=z),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=z)};let j=null;function K(z,F){if(c=F.getViewerPose(l||o),f=F,c!==null){let O=c.views;d!==null&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let G=!1;O.length!==M.cameras.length&&(M.cameras.length=0,G=!0);for(let W=0;W<O.length;W++){let X=O[W],q=null;if(d!==null)q=d.getViewport(X);else{let Z=h.getViewSubImage(u,X);q=Z.viewport,W===0&&(e.setRenderTargetTextures(g,Z.colorTexture,u.ignoreDepthValues?void 0:Z.depthStencilTexture),e.setRenderTarget(g))}let se=S[W];se===void 0&&(se=new Zt,se.layers.enable(W),se.viewport=new qe,S[W]=se),se.matrix.fromArray(X.transform.matrix),se.projectionMatrix.fromArray(X.projectionMatrix),se.viewport.set(q.x,q.y,q.width,q.height),W===0&&M.matrix.copy(se.matrix),G===!0&&M.cameras.push(se)}}let V=i.inputSources;for(let O=0;O<x.length;O++){let G=V[O],W=v.get(G);W!==void 0&&W.update(G,F,l||o)}j&&j(z,F),f=null}let Y=new sx;Y.setAnimationLoop(K),this.setAnimationLoop=function(z){j=z},this.dispose=function(){}}};function bD(r,e){function t(p,g){p.fogColor.value.copy(g.color),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function n(p,g,x,v,w){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),h(p,g)):g.isMeshPhongMaterial?(i(p,g),c(p,g)):g.isMeshStandardMaterial?(i(p,g),u(p,g),g.isMeshPhysicalMaterial&&d(p,g,w)):g.isMeshMatcapMaterial?(i(p,g),f(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,x,v):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===wn&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===wn&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x=e.get(g).envMap;if(x&&(p.envMap.value=x,p.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let b=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix));let w;g.aoMap?w=g.aoMap:g.lightMap&&(w=g.lightMap),w!==void 0&&(w.isWebGLRenderTarget&&(w=w.texture),w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uv2Transform.value.copy(w.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,x,v){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*x,p.scale.value=v*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let w;g.map?w=g.map:g.alphaMap&&(w=g.alphaMap),w!==void 0&&(w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uvTransform.value.copy(w.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),p.uvTransform.value.copy(x.matrix))}function c(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function h(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function u(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function d(p,g,x){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===wn&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=x.texture,p.transmissionSamplerSize.value.set(x.width,x.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function f(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function wD(){let r=fu("canvas");return r.style.display="block",r}function Wm(r={}){this.isWebGLRenderer=!0;let e=r.canvas!==void 0?r.canvas:wD(),t=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",c=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,h;t!==null?h=t.getContextAttributes().alpha:h=r.alpha!==void 0?r.alpha:!1;let u=null,d=null,f=[],m=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=lr,this.physicallyCorrectLights=!1,this.toneMapping=Ui,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});let p=this,g=!1,x=0,v=0,w=null,b=-1,S=null,M=new qe,_=new qe,y=null,T=e.width,E=e.height,C=1,I=null,R=null,N=new qe(0,0,T,E),H=new qe(0,0,T,E),j=!1,K=new fc,Y=!1,z=!1,F=null,V=new Oe,O=new B,G=new A,W={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function X(){return w===null?C:1}let q=t;function se(L,$){for(let ie=0;ie<L.length;ie++){let ne=L[ie],he=e.getContext(ne,$);if(he!==null)return he}return null}try{let L={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${mo}`),e.addEventListener("webglcontextlost",U,!1),e.addEventListener("webglcontextrestored",xe,!1),e.addEventListener("webglcontextcreationerror",Me,!1),q===null){let $=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&$.shift(),q=se($,L),q===null)throw se($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}q.getShaderPrecisionFormat===void 0&&(q.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let Z,te,k,le,ce,ae,de,ge,fe,Ee,De,ye,Re,mt,P,D,J,ue,pe,Ce,Fe,re,Be;function Ie(){Z=new VC(q),te=new OC(q,Z,r),Z.init(te),re=new vD(q,Z,te),k=new gD(q,Z,te),le=new jC(q),ce=new iD,ae=new yD(q,Z,k,ce,te,re,le),de=new UC(p),ge=new kC(p),fe=new rT(q,te),Be=new RC(q,Z,fe,te),Ee=new HC(q,fe,le,Be),De=new QC(q,Ee,fe,le),pe=new YC(q,te,ae),D=new FC(ce),ye=new rD(p,de,ge,Z,te,Be,D),Re=new bD(p,ce),mt=new oD,P=new dD(Z,te),ue=new NC(p,de,k,De,h,o),J=new mD(p,De,te),Ce=new BC(q,Z,le,te),Fe=new WC(q,Z,le,te),le.programs=ye.programs,p.capabilities=te,p.extensions=Z,p.properties=ce,p.renderLists=mt,p.shadowMap=J,p.state=k,p.info=le}Ie();let ve=new am(p,q);this.xr=ve,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){let L=Z.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=Z.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(L){L!==void 0&&(C=L,this.setSize(T,E,!1))},this.getSize=function(L){return L.set(T,E)},this.setSize=function(L,$,ie){if(ve.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=L,E=$,e.width=Math.floor(L*C),e.height=Math.floor($*C),ie!==!1&&(e.style.width=L+"px",e.style.height=$+"px"),this.setViewport(0,0,L,$)},this.getDrawingBufferSize=function(L){return L.set(T*C,E*C).floor()},this.setDrawingBufferSize=function(L,$,ie){T=L,E=$,C=ie,e.width=Math.floor(L*ie),e.height=Math.floor($*ie),this.setViewport(0,0,L,$)},this.getCurrentViewport=function(L){return L.copy(M)},this.getViewport=function(L){return L.copy(N)},this.setViewport=function(L,$,ie,ne){L.isVector4?N.set(L.x,L.y,L.z,L.w):N.set(L,$,ie,ne),k.viewport(M.copy(N).multiplyScalar(C).floor())},this.getScissor=function(L){return L.copy(H)},this.setScissor=function(L,$,ie,ne){L.isVector4?H.set(L.x,L.y,L.z,L.w):H.set(L,$,ie,ne),k.scissor(_.copy(H).multiplyScalar(C).floor())},this.getScissorTest=function(){return j},this.setScissorTest=function(L){k.setScissorTest(j=L)},this.setOpaqueSort=function(L){I=L},this.setTransparentSort=function(L){R=L},this.getClearColor=function(L){return L.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(L=!0,$=!0,ie=!0){let ne=0;L&&(ne|=16384),$&&(ne|=256),ie&&(ne|=1024),q.clear(ne)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",U,!1),e.removeEventListener("webglcontextrestored",xe,!1),e.removeEventListener("webglcontextcreationerror",Me,!1),mt.dispose(),P.dispose(),ce.dispose(),de.dispose(),ge.dispose(),De.dispose(),Be.dispose(),ye.dispose(),ve.dispose(),ve.removeEventListener("sessionstart",rt),ve.removeEventListener("sessionend",gt),F&&(F.dispose(),F=null),wt.stop()};function U(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let L=le.autoReset,$=J.enabled,ie=J.autoUpdate,ne=J.needsUpdate,he=J.type;Ie(),le.autoReset=L,J.enabled=$,J.autoUpdate=ie,J.needsUpdate=ne,J.type=he}function Me(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function Qe(L){let $=L.target;$.removeEventListener("dispose",Qe),Ne($)}function Ne(L){Ke(L),ce.remove(L)}function Ke(L){let $=ce.get(L).programs;$!==void 0&&($.forEach(function(ie){ye.releaseProgram(ie)}),L.isShaderMaterial&&ye.releaseShaderCache(L))}this.renderBufferDirect=function(L,$,ie,ne,he,Je){$===null&&($=W);let et=he.isMesh&&he.matrixWorld.determinant()<0,st=vM(L,$,ie,ne,he);k.setMaterial(ne,et);let it=ie.index,Et=ie.attributes.position;if(it===null){if(Et===void 0||Et.count===0)return}else if(it.count===0)return;let ut=1;ne.wireframe===!0&&(it=Ee.getWireframeAttribute(ie),ut=2),Be.setup(he,ne,st,ie,it);let yt,Wt=Ce;it!==null&&(yt=fe.get(it),Wt=Fe,Wt.setIndex(yt));let Ys=it!==null?it.count:Et.count,Ro=ie.drawRange.start*ut,Bo=ie.drawRange.count*ut,ri=Je!==null?Je.start*ut:0,St=Je!==null?Je.count*ut:1/0,Oo=Math.max(Ro,ri),nn=Math.min(Ys,Ro+Bo,ri+St)-1,ii=Math.max(0,nn-Oo+1);if(ii!==0){if(he.isMesh)ne.wireframe===!0?(k.setLineWidth(ne.wireframeLinewidth*X()),Wt.setMode(1)):Wt.setMode(4);else if(he.isLine){let $i=ne.linewidth;$i===void 0&&($i=1),k.setLineWidth($i*X()),he.isLineSegments?Wt.setMode(1):he.isLineLoop?Wt.setMode(2):Wt.setMode(3)}else he.isPoints?Wt.setMode(0):he.isSprite&&Wt.setMode(4);if(he.isInstancedMesh)Wt.renderInstances(Oo,ii,he.count);else if(ie.isInstancedBufferGeometry){let $i=Math.min(ie.instanceCount,ie._maxInstanceCount);Wt.renderInstances(Oo,ii,$i)}else Wt.render(Oo,ii)}},this.compile=function(L,$){d=P.get(L),d.init(),m.push(d),L.traverseVisible(function(ie){ie.isLight&&ie.layers.test($.layers)&&(d.pushLight(ie),ie.castShadow&&d.pushShadow(ie))}),d.setupLights(p.physicallyCorrectLights),L.traverse(function(ie){let ne=ie.material;if(ne)if(Array.isArray(ne))for(let he=0;he<ne.length;he++){let Je=ne[he];ip(Je,L,ie)}else ip(ne,L,ie)}),m.pop(),d=null};let be=null;function Ze(L){be&&be(L)}function rt(){wt.stop()}function gt(){wt.start()}let wt=new sx;wt.setAnimationLoop(Ze),typeof self<"u"&&wt.setContext(self),this.setAnimationLoop=function(L){be=L,ve.setAnimationLoop(L),L===null?wt.stop():wt.start()},ve.addEventListener("sessionstart",rt),ve.addEventListener("sessionend",gt),this.render=function(L,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;L.autoUpdate===!0&&L.updateMatrixWorld(),$.parent===null&&$.updateMatrixWorld(),ve.enabled===!0&&ve.isPresenting===!0&&(ve.cameraAutoUpdate===!0&&ve.updateCamera($),$=ve.getCamera()),L.isScene===!0&&L.onBeforeRender(p,L,$,w),d=P.get(L,m.length),d.init(),m.push(d),V.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),K.setFromProjectionMatrix(V),z=this.localClippingEnabled,Y=D.init(this.clippingPlanes,z,$),u=mt.get(L,f.length),u.init(),f.push(u),Qn(L,$,0,p.sortObjects),u.finish(),p.sortObjects===!0&&u.sort(I,R),Y===!0&&D.beginShadows();let ie=d.state.shadowsArray;if(J.render(ie,L,$),Y===!0&&D.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(u,L),d.setupLights(p.physicallyCorrectLights),$.isArrayCamera){let ne=$.cameras;for(let he=0,Je=ne.length;he<Je;he++){let et=ne[he];Nh(u,L,et,et.viewport)}}else Nh(u,L,$);w!==null&&(ae.updateMultisampleRenderTarget(w),ae.updateRenderTargetMipmap(w)),L.isScene===!0&&L.onAfterRender(p,L,$),Be.resetDefaultState(),b=-1,S=null,m.pop(),m.length>0?d=m[m.length-1]:d=null,f.pop(),f.length>0?u=f[f.length-1]:u=null};function Qn(L,$,ie,ne){if(L.visible===!1)return;if(L.layers.test($.layers)){if(L.isGroup)ie=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update($);else if(L.isLight)d.pushLight(L),L.castShadow&&d.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||K.intersectsSprite(L)){ne&&G.setFromMatrixPosition(L.matrixWorld).applyMatrix4(V);let et=De.update(L),st=L.material;st.visible&&u.push(L,et,st,ie,G.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(L.isSkinnedMesh&&L.skeleton.frame!==le.render.frame&&(L.skeleton.update(),L.skeleton.frame=le.render.frame),!L.frustumCulled||K.intersectsObject(L))){ne&&G.setFromMatrixPosition(L.matrixWorld).applyMatrix4(V);let et=De.update(L),st=L.material;if(Array.isArray(st)){let it=et.groups;for(let Et=0,ut=it.length;Et<ut;Et++){let yt=it[Et],Wt=st[yt.materialIndex];Wt&&Wt.visible&&u.push(L,et,Wt,ie,G.z,yt)}}else st.visible&&u.push(L,et,st,ie,G.z,null)}}let Je=L.children;for(let et=0,st=Je.length;et<st;et++)Qn(Je[et],$,ie,ne)}function Nh(L,$,ie,ne){let he=L.opaque,Je=L.transmissive,et=L.transparent;d.setupLightsView(ie),Je.length>0&&No(he,$,ie),ne&&k.viewport(M.copy(ne)),he.length>0&&Rh(he,$,ie),Je.length>0&&Rh(Je,$,ie),et.length>0&&Rh(et,$,ie),k.buffers.depth.setTest(!0),k.buffers.depth.setMask(!0),k.buffers.color.setMask(!0),k.setPolygonOffset(!1)}function No(L,$,ie){let ne=te.isWebGL2;F===null&&(F=new lt(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")?hc:Lt,minFilter:xs,samples:ne&&s===!0?4:0})),p.getDrawingBufferSize(O),ne?F.setSize(O.x,O.y):F.setSize(du(O.x),du(O.y));let he=p.getRenderTarget();p.setRenderTarget(F),p.clear();let Je=p.toneMapping;p.toneMapping=Ui,Rh(L,$,ie),p.toneMapping=Je,ae.updateMultisampleRenderTarget(F),ae.updateRenderTargetMipmap(F),p.setRenderTarget(he)}function Rh(L,$,ie){let ne=$.isScene===!0?$.overrideMaterial:null;for(let he=0,Je=L.length;he<Je;he++){let et=L[he],st=et.object,it=et.geometry,Et=ne===null?et.material:ne,ut=et.group;st.layers.test(ie.layers)&&yM(st,$,ie,it,Et,ut)}}function yM(L,$,ie,ne,he,Je){L.onBeforeRender(p,$,ie,ne,he,Je),L.modelViewMatrix.multiplyMatrices(ie.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),he.onBeforeRender(p,$,ie,ne,L,Je),he.transparent===!0&&he.side===hn?(he.side=wn,he.needsUpdate=!0,p.renderBufferDirect(ie,$,ne,he,L,Je),he.side=zi,he.needsUpdate=!0,p.renderBufferDirect(ie,$,ne,he,L,Je),he.side=hn):p.renderBufferDirect(ie,$,ne,he,L,Je),L.onAfterRender(p,$,ie,ne,he,Je)}function ip(L,$,ie){$.isScene!==!0&&($=W);let ne=ce.get(L),he=d.state.lights,Je=d.state.shadowsArray,et=he.state.version,st=ye.getParameters(L,he.state,Je,$,ie),it=ye.getProgramCacheKey(st),Et=ne.programs;ne.environment=L.isMeshStandardMaterial?$.environment:null,ne.fog=$.fog,ne.envMap=(L.isMeshStandardMaterial?ge:de).get(L.envMap||ne.environment),Et===void 0&&(L.addEventListener("dispose",Qe),Et=new Map,ne.programs=Et);let ut=Et.get(it);if(ut!==void 0){if(ne.currentProgram===ut&&ne.lightsStateVersion===et)return bv(L,st),ut}else st.uniforms=ye.getUniforms(L),L.onBuild(ie,st,p),L.onBeforeCompile(st,p),ut=ye.acquireProgram(st,it),Et.set(it,ut),ne.uniforms=st.uniforms;let yt=ne.uniforms;(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(yt.clippingPlanes=D.uniform),bv(L,st),ne.needsLights=bM(L),ne.lightsStateVersion=et,ne.needsLights&&(yt.ambientLightColor.value=he.state.ambient,yt.lightProbe.value=he.state.probe,yt.directionalLights.value=he.state.directional,yt.directionalLightShadows.value=he.state.directionalShadow,yt.spotLights.value=he.state.spot,yt.spotLightShadows.value=he.state.spotShadow,yt.rectAreaLights.value=he.state.rectArea,yt.ltc_1.value=he.state.rectAreaLTC1,yt.ltc_2.value=he.state.rectAreaLTC2,yt.pointLights.value=he.state.point,yt.pointLightShadows.value=he.state.pointShadow,yt.hemisphereLights.value=he.state.hemi,yt.directionalShadowMap.value=he.state.directionalShadowMap,yt.directionalShadowMatrix.value=he.state.directionalShadowMatrix,yt.spotShadowMap.value=he.state.spotShadowMap,yt.spotShadowMatrix.value=he.state.spotShadowMatrix,yt.pointShadowMap.value=he.state.pointShadowMap,yt.pointShadowMatrix.value=he.state.pointShadowMatrix);let Wt=ut.getUniforms(),Ys=ea.seqWithValue(Wt.seq,yt);return ne.currentProgram=ut,ne.uniformsList=Ys,ut}function bv(L,$){let ie=ce.get(L);ie.outputEncoding=$.outputEncoding,ie.instancing=$.instancing,ie.skinning=$.skinning,ie.morphTargets=$.morphTargets,ie.morphNormals=$.morphNormals,ie.morphColors=$.morphColors,ie.morphTargetsCount=$.morphTargetsCount,ie.numClippingPlanes=$.numClippingPlanes,ie.numIntersection=$.numClipIntersection,ie.vertexAlphas=$.vertexAlphas,ie.vertexTangents=$.vertexTangents,ie.toneMapping=$.toneMapping}function vM(L,$,ie,ne,he){$.isScene!==!0&&($=W),ae.resetTextureUnits();let Je=$.fog,et=ne.isMeshStandardMaterial?$.environment:null,st=w===null?p.outputEncoding:w.isXRRenderTarget===!0?w.texture.encoding:lr,it=(ne.isMeshStandardMaterial?ge:de).get(ne.envMap||et),Et=ne.vertexColors===!0&&!!ie.attributes.color&&ie.attributes.color.itemSize===4,ut=!!ne.normalMap&&!!ie.attributes.tangent,yt=!!ie.morphAttributes.position,Wt=!!ie.morphAttributes.normal,Ys=!!ie.morphAttributes.color,Ro=ne.toneMapped?p.toneMapping:Ui,Bo=ie.morphAttributes.position||ie.morphAttributes.normal||ie.morphAttributes.color,ri=Bo!==void 0?Bo.length:0,St=ce.get(ne),Oo=d.state.lights;if(Y===!0&&(z===!0||L!==S)){let si=L===S&&ne.id===b;D.setState(ne,L,si)}let nn=!1;ne.version===St.__version?(St.needsLights&&St.lightsStateVersion!==Oo.state.version||St.outputEncoding!==st||he.isInstancedMesh&&St.instancing===!1||!he.isInstancedMesh&&St.instancing===!0||he.isSkinnedMesh&&St.skinning===!1||!he.isSkinnedMesh&&St.skinning===!0||St.envMap!==it||ne.fog===!0&&St.fog!==Je||St.numClippingPlanes!==void 0&&(St.numClippingPlanes!==D.numPlanes||St.numIntersection!==D.numIntersection)||St.vertexAlphas!==Et||St.vertexTangents!==ut||St.morphTargets!==yt||St.morphNormals!==Wt||St.morphColors!==Ys||St.toneMapping!==Ro||te.isWebGL2===!0&&St.morphTargetsCount!==ri)&&(nn=!0):(nn=!0,St.__version=ne.version);let ii=St.currentProgram;nn===!0&&(ii=ip(ne,$,he));let $i=!1,Zl=!1,sp=!1,zn=ii.getUniforms(),Jl=St.uniforms;if(k.useProgram(ii.program)&&($i=!0,Zl=!0,sp=!0),ne.id!==b&&(b=ne.id,Zl=!0),$i||S!==L){if(zn.setValue(q,"projectionMatrix",L.projectionMatrix),te.logarithmicDepthBuffer&&zn.setValue(q,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),S!==L&&(S=L,Zl=!0,sp=!0),ne.isShaderMaterial||ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshStandardMaterial||ne.envMap){let si=zn.map.cameraPosition;si!==void 0&&si.setValue(q,G.setFromMatrixPosition(L.matrixWorld))}(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial)&&zn.setValue(q,"isOrthographic",L.isOrthographicCamera===!0),(ne.isMeshPhongMaterial||ne.isMeshToonMaterial||ne.isMeshLambertMaterial||ne.isMeshBasicMaterial||ne.isMeshStandardMaterial||ne.isShaderMaterial||ne.isShadowMaterial||he.isSkinnedMesh)&&zn.setValue(q,"viewMatrix",L.matrixWorldInverse)}if(he.isSkinnedMesh){zn.setOptional(q,he,"bindMatrix"),zn.setOptional(q,he,"bindMatrixInverse");let si=he.skeleton;si&&(te.floatVertexTextures?(si.boneTexture===null&&si.computeBoneTexture(),zn.setValue(q,"boneTexture",si.boneTexture,ae),zn.setValue(q,"boneTextureSize",si.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let op=ie.morphAttributes;return(op.position!==void 0||op.normal!==void 0||op.color!==void 0&&te.isWebGL2===!0)&&pe.update(he,ie,ne,ii),(Zl||St.receiveShadow!==he.receiveShadow)&&(St.receiveShadow=he.receiveShadow,zn.setValue(q,"receiveShadow",he.receiveShadow)),Zl&&(zn.setValue(q,"toneMappingExposure",p.toneMappingExposure),St.needsLights&&xM(Jl,sp),Je&&ne.fog===!0&&Re.refreshFogUniforms(Jl,Je),Re.refreshMaterialUniforms(Jl,ne,C,E,F),ea.upload(q,St.uniformsList,Jl,ae)),ne.isShaderMaterial&&ne.uniformsNeedUpdate===!0&&(ea.upload(q,St.uniformsList,Jl,ae),ne.uniformsNeedUpdate=!1),ne.isSpriteMaterial&&zn.setValue(q,"center",he.center),zn.setValue(q,"modelViewMatrix",he.modelViewMatrix),zn.setValue(q,"normalMatrix",he.normalMatrix),zn.setValue(q,"modelMatrix",he.matrixWorld),ii}function xM(L,$){L.ambientLightColor.needsUpdate=$,L.lightProbe.needsUpdate=$,L.directionalLights.needsUpdate=$,L.directionalLightShadows.needsUpdate=$,L.pointLights.needsUpdate=$,L.pointLightShadows.needsUpdate=$,L.spotLights.needsUpdate=$,L.spotLightShadows.needsUpdate=$,L.rectAreaLights.needsUpdate=$,L.hemisphereLights.needsUpdate=$}function bM(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return x},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(L,$,ie){ce.get(L.texture).__webglTexture=$,ce.get(L.depthTexture).__webglTexture=ie;let ne=ce.get(L);ne.__hasExternalTextures=!0,ne.__hasExternalTextures&&(ne.__autoAllocateDepthBuffer=ie===void 0,ne.__autoAllocateDepthBuffer||Z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ne.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,$){let ie=ce.get(L);ie.__webglFramebuffer=$,ie.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(L,$=0,ie=0){w=L,x=$,v=ie;let ne=!0;if(L){let it=ce.get(L);it.__useDefaultFramebuffer!==void 0?(k.bindFramebuffer(36160,null),ne=!1):it.__webglFramebuffer===void 0?ae.setupRenderTarget(L):it.__hasExternalTextures&&ae.rebindTextures(L,ce.get(L.texture).__webglTexture,ce.get(L.depthTexture).__webglTexture)}let he=null,Je=!1,et=!1;if(L){let it=L.texture;(it.isData3DTexture||it.isDataArrayTexture)&&(et=!0);let Et=ce.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(he=Et[$],Je=!0):te.isWebGL2&&L.samples>0&&ae.useMultisampledRTT(L)===!1?he=ce.get(L).__webglMultisampledFramebuffer:he=Et,M.copy(L.viewport),_.copy(L.scissor),y=L.scissorTest}else M.copy(N).multiplyScalar(C).floor(),_.copy(H).multiplyScalar(C).floor(),y=j;if(k.bindFramebuffer(36160,he)&&te.drawBuffers&&ne&&k.drawBuffers(L,he),k.viewport(M),k.scissor(_),k.setScissorTest(y),Je){let it=ce.get(L.texture);q.framebufferTexture2D(36160,36064,34069+$,it.__webglTexture,ie)}else if(et){let it=ce.get(L.texture),Et=$||0;q.framebufferTextureLayer(36160,36064,it.__webglTexture,ie||0,Et)}b=-1},this.readRenderTargetPixels=function(L,$,ie,ne,he,Je,et){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let st=ce.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&et!==void 0&&(st=st[et]),st){k.bindFramebuffer(36160,st);try{let it=L.texture,Et=it.format,ut=it.type;if(Et!==xr&&re.convert(Et)!==q.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let yt=ut===hc&&(Z.has("EXT_color_buffer_half_float")||te.isWebGL2&&Z.has("EXT_color_buffer_float"));if(ut!==Lt&&re.convert(ut)!==q.getParameter(35738)&&!(ut===vr&&(te.isWebGL2||Z.has("OES_texture_float")||Z.has("WEBGL_color_buffer_float")))&&!yt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=L.width-ne&&ie>=0&&ie<=L.height-he&&q.readPixels($,ie,ne,he,re.convert(Et),re.convert(ut),Je)}finally{let it=w!==null?ce.get(w).__webglFramebuffer:null;k.bindFramebuffer(36160,it)}}},this.copyFramebufferToTexture=function(L,$,ie=0){let ne=Math.pow(2,-ie),he=Math.floor($.image.width*ne),Je=Math.floor($.image.height*ne);ae.setTexture2D($,0),q.copyTexSubImage2D(3553,ie,0,0,L.x,L.y,he,Je),k.unbindTexture()},this.copyTextureToTexture=function(L,$,ie,ne=0){let he=$.image.width,Je=$.image.height,et=re.convert(ie.format),st=re.convert(ie.type);ae.setTexture2D(ie,0),q.pixelStorei(37440,ie.flipY),q.pixelStorei(37441,ie.premultiplyAlpha),q.pixelStorei(3317,ie.unpackAlignment),$.isDataTexture?q.texSubImage2D(3553,ne,L.x,L.y,he,Je,et,st,$.image.data):$.isCompressedTexture?q.compressedTexSubImage2D(3553,ne,L.x,L.y,$.mipmaps[0].width,$.mipmaps[0].height,et,$.mipmaps[0].data):q.texSubImage2D(3553,ne,L.x,L.y,et,st,$.image),ne===0&&ie.generateMipmaps&&q.generateMipmap(3553),k.unbindTexture()},this.copyTextureToTexture3D=function(L,$,ie,ne,he=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Je=L.max.x-L.min.x+1,et=L.max.y-L.min.y+1,st=L.max.z-L.min.z+1,it=re.convert(ne.format),Et=re.convert(ne.type),ut;if(ne.isData3DTexture)ae.setTexture3D(ne,0),ut=32879;else if(ne.isDataArrayTexture)ae.setTexture2DArray(ne,0),ut=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}q.pixelStorei(37440,ne.flipY),q.pixelStorei(37441,ne.premultiplyAlpha),q.pixelStorei(3317,ne.unpackAlignment);let yt=q.getParameter(3314),Wt=q.getParameter(32878),Ys=q.getParameter(3316),Ro=q.getParameter(3315),Bo=q.getParameter(32877),ri=ie.isCompressedTexture?ie.mipmaps[0]:ie.image;q.pixelStorei(3314,ri.width),q.pixelStorei(32878,ri.height),q.pixelStorei(3316,L.min.x),q.pixelStorei(3315,L.min.y),q.pixelStorei(32877,L.min.z),ie.isDataTexture||ie.isData3DTexture?q.texSubImage3D(ut,he,$.x,$.y,$.z,Je,et,st,it,Et,ri.data):ie.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),q.compressedTexSubImage3D(ut,he,$.x,$.y,$.z,Je,et,st,it,ri.data)):q.texSubImage3D(ut,he,$.x,$.y,$.z,Je,et,st,it,Et,ri),q.pixelStorei(3314,yt),q.pixelStorei(32878,Wt),q.pixelStorei(3316,Ys),q.pixelStorei(3315,Ro),q.pixelStorei(32877,Bo),he===0&&ne.generateMipmaps&&q.generateMipmap(ut),k.unbindTexture()},this.initTexture=function(L){ae.setTexture2D(L,0),k.unbindTexture()},this.resetState=function(){x=0,v=0,w=null,k.reset(),Be.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var lm=class extends Wm{};lm.prototype.isWebGL1Renderer=!0;var sa=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ae(e),this.near=t,this.far=n}clone(){return new sa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Wn=class extends ct{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}},wu=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Yp,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ci()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ci()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ci()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Gn=new A,io=class{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i===!0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.applyMatrix4(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.applyNormalMatrix(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Gn.fromBufferAttribute(this,t),Gn.transformDirection(e),this.setXYZ(t,Gn.x,Gn.y,Gn.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new Xe(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new io(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},cm=class extends un{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};var hm=class extends Xe{constructor(e,t,n,i=1){typeof n=="number"&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};var Jn=class extends un{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ae(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},N0=new A,R0=new A,B0=new Oe,zp=new ro,nu=new Rn,so=class extends ct{constructor(e=new Le,t=new Jn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)N0.fromBufferAttribute(t,i-1),R0.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=N0.distanceTo(R0);e.setAttribute("lineDistance",new Se(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),nu.copy(n.boundingSphere),nu.applyMatrix4(i),nu.radius+=s,e.ray.intersectsSphere(nu)===!1)return;B0.copy(i).invert(),zp.copy(e.ray).applyMatrix4(B0);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=new A,h=new A,u=new A,d=new A,f=this.isLineSegments?2:1,m=n.index,g=n.attributes.position;if(m!==null){let x=Math.max(0,o.start),v=Math.min(m.count,o.start+o.count);for(let w=x,b=v-1;w<b;w+=f){let S=m.getX(w),M=m.getX(w+1);if(c.fromBufferAttribute(g,S),h.fromBufferAttribute(g,M),zp.distanceSqToSegment(c,h,d,u)>l)continue;d.applyMatrix4(this.matrixWorld);let y=e.ray.origin.distanceTo(d);y<e.near||y>e.far||t.push({distance:y,point:u.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{let x=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let w=x,b=v-1;w<b;w+=f){if(c.fromBufferAttribute(g,w),h.fromBufferAttribute(g,w+1),zp.distanceSqToSegment(c,h,d,u)>l)continue;d.applyMatrix4(this.matrixWorld);let M=e.ray.origin.distanceTo(d);M<e.near||M>e.far||t.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},O0=new A,F0=new A,ms=class extends so{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)O0.fromBufferAttribute(t,i),F0.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+O0.distanceTo(F0);e.setAttribute("lineDistance",new Se(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var um=class extends un{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}};var Sr=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),i=0,s=n.length,o;t?o=t:o=e*n[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let h=n[i],d=n[i+1]-h,f=(o-h)/d;return(i+f)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new B:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new A,i=[],s=[],o=[],a=new A,l=new Oe;for(let f=0;f<=e;f++){let m=f/e;i[f]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let c=Number.MAX_VALUE,h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(sn(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(sn(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},oo=class extends Sr{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let n=t||new B,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},dm=class extends oo{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function jm(){let r=0,e=0,t=0,n=0;function i(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,u){let d=(o-s)/c-(a-s)/(c+h)+(a-o)/h,f=(a-o)/h-(l-o)/(h+u)+(l-a)/u;d*=h,f*=h,i(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return r+e*s+t*o+n*a}}}var ru=new A,Gp=new jm,kp=new jm,Vp=new jm,fm=class extends Sr{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new A){let n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(ru.subVectors(i[0],i[1]).add(i[0]),c=ru);let u=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(ru.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=ru),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(c.distanceToSquared(u),f),p=Math.pow(u.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(h),f);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),Gp.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,m,p,g),kp.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,m,p,g),Vp.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,m,p,g)}else this.curveType==="catmullrom"&&(Gp.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),kp.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Vp.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(Gp.calc(l),kp.calc(l),Vp.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new A().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function U0(r,e,t,n,i){let s=(n-e)*.5,o=(i-t)*.5,a=r*r,l=r*a;return(2*t-2*n+s+o)*l+(-3*t+3*n-2*s-o)*a+s*r+t}function SD(r,e){let t=1-r;return t*t*e}function AD(r,e){return 2*(1-r)*r*e}function MD(r,e){return r*r*e}function lc(r,e,t,n){return SD(r,e)+AD(r,t)+MD(r,n)}function _D(r,e){let t=1-r;return t*t*t*e}function TD(r,e){let t=1-r;return 3*t*t*r*e}function ED(r,e){return 3*(1-r)*r*r*e}function CD(r,e){return r*r*r*e}function cc(r,e,t,n,i){return _D(r,e)+TD(r,t)+ED(r,n)+CD(r,i)}var $n=class extends Sr{constructor(e=new B,t=new B,n=new B,i=new B){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new B){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(cc(e,i.x,s.x,o.x,a.x),cc(e,i.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},pm=class extends Sr{constructor(e=new A,t=new A,n=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new A){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(cc(e,i.x,s.x,o.x,a.x),cc(e,i.y,s.y,o.y,a.y),cc(e,i.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},er=class extends Sr{constructor(e=new B,t=new B){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new B){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let n=t||new B;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},pc=class extends Sr{constructor(e=new A,t=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new A){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Vr=class extends Sr{constructor(e=new B,t=new B,n=new B){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new B){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(lc(e,i.x,s.x,o.x),lc(e,i.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},mm=class extends Sr{constructor(e=new A,t=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new A){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(lc(e,i.x,s.x,o.x),lc(e,i.y,s.y,o.y),lc(e,i.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},oa=class extends Sr{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new B){let n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(U0(a,l.x,c.x,h.x,u.x),U0(a,l.y,c.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new B().fromArray(i))}return this}},DD=Object.freeze({__proto__:null,ArcCurve:dm,CatmullRomCurve3:fm,CubicBezierCurve:$n,CubicBezierCurve3:pm,EllipseCurve:oo,LineCurve:er,LineCurve3:pc,QuadraticBezierCurve:Vr,QuadraticBezierCurve3:mm,SplineCurve:oa}),gm=class extends Sr{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new er(t,e))}getPoint(e,t){let n=e*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){let h=l[c];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(new DD[i.type]().fromJSON(i))}return this}},mc=class extends gm{constructor(e){super(),this.type="Path",this.currentPoint=new B,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new er(this.currentPoint.clone(),new B(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let s=new Vr(this.currentPoint.clone(),new B(e,t),new B(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){let a=new $n(this.currentPoint.clone(),new B(e,t),new B(n,i),new B(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new oa(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,l){let c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+c,t+h,n,i,s,o,a,l),this}absellipse(e,t,n,i,s,o,a,l){let c=new oo(e,t,n,i,s,o,a,l);if(this.curves.length>0){let u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);let h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},aa=class extends Le{constructor(e=[new B(0,.5),new B(.5,0),new B(0,-.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=sn(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],h=1/t,u=new A,d=new B,f=new A,m=new A,p=new A,g=0,x=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,x=e[v+1].y-e[v].y,f.x=x*1,f.y=-g,f.z=x*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(p.x,p.y,p.z);break;default:g=e[v+1].x-e[v].x,x=e[v+1].y-e[v].y,f.x=x*1,f.y=-g,f.z=x*0,m.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(m)}for(let v=0;v<=t;v++){let w=n+v*h*i,b=Math.sin(w),S=Math.cos(w);for(let M=0;M<=e.length-1;M++){u.x=e[M].x*b,u.y=e[M].y,u.z=e[M].x*S,o.push(u.x,u.y,u.z),d.x=v/t,d.y=M/(e.length-1),a.push(d.x,d.y);let _=l[3*M+0]*b,y=l[3*M+1],T=l[3*M+0]*S;c.push(_,y,T)}}for(let v=0;v<t;v++)for(let w=0;w<e.length-1;w++){let b=w+v*e.length,S=b,M=b+e.length,_=b+e.length+1,y=b+1;s.push(S,M,y),s.push(_,y,M)}this.setIndex(s),this.setAttribute("position",new Se(o,3)),this.setAttribute("uv",new Se(a,2)),this.setAttribute("normal",new Se(c,3))}static fromJSON(e){return new aa(e.points,e.segments,e.phiStart,e.phiLength)}};var ao=class extends Le{constructor(e=1,t=1,n=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let c=this;i=Math.floor(i),s=Math.floor(s);let h=[],u=[],d=[],f=[],m=0,p=[],g=n/2,x=0;v(),o===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new Se(u,3)),this.setAttribute("normal",new Se(d,3)),this.setAttribute("uv",new Se(f,2));function v(){let b=new A,S=new A,M=0,_=(t-e)/n;for(let y=0;y<=s;y++){let T=[],E=y/s,C=E*(t-e)+e;for(let I=0;I<=i;I++){let R=I/i,N=R*l+a,H=Math.sin(N),j=Math.cos(N);S.x=C*H,S.y=-E*n+g,S.z=C*j,u.push(S.x,S.y,S.z),b.set(H,_,j).normalize(),d.push(b.x,b.y,b.z),f.push(R,1-E),T.push(m++)}p.push(T)}for(let y=0;y<i;y++)for(let T=0;T<s;T++){let E=p[T][y],C=p[T+1][y],I=p[T+1][y+1],R=p[T][y+1];h.push(E,C,R),h.push(C,I,R),M+=6}c.addGroup(x,M,0),x+=M}function w(b){let S=m,M=new B,_=new A,y=0,T=b===!0?e:t,E=b===!0?1:-1;for(let I=1;I<=i;I++)u.push(0,g*E,0),d.push(0,E,0),f.push(.5,.5),m++;let C=m;for(let I=0;I<=i;I++){let N=I/i*l+a,H=Math.cos(N),j=Math.sin(N);_.x=T*j,_.y=g*E,_.z=T*H,u.push(_.x,_.y,_.z),d.push(0,E,0),M.x=H*.5+.5,M.y=j*.5*E+.5,f.push(M.x,M.y),m++}for(let I=0;I<i;I++){let R=S+I,N=C+I;b===!0?h.push(N,N+1,R):h.push(N+1,N,R),y+=3}c.addGroup(x,y,b===!0?1:2),x+=y}}static fromJSON(e){return new ao(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},la=class extends ao{constructor(e=1,t=1,n=8,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new la(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ca=class extends Le{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};let s=[],o=[];a(i),c(n),h(),this.setAttribute("position",new Se(s,3)),this.setAttribute("normal",new Se(s.slice(),3)),this.setAttribute("uv",new Se(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let w=new A,b=new A,S=new A;for(let M=0;M<t.length;M+=3)f(t[M+0],w),f(t[M+1],b),f(t[M+2],S),l(w,b,S,v)}function l(v,w,b,S){let M=S+1,_=[];for(let y=0;y<=M;y++){_[y]=[];let T=v.clone().lerp(b,y/M),E=w.clone().lerp(b,y/M),C=M-y;for(let I=0;I<=C;I++)I===0&&y===M?_[y][I]=T:_[y][I]=T.clone().lerp(E,I/C)}for(let y=0;y<M;y++)for(let T=0;T<2*(M-y)-1;T++){let E=Math.floor(T/2);T%2===0?(d(_[y][E+1]),d(_[y+1][E]),d(_[y][E])):(d(_[y][E+1]),d(_[y+1][E+1]),d(_[y+1][E]))}}function c(v){let w=new A;for(let b=0;b<s.length;b+=3)w.x=s[b+0],w.y=s[b+1],w.z=s[b+2],w.normalize().multiplyScalar(v),s[b+0]=w.x,s[b+1]=w.y,s[b+2]=w.z}function h(){let v=new A;for(let w=0;w<s.length;w+=3){v.x=s[w+0],v.y=s[w+1],v.z=s[w+2];let b=g(v)/2/Math.PI+.5,S=x(v)/Math.PI+.5;o.push(b,1-S)}m(),u()}function u(){for(let v=0;v<o.length;v+=6){let w=o[v+0],b=o[v+2],S=o[v+4],M=Math.max(w,b,S),_=Math.min(w,b,S);M>.9&&_<.1&&(w<.2&&(o[v+0]+=1),b<.2&&(o[v+2]+=1),S<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,w){let b=v*3;w.x=e[b+0],w.y=e[b+1],w.z=e[b+2]}function m(){let v=new A,w=new A,b=new A,S=new A,M=new B,_=new B,y=new B;for(let T=0,E=0;T<s.length;T+=9,E+=6){v.set(s[T+0],s[T+1],s[T+2]),w.set(s[T+3],s[T+4],s[T+5]),b.set(s[T+6],s[T+7],s[T+8]),M.set(o[E+0],o[E+1]),_.set(o[E+2],o[E+3]),y.set(o[E+4],o[E+5]),S.copy(v).add(w).add(b).divideScalar(3);let C=g(S);p(M,E+0,v,C),p(_,E+2,w,C),p(y,E+4,b,C)}}function p(v,w,b,S){S<0&&v.x===1&&(o[w]=v.x-1),b.x===0&&b.z===0&&(o[w]=S/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function x(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new ca(e.vertices,e.indices,e.radius,e.details)}},ha=class extends ca{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ha(e.radius,e.detail)}},cz=new A,hz=new A,uz=new A,dz=new Kn;var Gr=class extends mc{constructor(e){super(e),this.uuid=ci(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(new mc().fromJSON(i))}return this}},PD={triangulate:function(r,e,t=2){let n=e&&e.length,i=n?e[0]*t:r.length,s=ux(r,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,c,h,u,d,f;if(n&&(s=BD(r,e,s,t)),r.length>80*t){a=c=r[0],l=h=r[1];for(let m=t;m<i;m+=t)u=r[m],d=r[m+1],u<a&&(a=u),d<l&&(l=d),u>c&&(c=u),d>h&&(h=d);f=Math.max(c-a,h-l),f=f!==0?1/f:0}return gc(s,o,t,a,l,f),o}};function ux(r,e,t,n,i){let s,o;if(i===qD(r,e,t,n)>0)for(s=e;s<t;s+=n)o=z0(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=z0(s,r[s],r[s+1],o);return o&&Uu(o,o.next)&&(vc(o),o=o.next),o}function gs(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(Uu(t,t.next)||kt(t.prev,t,t.next)===0)){if(vc(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function gc(r,e,t,n,i,s,o){if(!r)return;!o&&s&&GD(r,n,i,s);let a=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?ID(r,n,i,s):LD(r)){e.push(l.i/t),e.push(r.i/t),e.push(c.i/t),vc(r),r=c.next,a=c.next;continue}if(r=c,r===a){o?o===1?(r=ND(gs(r),e,t),gc(r,e,t,n,i,s,2)):o===2&&RD(r,e,t,n,i,s):gc(gs(r),e,t,n,i,s,1);break}}}function LD(r){let e=r.prev,t=r,n=r.next;if(kt(e,t,n)>=0)return!1;let i=r.next.next;for(;i!==r.prev;){if($o(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&kt(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function ID(r,e,t,n){let i=r.prev,s=r,o=r.next;if(kt(i,s,o)>=0)return!1;let a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,c=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,h=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,u=ym(a,l,e,t,n),d=ym(c,h,e,t,n),f=r.prevZ,m=r.nextZ;for(;f&&f.z>=u&&m&&m.z<=d;){if(f!==r.prev&&f!==r.next&&$o(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&kt(f.prev,f,f.next)>=0||(f=f.prevZ,m!==r.prev&&m!==r.next&&$o(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&kt(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;f&&f.z>=u;){if(f!==r.prev&&f!==r.next&&$o(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&kt(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;m&&m.z<=d;){if(m!==r.prev&&m!==r.next&&$o(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&kt(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function ND(r,e,t){let n=r;do{let i=n.prev,s=n.next.next;!Uu(i,s)&&dx(i,n,n.next,s)&&yc(i,s)&&yc(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),vc(n),vc(n.next),n=r=s),n=n.next}while(n!==r);return gs(n)}function RD(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&HD(o,a)){let l=fx(o,a);o=gs(o,o.next),l=gs(l,l.next),gc(o,e,t,n,i,s),gc(l,e,t,n,i,s);return}a=a.next}o=o.next}while(o!==r)}function BD(r,e,t,n){let i=[],s,o,a,l,c;for(s=0,o=e.length;s<o;s++)a=e[s]*n,l=s<o-1?e[s+1]*n:r.length,c=ux(r,a,l,n,!1),c===c.next&&(c.steiner=!0),i.push(VD(c));for(i.sort(OD),s=0;s<i.length;s++)FD(i[s],t),t=gs(t,t.next);return t}function OD(r,e){return r.x-e.x}function FD(r,e){if(e=UD(r,e),e){let t=fx(e,r);gs(e,e.next),gs(t,t.next)}}function UD(r,e){let t=e,n=r.x,i=r.y,s=-1/0,o;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){let d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>s){if(s=d,d===n){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(n===s)return o;let a=o,l=o.x,c=o.y,h=1/0,u;t=o;do n>=t.x&&t.x>=l&&n!==t.x&&$o(i<c?n:s,i,l,c,i<c?s:n,i,t.x,t.y)&&(u=Math.abs(i-t.y)/(n-t.x),yc(t,r)&&(u<h||u===h&&(t.x>o.x||t.x===o.x&&zD(o,t)))&&(o=t,h=u)),t=t.next;while(t!==a);return o}function zD(r,e){return kt(r.prev,r,e.prev)<0&&kt(e.next,r,r.next)<0}function GD(r,e,t,n){let i=r;do i.z===null&&(i.z=ym(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,kD(i)}function kD(r){let e,t,n,i,s,o,a,l,c=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<c&&(a++,n=n.nextZ,!!n);e++);for(l=c;a>0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,c*=2}while(o>1);return r}function ym(r,e,t,n,i){return r=32767*(r-t)*i,e=32767*(e-n)*i,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function VD(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function $o(r,e,t,n,i,s,o,a){return(i-o)*(e-a)-(r-o)*(s-a)>=0&&(r-o)*(n-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(i-o)*(n-a)>=0}function HD(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!WD(r,e)&&(yc(r,e)&&yc(e,r)&&jD(r,e)&&(kt(r.prev,r,e.prev)||kt(r,e.prev,e))||Uu(r,e)&&kt(r.prev,r,r.next)>0&&kt(e.prev,e,e.next)>0)}function kt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Uu(r,e){return r.x===e.x&&r.y===e.y}function dx(r,e,t,n){let i=su(kt(r,e,t)),s=su(kt(r,e,n)),o=su(kt(t,n,r)),a=su(kt(t,n,e));return!!(i!==s&&o!==a||i===0&&iu(r,t,e)||s===0&&iu(r,n,e)||o===0&&iu(t,r,n)||a===0&&iu(t,e,n))}function iu(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function su(r){return r>0?1:r<0?-1:0}function WD(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&dx(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function yc(r,e){return kt(r.prev,r,r.next)<0?kt(r,e,r.next)>=0&&kt(r,r.prev,e)>=0:kt(r,e,r.prev)<0||kt(r,r.next,e)<0}function jD(r,e){let t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function fx(r,e){let t=new vm(r.i,r.x,r.y),n=new vm(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function z0(r,e,t,n){let i=new vm(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function vc(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function vm(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qD(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var hs=class{static area(e){let t=e.length,n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return hs.area(e)<0}static triangulateShape(e,t){let n=[],i=[],s=[];G0(e),k0(n,e);let o=e.length;t.forEach(G0);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,k0(n,t[l]);let a=PD.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function G0(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function k0(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var ua=class extends ca{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ua(e.radius,e.detail)}};var da=class extends Le{constructor(e=new Gr([new B(0,.5),new B(-.5,-.5),new B(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let n=[],i=[],s=[],o=[],a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let h=0;h<e.length;h++)c(e[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(n),this.setAttribute("position",new Se(i,3)),this.setAttribute("normal",new Se(s,3)),this.setAttribute("uv",new Se(o,2));function c(h){let u=i.length/3,d=h.extractPoints(t),f=d.shape,m=d.holes;hs.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,x=m.length;g<x;g++){let v=m[g];hs.isClockWise(v)===!0&&(m[g]=v.reverse())}let p=hs.triangulateShape(f,m);for(let g=0,x=m.length;g<x;g++){let v=m[g];f=f.concat(v)}for(let g=0,x=f.length;g<x;g++){let v=f[g];i.push(v.x,v.y,0),s.push(0,0,1),o.push(v.x,v.y)}for(let g=0,x=p.length;g<x;g++){let v=p[g],w=v[0]+u,b=v[1]+u,S=v[2]+u;n.push(w,b,S),l+=3}}}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return XD(t,e)}static fromJSON(e,t){let n=[];for(let i=0,s=e.shapes.length;i<s;i++){let o=t[e.shapes[i]];n.push(o)}return new da(n,e.curveSegments)}};function XD(r,e){if(e.shapes=[],Array.isArray(r))for(let t=0,n=r.length;t<n;t++){let i=r[t];e.shapes.push(i.uuid)}else e.shapes.push(r.uuid);return e}var lo=class extends Le{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),c=0,h=[],u=new A,d=new A,f=[],m=[],p=[],g=[];for(let x=0;x<=n;x++){let v=[],w=x/n,b=0;x==0&&o==0?b=.5/t:x==n&&l==Math.PI&&(b=-.5/t);for(let S=0;S<=t;S++){let M=S/t;u.x=-e*Math.cos(i+M*s)*Math.sin(o+w*a),u.y=e*Math.cos(o+w*a),u.z=e*Math.sin(i+M*s)*Math.sin(o+w*a),m.push(u.x,u.y,u.z),d.copy(u).normalize(),p.push(d.x,d.y,d.z),g.push(M+b,1-w),v.push(c++)}h.push(v)}for(let x=0;x<n;x++)for(let v=0;v<t;v++){let w=h[x][v+1],b=h[x][v],S=h[x+1][v],M=h[x+1][v+1];(x!==0||o>0)&&f.push(w,b,M),(x!==n-1||l<Math.PI)&&f.push(b,S,M)}this.setIndex(f),this.setAttribute("position",new Se(m,3)),this.setAttribute("normal",new Se(p,3)),this.setAttribute("uv",new Se(g,2))}static fromJSON(e){return new lo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var fa=class extends Le{constructor(e=1,t=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],l=[],c=[],h=[],u=new A,d=new A,f=new A,m=new A,p=new A,g=new A,x=new A;for(let w=0;w<=n;++w){let b=w/n*s*Math.PI*2;v(b,s,o,e,f),v(b+.01,s,o,e,m),g.subVectors(m,f),x.addVectors(m,f),p.crossVectors(g,x),x.crossVectors(p,g),p.normalize(),x.normalize();for(let S=0;S<=i;++S){let M=S/i*Math.PI*2,_=-t*Math.cos(M),y=t*Math.sin(M);u.x=f.x+(_*x.x+y*p.x),u.y=f.y+(_*x.y+y*p.y),u.z=f.z+(_*x.z+y*p.z),l.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),c.push(d.x,d.y,d.z),h.push(w/n),h.push(S/i)}}for(let w=1;w<=n;w++)for(let b=1;b<=i;b++){let S=(i+1)*(w-1)+(b-1),M=(i+1)*w+(b-1),_=(i+1)*w+b,y=(i+1)*(w-1)+b;a.push(S,M,y),a.push(M,_,y)}this.setIndex(a),this.setAttribute("position",new Se(l,3)),this.setAttribute("normal",new Se(c,3)),this.setAttribute("uv",new Se(h,2));function v(w,b,S,M,_){let y=Math.cos(w),T=Math.sin(w),E=S/b*w,C=Math.cos(E);_.x=M*(2+C)*.5*y,_.y=M*(2+C)*T*.5,_.z=M*Math.sin(E)*.5}}static fromJSON(e){return new fa(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};var xm=class extends un{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ae(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},bm=class extends dt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Su=class extends un{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ae(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},wm=class extends Su{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new B(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return sn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ae(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new Ae(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ae(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Sm=class extends un{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ae(16777215),this.specular=new Ae(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ou,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Am=class extends un{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ae(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Mm=class extends un{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},_m=class extends un{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ou,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Tm=class extends un{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ae(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=va,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},Em=class extends Jn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}},YD={ShadowMaterial:xm,SpriteMaterial:cm,RawShaderMaterial:bm,ShaderMaterial:dt,PointsMaterial:um,MeshPhysicalMaterial:wm,MeshStandardMaterial:Su,MeshPhongMaterial:Sm,MeshToonMaterial:Am,MeshNormalMaterial:Mm,MeshLambertMaterial:_m,MeshDepthMaterial:xu,MeshDistanceMaterial:bu,MeshBasicMaterial:hi,MeshMatcapMaterial:Tm,LineDashedMaterial:Em,LineBasicMaterial:Jn,Material:un};un.fromType=function(r){return new YD[r]};var cn={arraySlice:function(r,e,t){return cn.isTypedArray(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)},convertArray:function(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)},isTypedArray:function(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)},getKeyframeOrder:function(r){function e(i,s){return r[i]-r[s]}let t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n},sortedArray:function(r,e,t){let n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i},flattenJSON:function(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)},subclip:function(r,e,t,n,i=30){let s=r.clone();s.name=e;let o=[];for(let l=0;l<s.tracks.length;++l){let c=s.tracks[l],h=c.getValueSize(),u=[],d=[];for(let f=0;f<c.times.length;++f){let m=c.times[f]*i;if(!(m<t||m>=n)){u.push(c.times[f]);for(let p=0;p<h;++p)d.push(c.values[f*h+p])}}u.length!==0&&(c.times=cn.convertArray(u,c.times.constructor),c.values=cn.convertArray(d,c.values.constructor),o.push(c))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(r,e=0,t=r,n=30){n<=0&&(n=30);let i=t.tracks.length,s=e/n;for(let o=0;o<i;++o){let a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;let c=r.tracks.find(function(x){return x.name===a.name&&x.ValueTypeName===l});if(c===void 0)continue;let h=0,u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let d=0,f=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);let m=a.times.length-1,p;if(s<=a.times[0]){let x=h,v=u-h;p=cn.arraySlice(a.values,x,v)}else if(s>=a.times[m]){let x=m*u+h,v=x+u-h;p=cn.arraySlice(a.values,x,v)}else{let x=a.createInterpolant(),v=h,w=u-h;x.evaluate(s),p=cn.arraySlice(x.resultBuffer,v,w)}l==="quaternion"&&new Xt().fromArray(p).normalize().conjugate().toArray(p);let g=c.times.length;for(let x=0;x<g;++x){let v=x*f+d;if(l==="quaternion")Xt.multiplyQuaternionsFlat(c.values,v,p,0,c.values,v);else{let w=f-d*2;for(let b=0;b<w;++b)c.values[v+b]-=p[b]}}}return r.blendMode=w_,r}},pa=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let o;t:{r:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break r;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break e}o=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Cm=class extends pa{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Kv,endingEnd:Kv}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Zv:s=e,a=2*t-n;break;case Jv:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Zv:o=e,l=2*n-t;break;case Jv:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}let c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=o*h}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,m=(n-t)/(i-t),p=m*m,g=p*m,x=-d*g+2*d*p-d*m,v=(1+d)*g+(-1.5-2*d)*p+(-.5+d)*m+1,w=(-1-f)*g+(1.5+f)*p+.5*m,b=f*g-f*p;for(let S=0;S!==a;++S)s[S]=x*o[h+S]+v*o[c+S]+w*o[l+S]+b*o[u+S];return s}},Dm=class extends pa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=(n-t)/(i-t),u=1-h;for(let d=0;d!==a;++d)s[d]=o[c+d]*u+o[l+d]*h;return s}},Pm=class extends pa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},Hr=class{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=cn.convertArray(t,this.TimeBufferType),this.values=cn.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:cn.convertArray(e.times,Array),values:cn.convertArray(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Pm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Dm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Cm(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case hu:t=this.InterpolantFactoryMethodDiscrete;break;case uu:t=this.InterpolantFactoryMethodLinear;break;case dp:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return hu;case this.InterpolantFactoryMethodLinear:return uu;case this.InterpolantFactoryMethodSmooth:return dp}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=cn.arraySlice(n,s,o),this.values=cn.arraySlice(this.values,s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&cn.isTypedArray(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=cn.arraySlice(this.times),t=cn.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===dp,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,c=e[a],h=e[a+1];if(c!==h&&(a!==1||c!==e[0]))if(i)l=!0;else{let u=a*n,d=u-n,f=u+n;for(let m=0;m!==n;++m){let p=t[u+m];if(p!==t[d+m]||p!==t[f+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let u=a*n,d=o*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=cn.arraySlice(e,0,o),this.values=cn.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this}clone(){let e=cn.arraySlice(this.times,0),t=cn.arraySlice(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Hr.prototype.TimeBufferType=Float32Array;Hr.prototype.ValueBufferType=Float32Array;Hr.prototype.DefaultInterpolation=uu;var co=class extends Hr{};co.prototype.ValueTypeName="bool";co.prototype.ValueBufferType=Array;co.prototype.DefaultInterpolation=hu;co.prototype.InterpolantFactoryMethodLinear=void 0;co.prototype.InterpolantFactoryMethodSmooth=void 0;var Lm=class extends Hr{};Lm.prototype.ValueTypeName="color";var Im=class extends Hr{};Im.prototype.ValueTypeName="number";var Nm=class extends pa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t),c=e*a;for(let h=c+a;c!==h;c+=4)Xt.slerpFlat(s,0,o,c-a,o,c,l);return s}},xc=class extends Hr{InterpolantFactoryMethodLinear(e){return new Nm(this.times,this.values,this.getValueSize(),e)}};xc.prototype.ValueTypeName="quaternion";xc.prototype.DefaultInterpolation=uu;xc.prototype.InterpolantFactoryMethodSmooth=void 0;var ho=class extends Hr{};ho.prototype.ValueTypeName="string";ho.prototype.ValueBufferType=Array;ho.prototype.DefaultInterpolation=hu;ho.prototype.InterpolantFactoryMethodLinear=void 0;ho.prototype.InterpolantFactoryMethodSmooth=void 0;var Rm=class extends Hr{};Rm.prototype.ValueTypeName="vector";var V0={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},uo=class{constructor(e,t,n){let i=this,s=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){let u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){let f=c[u],m=c[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return m}return null}}},QD=new uo,ys=class{constructor(e){this.manager=e!==void 0?e:QD,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},Bi={},vs=class extends ys{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=V0.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Bi[e]!==void 0){Bi[e].push({onLoad:t,onProgress:n,onError:i});return}Bi[e]=[],Bi[e].push({onLoad:t,onProgress:n,onError:i});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let h=Bi[e],u=c.body.getReader(),d=c.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0,p=0,g=new ReadableStream({start(x){v();function v(){u.read().then(({done:w,value:b})=>{if(w)x.close();else{p+=b.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let M=0,_=h.length;M<_;M++){let y=h[M];y.onProgress&&y.onProgress(S)}x.enqueue(b),v()}})}}});return new Response(g)}else throw Error(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a===void 0)return c.text();{let u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{V0.add(e,c);let h=Bi[e];delete Bi[e];for(let u=0,d=h.length;u<d;u++){let f=h[u];f.onLoad&&f.onLoad(c)}}).catch(c=>{let h=Bi[e];if(h===void 0)throw this.manager.itemError(e),c;delete Bi[e];for(let u=0,d=h.length;u<d;u++){let f=h[u];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var ma=class extends ct{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ae(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},fo=class extends ma{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ct.DefaultUp),this.updateMatrix(),this.groundColor=new Ae(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},H0=new Oe,W0=new A,j0=new A,bc=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new B(512,512),this.map=null,this.mapPass=null,this.matrix=new Oe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new fc,this._frameExtents=new B(1,1),this._viewportCount=1,this._viewports=[new qe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;W0.setFromMatrixPosition(e.matrixWorld),t.position.copy(W0),j0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(j0),t.updateMatrixWorld(),H0.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(H0),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Bm=class extends bc{constructor(){super(new Zt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=uc*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Au=class extends ma{constructor(e,t,n=0,i=Math.PI/3,s=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ct.DefaultUp),this.updateMatrix(),this.target=new ct,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.shadow=new Bm}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},q0=new Oe,nc=new A,Hp=new A,Om=class extends bc{constructor(){super(new Zt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new B(4,2),this._viewportCount=6,this._viewports=[new qe(2,1,1,1),new qe(0,1,1,1),new qe(3,1,1,1),new qe(1,1,1,1),new qe(3,0,1,1),new qe(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),nc.setFromMatrixPosition(e.matrixWorld),n.position.copy(nc),Hp.copy(n.position),Hp.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Hp),n.updateMatrixWorld(),i.makeTranslation(-nc.x,-nc.y,-nc.z),q0.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(q0)}},Mu=class extends ma{constructor(e,t,n=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Om}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Fm=class extends bc{constructor(){super(new ia(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},_u=class extends ma{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ct.DefaultUp),this.updateMatrix(),this.target=new ct,this.shadow=new Fm}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var Um=class extends Le{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){let e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},ga=class extends ys{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new vs(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){let t={},n={};function i(f,m){if(t[m]!==void 0)return t[m];let g=f.interleavedBuffers[m],x=s(f,g.buffer),v=Bh(g.type,x),w=new wu(v,g.stride);return w.uuid=g.uuid,t[m]=w,w}function s(f,m){if(n[m]!==void 0)return n[m];let g=f.arrayBuffers[m],x=new Uint32Array(g).buffer;return n[m]=x,x}let o=e.isInstancedBufferGeometry?new Um:new Le,a=e.data.index;if(a!==void 0){let f=Bh(a.type,a.array);o.setIndex(new Xe(f,1))}let l=e.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=i(e.data,m.data);p=new io(g,m.itemSize,m.offset,m.normalized)}else{let g=Bh(m.type,m.array),x=m.isInstancedBufferAttribute?hm:Xe;p=new x(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(f,p)}let c=e.data.morphAttributes;if(c)for(let f in c){let m=c[f],p=[];for(let g=0,x=m.length;g<x;g++){let v=m[g],w;if(v.isInterleavedBufferAttribute){let b=i(e.data,v.data);w=new io(b,v.itemSize,v.offset,v.normalized)}else{let b=Bh(v.type,v.array);w=new Xe(b,v.itemSize,v.normalized)}v.name!==void 0&&(w.name=v.name),p.push(w)}o.morphAttributes[f]=p}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let f=0,m=u.length;f!==m;++f){let p=u[f];o.addGroup(p.start,p.count,p.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let f=new A;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new Rn(f,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}};var Tu=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=X0(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=X0();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function X0(){return(typeof performance>"u"?Date:performance).now()}var qm="\\[\\]\\.:\\/",KD=new RegExp("["+qm+"]","g"),Xm="[^"+qm+"]",ZD="[^"+qm.replace("\\.","")+"]",JD=/((?:WC+[\/:])*)/.source.replace("WC",Xm),$D=/(WCOD+)?/.source.replace("WCOD",ZD),eP=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Xm),tP=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Xm),nP=new RegExp("^"+JD+$D+eP+tP+"$"),rP=["material","materials","bones"],zm=class{constructor(e,t,n){let i=n||At.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},At=class{constructor(e,t,n){this.path=t,this.parsedPath=n||At.parseTrackName(t),this.node=At.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new At.Composite(e,t,n):new At(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(KD,"")}static parseTrackName(e){let t=nP.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);rP.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=At.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[i];if(o===void 0){let c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};At.Composite=zm;At.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};At.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};At.prototype.GetterByBindingType=[At.prototype._getValue_direct,At.prototype._getValue_array,At.prototype._getValue_arrayElement,At.prototype._getValue_toArray];At.prototype.SetterByBindingTypeAndVersioning=[[At.prototype._setValue_direct,At.prototype._setValue_direct_setNeedsUpdate,At.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[At.prototype._setValue_array,At.prototype._setValue_array_setNeedsUpdate,At.prototype._setValue_array_setMatrixWorldNeedsUpdate],[At.prototype._setValue_arrayElement,At.prototype._setValue_arrayElement_setNeedsUpdate,At.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[At.prototype._setValue_fromArray,At.prototype._setValue_fromArray_setNeedsUpdate,At.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var we=class{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new we(this.value.clone===void 0?this.value:this.value.clone())}};var Eu=class{constructor(e,t,n=0,i=1/0){this.ray=new ro(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new dc,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return Gm(e,this,n,t),n.sort(Y0),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Gm(e[i],this,n,t);return n.sort(Y0),n}};function Y0(r,e){return r.distance-e.distance}function Gm(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)Gm(i[s],e,t,!0)}}var wc=class{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(sn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var Q0=new A,ou=new A,Cu=class{constructor(e=new A,t=new A){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Q0.subVectors(e,this.start),ou.subVectors(this.end,this.start);let n=ou.dot(ou),s=ou.dot(Q0)/n;return t&&(s=sn(s,0,1)),s}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},K0=new A,Du=class extends ct{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;let n=new Le,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let c=o/l*Math.PI*2,h=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(h),Math.sin(h),1)}n.setAttribute("position",new Se(i,3));let s=new Jn({fog:!1,toneMapped:!1});this.cone=new ms(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),K0.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(K0),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var Pu=class extends Vt{constructor(e,t,n){let i=new lo(t,4,2),s=new hi({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var Z0=new A,au=new A,J0=new A,Lu=class extends ct{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,t===void 0&&(t=1);let i=new Le;i.setAttribute("position",new Se([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Jn({fog:!1,toneMapped:!1});this.lightPlane=new so(i,s),this.add(this.lightPlane),i=new Le,i.setAttribute("position",new Se([0,0,0,0,0,1],3)),this.targetLine=new so(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){Z0.setFromMatrixPosition(this.light.matrixWorld),au.setFromMatrixPosition(this.light.target.matrixWorld),J0.subVectors(au,Z0),this.lightPlane.lookAt(au),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(au),this.targetLine.scale.z=J0.length()}},lu=new A,jt=new kr,Ar=class extends ms{constructor(e){let t=new Le,n=new Jn({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={},a=new Ae(16755200),l=new Ae(16711680),c=new Ae(43775),h=new Ae(16777215),u=new Ae(3355443);d("n1","n2",a),d("n2","n4",a),d("n4","n3",a),d("n3","n1",a),d("f1","f2",a),d("f2","f4",a),d("f4","f3",a),d("f3","f1",a),d("n1","f1",a),d("n2","f2",a),d("n3","f3",a),d("n4","f4",a),d("p","n1",l),d("p","n2",l),d("p","n3",l),d("p","n4",l),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c),d("c","t",h),d("p","c",u),d("cn1","cn2",u),d("cn3","cn4",u),d("cf1","cf2",u),d("cf3","cf4",u);function d(m,p,g){f(m,g),f(p,g)}function f(m,p){i.push(0,0,0),s.push(p.r,p.g,p.b),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}t.setAttribute("position",new Se(i,3)),t.setAttribute("color",new Se(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){let e=this.geometry,t=this.pointMap,n=1,i=1;jt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Kt("c",t,e,jt,0,0,-1),Kt("t",t,e,jt,0,0,1),Kt("n1",t,e,jt,-n,-i,-1),Kt("n2",t,e,jt,n,-i,-1),Kt("n3",t,e,jt,-n,i,-1),Kt("n4",t,e,jt,n,i,-1),Kt("f1",t,e,jt,-n,-i,1),Kt("f2",t,e,jt,n,-i,1),Kt("f3",t,e,jt,-n,i,1),Kt("f4",t,e,jt,n,i,1),Kt("u1",t,e,jt,n*.7,i*1.1,-1),Kt("u2",t,e,jt,-n*.7,i*1.1,-1),Kt("u3",t,e,jt,0,i*2,-1),Kt("cf1",t,e,jt,-n,0,1),Kt("cf2",t,e,jt,n,0,1),Kt("cf3",t,e,jt,0,-i,1),Kt("cf4",t,e,jt,0,i,1),Kt("cn1",t,e,jt,-n,0,-1),Kt("cn2",t,e,jt,n,0,-1),Kt("cn3",t,e,jt,0,-i,-1),Kt("cn4",t,e,jt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Kt(r,e,t,n,i,s,o){lu.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],lu.x,lu.y,lu.z)}}var po=class extends ms{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new Le;s.setIndex(new Xe(n,1)),s.setAttribute("position",new Se(i,3)),super(s,new Jn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}};var Iu=class extends ms{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Le;i.setAttribute("position",new Se(t,3)),i.setAttribute("color",new Se(n,3));let s=new Jn({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){let i=new Ae,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Nu=class{constructor(){this.type="ShapePath",this.color=new Ae,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new mc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,o){return this.currentPath.bezierCurveTo(e,t,n,i,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function n(v){let w=[];for(let b=0,S=v.length;b<S;b++){let M=v[b],_=new Gr;_.curves=M.curves,w.push(_)}return w}function i(v,w){let b=w.length,S=!1;for(let M=b-1,_=0;_<b;M=_++){let y=w[M],T=w[_],E=T.x-y.x,C=T.y-y.y;if(Math.abs(C)>Number.EPSILON){if(C<0&&(y=w[_],E=-E,T=w[M],C=-C),v.y<y.y||v.y>T.y)continue;if(v.y===y.y){if(v.x===y.x)return!0}else{let I=C*(v.x-y.x)-E*(v.y-y.y);if(I===0)return!0;if(I<0)continue;S=!S}}else{if(v.y!==y.y)continue;if(T.x<=v.x&&v.x<=y.x||y.x<=v.x&&v.x<=T.x)return!0}}return S}let s=hs.isClockWise,o=this.subPaths;if(o.length===0)return[];if(t===!0)return n(o);let a,l,c,h=[];if(o.length===1)return l=o[0],c=new Gr,c.curves=l.curves,h.push(c),h;let u=!s(o[0].getPoints());u=e?!u:u;let d=[],f=[],m=[],p=0,g;f[p]=void 0,m[p]=[];for(let v=0,w=o.length;v<w;v++)l=o[v],g=l.getPoints(),a=s(g),a=e?!a:a,a?(!u&&f[p]&&p++,f[p]={s:new Gr,p:g},f[p].s.curves=l.curves,u&&p++,m[p]=[]):m[p].push({h:l,p:g[0]});if(!f[0])return n(o);if(f.length>1){let v=!1,w=0;for(let b=0,S=f.length;b<S;b++)d[b]=[];for(let b=0,S=f.length;b<S;b++){let M=m[b];for(let _=0;_<M.length;_++){let y=M[_],T=!0;for(let E=0;E<f.length;E++)i(y.p,f[E].p)&&(b!==E&&w++,T?(T=!1,d[E].push(y)):v=!0);T&&d[b].push(y)}}w>0&&v===!1&&(m=d)}let x;for(let v=0,w=f.length;v<w;v++){c=f[v].s,h.push(c),x=m[v];for(let b=0,S=x.length;b<S;b++)c.holes.push(x[b].h)}return h}};var px=new ArrayBuffer(4),fz=new Float32Array(px),pz=new Uint32Array(px),oi=new Uint32Array(512),ai=new Uint32Array(512);for(let r=0;r<256;++r){let e=r-127;e<-27?(oi[r]=0,oi[r|256]=32768,ai[r]=24,ai[r|256]=24):e<-14?(oi[r]=1024>>-e-14,oi[r|256]=1024>>-e-14|32768,ai[r]=-e-1,ai[r|256]=-e-1):e<=15?(oi[r]=e+15<<10,oi[r|256]=e+15<<10|32768,ai[r]=13,ai[r|256]=13):e<128?(oi[r]=31744,oi[r|256]=64512,ai[r]=24,ai[r|256]=24):(oi[r]=31744,oi[r|256]=64512,ai[r]=13,ai[r|256]=13)}var mx=new Uint32Array(2048),Sc=new Uint32Array(64),iP=new Uint32Array(64);for(let r=1;r<1024;++r){let e=r<<13,t=0;for(;(e&8388608)===0;)e<<=1,t-=8388608;e&=-8388609,t+=947912704,mx[r]=e|t}for(let r=1024;r<2048;++r)mx[r]=939524096+(r-1024<<13);for(let r=1;r<31;++r)Sc[r]=r<<23;Sc[31]=1199570944;Sc[32]=2147483648;for(let r=33;r<63;++r)Sc[r]=2147483648+(r-32<<23);Sc[63]=3347054592;for(let r=1;r<64;++r)r!==32&&(iP[r]=1024);var Ru=class extends lt{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:mo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=mo);var ba=".",Ac=Symbol("target"),Ym=Symbol("unsubscribe");function Mc(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function gx(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var hr=Array.isArray;function go(r){return typeof r=="symbol"}var sP={after:(r,e)=>hr(r)?r.slice(e.length):e===""?r:r.slice(e.length+1),concat:(r,e)=>hr(r)?(r=[...r],e&&r.push(e),r):e&&e.toString!==void 0?(r!==""&&(r+=ba),go(e)?r+e.toString():r+e):r,initial:r=>{if(hr(r))return r.slice(0,-1);if(r==="")return r;let e=r.lastIndexOf(ba);return e===-1?"":r.slice(0,e)},last:r=>{if(hr(r))return r[r.length-1]||"";if(r==="")return r;let e=r.lastIndexOf(ba);return e===-1?r:r.slice(e+1)},walk:(r,e)=>{if(hr(r))for(let t of r)e(t);else if(r!==""){let t=0,n=r.indexOf(ba);if(n===-1)e(r);else for(;t<r.length;)n===-1&&(n=r.length),e(r.slice(t,n)),t=n+1,n=r.indexOf(ba,t)}},get(r,e){return this.walk(e,t=>{r&&(r=r[t])}),r}},jn=sP;function Qm(r){return typeof r=="object"&&typeof r.next=="function"}function Km(r,e,t,n,i){let s=r.next;if(e.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],e,o.value[0],n),o.value[1]=i(o.value[1],e,o.value[0],n)),o};else if(e.name==="values"){let o=t[Ac].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,e,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,e,o.value,n)),o};return r}function zu(r,e,t){return r.isUnsubscribed||e.ignoreSymbols&&go(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var _c=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),n=t.get(e);return n===void 0&&(n={},t.set(e,n)),n}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let n=this._getProperties(e),i=n[t];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(e,t),n[t]=i),i}getProxy(e,t,n,i){if(this.isUnsubscribed)return e;let s=e[i],o=s||e;this._pathCache.set(o,t);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(e,n):e,this._proxyCache.set(o,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,jn.get(t,this.getPath(e)))}defineProperty(e,t,n){return Reflect.defineProperty(e,t,n)?(this.isUnsubscribed||(this._getProperties(e)[t]=n),!0):!1}setProperty(e,t,n,i,s){if(!this._equals(s,n)||!(t in e)){let o=this._getOwnPropertyDescriptor(e,t);return o!==void 0&&"set"in o?Reflect.set(e,t,n,i):Reflect.set(e,t,n)}return!0}deleteProperty(e,t,n){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(e);i&&(delete i[t],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(e,t,n){let i=this._getOwnPropertyDescriptor(t,n);return e!==void 0&&i!==void 0&&Object.is(e.value,i.value)&&(e.writable||!1)===(i.writable||!1)&&(e.enumerable||!1)===(i.enumerable||!1)&&(e.configurable||!1)===(i.configurable||!1)&&e.get===i.get&&e.set===i.set}isGetInvariant(e,t){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function wa(r){return toString.call(r)==="[object Object]"}function Sa(){return!0}function bs(r,e){return r.length!==e.length||r.some((t,n)=>e[n]!==t)}var Gu=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var oP=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Zm={push:Sa,pop:Sa,shift:Sa,unshift:Sa,copyWithin:bs,reverse:bs,sort:bs,splice:bs,flat:bs,fill:bs},yx=new Set([...Gu,...oP,...Object.keys(Zm)]);function Aa(r,e){if(r.size!==e.size)return!0;for(let t of r)if(!e.has(t))return!0;return!1}var Jm=["keys","values","entries"],$m=new Set(["has","toString"]),eg={add:Aa,clear:Aa,delete:Aa,forEach:Aa},vx=new Set([...$m,...Object.keys(eg),...Jm]);function Ma(r,e){if(r.size!==e.size)return!0;let t;for(let[n,i]of r)if(t=e.get(n),t!==i||t===void 0&&!e.has(n))return!0;return!1}var aP=new Set([...$m,"get"]),tg={set:Ma,clear:Ma,delete:Ma,forEach:Ma},xx=new Set([...aP,...Object.keys(tg),...Jm]);var Mn=class{constructor(e,t,n,i){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return Gu.has(e)}_shallowClone(e){let t=e;if(wa(e))t={...e};else if(hr(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(n=>this._shallowClone(n)));else if(e instanceof Map){t=new Map;for(let[n,i]of e.entries())t.set(n,this._shallowClone(i))}return this._clonedCache.add(t),t}preferredThisArg(e,t,n,i){return e?(hr(i)?this._onIsChanged=Zm[t]:i instanceof Set?this._onIsChanged=eg[t]:i instanceof Map&&(this._onIsChanged=tg[t]),i):n}update(e,t,n){let i=jn.after(e,this._path);if(t!=="length"){let s=this.clone;jn.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:t,previous:n}),s&&s[t]&&(s[t]=n)}this._isChanged=!0}undo(e){let t;for(let n=this._changes.length-1;n!==-1;n--)t=this._changes[n],jn.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var _a=class extends Mn{static isHandledMethod(e){return yx.has(e)}};var Tc=class extends Mn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var Ta=class extends Mn{static isHandledMethod(e){return vx.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}};var Ea=class extends Mn{static isHandledMethod(e){return xx.has(e)}undo(e){for(let[t,n]of this.clone.entries())e.set(t,n);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};var Ec=class extends Mn{constructor(e,t,n,i){super(void 0,t,n,i),this._arg1=n[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}};var Cc=class extends Mn{constructor(e,t,n,i){super(void 0,t,n,i),this._weakKey=n[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}};var jr=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return wa(e)||hr(e)||Mc(e)}static isHandledMethod(e,t){return wa(e)?Mn.isHandledMethod(t):hr(e)?_a.isHandledMethod(t):e instanceof Set?Ta.isHandledMethod(t):e instanceof Map?Ea.isHandledMethod(t):Mc(e)}get isCloning(){return this._stack.length>0}start(e,t,n){let i=Mn;hr(e)?i=_a:e instanceof Date?i=Tc:e instanceof Set?i=Ta:e instanceof Map?i=Ea:e instanceof WeakSet?i=Ec:e instanceof WeakMap&&(i=Cc),this._stack.push(new i(e,t,n,this._hasOnValidate))}update(e,t,n){this._stack[this._stack.length-1].update(e,t,n)}preferredThisArg(e,t,n){let{name:i}=e,s=jr.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,t,n)}isChanged(e,t,n){return this._stack[this._stack.length-1].isChanged(e,t,n)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var lP={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},ng=(r,e,t={})=>{t={...lP,...t};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=t,l=new _c(i),c=typeof t.onValidate=="function",h=new jr(c),u=(v,w,b,S,M)=>!c||h.isCloning||t.onValidate(jn.concat(l.getPath(v),w),b,S,M)===!0,d=(v,w,b,S)=>{!zu(l,t,w)&&!(o&&l.isDetached(v,r))&&f(l.getPath(v),w,b,S)},f=(v,w,b,S,M)=>{h.isCloning?h.update(v,w,S):e(jn.concat(v,w),b,S,M)},m=v=>v&&(v[n]||v),p=(v,w,b,S)=>gx(v)||b==="constructor"||s&&!jr.isHandledMethod(w,b)||zu(l,t,b)||l.isGetInvariant(w,b)||o&&l.isDetached(w,r)?v:(S===void 0&&(S=l.getPath(w)),l.getProxy(v,jn.concat(S,b),g,n)),g={get(v,w,b){if(go(w)){if(w===n||w===Ac)return v;if(w===Ym&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let S=Mc(v)?Reflect.get(v,w):Reflect.get(v,w,b);return p(S,v,w)},set(v,w,b,S){b=m(b);let M=v[n]||v,_=M[w];if(i(_,b)&&w in v)return!0;let y=u(v,w,b,_);return y&&l.setProperty(M,w,b,S,_)?(d(v,w,v[w],_),!0):!y},defineProperty(v,w,b){if(!l.isSameDescriptor(b,v,w)){let S=v[w];u(v,w,b.value,S)&&l.defineProperty(v,w,b,S)&&d(v,w,b.value,S)}return!0},deleteProperty(v,w){if(!Reflect.has(v,w))return!0;let b=Reflect.get(v,w),S=u(v,w,void 0,b);return S&&l.deleteProperty(v,w,b)?(d(v,w,void 0,b),!0):!S},apply(v,w,b){let S=w[n]||w;if(l.isUnsubscribed)return Reflect.apply(v,S,b);if((a===!1||a!==!0&&!a.includes(v.name))&&jr.isHandledType(S)){let M=jn.initial(l.getPath(v)),_=jr.isHandledMethod(S,v.name);h.start(S,M,b);let y=Reflect.apply(v,h.preferredThisArg(v,w,S),_?b.map(C=>m(C)):b),T=h.isChanged(S,i),E=h.stop();if(jr.isHandledType(y)&&_&&(w instanceof Map&&v.name==="get"&&(M=jn.concat(M,b[0])),y=l.getProxy(y,M,g)),T){let C={name:v.name,args:b,result:y},I=h.isCloning?jn.initial(M):M,R=h.isCloning?jn.last(M):"";u(jn.get(r,I),R,S,E,C)?f(I,R,S,E,C):h.undo(S)}return(w instanceof Map||w instanceof Set)&&Qm(y)?Km(y,v,w,M,p):y}return Reflect.apply(v,w,b)}},x=l.getProxy(r,t.pathAsArray?[]:"",g);return e=e.bind(x),c&&(t.onValidate=t.onValidate.bind(x)),x};ng.target=r=>r&&r[Ac]||r;ng.unsubscribe=r=>r[Ym]||r;var rg=ng;var cP=typeof global=="object"&&global&&global.Object===Object&&global,ku=cP;var hP=typeof self=="object"&&self&&self.Object===Object&&self,uP=ku||hP||Function("return this")(),Yt=uP;var dP=Yt.Symbol,qn=dP;var bx=Object.prototype,fP=bx.hasOwnProperty,pP=bx.toString,Dc=qn?qn.toStringTag:void 0;function mP(r){var e=fP.call(r,Dc),t=r[Dc];try{r[Dc]=void 0;var n=!0}catch{}var i=pP.call(r);return n&&(e?r[Dc]=t:delete r[Dc]),i}var wx=mP;var gP=Object.prototype,yP=gP.toString;function vP(r){return yP.call(r)}var Sx=vP;var xP="[object Null]",bP="[object Undefined]",Ax=qn?qn.toStringTag:void 0;function wP(r){return r==null?r===void 0?bP:xP:Ax&&Ax in Object(r)?wx(r):Sx(r)}var ur=wP;function SP(r){return r!=null&&typeof r=="object"}var Bn=SP;var AP="[object Symbol]";function MP(r){return typeof r=="symbol"||Bn(r)&&ur(r)==AP}var ws=MP;function _P(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var Vu=_P;var TP=Array.isArray,Dn=TP;var EP=1/0,Mx=qn?qn.prototype:void 0,_x=Mx?Mx.toString:void 0;function Tx(r){if(typeof r=="string")return r;if(Dn(r))return Vu(r,Tx)+"";if(ws(r))return _x?_x.call(r):"";var e=r+"";return e=="0"&&1/r==-EP?"-0":e}var Ex=Tx;var CP=/\s/;function DP(r){for(var e=r.length;e--&&CP.test(r.charAt(e)););return e}var Cx=DP;var PP=/^\s+/;function LP(r){return r&&r.slice(0,Cx(r)+1).replace(PP,"")}var Dx=LP;function IP(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var Jt=IP;var Px=0/0,NP=/^[-+]0x[0-9a-f]+$/i,RP=/^0b[01]+$/i,BP=/^0o[0-7]+$/i,OP=parseInt;function FP(r){if(typeof r=="number")return r;if(ws(r))return Px;if(Jt(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Jt(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=Dx(r);var t=RP.test(r);return t||BP.test(r)?OP(r.slice(2),t?2:8):NP.test(r)?Px:+r}var ig=FP;function UP(r){return r}var Hu=UP;var zP="[object AsyncFunction]",GP="[object Function]",kP="[object GeneratorFunction]",VP="[object Proxy]";function HP(r){if(!Jt(r))return!1;var e=ur(r);return e==GP||e==kP||e==zP||e==VP}var Ca=HP;var WP=Yt["__core-js_shared__"],Wu=WP;var Lx=function(){var r=/[^.]+$/.exec(Wu&&Wu.keys&&Wu.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function jP(r){return!!Lx&&Lx in r}var Ix=jP;var qP=Function.prototype,XP=qP.toString;function YP(r){if(r!=null){try{return XP.call(r)}catch{}try{return r+""}catch{}}return""}var ki=YP;var QP=/[\\^$.*+?()[\]{}|]/g,KP=/^\[object .+?Constructor\]$/,ZP=Function.prototype,JP=Object.prototype,$P=ZP.toString,eL=JP.hasOwnProperty,tL=RegExp("^"+$P.call(eL).replace(QP,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function nL(r){if(!Jt(r)||Ix(r))return!1;var e=Ca(r)?tL:KP;return e.test(ki(r))}var Nx=nL;function rL(r,e){return r?.[e]}var Rx=rL;function iL(r,e){var t=Rx(r,e);return Nx(t)?t:void 0}var tr=iL;var sL=tr(Yt,"WeakMap"),ju=sL;var Bx=Object.create,oL=function(){function r(){}return function(e){if(!Jt(e))return{};if(Bx)return Bx(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),Ox=oL;function aL(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var Fx=aL;function lL(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var qu=lL;var cL=800,hL=16,uL=Date.now;function dL(r){var e=0,t=0;return function(){var n=uL(),i=hL-(n-t);if(t=n,i>0){if(++e>=cL)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var Ux=dL;function fL(r){return function(){return r}}var zx=fL;var pL=function(){try{var r=tr(Object,"defineProperty");return r({},"",{}),r}catch{}}(),Da=pL;var mL=Da?function(r,e){return Da(r,"toString",{configurable:!0,enumerable:!1,value:zx(e),writable:!0})}:Hu,Gx=mL;var gL=Ux(Gx),Xu=gL;function yL(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var kx=yL;var vL=9007199254740991,xL=/^(?:0|[1-9]\d*)$/;function bL(r,e){var t=typeof r;return e=e??vL,!!e&&(t=="number"||t!="symbol"&&xL.test(r))&&r>-1&&r%1==0&&r<e}var Yu=bL;function wL(r,e,t){e=="__proto__"&&Da?Da(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var Pa=wL;function SL(r,e){return r===e||r!==r&&e!==e}var Ss=SL;var AL=Object.prototype,ML=AL.hasOwnProperty;function _L(r,e,t){var n=r[e];(!(ML.call(r,e)&&Ss(n,t))||t===void 0&&!(e in r))&&Pa(r,e,t)}var Qu=_L;function TL(r,e,t,n){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],l=n?n(t[a],r[a],a,t,r):void 0;l===void 0&&(l=r[a]),i?Pa(t,a,l):Qu(t,a,l)}return t}var Mr=TL;var Vx=Math.max;function EL(r,e,t){return e=Vx(e===void 0?r.length-1:e,0),function(){for(var n=arguments,i=-1,s=Vx(n.length-e,0),o=Array(s);++i<s;)o[i]=n[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=n[i];return a[e]=t(o),Fx(r,this,a)}}var Ku=EL;function CL(r,e){return Xu(Ku(r,e,Hu),r+"")}var Hx=CL;var DL=9007199254740991;function PL(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=DL}var Zu=PL;function LL(r){return r!=null&&Zu(r.length)&&!Ca(r)}var As=LL;function IL(r,e,t){if(!Jt(t))return!1;var n=typeof e;return(n=="number"?As(t)&&Yu(e,t.length):n=="string"&&e in t)?Ss(t[e],r):!1}var Wx=IL;function NL(r){return Hx(function(e,t){var n=-1,i=t.length,s=i>1?t[i-1]:void 0,o=i>2?t[2]:void 0;for(s=r.length>3&&typeof s=="function"?(i--,s):void 0,o&&Wx(t[0],t[1],o)&&(s=i<3?void 0:s,i=1),e=Object(e);++n<i;){var a=t[n];a&&r(e,a,n,s)}return e})}var jx=NL;var RL=Object.prototype;function BL(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||RL;return r===t}var La=BL;function OL(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var qx=OL;var FL="[object Arguments]";function UL(r){return Bn(r)&&ur(r)==FL}var sg=UL;var Xx=Object.prototype,zL=Xx.hasOwnProperty,GL=Xx.propertyIsEnumerable,kL=sg(function(){return arguments}())?sg:function(r){return Bn(r)&&zL.call(r,"callee")&&!GL.call(r,"callee")},yo=kL;function VL(){return!1}var Yx=VL;var Zx=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Qx=Zx&&typeof module=="object"&&module&&!module.nodeType&&module,HL=Qx&&Qx.exports===Zx,Kx=HL?Yt.Buffer:void 0,WL=Kx?Kx.isBuffer:void 0,jL=WL||Yx,Ia=jL;var qL="[object Arguments]",XL="[object Array]",YL="[object Boolean]",QL="[object Date]",KL="[object Error]",ZL="[object Function]",JL="[object Map]",$L="[object Number]",eI="[object Object]",tI="[object RegExp]",nI="[object Set]",rI="[object String]",iI="[object WeakMap]",sI="[object ArrayBuffer]",oI="[object DataView]",aI="[object Float32Array]",lI="[object Float64Array]",cI="[object Int8Array]",hI="[object Int16Array]",uI="[object Int32Array]",dI="[object Uint8Array]",fI="[object Uint8ClampedArray]",pI="[object Uint16Array]",mI="[object Uint32Array]",It={};It[aI]=It[lI]=It[cI]=It[hI]=It[uI]=It[dI]=It[fI]=It[pI]=It[mI]=!0;It[qL]=It[XL]=It[sI]=It[YL]=It[oI]=It[QL]=It[KL]=It[ZL]=It[JL]=It[$L]=It[eI]=It[tI]=It[nI]=It[rI]=It[iI]=!1;function gI(r){return Bn(r)&&Zu(r.length)&&!!It[ur(r)]}var Jx=gI;function yI(r){return function(e){return r(e)}}var Na=yI;var $x=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pc=$x&&typeof module=="object"&&module&&!module.nodeType&&module,vI=Pc&&Pc.exports===$x,og=vI&&ku.process,xI=function(){try{var r=Pc&&Pc.require&&Pc.require("util").types;return r||og&&og.binding&&og.binding("util")}catch{}}(),Vi=xI;var eb=Vi&&Vi.isTypedArray,bI=eb?Na(eb):Jx,Ju=bI;var wI=Object.prototype,SI=wI.hasOwnProperty;function AI(r,e){var t=Dn(r),n=!t&&yo(r),i=!t&&!n&&Ia(r),s=!t&&!n&&!i&&Ju(r),o=t||n||i||s,a=o?qx(r.length,String):[],l=a.length;for(var c in r)(e||SI.call(r,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Yu(c,l)))&&a.push(c);return a}var $u=AI;function MI(r,e){return function(t){return r(e(t))}}var ed=MI;var _I=ed(Object.keys,Object),tb=_I;var TI=Object.prototype,EI=TI.hasOwnProperty;function CI(r){if(!La(r))return tb(r);var e=[];for(var t in Object(r))EI.call(r,t)&&t!="constructor"&&e.push(t);return e}var nb=CI;function DI(r){return As(r)?$u(r):nb(r)}var Ra=DI;function PI(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var rb=PI;var LI=Object.prototype,II=LI.hasOwnProperty;function NI(r){if(!Jt(r))return rb(r);var e=La(r),t=[];for(var n in r)n=="constructor"&&(e||!II.call(r,n))||t.push(n);return t}var ib=NI;function RI(r){return As(r)?$u(r,!0):ib(r)}var ui=RI;var BI=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,OI=/^\w*$/;function FI(r,e){if(Dn(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||ws(r)?!0:OI.test(r)||!BI.test(r)||e!=null&&r in Object(e)}var sb=FI;var UI=tr(Object,"create"),Hi=UI;function zI(){this.__data__=Hi?Hi(null):{},this.size=0}var ob=zI;function GI(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var ab=GI;var kI="__lodash_hash_undefined__",VI=Object.prototype,HI=VI.hasOwnProperty;function WI(r){var e=this.__data__;if(Hi){var t=e[r];return t===kI?void 0:t}return HI.call(e,r)?e[r]:void 0}var lb=WI;var jI=Object.prototype,qI=jI.hasOwnProperty;function XI(r){var e=this.__data__;return Hi?e[r]!==void 0:qI.call(e,r)}var cb=XI;var YI="__lodash_hash_undefined__";function QI(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Hi&&e===void 0?YI:e,this}var hb=QI;function Ba(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Ba.prototype.clear=ob;Ba.prototype.delete=ab;Ba.prototype.get=lb;Ba.prototype.has=cb;Ba.prototype.set=hb;var ag=Ba;function KI(){this.__data__=[],this.size=0}var ub=KI;function ZI(r,e){for(var t=r.length;t--;)if(Ss(r[t][0],e))return t;return-1}var Ms=ZI;var JI=Array.prototype,$I=JI.splice;function e3(r){var e=this.__data__,t=Ms(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():$I.call(e,t,1),--this.size,!0}var db=e3;function t3(r){var e=this.__data__,t=Ms(e,r);return t<0?void 0:e[t][1]}var fb=t3;function n3(r){return Ms(this.__data__,r)>-1}var pb=n3;function r3(r,e){var t=this.__data__,n=Ms(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var mb=r3;function Oa(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Oa.prototype.clear=ub;Oa.prototype.delete=db;Oa.prototype.get=fb;Oa.prototype.has=pb;Oa.prototype.set=mb;var _s=Oa;var i3=tr(Yt,"Map"),Ts=i3;function s3(){this.size=0,this.__data__={hash:new ag,map:new(Ts||_s),string:new ag}}var gb=s3;function o3(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var yb=o3;function a3(r,e){var t=r.__data__;return yb(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Es=a3;function l3(r){var e=Es(this,r).delete(r);return this.size-=e?1:0,e}var vb=l3;function c3(r){return Es(this,r).get(r)}var xb=c3;function h3(r){return Es(this,r).has(r)}var bb=h3;function u3(r,e){var t=Es(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var wb=u3;function Fa(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Fa.prototype.clear=gb;Fa.prototype.delete=vb;Fa.prototype.get=xb;Fa.prototype.has=bb;Fa.prototype.set=wb;var Lc=Fa;var d3="Expected a function";function lg(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(d3);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=t.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return t.cache=s.set(i,o)||s,o};return t.cache=new(lg.Cache||Lc),t}lg.Cache=Lc;var Sb=lg;var f3=500;function p3(r){var e=Sb(r,function(n){return t.size===f3&&t.clear(),n}),t=e.cache;return e}var Ab=p3;var m3=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,g3=/\\(\\)?/g,y3=Ab(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(m3,function(t,n,i,s){e.push(i?s.replace(g3,"$1"):n||t)}),e}),Mb=y3;function v3(r){return r==null?"":Ex(r)}var _b=v3;function x3(r,e){return Dn(r)?r:sb(r,e)?[r]:Mb(_b(r))}var Ua=x3;var b3=1/0;function w3(r){if(typeof r=="string"||ws(r))return r;var e=r+"";return e=="0"&&1/r==-b3?"-0":e}var td=w3;function S3(r,e){e=Ua(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[td(e[t++])];return t&&t==n?r:void 0}var Tb=S3;function A3(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var za=A3;var Eb=qn?qn.isConcatSpreadable:void 0;function M3(r){return Dn(r)||yo(r)||!!(Eb&&r&&r[Eb])}var Cb=M3;function Db(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=Cb),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?Db(a,e-1,t,n,i):za(i,a):n||(i[i.length]=a)}return i}var Pb=Db;function _3(r){var e=r==null?0:r.length;return e?Pb(r,1):[]}var Lb=_3;function T3(r){return Xu(Ku(r,void 0,Lb),r+"")}var Ib=T3;var E3=ed(Object.getPrototypeOf,Object),Ga=E3;var C3="[object Object]",D3=Function.prototype,P3=Object.prototype,Nb=D3.toString,L3=P3.hasOwnProperty,I3=Nb.call(Object);function N3(r){if(!Bn(r)||ur(r)!=C3)return!1;var e=Ga(r);if(e===null)return!0;var t=L3.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Nb.call(t)==I3}var nd=N3;function R3(r,e,t){var n=-1,i=r.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+e];return s}var Rb=R3;function B3(){this.__data__=new _s,this.size=0}var Bb=B3;function O3(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var Ob=O3;function F3(r){return this.__data__.get(r)}var Fb=F3;function U3(r){return this.__data__.has(r)}var Ub=U3;var z3=200;function G3(r,e){var t=this.__data__;if(t instanceof _s){var n=t.__data__;if(!Ts||n.length<z3-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new Lc(n)}return t.set(r,e),this.size=t.size,this}var zb=G3;function ka(r){var e=this.__data__=new _s(r);this.size=e.size}ka.prototype.clear=Bb;ka.prototype.delete=Ob;ka.prototype.get=Fb;ka.prototype.has=Ub;ka.prototype.set=zb;var rd=ka;function k3(r,e){return r&&Mr(e,Ra(e),r)}var Gb=k3;function V3(r,e){return r&&Mr(e,ui(e),r)}var kb=V3;var jb=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vb=jb&&typeof module=="object"&&module&&!module.nodeType&&module,H3=Vb&&Vb.exports===jb,Hb=H3?Yt.Buffer:void 0,Wb=Hb?Hb.allocUnsafe:void 0;function W3(r,e){if(e)return r.slice();var t=r.length,n=Wb?Wb(t):new r.constructor(t);return r.copy(n),n}var id=W3;function j3(r,e){for(var t=-1,n=r==null?0:r.length,i=0,s=[];++t<n;){var o=r[t];e(o,t,r)&&(s[i++]=o)}return s}var qb=j3;function q3(){return[]}var sd=q3;var X3=Object.prototype,Y3=X3.propertyIsEnumerable,Xb=Object.getOwnPropertySymbols,Q3=Xb?function(r){return r==null?[]:(r=Object(r),qb(Xb(r),function(e){return Y3.call(r,e)}))}:sd,Va=Q3;function K3(r,e){return Mr(r,Va(r),e)}var Yb=K3;var Z3=Object.getOwnPropertySymbols,J3=Z3?function(r){for(var e=[];r;)za(e,Va(r)),r=Ga(r);return e}:sd,od=J3;function $3(r,e){return Mr(r,od(r),e)}var Qb=$3;function eN(r,e,t){var n=e(r);return Dn(r)?n:za(n,t(r))}var ad=eN;function tN(r){return ad(r,Ra,Va)}var Kb=tN;function nN(r){return ad(r,ui,od)}var ld=nN;var rN=tr(Yt,"DataView"),cd=rN;var iN=tr(Yt,"Promise"),hd=iN;var sN=tr(Yt,"Set"),ud=sN;var Zb="[object Map]",oN="[object Object]",Jb="[object Promise]",$b="[object Set]",ew="[object WeakMap]",tw="[object DataView]",aN=ki(cd),lN=ki(Ts),cN=ki(hd),hN=ki(ud),uN=ki(ju),vo=ur;(cd&&vo(new cd(new ArrayBuffer(1)))!=tw||Ts&&vo(new Ts)!=Zb||hd&&vo(hd.resolve())!=Jb||ud&&vo(new ud)!=$b||ju&&vo(new ju)!=ew)&&(vo=function(r){var e=ur(r),t=e==oN?r.constructor:void 0,n=t?ki(t):"";if(n)switch(n){case aN:return tw;case lN:return Zb;case cN:return Jb;case hN:return $b;case uN:return ew}return e});var Ha=vo;var dN=Object.prototype,fN=dN.hasOwnProperty;function pN(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&fN.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var nw=pN;var mN=Yt.Uint8Array,cg=mN;function gN(r){var e=new r.constructor(r.byteLength);return new cg(e).set(new cg(r)),e}var Wa=gN;function yN(r,e){var t=e?Wa(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var rw=yN;var vN=/\w*$/;function xN(r){var e=new r.constructor(r.source,vN.exec(r));return e.lastIndex=r.lastIndex,e}var iw=xN;var sw=qn?qn.prototype:void 0,ow=sw?sw.valueOf:void 0;function bN(r){return ow?Object(ow.call(r)):{}}var aw=bN;function wN(r,e){var t=e?Wa(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var dd=wN;var SN="[object Boolean]",AN="[object Date]",MN="[object Map]",_N="[object Number]",TN="[object RegExp]",EN="[object Set]",CN="[object String]",DN="[object Symbol]",PN="[object ArrayBuffer]",LN="[object DataView]",IN="[object Float32Array]",NN="[object Float64Array]",RN="[object Int8Array]",BN="[object Int16Array]",ON="[object Int32Array]",FN="[object Uint8Array]",UN="[object Uint8ClampedArray]",zN="[object Uint16Array]",GN="[object Uint32Array]";function kN(r,e,t){var n=r.constructor;switch(e){case PN:return Wa(r);case SN:case AN:return new n(+r);case LN:return rw(r,t);case IN:case NN:case RN:case BN:case ON:case FN:case UN:case zN:case GN:return dd(r,t);case MN:return new n;case _N:case CN:return new n(r);case TN:return iw(r);case EN:return new n;case DN:return aw(r)}}var lw=kN;function VN(r){return typeof r.constructor=="function"&&!La(r)?Ox(Ga(r)):{}}var fd=VN;var HN="[object Map]";function WN(r){return Bn(r)&&Ha(r)==HN}var cw=WN;var hw=Vi&&Vi.isMap,jN=hw?Na(hw):cw,uw=jN;var qN="[object Set]";function XN(r){return Bn(r)&&Ha(r)==qN}var dw=XN;var fw=Vi&&Vi.isSet,YN=fw?Na(fw):dw,pw=YN;var QN=1,KN=2,ZN=4,mw="[object Arguments]",JN="[object Array]",$N="[object Boolean]",eR="[object Date]",tR="[object Error]",gw="[object Function]",nR="[object GeneratorFunction]",rR="[object Map]",iR="[object Number]",yw="[object Object]",sR="[object RegExp]",oR="[object Set]",aR="[object String]",lR="[object Symbol]",cR="[object WeakMap]",hR="[object ArrayBuffer]",uR="[object DataView]",dR="[object Float32Array]",fR="[object Float64Array]",pR="[object Int8Array]",mR="[object Int16Array]",gR="[object Int32Array]",yR="[object Uint8Array]",vR="[object Uint8ClampedArray]",xR="[object Uint16Array]",bR="[object Uint32Array]",Dt={};Dt[mw]=Dt[JN]=Dt[hR]=Dt[uR]=Dt[$N]=Dt[eR]=Dt[dR]=Dt[fR]=Dt[pR]=Dt[mR]=Dt[gR]=Dt[rR]=Dt[iR]=Dt[yw]=Dt[sR]=Dt[oR]=Dt[aR]=Dt[lR]=Dt[yR]=Dt[vR]=Dt[xR]=Dt[bR]=!0;Dt[tR]=Dt[gw]=Dt[cR]=!1;function pd(r,e,t,n,i,s){var o,a=e&QN,l=e&KN,c=e&ZN;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!Jt(r))return r;var h=Dn(r);if(h){if(o=nw(r),!a)return qu(r,o)}else{var u=Ha(r),d=u==gw||u==nR;if(Ia(r))return id(r,a);if(u==yw||u==mw||d&&!i){if(o=l||d?{}:fd(r),!a)return l?Qb(r,kb(o,r)):Yb(r,Gb(o,r))}else{if(!Dt[u])return i?r:{};o=lw(r,u,a)}}s||(s=new rd);var f=s.get(r);if(f)return f;s.set(r,o),pw(r)?r.forEach(function(g){o.add(pd(g,e,t,g,r,s))}):uw(r)&&r.forEach(function(g,x){o.set(x,pd(g,e,t,x,r,s))});var m=c?l?ld:Kb:l?ui:Ra,p=h?void 0:m(r);return kx(p||r,function(g,x){p&&(x=g,g=r[x]),Qu(o,x,pd(g,e,t,x,r,s))}),o}var md=pd;var wR=1,SR=4;function AR(r){return md(r,wR|SR)}var Ic=AR;function MR(r){return function(e,t,n){for(var i=-1,s=Object(e),o=n(e),a=o.length;a--;){var l=o[r?a:++i];if(t(s[l],l,s)===!1)break}return e}}var vw=MR;var _R=vw(),xw=_R;var TR=function(){return Yt.Date.now()},gd=TR;var ER="Expected a function",CR=Math.max,DR=Math.min;function PR(r,e,t){var n,i,s,o,a,l,c=0,h=!1,u=!1,d=!0;if(typeof r!="function")throw new TypeError(ER);e=ig(e)||0,Jt(t)&&(h=!!t.leading,u="maxWait"in t,s=u?CR(ig(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function f(M){var _=n,y=i;return n=i=void 0,c=M,o=r.apply(y,_),o}function m(M){return c=M,a=setTimeout(x,e),h?f(M):o}function p(M){var _=M-l,y=M-c,T=e-_;return u?DR(T,s-y):T}function g(M){var _=M-l,y=M-c;return l===void 0||_>=e||_<0||u&&y>=s}function x(){var M=gd();if(g(M))return v(M);a=setTimeout(x,p(M))}function v(M){return a=void 0,d&&n?f(M):(n=i=void 0,o)}function w(){a!==void 0&&clearTimeout(a),c=0,n=l=i=a=void 0}function b(){return a===void 0?o:v(gd())}function S(){var M=gd(),_=g(M);if(n=arguments,i=this,l=M,_){if(a===void 0)return m(l);if(u)return clearTimeout(a),a=setTimeout(x,e),f(l)}return a===void 0&&(a=setTimeout(x,e)),o}return S.cancel=w,S.flush=b,S}var Nc=PR;function LR(r,e,t){(t!==void 0&&!Ss(r[e],t)||t===void 0&&!(e in r))&&Pa(r,e,t)}var Rc=LR;function IR(r){return Bn(r)&&As(r)}var bw=IR;function NR(r,e){if(!(e==="constructor"&&typeof r[e]=="function")&&e!="__proto__")return r[e]}var Bc=NR;function RR(r){return Mr(r,ui(r))}var ww=RR;function BR(r,e,t,n,i,s,o){var a=Bc(r,t),l=Bc(e,t),c=o.get(l);if(c){Rc(r,t,c);return}var h=s?s(a,l,t+"",r,e,o):void 0,u=h===void 0;if(u){var d=Dn(l),f=!d&&Ia(l),m=!d&&!f&&Ju(l);h=l,d||f||m?Dn(a)?h=a:bw(a)?h=qu(a):f?(u=!1,h=id(l,!0)):m?(u=!1,h=dd(l,!0)):h=[]:nd(l)||yo(l)?(h=a,yo(a)?h=ww(a):(!Jt(a)||Ca(a))&&(h=fd(l))):u=!1}u&&(o.set(l,h),i(h,l,n,s,o),o.delete(l)),Rc(r,t,h)}var Sw=BR;function Aw(r,e,t,n,i){r!==e&&xw(e,function(s,o){if(i||(i=new rd),Jt(s))Sw(r,e,o,t,Aw,n,i);else{var a=n?n(Bc(r,o),s,o+"",r,e,i):void 0;a===void 0&&(a=s),Rc(r,o,a)}},ui)}var Mw=Aw;function OR(r){var e=r==null?0:r.length;return e?r[e-1]:void 0}var _w=OR;function FR(r,e){return e.length<2?r:Tb(r,Rb(e,0,-1))}var Tw=FR;var UR=jx(function(r,e,t){Mw(r,e,t)}),xo=UR;function zR(r,e){return e=Ua(e,r),r=Tw(r,e),r==null||delete r[td(_w(e))]}var Ew=zR;function GR(r){return nd(r)?void 0:r}var Cw=GR;var kR=1,VR=2,HR=4,WR=Ib(function(r,e){var t={};if(r==null)return t;var n=!1;e=Vu(e,function(s){return s=Ua(s,r),n||(n=s.length>1),s}),Mr(r,ld(r),t),n&&(t=md(t,kR|VR|HR,Cw));for(var i=e.length;i--;)Ew(t,e[i]);return t}),ja=WR;var jR=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),qR=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),XR=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Oc&&"ontouchend"in document,YR=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,QR=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,KR=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,e=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(e)},ZR=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},Q6=jR(),Oc=qR(),Cs=XR(),Dw=YR(),yd=QR(),Pw=KR(),K6=Number(ZR());function Lw(r){return Array.isArray(r)?r:[r]}function Fc(r){return Oc?r.metaKey:r.ctrlKey}var Ds;(t=>{t.all=["PerspectiveCamera","OrthographicCamera"];function e(n){return t.all.includes(n)}t.is=e})(Ds||(Ds={}));var bo;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(bo||(bo={}));var Wi;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}t.lerp=e})(Wi||(Wi={}));var on;(i=>{function r(s,o){return s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]}i.isEqual=r;function e(s,o){return[s[0]+o[0],s[1]+o[1],s[2]+o[2]]}i.add=e;function t(s,o){return[s[0]-o[0],s[1]-o[1],s[2]-o[2]]}i.sub=t;function n(s,o,a){return[s[0]+(o[0]-s[0])*a,s[1]+(o[1]-s[1])*a,s[2]+(o[2]-s[2])*a]}i.lerp=n})(on||(on={}));var Uc;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}t.lerp=e})(Uc||(Uc={}));var di;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=e;function t(s){return s??i.identity}i.simplify=t;function n(s,o){let a=o.slice(0);for(var l=0,c=o.length;l<c;l+=3){let h=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/h,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/h,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/h}return a}i.applyMatrix4=n})(di||(di={}));var dn;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function n(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=n;function i(c){return{r:c.r,g:c.g,b:c.b}}l.clone=i;function s(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=s;function o(c,h){return c.r===h.r&&c.g===h.g&&c.b===h.b}l.equals=o;function a(c,h,u){return{r:c.r+(h.r-c.r)*u,g:c.g+(h.g-c.g)*u,b:c.b+(h.b-c.b)*u}}l.lerp=a})(dn||(dn={}));var On;(o=>{o.white={...dn.white,a:1};function e(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}o.from0to1=e;function t(a,l){return{...dn.fromHex(a),a:l}}o.fromHexAndA=t;function n(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}o.toRgb255a1=n;function i(a,l){return dn.equals(a,l)&&a.a===l.a}o.equals=i;function s(a,l,c){return{r:a.r+(l.r-a.r)*c,g:a.g+(l.g-a.g)*c,b:a.b+(l.b-a.b)*c,a:a.a+(l.a-a.a)*c}}o.lerp=s})(On||(On={}));var vd;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(vd||(vd={}));var xd;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(xd||(xd={}));var bd;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(bd||(bd={}));var wd;(e=>{function r(t,n=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*n,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+n)),useCenter:!0}}}e.defaultData=r})(wd||(wd={}));var _r=class{modifyById(e,t){let n=this;if(n[e]===void 0)throw new Error("not expected");{let s={...n,[e]:t};return Object.setPrototypeOf(s,_r.prototype),s}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let n=t[e.id],i;n===void 0?i={type:2,id:e.id}:i={type:1,id:e.id,data:n};let{id:s,data:o}=e,a={...t,[s]:o};return Object.setPrototypeOf(a,_r.prototype),{data:a,actual:e,reverse:i}}else if(e.type===2){let{id:n}=e,i=t[n];if(i===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,_r.prototype),delete s[n],{data:s,actual:e,reverse:{type:1,id:n,data:i}}}}throw new Error("illegal arg")}};function zc(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let e=Object.getOwnPropertyNames(r);for(let t of e){let n=r[t];n&&typeof n=="object"&&zc(n)}return Object.freeze(r)}function Iw(r,e){let t=0;for(;t<r.length&&t<e.length;){if(r[t]<e[t])return-1;if(r[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==r.length?1:0}var Sd=class extends Error{};function fi(r,e,t){if(r===void 0?e===void 0?(r=0,e=10):r=e-10:e===void 0&&(e=r+10),r>e){let s=r;r=e,e=s}let n=[],i=1/(t+1);for(let s=0;s<t;s++){let o=r+(e-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function Ad(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function Nw(){return typeof process<"u"}function Rw(r,e){for(let t of r)e(t.id,t.data),Rw(t.children,e)}function Bw(r,e){e(r.id,r.data);for(let t of r.children)Bw(t,e)}var Tr=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Tr.prototype)}deepFreeze(){let t=0;for(;t<this.length;)zc(this[t]),t++}fillCaches0(t,n){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,n);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}isDescendantOf(t,n){for(;t;){let i=this.parent(t);if(i===n)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}get(t){return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,n){if(t===null)this.traverse(n);else{let i=this.get(t);i&&Bw(i,n)}}traverse(t){Rw(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this.parent(t),o=this.childrenArray(s),a=o.findIndex(h=>h.id===t);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(t,n){let i=t,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let c=s.findIndex(h=>h.id===l);if(c<0)throw new Error;s=[...s],s[c]={...s[c],children:a}}Object.setPrototypeOf(s,Tr.prototype);let o=s;return o.fillCaches(),o}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}}checkDuplicatedIdRec({id:t,children:n}){if(this.get(t)!==void 0)return!0;for(let i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:n,fi:i,id:s,data:o,children:a}=t;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(t))return null;{let l=n,c=this.childrenArray(l),h={fi:i,id:s,data:o,children:a};return c=[...c,h],c.sort((d,f)=>d.fi-f.fi),t.localIndex=c.indexOf(h),{data:this.modifyArrayBy(l,c),actual:t,reverse:{type:8,id:s}}}}deleteOp(t){let{id:n}=t;if(this.get(n)===null)return null;{let i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(c=>c.id===n);t.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:t,reverse:{type:7,...a,parent:i}}}}moveOp(t){let{parent:n,fi:i,id:s}=t;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Sd("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),c=l.findIndex(f=>f.id===s);l=[...l];let h=l.splice(c,1)[0],u=this.modifyArrayBy(o,l);o=n,l=u.childrenArray(o);let d=h.fi;return h={...h,fi:i},l=[...l,h],l.sort((f,m)=>f.fi-m.fi),t.localIndex=l.indexOf(h),u=u.modifyArrayBy(o,l),{data:u,actual:t,reverse:{type:9,parent:a,fi:d,id:s}}}previous(t,n){if(n===null){let s=this.childrenArray(t);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(t)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)+1;if(s<i.length)return i[s].id;if(n)return this.traverseSortNext(n)}}sortNext(t){let n=this.childrenArray(t);return n.length>0?n[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let n=this.childrenArray(t);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):t}sortPrevious(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(t){let n=[];for(let i of t){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>Iw(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(t){var n=t;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(t,n,i){return this.insertAfterHelper(t,this.previous(t,n),i)}insertAfterHelper(t,n,i){let s=this.childrenArray(t);if(n===null){if(s.length===0)return fi(0,i,i);{let o=s[0].fi;return fi(o-i,o,i)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==t)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return fi(l,l+i,i)}else return fi(o.fi,a.fi,i)}}};var Md;(e=>{function r(t,n){if(Array.isArray(t)){let i=n.props,s={},o=[...t],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=o[c],o[c]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...t},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let c=i[l];c===void 0?delete o[l]:o[l]=c,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}e.runOp=r})(Md||(Md={}));var Ht=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Ht.prototype)}deepFreeze(){let t=0;for(;t<this.length;)zc(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(c=>c.id===t);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(t){Object.setPrototypeOf(t,Ht.prototype);let n=t;return Nw()||n.fillCaches(),n}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}}addOp(t){let{fi:n,id:i,data:s}=t,o=this,a={fi:n,id:i,data:s};return o=[...o,a],o.sort((c,h)=>c.fi-h.fi),t.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:n}=t,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;t.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...o}}}moveOp(t){let{fi:n,id:i}=t,s=this;s=[...s];let o=s.findIndex(h=>h.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((h,u)=>h.fi-u.fi),t.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:t,reverse:{type:6,fi:a,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===t)return n;n=i.id}return null}insertBeforeHelper(t,n){return this.insertAfterHelper(this.previous(t),n)}insertAfterHelper(t,n){let i=this;if(t===null){if(i.length===0)return fi(0,n,n);{let s=i[0].fi;return fi(s-n,s,n)}}else{let s=this.get(t);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return fi(a,a+n,n)}else return fi(s.fi,o.fi,n)}}};var Ow=Symbol(),Td=Symbol(),qa=class{reportOp(e,t){let n=this;if(t===null)return;n._current=t.data;let i=[];for(;!(n instanceof _d);){let s=n._path,o=n._current;if(s!==""&&i.splice(0,0,s),n=n._parent,n===null)return;n.update(s,o)}n.push(i,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let n=t[Td];n&&n(),delete this._children[e]}}}},ug=class extends qa{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,Md.runOp(this._current,e))}},dg=class extends qa{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,_r.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},Fw={get(r,e){if(e===Td)return()=>{r._parent=null};if(e===Ow)return r._current;let{_current:t,_children:n}=r;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t[e],o=Ed(r,e,s);return o!==s?(n===void 0&&(n={},r._children=n),n[e]=o,o):s},has(r,e){return e in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,e){let t=r._current,n=Reflect.getOwnPropertyDescriptor(t,e);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:t[e]}}},JR={...Fw,set(r,e,t){let n={type:0,props:{[e]:mg(t)??t}};return r.deleteChildren(e),r.runOp(n),!0},deleteProperty(r,e){let t={type:0,props:{[e]:void 0}};return r.deleteChildren(e),r.runOp(t),!0}},$R={...Fw,set(r,e,t){return t===void 0?this.deleteProperty(r,e):(r.deleteChildren(e),r.runOp({type:1,id:e,data:t})),!0},deleteProperty(r,e){return r.runOp({type:2,id:e}),!0}},Xa=class extends qa{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Td]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,n)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Ed(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}add(e,t,n,i,s){this.runOp({type:7,parent:e,fi:t,id:n,data:i,children:s})}move(e,t,n){this.runOp({type:9,parent:e,fi:t,id:n})}insertAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}insertBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}moveAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}moveBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Ya=class extends qa{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Td]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let n=0;n<t;n++){let i=this._current[n].id;e(this.data(this._current[n].id),i)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Ed(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,n){this.runOp({type:4,fi:e,id:t,data:n})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}insertBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}moveAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}moveBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function hg(r,e,t){if(r.length>0){let n=r[r.length-1];if(n.type===0&&e.type===0&&Cd.equal(n.path,t)){Object.assign(n.props,e.props);return}}r.push({...e,path:t})}var _d=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,n,i){hg(this.ts,t,e),hg(this.actual,n,e),hg(this.reverse,i,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Ed(r,e,t){return t instanceof Tr?new Xa(r,e,t):t instanceof Ht?new Ya(r,e,t):t instanceof _r?new Proxy(new dg(r,e,t),$R):t!==null&&typeof t=="object"?Ad(t)?t:new Proxy(new ug(r,e,t),JR):t}function fg(r){let e=new _d(r);return[Ed(e,"",r),e]}function pg(r,e){let[t,n]=fg(r);return e(t),n.result()}function mg(r){return r instanceof Xa||r instanceof Ya?r._current:r!==null&&typeof r=="object"?r[Ow]:r}var Cd;(n=>{function r(i,s){if(s.length===i.length)for(var o=0;o<i.length;){if(i[o]!==s[o])return!1;o+=1}else return!1;return!0}n.equal=r;function e(i,s,o){let a=t(o,i);if(a!==void 0&&typeof a=="object"&&a!==null){let l={...s};return Object.keys(a).forEach(c=>{delete l[c]}),l}else return s}n.removeOverridden=e;function t(i,s,o=0){if(s.length<=o)return i;if((i instanceof Tr||i instanceof Xa)&&typeof s[o]=="string")return t(i.data(s[o]),s,o+1);if((i instanceof Ht||i instanceof Ya)&&typeof s[o]=="string")return t(i.data(s[o]),s,o+1);if(typeof s[o]=="number"&&Array.isArray(i))return t(i[s[o]],s,o+1);if(typeof s[o]=="string"&&typeof i=="object")return t(i[s[o]],s,o+1)}n.zoom=t})(Cd||(Cd={}));var Dd=class{},Gc=class extends Dd{constructor(t){super();this.id=t}},kc=class extends Dd{constructor(t){super();this.data=t}};var yg;try{yg=new TextDecoder}catch{}var Pe,Ls,Q=0;var jw=[],vg=jw,xg=0,nr={},vt,Ps,Er=0,pi=0,dr,ji,Xn=[],Mt,Uw={useRecords:!1,mapsAsObjects:!0},Vc=class{},wg=new Vc;wg.name="MessagePack 0xC1";var Qa=!1,mi=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Pe)return Kw(()=>(Ld(),this?this.unpack(e,t):mi.prototype.unpack.call(Uw,e,t)));Ls=t>-1?t:e.length,Q=0,xg=0,pi=0,Ps=null,vg=jw,dr=null,Pe=e;try{Mt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw Pe=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof mi){if(nr=this,this.structures)return vt=this.structures,Pd();(!vt||vt.length>0)&&(vt=[])}else nr=Uw,(!vt||vt.length>0)&&(vt=[]);return Pd()}unpackMultiple(e,t){let n,i=0;try{Qa=!0;let s=e.length,o=this?this.unpack(e,s):Rd.unpack(e,s);if(t){for(t(o);Q<s;)if(i=Q,t(Pd())===!1)return}else{for(n=[o];Q<s;)i=Q,n.push(Pd());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Qa=!1,Ld()}}_mergeStructures(e,t){e=e||[];for(let n=0,i=e.length;n<i;n++){let s=e[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let i=e[n],s=t[n];s&&(i&&((e.restoreStructures||(e.restoreStructures=[]))[n]=i),e[n]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Pd(){try{if(!nr.trusted&&!Qa){let e=vt.sharedLength||0;e<vt.length&&(vt.length=e)}let r=Qt();if(Q==Ls)vt.restoreStructures&&zw(),vt=null,Pe=null,ji&&(ji=null);else if(Q>Ls){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!Qa)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw vt.restoreStructures&&zw(),Ld(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function zw(){for(let r in vt.restoreStructures)vt[r]=vt.restoreStructures[r];vt.restoreStructures=null}function Qt(){let r=Pe[Q++];if(r<160)if(r<128){if(r<64)return r;{let e=vt[r&63]||nr.getStructures&&qw()[r&63];return e?(e.read||(e.read=Sg(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,nr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[Yw()]=Qt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Qt(),Qt());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Qt();return e}else if(r<192){let e=r-160;if(pi>=Q)return Ps.slice(Q-Er,(Q+=e)-Er);if(pi==0&&Ls<140){let t=e<16?Ag(e):Xw(e);if(t!=null)return t}return bg(e)}else{let e;switch(r){case 192:return null;case 193:return dr?(e=Qt(),e>0?dr[1].slice(dr.position1,dr.position1+=e):dr[0].slice(dr.position0,dr.position0-=e)):wg;case 194:return!1;case 195:return!0;case 196:return gg(Pe[Q++]);case 197:return e=Mt.getUint16(Q),Q+=2,gg(e);case 198:return e=Mt.getUint32(Q),Q+=4,gg(e);case 199:return wo(Pe[Q++]);case 200:return e=Mt.getUint16(Q),Q+=2,wo(e);case 201:return e=Mt.getUint32(Q),Q+=4,wo(e);case 202:if(e=Mt.getFloat32(Q),nr.useFloat32>2){let t=Nd[(Pe[Q]&127)<<1|Pe[Q+1]>>7];return Q+=4,(t*e+(e>0?.5:-.5)>>0)/t}return Q+=4,e;case 203:return e=Mt.getFloat64(Q),Q+=8,e;case 204:return Pe[Q++];case 205:return e=Mt.getUint16(Q),Q+=2,e;case 206:return e=Mt.getUint32(Q),Q+=4,e;case 207:return nr.int64AsNumber?(e=Mt.getUint32(Q)*4294967296,e+=Mt.getUint32(Q+4)):e=Mt.getBigUint64(Q),Q+=8,e;case 208:return Mt.getInt8(Q++);case 209:return e=Mt.getInt16(Q),Q+=2,e;case 210:return e=Mt.getInt32(Q),Q+=4,e;case 211:return nr.int64AsNumber?(e=Mt.getInt32(Q)*4294967296,e+=Mt.getUint32(Q+4)):e=Mt.getBigInt64(Q),Q+=8,e;case 212:if(e=Pe[Q++],e==114)return Ww(Pe[Q++]&63);{let t=Xn[e];if(t)return t.read?(Q++,t.read(Qt())):t.noBuffer?(Q++,t()):t(Pe.subarray(Q,++Q));throw new Error("Unknown extension "+e)}case 213:return e=Pe[Q],e==114?(Q++,Ww(Pe[Q++]&63,Pe[Q++])):wo(2);case 214:return wo(4);case 215:return wo(8);case 216:return wo(16);case 217:return e=Pe[Q++],pi>=Q?Ps.slice(Q-Er,(Q+=e)-Er):tB(e);case 218:return e=Mt.getUint16(Q),Q+=2,pi>=Q?Ps.slice(Q-Er,(Q+=e)-Er):nB(e);case 219:return e=Mt.getUint32(Q),Q+=4,pi>=Q?Ps.slice(Q-Er,(Q+=e)-Er):rB(e);case 220:return e=Mt.getUint16(Q),Q+=2,kw(e);case 221:return e=Mt.getUint32(Q),Q+=4,kw(e);case 222:return e=Mt.getUint16(Q),Q+=2,Vw(e);case 223:return e=Mt.getUint32(Q),Q+=4,Vw(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}var eB=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Sg(r,e){function t(){if(t.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>eB.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Qt);return r.highByte===0&&(r.read=Gw(e,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=Qt()}return n}return t.count=0,r.highByte===0?Gw(e,t):t}var Gw=(r,e)=>function(){let t=Pe[Q++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),i=vt[n]||qw()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=Sg(i,r)),i.read()};function qw(){let r=Kw(()=>(Pe=null,nr.getStructures()));return vt=nr._mergeStructures(r,vt)}var bg=Id,tB=Id,nB=Id,rB=Id;function Id(r){let e;if(r<16&&(e=Ag(r)))return e;if(r>64&&yg)return yg.decode(Pe.subarray(Q,Q+=r));let t=Q+r,n=[];for(e="";Q<t;){let i=Pe[Q++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Pe[Q++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Pe[Q++]&63,o=Pe[Q++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Pe[Q++]&63,o=Pe[Q++]&63,a=Pe[Q++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(i);n.length>=4096&&(e+=_n.apply(String,n),n.length=0)}return n.length>0&&(e+=_n.apply(String,n)),e}function kw(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Qt();return e}function Vw(r){if(nr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[Yw()]=Qt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Qt(),Qt());return e}}var _n=String.fromCharCode;function Xw(r){let e=Q,t=new Array(r);for(let n=0;n<r;n++){let i=Pe[Q++];if((i&128)>0){Q=e;return}t[n]=i}return _n.apply(String,t)}function Ag(r){if(r<4)if(r<2){if(r===0)return"";{let e=Pe[Q++];if((e&128)>1){Q-=1;return}return _n(e)}}else{let e=Pe[Q++],t=Pe[Q++];if((e&128)>0||(t&128)>0){Q-=2;return}if(r<3)return _n(e,t);let n=Pe[Q++];if((n&128)>0){Q-=3;return}return _n(e,t,n)}else{let e=Pe[Q++],t=Pe[Q++],n=Pe[Q++],i=Pe[Q++];if((e&128)>0||(t&128)>0||(n&128)>0||(i&128)>0){Q-=4;return}if(r<6){if(r===4)return _n(e,t,n,i);{let s=Pe[Q++];if((s&128)>0){Q-=5;return}return _n(e,t,n,i,s)}}else if(r<8){let s=Pe[Q++],o=Pe[Q++];if((s&128)>0||(o&128)>0){Q-=6;return}if(r<7)return _n(e,t,n,i,s,o);let a=Pe[Q++];if((a&128)>0){Q-=7;return}return _n(e,t,n,i,s,o,a)}else{let s=Pe[Q++],o=Pe[Q++],a=Pe[Q++],l=Pe[Q++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){Q-=8;return}if(r<10){if(r===8)return _n(e,t,n,i,s,o,a,l);{let c=Pe[Q++];if((c&128)>0){Q-=9;return}return _n(e,t,n,i,s,o,a,l,c)}}else if(r<12){let c=Pe[Q++],h=Pe[Q++];if((c&128)>0||(h&128)>0){Q-=10;return}if(r<11)return _n(e,t,n,i,s,o,a,l,c,h);let u=Pe[Q++];if((u&128)>0){Q-=11;return}return _n(e,t,n,i,s,o,a,l,c,h,u)}else{let c=Pe[Q++],h=Pe[Q++],u=Pe[Q++],d=Pe[Q++];if((c&128)>0||(h&128)>0||(u&128)>0||(d&128)>0){Q-=12;return}if(r<14){if(r===12)return _n(e,t,n,i,s,o,a,l,c,h,u,d);{let f=Pe[Q++];if((f&128)>0){Q-=13;return}return _n(e,t,n,i,s,o,a,l,c,h,u,d,f)}}else{let f=Pe[Q++],m=Pe[Q++];if((f&128)>0||(m&128)>0){Q-=14;return}if(r<15)return _n(e,t,n,i,s,o,a,l,c,h,u,d,f,m);let p=Pe[Q++];if((p&128)>0){Q-=15;return}return _n(e,t,n,i,s,o,a,l,c,h,u,d,f,m,p)}}}}}function gg(r){return nr.copyBuffers?Uint8Array.prototype.slice.call(Pe,Q,Q+=r):Pe.subarray(Q,Q+=r)}function wo(r){let e=Pe[Q++];if(Xn[e])return Xn[e](Pe.subarray(Q,Q+=r));throw new Error("Unknown extension type "+e)}var Hw=new Array(4096);function Yw(){let r=Pe[Q++];if(r>=160&&r<192){if(r=r-160,pi>=Q)return Ps.slice(Q-Er,(Q+=r)-Er);if(!(pi==0&&Ls<180))return bg(r)}else return Q--,Qt();let e=(r<<5^(r>1?Mt.getUint16(Q):r>0?Pe[Q]:0))&4095,t=Hw[e],n=Q,i=Q+r-3,s,o=0;if(t&&t.bytes==r){for(;n<i;){if(s=Mt.getUint32(n),s!=t[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Pe[n++],s!=t[o++]){n=1879048192;break}if(n===i)return Q=n,t.string;i-=3,n=Q}for(t=[],Hw[e]=t,t.bytes=r;n<i;)s=Mt.getUint32(n),t.push(s),n+=4;for(i+=3;n<i;)s=Pe[n++],t.push(s);let a=r<16?Ag(r):Xw(r);return a!=null?t.string=a:t.string=bg(r)}var Ww=(r,e)=>{var t=Qt();let n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let i=vt[r];return i&&i.isShared&&((vt.restoreStructures||(vt.restoreStructures=[]))[r]=i),vt[r]=t,t.read=Sg(t,n),t.read()},Qw=typeof self=="object"?self:global;Xn[0]=()=>{};Xn[0].noBuffer=!0;Xn[101]=()=>{let r=Qt();return(Qw[r[0]]||Error)(r[1])};Xn[105]=r=>{let e=Mt.getUint32(Q-4);ji||(ji=new Map);let t=Pe[Q],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let i={target:n};ji.set(e,i);let s=Qt();return i.used?Object.assign(n,s):(i.target=s,s)};Xn[112]=r=>{let e=Mt.getUint32(Q-4),t=ji.get(e);return t.used=!0,t.target};Xn[115]=()=>new Set(Qt());var Mg=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");Xn[116]=r=>{let e=r[0],t=Mg[e];if(!t)throw new Error("Could not find typed array for code "+e);return new Qw[t](Uint8Array.prototype.slice.call(r,1).buffer)};Xn[120]=()=>{let r=Qt();return new RegExp(r[0],r[1])};Xn[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=Q;Q+=e-4,dr=[Qt(),Qt()],dr.position0=0,dr.position1=0;let n=Q;Q=t;try{return Qt()}finally{Q=n}};Xn[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function Kw(r){let e=Ls,t=Q,n=xg,i=Er,s=pi,o=Ps,a=vg,l=ji,c=dr,h=new Uint8Array(Pe.slice(0,Ls)),u=vt,d=vt.slice(0,vt.length),f=nr,m=Qa,p=r();return Ls=e,Q=t,xg=n,Er=i,pi=s,Ps=o,vg=a,ji=l,dr=c,Pe=h,Qa=m,vt=u,vt.splice(0,vt.length,...d),nr=f,Mt=new DataView(Pe.buffer,Pe.byteOffset,Pe.byteLength),p}function Ld(){Pe=null,ji=null,vt=null}function Zw(r){r.unpack?Xn[r.type]=r.unpack:Xn[r.type]=r}var Nd=new Array(147);for(let r=0;r<256;r++)Nd[r]=+("1e"+Math.floor(45.15-r*.30103));var Rd=new mi({useRecords:!1}),iB=Rd.unpack,sB=Rd.unpackMultiple,oB=Rd.unpack,Bd={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},aB=new Float32Array(1),Cj=new Uint8Array(aB.buffer,0,4);var Od;try{Od=new TextEncoder}catch{}var Fd,Tg,Ud=typeof Buffer<"u",_g=Ud?Buffer.allocUnsafeSlow:Uint8Array,tS=Ud?Buffer:Uint8Array,Jw=Ud?4294967296:2144337920,oe,$t,ee=0,gi,yi=null,lB=/[\u0080-\uFFFF]/,Hc=Symbol("record-id"),So=class extends mi{constructor(e){super(e),this.offset=0;let t,n,i,s,o,a,l=0,c=tS.prototype.utf8Write?function(y,T,E){return oe.utf8Write(y,T,E)}:Od&&Od.encodeInto?function(y,T){return Od.encodeInto(y,oe.subarray(T)).written}:!1,h=this;e||(e={});let u=e&&e.sequential,d=e.structures||e.saveStructures,f=e.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=d?32:64),u&&!e.saveStructures&&(this.structures=[]);let p=f>32||m+f>64,g=f+64,x=f+m+64;if(x>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],w=0,b=0;this.pack=this.encode=function(y,T){if(oe||(oe=new _g(8192),$t=new DataView(oe.buffer,0,8192),ee=0),gi=oe.length-10,gi-ee<2048?(oe=new _g(oe.length),$t=new DataView(oe.buffer,0,oe.length),gi=oe.length-10,ee=0):ee=ee+7&2147483640,n=ee,a=h.structuredClone?new Map:null,h.bundleStrings?(yi=["",""],oe[ee++]=214,oe[ee++]=98,yi.position=ee-n,ee+=4):yi=null,i=h.structures,i){i.uninitialized&&(i=h._mergeStructures(h.getStructures()));let E=i.sharedLength||0;if(E>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let C=0;C<E;C++){let I=i[C];if(!I)continue;let R,N=i.transitions;for(let H=0,j=I.length;H<j;H++){let K=I[H];R=N[K],R||(R=N[K]=Object.create(null)),N=R}N[Hc]=C+64}l=E}u||(i.nextId=E+64)}s&&(s=!1),o=i||[];try{if(S(y),yi){$t.setUint32(yi.position+n,ee-yi.position-n);let E=yi;yi=null,S(E[0]),S(E[1])}if(h.offset=ee,a&&a.idsToInsert){ee+=a.idsToInsert.length*6,ee>gi&&_(ee),h.offset=ee;let E=hB(oe.subarray(n,ee),a.idsToInsert);return a=null,E}return T&rS?(oe.start=n,oe.end=ee,oe):oe.subarray(n,ee)}finally{if(i){if(b<10&&b++,w>1e4)i.transitions=null,b=0,w=0,v.length>0&&(v=[]);else if(v.length>0&&!u){for(let E=0,C=v.length;E<C;E++)v[E][Hc]=0;v=[]}if(s&&h.saveStructures){let E=i.sharedLength||f;i.length>E&&(i=i.slice(0,E));let C=oe.subarray(n,ee);return h.saveStructures(i,l)===!1?(h._mergeStructures(h.getStructures()),h.pack(y)):(l=E,C)}}T&yB&&(ee=n)}};let S=y=>{ee>gi&&(oe=_(ee));var T=typeof y,E;if(T==="string"){let C=y.length;if(yi&&C>=8&&C<4096){let N=lB.test(y);yi[N?0:1]+=y,oe[ee++]=193,S(N?-C:C);return}let I;C<32?I=1:C<256?I=2:C<65536?I=3:I=5;let R=C*3;if(ee+R>gi&&(oe=_(ee+R)),C<64||!c){let N,H,j,K=ee+I;for(N=0;N<C;N++)H=y.charCodeAt(N),H<128?oe[K++]=H:H<2048?(oe[K++]=H>>6|192,oe[K++]=H&63|128):(H&64512)===55296&&((j=y.charCodeAt(N+1))&64512)===56320?(H=65536+((H&1023)<<10)+(j&1023),N++,oe[K++]=H>>18|240,oe[K++]=H>>12&63|128,oe[K++]=H>>6&63|128,oe[K++]=H&63|128):(oe[K++]=H>>12|224,oe[K++]=H>>6&63|128,oe[K++]=H&63|128);E=K-ee-I}else E=c(y,ee+I,R);E<32?oe[ee++]=160|E:E<256?(I<2&&oe.copyWithin(ee+2,ee+1,ee+1+E),oe[ee++]=217,oe[ee++]=E):E<65536?(I<3&&oe.copyWithin(ee+3,ee+2,ee+2+E),oe[ee++]=218,oe[ee++]=E>>8,oe[ee++]=E&255):(I<5&&oe.copyWithin(ee+5,ee+3,ee+3+E),oe[ee++]=219,$t.setUint32(ee,E),ee+=4),ee+=E}else if(T==="number")if(y>>>0===y)y<64?oe[ee++]=y:y<256?(oe[ee++]=204,oe[ee++]=y):y<65536?(oe[ee++]=205,oe[ee++]=y>>8,oe[ee++]=y&255):(oe[ee++]=206,$t.setUint32(ee,y),ee+=4);else if(y>>0===y)y>=-32?oe[ee++]=256+y:y>=-128?(oe[ee++]=208,oe[ee++]=y+256):y>=-32768?(oe[ee++]=209,$t.setInt16(ee,y),ee+=2):(oe[ee++]=210,$t.setInt32(ee,y),ee+=4);else{let C;if((C=this.useFloat32)>0&&y<4294967296&&y>=-2147483648){oe[ee++]=202,$t.setFloat32(ee,y);let I;if(C<4||(I=y*Nd[(oe[ee]&127)<<1|oe[ee+1]>>7])>>0===I){ee+=4;return}else ee--}oe[ee++]=203,$t.setFloat64(ee,y),ee+=8}else if(T==="object")if(!y)oe[ee++]=192;else{if(a){let I=a.get(y);if(I){if(!I.id){let R=a.idsToInsert||(a.idsToInsert=[]);I.id=R.push(I)}oe[ee++]=214,oe[ee++]=112,$t.setUint32(ee,I.id),ee+=4;return}else a.set(y,{offset:ee-n})}let C=y.constructor;if(C===Object)M(y,!0);else if(C===Array){E=y.length,E<16?oe[ee++]=144|E:E<65536?(oe[ee++]=220,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=221,$t.setUint32(ee,E),ee+=4);for(let I=0;I<E;I++)S(y[I])}else if(C===Map){E=y.size,E<16?oe[ee++]=128|E:E<65536?(oe[ee++]=222,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=223,$t.setUint32(ee,E),ee+=4);for(let[I,R]of y)S(I),S(R)}else{for(let I=0,R=Fd.length;I<R;I++){let N=Tg[I];if(y instanceof N){let H=Fd[I];if(H.write){H.type&&(oe[ee++]=212,oe[ee++]=H.type,oe[ee++]=0),S(H.write.call(this,y));return}let j=oe,K=$t,Y=ee;oe=null;let z;try{z=H.pack.call(this,y,F=>(oe=j,j=null,ee+=F,ee>gi&&_(ee),{target:oe,targetView:$t,position:ee-F}),S)}finally{j&&(oe=j,$t=K,ee=Y,gi=oe.length-10)}z&&(z.length+ee>gi&&_(z.length+ee),ee=cB(z,oe,ee,H.type));return}}M(y,!y.hasOwnProperty)}}else if(T==="boolean")oe[ee++]=y?195:194;else if(T==="bigint"){if(y<BigInt(1)<<BigInt(63)&&y>=-(BigInt(1)<<BigInt(63)))oe[ee++]=211,$t.setBigInt64(ee,y);else if(y<BigInt(1)<<BigInt(64)&&y>0)oe[ee++]=207,$t.setBigUint64(ee,y);else if(this.largeBigIntToFloat)oe[ee++]=203,$t.setFloat64(ee,Number(y));else throw new RangeError(y+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");ee+=8}else if(T==="undefined")this.encodeUndefinedAsNil?oe[ee++]=192:(oe[ee++]=212,oe[ee++]=0,oe[ee++]=0);else if(T==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},M=this.useRecords===!1?this.variableMapSize?y=>{let T=Object.keys(y),E=T.length;E<16?oe[ee++]=128|E:E<65536?(oe[ee++]=222,oe[ee++]=E>>8,oe[ee++]=E&255):(oe[ee++]=223,$t.setUint32(ee,E),ee+=4);let C;for(let I=0;I<E;I++)S(C=T[I]),S(y[C])}:(y,T)=>{oe[ee++]=222;let E=ee-n;ee+=2;let C=0;for(let I in y)(T||y.hasOwnProperty(I))&&(S(I),S(y[I]),C++);oe[E+++n]=C>>8,oe[E+n]=C&255}:y=>{let T=Object.keys(y),E,C=o.transitions||(o.transitions=Object.create(null)),I=0;for(let N=0,H=T.length;N<H;N++){let j=T[N];E=C[j],E||(E=C[j]=Object.create(null),I++),C=E}let R=C[Hc];if(R)R>=96&&p?(oe[ee++]=((R-=96)&31)+96,oe[ee++]=R>>5):oe[ee++]=R;else{R=o.nextId,R||(R=64),R<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(R=o.nextOwnId,R<x||(R=g),o.nextOwnId=R+1):(R>=x&&(R=g),o.nextId=R+1);let N=T.highByte=R>=96&&p?R-96>>5:-1;C[Hc]=R,o[R-64]=T,R<g?(T.isShared=!0,o.sharedLength=R-63,s=!0,N>=0?(oe[ee++]=(R&31)+96,oe[ee++]=N):oe[ee++]=R):(N>=0?(oe[ee++]=213,oe[ee++]=114,oe[ee++]=(R&31)+96,oe[ee++]=N):(oe[ee++]=212,oe[ee++]=114,oe[ee++]=R),I&&(w+=b*I),v.length>=m&&(v.shift()[Hc]=0),v.push(C),S(T))}for(let N=0,H=T.length;N<H;N++)S(y[T[N]])},_=y=>{let T;if(y>16777216){if(y-n>Jw)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(Jw,Math.round(Math.max((y-n)*(y>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(y-n<<2,oe.length-1)>>12)+1<<12;let E=new _g(T);return $t=new DataView(E.buffer,0,T),oe.copy?oe.copy(E,0,n,y):E.set(oe.slice(n,y)),ee-=n,n=0,gi=E.length-10,oe=E}}useBuffer(e){oe=e,$t=new DataView(oe.buffer,oe.byteOffset,oe.byteLength),ee=0}};Tg=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Vc];Fd=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=e(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=e(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:i,targetView:s,position:o}=e(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=e(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){let n=Array.from(r),{target:i,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),t(n)}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),t([r.source,r.flags])}},{pack(r,e){this.structuredClone?$w(r,16,e):eS(Ud?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==tS&&this.structuredClone?$w(r,Mg.indexOf(t.name),e):eS(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function $w(r,e,t,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=t(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=t(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=t(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=e,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function eS(r,e){let t=r.byteLength;var n,i;if(t<256){var{target:n,position:i}=e(t+2);n[i++]=196,n[i++]=t}else if(t<65536){var{target:n,position:i}=e(t+3);n[i++]=197,n[i++]=t>>8,n[i++]=t&255}else{var{target:n,position:i,targetView:s}=e(t+5);n[i++]=198,s.setUint32(i,t),i+=4}n.set(r,i)}function cB(r,e,t,n){let i=r.length;switch(i){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:i<256?(e[t++]=199,e[t++]=i):i<65536?(e[t++]=200,e[t++]=i>>8,e[t++]=i&255):(e[t++]=201,e[t++]=i>>24,e[t++]=i>>16&255,e[t++]=i>>8&255,e[t++]=i&255)}return e[t++]=n,e.set(r,t),t+=i,t}function hB(r,e){let t,n=e.length*6,i=r.length-n;for(e.sort((s,o)=>s.offset>o.offset?1:-1);t=e.pop();){let s=t.offset,o=t.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function Ao(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");Tg.unshift(r.Class),Fd.unshift(r)}Zw(r)}var nS=new So({useRecords:!1}),uB=nS.pack,dB=nS.pack;var{NEVER:fB,ALWAYS:pB,DECIMAL_ROUND:mB,DECIMAL_FIT:gB}=Bd,rS=512,yB=1024;var iS=new So({structuredClone:!0});Ao({Class:_r.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,_r.prototype),r}});Ao({Class:Ht.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Ht.prototype),r}});Ao({Class:Tr.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Tr.prototype),r}});Ao({Class:Gc.prototype.constructor,type:4,write(r){return r.id},read(r){return new Gc(r)}});Ao({Class:kc.prototype.constructor,type:5,write(r){return r.data},read(r){return new kc(r)}});function vB(r){var e=0;if(r.length===0)return e;for(let t=0;t<r.length;t++){let n=r[t];e=(e<<5)-e+n,e=e&e}return e}function Eg(r){if(Ad(r))return r;if(Array.isArray(r))return r.map(Eg);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=Eg(r[t]);return Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else return r}var zd;(n=>{function r(i){return iS.pack(i)}n.serialize=r;function e(i){return iS.unpack(i)}n.deserialize=e;function t(i){return vB(r(Eg(i))).toString()}n.checksum=t})(zd||(zd={}));var Gd;(t=>{t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(n){return t.all.includes(n)}t.is=e})(Gd||(Gd={}));var kd;(t=>{function r(n){return e(n)}t.defaultData=r;function e(n){if(n==="PointLight")return{type:n,color:On.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5,helper:!0};if(n==="SpotLight")return{type:n,color:On.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,helper:!0,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:On.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,helper:!0,shadowRadius:1};throw new Error("not implemented")}})(kd||(kd={}));var Cg;(t=>{t.defaultData={castShadow:!0,receiveShadow:!0};function e(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}t.equals=e})(Cg||(Cg={}));var Dg;(t=>{t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}t.equals=e})(Dg||(Dg={}));var Vd;(e=>e.defaultData={...Dg.defaultData,...Cg.defaultData,cloner:null,booleanExclude:null})(Vd||(Vd={}));var Pg=(i=>(i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.Center=3]="Center",i[i.Justify=4]="Justify",i))(Pg||{}),Lg=(n=>(n[n.Top=1]="Top",n[n.Center=2]="Center",n[n.Bottom=3]="Bottom",n))(Lg||{}),Ig=(n=>(n[n.None=1]="None",n[n.Upper=2]="Upper",n[n.Lower=3]="Lower",n))(Ig||{}),Hd;(e=>e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:On.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(Hd||(Hd={}));var sS=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"];var Ka;(n=>{function r(i,s){return i==="light"&&s?e(s):t(i)}n.defaultData=r;function e(i){switch(i){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:dn.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...dn.fromHex(6710886),a:1},colorB:{...dn.fromHex(6710886),a:1},colorC:{...dn.fromHex(16777215),a:1},colorD:{...dn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:On.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:On.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:On.fromHexAndA(0,1),contourColor:On.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(Ka||(Ka={}));var qr;(a=>{function r(l){return!l.layers.some(h=>{if(h.data.type==="texture"&&h.data.projection!==0||h.data.type==="depth"&&!h.data.isWorldSpace||h.data.type==="noise"||h.data.type==="displace")return!0})&&!t(l)}a.isMergable=r;function e(l){let c="";return l.layers.forEach(h=>{Object.entries(h.data).forEach(([u,d])=>{c+=`${u}${d}`,Array.isArray(d)?d.forEach(f=>c+=`${f}`):typeof d=="object"?Object.values(d).forEach(f=>{typeof f=="number"?c+=`${f.toFixed(4)}`:c+=`${f}`}):c+=`${d}`})}),c}a.getHash=e;function t(l){let c=0;for(let h of l.layers)"alpha"in h.data&&h.data.type!=="light"&&h.data.type!=="fresnel"&&(c+=(1-c)*h.data.alpha);return c<1}a.isTransparent=t;function n(){return{layers:new Ht}}a.defaultEmptyData=n;function i(l="layer1",c="layer2"){return s("phong",l,c)}a.defaultData=i;function s(l,c="layer1",h="layer2"){let u=new Ht;return u.push({fi:0,data:Ka.defaultData("light",l),id:c}),u.push({fi:1,data:Ka.defaultData("color"),id:h}),{layers:u}}a.defaultTwoLayerData=s;function o(l,c="basic",h="layer1",u="layer2"){let d=Ka.defaultData("texture");Object.assign(d.texture,{image:l});let f=new Ht;return f.push({fi:0,data:d,id:h}),f.push({fi:1,data:Ka.defaultData("light",c),id:u}),{layers:f}}a.defaultTwoLayerTextureData=o})(qr||(qr={}));var Za;(e=>{function r(){return{points:new Ht,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=r})(Za||(Za={}));var Wd;(e=>{function r(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=r})(Wd||(Wd={}));var Wc;(e=>{function r(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="VectorGeometry")return{width:1,height:1,type:t,subdivisions:12,shape:Za.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="BooleanGeometry")return{type:t,operation:2,width:0,height:0,depth:0,phongAngle:35};throw new Error("not implemented")}e.defaultData=r})(Wc||(Wc={}));var jc;(i=>{i.identity={...vd.identity,hiddenMatrix:di.identity};function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=e;function t(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=t;function n(s,o){return{position:on.isEqual(s.position,o.position)?null:o.position,rotation:on.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:on.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:di.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=n})(jc||(jc={}));var qi;(e=>e.defaultData={states:new Ht,events:new Ht,visible:!0,raycastLock:!1,...jc.identity})(qi||(qi={}));var oS;(e=>e.defaultData={type:"Empty",...qi.defaultData})(oS||(oS={}));var jd;(e=>e.defaultData={type:"Mesh",...qi.defaultData,...Vd.defaultData})(jd||(jd={}));var aS;(e=>e.defaultData={type:"TextFrame",...qi.defaultData,...Hd.defaultData})(aS||(aS={}));var qd;(e=>e.defaultData={...qi.defaultData,...jc.identity,...bo.defaultData})(qd||(qd={}));var lS;(e=>{function r(t){return{...qi.defaultData,...kd.defaultData(t)}}e.defaultData=r})(lS||(lS={}));var cS;(n=>(n.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:di.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new Ht,events:new Ht,...bo.defaultData},n.defaultMeshObject={name:"Rectangle",...qi.defaultData,...jd.defaultData,geometry:Wc.defaultData("RectangleGeometry"),material:qr.defaultTwoLayerData("basic","layer1","layer2")},n.defaultBooleanObject={name:"Boolean",...qi.defaultData,...jd.defaultData,geometry:Wc.defaultData("BooleanGeometry"),material:qr.defaultTwoLayerData("phong","layer1","layer2")}))(cS||(cS={}));var qc;(t=>{function r(n,i){if(i===void 0)return n;let s={...n};return"material"in s&&"material"in i&&i.material&&(s.material=pg(s.material,o=>{if(typeof o!="string")for(let[a,l]of Object.entries(i.material.layers)){let c=o.layers.data(a);c&&xo(c,l)}}).data),s.materials&&i.materials&&(s.materials=pg(s.materials,o=>{for(let a=0;a<s.materials.length;a++){let l=i.materials[a];if(typeof l!="string")for(let[c,h]of Object.entries(l.layers)){let u=o[a]?.layers?.data(c);u&&xo(u,h)}}}).data),s}t.patchMaterialState=r;function e(n,i){if(i===void 0)return n;let s={...n};if(Object.assign(s,jc.merge(s,i)),Ds.is(n.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let o=i;o.orthographic?.zoom!==void 0&&(s.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(s.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(s.targetOffset=o.targetOffset)}else if(n.type==="Mesh")s.geometry={...s.geometry},Object.assign(s.geometry,i.geometry),s=r(s,i);else if(Gd.is(n.type)){let o=i;s.intensity!==void 0&&(s.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?s.color=o.color:s.color=dn.clone(o.color))}return s}t.patch=e})(qc||(qc={}));function uS(r,e=!1){let t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new Le,c=0;for(let h=0;h<r.length;++h){let u=r[h],d=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in u.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(u.attributes[f]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in u.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(u.morphAttributes[f])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(u.userData),e){let f;if(t)f=u.index.count;else if(u.attributes.position!==void 0)f=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,f,h),c+=f}}if(t){let h=0,u=[];for(let d=0;d<r.length;++d){let f=r[d].index;for(let m=0;m<f.count;++m)u.push(f.getX(m)+h);h+=r[d].attributes.position.count}l.setIndex(u)}for(let h in s){let u=hS(s[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(let h in o){let u=o[h][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let d=0;d<u;++d){let f=[];for(let p=0;p<o[h].length;++p)f.push(o[h][p][d]);let m=hS(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}return l}function hS(r){let e,t,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=l.array.length}let s=new e(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new Xe(s,t,n)}var Ng={type:"change"},dS={type:"changeZoom"},xB={type:"changePan"},Ja={type:"start"},Xc={type:"end"},Rg=new Xt,bB=new B,wB=2*Math.PI,SB=1e-8,AB=.01,fS=2,Bg=.125,pS=2,Og=1,Fg=1,Ug=.1;var Xd=class extends Rt{constructor(t,n){super();this.object=t;this.domElement=n;this.enabled=!0;this.useKeyEvents=!0;this.enableDamping=!1;this.enableZoom=!0;this.enableRotate=!0;this.enablePan=!0;this.autoRotate=!1;this.rotationLimitsMode=0;this.panLimitsMode=0;this.rotationSoftLimit=2;this.panSoftLimit=2;this.hoverRotatePanMode=0;this.zoomLimitsEnabled=!1;this.preventScroll=!0;this.mouseButtons=[0,5];this.mouseButtonsPlay=[3,4,5];this.touches=[null,cr.DOLLY_ROTATE,cr.PAN];this.offset=new A;this.eye=new A;this.lastPosition=new A;this.lastQuaternion=new Xt;this.current=new B;this.overShoot=new B;this.overRatio=new B;this.spherical=new wc;this.sphericalDelta=new wc;this.panOffset=new A;this.panLeftV=new A;this.panUpV=new A;this.panV=new A;this.rotateStart=new B;this.rotateEnd=new B;this.rotateDelta=new B;this.panStart=new B;this.panEnd=new B;this.panDelta=new B;this.dollyStart=new B;this.dollyEnd=new B;this.dollyDelta=new B;this.rotationRangeFactor=new B;this.panRangeFactor=new B;this.state=-1;this.zoomChanged=!1;this.isPointerDown=!1;this.isFirstHover=!0;this.isThetaFlipped=!1;this.prevScale=0;this.scale=1;this.gesture=!1;this.timer=-1;this.timerHover=-1;this.minDistance=0;this.maxDistance=1/0;this.minZoom=0;this.maxZoom=1/0;this.minPhi=0;this.maxPhi=Math.PI;this.minTheta=-1/0;this.maxTheta=1/0;this.minH=0;this.maxH=Math.PI;this.minV=-1/0;this.maxV=1/0;this.autoRotateClockwise=!0;this.isPanOverShoot=!1;this.isRotateOverShoot=!1;this.update=()=>{let t=this.object.position;this.offset.copy(t).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(Rg.copy(this.object.quaternion).invert()),this.panOffset.applyQuaternion(Rg),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(this.object.quaternion),this.panOffset.applyQuaternion(this.object.quaternion)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-Bg),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),t.copy(this.target).add(this.offset);let n=this.spherical.phi%wB;return this.eye.copy(this.offset).normalize(),this.object.up.copy(ct.DefaultUp).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),n>0&&n>Math.PI||n<0&&n>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0?(this.sphericalDelta.theta*=1-Bg,this.sphericalDelta.phi*=1-Bg):this.sphericalDelta.set(0,0,0),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>AB||8*(1-this.lastQuaternion.dot(this.object.quaternion))>SB?(this.dispatchEvent(Ng),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)};this.onPointerDown=t=>{this.enabled!==!1&&(this.isPointerDown=!0,ft.length===0&&(this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)),_B(t),t.pointerType==="touch"?this.onPointerDownTouch(t):this.onPointerDownMouse(t))};this.onPointerMove=t=>{this.enabled!==!1&&(t.pointerType==="touch"?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t))};this.onPointerUp=t=>{gS(t),this.isPointerDown=!1,ft.length===0&&(this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)),this.dispatchEvent(Xc),this.state=-1};this.onPointerCancel=t=>{gS(t)};this.onPointerDownMouse=t=>{let n;switch(this.useKeyEvents?n=this.mouseButtons[t.button]:n=this.mouseButtonsPlay[t.button],n){case 0:if(t.altKey===!0&&!t.shiftKey&&!Fc(t)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(Fc(t)||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(Fc(t)||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Ja)};this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}};this.onPointerDownTouch=t=>{switch(yS(t),this.touches[ft.length-1]){case cr.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case cr.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case cr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case cr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Ja)};this.onPointerMoveTouch=t=>{switch(yS(t),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}};this.dispatchEndDebounced=Nc(()=>this.dispatchEvent(Xc),33);this.onMouseWheel=t=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||((this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth||this.preventScroll)&&t.preventDefault(),this.dispatchEvent(Ja),this.handleMouseWheel(t),this.dispatchEndDebounced())};this.onGesture=t=>{if(this.enabled!==!1)if(t.preventDefault(),t.type==="gesturechange"){if(this.enableZoom===!1)return;this.dispatchEvent(Ja),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update()}else this.dispatchEvent(Xc)};this.onContextMenu=t=>{this.enabled!==!1&&t.preventDefault()};this.onTouchMove=t=>{(t.touches.length>1||this.preventScroll)&&t.preventDefault()};this.onTouchEnd=t=>{t.preventDefault()};this.onKeyDown=t=>{this.enabled!==!1&&(this.key=t.key)};this.onKeyUp=()=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&this.onPointerUp(ft[0]))};this.onPointerHover=t=>{if(!(yd||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot)){if(window.clearTimeout(this.timerHover),this.isPointerDown=!0,this.isFirstHover){let n={clientX:window.innerWidth/2,clientY:window.innerHeight/2};this.hoverRotatePanMode===2?this.handleMouseDownPan(n):this.hoverRotatePanMode===1&&this.handleMouseDownRotate(n),this.isFirstHover=!1}this.hoverRotatePanMode===2?this.handleMouseMovePan(t,Ug):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(t,Ug),this.timerHover=window.setTimeout(()=>{this.isPointerDown=!1},30)}};this.object=t,this.domElement=n,this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.connect(),this.update()}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ng),this.isFirstHover=!0,this.update(),this.state=-1}resetTo(t,n,i){this.target.copy(t),this.object.position.copy(n),this.object.zoom=i,this.object.updateProjectionMatrix(),this.dispatchEvent(Ng),this.update(),this.state=-1}fromJSON(t){this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.isFirstHover=!0,this.hoverRotatePanMode!==0&&this.domElement.addEventListener("pointermove",this.onPointerHover),Ug=(t.hoverRotatePanStrength/100)**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/t.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,fS=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let i=this.object.getTarget().applyQuaternion(Rg.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+i.y,this.maxV=t.panVerticalOffset.max+i.y,this.minH=-t.panHorizontalOffset.min+i.x,this.maxH=t.panHorizontalOffset.max+i.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=Is(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=Is(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=Is(this.spherical.theta-t.rotationHorizontalOffset.min),this.maxTheta=Is(this.spherical.theta+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,this.preventScroll=t.preventScroll,t.orbitTouches===1&&(this.touches[0]=cr.ROTATE),t.panTouches===1&&(this.touches[0]=cr.PAN),t.orbitTouches===2&&(this.touches[1]=cr.DOLLY_ROTATE),t.panTouches===2&&(this.touches[1]=cr.DOLLY_PAN),t.orbitTouches===3&&(this.touches[2]=cr.ROTATE),t.panTouches===3&&(this.touches[2]=cr.PAN)}connect(){this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),Cs||(this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture)),this.domElement.addEventListener("touchmove",this.onTouchMove),this.domElement.addEventListener("touchend",this.onTouchEnd)}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),Cs||(this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture)),this.domElement.removeEventListener("touchmove",this.onTouchMove),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,n,i,s,o,a,l,c){this.overShoot.set(0,0);let h,u,d;t instanceof A?(h=t.x,u=t.y,this.current.set(this.target.x,this.target.y),d=!0):(h=t.theta,u=t.phi,this.current.set(Is(this.spherical.theta),Is(this.spherical.phi)),d=!1),i===0&&(this.current.x+=h,this.current.y+=u),(n===3||n===2)&&(!d&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x),s===o&&(h=0)),(n===3||n===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<l&&(this.overShoot.y=l-this.current.y),a===l&&(u=0)),d||(this.overShoot.x=Is(this.overShoot.x),this.overShoot.y=Is(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(c),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=mS(Math.abs(this.overRatio.x)),this.overRatio.y=mS(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9||this.overRatio.y>.9)?this.isPointerDown=!1:(h*this.overShoot.x<0&&(h*=1-this.overRatio.x),u*this.overShoot.y<0&&(u*=1-this.overRatio.y)):i===2&&(!d&&(this.overRatio.x>.002||this.overRatio.y>.002)||d&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(h=this.overShoot.x*.05,u=this.overShoot.y*.05,d?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):d?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(h+=this.overShoot.x,u+=this.overShoot.y),t instanceof A?(t.x=h,t.y=u):(t.theta=h,t.phi=u)}setEnableDampingSpeed(t){this.enableDamping=t,Og=t===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*fS}getZoomScale(){return Math.pow(.95,pS)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,n){this.panLeftV.setFromMatrixColumn(n,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,n){this.panUpV.setFromMatrixColumn(n,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,n){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrix),this.panUp(2*n*o/i.clientHeight,this.object.matrix)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this.panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix));this.dispatchEvent(xB)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(dS)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(dS)}zoomOut(t=this.getZoomScale()){this.dispatchEvent(Ja),this.dollyOut(t),this.dispatchEvent(Xc)}zoomIn(t=this.getZoomScale()){this.dispatchEvent(Ja),this.dollyIn(t),this.dispatchEvent(Xc)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,n=1){this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Og*n).rotateAround(bB,-this.object.angleOffsetFromUp);let i=this.domElement;this.rotateLeft(2*Math.PI*this.rotateDelta.x/i.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/i.clientHeight),this.rotateStart.copy(this.rotateEnd),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,n=1){this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(Fg*n),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd),this.update()}handleMouseWheel(t){if(Dw===!1&&Fc(t)===!1&&MB(t)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(Fg),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1)return;t.deltaY===0?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if(ft.length===2){let t=.5*(ft[0].pageX+ft[1].pageX),n=.5*(ft[0].pageY+ft[1].pageY);this.rotateStart.set(t,n)}else this.rotateStart.set(ft[0].pageX,ft[0].pageY)}handleTouchStartPan(){if(ft.length===2){let t=.5*(ft[0].pageX+ft[1].pageX),n=.5*(ft[0].pageY+ft[1].pageY);this.panStart.set(t,n)}else this.panStart.set(ft[0].pageX,ft[0].pageY)}handleTouchStartDolly(){let t=ft[0].pageX-ft[1].pageX,n=ft[0].pageY-ft[1].pageY,i=Math.sqrt(t*t+n*n);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(ft.length===2){let i=zg(t),s=.5*(t.pageX+i.x),o=.5*(t.pageY+i.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==ft[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Og);let n=this.domElement;n&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/n.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/n.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(ft.length===2){let n=zg(t),i=.5*(t.pageX+n.x),s=.5*(t.pageY+n.y);this.panEnd.set(i,s)}else{if(t.pointerId!==ft[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(Fg),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let n=zg(t),i=t.pageX-n.x,s=t.pageY-n.y,o=Math.sqrt(i*i+s*s);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,pS)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}};function Is(r){let e=Math.PI*2;for(;r<=-Math.PI;)r+=e;for(;r>Math.PI;)r-=e;return r}function mS(r){return 1-Math.pow(1-r,4)}function MB(r){return r.wheelDeltaY===0||r.deltaY===0?Oc&&r.shiftKey&&Math.abs(r.wheelDeltaX)>=120?!1:r.wheelDeltaX?r.wheelDeltaX===-3*r.deltaX:r.deltaMode===0:r.wheelDeltaY?r.wheelDeltaY===-3*r.deltaY:r.deltaMode===0}var ft=[],Yd={};function _B(r){ft.push(r)}function gS(r){delete Yd[r.pointerId];for(let e=0;e<ft.length;e++)if(ft[e].pointerId===r.pointerId){ft.splice(e,1);return}}function yS(r){let e=Yd[r.pointerId];e===void 0&&(e=new B,Yd[r.pointerId]=e),e.set(r.pageX,r.pageY)}function zg(r){let e=r.pointerId===ft[0].pointerId?ft[1]:ft[0];return Yd[e.pointerId]}var Ns=class extends Eu{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,n=[]){return e.forEach(i=>{i.visible&&this.intersectObject(i,t,n)}),n}createRaycastLineHelper(){let e=new Jn({color:65280,linewidth:10}),t=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new A().addVectors(t,n.multiplyScalar(i)),o=new Le;return o.setFromPoints([t,s]),new so(o,e)}};var xS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},r.parameters),n=t.width/2,i=t.radiusTop??n,s=t.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:h,cornerRadius:u,cornerSegments:d,hollow:f}=r.parameters,m;return u||f?m=new Yc(c,h,n,i,s,o,a,l*Math.PI/180,u,u,d,f):m=new ao(c,h,n,i,s,o,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:{...r,type:"CylinderGeometry"}})}};function Rs(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function vS(r){return new B(r.y,-r.x)}var Yc=class extends Le{constructor(e,t,n,i,s,o,a,l,c,h,u,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(c=0,h=0);let m=[],p=[],g=[],x=[],v=0,w=n/2,b=new A,S=new A;f&&e==0&&(e=c),f&&t==0&&(t=h);let M=new B(e,w),_=new B(t,-w),y=null,T=null,E=null,C=null,I=M.clone().sub(_),R=0,N=0,H=0;d>0&&(R=Math.min(e,t)*(1-d),N=e-R,H=t-R);let j=M.clone();j.x-=R;let K=Math.PI-I.angle(),Y=I.angle(),z=Math.tan(Y/2),F=Math.tan(K/2),V=z+F,O=d?V:F,G=d?V:z;if(c=Math.min(c,(e-N)/O,I.length()/V),h=Math.min(h,(t-H)/G,I.length()/V),c>0){let te=c/z;y=M.clone().sub(new B(te,c)),d&&(E=y.clone(),E.x-=R-V*c),M.sub(I.clone().setLength(te))}if(h>0){let te=h/F;T=_.clone().sub(new B(te,-h)),_.add(I.clone().setLength(te)),d&&(C=T.clone(),C.x-=R-V*h,j.sub(I.clone().setLength(te)))}I=M.clone().sub(_);let W=I.length()<.5,X=[];for(let te=0;te<=i;te++){let k=[],le=te/i,ce=le*l+a,ae=new B(Math.sin(ce),Math.cos(ce));C&&T?(q(k,le,ae,K,h,C,-1,!0),q(k,le,ae,Y,h,T,-1,!1)):T?(se(k,ae,T.x,0,-1),q(k,le,ae,Y,h,T,-1,!1)):o||se(k,ae,t,H,-1);let de=vS(I).normalize();if(Rs(de,ae,b),!W)for(let ge=0;ge<=s;ge++){let fe=ge/s,Ee=I.clone().multiplyScalar(fe).add(_);Rs(Ee,ae,S),p.push(S.x,S.y,S.z),g.push(b.x,b.y,b.z),x.push(le,.5+S.y/n),k.push(v++)}if(E&&y?(q(k,le,ae,K,c,y,1,!1),q(k,le,ae,Y,c,E,1,!0)):y?(q(k,le,ae,K,c,y,1,!1),se(k,ae,y.x,0,1)):o||se(k,ae,e,N,1),d&&!W){let ge=vS(I).multiplyScalar(-1).normalize();Rs(ge,ae,b);for(let fe=0;fe<=s;fe++){let Ee=fe/s,De=I.clone().multiplyScalar(-Ee).add(j);Rs(De,ae,S),p.push(S.x,S.y,S.z),g.push(b.x,b.y,b.z),x.push(le,.5+S.y/n),k.push(v++)}}d&&!o&&k.push(k[0]),X.push(k)}for(let te=0;te<X.length-1;te++)for(let k=0;k<X[0].length-1;k++){if(o&&d&&k==s)continue;let le=X[te][k],ce=X[te+1][k],ae=X[te+1][k+1],de=X[te][k+1],ge=p[ae*3+0],fe=p[ae*3+2];m.push(le,ce,de),(ge!=0||fe!=0)&&m.push(ce,ae,de)}l<Math.PI*2&&(Z(-1,X[0],a),Z(1,X[X.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Se(p,3)),this.setAttribute("normal",new Se(g,3)),this.setAttribute("uv",new Se(x,2));function q(te,k,le,ce,ae,de,ge,fe){for(let Ee=0;Ee<u+1;Ee++){let De=Ee/u,ye=ge<0?De:1-De;fe&&(ye-=1),ye*=ce;let Re=new B(Math.sin(ye),Math.cos(ye)*ge),mt=Re.clone().multiplyScalar(ae).add(de);Rs(mt,le,S),p.push(S.x,S.y,S.z),Rs(Re,le,b),g.push(b.x,b.y,b.z),x.push(k,.5+S.y/n),te.push(v++)}}function se(te,k,le,ce,ae){let de=new A,ge=new B,fe=[le,ce];ae<0&&fe.reverse();for(let Ee of fe)ge.set(Ee,w*ae),Rs(ge,k,de),p.push(de.x,de.y,de.z),g.push(0,ae,0),x.push(.5,.5),te.push(v++)}function Z(te,k,le){let ce=new B(Math.sin(le),Math.cos(le)),ae=new B(-Math.cos(le),Math.sin(le)),de=new A,ge=te<0?(De,ye,Re)=>m.push(De,ye,Re):(De,ye,Re)=>m.push(De,Re,ye),fe=new B((e+t+N+H)/4,0);Rs(fe,ce,de),p.push(de.x,de.y,de.z),g.push(ae.x,0,ae.y),x.push(.5,.5);let Ee=v++;for(let De of k){let ye=p.slice(De*3,De*3+3);p.push(...ye),g.push(ae.x,0,ae.y);let Re=x.slice(De*2,De*2+2);x.push(...Re),v++}for(let De=Ee+1;De<v-1;De++)ge(Ee,De,De+1);ge(Ee,v-1,Ee+1)}}};var bS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:h,cornerSegments:u}=r.parameters,d;return c>0||h>0||l<360?d=new Yc(0,e/2,n,i,s,o,a,l*Math.PI/180,c,h,u,0,!0):d=new la(e/2,n,i,s,o),d.scale(1,1,t/e),Object.assign(d,{userData:{...r,type:"ConeGeometry"}})}};var wS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,c;return a==0?c=new Zn(e,t,n,i,s,o):c=new Vg(e,t,n,i,s,o,a,l),Object.assign(c,{userData:{...r,type:"CubeGeometry"}})}},kg=Math.PI/2,Vg=class extends Le{constructor(e=1,t=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let c=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,e/2,t/2,n/2);let h=[],u=[],d=[],f=[],m=0,p=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,s,4),g("x","y","z",-1,-1,e,t,-n,i,s,5),a>0&&(x("z","y","x",-1,-1,1,n,t,e,o,0),x("z","y","x",1,-1,-1,n,t,e,o,1),x("z","y","x",-1,1,-1,n,t,e,o,1),x("z","y","x",1,1,1,n,t,e,o,0),x("x","y","z",-1,-1,-1,e,t,n,i,0),x("x","y","z",1,-1,1,e,t,n,i,1),x("x","y","z",-1,1,1,e,t,n,i,0),x("x","y","z",1,1,-1,e,t,n,i,1),x("y","x","z",-1,-1,1,t,e,n,s,0),x("y","x","z",1,-1,-1,t,e,n,s,1),x("y","x","z",1,1,1,t,e,n,s,1),x("y","x","z",-1,1,-1,t,e,n,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new Se(u,3)),this.setAttribute("normal",new Se(d,3)),this.setAttribute("uv",new Se(f,2));function g(w,b,S,M,_,y,T,E,C,I,R){let N=(y-2*a)/C,H=(T-2*a)/I,j=y/2-a,K=T/2-a,Y=E/2,z=C+1,F=I+1,V=0,O=0,G=new A;for(let W=0;W<F;W++){let X=W*H-K;for(let q=0;q<z;q++){let se=q*N-j;G[w]=se*M,G[b]=X*_,G[S]=Y,u.push(G.x,G.y,G.z),G[w]=0,G[b]=0,G[S]=E>0?1:-1,d.push(G.x,G.y,G.z),f.push(q/C),f.push(1-W/I),V+=1}}for(let W=0;W<I;W++)for(let X=0;X<C;X++){let q=m+X+z*W,se=m+X+z*(W+1),Z=m+(X+1)+z*(W+1),te=m+(X+1)+z*W;h.push(q,se,te),h.push(se,Z,te),O+=6}c.addGroup(p,O,R),p+=O,m+=V}function x(w,b,S,M,_,y,T,E,C,I,R){let N=(T-2*a)/I,H=T/2-a,j=E/2-a,K=C/2,Y=I+1,z=0,F=0,V=new A,O=new A;for(let G=0;G<l+1;G++){let W=G/l*kg,X=Math.sin(W)*a,q=(1-Math.cos(W))*a,se=Math.sin(W),Z=Math.cos(W);V[b]=(j+X)*_,V[S]=(K-q)*y,O[w]=0,O[b]=se*Math.sign(V[b]),O[S]=Z*Math.sign(V[S]);for(let te=0;te<Y;te++){let k=te*N-H;V[w]=k*M,u.push(V.x,V.y,V.z),d.push(O.x,O.y,O.z),f.push(te/I),f.push(0),z+=1}}for(let G=0;G<l;G++)for(let W=0;W<I;W++){let X=m+W+Y*G,q=m+W+Y*(G+1),se=m+(W+1)+Y*(G+1),Z=m+(W+1)+Y*G;h.push(X,q,Z),h.push(q,se,Z),F+=6}c.addGroup(p,F,R),p+=F,m+=z}function v(w,b,S){let M=new A,_=new A(e/2,t/2,n/2);_.subScalar(a);let y=[],T=w*b*S>0?(C,I,R)=>h.push(C,I,R):(C,I,R)=>h.push(C,R,I);for(let C=0;C<=l;C++){let I=[],R=kg*(1-C/l),N=Math.cos(R),H=Math.sin(R),j=0;for(let K=0;K<=C;K++){let Y=Math.cos(j),z=Math.sin(j);M.x=N*Y,M.y=H,M.z=N*z;let F=_.clone().addScaledVector(M,a);u.push(w*F.x,b*F.y,S*F.z),d.push(w*M.x,b*M.y,S*M.z),f.push(0,0),I.push(m++),j+=kg/C}y.push(I)}let E=y.length-1;for(let C=0;C<E;C++){let I=y[C],R=y[C+1],N=I.length-1;T(I[0],R[1],R[0]);for(let H=1;H<=N;H++)T(I[H-1],I[H],R[H]),T(I[H],R[H+1],R[H])}}}};var Bs=class extends Le{constructor(e=[],t=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];h(),u(),this.setAttribute("position",new Se(a,3)),this.setAttribute("normal",new Se(c,3)),this.setAttribute("uv",new Se(l,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],m=new A,p=m.clone(),g=new Kn,x=s*i,v=i-x,w=o+1,b=new A,S=(z,F)=>b.subVectors(z,F).normalize(),M=(z,F)=>Array(z).fill(void 0).map(F),_=M(e.length/3,(z,F)=>new A().fromArray(e,F*3).setLength(i)),y=[],T=1e6;for(let z=0;z<_.length;z++){let F=_[z],V=[],O,G,W,X=1e10,q=-1;for(;(q=t.indexOf(z,q+1))!=-1;){let k=q-q%3;O=t[k+(q+1)%3],G=t[k+(q+2)%3],W=F.distanceToSquared(_[O]),X=Math.min(X,W),V.push([O,G,W])}X+=1e-6;let se=[],Z=0,te=V.length;for(let k=0;k<te;k++){[O,G,W]=V[Z];let le=y[O]?.includes(z)==!0;W<=X&&se.push(O+ +le*T),Z=V.findIndex(ce=>ce[0]==G)}y.push(se)}let E=[];{let z=0,F=0,V,O,G=f==3;for(let W=0;W<=o;W++){V=W*(W+1)/2,O=(W+1)*(W+2)/2;for(let X=0;X<o-W;X++)[z,F]=[V+X+W+2,O+X+W+3],E.push(V,O,...G?[F,V]:[z,O],F,z),[V,O]=[z,F];E.push(V,O,V+o+2)}}let C=m.clone(),I=m.clone(),R=m.clone(),N=m.clone(),H=m.clone(),j=[],K=M(_.length,()=>M(f,()=>m.clone()));for(let z=0;z<_.length;z++){m.copy(_[z]).normalize(),C.copy(m).multiplyScalar(v);let F=y[z];for(let se=0;se<F.length;se++){let Z=F[se],te=F[(se+1)%f];g.setFromPointsAndIndices(_,z,Z%T,te%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,K[z][se])}let V=[],O=[],G=[],W=new A;o==0&&[...K[z]].reduce((se,Z)=>se.add(Z),W).multiplyScalar(1/f);for(let se=0;se<f;se++){let Z=[],te=(se-1+f)%f,k=K[z][te],le=K[z][se];m.copy(k).sub(C),p.copy(le).sub(C);let ce=C.angleTo(m),ae=m.angleTo(p),de=Math.cos(ce)*x;o==0?I.copy(W):I.copy(C).setLength(v+de),O.push(de);let ge=[I,k,le];for(let fe=0;fe<2;fe++){let Ee=ge[fe],De=ge[fe+1];N.subVectors(Ee,C),H.subVectors(De,C),R.crossVectors(N,H).normalize();for(let ye=0;ye<w;ye++){let Re=[ce,ae][fe]*ye/w;m.copy(N).applyAxisAngle(R,Re).add(C),V.push(m.clone()),fe&&(S(m,C),Z.push([ye==0?Ee:m.clone(),b.clone()]))}fe&&(S(De,C),Z.push([De,b.clone()]))}G.push(Z)}j.push(G);let X=2*w,q=2;for(let se=0;se<f;se++){let Z=X*se,te=X*((se+1)%f),k=[V[Z]];for(let ce=1;ce<w;ce++){N=V[Z+ce],H=V[te+ce],k.push(N);for(let ae=1,de=ce-q+1;ae<=de;ae++)m.lerpVectors(N,H,ae/(de+1)),m.sub(C).setLength(O[se]).add(C),k.push(m.clone());k.push(H)}for(let ce=0;ce<w;ce++)k.push(V[ce+w+Z]);k.push(V[te+w]);let le=E.map(ce=>k[ce]);a.push(...le.map(ce=>[ce.x,ce.y,ce.z]).flat()),c.push(...le.map(ce=>(S(ce,C),[b.x,b.y,b.z])).flat())}}let Y=[];for(let z=0;z<y.length;z++)for(let F=0;F<f;F++){let V=y[z][F];if(V<T){let O=y[V].findIndex(X=>X%T==z),G=j[z][F],W=j[V][O];for(let X=0;X<w;X++){let q=G[X],se=W[w-X],Z=G[X+1],te=W[w-(X+1)];[q,se,Z,Z,se,te].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),c.push(k[1].x,k[1].y,k[1].z)})}Y.push(G[0][0],W[w][0],G[w][0],W[0][0])}}for(;Y.length;){let z,F,V,O;[z,F]=Y.splice(0,2);let G=[z];for(;z!=F;)G.push(F),V=Y.indexOf(F),O=V%2,F=Y.splice(V-O,2)[1-O];b.subVectors(G[0],G[1]).cross(m.subVectors(G[0],G[2])).normalize();let W=b.dot(G[0])<0;W&&b.negate();for(let X=1;X<=G.length-2;X++)[G[X+ +W],G[X+1-+W],G[0]].forEach(q=>{a.push(q.x,q.y,q.z),c.push(b.x,b.y,b.z)})}}function u(){let d=new A;for(let _=0;_<a.length;_+=3){d.x=a[_+0],d.y=a[_+1],d.z=a[_+2];let y=S(d)/2/Math.PI+.5,T=M(d)/Math.PI+.5;l.push(y,1-T)}let f=new A,m=new A,p=new A,g=new A,x=new B,v=new B,w=new B,b=(_,y,T,E)=>{E<0&&_.x===1&&(l[y]=_.x-1),T.x===0&&T.z===0&&(l[y]=E/2/Math.PI+.5)};for(let _=0,y=0;_<a.length;_+=9,y+=6){f.set(a[_+0],a[_+1],a[_+2]),m.set(a[_+3],a[_+4],a[_+5]),p.set(a[_+6],a[_+7],a[_+8]),x.set(l[y+0],l[y+1]),v.set(l[y+2],l[y+3]),w.set(l[y+4],l[y+5]),g.copy(f).add(m).add(p).divideScalar(3);let T=S(g);b(x,y+0,f,T),b(v,y+2,m,T),b(w,y+4,p,T)}for(let _=0;_<l.length;_+=6){let y=l[_+0],T=l[_+2],E=l[_+4],C=Math.max(y,T,E),I=Math.min(y,T,E);C>.9&&I<.1&&(y<.2&&(l[_+0]+=1),T<.2&&(l[_+2]+=1),E<.2&&(l[_+4]+=1))}function S(_){return Math.atan2(_.z,-_.x)}function M(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(e){return new Bs(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};var SS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new Qc(e*.5,s,o):new ha(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},Qc=class extends Bs{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,e,t,n),this.type=l}static fromJSON(e){return new Qc(e.radius,e.corner,e.cornerSides)}};var Kc=1e-12,el=class{constructor(e){this.position=new B;this.startPosition=new B;this.uuid=Ge.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new el(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},tl=class extends el{constructor(t){super(t.position);this.parent=t}copy(t){return super.copy(t),this}clone(){return new tl(this.parent).copy(this)}},Xr=class extends el{constructor(t,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=t,this.controls.push(new tl(this),new tl(this))}static create(t,n){let i=new Xr(t,new B(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(t){let n=this.controls.indexOf(t);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(t,n=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new Xr(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[t,n]}computeNormals(t=new B,n=new B){let[i,s]=this.computeTangents();return i&&s&&(AS(i,t),AS(s,n)),[t,n]}computeTangent(t=new B){let[n,i]=this.computeTangents();return n&&i&&t.copy(n).add(i).normalize(),t}computeNormal(t=new B){let[n,i]=this.computeNormals();return t.copy(n).add(i).normalize(),t}};function AS(r,e=new B){let t=r.length();return e.set(-r.y/t,r.x/t)}var Wg=r=>r,nl=new B,Qd=new B,TB=new B,EB=new B,CB=new B,DB=new B,_S=new A,TS=new A;function ES(r){let e=new B;e.addVectors(r.v0,nl.subVectors(r.v1,r.v0).multiplyScalar(2/3));let t=new B;return t.addVectors(r.v2,Qd.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new $n(r.v0,e,t,r.v2)}function Zc(r,e,t=Number.EPSILON){return Math.abs(r-e)<t}function PB(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function LB(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function jg(r,e,t){let n=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function CS(r,e,t){return MS(r,e)&&MS(e,t)&&Hg(r.position,e.position,t.position)}function Hg(r,e,t){return nl.copy(e).sub(r).cross(Qd.copy(t).sub(r))===0}function DS(r,e,t,n,i){let s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),o=(r.y+e.y)/2,a=(r.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(r.y-e.y)/s,c=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-r.x)/s;return n.set(a+l,o+c),i.set(a-l,o-c),[n,i]}function PS(r,e,t){let n=r.distanceTo(t),i=e.distanceTo(t);return n<i?e:r}function LS(r,e,t,n,i,s){let o=e.x-r.x,a=e.y-r.y,l=t.x-r.x,c=t.y-r.y,h=Math.sqrt((o+l)*(o+l)+(a+c)*(a+c)),u;return jg(e,r,t)>Math.PI&&(h*=-1),Zc(c,a)?u=(a+c)*(n/h-.5)*8/3/(o-l):u=(o+l)*(n/h-.5)*8/3/(c-a),i.set(e.x-u*a,e.y+u*o),s.set(t.x+u*c,t.y-u*l),[i,s]}function qg(r,e){return r.position.equals(r.controls[1].position)&&e.position.equals(e.controls[0].position)}function MS(r,e){return Hg(r.position,r.controls[1].position,e.position)&&Hg(r.position,e.controls[0].position,e.position)}function IS(r,e,t,n,i=.5){let s=nl.subVectors(e,r).multiplyScalar(i).add(r),o=Qd.subVectors(t,e).multiplyScalar(i).add(e),a=TB.subVectors(n,t).multiplyScalar(i).add(t),l=s,c=EB.subVectors(o,s).multiplyScalar(i).add(s),h=CB.subVectors(a,o).multiplyScalar(i).add(o),u=a,d=DB.subVectors(h,c).multiplyScalar(i).add(c);return[r.x,r.y,l.x,l.y,c.x,c.y,d.x,d.y,h.x,h.y,u.x,u.y,n.x,n.y]}function NS(r,e,t=12,n=!0){let i=TS.set(0,0,0),s,o=0,a=[];for(let l=0;l<e.length;l++){let c=Wg(e[l]),h=nl,u=Os(c,t);a.push(u);for(let d=0;d<=u;d++)if(c instanceof $n||c instanceof Vr||c instanceof er){if(c.getPoint(d/u,h),i.set(h.x,h.y,0),s!==void 0&&LB(s,i))continue;s===void 0&&(s=_S),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function RS(r,e,t,n=12,i=!0){let s=TS.set(0,0,0),o=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let c,h=Wg(e[l]),u=nl,d=Os(h,n);a.push(d);for(let f=0;f<=d;f++)if(h instanceof $n||h instanceof Vr||h instanceof er){if(h.getPoint(f/d,u),s.set(u.x,u.y,0),c?.equals(s))continue;c===void 0?c=_S:(r.setXYZ(o,c.x,c.y,c.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),c.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function Xg(r,e=12,t=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(t&&o.roundedCurveCorner!==void 0){let l=Os(o.roundedCurveCorner,e)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=Os(o.curveAfter,e)),n.push(a)}return r.length>0&&t&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=Os(r[0].roundedCurveCorner,e)*.5),n}function Os(r,e=12){return r&&r instanceof oo?e*2:r&&(r instanceof er||r instanceof pc)?1:r&&r instanceof oa?e*r.points.length:e}function BS(r,e,t=12,n=!0){let i,s=0;for(let o=0;o<e.length;o++){let a=Wg(e[o]),l=Os(a,t),c=nl;for(let h=0;h<=l;h++)if(a instanceof $n||a instanceof Vr||a instanceof er){if(a.getPoint(h/l,c),i!==void 0&&PB(i,c,Kc))continue;i===void 0&&(i=Qd),i.copy(c),r.push(c.x,c.y),s++}}return Zc(r[0],r[r.length-2],Kc)&&Zc(r[1],r[r.length-1],Kc)&&(r.pop(),r.pop()),n&&s>1&&!(Zc(r[s-1],r[1],Kc)&&Zc(r[s-2],r[0],Kc))&&(r.push(r[0],r[1]),s++),r}var Yg=new B,IB=new B,NB=new B,RB=new B,BB=new B,OB=new B,pt=class extends Gr{constructor(t=100,n=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Rt;this.plane=new kn(new A(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ge.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=t,this._height=n}static createFromState(t,n,i){let s=new pt;return s.isClosed=t.isClosed,s.points=t.points.map(o=>Xr.create(o.id,o.data)),typeof t.roundness=="number"&&(s.roundness=t.roundness),s.shapeHoles=t.shapeHoles.map(o=>pt.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let n=0,i=this.points.length;n<i;n++)this.points[n].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(t){let n=this.points.length,i=this.points.findIndex(s=>s.uuid===t);if(i<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],c=l.points.length-1,h=l.getPointIndexById(t);if(h<0)s+=c;else return h+s}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0)for(let n=0,i=this.shapeHoles.length;n<i;n++){let s=this.shapeHoles[n],o=t-this.points.length;if(o<=s.points.length-1)return s.points[o]}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let n=this.points.indexOf(t);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(t);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...t]}applySize(t,n){t===0&&(t=.001),n===0&&(n=.001),this._width=t,this._height=n}applyScale(t,n){let i=Yg.set(t,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(t,n);this._update(!1)}createPoint(t,n=0,i=Ge.generateUUID()){let s;t instanceof B?s=t:s=new B(t,n);let o=new Xr(i,s);return o.roundness=this.roundness,o}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,n){this.points.splice(n,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===t)return s}for(let n=0,i=this.shapeHoles.length;n<i;n++){let o=this.shapeHoles[n].getPointByUuid(t);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let n=this.points.indexOf(t);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(t){let n=this.points.find(i=>i.uuid===t);n&&this.removePoint(n)}update(t=!0){for(let n=0,i=this.shapeHoles.length;n<i;n++)this.shapeHoles[n].update(!1);this._update(t)}extractShapePointsToBuffer(t,n=12,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return NS(t,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=Xg(this.points,t,!1),this.roundedCurveDivisions=Xg(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,n,i=12){return RS(t,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(t,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),BS(t,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(t,n=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=Os(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=t-o;a<0&&(a+=s.reduce((l,c)=>l+c,0));for(let l=0,c=s.length;l<c;l++){let h=s[l];if(a<i+h)return[l,(a-i+1)/h];i+=h}return[0,1]}getCurveT(t,n,i){let s=this.points[t],o=this.points[t>=this.points.length-1?0:t+1],a=this.curveDivisions,l=a[t];if(qg(s,o)){let u=s.position.distanceTo(o.position);return s.position.distanceTo(Yg.set(i.x,i.y))/u}let c=0;for(let u=0;u<t;u++)c+=a[u];return(n-c)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(t,n){qg(n,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,n.curveAfter=i;let s=i.clone();t.roundedCurveBefore=s,n.roundedCurveAfter=s,t.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(t=!0){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i];if(i===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[i-1];this._applyCurveForPoint(o,a)}}let n=this.getLastPoint();if(n?.curveAfter&&(n.curveAfter=void 0),this.isClosed){let i=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(i,s)}if(this.points.length>2){let i=0;for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s],l=this.points[s-1]??this.points[this.points.length-1],c=this.points[s+1]??this.points[0],h=a.roundness,u=l&&c&&CS(l,a,c);if(!a.controlsMoved()&&h>0&&!u){let d=a.curveBefore,f=a.curveAfter;if(d===void 0||f===void 0)continue;let m=a.roundedCurveBefore,p=a.roundedCurveAfter,g=d.getLength(),x=f.getLength(),v=Math.min(h,g*.499),w=Math.min(h,x*.499),b=Math.min(v,w),S=1-b/g,M=b/x,_=d.getPointAt(S,Yg),y=f.getPointAt(M,IB);this._subSplitCurve(d,m,S,_,void 0),this._subSplitCurve(f,p,M,void 0,y);let T;if(this.useCubicForRoundedCorners){let E=jg(_,a.position,y)/2,C=Math.tan(E)*_.distanceTo(a.position),[I,R]=DS(_,y,C,NB,RB),N=PS(I,R,a.position),[H,j]=LS(N,_,y,C,BB,OB);T=new $n(_.clone(),H.clone(),j.clone(),y.clone())}else T=new Vr(_.clone(),a.position.clone(),y.clone());a.roundedCurveCorner=T,this.roundedCurves.splice(s+i,0,T),i++}}}t&&this.eventDispatcher?.dispatchEvent({type:"update"})}_subSplitCurve(t,n,i,s,o){if(t instanceof er)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=t,l=n,c=a.getUtoTmapping(i,0),h=IS(a.v0,a.v1,a.v2,a.v3,c);return s!==void 0&&(l.v0.set(h[0],h[1]),l.v1.set(h[2],h[3]),l.v2.set(h[4],h[5]),l.v3.set(h[6],h[7])),o!==void 0&&(l.v0.set(h[6],h[7]),l.v1.set(h[8],h[9]),l.v2.set(h[10],h[11]),l.v3.set(h[12],h[13])),l}return n}clone(){let t=new pt(this._width,this._height);return t.points=this.points.map(n=>n.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(n=>n.clone()),t}toJSON(){return{points:this.points.reduce((t,n)=>t.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let n=t.points.length/7;for(let i=0;i<n;i++){let s=i*7,o=t.points[s+0],a=t.points[s+1],l=t.points[s+2],c=t.points[s+3],h=t.points[s+4],u=t.points[s+5],d=t.points[s+6],f=new Xr(Ge.generateUUID(),new B(o,a));f.controls[0].position.set(l,c),f.controls[1].position.set(h,u),f.roundness=d,this.points.push(f)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let s=new pt;return s.fromJSON(i),s}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t){let n=(s,o)=>{o instanceof $n&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof Vr&&(s[a]=ES(s[a]));for(a=0,l=s.length;a<l;a++){let u=s[a],d=a>0?s[a-1]:null,f;u instanceof $n?(f=this.createPoint(u.v0),f.controls[1].position.copy(u.v1)):u instanceof er&&(f=this.createPoint(u.v1)),f!==void 0&&(d!==null&&n(f,d),o.push(f))}let c=s[s.length-1],h=!1;return c instanceof $n?c.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(c.v2),h=!0):c instanceof er&&c.v2.equals(o[0].position)&&(h=!0),this.isClosed=h,o};return this.points=i(t.curves),t instanceof Gr&&(this.shapeHoles=t.holes.map(s=>{let o=new pt;return o.fromShape(s),o})),this.update(),this}};var Kg=Math.PI*2;function Qg({x:r,y:e},t,n,i,s){return{x:r*t+i,y:e*n+s}}function FB(r,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+e),o=Math.sin(r+e);return[{x:n-i*t,y:i+n*t},{x:s+o*t,y:o-s*t},{x:s,y:o}]}function OS(r,e,t,n){let i=r*n-e*t<0?-1:1,s=Math.min(1,Math.max(-1,r*t+e*n));return i*Math.acos(s)}function UB(r,e,t,n,i,s,o,a,l,c){let h=Math.pow(i,2),u=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),m=h*u-h*f-u*d;m<0&&(m=0),m/=h*f+u*d,m=Math.sqrt(m)*(l===c?-1:1);let p=m*i/s*a,g=m*-s/i*o,x=p+(r+t)/2,v=g+(e+n)/2,w=(o-p)/i,b=(a-g)/s,S=(-o-p)/i,M=(-a-g)/s,_=OS(1,0,w,b),y=OS(w,b,S,M);return!c&&y>0&&(y-=Kg),c&&y<0&&(y+=Kg),{centerx:x,centery:v,ang1:_,ang2:y}}function FS({px:r,py:e,cx:t,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let c=(r-t)/2,h=(e-n)/2;if(c===0&&h===0)return[];i=Math.abs(i),s=Math.abs(s);let u=Math.pow(c,2)/Math.pow(i,2)+Math.pow(h,2)/Math.pow(s,2);u>1&&(i*=Math.sqrt(u),s*=Math.sqrt(u));let d=UB(r,e,t,n,i,s,c,h,o,a),{ang1:f,ang2:m}=d,{centerx:p,centery:g}=d,x=Math.abs(m)/(Kg/4);Math.abs(1-x)<1e-7&&(x=1);let v=Math.max(Math.ceil(x),1);m/=v;for(let w=0;w<v;w++)l.push(FB(f,m)),f+=m;return l.map(w=>{let{x:b,y:S}=Qg(w[0],i,s,p,g),{x:M,y:_}=Qg(w[1],i,s,p,g),{x:y,y:T}=Qg(w[2],i,s,p,g);return{x1:b,y1:S,x2:M,y2:_,x:y,y:T}})}var Ot;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ot||(Ot={}));var fn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(fn||(fn={}));function Ve(r,e){if(!r)throw e||"Assertion Failed!"}var Ue=function(){function r(){}return r.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},r.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},r.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},r.edgeGoesLeft=function(e){return r.vertLeq(e.Dst,e.Org)},r.edgeGoesRight=function(e){return r.vertLeq(e.Org,e.Dst)},r.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},r.edgeEval=function(e,t,n){Ve(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?i<s?t.t-e.t+(e.t-n.t)*(i/(i+s)):t.t-n.t+(n.t-e.t)*(s/(i+s)):0},r.edgeSign=function(e,t,n){Ve(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?(t.t-n.t)*i+(t.t-e.t)*s:0},r.transEval=function(e,t,n){Ve(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?i<s?t.s-e.s+(e.s-n.s)*(i/(i+s)):t.s-n.s+(n.s-e.s)*(s/(i+s)):0},r.transSign=function(e,t,n){Ve(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?(t.s-n.s)*i+(t.s-e.s)*s:0},r.vertCCW=function(e,t,n){return e.s*(t.t-n.t)+t.s*(n.t-e.t)+n.s*(e.t-t.t)>=0},r.interpolate=function(e,t,n,i){return e=e<0?0:e,n=n<0?0:n,e<=n?n===0?(t+i)/2:t+(i-t)*(e/(e+n)):i+(t-i)*(n/(e+n))},r.intersect=function(e,t,n,i,s){var o,a,l;r.vertLeq(e,t)||(l=e,e=t,t=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.vertLeq(n,t)?r.vertLeq(t,i)?(o=r.edgeEval(e,n,t),a=r.edgeEval(n,t,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,t.s)):(o=r.edgeSign(e,n,t),a=-r.edgeSign(e,i,t),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+t.s)/2,r.transLeq(e,t)||(l=e,e=t,t=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.transLeq(n,t)?r.transLeq(t,i)?(o=r.transEval(e,n,t),a=r.transEval(n,t,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,t.t)):(o=r.transSign(e,n,t),a=-r.transSign(e,i,t),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+t.t)/2},r}(),Jc=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),Kd=function(){function r(e){this.side=e,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),r}(),rl=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return r}(),US=function(){function r(){var e=new rl,t=new Jc,n=new Kd(0),i=new Kd(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=e,this.fHead=t,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(e){var t=new Kd(0),n=new Kd(1);e.Sym.side<e.side&&(e=e.Sym);var i=e.Sym.next;return n.next=i,i.Sym.next=t,t.next=e,e.Sym.next=n,t.Sym=n,t.Onext=t,t.Lnext=n,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,n.Sym=t,n.Onext=n,n.Lnext=t,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,t},r.prototype.splice_=function(e,t){var n=e.Onext,i=t.Onext;n.Sym.Lnext=t,i.Sym.Lnext=e,e.Onext=i,t.Onext=n},r.prototype.makeVertex_=function(e,t,n){var i=e;Ve(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t;var o=t;do o.Org=i,o=o.Onext;while(o!==t)},r.prototype.makeFace_=function(e,t,n){var i=e;Ve(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t,i.trail=null,i.marked=!1,i.inside=n.inside;var o=t;do o.Lface=i,o=o.Lnext;while(o!==t)},r.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,n=e.Sym.next;t.Sym.next=n,n.Sym.next=t},r.prototype.killVertex_=function(e,t){var n=e.anEdge,i=n;do i.Org=t,i=i.Onext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.killFace_=function(e,t){var n=e.anEdge,i=n;do i.Lface=t,i=i.Lnext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var e=new rl,t=new rl,n=new Jc,i=this.makeEdge_(this.eHead);return this.makeVertex_(e,i,this.vHead),this.makeVertex_(t,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(e,t){var n=!1,i=!1;if(e!==t){if(t.Org!==e.Org&&(i=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!i){var s=new rl;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!n){var o=new Jc;this.makeFace_(o,t,e.Lface),e.Lface.anEdge=e}}},r.prototype.delete=function(e){var t=e.Sym,n=!1;if(e.Lface!==e.Rface&&(n=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!n){var i=new Jc;this.makeFace_(i,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},r.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),n=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var i=new rl;return this.makeVertex_(i,n,t.Org),t.Lface=n.Lface=e.Lface,t},r.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),n=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,n),e.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=e.Rface,n.winding=e.winding,n.Sym.winding=e.Sym.winding,n.idx=e.idx,n.Sym.idx=e.Sym.idx,n},r.prototype.connect=function(e,t){var n=!1,i=this.makeEdge_(e),s=i.Sym;if(t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(i,e.Lnext),this.splice_(s,t),i.Org=e.Dst,s.Org=t.Org,i.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!n){var o=new Jc;this.makeFace_(o,i,e.Lface)}return i},r.prototype.zapFace=function(e){var t=e.anEdge,n,i,s,o,a;i=t.Lnext;do n=i,i=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=t);o=e.prev,a=e.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(e){var t=e.anEdge,n=0;do n++,t=t.Lnext;while(t!==e.anEdge);return n},r.prototype.mergeConvexFaces=function(e){var t,n,i,s,o,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(n=t.anEdge,o=n.Org;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(s.Lface),a+l-2<=e&&Ue.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&Ue.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var e=this.fHead,t=this.vHead,n=this.eHead,i,s,o,a,l,c;for(s=e,s=e;(i=s.next)!==e;s=i){Ve(i.prev===s),l=i.anEdge;do Ve(l.Sym!==l),Ve(l.Sym.Sym===l),Ve(l.Lnext.Onext.Sym===l),Ve(l.Onext.Sym.Lnext===l),Ve(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(Ve(i.prev===s&&i.anEdge===null),a=t,a=t;(o=a.next)!==t;a=o){Ve(o.prev===a),l=o.anEdge;do Ve(l.Sym!==l),Ve(l.Sym.Sym===l),Ve(l.Lnext.Onext.Sym===l),Ve(l.Onext.Sym.Lnext===l),Ve(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(Ve(o.prev===a&&o.anEdge===null),c=n,c=n;(l=c.next)!==n;c=l)Ve(l.Sym.next===c.Sym),Ve(l.Sym!==l),Ve(l.Sym.Sym===l),Ve(l.Org!==null),Ve(l.Dst!==null),Ve(l.Lnext.Onext.Sym===l),Ve(l.Onext.Sym.Lnext===l);Ve(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},r}(),zS=function(){function r(){this.handle=null}return r}(),GS=function(){function r(){this.key=null,this.node=0}return r}(),zB=function(){function r(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var n=0;n<e+1;n++)this.nodes[n]=new zS,this.handles[n]=new GS;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e<<1,o<this.size&&this.leq(n[t[o+1].handle].key,n[t[o].handle].key)&&++o,Ve(o<=this.max),s=t[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.floatUp_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e>>1,s=t[o].handle,o===0||this.leq(n[s].key,n[i].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(e){var t,n;if(t=++this.size,t*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new zS;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new GS}return this.freeList===0?n=t:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[t].handle=n,this.handles[n].node=t,this.handles[n].key=e,this.initialized&&this.floatUp_(t),n},r.prototype.extractMin=function(){var e=this.nodes,t=this.handles,n=e[1].handle,i=t[n].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[n].key=null,t[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),i},r.prototype.delete=function(e){var t=this.nodes,n=this.handles,i;Ve(e>=1&&e<=this.max&&n[e].key!==null),i=n[e].node,t[i].handle=t[this.size].handle,n[t[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[t[i>>1].handle].key,n[t[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[e].key=null,n[e].node=this.freeList,this.freeList=e},r}(),Zg=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),kS=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),GB=function(){function r(e,t){this.frame=e,this.leq=t,this.head=new kS,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(e){return this.insertBefore(this.head,e)},r.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},r.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var n=new kS;return n.key=t,n.next=e.next,e.next.prev=n,n.prev=e,e.next=n,n},r.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},r}(),kB=function(){function r(){}return r.regionBelow=function(e){return e.nodeUp.prev.key},r.regionAbove=function(e){return e.nodeUp.next.key},r.debugEvent=function(e){},r.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.edgeLeq=function(e,t,n){var i=e.event,s=t.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?Ue.vertLeq(s.Org,o.Org)?Ue.edgeSign(o.Dst,s.Org,o.Org)<=0:Ue.edgeSign(s.Dst,o.Org,s.Org)>=0:Ue.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return Ue.edgeSign(s.Dst,i,s.Org)>=0;var a=Ue.edgeEval(s.Dst,i,s.Org),l=Ue.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(e,t){t.fixUpperEdge&&Ve(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},r.fixUpperEdge=function(e,t,n){Ve(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=n,n.activeRegion=t},r.topLeftRegion=function(e,t){var n=t.eUp.Org,i;do t=r.regionAbove(t);while(t.eUp.Org===n);if(t.fixUpperEdge){if(i=e.mesh.connect(r.regionBelow(t).eUp.Sym,t.eUp.Lnext),i===null)return null;r.fixUpperEdge(e,t,i),t=r.regionAbove(t)}return t},r.topRightRegion=function(e){var t=e.eUp.Dst;do e=r.regionAbove(e);while(e.eUp.Dst===t);return e},r.addRegionBelow=function(e,t,n){var i=new Zg;return i.eUp=n,i.nodeUp=e.dict.insertBefore(t.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(e,t){switch(e.windingRule){case Ot.ODD:return(t&1)!==0;case Ot.NONZERO:return t!==0;case Ot.POSITIVE:return t>0;case Ot.NEGATIVE:return t<0;case Ot.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(e,t){t.windingNumber=r.regionAbove(t).windingNumber+t.eUp.winding,t.inside=r.isWindingInside(e,t.windingNumber)},r.finishRegion=function(e,t){var n=t.eUp,i=n.Lface;i.inside=t.inside,i.anEdge=n,r.deleteRegion(e,t)},r.finishLeftRegions=function(e,t,n){for(var i,s=null,o=t,a=t.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(e,o);break}i=e.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(e,s,i)}a.Onext!==i&&(e.mesh.splice(i.Oprev,i),e.mesh.splice(a,i)),r.finishRegion(e,o),a=s.eUp,o=s}return a},r.addRightEdges=function(e,t,n,i,s,o){var a,l,c,h,u=!0;c=n;do Ve(Ue.vertLeq(c.Org,c.Dst)),r.addRegionBelow(e,t,c.Sym),c=c.Onext;while(c!==i);for(s===null&&(s=r.regionBelow(t).eUp.Rprev),l=t,h=s;a=r.regionBelow(l),c=a.eUp.Sym,c.Org===h.Org;)c.Onext!==h&&(e.mesh.splice(c.Oprev,c),e.mesh.splice(h.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=r.isWindingInside(e,a.windingNumber),l.dirty=!0,!u&&r.checkForRightSplice(e,l)&&(r.addWinding(c,h),r.deleteRegion(e,l),e.mesh.delete(h)),u=!1,l=a,h=c;l.dirty=!0,Ve(l.windingNumber-c.winding===a.windingNumber),o&&r.walkDirtyRegions(e,l)},r.spliceMergeVertices=function(e,t,n){e.mesh.splice(t,n)},r.vertexWeights=function(e,t,n){var i=Ue.vertL1dist(t,e),s=Ue.vertL1dist(n,e),o=.5*s/(i+s),a=.5*i/(i+s);e.coords[0]+=o*t.coords[0]+a*n.coords[0],e.coords[1]+=o*t.coords[1]+a*n.coords[1],e.coords[2]+=o*t.coords[2]+a*n.coords[2]},r.getIntersectData=function(e,t,n,i,s,o){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,r.vertexWeights(t,n,i),r.vertexWeights(t,s,o)},r.checkForRightSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp;if(Ue.vertLeq(i.Org,s.Org)){if(Ue.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;Ue.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(e.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(e,s.Oprev,i)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(i,s.Oprev),t.dirty=n.dirty=!0)}else{if(Ue.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o;if(Ve(!Ue.vertEq(i.Dst,s.Dst)),Ue.vertLeq(i.Dst,s.Dst)){if(Ue.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,o=e.mesh.splitEdge(i),e.mesh.splice(s.Sym,o),o.Lface.inside=t.inside}else{if(Ue.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;t.dirty=n.dirty=!0,o=e.mesh.splitEdge(s),e.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=t.inside}return!0},r.checkForIntersect=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,c=s.Dst,h,u,d=new rl,f,m;if(Ve(!Ue.vertEq(c,l)),Ve(Ue.edgeSign(l,e.event,o)<=0),Ve(Ue.edgeSign(c,e.event,a)>=0),Ve(o!==e.event&&a!==e.event),Ve(!t.fixUpperEdge&&!n.fixUpperEdge),o===a||(h=Math.min(o.t,l.t),u=Math.max(a.t,c.t),h>u))return!1;if(Ue.vertLeq(o,a)){if(Ue.edgeSign(c,o,a)>0)return!1}else if(Ue.edgeSign(l,a,o)<0)return!1;return r.debugEvent(e),Ue.intersect(l,o,c,a,d),Ve(Math.min(o.t,l.t)<=d.t),Ve(d.t<=Math.max(a.t,c.t)),Ve(Math.min(c.s,l.s)<=d.s),Ve(d.s<=Math.max(a.s,o.s)),Ue.vertLeq(d,e.event)&&(d.s=e.event.s,d.t=e.event.t),f=Ue.vertLeq(o,a)?o:a,Ue.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),Ue.vertEq(d,o)||Ue.vertEq(d,a)?(r.checkForRightSplice(e,t),!1):!Ue.vertEq(l,e.event)&&Ue.edgeSign(l,e.event,d)>=0||!Ue.vertEq(c,e.event)&&Ue.edgeSign(c,e.event,d)<=0?c===e.event?(e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Sym,i),t=r.topLeftRegion(e,t),i=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),n),r.addRightEdges(e,t,i.Oprev,i,i,!0),!0):l===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(i.Lnext,s.Oprev),n=t,t=r.topRightRegion(t),m=r.regionBelow(t).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(e,n,null),r.addRightEdges(e,t,s.Onext,i.Rprev,m,!0),!0):(Ue.edgeSign(l,e.event,d)>=0&&(r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),i.Org.s=e.event.s,i.Org.t=e.event.t),Ue.edgeSign(c,e.event,d)<=0&&(t.dirty=n.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(i.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=e.pq.insert(i.Org),r.getIntersectData(e,i.Org,o,l,a,c),r.regionAbove(t).dirty=t.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(e,t){for(var n=r.regionBelow(t),i,s;;){for(;n.dirty;)t=n,n=r.regionBelow(n);if(!t.dirty&&(n=t,t=r.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,i=t.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(e,t)&&(n.fixUpperEdge?(r.deleteRegion(e,n),e.mesh.delete(s),n=r.regionBelow(t),s=n.eUp):t.fixUpperEdge&&(r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n),i=t.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!t.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===e.event||s.Dst===e.event)){if(r.checkForIntersect(e,t))return}else r.checkForRightSplice(e,t);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n))}},r.connectRightVertex=function(e,t,n){var i,s=n.Onext,o=r.regionBelow(t),a=t.eUp,l=o.eUp,c=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(e,t),Ue.vertEq(a.Org,e.event)&&(e.mesh.splice(s.Oprev,a),t=r.topLeftRegion(e,t),s=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),o),c=!0),Ue.vertEq(l.Org,e.event)&&(e.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(e,o,null),c=!0),c){r.addRightEdges(e,t,n.Onext,s,s,!0);return}Ue.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=e.mesh.connect(n.Lprev,i),r.addRightEdges(e,t,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(e,t)},r.connectLeftDegenerate=function(e,t,n){var i,s,o,a,l;if(i=t.eUp,Ue.vertEq(i.Org,n)){Ve(!1),r.spliceMergeVertices(e,i,n.anEdge);return}if(!Ue.vertEq(i.Dst,n)){e.mesh.splitEdge(i.Sym),t.fixUpperEdge&&(e.mesh.delete(i.Onext),t.fixUpperEdge=!1),e.mesh.splice(n.anEdge,i),r.sweepEvent(e,n);return}Ve(!1),t=r.topRightRegion(t),l=r.regionBelow(t),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(Ve(s!==o),r.deleteRegion(e,l),e.mesh.delete(o),o=s.Oprev),e.mesh.splice(n.anEdge,o),Ue.edgeGoesLeft(s)||(s=null),r.addRightEdges(e,t,o.Onext,a,s,!0)},r.connectLeftVertex=function(e,t){var n,i,s,o,a,l,c=new Zg;if(c.eUp=t.anEdge.Sym,n=e.dict.search(c).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,Ue.edgeSign(o.Dst,t,o.Org)===0){r.connectLeftDegenerate(e,n,t);return}if(s=Ue.vertLeq(a.Dst,o.Dst)?n:i,n.inside||s.fixUpperEdge){if(s===n)l=e.mesh.connect(t.anEdge.Sym,o.Lnext);else{var h=e.mesh.connect(a.Dnext,t.anEdge);l=h.Sym}s.fixUpperEdge?r.fixUpperEdge(e,s,l):r.computeWinding(e,r.addRegionBelow(e,n,l)),r.sweepEvent(e,t)}else r.addRightEdges(e,n,t.anEdge,t.anEdge,null,!0)}},r.sweepEvent=function(e,t){e.event=t,r.debugEvent(e);for(var n=t.anEdge;n.activeRegion===null;)if(n=n.Onext,n===t.anEdge){r.connectLeftVertex(e,t);return}var i=r.topLeftRegion(e,n.activeRegion);Ve(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(e,s,null);a.Onext===o?r.connectRightVertex(e,i,a):r.addRightEdges(e,i,a.Onext,o,o,!0)},r.addSentinel=function(e,t,n,i){var s=new Zg,o=e.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=t,o.Dst.t=i,e.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},r.initEdgeDict=function(e){e.dict=new GB(e,r.edgeLeq);var t=e.bmax[0]-e.bmin[0],n=e.bmax[1]-e.bmin[1],i=e.bmin[0]-t,s=e.bmax[0]+t,o=e.bmin[1]-n,a=e.bmax[1]+n;r.addSentinel(e,i,s,o),r.addSentinel(e,i,s,a)},r.doneEdgeDict=function(e){for(var t,n=0;(t=e.dict.min().key)!==null;)t.sentinel||(Ve(t.fixUpperEdge),Ve(++n===1)),Ve(t.windingNumber===0),r.deleteRegion(e,t)},r.removeDegenerateEdges=function(e){var t,n,i,s=e.mesh.eHead;for(t=s.next;t!==s;t=n)n=t.next,i=t.Lnext,Ue.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(r.spliceMergeVertices(e,i,t),e.mesh.delete(t),t=i,i=t.Lnext),i.Lnext===t&&(i!==t&&((i===n||i===n.Sym)&&(n=n.next),e.mesh.delete(i)),(t===n||t===n.Sym)&&(n=n.next),e.mesh.delete(t))},r.initPriorityQ=function(e){var t,n,i,s=0;for(i=e.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,t=e.pq=new zB(s,Ue.vertLeq),i=e.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=t.insert(n);return n!==i?!1:(t.init(),!0)},r.donePriorityQ=function(e){e.pq=null},r.removeDegenerateFaces=function(e,t){var n,i,s;for(n=t.fHead.next;n!==t.fHead;n=i)i=n.next,s=n.anEdge,Ve(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),e.mesh.delete(s));return!0},r.computeInterior=function(e,t){t===void 0&&(t=!0);var n,i;if(r.removeDegenerateEdges(e),!r.initPriorityQ(e))return!1;for(r.initEdgeDict(e);(n=e.pq.extractMin())!==null;){for(;i=e.pq.min(),!(i===null||!Ue.vertEq(i,n));)i=e.pq.extractMin(),r.spliceMergeVertices(e,n.anEdge,i.anEdge);r.sweepEvent(e,n)}return e.event=e.dict.min().key.eUp.Org,r.debugEvent(e),r.doneEdgeDict(e),r.donePriorityQ(e),r.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},r}(),VB=function(){function r(){this.mesh=new US,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=Ot.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return r.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},r.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},r.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},r.prototype.computeNormal_=function(e){var t,n,i,s,o,a,l=[0,0,0],c=[0,0,0],h=[0,0,0],u=[0,0,0],d=[0,0,0],f=[null,null,null],m=[null,null,null],p=this.mesh.vHead;t=p.next;for(var g=0;g<3;++g)s=t.coords[g],c[g]=s,m[g]=t,l[g]=s,f[g]=t;for(t=p.next;t!==p;t=t.next)for(var x=0;x<3;++x)s=t.coords[x],s<c[x]&&(c[x]=s,m[x]=t),s>l[x]&&(l[x]=s,f[x]=t);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,n=m[v],i=f[v],h[0]=n.coords[0]-i.coords[0],h[1]=n.coords[1]-i.coords[1],h[2]=n.coords[2]-i.coords[2],t=p.next;t!==p;t=t.next)u[0]=t.coords[0]-i.coords[0],u[1]=t.coords[1]-i.coords[1],u[2]=t.coords[2]-i.coords[2],d[0]=h[1]*u[2]-h[2]*u[1],d[1]=h[2]*u[0]-h[0]*u[2],d[2]=h[0]*u[1]-h[1]*u[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,e[0]=d[0],e[1]=d[1],e[2]=d[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(h)]=1)},r.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,n=this.mesh.vHead,i,s=0,o=e.next;o!==e;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(t=n.next;t!==n;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},r.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],n,i,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),n=this.sUnit,i=this.tUnit;var o=this.longAxis_(t);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=t[o]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,c=e.next;c!==e;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},r.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.prototype.tessellateMonoRegion_=function(e,t){var n,i;if(n=t.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;Ue.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;Ue.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(Ue.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(Ue.edgeGoesLeft(i.Lnext)||Ue.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=e.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(Ue.edgeGoesRight(n.Lprev)||Ue.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=e.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=e.connect(i.Lnext,i),i=s.Sym;return!0},r.prototype.tessellateInterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)if(t=n.next,n.inside&&!this.tessellateMonoRegion_(e,n))return!1;return!0},r.prototype.discardExterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)t=n.next,n.inside||e.zapFace(n)},r.prototype.setWindingNumber_=function(e,t,n){for(var i,s=e.eHead.next;s!==e.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:n?e.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},r.prototype.outputPolymesh_=function(e,t,n,i){var s,o=0,a=0,l;n>3&&e.mergeConvexFaces(n);for(var c=e.vHead.next;c!==e.vHead;c=c.next)c.n=-1;for(var h=e.fHead.next;h!==e.fHead;h=h.next)if(h.n=-1,!!h.inside){s=h.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==h.anEdge);if(l>n)throw"Face vertex greater that support polygon";h.n=o,++o}this.elementCount=o,t===fn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=e.vHead.next;c!==e.vHead;c=c.next)if(c.n!==-1){var u=c.n*i;this.vertices[u+0]=c.coords[0],this.vertices[u+1]=c.coords[1],i>2&&(this.vertices[u+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,h=e.fHead.next;h!==e.fHead;h=h.next)if(!!h.inside){s=h.anEdge,l=0;do{var c=s.Org;this.elements[d++]=c.n,l++,s=s.Lnext}while(s!==h.anEdge);for(var f=l;f<n;++f)this.elements[d++]=-1;if(t===fn.CONNECTED_POLYGONS){s=h.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==h.anEdge);for(var m=l;m<n;++m)this.elements[d++]=-1}}},r.prototype.outputContours_=function(e,t){var n,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,h=0;s=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=0,i=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],t>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==i);this.elements[h++]=s,this.elements[h++]=o,s+=o}},r.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new US),e<2&&(e=2),e>3&&(e=3);for(var n=null,i=0;i<t.length;i+=e)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=t[i+0],n.Org.coords[1]=t[i+1],e>2?n.Org.coords[2]=t[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(e,t,n,i,s,o){if(e===void 0&&(e=Ot.ODD),t===void 0&&(t=fn.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),kB.computeInterior(this,o);var a=this.mesh;return t===fn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),t===fn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,t,n,i),!0},r}();function Mo(r){var e=r.windingRule,t=e===void 0?Ot.ODD:e,n=r.elementType,i=n===void 0?fn.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,c=r.normal,h=c===void 0?[0,0,1]:c,u=r.contours,d=u===void 0?[]:u,f=r.strict,m=f===void 0?!0:f,p=r.debug,g=p===void 0?!1:p;if(!d&&m)throw new Error("Contours can't be empty");if(!!d){var x=new VB;r.edgeCreateCallback&&(x.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(x.vertexIdCallback=r.vertexIdCallback);for(var v=0;v<d.length;v++)x.addContour(l||2,d[v]);return x.tesselate(t,i,o,l,h,m),{vertices:x.vertices,vertexIndices:x.vertexIndices,vertexCount:x.vertexCount,elements:x.elements,elementCount:x.elementCount,mesh:g?x.mesh:void 0}}}var Pq=Ot.ODD,Lq=Ot.NONZERO,Iq=Ot.POSITIVE,Nq=Ot.NEGATIVE,Rq=Ot.ABS_GEQ_TWO,Bq=fn.POLYGONS,Oq=fn.CONNECTED_POLYGONS,Fq=fn.BOUNDARY_CONTOURS;var il=class extends Le{constructor(t,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=Ot.ODD;this.elementType=fn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=t,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:Ot.ODD,elementType:fn.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,h,u;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,x=s[g+0],v=s[g+1];if(h!==void 0&&x!==h&&(l=!1),u!==void 0&&v!==u&&(c=!1),h=x,u=v,!l&&!c)break}!l&&!c&&(a=Mo({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Xe(new Float32Array(d*3),3),this._normalAttribute=new Xe(new Float32Array(d*3),3),this._uvAttribute=new Xe(new Float32Array(d*2),2),this._indexAttribute=new Xe(new Uint32Array(f*3),1),a){let m=1/0,p=-1/0,g=1/0,x=-1/0;for(let b=0,S=d;b<S;b++){let M=b*2,_=a.vertices[M+0],y=a.vertices[M+1];_<m&&(m=_),_>p&&(p=_),y<g&&(g=y),y>x&&(x=y)}let v=p-m,w=x-g;for(let b=0,S=d;b<S;b++){let M=b*2,_=a.vertices[M+0],y=a.vertices[M+1],T=(_-m)/v,E=(y-g)/w;this._positionAttribute.setXYZ(b,_,y,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,T,E)}for(let b=0,S=f;b<S;b++){let M=b*3,_=a.elements[M+0],y=a.elements[M+1],T=a.elements[M+2];this._indexAttribute.setX(M+0,_),this._indexAttribute.setX(M+1,y),this._indexAttribute.setX(M+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let t=new il(this._shape,this._curveSegments);return t.userData=Ic(this.userData),t}};var Zd=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let n=e*Zd.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*i,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let n=e*Zd.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*e);o+=3*e;let l=new Float32Array(i,o*s,3*e);o+=3*e;let c=new Float32Array(i,o*s,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=c,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let i=this.capacity;for(;t>i;)i*=2;this.realloc(i)}let n=this.size;return this.size=t,n}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},$c=Zd;$c.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Jg=(r,e)=>([t,n])=>(n<t&&(n+=e),(r>=t?r:r+e)<=n),sl=class extends Le{constructor(t,n,i=0,s=12,o=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=t,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let a=this._shape.extractShapePointsToFlatArray([],s),l=this._shape.shapeHoles.map(_=>{let y=_.extractShapePointsToFlatArray([],s),T=[];for(let E=y.length-1;E>=1;E-=2){let C=y[E-1],I=y[E-0];T.push(C,I)}return T}),c=Mo({windingRule:Ot.ODD,elementType:fn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]}),h=Mo({windingRule:Ot.ODD,elementType:fn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]});if(!c)throw new Error("error generating geometry");let u=c.elementCount;if(h){c.elementCount+=h.elementCount;for(let _=0;_<h.elements.length;_++){let y=h.elements[_],T=_%2===0?c.vertexCount:0;c.elements.push(y+T)}for(let _=0;_<h.vertexIndices.length;_++){let y=h.vertexIndices[_],T=c.vertexCount;c.vertexIndices.push(y+T)}for(let _=0;_<h.vertices.length;_++){let y=h.vertices[_];c.vertices.push(y)}}let d=1/0,f=-1/0,m=1/0,p=-1/0;for(let _=0,y=c.vertexCount;_<y;_++){let T=_*2,E=c.vertices[T+0],C=c.vertices[T+1];E<d&&(d=E),E>f&&(f=E),C<m&&(m=C),C>p&&(p=C)}this._minX=d,this._minY=m,this._width=f-d,this._height=p-m;let g=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new $c(g);let x=[],v=[];for(let _=c.elementCount-1;_>=0;_--){let y=_>=u,T=_*2,E=c.elements[T+0],C=c.elements[T+1],I=E+C,R={start:E,count:C,normals:[],continuous:[],concave:[]},N=E,H=I-1,j=E+1,K=this._shape.roundedCurves.length;do{let V=N-E,O=c.vertices[H*2+0],G=c.vertices[H*2+1],W=c.vertices[N*2+0],X=c.vertices[N*2+1],q=c.vertices[j*2+0],se=c.vertices[j*2+1],Z=W-O,te=X-G,k=Math.sqrt(Z*Z+te*te);Z/=k,te/=k;let le=W-q,ce=X-se,ae=Math.sqrt(le*le+ce*ce);le/=ae,ce/=ae,R.normals[V*2+0]=-ce,R.normals[V*2+1]=le,R.concave[V]=Z*ce-te*le>0;let de=c.vertexIndices[N];if(Array.isArray(de))R.continuous[V]=!1;else{let[ge,fe]=this._shape.getCurveIndexFromVertexId(de-1,!0);if(fe>0&&fe<1)R.continuous[V]=!0;else{let Ee=fe===1?ge+1:ge-1;Ee=(Ee+K)%K;let De=fe===1?0:1,ye=this._shape.roundedCurves[ge].getTangent(fe),Re=this._shape.roundedCurves[Ee].getTangent(De);R.continuous[V]=ye.dot(Re)>.95}}y&&(R.normals[V*2+0]*=-1,R.normals[V*2+1]*=-1),[H,N,j]=[N,j,j+1],j>=I&&(j-=C)}while(j!==E+1);let Y=[];Y.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(E*2,I*2),vertexCount:C,vertexIndices:new Array(C).fill(!0).map((V,O)=>[O,O]),elements:[0,C],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(E*2,I*2)});for(let V=1;V<=this._bevelSegments;V++){let O=V/this._bevelSegments*Math.PI/2,G=(1-Math.cos(O))*this._bevelSize,W=[],X=[],q=[],se=[],Z=0;for(let k=0;k<C;k++){let le=k*2,ce=(k-1+C)%C*2,ae=c.vertices[R.start*2+le+0],de=c.vertices[R.start*2+le+1],ge=-R.normals[ce+0]*G,fe=-R.normals[ce+1]*G,Ee=-R.normals[le+0]*G,De=-R.normals[le+1]*G;if(R.concave[k]||!R.concave[k]&&y){let ye=Math.atan2(fe,ge),Re=Math.atan2(De,Ee);Re>ye&&(Re-=Math.PI*2);let mt=Re-ye;if(R.continuous[k]||y){let P=ye+mt/2,D=Math.cos(P)*G,J=Math.sin(P)*G;W[2*Z+0]=ae+D*(y?-1:1),W[2*Z+1]=de+J*(y?-1:1),se[Z]=k,Z++}else{let P=Math.max(1,Math.floor(s/4*Math.abs(mt)/Math.PI));for(let D=0;D<=P;D++){let J=ye+mt*(D/P),ue=Math.cos(J)*G,pe=Math.sin(J)*G;W[2*Z+0]=ae+ue,W[2*Z+1]=de+pe,se[Z]=k,Z++}}}else W[2*Z+0]=ae+ge,W[2*Z+1]=de+fe,se[Z]=k,X[k]=Z,Z++,W[2*Z+0]=ae,W[2*Z+1]=de,se[Z]=k,Z++,W[2*Z+0]=ae+Ee,W[2*Z+1]=de+De,se[Z]=k,q[k]=Z,Z++}let te=Mo({windingRule:Ot.POSITIVE,elementType:fn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[W],edgeCreateCallback:k=>{let ce=k.Org.idx,ae=se[ce],de=se[(ce+1)%se.length];k.idx=[ae,de],k.Sym.idx=[de,ae]},vertexIdCallback:k=>{let le=k.Lprev.idx;return[le?le[1]:0,k.idx[0]]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!te.vertexCount)break;for(let k=0;k<te.vertexIndices.length;k++){let[le,ce]=te.vertexIndices[k];if(le===ce)continue;let ae=ce;ce<le&&(ae+=C);for(let de=le;de<ae;de++){let ge=de%C,fe=(de+1)%C;if(!R.continuous[ge]||!R.continuous[fe]){te.vertexIndices[k]=[le,ge],te.vertexIndices.splice(k+1,0,[fe,ce]),te.vertices.splice((k+1)*2,0,te.vertices[k*2],te.vertices[k*2+1]);break}}}Y.push({bevelI:V,angle:O,size:G,boundary:te,reverseMap:se,insetPoints:W})}let z=(V,O,G)=>{let W=0,X=V.boundary.vertexIndices.length;for(;W<X&&G(V.boundary.vertexIndices[O]);)O=(O+1)%X,W++;return W},F=x.length;for(let V=1;V<Y.length;V++){let O=Y[V-1],G=Y[V],W=O.boundary.vertexIndices.length,X=G.boundary.vertexIndices.length;if(!W||!X)break;let q=R.concave.length,se=0,Z=Jg(se,C);for(;!O.boundary.vertexIndices.filter(Z).length||!G.boundary.vertexIndices.filter(Z).length;)se++,Z=Jg(se,C);let te=O.boundary.vertexIndices.findIndex(Z),k=G.boundary.vertexIndices.findIndex(Z);do te=(te+1)%W;while(Z(O.boundary.vertexIndices[te]));do k=(k+1)%X;while(Z(G.boundary.vertexIndices[k]));se=(se+1)%C;let le=se,ce=this.buildBevelVert(R,O,(te-1+W)%W),ae=this.buildBevelVert(R,G,(k-1+X)%X),de=ce,ge=ae,fe,Ee,De=!1;do{Z=Jg(se,C);let ye=z(O,te,Z),Re=z(G,k,Z),mt=De;if(De=!1,ye&&!Re){for(let P=0;P<ye;P++)fe=this.buildBevelVert(R,O,(te+P)%W,P/(ye-1)),x.push(de.topN,fe.topP,ge.topN),x.push(fe.bottomP,de.bottomN,ge.bottomN),de=fe;De=!0}else if(!ye&&Re)for(let P=0;P<Re;P++)Ee=this.buildBevelVert(R,G,(k+P)%X,P/(Re-1)),x.push(ge.topN,de.topP,Ee.topP),x.push(de.bottomP,ge.bottomN,Ee.bottomP),ge=Ee;else if(ye&&Re)if(fe=this.buildBevelVert(R,O,te,0),Ee=this.buildBevelVert(R,G,k,0),mt?(x.push(de.topN,Ee.topP,ge.topN),x.push(de.topN,fe.topP,Ee.topP),x.push(Ee.bottomP,de.bottomN,ge.bottomN),x.push(Ee.bottomP,fe.bottomP,de.bottomN)):(x.push(ge.topN,de.topN,fe.topP),x.push(ge.topN,fe.topP,Ee.topP),x.push(fe.bottomP,de.bottomN,ge.bottomN),x.push(fe.bottomP,ge.bottomN,Ee.bottomP)),de=fe,ge=Ee,ye===Re)for(let P=1;P<ye;P++)fe=this.buildBevelVert(R,O,(te+P)%W,P/(ye-1)),Ee=this.buildBevelVert(R,G,(k+P)%X,P/(Re-1)),x.push(de.topN,fe.topP,ge.topN),x.push(ge.topN,fe.topP,Ee.topP),x.push(fe.bottomP,de.bottomN,ge.bottomN),x.push(fe.bottomP,ge.bottomN,Ee.bottomP),de=fe,ge=Ee;else if(ye>Re){let P=ye/Re,D=0;for(let J=1;J<ye;J++)fe=this.buildBevelVert(R,O,(te+J)%W,J/(ye-1)),x.push(de.topN,fe.topP,ge.topN),x.push(fe.bottomP,de.bottomN,ge.bottomN),de=fe,J>(D+1)*P&&(D++,Ee=this.buildBevelVert(R,G,(k+D)%X,D/(Re-1)),x.push(ge.topN,fe.topP,Ee.topP),x.push(fe.bottomP,ge.bottomN,Ee.bottomP),ge=Ee)}else{let P=Re/ye,D=0;for(let J=1;J<Re;J++)Ee=this.buildBevelVert(R,G,(k+J)%X,J/(Re-1)),x.push(ge.topN,fe.topP,Ee.topP),x.push(fe.bottomP,ge.bottomN,Ee.bottomP),ge=Ee,J>(D+1)*P&&(D++,fe=this.buildBevelVert(R,O,(te+D)%W,D/(ye-1)),x.push(de.topN,fe.topP,ge.topN),x.push(fe.bottomP,de.bottomN,ge.bottomN),de=fe)}te=(te+ye)%W,k=(k+Re)%X,se=(se+1)%q}while(se!==le)}{let V=Y[0];for(let O=0,G=V.boundary.vertexCount;O<G;O++){let W=this.buildBevelVert(R,V,O),X=this.buildBevelVert(R,V,(O+1)%G);x.push(X.topP,W.topN,W.bottomN),x.push(X.topP,W.bottomN,X.bottomP)}}if(y){let V=[];for(let O=x.length-1;O>=F+2;O-=3){let G=x[O-2],W=x[O-1],X=x[O-0];V.push(X,W,G)}x.splice(F,x.length-F,...V)}if(y){let V=[];for(let O=Y[Y.length-1].boundary.vertices.length-1;O>=1;O-=2){let G=Y[Y.length-1].boundary.vertices[O-1],W=Y[Y.length-1].boundary.vertices[O-0];V.push(G,W)}v.push(V)}if(!y){let V=Y[Y.length-1],O=Mo({windingRule:Y.length>1?Ot.POSITIVE:Ot.ODD,elementType:fn.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...v]});if(!O)throw new Error("Error generating geometry for surface");l.length===0&&Object.assign(this,{capStartIndex:x.length});for(let G=0;G<O.elementCount*3;G+=3){let W=this.buildSurfaceVert(O,O.elements[G+0]),X=this.buildSurfaceVert(O,O.elements[G+1]),q=this.buildSurfaceVert(O,O.elements[G+2]);x.push(W.top,X.top,q.top),x.push(q.bottom,X.bottom,W.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Xe(Uint32Array.from(x),1),b=new Xe(this._buffer.positions,3),S=new Xe(this._buffer.normals,3),M=new Xe(this._buffer.uvs,2);b.needsUpdate=!0,S.needsUpdate=!0,M.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",b),this.setAttribute("normal",S),this.setAttribute("uv",M),this.setIndex(w)}buildSurfaceVert(t,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=t.vertices[n*2+0],o=t.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,c=this._buffer.get(2),h=c*3,u=c*2,d={top:c+0,bottom:c+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=o,this._buffer.positions[h+2]=this._depth,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[u+0]=a,this._buffer.uvs[u+1]=l,this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=o,this._buffer.positions[h+5]=0,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[u+2]=a,this._buffer.uvs[u+3]=l,this.vertexCache[i]=d,d}buildBevelVert(t,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],c,h,u,d;a!==l?(h=a,c=l,d=!1,u=t.continuous[h]&&t.continuous[c]):(c=a,h=(c-1+t.count)%t.count,d=t.concave[c]&&n.bevelI>0,u=t.continuous[c]||d);let f=Math.cos(n.angle),m=Math.sin(n.angle),p=i*2,g=c*2,x=h*2,v=n.boundary.vertices[p+0],w=n.boundary.vertices[p+1],b=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,M=(w-this._minY)/this._height,_=t.normals[g+0],y=t.normals[g+1],T=t.normals[x+0],E=t.normals[x+1];if(d){let H=T-_,j=E-y;_=_+H*(1-s),y=y+j*(1-s);let K=Math.sqrt(_*_+y*y);_/=K,y/=K}let C=this._buffer.get(u?2:4),I=C*3,R=C*2,N={i,fi:c,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[I+0]=v,this._buffer.positions[I+1]=w,this._buffer.positions[I+2]=this._depth-b,this._buffer.normals[I+0]=_*f,this._buffer.normals[I+1]=y*f,this._buffer.normals[I+2]=m,this._buffer.uvs[R+0]=S,this._buffer.uvs[R+1]=M,this._buffer.positions[I+3]=v,this._buffer.positions[I+4]=w,this._buffer.positions[I+5]=b,this._buffer.normals[I+3]=_*f,this._buffer.normals[I+4]=y*f,this._buffer.normals[I+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=S,u||(C+=2,I+=6,R+=4,N.topP=C+0,N.bottomP=C+1,this._buffer.positions[I+0]=v,this._buffer.positions[I+1]=w,this._buffer.positions[I+2]=this._depth-b,this._buffer.normals[I+0]=T*f,this._buffer.normals[I+1]=E*f,this._buffer.normals[I+2]=m,this._buffer.uvs[R+0]=S,this._buffer.uvs[R+1]=M,this._buffer.positions[I+3]=v,this._buffer.positions[I+4]=w,this._buffer.positions[I+5]=b,this._buffer.normals[I+3]=T*f,this._buffer.normals[I+4]=E*f,this._buffer.normals[I+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=S),this.vertexCache[o]=N,N}clone(){let t=new sl(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=Ic(this.userData),t}};var Pn=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??0),o=r.shape??e?.shape,a=o?.roundness??t.roundness;o!==void 0&&(o instanceof pt?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new pt(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update(!1));let l=o??new pt(n,i);return{parameters:Object.assign(t,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:e,extrudeBevelSize:t,extrudeBevelSegments:n,subdivisions:i,roundness:s}=r.parameters;r.shape.roundness=s;let o;return e<=0?o=new il(r.shape,i):o=new sl(r.shape,e,t,i,n),Object.assign(o,{userData:{...r,type:"VectorGeometry"}})}};var HS=Math.PI*2,WS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof pt?r.shape:new pt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,c=r.shape,h=e*.5,u=t*.5,d=HB(c,h,u,i*Math.PI/180,n,s);c.isClosed=!0,c.update();let f=Pn.create({shape:c,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function HB(r,e,t,n,i,s){if(n>=HS)return i>30||i%4===0?(jB(r,e,t,s),Math.round(i/4)):VS(r,n,i,e,t,s);let o={x:0,y:t},a=n+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},c=FS({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?WB(r,o.x,o.y,c,i,e,t,s):VS(r,n,i,e,t,s)}function WB(r,e,t,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(ol(e,t));for(let c=0,h=n.length;c<h;c++){let u=n[c],d=r.points[c],f=ol(u.x,u.y);d.controls[1].position.set(u.x1,u.y1),f.controls[0].position.set(u.x2,u.y2),r.addPoint(f)}return a>0?jS(r,s,o,a):r.addPoint(ol(0,0)),l}function VS(r,e,t,n,i,s){let o=-e/t;for(let a=0;a<=t;a++){let l=o*a,c=Math.sin(l)*n,h=Math.cos(l)*i;r.addPoint(ol(c,h))}return e<HS?s>0?jS(r,n,i,s):r.addPoint(ol(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&qS(r,n,i,s)),1}function jB(r,e,t,n=0,i=0,s=0){let o=.5522847498,a=e*o,l=t*o;r.addPoint(Jd(i-e,s,i-e,s-l,i-e,s+l)),r.addPoint(Jd(i,s+t,i-a,s+t,i+a,s+t)),r.addPoint(Jd(i+e,s,i+e,s+l,i+e,s-l)),r.addPoint(Jd(i,s-t,i+a,s-t,i-a,s-t)),n>0&&qS(r,e,t,n)}function ol(r,e){return new Xr(Ge.generateUUID(),new B(r,e))}function Jd(r,e,t,n,i,s){let o=ol(r,e);return o.controls[0].position.set(t,n),o.controls[1].position.set(i,s),o}function jS(r,e,t,n){XS(r,e,t,n).forEach(s=>r.addPoint(s))}function qS(r,e,t,n){let i=XS(r,e,t,n),s=new pt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function XS(r,e,t,n){let i=n*e/100,s=i*(Math.abs(t)/Math.abs(e)),o=new B(i/e,s/t),a=r.points.map(l=>{let c=l.clone();return c.uuid=Ge.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(o);let c=l.controls[0].position.clone().multiply(o),h=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(h),l.controls[1].position.copy(c)}),a}var YS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??n),s=Math.abs(t.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(t,{width:n,height:i,depth:s,radius:o,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(r){let{width:e,height:t,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:h,cornerSegments:u}=r.parameters,d=new eh(!1,e,t,n,i,s,o,a,l,c,h,u);return Object.assign(d,{userData:{...r,type:"HelixGeometry"}})}},eh=class extends Le{constructor(e=!0,t=1,n=1,i=1,s=1,o=1,a=1,l=1,c=1,h=1,u=1,d=1){super();let f=e&&o===1;f&&(d=0),u>100&&(u=100);let m=()=>new A,p=new A,g=m(),x=m(),v=m(),w,b,S,M,_,y,T,E,C=m(),I=m(),R=m(),N=m(),H=m(),j=m(),K=m(),Y=m(),z=n-2*l+.001,F=z/o,V=Math.ceil(a*o),O=V+1,G=z/V,W=-z/2,X=h+1,q=2*Math.PI/h,se=Math.PI/2/d,Z=.01,te=Math.min((1-u/100)*l,l-Z),k=l-te,le=0,ce=2,ae=d*ce+ce,de=X*ae/ce,ge=de+X*O,fe=X*(O+ae),[Ee,De,ye]=[3,3,2].map(ve=>Array(fe*ve).fill(0)),Re=[],mt=s-l;function P(ve,U){let xe=Math.PI/2;y=U*G,E=2*Math.PI*(y%F)/F+xe,y+=W,T=Math.sin(E)*mt,_=Math.cos(E)*mt,e?ve.set(_,T,y):ve.set(_,y,T)}P(p,-1e-10),P(g,0),C.copy(p),P(p,1);let D=p.distanceTo(g),J=k+te,ue=D*V+2*J,pe=te,Ce=ue-J;for(let ve=0;ve<=V;ve++){P(x,ve),Y.subVectors(x,C).normalize(),C.copy(x),j.copy(x).setComponent(+e+1,0).normalize(),K.crossVectors(Y,j).normalize();let U=ve===0,xe=ve===V,Me=U?3*Math.PI/2:se,Qe=U?pe:Ce,Ne=U?X:ge,Ke=U?0:fe-X,be=Y.clone().multiplyScalar(U?-k:k).add(x),Ze=Y.clone().multiplyScalar(U?-1:1).normalize();for(let rt=0;rt<X;rt++){let gt=rt*q;if(I.addVectors(p.copy(j).multiplyScalar(l*Math.cos(gt)),g.copy(K).multiplyScalar(l*Math.sin(gt))),R.copy(I).normalize(),U||xe){f||(le=Ke+rt,[0,1,2].forEach(wt=>{Ee[le*3+wt]=be.getComponent(wt),De[le*3+wt]=Ze.getComponent(wt)}),ye[le*2]=+xe,ye[le*2+1]=rt/h),g.copy(R).multiplyScalar(te),v.addVectors(x,g);for(let wt=0;wt<d;wt++){let Qn=wt*se+Me;N.addVectors(p.copy(Y).multiplyScalar(k*Math.sin(Qn)),g.copy(R).multiplyScalar(k*Math.cos(Qn))),H.copy(N).normalize(),g.addVectors(v,N),N.normalize(),le=Ne+wt*X+rt,[0,1,2].forEach(No=>{Ee[le*3+No]=g.getComponent(No),De[le*3+No]=H.getComponent(No)});let Nh=+U+Math.sin(Qn);ye[le*2]=(Qe+k*Nh)/ue,ye[le*2+1]=rt/h}}g.addVectors(x,I),le=de+ve*X+rt,[0,1,2].forEach(wt=>{Ee[le*3+wt]=g.getComponent(wt),De[le*3+wt]=R.getComponent(wt)}),ye[le*2]=(J+ve*D)/ue,ye[le*2+1]=rt/h}}let Fe=O+2*d+ce,re=1,[Be,Ie]=f?[re,re+O-1]:[0,Fe-1];for(let ve=Be;ve<=Ie-1;ve++){let U=f&&ve===Ie-1;for(let xe=0;xe<X-1;xe++)w=ve*X+xe,b=w+1,S=(U?xe:w)+X,M=(U?xe+1:b)+X,ve===0?Re.push(b,M,S):ve===Fe-2?Re.push(w,b,S):Re.push(w,b,S,b,M,S)}this.setIndex(Re),this.setAttribute("position",new Se(Ee,3)),this.setAttribute("normal",new Se(De,3)),this.setAttribute("uv",new Se(ye,2))}};var QS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new th(e*.5,s,o):new ua(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},th=class extends Bs{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,e,t,n),this.type=a}static fromJSON(e){return new th(e.radius,e.corner,e.cornerSides)}};var KS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){(r.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let t=Object.assign({},e?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{points:e,segments:t,verticalSegments:n}=r.parameters,i=new Gr;i.moveTo(e[0].x,e[0].y),i.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new aa(i.extractPoints(n).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var vi=new Oe,$g=new ct,$d=new A,Fs=class extends Rt{constructor(){super(),this.uuid=Ge.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new qt().getNormalMatrix(e);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(e);for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];s.normal.applyMatrix3(t).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return vi.makeRotationX(e),this.applyMatrix4(vi),this}rotateY(e){return vi.makeRotationY(e),this.applyMatrix4(vi),this}rotateZ(e){return vi.makeRotationZ(e),this.applyMatrix4(vi),this}translate(e,t,n){return vi.makeTranslation(e,t,n),this.applyMatrix4(vi),this}scale(e,t,n){return vi.makeScale(e,t,n),this.applyMatrix4(vi),this}lookAt(e){return $g.lookAt(e),$g.updateMatrix(),this.applyMatrix4($g.matrix),this}fromBufferGeometry(e){let t=this,n=e.index!==null?e.index:void 0,i=e.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,c=i.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)t.vertices.push(new A().fromBufferAttribute(s,d)),a!==void 0&&t.colors.push(new Ae().fromBufferAttribute(a,d));function h(d,f,m,p){let g=a===void 0?[]:[t.colors[d].clone(),t.colors[f].clone(),t.colors[m].clone()],x=o===void 0?[]:[new A().fromBufferAttribute(o,d),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,m)],v=new al(d,f,m,x,g,p);t.faces.push(v),l!==void 0&&t.faceVertexUvs[0].push([new B().fromBufferAttribute(l,d),new B().fromBufferAttribute(l,f),new B().fromBufferAttribute(l,m)]),c!==void 0&&t.faceVertexUvs[1].push([new B().fromBufferAttribute(c,d),new B().fromBufferAttribute(c,f),new B().fromBufferAttribute(c,m)])}let u=e.groups;if(u.length>0)for(let d=0;d<u.length;d++){let f=u[d],m=f.start,p=f.count;for(let g=m,x=m+p;g<x;g+=3)n!==void 0?h(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):h(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let d=0;d<n.count;d+=3)h(n.getX(d),n.getX(d+1),n.getX(d+2));else for(let d=0;d<s.count;d+=3)h(d,d+1,d+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($d).negate(),this.translate($d.x,$d.y,$d.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,n=t===0?1:1/t,i=new Oe;return i.set(n,0,0,-n*e.x,0,n,0,-n*e.y,0,0,n,-n*e.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let e=new A,t=new A;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];e.subVectors(l,a),t.subVectors(o,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let n=0,i=this.vertices.length;n<i;n++)t[n]=new A;if(e){let n=new A,i=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],c=this.vertices[a.b],h=this.vertices[a.c];n.subVectors(h,c),i.subVectors(l,c),n.cross(i),t[a.a].add(n),t[a.b].add(n),t[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let n=0,i=this.vertices.length;n<i;n++)t[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(t[s.a]),o[1].copy(t[s.b]),o[2].copy(t[s.c])):(o[0]=t[s.a].clone(),o[1]=t[s.b].clone(),o[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let n=this.faces[e],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let e=new Fs;e.faces=this.faces;for(let t=0,n=this.morphTargets.length;t<n;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,o=this.morphNormals[t].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let c=new A,h={a:new A,b:new A,c:new A};s.push(c),o.push(h)}}let i=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],c=i.vertexNormals[s];l.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}}for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Sn),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Rn),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,n=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let i,s=this.vertices.length,o=this.vertices,a=e.vertices,l=this.faces,c=e.faces,h=this.colors,u=e.colors;t!==void 0&&(i=new qt().getNormalMatrix(t));for(let d=0,f=a.length;d<f;d++){let p=a[d].clone();t!==void 0&&p.applyMatrix4(t),o.push(p)}for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone());for(let d=0,f=c.length;d<f;d++){let m=c[d],p,g,x=m.vertexNormals,v=m.vertexColors,w=new al(m.a+s,m.b+s,m.c+s);w.normal.copy(m.normal),i!==void 0&&w.normal.applyMatrix3(i).normalize();for(let b=0,S=x.length;b<S;b++)p=x[b].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),w.vertexNormals.push(p);w.color.copy(m.color);for(let b=0,S=v.length;b<S;b++)g=v[b],w.vertexColors.push(g.clone());w.materialIndex=m.materialIndex+n,l.push(w)}for(let d=0,f=e.faceVertexUvs.length;d<f;d++){let m=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,g=m.length;p<g;p++){let x=m[p],v=[];for(let w=0,b=x.length;w<b;w++)v.push(x[w].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},n=[],i=[],s=Math.pow(10,e);for(let l=0,c=this.vertices.length;l<c;l++){let h=this.vertices[l],u=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[u]===void 0?(t[u]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[t[u]]}let o=[];for(let l=0,c=this.faces.length;l<c;l++){let h=this.faces[l];h.a=i[h.a],h.b=i[h.b],h.c=i[h.c];let u=[h.a,h.b,h.c];for(let d=0;d<3;d++)if(u[d]===u[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let c=o[l];this.faces.splice(c,1);for(let h=0,u=this.faceVertexUvs.length;h<u;h++)this.faceVertexUvs[h].splice(c,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(e){this.vertices=[];for(let t=0,n=e.length;t<n;t++){let i=e[t];this.vertices.push(new A(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let l=0;l<t;l++)e[l]._id=l;function n(l,c){return l.materialIndex-c.materialIndex}e.sort(n);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===t&&(o=[]),s&&s.length===t&&(a=[]);for(let l=0;l<t;l++){let c=e[l]._id;o&&o.push(i[c]),a&&a.push(s[c])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(e[p]=m[p]);return e}let t=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];t.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],c={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,x=!1,v=this.faceVertexUvs[0][m]!==void 0,w=p.normal.length()>0,b=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,M=p.vertexColors.length>0,_=0;if(_=h(_,0,0),_=h(_,1,g),_=h(_,2,x),_=h(_,3,v),_=h(_,4,w),_=h(_,5,b),_=h(_,6,S),_=h(_,7,M),n.push(_),n.push(p.a,p.b,p.c),n.push(p.materialIndex),v){let y=this.faceVertexUvs[0][m];n.push(f(y[0]),f(y[1]),f(y[2]))}if(w&&n.push(u(p.normal)),b){let y=p.vertexNormals;n.push(u(y[0]),u(y[1]),u(y[2]))}if(S&&n.push(d(p.color)),M){let y=p.vertexColors;n.push(d(y[0]),d(y[1]),d(y[2]))}}function h(m,p,g){return g?m|1<<p:m&~(1<<p)}function u(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(m.x,m.y,m.z)),s[p]}function d(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function f(m){let p=m.x.toString()+m.y.toString();return c[p]!==void 0||(c[p]=l.length/2,l.push(m.x,m.y)),c[p]}return e.data={},e.data.vertices=t,e.data.normals=i,o.length>0&&(e.data.colors=o),l.length>0&&(e.data.uvs=[l]),e.data.faces=n,e}clone(){return new Fs().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let d=0,f=t.length;d<f;d++)this.vertices.push(t[d].clone());let n=e.colors;for(let d=0,f=n.length;d<f;d++)this.colors.push(n[d].clone());let i=e.faces;for(let d=0,f=i.length;d<f;d++)this.faces.push(i[d].clone());for(let d=0,f=e.faceVertexUvs.length;d<f;d++){let m=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,g=m.length;p<g;p++){let x=m[p],v=[];for(let w=0,b=x.length;w<b;w++){let S=x[w];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let s=e.morphTargets;for(let d=0,f=s.length;d<f;d++){let m={};if(m.name=s[d].name,s[d].vertices!==void 0){m.vertices=[];for(let p=0,g=s[d].vertices.length;p<g;p++)m.vertices.push(s[d].vertices[p].clone())}if(s[d].normals!==void 0){m.normals=[];for(let p=0,g=s[d].normals.length;p<g;p++)m.normals.push(s[d].normals[p].clone())}this.morphTargets.push(m)}let o=e.morphNormals;for(let d=0,f=o.length;d<f;d++){let m={};if(o[d].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[d].vertexNormals.length;p<g;p++){let x=o[d].vertexNormals[p],v={};v.a=x.a.clone(),v.b=x.b.clone(),v.c=x.c.clone(),m.vertexNormals.push(v)}}if(o[d].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[d].faceNormals.length;p<g;p++)m.faceNormals.push(o[d].faceNormals[p].clone())}this.morphNormals.push(m)}let a=e.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=e.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let c=e.lineDistances;for(let d=0,f=c.length;d<f;d++)this.lineDistances.push(c[d]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new ey().fromGeometry(this),t=new Le,n=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",new Xe(n,3).copyVector3sArray(e.vertices)),e.normals.length>0){let i=new Float32Array(e.normals.length*3);t.setAttribute("normal",new Xe(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let i=new Float32Array(e.colors.length*3);t.setAttribute("color",new Xe(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let i=new Float32Array(e.uvs.length*2);t.setAttribute("uv",new Xe(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let i=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",new Xe(i,2).copyVector2sArray(e.uvs2))}t.groups=e.groups;for(let i in e.morphTargets){let s=[],o=e.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let c=o[a],h=new Se(c.data.length*3,3);h.name=c.name,s.push(h.copyVector3sArray(c.data))}t.morphAttributes[i]=s}if(e.skinIndices.length>0){let i=new Se(e.skinIndices.length*4,4);t.setAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){let i=new Se(e.skinWeights.length*4,4);t.setAttribute("skinWeight",i.copyVector4sArray(e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new Le,n=e.geometry;if(e.isPoints||e.isLine){let i=new Se(n.vertices.length*3,3),s=new Se(n.colors.length*3,3);if(t.setAttribute("position",i.copyVector3sArray(n.vertices)),t.setAttribute("color",s.copyColorsArray(n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Se(n.lineDistances.length,1);t.setAttribute("lineDistance",o.copyArray(n.lineDistances))}n.boundingSphere!==null&&(t.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(t.boundingBox=n.boundingBox.clone())}else e.isMesh&&(t=n.toBufferGeometry());return t}};Fs.prototype.isGeometry=!0;var ey=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],n,i,s,o=e.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,t.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,t.push(n)),this.groups=t}fromGeometry(e){let t=e.faces,n=e.vertices,i=e.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=e.morphTargets,l=a.length,c;if(l>0){c=[];for(let x=0;x<l;x++)c[x]={name:a[x].name,data:[]};this.morphTargets.position=c}let h=e.morphNormals,u=h.length,d;if(u>0){d=[];for(let x=0;x<u;x++)d[x]={name:h[x].name,data:[]};this.morphTargets.normal=d}let f=e.skinIndices,m=e.skinWeights,p=f.length===n.length,g=m.length===n.length;n.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let x=0;x<t.length;x++){let v=t[x];this.vertices.push(n[v.a],n[v.b],n[v.c]);let w=v.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=v.normal;this.normals.push(S,S,S)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let S=v.color;this.colors.push(S,S,S)}if(s===!0){let S=i[0][x];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",x),this.uvs.push(new B,new B,new B))}if(o===!0){let S=i[1][x];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",x),this.uvs2.push(new B,new B,new B))}for(let S=0;S<l;S++){let M=a[S].vertices;c[S].data.push(M[v.a],M[v.b],M[v.c])}for(let S=0;S<u;S++){let M=h[S].vertexNormals[x];d[S].data.push(M.a,M.b,M.c)}p&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),g&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},al=class{constructor(e,t,n,i,s,o=0){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Ae,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};var qB=["a","b","c"];function XB(r,e){switch(e){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function ty(r,e,t){let n=Math.min(r,e),i=Math.max(r,e),s=n+"_"+i;return t.get(s)}function ny(r,e,t,n,i,s){let o=Math.min(r,e),a=Math.max(r,e),l=o+"_"+a,c;if(n.has(l))c=n.get(l);else{let h=t[o],u=t[a];c={a:h,b:u,newEdge:null,faces:[]},n.set(l,c)}c.faces.push(i),s[r].edges.push(c),s[e].edges.push(c)}function YB(r,e,t,n){let i,s,o;for(i=0,s=r.length;i<s;i++)t[i]={edges:[]};for(i=0,s=e.length;i<s;i++)o=e[i],ny(o.a,o.b,r,n,o,t),ny(o.b,o.c,r,n,o,t),ny(o.c,o.a,r,n,o,t)}function ef(r,e,t,n,i){r.push(new al(e,t,n,void 0,void 0,i))}function ll(r,e){return Math.abs(e-r)/2+Math.min(r,e)}function tf(r,e,t,n){r.push([e.clone(),t.clone(),n.clone()])}var nf=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Le?e=new Fs().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new A,n,i,s,o,a,l=e.vertices,c=e.faces,h=e.faceVertexUvs[0],u=h!==void 0&&h.length>0,d=[],f=new Map;YB(l,c,d,f);let m=[],p,g,x,v,w,b,S;for(let Z of Array.from(f.keys())){for(g=f.get(Z),x=new A,w=3/8,b=1/8,S=g.faces.length,S!=2&&(w=.5,b=0,S!=1),x.addVectors(g.a,g.b).multiplyScalar(w),t.set(0,0,0),o=0;o<S;o++){for(v=g.faces[o],a=0;a<3&&(p=l[XB(v,qB[a])],!(p!==g.a&&p!==g.b));a++);p&&t.add(p)}t.multiplyScalar(b),x.add(t),g.newEdge=m.length,m.push(x)}let M,_,y,T,E,C,I,R=[];for(i=0,s=l.length;i<s;i++){for(C=l[i],E=d[i].edges,n=E.length,n==3?M=3/16:n>3&&(M=3/(8*n)),_=1-n*Number(M),y=M,n<=2&&(n==2?(_=3/4,y=1/8):n==1||n==0),I=C.clone().multiplyScalar(_),t.set(0,0,0),o=0;o<n;o++)T=E[o],p=T.a!==C?T.a:T.b,t.add(p);t.multiplyScalar(Number(y)),I.add(t),R.push(I)}let N=R.concat(m),H=R.length,j,K,Y,z=[],F=[],V,O,G,W,X=new B,q=new B,se=new B;for(i=0,s=c.length;i<s;i++)v=c[i],j=Number(ty(v.a,v.b,f).newEdge)+H,K=Number(ty(v.b,v.c,f).newEdge)+H,Y=Number(ty(v.c,v.a,f).newEdge)+H,ef(z,j,K,Y,v.materialIndex),ef(z,v.a,j,Y,v.materialIndex),ef(z,v.b,K,j,v.materialIndex),ef(z,v.c,Y,K,v.materialIndex),u&&(V=h[i],O=V[0],G=V[1],W=V[2],X.set(ll(O.x,G.x),ll(O.y,G.y)),q.set(ll(G.x,W.x),ll(G.y,W.y)),se.set(ll(O.x,W.x),ll(O.y,W.y)),tf(F,X,q,se),tf(F,O,X,se),tf(F,G,q,X),tf(F,W,se,q));e.vertices=N,e.faces=z,u&&(e.faceVertexUvs[0]=F)}};var pn=new A,ZS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=r.geometry??e?.geometry??new Le().copy(new Zn(100,100,100)),n;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(pn),n={width:pn.x,height:pn.y,depth:pn.z,subdivisions:0}):n=e.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:t}}static build(r){let{width:e,height:t,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new Le().copy(new Zn(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(pn)):pn.set(o.width,o.height,o.depth),(e!==pn.x||t!==pn.y||n!==pn.z)&&s.scale(pn.x===0?1:e/pn.x,pn.y===0?1:t/pn.y,pn.z===0?1:n/pn.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new nf(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,e,t){new ga(t).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(pn);let o=100/pn.x;Object.assign(s.parameters,{width:100,height:pn.y*o,depth:pn.z*o}),e(this.build(s))})}};var JS=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof pt?r.shape:new pt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,c=e*.5,h=t*.5,u=0,d=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let g=f*p,x=u+Math.sin(g)*c,v=d+Math.cos(g)*h;l.addPoint(l.createPoint(x,v))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=i;l.roundness=i,l.update();let m=Pn.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...r,type:"PolygonGeometry"}})}};var $S=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,c=new iy(e*.5,t,i,s,o,a,l);return c.scale(1,1,n/e),Object.assign(c,{userData:{...r,type:"PyramidGeometry"}})}};function nh(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function ry(r,e,t,n,i,s){let o=e.clone().sub(r),a=t.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let c=o.add(a).normalize();s.copy(r).addScaledVector(c,n/Math.sin(l/2))}else{let c=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(c)),s.addScaledVector(a,n/Math.sin(c))}}function QB(r,e,t){let n=r.clone().sub(e),i=t.clone().sub(e);return n.projectOnVector(i),n.add(e)}var iy=class extends Le{constructor(e=.5,t=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],c=[],h=[],u=[],d=0,f=t/2,m=Math.PI/n,p=e*Math.cos(Math.PI/n),g=2*Math.PI/n,x=(n-2)*Math.PI/n,v=Math.PI-x,w=new A(0,-f,0),b=new A(0,f,0),S=new B(e,-f),M=new B(p,-f),_=new B(0,b.y).sub(M),y=new B(0,b.y).sub(S),T=new B(_.y,-_.x).normalize(),E=new B(y.y,-y.x).normalize(),I=e*Math.cos(Math.PI/n)*Math.tan((Math.PI-_.angle())/2)-1e-8;o=Math.min(o,I);let R;{let F=new A(T.x,T.y,0),V=new A(Math.cos(g)*F.x,F.y,Math.sin(g)*F.x);R=F.angleTo(V)}let N=o/Math.tan((Math.PI-_.angle())/2),H=o/Math.tan((Math.PI-R)/2),j=new A;if(!s){c.push(w.x,w.y,w.z),h.push(0,-1,0),u.push(0,0);let F=d++,V=[],O=S.clone(),G=N/Math.cos(Math.PI/n);O.x-=G;for(let W=0;W<n;W++){let X=W/n*Math.PI*2+m,q=new B(Math.sin(X),Math.cos(X));nh(O,q,j),c.push(j.x,j.y,j.z),h.push(0,-1,0),u.push(0,0),V.push(d++)}for(let W=0;W<V.length;W++)l.push(V[W],F,V[(W+1)%V.length])}let K=[];{let F=new A,V=new A,O=new A,G=new A,W=new A,X=new A;for(let q=0;q<n;q++){let se=q/n*Math.PI*2+m,Z=(q+.5)/n*Math.PI*2+m,te=(q+1)/n*Math.PI*2+m,k=new B(Math.sin(se),Math.cos(se)),le=new B(Math.sin(Z),Math.cos(Z)),ce=new B(Math.sin(te),Math.cos(te));nh(S,k,V),nh(S,ce,O),nh(T,le,F),ry(b,V,O,H,H,G),c.push(G.x,G.y,G.z),ry(V,b,O,H,N,W),c.push(W.x,W.y,W.z),ry(O,V,b,N,H,X),c.push(X.x,X.y,X.z),h.push(F.x,F.y,F.z),h.push(F.x,F.y,F.z),h.push(F.x,F.y,F.z),u.push(0,0),u.push(0,0),u.push(0,0);let ae=d++,de=d++,ge=d++;if(l.push(ae,de,ge),o>0){{let De=V.clone().add(O).multiplyScalar(.5),ye=b.clone().sub(De).normalize(),mt=w.clone().sub(De).normalize().add(ye).normalize().multiplyScalar(-1),P=X.clone().sub(W);Y(De,P,mt,_.angle())}let fe,Ee;{let De=new A;nh(E,ce,De);let ye=X.clone().add(G).multiplyScalar(.5);ye=QB(ye,O,b);let Re=X.clone().sub(G);[fe,Ee]=Y(ye,Re,De,R,G.y)}{let De=fe,ye=De.clone().setY(0).normalize(),Re=new A(0,-1,0),mt=ye.clone().cross(Re);z(De,ye,Re,mt)}K.concat(Ee);{let De=_.angle(),ye=Math.PI-De,Re=b.clone();Re.y-=o/Math.sin(De-Math.PI/2);let mt=new A,P=[];for(let J=0;J<a;J++){let ue=[],pe=Math.PI/2-ye*J/a,Ce=Math.cos(pe),Fe=Math.sin(pe),re=Z;for(let Be=0;Be<=J;Be++){let Ie=Math.cos(re),ve=Math.sin(re);F.x=Ce*ve,F.y=Fe,F.z=Ce*Ie,mt.copy(Re).addScaledVector(F,o),c.push(mt.x,mt.y,mt.z),h.push(F.x,F.y,F.z),u.push(0,0),ue.push(d++),re+=Math.PI*2/J/n}P.push(ue)}Ee.reverse(),P.push(Ee);let D=P.length-1;for(let J=0;J<D;J++){let ue=P[J],pe=P[J+1],Ce=ue.length-1;l.push(pe[1],ue[0],pe[0]);for(let Fe=1;Fe<=Ce;Fe++)l.push(ue[Fe],ue[Fe-1],pe[Fe]),l.push(pe[Fe+1],ue[Fe],pe[Fe])}}}}}this.setIndex(l),this.setAttribute("position",new Se(c,3)),this.setAttribute("normal",new Se(h,3)),this.setAttribute("uv",new Se(u,2));function Y(F,V,O,G,W){let X=-G/2,q=(Math.PI-G)/2,se=V.clone().normalize().cross(O);F.addScaledVector(O,-o/Math.sin(q));let Z=new A,te=new A,k=1,le=d,ce=[];for(let ae=0;ae<=a;ae++){let de=X+ae/a*G;te.set(0,0,0),te.addScaledVector(se,Math.sin(de)),te.addScaledVector(O,Math.cos(de));for(let ge=0;ge<=k;ge++){let fe=ge/k-.5;if(Z.copy(F),Z.addScaledVector(V,fe),Z.addScaledVector(te,o),W!=null){let Ee=Math.max(0,Z.y-W);Z.addScaledVector(V,-Ee/V.y)}c.push(Z.x,Z.y,Z.z),h.push(te.x,te.y,te.z),u.push(0,0),ge===0&&ce.push(d),d++}}for(let ae=0;ae<a;ae++)for(let de=0;de<k;de++){let ge=le+de+(k+1)*ae,fe=ge+(k+1),Ee=fe+1,De=ge+1;l.push(ge,fe,De),l.push(fe,Ee,De)}return[F.clone().addScaledVector(V,.5),ce]}function z(F,V,O,G){let W=Math.PI/2,X=y.angle()-W,q=[],se=new A,Z=new A;for(let k=0;k<=a;k++){let le=[],ce=k/a;for(let ae=0;ae<=k;ae++){let ge=((k?ae/k:0)-.5)*v,fe=Math.cos(ge),Ee=Math.sin(ge),De=Math.atan(Math.tan(X)*fe),ye=(W+De)*ce,Re=Math.cos(ye),mt=Math.sin(ye);se.set(0,0,0),se.addScaledVector(V,mt*fe),se.addScaledVector(O,Re),se.addScaledVector(G,mt*Ee),Z.copy(F).addScaledVector(se,o),c.push(Z.x,Z.y,Z.z),h.push(se.x,se.y,se.z),u.push(0,0),le.push(d++)}q.push(le)}let te=q.length-1;for(let k=0;k<te;k++){let le=q[k],ce=q[k+1],ae=le.length-1;l.push(le[0],ce[1],ce[0]);for(let de=1;de<=ae;de++)l.push(le[de-1],le[de],ce[de]),l.push(le[de],ce[de+1],ce[de])}}}};var e1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(e?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof pt?r.shape:new pt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)}),ui:n}}static build(r){let e=r.shape,{width:t,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,c={x:t*.5,y:n*.5},h={x:-c.x,y:-c.y},u={x:c.x,y:c.y};function d(b,S,M){return S>t&&M>n?Math.min(b*t/S,b*n/M):S>t?b*t/S:M>n?b*n/M:b}let f=[];f[0]=i[0]===0?0:d(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:d(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:d(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:d(i[3],i[3]+i[0],i[3]+i[2]);let m=h.x,p=u.x,g=u.y,x=h.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(p,g)),e.addPoint(e.createPoint(p,x)),e.addPoint(e.createPoint(m,x)),e.isClosed=!0;let v=!0;for(let b=0,S=e.points.length;b<S;b++)e.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(v=!1);v&&(e.roundness=f[0]),e.useCubicForRoundedCorners=s!==1,e.update();let w=Pn.create({shape:e,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...r,type:"RectangleGeometry"}})}};var t1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e=100,height:t=e,depth:n=e,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:c}=r.parameters,h=new lo(.5*e,i,s,o,a,l,c);return h.scale(1,t/e,n/e),Object.assign(h,{userData:{...r,type:"SphereGeometry"}})}};var n1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:0})}}static build(r){let{width:e=100,height:t=e,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new Gi(e,t,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var r1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new sy(e,t,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},sy=class extends Le{constructor(e=1,t=1,n=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],c=[],h=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-h,i),i*=Math.PI/180;let u=[],d=Math.PI/2,f=(Z=0,te=0,k=0)=>new A(Z,te,k),m=f(),p=f(),[g,x,v]=[t/2,e/2,n/2],w=-x,b=+x,[S,M,_]=[f(w,-g,+v),f(w,-g,-v),f(w,+g,-v)],y=(Z,te=!1)=>Math.sin(Z-Math.PI/(1+ +te)),T=(Z,te=!1)=>Math.cos(Z-Math.PI/(1+ +te));_.y=Math.sin(i)*t-g;let E=Math.cos(i)*t-v,C=S.z-h;i<=d?(_.z=Math.min(E,C),_.z==C&&(_.y-=(E-C)/Math.tan(d-i))):M.z=Math.min(M.z-E-v,S.z-h),m.subVectors(S,M),p.subVectors(_,M);let I=Math.min(m.length(),p.length())*s/100,R=I*Math.tan(i/2),N=I/Math.cos(i/2),H=m.clone().normalize().add(p.normalize()).setLength(N).add(M);m.set(0,y(i,!0),T(i,!0)),u.push([_,m.clone()]);let j=(Math.PI-i)/o;for(let Z=0;Z<=o;Z++){let te=d+i+Z*j;m.set(0,Math.sin(te)*R,Math.cos(te)*R),m.add(H),p.set(0,y(te),T(te)),u.push([m.clone(),p.clone()])}u.push([S,f(0,1,0)]);let K=Math.sin(j/2)*R*2,Y=u.length-1,z=u[0][0].distanceTo(u[1][0]),F=u[Y-1][0].distanceTo(u[Y][0]),V=z+K*o+F;u[0].push(1);for(let Z=0;Z<=o;Z++)u[Z+1].push(1-(z+Z*K)/V);u[Y].push(0);let[O,G,W]=u[0],X,q,se;for(let Z=1;Z<u.length;Z++)[X,q,se]=u[Z],a.push(w,O.y,O.z,w,X.y,X.z,b,O.y,O.z,b,O.y,O.z,w,X.y,X.z,b,X.y,X.z),l.push(0,G.y,G.z,0,q.y,q.z,0,G.y,G.z,0,G.y,G.z,0,q.y,q.z,0,q.y,q.z),c.push(0,W,0,se,1,W,1,W,0,se,1,se),[O,G,W]=[X,q,se];this.setAttribute("position",new Se(a,3)),this.setAttribute("normal",new Se(l,3)),this.setAttribute("uv",new Se(c,2))}};var i1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof pt?r.shape:new pt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=r.parameters,h=r.shape,u=e*.5,d=t*.5,f=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,x=u*n/100,v=d*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let b=0;b<i;b++){let S=p*b,M=f+Math.sin(S)*u,_=m+Math.cos(S)*d;h.addPoint(h.createPoint(M,_))}}else for(let b=0;b<i;b++){let S=f+Math.cos(g)*u,M=m+Math.sin(g)*d;h.addPoint(h.createPoint(S,M)),g+=p,S=f+Math.cos(g)*x,M=m+Math.sin(g)*v,b<=i,h.addPoint(h.createPoint(S,M)),g+=p}h.isClosed=!0;for(let b=0,S=h.points.length;b<S;b++)h.points[b].roundness=s;h.roundness=s,h.update();let w=Pn.create({shape:h,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...r,type:"StarGeometry"}})}};var rf=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t}=r.parameters,n=new Gi(e,t);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var s1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??t.width*.25);return{parameters:Object.assign(t,{width:n,height:i,depth:s})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,c=KB(e,t,n,e*.5,o,s,0,0,i,a,l);return c.scale(1,t/e,1),Object.assign(c,{userData:{...r,type:"TorusGeometry"}})}};function KB(r,e,t,n,i,s,o,a,l,c,h){return[e,t]=[t,e],o=e/2,i/=2*Math.PI,i==1&&(c=0),new eh(!0,r,e,t,n,i,s,o,a,l,c,h)}var o1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),tube:t.tube??t.width*.125})}}static build(r){let{width:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=e*.5;a!==t&&(a-=t);let l=new fa(a,t,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var a1=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof pt?r.shape:new pt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e=100,height:t,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.shape,c=e*.5,h=t*.5;a?(l.addPoint(l.createPoint(-c,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))):(l.addPoint(l.createPoint(0,h)),l.addPoint(l.createPoint(c,-h)),l.addPoint(l.createPoint(-c,-h))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=n;l.roundness=n,l.update();let u=Pn.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(u,{userData:{...r,type:"TriangleGeometry"}})}};var ZB,sf=new Promise(r=>{ZB=r});var Ln=class extends Ae{constructor(t,n,i,s){super(t,n,i);this.isColorA=!0;this.a=s}setRGBA(t,n,i,s){super.setRGB(t,n,i),this.a=s}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}};function Ft(r,e){let t;if(typeof r=="string"){let n=e?.getColor(r);n?t=n:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new Ln(0,0,0,0))}else return"a"in r?new Ln(r.r,r.g,r.b,r.a):new Ln(r.r,r.g,r.b,1);return t}var Us=r=>"isEntity"in r,Ut=r=>"isAbstractMesh"in r,bt=r=>r!==null&&r.isBooleanMesh,l1=r=>r.objectType==="CombinedCamera",c1=r=>Us(r)&&(r.objectType==="LightDirectional"||r.objectType==="LightSpot"||r.objectType==="LightPoint");var oy=r=>r.objectType==="EmptyObject",Xi=r=>"objectHelper"in r;function ay(r,e){let t=!1;e.position&&(r.position.fromArray(e.position),t=!0),e.rotation&&(r.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,r.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in r&&(t=!0,r.hiddenMatrix.fromArray(e.hiddenMatrix??di.identity)),t&&(r.updateMatrix(),bt(r.parent)&&Ut(r)&&r.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&r.updateWorldMatrix(!1,!0),r.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(r.isUpVectorFlipped=e.isUpVectorFlipped),r.updateUp())}function JB(r,e){ay(r,e),e.name!==void 0&&(r.name=e.name),e.visible!==void 0&&(r.isEntity?r.visibility=e.visible:r.visible=e.visible)}function h1(r,e,t){JB(r,e),e.color!==void 0&&(r.color=Ft(e.color,t)),e.intensity!==void 0&&(r.intensity=e.intensity),e.shadows!==void 0&&!(r instanceof fo)&&(r.castShadow=e.shadows),r.shadow&&!(r instanceof fo)&&e.depth!==void 0&&(r.shadow.camera.far=e.depth,r.shadow.needsUpdate=!0),e.helper!==void 0&&Xi(r)&&(r.enableHelper=e.helper,r.gizmos.shadowmap.visible=e.helper)}function u1(r,e){r.shadow.camera.right=e/2,r.shadow.camera.left=-e/2,r.shadow.camera.top=e/2,r.shadow.camera.bottom=-e/2,r.shadow.needsUpdate=!0}var cl=new Sn,xi=new A,bi=new A,hl=new Oe,f1=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],$B=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],eO=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function tO(r,e,t=0,n=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let h=t;h<n;h++){let u=e.getX(h),d=e.getY(h),f=e.getZ(h);u<i&&(i=u),d<s&&(s=d),f<o&&(o=f),u>a&&(a=u),d>l&&(l=d),f>c&&(c=f)}return r.min.set(i,s,o),r.max.set(a,l,c),r}var d1=(r,e,t,n)=>{if(Ut(r)){let i=r.geometry.userData.parameters,s=r.geometry.getAttribute("position");r.geometry.userData.type==="SubdivGeometry"?xi.copy(r.originalGeometry.boundingSphere.center):s!==void 0&&(tO(cl,s,r.geometry.drawRange.start,r.geometry.drawRange.count<1/0?r.geometry.drawRange.count:s.count),cl.getCenter(xi)),r.forceComputeSize?cl.getSize(bi).multiplyScalar(.5):bi.set(i.width,i.height,i.depth??0).multiplyScalar(.5)}else if(Xi(r)&&n===!0){let i=r.geometryHelper.getAttribute("position");cl.setFromArray(i.array),cl.getCenter(xi),cl.getSize(bi).multiplyScalar(.5)}else xi.setScalar(0),bi.setScalar(0);hl.copy(e).multiply(r.matrixWorld),bi.x===0&&bi.y===0&&bi.z===0?t.push(new A(xi.x,xi.y,xi.z).applyMatrix4(hl)):f1.forEach(i=>{t.push(i.clone().multiply(bi).add(xi).applyMatrix4(hl))})},rh=class extends Sn{constructor(){super(...arguments);this.matrix=new Oe;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(n=>n.clone()),this.faces=t.faces.map(n=>n.clone()),this.edges=t.edges.map(n=>n.clone()),this.centerEdges=t.centerEdges.map(n=>n.clone()),this}setFromObjectSize(t,n=!1){t.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new Oe().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,n)}expandByObjectSize(t,n,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&d1(o,n,s,t.enableHelper===!0)}):d1(t,n,s,t.enableHelper===!0),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(hl.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(bi).multiplyScalar(.5),this.getCenter(xi),hl.copy(this.matrix).setPosition(xi),this.vertices=f1.map(t=>t.clone().multiply(bi).applyMatrix4(hl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=$B.map(([t,n])=>new Cu(this.vertices[t],this.vertices[n])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=eO.map(([t,n])=>this.vertices[t].clone().add(this.vertices[n]).multiplyScalar(.5))}};var of=r=>class extends r{hasEntityChild(){return this.children.some(t=>Us(t))}isDescendantOf(t){t instanceof ct&&(t=t.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===t)return!0;n=n.parent}return!1}attach(t,n){this.updateWorldMatrix(!0,!1);let i=new Oe().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Us(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),n!==void 0&&(this.children.pop(),this.children.splice(n,0,t)),this}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}};var Cr=r=>"isEntity"in r,p1=r=>"isAbstractMesh"in r,Dr=r=>class extends of(r){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Oe;this._singleBBox=new rh;this._recursiveBBox=new rh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(n){this.visible=n;for(let i of this.children)Cr(i)&&i.traverseEntity(s=>{Xi(s)&&s.visible&&(s.objectHelper.visible=n)})}get visibility(){return this.visible}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(n=>{Cr(n)&&(n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(n=>{n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0})}traverseEntity(n){n(this);for(let i of this.children)Cr(i)&&i.traverseEntity(n)}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}shallowClone(n){return new this.constructor().shallowCopy(this,n)}shallowCopy(n,i=!0){if(super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),i===!0)for(let s of n.children)Cr(s)&&this.add(s.shallowClone());return this}clone(n){return new this.constructor().copy(this,n)}copy(n,i=!0){if(super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),i===!0)for(let s of n.children)Cr(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let n=new Oe,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),n.copy(this.matrixWorld).invert(),n.multiply(i);for(let s of this.children)Cr(s)&&s.hiddenMatrix.premultiply(n)}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ja(i,n)}fromObjectTransformState(n){return n.position&&this.position.fromArray(n.position),n.rotation&&this.rotation.fromArray(n.rotation),n.scale&&this.scale.fromArray(n.scale),n.hiddenMatrix&&this.hiddenMatrix.fromArray(n.hiddenMatrix),this.updateMatrix(),this}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return ja(i,n)}fromState(n,i){return n.name&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.type!=="OrthographicCamera"&&n.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),n.visible!==void 0&&(this.visibility=n.visible),this.fromObjectTransformState(n),this}};var ih=class extends ct{constructor(t,n={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=wd.defaultData(i.toArray(),s),xo(this.parameters,n),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let t of this.children)t.material=this.object.material}refreshClonerMasks(){for(let t of this.children)t.layers.mask=this.object.layers.mask}setHideBase(t){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let n of this.object.material)n.visible=!0;if(t){let n=this.object.material;for(let i of this.children)i.material=n}else for(let n of this.children)n.material=this.object.material}for(let n of this.object.material)n.visible=!t}else{if(this.children.length>0)if(this.object.material.visible=!0,t){let n=this.object.material;for(let i of this.children)i.material=n}else for(let n of this.children)n.material=this.object.material;this.object.material.visible=!t}this.parameters.hideBase=t}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let n=0,i=t-this.children.length;n<i;++n){let s=this.object.shallowClone(!1);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let n=0,i=this.children.length-t;n<i;++n)this.remove(this.children[0])}_updateRadial(t){let n=t.radial,i=n.start*Ge.DEG2RAD,s=n.end*Ge.DEG2RAD,o=i-s,a=new br(n.rotation[0]*Ge.DEG2RAD,n.rotation[1]*Ge.DEG2RAD,n.rotation[2]*Ge.DEG2RAD),l;switch(n.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[c,h]of this.children.entries()){h.hiddenMatrix.identity(),h.scale.x=n.scale[0],h.scale.y=n.scale[1],h.scale.z=n.scale[2],h.position.setScalar(0);let u=o/t.count*c-i;switch(n.axis){case"x":h.rotation.set(0,u,0);break;case"y":h.rotation.set(0,0,u);break;case"z":h.rotation.set(u,0,0);break}h.translateOnAxis(l,n.radius),h.position.x+=n.position[0],h.position.y+=n.position[1],h.position.z+=n.position[2],n.alignment===!0?(h.rotation.x+=a.x,h.rotation.y+=a.y,h.rotation.z+=a.z):h.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let n=t.linear,i=new br(n.rotation[0]*Ge.DEG2RAD,n.rotation[1]*Ge.DEG2RAD,n.rotation[2]*Ge.DEG2RAD);for(let[s,o]of this.children.entries())o.hiddenMatrix.identity(),o.scale.x=1+(n.scale[0]-1)*s,o.scale.y=1+(n.scale[1]-1)*s,o.scale.z=1+(n.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=n.position[0]*s,o.position.y=n.position[1]*s,o.position.z=n.position[2]*s}_updateGrid(t){let n=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let h=this.children[n++];h.hiddenMatrix.identity(),h.scale.setScalar(1),h.rotation.set(0,0,0),h.position.x=i.size[0]*a-o.x,h.position.y=i.size[1]*l-o.y,h.position.z=i.size[2]*c-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[n++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),xo(this.parameters,t),this.update(),this}};var zt=class{constructor(e,t,n,i){this.next=void 0;this.uniforms={};this.textures={};this.defines={};if(this.id=e,this.uuid=t,n){this.type=n.type;for(let s in n)s!=="type"&&s!=="calpha"&&(this.uniforms[`f${this.id}_${s}`]=n[s]);for(let s in i)this.defines[s]=i[s]}}copy(e){this.id=e.id,this.type=e.type,this.defines={...e.defines};for(let t in e.uniforms)this.getName(t)==="transmissionSamplerMap"||this.getName(t)==="transmissionDepthMap"||this.getName(t)==="normalMap"||this.getName(t)==="depthMap"||(this.uniforms[t]?this.uniforms[t].copy(e.uniforms[t]):this.uniforms[t]=e.uniforms[t].clone());return this}clone(){return new zt(this.id).copy(this)}copyUniforms(e){for(let t in this.uniforms){let n=this.getName(t);n!==void 0&&e.uniforms[`f${e.id}_${n}`]&&n!=="transmissionDepthMap"&&n!=="transmissionSamplerMap"&&this.uniforms[t].copy(e.uniforms[`f${e.id}_${n}`])}return this}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let n=`f${this.id}_${e}`;this.hasValueByKey(n)&&t!==void 0&&(this.uniforms[n].value=t)}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getValues(){let e={type:this.type};for(let t in this.uniforms){let n=this.getName(t);if(n===void 0)continue;let s=this.uniforms[`f${this.id}_${n}`].value;s!==void 0&&(Array.isArray(s)?e[n]=s.map(o=>o.clone?o.clone():o):e[n]=s.clone?s.clone():s)}return e}getName(e){let n=/f\d+_(.*)/.exec(e);if(n&&n.length>1)return n[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let n=this.getName(t);n&&e.push(n)}return e}isEqual(e){for(let t in e.uniforms){let n=e.getName(t);if(!n)return!1;let i=this.getValue(n),s=e.uniforms[t].value;if(s.value instanceof Bt){if(i.image!==s.image)return!1}else if(Array.isArray(s)){let o=i;for(let a=0,l=o.length;a<l;++a)if(o[a]!==s[a])return!1}else{let o=i;if(o.equals){if(!o.equals(s))return!1}else if(i!==s)return!1}}return!0}dispose(){}};function m1(r){let e=r instanceof zt?r.type:r;return e==="texture"||e==="displace_map"||e==="matcap"}var ke=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Ge.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n??{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n??{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t??this.getType(e,t);let i=e.getNodeData(n??this);return e.analyzing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,s,o){return""}generate(e,t,n,i,s){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,n;for(t in this)n=this[t],n instanceof ke&&(e+='"'+t+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)t=this.hashProperties[i],n=this[t],e+='"'+t+'":"'+String(n)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}};var ze=class extends ke{constructor(t,n){super(t);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(t,n,i,s){if(n=n??this.getType(t),this.getShared(t,n)){let o=this.getUnique(t,n);o&&this.uuid===void 0&&(this.uuid=Ge.generateUUID()),i=t.getUUID(i??this.getUUID(),!o);let a=t.getNodeData(i),l=a.output||this.getType(t);if(t.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(t,a,n),this.generate(t,n,i)):super.build(t,n,i);if(o)return a.name=a.name||super.build(t,n,i),a.name;if(!this.getLabel()&&(!this.getShared(t,l)||t.context.ignoreCache||a.deps===1))return super.build(t,n,i);i=this.getUUID(!1);let c=this.getTemp(t,i);if(c)return t.format(c,l,n);{c=super.generate(t,n,i,a.output,s);let h=this.generate(t,l,i);return t.addNodeCode(c+" = "+h+";"),t.format(c,l,n)}}return super.build(t,n,i)}getShared(t,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(t,n){return this.unique}setLabel(t){return this.label=t,this}getLabel(){return this.label}getUUID(t){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(t,n){n=n||this.uuid;let i=t.getVars()[n];return i?i.name:void 0}generate(t,n,i,s,o){return this.getShared(t,n)||console.error("TempNode is not shared"),i=i??this.uuid,t.getTempVar(i,s??this.getType(t),o,this.getLabel()).name}};var Pt=class extends ze{constructor(t,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(t,n);this.readonly=!1}setReadonly(t){return this.readonly=t,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(t,n,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(t,n,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,n))}copy(t){return super.copy(t),this.readonly=t.readonly,this}};var xt=class extends Pt{constructor(t=0,n,i,s){super("c");this.nodeType="Color";this.value=t instanceof Ln?t:new Ln(t||0,n,i,s)}setRGBA(t){this.value.setRGBA(t.r,t.g,t.b,t.a)}generate(t,n,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let h=this.alpha.build(t,"f");t.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${h};`)}return c?this.generateReadonly(t,n,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,n))}generateReadonly(t,n,i,s,o,a){return t.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",s,n)}};var _e=class extends Pt{constructor(t){super("f");this.nodeType="Float";this.value=t??0}generateReadonly(t,n,i,s,o,a){return t.format(this.value+(this.value%1?"":".0"),s,n)}copy(t){return super.copy(t),this.value=t.value,this}};var nt=class extends Pt{constructor(t){super("i");this.nodeType="Int";this.value=Math.floor(t??0)}generateReadonly(t,n,i,s,o,a){return t.format(this.value.toString(),s,n)}copy(t){return super.copy(t),this.value=t.value,this}};var zs=class extends Pt{constructor(t){super("b");this.nodeType="Bool";this.value=t??!1}generateReadonly(t,n,i,s){return t.format(this.value?"true":"false",s,n)}copy(t){return super.copy(t),this.value=t.value,this}};var mn=class extends Pt{constructor(t=0,n){super("v2");this.nodeType="Vector2";this.value=t instanceof B?t:new B(t,n)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}generateReadonly(t,n,i,s,o,a){return t.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var Tn=class extends Pt{constructor(t=0,n,i){super("v3");this.nodeType="Vector3";this.value=t instanceof A?t:new A(t,n,i)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}get z(){return this.value.z}set z(t){this.value.z=t}generateReadonly(t,n,i,s,o,a){return t.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var Pr=class extends Pt{constructor(t){super("v4");this.nodeType="Vector4";this.value=t instanceof Ln?t:new Ln(t.r,t.g,t.b,t.a)}generateReadonly(t,n,i,s,o,a){return t.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}copy(t){return super.copy(t),this.value.copy(t.value),this}};var Yr=class extends Pt{constructor(t=1,n){super("v4[]");this.nodeType="Vector4Array";this.size=t,this.value=Array.isArray(n)?n:n instanceof qe?new Array(t).fill(n):new Array(t).fill(new qe(0))}copy(t){return super.copy(t),this.value=t.value.map(n=>n.clone()),this}};var gn=class extends Pt{constructor(t=1,n){super("f[]");this.nodeType="FloatArray";this.size=t,this.value=Array.isArray(n)?n:typeof n=="number"?new Array(t).fill(n):new Array(t).fill(0)}copy(t){return super.copy(t),this.size=t.size,this.value=[...t.value],this}};var ly=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=n!==void 0?n:!0,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},yn=new ly;var ul=class extends ze{constructor(t){super("v2",{shared:!1});this.nodeType="UV";this.index=t??0}generate(t,n){t.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=t.isShader("vertex")?"uv"+i:"vUv"+i;return t.format(s,this.getType(t),n)}copy(t){return super.copy(t),this.index=t.index,this}};yn.addKeyword("uv",function(){return new ul});yn.addKeyword("uv2",function(){return new ul(1)});var nO=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,g1=/[a-z_0-9]+/gi,Te=class extends ze{constructor(t,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(t,n,i,s)}getShared(t,n){return!this.isMethod}getType(t){return t.getTypeByFormat(this.type)}getInputByName(t){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}}getIncludeByName(t){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===t)return this.includes[n]}}generate(t,n,i,s,o){let a,l=0,c=this.src;if(this.includes)for(let u=0;u<this.includes.length;u++)t.include(this.includes[u],this);for(let u in this.extensions)t.extensions[u]=!0;let h=[];for(;a=g1.exec(this.src);)h.push(a);for(let u=0;u<h.length;u++){let d=h[u],f=d[0],m=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&m&&yn.containsKeyword(f)){let g=this.keywords[f];if(!g){let x=yn.getKeywordData(f);x.cache&&(g=t.keywords[f]),g=g||yn.getKeyword(f,t),x.cache&&(t.keywords[f]=g)}p=g.build(t)}f!==p&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+p+c.substring(d.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&yn.contains(p)&&t.include(yn.get(p))}return n==="source"?c:this.isMethod?(this.isInterface||t.include(this,void 0,c),this.name):t.format("( "+c+" )",this.getType(t),n)}parse(t,n,i,s){if(this.src=t||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=nO.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(g1);if(a){let l=0;for(;l<a.length;){let c=a[l++],h;c==="in"||c==="out"||c==="inout"?h=a[l++]:(h=c,c="");let u=a[l++];this.inputs.push({name:u,type:h,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(t){return super.copy(t),this.isMethod=t.isMethod,this.useKeywords=t.useKeywords,t.type!==void 0&&(this.type=t.type),this.parse(t.src,t.includes,t.extensions,t.keywords),this}};var _o=class extends ze{constructor(t=new ke,n){super("v4");this.nodeType="ColorSpace";this.factor=new ke;this.input=t,this.method=n??_o.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(t){switch(t){case lr:return["Linear"];case We:return["sRGB"];default:return[]}}generate(t,n){let i=this.input.build(t,"v4"),s=this.getType(t),o=_o.Nodes[this.method],a=t.include(o);if(a===_o.LINEAR_TO_LINEAR)return t.format(i,s,n);if(o.inputs?.length===2){let l=this.factor.build(t,"f");return t.format(a+"( "+i+", "+l+" )",s,n)}else return t.format(a+"( "+i+" )",s,n)}fromEncoding(t){let n=_o.getEncodingComponents(t);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(t){let n=_o.getEncodingComponents(t);this.method=n[0]+"ToLinear",this.factor=n[1]}copy(t){return super.copy(t),this.input.copy(t.input),this.method=t.method,this.factor.copy(t.factor),this}},Yn=_o;Yn.Nodes={LinearToLinear:new Te(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3138
3138
|
`)),sRGBToLinear:new Te(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
3139
3139
|
`)),LinearTosRGB:new Te(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
|
|
3140
|
-
`))},Yn.LINEAR_TO_LINEAR="LinearToLinear",Yn.SRGB_TO_LINEAR="sRGBToLinear",Yn.LINEAR_TO_SRGB="LinearTosRGB";var _t=class extends Te{constructor(t="",n,i,s,o){super(t,o,s,i,n);this.nodeType="Expression"}};var
|
|
3140
|
+
`))},Yn.LINEAR_TO_LINEAR="LinearToLinear",Yn.SRGB_TO_LINEAR="sRGBToLinear",Yn.LINEAR_TO_SRGB="LinearTosRGB";var _t=class extends Te{constructor(t="",n,i,s,o){super(t,o,s,i,n);this.nodeType="Expression"}};var Lr=class extends Bt{toJSON(e){let t=super.toJSON(e),n=e===void 0||typeof e=="string";if(this.image!==void 0&&!n){let i=this.image;if(Array.isArray(i)){e.images[i.uuid].url=[];for(let s=0;s<i.length;s++)e.images[i.uuid].url[s]=y1(i[s])}else e.images[i.uuid].url=y1(i)}return t}};function y1(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?rO(r):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var dl;function rO(r){if(/^data:/i.test(r.src))return r.src;let e;if(r instanceof HTMLCanvasElement)e=r;else{dl===void 0&&(dl=document.createElement("canvas")),dl.width=r.width,dl.height=r.height;let n=dl.getContext("2d");r instanceof ImageData?n.putImageData(r,0,0):n.drawImage(r,0,0,r.width,r.height),e=dl}let t=r.src.startsWith("blob:")?r.fileName:r.src;return/\.jpe?g$/i.test(t)?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}var vn=class extends Pt{constructor(t=new Lr,n,i,s){super("v4",{shared:!0});this.nodeType="Texture";this.value=t,this.uv=n??new ul,this.bias=i,this.project=s!==void 0?s:!1}getTexture(t,n){return super.generate(t,n,this.value.uuid,"t")}generate(t,n){if(n==="sampler2D")return this.getTexture(t,n);let i=this.getTexture(t,n),s=this.uv.build(t,this.project?"v4":"v2"),o=this.bias?this.bias.build(t,"f"):void 0;o===void 0&&t.context.bias&&(o=t.context.bias.setTexture(this).build(t,"f"));let a,l;this.project?a="texture2DProj":a=o?"tex2DBias":"tex2D",o?l=a+"( "+i+", "+s+", "+o+" )":l=a+"( "+i+", "+s+" )";let c={include:t.isShader("vertex"),ignoreCache:!0},h=this.getType(t);return t.addContext(c),this.colorSpace=this.colorSpace??new Yn(new _t("",h)),this.colorSpace.fromDecoding(t.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(t,h),t.removeContext(),t.format(l,h,n)}copy(t){return super.copy(t),t.value.isRenderTargetTexture?this.value=t.value:this.value.copy(t.value),this.uv.copy(t.uv),t.bias?this.bias?this.bias.copy(t.bias):this.bias=t.bias.clone():this.bias=void 0,t.colorSpace?this.colorSpace?this.colorSpace.copy(t.colorSpace):this.colorSpace=t.colorSpace.clone():this.colorSpace=void 0,this.project=t.project,t.value.isRenderTargetTexture||(this.value.updateMatrix(),this.value.needsUpdate=!0),this}};var fl=class extends Pt{constructor(t){super("m3");this.nodeType="Matrix3";this.value=t??new qt}generateReadonly(t,n,i,s,o,a){return t.format("mat3("+this.value.elements.join(", ")+")",s,n)}copy(t){return super.copy(t),this.elements=t.elements,this}get elements(){return this.value.elements}set elements(t){this.value.fromArray(t)}};var oh=class extends ze{constructor(t=new vn,n,i,s,o,a,l,c,h){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=t,this.textureSize=n,this.crop=i,this.projection=s,this.axis=o,this.side=a,this.size=l,this.mat=new fl(this.texture.value.matrix),this.alpha=c,this.mode=h,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(t,n){t.require("position"),t.require("normal"),t.require("uv"),t.requires.uv=[!0],t.extensions.shaderTextureLOD=!0,t.extensions.derivatives=!0;let i=`g${this.uuid.toString().replace(/-/g,"")}`,s;switch(this.projection.value){case 3:s=t.include(oh.Nodes.cylindrical);break;case 2:s=t.include(oh.Nodes.spherical);break;case 1:let a=["vec3(1.0, 0.0, 0.0)","vec3(0.0, 1.0, 0.0)","vec3(0.0, 0.0, 1.0)"][this.axis.value],l=new Te(`
|
|
3141
3141
|
vec3 ${i}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
|
|
3142
3142
|
|
|
3143
3143
|
vec2 uvs = ( mat * vec3( (${i}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
|
|
@@ -3512,28 +3512,32 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
3512
3512
|
|
|
3513
3513
|
#if (NUM_POINT_LIGHTS > 0)
|
|
3514
3514
|
|
|
3515
|
+
#if defined(USE_SHADOWMAP) && (NUM_POINT_LIGHT_SHADOWS > 0)
|
|
3516
|
+
PointLightShadow pointLightShadow;
|
|
3517
|
+
#endif
|
|
3518
|
+
|
|
3515
3519
|
#pragma unroll_loop_start
|
|
3516
3520
|
for (int i = 0; i < NUM_POINT_LIGHTS; i++) {
|
|
3517
3521
|
// Light positions are in view-space for some reason?
|
|
3518
|
-
lpos = (inverse(viewMatrix) * vec4(pointLights[
|
|
3522
|
+
lpos = (inverse(viewMatrix) * vec4(pointLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
|
|
3519
3523
|
l = normalize(lpos - worldPosition);
|
|
3520
3524
|
|
|
3521
3525
|
dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
|
|
3522
3526
|
|
|
3523
3527
|
// TODO: we want to use "intensity" but it isn't available in the shader code
|
|
3524
|
-
//dproduct += dot(pointLights[
|
|
3528
|
+
//dproduct += dot(pointLights[UNROLLED_LOOP_INDEX].color, weights);
|
|
3525
3529
|
|
|
3526
3530
|
t = max(t, dproduct);
|
|
3527
3531
|
|
|
3528
3532
|
// Accumulate shadow contribution
|
|
3529
3533
|
#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS)
|
|
3530
|
-
|
|
3534
|
+
pointLightShadow = pointLightShadows[UNROLLED_LOOP_INDEX];
|
|
3531
3535
|
shadow *= getPointShadow(
|
|
3532
|
-
pointShadowMap[
|
|
3536
|
+
pointShadowMap[UNROLLED_LOOP_INDEX],
|
|
3533
3537
|
pointLightShadow.shadowMapSize,
|
|
3534
3538
|
pointLightShadow.shadowBias,
|
|
3535
3539
|
pointLightShadow.shadowRadius,
|
|
3536
|
-
vPointShadowCoord[
|
|
3540
|
+
vPointShadowCoord[UNROLLED_LOOP_INDEX],
|
|
3537
3541
|
pointLightShadow.shadowCameraNear,
|
|
3538
3542
|
pointLightShadow.shadowCameraFar);
|
|
3539
3543
|
#endif
|
|
@@ -3544,24 +3548,28 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
3544
3548
|
|
|
3545
3549
|
#if NUM_DIR_LIGHTS > 0
|
|
3546
3550
|
|
|
3551
|
+
#if defined(USE_SHADOWMAP) && (NUM_DIR_LIGHT_SHADOWS > 0)
|
|
3552
|
+
DirectionalLightShadow directionalLightShadow;
|
|
3553
|
+
#endif
|
|
3554
|
+
|
|
3547
3555
|
#pragma unroll_loop_start
|
|
3548
3556
|
for (int i = 0; i < NUM_DIR_LIGHTS; i++) {
|
|
3549
3557
|
// Use the direction vector for directional lights instead
|
|
3550
|
-
l = (inverse(viewMatrix) * vec4(directionalLights[
|
|
3558
|
+
l = (inverse(viewMatrix) * vec4(directionalLights[UNROLLED_LOOP_INDEX].direction, 0.0)).xyz;
|
|
3551
3559
|
|
|
3552
3560
|
dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
|
|
3553
3561
|
t = max(t, dproduct);
|
|
3554
3562
|
|
|
3555
3563
|
// Accumulate shadow contribution
|
|
3556
3564
|
#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS)
|
|
3557
|
-
|
|
3565
|
+
directionalLightShadow = directionalLightShadows[UNROLLED_LOOP_INDEX];
|
|
3558
3566
|
shadow *= getShadow(
|
|
3559
3567
|
UNROLLED_LOOP_INDEX,
|
|
3560
|
-
directionalShadowMap[
|
|
3568
|
+
directionalShadowMap[UNROLLED_LOOP_INDEX],
|
|
3561
3569
|
directionalLightShadow.shadowMapSize,
|
|
3562
3570
|
directionalLightShadow.shadowBias,
|
|
3563
3571
|
directionalLightShadow.shadowRadius,
|
|
3564
|
-
vDirectionalShadowCoord[
|
|
3572
|
+
vDirectionalShadowCoord[UNROLLED_LOOP_INDEX]);
|
|
3565
3573
|
#endif
|
|
3566
3574
|
}
|
|
3567
3575
|
#pragma unroll_loop_end
|
|
@@ -3569,10 +3577,14 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
3569
3577
|
#endif
|
|
3570
3578
|
|
|
3571
3579
|
#if NUM_SPOT_LIGHTS > 0
|
|
3580
|
+
|
|
3581
|
+
#if defined(USE_SHADOWMAP) && (NUM_SPOT_LIGHT_SHADOWS > 0)
|
|
3582
|
+
SpotLightShadow spotLightShadow;
|
|
3583
|
+
#endif
|
|
3572
3584
|
|
|
3573
3585
|
#pragma unroll_loop_start
|
|
3574
3586
|
for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {
|
|
3575
|
-
lpos = (inverse(viewMatrix) * vec4(spotLights[
|
|
3587
|
+
lpos = (inverse(viewMatrix) * vec4(spotLights[UNROLLED_LOOP_INDEX].position, 1.0)).xyz;
|
|
3576
3588
|
l = normalize(lpos - worldPosition);
|
|
3577
3589
|
|
|
3578
3590
|
dproduct = dot(l, normalize(worldNormal)) * 0.5 + 0.5;
|
|
@@ -3580,14 +3592,14 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
|
|
|
3580
3592
|
|
|
3581
3593
|
// Accumulate shadow contribution
|
|
3582
3594
|
#if defined(USE_SHADOWMAP) && (UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS)
|
|
3583
|
-
|
|
3595
|
+
spotLightShadow = spotLightShadows[UNROLLED_LOOP_INDEX];
|
|
3584
3596
|
shadow *= getShadow(
|
|
3585
3597
|
UNROLLED_LOOP_INDEX,
|
|
3586
|
-
spotShadowMap[
|
|
3598
|
+
spotShadowMap[UNROLLED_LOOP_INDEX],
|
|
3587
3599
|
spotLightShadow.shadowMapSize,
|
|
3588
3600
|
spotLightShadow.shadowBias,
|
|
3589
3601
|
spotLightShadow.shadowRadius,
|
|
3590
|
-
vSpotShadowCoord[
|
|
3602
|
+
vSpotShadowCoord[UNROLLED_LOOP_INDEX]);
|
|
3591
3603
|
#endif
|
|
3592
3604
|
}
|
|
3593
3605
|
#pragma unroll_loop_end
|
|
@@ -4075,7 +4087,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
4075
4087
|
|
|
4076
4088
|
return matcapColor.rgb;
|
|
4077
4089
|
}
|
|
4078
|
-
`)}}();var gl=class{constructor(e){this.id=2,this.layerCount=2,this.uuid=Ge.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];let t=this._createLayer({id:0,type:"color"});this._material.color=t.color,this._material.alpha===void 0&&(this._material.alpha=new _e(1));let n=new _e(1),i=new nt(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=n,this._material.shadingBlend=i),this._layerNodes.push({id:0,type:"color",color:t.color,alpha:t.alpha,mode:t.mode}),this._layerNodes.push({id:1,type:"light",alpha:n,mode:i}),this.head=t.layer,this.head.next=new zt(1,void 0,{type:"light",alpha:n,mode:i}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(e){this._material=e;let t,n,i=this.head;for(;i!==void 0;){if(i.type==="light"){t=i.uniforms[`f${i.id}_alpha`],n=i.uniforms[`f${i.id}_mode`];break}i=i.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=t,this._material.shadingBlend=n),this.attachLightNodes(e.userData.layers?.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(e){let t=[],n=this.head;for(;n;)n.type===e&&t.push(n),n=n.next;return t}addLayer(e){if(e.id=e.id??++this.id,this.layerCount++,e.type==="light"){let i=this.createLightLayer(e);return this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),i}let t=this._createLayer(e),n=t.layer;if(this.head===void 0)this.head=n;else{let i=this.head;for(;i.next!=null;)i=i.next;i.next=n}return t.color&&this._layerNodes.push({id:n.id,type:"color",color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&this._layerNodes.push({id:n.id,type:"position",position:t.position}),this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}addLayerBeforeAt(e,t){let n=this.head;e.id=e.id??++this.id,this.layerCount++;let i=this._createLayer(e),s=i.layer;s.next=t;let o=0;if(n===t)this.head=s,i.color&&this._layerNodes.splice(0,0,{id:s.id,type:"color",color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(0,0,{id:s.id,type:"position",position:i.position});else{for(o=1;n?.next!==t;)n=n?.next,o++;n.next=s,i.color&&this._layerNodes.splice(o,0,{id:s.id,type:"color",color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(o,0,{id:s.id,type:"position",position:i.position})}return this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}addLayerAt(e,t){t.id=t.id??++this.id,this.layerCount++;let n=this._createLayer(t),i=n.layer;if(n.color&&this._layerNodes.splice(e,0,{id:i.id,type:"color",color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(e,0,{id:i.id,type:"position",position:n.position}),e==0)i.next=this.head,this.head=i;else{let s=this.head,o=this.head.next;for(let a=0;a<e-1;a++)s=o,o=o.next;i.next=o,s.next=i}return this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),i}removeLayer(e){let t=this.head,n,i=0;if(t?.id==e)this.head=t.next;else for(i=1,n=t,t=t?.next;t!=null;){if(t.id==e){n.next=t.next;break}i++,n=t,t=t.next}return this.cleanupChangedLayer(t),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=Ge.generateUUID(),this.layerCount--,i}changeLayer(e,t){let n,i=this.head,s;if(i?.id==e){let o=this._createLayer({id:e,uuid:i.uuid,...t});s=o.layer,s.next=i.next,this.head=s,o.color&&(this._layerNodes[0]={id:s.id,type:"color",color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&(this._layerNodes[0]={id:s.id,type:"position",position:o.position}),s.uniforms[`f${e}_mode`].value=i.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=i.uniforms[`f${e}_alpha`].value}else{n=i,i=i.next;let o=1;for(;i!=null;){if(i.id==e){let a=this._createLayer({id:e,uuid:i.uuid,...t});s=a.layer,n.next=s,s.next=i.next,a.color&&(this._layerNodes[o]={id:e,type:"color",color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[o]={id:e,type:"position",position:a.position}),s.uniforms[`f${e}_mode`].value=i.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=i.uniforms[`f${e}_alpha`].value;break}n=i,i=i.next,o++}}return this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}getLayer(e){let t=this.head;for(;t!=null&&t.id!=e;)t=t.next;return t}getLayerByUuid(e){let t=this.head;for(;t!==void 0;){if(t.uuid===e)return t;t=t.next}}getLayers(){let e=[],t=this.head;for(;t!=null;)e.push(t),t=t.next;return e}getLayerPosition(e){let t=this.head,n=0;for(;t!==void 0&&t.id!=e;)n++,t=t.next;return n}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(e,t){let n,i=this.head,s;if(e==0)n=this.head,this.head=n.next;else{for(let a=0;a<e;a++)s=i,i=i.next;s.next=i.next,n=i}if(i=this.head,s=void 0,t==0)n.next=this.head,this.head=n;else{for(let a=0;a<t-1;a++)i=i.next;n.next=i?.next,i.next=n}let o=this._layerNodes.splice(e,1)[0];this._layerNodes.splice(t,0,o),this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(e){this.needsUpdate=!1,this.layerCount=e.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,e.head);let t=e.head,n=this.head;for(;t.next!=null;)this.rebuildLayerNodes(n,t.next),n=n.next,t=t.next;return this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(e){let t=new _e(e.alpha),n=new nt(e.mode);this._material.shadingAlpha=t,this._material.shadingBlend=n,this._layerNodes.push({id:e.id,type:"light",alpha:t,mode:n});let i=new zt(e.id,void 0,{type:"light",alpha:t,mode:n});if(this.head===void 0)this.head=i;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=i}return this.attachLightNodes(this.getLightLayer()),i}rebuildLayerNodes(e,t,n=!1){if(t.type==="light"){let i=n?t.uniforms[`f${t.id}_alpha`]:new _e(t.uniforms[`f${t.id}_alpha`].value),s=n?t.uniforms[`f${t.id}_mode`]:new nt(t.uniforms[`f${t.id}_mode`].value);this._material.shadingAlpha=i,this._material.shadingBlend=s,this._layerNodes.push({id:t.id,type:"light",alpha:i,mode:s}),this.head===void 0?this.head=new zt(t.id,t.uuid,{type:"light",alpha:i,mode:s}):e&&(e.next=new zt(t.id,t.uuid,{type:"light",alpha:i,mode:s})),this.attachLightNodes(t)}else{let i={type:t.type,id:t.id};for(let s in t.uniforms){let o=t.getName(s);if(!o)continue;let a=`f${t.id}_${o}`;if(Array.isArray(t.uniforms[a].value))i[o]=t.uniforms[a].value.map(l=>l.clone&&!n?l.clone():l);else{let l=t.uniforms[a].value;if(o==="transmissionDepthMap"){i[o]=l;continue}l!=null&&(i[o]=l.clone&&!n&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(i)}}attachLightNodes(e){let t={},n=this.getLightLayer();switch(this._material.userData.category){case"Lambert":t.emissive=new xt(e?.getValue("emissive")?.clone()??0);break;case"Phong":t.shininess=new _e(e?.getValue("shininess")??30),t.specular=new xt(e?.getValue("specular")?.clone()??1118481);break;case"Toon":t.shininess=new _e(e?.getValue("shininess")??30),t.specular=new xt(e?.getValue("specular")?.clone()??1118481);break;case"Physical":t.roughness=new _e(e?.getValue("roughness")??.3),t.metalness=new _e(e?.getValue("metalness")??0),t.reflectivity=new _e(e?.getValue("reflectivity")??.5);break;default:break}Object.keys(t).forEach(i=>{this._material[i]=t[i],n.uniforms[`f${n.id}_${i}`]=t[i]})}clone(e){return new gl(e).copy(this)}getLightLayer(){let e=this.head;for(;e!==void 0&&e.type!=="light";)e=e.next??e;return e}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;e!==void 0;)e.hasOwnProperty("dispose")===!0&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){let t=e.type;switch(t){case"color":{let n=new xt(e.color??5855577),i=new _e(e.alpha??1),s=new _t("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=i;let o=new nt(e.mode??0);return n.alpha=i,{layer:new zt(e.id,e.uuid,{type:t,color:n,alpha:i,calpha:s,mode:o}),color:n,alpha:s,mode:o}}case"texture":{let n=e.texture??new Ir,i=n.matrix;e.mat&&i.copy(e.mat),n.needsUpdate=!0;let s=new _e(e.crop??0),o=new nt(e.projection??0),a=new nt(e.axis??0),l=new nt(e.side??0),c=new mn(e.size?new B(e.size[0],e.size[1]):new B(100,100)),h=new _e(e.alpha??1),u=new nt(e.mode??0),d=new vn(n),f=new Tn(e.textureSize??new A(n.image?n.image.width:0,n.image?n.image.height:0)),m=new sh(d,f,s,o,a,l,c,h,u),p=new _t(m.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,texture:d,textureSize:f,crop:s,projection:o,axis:a,side:l,size:c,mat:m.mat,alpha:h,calpha:p,mode:u}),color:m,alpha:p,mode:u}}case"matcap":{let n=e.texture??new Ir;n.needsUpdate=!0;let i=new _e(e.alpha??1),s=new vn(n),o=new nt(e.mode??0),a=new vh(s,i,o),l=new _t(a.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,texture:s,alpha:i,calpha:l,mode:o}),color:a,alpha:l,mode:o}}case"fresnel":{let n=new xt(e.color??16777215),i=new _e(e.bias??.1),s=new _e(e.scale??1),o=new _e(e.intensity??2),a=new _e(e.factor??1),l=new _e(e.alpha??1),c=new nt(e.mode??0),h=new ah(n,i,s,o,a,l,c),u=new _t(h.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,color:n,bias:i,scale:s,intensity:o,factor:a,alpha:l,calpha:u,mode:c}),color:h,alpha:u,mode:c}}case"rainbow":{let n=new _e(e.filmThickness??30),i=new _e(e.movement??0),s=new Tn(e.wavelengths??new A(0,0,0)),o=new _e(e.noiseStrength??0),a=new _e(e.noiseScale??1),l=new Tn(e.offset??new A(0,0,0)),c=new _e(e.alpha??1),h=new ch(n,i,s,o,a,l,c),u=new _t(h.calpha,"f"),d=new nt(e.mode??0);return{layer:new zt(e.id,e.uuid,{type:t,filmThickness:n,movement:i,wavelengths:s,noiseStrength:o,noiseScale:a,offset:l,alpha:c,calpha:u,mode:d}),color:h,alpha:u,mode:d}}case"toon":{let n=new nt(e.positioning??0),i;e.colors?i=new Yr(e.colors.length,e.colors):(i=new Yr(10,new qe(0,0,0,1)),i.value[1]=new qe(1,1,1,1));let s;e.steps?s=new gn(e.steps.length,e.steps):(s=new gn(10,1),s.value[0]=0);let o=new Tn(e.source??new A(0,0,0)),a=new zs(e.isWorldSpace??!0),l=new _e(e.noiseStrength??0),c=new _e(e.noiseScale??1),h=new Pr(e.shadowColor),u=new Tn(e.offset??new A(0,0,0)),d=new _e(e.alpha??1),f=new hh(n,i,s,o,a,l,c,h,u,d),m=new _t(f.calpha,"f"),p=new nt(e.mode??0);return{layer:new zt(e.id,e.uuid,{type:t,positioning:n,colors:i,steps:s,source:o,isWorldSpace:a,noiseStrength:l,noiseScale:c,shadowColor:h,offset:u,alpha:d,calpha:m,mode:p}),color:f,alpha:m,mode:p}}case"outline":{let n=new xt(e.outlineColor??16777215),i=new xt(e.contourColor??16777215),s=new _e(e.outlineWidth??.1),o=new _e(e.contourWidth??.1),a=new _e(e.outlineThreshold??.1),l=new _e(e.contourThreshold??.1),c=new _e(e.outlineSmoothing??.1),h=new _e(e.contourFrequency??.1),u=new Tn(e.contourDirections??new A(0,1,0)),d=new zs(e.positionalLines??!1),f=new zs(e.compensation??!0),m=e.normalMap??new Ir,p=new vn(m),g=e.depthMap??new Ir,x=new vn(g),v=e.pixelRatio??new _e(window.devicePixelRatio),w=e.resolution??new mn(new B(1,1)),b=new _e(e.alpha??1),S=new uh(n,i,s,o,a,l,c,h,u,d,f,w,p,x,v,b),M=new _t(S.calpha,"f"),_=new nt(e.mode??0);return{layer:new zt(e.id,e.uuid,{type:t,outlineColor:n,contourColor:i,outlineWidth:s,contourWidth:o,outlineThreshold:a,contourThreshold:l,outlineSmoothing:c,contourFrequency:h,contourDirection:u,positionalLines:d,compensation:f,resolution:w,normalMap:p,depthMap:x,pixelRatio:v,alpha:b,calpha:M,mode:_}),color:S,alpha:M,mode:_}}case"transmission":{let n=new _e(e.thickness??10),i=new _e(e.ior??1.5),s=new _e(e.roughness??.5),o=new mn(e.transmissionSamplerSize??new B(2048,2048)),a=e.transmissionSamplerMap??new Ir,l=e.transmissionDepthMap??new Ir,c=new vn(a),h=new vn(l),u=window.innerWidth,d=window.innerHeight,f=u>=d?new mn(d/u,1):new mn(1,u/d),m=new _e(e.alpha??1),p=new dh(n,i,s,o,c,h,f,m),g=new _t(p.calpha,"f"),x=new nt(e.mode??0);return{layer:new zt(e.id,e.uuid,{type:t,thickness:n,ior:i,roughness:s,transmissionSamplerSize:o,transmissionSamplerMap:c,transmissionDepthMap:h,aspectRatio:f,alpha:m,calpha:g,mode:x}),color:p,alpha:g,mode:x}}case"depth":{let n=new nt(e.gradientType??0),i=new zs(e.smooth??!1),s=new _e(e.near??50),o=new _e(e.far??200),a=new _e(e.isVector??1),l=new _e(e.isWorldSpace??0),c=new Tn(e.origin??new A),h=new Tn(e.direction??new A),u=new nt(e.num??0),d;e.colors?d=new Yr(u.value+1,e.colors):(d=new Yr(u.value+1,new qe(0,0,0,1)),d.value[1]=new qe(1,1,1,1));let f;e.steps?f=new gn(u.value+1,e.steps):(f=new gn(u.value+1,1),f.value[0]=0);let m=new _e(e.alpha??1),p=new nt(e.mode??0),g=new yh(n,i,s,o,a,l,c,h,d,f,u,m),x=new _t(g.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,gradientType:n,smooth:i,near:s,far:o,isVector:a,isWorldSpace:l,origin:c,direction:h,colors:d,steps:f,num:u,alpha:m,calpha:x,mode:p}),color:g,alpha:x,mode:p}}case"noise":{let n=new _e(e.scale??1),i=new Tn(e.size??new A(100,100,100)),s=new _e(e.move??1),o=new mn(e.fA??new B(1.7,9.2)),a=new mn(e.fB??new B(8.3,2.8)),l=new mn(e.distortion??new B(1,1)),c=new Pr(e.colorA),h=new Pr(e.colorB),u=new Pr(e.colorC),d=new Pr(e.colorD),f=new _e(e.alpha??1),m=new nt(e.mode??0),p=new nt(e.noiseType??0),g=new mh(n,i,s,o,a,l,c,h,u,d,f,p),x=new _t(g.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,scale:n,size:i,move:s,fA:o,fB:a,distortion:l,colorA:c,colorB:h,colorC:u,colorD:d,alpha:f,calpha:x,mode:m,noiseType:p}),color:g,alpha:x,mode:m}}case"normal":{let n=new Tn(e.cnormal??new A(1,1,1)),i=new _e(e.alpha??1),s=new nt(e.mode??0),o=new fh(n,i),a=new _t("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return a.keywords.alpha=i,{layer:new zt(e.id,e.uuid,{type:t,cnormal:n,alpha:i,calpha:a,mode:s}),color:o,alpha:a,mode:s}}case"gradient":{let n=new nt(e.gradientType??0),i=new zs(e.smooth??!1),s;e.colors?s=new Yr(e.colors.length,e.colors):(s=new Yr(10,new qe(0,0,0,1)),s.value[1]=new qe(1,1,1,1));let o;e.steps?o=new gn(e.steps.length,e.steps):(o=new gn(10,1),o.value[0]=0);let a=new mn(e.offset??new B(0,0)),l=new mn(e.morph??new B(0,0)),c=new _e(e.angle??0),h=new _e(e.alpha??1),u=new nt(e.mode??0),d=new ph(n,i,s,o,a,l,c,h),f=new _t(d.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,gradientType:n,smooth:i,colors:s,steps:o,offset:a,morph:l,angle:c,alpha:h,calpha:f,mode:u}),color:d,alpha:f,mode:u}}case"displace":{let n=new nt(e.displacementType??0);if(n.value===0){let i=new Tn(e.offset??new A(0,0,0)),s=new _e(e.scale??10),o=new _e(e.intensity??8),a=new _e(e.movement??1),l=new _e(e.alpha??1),c=new nt(e.mode??0),h=new nt(e.noiseType??0),u=new pl(n,o,a,i,s,h);return{layer:new zt(e.id,e.uuid,{displacementType:n,type:t,offset:i,scale:s,intensity:o,movement:a,alpha:l,mode:c,noiseType:h}),position:u}}else if(n.value===1){let i=e.texture??new Ir,s=i.matrix;e.mat&&s.copy(e.mat),i.needsUpdate=!0;let o=new _e(e.intensity??8),a=new vn(i),l=new _e(e.crop??0),c=new _e(e.alpha??1),h=new nt(e.mode??0),u=new pl(n,o,a,l);return{layer:new zt(e.id,e.uuid,{displacementType:n,type:t,intensity:o,texture:a,crop:l,mat:u.mat,alpha:c,mode:h}),position:u}}return{}}}return{}}blendColors(){let e=this._layerNodes.findIndex(n=>n.type==="color"),t=this._layerNodes.findIndex(n=>n.type==="light");if(e!==-1&&e<t){let n=this._layerNodes[e].color;for(let i=e+1;i<t;++i){let s=this._layerNodes[i];s.type==="color"&&(n=new gh(n,s.color,s.alpha,s.mode))}this._material.color=n}else this._material.color=void 0}blendAfterColors(){let e=new _t("outgoingLight","f"),t=this._layerNodes.findIndex(n=>n.type==="light");if(this._layerNodes.length>t+1){for(let n=t+1;n<this._layerNodes.length;++n){let i=this._layerNodes[n];i.type==="color"&&(e=new gh(e,i.color,i.alpha,i.mode))}"afterColor"in this._material&&(this._material.afterColor=e)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let e=this._layerNodes.filter(t=>t.type==="position");if(e.length>0){let t=e[0].position;for(let n=1;n<e.length;++n)e[n]&&(t=new rr(t,e[n].position,rr.ADD),t=new rr(t,new _e(.5).setReadonly(!0),rr.MUL));this._material.position=t}else this._material.position=void 0}cleanupChangedLayer(e){switch(this._layerNodes=this._layerNodes.filter(t=>t.id!==e.id),e.type){case"displace":{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var xh=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};var oO=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
4090
|
+
`)}}();var gl=class{constructor(e){this.id=2,this.layerCount=2,this.uuid=Ge.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];let t=this._createLayer({id:0,type:"color"});this._material.color=t.color,this._material.alpha===void 0&&(this._material.alpha=new _e(1));let n=new _e(1),i=new nt(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=n,this._material.shadingBlend=i),this._layerNodes.push({id:0,type:"color",color:t.color,alpha:t.alpha,mode:t.mode}),this._layerNodes.push({id:1,type:"light",alpha:n,mode:i}),this.head=t.layer,this.head.next=new zt(1,void 0,{type:"light",alpha:n,mode:i}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(e){this._material=e;let t,n,i=this.head;for(;i!==void 0;){if(i.type==="light"){t=i.uniforms[`f${i.id}_alpha`],n=i.uniforms[`f${i.id}_mode`];break}i=i.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=t,this._material.shadingBlend=n),this.attachLightNodes(e.userData.layers?.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(e){let t=[],n=this.head;for(;n;)n.type===e&&t.push(n),n=n.next;return t}addLayer(e){if(e.id=e.id??++this.id,this.layerCount++,e.type==="light"){let i=this.createLightLayer(e);return this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),i}let t=this._createLayer(e),n=t.layer;if(this.head===void 0)this.head=n;else{let i=this.head;for(;i.next!=null;)i=i.next;i.next=n}return t.color&&this._layerNodes.push({id:n.id,type:"color",color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&this._layerNodes.push({id:n.id,type:"position",position:t.position}),this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}addLayerBeforeAt(e,t){let n=this.head;e.id=e.id??++this.id,this.layerCount++;let i=this._createLayer(e),s=i.layer;s.next=t;let o=0;if(n===t)this.head=s,i.color&&this._layerNodes.splice(0,0,{id:s.id,type:"color",color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(0,0,{id:s.id,type:"position",position:i.position});else{for(o=1;n?.next!==t;)n=n?.next,o++;n.next=s,i.color&&this._layerNodes.splice(o,0,{id:s.id,type:"color",color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(o,0,{id:s.id,type:"position",position:i.position})}return this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}addLayerAt(e,t){t.id=t.id??++this.id,this.layerCount++;let n=this._createLayer(t),i=n.layer;if(n.color&&this._layerNodes.splice(e,0,{id:i.id,type:"color",color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(e,0,{id:i.id,type:"position",position:n.position}),e==0)i.next=this.head,this.head=i;else{let s=this.head,o=this.head.next;for(let a=0;a<e-1;a++)s=o,o=o.next;i.next=o,s.next=i}return this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),i}removeLayer(e){let t=this.head,n,i=0;if(t?.id==e)this.head=t.next;else for(i=1,n=t,t=t?.next;t!=null;){if(t.id==e){n.next=t.next;break}i++,n=t,t=t.next}return this.cleanupChangedLayer(t),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=Ge.generateUUID(),this.layerCount--,i}changeLayer(e,t){let n,i=this.head,s;if(i?.id==e){let o=this._createLayer({id:e,uuid:i.uuid,...t});s=o.layer,s.next=i.next,this.head=s,o.color&&(this._layerNodes[0]={id:s.id,type:"color",color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&(this._layerNodes[0]={id:s.id,type:"position",position:o.position}),s.uniforms[`f${e}_mode`].value=i.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=i.uniforms[`f${e}_alpha`].value}else{n=i,i=i.next;let o=1;for(;i!=null;){if(i.id==e){let a=this._createLayer({id:e,uuid:i.uuid,...t});s=a.layer,n.next=s,s.next=i.next,a.color&&(this._layerNodes[o]={id:e,type:"color",color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[o]={id:e,type:"position",position:a.position}),s.uniforms[`f${e}_mode`].value=i.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=i.uniforms[`f${e}_alpha`].value;break}n=i,i=i.next,o++}}return this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}getLayer(e){let t=this.head;for(;t!=null&&t.id!=e;)t=t.next;return t}getLayerByUuid(e){let t=this.head;for(;t!==void 0;){if(t.uuid===e)return t;t=t.next}}getLayers(){let e=[],t=this.head;for(;t!=null;)e.push(t),t=t.next;return e}getLayerPosition(e){let t=this.head,n=0;for(;t!==void 0&&t.id!=e;)n++,t=t.next;return n}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(e,t){let n,i=this.head,s;if(e==0)n=this.head,this.head=n.next;else{for(let a=0;a<e;a++)s=i,i=i.next;s.next=i.next,n=i}if(i=this.head,s=void 0,t==0)n.next=this.head,this.head=n;else{for(let a=0;a<t-1;a++)i=i.next;n.next=i?.next,i.next=n}let o=this._layerNodes.splice(e,1)[0];this._layerNodes.splice(t,0,o),this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=Ge.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(e){this.needsUpdate=!1,this.layerCount=e.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,e.head);let t=e.head,n=this.head;for(;t.next!=null;)this.rebuildLayerNodes(n,t.next),n=n.next,t=t.next;return this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(e){let t=new _e(e.alpha),n=new nt(e.mode);this._material.shadingAlpha=t,this._material.shadingBlend=n,this._layerNodes.push({id:e.id,type:"light",alpha:t,mode:n});let i=new zt(e.id,void 0,{type:"light",alpha:t,mode:n});if(this.head===void 0)this.head=i;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=i}return this.attachLightNodes(this.getLightLayer()),i}rebuildLayerNodes(e,t,n=!1){if(t.type==="light"){let i=n?t.uniforms[`f${t.id}_alpha`]:new _e(t.uniforms[`f${t.id}_alpha`].value),s=n?t.uniforms[`f${t.id}_mode`]:new nt(t.uniforms[`f${t.id}_mode`].value);this._material.shadingAlpha=i,this._material.shadingBlend=s,this._layerNodes.push({id:t.id,type:"light",alpha:i,mode:s}),this.head===void 0?this.head=new zt(t.id,t.uuid,{type:"light",alpha:i,mode:s}):e&&(e.next=new zt(t.id,t.uuid,{type:"light",alpha:i,mode:s})),this.attachLightNodes(t)}else{let i={type:t.type,id:t.id};for(let s in t.uniforms){let o=t.getName(s);if(!o)continue;let a=`f${t.id}_${o}`;if(Array.isArray(t.uniforms[a].value))i[o]=t.uniforms[a].value.map(l=>l.clone&&!n?l.clone():l);else{let l=t.uniforms[a].value;if(o==="transmissionDepthMap"){i[o]=l;continue}l!=null&&(i[o]=l.clone&&!n&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(i)}}attachLightNodes(e){let t={},n=this.getLightLayer();switch(this._material.userData.category){case"Lambert":t.emissive=new xt(e?.getValue("emissive")?.clone()??0);break;case"Phong":t.shininess=new _e(e?.getValue("shininess")??30),t.specular=new xt(e?.getValue("specular")?.clone()??1118481);break;case"Toon":t.shininess=new _e(e?.getValue("shininess")??30),t.specular=new xt(e?.getValue("specular")?.clone()??1118481);break;case"Physical":t.roughness=new _e(e?.getValue("roughness")??.3),t.metalness=new _e(e?.getValue("metalness")??0),t.reflectivity=new _e(e?.getValue("reflectivity")??.5);break;default:break}Object.keys(t).forEach(i=>{this._material[i]=t[i],n.uniforms[`f${n.id}_${i}`]=t[i]})}clone(e){return new gl(e).copy(this)}getLightLayer(){let e=this.head;for(;e!==void 0&&e.type!=="light";)e=e.next??e;return e}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;e!==void 0;)e.hasOwnProperty("dispose")===!0&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){let t=e.type;switch(t){case"color":{let n=new xt(e.color??5855577),i=new _e(e.alpha??1),s=new _t("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");s.keywords.alpha=i;let o=new nt(e.mode??0);return n.alpha=i,{layer:new zt(e.id,e.uuid,{type:t,color:n,alpha:i,calpha:s,mode:o}),color:n,alpha:s,mode:o}}case"texture":{let n=e.texture??new Lr,i=n.matrix;e.mat&&i.copy(e.mat),n.needsUpdate=!0;let s=new _e(e.crop??0),o=new nt(e.projection??0),a=new nt(e.axis??0),l=new nt(e.side??0),c=new mn(e.size?new B(e.size[0],e.size[1]):new B(100,100)),h=new _e(e.alpha??1),u=new nt(e.mode??0),d=new vn(n),f=new Tn(e.textureSize??new A(n.image?n.image.width:0,n.image?n.image.height:0)),m=new sh(d,f,s,o,a,l,c,h,u),p=new _t(m.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,texture:d,textureSize:f,crop:s,projection:o,axis:a,side:l,size:c,mat:m.mat,alpha:h,calpha:p,mode:u}),color:m,alpha:p,mode:u}}case"matcap":{let n=e.texture??new Lr;n.needsUpdate=!0;let i=new _e(e.alpha??1),s=new vn(n),o=new nt(e.mode??0),a=new vh(s,i,o),l=new _t(a.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,texture:s,alpha:i,calpha:l,mode:o}),color:a,alpha:l,mode:o}}case"fresnel":{let n=new xt(e.color??16777215),i=new _e(e.bias??.1),s=new _e(e.scale??1),o=new _e(e.intensity??2),a=new _e(e.factor??1),l=new _e(e.alpha??1),c=new nt(e.mode??0),h=new ah(n,i,s,o,a,l,c),u=new _t(h.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,color:n,bias:i,scale:s,intensity:o,factor:a,alpha:l,calpha:u,mode:c}),color:h,alpha:u,mode:c}}case"rainbow":{let n=new _e(e.filmThickness??30),i=new _e(e.movement??0),s=new Tn(e.wavelengths??new A(0,0,0)),o=new _e(e.noiseStrength??0),a=new _e(e.noiseScale??1),l=new Tn(e.offset??new A(0,0,0)),c=new _e(e.alpha??1),h=new ch(n,i,s,o,a,l,c),u=new _t(h.calpha,"f"),d=new nt(e.mode??0);return{layer:new zt(e.id,e.uuid,{type:t,filmThickness:n,movement:i,wavelengths:s,noiseStrength:o,noiseScale:a,offset:l,alpha:c,calpha:u,mode:d}),color:h,alpha:u,mode:d}}case"toon":{let n=new nt(e.positioning??0),i;e.colors?i=new Yr(e.colors.length,e.colors):(i=new Yr(10,new qe(0,0,0,1)),i.value[1]=new qe(1,1,1,1));let s;e.steps?s=new gn(e.steps.length,e.steps):(s=new gn(10,1),s.value[0]=0);let o=new Tn(e.source??new A(0,0,0)),a=new zs(e.isWorldSpace??!0),l=new _e(e.noiseStrength??0),c=new _e(e.noiseScale??1),h=new Pr(e.shadowColor),u=new Tn(e.offset??new A(0,0,0)),d=new _e(e.alpha??1),f=new hh(n,i,s,o,a,l,c,h,u,d),m=new _t(f.calpha,"f"),p=new nt(e.mode??0);return{layer:new zt(e.id,e.uuid,{type:t,positioning:n,colors:i,steps:s,source:o,isWorldSpace:a,noiseStrength:l,noiseScale:c,shadowColor:h,offset:u,alpha:d,calpha:m,mode:p}),color:f,alpha:m,mode:p}}case"outline":{let n=new xt(e.outlineColor??16777215),i=new xt(e.contourColor??16777215),s=new _e(e.outlineWidth??.1),o=new _e(e.contourWidth??.1),a=new _e(e.outlineThreshold??.1),l=new _e(e.contourThreshold??.1),c=new _e(e.outlineSmoothing??.1),h=new _e(e.contourFrequency??.1),u=new Tn(e.contourDirections??new A(0,1,0)),d=new zs(e.positionalLines??!1),f=new zs(e.compensation??!0),m=e.normalMap??new Lr,p=new vn(m),g=e.depthMap??new Lr,x=new vn(g),v=e.pixelRatio??new _e(window.devicePixelRatio),w=e.resolution??new mn(new B(1,1)),b=new _e(e.alpha??1),S=new uh(n,i,s,o,a,l,c,h,u,d,f,w,p,x,v,b),M=new _t(S.calpha,"f"),_=new nt(e.mode??0);return{layer:new zt(e.id,e.uuid,{type:t,outlineColor:n,contourColor:i,outlineWidth:s,contourWidth:o,outlineThreshold:a,contourThreshold:l,outlineSmoothing:c,contourFrequency:h,contourDirection:u,positionalLines:d,compensation:f,resolution:w,normalMap:p,depthMap:x,pixelRatio:v,alpha:b,calpha:M,mode:_}),color:S,alpha:M,mode:_}}case"transmission":{let n=new _e(e.thickness??10),i=new _e(e.ior??1.5),s=new _e(e.roughness??.5),o=new mn(e.transmissionSamplerSize??new B(2048,2048)),a=e.transmissionSamplerMap??new Lr,l=e.transmissionDepthMap??new Lr,c=new vn(a),h=new vn(l),u=window.innerWidth,d=window.innerHeight,f=u>=d?new mn(d/u,1):new mn(1,u/d),m=new _e(e.alpha??1),p=new dh(n,i,s,o,c,h,f,m),g=new _t(p.calpha,"f"),x=new nt(e.mode??0);return{layer:new zt(e.id,e.uuid,{type:t,thickness:n,ior:i,roughness:s,transmissionSamplerSize:o,transmissionSamplerMap:c,transmissionDepthMap:h,aspectRatio:f,alpha:m,calpha:g,mode:x}),color:p,alpha:g,mode:x}}case"depth":{let n=new nt(e.gradientType??0),i=new zs(e.smooth??!1),s=new _e(e.near??50),o=new _e(e.far??200),a=new _e(e.isVector??1),l=new _e(e.isWorldSpace??0),c=new Tn(e.origin??new A),h=new Tn(e.direction??new A),u=new nt(e.num??0),d;e.colors?d=new Yr(u.value+1,e.colors):(d=new Yr(u.value+1,new qe(0,0,0,1)),d.value[1]=new qe(1,1,1,1));let f;e.steps?f=new gn(u.value+1,e.steps):(f=new gn(u.value+1,1),f.value[0]=0);let m=new _e(e.alpha??1),p=new nt(e.mode??0),g=new yh(n,i,s,o,a,l,c,h,d,f,u,m),x=new _t(g.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,gradientType:n,smooth:i,near:s,far:o,isVector:a,isWorldSpace:l,origin:c,direction:h,colors:d,steps:f,num:u,alpha:m,calpha:x,mode:p}),color:g,alpha:x,mode:p}}case"noise":{let n=new _e(e.scale??1),i=new Tn(e.size??new A(100,100,100)),s=new _e(e.move??1),o=new mn(e.fA??new B(1.7,9.2)),a=new mn(e.fB??new B(8.3,2.8)),l=new mn(e.distortion??new B(1,1)),c=new Pr(e.colorA),h=new Pr(e.colorB),u=new Pr(e.colorC),d=new Pr(e.colorD),f=new _e(e.alpha??1),m=new nt(e.mode??0),p=new nt(e.noiseType??0),g=new mh(n,i,s,o,a,l,c,h,u,d,f,p),x=new _t(g.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,scale:n,size:i,move:s,fA:o,fB:a,distortion:l,colorA:c,colorB:h,colorC:u,colorD:d,alpha:f,calpha:x,mode:m,noiseType:p}),color:g,alpha:x,mode:m}}case"normal":{let n=new Tn(e.cnormal??new A(1,1,1)),i=new _e(e.alpha??1),s=new nt(e.mode??0),o=new fh(n,i),a=new _t("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return a.keywords.alpha=i,{layer:new zt(e.id,e.uuid,{type:t,cnormal:n,alpha:i,calpha:a,mode:s}),color:o,alpha:a,mode:s}}case"gradient":{let n=new nt(e.gradientType??0),i=new zs(e.smooth??!1),s;e.colors?s=new Yr(e.colors.length,e.colors):(s=new Yr(10,new qe(0,0,0,1)),s.value[1]=new qe(1,1,1,1));let o;e.steps?o=new gn(e.steps.length,e.steps):(o=new gn(10,1),o.value[0]=0);let a=new mn(e.offset??new B(0,0)),l=new mn(e.morph??new B(0,0)),c=new _e(e.angle??0),h=new _e(e.alpha??1),u=new nt(e.mode??0),d=new ph(n,i,s,o,a,l,c,h),f=new _t(d.calpha,"f");return{layer:new zt(e.id,e.uuid,{type:t,gradientType:n,smooth:i,colors:s,steps:o,offset:a,morph:l,angle:c,alpha:h,calpha:f,mode:u}),color:d,alpha:f,mode:u}}case"displace":{let n=new nt(e.displacementType??0);if(n.value===0){let i=new Tn(e.offset??new A(0,0,0)),s=new _e(e.scale??10),o=new _e(e.intensity??8),a=new _e(e.movement??1),l=new _e(e.alpha??1),c=new nt(e.mode??0),h=new nt(e.noiseType??0),u=new pl(n,o,a,i,s,h);return{layer:new zt(e.id,e.uuid,{displacementType:n,type:t,offset:i,scale:s,intensity:o,movement:a,alpha:l,mode:c,noiseType:h}),position:u}}else if(n.value===1){let i=e.texture??new Lr,s=i.matrix;e.mat&&s.copy(e.mat),i.needsUpdate=!0;let o=new _e(e.intensity??8),a=new vn(i),l=new _e(e.crop??0),c=new _e(e.alpha??1),h=new nt(e.mode??0),u=new pl(n,o,a,l);return{layer:new zt(e.id,e.uuid,{displacementType:n,type:t,intensity:o,texture:a,crop:l,mat:u.mat,alpha:c,mode:h}),position:u}}return{}}}return{}}blendColors(){let e=this._layerNodes.findIndex(n=>n.type==="color"),t=this._layerNodes.findIndex(n=>n.type==="light");if(e!==-1&&e<t){let n=this._layerNodes[e].color;for(let i=e+1;i<t;++i){let s=this._layerNodes[i];s.type==="color"&&(n=new gh(n,s.color,s.alpha,s.mode))}this._material.color=n}else this._material.color=void 0}blendAfterColors(){let e=new _t("outgoingLight","f"),t=this._layerNodes.findIndex(n=>n.type==="light");if(this._layerNodes.length>t+1){for(let n=t+1;n<this._layerNodes.length;++n){let i=this._layerNodes[n];i.type==="color"&&(e=new gh(e,i.color,i.alpha,i.mode))}"afterColor"in this._material&&(this._material.afterColor=e)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let e=this._layerNodes.filter(t=>t.type==="position");if(e.length>0){let t=e[0].position;for(let n=1;n<e.length;++n)e[n]&&(t=new rr(t,e[n].position,rr.ADD),t=new rr(t,new _e(.5).setReadonly(!0),rr.MUL));this._material.position=t}else this._material.position=void 0}cleanupChangedLayer(e){switch(this._layerNodes=this._layerNodes.filter(t=>t.id!==e.id),e.type){case"displace":{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var xh=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};var oO=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
4079
4091
|
)*?)}`,"gim"),aO=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),yl=class extends ze{constructor(t=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(t)}getType(t){return t.getTypeByFormat(this.name)}getInputByName(t){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}generate(t,n,i,s,o){return n==="source"?this.src+";":t.format("( "+this.src+" )",this.getType(t),n)}parse(t=""){this.src=t,this.inputs=[];let n=oO.exec(t);if(n){let i=n[2],s;for(;s=aO.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var bh=class extends ze{constructor(t,n){super();this.inputs=[];this.nodeType="FunctionCall";this.value=t,this.inputs=n??[]}getFunction(){return this.value}getType(t){return this.value.getType(t)}generate(t,n,i,s,o){s=this.getType(t);let a=this.value,l=a.build(t,n)+"( ",c=[];if(a.inputs){for(let h=0;h<a.inputs.length;h++){let u=a.inputs[h],d=this.inputs[h]||this.inputs[u.name];c.push(d.build(t,t.getTypeByFormat(u.type)))}l+=c.join(", ")+" )"}return t.format(l,s,n)}copy(t){return super.copy(t),this.value.copy(t.value),this.inputs=t.inputs.map(n=>n.clone()),this}};var Tt=class extends ze{constructor(t=new ke,n=Tt.ABS,i,s){super();this.nodeType="Math";this.a=t,typeof n!="string"?this.b=n:s=n,typeof i!="string"?this.c=i:s=i,this.method=s,this.hashProperties=["method"]}getNumInputs(t){switch(this.method){case Tt.MIX:case Tt.CLAMP:case Tt.REFRACT:case Tt.SMOOTHSTEP:case Tt.FACEFORWARD:return 3;case Tt.MIN:case Tt.MAX:case Tt.MOD:case Tt.STEP:case Tt.REFLECT:case Tt.DISTANCE:case Tt.DOT:case Tt.CROSS:case Tt.POW:return 2;default:return 1}}getInputType(t){let n=t.getTypeLength(this.a.getType(t)),i=this.b?t.getTypeLength(this.b.getType(t)):0,s=this.c?t.getTypeLength(this.c.getType(t)):0;return n>i&&n>s?this.a.getType(t):i>s?this.b.getType(t):this.c.getType(t)}getType(t){switch(this.method){case Tt.LENGTH:case Tt.DISTANCE:case Tt.DOT:return"f";case Tt.CROSS:return"v3"}return this.getInputType(t)}generate(t,n){let i,s,o,a=this.a?t.getTypeLength(this.a.getType(t)):0,l=this.b?t.getTypeLength(this.b.getType(t)):0,c=this.c?t.getTypeLength(this.c.getType(t)):0,h=this.getInputType(t),u=this.getType(t);switch(this.type=u,this.method){case Tt.NEGATE:return t.format("( -"+this.a.build(t,h)+" )",h,n);case Tt.INVERT:return t.format("( 1.0 - "+this.a.build(t,h)+" )",h,n);case Tt.CROSS:i=this.a.build(t,"v3"),s=this.b.build(t,"v3");break;case Tt.STEP:i=this.a.build(t,a===1?"f":h),s=this.b.build(t,h);break;case Tt.MIN:case Tt.MAX:case Tt.MOD:i=this.a.build(t,h),s=this.b.build(t,l===1?"f":h);break;case Tt.REFRACT:i=this.a.build(t,h),s=this.b.build(t,h),o=this.c.build(t,"f");break;case Tt.MIX:i=this.a.build(t,h),s=this.b.build(t,h),o=this.c.build(t,c===1?"f":h);break;default:i=this.a.build(t,h),this.b&&(s=this.b.build(t,h)),this.c&&(o=this.c.build(t,h));break}let d=[];d.push(i),s&&d.push(s),o&&d.push(o);let f=this.getNumInputs(t);if(d.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${d.length}.`);return t.format(this.method+"( "+d.join(", ")+" )",u,n)}copy(t){return super.copy(t),this.a.copy(t.a),this.b=t.b instanceof ke?t.b.clone():t.b,this.c=t.c instanceof ke?t.c.clone():t.c,this.method=t.method,this}},Ye=Tt;Ye.RAD="radians",Ye.DEG="degrees",Ye.EXP="exp",Ye.EXP2="exp2",Ye.LOG="log",Ye.LOG2="log2",Ye.SQRT="sqrt",Ye.INV_SQRT="inversesqrt",Ye.FLOOR="floor",Ye.CEIL="ceil",Ye.NORMALIZE="normalize",Ye.FRACT="fract",Ye.SATURATE="saturate",Ye.SIN="sin",Ye.COS="cos",Ye.TAN="tan",Ye.ASIN="asin",Ye.ACOS="acos",Ye.ARCTAN="atan",Ye.ABS="abs",Ye.SIGN="sign",Ye.LENGTH="length",Ye.NEGATE="negate",Ye.INVERT="invert",Ye.MIN="min",Ye.MAX="max",Ye.MOD="mod",Ye.STEP="step",Ye.REFLECT="reflect",Ye.DISTANCE="distance",Ye.DOT="dot",Ye.CROSS="cross",Ye.POW="pow",Ye.MIX="mix",Ye.CLAMP="clamp",Ye.REFRACT="refract",Ye.SMOOTHSTEP="smoothstep",Ye.FACEFORWARD="faceforward";var vl=class extends ze{constructor(t=new ke,n=new ke,i=new ke){super("v4");this.nodeType="TextureCubeUV";this.value=t,this.uv=n,this.bias=i}bilinearCubeUV(t,n,i,s){let o=new bh(vl.Nodes.bilinearCubeUV,[n,i,s]);this.colorSpaceTL=this.colorSpaceTL??new Yn(new _t("","v4")),this.colorSpaceTL.fromDecoding(t.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(o.build(t)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Yn(new _t("","v4")),this.colorSpaceTR.fromDecoding(t.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(o.build(t)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Yn(new _t("","v4")),this.colorSpaceBL.fromDecoding(t.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(o.build(t)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Yn(new _t("","v4")),this.colorSpaceBR.fromDecoding(t.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(o.build(t)+".br");let a={include:t.isShader("vertex"),ignoreCache:!0};t.addContext(a),this.colorSpaceTLExp=new _t(this.colorSpaceTL.build(t,"v4"),"v4"),this.colorSpaceTRExp=new _t(this.colorSpaceTR.build(t,"v4"),"v4"),this.colorSpaceBLExp=new _t(this.colorSpaceBL.build(t,"v4"),"v4"),this.colorSpaceBRExp=new _t(this.colorSpaceBR.build(t,"v4"),"v4"),t.removeContext();let l=new _t("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=o,l}generate(t,n){if(t.isShader("fragment")){let i=this.uv,s=this.bias||t.context.roughness,o=new bh(vl.Nodes.roughnessToMip,[s]),a=new Ye(o,vl.Nodes.m0,vl.Nodes.cubeUV_maxMipLevel,Ye.CLAMP),l=new Ye(a,Ye.FLOOR),c=new Ye(a,Ye.FRACT),h=this.bilinearCubeUV(t,this.value,i,l),u=this.bilinearCubeUV(t,this.value,i,new rr(l,new _e(1).setReadonly(!0),rr.ADD)),d=new Ye(h,u,c,Ye.MIX);return t.format(d.build(t),"v4",n)}else return console.warn("TextureCubeUVNode is not compatible with "+t.shader+" shader."),t.format("vec4( 0.0 )",this.getType(t),n)}copy(t){return super.copy(t),this.uv.copy(t.uv),this.bias.copy(t.bias),this.value.copy(t.value),t.colorSpaceTL?this.colorSpaceTL?this.colorSpaceTL.copy(t.colorSpaceTL):this.colorSpaceTL=t.colorSpaceTL.clone():this.colorSpaceTL=void 0,t.colorSpaceTR?this.colorSpaceTR?this.colorSpaceTR.copy(t.colorSpaceTR):this.colorSpaceTR=t.colorSpaceTR.clone():this.colorSpaceTR=void 0,t.colorSpaceBL?this.colorSpaceBL?this.colorSpaceBL.copy(t.colorSpaceBL):this.colorSpaceBL=t.colorSpaceBL.clone():this.colorSpaceBL=void 0,t.colorSpaceBR?this.colorSpaceBR?this.colorSpaceBR.copy(t.colorSpaceBR):this.colorSpaceBR=t.colorSpaceBR.clone():this.colorSpaceBR=void 0,t.colorSpaceTLExp?this.colorSpaceTLExp?this.colorSpaceTLExp.copy(t.colorSpaceTLExp):this.colorSpaceTLExp=t.colorSpaceTLExp.clone():this.colorSpaceTLExp=void 0,t.colorSpaceTRExp?this.colorSpaceTRExp?this.colorSpaceTRExp.copy(t.colorSpaceTRExp):this.colorSpaceTRExp=t.colorSpaceTRExp.clone():this.colorSpaceTRExp=void 0,t.colorSpaceBLExp?this.colorSpaceBLExp?this.colorSpaceBLExp.copy(t.colorSpaceBLExp):this.colorSpaceBLExp=t.colorSpaceBLExp.clone():this.colorSpaceBLExp=void 0,t.colorSpaceBRExp?this.colorSpaceBRExp?this.colorSpaceBRExp.copy(t.colorSpaceBRExp):this.colorSpaceBRExp=t.colorSpaceBRExp.clone():this.colorSpaceBRExp=void 0,this}},xl=vl;xl.Nodes=function(){let t=new yl(`struct TextureCubeUVData {
|
|
4080
4092
|
vec4 tl;
|
|
4081
4093
|
vec4 tr;
|
|
@@ -4155,7 +4167,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
4155
4167
|
mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
|
|
4156
4168
|
}
|
|
4157
4169
|
return mip;
|
|
4158
|
-
}`,T);return{bilinearCubeUV:c,roughnessToMip:E,m0:d,cubeUV_maxMipLevel:n}}();var To=class extends ze{constructor(t){super("v3");this.nodeType="Normal";this.scope=t??To.VIEW}getShared(){return this.scope===To.WORLD}build(t,n,i,s){let o=t.context[this.scope+"Normal"];return o?o.build(t,n,i,s):super.build(t,n,i)}generate(t,n,i,s,o){let a;switch(this.scope){case To.VIEW:t.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case To.LOCAL:t.isShader("vertex")?a="objectNormal":(t.requires.normal=!0,a="vObjectNormal");break;case To.WORLD:t.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(t.requires.worldNormal=!0,a="vWNormal");break}return t.format(a,this.getType(t),n)}copy(t){return super.copy(t),this.scope=t.scope,this}},En=To;En.LOCAL="local",En.WORLD="world",En.VIEW="view",En.NORMAL="normal";yn.addKeyword("viewNormal",function(){return new En(En.VIEW)});yn.addKeyword("localNormal",function(){return new En(En.NORMAL)});yn.addKeyword("worldNormal",function(){return new En(En.WORLD)});var wi=class extends ze{constructor(t){super("v3");this.nodeType="Position";this.scope=t??wi.LOCAL}getType(){switch(this.scope){case wi.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case wi.LOCAL:case wi.WORLD:return!1}return!0}generate(t,n,i,s,o){let a;switch(this.scope){case wi.LOCAL:t.isShader("vertex")?a="transformed":(t.requires.position=!0,a="vPosition");break;case wi.WORLD:if(t.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";t.requires.worldPosition=!0,a="vWPosition";break;case wi.VIEW:a=t.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case wi.PROJECTION:a=t.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return t.format(a,this.getType(),n)}copy(t){return super.copy(t),this.scope=t.scope,this}},
|
|
4170
|
+
}`,T);return{bilinearCubeUV:c,roughnessToMip:E,m0:d,cubeUV_maxMipLevel:n}}();var To=class extends ze{constructor(t){super("v3");this.nodeType="Normal";this.scope=t??To.VIEW}getShared(){return this.scope===To.WORLD}build(t,n,i,s){let o=t.context[this.scope+"Normal"];return o?o.build(t,n,i,s):super.build(t,n,i)}generate(t,n,i,s,o){let a;switch(this.scope){case To.VIEW:t.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case To.LOCAL:t.isShader("vertex")?a="objectNormal":(t.requires.normal=!0,a="vObjectNormal");break;case To.WORLD:t.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(t.requires.worldNormal=!0,a="vWNormal");break}return t.format(a,this.getType(t),n)}copy(t){return super.copy(t),this.scope=t.scope,this}},En=To;En.LOCAL="local",En.WORLD="world",En.VIEW="view",En.NORMAL="normal";yn.addKeyword("viewNormal",function(){return new En(En.VIEW)});yn.addKeyword("localNormal",function(){return new En(En.NORMAL)});yn.addKeyword("worldNormal",function(){return new En(En.WORLD)});var wi=class extends ze{constructor(t){super("v3");this.nodeType="Position";this.scope=t??wi.LOCAL}getType(){switch(this.scope){case wi.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case wi.LOCAL:case wi.WORLD:return!1}return!0}generate(t,n,i,s,o){let a;switch(this.scope){case wi.LOCAL:t.isShader("vertex")?a="transformed":(t.requires.position=!0,a="vPosition");break;case wi.WORLD:if(t.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";t.requires.worldPosition=!0,a="vWPosition";break;case wi.VIEW:a=t.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case wi.PROJECTION:a=t.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return t.format(a,this.getType(),n)}copy(t){return super.copy(t),this.scope=t.scope,this}},In=wi;In.LOCAL="local",In.WORLD="world",In.VIEW="view",In.PROJECTION="projection";yn.addKeyword("position",function(){return new In});yn.addKeyword("worldPosition",function(){return new In(In.WORLD)});yn.addKeyword("viewPosition",function(){return new In(In.VIEW)});var Kr=class extends ze{constructor(t){super("v3");this.nodeType="Reflect";this.scope=t??Kr.CUBE}getUnique(t){return!t.context.viewNormal}getType(){switch(this.scope){case Kr.SPHERE:return"v2"}return this.type}generate(t,n){let i=this.getUnique(t);if(t.isShader("fragment")){let s;switch(this.scope){case Kr.VECTOR:{let o=new En(En.VIEW),a=t.context.roughness,l=o.build(t,"v3"),c=new In(In.VIEW).build(t,"v3"),h=a?a.build(t,"f"):void 0,u=`reflect( -normalize( ${c} ), ${l} )`;h&&(u=`normalize( mix( ${u}, ${l}, ${h} * ${h} ) )`);let d=`inverseTransformDirection( ${u}, viewMatrix )`;i?(t.addNodeCode(`vec3 reflectVec = ${d};`),s="reflectVec"):s=d;break}case Kr.CUBE:{let o=new Kr(Kr.VECTOR).build(t,"v3"),a="vec3( -"+o+".x, "+o+".yz )";i?(t.addNodeCode(`vec3 reflectCubeVec = ${a};`),s="reflectCubeVec"):s=a;break}case Kr.SPHERE:{let o=new Kr(Kr.VECTOR).build(t,"v3"),a="normalize( ( viewMatrix * vec4( "+o+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";i?(t.addNodeCode(`vec2 reflectSphereVec = ${a};`),s="reflectSphereVec"):s=a;break}}return t.format(s,this.getType(),n)}else return console.warn("ReflectNode is not compatible with "+t.shader+" shader."),t.format("vec3( 0.0 )",this.type,n)}copy(t){return super.copy(t),this.scope=t.scope,this}},Si=Kr;Si.CUBE="cube",Si.SPHERE="sphere",Si.VECTOR="vector";var af=class extends ze{constructor(t=new vn,n,i){super("v4");this.nodeType="TextureCube";this.value=t,this.radianceNode=new xl(this.value,n??new Si(Si.VECTOR),i),this.irradianceNode=new xl(this.value,new En(En.WORLD),new _e(1).setReadonly(!0))}generate(t,n){return t.isShader("fragment")?(t.require("irradiance"),t.context.bias&&t.context.bias.setTexture(this.value),(t.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(t,n)):(console.warn("TextureCubeNode is not compatible with "+t.shader+" shader."),t.format("vec4( 0.0 )",this.getType(t),n))}copy(t){return super.copy(t),this.value.copy(t.value),this.radianceNode.copy(t.radianceNode),this.irradianceNode.copy(t.irradianceNode),this}};var lf=class extends Pt{constructor(t=new ra,n,i){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=t,this.uv=n??new Si,this.bias=i}getTexture(t,n){return super.generate(t,n,this.value.uuid,"tc")}generate(t,n){if(n==="samplerCube")return this.getTexture(t,n);let i=this.getTexture(t,n),s=this.uv?.build(t,"v3"),o=this.bias?this.bias.build(t,"f"):void 0;o===void 0&&t.context.bias&&(o=t.context.bias.setTexture(this).build(t,"f"));let a;o?a="texCubeBias( "+i+", "+s+", "+o+" )":a="texCube( "+i+", "+s+" )";let l={include:t.isShader("vertex"),ignoreCache:!0},c=this.getType(t);return t.addContext(l),this.colorSpace=this.colorSpace??new Yn(new _t("",c)),this.colorSpace.fromDecoding(t.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(t,c),t.removeContext(),t.format(a,c,n)}copy(t){return super.copy(t),this.value.copy(t.value),t.uv?this.uv?this.uv.copy(t.uv):this.uv=t.uv.clone():this.uv=void 0,t.bias?this.bias?this.bias.copy(t.bias):this.bias=t.bias.clone():this.bias=void 0,this}};var v1=["x","y","z","w"],lO=["float","vec2","vec3","vec4"],cO={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},hO={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},cf=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function e(t,n){return t.deps.length-n.deps.length}return function(n,i){let s=this.getIncludes(n,i);if(!s)return"";let o="";s=s.sort(e);for(let a=0;a<s.length;a++)s[a].src&&(o+=s[a].src+`
|
|
4159
4171
|
`);return o}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],lights:!1,fog:!1,transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
|
|
4160
4172
|
// NOTE: Include Spline's blending modes. This could be part of BlendNode
|
|
4161
4173
|
#define SPE_BLENDING_NORMAL 0
|
|
@@ -4201,7 +4213,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
4201
4213
|
`)}getVarListCode(e,t){t=t??"";let n="";for(let i=0,s=e.length;i<s;++i){let o=e[i],a=o.type,l=o.name,c=o.size,h=this.getFormatByType(a);if(h===void 0)throw new Error("Node pars "+h+" not found.");h.includes("[]")?n+=t+" "+h.substring(0,h.length-2)+" "+l+`[${c}];
|
|
4202
4214
|
`:n+=t+" "+h+" "+l+`;
|
|
4203
4215
|
`}return n}getVars(e){return this.inputs.vars[e??this.shader]}getNodeData(e){let t=e instanceof ke?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,n,i,s,o){if(t.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,c=new xh({type:t,size:n.size,name:i||"nodeUA"+l+(o?"_"+o:""),node:n,needsUpdate:s});return a.list.push(c),a[e].push(c),a[e][c.name]=c,this.uniforms[c.name]=c,c}else{let a=this.inputs.uniforms,l=a.list.length,c=new xh({type:t,name:i||"nodeU"+l+(o?"_"+o:""),node:n,needsUpdate:s});return a.list.push(c),a[e].push(c),a[e][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(e,t,n,i,s){return this.createUniform("vertex",e,t,n,i,s)}createFragmentUniform(e,t,n,i,s){return this.createUniform("fragment",e,t,n,i,s)}include(e,t,n){let i;if(e=typeof e=="string"?yn.get(e):e,this.context.include===!1)return e.name;e instanceof Te?i=this.includes.functions:e instanceof ht?i=this.includes.consts:e instanceof yl&&(i=this.includes.structs);let s=i[this.shader]=i[this.shader]||[];if(e){let o=s[e.name];if(o||(o=s[e.name]={node:e,deps:[]},s.push(o),o.src=e.build(this,"source")),e instanceof Te&&t&&s[t.name]&&s[t.name].deps.indexOf(e)===-1&&(s[t.name].deps.push(e),e.includes?.length)){let a=0;do this.include(e.includes[a++],t);while(a<e.includes.length)}return n&&(o.src=n),e.name}else throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return lO[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return e==="f"?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return e===1?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){let n=e[t];if(n?.isNode)return n}}resolve(...e){for(let t=0;t<arguments.length;t++){let n=e[t];if(n!==void 0){if(n.isNode)return n;if(n.isTexture)switch(n.mapping){case us:case ds:return new lf(n);case ya:return new af(new vn(n));default:return new vn(n)}else{if(n.isVector2)return new mn(n);if(n.isVector3)return new Tn(n);if(n.isVector4)return new Pr(n)}}}}format(e,t,n){switch(this.colorToVector(n+" <- "+t)){case"f <- v2":return e+".x";case"f <- v3":return e+".x";case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":return e+".xy";case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":return"int( "+e+".x )";case"i <- v3":return"int( "+e+".x )";case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return cO[e]||e}getFormatByType(e){return hO[e]||e}getUUID(e,t){return t=t!==void 0?t:!0,t&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return v1[e]}getIndexByElement(e){return v1.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(let t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(let t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let t;return e?e.isTexture&&(t=e.encoding):t=lr,t===lr&&this.context.gamma&&(t=We),t}};var wh=class extends ke{constructor(t=new ke){super("v4");this.nodeType="Raw";this.value=t}generate(t){let n=this.value.analyzeAndFlow(t,this.type),i=n.code+`
|
|
4204
|
-
`;return t.isShader("vertex")?i+="gl_Position = "+n.result+";":i+="gl_FragColor = "+n.result+";",i}copy(t){return super.copy(t),this.value.copy(t.value),this}};var fr=class extends dt{constructor(t,n,i){super(i);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=t??new wh(new
|
|
4216
|
+
`;return t.isShader("vertex")?i+="gl_Position = "+n.result+";":i+="gl_FragColor = "+n.result+";",i}copy(t){return super.copy(t),this.value.copy(t.value),this}};var fr=class extends dt{constructor(t,n,i){super(i);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=t??new wh(new In(In.PROJECTION)),this.fragment=n??new wh(new xt(5855577)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.vertexColors=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(t,n){this.build({renderer:n}),t.defines=this.defines,t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.extensionDerivatives=this.extensions.derivatives===!0,t.extensionFragDepth=this.extensions.fragDepth===!0,t.extensionDrawBuffers=this.extensions.drawBuffers===!0,t.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}_getLayerStack(t){let n=new gl(this);return t&&(async()=>{for(;t.image===void 0;)await new Promise(i=>requestAnimationFrame(i));n.addLayerAt(1,{type:"texture",texture:t}),this.dispose()})(),n}clampUniformsForPreview(t,n){let i=(s,o,a)=>Math.min(Math.max(s,o),a);if(this.userData.layers){for(let s of this.userData.layers.getLayers())if(s.type=="displace"){this.uniformsBackup[`f${s.id}_intensity`]=s.uniforms[`f${s.id}_intensity`].value;let o=i(s.uniforms[`f${s.id}_intensity`].value,t,n);s.uniforms[`f${s.id}_intensity`].value=o}}}restoreClampedUniforms(){if(this.userData.layers)for(let t of this.userData.layers.getLayers())t.type=="displace"&&(t.uniforms[`f${t.id}_intensity`].value=this.uniformsBackup[`f${t.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(t){for(let n=0;n<this.updaters.length;++n)t.updateNode(this.updaters[n])}build(t){t=t??{};let n=t.builder??new cf;return n.setMaterial(this,t.renderer),n.build(this.vertex,this.fragment),this.vertexShader=n.getCode("vertex"),this.fragmentShader=n.getCode("fragment"),this.defines=n.defines,this.uniforms=n.uniforms,this.extensions=n.extensions,this.updaters=n.updaters,this.fog=n.requires.fog,this.lights=n.requires.lights,this.transparent=n.requires.transparent||this.blending>ls,this}getHash(){let t="{";return t+='"vertex":'+this.vertex.getHash()+",",t+='"fragment":'+this.fragment.getHash(),t+="}",t}get penumbraSizeNode(){return this.fragment.penumbraSize}set penumbraSizeNode(t){this.fragment.penumbraSize=t}};Object.defineProperties(fr.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(r){r===!0&&this.version++,this.needsCompile=r},get:function(){return this.needsCompile}}});var hf=class extends ke{constructor(){super("basic");this.nodeType="Basic";this.color=new xt(5855577)}generate(t){let n;if(t.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(t,"v3",{cache:"position"}):void 0;t.mergeUniform(Wr.merge([me.fog])),t.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
|
4205
4217
|
`));let s=["#include <beginnormal_vertex>",`
|
|
4206
4218
|
#if !defined( USE_LAYER_DISPLACE )
|
|
4207
4219
|
#include <defaultnormal_vertex>
|
|
@@ -4863,7 +4875,7 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
|
|
|
4863
4875
|
}
|
|
4864
4876
|
|
|
4865
4877
|
#endif
|
|
4866
|
-
`,CO=$e.lights_fragment_begin,DO=$e.shadowmask_pars_fragment,Sy=!1,PO=r=>{switch(r){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},Ay=(r="medium")=>{if(!Sy){Sy=!0;let e=PO(r);$e.shadowmap_pars_fragment=EO(e);let t=CO.slice();t=t.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),t=t.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),$e.lights_fragment_begin=t;let n=DO.slice();n=n.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),$e.shadowmask_pars_fragment=n}},A1=r=>{Sy=!1,Ay(r)};var
|
|
4878
|
+
`,CO=$e.lights_fragment_begin,DO=$e.shadowmask_pars_fragment,Sy=!1,PO=r=>{switch(r){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},Ay=(r="medium")=>{if(!Sy){Sy=!0;let e=PO(r);$e.shadowmap_pars_fragment=EO(e);let t=CO.slice();t=t.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),t=t.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),$e.lights_fragment_begin=t;let n=DO.slice();n=n.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),$e.shadowmask_pars_fragment=n}},A1=r=>{Sy=!1,Ay(r)};var LO=`
|
|
4867
4879
|
attribute vec3 randomColor;
|
|
4868
4880
|
varying vec3 vNormal;
|
|
4869
4881
|
flat out vec3 vColor;
|
|
@@ -4874,7 +4886,7 @@ vNormal = normal;
|
|
|
4874
4886
|
vColor = randomColor;
|
|
4875
4887
|
gl_Position = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
|
|
4876
4888
|
}
|
|
4877
|
-
`,
|
|
4889
|
+
`,IO=`
|
|
4878
4890
|
uniform float depthContrast;
|
|
4879
4891
|
varying vec3 vNormal;
|
|
4880
4892
|
flat in vec3 vColor;
|
|
@@ -4887,10 +4899,10 @@ float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;
|
|
|
4887
4899
|
vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);
|
|
4888
4900
|
gl_FragColor = vec4(resultColor, vColor.r);
|
|
4889
4901
|
}
|
|
4890
|
-
`,M1=new dt({vertexShader:IO,fragmentShader:LO,uniforms:{depthContrast:{value:1}}});function NO(r,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=r.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=r.depthTexture}function RO(r,e){e.uniforms[`f${e.id}_normalMap`].value=r.texture,e.uniforms[`f${e.id}_depthMap`].value=r.depthTexture}function BO(r){if(r.geometry.attributes.extrudeNormals)return;let e=new Map,t=r.geometry.attributes.position.array,n=r.geometry.attributes.normal.array,i=new Float32Array(t.length);for(let s=0;s<t.length;s+=3){let o=`${t[s]}_${t[s+1]}_${t[s+2]}`,a=new A(n[s],n[s+1],n[s+2]);e.has(o)?e.get(o)?.normals.push(a):e.set(o,{normals:[a],result:new A})}e.forEach((s,o)=>{for(let a of s.normals)s.result.add(a);s.result.divideScalar(s.normals.length)});for(let s=0;s<t.length;s+=3){let o=`${t[s]}_${t[s+1]}_${t[s+2]}`,a=e.get(o)?.result;a&&(i[s]=a.x,i[s+1]=a.y,i[s+2]=a.z)}r.geometry.setAttribute("extrudeNormal",new Se(i,3))}function OO(r){if(r.geometry.attributes.extrudeNormals)return;let e=r.geometry.attributes.position.array,t=new Float32Array(e.length),n=new A;for(let i=0;i<e.length;i+=3)n.set(e[i],e[i+1],e[i+2]).normalize(),t[i]=n.x,t[i+1]=n.y,t[i+2]=n.z;r.geometry.setAttribute("extrudeNormal",new Se(t,3))}function Ah(r){r.objectType==="Mesh2D"?OO(r):BO(r)}function My(r){let e=r.geometry.attributes.position.array,t=new Float32Array(e.length),n=parseInt(r.uuid.replace(/\D/g,"")),i=[Ge.seededRandom(n),Ge.seededRandom(n+1e4),Ge.seededRandom(n+2e4)];for(let s=0;s<e.length;s++)t[s]=i[s%3];r.geometry.setAttribute("randomColor",new Xe(t,3))}function _1(r,e,t){if(!t.userData.layers)return!1;let n=!1,i=t.userData.layers.getLayersOfType("transmission"),s=t.userData.layers.getLayersOfType("outline");return s.length>0&&(e.layers.set(8),i.length===0&&e.layers.enable(3),e.cloner?.refreshClonerMasks(),n=!0,r!==void 0&&s.forEach(o=>RO(r,o)),My(e),Ah(e)),i.length===0&&s.length===0&&e.layers.set(0),n}function T1(r,e,t){if(!t.userData.layers)return!1;let n=!1,i=t.userData.layers.getLayersOfType("transmission"),s=t.userData.layers.getLayersOfType("outline");return i.length>0&&(e.layers.set(3),s.length>0&&e.layers.enable(8),e.cloner?.refreshClonerMasks(),n=!0,r!==void 0&&i.forEach(o=>NO(r,o))),i.length===0&&s.length===0&&e.layers.set(0),n}function E1(r,e){let t=!1;return e.traverseEntity(n=>{if(n instanceof Vt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)_1(r,n,n.material[i])&&(t=!0);else _1(r,n,n.material)&&(t=!0)}),t}function C1(r,e){let t=!1;return e.traverseEntity(n=>{if(n instanceof Vt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)T1(r,n,n.material[i])&&(t=!0);else T1(r,n,n.material)&&(t=!0)}),t}function D1(r,e){"material"in r&&FO(r.material,e),"geometry"in r&&r.geometry.dispose()}function FO(r,e){Iw(r).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var Nt=class extends Dr(Vt){constructor(t,n){super(t,n);this.isAbstractMesh=!0;this.isBooleanMesh=!1;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Oe;this.booleanExclude=null;Array.isArray(n)&&t.groups.length===0&&t.addGroup(0,t.getAttribute("position").count,0)}get cloner(){return this._cloner}set cloner(t){this._cloner&&this.remove(this._cloner),t&&this.add(t),this._cloner=t}updateGeometry(t){let n=this.geometry,i=_y[n.userData.type],s=this.objectType==="NonParametric"?Object.assign({},n.userData,{geometry:n}):n.userData,o=i.build(i.normalizeInputs(t,s)),a=n.uuid;if(this.geometry.dispose(),this.geometry=o,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),Ah(this),n.getAttribute("randomColor")&&My(this),this.cloner)for(let c of this.cloner.children)c.geometry=this.geometry}shallowClone(t){return new this.constructor(this.geometry,this.material).shallowCopy(this,t)}clone(t){let n=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=Mh(n),s=this.material;return new this.constructor(i,s).copy(this,t)}copy(t,n=!0){return super.copy(t,n),t.cloner&&(this.cloner=new ih(t,t.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(t){t===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new ih(this)),this.cloner.fromClonerState(t))}fromState(t,n){return super.fromState(t),t.type==="Mesh"&&(this.setFromClonerState(t.cloner),this.castShadow=t.castShadow??!0,this.receiveShadow=t.receiveShadow??!0,this.booleanExclude=t.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Jr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),bt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)Ut(t)&&(t.freeBooleanPointer(),bt(t)&&t.invalidateUpstreamBooleanData())}};var UO=new A(0,0,1),P1=new A,I1=new A,L1=new qt,ks=class extends Nt{constructor(t=Pn.create({}),n){super(t,n);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Rt;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=t.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}fromState(t){return super.fromState(t),this.shape.update(),this}setHelperVisibility(){}updateGeometry(t){if(super.updateGeometry(t),"userData"in this.geometry){let n=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:n})}}setShape(t){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=t,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(t,n){super.updateWorldMatrix(t,n),L1.getNormalMatrix(this.matrixWorld),P1.copy(UO).applyMatrix3(L1).normalize(),I1.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(P1,I1)}clone(t){let n=this.shape.clone(),i=this.material,s=this.geometry.userData,o=Pn.create(Object.assign({},s,{shape:n})),a=new ks(o,i).copy(this,t);return a.shape=n,n.update(),a}raycast(t,n){Nt.prototype.raycast.call(this,t,n)}};function _f(r,e){return zO(r)}function zO(r){let e={parameters:r,type:r.type};if(r.type==="VectorGeometry"){let n=pt.createFromState(r.shape,r.width,r.height);e.shape=n}else r.type==="NonParametricGeometry"&&(r.data.groups&&r.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),e.geometry=new ga().parse(r));let t;try{t=Mh(e)}catch(n){console.error(n)}if(!t){let n=pt.createFromState(Za.defaultData(),100,100);e.shape=n,t=Mh(e)}return t}var je;sf.then(r=>{je=r});var N1=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),R1=new Uint32Array([0,1,2,3]),B1=new Uint8Array([4]),Lr=class{static build(r,e,t,n,i){let s,o,a,l=r?.phongAngle??e?.phongAngle??35;if(n===!1&&(l=-1),r.positionWASM!==void 0){t&&t!==0&&(je.free_bvh(t),je.free_subdivision_surface(t));try{s=Lr.allocate(r,i)}catch(c){console.error(c,r),s=Lr.allocate({positionWASM:N1,indexWASM:R1,verticesPerFaceWASM:B1},i)}je.set_destination_refinement_level(s,0),o=Lr.buildLevel(s,!0,l)}else s=t,r.phongAngle!==void 0&&(o=Lr.buildLevel(s,!0,l));return r.subdivisions!==void 0&&(je.set_destination_refinement_level(s,r.subdivisions),r.subdivisions>0?a=Lr.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(r,e){r.widthSegments>16&&(r.widthSegments=16),r.heightSegments>16&&(r.heightSegments=16),r.depthSegments>16&&(r.depthSegments=16),r.radialSegments>16&&(r.radialSegments=16),r.type==="DodecahedronGeometry"&&(r.detail=0);let t=r.shape!==void 0?e.geometry:_f(r),n,i,s,o;return{positions:n,triIndices:o}=Dy(t.getAttribute("position"),t.getIndex()),{indices:i,verticesPerFace:s}=Py(n,o,t),{positions:n,indices:i,verticesPerFace:s}}static allocate(r,e){let t,n,i,s=[],o=[];r.positionWASM&&r.positionWASM.length>0?(t=r.positionWASM,n=r.indexWASM,i=r.verticesPerFaceWASM):(t=N1,n=R1,i=B1);let a=t.length,l=n.length,c=i.length,h=t.length+s.length+o.length,u=n.length+i.length,d=h*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,f=h*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,p=je._malloc(d),g=new Float32Array(je.HEAPF32.buffer,p,h),x=new Uint32Array(je.HEAPU32.buffer,p+f,u);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),x.set(n,0),x.set(i,n.length);let v;r?.scaleBaked?.some(b=>b!==1)&&(v=new Oe().makeScale(...r.scaleBaked)),e&&(v?v.premultiply(e):v=e);let w=v?je.alloc_subdivision_surface2(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):je.alloc_subdivision_surface(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,c);return je._free(p),w}static buildLevel(r,e,t,n,i){let s=i?je.get_mesh_data2(r,e?je.Level.CONTROL:je.Level.REFINED,t,i.elements):je.get_mesh_data(r,e?je.Level.CONTROL:je.Level.REFINED,t),o=8,a=je.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),c=0,h=je.HEAPU32[a[c]>>2],u=je.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let d=je.HEAPU32[a[c]>>2],f=je.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let m=je.HEAPU32[a[c]>>2],p=je.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let g=je.HEAPU32[a[c]>>2],x=je.HEAPU32.subarray(g>>2,(g>>2)+l[c]);if(c++,n===void 0){let v=new Ie;if(v.setIndex(new ps(x,1)),v.setAttribute("position",new Se(u,3)),v.setAttribute("normal",new Se(f,3)),e){v.setAttribute("faceMap",new ps(p,1));let w=new Float32Array(f.length/3*4).fill(0);v.setAttribute("color",new Xe(w,4))}return je.free_mesh_data(s),v.userData.type="SubdivGeometry",v}n.getAttribute("position").copyArray(u),n.getAttribute("normal").copyArray(f),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,je.free_mesh_data(s)}static buildControlCageWireframe(r,e,t){let n=je.get_wireframe_data_for_base_level(r),i=4,s=je.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(2,2+2),a=0,l=je.HEAPU32[s[a]>>2],c=je.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let h=je.HEAPU32[s[a]>>2],u=je.HEAPU32.subarray(h>>2,(h>>2)+o[a]);if(e===void 0){let d=new Ie;d.setAttribute("position",new Se(c,3));let f=new Float32Array(c.length);for(let m=0,p=c.length;m<p;)f[m++]=t.r,f[m++]=t.g,f[m++]=t.b;return d.setAttribute("color",new Xe(f,3)),d.setIndex(new ps(u,1)),je.free_wireframe_data_for_base_level(n),d}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,je.free_wireframe_data_for_base_level(n)}static updateCollabMesh(r,e,t){e||je.set_destination_refinement_level(r,1);let n=t?je.get_topological_data2(r,e?je.Level.CONTROL:je.Level.REFINED,t.elements):je.get_topological_data(r,e?je.Level.CONTROL:je.Level.REFINED),i=6,s=je.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=je.HEAPU32[s[a]>>2],c=new Float32Array(je.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=je.HEAPU32[s[a]>>2],u=new Uint32Array(je.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let d=je.HEAPU32[s[a]>>2],f=new Uint8Array(je.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return je.free_topological_data(n),{positions:c,indices:u,verticesPerFace:f}}};var O1=["getX","getY","getZ"];function Dy(r,e){let t={},n=e?e.count:r.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<n;c++){let h=e?e.getX(c):c,u="";for(let d=0;d<3;d++)u+=`${~~(r[O1[d]](h)*a)},`;if(u in t)s.push(t[u]);else{for(let d=0;d<3;d++)o.push(r[O1[d]](h));t[u]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var Tf=new A,Ty=new A,Ey=new A,Cy=new A;function Py(r,e,t){let n=[],i=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0&&t.userData.shape.shapeHoles.length===0){let s=t.userData.shape.extractShapePointsToFlatArray([]),o=0;for(let l=0;l<s.length;l+=2)o+=(s[l]-s[(l===0?s.length:l)-2])*(s[l+1]+s[(l===0?s.length:l)-1]);r.length=0;let a=0;if(o<0)for(let l=0;l<s.length;l+=2)r.push(s[l],s[l+1],0),n.push(a++);else for(let l=s.length-2;l>=0;l-=2)r.push(s[l],s[l+1],0),n.push(a++);return i.push(a),{indices:n,verticesPerFace:i}}for(let s=0,o=t.capStartIndex??e.length;s<o;)if(e[s+1]===e[s+3]&&e[s+2]===e[s+5]||e[s+0]===e[s+3]&&e[s+2]===e[s+4]){Tf.set(r[e[s]*3],r[e[s]*3+1],r[e[s]*3+2]),Ty.set(r[e[s+1]*3],r[e[s+1]*3+1],r[e[s+1]*3+2]),Ey.set(r[e[s+4]*3],r[e[s+4]*3+1],r[e[s+4]*3+2]),Cy.set(r[e[s+5]*3],r[e[s+5]*3+1],r[e[s+5]*3+2]),Ty.sub(Tf).normalize(),Ey.sub(Tf).normalize(),Cy.sub(Tf).normalize();let a=Ty.cross(Ey).dot(Cy);Math.abs(a)>.005?(n.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3):(n.push(e[s],e[s+1],e[s+4],e[s+5]),i.push(4),s+=6)}else n.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3;if(t.capStartIndex!==void 0){let s=[],o=[],a=0;for(let l=0,c=0;l<r.length;l+=3,c++)r[l+2]===0&&(s.push(c),a++),r[l+2]===t.userData.parameters.depth&&o.push(c);if(t.userData.parameters.extrudeBevelSize===0){let l=o[0];o[0]=o[1],o[1]=l}s.reverse(),n.push(...s,...o),i.push(a,a)}return{indices:n,verticesPerFace:i}}var Jr={};EM(Jr,{calcBoolean:()=>VO,calcBooleanTopological:()=>kO,freeMeshSet:()=>jO,getMeshSet:()=>HO,transformMeshSet:()=>WO});var U1,z1=new Promise(r=>{U1=r}),F1=!1;async function G1(){if(F1)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.70/build",[t,n]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});U1(s),F1=!0}var ot,Sl;z1.then(r=>ot=r);function GO(r,e){let t,{positions:n,triIndices:i}=Dy(r.getAttribute("position"),r.getIndex()),s;if(e){let{indices:o,verticesPerFace:a}=Py(n,i,r);s=a.length,t=[];for(let l=0,c=0;l<s;l++){t.push(a[l]);for(let h=0;h<a[l];h++)t.push(o[c++])}}else{let o=i.length;t=Array(o+o/3),s=0;for(let a=0,l=0;l<t.length;)t[l++]=3,s++,t[l++]=i[a++],t[l++]=i[a++],t[l++]=i[a++]}return{positions:n,faceIndices:t,nFaces:s}}function k1(r){let e=r.length,t=e*Uint32Array.BYTES_PER_ELEMENT,n=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?t:n,s=ot._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(ot.HEAPU32.buffer,s,e):new Float32Array(ot.HEAPF32.buffer,s,e)).set(r,0),s}function V1(r){switch(r){case 0:return ot.OP.UNION;case 1:return ot.OP.INTERSECTION;case 2:return ot.OP.A_MINUS_B;case 3:return ot.OP.B_MINUS_A;case 4:return ot.OP.SYMMETRIC_DIFFERENCE;case 5:return ot.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function kO(r,e){Sl===void 0&&(Sl=ot.init_csg());let t=k1(r),n=ot.csg_calc_topological(Sl,t,r.length,V1(e));ot._free(t);let i=6,s=ot.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=ot.HEAPU32[s[a]>>2],c=new Float32Array(ot.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=ot.HEAPU32[s[a]>>2],u=new Uint32Array(ot.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let d=ot.HEAPU32[s[a]>>2],f=new Uint8Array(ot.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return ot.free_mesh_data(n),{positions:c,indices:u,verticesPerFace:f}}function VO(r,e,t,n){Sl===void 0&&(Sl=ot.init_csg());let i=k1(r),s=ot.csg_calc(Sl,i,r.length,n,V1(e));ot._free(i);let o=5,a=ot.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,h=ot.HEAPU32[a[c]>>2],u=ot.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let d=ot.HEAPU32[a[c]>>2],f=ot.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let m=l[c];t.setAttribute("position",new Se(u,3)),t.setAttribute("normal",new Se(f,3));let p=ot.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Rn),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ot.free_mesh_data(s),m}function HO(r,e){if(ot===void 0)return-1;let t,n,i;if(e&&r.userData.positions!==void 0){let p=r.userData;i=p.verticesPerFace.length,t=p.positions,n=Array(p.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,v=0;g<p.verticesPerFace.length;g++){n[v++]=p.verticesPerFace[g];for(let w=0;w<p.verticesPerFace[g];w++)n[v++]=p.indices[x++]}}else({positions:t,faceIndices:n,nFaces:i}=GO(r,e));let s=t.length,o=n.length,a=t.length,l=n.length,c=a*Float32Array.BYTES_PER_ELEMENT+l*Uint32Array.BYTES_PER_ELEMENT,h=a*Float32Array.BYTES_PER_ELEMENT,u=l*Uint32Array.BYTES_PER_ELEMENT,d=ot._malloc(c),f=new Float32Array(ot.HEAPF32.buffer,d,a),m=new Uint32Array(ot.HEAPU32.buffer,d+h,l);return f.set(t,0),m.set(n,0),ot.get_csg_mesh(d,s,d+h,o,i)}function WO(r,e){ot.transform_csg_mesh(r,e.elements)}function jO(r){ot.free_csg_mesh(r)}var _y={ConeGeometry:bS,CubeGeometry:wS,CylinderGeometry:xS,DodecahedronGeometry:SS,EllipseGeometry:WS,HelixGeometry:YS,IcosahedronGeometry:QS,LatheGeometry:KS,NonParametricGeometry:ZS,PolygonGeometry:JS,PyramidGeometry:$S,RectangleGeometry:e1,SphereGeometry:t1,PlaneGeometry:n1,BackdropGeometry:r1,StarGeometry:i1,TextFrameGeometry:rf,TorusGeometry:s1,TorusKnotGeometry:o1,TriangleGeometry:a1,VectorGeometry:Pn},Mh=r=>_y[r.type].create(r);var H1=new Oe;function Iy(r){let e=!1;return r.scene.objects.traverse((t,n)=>{n.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}var Ef=class extends Nt{constructor(t=new Ie,n){super(t,n);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.isBooleanMesh=!0,this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.isBooleanMesh=!0,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(t){if(this.booleanMeshSetAddress!==-1)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];bt(s)&&s.recomputeBoolean(t===!0)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(p1(s)&&s.booleanExclude===!1&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if(s.booleanMeshSetAddress=Jr.getMeshSet(s.geometry,t===!0),s.booleanMeshSetAddress===-1)return;Jr.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else bt(s)&&s.needsTransformForDownstream===!0?(Jr.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(H1.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),Jr.transformMeshSet(s.booleanMeshSetAddress,H1),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(t===!0)return Jr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let n=this.geometry;n.dispose(),this.geometry=new Ie,this.geometry.userData=n.userData,this.geometry.boundingSphere=n.boundingSphere;try{this.booleanMeshSetAddress=Jr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0}updateGeometry(t){let n=t.parameters;n.operation!==void 0&&(this.booleanOp=n.operation),n.phongAngle!==void 0&&(this.phongAngle=n.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var Ai=r=>{var e;return e=class extends r{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new Zn(30,30,30),e};var Cf=new ro,Ly=new Rn,W1=new Oe,Mi=(r,e,t,n,i=!1)=>{let s=e,o=r.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Ly.copy(s.boundingSphere),Ly.applyMatrix4(o),t.ray.intersectsSphere(Ly)===!1||(W1.copy(o).invert(),Cf.copy(t.ray).applyMatrix4(W1),s.boundingBox!==null&&Cf.intersectsBox(s.boundingBox)===!1))return;let a,l,c,h,u=s.index,d=s.attributes.position,f=s.drawRange,m,p;if(i===!1){let x=Math.max(0,f.start),v=Math.min(u.count,f.start+f.count);for(m=x,p=v;m<p;m+=3)if(l=u.getX(m),c=u.getX(m+1),h=u.getX(m+2),a=g(r,t,Cf,d,l,c,h),a){a.faceIndex=Math.floor(m/3),n.push(a);return}}else{let v=s.attributes.position,w=new A,b=new A,S=new A,M=new A,_=2,T=1/((r.scale.x+r.scale.y+r.scale.z)/3),E=T*T,C=Math.max(0,f.start),L=Math.min(v.count,f.start+f.count);for(let R=C,N=L-1;R<N;R+=_){if(w.fromBufferAttribute(v,R),b.fromBufferAttribute(v,R+1),Cf.distanceSqToSegment(w,b,M,S)>E)continue;M.applyMatrix4(r.matrixWorld);let j=t.ray.origin.distanceTo(M);j<t.near||j>t.far||n.push({distance:j,point:S.clone().applyMatrix4(r.matrixWorld),object:r})}}function g(x,v,w,b,S,M,_){let y=new A,T=new A,E=new A,C=new A,L=new A;if(y.fromBufferAttribute(b,S),T.fromBufferAttribute(b,M),E.fromBufferAttribute(b,_),w.intersectTriangle(y,T,E,!1,C)===null)return null;L.copy(C),L.applyMatrix4(x.matrixWorld);let N=v.ray.origin.distanceTo(L);return N<v.near||N>v.far?null:{faceIndex:1,distance:N,point:L.clone(),object:x}}};var Df=new A,Nr=new kr,Ny=class extends ms{constructor(t){let n=new Ie,i=new Jn({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Ae(15711266),c=new Ae(15711266),h=new Ae(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",h),u("u2","u3",h),u("u3","u1",h);function u(f,m,p){d(f,p),d(m,p)}function d(f,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[f]===void 0&&(a[f]=[]),a[f].push(s.length/3-1)}n.setAttribute("position",new Se(s,3)),n.setAttribute("color",new Se(o,3));super(n,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,n=this.pointMap,i=!0;Nr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;$r("n1",n,t,Nr,-s,-o,a),$r("n2",n,t,Nr,s,-o,a),$r("n3",n,t,Nr,-s,o,a),$r("n4",n,t,Nr,s,o,a);let l=a;$r("f1",n,t,Nr,-s,-o,l),$r("f2",n,t,Nr,s,-o,l),$r("f3",n,t,Nr,-s,o,l),$r("f4",n,t,Nr,s,o,l);let c=l,h=.5;$r("u1",n,t,Nr,s*.7*h,o*1.1,c),$r("u2",n,t,Nr,-s*.7*h,o*1.1,c),$r("u3",n,t,Nr,0,o*(1.1+.9*h),c),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function $r(r,e,t,n,i,s,o){Df.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],Df.x,Df.y,Df.z)}}var Pf=class extends Ai(Ny){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,n){Mi(this.object,this.geometry,t,n,!0)}};var Al=class extends Ai(Iu){constructor(t,n=15,i=10066329){super(t,n,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,n){Mi(this.object,Al.geometryHelper,t,n)}};var Ml=class extends Ai(Lu){constructor(t,n=15){super(n);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,n){Mi(this.object,Ml.geometryHelper,t,n)}update(){}};var _l=class extends Ai(Pu){constructor(t,n=15,i=6710886){super(t,n,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,n){Mi(this.object,_l.geometryHelper,t,n)}};var If=class extends Ai(Du){constructor(t,n=6710886){super(t,n);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,n){Mi(this.object,If.geometryHelper,t,n)}update(){if(this.object!==void 0){let t=If._vector,n=this.object.distance?this.object.distance:1e3,i=n*Math.tan(this.object.angle);this.cone.scale.set(i,i,n),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},_h=If;_h._vector=new A;var _i=(r,e)=>class extends r{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let s of this.children)Cr(s)&&s.traverseEntity(o=>{Xi(o)&&o.visible&&(o.objectHelper.visible=i)})}raycast(i,s){this.objectHelper.raycast(i,s)}fromLightState(i,s){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let o=this;i.color!==void 0&&(o.color=Ft(i.color,s)),i.intensity!==void 0&&(o.intensity=i.intensity),i.depth!==void 0&&(o.shadow.camera.far=i.depth,o.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,o.gizmos.shadowmap.visible=i.helper)}return this}};var Tl=new A,Ry=new A,mr=class extends _i(Dr(kr),Pf){constructor(t=window.innerWidth,n=window.innerHeight,i=45,s,o=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=bo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=t,this.height=n,this.orthoCamera=new ia(t*-.5,t*.5,n*.5,n*-.5,s??-5e4,o),this.perspCamera=new Zt(i,t/n,s??50,o),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(t,n){let i=new mr().fromState(n);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=t,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(t,n){t==="PerspectiveCamera"?this.perspCamera.near=n:this.orthoCamera.near=n}setZoom(t,n){n>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=n:this.orthoCamera.zoom=n)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t){super.lookAt(t),this.getWorldPosition(Tl),this.targetOffset=Tl.distanceTo(t)}getTarget(t=new A){return this.getWorldDirection(Ry),this.getWorldPosition(Tl),Ry.multiplyScalar(this.targetOffset),t.copy(Tl).add(Ry),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Tl),Tl.distanceTo(t)}updateUp(){let t=this.getWorldQuaternion(new Xt),n=new A(0,0,1).applyQuaternion(t),i=new A().copy(ct.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(t);let s=new A().copy(ct.DefaultUp).projectOnPlane(n),o=new A().crossVectors(s,i).dot(n)>=0?1:-1;this.angleOffsetFromUp=s.angleTo(i)*o}getViewFrontToObject(t){let n=t.getWorldPosition(new A),s=t.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:n.clone().add(s),target:n}}getViewToObject(t){let n=t.getWorldPosition(new A),s=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:n.clone().sub(s),target:n}}setViewplaneSize(t,n){this.left=-t*.5,this.right=t*.5,this.top=n*.5,this.bottom=-n*.5,this.aspect=t/n,this.updateProjectionMatrix()}toOrthographic(t){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||t===!0)&&this.objectHelper.update()}toPerspective(t){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||t===!0)&&this.objectHelper.update()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,n,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,n,i,s,o,a):this.orthoCamera.setViewOffset(t,n,i,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(t){this._cameraType==="PerspectiveCamera"?this.toPerspective(t):this._cameraType==="OrthographicCamera"&&this.toOrthographic(t)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,n){super.updateWorldMatrix(t,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,n){return super.copy(t,n),this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=t.targetOffset,this.updateProjectionMatrix(),this}toCameraState(t=[]){let n={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ja(n,t)}fromCameraState(t){let{orthographic:n,perspective:i}=t;return t.type!==void 0&&(this.cameraType=t.type),t.far!==void 0&&(this.far=t.far),n!==void 0&&(n.near!==void 0&&(this.orthoCamera.near=n.near),n.zoom!==void 0&&(this.orthoCamera.zoom=n.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.zoom)),t.up!==void 0&&this.up.fromArray(t.up),t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}fromState(t){return super.fromState(t),this.fromCameraState(t),this}};var Qi=class extends _i(Dr(as),Ml){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(t,n){let i=new Qi().fromState(n);return i.uuid=t,i.enableHelper=!0,i.objectHelper.update(),i}};var El=class extends _i(Dr(_u),Al){constructor(...t){super(...t);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new Ar(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,n,i){let s=new El().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&(n.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&n.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromDirectionalLightState(t,n){let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;return super.fromLightState(t,n),t.size!==void 0&&u1(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),i&&this.update(),this}fromState(t,n){return super.fromState(t),this.fromDirectionalLightState(t,n),this}};var Cl=class extends _i(Dr(Mu),_l){constructor(...t){super(...t);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new Sn(s,o),l=new po(a,new Ae(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(t,n,i){let s=new Cl().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof po&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof po&&(n.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let t in this._gizmos){let n=this._gizmos[t];if(n instanceof po){let i=this.shadow.camera,s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);n.box.set(s,o),n.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromPointLightState(t,n){return super.fromLightState(t,n),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,n){return super.fromState(t),this.fromPointLightState(t,n),this}};var j1=new A,q1=new A,X1=new Xt,Dl=class extends _i(Dr(Au),_h){constructor(...t){super(...t);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=Ge.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new Ar(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,n,i){let s=new Dl().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&(n.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&n.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),q1.setFromMatrixPosition(this.matrixWorld),X1.setFromRotationMatrix(this.matrixWorld),j1.copy(this.up).applyQuaternion(X1).negate().multiplyScalar(this.distance),this.target.position.copy(q1).add(j1),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromSpotLightState(t,n){return super.fromLightState(t,n),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,n){return super.fromState(t),this.fromSpotLightState(t,n),this}};var Y1=r=>r.tagName==="VIDEO",Pl=class{static resize(e,t,n){let i=e/t,s;if(!n.image)return;let o=n.image;Y1(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1*s/i):n.repeat.set(1,1*s/i)),i<s&&(n.imageType=="WEBCAM"?n.repeat.set(1*i/s*-1,1):n.repeat.set(1*i/s,1)),i==s&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1):n.repeat.set(1,1))}static resizeTextureLayer(e,t,n){let i=e/t,s=n.image!==void 0?n.image.width/n.image.height:1,o;i>s?o={x:1,y:s/i}:i<s?o={x:i/s,y:1}:o={x:1,y:1},n.repeat.set(o.x,o.y),n.updateMatrix()}static resizeTextureLayers(e,t,n){let i=n.userData.layers,s=i.getLayers();for(let o=0;o<s.length;o++){let a=s[o];m1(a)&&(Pl.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(e,t,n,i){let s=e/t,o,a=n.image;Y1(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,i.geometry.type.includes("Shape")?(s>o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*-1,1/t*o/s):n.repeat.set(1/e,1/t*o/s)),s<o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*s/o*-1,1/t):n.repeat.set(1/e*s/o,1/t)),s==o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*-1,1/t):n.repeat.set(1/e,1/t))):(s>o&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1*o/s):n.repeat.set(1,1*o/s)),s<o&&(n.imageType=="WEBCAM"?n.repeat.set(1*s/o*-1,1):n.repeat.set(1*s/o,1)),s==o&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1):n.repeat.set(1,1)))}};var Lf=class extends Nt{constructor(t,n){super(t,n);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(t){super.updateGeometry(t),this.material.userData.layers&&Pl.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}};var Il=class extends Nt{constructor(t,n){super(t,n);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}};var Ll=class extends Il{constructor(t,n){super(t,n);this.objectType="NonParametric"}};var Nf=class extends ys{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new vs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){let l;try{l=JSON.parse(a)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),l=JSON.parse(a.substring(65,a.length-2))}let c=s.parse(l);t&&t(c)},n,i)}parse(e){return new By(e)}},By=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let n=[],i=XO(e,t,this.data);for(let s=0,o=i.length;s<o;s++)Array.prototype.push.apply(n,i[s].toShapes());return n}};function XO(r,e,t){let n=Array.from(r),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[],a=0,l=0;for(let c=0;c<n.length;c++){let h=n[c];if(h===`
|
|
4902
|
+
`,M1=new dt({vertexShader:LO,fragmentShader:IO,uniforms:{depthContrast:{value:1}}});function NO(r,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=r.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=r.depthTexture}function RO(r,e){e.uniforms[`f${e.id}_normalMap`].value=r.texture,e.uniforms[`f${e.id}_depthMap`].value=r.depthTexture}function BO(r){if(r.geometry.attributes.extrudeNormals)return;let e=new Map,t=r.geometry.attributes.position.array,n=r.geometry.attributes.normal.array,i=new Float32Array(t.length);for(let s=0;s<t.length;s+=3){let o=`${t[s]}_${t[s+1]}_${t[s+2]}`,a=new A(n[s],n[s+1],n[s+2]);e.has(o)?e.get(o)?.normals.push(a):e.set(o,{normals:[a],result:new A})}e.forEach((s,o)=>{for(let a of s.normals)s.result.add(a);s.result.divideScalar(s.normals.length)});for(let s=0;s<t.length;s+=3){let o=`${t[s]}_${t[s+1]}_${t[s+2]}`,a=e.get(o)?.result;a&&(i[s]=a.x,i[s+1]=a.y,i[s+2]=a.z)}r.geometry.setAttribute("extrudeNormal",new Se(i,3))}function OO(r){if(r.geometry.attributes.extrudeNormals)return;let e=r.geometry.attributes.position.array,t=new Float32Array(e.length),n=new A;for(let i=0;i<e.length;i+=3)n.set(e[i],e[i+1],e[i+2]).normalize(),t[i]=n.x,t[i+1]=n.y,t[i+2]=n.z;r.geometry.setAttribute("extrudeNormal",new Se(t,3))}function Ah(r){r.objectType==="Mesh2D"?OO(r):BO(r)}function My(r){let e=r.geometry.attributes.position.array,t=new Float32Array(e.length),n=parseInt(r.uuid.replace(/\D/g,"")),i=[Ge.seededRandom(n),Ge.seededRandom(n+1e4),Ge.seededRandom(n+2e4)];for(let s=0;s<e.length;s++)t[s]=i[s%3];r.geometry.setAttribute("randomColor",new Xe(t,3))}function _1(r,e,t){if(!t.userData.layers)return!1;let n=!1,i=t.userData.layers.getLayersOfType("transmission"),s=t.userData.layers.getLayersOfType("outline");return s.length>0&&(e.layers.set(8),i.length===0&&e.layers.enable(3),e.cloner?.refreshClonerMasks(),n=!0,r!==void 0&&s.forEach(o=>RO(r,o)),My(e),Ah(e)),i.length===0&&s.length===0&&e.layers.set(0),n}function T1(r,e,t){if(!t.userData.layers)return!1;let n=!1,i=t.userData.layers.getLayersOfType("transmission"),s=t.userData.layers.getLayersOfType("outline");return i.length>0&&(e.layers.set(3),s.length>0&&e.layers.enable(8),e.cloner?.refreshClonerMasks(),n=!0,r!==void 0&&i.forEach(o=>NO(r,o))),i.length===0&&s.length===0&&e.layers.set(0),n}function E1(r,e){let t=!1;return e.traverseEntity(n=>{if(n instanceof Vt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)_1(r,n,n.material[i])&&(t=!0);else _1(r,n,n.material)&&(t=!0)}),t}function C1(r,e){let t=!1;return e.traverseEntity(n=>{if(n instanceof Vt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)T1(r,n,n.material[i])&&(t=!0);else T1(r,n,n.material)&&(t=!0)}),t}function D1(r,e){"material"in r&&FO(r.material,e),"geometry"in r&&r.geometry.dispose()}function FO(r,e){Lw(r).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var Nt=class extends Dr(Vt){constructor(t,n){super(t,n);this.isAbstractMesh=!0;this.isBooleanMesh=!1;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Oe;this.booleanExclude=null;Array.isArray(n)&&t.groups.length===0&&t.addGroup(0,t.getAttribute("position").count,0)}get cloner(){return this._cloner}set cloner(t){this._cloner&&this.remove(this._cloner),t&&this.add(t),this._cloner=t}updateGeometry(t){let n=this.geometry,i=_y[n.userData.type],s=this.objectType==="NonParametric"?Object.assign({},n.userData,{geometry:n}):n.userData,o=i.build(i.normalizeInputs(t,s)),a=n.uuid;if(this.geometry.dispose(),this.geometry=o,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),Ah(this),n.getAttribute("randomColor")&&My(this),this.cloner)for(let c of this.cloner.children)c.geometry=this.geometry}shallowClone(t){return new this.constructor(this.geometry,this.material).shallowCopy(this,t)}clone(t){let n=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=Mh(n),s=this.material;return new this.constructor(i,s).copy(this,t)}copy(t,n=!0){return super.copy(t,n),t.cloner&&(this.cloner=new ih(t,t.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(t){t===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new ih(this)),this.cloner.fromClonerState(t))}fromState(t,n){return super.fromState(t),t.type==="Mesh"&&(this.setFromClonerState(t.cloner),this.castShadow=t.castShadow??!0,this.receiveShadow=t.receiveShadow??!0,this.booleanExclude=t.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Jr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),bt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)Ut(t)&&(t.freeBooleanPointer(),bt(t)&&t.invalidateUpstreamBooleanData())}};var UO=new A(0,0,1),P1=new A,L1=new A,I1=new qt,ks=class extends Nt{constructor(t=Pn.create({}),n){super(t,n);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Rt;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=t.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}fromState(t){return super.fromState(t),this.shape.update(),this}setHelperVisibility(){}updateGeometry(t){if(super.updateGeometry(t),"userData"in this.geometry){let n=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:n})}}setShape(t){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=t,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(t,n){super.updateWorldMatrix(t,n),I1.getNormalMatrix(this.matrixWorld),P1.copy(UO).applyMatrix3(I1).normalize(),L1.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(P1,L1)}clone(t){let n=this.shape.clone(),i=this.material,s=this.geometry.userData,o=Pn.create(Object.assign({},s,{shape:n})),a=new ks(o,i).copy(this,t);return a.shape=n,n.update(),a}raycast(t,n){Nt.prototype.raycast.call(this,t,n)}};function _f(r,e){return zO(r)}function zO(r){let e={parameters:r,type:r.type};if(r.type==="VectorGeometry"){let n=pt.createFromState(r.shape,r.width,r.height);e.shape=n}else r.type==="NonParametricGeometry"&&(r.data.groups&&r.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),e.geometry=new ga().parse(r));let t;try{t=Mh(e)}catch(n){console.error(n)}if(!t){let n=pt.createFromState(Za.defaultData(),100,100);e.shape=n,t=Mh(e)}return t}var je;sf.then(r=>{je=r});var N1=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),R1=new Uint32Array([0,1,2,3]),B1=new Uint8Array([4]),Ir=class{static build(r,e,t,n,i){let s,o,a,l=r?.phongAngle??e?.phongAngle??35;if(n===!1&&(l=-1),r.positionWASM!==void 0){t&&t!==0&&(je.free_bvh(t),je.free_subdivision_surface(t));try{s=Ir.allocate(r,i)}catch(c){console.error(c,r),s=Ir.allocate({positionWASM:N1,indexWASM:R1,verticesPerFaceWASM:B1},i)}je.set_destination_refinement_level(s,0),o=Ir.buildLevel(s,!0,l)}else s=t,r.phongAngle!==void 0&&(o=Ir.buildLevel(s,!0,l));return r.subdivisions!==void 0&&(je.set_destination_refinement_level(s,r.subdivisions),r.subdivisions>0?a=Ir.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(r,e){r.widthSegments>16&&(r.widthSegments=16),r.heightSegments>16&&(r.heightSegments=16),r.depthSegments>16&&(r.depthSegments=16),r.radialSegments>16&&(r.radialSegments=16),r.type==="DodecahedronGeometry"&&(r.detail=0);let t=r.shape!==void 0?e.geometry:_f(r),n,i,s,o;return{positions:n,triIndices:o}=Dy(t.getAttribute("position"),t.getIndex()),{indices:i,verticesPerFace:s}=Py(n,o,t),{positions:n,indices:i,verticesPerFace:s}}static allocate(r,e){let t,n,i,s=[],o=[];r.positionWASM&&r.positionWASM.length>0?(t=r.positionWASM,n=r.indexWASM,i=r.verticesPerFaceWASM):(t=N1,n=R1,i=B1);let a=t.length,l=n.length,c=i.length,h=t.length+s.length+o.length,u=n.length+i.length,d=h*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,f=h*Float32Array.BYTES_PER_ELEMENT,m=u*Uint32Array.BYTES_PER_ELEMENT,p=je._malloc(d),g=new Float32Array(je.HEAPF32.buffer,p,h),x=new Uint32Array(je.HEAPU32.buffer,p+f,u);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),x.set(n,0),x.set(i,n.length);let v;r?.scaleBaked?.some(b=>b!==1)&&(v=new Oe().makeScale(...r.scaleBaked)),e&&(v?v.premultiply(e):v=e);let w=v?je.alloc_subdivision_surface2(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,c,v.elements):je.alloc_subdivision_surface(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,c);return je._free(p),w}static buildLevel(r,e,t,n,i){let s=i?je.get_mesh_data2(r,e?je.Level.CONTROL:je.Level.REFINED,t,i.elements):je.get_mesh_data(r,e?je.Level.CONTROL:je.Level.REFINED,t),o=8,a=je.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),c=0,h=je.HEAPU32[a[c]>>2],u=je.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let d=je.HEAPU32[a[c]>>2],f=je.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let m=je.HEAPU32[a[c]>>2],p=je.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let g=je.HEAPU32[a[c]>>2],x=je.HEAPU32.subarray(g>>2,(g>>2)+l[c]);if(c++,n===void 0){let v=new Le;if(v.setIndex(new ps(x,1)),v.setAttribute("position",new Se(u,3)),v.setAttribute("normal",new Se(f,3)),e){v.setAttribute("faceMap",new ps(p,1));let w=new Float32Array(f.length/3*4).fill(0);v.setAttribute("color",new Xe(w,4))}return je.free_mesh_data(s),v.userData.type="SubdivGeometry",v}n.getAttribute("position").copyArray(u),n.getAttribute("normal").copyArray(f),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,je.free_mesh_data(s)}static buildControlCageWireframe(r,e,t){let n=je.get_wireframe_data_for_base_level(r),i=4,s=je.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(2,2+2),a=0,l=je.HEAPU32[s[a]>>2],c=je.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let h=je.HEAPU32[s[a]>>2],u=je.HEAPU32.subarray(h>>2,(h>>2)+o[a]);if(e===void 0){let d=new Le;d.setAttribute("position",new Se(c,3));let f=new Float32Array(c.length);for(let m=0,p=c.length;m<p;)f[m++]=t.r,f[m++]=t.g,f[m++]=t.b;return d.setAttribute("color",new Xe(f,3)),d.setIndex(new ps(u,1)),je.free_wireframe_data_for_base_level(n),d}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,je.free_wireframe_data_for_base_level(n)}static updateCollabMesh(r,e,t){e||je.set_destination_refinement_level(r,1);let n=t?je.get_topological_data2(r,e?je.Level.CONTROL:je.Level.REFINED,t.elements):je.get_topological_data(r,e?je.Level.CONTROL:je.Level.REFINED),i=6,s=je.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=je.HEAPU32[s[a]>>2],c=new Float32Array(je.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=je.HEAPU32[s[a]>>2],u=new Uint32Array(je.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let d=je.HEAPU32[s[a]>>2],f=new Uint8Array(je.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return je.free_topological_data(n),{positions:c,indices:u,verticesPerFace:f}}};var O1=["getX","getY","getZ"];function Dy(r,e){let t={},n=e?e.count:r.count,i=0,s=[],o=[],a=1e4;for(let c=0;c<n;c++){let h=e?e.getX(c):c,u="";for(let d=0;d<3;d++)u+=`${~~(r[O1[d]](h)*a)},`;if(u in t)s.push(t[u]);else{for(let d=0;d<3;d++)o.push(r[O1[d]](h));t[u]=i,s.push(i),i++}}let l=[];for(let c=0;c<s.length;c+=3)s[c]===s[c+1]||s[c]===s[c+2]||s[c+1]===s[c+2]||l.push(s[c],s[c+1],s[c+2]);return{positions:o,triIndices:l}}var Tf=new A,Ty=new A,Ey=new A,Cy=new A;function Py(r,e,t){let n=[],i=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0&&t.userData.shape.shapeHoles.length===0){let s=t.userData.shape.extractShapePointsToFlatArray([]),o=0;for(let l=0;l<s.length;l+=2)o+=(s[l]-s[(l===0?s.length:l)-2])*(s[l+1]+s[(l===0?s.length:l)-1]);r.length=0;let a=0;if(o<0)for(let l=0;l<s.length;l+=2)r.push(s[l],s[l+1],0),n.push(a++);else for(let l=s.length-2;l>=0;l-=2)r.push(s[l],s[l+1],0),n.push(a++);return i.push(a),{indices:n,verticesPerFace:i}}for(let s=0,o=t.capStartIndex??e.length;s<o;)if(e[s+1]===e[s+3]&&e[s+2]===e[s+5]||e[s+0]===e[s+3]&&e[s+2]===e[s+4]){Tf.set(r[e[s]*3],r[e[s]*3+1],r[e[s]*3+2]),Ty.set(r[e[s+1]*3],r[e[s+1]*3+1],r[e[s+1]*3+2]),Ey.set(r[e[s+4]*3],r[e[s+4]*3+1],r[e[s+4]*3+2]),Cy.set(r[e[s+5]*3],r[e[s+5]*3+1],r[e[s+5]*3+2]),Ty.sub(Tf).normalize(),Ey.sub(Tf).normalize(),Cy.sub(Tf).normalize();let a=Ty.cross(Ey).dot(Cy);Math.abs(a)>.005?(n.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3):(n.push(e[s],e[s+1],e[s+4],e[s+5]),i.push(4),s+=6)}else n.push(e[s],e[s+1],e[s+2]),i.push(3),s+=3;if(t.capStartIndex!==void 0){let s=[],o=[],a=0;for(let l=0,c=0;l<r.length;l+=3,c++)r[l+2]===0&&(s.push(c),a++),r[l+2]===t.userData.parameters.depth&&o.push(c);if(t.userData.parameters.extrudeBevelSize===0){let l=o[0];o[0]=o[1],o[1]=l}s.reverse(),n.push(...s,...o),i.push(a,a)}return{indices:n,verticesPerFace:i}}var Jr={};EM(Jr,{calcBoolean:()=>VO,calcBooleanTopological:()=>kO,freeMeshSet:()=>jO,getMeshSet:()=>HO,transformMeshSet:()=>WO});var U1,z1=new Promise(r=>{U1=r}),F1=!1;async function G1(){if(F1)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.71/build",[t,n]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});U1(s),F1=!0}var ot,Sl;z1.then(r=>ot=r);function GO(r,e){let t,{positions:n,triIndices:i}=Dy(r.getAttribute("position"),r.getIndex()),s;if(e){let{indices:o,verticesPerFace:a}=Py(n,i,r);s=a.length,t=[];for(let l=0,c=0;l<s;l++){t.push(a[l]);for(let h=0;h<a[l];h++)t.push(o[c++])}}else{let o=i.length;t=Array(o+o/3),s=0;for(let a=0,l=0;l<t.length;)t[l++]=3,s++,t[l++]=i[a++],t[l++]=i[a++],t[l++]=i[a++]}return{positions:n,faceIndices:t,nFaces:s}}function k1(r){let e=r.length,t=e*Uint32Array.BYTES_PER_ELEMENT,n=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?t:n,s=ot._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(ot.HEAPU32.buffer,s,e):new Float32Array(ot.HEAPF32.buffer,s,e)).set(r,0),s}function V1(r){switch(r){case 0:return ot.OP.UNION;case 1:return ot.OP.INTERSECTION;case 2:return ot.OP.A_MINUS_B;case 3:return ot.OP.B_MINUS_A;case 4:return ot.OP.SYMMETRIC_DIFFERENCE;case 5:return ot.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function kO(r,e){Sl===void 0&&(Sl=ot.init_csg());let t=k1(r),n=ot.csg_calc_topological(Sl,t,r.length,V1(e));ot._free(t);let i=6,s=ot.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=ot.HEAPU32[s[a]>>2],c=new Float32Array(ot.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let h=ot.HEAPU32[s[a]>>2],u=new Uint32Array(ot.HEAPU32.subarray(h>>2,(h>>2)+o[a]));a++;let d=ot.HEAPU32[s[a]>>2],f=new Uint8Array(ot.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return ot.free_mesh_data(n),{positions:c,indices:u,verticesPerFace:f}}function VO(r,e,t,n){Sl===void 0&&(Sl=ot.init_csg());let i=k1(r),s=ot.csg_calc(Sl,i,r.length,n,V1(e));ot._free(i);let o=5,a=ot.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),c=0,h=ot.HEAPU32[a[c]>>2],u=ot.HEAPF32.subarray(h>>2,(h>>2)+l[c]);c++;let d=ot.HEAPU32[a[c]>>2],f=ot.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let m=l[c];t.setAttribute("position",new Se(u,3)),t.setAttribute("normal",new Se(f,3));let p=ot.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new Rn),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},ot.free_mesh_data(s),m}function HO(r,e){if(ot===void 0)return-1;let t,n,i;if(e&&r.userData.positions!==void 0){let p=r.userData;i=p.verticesPerFace.length,t=p.positions,n=Array(p.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,v=0;g<p.verticesPerFace.length;g++){n[v++]=p.verticesPerFace[g];for(let w=0;w<p.verticesPerFace[g];w++)n[v++]=p.indices[x++]}}else({positions:t,faceIndices:n,nFaces:i}=GO(r,e));let s=t.length,o=n.length,a=t.length,l=n.length,c=a*Float32Array.BYTES_PER_ELEMENT+l*Uint32Array.BYTES_PER_ELEMENT,h=a*Float32Array.BYTES_PER_ELEMENT,u=l*Uint32Array.BYTES_PER_ELEMENT,d=ot._malloc(c),f=new Float32Array(ot.HEAPF32.buffer,d,a),m=new Uint32Array(ot.HEAPU32.buffer,d+h,l);return f.set(t,0),m.set(n,0),ot.get_csg_mesh(d,s,d+h,o,i)}function WO(r,e){ot.transform_csg_mesh(r,e.elements)}function jO(r){ot.free_csg_mesh(r)}var _y={ConeGeometry:bS,CubeGeometry:wS,CylinderGeometry:xS,DodecahedronGeometry:SS,EllipseGeometry:WS,HelixGeometry:YS,IcosahedronGeometry:QS,LatheGeometry:KS,NonParametricGeometry:ZS,PolygonGeometry:JS,PyramidGeometry:$S,RectangleGeometry:e1,SphereGeometry:t1,PlaneGeometry:n1,BackdropGeometry:r1,StarGeometry:i1,TextFrameGeometry:rf,TorusGeometry:s1,TorusKnotGeometry:o1,TriangleGeometry:a1,VectorGeometry:Pn},Mh=r=>_y[r.type].create(r);var H1=new Oe;function Ly(r){let e=!1;return r.scene.objects.traverse((t,n)=>{n.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}var Ef=class extends Nt{constructor(t=new Le,n){super(t,n);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.isBooleanMesh=!0,this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.isBooleanMesh=!0,this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(t){if(this.booleanMeshSetAddress!==-1)return;for(let i=0;i<this.children.length;i++){let s=this.children[i];bt(s)&&s.recomputeBoolean(t===!0)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(p1(s)&&s.booleanExclude===!1&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(s.booleanMeshSetAddress===-1){if(s.booleanMeshSetAddress=Jr.getMeshSet(s.geometry,t===!0),s.booleanMeshSetAddress===-1)return;Jr.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1}else bt(s)&&s.needsTransformForDownstream===!0?(Jr.transformMeshSet(s.booleanMeshSetAddress,s.matrix),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(H1.multiplyMatrices(s.matrix,s.booleanMatrixInvOld),Jr.transformMeshSet(s.booleanMeshSetAddress,H1),s.booleanMatrixInvOld.copy(s.matrix).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(t===!0)return Jr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let n=this.geometry;n.dispose(),this.geometry=new Le,this.geometry.userData=n.userData,this.geometry.boundingSphere=n.boundingSphere;try{this.booleanMeshSetAddress=Jr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0}updateGeometry(t){let n=t.parameters;n.operation!==void 0&&(this.booleanOp=n.operation),n.phongAngle!==void 0&&(this.phongAngle=n.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var Ai=r=>{var e;return e=class extends r{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new Zn(30,30,30),e};var Cf=new ro,Iy=new Rn,W1=new Oe,Mi=(r,e,t,n,i=!1)=>{let s=e,o=r.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Iy.copy(s.boundingSphere),Iy.applyMatrix4(o),t.ray.intersectsSphere(Iy)===!1||(W1.copy(o).invert(),Cf.copy(t.ray).applyMatrix4(W1),s.boundingBox!==null&&Cf.intersectsBox(s.boundingBox)===!1))return;let a,l,c,h,u=s.index,d=s.attributes.position,f=s.drawRange,m,p;if(i===!1){let x=Math.max(0,f.start),v=Math.min(u.count,f.start+f.count);for(m=x,p=v;m<p;m+=3)if(l=u.getX(m),c=u.getX(m+1),h=u.getX(m+2),a=g(r,t,Cf,d,l,c,h),a){a.faceIndex=Math.floor(m/3),n.push(a);return}}else{let v=s.attributes.position,w=new A,b=new A,S=new A,M=new A,_=2,T=1/((r.scale.x+r.scale.y+r.scale.z)/3),E=T*T,C=Math.max(0,f.start),I=Math.min(v.count,f.start+f.count);for(let R=C,N=I-1;R<N;R+=_){if(w.fromBufferAttribute(v,R),b.fromBufferAttribute(v,R+1),Cf.distanceSqToSegment(w,b,M,S)>E)continue;M.applyMatrix4(r.matrixWorld);let j=t.ray.origin.distanceTo(M);j<t.near||j>t.far||n.push({distance:j,point:S.clone().applyMatrix4(r.matrixWorld),object:r})}}function g(x,v,w,b,S,M,_){let y=new A,T=new A,E=new A,C=new A,I=new A;if(y.fromBufferAttribute(b,S),T.fromBufferAttribute(b,M),E.fromBufferAttribute(b,_),w.intersectTriangle(y,T,E,!1,C)===null)return null;I.copy(C),I.applyMatrix4(x.matrixWorld);let N=v.ray.origin.distanceTo(I);return N<v.near||N>v.far?null:{faceIndex:1,distance:N,point:I.clone(),object:x}}};var Df=new A,Nr=new kr,Ny=class extends ms{constructor(t){let n=new Le,i=new Jn({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Ae(15711266),c=new Ae(15711266),h=new Ae(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",h),u("u2","u3",h),u("u3","u1",h);function u(f,m,p){d(f,p),d(m,p)}function d(f,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[f]===void 0&&(a[f]=[]),a[f].push(s.length/3-1)}n.setAttribute("position",new Se(s,3)),n.setAttribute("color",new Se(o,3));super(n,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,n=this.pointMap,i=!0;Nr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;$r("n1",n,t,Nr,-s,-o,a),$r("n2",n,t,Nr,s,-o,a),$r("n3",n,t,Nr,-s,o,a),$r("n4",n,t,Nr,s,o,a);let l=a;$r("f1",n,t,Nr,-s,-o,l),$r("f2",n,t,Nr,s,-o,l),$r("f3",n,t,Nr,-s,o,l),$r("f4",n,t,Nr,s,o,l);let c=l,h=.5;$r("u1",n,t,Nr,s*.7*h,o*1.1,c),$r("u2",n,t,Nr,-s*.7*h,o*1.1,c),$r("u3",n,t,Nr,0,o*(1.1+.9*h),c),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function $r(r,e,t,n,i,s,o){Df.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,h=a.length;c<h;c++)l.setXYZ(a[c],Df.x,Df.y,Df.z)}}var Pf=class extends Ai(Ny){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,n){Mi(this.object,this.geometry,t,n,!0)}};var Al=class extends Ai(Lu){constructor(t,n=15,i=10066329){super(t,n,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,n){Mi(this.object,Al.geometryHelper,t,n)}};var Ml=class extends Ai(Iu){constructor(t,n=15){super(n);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,n){Mi(this.object,Ml.geometryHelper,t,n)}update(){}};var _l=class extends Ai(Pu){constructor(t,n=15,i=6710886){super(t,n,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,n){Mi(this.object,_l.geometryHelper,t,n)}};var Lf=class extends Ai(Du){constructor(t,n=6710886){super(t,n);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,n){Mi(this.object,Lf.geometryHelper,t,n)}update(){if(this.object!==void 0){let t=Lf._vector,n=this.object.distance?this.object.distance:1e3,i=n*Math.tan(this.object.angle);this.cone.scale.set(i,i,n),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},_h=Lf;_h._vector=new A;var _i=(r,e)=>class extends r{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let s of this.children)Cr(s)&&s.traverseEntity(o=>{Xi(o)&&o.visible&&(o.objectHelper.visible=i)})}raycast(i,s){this.objectHelper.raycast(i,s)}fromLightState(i,s){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let o=this;i.color!==void 0&&(o.color=Ft(i.color,s)),i.intensity!==void 0&&(o.intensity=i.intensity),i.depth!==void 0&&(o.shadow.camera.far=i.depth,o.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,o.gizmos.shadowmap.visible=i.helper)}return this}};var Tl=new A,Ry=new A,mr=class extends _i(Dr(kr),Pf){constructor(t=window.innerWidth,n=window.innerHeight,i=45,s,o=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=bo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=t,this.height=n,this.orthoCamera=new ia(t*-.5,t*.5,n*.5,n*-.5,s??-5e4,o),this.perspCamera=new Zt(i,t/n,s??50,o),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(t,n){let i=new mr().fromState(n);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=t,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(t,n){t==="PerspectiveCamera"?this.perspCamera.near=n:this.orthoCamera.near=n}setZoom(t,n){n>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=n:this.orthoCamera.zoom=n)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t){super.lookAt(t),this.getWorldPosition(Tl),this.targetOffset=Tl.distanceTo(t)}getTarget(t=new A){return this.getWorldDirection(Ry),this.getWorldPosition(Tl),Ry.multiplyScalar(this.targetOffset),t.copy(Tl).add(Ry),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Tl),Tl.distanceTo(t)}updateUp(){let t=this.getWorldQuaternion(new Xt),n=new A(0,0,1).applyQuaternion(t),i=new A().copy(ct.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(t);let s=new A().copy(ct.DefaultUp).projectOnPlane(n),o=new A().crossVectors(s,i).dot(n)>=0?1:-1;this.angleOffsetFromUp=s.angleTo(i)*o}getViewFrontToObject(t){let n=t.getWorldPosition(new A),s=t.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:n.clone().add(s),target:n}}getViewToObject(t){let n=t.getWorldPosition(new A),s=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:n.clone().sub(s),target:n}}setViewplaneSize(t,n){this.left=-t*.5,this.right=t*.5,this.top=n*.5,this.bottom=-n*.5,this.aspect=t/n,this.updateProjectionMatrix()}toOrthographic(t){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||t===!0)&&this.objectHelper.update()}toPerspective(t){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||t===!0)&&this.objectHelper.update()}setFocalLength(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,n,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,n,i,s,o,a):this.orthoCamera.setViewOffset(t,n,i,s,o,a)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(t){this._cameraType==="PerspectiveCamera"?this.toPerspective(t):this._cameraType==="OrthographicCamera"&&this.toOrthographic(t)}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,n){super.updateWorldMatrix(t,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,n){return super.copy(t,n),this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=t.targetOffset,this.updateProjectionMatrix(),this}toCameraState(t=[]){let n={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return ja(n,t)}fromCameraState(t){let{orthographic:n,perspective:i}=t;return t.type!==void 0&&(this.cameraType=t.type),t.far!==void 0&&(this.far=t.far),n!==void 0&&(n.near!==void 0&&(this.orthoCamera.near=n.near),n.zoom!==void 0&&(this.orthoCamera.zoom=n.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.zoom)),t.up!==void 0&&this.up.fromArray(t.up),t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}fromState(t){return super.fromState(t),this.fromCameraState(t),this}};var Qi=class extends _i(Dr(as),Ml){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(t,n){let i=new Qi().fromState(n);return i.uuid=t,i.enableHelper=!0,i.objectHelper.update(),i}};var El=class extends _i(Dr(_u),Al){constructor(...t){super(...t);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=-1e4,i.far=2500;let s=new Ar(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,n,i){let s=new El().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&(n.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&n.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromDirectionalLightState(t,n){let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;return super.fromLightState(t,n),t.size!==void 0&&u1(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),i&&this.update(),this}fromState(t,n){return super.fromState(t),this.fromDirectionalLightState(t,n),this}};var Cl=class extends _i(Dr(Mu),_l){constructor(...t){super(...t);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new Sn(s,o),l=new po(a,new Ae(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(t,n,i){let s=new Cl().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof po&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof po&&(n.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let t in this._gizmos){let n=this._gizmos[t];if(n instanceof po){let i=this.shadow.camera,s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);n.box.set(s,o),n.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromPointLightState(t,n){return super.fromLightState(t,n),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,n){return super.fromState(t),this.fromPointLightState(t,n),this}};var j1=new A,q1=new A,X1=new Xt,Dl=class extends _i(Dr(Au),_h){constructor(...t){super(...t);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1;let i=this.shadow.camera;i.fov=Ge.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new Ar(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,n,i){let s=new Dl().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&(n.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Ar&&n.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),q1.setFromMatrixPosition(this.matrixWorld),X1.setFromRotationMatrix(this.matrixWorld),j1.copy(this.up).applyQuaternion(X1).negate().multiplyScalar(this.distance),this.target.position.copy(q1).add(j1),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}fromSpotLightState(t,n){return super.fromLightState(t,n),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,n){return super.fromState(t),this.fromSpotLightState(t,n),this}};var Y1=r=>r.tagName==="VIDEO",Pl=class{static resize(e,t,n){let i=e/t,s;if(!n.image)return;let o=n.image;Y1(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1*s/i):n.repeat.set(1,1*s/i)),i<s&&(n.imageType=="WEBCAM"?n.repeat.set(1*i/s*-1,1):n.repeat.set(1*i/s,1)),i==s&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1):n.repeat.set(1,1))}static resizeTextureLayer(e,t,n){let i=e/t,s=n.image!==void 0?n.image.width/n.image.height:1,o;i>s?o={x:1,y:s/i}:i<s?o={x:i/s,y:1}:o={x:1,y:1},n.repeat.set(o.x,o.y),n.updateMatrix()}static resizeTextureLayers(e,t,n){let i=n.userData.layers,s=i.getLayers();for(let o=0;o<s.length;o++){let a=s[o];m1(a)&&(Pl.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(e,t,n,i){let s=e/t,o,a=n.image;Y1(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,i.geometry.type.includes("Shape")?(s>o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*-1,1/t*o/s):n.repeat.set(1/e,1/t*o/s)),s<o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*s/o*-1,1/t):n.repeat.set(1/e*s/o,1/t)),s==o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*-1,1/t):n.repeat.set(1/e,1/t))):(s>o&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1*o/s):n.repeat.set(1,1*o/s)),s<o&&(n.imageType=="WEBCAM"?n.repeat.set(1*s/o*-1,1):n.repeat.set(1*s/o,1)),s==o&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1):n.repeat.set(1,1)))}};var If=class extends Nt{constructor(t,n){super(t,n);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(t){super.updateGeometry(t),this.material.userData.layers&&Pl.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}};var Ll=class extends Nt{constructor(t,n){super(t,n);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}};var Il=class extends Ll{constructor(t,n){super(t,n);this.objectType="NonParametric"}};var Nf=class extends ys{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new vs(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){let l;try{l=JSON.parse(a)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),l=JSON.parse(a.substring(65,a.length-2))}let c=s.parse(l);t&&t(c)},n,i)}parse(e){return new By(e)}},By=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let n=[],i=XO(e,t,this.data);for(let s=0,o=i.length;s<o;s++)Array.prototype.push.apply(n,i[s].toShapes());return n}};function XO(r,e,t){let n=Array.from(r),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[],a=0,l=0;for(let c=0;c<n.length;c++){let h=n[c];if(h===`
|
|
4891
4903
|
`)a=0,l-=s;else{let u=YO(h,i,a,l,t);a+=u.offsetX,o.push(u.path)}}return o}function YO(r,e,t,n,i){let s=i.glyphs[r]||i.glyphs["?"];if(!s){console.error('THREE.Font: character "'+r+'" does not exists in font family '+i.familyName+".");return}let o=new Nu,a,l,c,h,u,d,f,m;if(s.o){let p=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let g=0,x=p.length;g<x;)switch(p[g++]){case"m":a=p[g++]*e+t,l=p[g++]*e+n,o.moveTo(a,l);break;case"l":a=p[g++]*e+t,l=p[g++]*e+n,o.lineTo(a,l);break;case"q":c=p[g++]*e+t,h=p[g++]*e+n,u=p[g++]*e+t,d=p[g++]*e+n,o.quadraticCurveTo(u,d,c,h);break;case"b":c=p[g++]*e+t,h=p[g++]*e+n,u=p[g++]*e+t,d=p[g++]*e+n,f=p[g++]*e+t,m=p[g++]*e+n,o.bezierCurveTo(u,d,f,m,c,h);break}}return{offsetX:s.ha*e,path:o}}var en=class extends Vt{constructor({char:t,originalChar:n,fontFamily:i,letterSpacing:s,fontSize:o,LOD:a=16},l=new hi({color:0,opacity:1,visible:!0,transparent:!0,side:hn})){let c=en.loadChar(t,i,a);super(c.geometry,l);this.char=t,this.originalChar=n??t,this.fontFamily=i,this.letterSpacing=s,this.fontSize=o,this.LOD=a,this.resolution=c.resolution,this.glyphsHa=c.glyphsHa,this.localPosition=new B,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return en._fontPath}static set FONTS_PATH(t){en._fontPath=t}updatePosition(t,n){this.localPosition.copy(t);let i=new A(this.localPosition.x,-this.localPosition.y,0);this.position.copy(i).add(n)}updateFontSize(t){let n=t/this.resolution;this.fontSize=t,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*n*this.letterSpacing}updateFontFamily(t){if(this.fontFamily===t)return;this.fontFamily=t;let n=en.loadChar(this.char,t,this.LOD);this.geometry=n.geometry,this.resolution=n.resolution,this.glyphsHa=n.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(t){if(this.char===t)return;this.char=t;let n=en.loadChar(t,this.fontFamily,this.LOD);this.geometry=n.geometry,this.resolution=n.resolution,this.glyphsHa=n.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(t){this.letterSpacing!==t&&(this.letterSpacing=t,this.updateFontSize(this.fontSize))}updateLOD(t){if(this.LOD===t)return;this.LOD=t;let n=en.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=n.geometry,this.resolution=n.resolution,this.glyphsHa=n.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let t={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new en(t).copy(this)}static loadFont(t){return new Promise(function(n,i){en.fontCache[t]?n(en.fontCache[t]):new Nf().load(en.FONTS_PATH+t+".json",o=>{en.fontCache[t]=o,n(o)},void 0,i)})}static loadChar(t,n,i){if(en.charCache[t]){if(en.charCache[t][i]&&en.charCache[t][i].fontFamily===n)return en.charCache[t][i]}else en.charCache[t]={};let s=en.fontCache[n],o=s.generateShapes(t,1);return en.charCache[t][i]={geometry:new da(o,i),fontFamily:n,resolution:s.data.resolution,glyphsHa:s.data.glyphs[t].ha},en.charCache[t][i]}},gr=en;gr.charCache={},gr.fontCache={},gr._fontPath="/_assets/_fonts/";var Rf=new B,Eo=class{constructor(e,t,n){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=n,this.nextChar3DPos=new B(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(e,t,n=this.message.length){this.message.splice(n,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let n=t,i=this.message.length;n<i;n+=1)this.message[n].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[n].charSize}checkOverFlow(e){let t,n=this.message.length-1;if(n<=0)return!1;for(;n>=0;){if(this.message[n].char!==" "){t=this.message[n];break}n-=1}return!!(n>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],n=!0,i;for(i=e;i>=0;i-=1)if(this.message[i].char===" "){n=!1,t.length===0&&(i-=1,t.splice(0,0,this.message[i]));break}else t.splice(0,0,this.message[i]);return n?t=[]:this.message.splice(i+1,t.length),t}getWord(e=0,t=1){let n=[],i=e;for(i=e;;i+=t){if(!this.message[i]||this.message[i].char===" "){n.length===0&&this.message[i]&&(n.push(this.message[i]),this.message.splice(i,1));break}t>0?(n.push(this.message[i]),this.message.splice(i,1),i-=t):(n.splice(0,0,this.message[i]),this.message.splice(i,1))}return n}getWordAtIndex(e){let t=[];for(let n=e;n<this.message.length&&this.message[n].char!==" ";n++)t.push(this.message[n]);for(let n=e-1;n>=0&&this.message[n].char!==" ";n--)t.splice(0,0,this.message[n]);return t}wordSize(e=0,t=-1){let n=0,i=e;for(;i>=0&&i<this.message.length;){if(this.message[i].char===" "){n===0&&(n=this.message[i].charSize);break}n+=this.message[i].charSize,i+=t}return(i<0||i>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:n===0?999999999:n}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,n=this.message.length-1){for(let i=t;i<=n;i+=1)this.message[i].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,n,i,s){switch(n){case 1:this.leftAlign(e,s);break;case 3:this.centerAlign(this.spaceLeft(t),e,s);break;case 2:this.rightAlign(this.spaceLeft(t),e,s);break;case 4:this.justifyAlign(this.spaceLeft(t),e,s);break}}offsetCharacters(e,t,n){Rf.set(t,n);let i=this.message.length;for(let s=0;s<i;s++)this.message[s].updatePosition(this.message[s].localPosition.add(Rf),e)}leftAlign(e,t){this.align=1,this.offsetCharacters(e,0,t)}centerAlign(e,t,n){this.align=3,this.offsetCharacters(t,e/2,n)}rightAlign(e,t,n){this.align=2,this.offsetCharacters(t,e,n)}justifyAlign(e,t,n){if(this.align=4,this.endLine){this.offsetCharacters(t,0,n);return}let i=this.countSpaces();if(i===0){this.offsetCharacters(t,0,n);return}let s=e/i,o=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(o+=s),Rf.set(o,n),this.message[a].updatePosition(this.message[a].localPosition.add(Rf),t)}clone(){let e=new Eo(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};var Oy=class extends Nt{constructor(t){super(t,new Zr({transparent:!0,opacity:1,visible:!1,side:hn}));this.objectType="TextFrame";this.charContainer=new ct,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=t.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:1,horizontalAlignment:1,verticalAlignment:1,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new A(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(t,n,i){let s=rf.create({parameters:{width:n.width,height:n.height}}),o=new Oy(s).fromState(n,i);return o.uuid=t,o}async updateText(t){this.clearText();let n=this.userData.textFrame,i=n.fontFamily;await gr.loadFont(i),n.text=t;let s=n.textOrigin,o=new hi({visible:n.visible,transparent:!0,side:hn}),a=t.split(`
|
|
4892
|
-
`),l=0;this.userData.textFrame.textLines=a.map((c,h)=>{let u=new Eo(l,n.lineHeight,n.fontSize);return u.message=c.split("").map(d=>{let f={char:d,fontFamily:i,letterSpacing:n.letterSpacing,fontSize:n.fontSize,LOD:16},m=o.clone();m.color=n.hexColor,m.opacity=n.opacity;let p=new gr(f,m);return u.addChar3D(p,s),this.charContainer.add(p),p}),l+=u.maxCharSize*u.lineHeight,u}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let t=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let n=this.charContainer.children[0];this.charContainer.remove(n)}for(;t.length;)t.pop()}raycast(t,n){let i=[];if(super.raycast(t,i),i.length>0){n.push(i[0]);return}let s=[];for(let o=0,a=this.charContainer.children.length;o<a;++o)if(this.charContainer.children[o]instanceof gr&&(t.intersectObject(this.charContainer.children[o],!1,s),s.length>0)){s[0].object=this,n.push(s[0]);return}}updateGeometry(t){let n=this.userData,i=this.geometry.userData,s=i.parameters.width,o=i.parameters.height,a=t.parameters?.width??s,l=t.parameters?.height??o,c=n.textFrame;super.updateGeometry(t),c.maxLineSize=a,c.textOrigin.set(-.5*a,.5*l,0),l!==o?(this.checkOverFlow(),this.checkCapacity()):a!==s&&(s<a?this.checkCapacity():s>a&&this.checkOverFlow())}checkOverFlow(t=0){let n=this.userData,i=n.textFrame.textOrigin,s=n.textFrame.textLines;for(let o=t;o<s.length;o++){s[o].updateYLinePos(this.getNewLinePosition(o)),s[o].fullUpdate(i);let a=[];for(;s[o].checkOverFlow(n.textFrame.maxLineSize);)s[o].containSpaceOverFlow()?a.unshift(s[o].getWord(s[o].message.length-1,-1)):a.unshift(s[o].popChar());if(a.length>0){s[o+1]===void 0?(s[o].isEndLine(!1),this.createTextLine()):s[o].endLine&&(this.createTextLine(o+1),s[o].isEndLine(!1),s[o+1].isEndLine(!0));let l=0;for(let c=0;c<a.length;c+=1)for(let h=0;h<a[c].length;h+=1)s[o+1].addChar3D(a[c][h],i,l),l+=1;s[o+1].fullUpdate(i)}s[o].fullUpdate(i)}this.textFullUpdate(t)}checkCapacity(t=0){let n=this.userData,i=n.textFrame.textOrigin,s=n.textFrame.maxLineSize,o=n.textFrame.textLines;for(let a=t;a<o.length;a+=1)if(o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i),!!o[a-1])for(;!o[a-1].endLine;){let l,c=o[a-1].spaceLeft(s);if(o[a].wordSize(0,1)<=c){o[a].containSpace()?l=o[a].getWord(0,1):l=o[a].popChar(0);for(let h=0;h<l.length;h+=1)l[h]&&o[a-1].addChar3D(l[h],i)}else{o[a].isEmpty()?(o[a].endLine&&o[a-1].isEndLine(!0),o.splice(a,1),a-=1):(o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i));break}}this.textFullUpdate(t)}createTextLine(t=this.userData.textFrame.textLines.length){let i=this.userData.textFrame;i.textLines.splice(t,0,new Eo(this.getNewLinePosition(t),i.lineHeight,i.fontSize))}textFullUpdate(t=0){let i=this.userData.textFrame,s=i.textLines,o=this.getVerticalAlignmentOffSet();for(let a=t;a<s.length;a++)s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i.textOrigin),s[a].alignText(i.textOrigin,i.maxLineSize,i.horizontalAlignment,i.verticalAlignment,o)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let n=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(n.length)}getNewLinePosition(t){let i=this.userData.textFrame.textLines,s=0;for(let o=0;o<t;o+=1)s+=i[o].maxCharSize*i[o].lineHeight;return s}updateColor(t){let n=this.userData;n.textFrame.hexColor=t;let i=n.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.color?.isColor&&(l.color=t)}}}updateOpacity(t){let n=this.userData;n.textFrame.opacity=t;let i=n.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.opacity=t}}}updateVisible(t){let n=this.userData;n.textFrame.visible=t;let i=n.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.visible=t}}}async updateFontFamily(t){await gr.loadFont(t);let i=this.userData.textFrame,s=i.textLines;i.fontFamily=t;for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)a[l].updateFontFamily(t)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(t){let i=this.userData.textFrame,s=i.textLines,o=i.fontSize;i.fontSize=t;for(let a=0;a<s.length;a++)s[a].updateFontSize(t);this.textFullUpdate(),t>o?this.checkOverFlow():t<o&&this.checkCapacity()}async updateTextTransform(t){let i=this.userData.textFrame;await gr.loadFont(i.fontFamily);let s=i.textLines;switch(i.textTransform=t,t){case 2:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].char.toUpperCase())}break;case 3:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].char.toLowerCase())}break;default:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(t){let n=this.userData,i=n.textFrame.textLines;n.textFrame.letterSpacing=t;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++)o[a].updateLetterSpacing(t)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(t){let n=this.userData;n.textFrame.LOD=t;let i=n.textFrame.textLines;for(let s=0;s<i.length;s++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(t){let n=this.userData,i=n.textFrame.textLines;n.textFrame.lineHeight=t;for(let s=0;s<i.length;s++)i[s].updatelineHeight(t);this.textFullUpdate()}updateVerticalAlignment(t){let n=this.userData;n.textFrame.verticalAlignment=t,this.textFullUpdate()}updateHorizontalAlignment(t){let n=this.userData;n.textFrame.horizontalAlignment=t,this.textFullUpdate()}fromTextFrameData(t,n){if(t.color!==void 0){let i=Ft(t.color,n);this.updateColor(i),this.updateOpacity(i.a)}t.alpha!==void 0&&this.updateOpacity(t.alpha),t.font!==void 0&&this.updateFontFamily(t.font),t.horizontalAlign!==void 0&&this.updateHorizontalAlignment(t.horizontalAlign),t.verticalAlign!==void 0&&this.updateVerticalAlignment(t.verticalAlign),t.textTransform!==void 0&&this.updateTextTransform(t.textTransform),t.fontSize!==void 0&&this.updateFontSize(t.fontSize),t.lineHeight!==void 0&&this.updateLineHeight(t.lineHeight),t.letterSpacing!==void 0&&this.updateLetterSpacing(t.letterSpacing),t.text!==void 0&&t.text!==""&&this.updateText(t.text),(t.width!==void 0||t.height!==void 0)&&this.updateGeometry({parameters:{width:t.width,height:t.height}})}fromState(t,n){return super.fromState(t),this.fromTextFrameData(t,n),this}convertToVector(){let{fontFamily:t,hexColor:n}=this.userData.textFrame,i=new Qi;i.name="Text Shape";let s=gr.fontCache[t];for(let o of this.charContainer.children)o instanceof gr&&s.generateShapes(o.char,1).forEach(a=>{let l=new pt().fromShape(a);l.applyScale(o.scale.x,o.scale.y);let c=Pn.create({shape:l}),h=new Zr({side:hn});h.color=n;let u=new ks(c,h);u.name=o.char,u.position.copy(o.position),u.rotation.copy(o.rotation),i.attach(u)});return i}},Co=Oy;Co.VerticalAlign=Ig,Co.HorizontalAlign=Pg,Co.TextTransform=Lg;var Fy=new WeakMap,Bf=class extends ys{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){let s=new vs(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{let a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,a).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(let l in t.attributeTypes){let c=t.attributeTypes[l];c.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=c.name)}let n=JSON.stringify(t);if(Fy.has(e)){let l=Fy.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((c,h)=>{i._callbacks[s]={resolve:c,reject:h},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Fy.set(e,{key:n,promise:a}),a}_createGeometry(e){let t=new Ie;e.index&&t.setIndex(new Xe(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n],s=i.name,o=i.array,a=i.itemSize;t.setAttribute(s,new Xe(o,a))}return t}_loadLibrary(e,t){let n=new vs(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{let i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);let s=QO.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
4893
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){let o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}};function QO(){let r,e;onmessage=function(o){let a=o.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(h){r.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(r)});break;case"decode":let l=a.buffer,c=a.taskConfig;e.then(h=>{let u=h.draco,d=new u.Decoder,f=new u.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let m=t(u,d,f,c),p=m.attributes.map(g=>g.array.buffer);m.index&&p.push(m.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:m},p)}catch(m){console.error(m),self.postMessage({type:"error",id:a.id,error:m.message})}finally{u.destroy(f),u.destroy(d)}});break}};function t(o,a,l,c){let h=c.attributeIDs,u=c.attributeTypes,d,f,m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(m===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let p={index:null,attributes:[]};for(let g in h){let x=self[u[g]],v,w;if(c.useUniqueIDs)w=h[g],v=a.GetAttributeByUniqueId(d,w);else{if(w=a.GetAttributeId(d,o[h[g]]),w===-1)continue;v=a.GetAttribute(d,w)}p.attributes.push(i(o,a,d,g,x,v))}return m===o.TRIANGULAR_MESH&&(p.index=n(o,a,d)),o.destroy(d),p}function n(o,a,l){let h=l.num_faces()*3,u=h*4,d=o._malloc(u);a.GetTrianglesUInt32Array(l,u,d);let f=new Uint32Array(o.HEAPF32.buffer,d,h).slice();return o._free(d),{array:f,itemSize:1}}function i(o,a,l,c,h,u){let d=u.num_components(),m=l.num_points()*d,p=m*h.BYTES_PER_ELEMENT,g=s(o,h),x=o._malloc(p);a.GetAttributeDataArrayForAllPoints(l,u,g,p,x);let v=new h(o.HEAPF32.buffer,x,m).slice();return o._free(x),{name:c,array:v,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var Vs;function KO(){return Vs||(Vs=new Bf,Vs.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Vs.decoderPending}async function ZO(r){if(Vs){let e={attributeIDs:Vs.defaultAttributeIDs,attributeTypes:Vs.defaultAttributeTypes,useUniqueIDs:!1},t;try{t=await Vs.decodeGeometry(new Int8Array(r).buffer,e)}catch(n){console.error(n)}if(t)return{index:t.index?{array:t.index.array}:void 0,attributes:Object.entries(t.attributes).map(([n,i])=>({name:n,itemSize:i.itemSize,array:i.array}))}}return null}async function Q1(r,e){let[t,n]=fg(zd.deserialize(new Uint8Array(r))),i=[];t.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&i.push(o)}),i.length&&await KO();for(let s of i){let o=await ZO(mg(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:c,itemSize:h})=>{a[l]={array:c,itemSize:h,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return e&&e(t),n.result().data}var tA={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},ky={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},JO=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Ff={CSS:{},springs:{}};function Ti(r,e,t){return Math.min(Math.max(r,e),t)}function Th(r,e){return r.indexOf(e)>-1}function Uy(r,e){return r.apply(null,e)}var He={arr:function(r){return Array.isArray(r)},obj:function(r){return Th(Object.prototype.toString.call(r),"Object")},pth:function(r){return He.obj(r)&&r.hasOwnProperty("totalLength")},svg:function(r){return r instanceof SVGElement},inp:function(r){return r instanceof HTMLInputElement},dom:function(r){return!("isNode"in r)&&(r.nodeType||He.svg(r))},str:function(r){return typeof r=="string"},fnc:function(r){return typeof r=="function"},und:function(r){return typeof r>"u"},hex:function(r){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(r)},rgb:function(r){return/^rgb/.test(r)},hsl:function(r){return/^hsl/.test(r)},col:function(r){return He.hex(r)||He.rgb(r)||He.hsl(r)},key:function(r){return!tA.hasOwnProperty(r)&&!ky.hasOwnProperty(r)&&r!=="targets"&&r!=="keyframes"}};function nA(r){var e=/\(([^)]+)\)/.exec(r);return e?e[1].split(",").map(function(t){return parseFloat(t)}):[]}function rA(r,e){var t=nA(r),n=Ti(He.und(t[0])?1:t[0],.1,100),i=Ti(He.und(t[1])?100:t[1],.1,100),s=Ti(He.und(t[2])?10:t[2],.1,100),o=Ti(He.und(t[3])?0:t[3],.1,100),a=Math.sqrt(i/n),l=s/(2*Math.sqrt(i*n)),c=l<1?a*Math.sqrt(1-l*l):0,h=1,u=l<1?(l*a+-o)/c:-o+a;function d(m){var p=e?e*m/1e3:m;return l<1?p=Math.exp(-p*l*a)*(h*Math.cos(c*p)+u*Math.sin(c*p)):p=(h+u*p)*Math.exp(-p*a),m===0||m===1?m:1-p}function f(){var m=Ff.springs[r];if(m)return m;for(var p=1/6,g=0,x=0;;)if(g+=p,d(g)===1){if(x++,x>=16)break}else x=0;var v=g*p*1e3;return Ff.springs[r]=v,v}return e?d:f}function $O(r){return r===void 0&&(r=10),function(e){return Math.ceil(Ti(e,1e-6,1)*r)*(1/r)}}var eF=function(){var r=11,e=1/(r-1);function t(h,u){return 1-3*u+3*h}function n(h,u){return 3*u-6*h}function i(h){return 3*h}function s(h,u,d){return((t(u,d)*h+n(u,d))*h+i(u))*h}function o(h,u,d){return 3*t(u,d)*h*h+2*n(u,d)*h+i(u)}function a(h,u,d,f,m){var p,g,x=0;do g=u+(d-u)/2,p=s(g,f,m)-h,p>0?d=g:u=g;while(Math.abs(p)>1e-7&&++x<10);return g}function l(h,u,d,f){for(var m=0;m<4;++m){var p=o(u,d,f);if(p===0)return u;var g=s(u,d,f)-h;u-=g/p}return u}function c(h,u,d,f){if(!(0<=h&&h<=1&&0<=d&&d<=1))return;var m=new Float32Array(r);if(h!==u||d!==f)for(var p=0;p<r;++p)m[p]=s(p*e,h,d);function g(x){for(var v=0,w=1,b=r-1;w!==b&&m[w]<=x;++w)v+=e;--w;var S=(x-m[w])/(m[w+1]-m[w]),M=v+S*e,_=o(M,h,d);return _>=.001?l(x,M,h,d):_===0?M:a(x,v,v+e,h,d)}return function(x){return h===u&&d===f||x===0||x===1?x:s(g(x),u,f)}}return c}(),iA=function(){var r={linear:function(){return function(n){return n}}},e={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var i,s=4;n<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-n,2)}},Elastic:function(n,i){n===void 0&&(n=1),i===void 0&&(i=.5);var s=Ti(n,1,10),o=Ti(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},t=["Quad","Cubic","Quart","Quint","Expo"];return t.forEach(function(n,i){e[n]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(e).forEach(function(n){var i=e[n];r["easeIn"+n]=i,r["easeOut"+n]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},r["easeInOut"+n]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),r}();function Vy(r,e){if(He.fnc(r))return r;var t=r.split("(")[0],n=iA[t],i=nA(r);switch(t){case"spring":return rA(r,e);case"cubicBezier":return Uy(eF,i);case"steps":return Uy($O,i);default:return Uy(n,i)}}function sA(r){try{var e=document.querySelectorAll(r);return e}catch{return}}function Uf(r,e){for(var t=r.length,n=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<t;s++)if(s in r){var o=r[s];e.call(n,o,s,r)&&i.push(o)}return i}function zf(r){return r.reduce(function(e,t){return e.concat(He.arr(t)?zf(t):t)},[])}function K1(r){return He.arr(r)?r:(He.str(r)&&(r=sA(r)||r),r instanceof NodeList||r instanceof HTMLCollection?[].slice.call(r):[r])}function Hy(r,e){return r.some(function(t){return t===e})}function Wy(r){var e={};for(var t in r)e[t]=r[t];return e}function zy(r,e){var t=Wy(r);for(var n in r)t[n]=e.hasOwnProperty(n)?e[n]:r[n];return t}function Gf(r,e){var t=Wy(r);for(var n in e)t[n]=He.und(r[n])?e[n]:r[n];return t}function tF(r){var e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(r);return e?"rgba("+e[1]+",1)":r}function nF(r){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,t=r.replace(e,function(a,l,c,h){return l+l+c+c+h+h}),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t),i=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+i+","+s+","+o+",1)"}function rF(r){var e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(r)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(r),t=parseInt(e[1],10)/360,n=parseInt(e[2],10)/100,i=parseInt(e[3],10)/100,s=e[4]||1;function o(d,f,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?d+(f-d)*6*m:m<1/2?f:m<2/3?d+(f-d)*(2/3-m)*6:d}var a,l,c;if(n==0)a=l=c=i;else{var h=i<.5?i*(1+n):i+n-i*n,u=2*i-h;a=o(u,h,t+1/3),l=o(u,h,t),c=o(u,h,t-1/3)}return"rgba("+a*255+","+l*255+","+c*255+","+s+")"}function iF(r){if(He.rgb(r))return tF(r);if(He.hex(r))return nF(r);if(He.hsl(r))return rF(r)}function Ki(r){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(r);if(e)return e[1]}function sF(r){if(Th(r,"translate")||r==="perspective")return"px";if(Th(r,"rotate")||Th(r,"skew"))return"deg"}function Gy(r,e){return He.fnc(r)?r(e.target,e.id,e.total):r}function Ei(r,e){return r.getAttribute(e)}function jy(r,e,t){var n=Ki(e);if(Hy([t,"deg","rad","turn"],n))return e;var i=Ff.CSS[e+t];if(!He.und(i))return i;var s=100,o=document.createElement(r.tagName),a=r.parentNode&&r.parentNode!==document?r.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+t;var l=s/o.offsetWidth;a.removeChild(o);var c=l*parseFloat(e);return Ff.CSS[e+t]=c,c}function oA(r,e,t){if(e in r.style){var n=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r.style[e]||getComputedStyle(r).getPropertyValue(n)||"0";return t?jy(r,i,t):i}}function qy(r,e){if(He.dom(r)&&!He.inp(r)&&(Ei(r,e)||He.svg(r)&&r[e]))return"attribute";if(He.dom(r)&&Hy(JO,e))return"transform";if(He.dom(r)&&e!=="transform"&&oA(r,e))return"css";if(r[e]!=null)return"object"}function aA(r){if(!!He.dom(r)){for(var e=r.style.transform||"",t=/(\w+)\(([^)]*)\)/g,n=new Map,i;i=t.exec(e);)n.set(i[1],i[2]);return n}}function oF(r,e,t,n){var i=Th(e,"scale")?1:0+sF(e),s=aA(r).get(e)||i;return t&&(t.transforms.list.set(e,s),t.transforms.last=e),n?jy(r,s,n):s}function Xy(r,e,t,n){switch(qy(r,e)){case"transform":return oF(r,e,n,t);case"css":return oA(r,e,t);case"attribute":return Ei(r,e);default:return r[e]||0}}function Yy(r,e){var t=/^(\*=|\+=|-=)/.exec(r);if(!t)return r;var n=Ki(r)||0,i=parseFloat(e),s=parseFloat(r.replace(t[0],""));switch(t[0][0]){case"+":return i+s+n;case"-":return i-s+n;case"*":return i*s+n}}function lA(r,e){if(He.col(r))return iF(r);if(/\s/g.test(r))return r;var t=Ki(r),n=t?r.substr(0,r.length-t.length):r;return e?n+e:n}function Qy(r,e){return Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))}function aF(r){return Math.PI*2*Ei(r,"r")}function lF(r){return Ei(r,"width")*2+Ei(r,"height")*2}function cF(r){return Qy({x:Ei(r,"x1"),y:Ei(r,"y1")},{x:Ei(r,"x2"),y:Ei(r,"y2")})}function cA(r){for(var e=r.points,t=0,n,i=0;i<e.numberOfItems;i++){var s=e.getItem(i);i>0&&(t+=Qy(n,s)),n=s}return t}function hF(r){var e=r.points;return cA(r)+Qy(e.getItem(e.numberOfItems-1),e.getItem(0))}function hA(r){if(r.getTotalLength)return r.getTotalLength();switch(r.tagName.toLowerCase()){case"circle":return aF(r);case"rect":return lF(r);case"line":return cF(r);case"polyline":return cA(r);case"polygon":return hF(r)}}function uF(r){var e=hA(r);return r.setAttribute("stroke-dasharray",e),e}function dF(r){for(var e=r.parentNode;He.svg(e)&&He.svg(e.parentNode);)e=e.parentNode;return e}function uA(r,e){var t=e||{},n=t.el||dF(r),i=n.getBoundingClientRect(),s=Ei(n,"viewBox"),o=i.width,a=i.height,l=t.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:n,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function fF(r,e){var t=He.str(r)?sA(r)[0]:r,n=e||100;return function(i){return{property:i,el:t,svg:uA(t),totalLength:hA(t)*(n/100)}}}function pF(r,e){function t(a){a===void 0&&(a=0);var l=e+a>=1?e+a:0;return r.el.getPointAtLength(l)}var n=uA(r.el,r.svg),i=t(),s=t(-1),o=t(1);switch(r.property){case"x":return(i.x-n.x)*n.w;case"y":return(i.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function Z1(r,e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=lA(He.pth(r)?r.totalLength:r,e)+"";return{original:n,numbers:n.match(t)?n.match(t).map(Number):[0],strings:He.str(r)||e?n.split(t):[]}}function dA(r){var e=r?zf(He.arr(r)?r.map(K1):K1(r)):[];return Uf(e,function(t,n,i){return i.indexOf(t)===n})}function fA(r){var e=dA(r);return e.map(function(t,n){return{target:t,id:n,total:e.length,transforms:{list:aA(t)}}})}function mF(r,e){var t=Wy(e);if(/^spring/.test(t.easing)&&(t.duration=rA(t.easing)),He.arr(r)){var n=r.length,i=n===2&&!He.obj(r[0]);i?r={value:r}:He.fnc(e.duration)||(t.duration=e.duration/n)}var s=He.arr(r)?r:[r];return s.map(function(o,a){var l=He.obj(o)&&!He.pth(o)?o:{value:o};return He.und(l.delay)&&(l.delay=a?0:e.delay),He.und(l.endDelay)&&(l.endDelay=a===s.length-1?e.endDelay:0),l}).map(function(o){return Gf(o,t)})}function gF(r){for(var e=Uf(zf(r.map(function(s){return Object.keys(s)})),function(s){return He.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),t={},n=function(s){var o=e[s];t[o]=r.map(function(a){var l={};for(var c in a)He.key(c)?c==o&&(l.value=a[c]):l[c]=a[c];return l})},i=0;i<e.length;i++)n(i);return t}function yF(r,e){var t=[],n=e.keyframes;n&&(e=Gf(gF(n),e));for(var i in e)He.key(i)&&t.push({name:i,tweens:mF(e[i],r)});return t}function vF(r,e){var t={};for(var n in r){var i=Gy(r[n],e);He.arr(i)&&(i=i.map(function(s){return Gy(s,e)}),i.length===1&&(i=i[0])),t[n]=i}return t.duration=parseFloat(t.duration),t.delay=parseFloat(t.delay),t}function xF(r,e){var t;return r.tweens.map(function(n){var i=vF(n,e),s=i.value,o=He.arr(s)?s[1]:s,a=Ki(o),l=Xy(e.target,r.name,a,e),c=t?t.to.original:l,h=He.arr(s)?s[0]:c,u=Ki(h)||Ki(l),d=a||u;return He.und(o)&&(o=c),i.from=Z1(h,d),i.to=Z1(Yy(o,h),d),i.start=t?t.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=Vy(i.easing,i.duration),i.isPath=He.pth(s),i.isColor=He.col(i.from.original),i.isColor&&(i.round=1),t=i,i})}var pA={css:function(r,e,t){return r.style[e]=t},attribute:function(r,e,t){return r.setAttribute(e,t)},object:function(r,e,t){return r[e]=t},transform:function(r,e,t,n,i){if(n.list.set(e,t),e===n.last||i){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),r.style.transform=s}}};function mA(r,e){var t=fA(r);t.forEach(function(n){for(var i in e){var s=Gy(e[i],n),o=n.target,a=Ki(s),l=Xy(o,i,a,n),c=a||Ki(l),h=Yy(lA(s,c),l),u=qy(o,i);pA[u](o,i,h,n.transforms,!0)}})}function bF(r,e){var t=qy(r.target,e.name);if(t){var n=xF(e,r),i=n[n.length-1];return{type:t,property:e.name,animatable:r,tweens:n,duration:i.end,delay:n[0].delay,endDelay:i.endDelay}}}function wF(r,e){return Uf(zf(r.map(function(t){return e.map(function(n){return bF(t,n)})})),function(t){return!He.und(t)})}function gA(r,e){var t=r.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=t?Math.max.apply(Math,r.map(function(s){return n(s)+s.duration})):e.duration,i.delay=t?Math.min.apply(Math,r.map(function(s){return n(s)+s.delay})):e.delay,i.endDelay=t?i.duration-Math.max.apply(Math,r.map(function(s){return n(s)+s.duration-s.endDelay})):e.endDelay,i}var J1=0;function SF(r){var e=zy(tA,r),t=zy(ky,r),n=yF(t,r),i=fA(r.targets),s=wF(i,n),o=gA(s,t),a=J1;return J1++,Gf(e,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay})}var ir=[],$1=[],Of,AF=function(){function r(){Of=requestAnimationFrame(e)}function e(t){var n=ir.length;if(n){for(var i=0;i<n;){var s=ir[i];if(!s.paused)s.tick(t);else{var o=ir.indexOf(s);o>-1&&(ir.splice(o,1),n=ir.length)}i++}r()}else Of=cancelAnimationFrame(Of)}return r}();function MF(){document.hidden?(ir.forEach(function(r){return r.pause()}),$1=ir.slice(0),an.running=ir=[]):$1.forEach(function(r){return r.play()})}typeof document<"u"&&document.addEventListener("visibilitychange",MF);function an(r){r===void 0&&(r={});var e=0,t=0,n=0,i,s=0,o=null;function a(w){var b=window.Promise&&new Promise(function(S){return o=S});return w.finished=b,b}var l=SF(r),c=a(l);function h(){var w=l.direction;w!=="alternate"&&(l.direction=w!=="normal"?"normal":"reverse"),l.reversed=!l.reversed,i.forEach(function(b){return b.reversed=l.reversed})}function u(w){return l.reversed?l.duration-w:w}function d(){e=0,t=u(l.currentTime)*(1/an.speed)}function f(w,b){b&&b.seek(w-b.timelineOffset)}function m(w){if(l.reversePlayback)for(var S=s;S--;)f(w,i[S]);else for(var b=0;b<s;b++)f(w,i[b])}function p(w){var b=0,S=l.animations,M=S.length;for(l.reversePlayback===!0&&l.rewind===!1&&(w=l.duration+l.delay-l.endDelay-w);b<M;){var _=S[b],y=_.animatable,T=_.tweens,E=T.length-1,C=T[E];E&&(C=Uf(T,function(Z){return w<Z.end})[0]||C);for(var L=Ti(w-C.start-C.delay,0,C.duration)/C.duration,R=isNaN(L)?1:C.easing(L),N=C.to.strings,H=C.round,j=[],K=C.to.numbers.length,Y=void 0,z=0;z<K;z++){var F=void 0;if(l.reversePlayback===!0&&l.rewind===!1)var V=C.to.numbers[z],O=C.from.numbers[z]||0;else var O=C.to.numbers[z],V=C.from.numbers[z]||0;C.isPath?F=pF(C.value,R*O):F=V+R*(O-V),H&&(C.isColor&&z>2||(F=Math.round(F*H)/H)),j.push(F)}var G=N.length;if(!G)Y=j[0];else{Y=N[0];for(var W=0;W<G;W++){var X=N[W],q=N[W+1],se=j[W];isNaN(se)||(q?Y+=se+q:Y+=se+" ")}}pA[_.type](y.target,_.property,Y,y.transforms),_.currentValue=Y,b++}}function g(w){l[w]&&!l.passThrough&&l[w](l)}function x(){l.remaining&&l.remaining!==!0&&l.remaining--}function v(w){var b=l.duration,S=l.delay,M=b-l.endDelay,_=u(w);l.progress=Ti(_/b*100,0,100),l.reversePlayback=_<l.currentTime,i&&m(_),!l.began&&l.currentTime>=0&&(l.began=!0,g("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,g("loopBegin")),_<=S&&l.currentTime!==0&&(p(0),g("change")),(_>=M&&l.currentTime!==b||!b)&&(p(b),g("change")),_>S&&_<M?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,g("changeBegin")),g("change"),p(_)):l.changeBegan?(l.changeCompleted=!0,l.changeBegan=!1,g("change"),g("changeComplete")):l.began&&_>M&&(g("change"),g("changeComplete")),l.currentTime=Ti(_,0,b),l.began&&g("update"),w>=b&&(t=0,x(),l.remaining?(e=n,g("loopComplete"),l.loopBegan=!1,l.direction==="alternate"&&h()):(l.paused=!0,l.completed||(l.completed=!0,g("loopComplete"),g("complete"),!l.passThrough&&"Promise"in window&&(o(),c=a(l)))))}return l.reset=function(){var w=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed=w==="reverse",l.remaining=l.loop,i=l.children,s=i.length;for(var b=s;b--;)l.children[b].reset();(l.reversed&&l.loop!==!0||w==="alternate"&&l.loop===1)&&l.remaining++,p(l.reversed?l.duration:0)},l.set=function(w,b){return mA(w,b),l},l.tick=function(w){n=w,e||(e=n),v((n+(t-e))*an.speed)},l.seek=function(w){v(u(w))},l.pause=function(){l.paused=!0,d()},l.play=function(){!l.paused||(l.completed&&l.reset(),l.paused=!1,ir.push(l),d(),Of||AF())},l.reverse=function(){h(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.reset(),l.autoplay&&l.play(),l}function eA(r,e){for(var t=e.length;t--;)Hy(r,e[t].animatable.target)&&e.splice(t,1)}function _F(r){for(var e=dA(r),t=ir.length;t--;){var n=ir[t],i=n.animations,s=n.children;eA(e,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;eA(e,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&n.pause()}}function TF(r,e){e===void 0&&(e={});var t=e.direction||"normal",n=e.easing?Vy(e.easing):null,i=e.grid,s=e.axis,o=e.from||0,a=o==="first",l=o==="center",c=o==="last",h=He.arr(r),u=parseFloat(h?r[0]:r),d=h?parseFloat(r[1]):0,f=Ki(h?r[1]:r)||0,m=e.start||0+(h?u:0),p=[],g=0;return function(x,v,w){if(a&&(o=0),l&&(o=(w-1)/2),c&&(o=w-1),!p.length){for(var b=0;b<w;b++){if(!i)p.push(Math.abs(o-b));else{var S=l?(i[0]-1)/2:o%i[0],M=l?(i[1]-1)/2:Math.floor(o/i[0]),_=b%i[0],y=Math.floor(b/i[0]),T=S-_,E=M-y,C=Math.sqrt(T*T+E*E);s==="x"&&(C=-T),s==="y"&&(C=-E),p.push(C)}g=Math.max.apply(Math,p)}n&&(p=p.map(function(R){return n(R/g)*g})),t==="reverse"&&(p=p.map(function(R){return s?R<0?R*-1:-R:Math.abs(g-R)}))}var L=h?(d-u)/g:u;return m+L*(Math.round(p[v]*100)/100)+f}}function EF(r){r===void 0&&(r={});var e=an(r);return e.duration=0,e.add=function(t,n){var i=ir.indexOf(e),s=e.children;i>-1&&ir.splice(i,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=Gf(t,zy(ky,r));l.targets=l.targets||r.targets;var c=e.duration;l.autoplay=!1,l.direction=e.direction,l.timelineOffset=He.und(n)?c:Yy(n,c),o(e),l.rewind=e.rewind,e.seek(l.timelineOffset);var h=an(l);o(h),s.push(h);var u=gA(s,r);return e.delay=u.delay,e.endDelay=u.endDelay,e.duration=u.duration,e.seek(0),e.reset(),e.autoplay&&e.play(),e},e}an.version="3.2.0";an.speed=1;an.running=ir;an.remove=_F;an.get=Xy;an.set=mA;an.convertPx=jy;an.path=fF;an.setDashoffset=uF;an.stagger=TF;an.timeline=EF;an.easing=Vy;an.penner=iA;an.random=function(r,e){return Math.floor(Math.random()*(e-r+1))+r};var yA=an;function vA(r,e,t){let n=r.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(n!==void 0){let i=r.zoom;i!==n&&t.push({change:s=>{r.zoom=Ge.lerp(i,n,s),r.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let i=r.targetOffset,s=e.targetOffset;i!==s&&t.push({change:o=>{r.targetOffset=Ge.lerp(i,s,o)}})}}function xA(r,e,t){if(e.width!==void 0&&e.height!==void 0&&e.depth!==void 0){let{width:n,height:i,depth:s}=r.geometry.userData.parameters,o=[n,i,s],a=[e.width,e.height,e.depth];!on.isEqual(o,a)&&!bt(r)&&t.push({change:l=>{let[c,h,u]=on.lerp(o,a,l);r.updateGeometry({parameters:{width:c,height:h,depth:u}}),r.invalidateDownstreamBooleanData()}})}}function bA(r,e,t,n){if(e.intensity!==void 0){let i=r.intensity,s=e.intensity;i!==s&&t.push({change:o=>{r.intensity=Ge.lerp(i,s,o)}})}if(e.color!==void 0){let i=r.color.clone(),s=typeof e.color=="string"?n.getColor(e.color):e.color;if(!dn.equals(i,s)){let o=i.clone();r.color=o,t.push({change:a=>{let{r:l,g:c,b:h}=dn.lerp(i,s,a);o.setRGB(l,c,h)}})}}}function wA(r,e,t,n){let i=r.layersList.head;for(;i;){let s=e.layers.data(i.uuid);if(s&&(i.visible??!0)&&(s.visible??!0)){let o=i.getNames().filter(a=>!sS.some(l=>a.includes(l)));for(let a of o)try{let l=i.getValue(a);if(a==="steps")NF(i,s,a,t);else if(a==="colors")RF(i,s,a,t);else if(typeof l=="number")CF(i,s,a,t);else{if(typeof l=="boolean")continue;"isVector2"in l?DF(i,s,a,t):"isVector3"in l?PF(i,s,a,t):"isColorA"in l?LF(i,s,a,t,n):"isColor"in l?IF(i,s,a,t,n):"isTexture"in l&&BF(i,s,a,t)}}catch(l){console.error(`animateMaterial: unexpected material layer for ${a}`,l)}}i=i.next}}function CF(r,e,t,n){if(!r.hasValue(t)||!(t in e))return;let i=r.getValue(t),s=e[t];i!==s&&n.push({change:o=>{r.setValue(t,Ge.lerp(i,s,o))}})}function DF(r,e,t,n){if(!r.hasValue(t)||!(t in e))return;let i=r.getValue(t),s=i.toArray(),o=e[t];Wi.isEqual(s,o)||n.push({change:a=>{i.fromArray(Wi.lerp(s,o,a))}})}function PF(r,e,t,n){if(!r.hasValue(t)||!(t in e))return;let i=r.getValue(t),s=i.toArray(),o=e[t];on.isEqual(s,o)||n.push({change:a=>{i.fromArray(on.lerp(s,o,a))}})}function IF(r,e,t,n,i){if(!r.hasValue(t)||!(t in e))return;let s=r.getValue(t).clone(),o=e[t],a=typeof o=="string"?i.getColor(o):o;if(dn.equals(s,a))return;let l=s.clone();r.setValue(t,l),n.push({change:c=>{let{r:h,g:u,b:d}=dn.lerp(s,a,c);l.setRGB(h,u,d)}})}function LF(r,e,t,n,i){if(!r.hasValue(t)||!(t in e))return;let s=r.getValue(t).clone(),o=e[t],a=typeof o=="string"?i.getColor(o):o;if(On.equals(s,a))return;let l=s.clone();r.setValue(t,l),n.push({change:c=>{let{r:h,g:u,b:d,a:f}=On.lerp(s,a,c);l.setRGBA(h,u,d,f)}})}function NF(r,e,t="steps",n){if(!r.hasValue(t)||!(t in e))return;let i=[...r.getValue(t)],s=e[t];for(let o=0;o<i.length;++o){let a=i[o],l=s[o];a!==l&&n.push({change:c=>{i[o]=Ge.lerp(a,l,c),r.setValue("steps",i)}})}}function RF(r,e,t="colors",n){if(!r.hasValue(t)||!(t in e))return;let i=r.getValue(t),s=e[t];for(let o=0;o<i.length;++o){let a=i[o].toArray(),l=s[o];Uc.isEqual(a,l)||n.push({change:c=>{i[o].fromArray(Uc.lerp(a,l,c))}})}}function BF(r,e,t="texture",n){if(!r.hasValue(t)||!(t in e))return;let i=r.getValue("texture"),s=e[t],o=i.repeat.toArray(),a=i.offset.toArray(),l=s.repeat,c=s.offset;(!Wi.isEqual(o,l)||!Wi.isEqual(a,c))&&n.push({change:h=>{i.repeat.fromArray(Wi.lerp(o,l,h)),i.offset.fromArray(Wi.lerp(a,c,h)),i.updateMatrix(),i.needsUpdate=!0}})}function SA(r,e,t,n){if(n===0)return t.copy(r);if(n===1)return t.copy(e);let i=r.w*e.w+r.x*e.x+r.y*e.y+r.z*e.z;if(i>=1)return t.copy(r);let s=1-i*i;if(s<=Number.EPSILON){let h=1-n;return t.w=h*r.w+n*e.w,t.x=h*r.x+n*e.x,t.y=h*r.y+n*e.y,t.z=h*r.z+n*e.z,t.normalize(),t}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-n)*a)/o,c=Math.sin(n*a)/o;return t.w=r.w*l+e.w*c,t.x=r.x*l+e.x*c,t.y=r.y*l+e.y*c,t.z=r.z*l+e.z*c,t}function AA(r,e,t=0){let n=Array.isArray(r.material)?r.material[t]:r.material,i;return"materials"in e?i=e.materials[t]:"material"in e&&(i=e.material),[n,i]}var Ky=new A,Zy=new A,MA=new Xt,OF=new br,FF=new Oe;function _A(r,e,t,n){if(t.position!==void 0){let i=r.position.toArray(),s=t.position;on.isEqual(i,s)||n.push({change:o=>{r.position.fromArray(on.lerp(i,s,o)),r.updateMatrix(),Ut(r)&&bt(r.parent)&&r.invalidateDownstreamBooleanData(!0)}})}if(t.scale!==void 0){let i=r.scale.toArray(),s=t.scale;on.isEqual(i,s)||n.push({change:o=>{r.scale.fromArray(on.lerp(i,s,o)),r.updateMatrix(),Ut(r)&&bt(r.parent)&&r.invalidateDownstreamBooleanData(!0)}})}UF(r,e,t,n),zF(r,t,n)}function UF(r,e,t,n){if(t.rotation===void 0)return;let i=Ky.setFromEuler(r.rotation).toArray(),s=t.rotation;if(on.isEqual(i,s))return;if(on.sub(t.rotation,e?e.rotation:r.rotation).every(a=>Math.abs(a)<2*Math.PI)){let a=r.quaternion.clone(),l=new Xt().setFromEuler(OF.set(t.rotation[0],t.rotation[1],t.rotation[2]));n.push({change:c=>{SA(a,l,r.quaternion,c),r.updateMatrix(),Ut(r)&&bt(r.parent)&&r.invalidateDownstreamBooleanData(!0)}})}else n.push({change:a=>{r.rotation.setFromVector3(Zy.fromArray(on.lerp(i,s,a))),r.updateMatrix(),Ut(r)&&bt(r.parent)&&r.invalidateDownstreamBooleanData(!0)}})}function zF(r,e,t){if(e.hiddenMatrix!==void 0&&!di.isEqual(r.hiddenMatrix.toArray(),e.hiddenMatrix)){let n=new A,i=new Xt,s=new A;r.hiddenMatrix.decompose(n,i,s);let o=new A,a=new Xt,l=new A;FF.fromArray(e.hiddenMatrix).decompose(o,a,l),t.push({change:c=>{MA.slerpQuaternions(i,a,c),Ky.lerpVectors(n,o,c),Zy.lerpVectors(s,l,c),r.hiddenMatrix.compose(Ky,MA,Zy),Ut(r)&&bt(r.parent)&&r.invalidateDownstreamBooleanData(!0)}})}}function TA(r,e,t,n){let i=[];if((r.visible||bt(r.parent))&&_A(r,e?.objectState,t.objectState,i),Ut(r)){if((r.visible||bt(r.parent))&&"geometry"in t.objectState&&xA(r,t.objectState.geometry,i),r.visible&&("material"in t.objectState||"materials"in t.objectState)){let[s,o]=AA(r,t.objectState,0);s&&o&&typeof o!="string"&&wA(s,o,i,n)}}else r.visible&&c1(r)?bA(r,t.objectState,i,n):l1(r)&&vA(r,t.objectState,i);return i.length?{change:s=>{i.forEach(o=>{o.change&&o.change(s)})}}:void 0}function GF(r,e,t){switch(r){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 5:let{control1:n,control2:i}=e??{...bd.defaultData};return`cubicBezier( ${n[0]}, ${n[1]}, ${i[0]}, ${i[1]} )`;case 6:let{mass:s,stiffness:o,damping:a,velocity:l}=t??{...xd.defaultData};return`spring( ${s}, ${o}, ${a}, ${l} )`}}var kf=class{constructor(e,t){this.object=e;this.sharedAssets=t;this.uuid=Ge.generateUUID();this.states=[];this.events={};this.animatingState=0;this._scrollCounter=null}get fromState(){return this._fromState}get animation(){return this._animation}start(){this._animation!==void 0&&(this._animation.pause(),this._animation=void 0,this._scrollCounter=null),this.states.length>1&&(this.states[0].execute(this.object,this.sharedAssets),this._toState=this.states[0],this._fromState=void 0)}end(){this._animation!==void 0&&(this._animation.pause(),this._animation=void 0),this.states.length>1&&this.states[0].execute(this.object,this.sharedAssets),this._toState=void 0,this._fromState=void 0}seek(e,t,n,i,s){this._scrollCounter===null&&(this.animate(e,i,s),this._scrollCounter=0),this._scrollCounter+=t,this._scrollCounter=Math.min(Math.max(this._scrollCounter,0),n),this._animation?.seek(this._scrollCounter/n*(i.duration?i.duration:1))}animate(e,t,n){if(this._fromState===e&&this._animation?.reversed){let i=this._animation?.currentTime??0;this._animation?.reset(),this._animation?.seek(i),this._animation?.play()}else if(this._toState!==e){this._animation!==void 0&&this._animation.pause(),this.animatingState=0,this._fromState=this._toState,this._toState=e;let i=TA(this.object,this._fromState,e,this.sharedAssets);if(!i)return;let s={t:0};this._animation=yA({autoplay:!1,loop:t.repeat?!0:t.cycle?1:!1,direction:t.cycle?"alternate":"normal",rewind:t.rewind,delay:t.startDelay,endDelay:t.endDelay,duration:t.duration,easing:GF(t.easing,t.cubicControls,t.springParameters),targets:s,t:1,change:()=>{i.change&&i.change(s.t),n?.change&&n.change(s.t)},loopBegin:o=>{if(this.animatingState===0){this.animatingState=1;return}o.reversed?(this._toState=this._fromState,this._fromState=e):(this._fromState=this._toState,this._toState=e)}}),t.autoplay?t.startOnceDelay>0?setTimeout(()=>this._animation?.play(),t.startOnceDelay):this._animation?.play():this._animation.finished.then(()=>{this._animation=void 0,this.animatingState=0})}}emitEvent(e,t){if(e==="keyDown"||e==="keyUp"||e==="mouseDown"||e==="mouseUp"||e==="mouseHover"||e==="scroll"||e==="start"){let n=this.events[e];if(n){for(let i of n)if("targets"in i)for(let{object:s,state:o,params:a}of i.targets)s.interaction?.animate(o,a,{change:t})}}}emitEventReverse(e,t){if(e==="keyDown"||e==="keyUp"||e==="mouseDown"||e==="mouseUp"||e==="mouseHover"||e==="scroll"||e==="start"){let n=this.events[e];if(n){for(let i of n)if("targets"in i)for(let{object:s,params:o}of i.targets){let a=s.interaction;a?._fromState!==void 0&&a.animate(a._fromState,o,{change:t})}}}}};var Nl=class{static create(e,t){if(e.object){let n=t.find(e.object);if(n?.interaction){let i=e.state?n.interaction.states.find(s=>s.uuid===e.state):n.interaction.states[0];if(i){let s=e.delay??0,o={cycle:e.cycle??!1,rewind:e.rewind??!1,repeat:e.repeat??!1,duration:e.duration??1e3,startOnceDelay:e.delayDirection==="start-once"?s:0,startDelay:e.delayDirection==="start"||!e.delayDirection?s:0,endDelay:e.delayDirection==="end"||!e.delayDirection?s:0,easing:e.easing??4,autoplay:!0};if(e.easing===5){let a=e;o.cubicControls={control1:[...a.control1],control2:[...a.control2]}}if(e.easing===6){let a=e;o.springParameters={mass:a.mass,stiffness:a.stiffness,damping:a.damping,velocity:a.velocity}}return new Nl(n,i,o)}}}}constructor(e,t,n){this.object=e,this.state=t,this.params=n}};var Jy=new Map,Eh={url:"head",time:0,data:null,next:null,prev:null},Rl={url:"tail",time:1/0,data:null,next:null,prev:null};Eh.next=Rl;Rl.prev=Eh;var EA=0;function Gs(r){if(typeof r=="string")return r;let e=Date.now(),t=Jy.get(r);return t===void 0?(t={url:URL.createObjectURL(new Blob([r])),data:r,time:e,next:null,prev:null},Jy.set(r,t)):(t.time=e,t.prev.next=t.next,t.next.prev=t.prev),t.prev=Rl.prev,t.next=Rl,Rl.prev.next=t,Rl.prev=t,e-EA>1e3*10&&(EA=e+1e3,setTimeout(()=>{let n=Date.now(),i=Eh.next;for(;i.time<n-1e3*10;)URL.revokeObjectURL(i.url),Jy.delete(i.data),i=i.next,i.prev=Eh,Eh.next=i},900)),t.url}var CA=new Zr,Do=class extends In{},Vf=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new lt(2048,2048,{generateMipmaps:!0,minFilter:xs,magFilter:tt,wrapS:bn,wrapT:bn}),this.transmissionRenderTarget.depthTexture=new wr(2048,2048),this.normalRenderTarget=new lt(1024,1024,{generateMipmaps:!1,minFilter:Gt,magFilter:Gt,type:vr}),this.normalRenderTarget.depthTexture=new wr(1024,1024),this.penumbraSizeNode=new gn(5,e.penumbraSize),this.resolutionNode=new mn(1,1),this.pixelRatioNode=new _e(window.devicePixelRatio),this.reset(e)}reset(e){for(let[t,n]of Object.entries(e.images))this.addImage(t,n.data);for(let[t,n]of Object.entries(e.colors))this.addColor(t,n);for(let[t,n]of Object.entries(e.materials))this.addMaterial(t,wy(n,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}get normalMap(){return this.normalRenderTarget.texture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===CA}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??CA}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad()},this.images[e].src=Gs(t),!0;{let n=new Image;return n.src=Gs(t),n.onload=()=>{this.onImageLoad&&this.onImageLoad()},this.images[e]=n,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new Do(t.r,t.g,t.b,t.a):this.colors[e]=new Do(t.r,t.g,t.b,1),!1)}updateColor(e,t){if(this.colors[e]){let n=this.colors[e];return this.colors[e].r=t.r??n.r,this.colors[e].g=t.g??n.g,this.colors[e].b=t.b??n.b,this.colors[e].a=t.a??n.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};var LA=DM(PA());var $y;sf.then(r=>{$y=r});var NA=new Oe,kF=new Oe,VF=new Oe,ei=new Sn,Hs=new A,HF=new Oe,WF=new Oe,Ws=class extends Nt{constructor(t,n,i,s){super(i??n,s);this.subdivPointer=t;this.originalGeometry=n;this.subdividedGeometry=i;this.objectType="SubdivObject";this.hiddenMatrixOld=new Oe;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new Oe;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(t,n,i){let{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}=Lr.build(n.geometry,void 0,void 0,!n.flatShading),l=Sh(n.material,i),c=new Ws(s,o,a||void 0,l);return n.geometry.phongAngle!==void 0&&(c.phongAngle=n.geometry.phongAngle),c.calcBoundingBox(),c.freeSubdivPointer(),c.uuid=t,c.fromState(n),c}shallowClone(t){return new Ll(this.geometry,this.material).shallowCopy(this,t)}buildFromStore(t,n){let{originalGeometry:i,subdividedGeometry:s,subdivPointer:o}=Lr.build(t,n,this.subdivPointer,this.smoothShading,this.shearScale);if(t.phongAngle!==void 0&&(this.phongAngle=t.phongAngle),this.subdivPointer=o,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,Ah(this),this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry;t.width&&(this.geometry.userData.parameters={width:t.width,height:t.height,depth:t.depth})}updateMesh(t=!1){Lr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,t?this.shearScaleInv:void 0),this.subdividedGeometry&&Lr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,t?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Lr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Lr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(t,n){this.geometry=this.originalGeometry,Nt.prototype.raycast.call(this,t,n),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,n=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:o}=(0,LA.SVD)(n),a=NA.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),l=kF.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),c=VF.copy(l).transpose();this.shearScale=HF.makeScale(o[0],o[1],o[2]).multiply(c).premultiply(l),this.shearScaleInv=WF.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,c),o.every(h=>Math.abs(o[0]-h)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new Rn);let n=t.attributes.position,i=t.boundingSphere.center;ei.setFromBufferAttribute(n),ei.getCenter(i),t.boundingSphere.radius=i.distanceTo(ei.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ei.getSize(Hs);let s={width:Hs.x,height:Hs.y,depth:Hs.z};return this.geometry.userData.parameters=s,s}updateBoundingBox(t){let n=this.originalGeometry;ei.min.set(t[0],t[2],t[4]),ei.max.set(t[1],t[3],t[5]),this.shearScaleInv&&(ei.min.applyMatrix4(this.shearScaleInv),ei.max.applyMatrix4(this.shearScaleInv)),n.boundingSphere===null&&(n.boundingSphere=new Rn);let i=n.boundingSphere.center;ei.getCenter(i),n.boundingSphere.radius=i.distanceTo(ei.max),isNaN(n.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ei.getSize(Hs);let s={width:Hs.x,height:Hs.y,depth:Hs.z};return this.geometry.userData.parameters=s,s}freeSubdivPointer(){this.subdivPointer&&($y.free_bvh(this.subdivPointer),$y.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(t){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:t.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:t.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:t.parameters.depth/this.geometry.userData.parameters.depth,IA(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(IA(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...t.parameters}}};function IA(r,e,t,n){let i=r.position.array,s=r.normal.array,o=NA.makeScale(e,t,n).invert().elements,a,l,c;for(var h=0,u=i.length;h<u;h+=3)i[h]*=e,i[h+1]*=t,i[h+2]*=n,a=s[h],l=s[h+1],c=s[h+2],s[h]=o[0]*a+o[4]*l+o[8]*c,s[h+1]=o[1]*a+o[5]*l+o[9]*c,s[h+2]=o[2]*a+o[6]*l+o[10]*c}function RA(r,e){e.flatShading!==void 0&&(r.flatShading=e.flatShading,r.needsUpdate=!0),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.side!==void 0&&(e.side===0?r.side=zi:e.side===1?r.side=wn:r.side=hn)}function jF(r,e){if(Array.isArray(r.material))for(let t of r.material)RA(t,e);else{let t=r.material;RA(t,e)}r.objectType==="SubdivObject"&&e.flatShading!==void 0&&(r.material.flatShading=!1,r.smoothShading=!e.flatShading,r.updateMesh())}function BA(r,e,t){let n;if(e.geometry.type==="SubdivGeometry")n=Ws.createFromState(r,e,t);else{let i=e.geometry.type==="BooleanGeometry"?new Ie:_f(e.geometry,t),s="materials"in e?S1(e.materials,t):Sh(e.material,t);Wd.is2DParametricMesh(i.userData.type)?n=new Lf(i,s):i?.userData.type==="VectorGeometry"?n=new ks(i,s):e.geometry.type==="NonParametricGeometry"?n=new Ll(i,s):e.geometry.type==="BooleanGeometry"?(n=new Ef(void 0,s),n.booleanOp=e.geometry.operation,e.geometry.phongAngle!==void 0&&(n.phongAngle=e.geometry.phongAngle)):n=new Il(i,s),n.uuid=r,n.fromState(e,t)}return jF(n,e),n}function OA(r,e,t){return e.type==="Mesh"?BA(r,e,t):e.type==="TextFrame"?Co.createFromState(r,e,t):e.type==="Empty"?Qi.createFromState(r,e):e.type==="PointLight"?Cl.createFromState(r,e,t):e.type==="SpotLight"?Dl.createFromState(r,e,t):e.type==="DirectionalLight"?El.createFromState(r,e,t):Ds.is(e.type)?mr.createFromState(r,e):(console.error(e),new Qi)}var FA=new A,ev=class extends of(Wn){constructor(t,n){super();this.objectType="Scene";this.alpha=1;this.backupFog=new sa(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this._color=new Ae(1,0,0);this.bgColor=new Ae(1,1,1);this.entityByUuid={};this.ambientLight=new fo(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=n,this.init(t,n)}needsTransmission(t){return this.needsTransmissionDirty&&(this._needsTransmission=C1(t,this),t!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}needsNormal(t){return this.needsNormalDirty&&(this._needsNormal=E1(t,this),t!==void 0&&(this.needsNormalDirty=!1)),this._needsNormal}find(t){if(t===""||t===void 0)return;let n=this.entityByUuid[t];return n===void 0?this.getObjectByProperty("uuid",t):n}get color(){return this._color}set color(t){this.fogUseBGColor===!0&&this.backupFog.color.copy(t),this._color.copy(t)}get enableFog(){return this.fog!==null}set enableFog(t){this.fog=t===!0?this.backupFog:null}init(t,n){if(this.createChildrenObjects(t.objects,this,n),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ft(t.backgroundColor,n)),this.updateFog(t.fog,n),this.updateAmbientLight(t.environment.ambientLight,n),this.activeCamera=this.personalCamera,t.publish.playCamera!==null){let i=this.find(t.publish.playCamera);i instanceof mr&&this.switchActiveCamera(i)}this.traverse(i=>{bt(i)&&i.recomputeBoolean()})}clearScene(t){this.traverseEntity(n=>{D1(n,t)});for(let n of this.children)Cr(n)&&n.removeFromParent()}resetAfterClear(t,n){this.init(t,n)}createPersonalCamera(){let t=mr.createFromState(ev.PERSONAL_CAMERA_ID,{...qd.defaultData,name:"Personal Camera"});return t.enableHelper=!1,t.objectHelper.visible=!1,delete t.isEntity,this.registerObjectCreatedInLegacy(t),t}raycast(t){let n=[],i=s=>{for(let o of s.children)Cr(o)&&!o.raycastLock&&o.visible&&((Ut(o)||Xi(o)&&o.enableHelper&&o.objectHelper.parent)&&t.intersectObject(o,!1,n),i(o))};return i(this),n}traverseEntity(t){for(let n of this.children)Cr(n)&&n.traverseEntity(t)}updateFog(t,n){this.enableFog=t.enabled,this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ft(t.color,n),this.backupFog.near=t.near,this.backupFog.far=t.far}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(t,n){h1(this.ambientLight,t,n),t.groundColor!==void 0&&(this.ambientLight.groundColor=Ft(t.groundColor,n)),t.enabled!==void 0&&(this.ambientLight.visible=t.enabled)}switchActiveCamera(t){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=t,t.enableHelper=!1}setBackgroundColor(t){this.bgColor=t,this.alpha=t.a}createChildrenObjects(t,n,i){for(let s of t)this.createChildObject(s.id,s.data,s.children,n,i)}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let n of t.children)this.unregisterObject(n)}createChildObject(t,n,i,s,o){let a=OA(t,n,o);return a&&(this.entityByUuid[t]=a,s.add(a),bt(s)&&Ut(a)&&(a.prevBooleanObjectParent=s),this.createChildrenObjects(i,a,o)),a}getCenter(t){let n=[];for(let s=0,o=t.length;s<o;++s){let{id:a,recursive:l}=t[s],c=this.find(a),h=l?c.recursiveBBox:c.singleBBox;n.push(...h.vertices)}let i=new Sn;return i.setFromPoints(n),i.getCenter(FA),FA}copyMatrixWorld(t,n){if(t===null){n.identity();return}let i=this.find(t);i?n.copy(i.matrixWorld):n.identity()}copyParentMatrixWorld(t,n){if(t===null){n.identity();return}let i=this.find(t)?.parent;i?n.copy(i.matrixWorld):n.identity()}traverseMaterial(t){this.traverseEntity(n=>{if(n instanceof Nt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)t(n.material[i]);else t(n.material)})}updateCanvasSize(t,n){this.activeCamera.setViewplaneSize(t,n);let i,s;t>=n?(i=n/t,s=1):(i=1,s=t/n),this.traverseMaterial(o=>{o.layersList.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},Ch=ev;Ch.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var WA={RED:0,GREEN:1,BLUE:2,ALPHA:3};var Dh="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var qF=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
4904
|
+
`),l=0;this.userData.textFrame.textLines=a.map((c,h)=>{let u=new Eo(l,n.lineHeight,n.fontSize);return u.message=c.split("").map(d=>{let f={char:d,fontFamily:i,letterSpacing:n.letterSpacing,fontSize:n.fontSize,LOD:16},m=o.clone();m.color=n.hexColor,m.opacity=n.opacity;let p=new gr(f,m);return u.addChar3D(p,s),this.charContainer.add(p),p}),l+=u.maxCharSize*u.lineHeight,u}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let t=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let n=this.charContainer.children[0];this.charContainer.remove(n)}for(;t.length;)t.pop()}raycast(t,n){let i=[];if(super.raycast(t,i),i.length>0){n.push(i[0]);return}let s=[];for(let o=0,a=this.charContainer.children.length;o<a;++o)if(this.charContainer.children[o]instanceof gr&&(t.intersectObject(this.charContainer.children[o],!1,s),s.length>0)){s[0].object=this,n.push(s[0]);return}}updateGeometry(t){let n=this.userData,i=this.geometry.userData,s=i.parameters.width,o=i.parameters.height,a=t.parameters?.width??s,l=t.parameters?.height??o,c=n.textFrame;super.updateGeometry(t),c.maxLineSize=a,c.textOrigin.set(-.5*a,.5*l,0),l!==o?(this.checkOverFlow(),this.checkCapacity()):a!==s&&(s<a?this.checkCapacity():s>a&&this.checkOverFlow())}checkOverFlow(t=0){let n=this.userData,i=n.textFrame.textOrigin,s=n.textFrame.textLines;for(let o=t;o<s.length;o++){s[o].updateYLinePos(this.getNewLinePosition(o)),s[o].fullUpdate(i);let a=[];for(;s[o].checkOverFlow(n.textFrame.maxLineSize);)s[o].containSpaceOverFlow()?a.unshift(s[o].getWord(s[o].message.length-1,-1)):a.unshift(s[o].popChar());if(a.length>0){s[o+1]===void 0?(s[o].isEndLine(!1),this.createTextLine()):s[o].endLine&&(this.createTextLine(o+1),s[o].isEndLine(!1),s[o+1].isEndLine(!0));let l=0;for(let c=0;c<a.length;c+=1)for(let h=0;h<a[c].length;h+=1)s[o+1].addChar3D(a[c][h],i,l),l+=1;s[o+1].fullUpdate(i)}s[o].fullUpdate(i)}this.textFullUpdate(t)}checkCapacity(t=0){let n=this.userData,i=n.textFrame.textOrigin,s=n.textFrame.maxLineSize,o=n.textFrame.textLines;for(let a=t;a<o.length;a+=1)if(o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i),!!o[a-1])for(;!o[a-1].endLine;){let l,c=o[a-1].spaceLeft(s);if(o[a].wordSize(0,1)<=c){o[a].containSpace()?l=o[a].getWord(0,1):l=o[a].popChar(0);for(let h=0;h<l.length;h+=1)l[h]&&o[a-1].addChar3D(l[h],i)}else{o[a].isEmpty()?(o[a].endLine&&o[a-1].isEndLine(!0),o.splice(a,1),a-=1):(o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i));break}}this.textFullUpdate(t)}createTextLine(t=this.userData.textFrame.textLines.length){let i=this.userData.textFrame;i.textLines.splice(t,0,new Eo(this.getNewLinePosition(t),i.lineHeight,i.fontSize))}textFullUpdate(t=0){let i=this.userData.textFrame,s=i.textLines,o=this.getVerticalAlignmentOffSet();for(let a=t;a<s.length;a++)s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i.textOrigin),s[a].alignText(i.textOrigin,i.maxLineSize,i.horizontalAlignment,i.verticalAlignment,o)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let n=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(n.length)}getNewLinePosition(t){let i=this.userData.textFrame.textLines,s=0;for(let o=0;o<t;o+=1)s+=i[o].maxCharSize*i[o].lineHeight;return s}updateColor(t){let n=this.userData;n.textFrame.hexColor=t;let i=n.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.color?.isColor&&(l.color=t)}}}updateOpacity(t){let n=this.userData;n.textFrame.opacity=t;let i=n.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.opacity=t}}}updateVisible(t){let n=this.userData;n.textFrame.visible=t;let i=n.textFrame.textLines;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++){let l=o[a].material;l.visible=t}}}async updateFontFamily(t){await gr.loadFont(t);let i=this.userData.textFrame,s=i.textLines;i.fontFamily=t;for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)a[l].updateFontFamily(t)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(t){let i=this.userData.textFrame,s=i.textLines,o=i.fontSize;i.fontSize=t;for(let a=0;a<s.length;a++)s[a].updateFontSize(t);this.textFullUpdate(),t>o?this.checkOverFlow():t<o&&this.checkCapacity()}async updateTextTransform(t){let i=this.userData.textFrame;await gr.loadFont(i.fontFamily);let s=i.textLines;switch(i.textTransform=t,t){case 2:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].char.toUpperCase())}break;case 3:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].char.toLowerCase())}break;default:for(let o=0;o<s.length;o++){let a=s[o].message;for(let l=0;l<a.length;l++)s[o].message[l].updateChar(a[l].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(t){let n=this.userData,i=n.textFrame.textLines;n.textFrame.letterSpacing=t;for(let s=0;s<i.length;s++){let o=i[s].message;for(let a=0;a<o.length;a++)o[a].updateLetterSpacing(t)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(t){let n=this.userData;n.textFrame.LOD=t;let i=n.textFrame.textLines;for(let s=0;s<i.length;s++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(t){let n=this.userData,i=n.textFrame.textLines;n.textFrame.lineHeight=t;for(let s=0;s<i.length;s++)i[s].updatelineHeight(t);this.textFullUpdate()}updateVerticalAlignment(t){let n=this.userData;n.textFrame.verticalAlignment=t,this.textFullUpdate()}updateHorizontalAlignment(t){let n=this.userData;n.textFrame.horizontalAlignment=t,this.textFullUpdate()}fromTextFrameData(t,n){if(t.color!==void 0){let i=Ft(t.color,n);this.updateColor(i),this.updateOpacity(i.a)}t.alpha!==void 0&&this.updateOpacity(t.alpha),t.font!==void 0&&this.updateFontFamily(t.font),t.horizontalAlign!==void 0&&this.updateHorizontalAlignment(t.horizontalAlign),t.verticalAlign!==void 0&&this.updateVerticalAlignment(t.verticalAlign),t.textTransform!==void 0&&this.updateTextTransform(t.textTransform),t.fontSize!==void 0&&this.updateFontSize(t.fontSize),t.lineHeight!==void 0&&this.updateLineHeight(t.lineHeight),t.letterSpacing!==void 0&&this.updateLetterSpacing(t.letterSpacing),t.text!==void 0&&t.text!==""&&this.updateText(t.text),(t.width!==void 0||t.height!==void 0)&&this.updateGeometry({parameters:{width:t.width,height:t.height}})}fromState(t,n){return super.fromState(t),this.fromTextFrameData(t,n),this}convertToVector(){let{fontFamily:t,hexColor:n}=this.userData.textFrame,i=new Qi;i.name="Text Shape";let s=gr.fontCache[t];for(let o of this.charContainer.children)o instanceof gr&&s.generateShapes(o.char,1).forEach(a=>{let l=new pt().fromShape(a);l.applyScale(o.scale.x,o.scale.y);let c=Pn.create({shape:l}),h=new Zr({side:hn});h.color=n;let u=new ks(c,h);u.name=o.char,u.position.copy(o.position),u.rotation.copy(o.rotation),i.attach(u)});return i}},Co=Oy;Co.VerticalAlign=Lg,Co.HorizontalAlign=Pg,Co.TextTransform=Ig;var Fy=new WeakMap,Bf=class extends ys{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){let s=new vs(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{let a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,a).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(let l in t.attributeTypes){let c=t.attributeTypes[l];c.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=c.name)}let n=JSON.stringify(t);if(Fy.has(e)){let l=Fy.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((c,h)=>{i._callbacks[s]={resolve:c,reject:h},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Fy.set(e,{key:n,promise:a}),a}_createGeometry(e){let t=new Le;e.index&&t.setIndex(new Xe(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n],s=i.name,o=i.array,a=i.itemSize;t.setAttribute(s,new Xe(o,a))}return t}_loadLibrary(e,t){let n=new vs(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{let i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);let s=QO.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
4905
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){let o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}};function QO(){let r,e;onmessage=function(o){let a=o.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(h){r.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(r)});break;case"decode":let l=a.buffer,c=a.taskConfig;e.then(h=>{let u=h.draco,d=new u.Decoder,f=new u.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let m=t(u,d,f,c),p=m.attributes.map(g=>g.array.buffer);m.index&&p.push(m.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:m},p)}catch(m){console.error(m),self.postMessage({type:"error",id:a.id,error:m.message})}finally{u.destroy(f),u.destroy(d)}});break}};function t(o,a,l,c){let h=c.attributeIDs,u=c.attributeTypes,d,f,m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(m===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let p={index:null,attributes:[]};for(let g in h){let x=self[u[g]],v,w;if(c.useUniqueIDs)w=h[g],v=a.GetAttributeByUniqueId(d,w);else{if(w=a.GetAttributeId(d,o[h[g]]),w===-1)continue;v=a.GetAttribute(d,w)}p.attributes.push(i(o,a,d,g,x,v))}return m===o.TRIANGULAR_MESH&&(p.index=n(o,a,d)),o.destroy(d),p}function n(o,a,l){let h=l.num_faces()*3,u=h*4,d=o._malloc(u);a.GetTrianglesUInt32Array(l,u,d);let f=new Uint32Array(o.HEAPF32.buffer,d,h).slice();return o._free(d),{array:f,itemSize:1}}function i(o,a,l,c,h,u){let d=u.num_components(),m=l.num_points()*d,p=m*h.BYTES_PER_ELEMENT,g=s(o,h),x=o._malloc(p);a.GetAttributeDataArrayForAllPoints(l,u,g,p,x);let v=new h(o.HEAPF32.buffer,x,m).slice();return o._free(x),{name:c,array:v,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var Vs;function KO(){return Vs||(Vs=new Bf,Vs.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Vs.decoderPending}async function ZO(r){if(Vs){let e={attributeIDs:Vs.defaultAttributeIDs,attributeTypes:Vs.defaultAttributeTypes,useUniqueIDs:!1},t;try{t=await Vs.decodeGeometry(new Int8Array(r).buffer,e)}catch(n){console.error(n)}if(t)return{index:t.index?{array:t.index.array}:void 0,attributes:Object.entries(t.attributes).map(([n,i])=>({name:n,itemSize:i.itemSize,array:i.array}))}}return null}async function Q1(r,e){let[t,n]=fg(zd.deserialize(new Uint8Array(r))),i=[];t.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&i.push(o)}),i.length&&await KO();for(let s of i){let o=await ZO(mg(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:c,itemSize:h})=>{a[l]={array:c,itemSize:h,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return e&&e(t),n.result().data}var tA={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},ky={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},JO=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Ff={CSS:{},springs:{}};function Ti(r,e,t){return Math.min(Math.max(r,e),t)}function Th(r,e){return r.indexOf(e)>-1}function Uy(r,e){return r.apply(null,e)}var He={arr:function(r){return Array.isArray(r)},obj:function(r){return Th(Object.prototype.toString.call(r),"Object")},pth:function(r){return He.obj(r)&&r.hasOwnProperty("totalLength")},svg:function(r){return r instanceof SVGElement},inp:function(r){return r instanceof HTMLInputElement},dom:function(r){return!("isNode"in r)&&(r.nodeType||He.svg(r))},str:function(r){return typeof r=="string"},fnc:function(r){return typeof r=="function"},und:function(r){return typeof r>"u"},hex:function(r){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(r)},rgb:function(r){return/^rgb/.test(r)},hsl:function(r){return/^hsl/.test(r)},col:function(r){return He.hex(r)||He.rgb(r)||He.hsl(r)},key:function(r){return!tA.hasOwnProperty(r)&&!ky.hasOwnProperty(r)&&r!=="targets"&&r!=="keyframes"}};function nA(r){var e=/\(([^)]+)\)/.exec(r);return e?e[1].split(",").map(function(t){return parseFloat(t)}):[]}function rA(r,e){var t=nA(r),n=Ti(He.und(t[0])?1:t[0],.1,100),i=Ti(He.und(t[1])?100:t[1],.1,100),s=Ti(He.und(t[2])?10:t[2],.1,100),o=Ti(He.und(t[3])?0:t[3],.1,100),a=Math.sqrt(i/n),l=s/(2*Math.sqrt(i*n)),c=l<1?a*Math.sqrt(1-l*l):0,h=1,u=l<1?(l*a+-o)/c:-o+a;function d(m){var p=e?e*m/1e3:m;return l<1?p=Math.exp(-p*l*a)*(h*Math.cos(c*p)+u*Math.sin(c*p)):p=(h+u*p)*Math.exp(-p*a),m===0||m===1?m:1-p}function f(){var m=Ff.springs[r];if(m)return m;for(var p=1/6,g=0,x=0;;)if(g+=p,d(g)===1){if(x++,x>=16)break}else x=0;var v=g*p*1e3;return Ff.springs[r]=v,v}return e?d:f}function $O(r){return r===void 0&&(r=10),function(e){return Math.ceil(Ti(e,1e-6,1)*r)*(1/r)}}var eF=function(){var r=11,e=1/(r-1);function t(h,u){return 1-3*u+3*h}function n(h,u){return 3*u-6*h}function i(h){return 3*h}function s(h,u,d){return((t(u,d)*h+n(u,d))*h+i(u))*h}function o(h,u,d){return 3*t(u,d)*h*h+2*n(u,d)*h+i(u)}function a(h,u,d,f,m){var p,g,x=0;do g=u+(d-u)/2,p=s(g,f,m)-h,p>0?d=g:u=g;while(Math.abs(p)>1e-7&&++x<10);return g}function l(h,u,d,f){for(var m=0;m<4;++m){var p=o(u,d,f);if(p===0)return u;var g=s(u,d,f)-h;u-=g/p}return u}function c(h,u,d,f){if(!(0<=h&&h<=1&&0<=d&&d<=1))return;var m=new Float32Array(r);if(h!==u||d!==f)for(var p=0;p<r;++p)m[p]=s(p*e,h,d);function g(x){for(var v=0,w=1,b=r-1;w!==b&&m[w]<=x;++w)v+=e;--w;var S=(x-m[w])/(m[w+1]-m[w]),M=v+S*e,_=o(M,h,d);return _>=.001?l(x,M,h,d):_===0?M:a(x,v,v+e,h,d)}return function(x){return h===u&&d===f||x===0||x===1?x:s(g(x),u,f)}}return c}(),iA=function(){var r={linear:function(){return function(n){return n}}},e={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var i,s=4;n<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-n,2)}},Elastic:function(n,i){n===void 0&&(n=1),i===void 0&&(i=.5);var s=Ti(n,1,10),o=Ti(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},t=["Quad","Cubic","Quart","Quint","Expo"];return t.forEach(function(n,i){e[n]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(e).forEach(function(n){var i=e[n];r["easeIn"+n]=i,r["easeOut"+n]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},r["easeInOut"+n]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),r}();function Vy(r,e){if(He.fnc(r))return r;var t=r.split("(")[0],n=iA[t],i=nA(r);switch(t){case"spring":return rA(r,e);case"cubicBezier":return Uy(eF,i);case"steps":return Uy($O,i);default:return Uy(n,i)}}function sA(r){try{var e=document.querySelectorAll(r);return e}catch{return}}function Uf(r,e){for(var t=r.length,n=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<t;s++)if(s in r){var o=r[s];e.call(n,o,s,r)&&i.push(o)}return i}function zf(r){return r.reduce(function(e,t){return e.concat(He.arr(t)?zf(t):t)},[])}function K1(r){return He.arr(r)?r:(He.str(r)&&(r=sA(r)||r),r instanceof NodeList||r instanceof HTMLCollection?[].slice.call(r):[r])}function Hy(r,e){return r.some(function(t){return t===e})}function Wy(r){var e={};for(var t in r)e[t]=r[t];return e}function zy(r,e){var t=Wy(r);for(var n in r)t[n]=e.hasOwnProperty(n)?e[n]:r[n];return t}function Gf(r,e){var t=Wy(r);for(var n in e)t[n]=He.und(r[n])?e[n]:r[n];return t}function tF(r){var e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(r);return e?"rgba("+e[1]+",1)":r}function nF(r){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,t=r.replace(e,function(a,l,c,h){return l+l+c+c+h+h}),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t),i=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+i+","+s+","+o+",1)"}function rF(r){var e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(r)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(r),t=parseInt(e[1],10)/360,n=parseInt(e[2],10)/100,i=parseInt(e[3],10)/100,s=e[4]||1;function o(d,f,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?d+(f-d)*6*m:m<1/2?f:m<2/3?d+(f-d)*(2/3-m)*6:d}var a,l,c;if(n==0)a=l=c=i;else{var h=i<.5?i*(1+n):i+n-i*n,u=2*i-h;a=o(u,h,t+1/3),l=o(u,h,t),c=o(u,h,t-1/3)}return"rgba("+a*255+","+l*255+","+c*255+","+s+")"}function iF(r){if(He.rgb(r))return tF(r);if(He.hex(r))return nF(r);if(He.hsl(r))return rF(r)}function Ki(r){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(r);if(e)return e[1]}function sF(r){if(Th(r,"translate")||r==="perspective")return"px";if(Th(r,"rotate")||Th(r,"skew"))return"deg"}function Gy(r,e){return He.fnc(r)?r(e.target,e.id,e.total):r}function Ei(r,e){return r.getAttribute(e)}function jy(r,e,t){var n=Ki(e);if(Hy([t,"deg","rad","turn"],n))return e;var i=Ff.CSS[e+t];if(!He.und(i))return i;var s=100,o=document.createElement(r.tagName),a=r.parentNode&&r.parentNode!==document?r.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+t;var l=s/o.offsetWidth;a.removeChild(o);var c=l*parseFloat(e);return Ff.CSS[e+t]=c,c}function oA(r,e,t){if(e in r.style){var n=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r.style[e]||getComputedStyle(r).getPropertyValue(n)||"0";return t?jy(r,i,t):i}}function qy(r,e){if(He.dom(r)&&!He.inp(r)&&(Ei(r,e)||He.svg(r)&&r[e]))return"attribute";if(He.dom(r)&&Hy(JO,e))return"transform";if(He.dom(r)&&e!=="transform"&&oA(r,e))return"css";if(r[e]!=null)return"object"}function aA(r){if(!!He.dom(r)){for(var e=r.style.transform||"",t=/(\w+)\(([^)]*)\)/g,n=new Map,i;i=t.exec(e);)n.set(i[1],i[2]);return n}}function oF(r,e,t,n){var i=Th(e,"scale")?1:0+sF(e),s=aA(r).get(e)||i;return t&&(t.transforms.list.set(e,s),t.transforms.last=e),n?jy(r,s,n):s}function Xy(r,e,t,n){switch(qy(r,e)){case"transform":return oF(r,e,n,t);case"css":return oA(r,e,t);case"attribute":return Ei(r,e);default:return r[e]||0}}function Yy(r,e){var t=/^(\*=|\+=|-=)/.exec(r);if(!t)return r;var n=Ki(r)||0,i=parseFloat(e),s=parseFloat(r.replace(t[0],""));switch(t[0][0]){case"+":return i+s+n;case"-":return i-s+n;case"*":return i*s+n}}function lA(r,e){if(He.col(r))return iF(r);if(/\s/g.test(r))return r;var t=Ki(r),n=t?r.substr(0,r.length-t.length):r;return e?n+e:n}function Qy(r,e){return Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))}function aF(r){return Math.PI*2*Ei(r,"r")}function lF(r){return Ei(r,"width")*2+Ei(r,"height")*2}function cF(r){return Qy({x:Ei(r,"x1"),y:Ei(r,"y1")},{x:Ei(r,"x2"),y:Ei(r,"y2")})}function cA(r){for(var e=r.points,t=0,n,i=0;i<e.numberOfItems;i++){var s=e.getItem(i);i>0&&(t+=Qy(n,s)),n=s}return t}function hF(r){var e=r.points;return cA(r)+Qy(e.getItem(e.numberOfItems-1),e.getItem(0))}function hA(r){if(r.getTotalLength)return r.getTotalLength();switch(r.tagName.toLowerCase()){case"circle":return aF(r);case"rect":return lF(r);case"line":return cF(r);case"polyline":return cA(r);case"polygon":return hF(r)}}function uF(r){var e=hA(r);return r.setAttribute("stroke-dasharray",e),e}function dF(r){for(var e=r.parentNode;He.svg(e)&&He.svg(e.parentNode);)e=e.parentNode;return e}function uA(r,e){var t=e||{},n=t.el||dF(r),i=n.getBoundingClientRect(),s=Ei(n,"viewBox"),o=i.width,a=i.height,l=t.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:n,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function fF(r,e){var t=He.str(r)?sA(r)[0]:r,n=e||100;return function(i){return{property:i,el:t,svg:uA(t),totalLength:hA(t)*(n/100)}}}function pF(r,e){function t(a){a===void 0&&(a=0);var l=e+a>=1?e+a:0;return r.el.getPointAtLength(l)}var n=uA(r.el,r.svg),i=t(),s=t(-1),o=t(1);switch(r.property){case"x":return(i.x-n.x)*n.w;case"y":return(i.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function Z1(r,e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=lA(He.pth(r)?r.totalLength:r,e)+"";return{original:n,numbers:n.match(t)?n.match(t).map(Number):[0],strings:He.str(r)||e?n.split(t):[]}}function dA(r){var e=r?zf(He.arr(r)?r.map(K1):K1(r)):[];return Uf(e,function(t,n,i){return i.indexOf(t)===n})}function fA(r){var e=dA(r);return e.map(function(t,n){return{target:t,id:n,total:e.length,transforms:{list:aA(t)}}})}function mF(r,e){var t=Wy(e);if(/^spring/.test(t.easing)&&(t.duration=rA(t.easing)),He.arr(r)){var n=r.length,i=n===2&&!He.obj(r[0]);i?r={value:r}:He.fnc(e.duration)||(t.duration=e.duration/n)}var s=He.arr(r)?r:[r];return s.map(function(o,a){var l=He.obj(o)&&!He.pth(o)?o:{value:o};return He.und(l.delay)&&(l.delay=a?0:e.delay),He.und(l.endDelay)&&(l.endDelay=a===s.length-1?e.endDelay:0),l}).map(function(o){return Gf(o,t)})}function gF(r){for(var e=Uf(zf(r.map(function(s){return Object.keys(s)})),function(s){return He.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),t={},n=function(s){var o=e[s];t[o]=r.map(function(a){var l={};for(var c in a)He.key(c)?c==o&&(l.value=a[c]):l[c]=a[c];return l})},i=0;i<e.length;i++)n(i);return t}function yF(r,e){var t=[],n=e.keyframes;n&&(e=Gf(gF(n),e));for(var i in e)He.key(i)&&t.push({name:i,tweens:mF(e[i],r)});return t}function vF(r,e){var t={};for(var n in r){var i=Gy(r[n],e);He.arr(i)&&(i=i.map(function(s){return Gy(s,e)}),i.length===1&&(i=i[0])),t[n]=i}return t.duration=parseFloat(t.duration),t.delay=parseFloat(t.delay),t}function xF(r,e){var t;return r.tweens.map(function(n){var i=vF(n,e),s=i.value,o=He.arr(s)?s[1]:s,a=Ki(o),l=Xy(e.target,r.name,a,e),c=t?t.to.original:l,h=He.arr(s)?s[0]:c,u=Ki(h)||Ki(l),d=a||u;return He.und(o)&&(o=c),i.from=Z1(h,d),i.to=Z1(Yy(o,h),d),i.start=t?t.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=Vy(i.easing,i.duration),i.isPath=He.pth(s),i.isColor=He.col(i.from.original),i.isColor&&(i.round=1),t=i,i})}var pA={css:function(r,e,t){return r.style[e]=t},attribute:function(r,e,t){return r.setAttribute(e,t)},object:function(r,e,t){return r[e]=t},transform:function(r,e,t,n,i){if(n.list.set(e,t),e===n.last||i){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),r.style.transform=s}}};function mA(r,e){var t=fA(r);t.forEach(function(n){for(var i in e){var s=Gy(e[i],n),o=n.target,a=Ki(s),l=Xy(o,i,a,n),c=a||Ki(l),h=Yy(lA(s,c),l),u=qy(o,i);pA[u](o,i,h,n.transforms,!0)}})}function bF(r,e){var t=qy(r.target,e.name);if(t){var n=xF(e,r),i=n[n.length-1];return{type:t,property:e.name,animatable:r,tweens:n,duration:i.end,delay:n[0].delay,endDelay:i.endDelay}}}function wF(r,e){return Uf(zf(r.map(function(t){return e.map(function(n){return bF(t,n)})})),function(t){return!He.und(t)})}function gA(r,e){var t=r.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=t?Math.max.apply(Math,r.map(function(s){return n(s)+s.duration})):e.duration,i.delay=t?Math.min.apply(Math,r.map(function(s){return n(s)+s.delay})):e.delay,i.endDelay=t?i.duration-Math.max.apply(Math,r.map(function(s){return n(s)+s.duration-s.endDelay})):e.endDelay,i}var J1=0;function SF(r){var e=zy(tA,r),t=zy(ky,r),n=yF(t,r),i=fA(r.targets),s=wF(i,n),o=gA(s,t),a=J1;return J1++,Gf(e,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay})}var ir=[],$1=[],Of,AF=function(){function r(){Of=requestAnimationFrame(e)}function e(t){var n=ir.length;if(n){for(var i=0;i<n;){var s=ir[i];if(!s.paused)s.tick(t);else{var o=ir.indexOf(s);o>-1&&(ir.splice(o,1),n=ir.length)}i++}r()}else Of=cancelAnimationFrame(Of)}return r}();function MF(){document.hidden?(ir.forEach(function(r){return r.pause()}),$1=ir.slice(0),an.running=ir=[]):$1.forEach(function(r){return r.play()})}typeof document<"u"&&document.addEventListener("visibilitychange",MF);function an(r){r===void 0&&(r={});var e=0,t=0,n=0,i,s=0,o=null;function a(w){var b=window.Promise&&new Promise(function(S){return o=S});return w.finished=b,b}var l=SF(r),c=a(l);function h(){var w=l.direction;w!=="alternate"&&(l.direction=w!=="normal"?"normal":"reverse"),l.reversed=!l.reversed,i.forEach(function(b){return b.reversed=l.reversed})}function u(w){return l.reversed?l.duration-w:w}function d(){e=0,t=u(l.currentTime)*(1/an.speed)}function f(w,b){b&&b.seek(w-b.timelineOffset)}function m(w){if(l.reversePlayback)for(var S=s;S--;)f(w,i[S]);else for(var b=0;b<s;b++)f(w,i[b])}function p(w){var b=0,S=l.animations,M=S.length;for(l.reversePlayback===!0&&l.rewind===!1&&(w=l.duration+l.delay-l.endDelay-w);b<M;){var _=S[b],y=_.animatable,T=_.tweens,E=T.length-1,C=T[E];E&&(C=Uf(T,function(Z){return w<Z.end})[0]||C);for(var I=Ti(w-C.start-C.delay,0,C.duration)/C.duration,R=isNaN(I)?1:C.easing(I),N=C.to.strings,H=C.round,j=[],K=C.to.numbers.length,Y=void 0,z=0;z<K;z++){var F=void 0;if(l.reversePlayback===!0&&l.rewind===!1)var V=C.to.numbers[z],O=C.from.numbers[z]||0;else var O=C.to.numbers[z],V=C.from.numbers[z]||0;C.isPath?F=pF(C.value,R*O):F=V+R*(O-V),H&&(C.isColor&&z>2||(F=Math.round(F*H)/H)),j.push(F)}var G=N.length;if(!G)Y=j[0];else{Y=N[0];for(var W=0;W<G;W++){var X=N[W],q=N[W+1],se=j[W];isNaN(se)||(q?Y+=se+q:Y+=se+" ")}}pA[_.type](y.target,_.property,Y,y.transforms),_.currentValue=Y,b++}}function g(w){l[w]&&!l.passThrough&&l[w](l)}function x(){l.remaining&&l.remaining!==!0&&l.remaining--}function v(w){var b=l.duration,S=l.delay,M=b-l.endDelay,_=u(w);l.progress=Ti(_/b*100,0,100),l.reversePlayback=_<l.currentTime,i&&m(_),!l.began&&l.currentTime>=0&&(l.began=!0,g("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,g("loopBegin")),_<=S&&l.currentTime!==0&&(p(0),g("change")),(_>=M&&l.currentTime!==b||!b)&&(p(b),g("change")),_>S&&_<M?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,g("changeBegin")),g("change"),p(_)):l.changeBegan?(l.changeCompleted=!0,l.changeBegan=!1,g("change"),g("changeComplete")):l.began&&_>M&&(g("change"),g("changeComplete")),l.currentTime=Ti(_,0,b),l.began&&g("update"),w>=b&&(t=0,x(),l.remaining?(e=n,g("loopComplete"),l.loopBegan=!1,l.direction==="alternate"&&h()):(l.paused=!0,l.completed||(l.completed=!0,g("loopComplete"),g("complete"),!l.passThrough&&"Promise"in window&&(o(),c=a(l)))))}return l.reset=function(){var w=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed=w==="reverse",l.remaining=l.loop,i=l.children,s=i.length;for(var b=s;b--;)l.children[b].reset();(l.reversed&&l.loop!==!0||w==="alternate"&&l.loop===1)&&l.remaining++,p(l.reversed?l.duration:0)},l.set=function(w,b){return mA(w,b),l},l.tick=function(w){n=w,e||(e=n),v((n+(t-e))*an.speed)},l.seek=function(w){v(u(w))},l.pause=function(){l.paused=!0,d()},l.play=function(){!l.paused||(l.completed&&l.reset(),l.paused=!1,ir.push(l),d(),Of||AF())},l.reverse=function(){h(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.reset(),l.autoplay&&l.play(),l}function eA(r,e){for(var t=e.length;t--;)Hy(r,e[t].animatable.target)&&e.splice(t,1)}function _F(r){for(var e=dA(r),t=ir.length;t--;){var n=ir[t],i=n.animations,s=n.children;eA(e,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;eA(e,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&n.pause()}}function TF(r,e){e===void 0&&(e={});var t=e.direction||"normal",n=e.easing?Vy(e.easing):null,i=e.grid,s=e.axis,o=e.from||0,a=o==="first",l=o==="center",c=o==="last",h=He.arr(r),u=parseFloat(h?r[0]:r),d=h?parseFloat(r[1]):0,f=Ki(h?r[1]:r)||0,m=e.start||0+(h?u:0),p=[],g=0;return function(x,v,w){if(a&&(o=0),l&&(o=(w-1)/2),c&&(o=w-1),!p.length){for(var b=0;b<w;b++){if(!i)p.push(Math.abs(o-b));else{var S=l?(i[0]-1)/2:o%i[0],M=l?(i[1]-1)/2:Math.floor(o/i[0]),_=b%i[0],y=Math.floor(b/i[0]),T=S-_,E=M-y,C=Math.sqrt(T*T+E*E);s==="x"&&(C=-T),s==="y"&&(C=-E),p.push(C)}g=Math.max.apply(Math,p)}n&&(p=p.map(function(R){return n(R/g)*g})),t==="reverse"&&(p=p.map(function(R){return s?R<0?R*-1:-R:Math.abs(g-R)}))}var I=h?(d-u)/g:u;return m+I*(Math.round(p[v]*100)/100)+f}}function EF(r){r===void 0&&(r={});var e=an(r);return e.duration=0,e.add=function(t,n){var i=ir.indexOf(e),s=e.children;i>-1&&ir.splice(i,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=Gf(t,zy(ky,r));l.targets=l.targets||r.targets;var c=e.duration;l.autoplay=!1,l.direction=e.direction,l.timelineOffset=He.und(n)?c:Yy(n,c),o(e),l.rewind=e.rewind,e.seek(l.timelineOffset);var h=an(l);o(h),s.push(h);var u=gA(s,r);return e.delay=u.delay,e.endDelay=u.endDelay,e.duration=u.duration,e.seek(0),e.reset(),e.autoplay&&e.play(),e},e}an.version="3.2.0";an.speed=1;an.running=ir;an.remove=_F;an.get=Xy;an.set=mA;an.convertPx=jy;an.path=fF;an.setDashoffset=uF;an.stagger=TF;an.timeline=EF;an.easing=Vy;an.penner=iA;an.random=function(r,e){return Math.floor(Math.random()*(e-r+1))+r};var yA=an;function vA(r,e,t){let n=r.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(n!==void 0){let i=r.zoom;i!==n&&t.push({change:s=>{r.zoom=Ge.lerp(i,n,s),r.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let i=r.targetOffset,s=e.targetOffset;i!==s&&t.push({change:o=>{r.targetOffset=Ge.lerp(i,s,o)}})}}function xA(r,e,t){if(e.width!==void 0&&e.height!==void 0&&e.depth!==void 0){let{width:n,height:i,depth:s}=r.geometry.userData.parameters,o=[n,i,s],a=[e.width,e.height,e.depth];!on.isEqual(o,a)&&!bt(r)&&t.push({change:l=>{let[c,h,u]=on.lerp(o,a,l);r.updateGeometry({parameters:{width:c,height:h,depth:u}}),r.invalidateDownstreamBooleanData()}})}}function bA(r,e,t,n){if(e.intensity!==void 0){let i=r.intensity,s=e.intensity;i!==s&&t.push({change:o=>{r.intensity=Ge.lerp(i,s,o)}})}if(e.color!==void 0){let i=r.color.clone(),s=typeof e.color=="string"?n.getColor(e.color):e.color;if(!dn.equals(i,s)){let o=i.clone();r.color=o,t.push({change:a=>{let{r:l,g:c,b:h}=dn.lerp(i,s,a);o.setRGB(l,c,h)}})}}}function wA(r,e,t,n){let i=r.layersList.head;for(;i;){let s=e.layers.data(i.uuid);if(s&&(i.visible??!0)&&(s.visible??!0)){let o=i.getNames().filter(a=>!sS.some(l=>a.includes(l)));for(let a of o)try{let l=i.getValue(a);if(a==="steps")NF(i,s,a,t);else if(a==="colors")RF(i,s,a,t);else if(typeof l=="number")CF(i,s,a,t);else{if(typeof l=="boolean")continue;"isVector2"in l?DF(i,s,a,t):"isVector3"in l?PF(i,s,a,t):"isColorA"in l?IF(i,s,a,t,n):"isColor"in l?LF(i,s,a,t,n):"isTexture"in l&&BF(i,s,a,t)}}catch(l){console.error(`animateMaterial: unexpected material layer for ${a}`,l)}}i=i.next}}function CF(r,e,t,n){if(!r.hasValue(t)||!(t in e))return;let i=r.getValue(t),s=e[t];i!==s&&n.push({change:o=>{r.setValue(t,Ge.lerp(i,s,o))}})}function DF(r,e,t,n){if(!r.hasValue(t)||!(t in e))return;let i=r.getValue(t),s=i.toArray(),o=e[t];Wi.isEqual(s,o)||n.push({change:a=>{i.fromArray(Wi.lerp(s,o,a))}})}function PF(r,e,t,n){if(!r.hasValue(t)||!(t in e))return;let i=r.getValue(t),s=i.toArray(),o=e[t];on.isEqual(s,o)||n.push({change:a=>{i.fromArray(on.lerp(s,o,a))}})}function LF(r,e,t,n,i){if(!r.hasValue(t)||!(t in e))return;let s=r.getValue(t).clone(),o=e[t],a=typeof o=="string"?i.getColor(o):o;if(dn.equals(s,a))return;let l=s.clone();r.setValue(t,l),n.push({change:c=>{let{r:h,g:u,b:d}=dn.lerp(s,a,c);l.setRGB(h,u,d)}})}function IF(r,e,t,n,i){if(!r.hasValue(t)||!(t in e))return;let s=r.getValue(t).clone(),o=e[t],a=typeof o=="string"?i.getColor(o):o;if(On.equals(s,a))return;let l=s.clone();r.setValue(t,l),n.push({change:c=>{let{r:h,g:u,b:d,a:f}=On.lerp(s,a,c);l.setRGBA(h,u,d,f)}})}function NF(r,e,t="steps",n){if(!r.hasValue(t)||!(t in e))return;let i=[...r.getValue(t)],s=e[t];for(let o=0;o<i.length;++o){let a=i[o],l=s[o];a!==l&&n.push({change:c=>{i[o]=Ge.lerp(a,l,c),r.setValue("steps",i)}})}}function RF(r,e,t="colors",n){if(!r.hasValue(t)||!(t in e))return;let i=r.getValue(t),s=e[t];for(let o=0;o<i.length;++o){let a=i[o].toArray(),l=s[o];Uc.isEqual(a,l)||n.push({change:c=>{i[o].fromArray(Uc.lerp(a,l,c))}})}}function BF(r,e,t="texture",n){if(!r.hasValue(t)||!(t in e))return;let i=r.getValue("texture"),s=e[t],o=i.repeat.toArray(),a=i.offset.toArray(),l=s.repeat,c=s.offset;(!Wi.isEqual(o,l)||!Wi.isEqual(a,c))&&n.push({change:h=>{i.repeat.fromArray(Wi.lerp(o,l,h)),i.offset.fromArray(Wi.lerp(a,c,h)),i.updateMatrix(),i.needsUpdate=!0}})}function SA(r,e,t,n){if(n===0)return t.copy(r);if(n===1)return t.copy(e);let i=r.w*e.w+r.x*e.x+r.y*e.y+r.z*e.z;if(i>=1)return t.copy(r);let s=1-i*i;if(s<=Number.EPSILON){let h=1-n;return t.w=h*r.w+n*e.w,t.x=h*r.x+n*e.x,t.y=h*r.y+n*e.y,t.z=h*r.z+n*e.z,t.normalize(),t}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-n)*a)/o,c=Math.sin(n*a)/o;return t.w=r.w*l+e.w*c,t.x=r.x*l+e.x*c,t.y=r.y*l+e.y*c,t.z=r.z*l+e.z*c,t}function AA(r,e,t=0){let n=Array.isArray(r.material)?r.material[t]:r.material,i;return"materials"in e?i=e.materials[t]:"material"in e&&(i=e.material),[n,i]}var Ky=new A,Zy=new A,MA=new Xt,OF=new br,FF=new Oe;function _A(r,e,t,n){if(t.position!==void 0){let i=r.position.toArray(),s=t.position;on.isEqual(i,s)||n.push({change:o=>{r.position.fromArray(on.lerp(i,s,o)),r.updateMatrix(),Ut(r)&&bt(r.parent)&&r.invalidateDownstreamBooleanData(!0)}})}if(t.scale!==void 0){let i=r.scale.toArray(),s=t.scale;on.isEqual(i,s)||n.push({change:o=>{r.scale.fromArray(on.lerp(i,s,o)),r.updateMatrix(),Ut(r)&&bt(r.parent)&&r.invalidateDownstreamBooleanData(!0)}})}UF(r,e,t,n),zF(r,t,n)}function UF(r,e,t,n){if(t.rotation===void 0)return;let i=Ky.setFromEuler(r.rotation).toArray(),s=t.rotation;if(on.isEqual(i,s))return;if(on.sub(t.rotation,e?e.rotation:r.rotation).every(a=>Math.abs(a)<2*Math.PI)){let a=r.quaternion.clone(),l=new Xt().setFromEuler(OF.set(t.rotation[0],t.rotation[1],t.rotation[2]));n.push({change:c=>{SA(a,l,r.quaternion,c),r.updateMatrix(),Ut(r)&&bt(r.parent)&&r.invalidateDownstreamBooleanData(!0)}})}else n.push({change:a=>{r.rotation.setFromVector3(Zy.fromArray(on.lerp(i,s,a))),r.updateMatrix(),Ut(r)&&bt(r.parent)&&r.invalidateDownstreamBooleanData(!0)}})}function zF(r,e,t){if(e.hiddenMatrix!==void 0&&!di.isEqual(r.hiddenMatrix.toArray(),e.hiddenMatrix)){let n=new A,i=new Xt,s=new A;r.hiddenMatrix.decompose(n,i,s);let o=new A,a=new Xt,l=new A;FF.fromArray(e.hiddenMatrix).decompose(o,a,l),t.push({change:c=>{MA.slerpQuaternions(i,a,c),Ky.lerpVectors(n,o,c),Zy.lerpVectors(s,l,c),r.hiddenMatrix.compose(Ky,MA,Zy),Ut(r)&&bt(r.parent)&&r.invalidateDownstreamBooleanData(!0)}})}}function TA(r,e,t,n){let i=[];if((r.visible||bt(r.parent))&&_A(r,e?.objectState,t.objectState,i),Ut(r)){if((r.visible||bt(r.parent))&&"geometry"in t.objectState&&xA(r,t.objectState.geometry,i),r.visible&&("material"in t.objectState||"materials"in t.objectState)){let[s,o]=AA(r,t.objectState,0);s&&o&&typeof o!="string"&&wA(s,o,i,n)}}else r.visible&&c1(r)?bA(r,t.objectState,i,n):l1(r)&&vA(r,t.objectState,i);return i.length?{change:s=>{i.forEach(o=>{o.change&&o.change(s)})}}:void 0}function GF(r,e,t){switch(r){case 0:return"cubicBezier( 0, 0, 1, 1 )";case 1:return"cubicBezier( .25, .1, .25, 1 )";case 2:return"cubicBezier( .42, 0, 1, 1 )";case 3:return"cubicBezier( 0, 0, .58, 1 )";case 4:return"cubicBezier( .42, 0, .58, 1 )";case 5:let{control1:n,control2:i}=e??{...bd.defaultData};return`cubicBezier( ${n[0]}, ${n[1]}, ${i[0]}, ${i[1]} )`;case 6:let{mass:s,stiffness:o,damping:a,velocity:l}=t??{...xd.defaultData};return`spring( ${s}, ${o}, ${a}, ${l} )`}}var kf=class{constructor(e,t){this.object=e;this.sharedAssets=t;this.uuid=Ge.generateUUID();this.states=[];this.events={};this.animatingState=0;this._scrollCounter=null}get fromState(){return this._fromState}get animation(){return this._animation}start(){this._animation!==void 0&&(this._animation.pause(),this._animation=void 0,this._scrollCounter=null),this.states.length>1&&(this.states[0].execute(this.object,this.sharedAssets),this._toState=this.states[0],this._fromState=void 0)}end(){this._animation!==void 0&&(this._animation.pause(),this._animation=void 0),this.states.length>1&&this.states[0].execute(this.object,this.sharedAssets),this._toState=void 0,this._fromState=void 0}seek(e,t,n,i,s){this._scrollCounter===null&&(this.animate(e,i,s),this._scrollCounter=0),this._scrollCounter+=t,this._scrollCounter=Math.min(Math.max(this._scrollCounter,0),n),this._animation?.seek(this._scrollCounter/n*(i.duration?i.duration:1))}animate(e,t,n){if(this._fromState===e&&this._animation?.reversed){let i=this._animation?.currentTime??0;this._animation?.reset(),this._animation?.seek(i),this._animation?.play()}else if(this._toState!==e){this._animation!==void 0&&this._animation.pause(),this.animatingState=0,this._fromState=this._toState,this._toState=e;let i=TA(this.object,this._fromState,e,this.sharedAssets);if(!i)return;let s={t:0};this._animation=yA({autoplay:!1,loop:t.repeat?!0:t.cycle?1:!1,direction:t.cycle?"alternate":"normal",rewind:t.rewind,delay:t.startDelay,endDelay:t.endDelay,duration:t.duration,easing:GF(t.easing,t.cubicControls,t.springParameters),targets:s,t:1,change:()=>{i.change&&i.change(s.t),n?.change&&n.change(s.t)},loopBegin:o=>{if(this.animatingState===0){this.animatingState=1;return}o.reversed?(this._toState=this._fromState,this._fromState=e):(this._fromState=this._toState,this._toState=e)}}),t.autoplay?t.startOnceDelay>0?setTimeout(()=>this._animation?.play(),t.startOnceDelay):this._animation?.play():this._animation.finished.then(()=>{this._animation=void 0,this.animatingState=0})}}emitEvent(e,t){if(e==="keyDown"||e==="keyUp"||e==="mouseDown"||e==="mouseUp"||e==="mouseHover"||e==="scroll"||e==="start"){let n=this.events[e];if(n){for(let i of n)if("targets"in i)for(let{object:s,state:o,params:a}of i.targets)s.interaction?.animate(o,a,{change:t})}}}emitEventReverse(e,t){if(e==="keyDown"||e==="keyUp"||e==="mouseDown"||e==="mouseUp"||e==="mouseHover"||e==="scroll"||e==="start"){let n=this.events[e];if(n){for(let i of n)if("targets"in i)for(let{object:s,params:o}of i.targets){let a=s.interaction;a?._fromState!==void 0&&a.animate(a._fromState,o,{change:t})}}}}};var Nl=class{static create(e,t){if(e.object){let n=t.find(e.object);if(n?.interaction){let i=e.state?n.interaction.states.find(s=>s.uuid===e.state):n.interaction.states[0];if(i){let s=e.delay??0,o={cycle:e.cycle??!1,rewind:e.rewind??!1,repeat:e.repeat??!1,duration:e.duration??1e3,startOnceDelay:e.delayDirection==="start-once"?s:0,startDelay:e.delayDirection==="start"||!e.delayDirection?s:0,endDelay:e.delayDirection==="end"||!e.delayDirection?s:0,easing:e.easing??4,autoplay:!0};if(e.easing===5){let a=e;o.cubicControls={control1:[...a.control1],control2:[...a.control2]}}if(e.easing===6){let a=e;o.springParameters={mass:a.mass,stiffness:a.stiffness,damping:a.damping,velocity:a.velocity}}return new Nl(n,i,o)}}}}constructor(e,t,n){this.object=e,this.state=t,this.params=n}};var Jy=new Map,Eh={url:"head",time:0,data:null,next:null,prev:null},Rl={url:"tail",time:1/0,data:null,next:null,prev:null};Eh.next=Rl;Rl.prev=Eh;var EA=0;function Gs(r){if(typeof r=="string")return r;let e=Date.now(),t=Jy.get(r);return t===void 0?(t={url:URL.createObjectURL(new Blob([r])),data:r,time:e,next:null,prev:null},Jy.set(r,t)):(t.time=e,t.prev.next=t.next,t.next.prev=t.prev),t.prev=Rl.prev,t.next=Rl,Rl.prev.next=t,Rl.prev=t,e-EA>1e3*10&&(EA=e+1e3,setTimeout(()=>{let n=Date.now(),i=Eh.next;for(;i.time<n-1e3*10;)URL.revokeObjectURL(i.url),Jy.delete(i.data),i=i.next,i.prev=Eh,Eh.next=i},900)),t.url}var CA=new Zr,Do=class extends Ln{},Vf=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new lt(2048,2048,{generateMipmaps:!0,minFilter:xs,magFilter:tt,wrapS:bn,wrapT:bn}),this.transmissionRenderTarget.depthTexture=new wr(2048,2048),this.normalRenderTarget=new lt(1024,1024,{generateMipmaps:!1,minFilter:Gt,magFilter:Gt,type:vr}),this.normalRenderTarget.depthTexture=new wr(1024,1024),this.penumbraSizeNode=new gn(5,e.penumbraSize),this.resolutionNode=new mn(1,1),this.pixelRatioNode=new _e(window.devicePixelRatio),this.reset(e)}reset(e){for(let[t,n]of Object.entries(e.images))this.addImage(t,n.data);for(let[t,n]of Object.entries(e.colors))this.addColor(t,n);for(let[t,n]of Object.entries(e.materials))this.addMaterial(t,wy(n,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}get normalMap(){return this.normalRenderTarget.texture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===CA}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??CA}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad()},this.images[e].src=Gs(t),!0;{let n=new Image;return n.src=Gs(t),n.onload=()=>{this.onImageLoad&&this.onImageLoad()},this.images[e]=n,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new Do(t.r,t.g,t.b,t.a):this.colors[e]=new Do(t.r,t.g,t.b,1),!1)}updateColor(e,t){if(this.colors[e]){let n=this.colors[e];return this.colors[e].r=t.r??n.r,this.colors[e].g=t.g??n.g,this.colors[e].b=t.b??n.b,this.colors[e].a=t.a??n.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};var IA=DM(PA());var $y;sf.then(r=>{$y=r});var NA=new Oe,kF=new Oe,VF=new Oe,ei=new Sn,Hs=new A,HF=new Oe,WF=new Oe,Ws=class extends Nt{constructor(t,n,i,s){super(i??n,s);this.subdivPointer=t;this.originalGeometry=n;this.subdividedGeometry=i;this.objectType="SubdivObject";this.hiddenMatrixOld=new Oe;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new Oe;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(t,n,i){let{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}=Ir.build(n.geometry,void 0,void 0,!n.flatShading),l=Sh(n.material,i),c=new Ws(s,o,a||void 0,l);return n.geometry.phongAngle!==void 0&&(c.phongAngle=n.geometry.phongAngle),c.calcBoundingBox(),c.freeSubdivPointer(),c.uuid=t,c.fromState(n),c}shallowClone(t){return new Il(this.geometry,this.material).shallowCopy(this,t)}buildFromStore(t,n){let{originalGeometry:i,subdividedGeometry:s,subdivPointer:o}=Ir.build(t,n,this.subdivPointer,this.smoothShading,this.shearScale);if(t.phongAngle!==void 0&&(this.phongAngle=t.phongAngle),this.subdivPointer=o,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,Ah(this),this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry;t.width&&(this.geometry.userData.parameters={width:t.width,height:t.height,depth:t.depth})}updateMesh(t=!1){Ir.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,t?this.shearScaleInv:void 0),this.subdividedGeometry&&Ir.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,t?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Ir.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Ir.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(t,n){this.geometry=this.originalGeometry,Nt.prototype.raycast.call(this,t,n),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,n=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:o}=(0,IA.SVD)(n),a=NA.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),l=kF.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),c=VF.copy(l).transpose();this.shearScale=HF.makeScale(o[0],o[1],o[2]).multiply(c).premultiply(l),this.shearScaleInv=WF.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,c),o.every(h=>Math.abs(o[0]-h)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new Rn);let n=t.attributes.position,i=t.boundingSphere.center;ei.setFromBufferAttribute(n),ei.getCenter(i),t.boundingSphere.radius=i.distanceTo(ei.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ei.getSize(Hs);let s={width:Hs.x,height:Hs.y,depth:Hs.z};return this.geometry.userData.parameters=s,s}updateBoundingBox(t){let n=this.originalGeometry;ei.min.set(t[0],t[2],t[4]),ei.max.set(t[1],t[3],t[5]),this.shearScaleInv&&(ei.min.applyMatrix4(this.shearScaleInv),ei.max.applyMatrix4(this.shearScaleInv)),n.boundingSphere===null&&(n.boundingSphere=new Rn);let i=n.boundingSphere.center;ei.getCenter(i),n.boundingSphere.radius=i.distanceTo(ei.max),isNaN(n.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ei.getSize(Hs);let s={width:Hs.x,height:Hs.y,depth:Hs.z};return this.geometry.userData.parameters=s,s}freeSubdivPointer(){this.subdivPointer&&($y.free_bvh(this.subdivPointer),$y.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(t){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:t.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:t.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:t.parameters.depth/this.geometry.userData.parameters.depth,LA(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(LA(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...t.parameters}}};function LA(r,e,t,n){let i=r.position.array,s=r.normal.array,o=NA.makeScale(e,t,n).invert().elements,a,l,c;for(var h=0,u=i.length;h<u;h+=3)i[h]*=e,i[h+1]*=t,i[h+2]*=n,a=s[h],l=s[h+1],c=s[h+2],s[h]=o[0]*a+o[4]*l+o[8]*c,s[h+1]=o[1]*a+o[5]*l+o[9]*c,s[h+2]=o[2]*a+o[6]*l+o[10]*c}function RA(r,e){e.flatShading!==void 0&&(r.flatShading=e.flatShading,r.needsUpdate=!0),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.side!==void 0&&(e.side===0?r.side=zi:e.side===1?r.side=wn:r.side=hn)}function jF(r,e){if(Array.isArray(r.material))for(let t of r.material)RA(t,e);else{let t=r.material;RA(t,e)}r.objectType==="SubdivObject"&&e.flatShading!==void 0&&(r.material.flatShading=!1,r.smoothShading=!e.flatShading,r.updateMesh())}function BA(r,e,t){let n;if(e.geometry.type==="SubdivGeometry")n=Ws.createFromState(r,e,t);else{let i=e.geometry.type==="BooleanGeometry"?new Le:_f(e.geometry,t),s="materials"in e?S1(e.materials,t):Sh(e.material,t);Wd.is2DParametricMesh(i.userData.type)?n=new If(i,s):i?.userData.type==="VectorGeometry"?n=new ks(i,s):e.geometry.type==="NonParametricGeometry"?n=new Il(i,s):e.geometry.type==="BooleanGeometry"?(n=new Ef(void 0,s),n.booleanOp=e.geometry.operation,e.geometry.phongAngle!==void 0&&(n.phongAngle=e.geometry.phongAngle)):n=new Ll(i,s),n.uuid=r,n.fromState(e,t)}return jF(n,e),n}function OA(r,e,t){return e.type==="Mesh"?BA(r,e,t):e.type==="TextFrame"?Co.createFromState(r,e,t):e.type==="Empty"?Qi.createFromState(r,e):e.type==="PointLight"?Cl.createFromState(r,e,t):e.type==="SpotLight"?Dl.createFromState(r,e,t):e.type==="DirectionalLight"?El.createFromState(r,e,t):Ds.is(e.type)?mr.createFromState(r,e):(console.error(e),new Qi)}var FA=new A,ev=class extends of(Wn){constructor(t,n){super();this.objectType="Scene";this.alpha=1;this.backupFog=new sa(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this._color=new Ae(1,0,0);this.bgColor=new Ae(1,1,1);this.entityByUuid={};this.ambientLight=new fo(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=n,this.init(t,n)}needsTransmission(t){return this.needsTransmissionDirty&&(this._needsTransmission=C1(t,this),t!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}needsNormal(t){return this.needsNormalDirty&&(this._needsNormal=E1(t,this),t!==void 0&&(this.needsNormalDirty=!1)),this._needsNormal}find(t){if(t===""||t===void 0)return;let n=this.entityByUuid[t];return n===void 0?this.getObjectByProperty("uuid",t):n}get color(){return this._color}set color(t){this.fogUseBGColor===!0&&this.backupFog.color.copy(t),this._color.copy(t)}get enableFog(){return this.fog!==null}set enableFog(t){this.fog=t===!0?this.backupFog:null}init(t,n){if(this.createChildrenObjects(t.objects,this,n),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ft(t.backgroundColor,n)),this.updateFog(t.fog,n),this.updateAmbientLight(t.environment.ambientLight,n),this.activeCamera=this.personalCamera,t.publish.playCamera!==null){let i=this.find(t.publish.playCamera);i instanceof mr&&this.switchActiveCamera(i)}this.traverse(i=>{bt(i)&&i.recomputeBoolean()})}clearScene(t){this.traverseEntity(n=>{D1(n,t)});for(let n of this.children)Cr(n)&&n.removeFromParent()}resetAfterClear(t,n){this.init(t,n)}createPersonalCamera(){let t=mr.createFromState(ev.PERSONAL_CAMERA_ID,{...qd.defaultData,name:"Personal Camera"});return t.enableHelper=!1,t.objectHelper.visible=!1,delete t.isEntity,this.registerObjectCreatedInLegacy(t),t}raycast(t){let n=[],i=s=>{for(let o of s.children)Cr(o)&&!o.raycastLock&&o.visible&&((Ut(o)||Xi(o)&&o.enableHelper&&o.objectHelper.parent)&&t.intersectObject(o,!1,n),i(o))};return i(this),n}traverseEntity(t){for(let n of this.children)Cr(n)&&n.traverseEntity(t)}updateFog(t,n){this.enableFog=t.enabled,this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ft(t.color,n),this.backupFog.near=t.near,this.backupFog.far=t.far}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(t,n){h1(this.ambientLight,t,n),t.groundColor!==void 0&&(this.ambientLight.groundColor=Ft(t.groundColor,n)),t.enabled!==void 0&&(this.ambientLight.visible=t.enabled)}switchActiveCamera(t){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=t,t.enableHelper=!1}setBackgroundColor(t){this.bgColor=t,this.alpha=t.a}createChildrenObjects(t,n,i){for(let s of t)this.createChildObject(s.id,s.data,s.children,n,i)}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let n of t.children)this.unregisterObject(n)}createChildObject(t,n,i,s,o){let a=OA(t,n,o);return a&&(this.entityByUuid[t]=a,s.add(a),bt(s)&&Ut(a)&&(a.prevBooleanObjectParent=s),this.createChildrenObjects(i,a,o)),a}getCenter(t){let n=[];for(let s=0,o=t.length;s<o;++s){let{id:a,recursive:l}=t[s],c=this.find(a),h=l?c.recursiveBBox:c.singleBBox;n.push(...h.vertices)}let i=new Sn;return i.setFromPoints(n),i.getCenter(FA),FA}copyMatrixWorld(t,n){if(t===null){n.identity();return}let i=this.find(t);i?n.copy(i.matrixWorld):n.identity()}copyParentMatrixWorld(t,n){if(t===null){n.identity();return}let i=this.find(t)?.parent;i?n.copy(i.matrixWorld):n.identity()}traverseMaterial(t){this.traverseEntity(n=>{if(n instanceof Nt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)t(n.material[i]);else t(n.material)})}updateCanvasSize(t,n){this.activeCamera.setViewplaneSize(t,n);let i,s;t>=n?(i=n/t,s=1):(i=1,s=t/n),this.traverseMaterial(o=>{o.layersList.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},Ch=ev;Ch.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var WA={RED:0,GREEN:1,BLUE:2,ALPHA:3};var Dh="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var qF=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
4894
4906
|
uniform mediump sampler2D inputBuffer;
|
|
4895
4907
|
#else
|
|
4896
4908
|
uniform lowp sampler2D inputBuffer;
|
|
@@ -5104,7 +5116,7 @@ gl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask);
|
|
|
5104
5116
|
#else
|
|
5105
5117
|
gl_FragColor=mask*texture2D(inputBuffer,vUv);
|
|
5106
5118
|
#endif
|
|
5107
|
-
}`,jA={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2},aU=class extends dt{constructor(r=null){super({name:"MaskMaterial",uniforms:{maskTexture:new we(r),inputBuffer:new we(null),strength:new we(1)},blending:Ct,depthWrite:!1,depthTest:!1,fragmentShader:oU,vertexShader:Dh}),this.toneMapped=!1,this.setColorChannel(WA.RED),this.setMaskFunction(jA.DISCARD)}set inputBuffer(r){this.uniforms.inputBuffer.value=r}setInputBuffer(r){this.uniforms.inputBuffer.value=r}set maskTexture(r){this.uniforms.maskTexture.value=r,delete this.defines.MASK_PRECISION_HIGH,r.type!==
|
|
5119
|
+
}`,jA={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2},aU=class extends dt{constructor(r=null){super({name:"MaskMaterial",uniforms:{maskTexture:new we(r),inputBuffer:new we(null),strength:new we(1)},blending:Ct,depthWrite:!1,depthTest:!1,fragmentShader:oU,vertexShader:Dh}),this.toneMapped=!1,this.setColorChannel(WA.RED),this.setMaskFunction(jA.DISCARD)}set inputBuffer(r){this.uniforms.inputBuffer.value=r}setInputBuffer(r){this.uniforms.inputBuffer.value=r}set maskTexture(r){this.uniforms.maskTexture.value=r,delete this.defines.MASK_PRECISION_HIGH,r.type!==Lt&&(this.defines.MASK_PRECISION_HIGH="1"),this.needsUpdate=!0}setMaskTexture(r){this.maskTexture=r}set colorChannel(r){this.defines.COLOR_CHANNEL=r.toFixed(0),this.needsUpdate=!0}setColorChannel(r){this.colorChannel=r}set maskFunction(r){this.defines.MASK_FUNCTION=r.toFixed(0),this.needsUpdate=!0}setMaskFunction(r){this.maskFunction=r}get inverted(){return this.defines.INVERTED!==void 0}set inverted(r){this.inverted&&!r?delete this.defines.INVERTED:r&&(this.defines.INVERTED="1"),this.needsUpdate=!0}isInverted(){return this.inverted}setInverted(r){this.inverted=r}get strength(){return this.uniforms.strength.value}set strength(r){this.uniforms.strength.value=r}getStrength(){return this.strength}setStrength(r){this.strength=r}};var lU=`#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize)
|
|
5108
5120
|
#if __VERSION__ < 300
|
|
5109
5121
|
#define round(v) floor(v + 0.5)
|
|
5110
5122
|
#endif
|
|
@@ -5129,7 +5141,7 @@ vec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOf
|
|
|
5129
5141
|
#if !defined(DISABLE_DIAG_DETECTION)
|
|
5130
5142
|
}else{e.r=0.0;}
|
|
5131
5143
|
#endif
|
|
5132
|
-
}if(e.r>0.0){vec2 d;vec3 coords;coords.y=searchYUp(vOffset[1].xy,vOffset[2].z);coords.x=vOffset[0].x;d.x=coords.y;float e1=texture2D(inputBuffer,coords.xy).g;coords.z=searchYDown(vOffset[1].zw,vOffset[2].w);d.y=coords.z;d=round(resolution.yy*d-vPixCoord.yy);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.xz,vec2(0,1)).g;weights.ba=area(sqrtD,e1,e2,subsampleIndices.x);coords.x=vUv.x;detectVerticalCornerPattern(weights.ba,coords.xyxz,d);}gl_FragColor=weights;}`,cU="uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void main(){vUv=position.xy*0.5+0.5;vPixCoord=vUv*resolution;vOffset[0]=vUv.xyxy+texelSize.xyxy*vec4(-0.25,-0.125,1.25,-0.125);vOffset[1]=vUv.xyxy+texelSize.xyxy*vec4(-0.125,-0.25,-0.125,1.25);vOffset[2]=vec4(vOffset[0].xz,vOffset[1].yw)+vec4(-2.0,2.0,-2.0,2.0)*texelSize.xxyy*MAX_SEARCH_STEPS_FLOAT;gl_Position=vec4(position.xy,1.0,1.0);}",hU=class extends dt{constructor(r=new B,e=new B){super({name:"SMAAWeightsMaterial",defines:{MAX_SEARCH_STEPS_INT:"16",MAX_SEARCH_STEPS_FLOAT:"16.0",MAX_SEARCH_STEPS_DIAG_INT:"8",MAX_SEARCH_STEPS_DIAG_FLOAT:"8.0",CORNER_ROUNDING:"25",CORNER_ROUNDING_NORM:"0.25",AREATEX_MAX_DISTANCE:"16.0",AREATEX_MAX_DISTANCE_DIAG:"20.0",AREATEX_PIXEL_SIZE:"(1.0 / vec2(160.0, 560.0))",AREATEX_SUBTEX_SIZE:"(1.0 / 7.0)",SEARCHTEX_SIZE:"vec2(66.0, 33.0)",SEARCHTEX_PACKED_SIZE:"vec2(64.0, 16.0)"},uniforms:{inputBuffer:new we(null),searchTexture:new we(null),areaTexture:new we(null),resolution:new we(e),texelSize:new we(r)},blending:Ct,depthWrite:!1,depthTest:!1,fragmentShader:lU,vertexShader:cU}),this.toneMapped=!1}set inputBuffer(r){this.uniforms.inputBuffer.value=r}setInputBuffer(r){this.uniforms.inputBuffer.value=r}get searchTexture(){return this.uniforms.searchTexture.value}set searchTexture(r){this.uniforms.searchTexture.value=r}get areaTexture(){return this.uniforms.areaTexture.value}set areaTexture(r){this.uniforms.areaTexture.value=r}setLookupTextures(r,e){this.searchTexture=r,this.areaTexture=e}get orthogonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_INT)}set orthogonalSearchSteps(r){let e=Math.min(Math.max(r,0),112);this.defines.MAX_SEARCH_STEPS_INT=e.toFixed("0"),this.defines.MAX_SEARCH_STEPS_FLOAT=e.toFixed("1"),this.needsUpdate=!0}setOrthogonalSearchSteps(r){this.orthogonalSearchSteps=r}get diagonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT)}set diagonalSearchSteps(r){let e=Math.min(Math.max(r,0),20);this.defines.MAX_SEARCH_STEPS_DIAG_INT=e.toFixed("0"),this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT=e.toFixed("1"),this.needsUpdate=!0}setDiagonalSearchSteps(r){this.diagonalSearchSteps=r}get diagonalDetection(){return this.defines.DISABLE_DIAG_DETECTION===void 0}set diagonalDetection(r){r?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION="1",this.needsUpdate=!0}isDiagonalDetectionEnabled(){return this.diagonalDetection}setDiagonalDetectionEnabled(r){this.diagonalDetection=r}get cornerRounding(){return Number(this.defines.CORNER_ROUNDING)}set cornerRounding(r){let e=Math.min(Math.max(r,0),100);this.defines.CORNER_ROUNDING=e.toFixed("4"),this.defines.CORNER_ROUNDING_NORM=(e/100).toFixed("4"),this.needsUpdate=!0}setCornerRounding(r){this.cornerRounding=r}get cornerDetection(){return this.defines.DISABLE_CORNER_DETECTION===void 0}set cornerDetection(r){r?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION="1",this.needsUpdate=!0}isCornerRoundingEnabled(){return this.cornerDetection}setCornerRoundingEnabled(r){this.cornerDetection=r}setSize(r,e){let t=this.uniforms;t.texelSize.value.set(1/r,1/e),t.resolution.value.set(r,e)}};var uU=new kr,js=null;function dU(){if(js===null){let r=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),e=new Float32Array([0,0,2,0,0,2]);js=new Ie,js.setAttribute!==void 0?(js.setAttribute("position",new Xe(r,3)),js.setAttribute("uv",new Xe(e,2))):(js.addAttribute("position",new Xe(r,3)),js.addAttribute("uv",new Xe(e,2)))}return js}var Zi=class{constructor(r="Pass",e=new Wn,t=uU){this.name=r,this.renderer=null,this.scene=e,this.camera=t,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(r){if(this.rtt===r){let e=this.getFullscreenMaterial();e!==null&&(e.needsUpdate=!0),this.rtt=!r}}setRenderer(r){this.renderer=r}isEnabled(){return this.enabled}setEnabled(r){this.enabled=r}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(r){let e=this.screen;e!==null?e.material=r:(e=new Vt(dU(),r),e.frustumCulled=!1,this.scene===null&&(this.scene=new Wn),this.scene.add(e),this.screen=e)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(r){this.fullscreenMaterial=r}getDepthTexture(){return null}setDepthTexture(r,e=An){}render(r,e,t,n,i){throw new Error("Render method not implemented!")}setSize(r,e){}initialize(r,e,t){}dispose(){for(let r of Object.keys(this)){let e=this[r];if(e!==null&&typeof e.dispose=="function"){if(e instanceof Wn||e===this.renderer)continue;this[r].dispose()}}}},lv=class extends Zi{constructor(r,e=!0){super("CopyPass"),this.fullscreenMaterial=new JF,this.needsSwap=!1,this.renderTarget=r,r===void 0&&(this.renderTarget=new lt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=e}get resize(){return this.autoResize}set resize(r){this.autoResize=r}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(r){this.autoResize=r}render(r,e,t,n,i){this.fullscreenMaterial.inputBuffer=e.texture,r.setRenderTarget(this.renderToScreen?null:this.renderTarget),r.render(this.scene,this.camera)}setSize(r,e){this.autoResize&&this.renderTarget.setSize(r,e)}initialize(r,e,t){t!==void 0&&(this.renderTarget.texture.type=t,t!==It?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":r.outputEncoding===We&&(this.renderTarget.texture.encoding=We))}};var fU=class extends Zi{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(r,e,t,n,i){let s=r.state.buffers.stencil;s.setLocked(!1),s.setTest(!1)}},tv=new Ae,Bl=class extends Zi{constructor(r=!0,e=!0,t=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=r,this.depth=e,this.stencil=t,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(r,e,t){this.color=r,this.depth=e,this.stencil=t}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(r){this.overrideClearColor=r}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(r){this.overrideClearAlpha=r}render(r,e,t,n,i){let s=this.overrideClearColor,o=this.overrideClearAlpha,a=r.getClearAlpha(),l=s!==null,c=o>=0;l?(tv.copy(r.getClearColor(tv)),r.setClearColor(s,c?o:a)):c&&r.setClearAlpha(o),r.setRenderTarget(this.renderToScreen?null:e),r.clear(this.color,this.depth,this.stencil),l?r.setClearColor(tv,a):c&&r.setClearAlpha(a)}},qs=-1,ni=class extends Rt{constructor(r,e=qs,t=qs,n=1){super(),this.resizable=r,this.base=new B(1,1),this.preferred=new B(e,t),this.target=this.preferred,this.s=n}get width(){let{base:r,preferred:e,scale:t}=this,n;return e.width!==qs?n=e.width:e.height!==qs?n=Math.round(e.height*(r.width/Math.max(r.height,1))):n=Math.round(r.width*t),n}set width(r){this.preferredWidth=r}get height(){let{base:r,preferred:e,scale:t}=this,n;return e.height!==qs?n=e.height:e.width!==qs?n=Math.round(e.width/Math.max(r.width/Math.max(r.height,1),1)):n=Math.round(r.height*t),n}set height(r){this.preferredHeight=r}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(r){this.s!==r&&(this.s=r,this.preferred.setScalar(qs),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getScale(){return this.scale}setScale(r){this.scale=r}get baseWidth(){return this.base.width}set baseWidth(r){this.base.width!==r&&(this.base.width=r,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseWidth(){return this.base.width}setBaseWidth(r){this.base.width!==r&&(this.base.width=r,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get baseHeight(){return this.base.height}set baseHeight(r){this.base.height!==r&&(this.base.height=r,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(r){this.baseHeight=r}setBaseSize(r,e){(this.base.width!==r||this.base.height!==e)&&(this.base.set(r,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get preferredWidth(){return this.preferred.width}set preferredWidth(r){this.preferred.width!==r&&(this.preferred.width=r,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(r){this.preferredWidth=r}get preferredHeight(){return this.preferred.height}set preferredHeight(r){this.preferred.height!==r&&(this.preferred.height=r,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(r){this.preferredHeight=r}setPreferredSize(r,e){(this.preferred.width!==r||this.preferred.height!==e)&&(this.preferred.set(r,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}copy(r){this.base.set(r.getBaseWidth(),r.getBaseHeight()),this.preferred.set(r.getPreferredWidth(),r.getPreferredHeight()),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height)}static get AUTO_SIZE(){return qs}},nv=!1,GA=class{constructor(r=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(r),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case hn:t=this.materialsFlatShadedDoubleSide;break;case wn:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case hn:t=this.materialsDoubleSide;break;case wn:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}setMaterial(r){if(this.disposeMaterials(),this.material=r,r!==null){let e=this.materials=[r.clone(),r.clone(),r.clone()];for(let t of e)t.uniforms=Object.assign({},r.uniforms),t.side=zi;e[2].skinning=!0,this.materialsBackSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.side=wn,n}),this.materialsDoubleSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.side=hn,n}),this.materialsFlatShaded=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.flatShading=!0,n}),this.materialsFlatShadedBackSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.flatShading=!0,n.side=wn,n}),this.materialsFlatShadedDoubleSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.flatShading=!0,n.side=hn,n})}}render(r,e,t){let n=r.shadowMap.enabled;if(r.shadowMap.enabled=!1,nv){let i=this.originalMaterials;this.meshCount=0,e.traverse(this.replaceMaterial),r.render(e,t);for(let s of i)s[0].material=s[1];this.meshCount!==i.size&&i.clear()}else{let i=e.overrideMaterial;e.overrideMaterial=this.material,r.render(e,t),e.overrideMaterial=i}r.shadowMap.enabled=n}disposeMaterials(){if(this.material!==null){let r=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let e of r)e.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return nv}static set workaroundEnabled(r){nv=r}},Io=class extends Zi{constructor(r,e,t=null){super("RenderPass",r,e),this.needsSwap=!1,this.clearPass=new Bl,this.overrideMaterialManager=t===null?null:new GA(t),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}get renderToScreen(){return super.renderToScreen}set renderToScreen(r){super.renderToScreen=r,this.clearPass.renderToScreen=r}get overrideMaterial(){let r=this.overrideMaterialManager;return r!==null?r.material:null}set overrideMaterial(r){let e=this.overrideMaterialManager;r!==null?e!==null?e.setMaterial(r):this.overrideMaterialManager=new GA(r):e!==null&&(e.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(r){this.overrideMaterial=r}get clear(){return this.clearPass.enabled}set clear(r){this.clearPass.enabled=r}getSelection(){return this.selection}setSelection(r){this.selection=r}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(r){this.ignoreBackground=r}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(r){this.skipShadowMapUpdate=r}getClearPass(){return this.clearPass}render(r,e,t,n,i){let s=this.scene,o=this.camera,a=this.selection,l=o.layers.mask,c=s.background,h=r.shadowMap.autoUpdate,u=this.renderToScreen?null:e;a!==null&&o.layers.set(a.getLayer()),this.skipShadowMapUpdate&&(r.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(s.background=null),this.clearPass.enabled&&this.clearPass.render(r,e),r.setRenderTarget(u),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(r,s,o):r.render(s,o),o.layers.mask=l,s.background=c,r.shadowMap.autoUpdate=h}};var Qoe=new Float32Array([255/256/256**3,255/256/256**2,255/256/256,255/256]);var at={SKIP:0,ADD:1,ALPHA:2,AVERAGE:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,EXCLUSION:8,LIGHTEN:9,MULTIPLY:10,DIVIDE:11,NEGATION:12,NORMAL:13,OVERLAY:14,REFLECT:15,SCREEN:16,SOFT_LIGHT:17,SUBTRACT:18},pU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x+y,1.0)*opacity+x*(1.0-opacity);}",mU="vec3 blend(const in vec3 x,const in vec3 y,const in float opacity){return y*opacity+x*(1.0-opacity);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){float a=min(y.a,opacity);return vec4(blend(x.rgb,y.rgb,a),max(x.a,a));}",gU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}",yU="float blend(const in float x,const in float y){return(y==0.0)? y : max(1.0-(1.0-x)/y,0.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",vU="float blend(const in float x,const in float y){return(y==1.0)? y : min(x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",xU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}",bU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}",wU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y-2.0*x*y)*opacity+x*(1.0-opacity);}",SU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}",AU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}",MU="float blend(const in float x,const in float y){return(y>0.0)? min(x/y,1.0): 1.0;}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",_U="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-abs(1.0-x-y))*opacity+x*(1.0-opacity);}",TU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}",EU="float blend(const in float x,const in float y){return(x<0.5)?(2.0*x*y):(1.0-2.0*(1.0-x)*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",CU="float blend(const in float x,const in float y){return(y==1.0)? y : min(x*x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",DU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-(1.0-x)*(1.0-y))*opacity+x*(1.0-opacity);}",PU="float blend(const in float x,const in float y){return(y<0.5)?(2.0*x*y+x*x*(1.0-2.0*y)):(sqrt(x)*(2.0*y-1.0)+2.0*x*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",IU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x+y-1.0,0.0)*opacity+x*(1.0-opacity);}",LU=new Map([[at.SKIP,null],[at.ADD,pU],[at.ALPHA,mU],[at.AVERAGE,gU],[at.COLOR_BURN,yU],[at.COLOR_DODGE,vU],[at.DARKEN,xU],[at.DIFFERENCE,bU],[at.EXCLUSION,wU],[at.LIGHTEN,SU],[at.MULTIPLY,AU],[at.DIVIDE,MU],[at.NEGATION,_U],[at.NORMAL,TU],[at.OVERLAY,EU],[at.REFLECT,CU],[at.SCREEN,DU],[at.SOFT_LIGHT,PU],[at.SUBTRACT,IU]]),NU=class extends Rt{constructor(r,e=1){super(),this.f=r,this.opacity=new we(e)}getOpacity(){return this.opacity.value}setOpacity(r){this.opacity.value=r}get blendFunction(){return this.f}set blendFunction(r){this.f=r,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(r){this.blendFunction=r}getShaderCode(){return LU.get(this.blendFunction)}},Ci={NONE:0,DEPTH:1,CONVOLUTION:2};var Di=class extends Rt{constructor(r,e,{attributes:t=Ci.NONE,blendFunction:n=at.SCREEN,defines:i=new Map,uniforms:s=new Map,extensions:o=null,vertexShader:a=null}={}){super(),this.name=r,this.renderer=null,this.attributes=t,this.fragmentShader=e,this.vertexShader=a,this.defines=i,this.uniforms=s,this.extensions=o,this.blendMode=new NU(n),this.blendMode.addEventListener("change",l=>this.setChanged())}getName(){return this.name}setRenderer(r){this.renderer=r}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(r){this.attributes=r,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(r){this.fragmentShader=r,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(r){this.vertexShader=r,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(r,e=An){}update(r,e,t){}setSize(r,e){}initialize(r,e,t){}dispose(){for(let r of Object.keys(this)){let e=this[r];if(e!==null&&typeof e.dispose=="function"){if(e instanceof Wn||e===this.renderer)continue;this[r].dispose()}}}};function kA(r,e,t){for(let n of e){let i="$1"+r+n.charAt(0).toUpperCase()+n.slice(1),s=new RegExp("([^\\.])(\\b"+n+"\\b)","g");for(let o of t.entries())o[1]!==null&&t.set(o[0],o[1].replace(s,i))}}function RU(r,e,t,n,i,s,o){let a=new Map([["fragment",e.getFragmentShader()],["vertex",e.getVertexShader()]]),l=a.get("fragment")!==void 0&&/mainImage/.test(a.get("fragment")),c=a.get("fragment")!==void 0&&/mainUv/.test(a.get("fragment")),h=[],u=[],d=!1,f=!1;if(a.get("fragment")===void 0)console.error("Missing fragment shader",e);else if(c&&(o&Ci.CONVOLUTION)!==0)console.error("Effects that transform UV coordinates are incompatible with convolution effects",e);else if(!l&&!c)console.error("The fragment shader contains neither a mainImage nor a mainUv function",e);else{let m=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,p=ov.Section;if(c){let x=` ${r}MainUv(UV);
|
|
5144
|
+
}if(e.r>0.0){vec2 d;vec3 coords;coords.y=searchYUp(vOffset[1].xy,vOffset[2].z);coords.x=vOffset[0].x;d.x=coords.y;float e1=texture2D(inputBuffer,coords.xy).g;coords.z=searchYDown(vOffset[1].zw,vOffset[2].w);d.y=coords.z;d=round(resolution.yy*d-vPixCoord.yy);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.xz,vec2(0,1)).g;weights.ba=area(sqrtD,e1,e2,subsampleIndices.x);coords.x=vUv.x;detectVerticalCornerPattern(weights.ba,coords.xyxz,d);}gl_FragColor=weights;}`,cU="uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void main(){vUv=position.xy*0.5+0.5;vPixCoord=vUv*resolution;vOffset[0]=vUv.xyxy+texelSize.xyxy*vec4(-0.25,-0.125,1.25,-0.125);vOffset[1]=vUv.xyxy+texelSize.xyxy*vec4(-0.125,-0.25,-0.125,1.25);vOffset[2]=vec4(vOffset[0].xz,vOffset[1].yw)+vec4(-2.0,2.0,-2.0,2.0)*texelSize.xxyy*MAX_SEARCH_STEPS_FLOAT;gl_Position=vec4(position.xy,1.0,1.0);}",hU=class extends dt{constructor(r=new B,e=new B){super({name:"SMAAWeightsMaterial",defines:{MAX_SEARCH_STEPS_INT:"16",MAX_SEARCH_STEPS_FLOAT:"16.0",MAX_SEARCH_STEPS_DIAG_INT:"8",MAX_SEARCH_STEPS_DIAG_FLOAT:"8.0",CORNER_ROUNDING:"25",CORNER_ROUNDING_NORM:"0.25",AREATEX_MAX_DISTANCE:"16.0",AREATEX_MAX_DISTANCE_DIAG:"20.0",AREATEX_PIXEL_SIZE:"(1.0 / vec2(160.0, 560.0))",AREATEX_SUBTEX_SIZE:"(1.0 / 7.0)",SEARCHTEX_SIZE:"vec2(66.0, 33.0)",SEARCHTEX_PACKED_SIZE:"vec2(64.0, 16.0)"},uniforms:{inputBuffer:new we(null),searchTexture:new we(null),areaTexture:new we(null),resolution:new we(e),texelSize:new we(r)},blending:Ct,depthWrite:!1,depthTest:!1,fragmentShader:lU,vertexShader:cU}),this.toneMapped=!1}set inputBuffer(r){this.uniforms.inputBuffer.value=r}setInputBuffer(r){this.uniforms.inputBuffer.value=r}get searchTexture(){return this.uniforms.searchTexture.value}set searchTexture(r){this.uniforms.searchTexture.value=r}get areaTexture(){return this.uniforms.areaTexture.value}set areaTexture(r){this.uniforms.areaTexture.value=r}setLookupTextures(r,e){this.searchTexture=r,this.areaTexture=e}get orthogonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_INT)}set orthogonalSearchSteps(r){let e=Math.min(Math.max(r,0),112);this.defines.MAX_SEARCH_STEPS_INT=e.toFixed("0"),this.defines.MAX_SEARCH_STEPS_FLOAT=e.toFixed("1"),this.needsUpdate=!0}setOrthogonalSearchSteps(r){this.orthogonalSearchSteps=r}get diagonalSearchSteps(){return Number(this.defines.MAX_SEARCH_STEPS_DIAG_INT)}set diagonalSearchSteps(r){let e=Math.min(Math.max(r,0),20);this.defines.MAX_SEARCH_STEPS_DIAG_INT=e.toFixed("0"),this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT=e.toFixed("1"),this.needsUpdate=!0}setDiagonalSearchSteps(r){this.diagonalSearchSteps=r}get diagonalDetection(){return this.defines.DISABLE_DIAG_DETECTION===void 0}set diagonalDetection(r){r?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION="1",this.needsUpdate=!0}isDiagonalDetectionEnabled(){return this.diagonalDetection}setDiagonalDetectionEnabled(r){this.diagonalDetection=r}get cornerRounding(){return Number(this.defines.CORNER_ROUNDING)}set cornerRounding(r){let e=Math.min(Math.max(r,0),100);this.defines.CORNER_ROUNDING=e.toFixed("4"),this.defines.CORNER_ROUNDING_NORM=(e/100).toFixed("4"),this.needsUpdate=!0}setCornerRounding(r){this.cornerRounding=r}get cornerDetection(){return this.defines.DISABLE_CORNER_DETECTION===void 0}set cornerDetection(r){r?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION="1",this.needsUpdate=!0}isCornerRoundingEnabled(){return this.cornerDetection}setCornerRoundingEnabled(r){this.cornerDetection=r}setSize(r,e){let t=this.uniforms;t.texelSize.value.set(1/r,1/e),t.resolution.value.set(r,e)}};var uU=new kr,js=null;function dU(){if(js===null){let r=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),e=new Float32Array([0,0,2,0,0,2]);js=new Le,js.setAttribute!==void 0?(js.setAttribute("position",new Xe(r,3)),js.setAttribute("uv",new Xe(e,2))):(js.addAttribute("position",new Xe(r,3)),js.addAttribute("uv",new Xe(e,2)))}return js}var Zi=class{constructor(r="Pass",e=new Wn,t=uU){this.name=r,this.renderer=null,this.scene=e,this.camera=t,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(r){if(this.rtt===r){let e=this.getFullscreenMaterial();e!==null&&(e.needsUpdate=!0),this.rtt=!r}}setRenderer(r){this.renderer=r}isEnabled(){return this.enabled}setEnabled(r){this.enabled=r}get fullscreenMaterial(){return this.screen!==null?this.screen.material:null}set fullscreenMaterial(r){let e=this.screen;e!==null?e.material=r:(e=new Vt(dU(),r),e.frustumCulled=!1,this.scene===null&&(this.scene=new Wn),this.scene.add(e),this.screen=e)}getFullscreenMaterial(){return this.fullscreenMaterial}setFullscreenMaterial(r){this.fullscreenMaterial=r}getDepthTexture(){return null}setDepthTexture(r,e=An){}render(r,e,t,n,i){throw new Error("Render method not implemented!")}setSize(r,e){}initialize(r,e,t){}dispose(){for(let r of Object.keys(this)){let e=this[r];if(e!==null&&typeof e.dispose=="function"){if(e instanceof Wn||e===this.renderer)continue;this[r].dispose()}}}},lv=class extends Zi{constructor(r,e=!0){super("CopyPass"),this.fullscreenMaterial=new JF,this.needsSwap=!1,this.renderTarget=r,r===void 0&&(this.renderTarget=new lt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="CopyPass.Target"),this.autoResize=e}get resize(){return this.autoResize}set resize(r){this.autoResize=r}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}setAutoResizeEnabled(r){this.autoResize=r}render(r,e,t,n,i){this.fullscreenMaterial.inputBuffer=e.texture,r.setRenderTarget(this.renderToScreen?null:this.renderTarget),r.render(this.scene,this.camera)}setSize(r,e){this.autoResize&&this.renderTarget.setSize(r,e)}initialize(r,e,t){t!==void 0&&(this.renderTarget.texture.type=t,t!==Lt?this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1":r.outputEncoding===We&&(this.renderTarget.texture.encoding=We))}};var fU=class extends Zi{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(r,e,t,n,i){let s=r.state.buffers.stencil;s.setLocked(!1),s.setTest(!1)}},tv=new Ae,Bl=class extends Zi{constructor(r=!0,e=!0,t=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=r,this.depth=e,this.stencil=t,this.overrideClearColor=null,this.overrideClearAlpha=-1}setClearFlags(r,e,t){this.color=r,this.depth=e,this.stencil=t}getOverrideClearColor(){return this.overrideClearColor}setOverrideClearColor(r){this.overrideClearColor=r}getOverrideClearAlpha(){return this.overrideClearAlpha}setOverrideClearAlpha(r){this.overrideClearAlpha=r}render(r,e,t,n,i){let s=this.overrideClearColor,o=this.overrideClearAlpha,a=r.getClearAlpha(),l=s!==null,c=o>=0;l?(tv.copy(r.getClearColor(tv)),r.setClearColor(s,c?o:a)):c&&r.setClearAlpha(o),r.setRenderTarget(this.renderToScreen?null:e),r.clear(this.color,this.depth,this.stencil),l?r.setClearColor(tv,a):c&&r.setClearAlpha(a)}},qs=-1,ni=class extends Rt{constructor(r,e=qs,t=qs,n=1){super(),this.resizable=r,this.base=new B(1,1),this.preferred=new B(e,t),this.target=this.preferred,this.s=n}get width(){let{base:r,preferred:e,scale:t}=this,n;return e.width!==qs?n=e.width:e.height!==qs?n=Math.round(e.height*(r.width/Math.max(r.height,1))):n=Math.round(r.width*t),n}set width(r){this.preferredWidth=r}get height(){let{base:r,preferred:e,scale:t}=this,n;return e.height!==qs?n=e.height:e.width!==qs?n=Math.round(e.width/Math.max(r.width/Math.max(r.height,1),1)):n=Math.round(r.height*t),n}set height(r){this.preferredHeight=r}getWidth(){return this.width}getHeight(){return this.height}get scale(){return this.s}set scale(r){this.s!==r&&(this.s=r,this.preferred.setScalar(qs),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getScale(){return this.scale}setScale(r){this.scale=r}get baseWidth(){return this.base.width}set baseWidth(r){this.base.width!==r&&(this.base.width=r,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseWidth(){return this.base.width}setBaseWidth(r){this.base.width!==r&&(this.base.width=r,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get baseHeight(){return this.base.height}set baseHeight(r){this.base.height!==r&&(this.base.height=r,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getBaseHeight(){return this.baseHeight}setBaseHeight(r){this.baseHeight=r}setBaseSize(r,e){(this.base.width!==r||this.base.height!==e)&&(this.base.set(r,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}get preferredWidth(){return this.preferred.width}set preferredWidth(r){this.preferred.width!==r&&(this.preferred.width=r,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredWidth(){return this.preferredWidth}setPreferredWidth(r){this.preferredWidth=r}get preferredHeight(){return this.preferred.height}set preferredHeight(r){this.preferred.height!==r&&(this.preferred.height=r,this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}getPreferredHeight(){return this.preferredHeight}setPreferredHeight(r){this.preferredHeight=r}setPreferredSize(r,e){(this.preferred.width!==r||this.preferred.height!==e)&&(this.preferred.set(r,e),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height))}copy(r){this.base.set(r.getBaseWidth(),r.getBaseHeight()),this.preferred.set(r.getPreferredWidth(),r.getPreferredHeight()),this.dispatchEvent({type:"change"}),this.resizable.setSize(this.base.width,this.base.height)}static get AUTO_SIZE(){return qs}},nv=!1,GA=class{constructor(r=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(r),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let t;if(e.material.flatShading)switch(e.material.side){case hn:t=this.materialsFlatShadedDoubleSide;break;case wn:t=this.materialsFlatShadedBackSide;break;default:t=this.materialsFlatShaded;break}else switch(e.material.side){case hn:t=this.materialsDoubleSide;break;case wn:t=this.materialsBackSide;break;default:t=this.materials;break}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=t[2]:e.isInstancedMesh?e.material=t[1]:e.material=t[0],++this.meshCount}}}setMaterial(r){if(this.disposeMaterials(),this.material=r,r!==null){let e=this.materials=[r.clone(),r.clone(),r.clone()];for(let t of e)t.uniforms=Object.assign({},r.uniforms),t.side=zi;e[2].skinning=!0,this.materialsBackSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.side=wn,n}),this.materialsDoubleSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.side=hn,n}),this.materialsFlatShaded=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.flatShading=!0,n}),this.materialsFlatShadedBackSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.flatShading=!0,n.side=wn,n}),this.materialsFlatShadedDoubleSide=e.map(t=>{let n=t.clone();return n.uniforms=Object.assign({},r.uniforms),n.flatShading=!0,n.side=hn,n})}}render(r,e,t){let n=r.shadowMap.enabled;if(r.shadowMap.enabled=!1,nv){let i=this.originalMaterials;this.meshCount=0,e.traverse(this.replaceMaterial),r.render(e,t);for(let s of i)s[0].material=s[1];this.meshCount!==i.size&&i.clear()}else{let i=e.overrideMaterial;e.overrideMaterial=this.material,r.render(e,t),e.overrideMaterial=i}r.shadowMap.enabled=n}disposeMaterials(){if(this.material!==null){let r=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(let e of r)e.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return nv}static set workaroundEnabled(r){nv=r}},Lo=class extends Zi{constructor(r,e,t=null){super("RenderPass",r,e),this.needsSwap=!1,this.clearPass=new Bl,this.overrideMaterialManager=t===null?null:new GA(t),this.ignoreBackground=!1,this.skipShadowMapUpdate=!1,this.selection=null}get renderToScreen(){return super.renderToScreen}set renderToScreen(r){super.renderToScreen=r,this.clearPass.renderToScreen=r}get overrideMaterial(){let r=this.overrideMaterialManager;return r!==null?r.material:null}set overrideMaterial(r){let e=this.overrideMaterialManager;r!==null?e!==null?e.setMaterial(r):this.overrideMaterialManager=new GA(r):e!==null&&(e.dispose(),this.overrideMaterialManager=null)}getOverrideMaterial(){return this.overrideMaterial}setOverrideMaterial(r){this.overrideMaterial=r}get clear(){return this.clearPass.enabled}set clear(r){this.clearPass.enabled=r}getSelection(){return this.selection}setSelection(r){this.selection=r}isBackgroundDisabled(){return this.ignoreBackground}setBackgroundDisabled(r){this.ignoreBackground=r}isShadowMapDisabled(){return this.skipShadowMapUpdate}setShadowMapDisabled(r){this.skipShadowMapUpdate=r}getClearPass(){return this.clearPass}render(r,e,t,n,i){let s=this.scene,o=this.camera,a=this.selection,l=o.layers.mask,c=s.background,h=r.shadowMap.autoUpdate,u=this.renderToScreen?null:e;a!==null&&o.layers.set(a.getLayer()),this.skipShadowMapUpdate&&(r.shadowMap.autoUpdate=!1),(this.ignoreBackground||this.clearPass.overrideClearColor!==null)&&(s.background=null),this.clearPass.enabled&&this.clearPass.render(r,e),r.setRenderTarget(u),this.overrideMaterialManager!==null?this.overrideMaterialManager.render(r,s,o):r.render(s,o),o.layers.mask=l,s.background=c,r.shadowMap.autoUpdate=h}};var Qoe=new Float32Array([255/256/256**3,255/256/256**2,255/256/256,255/256]);var at={SKIP:0,ADD:1,ALPHA:2,AVERAGE:3,COLOR_BURN:4,COLOR_DODGE:5,DARKEN:6,DIFFERENCE:7,EXCLUSION:8,LIGHTEN:9,MULTIPLY:10,DIVIDE:11,NEGATION:12,NORMAL:13,OVERLAY:14,REFLECT:15,SCREEN:16,SOFT_LIGHT:17,SUBTRACT:18},pU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x+y,1.0)*opacity+x*(1.0-opacity);}",mU="vec3 blend(const in vec3 x,const in vec3 y,const in float opacity){return y*opacity+x*(1.0-opacity);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){float a=min(y.a,opacity);return vec4(blend(x.rgb,y.rgb,a),max(x.a,a));}",gU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}",yU="float blend(const in float x,const in float y){return(y==0.0)? y : max(1.0-(1.0-x)/y,0.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",vU="float blend(const in float x,const in float y){return(y==1.0)? y : min(x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",xU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}",bU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}",wU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y-2.0*x*y)*opacity+x*(1.0-opacity);}",SU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}",AU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}",MU="float blend(const in float x,const in float y){return(y>0.0)? min(x/y,1.0): 1.0;}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",_U="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-abs(1.0-x-y))*opacity+x*(1.0-opacity);}",TU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}",EU="float blend(const in float x,const in float y){return(x<0.5)?(2.0*x*y):(1.0-2.0*(1.0-x)*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",CU="float blend(const in float x,const in float y){return(y==1.0)? y : min(x*x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",DU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-(1.0-x)*(1.0-y))*opacity+x*(1.0-opacity);}",PU="float blend(const in float x,const in float y){return(y<0.5)?(2.0*x*y+x*x*(1.0-2.0*y)):(sqrt(x)*(2.0*y-1.0)+2.0*x*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}",LU="vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x+y-1.0,0.0)*opacity+x*(1.0-opacity);}",IU=new Map([[at.SKIP,null],[at.ADD,pU],[at.ALPHA,mU],[at.AVERAGE,gU],[at.COLOR_BURN,yU],[at.COLOR_DODGE,vU],[at.DARKEN,xU],[at.DIFFERENCE,bU],[at.EXCLUSION,wU],[at.LIGHTEN,SU],[at.MULTIPLY,AU],[at.DIVIDE,MU],[at.NEGATION,_U],[at.NORMAL,TU],[at.OVERLAY,EU],[at.REFLECT,CU],[at.SCREEN,DU],[at.SOFT_LIGHT,PU],[at.SUBTRACT,LU]]),NU=class extends Rt{constructor(r,e=1){super(),this.f=r,this.opacity=new we(e)}getOpacity(){return this.opacity.value}setOpacity(r){this.opacity.value=r}get blendFunction(){return this.f}set blendFunction(r){this.f=r,this.dispatchEvent({type:"change"})}getBlendFunction(){return this.blendFunction}setBlendFunction(r){this.blendFunction=r}getShaderCode(){return IU.get(this.blendFunction)}},Ci={NONE:0,DEPTH:1,CONVOLUTION:2};var Di=class extends Rt{constructor(r,e,{attributes:t=Ci.NONE,blendFunction:n=at.SCREEN,defines:i=new Map,uniforms:s=new Map,extensions:o=null,vertexShader:a=null}={}){super(),this.name=r,this.renderer=null,this.attributes=t,this.fragmentShader=e,this.vertexShader=a,this.defines=i,this.uniforms=s,this.extensions=o,this.blendMode=new NU(n),this.blendMode.addEventListener("change",l=>this.setChanged())}getName(){return this.name}setRenderer(r){this.renderer=r}getDefines(){return this.defines}getUniforms(){return this.uniforms}getExtensions(){return this.extensions}getBlendMode(){return this.blendMode}getAttributes(){return this.attributes}setAttributes(r){this.attributes=r,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(r){this.fragmentShader=r,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(r){this.vertexShader=r,this.setChanged()}setChanged(){this.dispatchEvent({type:"change"})}setDepthTexture(r,e=An){}update(r,e,t){}setSize(r,e){}initialize(r,e,t){}dispose(){for(let r of Object.keys(this)){let e=this[r];if(e!==null&&typeof e.dispose=="function"){if(e instanceof Wn||e===this.renderer)continue;this[r].dispose()}}}};function kA(r,e,t){for(let n of e){let i="$1"+r+n.charAt(0).toUpperCase()+n.slice(1),s=new RegExp("([^\\.])(\\b"+n+"\\b)","g");for(let o of t.entries())o[1]!==null&&t.set(o[0],o[1].replace(s,i))}}function RU(r,e,t,n,i,s,o){let a=new Map([["fragment",e.getFragmentShader()],["vertex",e.getVertexShader()]]),l=a.get("fragment")!==void 0&&/mainImage/.test(a.get("fragment")),c=a.get("fragment")!==void 0&&/mainUv/.test(a.get("fragment")),h=[],u=[],d=!1,f=!1;if(a.get("fragment")===void 0)console.error("Missing fragment shader",e);else if(c&&(o&Ci.CONVOLUTION)!==0)console.error("Effects that transform UV coordinates are incompatible with convolution effects",e);else if(!l&&!c)console.error("The fragment shader contains neither a mainImage nor a mainUv function",e);else{let m=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,p=ov.Section;if(c){let x=` ${r}MainUv(UV);
|
|
5133
5145
|
`;t.set(p.FRAGMENT_MAIN_UV,t.get(p.FRAGMENT_MAIN_UV)+x),d=!0}if(a.get("vertex")!==null&&/mainSupport/.test(a.get("vertex"))){let x=` ${r}MainSupport(`;x+=/mainSupport *\([\w\s]*?uv\s*?\)/.test(a.get("vertex"))?`vUv);
|
|
5134
5146
|
`:`);
|
|
5135
5147
|
`,t.set(p.VERTEX_MAIN_SUPPORT,t.get(p.VERTEX_MAIN_SUPPORT)+x),h=h.concat([...a.get("vertex").matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map(v=>v[1])),u=u.concat(h).concat([...a.get("vertex").matchAll(m)].map(v=>v[1]))}u=u.concat([...a.get("fragment").matchAll(m)].map(x=>x[1])),u=u.concat([...e.defines.keys()].map(x=>x.replace(/\([\w\s,]*\)/g,""))),u=u.concat([...e.uniforms.keys()]),e.uniforms.forEach((x,v)=>s.set(r+v.charAt(0).toUpperCase()+v.slice(1),x)),e.defines.forEach((x,v)=>i.set(r+v.charAt(0).toUpperCase()+v.slice(1),x)),kA(r,u,i),kA(r,u,a);let g=e.blendMode;if(n.set(g.blendFunction,g),l){let x=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,v=`${r}MainImage(color0, UV, `;(o&Ci.DEPTH)!==0&&x.test(a.get("fragment"))&&(v+="depth, ",f=!0),v+=`color1);
|
|
@@ -5144,7 +5156,7 @@ vec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOf
|
|
|
5144
5156
|
|
|
5145
5157
|
`;e.set(r.FRAGMENT_MAIN_IMAGE,d+e.get(r.FRAGMENT_MAIN_IMAGE))}this.needsDepthTexture=this.getDepthTexture()===null}else this.needsDepthTexture=!1;if(c){let d=`vec2 transformedUv = vUv;
|
|
5146
5158
|
`;e.set(r.FRAGMENT_MAIN_UV,d+e.get(r.FRAGMENT_MAIN_UV)),n.set("UV","transformedUv")}else n.set("UV","vUv");e.forEach((d,f,m)=>m.set(f,d.trim().replace(/^#/,`
|
|
5147
|
-
#`))),this.uniformCount=i.size,this.varyingCount=a,this.skipRendering=o===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderParts(e).setExtensions(s).setUniforms(i).setDefines(n)}recompile(){this.updateMaterial(),this.verifyResources()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(r,e=An){this.fullscreenMaterial.depthBuffer=r,this.fullscreenMaterial.depthPacking=e;for(let t of this.effects)t.setDepthTexture(r,e)}render(r,e,t,n,i){for(let s of this.effects)s.update(r,e,n);if(!this.skipRendering||this.renderToScreen){let s=this.fullscreenMaterial;s.inputBuffer=e.texture,s.time+=n,r.setRenderTarget(this.renderToScreen?null:t),r.render(this.scene,this.camera)}}setSize(r,e){this.fullscreenMaterial.setSize(r,e);for(let t of this.effects)t.setSize(r,e)}initialize(r,e,t){this.renderer=r;for(let n of this.effects)n.initialize(r,e,t),n.addEventListener("change",i=>this.handleEvent(i));this.updateMaterial(),this.verifyResources(),t!==void 0&&t!==It&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(let r of this.effects)r.dispose()}handleEvent(r){switch(r.type){case"change":this.recompile();break}}},BU=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],qA=class extends Zi{constructor({resolutionScale:r=.5,width:e=ni.AUTO_SIZE,height:t=ni.AUTO_SIZE,kernelSize:n=cv.LARGE}={}){super("KawaseBlurPass"),this.renderTargetA=new lt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";let i=this.resolution=new ni(this,e,t,r);i.addEventListener("change",s=>this.setSize(i.baseWidth,i.baseHeight)),this.blurMaterial=new zA,this.ditheredBlurMaterial=new zA,this.ditheredBlurMaterial.uniforms.scale=this.blurMaterial.uniforms.scale,this.ditheredBlurMaterial.dithering=!0,this.dithering=!1,this.kernelSize=n}getResolution(){return this.resolution}get width(){return this.resolution.width}set width(r){this.resolution.preferredWidth=r}get height(){return this.resolution.height}set height(r){this.resolution.preferredHeight=r}get scale(){return this.blurMaterial.scale}set scale(r){this.blurMaterial.scale=r}getScale(){return this.blurMaterial.scale}setScale(r){this.blurMaterial.scale=r}getKernelSize(){return this.kernelSize}setKernelSize(r){this.kernelSize=r}getResolutionScale(){return this.resolution.scale}setResolutionScale(r){this.resolution.scale=r}render(r,e,t,n,i){let s=this.scene,o=this.camera,a=this.renderTargetA,l=this.renderTargetB,c=BU[this.kernelSize],h=this.blurMaterial,u=e,d,f;for(this.fullscreenMaterial=h,d=0,f=c.length-1;d<f;++d){let m=(d&1)===0?a:l;h.kernel=c[d],h.inputBuffer=u.texture,r.setRenderTarget(m),r.render(s,o),u=m}this.dithering&&(h=this.ditheredBlurMaterial,this.fullscreenMaterial=h),h.kernel=c[d],h.inputBuffer=u.texture,r.setRenderTarget(this.renderToScreen?null:t),r.render(s,o)}setSize(r,e){let t=this.resolution;t.setBaseSize(r,e);let n=t.width,i=t.height;this.renderTargetA.setSize(n,i),this.renderTargetB.setSize(n,i),this.blurMaterial.setSize(n,i),this.ditheredBlurMaterial.setSize(n,i)}initialize(r,e,t){t!==void 0&&(this.renderTargetA.texture.type=t,this.renderTargetB.texture.type=t,t!==It?(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.ditheredBlurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1"):r.outputEncoding===We&&(this.renderTargetA.texture.encoding=We,this.renderTargetB.texture.encoding=We))}static get AUTO_SIZE(){return ni.AUTO_SIZE}};var OU=class extends Zi{constructor({width:r=ni.AUTO_SIZE,height:e=ni.AUTO_SIZE,renderTarget:t,luminanceRange:n,colorOutput:i}={}){super("LuminancePass"),this.fullscreenMaterial=new sU(i,n),this.needsSwap=!1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new lt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target",this.renderTarget.texture.generateMipmaps=!1);let s=this.resolution=new ni(this,r,e);s.addEventListener("change",o=>this.setSize(s.baseWidth,s.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(r,e,t,n,i){let s=this.fullscreenMaterial;s.inputBuffer=e.texture,r.setRenderTarget(this.renderToScreen?null:this.renderTarget),r.render(this.scene,this.camera)}setSize(r,e){let t=this.resolution;t.setBaseSize(r,e),this.renderTarget.setSize(t.width,t.height)}initialize(r,e,t){t!==void 0&&t!==It&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},FU=class extends Zi{constructor(r,e){super("MaskPass",r,e),this.needsSwap=!1,this.clearPass=new Bl(!1,!1,!0),this.inverse=!1}get inverted(){return this.inverse}set inverted(r){this.inverse=r}get clear(){return this.clearPass.enabled}set clear(r){this.clearPass.enabled=r}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(r){this.inverted=r}render(r,e,t,n,i){let s=r.getContext(),o=r.state.buffers,a=this.scene,l=this.camera,c=this.clearPass,h=this.inverted?0:1,u=1-h;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),o.stencil.setFunc(s.ALWAYS,h,4294967295),o.stencil.setClear(u),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?c.render(r,null):(c.render(r,e),c.render(r,t))),this.renderToScreen?(r.setRenderTarget(null),r.render(a,l)):(r.setRenderTarget(e),r.render(a,l),r.setRenderTarget(t),r.render(a,l)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(s.EQUAL,1,4294967295),o.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),o.stencil.setLocked(!0)}};var Xs=class extends Zi{constructor(r,e="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=r,this.inputBufferUniform=null,this.setInput(e)}setInput(r){if(this.inputBufferUniform=null,this.fullscreenMaterial!==null){let e=this.fullscreenMaterial.uniforms;e!==void 0&&e[r]!==void 0&&(this.inputBufferUniform=e[r])}}render(r,e,t,n,i){this.inputBufferUniform!==null&&e!==null&&(this.inputBufferUniform.value=e.texture),r.setRenderTarget(this.renderToScreen?null:t),r.render(this.scene,this.camera)}initialize(r,e,t){t!==void 0&&t!==It&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},rv=1/1e3,UU=1e3,zU=class{constructor(){this.previousTime=0,this.currentTime=0,this.delta=0,this.fixedDelta=1e3/60,this.elapsed=0,this.timescale=1,this.fixedDeltaEnabled=!1,this.autoReset=!1}setFixedDeltaEnabled(r){return this.fixedDeltaEnabled=r,this}isAutoResetEnabled(r){return this.autoReset}setAutoResetEnabled(r){return typeof document<"u"&&document.hidden!==void 0&&(r?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this.autoReset=r),this}getDelta(){return this.delta*rv}getFixedDelta(){return this.fixedDelta*rv}setFixedDelta(r){return this.fixedDelta=r*UU,this}getElapsed(){return this.elapsed*rv}getTimescale(){return this.timescale}setTimescale(r){return this.timescale=r,this}update(r){return this.fixedDeltaEnabled?this.delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=r!==void 0?r:performance.now(),this.delta=this.currentTime-this.previousTime),this.delta*=this.timescale,this.elapsed+=this.delta,this}reset(){return this.delta=0,this.elapsed=0,this.currentTime=performance.now(),this}handleEvent(r){document.hidden||(this.currentTime=performance.now())}dispose(){this.setAutoResetEnabled(!1)}},XA=class{constructor(r=null,{depthBuffer:e=!0,stencilBuffer:t=!1,multisampling:n=0,frameBufferType:i}={}){this.renderer=null,this.inputBuffer=this.createBuffer(e,t,i,n),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new lv,this.depthTexture=null,this.passes=[],this.timer=new zU,this.autoRenderToScreen=!0,this.setRenderer(r)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(r){let e=this.inputBuffer,t=this.multisampling;t>0&&r>0?(this.inputBuffer.samples=r,this.outputBuffer.samples=r,this.inputBuffer.dispose(),this.outputBuffer.dispose()):t!==r&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(e.depthBuffer,e.stencilBuffer,e.texture.type,r),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(r){if(this.renderer=r,r!==null){let e=r.getSize(new B),t=r.getContext().getContextAttributes().alpha,n=this.inputBuffer.texture.type;n===It&&r.outputEncoding===We&&(this.inputBuffer.texture.encoding=We,this.outputBuffer.texture.encoding=We,this.inputBuffer.dispose(),this.outputBuffer.dispose()),r.autoClear=!1,this.setSize(e.width,e.height);for(let i of this.passes)i.initialize(r,t,n)}}replaceRenderer(r,e=!0){let t=this.renderer,n=t.domElement.parentNode;return this.setRenderer(r),e&&n!==null&&(n.removeChild(t.domElement),n.appendChild(r.domElement)),t}createDepthTexture(){let r=this.depthTexture=new wr;return this.inputBuffer.depthTexture=r,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(r.format=fs,r.type=cs):r.type=Fi,r}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let r of this.passes)r.setDepthTexture(null)}}createBuffer(r,e,t,n){let i=this.renderer,s=i===null?new B:i.getDrawingBufferSize(new B),o={minFilter:tt,magFilter:tt,stencilBuffer:e,depthBuffer:r,type:t},a;return n>0?(a=Number(mo.replace(/\D+/g,""))<138?new Ru(s.width,s.height,o):new lt(s.width,s.height,o),a.ignoreDepthForMultisampleCopy=!1,a.samples=n):a=new lt(s.width,s.height,o),t===It&&i!==null&&i.outputEncoding===We&&(a.texture.encoding=We),a.texture.name="EffectComposer.Buffer",a.texture.generateMipmaps=!1,a}addPass(r,e){let t=this.passes,n=this.renderer,i=n.getDrawingBufferSize(new B),s=n.getContext().getContextAttributes().alpha,o=this.inputBuffer.texture.type;if(r.setRenderer(n),r.setSize(i.width,i.height),r.initialize(n,s,o),this.autoRenderToScreen&&(t.length>0&&(t[t.length-1].renderToScreen=!1),r.renderToScreen&&(this.autoRenderToScreen=!1)),e!==void 0?t.splice(e,0,r):t.push(r),this.autoRenderToScreen&&(t[t.length-1].renderToScreen=!0),r.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let a=this.createDepthTexture();for(r of t)r.setDepthTexture(a)}else r.setDepthTexture(this.depthTexture)}removePass(r){let e=this.passes,t=e.indexOf(r);if(t!==-1&&e.splice(t,1).length>0){if(this.depthTexture!==null){let s=(a,l)=>a||l.needsDepthTexture;e.reduce(s,!1)||(r.getDepthTexture()===this.depthTexture&&r.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&t===e.length&&(r.renderToScreen=!1,e.length>0&&(e[e.length-1].renderToScreen=!0))}}removeAllPasses(){let r=this.passes;this.deleteDepthTexture(),r.length>0&&(this.autoRenderToScreen&&(r[r.length-1].renderToScreen=!1),this.passes=[])}render(r){let e=this.renderer,t=this.copyPass,n=this.inputBuffer,i=this.outputBuffer,s=!1,o,a,l;r===void 0&&(r=this.timer.update().getDelta());for(let c of this.passes)c.enabled&&(c.render(e,n,i,r,s),c.needsSwap&&(s&&(t.renderToScreen=c.renderToScreen,o=e.getContext(),a=e.state.buffers.stencil,a.setFunc(o.NOTEQUAL,1,4294967295),t.render(e,n,i,r,s),a.setFunc(o.EQUAL,1,4294967295)),l=n,n=i,i=l),c instanceof FU?s=!0:c instanceof fU&&(s=!1))}setSize(r,e,t){let n=this.renderer;if(r===void 0||e===void 0){let s=n.getSize(new B);r=s.width,e=s.height}n.setSize(r,e,t);let i=n.getDrawingBufferSize(new B);this.inputBuffer.setSize(i.width,i.height),this.outputBuffer.setSize(i.width,i.height);for(let s of this.passes)s.setSize(i.width,i.height)}reset(){let r=this.timer.isAutoResetEnabled();this.dispose(),this.autoRenderToScreen=!0,this.timer.setAutoResetEnabled(r)}dispose(){for(let r of this.passes)r.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose()}};var cv={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5};var GU=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
5159
|
+
#`))),this.uniformCount=i.size,this.varyingCount=a,this.skipRendering=o===0,this.needsSwap=!this.skipRendering,this.fullscreenMaterial.setShaderParts(e).setExtensions(s).setUniforms(i).setDefines(n)}recompile(){this.updateMaterial(),this.verifyResources()}getDepthTexture(){return this.fullscreenMaterial.depthBuffer}setDepthTexture(r,e=An){this.fullscreenMaterial.depthBuffer=r,this.fullscreenMaterial.depthPacking=e;for(let t of this.effects)t.setDepthTexture(r,e)}render(r,e,t,n,i){for(let s of this.effects)s.update(r,e,n);if(!this.skipRendering||this.renderToScreen){let s=this.fullscreenMaterial;s.inputBuffer=e.texture,s.time+=n,r.setRenderTarget(this.renderToScreen?null:t),r.render(this.scene,this.camera)}}setSize(r,e){this.fullscreenMaterial.setSize(r,e);for(let t of this.effects)t.setSize(r,e)}initialize(r,e,t){this.renderer=r;for(let n of this.effects)n.initialize(r,e,t),n.addEventListener("change",i=>this.handleEvent(i));this.updateMaterial(),this.verifyResources(),t!==void 0&&t!==Lt&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}dispose(){super.dispose();for(let r of this.effects)r.dispose()}handleEvent(r){switch(r.type){case"change":this.recompile();break}}},BU=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],qA=class extends Zi{constructor({resolutionScale:r=.5,width:e=ni.AUTO_SIZE,height:t=ni.AUTO_SIZE,kernelSize:n=cv.LARGE}={}){super("KawaseBlurPass"),this.renderTargetA=new lt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B";let i=this.resolution=new ni(this,e,t,r);i.addEventListener("change",s=>this.setSize(i.baseWidth,i.baseHeight)),this.blurMaterial=new zA,this.ditheredBlurMaterial=new zA,this.ditheredBlurMaterial.uniforms.scale=this.blurMaterial.uniforms.scale,this.ditheredBlurMaterial.dithering=!0,this.dithering=!1,this.kernelSize=n}getResolution(){return this.resolution}get width(){return this.resolution.width}set width(r){this.resolution.preferredWidth=r}get height(){return this.resolution.height}set height(r){this.resolution.preferredHeight=r}get scale(){return this.blurMaterial.scale}set scale(r){this.blurMaterial.scale=r}getScale(){return this.blurMaterial.scale}setScale(r){this.blurMaterial.scale=r}getKernelSize(){return this.kernelSize}setKernelSize(r){this.kernelSize=r}getResolutionScale(){return this.resolution.scale}setResolutionScale(r){this.resolution.scale=r}render(r,e,t,n,i){let s=this.scene,o=this.camera,a=this.renderTargetA,l=this.renderTargetB,c=BU[this.kernelSize],h=this.blurMaterial,u=e,d,f;for(this.fullscreenMaterial=h,d=0,f=c.length-1;d<f;++d){let m=(d&1)===0?a:l;h.kernel=c[d],h.inputBuffer=u.texture,r.setRenderTarget(m),r.render(s,o),u=m}this.dithering&&(h=this.ditheredBlurMaterial,this.fullscreenMaterial=h),h.kernel=c[d],h.inputBuffer=u.texture,r.setRenderTarget(this.renderToScreen?null:t),r.render(s,o)}setSize(r,e){let t=this.resolution;t.setBaseSize(r,e);let n=t.width,i=t.height;this.renderTargetA.setSize(n,i),this.renderTargetB.setSize(n,i),this.blurMaterial.setSize(n,i),this.ditheredBlurMaterial.setSize(n,i)}initialize(r,e,t){t!==void 0&&(this.renderTargetA.texture.type=t,this.renderTargetB.texture.type=t,t!==Lt?(this.blurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1",this.ditheredBlurMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1"):r.outputEncoding===We&&(this.renderTargetA.texture.encoding=We,this.renderTargetB.texture.encoding=We))}static get AUTO_SIZE(){return ni.AUTO_SIZE}};var OU=class extends Zi{constructor({width:r=ni.AUTO_SIZE,height:e=ni.AUTO_SIZE,renderTarget:t,luminanceRange:n,colorOutput:i}={}){super("LuminancePass"),this.fullscreenMaterial=new sU(i,n),this.needsSwap=!1,this.renderTarget=t,this.renderTarget===void 0&&(this.renderTarget=new lt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target",this.renderTarget.texture.generateMipmaps=!1);let s=this.resolution=new ni(this,r,e);s.addEventListener("change",o=>this.setSize(s.baseWidth,s.baseHeight))}get texture(){return this.renderTarget.texture}getTexture(){return this.renderTarget.texture}getResolution(){return this.resolution}render(r,e,t,n,i){let s=this.fullscreenMaterial;s.inputBuffer=e.texture,r.setRenderTarget(this.renderToScreen?null:this.renderTarget),r.render(this.scene,this.camera)}setSize(r,e){let t=this.resolution;t.setBaseSize(r,e),this.renderTarget.setSize(t.width,t.height)}initialize(r,e,t){t!==void 0&&t!==Lt&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},FU=class extends Zi{constructor(r,e){super("MaskPass",r,e),this.needsSwap=!1,this.clearPass=new Bl(!1,!1,!0),this.inverse=!1}get inverted(){return this.inverse}set inverted(r){this.inverse=r}get clear(){return this.clearPass.enabled}set clear(r){this.clearPass.enabled=r}getClearPass(){return this.clearPass}isInverted(){return this.inverted}setInverted(r){this.inverted=r}render(r,e,t,n,i){let s=r.getContext(),o=r.state.buffers,a=this.scene,l=this.camera,c=this.clearPass,h=this.inverted?0:1,u=1-h;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),o.stencil.setFunc(s.ALWAYS,h,4294967295),o.stencil.setClear(u),o.stencil.setLocked(!0),this.clearPass.enabled&&(this.renderToScreen?c.render(r,null):(c.render(r,e),c.render(r,t))),this.renderToScreen?(r.setRenderTarget(null),r.render(a,l)):(r.setRenderTarget(e),r.render(a,l),r.setRenderTarget(t),r.render(a,l)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(s.EQUAL,1,4294967295),o.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),o.stencil.setLocked(!0)}};var Xs=class extends Zi{constructor(r,e="inputBuffer"){super("ShaderPass"),this.fullscreenMaterial=r,this.inputBufferUniform=null,this.setInput(e)}setInput(r){if(this.inputBufferUniform=null,this.fullscreenMaterial!==null){let e=this.fullscreenMaterial.uniforms;e!==void 0&&e[r]!==void 0&&(this.inputBufferUniform=e[r])}}render(r,e,t,n,i){this.inputBufferUniform!==null&&e!==null&&(this.inputBufferUniform.value=e.texture),r.setRenderTarget(this.renderToScreen?null:t),r.render(this.scene,this.camera)}initialize(r,e,t){t!==void 0&&t!==Lt&&(this.fullscreenMaterial.defines.FRAMEBUFFER_PRECISION_HIGH="1")}},rv=1/1e3,UU=1e3,zU=class{constructor(){this.previousTime=0,this.currentTime=0,this.delta=0,this.fixedDelta=1e3/60,this.elapsed=0,this.timescale=1,this.fixedDeltaEnabled=!1,this.autoReset=!1}setFixedDeltaEnabled(r){return this.fixedDeltaEnabled=r,this}isAutoResetEnabled(r){return this.autoReset}setAutoResetEnabled(r){return typeof document<"u"&&document.hidden!==void 0&&(r?document.addEventListener("visibilitychange",this):document.removeEventListener("visibilitychange",this),this.autoReset=r),this}getDelta(){return this.delta*rv}getFixedDelta(){return this.fixedDelta*rv}setFixedDelta(r){return this.fixedDelta=r*UU,this}getElapsed(){return this.elapsed*rv}getTimescale(){return this.timescale}setTimescale(r){return this.timescale=r,this}update(r){return this.fixedDeltaEnabled?this.delta=this.fixedDelta:(this.previousTime=this.currentTime,this.currentTime=r!==void 0?r:performance.now(),this.delta=this.currentTime-this.previousTime),this.delta*=this.timescale,this.elapsed+=this.delta,this}reset(){return this.delta=0,this.elapsed=0,this.currentTime=performance.now(),this}handleEvent(r){document.hidden||(this.currentTime=performance.now())}dispose(){this.setAutoResetEnabled(!1)}},XA=class{constructor(r=null,{depthBuffer:e=!0,stencilBuffer:t=!1,multisampling:n=0,frameBufferType:i}={}){this.renderer=null,this.inputBuffer=this.createBuffer(e,t,i,n),this.outputBuffer=this.inputBuffer.clone(),this.copyPass=new lv,this.depthTexture=null,this.passes=[],this.timer=new zU,this.autoRenderToScreen=!0,this.setRenderer(r)}get multisampling(){return this.inputBuffer.samples||0}set multisampling(r){let e=this.inputBuffer,t=this.multisampling;t>0&&r>0?(this.inputBuffer.samples=r,this.outputBuffer.samples=r,this.inputBuffer.dispose(),this.outputBuffer.dispose()):t!==r&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(e.depthBuffer,e.stencilBuffer,e.texture.type,r),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getTimer(){return this.timer}getRenderer(){return this.renderer}setRenderer(r){if(this.renderer=r,r!==null){let e=r.getSize(new B),t=r.getContext().getContextAttributes().alpha,n=this.inputBuffer.texture.type;n===Lt&&r.outputEncoding===We&&(this.inputBuffer.texture.encoding=We,this.outputBuffer.texture.encoding=We,this.inputBuffer.dispose(),this.outputBuffer.dispose()),r.autoClear=!1,this.setSize(e.width,e.height);for(let i of this.passes)i.initialize(r,t,n)}}replaceRenderer(r,e=!0){let t=this.renderer,n=t.domElement.parentNode;return this.setRenderer(r),e&&n!==null&&(n.removeChild(t.domElement),n.appendChild(r.domElement)),t}createDepthTexture(){let r=this.depthTexture=new wr;return this.inputBuffer.depthTexture=r,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(r.format=fs,r.type=cs):r.type=Fi,r}deleteDepthTexture(){if(this.depthTexture!==null){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(let r of this.passes)r.setDepthTexture(null)}}createBuffer(r,e,t,n){let i=this.renderer,s=i===null?new B:i.getDrawingBufferSize(new B),o={minFilter:tt,magFilter:tt,stencilBuffer:e,depthBuffer:r,type:t},a;return n>0?(a=Number(mo.replace(/\D+/g,""))<138?new Ru(s.width,s.height,o):new lt(s.width,s.height,o),a.ignoreDepthForMultisampleCopy=!1,a.samples=n):a=new lt(s.width,s.height,o),t===Lt&&i!==null&&i.outputEncoding===We&&(a.texture.encoding=We),a.texture.name="EffectComposer.Buffer",a.texture.generateMipmaps=!1,a}addPass(r,e){let t=this.passes,n=this.renderer,i=n.getDrawingBufferSize(new B),s=n.getContext().getContextAttributes().alpha,o=this.inputBuffer.texture.type;if(r.setRenderer(n),r.setSize(i.width,i.height),r.initialize(n,s,o),this.autoRenderToScreen&&(t.length>0&&(t[t.length-1].renderToScreen=!1),r.renderToScreen&&(this.autoRenderToScreen=!1)),e!==void 0?t.splice(e,0,r):t.push(r),this.autoRenderToScreen&&(t[t.length-1].renderToScreen=!0),r.needsDepthTexture||this.depthTexture!==null)if(this.depthTexture===null){let a=this.createDepthTexture();for(r of t)r.setDepthTexture(a)}else r.setDepthTexture(this.depthTexture)}removePass(r){let e=this.passes,t=e.indexOf(r);if(t!==-1&&e.splice(t,1).length>0){if(this.depthTexture!==null){let s=(a,l)=>a||l.needsDepthTexture;e.reduce(s,!1)||(r.getDepthTexture()===this.depthTexture&&r.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&t===e.length&&(r.renderToScreen=!1,e.length>0&&(e[e.length-1].renderToScreen=!0))}}removeAllPasses(){let r=this.passes;this.deleteDepthTexture(),r.length>0&&(this.autoRenderToScreen&&(r[r.length-1].renderToScreen=!1),this.passes=[])}render(r){let e=this.renderer,t=this.copyPass,n=this.inputBuffer,i=this.outputBuffer,s=!1,o,a,l;r===void 0&&(r=this.timer.update().getDelta());for(let c of this.passes)c.enabled&&(c.render(e,n,i,r,s),c.needsSwap&&(s&&(t.renderToScreen=c.renderToScreen,o=e.getContext(),a=e.state.buffers.stencil,a.setFunc(o.NOTEQUAL,1,4294967295),t.render(e,n,i,r,s),a.setFunc(o.EQUAL,1,4294967295)),l=n,n=i,i=l),c instanceof FU?s=!0:c instanceof fU&&(s=!1))}setSize(r,e,t){let n=this.renderer;if(r===void 0||e===void 0){let s=n.getSize(new B);r=s.width,e=s.height}n.setSize(r,e,t);let i=n.getDrawingBufferSize(new B);this.inputBuffer.setSize(i.width,i.height),this.outputBuffer.setSize(i.width,i.height);for(let s of this.passes)s.setSize(i.width,i.height)}reset(){let r=this.timer.isAutoResetEnabled();this.dispose(),this.autoRenderToScreen=!0,this.timer.setAutoResetEnabled(r)}dispose(){for(let r of this.passes)r.dispose();this.passes=[],this.inputBuffer!==null&&this.inputBuffer.dispose(),this.outputBuffer!==null&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose(),this.timer.dispose()}};var cv={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5};var GU=`#ifdef FRAMEBUFFER_PRECISION_HIGH
|
|
5148
5160
|
uniform mediump sampler2D map;
|
|
5149
5161
|
#else
|
|
5150
5162
|
uniform lowp sampler2D map;
|
|
@@ -5154,7 +5166,7 @@ uniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuff
|
|
|
5154
5166
|
#else
|
|
5155
5167
|
uniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer;
|
|
5156
5168
|
#endif
|
|
5157
|
-
uniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);float CoCNear=texture2D(nearCoCBuffer,uv).r;CoCNear=min(CoCNear*scale,1.0);vec4 result=inputColor*(1.0-colorFar.a)+colorFar;result=mix(result,colorNear,CoCNear);outputColor=result;}`,JA=class extends Di{constructor(r,{blendFunction:e=at.NORMAL,worldFocusDistance:t,worldFocusRange:n,focusDistance:i=0,focalLength:s=.1,focusRange:o=s,bokehScale:a=1,width:l=ni.AUTO_SIZE,height:c=ni.AUTO_SIZE}={}){super("DepthOfFieldEffect",jU,{blendFunction:e,attributes:Ci.DEPTH,uniforms:new Map([["nearColorBuffer",new we(null)],["farColorBuffer",new we(null)],["nearCoCBuffer",new we(null)],["scale",new we(1)]])}),this.camera=r,this.renderTarget=new lt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="DoF.Intermediate",this.renderTarget.texture.generateMipmaps=!1,this.renderTargetMasked=this.renderTarget.clone(),this.renderTargetMasked.texture.name="DoF.Masked.Far",this.renderTargetNear=this.renderTarget.clone(),this.renderTargetNear.texture.name="DoF.Bokeh.Near",this.uniforms.get("nearColorBuffer").value=this.renderTargetNear.texture,this.renderTargetFar=this.renderTarget.clone(),this.renderTargetFar.texture.name="DoF.Bokeh.Far",this.uniforms.get("farColorBuffer").value=this.renderTargetFar.texture,this.renderTargetCoC=this.renderTarget.clone(),this.renderTargetCoC.texture.name="DoF.CoC",this.renderTargetCoCBlurred=this.renderTargetCoC.clone(),this.renderTargetCoCBlurred.texture.name="DoF.CoC.Blurred",this.uniforms.get("nearCoCBuffer").value=this.renderTargetCoCBlurred.texture,this.cocPass=new Xs(new YF(r));let h=this.cocMaterial;h.focusDistance=i,h.focusRange=o,t!==void 0&&(h.worldFocusDistance=t),n!==void 0&&(h.worldFocusRange=n),this.blurPass=new qA({kernelSize:cv.MEDIUM,width:l,height:c});let u=this.blurPass.getResolution();u.addEventListener("change",f=>this.setSize(u.getBaseWidth(),u.getBaseHeight())),this.maskPass=new Xs(new aU(this.renderTargetCoC.texture));let d=this.maskPass.fullscreenMaterial;d.maskFunction=jA.MULTIPLY,d.colorChannel=WA.GREEN,this.bokehNearBasePass=new Xs(new Wf(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new Xs(new Wf(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new Xs(new Wf(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new Xs(new Wf(!0,!1)),this.bokehFarFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.target=null,this.bokehScale=a}get cocTexture(){return this.renderTargetCoC.texture}get cocMaterial(){return this.cocPass.fullscreenMaterial}get circleOfConfusionMaterial(){return this.cocMaterial}getCircleOfConfusionMaterial(){return this.circleOfConfusionMaterial}getBlurPass(){return this.blurPass}get resolution(){return this.blurPass.getResolution()}getResolution(){return this.blurPass.getResolution()}get bokehScale(){return this.uniforms.get("scale").value}set bokehScale(r){let e=[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];for(let t of e)t.fullscreenMaterial.setScale(r);this.maskPass.fullscreenMaterial.setStrength(r),this.uniforms.get("scale").value=r}getBokehScale(){return this.bokehScale}setBokehScale(r){this.bokehScale=r}getTarget(){return this.target}setTarget(r){this.target=r}calculateFocusDistance(r){let e=this.camera,t=e.position.distanceTo(r);return sv(-t,e.near,e.far)}setDepthTexture(r,e=An){this.circleOfConfusionMaterial.depthBuffer=r,this.circleOfConfusionMaterial.depthPacking=e}update(r,e,t){let n=this.renderTarget,i=this.renderTargetCoC,s=this.renderTargetCoCBlurred,o=this.renderTargetMasked;if(this.target!==null){let a=this.calculateFocusDistance(this.target);this.circleOfConfusionMaterial.focusDistance=a}this.cocPass.render(r,null,i),this.blurPass.render(r,i,s),this.maskPass.render(r,e,o),this.bokehFarBasePass.render(r,o,n),this.bokehFarFillPass.render(r,n,this.renderTargetFar),this.bokehNearBasePass.render(r,e,n),this.bokehNearFillPass.render(r,n,this.renderTargetNear)}setSize(r,e){let t=this.resolution;t.setBaseSize(r,e);let n=t.width,i=t.height,s=[this.cocPass,this.blurPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];s.push(this.renderTargetCoC,this.renderTargetMasked),s.forEach(a=>a.setSize(r,e)),s=[this.renderTarget,this.renderTargetNear,this.renderTargetFar,this.renderTargetCoCBlurred],s.forEach(a=>a.setSize(n,i)),[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(a=>a.fullscreenMaterial.setSize(n,i))}initialize(r,e,t){[this.cocPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(i=>i.initialize(r,e,t)),this.blurPass.initialize(r,e,
|
|
5169
|
+
uniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);float CoCNear=texture2D(nearCoCBuffer,uv).r;CoCNear=min(CoCNear*scale,1.0);vec4 result=inputColor*(1.0-colorFar.a)+colorFar;result=mix(result,colorNear,CoCNear);outputColor=result;}`,JA=class extends Di{constructor(r,{blendFunction:e=at.NORMAL,worldFocusDistance:t,worldFocusRange:n,focusDistance:i=0,focalLength:s=.1,focusRange:o=s,bokehScale:a=1,width:l=ni.AUTO_SIZE,height:c=ni.AUTO_SIZE}={}){super("DepthOfFieldEffect",jU,{blendFunction:e,attributes:Ci.DEPTH,uniforms:new Map([["nearColorBuffer",new we(null)],["farColorBuffer",new we(null)],["nearCoCBuffer",new we(null)],["scale",new we(1)]])}),this.camera=r,this.renderTarget=new lt(1,1,{minFilter:tt,magFilter:tt,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="DoF.Intermediate",this.renderTarget.texture.generateMipmaps=!1,this.renderTargetMasked=this.renderTarget.clone(),this.renderTargetMasked.texture.name="DoF.Masked.Far",this.renderTargetNear=this.renderTarget.clone(),this.renderTargetNear.texture.name="DoF.Bokeh.Near",this.uniforms.get("nearColorBuffer").value=this.renderTargetNear.texture,this.renderTargetFar=this.renderTarget.clone(),this.renderTargetFar.texture.name="DoF.Bokeh.Far",this.uniforms.get("farColorBuffer").value=this.renderTargetFar.texture,this.renderTargetCoC=this.renderTarget.clone(),this.renderTargetCoC.texture.name="DoF.CoC",this.renderTargetCoCBlurred=this.renderTargetCoC.clone(),this.renderTargetCoCBlurred.texture.name="DoF.CoC.Blurred",this.uniforms.get("nearCoCBuffer").value=this.renderTargetCoCBlurred.texture,this.cocPass=new Xs(new YF(r));let h=this.cocMaterial;h.focusDistance=i,h.focusRange=o,t!==void 0&&(h.worldFocusDistance=t),n!==void 0&&(h.worldFocusRange=n),this.blurPass=new qA({kernelSize:cv.MEDIUM,width:l,height:c});let u=this.blurPass.getResolution();u.addEventListener("change",f=>this.setSize(u.getBaseWidth(),u.getBaseHeight())),this.maskPass=new Xs(new aU(this.renderTargetCoC.texture));let d=this.maskPass.fullscreenMaterial;d.maskFunction=jA.MULTIPLY,d.colorChannel=WA.GREEN,this.bokehNearBasePass=new Xs(new Wf(!1,!0)),this.bokehNearBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehNearFillPass=new Xs(new Wf(!0,!0)),this.bokehNearFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoCBlurred.texture,this.bokehFarBasePass=new Xs(new Wf(!1,!1)),this.bokehFarBasePass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.bokehFarFillPass=new Xs(new Wf(!0,!1)),this.bokehFarFillPass.fullscreenMaterial.cocBuffer=this.renderTargetCoC.texture,this.target=null,this.bokehScale=a}get cocTexture(){return this.renderTargetCoC.texture}get cocMaterial(){return this.cocPass.fullscreenMaterial}get circleOfConfusionMaterial(){return this.cocMaterial}getCircleOfConfusionMaterial(){return this.circleOfConfusionMaterial}getBlurPass(){return this.blurPass}get resolution(){return this.blurPass.getResolution()}getResolution(){return this.blurPass.getResolution()}get bokehScale(){return this.uniforms.get("scale").value}set bokehScale(r){let e=[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];for(let t of e)t.fullscreenMaterial.setScale(r);this.maskPass.fullscreenMaterial.setStrength(r),this.uniforms.get("scale").value=r}getBokehScale(){return this.bokehScale}setBokehScale(r){this.bokehScale=r}getTarget(){return this.target}setTarget(r){this.target=r}calculateFocusDistance(r){let e=this.camera,t=e.position.distanceTo(r);return sv(-t,e.near,e.far)}setDepthTexture(r,e=An){this.circleOfConfusionMaterial.depthBuffer=r,this.circleOfConfusionMaterial.depthPacking=e}update(r,e,t){let n=this.renderTarget,i=this.renderTargetCoC,s=this.renderTargetCoCBlurred,o=this.renderTargetMasked;if(this.target!==null){let a=this.calculateFocusDistance(this.target);this.circleOfConfusionMaterial.focusDistance=a}this.cocPass.render(r,null,i),this.blurPass.render(r,i,s),this.maskPass.render(r,e,o),this.bokehFarBasePass.render(r,o,n),this.bokehFarFillPass.render(r,n,this.renderTargetFar),this.bokehNearBasePass.render(r,e,n),this.bokehNearFillPass.render(r,n,this.renderTargetNear)}setSize(r,e){let t=this.resolution;t.setBaseSize(r,e);let n=t.width,i=t.height,s=[this.cocPass,this.blurPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];s.push(this.renderTargetCoC,this.renderTargetMasked),s.forEach(a=>a.setSize(r,e)),s=[this.renderTarget,this.renderTargetNear,this.renderTargetFar,this.renderTargetCoCBlurred],s.forEach(a=>a.setSize(n,i)),[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(a=>a.fullscreenMaterial.setSize(n,i))}initialize(r,e,t){[this.cocPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach(i=>i.initialize(r,e,t)),this.blurPass.initialize(r,e,Lt),t!==void 0&&(this.renderTarget.texture.type=t,this.renderTargetNear.texture.type=t,this.renderTargetFar.texture.type=t,this.renderTargetMasked.texture.type=t,r.outputEncoding===We&&(this.renderTarget.texture.encoding=We,this.renderTargetNear.texture.encoding=We,this.renderTargetFar.texture.encoding=We,this.renderTargetMasked.texture.encoding=We))}};var aae=new A,lae=new Oe;var qU="uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}",$A=class extends Di{constructor({blendFunction:r=at.NORMAL,hue:e=0,saturation:t=0}={}){super("HueSaturationEffect",qU,{blendFunction:r,uniforms:new Map([["hue",new we(new A)],["saturation",new we(t)]])}),this.hue=e}get saturation(){return this.uniforms.get("saturation").value}set saturation(r){this.uniforms.get("saturation").value=r}getSaturation(){return this.saturation}setSaturation(r){this.saturation=r}get hue(){let r=this.uniforms.get("hue").value;return Math.acos((r.x*3-1)/2)}set hue(r){let e=Math.sin(r),t=Math.cos(r);this.uniforms.get("hue").value.set((2*t+1)/3,(-Math.sqrt(3)*e-t+1)/3,(Math.sqrt(3)*e-t+1)/3)}getHue(){return this.hue}setHue(r){this.hue=r}};var uae=new Ae;var XU=`void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*time));
|
|
5158
5170
|
#ifdef PREMULTIPLY
|
|
5159
5171
|
outputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a);
|
|
5160
5172
|
#else
|
|
@@ -5166,4 +5178,4 @@ float d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offse
|
|
|
5166
5178
|
#else
|
|
5167
5179
|
vec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord));
|
|
5168
5180
|
#endif
|
|
5169
|
-
outputColor=vec4(color,inputColor.a);}`,jf={DEFAULT:0,ESKIL:1},rM=class extends Di{constructor({blendFunction:r=at.NORMAL,technique:e=jf.DEFAULT,eskil:t=!1,offset:n=.5,darkness:i=.5}={}){super("VignetteEffect",ZU,{blendFunction:r,defines:new Map([["VIGNETTE_TECHNIQUE",e.toFixed(0)]]),uniforms:new Map([["offset",new we(n)],["darkness",new we(i)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(r){this.technique!==r&&(this.defines.set("VIGNETTE_TECHNIQUE",r.toFixed(0)),this.setChanged())}get eskil(){return this.technique===jf.ESKIL}set eskil(r){this.technique=r?jf.ESKIL:jf.DEFAULT}getTechnique(){return this.technique}setTechnique(r){this.technique=r}get offset(){return this.uniforms.get("offset").value}set offset(r){this.uniforms.get("offset").value=r}getOffset(){return this.offset}setOffset(r){this.offset=r}get darkness(){return this.uniforms.get("darkness").value}set darkness(r){this.uniforms.get("darkness").value=r}getDarkness(){return this.darkness}setDarkness(r){this.darkness=r}},xae=[new Float32Array(3),new Float32Array(3)],bae=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],wae=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];var Sae=[new Float32Array(2),new Float32Array(2)];var Aae=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),Mae=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],_ae=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],Tae=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];var Eae=new Map([[Un(0,0,0,0),new Float32Array([0,0,0,0])],[Un(0,0,0,1),new Float32Array([0,0,0,1])],[Un(0,0,1,0),new Float32Array([0,0,1,0])],[Un(0,0,1,1),new Float32Array([0,0,1,1])],[Un(0,1,0,0),new Float32Array([0,1,0,0])],[Un(0,1,0,1),new Float32Array([0,1,0,1])],[Un(0,1,1,0),new Float32Array([0,1,1,0])],[Un(0,1,1,1),new Float32Array([0,1,1,1])],[Un(1,0,0,0),new Float32Array([1,0,0,0])],[Un(1,0,0,1),new Float32Array([1,0,0,1])],[Un(1,0,1,0),new Float32Array([1,0,1,0])],[Un(1,0,1,1),new Float32Array([1,0,1,1])],[Un(1,1,0,0),new Float32Array([1,1,0,0])],[Un(1,1,0,1),new Float32Array([1,1,0,1])],[Un(1,1,1,0),new Float32Array([1,1,1,0])],[Un(1,1,1,1),new Float32Array([1,1,1,1])]]);function iv(r,e,t){return r+(e-r)*t}function Un(r,e,t,n){let i=iv(r,e,.75),s=iv(t,n,1-.25);return iv(i,s,1-.125)}var tn=class{constructor(e,t){this.enabled=!1;this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(n){this.effect.blendMode.opacity.value=n},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(n){this.effect.blendMode.setBlendFunction(Number(n))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=at.NORMAL}toJSON(){let e=["constructor","effect","subscriptions"],t={...this},n=Object.getPrototypeOf(this),i=Object.getOwnPropertyNames(n);for(let s of i){let o=Object.getOwnPropertyDescriptor(n,s);o&&typeof o.get=="function"&&(t[s]=this[s])}return e.forEach(s=>delete t[s]),t}};var Ol=class extends tn{constructor(){super(YA),this.blendFunction=at.SCREEN}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}};var Fl=class extends tn{constructor(){super(QA)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}};var Ul=class extends tn{constructor(){super(ZA),this.effect.offset=new B(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}};var zl=class extends tn{constructor(){super(KA)}};var Gl=class extends tn{constructor(){super($A);this._hue=0}set hue(t){this._hue=t,this.effect.setHue(t)}get hue(){return this._hue}set saturation(t){this.effect.uniforms.get("saturation").value=t}get saturation(){return this.effect.uniforms.get("saturation").value}};var kl=class extends tn{constructor(){super(eM),this.blendFunction=at.OVERLAY}};var Vl=class extends tn{constructor(){super(rM)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}};var Hl=class extends tn{constructor(e){super(JA,e)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=e}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}};var Wl=class extends tn{constructor(){super(tM)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}};function iM(r,e){return e&&e.enabled&&r.push(e.effect),r}var Ph=class extends Rt{constructor(){super();this._scene=new Wn;this._camera=new mr;this.sceneHelpers=new Wn;this.sceneHelpersOnTop=new Wn;this.uiHandler=null;this.overmind=null;this.effects=new Map;this.loadingManager=new uo;this.renderPass=new Io;this.helperPass=new Io;this.helperPassOnTop=new Io;this._renderToScreen=!0;this._hasSmaa=!1;this.clock=new Tu,this.enabled=!1,this.debug=!1,this.effects.set("bloom",new Ol),this.effects.set("chromaticAberration",new Ul),this.effects.set("vignette",new Vl),this.effects.set("noise",new kl),this.effects.set("colorAverage",new zl),this.effects.set("hueSaturation",new Gl),this.effects.set("brightnessContrast",new Fl),this.effects.set("depthOfField",new Hl),this.effects.set("pixelation",new Wl)}get scene(){return this._scene}set scene(t){this._scene=t}get camera(){return this._camera}set camera(t){this._camera=t}_initSmaa(){if(!this.effectComposer)return;let t=this.effectComposer.passes.length,n=new nM({preset:Po.ULTRA,edgeDetectionMode:qf.COLOR}),i=()=>{n.removeEventListener("load",i),this.dispatchEvent({type:"smaaloaded"})};n.addEventListener("load",i),n.edgeDetectionMaterial.predicationMode=av.DEPTH,n.edgeDetectionMaterial.edgeDetectionThreshold=.05,n.edgeDetectionMaterial.predicationThreshold=.002,n.edgeDetectionMaterial.predicationScale=1,this.effectComposer.addPass(new Xf(this.camera,n),t),this._hasSmaa=!0}_initPasses(){if(!this.effectComposer||!this.renderer)return;let t;if(this.effectComposer.removeAllPasses(),this._hasSmaa=!1,this.renderPass=new Io(this.scene,this.camera),this.helperPass=new Io(this.sceneHelpers,this.camera),this.helperPassOnTop=new Io(this.sceneHelpersOnTop,this.camera),this.enabled){this.effectComposer.addPass(this.renderPass);let n=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(iM,[]),i=[this.effects.get("pixelation")].reduce(iM,[]);i.length>0&&this.effectComposer.addPass(new Xf(this.camera,...i)),this.effectComposer.addPass(new Xf(this.camera,...n)),(!this.uiHandler||this.uiHandler.state!==this.uiHandler.STATE.PLAY&&this.uiHandler.state!==this.uiHandler.STATE.FRAME&&this.uiHandler.state!==this.uiHandler.STATE.COLOR&&!this.overmind.state.editor.recording)&&(this.helperPass.clear=!1,this.helperPassOnTop.clear=!1,this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(new Bl(!1,!0,!1)),this.effectComposer.addPass(this.helperPassOnTop))}else this.effectComposer.addPass(this.renderPass),(!this.uiHandler||this.uiHandler.state!==this.uiHandler.STATE.PLAY&&this.uiHandler.state!==this.uiHandler.STATE.FRAME&&this.uiHandler.state!==this.uiHandler.STATE.COLOR&&!this.overmind.state.editor.recording)&&(this.helperPass.clear=!1,this.helperPassOnTop.clear=!1,this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(new Bl(!1,!0,!1)),this.effectComposer.addPass(this.helperPassOnTop));if(this._initSmaa(),t)return t}reinit(){if(!this.renderer)return Promise.all([]);this.effectComposer=new XA(this.renderer),this._initPasses()}init({renderer:t,camera:n,scene:i,sceneHelpers:s,sceneHelpersOnTop:o,uiHandler:a,overmind:l}){this.renderer=t,this.scene=i,this.sceneHelpers=s,this.sceneHelpersOnTop=o,this.camera=n,this.uiHandler=a,this.overmind=l,this._initCopyPass(),this.reinit()}_initCopyPass(){if(this._savePass)return;let t=new B;this.renderer.getDrawingBufferSize(t),this._rt=new lt(t.x,t.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:ta,wrapT:ta}),this._rt.samples=0,this._savePass=new lv(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(t){let n=this.effectComposer;!n||(t===!0?(n.removePass(this._savePass),n.passes[n.passes.length-1].renderToScreen=!0,n.autoRenderToScreen=!0):(n.autoRenderToScreen=!1,n.passes[n.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.enabled||(this._savePass.needsDepthTexture=!0),n.addPass(this._savePass)),this._renderToScreen=t)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}fromJSON(t){t&&(Object.keys(t).forEach(n=>{let i=t[n],s=this.effects.get(n);Object.keys(i).forEach(o=>{s[o]=i[o]})}),this.enabled=t.enabled)}toJSON(){let t={};return this.effects.forEach((n,i)=>{t[i]=n.toJSON()},t),{enabled:this.enabled,...t}}render(){this.effectComposer?.render(this.clock.getDelta())}setScissor(t,n,i,s){if(!this.effectComposer||!this.renderer)return;t instanceof qe?(this.effectComposer.inputBuffer.scissor.set(t.x,t.y,t.z,t.w),this.effectComposer.outputBuffer.scissor.set(t.x,t.y,t.z,t.w)):(this.effectComposer.inputBuffer.scissor.set(t,n,i,s),this.effectComposer.outputBuffer.scissor.set(t,n,i,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(t,n,i,s)}setScissorTest(t){!this.effectComposer||!this.renderer||(this.effectComposer.inputBuffer.scissorTest=t,this.effectComposer.outputBuffer.scissorTest=t,this.renderer.setScissorTest(t))}setViewport(t,n,i,s){!this.effectComposer||(t instanceof qe?(this.effectComposer.inputBuffer.viewport.copy(t),this.effectComposer.outputBuffer.viewport.copy(t)):(this.effectComposer.inputBuffer.viewport.set(t,n,i,s),this.effectComposer.outputBuffer.viewport.set(t,n,i,s)))}resize(t,n,i){if(this.effectComposer?.setSize(t,n,i),this._rt){let s=this.renderer?.getPixelRatio()||window.devicePixelRatio;this._rt.setSize(t*s,n*s)}}dispose(){this._listeners=void 0,this.effectComposer?.dispose()}};var Yf=class extends Ch{constructor(t,n){super(t,n);this.postprocessing=new Ph;this.initPostprocessing(t.postprocessing)}resetAfterClear(t,n){super.resetAfterClear(t,n),this.initPostprocessing(t.postprocessing)}initPostprocessing(t){let{enabled:n,...i}=t;for(let s of Object.entries(i)){let o=s[1],a=this.postprocessing.effects.get(s[0]);if(a){a.enabled=o.enabled;for(let[l,c]of Object.entries(o))a[l]=c}}this.postprocessing.enabled=n,this.postprocessing.reinit()}dispose(){super.dispose(),this.postprocessing.dispose()}switchActiveCamera(t){super.switchActiveCamera(t),this.postprocessing&&(this.postprocessing.camera=t)}};function $U(r,e){switch(r.type){case"noise":return e==="noiseType";case"texture":return e==="projection"||e==="axis"||e==="side";case"displace":return e==="noiseType";case"depth":return e==="num"||e==="smooth"||e==="isWorldSpace"||e==="gradientType"||e==="isVector";default:return!1}}function hv(r,e,t,n,i){let s=!1;for(let[o,a]of Object.entries(r)){if(!o||a===void 0||Mf(o,t,i))continue;t.visible=i.visible;let l=t.uniforms[`f${t.id}_${o}`];if(!!l)switch(l.constructor){case xt:if(typeof a=="string"){let c=e.getColor(a);c&&(l.value=c);break}else{let c=a;l.value instanceof Do?l.value=new In(c.r,c.g,c.b,c.a):l.setRGBA(c);break}case Pr:if(typeof a=="string"){let c=e.getColor(a);c&&(l.value=c);break}else{let c=a;l.value instanceof Do?l.value=new In(c.r,c.g,c.b,c.a):l.value.setRGBA(c.r,c.g,c.b,c.a);break}case mn:{let c=a;l.value.setX(c[0]),l.value.setY(c[1]);break}case Tn:{let c=a;l.value.setX(c[0]),l.value.setY(c[1]),l.value.setZ(c[2]);break}case vn:{let c=a;if("image"in c){let h=c.image;if(typeof h=="string"){let u=e.getImage(h);u&&(l.value.image=u)}else{let u=new Image;u.src=Gs(h.data),l.value.image=u}}"wrapping"in c&&(l.value.wrapS=l.value.wrapT=c.wrapping),"repeat"in c&&l.value.repeat.fromArray(c.repeat),"offset"in c&&l.value.offset.fromArray(c.offset),l.value.needsUpdate=!0;break}case Yr:{a.forEach((c,h)=>{l.value[h].setX(c[0]),l.value[h].setY(c[1]),l.value[h].setZ(c[2]),l.value[h].setW(c[3])});break}default:{s=s||$U(t,o),l.value=a;break}}}if(s&&i){let o=Af({id:"0",fi:0,data:i},e);n.userData.layers?.changeLayer(t.id,{...o}),n.dispose(),n.needsUpdate=!0}}var uv=new A,sM=new kn,oM=new Oe,Ih={type:"follow",normal:new A,raycaster:new Ns},jl;(t=>{function r(n){if(n.type===10)return{type:"follow"}}t.create=r;function e({target:n,normal:i,raycaster:s,begin:o,change:a}){!n||!i||!s||(o&&o("follow",n.uuid),sM.setFromNormalAndCoplanarPoint(i,n.getWorldPosition(uv)),s.ray.intersectPlane(sM,uv),n.position.copy(uv),n.parent!==null&&n.position.applyMatrix4(oM.copy(n.parent.matrixWorld).invert()),n.position.applyMatrix4(oM.copy(n.hiddenMatrix).invert()),n.updateMatrix(),Ut(n)&&bt(n.parent)&&n.invalidateDownstreamBooleanData(!0),a&&a())}t.listener=e})(jl||(jl={}));var dv=new A,aM=new kn,Lh={type:"lookAt",normal:new A,raycaster:new Ns},ql;(t=>{function r(n){if(n.type===9&&n.distance)return{type:"lookAt",distance:n.distance}}t.create=r;function e({target:n,normal:i,raycaster:s,begin:o,change:a}){if(!n?.interaction?.events.lookAt?.length||!i||!s)return;o&&o("lookAt",n.uuid);let l=n.interaction.events.lookAt[0].distance;aM.set(i,-l),s.ray.intersectPlane(aM,dv),n.lookAt(dv),n.updateMatrix(),n.interaction.animation?.finished.then(()=>{n.lookAt(dv),n.updateMatrix(),Ut(n)&&bt(n.parent)&&n.invalidateDownstreamBooleanData(!0)}),Ut(n)&&bt(n.parent)&&n.invalidateDownstreamBooleanData(!0),a&&a()}t.listener=e})(ql||(ql={}));var fv={type:"start"},Xl;(t=>{function r(n){if(n.type===7)return{type:"start",targets:[]}}t.create=r;function e({target:n,begin:i,change:s}){if(!n?.interaction?.events.start?.length)return;i&&i("start",n.uuid);let o={change:s};n.interaction.events.start.forEach(a=>{a.targets.forEach(({object:l,state:c,params:h})=>l.interaction?.animate(c,h,o))})}t.listener=e})(Xl||(Xl={}));var Qf={type:"scroll"},Yl;(t=>{function r(n){if(!(n.type!==11||n.steps===void 0))return{type:"scroll",targets:[],steps:n.steps}}t.create=r;function e({target:n,deltaY:i,begin:s,change:o}){if(!n?.interaction?.events.scroll?.length||!i)return;s&&s("scroll",n.uuid);let a={change:o},l=i>0?1:-1;n.interaction.events.scroll.forEach(c=>{c.targets.forEach(({object:h,state:u,params:d})=>{let f={...d,autoplay:!1};h.interaction?.seek(u,l,c.steps,f,a)})})}t.listener=e})(Yl||(Yl={}));var Kl={type:"mouseHover"},Ql;(t=>{function r(n){if(n.type===2)return{type:"mouseHover",targets:[]}}t.create=r;function e({target:n,begin:i,change:s,enter:o}){if(!n?.interaction?.events.mouseHover?.length||o===void 0)return;i&&i("mouseHover",n.uuid);let a={change:s};o?n.interaction.events.mouseHover.forEach(l=>{l.targets.forEach(({object:c,state:h,params:u})=>{c.interaction?.animate(h,u,a)})}):n.interaction.events.mouseHover.forEach(l=>{l.targets.forEach(({object:c,params:h})=>{let u=c.interaction;u?.fromState!==void 0&&u.animate(u.fromState,h,a)})})}t.listener=e})(Ql||(Ql={}));var Kf={type:"mouseDown"},pv={type:"mouseUp"},Zf={type:"keyDown"},mv={type:"keyUp"},Ji;(t=>{function r(n){let i,s;if(n.type===0)i={type:"mousedown"},s="mouseDown";else if(n.type===1)i={type:"mouseup"},s="mouseUp";else if(n.type===5){if(!n.key)return;i={type:"keydown",key:n.key},s="keyDown"}else if(n.type===6){if(!n.key)return;i={type:"keyup",key:n.key},s="keyUp"}else return;return{type:s,domEvent:i,targets:[],url:n.url??void 0,toggle:n.toggle??!1,enable:!1}}t.create=r;function e({target:n,interactionEvents:i,type:s,begin:o,change:a}){if(!n)return;i||(i=n.interaction?.events[s]),o&&o(s,n.uuid);let l={change:a};i.forEach(c=>{if(c.toggle){c.enable=!c.enable;for(let{object:h,state:u,params:d}of c.targets){let f=h.interaction;if(f!==void 0){let m={...d,cycle:!1,rewind:!1,repeat:!1};c.enable?f.animate(u,m,l):f.fromState!==void 0&&f.animate(f.fromState,m,l)}}}else c.targets.forEach(({object:h,state:u,params:d})=>h.interaction?.animate(u,d,l));c.url&&(Cs?window.location.assign(c.url):window.open(c.url,"_blank"))})}t.listener=e})(Ji||(Ji={}));var Jf;(e=>e.emptyAudio={data:"data:audio/wav;base64,UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA==",name:"Unknown",mimeType:"audio/wav"})(Jf||(Jf={}));var Rr=class{constructor(e){this.type="sound";this.loopsRemaining=0;this.onEnded=()=>{this.loopsRemaining>0&&(this.start(),this.loopsRemaining--)};this.data=e;let t=e.audio??{...Jf.emptyAudio},n=new Blob([t.data]);if(this.url=URL.createObjectURL(n),this.audio=new Audio,this.audio.volume=e.volume,this.audio.addEventListener("ended",this.onEnded),Pw||Cs){let i=document.createElement("source");i.src=this.url,i.type=t.mimeType,this.audio.appendChild(i)}else this.audio.src=this.url}static create(e){if(!(!e.audio||(e.trigger==="keyDown"||e.trigger==="keyUp")&&e.key===void 0))return new Rr(e)}static start(e){e.interaction?.events.sound?.forEach(t=>t.restart())}static startByEvent(e){e.restart()}static stop(e){e.interaction?.events.sound?.forEach(t=>t.stop())}static dispose(e){e.interaction?.events.sound?.forEach(t=>{let n=t;n.stop(),URL.revokeObjectURL(n.url)})}restart(){Cs&&this.audio.play(),this.stop(),this.loopsRemaining=this.data.loop,this.start()}stop(){this.audio.paused||this.audio.pause(),this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0)}start(){this.data.delay>0?(this.timerId&&clearTimeout(this.timerId),this.timerId=window.setTimeout(()=>{this.audio.load(),this.audio.play()},this.data.delay)):(this.audio.load(),this.audio.play())}};function ez(r){let e,{type:t}=r;return t===10?e=jl.create(r):t===0||t===1||t===5||t===6?e=Ji.create(r):t===9?e=ql.create(r):t===2?e=Ql.create(r):t===11?e=Yl.create(r):t===7?e=Xl.create(r):t===12&&(e=Rr.create(r)),e}function lM(r,e,t){let n=[];r.objects.traverse((i,s)=>{let o=e.find(i);if(delete o.interaction,!s.visible&&!bt(o.parent)||s.states===void 0)return;let a=new kf(o,t),l=a.states;l.push(Lo.create(i,s));for(let h of s.states){let u=qc.patch(s,h.data);l.push(Lo.create(h.id,u))}let c=a.events;if(s.events)for(let{data:h}of s.events){let u=ez(h);if(!u)continue;let d=u.type;c[d]?c[d].push(u):c[d]=[u],"targets"in h&&n.push([h,u])}(l.length>0||Object.keys(c).length>0)&&(o.interaction=a)});for(let[i,s]of n)if("targets"in i&&"targets"in s)for(let{data:o}of i.targets){let a=Nl.create(o,e);a&&s.targets.push(a)}}function cM(r,e,t,n,i=!1){if(!i&&e.states.length===0)return;let s=t===null?e:qc.patch(e,e.states.data(t));if(ay(r,s),r instanceof Nt&&s.type==="Mesh"){if(r instanceof Ws?r.buildFromStore(s.geometry):r.updateGeometry({parameters:s.geometry}),r.freeBooleanPointer(),bt(r.parent)&&r.parent.invalidateDownstreamBooleanData().recomputeBoolean(),"material"in s){if(r.material instanceof Array)return;if(typeof s.material!="string"){let a=s.material.layers;for(let l of a){let c=r.material.userData.layers.getLayerByUuid(l.id);hv(l.data,n,c,r.material,l.data)}}}else if("materials"in s){if(!(r.material instanceof Array))return;var o=0;for(let a of s.materials){if(typeof a!="string"){let l=a.layers;for(let c of l){let h=r.material[o].userData.layers.getLayerByUuid(c.id);hv(c.data,n,h,r.material[o],c.data)}}o++}}}else if(s.type==="DirectionalLight")r.fromDirectionalLightState(s,n);else if(s.type==="PointLight")r.fromPointLightState(s,n);else if(s.type==="SpotLight")r.fromSpotLightState(s,n);else if(r instanceof mr&&Ds.is(s.type)){let a=s;r.setZoom("PerspectiveCamera",a.perspective.zoom),r.setZoom("OrthographicCamera",a.orthographic.zoom),r.isUpVectorFlipped=a.isUpVectorFlipped,r.targetOffset=a.targetOffset}}var Lo=class{constructor(e){this.objectState=e;this.uuid=Ge.generateUUID()}static create(e,t){let n=new Lo(t);return n.uuid=e,n}execute(e,t){cM(e,this.objectState,null,t,!0)}};var sr=new Ns,Br=new A,gv={follow:jl.listener,keyDown:Ji.listener,keyUp:Ji.listener,lookAt:ql.listener,mouseDown:Ji.listener,mouseUp:Ji.listener,mouseHover:Ql.listener,scroll:Yl.listener,start:Xl.listener},hM={follow:Ih,keyDown:Zf,keyUp:mv,lookAt:Lh,mouseDown:Kf,mouseUp:pv,mouseHover:Kl,scroll:Qf,start:fv};function tz(r){if(r.style.transform!==""){let e=getComputedStyle(r).getPropertyValue("transform");if(e!=="none"){let t=e.replace("matrix(","").split(",");return{x:parseFloat(t[0]),y:parseFloat(t[3])}}}return{x:1,y:1}}function uM(r){let e=r.getViewport(new qe),t=tz(r.domElement);return{left:e.x*t.x,top:e.y*t.y,width:e.z*t.x,height:e.w*t.y}}function nz(r,e){return r.distance-e.distance}function dM(r,e,t){if(Us(e)&&e.visible&&!e.raycastLock)e.raycast(r,t);else return;for(let n of e.children)dM(r,n,t)}function yv(r,e,t){if(!t.some(i=>$f(sr,i)!==void 0))return[];let n=[];return e.children.forEach(i=>dM(r,i,n)),n.sort(nz),n}function vv(r,e){let t=[];if(r.length){let n=r[0].object;Us(n)&&n.interaction?.events[e]?.length&&t.push(n);let i=n.parent;for(;i;)oy(i)&&i.interaction?.events[e]?.length&&t.push(i),i=i.parent}return t}function $f(r,e){if(Ut(e)){if(!e.raycastLock&&e.visible){let t=[];return e.raycast(r,t),t.length?t[0]:void 0}}else if(oy(e))return fM(r,e)}function fM(r,e){if(Ut(e)&&!e.raycastLock&&e.visible){let t=[];if(e.raycast(r,t),t.length)return t[0]}for(let t of e.children)if(Us(t)){let n=fM(r,t);if(n)return n}}var ep=class{constructor(e,t,n,i,s){this.stopRaycast=i;this.isEnable=!1;this.splineEvents={};this._map={};this._mapSound={};this._prevObjects=[];this._onMouseDown=e=>{sr.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(Br),Br.negate(),this._handleMouseDownEvent(e)};this._onMouseUp=e=>{sr.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(Br),Br.negate(),this._handleMouseUpEvent(e)};this._onMouseMove=e=>{sr.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(Br),Br.negate(),this._handleMouseHoverEvent(e),this._handleLookAtEvent(e),this._handleFollowEvent(e)};this._onTouchStart=e=>{e.touches.length===1&&(sr.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(Br),Br.negate(),this._handleMouseDownEvent(e),this._handleMouseHoverEvent(e),this._handleLookAtEvent(e),this._handleFollowEvent(e))};this._onTouchEnd=e=>{this._handleMouseUpEvent(e),this._handleMouseHoverEvent(e,!0)};this._onTouchMove=e=>{e.touches.length===1&&(sr.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(Br),Br.negate(),this._handleMouseHoverEvent(e),this._handleLookAtEvent(e),this._handleFollowEvent(e))};this._onWheel=e=>{this._handleWheelEvent(e)};this._onKeyDown=e=>{this._handleKeyDownEvent(e)};this._onKeyUp=e=>{this._handleKeyUpEvent(e)};this._renderer=e,this._domElement=e.domElement,this._camera=n,this._scene=t,this._app=s,this._domRect=this._domElement.getBoundingClientRect(),this._viewRect=uM(e)}activate(){this.isEnable=!0,this._map={},this._mapSound={},this._scene.traverseEntity(e=>{e.interaction!==void 0&&(e.interaction.start(),Object.keys(e.interaction.events).forEach(t=>{let n=t;this._addDOMCustomEvent(n,e),(e.visible||n!=="mouseDown"&&n!=="mouseUp"&&n!=="mouseHover"&&n!=="sound")&&this._addSPEEvent(n,e),e.visible&&n==="sound"&&e.interaction?.events.sound?.forEach(i=>{let s=i.data.trigger;this._mapSound[s]===void 0?this._mapSound[s]=[e]:this._mapSound[s].push(e)})}))}),yd?((this._map.mouseDown?.length||this._map.mouseHover?.length||this._map.lookAt?.length||this._map.follow?.length||this._mapSound.mouseDown?.length)&&this._domElement.addEventListener("touchstart",this._onTouchStart),(this._map.mouseUp?.length||this._map.mouseHover?.length||this._mapSound.mouseUp?.length)&&this._domElement.addEventListener("touchend",this._onTouchEnd),(this._map.mouseHover?.length||this._map.lookAt?.length||this._map.follow?.length)&&this._domElement.addEventListener("touchmove",this._onTouchMove)):((this._map.mouseDown?.length||this._mapSound.mouseDown?.length)&&this._domElement.addEventListener("pointerdown",this._onMouseDown),(this._map.mouseUp?.length||this._mapSound.mouseUp?.length)&&this._domElement.addEventListener("pointerup",this._onMouseUp),(this._map.mouseHover?.length||this._map.lookAt?.length||this._map.follow?.length)&&this._domElement.addEventListener("pointermove",this._onMouseMove)),this._map.scroll?.length&&this._domElement.addEventListener("wheel",this._onWheel),(this._map.keyDown?.length||this._mapSound.keyDown?.length)&&document.addEventListener("keydown",this._onKeyDown),(this._map.keyUp?.length||this._mapSound.keyUp?.length)&&document.addEventListener("keyup",this._onKeyUp),this._handleStartEvent(),this.resize()}deactivate(){this._scene.traverseEntity(e=>{if(!e.interaction)return;e.interaction.end(),Rr.dispose(e);let t=e;Object.keys(gv).forEach(n=>{let i=n;t.removeEventListener(i,gv[i])})}),this._domElement.removeEventListener("pointerdown",this._onMouseDown),this._domElement.removeEventListener("pointerup",this._onMouseUp),this._domElement.removeEventListener("pointermove",this._onMouseMove),this._domElement.removeEventListener("touchstart",this._onTouchStart),this._domElement.removeEventListener("touchend",this._onTouchEnd),this._domElement.removeEventListener("touchmove",this._onTouchMove),this._domElement.removeEventListener("wheel",this._onWheel),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keyup",this._onKeyUp),this._map={},this._mapSound={},this.isEnable=!1}reset(){this._scene.traverseEntity(e=>{e.interaction?.start()}),this._handleStartEvent()}resize(){this._domRect=this._domElement.getBoundingClientRect(),this._viewRect=uM(this._renderer)}_getPointer(e,t){let n=this._domRect,i=this._viewRect,s=n.height-i.height,o=(e-i.left-n.left)*(n.width/i.width),a=(t-s+i.top-n.top)*(n.height/i.height);return{x:o/n.width*2-1,y:-(a/n.height)*2+1}}_handleStartEvent(){this._map.start?.forEach(e=>{e.dispatchEvent(fv)}),Object.keys(this._mapSound).forEach(e=>{this._mapSound[e]?.forEach(t=>{Rr.stop(t)})})}_handleWheelEvent(e){this._map.scroll?.length&&(Qf.deltaY=e.deltaY,this._map.scroll.forEach(t=>{t.dispatchEvent(Qf)}))}_handleMouseEvent(e){if(this.stopRaycast){let t=this._map[e];if(t?.length){let n=yv(sr,this._scene,t);vv(n,e).forEach(i=>i.dispatchEvent(e==="mouseDown"?Kf:pv))}if(t=this._mapSound[e],t?.length){let n=yv(sr,this._scene,t);vv(n,"sound").forEach(i=>{i.interaction?.events.sound?.some(s=>s.data.trigger===e)&&Rr.start(i)})}}else this._map[e]?.forEach(t=>{$f(sr,t)&&t.dispatchEvent(Kf)}),this._mapSound[e]?.forEach(t=>{$f(sr,t)&&Rr.start(t)})}_handleMouseDownEvent(e){this._handleMouseEvent("mouseDown")}_handleMouseUpEvent(e){this._handleMouseEvent("mouseUp")}_handleMouseHoverEvent(e,t=!1){let n=[];if(!t)if(this.stopRaycast){if(this._map.mouseHover?.length){let i=yv(sr,this._scene,this._map.mouseHover);n=vv(i,"mouseHover")}}else this._map.mouseHover?.forEach(i=>{$f(sr,i)&&n.push(i)});this._prevObjects.length&&(Kl.enter=!1,this._prevObjects.forEach(i=>{n.includes(i)||i.dispatchEvent(Kl)})),n.length&&(Kl.enter=!0,n.forEach(i=>{i.dispatchEvent(Kl)})),this._prevObjects=n}_handleLookAtEvent(e){this._map.lookAt?.length&&(Lh.normal=Br,Lh.raycaster=sr,this._map.lookAt.forEach(t=>{t.dispatchEvent(Lh)}))}_handleFollowEvent(e){this._map.follow&&(Ih.normal=Br,Ih.raycaster=sr,this._map.follow.forEach(t=>t.dispatchEvent(Ih)))}_handleKeyEvent(e,t,n){this._map[t]?.forEach(i=>{Zf.interactionEvents=i.interaction?.events?.keyDown?.filter(s=>s.domEvent.type===n&&s.domEvent.key===e.key),i.dispatchEvent(t==="keyDown"?Zf:mv)}),this._mapSound[t]?.forEach(i=>{i.interaction?.events?.sound?.forEach(s=>{s.data.trigger===t&&s.data.key===e.key&&Rr.startByEvent(s)})})}_handleKeyDownEvent(e){this._handleKeyEvent(e,"keyDown","keydown")}_handleKeyUpEvent(e){this._handleKeyEvent(e,"keyUp","keyup")}_addSPEEvent(e,t){!t.interaction||e!=="sound"&&(hM[e].begin=this._dispatchDOMCustomEvent.bind(this),hM[e].change=this._app.requestRender.bind(this),t.interaction.events[e]?.length&&(t.addEventListener(e,gv[e]),this._map[e]===void 0?this._map[e]=[t]:this._map[e].push(t)))}_addDOMCustomEvent(e,t){if(e){let n=new CustomEvent(e,{bubbles:!0});Object.defineProperty(n,"target",{writable:!1,value:{id:t.uuid,name:t.name}}),this.splineEvents[e]?this.splineEvents[e][t.uuid]=n:this.splineEvents[e]={[t.uuid]:n}}}_dispatchDOMCustomEvent(e,t){let n=this.splineEvents[e]?.[t];n&&this._domElement.dispatchEvent(n)}};var tp=class{constructor(e,t,n,i,s){this._aspect=1;this._renderer=e,this._camera=t,this._frameSize=new B().copy(n),this._editorSize=new B().copy(i),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y,!1)}updateViewportForImageExport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y;this._aspect=e/t,this._camera.zoom*=Math.min(n/e,i/t),this._renderer.setViewport(0,0,e,t)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y,s=0,o=0,a=e,l=t;e<n&&(s=(n-e)*.5,s=-s,a=n),t<i&&(o=(i-t)*.5,o=-o,l=i),this._aspect=a/l,this._renderer.setViewport(s,o,a,l)}updateCamera(){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,t=this._editorSize.y,n=this._fov;if(e>t){let i=rz(e,1080,2160,1,15)/100;n*=e/t,n*=1-i}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t,!1)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function rz(r,e,t,n,i){return(r-e)/(t-e)*(i-n)+n}var np=class{constructor(e){this.sharedAssets=new Vf(e.shared),this.scene=new Yf(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(this.sharedAssets),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose()}};var rp=class{constructor({x:e=10,y:t=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let t=performance.now()-this._startTime;this.element.innerHTML=t.toFixed(3)+" ms"}};function iz(r){let e;if(!!r.index)for(let t=0;t<r.index.array.length;t+=3)e=r.index.array[t],r.index.array[t]=r.index.array[t+2],r.index.array[t+2]=e}function xv(r){return r==="SubdivObject"||r==="NonParametric"?r:"Mesh"}function sz(r,e){let t={};return r.traverseEntity(n=>{if(n.type!=="Mesh"||!("material"in n)||!n.visible||!(n instanceof Nt)||Array.isArray(n.material)||n&&n.interaction&&n.interaction.states.length>0)return;let i=n.parent;for(;i;){if(i instanceof Nt&&i.interaction&&i.interaction.states.length>1)return;i=i.parent}let s=n.material.uuid,o=e.shared.materials[s];if(o){if(!qr.isMergable(o))return}else{let c=e.scene.objects.get(n.uuid)?.data;if(c&&"material"in c&&typeof c.material!="string"){if(!qr.isMergable(c.material))return;s=qr.getHash(c.material)}}t[s]||(t[s]={});let l=t[s][xv(n.objectType)];if(l){if(l.push(n),n.cloner)for(let c of n.cloner.children)l.push(c)}else if(t[s][xv(n.objectType)]=[n],n.cloner)for(let c of n.cloner.children)t[s][xv(n.objectType)].push(c)}),t}function oz(r){let e=0;return Object.values(r).forEach(t=>{Object.values(t).forEach(n=>{let i=n.length;i>e&&(e=i)})}),e}function pM(r,e){let t=sz(e,r),n=oz(t),i=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),c=0,h=new Array(n),u=0;for(let d of Object.values(t))for(let f of Object.values(d)){if(a=0,c=0,f.forEach(p=>{p instanceof Nt&&(o[a++]=p.geometry.clone(),l[c++]=p)}),c<2)continue;for(let p=0;p<c;p++)l[p].updateWorldMatrix(!0,!1),o[p].applyMatrix4(l[p].matrixWorld),l[p].matrixWorld.determinant()<0&&iz(o[p]);let m=uS(o.slice(0,a),!1);if(m){let p;switch(f[0].objectType){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),p=new Vt(m,l[0].material);break}default:{p=new Vt(m,l[0].material);break}}p.castShadow=l[0].castShadow,p.receiveShadow=l[0].receiveShadow,e.add(p);let g=x=>{u=0;for(let v of x)v.children&&g(v.children),v instanceof Nt&&(Array.isArray(v.material)||t[v.material.uuid]&&t[v.material.uuid][v.objectType]&&t[v.material.uuid][v.objectType].length>1||(h[u++]=v));for(let v=0;v<u;v++)e.attach(h[v])};for(let x=0;x<c;x++){let v=l[x];g(v.children),i[s++]=v}}}for(let d=0;d<s;d++)i[d].removeFromParent()}var az=new B,mM="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.",gM=class{constructor(e,{autoRender:t=!1}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._skipRender=!0;this.autoRender=!1;this.disposed=!1;this.requestRender=()=>{this._skipRender=!1};this.render=()=>{!this._renderer||(this._rafId=requestAnimationFrame(this.render),this._perfs?.start(),!(!this.autoRender&&this._skipRender)&&(this._controls&&(this._controls.enableDamping||this._controls.autoRotate)?this._skipRender=!this._controls.update():this._skipRender=!0,this._playmode&&!this._playmode.isEnable&&this._playmode.activate(),this._scene&&this._camera&&(this._renderer.autoClear=!1,this._normalRenderTarget&&(this._renderer.setClearColor(0),this._renderer.setClearAlpha(0),this._camera.layers.enable(8),this._camera.layers.disable(0),this._camera.layers.disable(3),this._renderer.setRenderTarget(this._normalRenderTarget),this._renderer.clear(),this._scene.overrideMaterial=this._normalMaterial,this._renderer.render(this._scene,this._camera),this._renderer.setClearColor(this._scene.bgColor,this._scene.alpha),this._renderer.setRenderTarget(null),this._scene.overrideMaterial=null,this._camera.layers.enable(0),this._camera.layers.enable(3)),this._transmissionRenderTarget&&(this._renderer.setRenderTarget(this._transmissionRenderTarget),this._renderer.clear(),this._camera.layers.enable(0),this._camera.layers.disable(3),this._renderer.render(this._scene,this._camera),this._renderer.setRenderTarget(null),this._camera.layers.enable(3)),this._renderer.autoClear=!1,this._scene.postprocessing.render()),this._perfs?.end()))};this.resize=Nc(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=az.set(this._viewportWidth,this._viewportHeight)),this._frameView?.updateRenderer(),this._scene?.postprocessing&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight,!1),this._sharedAssetsManager?.resolutionNode.value.set(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio),this._normalRenderTarget?.setSize(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio),this._transmissionRenderTarget?.setSize(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio),this._viewportMode!==1&&this._frameView?.updateViewport(),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&this._viewportMode===1&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this._playmode?.resize(),this.requestRender())},10);this.canvas=e,this.autoRender=t,Ay(),window.location.search.includes("perfs")&&(this._perfs=new rp({x:10,y:10}))}async load(e){e.endsWith(".spline")?console.warn(mM+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(mM);let n=await(await fetch(e)).arrayBuffer();await this.start(n)}async start(e){if(this.disposed)return;let t=await Q1(e);Iy(t)&&await G1();let n=new np(t);if(window.location.search.includes("merge-geometries")){let d=performance.now();pM(t,n.scene);let f=performance.now();console.log("Merged geometries in ",f-d," ms")}this._scene=n.scene,Iy(t)&&this._scene.traverse(d=>{bt(d)&&d.recomputeBoolean()}),this._sharedAssetsManager=n.sharedAssets,this._sharedAssetsManager.onImageLoad=()=>{this.requestRender()},lM(t.scene,this._scene,this._sharedAssetsManager),this._camera=this._scene.activeCamera;let i=Object.values(t.frames)[0],s,o;if(i)if(i.preset==="fullscreen"){this._viewportMode=1;let{width:d,height:f}=window.getComputedStyle(this.canvas);this.canvas.parentElement&&(d==="300px"||d==="auto")?(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%",s=this.canvas.style.width):this._viewportWidth=this.canvas.clientWidth,this.canvas.parentElement&&(f==="150px"||f==="auto")?(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%",o=this.canvas.style.height):this._viewportHeight=this.canvas.clientHeight}else this._viewportMode=2,this._viewportWidth=i.size[0],this._viewportHeight=i.size[1],s=this._viewportWidth+"px",o=this._viewportHeight+"px";this._renderer=new Wm({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._scene.postprocessing.init({renderer:this._renderer,camera:this._camera,scene:this._scene}),this._scene.postprocessing.addEventListener("smaaloaded",this.requestRender),s&&(this.canvas.style.width=s),o&&(this.canvas.style.height=o),this._scene.needsTransmission(void 0)&&(this._transmissionRenderTarget=new lt(2048,2048,{generateMipmaps:!0,minFilter:xs,magFilter:tt,wrapS:bn,wrapT:bn}),this._transmissionRenderTarget.depthTexture=new wr(2048,2048),this._scene.needsTransmission(this._transmissionRenderTarget)),this._scene.needsNormal(void 0)&&(this._normalRenderTarget=new lt(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio,{generateMipmaps:!1,minFilter:Gt,magFilter:Gt,type:vr}),this._normalMaterial=M1,this._normalRenderTarget.depthTexture=new wr(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio),this._scene.needsNormal(this._normalRenderTarget)),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._scene.postprocessing&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight,!1),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=t.scene.environment.ambientLight.softShadows?Bu:km,A1(t.scene.environment.ambientLight.softShadowQuality),this._renderer.setClearColor(this._scene.bgColor,this._scene.alpha),this._frameView=new tp(this._renderer,this._camera,new B(this._viewportWidth,this._viewportHeight),new B(window.innerWidth,window.innerHeight)),this._publishData=t.scene.publish;let{enableRotate:a,enablePan:l,enableZoom:c,autoRotate:h,hoverRotatePanMode:u}=this._publishData.orbitControls;if((a||l||c||h||u!==0)&&(this._camera.interaction===void 0||this._camera.interaction.states.length<=1)&&(this._controls=new Xd(this._camera,this._renderer.domElement),this._controls.fromJSON(this._publishData.orbitControls),this._controls.useKeyEvents=!1,this._controls.addEventListener("change",this.requestRender),this._controls.addEventListener("start",this.requestRender)),this._playmode=new ep(this._renderer,this._scene,this._camera,this._publishData.stopRaycast,this),this._sharedAssetsManager.resolutionNode.value.set(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio),this._sharedAssetsManager.pixelRatioNode.value=window.devicePixelRatio,this.resize(),this.render(),this.canvas.parentElement){let d=!0;this._resizeObserver=new ResizeObserver(()=>{if(d){d=!1;return}this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this.resize()}),this._resizeObserver.observe(this.canvas.parentElement)}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getSplineEvents(){return this._playmode?.splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this._renderer?.domElement.addEventListener(e,t)}removeEventListener(e,t){this._renderer?.domElement.removeEventListener(e,t)}setZoom(e){this._controls?.zoomOut(e)}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this.resize()}dispose(){this.disposed=!0,this._playmode?.deactivate(),this._scene?.dispose(),this._rafId&&cancelAnimationFrame(this._rafId),this._proxyObjectCache.forEach(e=>{rg.unsubscribe(e)}),this._renderer?.dispose(),this._transmissionRenderTarget?.dispose(),this._transmissionRenderTarget?.depthTexture?.dispose(),this._normalRenderTarget?.dispose(),this._normalRenderTarget?.depthTexture?.dispose(),this._sharedAssetsManager?.dispose(),this._resizeObserver&&this._resizeObserver.disconnect(),this.canvas.style.width="",this.canvas.style.height=""}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let{requestRender:t}=this,n={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(s){e.interaction?.emitEvent(s,t)},emitEventReverse(s){e.interaction?.emitEventReverse(s,t)}},i=rg(n,(s,o)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=o),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};export{gM as Application};
|
|
5181
|
+
outputColor=vec4(color,inputColor.a);}`,jf={DEFAULT:0,ESKIL:1},rM=class extends Di{constructor({blendFunction:r=at.NORMAL,technique:e=jf.DEFAULT,eskil:t=!1,offset:n=.5,darkness:i=.5}={}){super("VignetteEffect",ZU,{blendFunction:r,defines:new Map([["VIGNETTE_TECHNIQUE",e.toFixed(0)]]),uniforms:new Map([["offset",new we(n)],["darkness",new we(i)]])})}get technique(){return Number(this.defines.get("VIGNETTE_TECHNIQUE"))}set technique(r){this.technique!==r&&(this.defines.set("VIGNETTE_TECHNIQUE",r.toFixed(0)),this.setChanged())}get eskil(){return this.technique===jf.ESKIL}set eskil(r){this.technique=r?jf.ESKIL:jf.DEFAULT}getTechnique(){return this.technique}setTechnique(r){this.technique=r}get offset(){return this.uniforms.get("offset").value}set offset(r){this.uniforms.get("offset").value=r}getOffset(){return this.offset}setOffset(r){this.offset=r}get darkness(){return this.uniforms.get("darkness").value}set darkness(r){this.uniforms.get("darkness").value=r}getDarkness(){return this.darkness}setDarkness(r){this.darkness=r}},xae=[new Float32Array(3),new Float32Array(3)],bae=[new Float32Array(3),new Float32Array(3),new Float32Array(3),new Float32Array(3)],wae=[[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([1,0,0]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([1,0,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([1,1,0]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,1,0]),new Float32Array([0,1,1]),new Float32Array([1,1,1])],[new Float32Array([0,0,0]),new Float32Array([0,0,1]),new Float32Array([0,1,1]),new Float32Array([1,1,1])]];var Sae=[new Float32Array(2),new Float32Array(2)];var Aae=new Float32Array([0,-.25,.25,-.125,.125,-.375,.375]),Mae=[new Float32Array([0,0]),new Float32Array([.25,-.25]),new Float32Array([-.25,.25]),new Float32Array([.125,-.125]),new Float32Array([-.125,.125])],_ae=[new Uint8Array([0,0]),new Uint8Array([3,0]),new Uint8Array([0,3]),new Uint8Array([3,3]),new Uint8Array([1,0]),new Uint8Array([4,0]),new Uint8Array([1,3]),new Uint8Array([4,3]),new Uint8Array([0,1]),new Uint8Array([3,1]),new Uint8Array([0,4]),new Uint8Array([3,4]),new Uint8Array([1,1]),new Uint8Array([4,1]),new Uint8Array([1,4]),new Uint8Array([4,4])],Tae=[new Uint8Array([0,0]),new Uint8Array([1,0]),new Uint8Array([0,2]),new Uint8Array([1,2]),new Uint8Array([2,0]),new Uint8Array([3,0]),new Uint8Array([2,2]),new Uint8Array([3,2]),new Uint8Array([0,1]),new Uint8Array([1,1]),new Uint8Array([0,3]),new Uint8Array([1,3]),new Uint8Array([2,1]),new Uint8Array([3,1]),new Uint8Array([2,3]),new Uint8Array([3,3])];var Eae=new Map([[Un(0,0,0,0),new Float32Array([0,0,0,0])],[Un(0,0,0,1),new Float32Array([0,0,0,1])],[Un(0,0,1,0),new Float32Array([0,0,1,0])],[Un(0,0,1,1),new Float32Array([0,0,1,1])],[Un(0,1,0,0),new Float32Array([0,1,0,0])],[Un(0,1,0,1),new Float32Array([0,1,0,1])],[Un(0,1,1,0),new Float32Array([0,1,1,0])],[Un(0,1,1,1),new Float32Array([0,1,1,1])],[Un(1,0,0,0),new Float32Array([1,0,0,0])],[Un(1,0,0,1),new Float32Array([1,0,0,1])],[Un(1,0,1,0),new Float32Array([1,0,1,0])],[Un(1,0,1,1),new Float32Array([1,0,1,1])],[Un(1,1,0,0),new Float32Array([1,1,0,0])],[Un(1,1,0,1),new Float32Array([1,1,0,1])],[Un(1,1,1,0),new Float32Array([1,1,1,0])],[Un(1,1,1,1),new Float32Array([1,1,1,1])]]);function iv(r,e,t){return r+(e-r)*t}function Un(r,e,t,n){let i=iv(r,e,.75),s=iv(t,n,1-.25);return iv(i,s,1-.125)}var tn=class{constructor(e,t){this.enabled=!1;this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(n){this.effect.blendMode.opacity.value=n},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(n){this.effect.blendMode.setBlendFunction(Number(n))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=at.NORMAL}toJSON(){let e=["constructor","effect","subscriptions"],t={...this},n=Object.getPrototypeOf(this),i=Object.getOwnPropertyNames(n);for(let s of i){let o=Object.getOwnPropertyDescriptor(n,s);o&&typeof o.get=="function"&&(t[s]=this[s])}return e.forEach(s=>delete t[s]),t}};var Ol=class extends tn{constructor(){super(YA),this.blendFunction=at.SCREEN}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}};var Fl=class extends tn{constructor(){super(QA)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}};var Ul=class extends tn{constructor(){super(ZA),this.effect.offset=new B(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}};var zl=class extends tn{constructor(){super(KA)}};var Gl=class extends tn{constructor(){super($A);this._hue=0}set hue(t){this._hue=t,this.effect.setHue(t)}get hue(){return this._hue}set saturation(t){this.effect.uniforms.get("saturation").value=t}get saturation(){return this.effect.uniforms.get("saturation").value}};var kl=class extends tn{constructor(){super(eM),this.blendFunction=at.OVERLAY}};var Vl=class extends tn{constructor(){super(rM)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}};var Hl=class extends tn{constructor(e){super(JA,e)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=e}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}};var Wl=class extends tn{constructor(){super(tM)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}};function iM(r,e){return e&&e.enabled&&r.push(e.effect),r}var Ph=class extends Rt{constructor(){super();this._scene=new Wn;this._camera=new mr;this.sceneHelpers=new Wn;this.sceneHelpersOnTop=new Wn;this.uiHandler=null;this.overmind=null;this.effects=new Map;this.loadingManager=new uo;this.renderPass=new Lo;this.helperPass=new Lo;this.helperPassOnTop=new Lo;this._renderToScreen=!0;this._hasSmaa=!1;this.clock=new Tu,this.enabled=!1,this.debug=!1,this.effects.set("bloom",new Ol),this.effects.set("chromaticAberration",new Ul),this.effects.set("vignette",new Vl),this.effects.set("noise",new kl),this.effects.set("colorAverage",new zl),this.effects.set("hueSaturation",new Gl),this.effects.set("brightnessContrast",new Fl),this.effects.set("depthOfField",new Hl),this.effects.set("pixelation",new Wl)}get scene(){return this._scene}set scene(t){this._scene=t}get camera(){return this._camera}set camera(t){this._camera=t}_initSmaa(){if(!this.effectComposer)return;let t=this.effectComposer.passes.length,n=new nM({preset:Po.ULTRA,edgeDetectionMode:qf.COLOR}),i=()=>{n.removeEventListener("load",i),this.dispatchEvent({type:"smaaloaded"})};n.addEventListener("load",i),n.edgeDetectionMaterial.predicationMode=av.DEPTH,n.edgeDetectionMaterial.edgeDetectionThreshold=.05,n.edgeDetectionMaterial.predicationThreshold=.002,n.edgeDetectionMaterial.predicationScale=1,this.effectComposer.addPass(new Xf(this.camera,n),t),this._hasSmaa=!0}_initPasses(){if(!this.effectComposer||!this.renderer)return;let t;if(this.effectComposer.removeAllPasses(),this._hasSmaa=!1,this.renderPass=new Lo(this.scene,this.camera),this.helperPass=new Lo(this.sceneHelpers,this.camera),this.helperPassOnTop=new Lo(this.sceneHelpersOnTop,this.camera),this.enabled){this.effectComposer.addPass(this.renderPass);let n=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(iM,[]),i=[this.effects.get("pixelation")].reduce(iM,[]);i.length>0&&this.effectComposer.addPass(new Xf(this.camera,...i)),this.effectComposer.addPass(new Xf(this.camera,...n)),(!this.uiHandler||this.uiHandler.state!==this.uiHandler.STATE.PLAY&&this.uiHandler.state!==this.uiHandler.STATE.FRAME&&this.uiHandler.state!==this.uiHandler.STATE.COLOR&&!this.overmind.state.editor.recording)&&(this.helperPass.clear=!1,this.helperPassOnTop.clear=!1,this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(new Bl(!1,!0,!1)),this.effectComposer.addPass(this.helperPassOnTop))}else this.effectComposer.addPass(this.renderPass),(!this.uiHandler||this.uiHandler.state!==this.uiHandler.STATE.PLAY&&this.uiHandler.state!==this.uiHandler.STATE.FRAME&&this.uiHandler.state!==this.uiHandler.STATE.COLOR&&!this.overmind.state.editor.recording)&&(this.helperPass.clear=!1,this.helperPassOnTop.clear=!1,this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(new Bl(!1,!0,!1)),this.effectComposer.addPass(this.helperPassOnTop));if(this._initSmaa(),t)return t}reinit(){if(!this.renderer)return Promise.all([]);this.effectComposer=new XA(this.renderer),this._initPasses()}init({renderer:t,camera:n,scene:i,sceneHelpers:s,sceneHelpersOnTop:o,uiHandler:a,overmind:l}){this.renderer=t,this.scene=i,this.sceneHelpers=s,this.sceneHelpersOnTop=o,this.camera=n,this.uiHandler=a,this.overmind=l,this._initCopyPass(),this.reinit()}_initCopyPass(){if(this._savePass)return;let t=new B;this.renderer.getDrawingBufferSize(t),this._rt=new lt(t.x,t.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:ta,wrapT:ta}),this._rt.samples=0,this._savePass=new lv(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(t){let n=this.effectComposer;!n||(t===!0?(n.removePass(this._savePass),n.passes[n.passes.length-1].renderToScreen=!0,n.autoRenderToScreen=!0):(n.autoRenderToScreen=!1,n.passes[n.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.enabled||(this._savePass.needsDepthTexture=!0),n.addPass(this._savePass)),this._renderToScreen=t)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}fromJSON(t){t&&(Object.keys(t).forEach(n=>{let i=t[n],s=this.effects.get(n);Object.keys(i).forEach(o=>{s[o]=i[o]})}),this.enabled=t.enabled)}toJSON(){let t={};return this.effects.forEach((n,i)=>{t[i]=n.toJSON()},t),{enabled:this.enabled,...t}}render(){this.effectComposer?.render(this.clock.getDelta())}setScissor(t,n,i,s){if(!this.effectComposer||!this.renderer)return;t instanceof qe?(this.effectComposer.inputBuffer.scissor.set(t.x,t.y,t.z,t.w),this.effectComposer.outputBuffer.scissor.set(t.x,t.y,t.z,t.w)):(this.effectComposer.inputBuffer.scissor.set(t,n,i,s),this.effectComposer.outputBuffer.scissor.set(t,n,i,s));let o=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(o),this.effectComposer.outputBuffer.scissor.multiplyScalar(o),this.renderer.setScissor(t,n,i,s)}setScissorTest(t){!this.effectComposer||!this.renderer||(this.effectComposer.inputBuffer.scissorTest=t,this.effectComposer.outputBuffer.scissorTest=t,this.renderer.setScissorTest(t))}setViewport(t,n,i,s){!this.effectComposer||(t instanceof qe?(this.effectComposer.inputBuffer.viewport.copy(t),this.effectComposer.outputBuffer.viewport.copy(t)):(this.effectComposer.inputBuffer.viewport.set(t,n,i,s),this.effectComposer.outputBuffer.viewport.set(t,n,i,s)))}resize(t,n,i){if(this.effectComposer?.setSize(t,n,i),this._rt){let s=this.renderer?.getPixelRatio()||window.devicePixelRatio;this._rt.setSize(t*s,n*s)}}dispose(){this._listeners=void 0,this.effectComposer?.dispose()}};var Yf=class extends Ch{constructor(t,n){super(t,n);this.postprocessing=new Ph;this.initPostprocessing(t.postprocessing)}resetAfterClear(t,n){super.resetAfterClear(t,n),this.initPostprocessing(t.postprocessing)}initPostprocessing(t){let{enabled:n,...i}=t;for(let s of Object.entries(i)){let o=s[1],a=this.postprocessing.effects.get(s[0]);if(a){a.enabled=o.enabled;for(let[l,c]of Object.entries(o))a[l]=c}}this.postprocessing.enabled=n,this.postprocessing.reinit()}dispose(){super.dispose(),this.postprocessing.dispose()}switchActiveCamera(t){super.switchActiveCamera(t),this.postprocessing&&(this.postprocessing.camera=t)}};function $U(r,e){switch(r.type){case"noise":return e==="noiseType";case"texture":return e==="projection"||e==="axis"||e==="side";case"displace":return e==="noiseType";case"depth":return e==="num"||e==="smooth"||e==="isWorldSpace"||e==="gradientType"||e==="isVector";default:return!1}}function hv(r,e,t,n,i){let s=!1;for(let[o,a]of Object.entries(r)){if(!o||a===void 0||Mf(o,t,i))continue;t.visible=i.visible;let l=t.uniforms[`f${t.id}_${o}`];if(!!l)switch(l.constructor){case xt:if(typeof a=="string"){let c=e.getColor(a);c&&(l.value=c);break}else{let c=a;l.value instanceof Do?l.value=new Ln(c.r,c.g,c.b,c.a):l.setRGBA(c);break}case Pr:if(typeof a=="string"){let c=e.getColor(a);c&&(l.value=c);break}else{let c=a;l.value instanceof Do?l.value=new Ln(c.r,c.g,c.b,c.a):l.value.setRGBA(c.r,c.g,c.b,c.a);break}case mn:{let c=a;l.value.setX(c[0]),l.value.setY(c[1]);break}case Tn:{let c=a;l.value.setX(c[0]),l.value.setY(c[1]),l.value.setZ(c[2]);break}case vn:{let c=a;if("image"in c){let h=c.image;if(typeof h=="string"){let u=e.getImage(h);u&&(l.value.image=u)}else{let u=new Image;u.src=Gs(h.data),l.value.image=u}}"wrapping"in c&&(l.value.wrapS=l.value.wrapT=c.wrapping),"repeat"in c&&l.value.repeat.fromArray(c.repeat),"offset"in c&&l.value.offset.fromArray(c.offset),l.value.needsUpdate=!0;break}case Yr:{a.forEach((c,h)=>{l.value[h].setX(c[0]),l.value[h].setY(c[1]),l.value[h].setZ(c[2]),l.value[h].setW(c[3])});break}default:{s=s||$U(t,o),l.value=a;break}}}if(s&&i){let o=Af({id:"0",fi:0,data:i},e);n.userData.layers?.changeLayer(t.id,{...o}),n.dispose(),n.needsUpdate=!0}}var uv=new A,sM=new kn,oM=new Oe,Lh={type:"follow",normal:new A,raycaster:new Ns},jl;(t=>{function r(n){if(n.type===10)return{type:"follow"}}t.create=r;function e({target:n,normal:i,raycaster:s,begin:o,change:a}){!n||!i||!s||(o&&o("follow",n.uuid),sM.setFromNormalAndCoplanarPoint(i,n.getWorldPosition(uv)),s.ray.intersectPlane(sM,uv),n.position.copy(uv),n.parent!==null&&n.position.applyMatrix4(oM.copy(n.parent.matrixWorld).invert()),n.position.applyMatrix4(oM.copy(n.hiddenMatrix).invert()),n.updateMatrix(),Ut(n)&&bt(n.parent)&&n.invalidateDownstreamBooleanData(!0),a&&a())}t.listener=e})(jl||(jl={}));var dv=new A,aM=new kn,Ih={type:"lookAt",normal:new A,raycaster:new Ns},ql;(t=>{function r(n){if(n.type===9&&n.distance)return{type:"lookAt",distance:n.distance}}t.create=r;function e({target:n,normal:i,raycaster:s,begin:o,change:a}){if(!n?.interaction?.events.lookAt?.length||!i||!s)return;o&&o("lookAt",n.uuid);let l=n.interaction.events.lookAt[0].distance;aM.set(i,-l),s.ray.intersectPlane(aM,dv),n.lookAt(dv),n.updateMatrix(),n.interaction.animation?.finished.then(()=>{n.lookAt(dv),n.updateMatrix(),Ut(n)&&bt(n.parent)&&n.invalidateDownstreamBooleanData(!0)}),Ut(n)&&bt(n.parent)&&n.invalidateDownstreamBooleanData(!0),a&&a()}t.listener=e})(ql||(ql={}));var fv={type:"start"},Xl;(t=>{function r(n){if(n.type===7)return{type:"start",targets:[]}}t.create=r;function e({target:n,begin:i,change:s}){if(!n?.interaction?.events.start?.length)return;i&&i("start",n.uuid);let o={change:s};n.interaction.events.start.forEach(a=>{a.targets.forEach(({object:l,state:c,params:h})=>l.interaction?.animate(c,h,o))})}t.listener=e})(Xl||(Xl={}));var Qf={type:"scroll"},Yl;(t=>{function r(n){if(!(n.type!==11||n.steps===void 0))return{type:"scroll",targets:[],steps:n.steps}}t.create=r;function e({target:n,deltaY:i,begin:s,change:o}){if(!n?.interaction?.events.scroll?.length||!i)return;s&&s("scroll",n.uuid);let a={change:o},l=i>0?1:-1;n.interaction.events.scroll.forEach(c=>{c.targets.forEach(({object:h,state:u,params:d})=>{let f={...d,autoplay:!1};h.interaction?.seek(u,l,c.steps,f,a)})})}t.listener=e})(Yl||(Yl={}));var Kl={type:"mouseHover"},Ql;(t=>{function r(n){if(n.type===2)return{type:"mouseHover",targets:[]}}t.create=r;function e({target:n,begin:i,change:s,enter:o}){if(!n?.interaction?.events.mouseHover?.length||o===void 0)return;i&&i("mouseHover",n.uuid);let a={change:s};o?n.interaction.events.mouseHover.forEach(l=>{l.targets.forEach(({object:c,state:h,params:u})=>{c.interaction?.animate(h,u,a)})}):n.interaction.events.mouseHover.forEach(l=>{l.targets.forEach(({object:c,params:h})=>{let u=c.interaction;u?.fromState!==void 0&&u.animate(u.fromState,h,a)})})}t.listener=e})(Ql||(Ql={}));var Kf={type:"mouseDown"},pv={type:"mouseUp"},Zf={type:"keyDown"},mv={type:"keyUp"},Ji;(t=>{function r(n){let i,s;if(n.type===0)i={type:"mousedown"},s="mouseDown";else if(n.type===1)i={type:"mouseup"},s="mouseUp";else if(n.type===5){if(!n.key)return;i={type:"keydown",key:n.key},s="keyDown"}else if(n.type===6){if(!n.key)return;i={type:"keyup",key:n.key},s="keyUp"}else return;return{type:s,domEvent:i,targets:[],url:n.url??void 0,toggle:n.toggle??!1,enable:!1}}t.create=r;function e({target:n,interactionEvents:i,type:s,begin:o,change:a}){if(!n)return;i||(i=n.interaction?.events[s]),o&&o(s,n.uuid);let l={change:a};i.forEach(c=>{if(c.toggle){c.enable=!c.enable;for(let{object:h,state:u,params:d}of c.targets){let f=h.interaction;if(f!==void 0){let m={...d,cycle:!1,rewind:!1,repeat:!1};c.enable?f.animate(u,m,l):f.fromState!==void 0&&f.animate(f.fromState,m,l)}}}else c.targets.forEach(({object:h,state:u,params:d})=>h.interaction?.animate(u,d,l));c.url&&(Cs?window.location.assign(c.url):window.open(c.url,"_blank"))})}t.listener=e})(Ji||(Ji={}));var Jf;(e=>e.emptyAudio={data:"data:audio/wav;base64,UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA==",name:"Unknown",mimeType:"audio/wav"})(Jf||(Jf={}));var Rr=class{constructor(e){this.type="sound";this.loopsRemaining=0;this.onEnded=()=>{this.loopsRemaining>0&&(this.start(),this.loopsRemaining--)};this.data=e;let t=e.audio??{...Jf.emptyAudio},n=new Blob([t.data]);if(this.url=URL.createObjectURL(n),this.audio=new Audio,this.audio.volume=e.volume,this.audio.addEventListener("ended",this.onEnded),Pw||Cs){let i=document.createElement("source");i.src=this.url,i.type=t.mimeType,this.audio.appendChild(i)}else this.audio.src=this.url}static create(e){if(!(!e.audio||(e.trigger==="keyDown"||e.trigger==="keyUp")&&e.key===void 0))return new Rr(e)}static start(e){e.interaction?.events.sound?.forEach(t=>t.restart())}static startByEvent(e){e.restart()}static stop(e){e.interaction?.events.sound?.forEach(t=>t.stop())}static dispose(e){e.interaction?.events.sound?.forEach(t=>{let n=t;n.stop(),URL.revokeObjectURL(n.url)})}restart(){Cs&&this.audio.play(),this.stop(),this.loopsRemaining=this.data.loop,this.start()}stop(){this.audio.paused||this.audio.pause(),this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0)}start(){this.data.delay>0?(this.timerId&&clearTimeout(this.timerId),this.timerId=window.setTimeout(()=>{this.audio.load(),this.audio.play()},this.data.delay)):(this.audio.load(),this.audio.play())}};function ez(r){let e,{type:t}=r;return t===10?e=jl.create(r):t===0||t===1||t===5||t===6?e=Ji.create(r):t===9?e=ql.create(r):t===2?e=Ql.create(r):t===11?e=Yl.create(r):t===7?e=Xl.create(r):t===12&&(e=Rr.create(r)),e}function lM(r,e,t){let n=[];r.objects.traverse((i,s)=>{let o=e.find(i);if(delete o.interaction,!s.visible&&!bt(o.parent)||s.states===void 0)return;let a=new kf(o,t),l=a.states;l.push(Io.create(i,s));for(let h of s.states){let u=qc.patch(s,h.data);l.push(Io.create(h.id,u))}let c=a.events;if(s.events)for(let{data:h}of s.events){let u=ez(h);if(!u)continue;let d=u.type;c[d]?c[d].push(u):c[d]=[u],"targets"in h&&n.push([h,u])}(l.length>0||Object.keys(c).length>0)&&(o.interaction=a)});for(let[i,s]of n)if("targets"in i&&"targets"in s)for(let{data:o}of i.targets){let a=Nl.create(o,e);a&&s.targets.push(a)}}function cM(r,e,t,n,i=!1){if(!i&&e.states.length===0)return;let s=t===null?e:qc.patch(e,e.states.data(t));if(ay(r,s),r instanceof Nt&&s.type==="Mesh"){if(r instanceof Ws?r.buildFromStore(s.geometry):r.updateGeometry({parameters:s.geometry}),r.freeBooleanPointer(),bt(r.parent)&&r.parent.invalidateDownstreamBooleanData().recomputeBoolean(),"material"in s){if(r.material instanceof Array)return;if(typeof s.material!="string"){let a=s.material.layers;for(let l of a){let c=r.material.userData.layers.getLayerByUuid(l.id);hv(l.data,n,c,r.material,l.data)}}}else if("materials"in s){if(!(r.material instanceof Array))return;var o=0;for(let a of s.materials){if(typeof a!="string"){let l=a.layers;for(let c of l){let h=r.material[o].userData.layers.getLayerByUuid(c.id);hv(c.data,n,h,r.material[o],c.data)}}o++}}}else if(s.type==="DirectionalLight")r.fromDirectionalLightState(s,n);else if(s.type==="PointLight")r.fromPointLightState(s,n);else if(s.type==="SpotLight")r.fromSpotLightState(s,n);else if(r instanceof mr&&Ds.is(s.type)){let a=s;r.setZoom("PerspectiveCamera",a.perspective.zoom),r.setZoom("OrthographicCamera",a.orthographic.zoom),r.isUpVectorFlipped=a.isUpVectorFlipped,r.targetOffset=a.targetOffset}}var Io=class{constructor(e){this.objectState=e;this.uuid=Ge.generateUUID()}static create(e,t){let n=new Io(t);return n.uuid=e,n}execute(e,t){cM(e,this.objectState,null,t,!0)}};var sr=new Ns,Br=new A,gv={follow:jl.listener,keyDown:Ji.listener,keyUp:Ji.listener,lookAt:ql.listener,mouseDown:Ji.listener,mouseUp:Ji.listener,mouseHover:Ql.listener,scroll:Yl.listener,start:Xl.listener},hM={follow:Lh,keyDown:Zf,keyUp:mv,lookAt:Ih,mouseDown:Kf,mouseUp:pv,mouseHover:Kl,scroll:Qf,start:fv};function tz(r){if(r.style.transform!==""){let e=getComputedStyle(r).getPropertyValue("transform");if(e!=="none"){let t=e.replace("matrix(","").split(",");return{x:parseFloat(t[0]),y:parseFloat(t[3])}}}return{x:1,y:1}}function uM(r){let e=r.getViewport(new qe),t=tz(r.domElement);return{left:e.x*t.x,top:e.y*t.y,width:e.z*t.x,height:e.w*t.y}}function nz(r,e){return r.distance-e.distance}function dM(r,e,t){if(Us(e)&&e.visible&&!e.raycastLock)e.raycast(r,t);else return;for(let n of e.children)dM(r,n,t)}function yv(r,e,t){if(!t.some(i=>$f(sr,i)!==void 0))return[];let n=[];return e.children.forEach(i=>dM(r,i,n)),n.sort(nz),n}function vv(r,e){let t=[];if(r.length){let n=r[0].object;Us(n)&&n.interaction?.events[e]?.length&&t.push(n);let i=n.parent;for(;i;)oy(i)&&i.interaction?.events[e]?.length&&t.push(i),i=i.parent}return t}function $f(r,e){if(Ut(e)){if(!e.raycastLock&&e.visible){let t=[];return e.raycast(r,t),t.length?t[0]:void 0}}else if(oy(e))return fM(r,e)}function fM(r,e){if(Ut(e)&&!e.raycastLock&&e.visible){let t=[];if(e.raycast(r,t),t.length)return t[0]}for(let t of e.children)if(Us(t)){let n=fM(r,t);if(n)return n}}var ep=class{constructor(e,t,n,i,s){this.stopRaycast=i;this.isEnable=!1;this.splineEvents={};this._map={};this._mapSound={};this._prevObjects=[];this._onMouseDown=e=>{sr.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(Br),Br.negate(),this._handleMouseDownEvent(e)};this._onMouseUp=e=>{sr.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(Br),Br.negate(),this._handleMouseUpEvent(e)};this._onMouseMove=e=>{sr.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(Br),Br.negate(),this._handleMouseHoverEvent(e),this._handleLookAtEvent(e),this._handleFollowEvent(e)};this._onTouchStart=e=>{e.touches.length===1&&(sr.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(Br),Br.negate(),this._handleMouseDownEvent(e),this._handleMouseHoverEvent(e),this._handleLookAtEvent(e),this._handleFollowEvent(e))};this._onTouchEnd=e=>{this._handleMouseUpEvent(e),this._handleMouseHoverEvent(e,!0)};this._onTouchMove=e=>{e.touches.length===1&&(sr.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(Br),Br.negate(),this._handleMouseHoverEvent(e),this._handleLookAtEvent(e),this._handleFollowEvent(e))};this._onWheel=e=>{this._handleWheelEvent(e)};this._onKeyDown=e=>{this._handleKeyDownEvent(e)};this._onKeyUp=e=>{this._handleKeyUpEvent(e)};this._renderer=e,this._domElement=e.domElement,this._camera=n,this._scene=t,this._app=s,this._domRect=this._domElement.getBoundingClientRect(),this._viewRect=uM(e)}activate(){this.isEnable=!0,this._map={},this._mapSound={},this._scene.traverseEntity(e=>{e.interaction!==void 0&&(e.interaction.start(),Object.keys(e.interaction.events).forEach(t=>{let n=t;this._addDOMCustomEvent(n,e),(e.visible||n!=="mouseDown"&&n!=="mouseUp"&&n!=="mouseHover"&&n!=="sound")&&this._addSPEEvent(n,e),e.visible&&n==="sound"&&e.interaction?.events.sound?.forEach(i=>{let s=i.data.trigger;this._mapSound[s]===void 0?this._mapSound[s]=[e]:this._mapSound[s].push(e)})}))}),yd?((this._map.mouseDown?.length||this._map.mouseHover?.length||this._map.lookAt?.length||this._map.follow?.length||this._mapSound.mouseDown?.length)&&this._domElement.addEventListener("touchstart",this._onTouchStart),(this._map.mouseUp?.length||this._map.mouseHover?.length||this._mapSound.mouseUp?.length)&&this._domElement.addEventListener("touchend",this._onTouchEnd),(this._map.mouseHover?.length||this._map.lookAt?.length||this._map.follow?.length)&&this._domElement.addEventListener("touchmove",this._onTouchMove)):((this._map.mouseDown?.length||this._mapSound.mouseDown?.length)&&this._domElement.addEventListener("pointerdown",this._onMouseDown),(this._map.mouseUp?.length||this._mapSound.mouseUp?.length)&&this._domElement.addEventListener("pointerup",this._onMouseUp),(this._map.mouseHover?.length||this._map.lookAt?.length||this._map.follow?.length)&&this._domElement.addEventListener("pointermove",this._onMouseMove)),this._map.scroll?.length&&this._domElement.addEventListener("wheel",this._onWheel),(this._map.keyDown?.length||this._mapSound.keyDown?.length)&&document.addEventListener("keydown",this._onKeyDown),(this._map.keyUp?.length||this._mapSound.keyUp?.length)&&document.addEventListener("keyup",this._onKeyUp),this._handleStartEvent(),this.resize()}deactivate(){this._scene.traverseEntity(e=>{if(!e.interaction)return;e.interaction.end(),Rr.dispose(e);let t=e;Object.keys(gv).forEach(n=>{let i=n;t.removeEventListener(i,gv[i])})}),this._domElement.removeEventListener("pointerdown",this._onMouseDown),this._domElement.removeEventListener("pointerup",this._onMouseUp),this._domElement.removeEventListener("pointermove",this._onMouseMove),this._domElement.removeEventListener("touchstart",this._onTouchStart),this._domElement.removeEventListener("touchend",this._onTouchEnd),this._domElement.removeEventListener("touchmove",this._onTouchMove),this._domElement.removeEventListener("wheel",this._onWheel),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keyup",this._onKeyUp),this._map={},this._mapSound={},this.isEnable=!1}reset(){this._scene.traverseEntity(e=>{e.interaction?.start()}),this._handleStartEvent()}resize(){this._domRect=this._domElement.getBoundingClientRect(),this._viewRect=uM(this._renderer)}_getPointer(e,t){let n=this._domRect,i=this._viewRect,s=n.height-i.height,o=(e-i.left-n.left)*(n.width/i.width),a=(t-s+i.top-n.top)*(n.height/i.height);return{x:o/n.width*2-1,y:-(a/n.height)*2+1}}_handleStartEvent(){this._map.start?.forEach(e=>{e.dispatchEvent(fv)}),Object.keys(this._mapSound).forEach(e=>{this._mapSound[e]?.forEach(t=>{Rr.stop(t)})})}_handleWheelEvent(e){this._map.scroll?.length&&(Qf.deltaY=e.deltaY,this._map.scroll.forEach(t=>{t.dispatchEvent(Qf)}))}_handleMouseEvent(e){if(this.stopRaycast){let t=this._map[e];if(t?.length){let n=yv(sr,this._scene,t);vv(n,e).forEach(i=>i.dispatchEvent(e==="mouseDown"?Kf:pv))}if(t=this._mapSound[e],t?.length){let n=yv(sr,this._scene,t);vv(n,"sound").forEach(i=>{i.interaction?.events.sound?.some(s=>s.data.trigger===e)&&Rr.start(i)})}}else this._map[e]?.forEach(t=>{$f(sr,t)&&t.dispatchEvent(Kf)}),this._mapSound[e]?.forEach(t=>{$f(sr,t)&&Rr.start(t)})}_handleMouseDownEvent(e){this._handleMouseEvent("mouseDown")}_handleMouseUpEvent(e){this._handleMouseEvent("mouseUp")}_handleMouseHoverEvent(e,t=!1){let n=[];if(!t)if(this.stopRaycast){if(this._map.mouseHover?.length){let i=yv(sr,this._scene,this._map.mouseHover);n=vv(i,"mouseHover")}}else this._map.mouseHover?.forEach(i=>{$f(sr,i)&&n.push(i)});this._prevObjects.length&&(Kl.enter=!1,this._prevObjects.forEach(i=>{n.includes(i)||i.dispatchEvent(Kl)})),n.length&&(Kl.enter=!0,n.forEach(i=>{i.dispatchEvent(Kl)})),this._prevObjects=n}_handleLookAtEvent(e){this._map.lookAt?.length&&(Ih.normal=Br,Ih.raycaster=sr,this._map.lookAt.forEach(t=>{t.dispatchEvent(Ih)}))}_handleFollowEvent(e){this._map.follow&&(Lh.normal=Br,Lh.raycaster=sr,this._map.follow.forEach(t=>t.dispatchEvent(Lh)))}_handleKeyEvent(e,t,n){this._map[t]?.forEach(i=>{Zf.interactionEvents=i.interaction?.events?.keyDown?.filter(s=>s.domEvent.type===n&&s.domEvent.key===e.key),i.dispatchEvent(t==="keyDown"?Zf:mv)}),this._mapSound[t]?.forEach(i=>{i.interaction?.events?.sound?.forEach(s=>{s.data.trigger===t&&s.data.key===e.key&&Rr.startByEvent(s)})})}_handleKeyDownEvent(e){this._handleKeyEvent(e,"keyDown","keydown")}_handleKeyUpEvent(e){this._handleKeyEvent(e,"keyUp","keyup")}_addSPEEvent(e,t){!t.interaction||e!=="sound"&&(hM[e].begin=this._dispatchDOMCustomEvent.bind(this),hM[e].change=this._app.requestRender.bind(this),t.interaction.events[e]?.length&&(t.addEventListener(e,gv[e]),this._map[e]===void 0?this._map[e]=[t]:this._map[e].push(t)))}_addDOMCustomEvent(e,t){if(e){let n=new CustomEvent(e,{bubbles:!0});Object.defineProperty(n,"target",{writable:!1,value:{id:t.uuid,name:t.name}}),this.splineEvents[e]?this.splineEvents[e][t.uuid]=n:this.splineEvents[e]={[t.uuid]:n}}}_dispatchDOMCustomEvent(e,t){let n=this.splineEvents[e]?.[t];n&&this._domElement.dispatchEvent(n)}};var tp=class{constructor(e,t,n,i,s){this._aspect=1;this._renderer=e,this._camera=t,this._frameSize=new B().copy(n),this._editorSize=new B().copy(i),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y,!1)}updateViewportForImageExport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y;this._aspect=e/t,this._camera.zoom*=Math.min(n/e,i/t),this._renderer.setViewport(0,0,e,t)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y,s=0,o=0,a=e,l=t;e<n&&(s=(n-e)*.5,s=-s,a=n),t<i&&(o=(i-t)*.5,o=-o,l=i),this._aspect=a/l,this._renderer.setViewport(s,o,a,l)}updateCamera(){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,t=this._editorSize.y,n=this._fov;if(e>t){let i=rz(e,1080,2160,1,15)/100;n*=e/t,n*=1-i}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t,!1)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function rz(r,e,t,n,i){return(r-e)/(t-e)*(i-n)+n}var np=class{constructor(e){this.sharedAssets=new Vf(e.shared),this.scene=new Yf(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(this.sharedAssets),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose()}};var rp=class{constructor({x:e=10,y:t=10}){this._startTime=0;let n=document.getElementById("spe-perfs");n?this.element=n:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let t=performance.now()-this._startTime;this.element.innerHTML=t.toFixed(3)+" ms"}};function iz(r){let e;if(!!r.index)for(let t=0;t<r.index.array.length;t+=3)e=r.index.array[t],r.index.array[t]=r.index.array[t+2],r.index.array[t+2]=e}function xv(r){return r==="SubdivObject"||r==="NonParametric"?r:"Mesh"}function sz(r,e){let t={};return r.traverseEntity(n=>{if(n.type!=="Mesh"||!("material"in n)||!n.visible||!(n instanceof Nt)||Array.isArray(n.material)||n&&n.interaction&&n.interaction.states.length>0)return;let i=n.parent;for(;i;){if(i instanceof Nt&&i.interaction&&i.interaction.states.length>1)return;i=i.parent}let s=n.material.uuid,o=e.shared.materials[s];if(o){if(!qr.isMergable(o))return}else{let c=e.scene.objects.get(n.uuid)?.data;if(c&&"material"in c&&typeof c.material!="string"){if(!qr.isMergable(c.material))return;s=qr.getHash(c.material)}}t[s]||(t[s]={});let l=t[s][xv(n.objectType)];if(l){if(l.push(n),n.cloner)for(let c of n.cloner.children)l.push(c)}else if(t[s][xv(n.objectType)]=[n],n.cloner)for(let c of n.cloner.children)t[s][xv(n.objectType)].push(c)}),t}function oz(r){let e=0;return Object.values(r).forEach(t=>{Object.values(t).forEach(n=>{let i=n.length;i>e&&(e=i)})}),e}function pM(r,e){let t=sz(e,r),n=oz(t),i=new Array(n),s=0,o=new Array(n),a=0,l=new Array(n),c=0,h=new Array(n),u=0;for(let d of Object.values(t))for(let f of Object.values(d)){if(a=0,c=0,f.forEach(p=>{p instanceof Nt&&(o[a++]=p.geometry.clone(),l[c++]=p)}),c<2)continue;for(let p=0;p<c;p++)l[p].updateWorldMatrix(!0,!1),o[p].applyMatrix4(l[p].matrixWorld),l[p].matrixWorld.determinant()<0&&iz(o[p]);let m=uS(o.slice(0,a),!1);if(m){let p;switch(f[0].objectType){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),p=new Vt(m,l[0].material);break}default:{p=new Vt(m,l[0].material);break}}p.castShadow=l[0].castShadow,p.receiveShadow=l[0].receiveShadow,e.add(p);let g=x=>{u=0;for(let v of x)v.children&&g(v.children),v instanceof Nt&&(Array.isArray(v.material)||t[v.material.uuid]&&t[v.material.uuid][v.objectType]&&t[v.material.uuid][v.objectType].length>1||(h[u++]=v));for(let v=0;v<u;v++)e.attach(h[v])};for(let x=0;x<c;x++){let v=l[x];g(v.children),i[s++]=v}}}for(let d=0;d<s;d++)i[d].removeFromParent()}var az=new B,mM="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.",gM=class{constructor(e,{autoRender:t=!1}={}){this._viewportMode=1;this._viewportWidth=window.innerWidth;this._viewportHeight=window.innerHeight;this._proxyObjectCache=new Map;this._skipRender=!0;this.autoRender=!1;this.disposed=!1;this.requestRender=()=>{this._skipRender=!1};this.render=()=>{!this._renderer||(this._rafId=requestAnimationFrame(this.render),this._perfs?.start(),!(!this.autoRender&&this._skipRender)&&(this._controls&&(this._controls.enableDamping||this._controls.autoRotate)?this._skipRender=!this._controls.update():this._skipRender=!0,this._playmode&&!this._playmode.isEnable&&this._playmode.activate(),this._scene&&this._camera&&(this._renderer.autoClear=!1,this._normalRenderTarget&&(this._renderer.setClearColor(0),this._renderer.setClearAlpha(0),this._camera.layers.enable(8),this._camera.layers.disable(0),this._camera.layers.disable(3),this._renderer.setRenderTarget(this._normalRenderTarget),this._renderer.clear(),this._scene.overrideMaterial=this._normalMaterial,this._renderer.render(this._scene,this._camera),this._renderer.setClearColor(this._scene.bgColor,this._scene.alpha),this._renderer.setRenderTarget(null),this._scene.overrideMaterial=null,this._camera.layers.enable(0),this._camera.layers.enable(3)),this._transmissionRenderTarget&&(this._renderer.setRenderTarget(this._transmissionRenderTarget),this._renderer.clear(),this._camera.layers.enable(0),this._camera.layers.disable(3),this._renderer.render(this._scene,this._camera),this._renderer.setRenderTarget(null),this._camera.layers.enable(3)),this._renderer.autoClear=!1,this._scene.postprocessing.render()),this._perfs?.end()))};this.resize=Nc(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=az.set(this._viewportWidth,this._viewportHeight)),this._frameView?.updateRenderer(),this._scene?.postprocessing&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight,!1),this._sharedAssetsManager?.resolutionNode.value.set(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio),this._normalRenderTarget?.setSize(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio),this._transmissionRenderTarget?.setSize(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio),this._viewportMode!==1&&this._frameView?.updateViewport(),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&this._viewportMode===1&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this._playmode?.resize(),this.requestRender())},10);this.canvas=e,this.autoRender=t,Ay(),window.location.search.includes("perfs")&&(this._perfs=new rp({x:10,y:10}))}async load(e){e.endsWith(".spline")?console.warn(mM+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(mM);let n=await(await fetch(e)).arrayBuffer();await this.start(n)}async start(e){if(this.disposed)return;let t=await Q1(e);Ly(t)&&await G1();let n=new np(t);if(window.location.search.includes("merge-geometries")){let d=performance.now();pM(t,n.scene);let f=performance.now();console.log("Merged geometries in ",f-d," ms")}this._scene=n.scene,Ly(t)&&this._scene.traverse(d=>{bt(d)&&d.recomputeBoolean()}),this._sharedAssetsManager=n.sharedAssets,this._sharedAssetsManager.onImageLoad=()=>{this.requestRender()},lM(t.scene,this._scene,this._sharedAssetsManager),this._camera=this._scene.activeCamera;let i=Object.values(t.frames)[0],s,o;if(i)if(i.preset==="fullscreen"){this._viewportMode=1;let{width:d,height:f}=window.getComputedStyle(this.canvas);this.canvas.parentElement&&(d==="300px"||d==="auto")?(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%",s=this.canvas.style.width):this._viewportWidth=this.canvas.clientWidth,this.canvas.parentElement&&(f==="150px"||f==="auto")?(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%",o=this.canvas.style.height):this._viewportHeight=this.canvas.clientHeight}else this._viewportMode=2,this._viewportWidth=i.size[0],this._viewportHeight=i.size[1],s=this._viewportWidth+"px",o=this._viewportHeight+"px";this._renderer=new Wm({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._scene.postprocessing.init({renderer:this._renderer,camera:this._camera,scene:this._scene}),this._scene.postprocessing.addEventListener("smaaloaded",this.requestRender),s&&(this.canvas.style.width=s),o&&(this.canvas.style.height=o),this._scene.needsTransmission(void 0)&&(this._transmissionRenderTarget=new lt(2048,2048,{generateMipmaps:!0,minFilter:xs,magFilter:tt,wrapS:bn,wrapT:bn}),this._transmissionRenderTarget.depthTexture=new wr(2048,2048),this._scene.needsTransmission(this._transmissionRenderTarget)),this._scene.needsNormal(void 0)&&(this._normalRenderTarget=new lt(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio,{generateMipmaps:!1,minFilter:Gt,magFilter:Gt,type:vr}),this._normalMaterial=M1,this._normalRenderTarget.depthTexture=new wr(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio),this._scene.needsNormal(this._normalRenderTarget)),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._scene.postprocessing&&this._scene.postprocessing.resize(this._viewportWidth,this._viewportHeight,!1),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=t.scene.environment.ambientLight.softShadows?Bu:km,A1(t.scene.environment.ambientLight.softShadowQuality),this._renderer.setClearColor(this._scene.bgColor,this._scene.alpha),this._frameView=new tp(this._renderer,this._camera,new B(this._viewportWidth,this._viewportHeight),new B(window.innerWidth,window.innerHeight)),this._publishData=t.scene.publish;let{enableRotate:a,enablePan:l,enableZoom:c,autoRotate:h,hoverRotatePanMode:u}=this._publishData.orbitControls;if((a||l||c||h||u!==0)&&(this._camera.interaction===void 0||this._camera.interaction.states.length<=1)&&(this._controls=new Xd(this._camera,this._renderer.domElement),this._controls.fromJSON(this._publishData.orbitControls),this._controls.useKeyEvents=!1,this._controls.addEventListener("change",this.requestRender),this._controls.addEventListener("start",this.requestRender)),this._playmode=new ep(this._renderer,this._scene,this._camera,this._publishData.stopRaycast,this),this._sharedAssetsManager.resolutionNode.value.set(this._viewportWidth*window.devicePixelRatio,this._viewportHeight*window.devicePixelRatio),this._sharedAssetsManager.pixelRatioNode.value=window.devicePixelRatio,this.resize(),this.render(),this.canvas.parentElement){let d=!0;this._resizeObserver=new ResizeObserver(()=>{if(d){d=!1;return}this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this.resize()}),this._resizeObserver.observe(this.canvas.parentElement)}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getSplineEvents(){return this._playmode?.splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this._renderer?.domElement.addEventListener(e,t)}removeEventListener(e,t){this._renderer?.domElement.removeEventListener(e,t)}setZoom(e){this._controls?.zoomOut(e)}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this.resize()}dispose(){this.disposed=!0,this._playmode?.deactivate(),this._scene?.dispose(),this._rafId&&cancelAnimationFrame(this._rafId),this._proxyObjectCache.forEach(e=>{rg.unsubscribe(e)}),this._renderer?.dispose(),this._transmissionRenderTarget?.dispose(),this._transmissionRenderTarget?.depthTexture?.dispose(),this._normalRenderTarget?.dispose(),this._normalRenderTarget?.depthTexture?.dispose(),this._sharedAssetsManager?.dispose(),this._resizeObserver&&this._resizeObserver.disconnect(),this.canvas.style.width="",this.canvas.style.height=""}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let{requestRender:t}=this,n={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(s){e.interaction?.emitEvent(s,t)},emitEventReverse(s){e.interaction?.emitEventReverse(s,t)}},i=rg(n,(s,o)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=o),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};export{gM as Application};
|