diff --git a/assets/index-wP8pu-br.js b/assets/index-eH2hlvmv.js similarity index 88% rename from assets/index-wP8pu-br.js rename to assets/index-eH2hlvmv.js index c1e028b..85ea2d6 100644 --- a/assets/index-wP8pu-br.js +++ b/assets/index-eH2hlvmv.js @@ -2,11 +2,11 @@ * @license * Copyright 2010-2023 Three.js Authors * SPDX-License-Identifier: MIT - */const Ql="159",Mr={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Tr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},od=0,Mc=1,ad=2,Zh=1,ld=2,Mi=3,ei=0,xn=1,Zn=2,ji=0,rs=1,Tc=2,Ac=3,Rc=4,cd=5,hr=100,ud=101,hd=102,Lc=103,Cc=104,fd=200,dd=201,pd=202,md=203,Tl=204,Al=205,_d=206,gd=207,vd=208,xd=209,yd=210,bd=211,Ed=212,Sd=213,wd=214,Md=0,Td=1,Ad=2,aa=3,Rd=4,Ld=5,Cd=6,Pd=7,Qh=0,Dd=1,Id=2,Yi=0,Nd=1,Fd=2,Od=3,Ud=4,Bd=5,Pc="attached",zd="detached",Jh=300,ls=301,cs=302,Rl=303,Ll=304,ga=306,us=1e3,Hn=1001,la=1002,Nt=1003,Cl=1004,sa=1005,Sn=1006,ef=1007,gr=1008,fi=1009,Pl=1010,tf=1011,va=1012,Ws=1013,Dn=1014,vn=1015,Qs=1016,nf=1017,rf=1018,pr=1020,kd=1021,sn=1023,Hd=1024,Vd=1025,mr=1026,hs=1027,sf=1028,Jl=1029,of=1030,xa=1031,Js=1033,La=33776,Ca=33777,Pa=33778,Da=33779,Dc=35840,Ic=35841,Nc=35842,Fc=35843,af=36196,Oc=37492,Uc=37496,Bc=37808,zc=37809,kc=37810,Hc=37811,Vc=37812,Gc=37813,Wc=37814,Xc=37815,qc=37816,jc=37817,Yc=37818,$c=37819,Kc=37820,Zc=37821,Ia=36492,Qc=36494,Jc=36495,Gd=36283,eu=36284,tu=36285,nu=36286,eo=2300,fs=2301,Na=2302,iu=2400,ru=2401,su=2402,Wd=2500,Xd=0,lf=1,Dl=2,cf=3e3,$i=3001,qd=3200,jd=3201,uf=0,Yd=1,Vn="",Ht="srgb",an="srgb-linear",ec="display-p3",ya="display-p3-linear",ca="linear",At="srgb",ua="rec709",ha="p3",Ar=7680,ou=519,$d=512,Kd=513,Zd=514,hf=515,Qd=516,Jd=517,ep=518,tp=519,Il=35044,au="300 es",Nl=1035,Ai=2e3,fa=2001;class xr{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const 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;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let s=0,o=i.length;s>8&255]+un[r>>16&255]+un[r>>24&255]+"-"+un[e&255]+un[e>>8&255]+"-"+un[e>>16&15|64]+un[e>>24&255]+"-"+un[t&63|128]+un[t>>8&255]+"-"+un[t>>16&255]+un[t>>24&255]+un[n&255]+un[n>>8&255]+un[n>>16&255]+un[n>>24&255]).toLowerCase()}function tn(r,e,t){return Math.max(e,Math.min(t,r))}function tc(r,e){return(r%e+e)%e}function np(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function ip(r,e,t){return r!==e?(t-r)/(e-r):0}function qs(r,e,t){return(1-t)*r+t*e}function rp(r,e,t,n){return qs(r,e,1-Math.exp(-t*n))}function sp(r,e=1){return e-Math.abs(tc(r,e*2)-e)}function op(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function ap(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function lp(r,e){return r+Math.floor(Math.random()*(e-r+1))}function cp(r,e){return r+Math.random()*(e-r)}function up(r){return r*(.5-Math.random())}function hp(r){r!==void 0&&(lu=r);let e=lu+=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 fp(r){return r*Xs}function dp(r){return r*ds}function Fl(r){return(r&r-1)===0&&r!==0}function pp(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function da(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function mp(r,e,t,n,i){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),u=o((e+n)/2),f=s((e-n)/2),h=o((e-n)/2),p=s((n-e)/2),_=o((n-e)/2);switch(i){case"XYX":r.set(a*u,l*f,l*h,a*c);break;case"YZY":r.set(l*h,a*u,l*f,a*c);break;case"ZXZ":r.set(l*f,l*h,a*u,a*c);break;case"XZX":r.set(a*u,l*_,l*p,a*c);break;case"YXY":r.set(l*p,a*u,l*_,a*c);break;case"ZYZ":r.set(l*_,l*p,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function hi(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function bt(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const ff={DEG2RAD:Xs,RAD2DEG:ds,generateUUID:Qn,clamp:tn,euclideanModulo:tc,mapLinear:np,inverseLerp:ip,lerp:qs,damp:rp,pingpong:sp,smoothstep:op,smootherstep:ap,randInt:lp,randFloat:cp,randFloatSpread:up,seededRandom:hp,degToRad:fp,radToDeg:dp,isPowerOfTwo:Fl,ceilPowerOfTwo:pp,floorPowerOfTwo:da,setQuaternionFromProperEuler:mp,normalize:bt,denormalize:hi};class Ue{constructor(e=0,t=0){Ue.prototype.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){return 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){return 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){const 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){const 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=Math.trunc(this.x),this.y=Math.trunc(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}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(tn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const 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){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const 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}}class st{constructor(e,t,n,i,s,o,a,l,c){st.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,l,c)}set(e,t,n,i,s,o,a,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const 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){const 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){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],f=n[7],h=n[2],p=n[5],_=n[8],g=i[0],m=i[3],d=i[6],x=i[1],v=i[4],y=i[7],b=i[2],M=i[5],T=i[8];return s[0]=o*g+a*x+l*b,s[3]=o*m+a*v+l*M,s[6]=o*d+a*y+l*T,s[1]=c*g+u*x+f*b,s[4]=c*m+u*v+f*M,s[7]=c*d+u*y+f*T,s[2]=h*g+p*x+_*b,s[5]=h*m+p*v+_*M,s[8]=h*d+p*y+_*T,this}multiplyScalar(e){const 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(){const 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],u=e[8];return t*o*u-t*a*c-n*s*u+n*a*l+i*s*c-i*o*l}invert(){const 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],u=e[8],f=u*o-a*c,h=a*l-u*s,p=c*s-o*l,_=t*f+n*h+i*p;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/_;return e[0]=f*g,e[1]=(i*c-u*n)*g,e[2]=(a*n-i*o)*g,e[3]=h*g,e[4]=(u*t-i*l)*g,e[5]=(i*s-a*t)*g,e[6]=p*g,e[7]=(n*l-c*t)*g,e[8]=(o*t-n*s)*g,this}transpose(){let e;const 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){const 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){const 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){return this.premultiply(Fa.makeScale(e,t)),this}rotate(e){return this.premultiply(Fa.makeRotation(-e)),this}translate(e,t){return this.premultiply(Fa.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const 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){const 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)}}const Fa=new st;function df(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function to(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function _p(){const r=to("canvas");return r.style.display="block",r}const cu={};function js(r){r in cu||(cu[r]=!0,console.warn(r))}const uu=new st().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),hu=new st().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),co={[an]:{transfer:ca,primaries:ua,toReference:r=>r,fromReference:r=>r},[Ht]:{transfer:At,primaries:ua,toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[ya]:{transfer:ca,primaries:ha,toReference:r=>r.applyMatrix3(hu),fromReference:r=>r.applyMatrix3(uu)},[ec]:{transfer:At,primaries:ha,toReference:r=>r.convertSRGBToLinear().applyMatrix3(hu),fromReference:r=>r.applyMatrix3(uu).convertLinearToSRGB()}},gp=new Set([an,ya]),pt={enabled:!0,_workingColorSpace:an,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(r){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!r},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!gp.has(r))throw new Error(`Unsupported working color space, "${r}".`);this._workingColorSpace=r},convert:function(r,e,t){if(this.enabled===!1||e===t||!e||!t)return r;const n=co[e].toReference,i=co[t].fromReference;return i(n(r))},fromWorkingColorSpace:function(r,e){return this.convert(r,this._workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this._workingColorSpace)},getPrimaries:function(r){return co[r].primaries},getTransfer:function(r){return r===Vn?ca:co[r].transfer}};function ss(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Oa(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Rr;class pf{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Rr===void 0&&(Rr=to("canvas")),Rr.width=e.width,Rr.height=e.height;const n=Rr.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Rr}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){const t=to("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Jh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case us:e.x=e.x-Math.floor(e.x);break;case Hn:e.x=e.x<0?0:1;break;case la: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 us:e.y=e.y-Math.floor(e.y);break;case Hn:e.y=e.y<0?0:1;break;case la: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)}get encoding(){return js("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ht?$i:cf}set encoding(e){js("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===$i?Ht:Vn}}on.DEFAULT_IMAGE=null;on.DEFAULT_MAPPING=Jh;on.DEFAULT_ANISOTROPY=1;class mt{constructor(e=0,t=0,n=0,i=1){mt.prototype.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){return 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){return 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){const 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);const 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;const l=e.elements,c=l[0],u=l[4],f=l[8],h=l[1],p=l[5],_=l[9],g=l[2],m=l[6],d=l[10];if(Math.abs(u-h)<.01&&Math.abs(f-g)<.01&&Math.abs(_-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(f+g)<.1&&Math.abs(_+m)<.1&&Math.abs(c+p+d-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(c+1)/2,y=(p+1)/2,b=(d+1)/2,M=(u+h)/4,T=(f+g)/4,I=(_+m)/4;return v>y&&v>b?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=M/n,s=T/n):y>b?y<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(y),n=M/i,s=I/i):b<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(b),n=T/s,i=I/s),this.set(n,i,s,t),this}let x=Math.sqrt((m-_)*(m-_)+(f-g)*(f-g)+(h-u)*(h-u));return Math.abs(x)<.001&&(x=1),this.x=(m-_)/x,this.y=(f-g)/x,this.z=(h-u)/x,this.w=Math.acos((c+p+d-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){const 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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(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){return 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}}class yp extends xr{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new mt(0,0,e,t),this.scissorTest=!1,this.viewport=new mt(0,0,e,t);const i={width:e,height:t,depth:1};n.encoding!==void 0&&(js("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===$i?Ht:Vn),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Sn,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},n),this.texture=new on(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps,this.texture.internalFormat=n.internalFormat,this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}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.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new mf(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"})}}class Ki extends yp{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class _f extends on{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=Nt,this.minFilter=Nt,this.wrapR=Hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class bp extends on{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=Nt,this.minFilter=Nt,this.wrapR=Hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class mi{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 slerpFlat(e,t,n,i,s,o,a){let l=n[i+0],c=n[i+1],u=n[i+2],f=n[i+3];const h=s[o+0],p=s[o+1],_=s[o+2],g=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=f;return}if(a===1){e[t+0]=h,e[t+1]=p,e[t+2]=_,e[t+3]=g;return}if(f!==g||l!==h||c!==p||u!==_){let m=1-a;const d=l*h+c*p+u*_+f*g,x=d>=0?1:-1,v=1-d*d;if(v>Number.EPSILON){const b=Math.sqrt(v),M=Math.atan2(b,d*x);m=Math.sin(m*M)/b,a=Math.sin(a*M)/b}const y=a*x;if(l=l*m+h*y,c=c*m+p*y,u=u*m+_*y,f=f*m+g*y,m===1-a){const b=1/Math.sqrt(l*l+c*c+u*u+f*f);l*=b,c*=b,u*=b,f*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,i,s,o){const a=n[i],l=n[i+1],c=n[i+2],u=n[i+3],f=s[o],h=s[o+1],p=s[o+2],_=s[o+3];return e[t]=a*_+u*f+l*p-c*h,e[t+1]=l*_+u*h+c*f-a*p,e[t+2]=c*_+u*p+a*h-l*f,e[t+3]=u*_-a*f-l*h-c*p,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){const n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(i/2),f=a(s/2),h=l(n/2),p=l(i/2),_=l(s/2);switch(o){case"XYZ":this._x=h*u*f+c*p*_,this._y=c*p*f-h*u*_,this._z=c*u*_+h*p*f,this._w=c*u*f-h*p*_;break;case"YXZ":this._x=h*u*f+c*p*_,this._y=c*p*f-h*u*_,this._z=c*u*_-h*p*f,this._w=c*u*f+h*p*_;break;case"ZXY":this._x=h*u*f-c*p*_,this._y=c*p*f+h*u*_,this._z=c*u*_+h*p*f,this._w=c*u*f-h*p*_;break;case"ZYX":this._x=h*u*f-c*p*_,this._y=c*p*f+h*u*_,this._z=c*u*_-h*p*f,this._w=c*u*f+h*p*_;break;case"YZX":this._x=h*u*f+c*p*_,this._y=c*p*f+h*u*_,this._z=c*u*_-h*p*f,this._w=c*u*f-h*p*_;break;case"XZY":this._x=h*u*f-c*p*_,this._y=c*p*f-h*u*_,this._z=c*u*_+h*p*f,this._w=c*u*f+h*p*_;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const 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){const t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],f=t[10],h=n+a+f;if(h>0){const p=.5/Math.sqrt(h+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(o-i)*p}else if(n>a&&n>f){const p=2*Math.sqrt(1+n-a-f);this._w=(u-l)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+c)/p}else if(a>f){const p=2*Math.sqrt(1+a-n-f);this._w=(s-c)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+f-n-a);this._w=(o-i)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.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(tn(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const 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){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+i*c-s*l,this._y=i*u+o*l+s*a-n*c,this._z=s*u+o*c+n*l-i*a,this._w=o*u-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,o=this._w;let 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;const l=1-a*a;if(l<=Number.EPSILON){const p=1-t;return this._w=p*o+t*this._w,this._x=p*n+t*this._x,this._y=p*i+t*this._y,this._z=p*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),f=Math.sin((1-t)*u)/c,h=Math.sin(t*u)/c;return this._w=o*f+this._w*h,this._x=n*f+this._x*h,this._y=i*f+this._y*h,this._z=s*f+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const 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}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class C{constructor(e=0,t=0,n=0){C.prototype.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){return 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){return 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){return 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 this.applyQuaternion(fu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fu.setFromAxisAngle(e,t))}applyMatrix3(e){const 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){const 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){const t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*i-a*n),u=2*(a*t-s*i),f=2*(s*n-o*t);return this.x=t+l*c+o*f-a*u,this.y=n+l*u+a*c-s*f,this.z=i+l*f+s*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const 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){const 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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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){return this.crossVectors(this,e)}crossVectors(e,t){const 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){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ba.copy(this).projectOnVector(e),this.sub(Ba)}reflect(e){return this.sub(Ba.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(tn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const 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){const 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){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const 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}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,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){return 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(){const 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}}const Ba=new C,fu=new mi;class $t{constructor(e=new C(1/0,1/0,1/0),t=new C(-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){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,jn),jn.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(Ts),ho.subVectors(this.max,Ts),Lr.subVectors(e.a,Ts),Cr.subVectors(e.b,Ts),Pr.subVectors(e.c,Ts),Fi.subVectors(Cr,Lr),Oi.subVectors(Pr,Cr),tr.subVectors(Lr,Pr);let t=[0,-Fi.z,Fi.y,0,-Oi.z,Oi.y,0,-tr.z,tr.y,Fi.z,0,-Fi.x,Oi.z,0,-Oi.x,tr.z,0,-tr.x,-Fi.y,Fi.x,0,-Oi.y,Oi.x,0,-tr.y,tr.x,0];return!za(t,Lr,Cr,Pr,ho)||(t=[1,0,0,0,1,0,0,0,1],!za(t,Lr,Cr,Pr,ho))?!1:(fo.crossVectors(Fi,Oi),t=[fo.x,fo.y,fo.z],za(t,Lr,Cr,Pr,ho))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(jn).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:(xi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),xi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),xi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),xi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),xi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),xi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),xi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),xi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(xi),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)}}const xi=[new C,new C,new C,new C,new C,new C,new C,new C],jn=new C,uo=new $t,Lr=new C,Cr=new C,Pr=new C,Fi=new C,Oi=new C,tr=new C,Ts=new C,ho=new C,fo=new C,nr=new C;function za(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){nr.fromArray(r,s);const a=i.x*Math.abs(nr.x)+i.y*Math.abs(nr.y)+i.z*Math.abs(nr.z),l=e.dot(nr),c=t.dot(nr),u=n.dot(nr);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const Ep=new $t,As=new C,ka=new C;class ni{constructor(e=new C,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Ep.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;sthis.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){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;As.subVectors(e,this.center);const t=As.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(As,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ka.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(As.copy(e.center).add(ka)),this.expandByPoint(As.copy(e.center).sub(ka))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const yi=new C,Ha=new C,po=new C,Ui=new C,Va=new C,mo=new C,Ga=new C;class so{constructor(e=new C,t=new C(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.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,yi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=yi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(yi.copy(this.origin).addScaledVector(this.direction,t),yi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Ha.copy(e).add(t).multiplyScalar(.5),po.copy(t).sub(e).normalize(),Ui.copy(this.origin).sub(Ha);const s=e.distanceTo(t)*.5,o=-this.direction.dot(po),a=Ui.dot(this.direction),l=-Ui.dot(po),c=Ui.lengthSq(),u=Math.abs(1-o*o);let f,h,p,_;if(u>0)if(f=o*l-a,h=o*a-l,_=s*u,f>=0)if(h>=-_)if(h<=_){const g=1/u;f*=g,h*=g,p=f*(f+o*h+2*a)+h*(o*f+h+2*l)+c}else h=s,f=Math.max(0,-(o*h+a)),p=-f*f+h*(h+2*l)+c;else h=-s,f=Math.max(0,-(o*h+a)),p=-f*f+h*(h+2*l)+c;else h<=-_?(f=Math.max(0,-(-o*s+a)),h=f>0?-s:Math.min(Math.max(-s,-l),s),p=-f*f+h*(h+2*l)+c):h<=_?(f=0,h=Math.min(Math.max(-s,-l),s),p=h*(h+2*l)+c):(f=Math.max(0,-(o*s+a)),h=f>0?s:Math.min(Math.max(-s,-l),s),p=-f*f+h*(h+2*l)+c);else h=o>0?-s:s,f=Math.max(0,-(o*h+a)),p=-f*f+h*(h+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(Ha).addScaledVector(po,h),p}intersectSphere(e,t){yi.subVectors(e.center,this.origin);const n=yi.dot(this.direction),i=yi.dot(yi)-n*n,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,l=n+o;return 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){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const 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;const c=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,h=this.origin;return c>=0?(n=(e.min.x-h.x)*c,i=(e.max.x-h.x)*c):(n=(e.max.x-h.x)*c,i=(e.min.x-h.x)*c),u>=0?(s=(e.min.y-h.y)*u,o=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,o=(e.min.y-h.y)*u),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o=0?(a=(e.min.z-h.z)*f,l=(e.max.z-h.z)*f):(a=(e.max.z-h.z)*f,l=(e.min.z-h.z)*f),n>l||a>i)||((a>n||n!==n)&&(n=a),(l=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,yi)!==null}intersectTriangle(e,t,n,i,s){Va.subVectors(t,e),mo.subVectors(n,e),Ga.crossVectors(Va,mo);let o=this.direction.dot(Ga),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Ui.subVectors(this.origin,e);const l=a*this.direction.dot(mo.crossVectors(Ui,mo));if(l<0)return null;const c=a*this.direction.dot(Va.cross(Ui));if(c<0||l+c>o)return null;const u=-a*Ui.dot(Ga);return u<0?null:this.at(u/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)}}class Ve{constructor(e,t,n,i,s,o,a,l,c,u,f,h,p,_,g,m){Ve.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,l,c,u,f,h,p,_,g,m)}set(e,t,n,i,s,o,a,l,c,u,f,h,p,_,g,m){const d=this.elements;return d[0]=e,d[4]=t,d[8]=n,d[12]=i,d[1]=s,d[5]=o,d[9]=a,d[13]=l,d[2]=c,d[6]=u,d[10]=f,d[14]=h,d[3]=p,d[7]=_,d[11]=g,d[15]=m,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 Ve().fromArray(this.elements)}copy(e){const 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){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const 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){const t=this.elements,n=e.elements,i=1/Dr.setFromMatrixColumn(e,0).length(),s=1/Dr.setFromMatrixColumn(e,1).length(),o=1/Dr.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){const 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),u=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const h=o*u,p=o*f,_=a*u,g=a*f;t[0]=l*u,t[4]=-l*f,t[8]=c,t[1]=p+_*c,t[5]=h-g*c,t[9]=-a*l,t[2]=g-h*c,t[6]=_+p*c,t[10]=o*l}else if(e.order==="YXZ"){const h=l*u,p=l*f,_=c*u,g=c*f;t[0]=h+g*a,t[4]=_*a-p,t[8]=o*c,t[1]=o*f,t[5]=o*u,t[9]=-a,t[2]=p*a-_,t[6]=g+h*a,t[10]=o*l}else if(e.order==="ZXY"){const h=l*u,p=l*f,_=c*u,g=c*f;t[0]=h-g*a,t[4]=-o*f,t[8]=_+p*a,t[1]=p+_*a,t[5]=o*u,t[9]=g-h*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const h=o*u,p=o*f,_=a*u,g=a*f;t[0]=l*u,t[4]=_*c-p,t[8]=h*c+g,t[1]=l*f,t[5]=g*c+h,t[9]=p*c-_,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const h=o*l,p=o*c,_=a*l,g=a*c;t[0]=l*u,t[4]=g-h*f,t[8]=_*f+p,t[1]=f,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=p*f+_,t[10]=h-g*f}else if(e.order==="XZY"){const h=o*l,p=o*c,_=a*l,g=a*c;t[0]=l*u,t[4]=-f,t[8]=c*u,t[1]=h*f+g,t[5]=o*u,t[9]=p*f-_,t[2]=_*f-p,t[6]=a*u,t[10]=g*f+h}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(Sp,e,wp)}lookAt(e,t,n){const i=this.elements;return Ln.subVectors(e,t),Ln.lengthSq()===0&&(Ln.z=1),Ln.normalize(),Bi.crossVectors(n,Ln),Bi.lengthSq()===0&&(Math.abs(n.z)===1?Ln.x+=1e-4:Ln.z+=1e-4,Ln.normalize(),Bi.crossVectors(n,Ln)),Bi.normalize(),_o.crossVectors(Ln,Bi),i[0]=Bi.x,i[4]=_o.x,i[8]=Ln.x,i[1]=Bi.y,i[5]=_o.y,i[9]=Ln.y,i[2]=Bi.z,i[6]=_o.z,i[10]=Ln.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],f=n[5],h=n[9],p=n[13],_=n[2],g=n[6],m=n[10],d=n[14],x=n[3],v=n[7],y=n[11],b=n[15],M=i[0],T=i[4],I=i[8],E=i[12],A=i[1],z=i[5],O=i[9],W=i[13],D=i[2],V=i[6],Z=i[10],Q=i[14],ce=i[3],ie=i[7],se=i[11],me=i[15];return s[0]=o*M+a*A+l*D+c*ce,s[4]=o*T+a*z+l*V+c*ie,s[8]=o*I+a*O+l*Z+c*se,s[12]=o*E+a*W+l*Q+c*me,s[1]=u*M+f*A+h*D+p*ce,s[5]=u*T+f*z+h*V+p*ie,s[9]=u*I+f*O+h*Z+p*se,s[13]=u*E+f*W+h*Q+p*me,s[2]=_*M+g*A+m*D+d*ce,s[6]=_*T+g*z+m*V+d*ie,s[10]=_*I+g*O+m*Z+d*se,s[14]=_*E+g*W+m*Q+d*me,s[3]=x*M+v*A+y*D+b*ce,s[7]=x*T+v*z+y*V+b*ie,s[11]=x*I+v*O+y*Z+b*se,s[15]=x*E+v*W+y*Q+b*me,this}multiplyScalar(e){const 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(){const 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],u=e[2],f=e[6],h=e[10],p=e[14],_=e[3],g=e[7],m=e[11],d=e[15];return _*(+s*l*f-i*c*f-s*a*h+n*c*h+i*a*p-n*l*p)+g*(+t*l*p-t*c*h+s*o*h-i*o*p+i*c*u-s*l*u)+m*(+t*c*f-t*a*p-s*o*f+n*o*p+s*a*u-n*c*u)+d*(-i*a*u-t*l*f+t*a*h+i*o*f-n*o*h+n*l*u)}transpose(){const e=this.elements;let 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){const 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(){const 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],u=e[8],f=e[9],h=e[10],p=e[11],_=e[12],g=e[13],m=e[14],d=e[15],x=f*m*c-g*h*c+g*l*p-a*m*p-f*l*d+a*h*d,v=_*h*c-u*m*c-_*l*p+o*m*p+u*l*d-o*h*d,y=u*g*c-_*f*c+_*a*p-o*g*p-u*a*d+o*f*d,b=_*f*l-u*g*l-_*a*h+o*g*h+u*a*m-o*f*m,M=t*x+n*v+i*y+s*b;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/M;return e[0]=x*T,e[1]=(g*h*s-f*m*s-g*i*p+n*m*p+f*i*d-n*h*d)*T,e[2]=(a*m*s-g*l*s+g*i*c-n*m*c-a*i*d+n*l*d)*T,e[3]=(f*l*s-a*h*s-f*i*c+n*h*c+a*i*p-n*l*p)*T,e[4]=v*T,e[5]=(u*m*s-_*h*s+_*i*p-t*m*p-u*i*d+t*h*d)*T,e[6]=(_*l*s-o*m*s-_*i*c+t*m*c+o*i*d-t*l*d)*T,e[7]=(o*h*s-u*l*s+u*i*c-t*h*c-o*i*p+t*l*p)*T,e[8]=y*T,e[9]=(_*f*s-u*g*s-_*n*p+t*g*p+u*n*d-t*f*d)*T,e[10]=(o*g*s-_*a*s+_*n*c-t*g*c-o*n*d+t*a*d)*T,e[11]=(u*a*s-o*f*s-u*n*c+t*f*c+o*n*p-t*a*p)*T,e[12]=b*T,e[13]=(u*g*i-_*f*i+_*n*h-t*g*h-u*n*m+t*f*m)*T,e[14]=(_*a*i-o*g*i-_*n*l+t*g*l+o*n*m-t*a*m)*T,e[15]=(o*f*i-u*a*i+u*n*l-t*f*l-o*n*h+t*a*h)*T,this}scale(e){const 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(){const 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 e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const 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){const 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){const 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){const n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+n,u*l-i*o,0,c*l-i*a,u*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){const i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,f=a+a,h=s*c,p=s*u,_=s*f,g=o*u,m=o*f,d=a*f,x=l*c,v=l*u,y=l*f,b=n.x,M=n.y,T=n.z;return i[0]=(1-(g+d))*b,i[1]=(p+y)*b,i[2]=(_-v)*b,i[3]=0,i[4]=(p-y)*M,i[5]=(1-(h+d))*M,i[6]=(m+x)*M,i[7]=0,i[8]=(_+v)*T,i[9]=(m-x)*T,i[10]=(1-(h+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Dr.set(i[0],i[1],i[2]).length();const o=Dr.set(i[4],i[5],i[6]).length(),a=Dr.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],Yn.copy(this);const c=1/s,u=1/o,f=1/a;return Yn.elements[0]*=c,Yn.elements[1]*=c,Yn.elements[2]*=c,Yn.elements[4]*=u,Yn.elements[5]*=u,Yn.elements[6]*=u,Yn.elements[8]*=f,Yn.elements[9]*=f,Yn.elements[10]*=f,t.setFromRotationMatrix(Yn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o,a=Ai){const l=this.elements,c=2*s/(t-e),u=2*s/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i);let p,_;if(a===Ai)p=-(o+s)/(o-s),_=-2*o*s/(o-s);else if(a===fa)p=-o/(o-s),_=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=u,l[9]=h,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,o,a=Ai){const l=this.elements,c=1/(t-e),u=1/(n-i),f=1/(o-s),h=(t+e)*c,p=(n+i)*u;let _,g;if(a===Ai)_=(o+s)*f,g=-2*f;else if(a===fa)_=s*f,g=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-h,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=g,l[14]=-_,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const 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){const 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}}const Dr=new C,Yn=new Ve,Sp=new C(0,0,0),wp=new C(1,1,1),Bi=new C,_o=new C,Ln=new C,du=new Ve,pu=new mi;class ba{constructor(e=0,t=0,n=0,i=ba.DEFAULT_ORDER){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){const i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],u=i[9],f=i[2],h=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(tn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-tn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(tn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-tn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(tn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-tn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,p),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 du.makeRotationFromQuaternion(e),this.setFromRotationMatrix(du,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return pu.setFromEuler(this),this.setFromQuaternion(pu,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}}ba.DEFAULT_ORDER="XYZ";class gf{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.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())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));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&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),f.length>0&&(n.shapes=f),h.length>0&&(n.skeletons=h),p.length>0&&(n.animations=p),_.length>0&&(n.nodes=_)}return n.object=i,n;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){$n.subVectors(i,t),Ei.subVectors(n,t),Wa.subVectors(e,t);const o=$n.dot($n),a=$n.dot(Ei),l=$n.dot(Wa),c=Ei.dot(Ei),u=Ei.dot(Wa),f=o*c-a*a;if(f===0)return s.set(-2,-1,-1);const h=1/f,p=(c*l-a*u)*h,_=(o*u-a*l)*h;return s.set(1-p-_,_,p)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Si),Si.x>=0&&Si.y>=0&&Si.x+Si.y<=1}static getUV(e,t,n,i,s,o,a,l){return vo===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),vo=!0),this.getInterpolation(e,t,n,i,s,o,a,l)}static getInterpolation(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,Si),l.setScalar(0),l.addScaledVector(s,Si.x),l.addScaledVector(o,Si.y),l.addScaledVector(a,Si.z),l}static isFrontFacing(e,t,n,i){return $n.subVectors(n,t),Ei.subVectors(e,t),$n.cross(Ei).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 $n.subVectors(this.c,this.b),Ei.subVectors(this.a,this.b),$n.cross(Ei).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return fn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return fn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return vo===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),vo=!0),fn.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}getInterpolation(e,t,n,i,s){return fn.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return fn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return fn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let o,a;Nr.subVectors(i,n),Fr.subVectors(s,n),Xa.subVectors(e,n);const l=Nr.dot(Xa),c=Fr.dot(Xa);if(l<=0&&c<=0)return t.copy(n);qa.subVectors(e,i);const u=Nr.dot(qa),f=Fr.dot(qa);if(u>=0&&f<=u)return t.copy(i);const h=l*f-u*c;if(h<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(Nr,o);ja.subVectors(e,s);const p=Nr.dot(ja),_=Fr.dot(ja);if(_>=0&&p<=_)return t.copy(s);const g=p*c-l*_;if(g<=0&&c>=0&&_<=0)return a=c/(c-_),t.copy(n).addScaledVector(Fr,a);const m=u*_-p*f;if(m<=0&&f-u>=0&&p-_>=0)return xu.subVectors(s,i),a=(f-u)/(f-u+(p-_)),t.copy(i).addScaledVector(xu,a);const d=1/(m+g+h);return o=g*d,a=h*d,t.copy(n).addScaledVector(Nr,o).addScaledVector(Fr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const vf={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},zi={h:0,s:0,l:0},xo={h:0,s:0,l:0};function Ya(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}class tt{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ht){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=pt.workingColorSpace){return this.r=e,this.g=t,this.b=n,pt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=pt.workingColorSpace){if(e=tc(e,1),t=tn(t,0,1),n=tn(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=Ya(o,s,e+1/3),this.g=Ya(o,s,e),this.b=Ya(o,s,e-1/3)}return pt.toWorkingColorSpace(this,i),this}setStyle(e,t=Ht){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const 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 n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ht){const n=vf[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=ss(e.r),this.g=ss(e.g),this.b=ss(e.b),this}copyLinearToSRGB(e){return this.r=Oa(e.r),this.g=Oa(e.g),this.b=Oa(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ht){return pt.fromWorkingColorSpace(hn.copy(this),e),Math.round(tn(hn.r*255,0,255))*65536+Math.round(tn(hn.g*255,0,255))*256+Math.round(tn(hn.b*255,0,255))}getHexString(e=Ht){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=pt.workingColorSpace){pt.fromWorkingColorSpace(hn.copy(this),t);const n=hn.r,i=hn.g,s=hn.b,o=Math.max(n,i,s),a=Math.min(n,i,s);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=u<=.5?f/(o+a):f/(2-o-a),o){case n:l=(i-s)/f+(i0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,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.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.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&&this.attenuationDistance!==1/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!==rs&&(n.blending=this.blending),this.side!==ei&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Tl&&(n.blendSrc=this.blendSrc),this.blendDst!==Al&&(n.blendDst=this.blendDst),this.blendEquation!==hr&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==aa&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ou&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ar&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ar&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ar&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),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.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),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=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const 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.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,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;const t=e.clippingPlanes;let n=null;if(t!==null){const 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.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,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++}}class Ri extends di{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new tt(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=Qh,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}}const Xt=new C,yo=new Ue;class Yt{constructor(e,t,n=!1){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,this.usage=Il,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=vn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let f=0,h=c.length;f0&&(i[l]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const 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;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],f=s[c];for(let h=0,p=f.length;h0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s(e.far-e.near)**2))&&(yu.copy(s).invert(),ir.copy(e.ray).applyMatrix4(yu),!(n.boundingBox!==null&&ir.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ir)))}_computeIntersections(e,t,n){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,f=s.attributes.normal,h=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let _=0,g=h.length;_t.far?null:{distance:c,point:Ao.clone(),object:r}}function Ro(r,e,t,n,i,s,o,a,l,c){r.getVertexPosition(a,Ur),r.getVertexPosition(l,Br),r.getVertexPosition(c,zr);const u=Dp(r,e,t,n,Ur,Br,zr,To);if(u){i&&(So.fromBufferAttribute(i,a),wo.fromBufferAttribute(i,l),Mo.fromBufferAttribute(i,c),u.uv=fn.getInterpolation(To,Ur,Br,zr,So,wo,Mo,new Ue)),s&&(So.fromBufferAttribute(s,a),wo.fromBufferAttribute(s,l),Mo.fromBufferAttribute(s,c),u.uv1=fn.getInterpolation(To,Ur,Br,zr,So,wo,Mo,new Ue),u.uv2=u.uv1),o&&(Eu.fromBufferAttribute(o,a),Su.fromBufferAttribute(o,l),wu.fromBufferAttribute(o,c),u.normal=fn.getInterpolation(To,Ur,Br,zr,Eu,Su,wu,new C),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const f={a,b:l,c,normal:new C,materialIndex:0};fn.getNormal(Ur,Br,zr,f.normal),u.face=f}return u}class oo extends yn{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};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],u=[],f=[];let h=0,p=0;_("z","y","x",-1,-1,n,t,e,o,s,0),_("z","y","x",1,-1,n,t,-e,o,s,1),_("x","z","y",1,1,e,n,t,i,o,2),_("x","z","y",1,-1,e,n,-t,i,o,3),_("x","y","z",1,-1,e,t,n,i,s,4),_("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new Jn(c,3)),this.setAttribute("normal",new Jn(u,3)),this.setAttribute("uv",new Jn(f,2));function _(g,m,d,x,v,y,b,M,T,I,E){const A=y/T,z=b/I,O=y/2,W=b/2,D=M/2,V=T+1,Z=I+1;let Q=0,ce=0;const ie=new C;for(let se=0;se0?1:-1,u.push(ie.x,ie.y,ie.z),f.push(ve/T),f.push(1-se/I),Q+=1}}for(let se=0;se>8&255]+un[r>>16&255]+un[r>>24&255]+"-"+un[e&255]+un[e>>8&255]+"-"+un[e>>16&15|64]+un[e>>24&255]+"-"+un[t&63|128]+un[t>>8&255]+"-"+un[t>>16&255]+un[t>>24&255]+un[n&255]+un[n>>8&255]+un[n>>16&255]+un[n>>24&255]).toLowerCase()}function tn(r,e,t){return Math.max(e,Math.min(t,r))}function tc(r,e){return(r%e+e)%e}function tp(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function np(r,e,t){return r!==e?(t-r)/(e-r):0}function qs(r,e,t){return(1-t)*r+t*e}function ip(r,e,t,n){return qs(r,e,1-Math.exp(-t*n))}function rp(r,e=1){return e-Math.abs(tc(r,e*2)-e)}function sp(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function op(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function ap(r,e){return r+Math.floor(Math.random()*(e-r+1))}function lp(r,e){return r+Math.random()*(e-r)}function cp(r){return r*(.5-Math.random())}function up(r){r!==void 0&&(lu=r);let e=lu+=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 hp(r){return r*Xs}function fp(r){return r*ds}function Fl(r){return(r&r-1)===0&&r!==0}function dp(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function da(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function pp(r,e,t,n,i){const s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),u=o((e+n)/2),f=s((e-n)/2),h=o((e-n)/2),p=s((n-e)/2),_=o((n-e)/2);switch(i){case"XYX":r.set(a*u,l*f,l*h,a*c);break;case"YZY":r.set(l*h,a*u,l*f,a*c);break;case"ZXZ":r.set(l*f,l*h,a*u,a*c);break;case"XZX":r.set(a*u,l*_,l*p,a*c);break;case"YXY":r.set(l*p,a*u,l*_,a*c);break;case"ZYZ":r.set(l*_,l*p,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function hi(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function bt(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const ff={DEG2RAD:Xs,RAD2DEG:ds,generateUUID:Qn,clamp:tn,euclideanModulo:tc,mapLinear:tp,inverseLerp:np,lerp:qs,damp:ip,pingpong:rp,smoothstep:sp,smootherstep:op,randInt:ap,randFloat:lp,randFloatSpread:cp,seededRandom:up,degToRad:hp,radToDeg:fp,isPowerOfTwo:Fl,ceilPowerOfTwo:dp,floorPowerOfTwo:da,setQuaternionFromProperEuler:pp,normalize:bt,denormalize:hi};class Ue{constructor(e=0,t=0){Ue.prototype.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){return 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){return 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){const 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){const 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=Math.trunc(this.x),this.y=Math.trunc(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}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(tn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const 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){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const 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}}class st{constructor(e,t,n,i,s,o,a,l,c){st.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,l,c)}set(e,t,n,i,s,o,a,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const 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){const 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){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],f=n[7],h=n[2],p=n[5],_=n[8],g=i[0],m=i[3],d=i[6],x=i[1],v=i[4],y=i[7],b=i[2],M=i[5],T=i[8];return s[0]=o*g+a*x+l*b,s[3]=o*m+a*v+l*M,s[6]=o*d+a*y+l*T,s[1]=c*g+u*x+f*b,s[4]=c*m+u*v+f*M,s[7]=c*d+u*y+f*T,s[2]=h*g+p*x+_*b,s[5]=h*m+p*v+_*M,s[8]=h*d+p*y+_*T,this}multiplyScalar(e){const 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(){const 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],u=e[8];return t*o*u-t*a*c-n*s*u+n*a*l+i*s*c-i*o*l}invert(){const 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],u=e[8],f=u*o-a*c,h=a*l-u*s,p=c*s-o*l,_=t*f+n*h+i*p;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/_;return e[0]=f*g,e[1]=(i*c-u*n)*g,e[2]=(a*n-i*o)*g,e[3]=h*g,e[4]=(u*t-i*l)*g,e[5]=(i*s-a*t)*g,e[6]=p*g,e[7]=(n*l-c*t)*g,e[8]=(o*t-n*s)*g,this}transpose(){let e;const 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){const 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){const 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){return this.premultiply(Fa.makeScale(e,t)),this}rotate(e){return this.premultiply(Fa.makeRotation(-e)),this}translate(e,t){return this.premultiply(Fa.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const 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){const 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)}}const Fa=new st;function df(r){for(let e=r.length-1;e>=0;--e)if(r[e]>=65535)return!0;return!1}function to(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function mp(){const r=to("canvas");return r.style.display="block",r}const cu={};function js(r){r in cu||(cu[r]=!0,console.warn(r))}const uu=new st().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),hu=new st().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),co={[an]:{transfer:ca,primaries:ua,toReference:r=>r,fromReference:r=>r},[Ht]:{transfer:At,primaries:ua,toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[ya]:{transfer:ca,primaries:ha,toReference:r=>r.applyMatrix3(hu),fromReference:r=>r.applyMatrix3(uu)},[ec]:{transfer:At,primaries:ha,toReference:r=>r.convertSRGBToLinear().applyMatrix3(hu),fromReference:r=>r.applyMatrix3(uu).convertLinearToSRGB()}},_p=new Set([an,ya]),pt={enabled:!0,_workingColorSpace:an,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(r){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!r},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!_p.has(r))throw new Error(`Unsupported working color space, "${r}".`);this._workingColorSpace=r},convert:function(r,e,t){if(this.enabled===!1||e===t||!e||!t)return r;const n=co[e].toReference,i=co[t].fromReference;return i(n(r))},fromWorkingColorSpace:function(r,e){return this.convert(r,this._workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this._workingColorSpace)},getPrimaries:function(r){return co[r].primaries},getTransfer:function(r){return r===Vn?ca:co[r].transfer}};function ss(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Oa(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Rr;class pf{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Rr===void 0&&(Rr=to("canvas")),Rr.width=e.width,Rr.height=e.height;const n=Rr.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Rr}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){const t=to("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Jh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case us:e.x=e.x-Math.floor(e.x);break;case Hn:e.x=e.x<0?0:1;break;case la: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 us:e.y=e.y-Math.floor(e.y);break;case Hn:e.y=e.y<0?0:1;break;case la: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)}get encoding(){return js("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ht?$i:cf}set encoding(e){js("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===$i?Ht:Vn}}on.DEFAULT_IMAGE=null;on.DEFAULT_MAPPING=Jh;on.DEFAULT_ANISOTROPY=1;class mt{constructor(e=0,t=0,n=0,i=1){mt.prototype.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){return 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){return 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){const 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);const 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;const l=e.elements,c=l[0],u=l[4],f=l[8],h=l[1],p=l[5],_=l[9],g=l[2],m=l[6],d=l[10];if(Math.abs(u-h)<.01&&Math.abs(f-g)<.01&&Math.abs(_-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(f+g)<.1&&Math.abs(_+m)<.1&&Math.abs(c+p+d-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(c+1)/2,y=(p+1)/2,b=(d+1)/2,M=(u+h)/4,T=(f+g)/4,I=(_+m)/4;return v>y&&v>b?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=M/n,s=T/n):y>b?y<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(y),n=M/i,s=I/i):b<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(b),n=T/s,i=I/s),this.set(n,i,s,t),this}let x=Math.sqrt((m-_)*(m-_)+(f-g)*(f-g)+(h-u)*(h-u));return Math.abs(x)<.001&&(x=1),this.x=(m-_)/x,this.y=(f-g)/x,this.z=(h-u)/x,this.w=Math.acos((c+p+d-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){const 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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(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){return 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}}class xp extends xr{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new mt(0,0,e,t),this.scissorTest=!1,this.viewport=new mt(0,0,e,t);const i={width:e,height:t,depth:1};n.encoding!==void 0&&(js("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===$i?Ht:Vn),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:En,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},n),this.texture=new on(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps,this.texture.internalFormat=n.internalFormat,this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}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.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new mf(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"})}}class Ki extends xp{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class _f extends on{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=Nt,this.minFilter=Nt,this.wrapR=Hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class yp extends on{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=Nt,this.minFilter=Nt,this.wrapR=Hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class mi{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 slerpFlat(e,t,n,i,s,o,a){let l=n[i+0],c=n[i+1],u=n[i+2],f=n[i+3];const h=s[o+0],p=s[o+1],_=s[o+2],g=s[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=f;return}if(a===1){e[t+0]=h,e[t+1]=p,e[t+2]=_,e[t+3]=g;return}if(f!==g||l!==h||c!==p||u!==_){let m=1-a;const d=l*h+c*p+u*_+f*g,x=d>=0?1:-1,v=1-d*d;if(v>Number.EPSILON){const b=Math.sqrt(v),M=Math.atan2(b,d*x);m=Math.sin(m*M)/b,a=Math.sin(a*M)/b}const y=a*x;if(l=l*m+h*y,c=c*m+p*y,u=u*m+_*y,f=f*m+g*y,m===1-a){const b=1/Math.sqrt(l*l+c*c+u*u+f*f);l*=b,c*=b,u*=b,f*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,i,s,o){const a=n[i],l=n[i+1],c=n[i+2],u=n[i+3],f=s[o],h=s[o+1],p=s[o+2],_=s[o+3];return e[t]=a*_+u*f+l*p-c*h,e[t+1]=l*_+u*h+c*f-a*p,e[t+2]=c*_+u*p+a*h-l*f,e[t+3]=u*_-a*f-l*h-c*p,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){const n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(i/2),f=a(s/2),h=l(n/2),p=l(i/2),_=l(s/2);switch(o){case"XYZ":this._x=h*u*f+c*p*_,this._y=c*p*f-h*u*_,this._z=c*u*_+h*p*f,this._w=c*u*f-h*p*_;break;case"YXZ":this._x=h*u*f+c*p*_,this._y=c*p*f-h*u*_,this._z=c*u*_-h*p*f,this._w=c*u*f+h*p*_;break;case"ZXY":this._x=h*u*f-c*p*_,this._y=c*p*f+h*u*_,this._z=c*u*_+h*p*f,this._w=c*u*f-h*p*_;break;case"ZYX":this._x=h*u*f-c*p*_,this._y=c*p*f+h*u*_,this._z=c*u*_-h*p*f,this._w=c*u*f+h*p*_;break;case"YZX":this._x=h*u*f+c*p*_,this._y=c*p*f+h*u*_,this._z=c*u*_-h*p*f,this._w=c*u*f-h*p*_;break;case"XZY":this._x=h*u*f-c*p*_,this._y=c*p*f-h*u*_,this._z=c*u*_+h*p*f,this._w=c*u*f+h*p*_;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const 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){const t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],f=t[10],h=n+a+f;if(h>0){const p=.5/Math.sqrt(h+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(o-i)*p}else if(n>a&&n>f){const p=2*Math.sqrt(1+n-a-f);this._w=(u-l)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+c)/p}else if(a>f){const p=2*Math.sqrt(1+a-n-f);this._w=(s-c)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+f-n-a);this._w=(o-i)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.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(tn(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const 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){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+i*c-s*l,this._y=i*u+o*l+s*a-n*c,this._z=s*u+o*c+n*l-i*a,this._w=o*u-n*a-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,o=this._w;let 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;const l=1-a*a;if(l<=Number.EPSILON){const p=1-t;return this._w=p*o+t*this._w,this._x=p*n+t*this._x,this._y=p*i+t*this._y,this._z=p*s+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),f=Math.sin((1-t)*u)/c,h=Math.sin(t*u)/c;return this._w=o*f+this._w*h,this._x=n*f+this._x*h,this._y=i*f+this._y*h,this._z=s*f+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const 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}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class C{constructor(e=0,t=0,n=0){C.prototype.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){return 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){return 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){return 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 this.applyQuaternion(fu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fu.setFromAxisAngle(e,t))}applyMatrix3(e){const 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){const 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){const t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*i-a*n),u=2*(a*t-s*i),f=2*(s*n-o*t);return this.x=t+l*c+o*f-a*u,this.y=n+l*u+a*c-s*f,this.z=i+l*f+s*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const 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){const 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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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){return this.crossVectors(this,e)}crossVectors(e,t){const 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){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ba.copy(this).projectOnVector(e),this.sub(Ba)}reflect(e){return this.sub(Ba.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(tn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const 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){const 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){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const 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}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,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){return 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(){const 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}}const Ba=new C,fu=new mi;class $t{constructor(e=new C(1/0,1/0,1/0),t=new C(-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){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,jn),jn.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(Ts),ho.subVectors(this.max,Ts),Lr.subVectors(e.a,Ts),Cr.subVectors(e.b,Ts),Pr.subVectors(e.c,Ts),Fi.subVectors(Cr,Lr),Oi.subVectors(Pr,Cr),tr.subVectors(Lr,Pr);let t=[0,-Fi.z,Fi.y,0,-Oi.z,Oi.y,0,-tr.z,tr.y,Fi.z,0,-Fi.x,Oi.z,0,-Oi.x,tr.z,0,-tr.x,-Fi.y,Fi.x,0,-Oi.y,Oi.x,0,-tr.y,tr.x,0];return!za(t,Lr,Cr,Pr,ho)||(t=[1,0,0,0,1,0,0,0,1],!za(t,Lr,Cr,Pr,ho))?!1:(fo.crossVectors(Fi,Oi),t=[fo.x,fo.y,fo.z],za(t,Lr,Cr,Pr,ho))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(jn).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:(xi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),xi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),xi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),xi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),xi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),xi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),xi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),xi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(xi),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)}}const xi=[new C,new C,new C,new C,new C,new C,new C,new C],jn=new C,uo=new $t,Lr=new C,Cr=new C,Pr=new C,Fi=new C,Oi=new C,tr=new C,Ts=new C,ho=new C,fo=new C,nr=new C;function za(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){nr.fromArray(r,s);const a=i.x*Math.abs(nr.x)+i.y*Math.abs(nr.y)+i.z*Math.abs(nr.z),l=e.dot(nr),c=t.dot(nr),u=n.dot(nr);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const bp=new $t,As=new C,ka=new C;class ni{constructor(e=new C,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):bp.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;sthis.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){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;As.subVectors(e,this.center);const t=As.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(As,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ka.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(As.copy(e.center).add(ka)),this.expandByPoint(As.copy(e.center).sub(ka))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const yi=new C,Ha=new C,po=new C,Ui=new C,Va=new C,mo=new C,Ga=new C;class so{constructor(e=new C,t=new C(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.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,yi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=yi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(yi.copy(this.origin).addScaledVector(this.direction,t),yi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Ha.copy(e).add(t).multiplyScalar(.5),po.copy(t).sub(e).normalize(),Ui.copy(this.origin).sub(Ha);const s=e.distanceTo(t)*.5,o=-this.direction.dot(po),a=Ui.dot(this.direction),l=-Ui.dot(po),c=Ui.lengthSq(),u=Math.abs(1-o*o);let f,h,p,_;if(u>0)if(f=o*l-a,h=o*a-l,_=s*u,f>=0)if(h>=-_)if(h<=_){const g=1/u;f*=g,h*=g,p=f*(f+o*h+2*a)+h*(o*f+h+2*l)+c}else h=s,f=Math.max(0,-(o*h+a)),p=-f*f+h*(h+2*l)+c;else h=-s,f=Math.max(0,-(o*h+a)),p=-f*f+h*(h+2*l)+c;else h<=-_?(f=Math.max(0,-(-o*s+a)),h=f>0?-s:Math.min(Math.max(-s,-l),s),p=-f*f+h*(h+2*l)+c):h<=_?(f=0,h=Math.min(Math.max(-s,-l),s),p=h*(h+2*l)+c):(f=Math.max(0,-(o*s+a)),h=f>0?s:Math.min(Math.max(-s,-l),s),p=-f*f+h*(h+2*l)+c);else h=o>0?-s:s,f=Math.max(0,-(o*h+a)),p=-f*f+h*(h+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(Ha).addScaledVector(po,h),p}intersectSphere(e,t){yi.subVectors(e.center,this.origin);const n=yi.dot(this.direction),i=yi.dot(yi)-n*n,s=e.radius*e.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=n-o,l=n+o;return 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){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const 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;const c=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,h=this.origin;return c>=0?(n=(e.min.x-h.x)*c,i=(e.max.x-h.x)*c):(n=(e.max.x-h.x)*c,i=(e.min.x-h.x)*c),u>=0?(s=(e.min.y-h.y)*u,o=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,o=(e.min.y-h.y)*u),n>o||s>i||((s>n||isNaN(n))&&(n=s),(o=0?(a=(e.min.z-h.z)*f,l=(e.max.z-h.z)*f):(a=(e.max.z-h.z)*f,l=(e.min.z-h.z)*f),n>l||a>i)||((a>n||n!==n)&&(n=a),(l=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,yi)!==null}intersectTriangle(e,t,n,i,s){Va.subVectors(t,e),mo.subVectors(n,e),Ga.crossVectors(Va,mo);let o=this.direction.dot(Ga),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Ui.subVectors(this.origin,e);const l=a*this.direction.dot(mo.crossVectors(Ui,mo));if(l<0)return null;const c=a*this.direction.dot(Va.cross(Ui));if(c<0||l+c>o)return null;const u=-a*Ui.dot(Ga);return u<0?null:this.at(u/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)}}class Ve{constructor(e,t,n,i,s,o,a,l,c,u,f,h,p,_,g,m){Ve.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,o,a,l,c,u,f,h,p,_,g,m)}set(e,t,n,i,s,o,a,l,c,u,f,h,p,_,g,m){const d=this.elements;return d[0]=e,d[4]=t,d[8]=n,d[12]=i,d[1]=s,d[5]=o,d[9]=a,d[13]=l,d[2]=c,d[6]=u,d[10]=f,d[14]=h,d[3]=p,d[7]=_,d[11]=g,d[15]=m,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 Ve().fromArray(this.elements)}copy(e){const 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){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const 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){const t=this.elements,n=e.elements,i=1/Dr.setFromMatrixColumn(e,0).length(),s=1/Dr.setFromMatrixColumn(e,1).length(),o=1/Dr.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){const 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),u=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const h=o*u,p=o*f,_=a*u,g=a*f;t[0]=l*u,t[4]=-l*f,t[8]=c,t[1]=p+_*c,t[5]=h-g*c,t[9]=-a*l,t[2]=g-h*c,t[6]=_+p*c,t[10]=o*l}else if(e.order==="YXZ"){const h=l*u,p=l*f,_=c*u,g=c*f;t[0]=h+g*a,t[4]=_*a-p,t[8]=o*c,t[1]=o*f,t[5]=o*u,t[9]=-a,t[2]=p*a-_,t[6]=g+h*a,t[10]=o*l}else if(e.order==="ZXY"){const h=l*u,p=l*f,_=c*u,g=c*f;t[0]=h-g*a,t[4]=-o*f,t[8]=_+p*a,t[1]=p+_*a,t[5]=o*u,t[9]=g-h*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const h=o*u,p=o*f,_=a*u,g=a*f;t[0]=l*u,t[4]=_*c-p,t[8]=h*c+g,t[1]=l*f,t[5]=g*c+h,t[9]=p*c-_,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const h=o*l,p=o*c,_=a*l,g=a*c;t[0]=l*u,t[4]=g-h*f,t[8]=_*f+p,t[1]=f,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=p*f+_,t[10]=h-g*f}else if(e.order==="XZY"){const h=o*l,p=o*c,_=a*l,g=a*c;t[0]=l*u,t[4]=-f,t[8]=c*u,t[1]=h*f+g,t[5]=o*u,t[9]=p*f-_,t[2]=_*f-p,t[6]=a*u,t[10]=g*f+h}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(Sp,e,Ep)}lookAt(e,t,n){const i=this.elements;return Ln.subVectors(e,t),Ln.lengthSq()===0&&(Ln.z=1),Ln.normalize(),Bi.crossVectors(n,Ln),Bi.lengthSq()===0&&(Math.abs(n.z)===1?Ln.x+=1e-4:Ln.z+=1e-4,Ln.normalize(),Bi.crossVectors(n,Ln)),Bi.normalize(),_o.crossVectors(Ln,Bi),i[0]=Bi.x,i[4]=_o.x,i[8]=Ln.x,i[1]=Bi.y,i[5]=_o.y,i[9]=Ln.y,i[2]=Bi.z,i[6]=_o.z,i[10]=Ln.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],f=n[5],h=n[9],p=n[13],_=n[2],g=n[6],m=n[10],d=n[14],x=n[3],v=n[7],y=n[11],b=n[15],M=i[0],T=i[4],I=i[8],S=i[12],A=i[1],z=i[5],O=i[9],W=i[13],D=i[2],V=i[6],Z=i[10],Q=i[14],ce=i[3],ie=i[7],se=i[11],me=i[15];return s[0]=o*M+a*A+l*D+c*ce,s[4]=o*T+a*z+l*V+c*ie,s[8]=o*I+a*O+l*Z+c*se,s[12]=o*S+a*W+l*Q+c*me,s[1]=u*M+f*A+h*D+p*ce,s[5]=u*T+f*z+h*V+p*ie,s[9]=u*I+f*O+h*Z+p*se,s[13]=u*S+f*W+h*Q+p*me,s[2]=_*M+g*A+m*D+d*ce,s[6]=_*T+g*z+m*V+d*ie,s[10]=_*I+g*O+m*Z+d*se,s[14]=_*S+g*W+m*Q+d*me,s[3]=x*M+v*A+y*D+b*ce,s[7]=x*T+v*z+y*V+b*ie,s[11]=x*I+v*O+y*Z+b*se,s[15]=x*S+v*W+y*Q+b*me,this}multiplyScalar(e){const 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(){const 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],u=e[2],f=e[6],h=e[10],p=e[14],_=e[3],g=e[7],m=e[11],d=e[15];return _*(+s*l*f-i*c*f-s*a*h+n*c*h+i*a*p-n*l*p)+g*(+t*l*p-t*c*h+s*o*h-i*o*p+i*c*u-s*l*u)+m*(+t*c*f-t*a*p-s*o*f+n*o*p+s*a*u-n*c*u)+d*(-i*a*u-t*l*f+t*a*h+i*o*f-n*o*h+n*l*u)}transpose(){const e=this.elements;let 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){const 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(){const 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],u=e[8],f=e[9],h=e[10],p=e[11],_=e[12],g=e[13],m=e[14],d=e[15],x=f*m*c-g*h*c+g*l*p-a*m*p-f*l*d+a*h*d,v=_*h*c-u*m*c-_*l*p+o*m*p+u*l*d-o*h*d,y=u*g*c-_*f*c+_*a*p-o*g*p-u*a*d+o*f*d,b=_*f*l-u*g*l-_*a*h+o*g*h+u*a*m-o*f*m,M=t*x+n*v+i*y+s*b;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/M;return e[0]=x*T,e[1]=(g*h*s-f*m*s-g*i*p+n*m*p+f*i*d-n*h*d)*T,e[2]=(a*m*s-g*l*s+g*i*c-n*m*c-a*i*d+n*l*d)*T,e[3]=(f*l*s-a*h*s-f*i*c+n*h*c+a*i*p-n*l*p)*T,e[4]=v*T,e[5]=(u*m*s-_*h*s+_*i*p-t*m*p-u*i*d+t*h*d)*T,e[6]=(_*l*s-o*m*s-_*i*c+t*m*c+o*i*d-t*l*d)*T,e[7]=(o*h*s-u*l*s+u*i*c-t*h*c-o*i*p+t*l*p)*T,e[8]=y*T,e[9]=(_*f*s-u*g*s-_*n*p+t*g*p+u*n*d-t*f*d)*T,e[10]=(o*g*s-_*a*s+_*n*c-t*g*c-o*n*d+t*a*d)*T,e[11]=(u*a*s-o*f*s-u*n*c+t*f*c+o*n*p-t*a*p)*T,e[12]=b*T,e[13]=(u*g*i-_*f*i+_*n*h-t*g*h-u*n*m+t*f*m)*T,e[14]=(_*a*i-o*g*i-_*n*l+t*g*l+o*n*m-t*a*m)*T,e[15]=(o*f*i-u*a*i+u*n*l-t*f*l-o*n*h+t*a*h)*T,this}scale(e){const 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(){const 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 e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const 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){const 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){const 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){const n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,c=s*o,u=s*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+n,u*l-i*o,0,c*l-i*a,u*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){const i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,c=s+s,u=o+o,f=a+a,h=s*c,p=s*u,_=s*f,g=o*u,m=o*f,d=a*f,x=l*c,v=l*u,y=l*f,b=n.x,M=n.y,T=n.z;return i[0]=(1-(g+d))*b,i[1]=(p+y)*b,i[2]=(_-v)*b,i[3]=0,i[4]=(p-y)*M,i[5]=(1-(h+d))*M,i[6]=(m+x)*M,i[7]=0,i[8]=(_+v)*T,i[9]=(m-x)*T,i[10]=(1-(h+g))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=Dr.set(i[0],i[1],i[2]).length();const o=Dr.set(i[4],i[5],i[6]).length(),a=Dr.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],Yn.copy(this);const c=1/s,u=1/o,f=1/a;return Yn.elements[0]*=c,Yn.elements[1]*=c,Yn.elements[2]*=c,Yn.elements[4]*=u,Yn.elements[5]*=u,Yn.elements[6]*=u,Yn.elements[8]*=f,Yn.elements[9]*=f,Yn.elements[10]*=f,t.setFromRotationMatrix(Yn),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o,a=Ai){const l=this.elements,c=2*s/(t-e),u=2*s/(n-i),f=(t+e)/(t-e),h=(n+i)/(n-i);let p,_;if(a===Ai)p=-(o+s)/(o-s),_=-2*o*s/(o-s);else if(a===fa)p=-o/(o-s),_=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=u,l[9]=h,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,s,o,a=Ai){const l=this.elements,c=1/(t-e),u=1/(n-i),f=1/(o-s),h=(t+e)*c,p=(n+i)*u;let _,g;if(a===Ai)_=(o+s)*f,g=-2*f;else if(a===fa)_=s*f,g=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-h,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=g,l[14]=-_,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const 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){const 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}}const Dr=new C,Yn=new Ve,Sp=new C(0,0,0),Ep=new C(1,1,1),Bi=new C,_o=new C,Ln=new C,du=new Ve,pu=new mi;class ba{constructor(e=0,t=0,n=0,i=ba.DEFAULT_ORDER){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){const i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],u=i[9],f=i[2],h=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(tn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-tn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(tn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-tn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(tn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-tn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,p),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 du.makeRotationFromQuaternion(e),this.setFromRotationMatrix(du,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return pu.setFromEuler(this),this.setFromQuaternion(pu,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}}ba.DEFAULT_ORDER="XYZ";class gf{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.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())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));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&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),f.length>0&&(n.shapes=f),h.length>0&&(n.skeletons=h),p.length>0&&(n.animations=p),_.length>0&&(n.nodes=_)}return n.object=i,n;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){$n.subVectors(i,t),Si.subVectors(n,t),Wa.subVectors(e,t);const o=$n.dot($n),a=$n.dot(Si),l=$n.dot(Wa),c=Si.dot(Si),u=Si.dot(Wa),f=o*c-a*a;if(f===0)return s.set(-2,-1,-1);const h=1/f,p=(c*l-a*u)*h,_=(o*u-a*l)*h;return s.set(1-p-_,_,p)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ei),Ei.x>=0&&Ei.y>=0&&Ei.x+Ei.y<=1}static getUV(e,t,n,i,s,o,a,l){return vo===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),vo=!0),this.getInterpolation(e,t,n,i,s,o,a,l)}static getInterpolation(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,Ei),l.setScalar(0),l.addScaledVector(s,Ei.x),l.addScaledVector(o,Ei.y),l.addScaledVector(a,Ei.z),l}static isFrontFacing(e,t,n,i){return $n.subVectors(n,t),Si.subVectors(e,t),$n.cross(Si).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 $n.subVectors(this.c,this.b),Si.subVectors(this.a,this.b),$n.cross(Si).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return fn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return fn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return vo===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),vo=!0),fn.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}getInterpolation(e,t,n,i,s){return fn.getInterpolation(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return fn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return fn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,s=this.c;let o,a;Nr.subVectors(i,n),Fr.subVectors(s,n),Xa.subVectors(e,n);const l=Nr.dot(Xa),c=Fr.dot(Xa);if(l<=0&&c<=0)return t.copy(n);qa.subVectors(e,i);const u=Nr.dot(qa),f=Fr.dot(qa);if(u>=0&&f<=u)return t.copy(i);const h=l*f-u*c;if(h<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(Nr,o);ja.subVectors(e,s);const p=Nr.dot(ja),_=Fr.dot(ja);if(_>=0&&p<=_)return t.copy(s);const g=p*c-l*_;if(g<=0&&c>=0&&_<=0)return a=c/(c-_),t.copy(n).addScaledVector(Fr,a);const m=u*_-p*f;if(m<=0&&f-u>=0&&p-_>=0)return xu.subVectors(s,i),a=(f-u)/(f-u+(p-_)),t.copy(i).addScaledVector(xu,a);const d=1/(m+g+h);return o=g*d,a=h*d,t.copy(n).addScaledVector(Nr,o).addScaledVector(Fr,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const vf={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},zi={h:0,s:0,l:0},xo={h:0,s:0,l:0};function Ya(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}class tt{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ht){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=pt.workingColorSpace){return this.r=e,this.g=t,this.b=n,pt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=pt.workingColorSpace){if(e=tc(e,1),t=tn(t,0,1),n=tn(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=Ya(o,s,e+1/3),this.g=Ya(o,s,e),this.b=Ya(o,s,e-1/3)}return pt.toWorkingColorSpace(this,i),this}setStyle(e,t=Ht){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const 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 n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ht){const n=vf[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=ss(e.r),this.g=ss(e.g),this.b=ss(e.b),this}copyLinearToSRGB(e){return this.r=Oa(e.r),this.g=Oa(e.g),this.b=Oa(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ht){return pt.fromWorkingColorSpace(hn.copy(this),e),Math.round(tn(hn.r*255,0,255))*65536+Math.round(tn(hn.g*255,0,255))*256+Math.round(tn(hn.b*255,0,255))}getHexString(e=Ht){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=pt.workingColorSpace){pt.fromWorkingColorSpace(hn.copy(this),t);const n=hn.r,i=hn.g,s=hn.b,o=Math.max(n,i,s),a=Math.min(n,i,s);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=u<=.5?f/(o+a):f/(2-o-a),o){case n:l=(i-s)/f+(i0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,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.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.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&&this.attenuationDistance!==1/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!==rs&&(n.blending=this.blending),this.side!==ei&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Tl&&(n.blendSrc=this.blendSrc),this.blendDst!==Al&&(n.blendDst=this.blendDst),this.blendEquation!==hr&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==aa&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ou&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ar&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ar&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ar&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),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.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),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=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(t){const 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.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,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;const t=e.clippingPlanes;let n=null;if(t!==null){const 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.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,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++}}class Ri extends di{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new tt(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=Qh,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}}const Xt=new C,yo=new Ue;class Yt{constructor(e,t,n=!1){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,this.usage=Il,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=vn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let f=0,h=c.length;f0&&(i[l]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const 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;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],f=s[c];for(let h=0,p=f.length;h0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s(e.far-e.near)**2))&&(yu.copy(s).invert(),ir.copy(e.ray).applyMatrix4(yu),!(n.boundingBox!==null&&ir.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ir)))}_computeIntersections(e,t,n){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,f=s.attributes.normal,h=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let _=0,g=h.length;_t.far?null:{distance:c,point:Ao.clone(),object:r}}function Ro(r,e,t,n,i,s,o,a,l,c){r.getVertexPosition(a,Ur),r.getVertexPosition(l,Br),r.getVertexPosition(c,zr);const u=Pp(r,e,t,n,Ur,Br,zr,To);if(u){i&&(Eo.fromBufferAttribute(i,a),wo.fromBufferAttribute(i,l),Mo.fromBufferAttribute(i,c),u.uv=fn.getInterpolation(To,Ur,Br,zr,Eo,wo,Mo,new Ue)),s&&(Eo.fromBufferAttribute(s,a),wo.fromBufferAttribute(s,l),Mo.fromBufferAttribute(s,c),u.uv1=fn.getInterpolation(To,Ur,Br,zr,Eo,wo,Mo,new Ue),u.uv2=u.uv1),o&&(Su.fromBufferAttribute(o,a),Eu.fromBufferAttribute(o,l),wu.fromBufferAttribute(o,c),u.normal=fn.getInterpolation(To,Ur,Br,zr,Su,Eu,wu,new C),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const f={a,b:l,c,normal:new C,materialIndex:0};fn.getNormal(Ur,Br,zr,f.normal),u.face=f}return u}class oo extends yn{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};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],u=[],f=[];let h=0,p=0;_("z","y","x",-1,-1,n,t,e,o,s,0),_("z","y","x",1,-1,n,t,-e,o,s,1),_("x","z","y",1,1,e,n,t,i,o,2),_("x","z","y",1,-1,e,n,-t,i,o,3),_("x","y","z",1,-1,e,t,n,i,s,4),_("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new Jn(c,3)),this.setAttribute("normal",new Jn(u,3)),this.setAttribute("uv",new Jn(f,2));function _(g,m,d,x,v,y,b,M,T,I,S){const A=y/T,z=b/I,O=y/2,W=b/2,D=M/2,V=T+1,Z=I+1;let Q=0,ce=0;const ie=new C;for(let se=0;se0?1:-1,u.push(ie.x,ie.y,ie.z),f.push(ve/T),f.push(1-se/I),Q+=1}}for(let se=0;se0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Ef extends Bt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ve,this.projectionMatrix=new Ve,this.projectionMatrixInverse=new Ve,this.coordinateSystem=Ai}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class _n extends Ef{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ds*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Xs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ds*2*Math.atan(Math.tan(Xs*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,o){this.aspect=e/t,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(){const e=this.near;let t=e*Math.tan(Xs*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,t-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const kr=-90,Hr=1;class Up extends Bt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new _n(kr,Hr,e,t);i.layers=this.layers,this.add(i);const s=new _n(kr,Hr,e,t);s.layers=this.layers,this.add(s);const o=new _n(kr,Hr,e,t);o.layers=this.layers,this.add(o);const a=new _n(kr,Hr,e,t);a.layers=this.layers,this.add(a);const l=new _n(kr,Hr,e,t);l.layers=this.layers,this.add(l);const c=new _n(kr,Hr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,s,o,a,l]=t;for(const c of t)this.remove(c);if(e===Ai)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===fa)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,l,c,u]=this.children,f=e.getRenderTarget(),h=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,s),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(f,h,p),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}}class Sf extends on{constructor(e,t,n,i,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:ls,super(e,t,n,i,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Bp extends Ki{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];t.encoding!==void 0&&(js("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===$i?Ht:Vn),this.texture=new Sf(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Sn}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` +}`;class Zi extends di{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Np,this.fragmentShader=Fp,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ps(e.uniforms),this.uniformsGroups=Dp(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Sf extends Bt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ve,this.projectionMatrix=new Ve,this.projectionMatrixInverse=new Ve,this.coordinateSystem=Ai}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class _n extends Sf{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ds*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Xs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ds*2*Math.atan(Math.tan(Xs*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,s,o){this.aspect=e/t,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(){const e=this.near;let t=e*Math.tan(Xs*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,s=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,t-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const kr=-90,Hr=1;class Op extends Bt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new _n(kr,Hr,e,t);i.layers=this.layers,this.add(i);const s=new _n(kr,Hr,e,t);s.layers=this.layers,this.add(s);const o=new _n(kr,Hr,e,t);o.layers=this.layers,this.add(o);const a=new _n(kr,Hr,e,t);a.layers=this.layers,this.add(a);const l=new _n(kr,Hr,e,t);l.layers=this.layers,this.add(l);const c=new _n(kr,Hr,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,s,o,a,l]=t;for(const c of t)this.remove(c);if(e===Ai)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===fa)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,l,c,u]=this.children,f=e.getRenderTarget(),h=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const g=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,s),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=g,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(f,h,p),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}}class Ef extends on{constructor(e,t,n,i,s,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:ls,super(e,t,n,i,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Up extends Ki{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];t.encoding!==void 0&&(js("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===$i?Ht:Vn),this.texture=new Ef(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:En}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -41,9 +41,9 @@ gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},i=new oo(5,5,5),s=new Zi({name:"CubemapFromEquirect",uniforms:ps(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:xn,blending:ji});s.uniforms.tEquirect.value=t;const o=new Mn(i,s),a=t.minFilter;return t.minFilter===gr&&(t.minFilter=Sn),new Up(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}}const Za=new C,zp=new C,kp=new st;class ci{constructor(e=new C(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){const i=Za.subVectors(n,t).cross(zp.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const 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(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Za),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const 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){const n=t||kp.getNormalMatrix(e),i=this.coplanarPoint(Za).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)}}const rr=new ni,Lo=new C;class nc{constructor(e=new ci,t=new ci,n=new ci,i=new ci,s=new ci,o=new ci){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){const 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){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ai){const n=this.planes,i=e.elements,s=i[0],o=i[1],a=i[2],l=i[3],c=i[4],u=i[5],f=i[6],h=i[7],p=i[8],_=i[9],g=i[10],m=i[11],d=i[12],x=i[13],v=i[14],y=i[15];if(n[0].setComponents(l-s,h-c,m-p,y-d).normalize(),n[1].setComponents(l+s,h+c,m+p,y+d).normalize(),n[2].setComponents(l+o,h+u,m+_,y+x).normalize(),n[3].setComponents(l-o,h-u,m-_,y-x).normalize(),n[4].setComponents(l-a,h-f,m-g,y-v).normalize(),t===Ai)n[5].setComponents(l+a,h+f,m+g,y+v).normalize();else if(t===fa)n[5].setComponents(a,f,g,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),rr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),rr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(rr)}intersectsSprite(e){return rr.center.set(0,0,0),rr.radius=.7071067811865476,rr.applyMatrix4(e.matrixWorld),this.intersectsSphere(rr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,Lo.y=i.normal.y>0?e.max.y:e.min.y,Lo.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Lo)<0)return!1}return!0}containsPoint(e){const 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 wf(){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 Hp(r,e){const t=e.isWebGL2,n=new WeakMap;function i(c,u){const f=c.array,h=c.usage,p=f.byteLength,_=r.createBuffer();r.bindBuffer(u,_),r.bufferData(u,f,h),c.onUploadCallback();let g;if(f instanceof Float32Array)g=r.FLOAT;else if(f instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)g=r.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else g=r.UNSIGNED_SHORT;else if(f instanceof Int16Array)g=r.SHORT;else if(f instanceof Uint32Array)g=r.UNSIGNED_INT;else if(f instanceof Int32Array)g=r.INT;else if(f instanceof Int8Array)g=r.BYTE;else if(f instanceof Uint8Array)g=r.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)g=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:_,type:g,bytesPerElement:f.BYTES_PER_ELEMENT,version:c.version,size:p}}function s(c,u,f){const h=u.array,p=u._updateRange,_=u.updateRanges;if(r.bindBuffer(f,c),p.count===-1&&_.length===0&&r.bufferSubData(f,0,h),_.length!==0){for(let g=0,m=_.length;g1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const 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){const n=t||zp.getNormalMatrix(e),i=this.coplanarPoint(Za).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)}}const rr=new ni,Lo=new C;class nc{constructor(e=new ci,t=new ci,n=new ci,i=new ci,s=new ci,o=new ci){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){const 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){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ai){const n=this.planes,i=e.elements,s=i[0],o=i[1],a=i[2],l=i[3],c=i[4],u=i[5],f=i[6],h=i[7],p=i[8],_=i[9],g=i[10],m=i[11],d=i[12],x=i[13],v=i[14],y=i[15];if(n[0].setComponents(l-s,h-c,m-p,y-d).normalize(),n[1].setComponents(l+s,h+c,m+p,y+d).normalize(),n[2].setComponents(l+o,h+u,m+_,y+x).normalize(),n[3].setComponents(l-o,h-u,m-_,y-x).normalize(),n[4].setComponents(l-a,h-f,m-g,y-v).normalize(),t===Ai)n[5].setComponents(l+a,h+f,m+g,y+v).normalize();else if(t===fa)n[5].setComponents(a,f,g,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),rr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),rr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(rr)}intersectsSprite(e){return rr.center.set(0,0,0),rr.radius=.7071067811865476,rr.applyMatrix4(e.matrixWorld),this.intersectsSphere(rr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)0?e.max.x:e.min.x,Lo.y=i.normal.y>0?e.max.y:e.min.y,Lo.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Lo)<0)return!1}return!0}containsPoint(e){const 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 wf(){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 kp(r,e){const t=e.isWebGL2,n=new WeakMap;function i(c,u){const f=c.array,h=c.usage,p=f.byteLength,_=r.createBuffer();r.bindBuffer(u,_),r.bufferData(u,f,h),c.onUploadCallback();let g;if(f instanceof Float32Array)g=r.FLOAT;else if(f instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)g=r.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else g=r.UNSIGNED_SHORT;else if(f instanceof Int16Array)g=r.SHORT;else if(f instanceof Uint32Array)g=r.UNSIGNED_INT;else if(f instanceof Int32Array)g=r.INT;else if(f instanceof Int8Array)g=r.BYTE;else if(f instanceof Uint8Array)g=r.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)g=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:_,type:g,bytesPerElement:f.BYTES_PER_ELEMENT,version:c.version,size:p}}function s(c,u,f){const h=u.array,p=u._updateRange,_=u.updateRanges;if(r.bindBuffer(f,c),p.count===-1&&_.length===0&&r.bufferSubData(f,0,h),_.length!==0){for(let g=0,m=_.length;g 0 +#endif`,nm=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { @@ -240,26 +240,26 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve #pragma unroll_loop_end if ( clipped ) discard; #endif -#endif`,rm=`#if NUM_CLIPPING_PLANES > 0 +#endif`,im=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,sm=`#if NUM_CLIPPING_PLANES > 0 +#endif`,rm=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; -#endif`,om=`#if NUM_CLIPPING_PLANES > 0 +#endif`,sm=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,am=`#if defined( USE_COLOR_ALPHA ) +#endif`,om=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; -#endif`,lm=`#if defined( USE_COLOR_ALPHA ) +#endif`,am=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; -#endif`,cm=`#if defined( USE_COLOR_ALPHA ) +#endif`,lm=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; -#endif`,um=`#if defined( USE_COLOR_ALPHA ) +#endif`,cm=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); @@ -269,7 +269,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; -#endif`,hm=`#define PI 3.141592653589793 +#endif`,um=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 @@ -347,7 +347,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,fm=`#ifdef ENVMAP_TYPE_CUBE_UV +} // validated`,hm=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { @@ -445,7 +445,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { return vec4( mix( color0, color1, mipF ), 1.0 ); } } -#endif`,dm=`vec3 transformedNormal = objectNormal; +#endif`,fm=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif @@ -474,18 +474,18 @@ transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif -#endif`,pm=`#ifdef USE_DISPLACEMENTMAP +#endif`,dm=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,mm=`#ifdef USE_DISPLACEMENTMAP +#endif`,pm=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,_m=`#ifdef USE_EMISSIVEMAP +#endif`,mm=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,gm=`#ifdef USE_EMISSIVEMAP +#endif`,_m=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,vm="gl_FragColor = linearToOutputTexel( gl_FragColor );",xm=` +#endif`,gm="gl_FragColor = linearToOutputTexel( gl_FragColor );",vm=` const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( vec3( 0.8224621, 0.177538, 0.0 ), vec3( 0.0331941, 0.9668058, 0.0 ), @@ -513,7 +513,7 @@ vec4 LinearToLinear( in vec4 value ) { } vec4 LinearTosRGB( in vec4 value ) { return sRGBTransferOETF( value ); -}`,ym=`#ifdef USE_ENVMAP +}`,xm=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { @@ -542,7 +542,7 @@ vec4 LinearTosRGB( in vec4 value ) { #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif -#endif`,bm=`#ifdef USE_ENVMAP +#endif`,ym=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE @@ -551,7 +551,7 @@ vec4 LinearTosRGB( in vec4 value ) { uniform sampler2D envMap; #endif -#endif`,Em=`#ifdef USE_ENVMAP +#endif`,bm=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS @@ -573,7 +573,7 @@ vec4 LinearTosRGB( in vec4 value ) { varying vec3 vReflect; uniform float refractionRatio; #endif -#endif`,wm=`#ifdef USE_ENVMAP +#endif`,Em=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else @@ -590,18 +590,18 @@ vec4 LinearTosRGB( in vec4 value ) { vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif -#endif`,Mm=`#ifdef USE_FOG +#endif`,wm=`#ifdef USE_FOG vFogDepth = - mvPosition.z; -#endif`,Tm=`#ifdef USE_FOG +#endif`,Mm=`#ifdef USE_FOG varying float vFogDepth; -#endif`,Am=`#ifdef USE_FOG +#endif`,Tm=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); -#endif`,Rm=`#ifdef USE_FOG +#endif`,Am=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 @@ -610,7 +610,7 @@ vec4 LinearTosRGB( in vec4 value ) { uniform float fogNear; uniform float fogFar; #endif -#endif`,Lm=`#ifdef USE_GRADIENTMAP +#endif`,Rm=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { @@ -622,16 +622,16 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif -}`,Cm=`#ifdef USE_LIGHTMAP +}`,Lm=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; -#endif`,Pm=`#ifdef USE_LIGHTMAP +#endif`,Cm=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,Dm=`LambertMaterial material; +#endif`,Pm=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,Im=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Dm=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; @@ -645,7 +645,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert -#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Nm=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Im=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; @@ -768,7 +768,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } -#endif`,Fm=`#ifdef USE_ENVMAP +#endif`,Nm=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); @@ -801,8 +801,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi #endif } #endif -#endif`,Om=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,Um=`varying vec3 vViewPosition; +#endif`,Fm=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Om=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; @@ -814,11 +814,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Bm=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Um=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,zm=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Bm=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; @@ -835,7 +835,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,km=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,zm=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); @@ -918,7 +918,7 @@ material.roughness = min( material.roughness, 1.0 ); material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,Hm=`struct PhysicalMaterial { +#endif`,km=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; @@ -1218,7 +1218,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`,Vm=` +}`,Hm=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); @@ -1333,7 +1333,7 @@ IncidentLight directLight; #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,Gm=`#if defined( RE_IndirectDiffuse ) +#endif`,Vm=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; @@ -1352,25 +1352,25 @@ IncidentLight directLight; #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif -#endif`,Wm=`#if defined( RE_IndirectDiffuse ) +#endif`,Gm=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,Xm=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) +#endif`,Wm=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,qm=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) +#endif`,Xm=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,jm=`#ifdef USE_LOGDEPTHBUF +#endif`,qm=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif -#endif`,Ym=`#ifdef USE_LOGDEPTHBUF +#endif`,jm=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); @@ -1380,16 +1380,16 @@ IncidentLight directLight; gl_Position.z *= gl_Position.w; } #endif -#endif`,$m=`#ifdef USE_MAP +#endif`,Ym=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,Km=`#ifdef USE_MAP +#endif`,$m=`#ifdef USE_MAP uniform sampler2D map; -#endif`,Zm=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,Km=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else @@ -1401,7 +1401,7 @@ IncidentLight directLight; #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`,Qm=`#if defined( USE_POINTS_UV ) +#endif`,Zm=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) @@ -1413,13 +1413,13 @@ IncidentLight directLight; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; -#endif`,Jm=`float metalnessFactor = metalness; +#endif`,Qm=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,e_=`#ifdef USE_METALNESSMAP +#endif`,Jm=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,t_=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) +#endif`,e_=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) @@ -1428,7 +1428,7 @@ IncidentLight directLight; if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } -#endif`,n_=`#ifdef USE_MORPHNORMALS +#endif`,t_=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { @@ -1440,7 +1440,7 @@ IncidentLight directLight; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif -#endif`,i_=`#ifdef USE_MORPHTARGETS +#endif`,n_=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; @@ -1460,7 +1460,7 @@ IncidentLight directLight; uniform float morphTargetInfluences[ 4 ]; #endif #endif -#endif`,r_=`#ifdef USE_MORPHTARGETS +#endif`,i_=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { @@ -1478,7 +1478,7 @@ IncidentLight directLight; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif -#endif`,s_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,r_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); @@ -1519,7 +1519,7 @@ IncidentLight directLight; tbn2[1] *= faceDirection; #endif #endif -vec3 nonPerturbedNormal = normal;`,o_=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,s_=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; @@ -1534,25 +1534,25 @@ vec3 nonPerturbedNormal = normal;`,o_=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,a_=`#ifndef FLAT_SHADED +#endif`,o_=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,l_=`#ifndef FLAT_SHADED +#endif`,a_=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,c_=`#ifndef FLAT_SHADED +#endif`,l_=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif -#endif`,u_=`#ifdef USE_NORMALMAP +#endif`,c_=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -1574,13 +1574,13 @@ vec3 nonPerturbedNormal = normal;`,o_=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,h_=`#ifdef USE_CLEARCOAT +#endif`,u_=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,f_=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,h_=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,d_=`#ifdef USE_CLEARCOATMAP +#endif`,f_=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -1589,18 +1589,18 @@ vec3 nonPerturbedNormal = normal;`,o_=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,p_=`#ifdef USE_IRIDESCENCEMAP +#endif`,d_=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,m_=`#ifdef OPAQUE +#endif`,p_=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,__=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,m_=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { @@ -1641,9 +1641,9 @@ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); -}`,g_=`#ifdef PREMULTIPLIED_ALPHA +}`,__=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,v_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`,g_=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif @@ -1651,20 +1651,20 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,v_=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,y_=`#ifdef DITHERING +#endif`,x_=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } -#endif`,b_=`float roughnessFactor = roughness; +#endif`,y_=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,E_=`#ifdef USE_ROUGHNESSMAP +#endif`,b_=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,S_=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; @@ -1843,7 +1843,7 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } -#endif`,w_=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,E_=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif @@ -1881,7 +1881,7 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,M_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) +#endif`,w_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif @@ -1913,7 +1913,7 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,T_=`float getShadowMask() { +#endif`,M_=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 @@ -1945,12 +1945,12 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING #endif #endif return shadow; -}`,A_=`#ifdef USE_SKINNING +}`,T_=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,R_=`#ifdef USE_SKINNING +#endif`,A_=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -1965,7 +1965,7 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,L_=`#ifdef USE_SKINNING +#endif`,R_=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; @@ -1973,7 +1973,7 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,C_=`#ifdef USE_SKINNING +#endif`,L_=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -1984,17 +1984,17 @@ gl_Position = projectionMatrix * mvPosition;`,x_=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,P_=`float specularStrength; +#endif`,C_=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,D_=`#ifdef USE_SPECULARMAP +#endif`,P_=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,I_=`#if defined( TONE_MAPPING ) +#endif`,D_=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,N_=`#ifndef saturate +#endif`,I_=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; @@ -2030,7 +2030,7 @@ vec3 ACESFilmicToneMapping( vec3 color ) { color = ACESOutputMat * color; return saturate( color ); } -vec3 CustomToneMapping( vec3 color ) { return color; }`,F_=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,N_=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -2051,7 +2051,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,F_=`#ifdef USE_TRANSMISS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,O_=`#ifdef USE_TRANSMISSION +#endif`,F_=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -2157,7 +2157,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,F_=`#ifdef USE_TRANSMISS float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } -#endif`,U_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,O_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2227,7 +2227,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,F_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,B_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,U_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2321,7 +2321,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,F_=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,B_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP @@ -2392,7 +2392,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,F_=`#ifdef USE_TRANSMISS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,k_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,z_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; @@ -2401,12 +2401,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,F_=`#ifdef USE_TRANSMISS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`;const H_=`varying vec2 vUv; +#endif`;const k_=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,V_=`uniform sampler2D t2D; +}`,H_=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -2418,14 +2418,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,G_=`varying vec3 vWorldDirection; +}`,V_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,W_=`#ifdef ENVMAP_TYPE_CUBE +}`,G_=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; @@ -2447,14 +2447,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,X_=`varying vec3 vWorldDirection; +}`,W_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,q_=`uniform samplerCube tCube; +}`,X_=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; @@ -2464,7 +2464,7 @@ void main() { gl_FragColor.a *= opacity; #include #include -}`,j_=`#include +}`,q_=`#include #include #include #include @@ -2490,7 +2490,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,Y_=`#if DEPTH_PACKING == 3200 +}`,j_=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include @@ -2520,7 +2520,7 @@ void main() { #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif -}`,$_=`#define DISTANCE +}`,Y_=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -2546,7 +2546,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,K_=`#define DISTANCE +}`,$_=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; @@ -2570,13 +2570,13 @@ void main () { dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); -}`,Z_=`varying vec3 vWorldDirection; +}`,K_=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,Q_=`uniform sampler2D tEquirect; +}`,Z_=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2585,7 +2585,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,J_=`uniform float scale; +}`,Q_=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -2606,7 +2606,7 @@ void main() { #include #include #include -}`,eg=`uniform vec3 diffuse; +}`,J_=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -2634,7 +2634,7 @@ void main() { #include #include #include -}`,tg=`#include +}`,eg=`#include #include #include #include @@ -2665,7 +2665,7 @@ void main() { #include #include #include -}`,ng=`uniform vec3 diffuse; +}`,tg=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -2713,7 +2713,7 @@ void main() { #include #include #include -}`,ig=`#define LAMBERT +}`,ng=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -2751,7 +2751,7 @@ void main() { #include #include #include -}`,rg=`#define LAMBERT +}`,ig=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -2808,7 +2808,7 @@ void main() { #include #include #include -}`,sg=`#define MATCAP +}`,rg=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -2841,7 +2841,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,og=`#define MATCAP +}`,sg=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -2887,7 +2887,7 @@ void main() { #include #include #include -}`,ag=`#define NORMAL +}`,og=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif @@ -2919,7 +2919,7 @@ void main() { #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif -}`,lg=`#define NORMAL +}`,ag=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; @@ -2940,7 +2940,7 @@ void main() { #ifdef OPAQUE gl_FragColor.a = 1.0; #endif -}`,cg=`#define PHONG +}`,lg=`#define PHONG varying vec3 vViewPosition; #include #include @@ -2978,7 +2978,7 @@ void main() { #include #include #include -}`,ug=`#define PHONG +}`,cg=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -3037,7 +3037,7 @@ void main() { #include #include #include -}`,hg=`#define STANDARD +}`,ug=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -3079,7 +3079,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,fg=`#define STANDARD +}`,hg=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -3201,7 +3201,7 @@ void main() { #include #include #include -}`,dg=`#define TOON +}`,fg=`#define TOON varying vec3 vViewPosition; #include #include @@ -3237,7 +3237,7 @@ void main() { #include #include #include -}`,pg=`#define TOON +}`,dg=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3290,7 +3290,7 @@ void main() { #include #include #include -}`,mg=`uniform float size; +}`,pg=`uniform float size; uniform float scale; #include #include @@ -3320,7 +3320,7 @@ void main() { #include #include #include -}`,_g=`uniform vec3 diffuse; +}`,mg=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3345,7 +3345,7 @@ void main() { #include #include #include -}`,gg=`#include +}`,_g=`#include #include #include #include @@ -3367,7 +3367,7 @@ void main() { #include #include #include -}`,vg=`uniform vec3 color; +}`,gg=`uniform vec3 color; uniform float opacity; #include #include @@ -3383,7 +3383,7 @@ void main() { #include #include #include -}`,xg=`uniform float rotation; +}`,vg=`uniform float rotation; uniform vec2 center; #include #include @@ -3409,7 +3409,7 @@ void main() { #include #include #include -}`,yg=`uniform vec3 diffuse; +}`,xg=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3434,7 +3434,7 @@ void main() { #include #include #include -}`,it={alphahash_fragment:Vp,alphahash_pars_fragment:Gp,alphamap_fragment:Wp,alphamap_pars_fragment:Xp,alphatest_fragment:qp,alphatest_pars_fragment:jp,aomap_fragment:Yp,aomap_pars_fragment:$p,batching_pars_vertex:Kp,batching_vertex:Zp,begin_vertex:Qp,beginnormal_vertex:Jp,bsdfs:em,iridescence_fragment:tm,bumpmap_pars_fragment:nm,clipping_planes_fragment:im,clipping_planes_pars_fragment:rm,clipping_planes_pars_vertex:sm,clipping_planes_vertex:om,color_fragment:am,color_pars_fragment:lm,color_pars_vertex:cm,color_vertex:um,common:hm,cube_uv_reflection_fragment:fm,defaultnormal_vertex:dm,displacementmap_pars_vertex:pm,displacementmap_vertex:mm,emissivemap_fragment:_m,emissivemap_pars_fragment:gm,colorspace_fragment:vm,colorspace_pars_fragment:xm,envmap_fragment:ym,envmap_common_pars_fragment:bm,envmap_pars_fragment:Em,envmap_pars_vertex:Sm,envmap_physical_pars_fragment:Fm,envmap_vertex:wm,fog_vertex:Mm,fog_pars_vertex:Tm,fog_fragment:Am,fog_pars_fragment:Rm,gradientmap_pars_fragment:Lm,lightmap_fragment:Cm,lightmap_pars_fragment:Pm,lights_lambert_fragment:Dm,lights_lambert_pars_fragment:Im,lights_pars_begin:Nm,lights_toon_fragment:Om,lights_toon_pars_fragment:Um,lights_phong_fragment:Bm,lights_phong_pars_fragment:zm,lights_physical_fragment:km,lights_physical_pars_fragment:Hm,lights_fragment_begin:Vm,lights_fragment_maps:Gm,lights_fragment_end:Wm,logdepthbuf_fragment:Xm,logdepthbuf_pars_fragment:qm,logdepthbuf_pars_vertex:jm,logdepthbuf_vertex:Ym,map_fragment:$m,map_pars_fragment:Km,map_particle_fragment:Zm,map_particle_pars_fragment:Qm,metalnessmap_fragment:Jm,metalnessmap_pars_fragment:e_,morphcolor_vertex:t_,morphnormal_vertex:n_,morphtarget_pars_vertex:i_,morphtarget_vertex:r_,normal_fragment_begin:s_,normal_fragment_maps:o_,normal_pars_fragment:a_,normal_pars_vertex:l_,normal_vertex:c_,normalmap_pars_fragment:u_,clearcoat_normal_fragment_begin:h_,clearcoat_normal_fragment_maps:f_,clearcoat_pars_fragment:d_,iridescence_pars_fragment:p_,opaque_fragment:m_,packing:__,premultiplied_alpha_fragment:g_,project_vertex:v_,dithering_fragment:x_,dithering_pars_fragment:y_,roughnessmap_fragment:b_,roughnessmap_pars_fragment:E_,shadowmap_pars_fragment:S_,shadowmap_pars_vertex:w_,shadowmap_vertex:M_,shadowmask_pars_fragment:T_,skinbase_vertex:A_,skinning_pars_vertex:R_,skinning_vertex:L_,skinnormal_vertex:C_,specularmap_fragment:P_,specularmap_pars_fragment:D_,tonemapping_fragment:I_,tonemapping_pars_fragment:N_,transmission_fragment:F_,transmission_pars_fragment:O_,uv_pars_fragment:U_,uv_pars_vertex:B_,uv_vertex:z_,worldpos_vertex:k_,background_vert:H_,background_frag:V_,backgroundCube_vert:G_,backgroundCube_frag:W_,cube_vert:X_,cube_frag:q_,depth_vert:j_,depth_frag:Y_,distanceRGBA_vert:$_,distanceRGBA_frag:K_,equirect_vert:Z_,equirect_frag:Q_,linedashed_vert:J_,linedashed_frag:eg,meshbasic_vert:tg,meshbasic_frag:ng,meshlambert_vert:ig,meshlambert_frag:rg,meshmatcap_vert:sg,meshmatcap_frag:og,meshnormal_vert:ag,meshnormal_frag:lg,meshphong_vert:cg,meshphong_frag:ug,meshphysical_vert:hg,meshphysical_frag:fg,meshtoon_vert:dg,meshtoon_frag:pg,points_vert:mg,points_frag:_g,shadow_vert:gg,shadow_frag:vg,sprite_vert:xg,sprite_frag:yg},xe={common:{diffuse:{value:new tt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new st},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new st}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new st}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new st}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new st},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new st},normalScale:{value:new Ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new st},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new st}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new st}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new st}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tt(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:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{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 tt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0},uvTransform:{value:new st}},sprite:{diffuse:{value:new tt(16777215)},opacity:{value:1},center:{value:new Ue(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new st},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0}}},ui={basic:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.fog]),vertexShader:it.meshbasic_vert,fragmentShader:it.meshbasic_frag},lambert:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new tt(0)}}]),vertexShader:it.meshlambert_vert,fragmentShader:it.meshlambert_frag},phong:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new tt(0)},specular:{value:new tt(1118481)},shininess:{value:30}}]),vertexShader:it.meshphong_vert,fragmentShader:it.meshphong_frag},standard:{uniforms:mn([xe.common,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.roughnessmap,xe.metalnessmap,xe.fog,xe.lights,{emissive:{value:new tt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag},toon:{uniforms:mn([xe.common,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.gradientmap,xe.fog,xe.lights,{emissive:{value:new tt(0)}}]),vertexShader:it.meshtoon_vert,fragmentShader:it.meshtoon_frag},matcap:{uniforms:mn([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,{matcap:{value:null}}]),vertexShader:it.meshmatcap_vert,fragmentShader:it.meshmatcap_frag},points:{uniforms:mn([xe.points,xe.fog]),vertexShader:it.points_vert,fragmentShader:it.points_frag},dashed:{uniforms:mn([xe.common,xe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:it.linedashed_vert,fragmentShader:it.linedashed_frag},depth:{uniforms:mn([xe.common,xe.displacementmap]),vertexShader:it.depth_vert,fragmentShader:it.depth_frag},normal:{uniforms:mn([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,{opacity:{value:1}}]),vertexShader:it.meshnormal_vert,fragmentShader:it.meshnormal_frag},sprite:{uniforms:mn([xe.sprite,xe.fog]),vertexShader:it.sprite_vert,fragmentShader:it.sprite_frag},background:{uniforms:{uvTransform:{value:new st},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:it.background_vert,fragmentShader:it.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:it.backgroundCube_vert,fragmentShader:it.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:it.cube_vert,fragmentShader:it.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:it.equirect_vert,fragmentShader:it.equirect_frag},distanceRGBA:{uniforms:mn([xe.common,xe.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:it.distanceRGBA_vert,fragmentShader:it.distanceRGBA_frag},shadow:{uniforms:mn([xe.lights,xe.fog,{color:{value:new tt(0)},opacity:{value:1}}]),vertexShader:it.shadow_vert,fragmentShader:it.shadow_frag}};ui.physical={uniforms:mn([ui.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new st},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new st},clearcoatNormalScale:{value:new Ue(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new st},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new st},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new st},sheen:{value:0},sheenColor:{value:new tt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new st},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new st},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new st},transmissionSamplerSize:{value:new Ue},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new st},attenuationDistance:{value:0},attenuationColor:{value:new tt(0)},specularColor:{value:new tt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new st},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new st},anisotropyVector:{value:new Ue},anisotropyMap:{value:null},anisotropyMapTransform:{value:new st}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag};const Co={r:0,b:0,g:0};function bg(r,e,t,n,i,s,o){const a=new tt(0);let l=s===!0?0:1,c,u,f=null,h=0,p=null;function _(m,d){let x=!1,v=d.isScene===!0?d.background:null;v&&v.isTexture&&(v=(d.backgroundBlurriness>0?t:e).get(v)),v===null?g(a,l):v&&v.isColor&&(g(v,1),x=!0);const y=r.xr.getEnvironmentBlendMode();y==="additive"?n.buffers.color.setClear(0,0,0,1,o):y==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(r.autoClear||x)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),v&&(v.isCubeTexture||v.mapping===ga)?(u===void 0&&(u=new Mn(new oo(1,1,1),new Zi({name:"BackgroundCubeMaterial",uniforms:ps(ui.backgroundCube.uniforms),vertexShader:ui.backgroundCube.vertexShader,fragmentShader:ui.backgroundCube.fragmentShader,side:xn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(b,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=v,u.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=d.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,u.material.toneMapped=pt.getTransfer(v.colorSpace)!==At,(f!==v||h!==v.version||p!==r.toneMapping)&&(u.material.needsUpdate=!0,f=v,h=v.version,p=r.toneMapping),u.layers.enableAll(),m.unshift(u,u.geometry,u.material,0,0,null)):v&&v.isTexture&&(c===void 0&&(c=new Mn(new ic(2,2),new Zi({name:"BackgroundMaterial",uniforms:ps(ui.background.uniforms),vertexShader:ui.background.vertexShader,fragmentShader:ui.background.fragmentShader,side:ei,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,c.material.toneMapped=pt.getTransfer(v.colorSpace)!==At,v.matrixAutoUpdate===!0&&v.updateMatrix(),c.material.uniforms.uvTransform.value.copy(v.matrix),(f!==v||h!==v.version||p!==r.toneMapping)&&(c.material.needsUpdate=!0,f=v,h=v.version,p=r.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null))}function g(m,d){m.getRGB(Co,bf(r)),n.buffers.color.setClear(Co.r,Co.g,Co.b,d,o)}return{getClearColor:function(){return a},setClearColor:function(m,d=1){a.set(m),l=d,g(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(m){l=m,g(a,l)},render:_}}function Eg(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=m(null);let c=l,u=!1;function f(D,V,Z,Q,ce){let ie=!1;if(o){const se=g(Q,Z,V);c!==se&&(c=se,p(c.object)),ie=d(D,Q,Z,ce),ie&&x(D,Q,Z,ce)}else{const se=V.wireframe===!0;(c.geometry!==Q.id||c.program!==Z.id||c.wireframe!==se)&&(c.geometry=Q.id,c.program=Z.id,c.wireframe=se,ie=!0)}ce!==null&&t.update(ce,r.ELEMENT_ARRAY_BUFFER),(ie||u)&&(u=!1,I(D,V,Z,Q),ce!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(ce).buffer))}function h(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function p(D){return n.isWebGL2?r.bindVertexArray(D):s.bindVertexArrayOES(D)}function _(D){return n.isWebGL2?r.deleteVertexArray(D):s.deleteVertexArrayOES(D)}function g(D,V,Z){const Q=Z.wireframe===!0;let ce=a[D.id];ce===void 0&&(ce={},a[D.id]=ce);let ie=ce[V.id];ie===void 0&&(ie={},ce[V.id]=ie);let se=ie[Q];return se===void 0&&(se=m(h()),ie[Q]=se),se}function m(D){const V=[],Z=[],Q=[];for(let ce=0;ce=0){const oe=ce[ve];let Ee=ie[ve];if(Ee===void 0&&(ve==="instanceMatrix"&&D.instanceMatrix&&(Ee=D.instanceMatrix),ve==="instanceColor"&&D.instanceColor&&(Ee=D.instanceColor)),oe===void 0||oe.attribute!==Ee||Ee&&oe.data!==Ee.data)return!0;se++}return c.attributesNum!==se||c.index!==Q}function x(D,V,Z,Q){const ce={},ie=V.attributes;let se=0;const me=Z.getAttributes();for(const ve in me)if(me[ve].location>=0){let oe=ie[ve];oe===void 0&&(ve==="instanceMatrix"&&D.instanceMatrix&&(oe=D.instanceMatrix),ve==="instanceColor"&&D.instanceColor&&(oe=D.instanceColor));const Ee={};Ee.attribute=oe,oe&&oe.data&&(Ee.data=oe.data),ce[ve]=Ee,se++}c.attributes=ce,c.attributesNum=se,c.index=Q}function v(){const D=c.newAttributes;for(let V=0,Z=D.length;V=0){let J=ce[me];if(J===void 0&&(me==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),me==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){const oe=J.normalized,Ee=J.itemSize,De=t.get(J);if(De===void 0)continue;const _e=De.buffer,qe=De.type,We=De.bytesPerElement,Fe=n.isWebGL2===!0&&(qe===r.INT||qe===r.UNSIGNED_INT||J.gpuType===Ws);if(J.isInterleavedBufferAttribute){const Ye=J.data,X=Ye.stride,Lt=J.offset;if(Ye.isInstancedInterleavedBuffer){for(let Ce=0;Ce0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&r.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),h=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_TEXTURE_SIZE),_=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),g=r.getParameter(r.MAX_VERTEX_ATTRIBS),m=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),d=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),v=h>0,y=o||e.has("OES_texture_float"),b=v&&y,M=o?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:f,maxVertexTextures:h,maxTextureSize:p,maxCubemapSize:_,maxAttributes:g,maxVertexUniforms:m,maxVaryings:d,maxFragmentUniforms:x,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:b,maxSamples:M}}function Mg(r){const e=this;let t=null,n=0,i=!1,s=!1;const o=new ci,a=new st,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){const p=f.length!==0||h||n!==0||i;return i=h,n=f.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){t=u(f,h,0)},this.setState=function(f,h,p){const _=f.clippingPlanes,g=f.clipIntersection,m=f.clipShadows,d=r.get(f);if(!i||_===null||_.length===0||s&&!m)s?u(null):c();else{const x=s?0:n,v=x*4;let y=d.clippingState||null;l.value=y,y=u(_,h,v,p);for(let b=0;b!==v;++b)y[b]=t[b];d.clippingState=y,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(f,h,p,_){const g=f!==null?f.length:0;let m=null;if(g!==0){if(m=l.value,_!==!0||m===null){const d=p+g*4,x=h.matrixWorldInverse;a.getNormalMatrix(x),(m===null||m.length0){const c=new Bp(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){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class ao extends Ef{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(){const 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;let s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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}}const ns=4,Mu=[.125,.215,.35,.446,.526,.582],fr=20,Qa=new ao,Tu=new tt;let Ja=null,el=0,tl=0;const cr=(1+Math.sqrt(5))/2,Vr=1/cr,Au=[new C(1,1,1),new C(-1,1,1),new C(1,1,-1),new C(-1,1,-1),new C(0,cr,Vr),new C(0,cr,-Vr),new C(Vr,0,cr),new C(-Vr,0,cr),new C(cr,Vr,0),new C(-cr,Vr,0)];class Ru{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){Ja=this._renderer.getRenderTarget(),el=this._renderer.getActiveCubeFace(),tl=this._renderer.getActiveMipmapLevel(),this._setSize(256);const 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=Pu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Cu(),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;e2?v:0,v,v),u.setRenderTarget(i),g&&u.render(_,a),u.render(e,a)}_.geometry.dispose(),_.material.dispose(),u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===ls||e.mapping===cs;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Pu()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Cu());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Mn(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;Po(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Qa)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;ifr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${fr}`);const d=[];let x=0;for(let T=0;Tv-ns?i-v+ns:0),M=4*(this._cubeSize-y);Po(t,b,M,3*y,2*y),l.setRenderTarget(t),l.render(f,Qa)}}function Ag(r){const e=[],t=[],n=[];let i=r;const s=r-ns+1+Mu.length;for(let o=0;or-ns?l=Mu[o-r+ns-1]:o===0&&(l=0),n.push(l);const c=1/(a-2),u=-c,f=1+c,h=[u,u,f,u,f,f,u,u,f,f,u,f],p=6,_=6,g=3,m=2,d=1,x=new Float32Array(g*_*p),v=new Float32Array(m*_*p),y=new Float32Array(d*_*p);for(let M=0;M2?0:-1,E=[T,I,0,T+2/3,I,0,T+2/3,I+1,0,T,I,0,T+2/3,I+1,0,T,I+1,0];x.set(E,g*_*M),v.set(h,m*_*M);const A=[M,M,M,M,M,M];y.set(A,d*_*M)}const b=new yn;b.setAttribute("position",new Yt(x,g)),b.setAttribute("uv",new Yt(v,m)),b.setAttribute("faceIndex",new Yt(y,d)),e.push(b),i>ns&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Lu(r,e,t){const n=new Ki(r,e,t);return n.texture.mapping=ga,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Po(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function Rg(r,e,t){const n=new Float32Array(fr),i=new C(0,1,0);return new Zi({name:"SphericalGaussianBlur",defines:{n:fr,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:rc(),fragmentShader:` +}`,it={alphahash_fragment:Hp,alphahash_pars_fragment:Vp,alphamap_fragment:Gp,alphamap_pars_fragment:Wp,alphatest_fragment:Xp,alphatest_pars_fragment:qp,aomap_fragment:jp,aomap_pars_fragment:Yp,batching_pars_vertex:$p,batching_vertex:Kp,begin_vertex:Zp,beginnormal_vertex:Qp,bsdfs:Jp,iridescence_fragment:em,bumpmap_pars_fragment:tm,clipping_planes_fragment:nm,clipping_planes_pars_fragment:im,clipping_planes_pars_vertex:rm,clipping_planes_vertex:sm,color_fragment:om,color_pars_fragment:am,color_pars_vertex:lm,color_vertex:cm,common:um,cube_uv_reflection_fragment:hm,defaultnormal_vertex:fm,displacementmap_pars_vertex:dm,displacementmap_vertex:pm,emissivemap_fragment:mm,emissivemap_pars_fragment:_m,colorspace_fragment:gm,colorspace_pars_fragment:vm,envmap_fragment:xm,envmap_common_pars_fragment:ym,envmap_pars_fragment:bm,envmap_pars_vertex:Sm,envmap_physical_pars_fragment:Nm,envmap_vertex:Em,fog_vertex:wm,fog_pars_vertex:Mm,fog_fragment:Tm,fog_pars_fragment:Am,gradientmap_pars_fragment:Rm,lightmap_fragment:Lm,lightmap_pars_fragment:Cm,lights_lambert_fragment:Pm,lights_lambert_pars_fragment:Dm,lights_pars_begin:Im,lights_toon_fragment:Fm,lights_toon_pars_fragment:Om,lights_phong_fragment:Um,lights_phong_pars_fragment:Bm,lights_physical_fragment:zm,lights_physical_pars_fragment:km,lights_fragment_begin:Hm,lights_fragment_maps:Vm,lights_fragment_end:Gm,logdepthbuf_fragment:Wm,logdepthbuf_pars_fragment:Xm,logdepthbuf_pars_vertex:qm,logdepthbuf_vertex:jm,map_fragment:Ym,map_pars_fragment:$m,map_particle_fragment:Km,map_particle_pars_fragment:Zm,metalnessmap_fragment:Qm,metalnessmap_pars_fragment:Jm,morphcolor_vertex:e_,morphnormal_vertex:t_,morphtarget_pars_vertex:n_,morphtarget_vertex:i_,normal_fragment_begin:r_,normal_fragment_maps:s_,normal_pars_fragment:o_,normal_pars_vertex:a_,normal_vertex:l_,normalmap_pars_fragment:c_,clearcoat_normal_fragment_begin:u_,clearcoat_normal_fragment_maps:h_,clearcoat_pars_fragment:f_,iridescence_pars_fragment:d_,opaque_fragment:p_,packing:m_,premultiplied_alpha_fragment:__,project_vertex:g_,dithering_fragment:v_,dithering_pars_fragment:x_,roughnessmap_fragment:y_,roughnessmap_pars_fragment:b_,shadowmap_pars_fragment:S_,shadowmap_pars_vertex:E_,shadowmap_vertex:w_,shadowmask_pars_fragment:M_,skinbase_vertex:T_,skinning_pars_vertex:A_,skinning_vertex:R_,skinnormal_vertex:L_,specularmap_fragment:C_,specularmap_pars_fragment:P_,tonemapping_fragment:D_,tonemapping_pars_fragment:I_,transmission_fragment:N_,transmission_pars_fragment:F_,uv_pars_fragment:O_,uv_pars_vertex:U_,uv_vertex:B_,worldpos_vertex:z_,background_vert:k_,background_frag:H_,backgroundCube_vert:V_,backgroundCube_frag:G_,cube_vert:W_,cube_frag:X_,depth_vert:q_,depth_frag:j_,distanceRGBA_vert:Y_,distanceRGBA_frag:$_,equirect_vert:K_,equirect_frag:Z_,linedashed_vert:Q_,linedashed_frag:J_,meshbasic_vert:eg,meshbasic_frag:tg,meshlambert_vert:ng,meshlambert_frag:ig,meshmatcap_vert:rg,meshmatcap_frag:sg,meshnormal_vert:og,meshnormal_frag:ag,meshphong_vert:lg,meshphong_frag:cg,meshphysical_vert:ug,meshphysical_frag:hg,meshtoon_vert:fg,meshtoon_frag:dg,points_vert:pg,points_frag:mg,shadow_vert:_g,shadow_frag:gg,sprite_vert:vg,sprite_frag:xg},xe={common:{diffuse:{value:new tt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new st},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new st}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new st}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new st}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new st},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new st},normalScale:{value:new Ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new st},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new st}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new st}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new st}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tt(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:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{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 tt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0},uvTransform:{value:new st}},sprite:{diffuse:{value:new tt(16777215)},opacity:{value:1},center:{value:new Ue(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new st},alphaMap:{value:null},alphaMapTransform:{value:new st},alphaTest:{value:0}}},ui={basic:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.fog]),vertexShader:it.meshbasic_vert,fragmentShader:it.meshbasic_frag},lambert:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new tt(0)}}]),vertexShader:it.meshlambert_vert,fragmentShader:it.meshlambert_frag},phong:{uniforms:mn([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new tt(0)},specular:{value:new tt(1118481)},shininess:{value:30}}]),vertexShader:it.meshphong_vert,fragmentShader:it.meshphong_frag},standard:{uniforms:mn([xe.common,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.roughnessmap,xe.metalnessmap,xe.fog,xe.lights,{emissive:{value:new tt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag},toon:{uniforms:mn([xe.common,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.gradientmap,xe.fog,xe.lights,{emissive:{value:new tt(0)}}]),vertexShader:it.meshtoon_vert,fragmentShader:it.meshtoon_frag},matcap:{uniforms:mn([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,{matcap:{value:null}}]),vertexShader:it.meshmatcap_vert,fragmentShader:it.meshmatcap_frag},points:{uniforms:mn([xe.points,xe.fog]),vertexShader:it.points_vert,fragmentShader:it.points_frag},dashed:{uniforms:mn([xe.common,xe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:it.linedashed_vert,fragmentShader:it.linedashed_frag},depth:{uniforms:mn([xe.common,xe.displacementmap]),vertexShader:it.depth_vert,fragmentShader:it.depth_frag},normal:{uniforms:mn([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,{opacity:{value:1}}]),vertexShader:it.meshnormal_vert,fragmentShader:it.meshnormal_frag},sprite:{uniforms:mn([xe.sprite,xe.fog]),vertexShader:it.sprite_vert,fragmentShader:it.sprite_frag},background:{uniforms:{uvTransform:{value:new st},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:it.background_vert,fragmentShader:it.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:it.backgroundCube_vert,fragmentShader:it.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:it.cube_vert,fragmentShader:it.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:it.equirect_vert,fragmentShader:it.equirect_frag},distanceRGBA:{uniforms:mn([xe.common,xe.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:it.distanceRGBA_vert,fragmentShader:it.distanceRGBA_frag},shadow:{uniforms:mn([xe.lights,xe.fog,{color:{value:new tt(0)},opacity:{value:1}}]),vertexShader:it.shadow_vert,fragmentShader:it.shadow_frag}};ui.physical={uniforms:mn([ui.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new st},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new st},clearcoatNormalScale:{value:new Ue(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new st},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new st},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new st},sheen:{value:0},sheenColor:{value:new tt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new st},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new st},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new st},transmissionSamplerSize:{value:new Ue},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new st},attenuationDistance:{value:0},attenuationColor:{value:new tt(0)},specularColor:{value:new tt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new st},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new st},anisotropyVector:{value:new Ue},anisotropyMap:{value:null},anisotropyMapTransform:{value:new st}}]),vertexShader:it.meshphysical_vert,fragmentShader:it.meshphysical_frag};const Co={r:0,b:0,g:0};function yg(r,e,t,n,i,s,o){const a=new tt(0);let l=s===!0?0:1,c,u,f=null,h=0,p=null;function _(m,d){let x=!1,v=d.isScene===!0?d.background:null;v&&v.isTexture&&(v=(d.backgroundBlurriness>0?t:e).get(v)),v===null?g(a,l):v&&v.isColor&&(g(v,1),x=!0);const y=r.xr.getEnvironmentBlendMode();y==="additive"?n.buffers.color.setClear(0,0,0,1,o):y==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(r.autoClear||x)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),v&&(v.isCubeTexture||v.mapping===ga)?(u===void 0&&(u=new Mn(new oo(1,1,1),new Zi({name:"BackgroundCubeMaterial",uniforms:ps(ui.backgroundCube.uniforms),vertexShader:ui.backgroundCube.vertexShader,fragmentShader:ui.backgroundCube.fragmentShader,side:xn,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(b,M,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=v,u.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=d.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,u.material.toneMapped=pt.getTransfer(v.colorSpace)!==At,(f!==v||h!==v.version||p!==r.toneMapping)&&(u.material.needsUpdate=!0,f=v,h=v.version,p=r.toneMapping),u.layers.enableAll(),m.unshift(u,u.geometry,u.material,0,0,null)):v&&v.isTexture&&(c===void 0&&(c=new Mn(new ic(2,2),new Zi({name:"BackgroundMaterial",uniforms:ps(ui.background.uniforms),vertexShader:ui.background.vertexShader,fragmentShader:ui.background.fragmentShader,side:ei,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,c.material.toneMapped=pt.getTransfer(v.colorSpace)!==At,v.matrixAutoUpdate===!0&&v.updateMatrix(),c.material.uniforms.uvTransform.value.copy(v.matrix),(f!==v||h!==v.version||p!==r.toneMapping)&&(c.material.needsUpdate=!0,f=v,h=v.version,p=r.toneMapping),c.layers.enableAll(),m.unshift(c,c.geometry,c.material,0,0,null))}function g(m,d){m.getRGB(Co,bf(r)),n.buffers.color.setClear(Co.r,Co.g,Co.b,d,o)}return{getClearColor:function(){return a},setClearColor:function(m,d=1){a.set(m),l=d,g(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(m){l=m,g(a,l)},render:_}}function bg(r,e,t,n){const i=r.getParameter(r.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=m(null);let c=l,u=!1;function f(D,V,Z,Q,ce){let ie=!1;if(o){const se=g(Q,Z,V);c!==se&&(c=se,p(c.object)),ie=d(D,Q,Z,ce),ie&&x(D,Q,Z,ce)}else{const se=V.wireframe===!0;(c.geometry!==Q.id||c.program!==Z.id||c.wireframe!==se)&&(c.geometry=Q.id,c.program=Z.id,c.wireframe=se,ie=!0)}ce!==null&&t.update(ce,r.ELEMENT_ARRAY_BUFFER),(ie||u)&&(u=!1,I(D,V,Z,Q),ce!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(ce).buffer))}function h(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function p(D){return n.isWebGL2?r.bindVertexArray(D):s.bindVertexArrayOES(D)}function _(D){return n.isWebGL2?r.deleteVertexArray(D):s.deleteVertexArrayOES(D)}function g(D,V,Z){const Q=Z.wireframe===!0;let ce=a[D.id];ce===void 0&&(ce={},a[D.id]=ce);let ie=ce[V.id];ie===void 0&&(ie={},ce[V.id]=ie);let se=ie[Q];return se===void 0&&(se=m(h()),ie[Q]=se),se}function m(D){const V=[],Z=[],Q=[];for(let ce=0;ce=0){const oe=ce[ve];let Se=ie[ve];if(Se===void 0&&(ve==="instanceMatrix"&&D.instanceMatrix&&(Se=D.instanceMatrix),ve==="instanceColor"&&D.instanceColor&&(Se=D.instanceColor)),oe===void 0||oe.attribute!==Se||Se&&oe.data!==Se.data)return!0;se++}return c.attributesNum!==se||c.index!==Q}function x(D,V,Z,Q){const ce={},ie=V.attributes;let se=0;const me=Z.getAttributes();for(const ve in me)if(me[ve].location>=0){let oe=ie[ve];oe===void 0&&(ve==="instanceMatrix"&&D.instanceMatrix&&(oe=D.instanceMatrix),ve==="instanceColor"&&D.instanceColor&&(oe=D.instanceColor));const Se={};Se.attribute=oe,oe&&oe.data&&(Se.data=oe.data),ce[ve]=Se,se++}c.attributes=ce,c.attributesNum=se,c.index=Q}function v(){const D=c.newAttributes;for(let V=0,Z=D.length;V=0){let J=ce[me];if(J===void 0&&(me==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),me==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){const oe=J.normalized,Se=J.itemSize,De=t.get(J);if(De===void 0)continue;const _e=De.buffer,qe=De.type,We=De.bytesPerElement,Fe=n.isWebGL2===!0&&(qe===r.INT||qe===r.UNSIGNED_INT||J.gpuType===Ws);if(J.isInterleavedBufferAttribute){const Ye=J.data,X=Ye.stride,Lt=J.offset;if(Ye.isInstancedInterleavedBuffer){for(let Ce=0;Ce0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&r.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);const c=o||e.has("WEBGL_draw_buffers"),u=t.logarithmicDepthBuffer===!0,f=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),h=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=r.getParameter(r.MAX_TEXTURE_SIZE),_=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),g=r.getParameter(r.MAX_VERTEX_ATTRIBS),m=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),d=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),v=h>0,y=o||e.has("OES_texture_float"),b=v&&y,M=o?r.getParameter(r.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:f,maxVertexTextures:h,maxTextureSize:p,maxCubemapSize:_,maxAttributes:g,maxVertexUniforms:m,maxVaryings:d,maxFragmentUniforms:x,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:b,maxSamples:M}}function wg(r){const e=this;let t=null,n=0,i=!1,s=!1;const o=new ci,a=new st,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){const p=f.length!==0||h||n!==0||i;return i=h,n=f.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,h){t=u(f,h,0)},this.setState=function(f,h,p){const _=f.clippingPlanes,g=f.clipIntersection,m=f.clipShadows,d=r.get(f);if(!i||_===null||_.length===0||s&&!m)s?u(null):c();else{const x=s?0:n,v=x*4;let y=d.clippingState||null;l.value=y,y=u(_,h,v,p);for(let b=0;b!==v;++b)y[b]=t[b];d.clippingState=y,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=x}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(f,h,p,_){const g=f!==null?f.length:0;let m=null;if(g!==0){if(m=l.value,_!==!0||m===null){const d=p+g*4,x=h.matrixWorldInverse;a.getNormalMatrix(x),(m===null||m.length0){const c=new Up(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){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}class ao extends Sf{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(){const 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;let s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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}}const ns=4,Mu=[.125,.215,.35,.446,.526,.582],fr=20,Qa=new ao,Tu=new tt;let Ja=null,el=0,tl=0;const cr=(1+Math.sqrt(5))/2,Vr=1/cr,Au=[new C(1,1,1),new C(-1,1,1),new C(1,1,-1),new C(-1,1,-1),new C(0,cr,Vr),new C(0,cr,-Vr),new C(Vr,0,cr),new C(-Vr,0,cr),new C(cr,Vr,0),new C(-cr,Vr,0)];class Ru{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){Ja=this._renderer.getRenderTarget(),el=this._renderer.getActiveCubeFace(),tl=this._renderer.getActiveMipmapLevel(),this._setSize(256);const 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=Pu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Cu(),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;e2?v:0,v,v),u.setRenderTarget(i),g&&u.render(_,a),u.render(e,a)}_.geometry.dispose(),_.material.dispose(),u.toneMapping=h,u.autoClear=f,e.background=m}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===ls||e.mapping===cs;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Pu()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Cu());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Mn(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;const l=this._cubeSize;Po(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Qa)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;ifr&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${fr}`);const d=[];let x=0;for(let T=0;Tv-ns?i-v+ns:0),M=4*(this._cubeSize-y);Po(t,b,M,3*y,2*y),l.setRenderTarget(t),l.render(f,Qa)}}function Tg(r){const e=[],t=[],n=[];let i=r;const s=r-ns+1+Mu.length;for(let o=0;or-ns?l=Mu[o-r+ns-1]:o===0&&(l=0),n.push(l);const c=1/(a-2),u=-c,f=1+c,h=[u,u,f,u,f,f,u,u,f,f,u,f],p=6,_=6,g=3,m=2,d=1,x=new Float32Array(g*_*p),v=new Float32Array(m*_*p),y=new Float32Array(d*_*p);for(let M=0;M2?0:-1,S=[T,I,0,T+2/3,I,0,T+2/3,I+1,0,T,I,0,T+2/3,I+1,0,T,I+1,0];x.set(S,g*_*M),v.set(h,m*_*M);const A=[M,M,M,M,M,M];y.set(A,d*_*M)}const b=new yn;b.setAttribute("position",new Yt(x,g)),b.setAttribute("uv",new Yt(v,m)),b.setAttribute("faceIndex",new Yt(y,d)),e.push(b),i>ns&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Lu(r,e,t){const n=new Ki(r,e,t);return n.texture.mapping=ga,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Po(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function Ag(r,e,t){const n=new Float32Array(fr),i=new C(0,1,0);return new Zi({name:"SphericalGaussianBlur",defines:{n:fr,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:rc(),fragmentShader:` precision mediump float; precision mediump int; @@ -3584,26 +3584,26 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}function Lg(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const l=a.mapping,c=l===Rl||l===Ll,u=l===ls||l===cs;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let f=e.get(a);return t===null&&(t=new Ru(r)),f=c?t.fromEquirectangular(a,f):t.fromCubemap(a,f),e.set(a,f),f.texture}else{if(e.has(a))return e.get(a).texture;{const f=a.image;if(c&&f&&f.height>0||u&&f&&i(f)){t===null&&(t=new Ru(r));const h=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,h),a.addEventListener("dispose",s),h.texture}else return null}}}return a}function i(a){let l=0;const c=6;for(let u=0;ue.maxTextureSize&&(z=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const O=new Float32Array(A*z*4*g),W=new _f(O,A,z,g);W.type=vn,W.needsUpdate=!0;const D=E*4;for(let Z=0;Z0)return r;const i=e*t;let s=Du[i];if(s===void 0&&(s=new Float32Array(i),Du[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 Kt(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t0||u&&f&&i(f)){t===null&&(t=new Ru(r));const h=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,h),a.addEventListener("dispose",s),h.texture}else return null}}}return a}function i(a){let l=0;const c=6;for(let u=0;ue.maxTextureSize&&(z=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const O=new Float32Array(A*z*4*g),W=new _f(O,A,z,g);W.type=vn,W.needsUpdate=!0;const D=S*4;for(let Z=0;Z0)return r;const i=e*t;let s=Du[i];if(s===void 0&&(s=new Float32Array(i),Du[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 Kt(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t":" "} ${a}: ${t[o]}`)}return n.join(` -`)}function Pv(r){const e=pt.getPrimaries(pt.workingColorSpace),t=pt.getPrimaries(r);let n;switch(e===t?n="":e===ha&&t===ua?n="LinearDisplayP3ToLinearSRGB":e===ua&&t===ha&&(n="LinearSRGBToLinearDisplayP3"),r){case an:case ya:return[n,"LinearTransferOETF"];case Ht:case ec:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),[n,"LinearTransferOETF"]}}function zu(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return t.toUpperCase()+` +`)}function C0(r){const e=pt.getPrimaries(pt.workingColorSpace),t=pt.getPrimaries(r);let n;switch(e===t?n="":e===ha&&t===ua?n="LinearDisplayP3ToLinearSRGB":e===ua&&t===ha&&(n="LinearSRGBToLinearDisplayP3"),r){case an:case ya:return[n,"LinearTransferOETF"];case Ht:case ec:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),[n,"LinearTransferOETF"]}}function zu(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const o=parseInt(s[1]);return t.toUpperCase()+` `+i+` -`+Cv(r.getShaderSource(e),o)}else return i}function Dv(r,e){const t=Pv(e);return`vec4 ${r}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function Iv(r,e){let t;switch(e){case Nd:t="Linear";break;case Fd:t="Reinhard";break;case Od:t="OptimizedCineon";break;case Ud:t="ACESFilmic";break;case Bd:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function Nv(r){return[r.extensionDerivatives||r.envMapCubeUVHeight||r.bumpMap||r.normalMapTangentSpace||r.clearcoatNormalMap||r.flatShading||r.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Hs).join(` -`)}function Fv(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` -`)}function Ov(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function Ol(r){return r.replace(Uv,zv)}const Bv=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function zv(r,e){let t=it[e];if(t===void 0){const n=Bv.get(e);if(n!==void 0)t=it[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Ol(t)}const kv=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Vu(r){return r.replace(kv,Hv)}function Hv(r,e,t,n){let i="";for(let s=parseInt(e);s/gm;function Ol(r){return r.replace(O0,B0)}const U0=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function B0(r,e){let t=it[e];if(t===void 0){const n=U0.get(e);if(n!==void 0)t=it[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Ol(t)}const z0=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Vu(r){return r.replace(z0,k0)}function k0(r,e,t,n){let i="";for(let s=parseInt(e);s0&&(m+=` `),d=[p,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(Hs).join(` `),d.length>0&&(d+=` `)):(m=[Gu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.batching?"#define USE_BATCHING":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Hs).join(` -`),d=[p,Gu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Yi?"#define TONE_MAPPING":"",t.toneMapping!==Yi?it.tonemapping_pars_fragment:"",t.toneMapping!==Yi?Iv("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",it.colorspace_pars_fragment,Dv("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`),d=[p,Gu(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Yi?"#define TONE_MAPPING":"",t.toneMapping!==Yi?it.tonemapping_pars_fragment:"",t.toneMapping!==Yi?D0("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",it.colorspace_pars_fragment,P0("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Hs).join(` `)),o=Ol(o),o=ku(o,t),o=Hu(o,t),a=Ol(a),a=ku(a,t),a=Hu(a,t),o=Vu(o),a=Vu(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(x=`#version 300 es `,m=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` @@ -3614,9 +3614,9 @@ precision `+r.precision+" int;";return r.precision==="highp"?e+=` Program Info Log: `+O+` `+Q+` -`+ce)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(W===""||D==="")&&(Z=!1);Z&&(z.diagnostics={runnable:V,programLog:O,vertexShader:{log:W,prefix:m},fragmentShader:{log:D,prefix:d}})}i.deleteShader(b),i.deleteShader(M),I=new oa(i,g),E=Ov(i,g)}let I;this.getUniforms=function(){return I===void 0&&T(this),I};let E;this.getAttributes=function(){return E===void 0&&T(this),E};let A=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return A===!1&&(A=i.getProgramParameter(g,Rv)),A},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Lv++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=b,this.fragmentShader=M,this}let Yv=0;class $v{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const 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){const t=this.materialCache.get(e);for(const 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){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new Kv(e),t.set(e,n)),n}}class Kv{constructor(e){this.id=Yv++,this.code=e,this.usedTimes=0}}function Zv(r,e,t,n,i,s,o){const a=new gf,l=new $v,c=[],u=i.isWebGL2,f=i.logarithmicDepthBuffer,h=i.vertexTextures;let p=i.precision;const _={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 g(E){return E===0?"uv":`uv${E}`}function m(E,A,z,O,W){const D=O.fog,V=W.geometry,Z=E.isMeshStandardMaterial?O.environment:null,Q=(E.isMeshStandardMaterial?t:e).get(E.envMap||Z),ce=Q&&Q.mapping===ga?Q.image.height:null,ie=_[E.type];E.precision!==null&&(p=i.getMaxPrecision(E.precision),p!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",p,"instead."));const se=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,me=se!==void 0?se.length:0;let ve=0;V.morphAttributes.position!==void 0&&(ve=1),V.morphAttributes.normal!==void 0&&(ve=2),V.morphAttributes.color!==void 0&&(ve=3);let J,oe,Ee,De;if(ie){const Vt=ui[ie];J=Vt.vertexShader,oe=Vt.fragmentShader}else J=E.vertexShader,oe=E.fragmentShader,l.update(E),Ee=l.getVertexShaderID(E),De=l.getFragmentShaderID(E);const _e=r.getRenderTarget(),qe=W.isInstancedMesh===!0,We=W.isBatchedMesh===!0,Fe=!!E.map,Ye=!!E.matcap,X=!!Q,Lt=!!E.aoMap,Ce=!!E.lightMap,$e=!!E.bumpMap,ze=!!E.normalMap,_t=!!E.displacementMap,Ke=!!E.emissiveMap,ke=!!E.metalnessMap,ot=!!E.roughnessMap,Tt=E.anisotropy>0,Ct=E.clearcoat>0,P=E.iridescence>0,S=E.sheen>0,q=E.transmission>0,le=Tt&&!!E.anisotropyMap,re=Ct&&!!E.clearcoatMap,fe=Ct&&!!E.clearcoatNormalMap,Me=Ct&&!!E.clearcoatRoughnessMap,pe=P&&!!E.iridescenceMap,ye=P&&!!E.iridescenceThicknessMap,N=S&&!!E.sheenColorMap,de=S&&!!E.sheenRoughnessMap,ne=!!E.specularMap,Oe=!!E.specularColorMap,Re=!!E.specularIntensityMap,Pe=q&&!!E.transmissionMap,we=q&&!!E.thicknessMap,be=!!E.gradientMap,Ge=!!E.alphaMap,F=E.alphaTest>0,ge=!!E.alphaHash,ae=!!E.extensions,ee=!!V.attributes.uv1,he=!!V.attributes.uv2,Le=!!V.attributes.uv3;let nt=Yi;return E.toneMapped&&(_e===null||_e.isXRRenderTarget===!0)&&(nt=r.toneMapping),{isWebGL2:u,shaderID:ie,shaderType:E.type,shaderName:E.name,vertexShader:J,fragmentShader:oe,defines:E.defines,customVertexShaderID:Ee,customFragmentShaderID:De,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:p,batching:We,instancing:qe,instancingColor:qe&&W.instanceColor!==null,supportsVertexTextures:h,outputColorSpace:_e===null?r.outputColorSpace:_e.isXRRenderTarget===!0?_e.texture.colorSpace:an,map:Fe,matcap:Ye,envMap:X,envMapMode:X&&Q.mapping,envMapCubeUVHeight:ce,aoMap:Lt,lightMap:Ce,bumpMap:$e,normalMap:ze,displacementMap:h&&_t,emissiveMap:Ke,normalMapObjectSpace:ze&&E.normalMapType===Yd,normalMapTangentSpace:ze&&E.normalMapType===uf,metalnessMap:ke,roughnessMap:ot,anisotropy:Tt,anisotropyMap:le,clearcoat:Ct,clearcoatMap:re,clearcoatNormalMap:fe,clearcoatRoughnessMap:Me,iridescence:P,iridescenceMap:pe,iridescenceThicknessMap:ye,sheen:S,sheenColorMap:N,sheenRoughnessMap:de,specularMap:ne,specularColorMap:Oe,specularIntensityMap:Re,transmission:q,transmissionMap:Pe,thicknessMap:we,gradientMap:be,opaque:E.transparent===!1&&E.blending===rs,alphaMap:Ge,alphaTest:F,alphaHash:ge,combine:E.combine,mapUv:Fe&&g(E.map.channel),aoMapUv:Lt&&g(E.aoMap.channel),lightMapUv:Ce&&g(E.lightMap.channel),bumpMapUv:$e&&g(E.bumpMap.channel),normalMapUv:ze&&g(E.normalMap.channel),displacementMapUv:_t&&g(E.displacementMap.channel),emissiveMapUv:Ke&&g(E.emissiveMap.channel),metalnessMapUv:ke&&g(E.metalnessMap.channel),roughnessMapUv:ot&&g(E.roughnessMap.channel),anisotropyMapUv:le&&g(E.anisotropyMap.channel),clearcoatMapUv:re&&g(E.clearcoatMap.channel),clearcoatNormalMapUv:fe&&g(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Me&&g(E.clearcoatRoughnessMap.channel),iridescenceMapUv:pe&&g(E.iridescenceMap.channel),iridescenceThicknessMapUv:ye&&g(E.iridescenceThicknessMap.channel),sheenColorMapUv:N&&g(E.sheenColorMap.channel),sheenRoughnessMapUv:de&&g(E.sheenRoughnessMap.channel),specularMapUv:ne&&g(E.specularMap.channel),specularColorMapUv:Oe&&g(E.specularColorMap.channel),specularIntensityMapUv:Re&&g(E.specularIntensityMap.channel),transmissionMapUv:Pe&&g(E.transmissionMap.channel),thicknessMapUv:we&&g(E.thicknessMap.channel),alphaMapUv:Ge&&g(E.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(ze||Tt),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,vertexUv1s:ee,vertexUv2s:he,vertexUv3s:Le,pointsUvs:W.isPoints===!0&&!!V.attributes.uv&&(Fe||Ge),fog:!!D,useFog:E.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:W.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:me,morphTextureStride:ve,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:E.dithering,shadowMapEnabled:r.shadowMap.enabled&&z.length>0,shadowMapType:r.shadowMap.type,toneMapping:nt,useLegacyLights:r._useLegacyLights,decodeVideoTexture:Fe&&E.map.isVideoTexture===!0&&pt.getTransfer(E.map.colorSpace)===At,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===Zn,flipSided:E.side===xn,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionDerivatives:ae&&E.extensions.derivatives===!0,extensionFragDepth:ae&&E.extensions.fragDepth===!0,extensionDrawBuffers:ae&&E.extensions.drawBuffers===!0,extensionShaderTextureLOD:ae&&E.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()}}function d(E){const A=[];if(E.shaderID?A.push(E.shaderID):(A.push(E.customVertexShaderID),A.push(E.customFragmentShaderID)),E.defines!==void 0)for(const z in E.defines)A.push(z),A.push(E.defines[z]);return E.isRawShaderMaterial===!1&&(x(A,E),v(A,E),A.push(r.outputColorSpace)),A.push(E.customProgramCacheKey),A.join()}function x(E,A){E.push(A.precision),E.push(A.outputColorSpace),E.push(A.envMapMode),E.push(A.envMapCubeUVHeight),E.push(A.mapUv),E.push(A.alphaMapUv),E.push(A.lightMapUv),E.push(A.aoMapUv),E.push(A.bumpMapUv),E.push(A.normalMapUv),E.push(A.displacementMapUv),E.push(A.emissiveMapUv),E.push(A.metalnessMapUv),E.push(A.roughnessMapUv),E.push(A.anisotropyMapUv),E.push(A.clearcoatMapUv),E.push(A.clearcoatNormalMapUv),E.push(A.clearcoatRoughnessMapUv),E.push(A.iridescenceMapUv),E.push(A.iridescenceThicknessMapUv),E.push(A.sheenColorMapUv),E.push(A.sheenRoughnessMapUv),E.push(A.specularMapUv),E.push(A.specularColorMapUv),E.push(A.specularIntensityMapUv),E.push(A.transmissionMapUv),E.push(A.thicknessMapUv),E.push(A.combine),E.push(A.fogExp2),E.push(A.sizeAttenuation),E.push(A.morphTargetsCount),E.push(A.morphAttributeCount),E.push(A.numDirLights),E.push(A.numPointLights),E.push(A.numSpotLights),E.push(A.numSpotLightMaps),E.push(A.numHemiLights),E.push(A.numRectAreaLights),E.push(A.numDirLightShadows),E.push(A.numPointLightShadows),E.push(A.numSpotLightShadows),E.push(A.numSpotLightShadowsWithMaps),E.push(A.numLightProbes),E.push(A.shadowMapType),E.push(A.toneMapping),E.push(A.numClippingPlanes),E.push(A.numClipIntersection),E.push(A.depthPacking)}function v(E,A){a.disableAll(),A.isWebGL2&&a.enable(0),A.supportsVertexTextures&&a.enable(1),A.instancing&&a.enable(2),A.instancingColor&&a.enable(3),A.matcap&&a.enable(4),A.envMap&&a.enable(5),A.normalMapObjectSpace&&a.enable(6),A.normalMapTangentSpace&&a.enable(7),A.clearcoat&&a.enable(8),A.iridescence&&a.enable(9),A.alphaTest&&a.enable(10),A.vertexColors&&a.enable(11),A.vertexAlphas&&a.enable(12),A.vertexUv1s&&a.enable(13),A.vertexUv2s&&a.enable(14),A.vertexUv3s&&a.enable(15),A.vertexTangents&&a.enable(16),A.anisotropy&&a.enable(17),A.alphaHash&&a.enable(18),A.batching&&a.enable(19),E.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.skinning&&a.enable(4),A.morphTargets&&a.enable(5),A.morphNormals&&a.enable(6),A.morphColors&&a.enable(7),A.premultipliedAlpha&&a.enable(8),A.shadowMapEnabled&&a.enable(9),A.useLegacyLights&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),E.push(a.mask)}function y(E){const A=_[E.type];let z;if(A){const O=ui[A];z=Np.clone(O.uniforms)}else z=E.uniforms;return z}function b(E,A){let z;for(let O=0,W=c.length;O0?n.push(d):p.transparent===!0?i.push(d):t.push(d)}function l(f,h,p,_,g,m){const d=o(f,h,p,_,g,m);p.transmission>0?n.unshift(d):p.transparent===!0?i.unshift(d):t.unshift(d)}function c(f,h){t.length>1&&t.sort(f||Jv),n.length>1&&n.sort(h||Wu),i.length>1&&i.sort(h||Wu)}function u(){for(let f=e,h=r.length;f=s.length?(o=new Xu,s.push(o)):o=s[i],o}function t(){r=new WeakMap}return{get:e,dispose:t}}function t0(){const 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 C,color:new tt};break;case"SpotLight":t={position:new C,direction:new C,color:new tt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new tt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new tt,groundColor:new tt};break;case"RectAreaLight":t={color:new tt,position:new C,halfWidth:new C,halfHeight:new C};break}return r[e.id]=t,t}}}function n0(){const 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 Ue};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let i0=0;function r0(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function s0(r,e){const t=new t0,n=n0(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)i.probe.push(new C);const s=new C,o=new Ve,a=new Ve;function l(u,f){let h=0,p=0,_=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let g=0,m=0,d=0,x=0,v=0,y=0,b=0,M=0,T=0,I=0,E=0;u.sort(r0);const A=f===!0?Math.PI:1;for(let O=0,W=u.length;O0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=xe.LTC_FLOAT_1,i.rectAreaLTC2=xe.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=xe.LTC_HALF_1,i.rectAreaLTC2=xe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=h,i.ambient[1]=p,i.ambient[2]=_;const z=i.hash;(z.directionalLength!==g||z.pointLength!==m||z.spotLength!==d||z.rectAreaLength!==x||z.hemiLength!==v||z.numDirectionalShadows!==y||z.numPointShadows!==b||z.numSpotShadows!==M||z.numSpotMaps!==T||z.numLightProbes!==E)&&(i.directional.length=g,i.spot.length=d,i.rectArea.length=x,i.point.length=m,i.hemi.length=v,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=M+T-I,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=E,z.directionalLength=g,z.pointLength=m,z.spotLength=d,z.rectAreaLength=x,z.hemiLength=v,z.numDirectionalShadows=y,z.numPointShadows=b,z.numSpotShadows=M,z.numSpotMaps=T,z.numLightProbes=E,i.version=i0++)}function c(u,f){let h=0,p=0,_=0,g=0,m=0;const d=f.matrixWorldInverse;for(let x=0,v=u.length;x=a.length?(l=new qu(r,e),a.push(l)):l=a[o],l}function i(){t=new WeakMap}return{get:n,dispose:i}}class a0 extends di{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=qd,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}}class l0 extends di{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",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.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const c0=`void main() { +`+ce)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(W===""||D==="")&&(Z=!1);Z&&(z.diagnostics={runnable:V,programLog:O,vertexShader:{log:W,prefix:m},fragmentShader:{log:D,prefix:d}})}i.deleteShader(b),i.deleteShader(M),I=new oa(i,g),S=F0(i,g)}let I;this.getUniforms=function(){return I===void 0&&T(this),I};let S;this.getAttributes=function(){return S===void 0&&T(this),S};let A=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return A===!1&&(A=i.getProgramParameter(g,A0)),A},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=R0++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=b,this.fragmentShader=M,this}let j0=0;class Y0{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const 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){const t=this.materialCache.get(e);for(const 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){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new $0(e),t.set(e,n)),n}}class $0{constructor(e){this.id=j0++,this.code=e,this.usedTimes=0}}function K0(r,e,t,n,i,s,o){const a=new gf,l=new Y0,c=[],u=i.isWebGL2,f=i.logarithmicDepthBuffer,h=i.vertexTextures;let p=i.precision;const _={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 g(S){return S===0?"uv":`uv${S}`}function m(S,A,z,O,W){const D=O.fog,V=W.geometry,Z=S.isMeshStandardMaterial?O.environment:null,Q=(S.isMeshStandardMaterial?t:e).get(S.envMap||Z),ce=Q&&Q.mapping===ga?Q.image.height:null,ie=_[S.type];S.precision!==null&&(p=i.getMaxPrecision(S.precision),p!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",p,"instead."));const se=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,me=se!==void 0?se.length:0;let ve=0;V.morphAttributes.position!==void 0&&(ve=1),V.morphAttributes.normal!==void 0&&(ve=2),V.morphAttributes.color!==void 0&&(ve=3);let J,oe,Se,De;if(ie){const Vt=ui[ie];J=Vt.vertexShader,oe=Vt.fragmentShader}else J=S.vertexShader,oe=S.fragmentShader,l.update(S),Se=l.getVertexShaderID(S),De=l.getFragmentShaderID(S);const _e=r.getRenderTarget(),qe=W.isInstancedMesh===!0,We=W.isBatchedMesh===!0,Fe=!!S.map,Ye=!!S.matcap,X=!!Q,Lt=!!S.aoMap,Ce=!!S.lightMap,$e=!!S.bumpMap,ze=!!S.normalMap,_t=!!S.displacementMap,Ke=!!S.emissiveMap,ke=!!S.metalnessMap,ot=!!S.roughnessMap,Tt=S.anisotropy>0,Ct=S.clearcoat>0,P=S.iridescence>0,E=S.sheen>0,q=S.transmission>0,le=Tt&&!!S.anisotropyMap,re=Ct&&!!S.clearcoatMap,fe=Ct&&!!S.clearcoatNormalMap,Me=Ct&&!!S.clearcoatRoughnessMap,pe=P&&!!S.iridescenceMap,ye=P&&!!S.iridescenceThicknessMap,N=E&&!!S.sheenColorMap,de=E&&!!S.sheenRoughnessMap,ne=!!S.specularMap,Oe=!!S.specularColorMap,Re=!!S.specularIntensityMap,Pe=q&&!!S.transmissionMap,we=q&&!!S.thicknessMap,be=!!S.gradientMap,Ge=!!S.alphaMap,F=S.alphaTest>0,ge=!!S.alphaHash,ae=!!S.extensions,ee=!!V.attributes.uv1,he=!!V.attributes.uv2,Le=!!V.attributes.uv3;let nt=Yi;return S.toneMapped&&(_e===null||_e.isXRRenderTarget===!0)&&(nt=r.toneMapping),{isWebGL2:u,shaderID:ie,shaderType:S.type,shaderName:S.name,vertexShader:J,fragmentShader:oe,defines:S.defines,customVertexShaderID:Se,customFragmentShaderID:De,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:p,batching:We,instancing:qe,instancingColor:qe&&W.instanceColor!==null,supportsVertexTextures:h,outputColorSpace:_e===null?r.outputColorSpace:_e.isXRRenderTarget===!0?_e.texture.colorSpace:an,map:Fe,matcap:Ye,envMap:X,envMapMode:X&&Q.mapping,envMapCubeUVHeight:ce,aoMap:Lt,lightMap:Ce,bumpMap:$e,normalMap:ze,displacementMap:h&&_t,emissiveMap:Ke,normalMapObjectSpace:ze&&S.normalMapType===jd,normalMapTangentSpace:ze&&S.normalMapType===uf,metalnessMap:ke,roughnessMap:ot,anisotropy:Tt,anisotropyMap:le,clearcoat:Ct,clearcoatMap:re,clearcoatNormalMap:fe,clearcoatRoughnessMap:Me,iridescence:P,iridescenceMap:pe,iridescenceThicknessMap:ye,sheen:E,sheenColorMap:N,sheenRoughnessMap:de,specularMap:ne,specularColorMap:Oe,specularIntensityMap:Re,transmission:q,transmissionMap:Pe,thicknessMap:we,gradientMap:be,opaque:S.transparent===!1&&S.blending===rs,alphaMap:Ge,alphaTest:F,alphaHash:ge,combine:S.combine,mapUv:Fe&&g(S.map.channel),aoMapUv:Lt&&g(S.aoMap.channel),lightMapUv:Ce&&g(S.lightMap.channel),bumpMapUv:$e&&g(S.bumpMap.channel),normalMapUv:ze&&g(S.normalMap.channel),displacementMapUv:_t&&g(S.displacementMap.channel),emissiveMapUv:Ke&&g(S.emissiveMap.channel),metalnessMapUv:ke&&g(S.metalnessMap.channel),roughnessMapUv:ot&&g(S.roughnessMap.channel),anisotropyMapUv:le&&g(S.anisotropyMap.channel),clearcoatMapUv:re&&g(S.clearcoatMap.channel),clearcoatNormalMapUv:fe&&g(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Me&&g(S.clearcoatRoughnessMap.channel),iridescenceMapUv:pe&&g(S.iridescenceMap.channel),iridescenceThicknessMapUv:ye&&g(S.iridescenceThicknessMap.channel),sheenColorMapUv:N&&g(S.sheenColorMap.channel),sheenRoughnessMapUv:de&&g(S.sheenRoughnessMap.channel),specularMapUv:ne&&g(S.specularMap.channel),specularColorMapUv:Oe&&g(S.specularColorMap.channel),specularIntensityMapUv:Re&&g(S.specularIntensityMap.channel),transmissionMapUv:Pe&&g(S.transmissionMap.channel),thicknessMapUv:we&&g(S.thicknessMap.channel),alphaMapUv:Ge&&g(S.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(ze||Tt),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,vertexUv1s:ee,vertexUv2s:he,vertexUv3s:Le,pointsUvs:W.isPoints===!0&&!!V.attributes.uv&&(Fe||Ge),fog:!!D,useFog:S.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:S.flatShading===!0,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:W.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:me,morphTextureStride:ve,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:S.dithering,shadowMapEnabled:r.shadowMap.enabled&&z.length>0,shadowMapType:r.shadowMap.type,toneMapping:nt,useLegacyLights:r._useLegacyLights,decodeVideoTexture:Fe&&S.map.isVideoTexture===!0&&pt.getTransfer(S.map.colorSpace)===At,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Zn,flipSided:S.side===xn,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionDerivatives:ae&&S.extensions.derivatives===!0,extensionFragDepth:ae&&S.extensions.fragDepth===!0,extensionDrawBuffers:ae&&S.extensions.drawBuffers===!0,extensionShaderTextureLOD:ae&&S.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()}}function d(S){const A=[];if(S.shaderID?A.push(S.shaderID):(A.push(S.customVertexShaderID),A.push(S.customFragmentShaderID)),S.defines!==void 0)for(const z in S.defines)A.push(z),A.push(S.defines[z]);return S.isRawShaderMaterial===!1&&(x(A,S),v(A,S),A.push(r.outputColorSpace)),A.push(S.customProgramCacheKey),A.join()}function x(S,A){S.push(A.precision),S.push(A.outputColorSpace),S.push(A.envMapMode),S.push(A.envMapCubeUVHeight),S.push(A.mapUv),S.push(A.alphaMapUv),S.push(A.lightMapUv),S.push(A.aoMapUv),S.push(A.bumpMapUv),S.push(A.normalMapUv),S.push(A.displacementMapUv),S.push(A.emissiveMapUv),S.push(A.metalnessMapUv),S.push(A.roughnessMapUv),S.push(A.anisotropyMapUv),S.push(A.clearcoatMapUv),S.push(A.clearcoatNormalMapUv),S.push(A.clearcoatRoughnessMapUv),S.push(A.iridescenceMapUv),S.push(A.iridescenceThicknessMapUv),S.push(A.sheenColorMapUv),S.push(A.sheenRoughnessMapUv),S.push(A.specularMapUv),S.push(A.specularColorMapUv),S.push(A.specularIntensityMapUv),S.push(A.transmissionMapUv),S.push(A.thicknessMapUv),S.push(A.combine),S.push(A.fogExp2),S.push(A.sizeAttenuation),S.push(A.morphTargetsCount),S.push(A.morphAttributeCount),S.push(A.numDirLights),S.push(A.numPointLights),S.push(A.numSpotLights),S.push(A.numSpotLightMaps),S.push(A.numHemiLights),S.push(A.numRectAreaLights),S.push(A.numDirLightShadows),S.push(A.numPointLightShadows),S.push(A.numSpotLightShadows),S.push(A.numSpotLightShadowsWithMaps),S.push(A.numLightProbes),S.push(A.shadowMapType),S.push(A.toneMapping),S.push(A.numClippingPlanes),S.push(A.numClipIntersection),S.push(A.depthPacking)}function v(S,A){a.disableAll(),A.isWebGL2&&a.enable(0),A.supportsVertexTextures&&a.enable(1),A.instancing&&a.enable(2),A.instancingColor&&a.enable(3),A.matcap&&a.enable(4),A.envMap&&a.enable(5),A.normalMapObjectSpace&&a.enable(6),A.normalMapTangentSpace&&a.enable(7),A.clearcoat&&a.enable(8),A.iridescence&&a.enable(9),A.alphaTest&&a.enable(10),A.vertexColors&&a.enable(11),A.vertexAlphas&&a.enable(12),A.vertexUv1s&&a.enable(13),A.vertexUv2s&&a.enable(14),A.vertexUv3s&&a.enable(15),A.vertexTangents&&a.enable(16),A.anisotropy&&a.enable(17),A.alphaHash&&a.enable(18),A.batching&&a.enable(19),S.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.skinning&&a.enable(4),A.morphTargets&&a.enable(5),A.morphNormals&&a.enable(6),A.morphColors&&a.enable(7),A.premultipliedAlpha&&a.enable(8),A.shadowMapEnabled&&a.enable(9),A.useLegacyLights&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),S.push(a.mask)}function y(S){const A=_[S.type];let z;if(A){const O=ui[A];z=Ip.clone(O.uniforms)}else z=S.uniforms;return z}function b(S,A){let z;for(let O=0,W=c.length;O0?n.push(d):p.transparent===!0?i.push(d):t.push(d)}function l(f,h,p,_,g,m){const d=o(f,h,p,_,g,m);p.transmission>0?n.unshift(d):p.transparent===!0?i.unshift(d):t.unshift(d)}function c(f,h){t.length>1&&t.sort(f||Q0),n.length>1&&n.sort(h||Wu),i.length>1&&i.sort(h||Wu)}function u(){for(let f=e,h=r.length;f=s.length?(o=new Xu,s.push(o)):o=s[i],o}function t(){r=new WeakMap}return{get:e,dispose:t}}function ev(){const 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 C,color:new tt};break;case"SpotLight":t={position:new C,direction:new C,color:new tt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new tt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new tt,groundColor:new tt};break;case"RectAreaLight":t={color:new tt,position:new C,halfWidth:new C,halfHeight:new C};break}return r[e.id]=t,t}}}function tv(){const 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 Ue};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let nv=0;function iv(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function rv(r,e){const t=new ev,n=tv(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)i.probe.push(new C);const s=new C,o=new Ve,a=new Ve;function l(u,f){let h=0,p=0,_=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let g=0,m=0,d=0,x=0,v=0,y=0,b=0,M=0,T=0,I=0,S=0;u.sort(iv);const A=f===!0?Math.PI:1;for(let O=0,W=u.length;O0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=xe.LTC_FLOAT_1,i.rectAreaLTC2=xe.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=xe.LTC_HALF_1,i.rectAreaLTC2=xe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=h,i.ambient[1]=p,i.ambient[2]=_;const z=i.hash;(z.directionalLength!==g||z.pointLength!==m||z.spotLength!==d||z.rectAreaLength!==x||z.hemiLength!==v||z.numDirectionalShadows!==y||z.numPointShadows!==b||z.numSpotShadows!==M||z.numSpotMaps!==T||z.numLightProbes!==S)&&(i.directional.length=g,i.spot.length=d,i.rectArea.length=x,i.point.length=m,i.hemi.length=v,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=M+T-I,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=S,z.directionalLength=g,z.pointLength=m,z.spotLength=d,z.rectAreaLength=x,z.hemiLength=v,z.numDirectionalShadows=y,z.numPointShadows=b,z.numSpotShadows=M,z.numSpotMaps=T,z.numLightProbes=S,i.version=nv++)}function c(u,f){let h=0,p=0,_=0,g=0,m=0;const d=f.matrixWorldInverse;for(let x=0,v=u.length;x=a.length?(l=new qu(r,e),a.push(l)):l=a[o],l}function i(){t=new WeakMap}return{get:n,dispose:i}}class ov extends di{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Xd,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}}class av extends di{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",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.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const lv=`void main() { gl_Position = vec4( position, 1.0 ); -}`,u0=`uniform sampler2D shadow_pass; +}`,cv=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include @@ -3642,7 +3642,7 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function h0(r,e,t){let n=new nc;const i=new Ue,s=new Ue,o=new mt,a=new a0({depthPacking:jd}),l=new l0,c={},u=t.maxTextureSize,f={[ei]:xn,[xn]:ei,[Zn]:Zn},h=new Zi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ue},radius:{value:4}},vertexShader:c0,fragmentShader:u0}),p=h.clone();p.defines.HORIZONTAL_PASS=1;const _=new yn;_.setAttribute("position",new Yt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Mn(_,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Zh;let d=this.type;this.render=function(b,M,T){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;const I=r.getRenderTarget(),E=r.getActiveCubeFace(),A=r.getActiveMipmapLevel(),z=r.state;z.setBlending(ji),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const O=d!==Mi&&this.type===Mi,W=d===Mi&&this.type!==Mi;for(let D=0,V=b.length;Du||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/ce.x),i.x=s.x*ce.x,Q.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/ce.y),i.y=s.y*ce.y,Q.mapSize.y=s.y)),Q.map===null||O===!0||W===!0){const se=this.type!==Mi?{minFilter:Nt,magFilter:Nt}:{};Q.map!==null&&Q.map.dispose(),Q.map=new Ki(i.x,i.y,se),Q.map.texture.name=Z.name+".shadowMap",Q.camera.updateProjectionMatrix()}r.setRenderTarget(Q.map),r.clear();const ie=Q.getViewportCount();for(let se=0;se0||M.map&&M.alphaTest>0){const z=E.uuid,O=M.uuid;let W=c[z];W===void 0&&(W={},c[z]=W);let D=W[O];D===void 0&&(D=E.clone(),W[O]=D),E=D}if(E.visible=M.visible,E.wireframe=M.wireframe,I===Mi?E.side=M.shadowSide!==null?M.shadowSide:M.side:E.side=M.shadowSide!==null?M.shadowSide:f[M.side],E.alphaMap=M.alphaMap,E.alphaTest=M.alphaTest,E.map=M.map,E.clipShadows=M.clipShadows,E.clippingPlanes=M.clippingPlanes,E.clipIntersection=M.clipIntersection,E.displacementMap=M.displacementMap,E.displacementScale=M.displacementScale,E.displacementBias=M.displacementBias,E.wireframeLinewidth=M.wireframeLinewidth,E.linewidth=M.linewidth,T.isPointLight===!0&&E.isMeshDistanceMaterial===!0){const z=r.properties.get(E);z.light=T}return E}function y(b,M,T,I,E){if(b.visible===!1)return;if(b.layers.test(M.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&E===Mi)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,b.matrixWorld);const O=e.update(b),W=b.material;if(Array.isArray(W)){const D=O.groups;for(let V=0,Z=D.length;V=1):se.indexOf("OpenGL ES")!==-1&&(ie=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),ce=ie>=2);let me=null,ve={};const J=r.getParameter(r.SCISSOR_BOX),oe=r.getParameter(r.VIEWPORT),Ee=new mt().fromArray(J),De=new mt().fromArray(oe);function _e(F,ge,ae,ee){const he=new Uint8Array(4),Le=r.createTexture();r.bindTexture(F,Le),r.texParameteri(F,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(F,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let nt=0;nt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),_=new WeakMap;let g;const m=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(P,S){return d?new OffscreenCanvas(P,S):to("canvas")}function v(P,S,q,le){let re=1;if((P.width>le||P.height>le)&&(re=le/Math.max(P.width,P.height)),re<1||S===!0)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap){const fe=S?da:Math.floor,Me=fe(re*P.width),pe=fe(re*P.height);g===void 0&&(g=x(Me,pe));const ye=q?x(Me,pe):g;return ye.width=Me,ye.height=pe,ye.getContext("2d").drawImage(P,0,0,Me,pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+P.width+"x"+P.height+") to ("+Me+"x"+pe+")."),ye}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+P.width+"x"+P.height+")."),P;return P}function y(P){return Fl(P.width)&&Fl(P.height)}function b(P){return a?!1:P.wrapS!==Hn||P.wrapT!==Hn||P.minFilter!==Nt&&P.minFilter!==Sn}function M(P,S){return P.generateMipmaps&&S&&P.minFilter!==Nt&&P.minFilter!==Sn}function T(P){r.generateMipmap(P)}function I(P,S,q,le,re=!1){if(a===!1)return S;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 fe=S;if(S===r.RED&&(q===r.FLOAT&&(fe=r.R32F),q===r.HALF_FLOAT&&(fe=r.R16F),q===r.UNSIGNED_BYTE&&(fe=r.R8)),S===r.RED_INTEGER&&(q===r.UNSIGNED_BYTE&&(fe=r.R8UI),q===r.UNSIGNED_SHORT&&(fe=r.R16UI),q===r.UNSIGNED_INT&&(fe=r.R32UI),q===r.BYTE&&(fe=r.R8I),q===r.SHORT&&(fe=r.R16I),q===r.INT&&(fe=r.R32I)),S===r.RG&&(q===r.FLOAT&&(fe=r.RG32F),q===r.HALF_FLOAT&&(fe=r.RG16F),q===r.UNSIGNED_BYTE&&(fe=r.RG8)),S===r.RGBA){const Me=re?ca:pt.getTransfer(le);q===r.FLOAT&&(fe=r.RGBA32F),q===r.HALF_FLOAT&&(fe=r.RGBA16F),q===r.UNSIGNED_BYTE&&(fe=Me===At?r.SRGB8_ALPHA8:r.RGBA8),q===r.UNSIGNED_SHORT_4_4_4_4&&(fe=r.RGBA4),q===r.UNSIGNED_SHORT_5_5_5_1&&(fe=r.RGB5_A1)}return(fe===r.R16F||fe===r.R32F||fe===r.RG16F||fe===r.RG32F||fe===r.RGBA16F||fe===r.RGBA32F)&&e.get("EXT_color_buffer_float"),fe}function E(P,S,q){return M(P,q)===!0||P.isFramebufferTexture&&P.minFilter!==Nt&&P.minFilter!==Sn?Math.log2(Math.max(S.width,S.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?S.mipmaps.length:1}function A(P){return P===Nt||P===Cl||P===sa?r.NEAREST:r.LINEAR}function z(P){const S=P.target;S.removeEventListener("dispose",z),W(S),S.isVideoTexture&&_.delete(S)}function O(P){const S=P.target;S.removeEventListener("dispose",O),V(S)}function W(P){const S=n.get(P);if(S.__webglInit===void 0)return;const q=P.source,le=m.get(q);if(le){const re=le[S.__cacheKey];re.usedTimes--,re.usedTimes===0&&D(P),Object.keys(le).length===0&&m.delete(q)}n.remove(P)}function D(P){const S=n.get(P);r.deleteTexture(S.__webglTexture);const q=P.source,le=m.get(q);delete le[S.__cacheKey],o.memory.textures--}function V(P){const S=P.texture,q=n.get(P),le=n.get(S);if(le.__webglTexture!==void 0&&(r.deleteTexture(le.__webglTexture),o.memory.textures--),P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let re=0;re<6;re++){if(Array.isArray(q.__webglFramebuffer[re]))for(let fe=0;fe=l&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+l),Z+=1,P}function ie(P){const S=[];return S.push(P.wrapS),S.push(P.wrapT),S.push(P.wrapR||0),S.push(P.magFilter),S.push(P.minFilter),S.push(P.anisotropy),S.push(P.internalFormat),S.push(P.format),S.push(P.type),S.push(P.generateMipmaps),S.push(P.premultiplyAlpha),S.push(P.flipY),S.push(P.unpackAlignment),S.push(P.colorSpace),S.join()}function se(P,S){const q=n.get(P);if(P.isVideoTexture&&Tt(P),P.isRenderTargetTexture===!1&&P.version>0&&q.__version!==P.version){const le=P.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{We(q,P,S);return}}t.bindTexture(r.TEXTURE_2D,q.__webglTexture,r.TEXTURE0+S)}function me(P,S){const q=n.get(P);if(P.version>0&&q.__version!==P.version){We(q,P,S);return}t.bindTexture(r.TEXTURE_2D_ARRAY,q.__webglTexture,r.TEXTURE0+S)}function ve(P,S){const q=n.get(P);if(P.version>0&&q.__version!==P.version){We(q,P,S);return}t.bindTexture(r.TEXTURE_3D,q.__webglTexture,r.TEXTURE0+S)}function J(P,S){const q=n.get(P);if(P.version>0&&q.__version!==P.version){Fe(q,P,S);return}t.bindTexture(r.TEXTURE_CUBE_MAP,q.__webglTexture,r.TEXTURE0+S)}const oe={[us]:r.REPEAT,[Hn]:r.CLAMP_TO_EDGE,[la]:r.MIRRORED_REPEAT},Ee={[Nt]:r.NEAREST,[Cl]:r.NEAREST_MIPMAP_NEAREST,[sa]:r.NEAREST_MIPMAP_LINEAR,[Sn]:r.LINEAR,[ef]:r.LINEAR_MIPMAP_NEAREST,[gr]:r.LINEAR_MIPMAP_LINEAR},De={[$d]:r.NEVER,[tp]:r.ALWAYS,[Kd]:r.LESS,[hf]:r.LEQUAL,[Zd]:r.EQUAL,[ep]:r.GEQUAL,[Qd]:r.GREATER,[Jd]:r.NOTEQUAL};function _e(P,S,q){if(q?(r.texParameteri(P,r.TEXTURE_WRAP_S,oe[S.wrapS]),r.texParameteri(P,r.TEXTURE_WRAP_T,oe[S.wrapT]),(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)&&r.texParameteri(P,r.TEXTURE_WRAP_R,oe[S.wrapR]),r.texParameteri(P,r.TEXTURE_MAG_FILTER,Ee[S.magFilter]),r.texParameteri(P,r.TEXTURE_MIN_FILTER,Ee[S.minFilter])):(r.texParameteri(P,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(P,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)&&r.texParameteri(P,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(S.wrapS!==Hn||S.wrapT!==Hn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(P,r.TEXTURE_MAG_FILTER,A(S.magFilter)),r.texParameteri(P,r.TEXTURE_MIN_FILTER,A(S.minFilter)),S.minFilter!==Nt&&S.minFilter!==Sn&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),S.compareFunction&&(r.texParameteri(P,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(P,r.TEXTURE_COMPARE_FUNC,De[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const le=e.get("EXT_texture_filter_anisotropic");if(S.magFilter===Nt||S.minFilter!==sa&&S.minFilter!==gr||S.type===vn&&e.has("OES_texture_float_linear")===!1||a===!1&&S.type===Qs&&e.has("OES_texture_half_float_linear")===!1)return;(S.anisotropy>1||n.get(S).__currentAnisotropy)&&(r.texParameterf(P,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy)}}function qe(P,S){let q=!1;P.__webglInit===void 0&&(P.__webglInit=!0,S.addEventListener("dispose",z));const le=S.source;let re=m.get(le);re===void 0&&(re={},m.set(le,re));const fe=ie(S);if(fe!==P.__cacheKey){re[fe]===void 0&&(re[fe]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,q=!0),re[fe].usedTimes++;const Me=re[P.__cacheKey];Me!==void 0&&(re[P.__cacheKey].usedTimes--,Me.usedTimes===0&&D(S)),P.__cacheKey=fe,P.__webglTexture=re[fe].texture}return q}function We(P,S,q){let le=r.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(le=r.TEXTURE_2D_ARRAY),S.isData3DTexture&&(le=r.TEXTURE_3D);const re=qe(P,S),fe=S.source;t.bindTexture(le,P.__webglTexture,r.TEXTURE0+q);const Me=n.get(fe);if(fe.version!==Me.__version||re===!0){t.activeTexture(r.TEXTURE0+q);const pe=pt.getPrimaries(pt.workingColorSpace),ye=S.colorSpace===Vn?null:pt.getPrimaries(S.colorSpace),N=S.colorSpace===Vn||pe===ye?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,S.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,S.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,N);const de=b(S)&&y(S.image)===!1;let ne=v(S.image,de,!1,u);ne=Ct(S,ne);const Oe=y(ne)||a,Re=s.convert(S.format,S.colorSpace);let Pe=s.convert(S.type),we=I(S.internalFormat,Re,Pe,S.colorSpace,S.isVideoTexture);_e(le,S,Oe);let be;const Ge=S.mipmaps,F=a&&S.isVideoTexture!==!0&&we!==af,ge=Me.__version===void 0||re===!0,ae=E(S,ne,Oe);if(S.isDepthTexture)we=r.DEPTH_COMPONENT,a?S.type===vn?we=r.DEPTH_COMPONENT32F:S.type===Dn?we=r.DEPTH_COMPONENT24:S.type===pr?we=r.DEPTH24_STENCIL8:we=r.DEPTH_COMPONENT16:S.type===vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),S.format===mr&&we===r.DEPTH_COMPONENT&&S.type!==va&&S.type!==Dn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),S.type=Dn,Pe=s.convert(S.type)),S.format===hs&&we===r.DEPTH_COMPONENT&&(we=r.DEPTH_STENCIL,S.type!==pr&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),S.type=pr,Pe=s.convert(S.type))),ge&&(F?t.texStorage2D(r.TEXTURE_2D,1,we,ne.width,ne.height):t.texImage2D(r.TEXTURE_2D,0,we,ne.width,ne.height,0,Re,Pe,null));else if(S.isDataTexture)if(Ge.length>0&&Oe){F&&ge&&t.texStorage2D(r.TEXTURE_2D,ae,we,Ge[0].width,Ge[0].height);for(let ee=0,he=Ge.length;ee>=1,he>>=1}}else if(Ge.length>0&&Oe){F&&ge&&t.texStorage2D(r.TEXTURE_2D,ae,we,Ge[0].width,Ge[0].height);for(let ee=0,he=Ge.length;ee0&&ge++,t.texStorage2D(r.TEXTURE_CUBE_MAP,ge,be,ne[0].width,ne[0].height));for(let ee=0;ee<6;ee++)if(de){Ge?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,ne[ee].width,ne[ee].height,Pe,we,ne[ee].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,be,ne[ee].width,ne[ee].height,0,Pe,we,ne[ee].data);for(let he=0;he>fe),ne=Math.max(1,S.height>>fe);re===r.TEXTURE_3D||re===r.TEXTURE_2D_ARRAY?t.texImage3D(re,fe,ye,de,ne,S.depth,0,Me,pe,null):t.texImage2D(re,fe,ye,de,ne,0,Me,pe,null)}t.bindFramebuffer(r.FRAMEBUFFER,P),ot(S)?h.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,le,re,n.get(q).__webglTexture,0,ke(S)):(re===r.TEXTURE_2D||re>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&re<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,le,re,n.get(q).__webglTexture,fe),t.bindFramebuffer(r.FRAMEBUFFER,null)}function X(P,S,q){if(r.bindRenderbuffer(r.RENDERBUFFER,P),S.depthBuffer&&!S.stencilBuffer){let le=a===!0?r.DEPTH_COMPONENT24:r.DEPTH_COMPONENT16;if(q||ot(S)){const re=S.depthTexture;re&&re.isDepthTexture&&(re.type===vn?le=r.DEPTH_COMPONENT32F:re.type===Dn&&(le=r.DEPTH_COMPONENT24));const fe=ke(S);ot(S)?h.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,fe,le,S.width,S.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,fe,le,S.width,S.height)}else r.renderbufferStorage(r.RENDERBUFFER,le,S.width,S.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,P)}else if(S.depthBuffer&&S.stencilBuffer){const le=ke(S);q&&ot(S)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,le,r.DEPTH24_STENCIL8,S.width,S.height):ot(S)?h.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,le,r.DEPTH24_STENCIL8,S.width,S.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,S.width,S.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,P)}else{const le=S.isWebGLMultipleRenderTargets===!0?S.texture:[S.texture];for(let re=0;re0){q.__webglFramebuffer[pe]=[];for(let ye=0;ye0){q.__webglFramebuffer=[];for(let pe=0;pe0&&ot(P)===!1){const pe=fe?S:[S];q.__webglMultisampledFramebuffer=r.createFramebuffer(),q.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,q.__webglMultisampledFramebuffer);for(let ye=0;ye0)for(let ye=0;ye0)for(let ye=0;ye0&&ot(P)===!1){const S=P.isWebGLMultipleRenderTargets?P.texture:[P.texture],q=P.width,le=P.height;let re=r.COLOR_BUFFER_BIT;const fe=[],Me=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,pe=n.get(P),ye=P.isWebGLMultipleRenderTargets===!0;if(ye)for(let N=0;N0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function Tt(P){const S=o.render.frame;_.get(P)!==S&&(_.set(P,S),P.update())}function Ct(P,S){const q=P.colorSpace,le=P.format,re=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||P.format===Nl||q!==an&&q!==Vn&&(pt.getTransfer(q)===At?a===!1?e.has("EXT_sRGB")===!0&&le===sn?(P.format=Nl,P.minFilter=Sn,P.generateMipmaps=!1):S=pf.sRGBToLinear(S):(le!==sn||re!==fi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",q)),S}this.allocateTextureUnit=ce,this.resetTextureUnits=Q,this.setTexture2D=se,this.setTexture2DArray=me,this.setTexture3D=ve,this.setTextureCube=J,this.rebindTextures=$e,this.setupRenderTarget=ze,this.updateRenderTargetMipmap=_t,this.updateMultisampleRenderTarget=Ke,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=Ye,this.useMultisampledRTT=ot}function p0(r,e,t){const n=t.isWebGL2;function i(s,o=Vn){let a;const l=pt.getTransfer(o);if(s===fi)return r.UNSIGNED_BYTE;if(s===nf)return r.UNSIGNED_SHORT_4_4_4_4;if(s===rf)return r.UNSIGNED_SHORT_5_5_5_1;if(s===Pl)return r.BYTE;if(s===tf)return r.SHORT;if(s===va)return r.UNSIGNED_SHORT;if(s===Ws)return r.INT;if(s===Dn)return r.UNSIGNED_INT;if(s===vn)return r.FLOAT;if(s===Qs)return n?r.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===kd)return r.ALPHA;if(s===sn)return r.RGBA;if(s===Hd)return r.LUMINANCE;if(s===Vd)return r.LUMINANCE_ALPHA;if(s===mr)return r.DEPTH_COMPONENT;if(s===hs)return r.DEPTH_STENCIL;if(s===Nl)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===sf)return r.RED;if(s===Jl)return r.RED_INTEGER;if(s===of)return r.RG;if(s===xa)return r.RG_INTEGER;if(s===Js)return r.RGBA_INTEGER;if(s===La||s===Ca||s===Pa||s===Da)if(l===At)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===La)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ca)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Pa)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Da)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===La)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ca)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Pa)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Da)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Dc||s===Ic||s===Nc||s===Fc)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Dc)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Ic)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Nc)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Fc)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===af)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Oc||s===Uc)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Oc)return l===At?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Uc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Bc||s===zc||s===kc||s===Hc||s===Vc||s===Gc||s===Wc||s===Xc||s===qc||s===jc||s===Yc||s===$c||s===Kc||s===Zc)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Bc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===zc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===kc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Hc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Vc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Gc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Wc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Xc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===qc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===jc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Yc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===$c)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Kc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Zc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Ia||s===Qc||s===Jc)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Ia)return l===At?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===Qc)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===Jc)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Gd||s===eu||s===tu||s===nu)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===Ia)return a.COMPRESSED_RED_RGTC1_EXT;if(s===eu)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===tu)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===nu)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===pr?n?r.UNSIGNED_INT_24_8:(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}}class m0 extends _n{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class dr extends Bt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const _0={type:"move"};class il{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dr,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 dr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),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}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data: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;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const g of e.hand.values()){const m=t.getJointPose(g,n),d=this._getHandJoint(c,g);m!==null&&(d.matrix.fromArray(m.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,d.jointRadius=m.radius),d.visible=m!==null}const u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],h=u.position.distanceTo(f.position),p=.02,_=.005;c.inputState.pinching&&h>p+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=p-_&&(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),l.matrixWorldNeedsUpdate=!0,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));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,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(_0)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new dr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class g0 extends xr{constructor(e,t){super();const n=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,f=null,h=null,p=null,_=null;const g=t.getContextAttributes();let m=null,d=null;const x=[],v=[],y=new Ue;let b=null;const M=new _n;M.layers.enable(1),M.viewport=new mt;const T=new _n;T.layers.enable(2),T.viewport=new mt;const I=[M,T],E=new m0;E.layers.enable(1),E.layers.enable(2);let A=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let oe=x[J];return oe===void 0&&(oe=new il,x[J]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(J){let oe=x[J];return oe===void 0&&(oe=new il,x[J]=oe),oe.getGripSpace()},this.getHand=function(J){let oe=x[J];return oe===void 0&&(oe=new il,x[J]=oe),oe.getHandSpace()};function O(J){const oe=v.indexOf(J.inputSource);if(oe===-1)return;const Ee=x[oe];Ee!==void 0&&(Ee.update(J.inputSource,J.frame,c||o),Ee.dispatchEvent({type:J.type,data:J.inputSource}))}function W(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",D);for(let J=0;J=0&&(v[De]=null,x[De].disconnect(Ee))}for(let oe=0;oe=v.length){v.push(Ee),De=qe;break}else if(v[qe]===null){v[qe]=Ee,De=qe;break}if(De===-1)break}const _e=x[De];_e&&_e.connect(Ee)}}const V=new C,Z=new C;function Q(J,oe,Ee){V.setFromMatrixPosition(oe.matrixWorld),Z.setFromMatrixPosition(Ee.matrixWorld);const De=V.distanceTo(Z),_e=oe.projectionMatrix.elements,qe=Ee.projectionMatrix.elements,We=_e[14]/(_e[10]-1),Fe=_e[14]/(_e[10]+1),Ye=(_e[9]+1)/_e[5],X=(_e[9]-1)/_e[5],Lt=(_e[8]-1)/_e[0],Ce=(qe[8]+1)/qe[0],$e=We*Lt,ze=We*Ce,_t=De/(-Lt+Ce),Ke=_t*-Lt;oe.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Ke),J.translateZ(_t),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert();const ke=We+_t,ot=Fe+_t,Tt=$e-Ke,Ct=ze+(De-Ke),P=Ye*Fe/ot*ke,S=X*Fe/ot*ke;J.projectionMatrix.makePerspective(Tt,Ct,P,S,ke,ot),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}function ce(J,oe){oe===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(oe.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(i===null)return;E.near=T.near=M.near=J.near,E.far=T.far=M.far=J.far,(A!==E.near||z!==E.far)&&(i.updateRenderState({depthNear:E.near,depthFar:E.far}),A=E.near,z=E.far);const oe=J.parent,Ee=E.cameras;ce(E,oe);for(let De=0;De0&&(m.alphaTest.value=d.alphaTest);const x=e.get(d).envMap;if(x&&(m.envMap.value=x,m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=d.reflectivity,m.ior.value=d.ior,m.refractionRatio.value=d.refractionRatio),d.lightMap){m.lightMap.value=d.lightMap;const v=r._useLegacyLights===!0?Math.PI:1;m.lightMapIntensity.value=d.lightMapIntensity*v,t(d.lightMap,m.lightMapTransform)}d.aoMap&&(m.aoMap.value=d.aoMap,m.aoMapIntensity.value=d.aoMapIntensity,t(d.aoMap,m.aoMapTransform))}function o(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,d.map&&(m.map.value=d.map,t(d.map,m.mapTransform))}function a(m,d){m.dashSize.value=d.dashSize,m.totalSize.value=d.dashSize+d.gapSize,m.scale.value=d.scale}function l(m,d,x,v){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.size.value=d.size*x,m.scale.value=v*.5,d.map&&(m.map.value=d.map,t(d.map,m.uvTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function c(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.rotation.value=d.rotation,d.map&&(m.map.value=d.map,t(d.map,m.mapTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function u(m,d){m.specular.value.copy(d.specular),m.shininess.value=Math.max(d.shininess,1e-4)}function f(m,d){d.gradientMap&&(m.gradientMap.value=d.gradientMap)}function h(m,d){m.metalness.value=d.metalness,d.metalnessMap&&(m.metalnessMap.value=d.metalnessMap,t(d.metalnessMap,m.metalnessMapTransform)),m.roughness.value=d.roughness,d.roughnessMap&&(m.roughnessMap.value=d.roughnessMap,t(d.roughnessMap,m.roughnessMapTransform)),e.get(d).envMap&&(m.envMapIntensity.value=d.envMapIntensity)}function p(m,d,x){m.ior.value=d.ior,d.sheen>0&&(m.sheenColor.value.copy(d.sheenColor).multiplyScalar(d.sheen),m.sheenRoughness.value=d.sheenRoughness,d.sheenColorMap&&(m.sheenColorMap.value=d.sheenColorMap,t(d.sheenColorMap,m.sheenColorMapTransform)),d.sheenRoughnessMap&&(m.sheenRoughnessMap.value=d.sheenRoughnessMap,t(d.sheenRoughnessMap,m.sheenRoughnessMapTransform))),d.clearcoat>0&&(m.clearcoat.value=d.clearcoat,m.clearcoatRoughness.value=d.clearcoatRoughness,d.clearcoatMap&&(m.clearcoatMap.value=d.clearcoatMap,t(d.clearcoatMap,m.clearcoatMapTransform)),d.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=d.clearcoatRoughnessMap,t(d.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),d.clearcoatNormalMap&&(m.clearcoatNormalMap.value=d.clearcoatNormalMap,t(d.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(d.clearcoatNormalScale),d.side===xn&&m.clearcoatNormalScale.value.negate())),d.iridescence>0&&(m.iridescence.value=d.iridescence,m.iridescenceIOR.value=d.iridescenceIOR,m.iridescenceThicknessMinimum.value=d.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=d.iridescenceThicknessRange[1],d.iridescenceMap&&(m.iridescenceMap.value=d.iridescenceMap,t(d.iridescenceMap,m.iridescenceMapTransform)),d.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=d.iridescenceThicknessMap,t(d.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),d.transmission>0&&(m.transmission.value=d.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),d.transmissionMap&&(m.transmissionMap.value=d.transmissionMap,t(d.transmissionMap,m.transmissionMapTransform)),m.thickness.value=d.thickness,d.thicknessMap&&(m.thicknessMap.value=d.thicknessMap,t(d.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=d.attenuationDistance,m.attenuationColor.value.copy(d.attenuationColor)),d.anisotropy>0&&(m.anisotropyVector.value.set(d.anisotropy*Math.cos(d.anisotropyRotation),d.anisotropy*Math.sin(d.anisotropyRotation)),d.anisotropyMap&&(m.anisotropyMap.value=d.anisotropyMap,t(d.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=d.specularIntensity,m.specularColor.value.copy(d.specularColor),d.specularColorMap&&(m.specularColorMap.value=d.specularColorMap,t(d.specularColorMap,m.specularColorMapTransform)),d.specularIntensityMap&&(m.specularIntensityMap.value=d.specularIntensityMap,t(d.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,d){d.matcap&&(m.matcap.value=d.matcap)}function g(m,d){const x=e.get(d).light;m.referencePosition.value.setFromMatrixPosition(x.matrixWorld),m.nearDistance.value=x.shadow.camera.near,m.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function x0(r,e,t,n){let i={},s={},o=[];const a=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(x,v){const y=v.program;n.uniformBlockBinding(x,y)}function c(x,v){let y=i[x.id];y===void 0&&(_(x),y=u(x),i[x.id]=y,x.addEventListener("dispose",m));const b=v.program;n.updateUBOMapping(x,b);const M=e.render.frame;s[x.id]!==M&&(h(x),s[x.id]=M)}function u(x){const v=f();x.__bindingPointIndex=v;const y=r.createBuffer(),b=x.__size,M=x.usage;return r.bindBuffer(r.UNIFORM_BUFFER,y),r.bufferData(r.UNIFORM_BUFFER,b,M),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,v,y),y}function f(){for(let x=0;x0){M=y%b;const O=b-M;M!==0&&O-A.boundary<0&&(y+=b-M,E.__offset=y)}y+=A.storage}return M=y%b,M>0&&(y+=b-M),x.__size=y,x.__cache={},this}function g(x){const v={boundary:0,storage:0};return typeof x=="number"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function m(x){const v=x.target;v.removeEventListener("dispose",m);const y=o.indexOf(v.__bindingPointIndex);o.splice(y,1),r.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function d(){for(const x in i)r.deleteBuffer(i[x]);o=[],i={},s={}}return{bind:l,update:c,dispose:d}}class Pf{constructor(e={}){const{canvas:t=_p(),context:n=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let h;n!==null?h=n.getContextAttributes().alpha:h=o;const p=new Uint32Array(4),_=new Int32Array(4);let g=null,m=null;const d=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ht,this._useLegacyLights=!1,this.toneMapping=Yi,this.toneMappingExposure=1;const v=this;let y=!1,b=0,M=0,T=null,I=-1,E=null;const A=new mt,z=new mt;let O=null;const W=new tt(0);let D=0,V=t.width,Z=t.height,Q=1,ce=null,ie=null;const se=new mt(0,0,V,Z),me=new mt(0,0,V,Z);let ve=!1;const J=new nc;let oe=!1,Ee=!1,De=null;const _e=new Ve,qe=new Ue,We=new C,Fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ye(){return T===null?Q:1}let X=n;function Lt(R,H){for(let j=0;j{function Se(){if(K.forEach(function(Ie){Ke.get(Ie).currentProgram.isReady()&&K.delete(Ie)}),K.size===0){Y(R);return}setTimeout(Se,10)}Ce.get("KHR_parallel_shader_compile")!==null?Se():setTimeout(Se,10)})};let nt=null;function gt(R){nt&&nt(R)}function Vt(){ft.stop()}function ht(){ft.start()}const ft=new wf;ft.setAnimationLoop(gt),typeof self<"u"&&ft.setContext(self),this.setAnimationLoop=function(R){nt=R,be.setAnimationLoop(R),R===null?ft.stop():ft.start()},be.addEventListener("sessionstart",Vt),be.addEventListener("sessionend",ht),this.render=function(R,H){if(H!==void 0&&H.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(y===!0)return;R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),H.parent===null&&H.matrixWorldAutoUpdate===!0&&H.updateMatrixWorld(),be.enabled===!0&&be.isPresenting===!0&&(be.cameraAutoUpdate===!0&&be.updateCamera(H),H=be.getCamera()),R.isScene===!0&&R.onBeforeRender(v,R,H,T),m=fe.get(R,x.length),m.init(),x.push(m),_e.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),J.setFromProjectionMatrix(_e),Ee=this.localClippingEnabled,oe=Me.init(this.clippingPlanes,Ee),g=re.get(R,d.length),g.init(),d.push(g),En(R,H,0,v.sortObjects),g.finish(),v.sortObjects===!0&&g.sort(ce,ie),this.info.render.frame++,oe===!0&&Me.beginShadows();const j=m.state.shadowsArray;if(pe.render(j,R,H),oe===!0&&Me.endShadows(),this.info.autoReset===!0&&this.info.reset(),ye.render(g,R),m.setupLights(v._useLegacyLights),H.isArrayCamera){const K=H.cameras;for(let Y=0,Se=K.length;Y0?m=x[x.length-1]:m=null,d.pop(),d.length>0?g=d[d.length-1]:g=null};function En(R,H,j,K){if(R.visible===!1)return;if(R.layers.test(H.layers)){if(R.isGroup)j=R.renderOrder;else if(R.isLOD)R.autoUpdate===!0&&R.update(H);else if(R.isLight)m.pushLight(R),R.castShadow&&m.pushShadow(R);else if(R.isSprite){if(!R.frustumCulled||J.intersectsSprite(R)){K&&We.setFromMatrixPosition(R.matrixWorld).applyMatrix4(_e);const Ie=S.update(R),He=R.material;He.visible&&g.push(R,Ie,He,j,We.z,null)}}else if((R.isMesh||R.isLine||R.isPoints)&&(!R.frustumCulled||J.intersectsObject(R))){const Ie=S.update(R),He=R.material;if(K&&(R.boundingSphere!==void 0?(R.boundingSphere===null&&R.computeBoundingSphere(),We.copy(R.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),We.copy(Ie.boundingSphere.center)),We.applyMatrix4(R.matrixWorld).applyMatrix4(_e)),Array.isArray(He)){const Xe=Ie.groups;for(let et=0,je=Xe.length;et0&&ln(Y,Se,H,j),K&&ze.viewport(A.copy(K)),Y.length>0&&Ii(Y,H,j),Se.length>0&&Ii(Se,H,j),Ie.length>0&&Ii(Ie,H,j),ze.buffers.depth.setTest(!0),ze.buffers.depth.setMask(!0),ze.buffers.color.setMask(!0),ze.setPolygonOffset(!1)}function ln(R,H,j,K){if((j.isScene===!0?j.overrideMaterial:null)!==null)return;const Se=$e.isWebGL2;De===null&&(De=new Ki(1,1,{generateMipmaps:!0,type:Ce.has("EXT_color_buffer_half_float")?Qs:fi,minFilter:gr,samples:Se?4:0})),v.getDrawingBufferSize(qe),Se?De.setSize(qe.x,qe.y):De.setSize(da(qe.x),da(qe.y));const Ie=v.getRenderTarget();v.setRenderTarget(De),v.getClearColor(W),D=v.getClearAlpha(),D<1&&v.setClearColor(16777215,.5),v.clear();const He=v.toneMapping;v.toneMapping=Yi,Ii(R,j,K),ke.updateMultisampleRenderTarget(De),ke.updateRenderTargetMipmap(De);let Xe=!1;for(let et=0,je=H.length;et0),Ze=!!j.morphAttributes.position,xt=!!j.morphAttributes.normal,Gt=!!j.morphAttributes.color;let zt=Yi;K.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(zt=v.toneMapping);const cn=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,at=cn!==void 0?cn.length:0,Qe=Ke.get(K),Ji=m.state.lights;if(oe===!0&&(Ee===!0||R!==E)){const te=R===E&&K.id===I;Me.setState(K,R,te)}let yt=!1;K.version===Qe.__version?(Qe.needsLights&&Qe.lightsStateVersion!==Ji.state.version||Qe.outputColorSpace!==He||Y.isBatchedMesh&&Qe.batching===!1||!Y.isBatchedMesh&&Qe.batching===!0||Y.isInstancedMesh&&Qe.instancing===!1||!Y.isInstancedMesh&&Qe.instancing===!0||Y.isSkinnedMesh&&Qe.skinning===!1||!Y.isSkinnedMesh&&Qe.skinning===!0||Y.isInstancedMesh&&Qe.instancingColor===!0&&Y.instanceColor===null||Y.isInstancedMesh&&Qe.instancingColor===!1&&Y.instanceColor!==null||Qe.envMap!==Xe||K.fog===!0&&Qe.fog!==Se||Qe.numClippingPlanes!==void 0&&(Qe.numClippingPlanes!==Me.numPlanes||Qe.numIntersection!==Me.numIntersection)||Qe.vertexAlphas!==et||Qe.vertexTangents!==je||Qe.morphTargets!==Ze||Qe.morphNormals!==xt||Qe.morphColors!==Gt||Qe.toneMapping!==zt||$e.isWebGL2===!0&&Qe.morphTargetsCount!==at)&&(yt=!0):(yt=!0,Qe.__version=K.version);let Fn=Qe.currentProgram;yt===!0&&(Fn=ri(K,H,Y));let Sr=!1,Qt=!1,nn=!1;const Wt=Fn.getUniforms(),w=Qe.uniforms;if(ze.useProgram(Fn.program)&&(Sr=!0,Qt=!0,nn=!0),K.id!==I&&(I=K.id,Qt=!0),Sr||E!==R){Wt.setValue(X,"projectionMatrix",R.projectionMatrix),Wt.setValue(X,"viewMatrix",R.matrixWorldInverse);const te=Wt.map.cameraPosition;te!==void 0&&te.setValue(X,We.setFromMatrixPosition(R.matrixWorld)),$e.logarithmicDepthBuffer&&Wt.setValue(X,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2)),(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial)&&Wt.setValue(X,"isOrthographic",R.isOrthographicCamera===!0),E!==R&&(E=R,Qt=!0,nn=!0)}if(Y.isSkinnedMesh){Wt.setOptional(X,Y,"bindMatrix"),Wt.setOptional(X,Y,"bindMatrixInverse");const te=Y.skeleton;te&&($e.floatVertexTextures?(te.boneTexture===null&&te.computeBoneTexture(),Wt.setValue(X,"boneTexture",te.boneTexture,ke)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Y.isBatchedMesh&&(Wt.setOptional(X,Y,"batchingTexture"),Wt.setValue(X,"batchingTexture",Y._matricesTexture,ke));const B=j.morphAttributes;if((B.position!==void 0||B.normal!==void 0||B.color!==void 0&&$e.isWebGL2===!0)&&N.update(Y,j,Fn),(Qt||Qe.receiveShadow!==Y.receiveShadow)&&(Qe.receiveShadow=Y.receiveShadow,Wt.setValue(X,"receiveShadow",Y.receiveShadow)),K.isMeshGouraudMaterial&&K.envMap!==null&&(w.envMap.value=Xe,w.flipEnvMap.value=Xe.isCubeTexture&&Xe.isRenderTargetTexture===!1?-1:1),Qt&&(Wt.setValue(X,"toneMappingExposure",v.toneMappingExposure),Qe.needsLights&&Ni(w,nn),Se&&K.fog===!0&&le.refreshFogUniforms(w,Se),le.refreshMaterialUniforms(w,K,Q,Z,De),oa.upload(X,br(Qe),w,ke)),K.isShaderMaterial&&K.uniformsNeedUpdate===!0&&(oa.upload(X,br(Qe),w,ke),K.uniformsNeedUpdate=!1),K.isSpriteMaterial&&Wt.setValue(X,"center",Y.center),Wt.setValue(X,"modelViewMatrix",Y.modelViewMatrix),Wt.setValue(X,"normalMatrix",Y.normalMatrix),Wt.setValue(X,"modelMatrix",Y.matrixWorld),K.isShaderMaterial||K.isRawShaderMaterial){const te=K.uniformsGroups;for(let G=0,ue=te.length;G0&&ke.useMultisampledRTT(R)===!1?Y=Ke.get(R).__webglMultisampledFramebuffer:Array.isArray(je)?Y=je[j]:Y=je,A.copy(R.viewport),z.copy(R.scissor),O=R.scissorTest}else A.copy(se).multiplyScalar(Q).floor(),z.copy(me).multiplyScalar(Q).floor(),O=ve;if(ze.bindFramebuffer(X.FRAMEBUFFER,Y)&&$e.drawBuffers&&K&&ze.drawBuffers(R,Y),ze.viewport(A),ze.scissor(z),ze.setScissorTest(O),Se){const Xe=Ke.get(R.texture);X.framebufferTexture2D(X.FRAMEBUFFER,X.COLOR_ATTACHMENT0,X.TEXTURE_CUBE_MAP_POSITIVE_X+H,Xe.__webglTexture,j)}else if(Ie){const Xe=Ke.get(R.texture),et=H||0;X.framebufferTextureLayer(X.FRAMEBUFFER,X.COLOR_ATTACHMENT0,Xe.__webglTexture,j||0,et)}I=-1},this.readRenderTargetPixels=function(R,H,j,K,Y,Se,Ie){if(!(R&&R.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let He=Ke.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He){ze.bindFramebuffer(X.FRAMEBUFFER,He);try{const Xe=R.texture,et=Xe.format,je=Xe.type;if(et!==sn&&Oe.convert(et)!==X.getParameter(X.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ze=je===Qs&&(Ce.has("EXT_color_buffer_half_float")||$e.isWebGL2&&Ce.has("EXT_color_buffer_float"));if(je!==fi&&Oe.convert(je)!==X.getParameter(X.IMPLEMENTATION_COLOR_READ_TYPE)&&!(je===vn&&($e.isWebGL2||Ce.has("OES_texture_float")||Ce.has("WEBGL_color_buffer_float")))&&!Ze){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H>=0&&H<=R.width-K&&j>=0&&j<=R.height-Y&&X.readPixels(H,j,K,Y,Oe.convert(et),Oe.convert(je),Se)}finally{const Xe=T!==null?Ke.get(T).__webglFramebuffer:null;ze.bindFramebuffer(X.FRAMEBUFFER,Xe)}}},this.copyFramebufferToTexture=function(R,H,j=0){const K=Math.pow(2,-j),Y=Math.floor(H.image.width*K),Se=Math.floor(H.image.height*K);ke.setTexture2D(H,0),X.copyTexSubImage2D(X.TEXTURE_2D,j,0,0,R.x,R.y,Y,Se),ze.unbindTexture()},this.copyTextureToTexture=function(R,H,j,K=0){const Y=H.image.width,Se=H.image.height,Ie=Oe.convert(j.format),He=Oe.convert(j.type);ke.setTexture2D(j,0),X.pixelStorei(X.UNPACK_FLIP_Y_WEBGL,j.flipY),X.pixelStorei(X.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),X.pixelStorei(X.UNPACK_ALIGNMENT,j.unpackAlignment),H.isDataTexture?X.texSubImage2D(X.TEXTURE_2D,K,R.x,R.y,Y,Se,Ie,He,H.image.data):H.isCompressedTexture?X.compressedTexSubImage2D(X.TEXTURE_2D,K,R.x,R.y,H.mipmaps[0].width,H.mipmaps[0].height,Ie,H.mipmaps[0].data):X.texSubImage2D(X.TEXTURE_2D,K,R.x,R.y,Ie,He,H.image),K===0&&j.generateMipmaps&&X.generateMipmap(X.TEXTURE_2D),ze.unbindTexture()},this.copyTextureToTexture3D=function(R,H,j,K,Y=0){if(v.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Se=R.max.x-R.min.x+1,Ie=R.max.y-R.min.y+1,He=R.max.z-R.min.z+1,Xe=Oe.convert(K.format),et=Oe.convert(K.type);let je;if(K.isData3DTexture)ke.setTexture3D(K,0),je=X.TEXTURE_3D;else if(K.isDataArrayTexture)ke.setTexture2DArray(K,0),je=X.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}X.pixelStorei(X.UNPACK_FLIP_Y_WEBGL,K.flipY),X.pixelStorei(X.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),X.pixelStorei(X.UNPACK_ALIGNMENT,K.unpackAlignment);const Ze=X.getParameter(X.UNPACK_ROW_LENGTH),xt=X.getParameter(X.UNPACK_IMAGE_HEIGHT),Gt=X.getParameter(X.UNPACK_SKIP_PIXELS),zt=X.getParameter(X.UNPACK_SKIP_ROWS),cn=X.getParameter(X.UNPACK_SKIP_IMAGES),at=j.isCompressedTexture?j.mipmaps[0]:j.image;X.pixelStorei(X.UNPACK_ROW_LENGTH,at.width),X.pixelStorei(X.UNPACK_IMAGE_HEIGHT,at.height),X.pixelStorei(X.UNPACK_SKIP_PIXELS,R.min.x),X.pixelStorei(X.UNPACK_SKIP_ROWS,R.min.y),X.pixelStorei(X.UNPACK_SKIP_IMAGES,R.min.z),j.isDataTexture||j.isData3DTexture?X.texSubImage3D(je,Y,H.x,H.y,H.z,Se,Ie,He,Xe,et,at.data):j.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),X.compressedTexSubImage3D(je,Y,H.x,H.y,H.z,Se,Ie,He,Xe,at.data)):X.texSubImage3D(je,Y,H.x,H.y,H.z,Se,Ie,He,Xe,et,at),X.pixelStorei(X.UNPACK_ROW_LENGTH,Ze),X.pixelStorei(X.UNPACK_IMAGE_HEIGHT,xt),X.pixelStorei(X.UNPACK_SKIP_PIXELS,Gt),X.pixelStorei(X.UNPACK_SKIP_ROWS,zt),X.pixelStorei(X.UNPACK_SKIP_IMAGES,cn),Y===0&&K.generateMipmaps&&X.generateMipmap(je),ze.unbindTexture()},this.initTexture=function(R){R.isCubeTexture?ke.setTextureCube(R,0):R.isData3DTexture?ke.setTexture3D(R,0):R.isDataArrayTexture||R.isCompressedArrayTexture?ke.setTexture2DArray(R,0):ke.setTexture2D(R,0),ze.unbindTexture()},this.resetState=function(){b=0,M=0,T=null,ze.reset(),Re.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ai}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===ec?"display-p3":"srgb",t.unpackColorSpace=pt.workingColorSpace===ya?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Ht?$i:cf}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===$i?Ht:an}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class y0 extends Pf{}y0.prototype.isWebGL1Renderer=!0;class b0 extends Bt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,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()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class E0{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Il,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Qn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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;il)continue;h.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(h);Ie.far||t.push({distance:I,point:f.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{const d=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let v=d,y=x-1;vl)continue;h.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(h);Me.far||t.push({distance:M,point:f.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;si.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class lc extends di{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new tt(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 tt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=uf,this.normalScale=new Ue(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}}class Di extends lc{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ue(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return tn(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 tt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new tt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new tt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=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 sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=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.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,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}}function Uo(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function P0(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function D0(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function lh(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){const a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i}function Ff(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)}class lo{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){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let o;t:{i:if(!(e=s)){const a=t[1];e=s)break e}o=n,n=0;break t}break n}for(;n>>1;et;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const 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++){const 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&&P0(i))for(let a=0,l=i.length;a!==l;++a){const 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(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Na,s=e.length-1;let o=1;for(let a=1;a0){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=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}_i.prototype.TimeBufferType=Float32Array;_i.prototype.ValueBufferType=Float32Array;_i.prototype.DefaultInterpolation=fs;class xs extends _i{}xs.prototype.ValueTypeName="bool";xs.prototype.ValueBufferType=Array;xs.prototype.DefaultInterpolation=eo;xs.prototype.InterpolantFactoryMethodLinear=void 0;xs.prototype.InterpolantFactoryMethodSmooth=void 0;class Of extends _i{}Of.prototype.ValueTypeName="color";class ms extends _i{}ms.prototype.ValueTypeName="number";class O0 extends lo{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t);let c=e*a;for(let u=c+a;c!==u;c+=4)mi.slerpFlat(s,0,o,c-a,o,c,l);return s}}class vr extends _i{InterpolantFactoryMethodLinear(e){return new O0(this.times,this.values,this.getValueSize(),e)}}vr.prototype.ValueTypeName="quaternion";vr.prototype.DefaultInterpolation=fs;vr.prototype.InterpolantFactoryMethodSmooth=void 0;class ys extends _i{}ys.prototype.ValueTypeName="string";ys.prototype.ValueBufferType=Array;ys.prototype.DefaultInterpolation=eo;ys.prototype.InterpolantFactoryMethodLinear=void 0;ys.prototype.InterpolantFactoryMethodSmooth=void 0;class _s extends _i{}_s.prototype.ValueTypeName="vector";class U0{constructor(e,t=-1,n,i=Wd){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Qn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(z0(n[o]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(_i.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,o=[];for(let a=0;a1){const f=u[1];let h=i[f];h||(i[f]=h=[]),h.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(f,h,p,_,g){if(p.length!==0){const m=[],d=[];Ff(p,m,d,_),m.length!==0&&g.push(new f(h,m,d))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let f=0;f{t&&t(s),this.manager.itemEnd(e)},0),s;if(wi[e]!==void 0){wi[e].push({onLoad:t,onProgress:n,onError:i});return}wi[e]=[],wi[e].push({onLoad:t,onProgress:n,onError:i});const 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;const u=wi[e],f=c.body.getReader(),h=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),p=h?parseInt(h):0,_=p!==0;let g=0;const m=new ReadableStream({start(d){x();function x(){f.read().then(({done:v,value:y})=>{if(v)d.close();else{g+=y.byteLength;const b=new ProgressEvent("progress",{lengthComputable:_,loaded:g,total:p});for(let M=0,T=u.length;M{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const f=/charset="?([^;"\s]*)"?/i.exec(a),h=f&&f[1]?f[1].toLowerCase():void 0,p=new TextDecoder(h);return c.arrayBuffer().then(_=>p.decode(_))}}}).then(c=>{gs.add(e,c);const u=wi[e];delete wi[e];for(let f=0,h=u.length;f{const u=wi[e];if(u===void 0)throw this.manager.itemError(e),c;delete wi[e];for(let f=0,h=u.length;f{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class G0 extends bs{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=gs.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=to("img");function l(){u(),gs.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(f){u(),i&&i(f),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class W0 extends bs{constructor(e){super(e)}load(e,t,n,i){const s=new on,o=new G0(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class Sa extends Bt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new tt(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){const 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}}const al=new Ve,ch=new C,uh=new C;class cc{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ue(512,512),this.map=null,this.mapPass=null,this.matrix=new Ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new nc,this._frameExtents=new Ue(1,1),this._viewportCount=1,this._viewports=[new mt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;ch.setFromMatrixPosition(e.matrixWorld),t.position.copy(ch),uh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(uh),t.updateMatrixWorld(),al.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(al),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(al)}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(){const 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}}class X0 extends cc{constructor(){super(new _n(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=ds*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}}class q0 extends Sa{constructor(e,t,n=0,i=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Bt.DEFAULT_UP),this.updateMatrix(),this.target=new Bt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new X0}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}}const hh=new Ve,Ds=new C,ll=new C;class j0 extends cc{constructor(){super(new _n(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ue(4,2),this._viewportCount=6,this._viewports=[new mt(2,1,1,1),new mt(0,1,1,1),new mt(3,1,1,1),new mt(1,1,1,1),new mt(3,0,1,1),new mt(1,0,1,1)],this._cubeDirections=[new C(1,0,0),new C(-1,0,0),new C(0,0,1),new C(0,0,-1),new C(0,1,0),new C(0,-1,0)],this._cubeUps=[new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,0,1),new C(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Ds.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ds),ll.copy(n.position),ll.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(ll),n.updateMatrixWorld(),i.makeTranslation(-Ds.x,-Ds.y,-Ds.z),hh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hh)}}class Y0 extends Sa{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new j0}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}}class $0 extends cc{constructor(){super(new ao(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Bf extends Sa{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Bt.DEFAULT_UP),this.updateMatrix(),this.target=new Bt,this.shadow=new $0}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class K0 extends Sa{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ys{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=gs.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){gs.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}const uc="\\[\\]\\.:\\/",Q0=new RegExp("["+uc+"]","g"),hc="[^"+uc+"]",J0="[^"+uc.replace("\\.","")+"]",ex=/((?:WC+[\/:])*)/.source.replace("WC",hc),tx=/(WCOD+)?/.source.replace("WCOD",J0),nx=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",hc),ix=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",hc),rx=new RegExp("^"+ex+tx+nx+ix+"$"),sx=["material","materials","bones","map"];class ox{constructor(e,t,n){const i=n||vt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class vt{constructor(e,t,n){this.path=t,this.parsedPath=n||vt.parseTrackName(t),this.node=vt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new vt.Composite(e,t,n):new vt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Q0,"")}static parseTrackName(e){const t=rx.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const 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){const s=n.nodeName.substring(i+1);sx.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){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let o=0;oMath.PI&&(ge-=we),ae<-Math.PI?ae+=we:ae>Math.PI&&(ae-=we),ge<=ae?a.theta=Math.max(ge,Math.min(ae,a.theta)):a.theta=a.theta>(ge+ae)/2?Math.max(ge,a.theta):Math.min(ae,a.theta)),a.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,a.phi)),a.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(u,n.dampingFactor):n.target.add(u),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&M||n.object.isOrthographicCamera?a.radius=ie(a.radius):a.radius=ie(a.radius*c),N.setFromSpherical(a),N.applyQuaternion(ne),F.copy(n.target).add(N),n.object.lookAt(n.target),n.enableDamping===!0?(l.theta*=1-n.dampingFactor,l.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(l.set(0,0,0),u.set(0,0,0));let ee=!1;if(n.zoomToCursor&&M){let he=null;if(n.object.isPerspectiveCamera){const Le=N.length();he=ie(Le*c);const nt=Le-he;n.object.position.addScaledVector(y,nt),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const Le=new C(b.x,b.y,0);Le.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/c)),n.object.updateProjectionMatrix(),ee=!0;const nt=new C(b.x,b.y,0);nt.unproject(n.object),n.object.position.sub(nt).add(Le),n.object.updateMatrixWorld(),he=N.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;he!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(he).add(n.object.position):(zo.origin.copy(n.object.position),zo.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(zo.direction))o||8*(1-Re.dot(n.object.quaternion))>o||Pe.distanceToSquared(n.target)>0?(n.dispatchEvent(ph),Oe.copy(n.object.position),Re.copy(n.object.quaternion),Pe.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",re),n.domElement.removeEventListener("pointerdown",Ke),n.domElement.removeEventListener("pointercancel",ot),n.domElement.removeEventListener("wheel",P),n.domElement.removeEventListener("pointermove",ke),n.domElement.removeEventListener("pointerup",ot),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener("keydown",S),n._domElementKeyEvents=null)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const o=1e-6,a=new fh,l=new fh;let c=1;const u=new C,f=new Ue,h=new Ue,p=new Ue,_=new Ue,g=new Ue,m=new Ue,d=new Ue,x=new Ue,v=new Ue,y=new C,b=new Ue;let M=!1;const T=[],I={};function E(N){return N!==null?2*Math.PI/60*n.autoRotateSpeed*N:2*Math.PI/60/60*n.autoRotateSpeed}function A(){return Math.pow(.95,n.zoomSpeed)}function z(N){l.theta-=N}function O(N){l.phi-=N}const W=function(){const N=new C;return function(ne,Oe){N.setFromMatrixColumn(Oe,0),N.multiplyScalar(-ne),u.add(N)}}(),D=function(){const N=new C;return function(ne,Oe){n.screenSpacePanning===!0?N.setFromMatrixColumn(Oe,1):(N.setFromMatrixColumn(Oe,0),N.crossVectors(n.object.up,N)),N.multiplyScalar(ne),u.add(N)}}(),V=function(){const N=new C;return function(ne,Oe){const Re=n.domElement;if(n.object.isPerspectiveCamera){const Pe=n.object.position;N.copy(Pe).sub(n.target);let we=N.length();we*=Math.tan(n.object.fov/2*Math.PI/180),W(2*ne*we/Re.clientHeight,n.object.matrix),D(2*Oe*we/Re.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(W(ne*(n.object.right-n.object.left)/n.object.zoom/Re.clientWidth,n.object.matrix),D(Oe*(n.object.top-n.object.bottom)/n.object.zoom/Re.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function Z(N){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c/=N:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function Q(N){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c*=N:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ce(N){if(!n.zoomToCursor)return;M=!0;const de=n.domElement.getBoundingClientRect(),ne=N.clientX-de.left,Oe=N.clientY-de.top,Re=de.width,Pe=de.height;b.x=ne/Re*2-1,b.y=-(Oe/Pe)*2+1,y.set(b.x,b.y,1).unproject(n.object).sub(n.object.position).normalize()}function ie(N){return Math.max(n.minDistance,Math.min(n.maxDistance,N))}function se(N){f.set(N.clientX,N.clientY)}function me(N){ce(N),d.set(N.clientX,N.clientY)}function ve(N){_.set(N.clientX,N.clientY)}function J(N){h.set(N.clientX,N.clientY),p.subVectors(h,f).multiplyScalar(n.rotateSpeed);const de=n.domElement;z(2*Math.PI*p.x/de.clientHeight),O(2*Math.PI*p.y/de.clientHeight),f.copy(h),n.update()}function oe(N){x.set(N.clientX,N.clientY),v.subVectors(x,d),v.y>0?Z(A()):v.y<0&&Q(A()),d.copy(x),n.update()}function Ee(N){g.set(N.clientX,N.clientY),m.subVectors(g,_).multiplyScalar(n.panSpeed),V(m.x,m.y),_.copy(g),n.update()}function De(N){ce(N),N.deltaY<0?Q(A()):N.deltaY>0&&Z(A()),n.update()}function _e(N){let de=!1;switch(N.code){case n.keys.UP:N.ctrlKey||N.metaKey||N.shiftKey?O(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(0,n.keyPanSpeed),de=!0;break;case n.keys.BOTTOM:N.ctrlKey||N.metaKey||N.shiftKey?O(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(0,-n.keyPanSpeed),de=!0;break;case n.keys.LEFT:N.ctrlKey||N.metaKey||N.shiftKey?z(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(n.keyPanSpeed,0),de=!0;break;case n.keys.RIGHT:N.ctrlKey||N.metaKey||N.shiftKey?z(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(-n.keyPanSpeed,0),de=!0;break}de&&(N.preventDefault(),n.update())}function qe(){if(T.length===1)f.set(T[0].pageX,T[0].pageY);else{const N=.5*(T[0].pageX+T[1].pageX),de=.5*(T[0].pageY+T[1].pageY);f.set(N,de)}}function We(){if(T.length===1)_.set(T[0].pageX,T[0].pageY);else{const N=.5*(T[0].pageX+T[1].pageX),de=.5*(T[0].pageY+T[1].pageY);_.set(N,de)}}function Fe(){const N=T[0].pageX-T[1].pageX,de=T[0].pageY-T[1].pageY,ne=Math.sqrt(N*N+de*de);d.set(0,ne)}function Ye(){n.enableZoom&&Fe(),n.enablePan&&We()}function X(){n.enableZoom&&Fe(),n.enableRotate&&qe()}function Lt(N){if(T.length==1)h.set(N.pageX,N.pageY);else{const ne=ye(N),Oe=.5*(N.pageX+ne.x),Re=.5*(N.pageY+ne.y);h.set(Oe,Re)}p.subVectors(h,f).multiplyScalar(n.rotateSpeed);const de=n.domElement;z(2*Math.PI*p.x/de.clientHeight),O(2*Math.PI*p.y/de.clientHeight),f.copy(h)}function Ce(N){if(T.length===1)g.set(N.pageX,N.pageY);else{const de=ye(N),ne=.5*(N.pageX+de.x),Oe=.5*(N.pageY+de.y);g.set(ne,Oe)}m.subVectors(g,_).multiplyScalar(n.panSpeed),V(m.x,m.y),_.copy(g)}function $e(N){const de=ye(N),ne=N.pageX-de.x,Oe=N.pageY-de.y,Re=Math.sqrt(ne*ne+Oe*Oe);x.set(0,Re),v.set(0,Math.pow(x.y/d.y,n.zoomSpeed)),Z(v.y),d.copy(x)}function ze(N){n.enableZoom&&$e(N),n.enablePan&&Ce(N)}function _t(N){n.enableZoom&&$e(N),n.enableRotate&&Lt(N)}function Ke(N){n.enabled!==!1&&(T.length===0&&(n.domElement.setPointerCapture(N.pointerId),n.domElement.addEventListener("pointermove",ke),n.domElement.addEventListener("pointerup",ot)),fe(N),N.pointerType==="touch"?q(N):Tt(N))}function ke(N){n.enabled!==!1&&(N.pointerType==="touch"?le(N):Ct(N))}function ot(N){Me(N),T.length===0&&(n.domElement.releasePointerCapture(N.pointerId),n.domElement.removeEventListener("pointermove",ke),n.domElement.removeEventListener("pointerup",ot)),n.dispatchEvent(mh),s=i.NONE}function Tt(N){let de;switch(N.button){case 0:de=n.mouseButtons.LEFT;break;case 1:de=n.mouseButtons.MIDDLE;break;case 2:de=n.mouseButtons.RIGHT;break;default:de=-1}switch(de){case Mr.DOLLY:if(n.enableZoom===!1)return;me(N),s=i.DOLLY;break;case Mr.ROTATE:if(N.ctrlKey||N.metaKey||N.shiftKey){if(n.enablePan===!1)return;ve(N),s=i.PAN}else{if(n.enableRotate===!1)return;se(N),s=i.ROTATE}break;case Mr.PAN:if(N.ctrlKey||N.metaKey||N.shiftKey){if(n.enableRotate===!1)return;se(N),s=i.ROTATE}else{if(n.enablePan===!1)return;ve(N),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(cl)}function Ct(N){switch(s){case i.ROTATE:if(n.enableRotate===!1)return;J(N);break;case i.DOLLY:if(n.enableZoom===!1)return;oe(N);break;case i.PAN:if(n.enablePan===!1)return;Ee(N);break}}function P(N){n.enabled===!1||n.enableZoom===!1||s!==i.NONE||(N.preventDefault(),n.dispatchEvent(cl),De(N),n.dispatchEvent(mh))}function S(N){n.enabled===!1||n.enablePan===!1||_e(N)}function q(N){switch(pe(N),T.length){case 1:switch(n.touches.ONE){case Tr.ROTATE:if(n.enableRotate===!1)return;qe(),s=i.TOUCH_ROTATE;break;case Tr.PAN:if(n.enablePan===!1)return;We(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(n.touches.TWO){case Tr.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ye(),s=i.TOUCH_DOLLY_PAN;break;case Tr.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;X(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(cl)}function le(N){switch(pe(N),s){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;Lt(N),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;Ce(N),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ze(N),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;_t(N),n.update();break;default:s=i.NONE}}function re(N){n.enabled!==!1&&N.preventDefault()}function fe(N){T.push(N)}function Me(N){delete I[N.pointerId];for(let de=0;de=2.0 are supported."));return}const c=new Wx(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function dx(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const lt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class px{constructor(e){this.parser=e,this.name=lt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class Ax{constructor(e){this.parser=e,this.name=lt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Rx{constructor(e){this.parser=e,this.name=lt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Lx{constructor(e){this.name=lt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,u=i.count,f=i.byteStride,h=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,f,h,i.mode,i.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(u*f);return o.decodeGltfBuffer(new Uint8Array(p),u,f,h,i.mode,i.filter),p})})}else return null}}class Cx{constructor(e){this.name=lt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==kn.TRIANGLES&&c.mode!==kn.TRIANGLE_STRIP&&c.mode!==kn.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(l[c]=u,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const u=c.pop(),f=u.isGroup?u.children:[u],h=c[0].count,p=[];for(const _ of f){const g=new Ve,m=new C,d=new mi,x=new C(1,1,1),v=new A0(_.geometry,_.material,h);for(let y=0;y0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Gx=new Ve;class Wx{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new dx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,s=-1;typeof navigator<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||i&&s<98?this.textureLoader=new W0(this.options.manager):this.textureLoader=new Z0(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Uf(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return sr(s,a,i),Gi(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,u]of o.children.entries())s(u,a.children[c])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&m.setY(E,M[T*l+1]),l>=3&&m.setZ(E,M[T*l+2]),l>=4&&m.setW(E,M[T*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const h=(s.samplers||{})[o.sampler]||{};return u.magFilter=yh[h.magFilter]||Sn,u.minFilter=yh[h.minFilter]||gr,u.wrapS=bh[h.wrapS]||us,u.wrapT=bh[h.wrapT]||us,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(f){c=!0;const h=new Blob([f],{type:o.mimeType});return l=a.createObjectURL(h),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(f){return new Promise(function(h,p){let _=h;t.isImageBitmapLoader===!0&&(_=function(g){const m=new on(g);m.needsUpdate=!0,h(m)}),t.load(Ys.resolveURL(f,s.path),_,void 0,p)})}).then(function(f){return c===!0&&a.revokeObjectURL(l),f.userData.mimeType=o.mimeType||Vx(o.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),f});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[lt.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[lt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[lt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new Nf,di.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new If,di.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return lc}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[lt.KHR_MATERIALS_UNLIT]){const f=i[lt.KHR_MATERIALS_UNLIT];o=f.getMaterialType(),c.push(f.extendParams(a,s,t))}else{const f=s.pbrMetallicRoughness||{};if(a.color=new tt(1,1,1),a.opacity=1,Array.isArray(f.baseColorFactor)){const h=f.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],an),a.opacity=h[3]}f.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",f.baseColorTexture,Ht)),a.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,a.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",f.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",f.metallicRoughnessTexture))),o=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Zn);const u=s.alphaMode||hl.OPAQUE;if(u===hl.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===hl.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Ri&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Ue(1,1),s.normalTexture.scale!==void 0)){const f=s.normalTexture.scale;a.normalScale.set(f,f)}if(s.occlusionTexture!==void 0&&o!==Ri&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Ri){const f=s.emissiveFactor;a.emissive=new tt().setRGB(f[0],f[1],f[2],an)}return s.emissiveTexture!==void 0&&o!==Ri&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,Ht)),Promise.all(c).then(function(){const f=new o(a);return s.name&&(f.name=s.name),Gi(f,s),t.associations.set(f,{materials:e}),s.extensions&&sr(i,f,s),f})}createUniqueName(e){const t=vt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[lt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Eh(l,a,t)})}const o=[];for(let a=0,l=e.length;a0&&kx(d,s),d.name=t.createUniqueName(s.name||"mesh_"+e),Gi(d,s),m.extensions&&sr(i,d,m),t.assignFinalMaterial(d),f.push(d)}for(let p=0,_=f.length;p<_;p++)t.associations.set(f[p],{meshes:e,primitives:p});if(f.length===1)return s.extensions&&sr(i,f[0],s),f[0];const h=new dr;s.extensions&&sr(i,h,s),t.associations.set(h,{meshes:e});for(let p=0,_=f.length;p<_;p++)h.add(f[p]);return h})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new _n(ff.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new ao(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Gi(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i1?u=new dr:c.length===1?u=c[0]:u=new Bt,u!==c[0])for(let f=0,h=c.length;f{const f=new Map;for(const[h,p]of i.associations)(h instanceof di||h instanceof on)&&f.set(h,p);return u.traverse(h=>{const p=i.associations.get(h);p!=null&&f.set(h,p)}),f};return i.associations=c(s),s})}_createAnimationTracks(e,t,n,i,s){const o=[],a=e.name?e.name:e.uuid,l=[];ki[s.path]===ki.weights?e.traverse(function(h){h.morphTargetInfluences&&l.push(h.name?h.name:h.uuid)}):l.push(a);let c;switch(ki[s.path]){case ki.weights:c=ms;break;case ki.rotation:c=vr;break;case ki.position:case ki.scale:c=_s;break;default:switch(n.itemSize){case 1:c=ms;break;case 2:case 3:default:c=_s;break}break}const u=i.interpolation!==void 0?Ux[i.interpolation]:fs,f=this._getArrayFromAccessor(n);for(let h=0,p=l.length;hl+1e3&&(u.update(1e3*c/(p-l),100),l=p,c=0,h)){var _=performance.memory;h.update(_.usedJSHeapSize/1048576,_.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,s){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),u=80*c,f=48*c,h=3*c,p=2*c,_=3*c,g=15*c,m=74*c,d=30*c,x=document.createElement("canvas");x.width=u,x.height=f,x.style.cssText="width:80px;height:48px";var v=x.getContext("2d");return v.font="bold "+9*c+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=s,v.fillRect(0,0,u,f),v.fillStyle=i,v.fillText(n,h,p),v.fillRect(_,g,m,d),v.fillStyle=s,v.globalAlpha=.9,v.fillRect(_,g,m,d),{dom:x,update:function(y,b){o=Math.min(o,y),a=Math.max(a,y),v.fillStyle=s,v.globalAlpha=1,v.fillRect(0,0,u,g),v.fillStyle=i,v.fillText(l(y)+" "+n+" ("+l(o)+"-"+l(a)+")",h,p),v.drawImage(x,_+c,g,m-c,d,_,g,m-c,d),v.fillRect(_+m-c,g,c,d),v.fillStyle=s,v.globalAlpha=.9,v.fillRect(_+m-c,g,c,l((1-y/b)*d))}}},t})})(Hf);var jx=Hf.exports;const Yx=qx(jx),Vf=0,$x=1,Gf=2,Sh=2,dl=1.25,wh=1,_r=6*4+4+4,wa=65535,Kx=Math.pow(2,-24),pl=Symbol("SKIP_GENERATION");function Wf(r){return r.index?r.index.count:r.attributes.position.count}function Es(r){return Wf(r)/3}function Xf(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Zx(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Xf(t,n);r.setIndex(new Yt(i,1));for(let s=0;sa-l);for(let a=0;as.offset-o.offset),n=t[t.length-1];n.count=Math.min(e-n.offset,n.count);let i=0;return t.forEach(({count:s})=>i+=s),e!==i}function Ut(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Jx(r){r[0]=r[1]=r[2]=1/0,r[3]=r[4]=r[5]=-1/0}function Mh(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Th(r,e){e.set(r)}function Ah(r,e,t){let n,i;for(let s=0;s<3;s++){const o=s+3;n=r[s],i=e[s],t[s]=ni?n:i}}function ko(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;ot[n+3]&&(t[n+3]=a)}}function Ns(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function ml(r,e,t,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,f=1/0,h=1/0,p=1/0,_=-1/0,g=-1/0,m=-1/0;const d=i!==null;for(let x=e*6,v=(e+t)*6;xl&&(l=T),d&&y_&&(_=y);const I=r[x+2],E=r[x+3],A=I-E,z=I+E;Ac&&(c=z),d&&Ig&&(g=I);const O=r[x+4],W=r[x+5],D=O-W,V=O+W;Du&&(u=V),d&&Om&&(m=O)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=c,n[5]=u,d&&(i[0]=f,i[1]=h,i[2]=p,i[3]=_,i[4]=g,i[5]=m)}function ey(r,e,t,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=e*6,f=(e+t)*6;ua&&(a=h);const p=r[u+2];pl&&(l=p);const _=r[u+4];_c&&(c=_)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=c}function ty(r,e){Jx(e);const t=r.attributes.position,n=r.index?r.index.array:null,i=Es(r),s=new Float32Array(i*6),o=t.normalized,a=t.array,l=t.offset||0;let c=3;t.isInterleavedBufferAttribute&&(c=t.data.stride);const u=["getX","getY","getZ"];for(let f=0;fM&&(M=v),y>M&&(M=y);const T=(M-b)/2,I=d*2;s[p+I+0]=b+T,s[p+I+1]=T+(Math.abs(b)+T)*Kx,be[d+3]&&(e[d+3]=M)}}return s}const Ti=32,ny=(r,e)=>r.candidate-e.candidate,Hi=new Array(Ti).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ho=new Float32Array(6);function iy(r,e,t,n,i,s){let o=-1,a=0;if(s===Vf)o=Mh(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===$x)o=Mh(r),o!==-1&&(a=ry(t,n,i,o));else if(s===Gf){const l=Ns(r);let c=dl*i;const u=n*6,f=(n+i)*6;for(let h=0;h<3;h++){const p=e[h],m=(e[h+3]-p)/Ti;if(i=T.candidate?ko(y,t,T.rightCacheBounds):(ko(y,t,T.leftCacheBounds),T.count++)}}for(let y=0;y=Ti&&(M=Ti-1);const T=Hi[M];T.count++,ko(v,t,T.bounds)}const d=Hi[Ti-1];Th(d.bounds,d.rightCacheBounds);for(let v=Ti-2;v>=0;v--){const y=Hi[v],b=Hi[v+1];Ah(y.bounds,b.rightCacheBounds,y.rightCacheBounds)}let x=0;for(let v=0;v=l;)a--;if(o=l;)a--;if(o2**16,i=n?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),o=n?new Uint32Array(s):new Uint16Array(s);for(let a=0,l=o.length;a=i&&(f=!0,s&&(console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`),console.warn(t))),M<=o||I>=i)return x(b+M),y.offset=b,y.count=M,y;const E=iy(y.boundingData,T,_,b,M,a);if(E.axis===-1)return x(b+M),y.offset=b,y.count=M,y;const A=g(u,n,_,b,M,E);if(A===b||A===b+M)x(b+M),y.offset=b,y.count=M;else{y.splitAxis=E.axis;const z=new Vo,O=b,W=A-b;y.left=z,z.boundingData=new Float32Array(6),ml(_,O,W,z.boundingData,p),v(z,O,W,p,I+1);const D=new Vo,V=A,Z=M-W;y.right=D,D.boundingData=new Float32Array(6),ml(_,V,Z,D.boundingData,p),v(D,V,Z,p,I+1)}return y}}function cy(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=ay(t,e.useSharedArrayBuffer),Qx(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||Zx(t,e);const n=ly(r,e);let i,s,o;const a=[],l=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let f=0;fMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[p+6]=y/4,y=u(y,x),s[p+7]=v,y}}}class Pi{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;si?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;si?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}Pi.prototype.setFromBox=function(){const r=new C;return function(t,n){const i=n.min,s=n.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){r.x=i.x*l+s.x*(1-l),r.y=i.y*c+s.y*(1-c),r.z=i.z*u+s.z*(1-u);const f=t.dot(r);o=Math.min(f,o),a=Math.max(f,a)}this.min=o,this.max=a}}();const uy=function(){const r=new C,e=new C,t=new C;return function(i,s,o){const a=i.start,l=r,c=s.start,u=e;t.subVectors(a,c),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const f=t.dot(u),h=u.dot(l),p=u.dot(u),_=t.dot(l),m=l.dot(l)*p-h*h;let d,x;m!==0?d=(f*h-_*p)/m:d=0,x=(f+d*h)/p,o.x=d,o.y=x}}(),fc=function(){const r=new Ue,e=new C,t=new C;return function(i,s,o,a){uy(i,s,r);let l=r.x,c=r.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=i.start:u=i.end;let f;c<0?f=s.start:f=s.end;const h=e,p=t;if(i.closestPointToPoint(f,!0,e),s.closestPointToPoint(u,!0,t),h.distanceToSquared(f)<=p.distanceToSquared(u)){o.copy(h),a.copy(f);return}else{o.copy(u),a.copy(p);return}}}}(),hy=function(){const r=new C,e=new C,t=new ci,n=new Ci;return function(s,o){const{radius:a,center:l}=s,{a:c,b:u,c:f}=o;if(n.start=c,n.end=u,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=c,n.end=f,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=u,n.end=f,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;const g=o.getPlane(t);if(Math.abs(g.distanceToPoint(l))<=a){const d=g.projectPoint(l,e);if(o.containsPoint(d))return!0}return!1}}(),fy=1e-15;function _l(r){return Math.abs(r)new C),this.satBounds=new Array(4).fill().map(()=>new Pi),this.points=[this.a,this.b,this.c],this.sphere=new ni,this.plane=new ci,this.needsUpdate=!0}intersectsSphere(e){return hy(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);const c=s[1],u=o[1];c.subVectors(e,t),u.setFromPoints(c,i);const f=s[2],h=o[2];f.subVectors(t,n),h.setFromPoints(f,i);const p=s[3],_=o[3];p.subVectors(n,e),_.setFromPoints(p,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}ti.prototype.closestPointToSegment=function(){const r=new C,e=new C,t=new Ci;return function(i,s=null,o=null){const{start:a,end:l}=i,c=this.points;let u,f=1/0;for(let h=0;h<3;h++){const p=(h+1)%3;t.start.copy(c[h]),t.end.copy(c[p]),fc(t,i,r,e),u=r.distanceToSquared(e),u=2){(y===1?d.start:d.end).copy(p),v=2;break}if(v++,v===2&&y===-1)break}}return v}return function(m,d=null,x=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(r.copy(m),r.update(),m=r);const v=this.plane,y=m.plane;if(Math.abs(v.normal.dot(y.normal))>1-1e-10){const b=this.satBounds,M=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let E=0;E<4;E++){const A=b[E],z=M[E];if(n.setFromPoints(z,t),A.isSeparated(n))return!1}const T=m.satBounds,I=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let E=0;E<4;E++){const A=T[E],z=I[E];if(n.setFromPoints(z,e),A.isSeparated(n))return!1}for(let E=0;E<4;E++){const A=M[E];for(let z=0;z<4;z++){const O=I[z];if(s.crossVectors(A,O),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return d&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),d.start.set(0,0,0),d.end.set(0,0,0)),!0}else{const b=_(this,y,f);if(b===1&&m.containsPoint(f.end))return d&&(d.start.copy(f.end),d.end.copy(f.end)),!0;if(b!==2)return!1;const M=_(m,v,h);if(M===1&&this.containsPoint(h.end))return d&&(d.start.copy(h.end),d.end.copy(h.end)),!0;if(M!==2)return!1;if(f.delta(a),h.delta(l),a.dot(l)<0){let W=h.start;h.start=h.end,h.end=W}const T=f.start.dot(a),I=f.end.dot(a),E=h.start.dot(a),A=h.end.dot(a),z=I0?d.start.copy(f.start):d.start.copy(h.start),c.subVectors(f.end,h.end),c.dot(a)<0?d.end.copy(f.end):d.end.copy(h.end)),!0)}}}();ti.prototype.distanceToPoint=function(){const r=new C;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();ti.prototype.distanceToTriangle=function(){const r=new C,e=new C,t=["a","b","c"],n=new Ci,i=new Ci;return function(o,a=null,l=null){const c=a||l?n:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let f=0;f<3;f++){let h;const p=t[f],_=o[p];this.closestPointToPoint(_,r),h=_.distanceToSquared(r),hnew C),this.satAxes=new Array(3).fill().map(()=>new C),this.satBounds=new Array(3).fill().map(()=>new Pi),this.alignedSatBounds=new Array(3).fill().map(()=>new Pi),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}bn.prototype.update=function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let f=0;f<=1;f++){const h=1*c|2*u|4*f,p=i[h];p.x=c?n.x:t.x,p.y=u?n.y:t.y,p.z=f?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,o=this.satAxes,a=i[0];for(let c=0;c<3;c++){const u=o[c],f=s[c],h=1<new Ci),t=new Array(12).fill().map(()=>new Ci),n=new C,i=new C;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),c&&c.copy(i)),0;const u=a*a,f=o.min,h=o.max,p=this.points;let _=1/0;for(let m=0;m<8;m++){const d=p[m];i.copy(d).clamp(f,h);const x=d.distanceToSquared(i);if(x<_&&(_=x,l&&l.copy(d),c&&c.copy(i),xnew ti)}}const Gn=new dy;function wn(r,e){return e[r+15]===65535}function Tn(r,e){return e[r+6]}function In(r,e){return e[r+14]}function Wn(r){return r+8}function Nn(r,e){return e[r+6]}function pc(r,e){return e[r+7]}class py{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const Rt=new py;let qi,is;const Wr=[],Go=new dc(()=>new $t);function my(r,e,t,n,i,s){qi=Go.getPrimitive(),is=Go.getPrimitive(),Wr.push(qi,is),Rt.setBuffer(r._roots[e]);const o=Vl(0,r.geometry,t,n,i,s);Rt.clearBuffer(),Go.releasePrimitive(qi),Go.releasePrimitive(is),Wr.pop(),Wr.pop();const a=Wr.length;return a>0&&(is=Wr[a-1],qi=Wr[a-2]),o}function Vl(r,e,t,n,i=null,s=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=Rt;let u=r*2;if(wn(u,l)){const _=Tn(r,c),g=In(u,l);return Ut(r,a,qi),n(_,g,!1,o,s+r,qi)}else{let O=function(D){const{uint16Array:V,uint32Array:Z}=Rt;let Q=D*2;for(;!wn(Q,V);)D=Wn(D),Q=D*2;return Tn(D,Z)},W=function(D){const{uint16Array:V,uint32Array:Z}=Rt;let Q=D*2;for(;!wn(Q,V);)D=Nn(D,Z),Q=D*2;return Tn(D,Z)+In(Q,V)};var h=O,p=W;const _=Wn(r),g=Nn(r,c);let m=_,d=g,x,v,y,b;if(i&&(y=qi,b=is,Ut(m,a,y),Ut(d,a,b),x=i(y),v=i(b),v(Fs.copy(e).clamp(u.min,u.max),Fs.distanceToSquared(e)),intersectsBounds:(u,f,h)=>h{u.closestPointToPoint(e,Fs);const h=e.distanceToSquared(Fs);return h0&&c.normal.multiplyScalar(-1));const u={a:s,b:o,c:a,normal:new C,materialIndex:0};fn.getNormal(Xr,qr,jr,u.normal),c.face=u,c.faceIndex=s}return c}function Ma(r,e,t,n,i){const s=n*3;let o=s+0,a=s+1,l=s+2;const c=r.index;r.index&&(o=c.getX(o),a=c.getX(a),l=c.getX(l));const{position:u,normal:f,uv:h,uv1:p}=r.attributes,_=vy(t,u,f,h,p,o,a,l,e);return _?(_.faceIndex=n,i&&i.push(_),_):null}function jt(r,e,t,n){const i=r.a,s=r.b,o=r.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(c),o.y=n.getY(c),o.z=n.getZ(c)}function xy(r,e,t,n,i,s){const{geometry:o,_indirectBuffer:a}=r;for(let l=n,c=n+i;lM&&(M=O),WT&&(T=W),DI&&(I=D)}return l[h+0]!==v||l[h+1]!==y||l[h+2]!==b||l[h+3]!==M||l[h+4]!==T||l[h+5]!==I?(l[h+0]=v,l[h+1]=y,l[h+2]=b,l[h+3]=M,l[h+4]=T,l[h+5]=I,!0):!1}else{const d=h+8,x=o[h+6],v=d+p,y=x+p;let b=_,M=!1,T=!1;e?b||(M=e.has(v),T=e.has(y),b=!M&&!T):(M=!0,T=!0);const I=b||M,E=b||T;let A=!1;I&&(A=f(d,p,b));let z=!1;E&&(z=f(x,p,b));const O=A||z;if(O)for(let W=0;W<3;W++){const D=d+W,V=x+W,Z=l[D],Q=l[D+3],ce=l[V],ie=l[V+3];l[h+W]=Zie?Q:ie}return O}}}const Ph=new $t;function Qi(r,e,t,n){return Ut(r,e,Ph),t.intersectBox(Ph,n)}function Sy(r,e,t,n,i,s){const{geometry:o,_indirectBuffer:a}=r;for(let l=n,c=n+i;l=0;let p,_;h?(p=Wn(r),_=Nn(r,o)):(p=Nn(r,o),_=Wn(r));const m=Qi(p,i,n,Ih)?Wl(p,e,t,n):null;if(m){const v=m.point[u];if(h?v<=i[_+c]:v>=i[_+c+3])return m}const x=Qi(_,i,n,Ih)?Wl(_,e,t,n):null;return m&&x?m.distance<=x.distance?m:x:m||x||null}}const Yo=new $t,Yr=new ti,$r=new ti,Os=new Ve,Nh=new bn,$o=new bn;function Ly(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=Xl(0,r,t,n);return Rt.clearBuffer(),i}function Xl(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Nh.set(t.boundingBox.min,t.boundingBox.max,n),i=Nh),wn(l,o)){const u=e.geometry,f=u.index,h=u.attributes.position,p=t.index,_=t.attributes.position,g=Tn(r,a),m=In(l,o);if(Os.copy(n).invert(),t.boundsTree)return Ut(r,s,$o),$o.matrix.copy(Os),$o.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>$o.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let v=g*3,y=(m+g)*3;vvl.distanceToBox(b),intersectsBounds:(b,M,T)=>T{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>Us.distanceToBox(I),intersectsBounds:(I,E,A)=>A{for(let A=I,z=I+E;AM&&(M=D),VT&&(T=V),ZI&&(I=Z)}}return l[h+0]!==v||l[h+1]!==y||l[h+2]!==b||l[h+3]!==M||l[h+4]!==T||l[h+5]!==I?(l[h+0]=v,l[h+1]=y,l[h+2]=b,l[h+3]=M,l[h+4]=T,l[h+5]=I,!0):!1}else{const d=h+8,x=o[h+6],v=d+p,y=x+p;let b=_,M=!1,T=!1;e?b||(M=e.has(v),T=e.has(y),b=!M&&!T):(M=!0,T=!0);const I=b||M,E=b||T;let A=!1;I&&(A=f(d,p,b));let z=!1;E&&(z=f(x,p,b));const O=A||z;if(O)for(let W=0;W<3;W++){const D=d+W,V=x+W,Z=l[D],Q=l[D+3],ce=l[V],ie=l[V+3];l[h+W]=Zie?Q:ie}return O}}}const Fh=new C;function Oy(r,e,t,n,i){Rt.setBuffer(r._roots[e]),ql(0,r,t,n,i),Rt.clearBuffer()}function ql(r,e,t,n,i){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt,l=r*2;if(wn(l,o)){const u=Tn(r,a),f=In(l,o);Sy(e,t,n,u,f,i)}else{const u=Wn(r);Qi(u,s,n,Fh)&&ql(u,e,t,n,i);const f=Nn(r,a);Qi(f,s,n,Fh)&&ql(f,e,t,n,i)}}const Oh=new C,Uy=["x","y","z"];function By(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=jl(0,r,t,n);return Rt.clearBuffer(),i}function jl(r,e,t,n){const{float32Array:i,uint16Array:s,uint32Array:o}=Rt;let a=r*2;if(wn(a,s)){const c=Tn(r,o),u=In(a,s);return wy(e,t,n,c,u)}else{const c=pc(r,o),u=Uy[c],h=n.direction[u]>=0;let p,_;h?(p=Wn(r),_=Nn(r,o)):(p=Nn(r,o),_=Wn(r));const m=Qi(p,i,n,Oh)?jl(p,e,t,n):null;if(m){const v=m.point[u];if(h?v<=i[_+c]:v>=i[_+c+3])return m}const x=Qi(_,i,n,Oh)?jl(_,e,t,n):null;return m&&x?m.distance<=x.distance?m:x:m||x||null}}const Zo=new $t,Kr=new ti,Zr=new ti,Bs=new Ve,Uh=new bn,Qo=new bn;function zy(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=Yl(0,r,t,n);return Rt.clearBuffer(),i}function Yl(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Uh.set(t.boundingBox.min,t.boundingBox.max,n),i=Uh),wn(l,o)){const u=e.geometry,f=u.index,h=u.attributes.position,p=t.index,_=t.attributes.position,g=Tn(r,a),m=In(l,o);if(Bs.copy(n).invert(),t.boundsTree)return Ut(r,s,Qo),Qo.matrix.copy(Bs),Qo.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Qo.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let v=g,y=m+g;vxl.distanceToBox(b),intersectsBounds:(b,M,T)=>T{if(e.boundsTree){const T=e.boundsTree;return T.shapecast({boundsTraverseOrder:I=>zs.distanceToBox(I),intersectsBounds:(I,E,A)=>A{for(let A=I,z=I+E;Anew $t),Qr=new $t,Jr=new $t,yl=new $t,bl=new $t;let El=!1;function qy(r,e,t,n){if(El)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");El=!0;const i=r._roots,s=e._roots;let o,a=0,l=0;const c=new Ve().copy(t).invert();for(let u=0,f=i.length;ul.slice()),index:o.array.slice(),indirectBuffer:s?s.slice():null}:a={roots:i,index:o.array,indirectBuffer:s},a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:o}=e,a=new mc(t,{...n,[pl]:!0});if(a._roots=s,a._indirectBuffer=o||null,n.setIndex){const l=t.getIndex();if(l===null){const c=new Yt(e.index,1,!1);t.setIndex(c)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:Vf,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[pl]:!1},t),t.useSharedArrayBuffer&&!Xy())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[pl]||(cy(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new $t)));const{_indirectBuffer:n}=this;this.resolveTriangleIndex=t.indirect?i=>n[i]:i=>i}refit(e=null){return(this.indirect?Fy:Ey)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){const c=a*2,u=s[c+15]===wa;if(u){const f=i[a+6],h=s[c+14];e(l,u,new Float32Array(n,a*4,6),f,h)}else{const f=a+_r/4,h=i[a+6],p=i[a+7];e(l,u,new Float32Array(n,a*4,6),p)||(o(f,l+1),o(h,l+1))}}}raycast(e,t=ei){const n=this._roots,i=this.geometry,s=[],o=t.isMaterial,a=Array.isArray(t),l=i.groups,c=o?t.side:t,u=this.indirect?Oy:Ty;for(let f=0,h=n.length;ff(h,p,_,g,m)?!0:n(h,p,this,a,_,g,t)}else o||(a?o=(f,h,p,_)=>n(f,h,this,a,p,_,t):o=(f,h,p)=>p);let l=!1,c=0;const u=this._roots;for(let f=0,h=u.length;f{const g=this.resolveTriangleIndex(_);jt(o,g*3,a,l)}:_=>{jt(o,_*3,a,l)},u=Gn.getPrimitive(),f=e.geometry.index,h=e.geometry.attributes.position,p=e.indirect?_=>{const g=e.resolveTriangleIndex(_);jt(u,g*3,f,h)}:_=>{jt(u,_*3,f,h)};if(s){const _=(g,m,d,x,v,y,b,M)=>{for(let T=d,I=d+x;Tea.intersectsBox(n),intersectsTriangle:n=>ea.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){return(this.indirect?Wy:Ny)(this,e,t,n,i,s,o)}closestPointToPoint(e,t={},n=0,i=1/0){return _y(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Ut(0,new Float32Array(n),Bh),e.union(Bh)}),e}}function jy(r){switch(r){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function Yy(r){switch(r){case 1:return sf;case 2:return of;case 3:return sn;case 4:return sn}}function zh(r){switch(r){case 1:return Jl;case 2:return xa;case 3:return Js;case 4:return Js}}class Yf extends pa{constructor(){super(),this.minFilter=Nt,this.magFilter=Nt,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const t=this.overrideItemSize,n=e.itemSize,i=e.count;if(t!==null){if(n*i%t!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");e.itemSize=t,e.count=i*n/t}const s=e.itemSize,o=e.count,a=e.normalized,l=e.array.constructor,c=l.BYTES_PER_ELEMENT;let u=this._forcedType,f=s;if(u===null)switch(l){case Float32Array:u=vn;break;case Uint8Array:case Uint16Array:case Uint32Array:u=Dn;break;case Int8Array:case Int16Array:case Int32Array:u=Ws;break}let h,p,_,g,m=jy(s);switch(u){case vn:_=1,p=Yy(s),a&&c===1?(g=l,m+="8",l===Uint8Array?h=fi:(h=Pl,m+="_SNORM")):(g=Float32Array,m+="32F",h=vn);break;case Ws:m+=c*8+"I",_=a?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,p=zh(s),c===1?(g=Int8Array,h=Pl):c===2?(g=Int16Array,h=tf):(g=Int32Array,h=Ws);break;case Dn:m+=c*8+"UI",_=a?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,p=zh(s),c===1?(g=Uint8Array,h=fi):c===2?(g=Uint16Array,h=va):(g=Uint32Array,h=Dn);break}f===3&&(p===sn||p===Js)&&(f=4);const d=Math.ceil(Math.sqrt(o)),x=f*d*d,v=new g(x),y=e.normalized;e.normalized=!1;for(let b=0;b=2&&(v[M+1]=e.getY(b)/_),s>=3&&(v[M+2]=e.getZ(b)/_,f===4&&(v[M+3]=1)),s>=4&&(v[M+3]=e.getW(b)/_)}e.normalized=y,this.internalFormat=m,this.format=p,this.type=h,this.image.width=d,this.image.height=d,this.image.data=v,this.needsUpdate=!0,this.dispose(),e.itemSize=n,e.count=i}}class $y extends Yf{constructor(){super(),this._forcedType=Dn}}class Vs extends Yf{constructor(){super(),this._forcedType=vn}}class kh{constructor(){this.index=new $y,this.position=new Vs,this.bvhBounds=new pa,this.bvhContents=new pa,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:t}=e;if(Zy(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(t.attributes.position),e.indirect){const n=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==n.length)if(t.index)this._cachedIndexAttr=t.index.clone();else{const i=Xf(Wf(t));this._cachedIndexAttr=new Yt(i,1,!1)}Ky(t,n,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(t.index)}dispose(){const{index:e,position:t,bvhBounds:n,bvhContents:i}=this;e&&e.dispose(),t&&t.dispose(),n&&n.dispose(),i&&i.dispose()}}function Ky(r,e,t){const n=t.array,i=r.index?r.index.array:null;for(let s=0,o=e.length;su||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/ce.x),i.x=s.x*ce.x,Q.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/ce.y),i.y=s.y*ce.y,Q.mapSize.y=s.y)),Q.map===null||O===!0||W===!0){const se=this.type!==Mi?{minFilter:Nt,magFilter:Nt}:{};Q.map!==null&&Q.map.dispose(),Q.map=new Ki(i.x,i.y,se),Q.map.texture.name=Z.name+".shadowMap",Q.camera.updateProjectionMatrix()}r.setRenderTarget(Q.map),r.clear();const ie=Q.getViewportCount();for(let se=0;se0||M.map&&M.alphaTest>0){const z=S.uuid,O=M.uuid;let W=c[z];W===void 0&&(W={},c[z]=W);let D=W[O];D===void 0&&(D=S.clone(),W[O]=D),S=D}if(S.visible=M.visible,S.wireframe=M.wireframe,I===Mi?S.side=M.shadowSide!==null?M.shadowSide:M.side:S.side=M.shadowSide!==null?M.shadowSide:f[M.side],S.alphaMap=M.alphaMap,S.alphaTest=M.alphaTest,S.map=M.map,S.clipShadows=M.clipShadows,S.clippingPlanes=M.clippingPlanes,S.clipIntersection=M.clipIntersection,S.displacementMap=M.displacementMap,S.displacementScale=M.displacementScale,S.displacementBias=M.displacementBias,S.wireframeLinewidth=M.wireframeLinewidth,S.linewidth=M.linewidth,T.isPointLight===!0&&S.isMeshDistanceMaterial===!0){const z=r.properties.get(S);z.light=T}return S}function y(b,M,T,I,S){if(b.visible===!1)return;if(b.layers.test(M.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&S===Mi)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,b.matrixWorld);const O=e.update(b),W=b.material;if(Array.isArray(W)){const D=O.groups;for(let V=0,Z=D.length;V=1):se.indexOf("OpenGL ES")!==-1&&(ie=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),ce=ie>=2);let me=null,ve={};const J=r.getParameter(r.SCISSOR_BOX),oe=r.getParameter(r.VIEWPORT),Se=new mt().fromArray(J),De=new mt().fromArray(oe);function _e(F,ge,ae,ee){const he=new Uint8Array(4),Le=r.createTexture();r.bindTexture(F,Le),r.texParameteri(F,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(F,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let nt=0;nt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),_=new WeakMap;let g;const m=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(P,E){return d?new OffscreenCanvas(P,E):to("canvas")}function v(P,E,q,le){let re=1;if((P.width>le||P.height>le)&&(re=le/Math.max(P.width,P.height)),re<1||E===!0)if(typeof HTMLImageElement<"u"&&P instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&P instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&P instanceof ImageBitmap){const fe=E?da:Math.floor,Me=fe(re*P.width),pe=fe(re*P.height);g===void 0&&(g=x(Me,pe));const ye=q?x(Me,pe):g;return ye.width=Me,ye.height=pe,ye.getContext("2d").drawImage(P,0,0,Me,pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+P.width+"x"+P.height+") to ("+Me+"x"+pe+")."),ye}else return"data"in P&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+P.width+"x"+P.height+")."),P;return P}function y(P){return Fl(P.width)&&Fl(P.height)}function b(P){return a?!1:P.wrapS!==Hn||P.wrapT!==Hn||P.minFilter!==Nt&&P.minFilter!==En}function M(P,E){return P.generateMipmaps&&E&&P.minFilter!==Nt&&P.minFilter!==En}function T(P){r.generateMipmap(P)}function I(P,E,q,le,re=!1){if(a===!1)return E;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 fe=E;if(E===r.RED&&(q===r.FLOAT&&(fe=r.R32F),q===r.HALF_FLOAT&&(fe=r.R16F),q===r.UNSIGNED_BYTE&&(fe=r.R8)),E===r.RED_INTEGER&&(q===r.UNSIGNED_BYTE&&(fe=r.R8UI),q===r.UNSIGNED_SHORT&&(fe=r.R16UI),q===r.UNSIGNED_INT&&(fe=r.R32UI),q===r.BYTE&&(fe=r.R8I),q===r.SHORT&&(fe=r.R16I),q===r.INT&&(fe=r.R32I)),E===r.RG&&(q===r.FLOAT&&(fe=r.RG32F),q===r.HALF_FLOAT&&(fe=r.RG16F),q===r.UNSIGNED_BYTE&&(fe=r.RG8)),E===r.RGBA){const Me=re?ca:pt.getTransfer(le);q===r.FLOAT&&(fe=r.RGBA32F),q===r.HALF_FLOAT&&(fe=r.RGBA16F),q===r.UNSIGNED_BYTE&&(fe=Me===At?r.SRGB8_ALPHA8:r.RGBA8),q===r.UNSIGNED_SHORT_4_4_4_4&&(fe=r.RGBA4),q===r.UNSIGNED_SHORT_5_5_5_1&&(fe=r.RGB5_A1)}return(fe===r.R16F||fe===r.R32F||fe===r.RG16F||fe===r.RG32F||fe===r.RGBA16F||fe===r.RGBA32F)&&e.get("EXT_color_buffer_float"),fe}function S(P,E,q){return M(P,q)===!0||P.isFramebufferTexture&&P.minFilter!==Nt&&P.minFilter!==En?Math.log2(Math.max(E.width,E.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?E.mipmaps.length:1}function A(P){return P===Nt||P===Cl||P===sa?r.NEAREST:r.LINEAR}function z(P){const E=P.target;E.removeEventListener("dispose",z),W(E),E.isVideoTexture&&_.delete(E)}function O(P){const E=P.target;E.removeEventListener("dispose",O),V(E)}function W(P){const E=n.get(P);if(E.__webglInit===void 0)return;const q=P.source,le=m.get(q);if(le){const re=le[E.__cacheKey];re.usedTimes--,re.usedTimes===0&&D(P),Object.keys(le).length===0&&m.delete(q)}n.remove(P)}function D(P){const E=n.get(P);r.deleteTexture(E.__webglTexture);const q=P.source,le=m.get(q);delete le[E.__cacheKey],o.memory.textures--}function V(P){const E=P.texture,q=n.get(P),le=n.get(E);if(le.__webglTexture!==void 0&&(r.deleteTexture(le.__webglTexture),o.memory.textures--),P.depthTexture&&P.depthTexture.dispose(),P.isWebGLCubeRenderTarget)for(let re=0;re<6;re++){if(Array.isArray(q.__webglFramebuffer[re]))for(let fe=0;fe=l&&console.warn("THREE.WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+l),Z+=1,P}function ie(P){const E=[];return E.push(P.wrapS),E.push(P.wrapT),E.push(P.wrapR||0),E.push(P.magFilter),E.push(P.minFilter),E.push(P.anisotropy),E.push(P.internalFormat),E.push(P.format),E.push(P.type),E.push(P.generateMipmaps),E.push(P.premultiplyAlpha),E.push(P.flipY),E.push(P.unpackAlignment),E.push(P.colorSpace),E.join()}function se(P,E){const q=n.get(P);if(P.isVideoTexture&&Tt(P),P.isRenderTargetTexture===!1&&P.version>0&&q.__version!==P.version){const le=P.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{We(q,P,E);return}}t.bindTexture(r.TEXTURE_2D,q.__webglTexture,r.TEXTURE0+E)}function me(P,E){const q=n.get(P);if(P.version>0&&q.__version!==P.version){We(q,P,E);return}t.bindTexture(r.TEXTURE_2D_ARRAY,q.__webglTexture,r.TEXTURE0+E)}function ve(P,E){const q=n.get(P);if(P.version>0&&q.__version!==P.version){We(q,P,E);return}t.bindTexture(r.TEXTURE_3D,q.__webglTexture,r.TEXTURE0+E)}function J(P,E){const q=n.get(P);if(P.version>0&&q.__version!==P.version){Fe(q,P,E);return}t.bindTexture(r.TEXTURE_CUBE_MAP,q.__webglTexture,r.TEXTURE0+E)}const oe={[us]:r.REPEAT,[Hn]:r.CLAMP_TO_EDGE,[la]:r.MIRRORED_REPEAT},Se={[Nt]:r.NEAREST,[Cl]:r.NEAREST_MIPMAP_NEAREST,[sa]:r.NEAREST_MIPMAP_LINEAR,[En]:r.LINEAR,[ef]:r.LINEAR_MIPMAP_NEAREST,[gr]:r.LINEAR_MIPMAP_LINEAR},De={[Yd]:r.NEVER,[ep]:r.ALWAYS,[$d]:r.LESS,[hf]:r.LEQUAL,[Kd]:r.EQUAL,[Jd]:r.GEQUAL,[Zd]:r.GREATER,[Qd]:r.NOTEQUAL};function _e(P,E,q){if(q?(r.texParameteri(P,r.TEXTURE_WRAP_S,oe[E.wrapS]),r.texParameteri(P,r.TEXTURE_WRAP_T,oe[E.wrapT]),(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)&&r.texParameteri(P,r.TEXTURE_WRAP_R,oe[E.wrapR]),r.texParameteri(P,r.TEXTURE_MAG_FILTER,Se[E.magFilter]),r.texParameteri(P,r.TEXTURE_MIN_FILTER,Se[E.minFilter])):(r.texParameteri(P,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(P,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(P===r.TEXTURE_3D||P===r.TEXTURE_2D_ARRAY)&&r.texParameteri(P,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(E.wrapS!==Hn||E.wrapT!==Hn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(P,r.TEXTURE_MAG_FILTER,A(E.magFilter)),r.texParameteri(P,r.TEXTURE_MIN_FILTER,A(E.minFilter)),E.minFilter!==Nt&&E.minFilter!==En&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),E.compareFunction&&(r.texParameteri(P,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(P,r.TEXTURE_COMPARE_FUNC,De[E.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const le=e.get("EXT_texture_filter_anisotropic");if(E.magFilter===Nt||E.minFilter!==sa&&E.minFilter!==gr||E.type===vn&&e.has("OES_texture_float_linear")===!1||a===!1&&E.type===Qs&&e.has("OES_texture_half_float_linear")===!1)return;(E.anisotropy>1||n.get(E).__currentAnisotropy)&&(r.texParameterf(P,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(E.anisotropy,i.getMaxAnisotropy())),n.get(E).__currentAnisotropy=E.anisotropy)}}function qe(P,E){let q=!1;P.__webglInit===void 0&&(P.__webglInit=!0,E.addEventListener("dispose",z));const le=E.source;let re=m.get(le);re===void 0&&(re={},m.set(le,re));const fe=ie(E);if(fe!==P.__cacheKey){re[fe]===void 0&&(re[fe]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,q=!0),re[fe].usedTimes++;const Me=re[P.__cacheKey];Me!==void 0&&(re[P.__cacheKey].usedTimes--,Me.usedTimes===0&&D(E)),P.__cacheKey=fe,P.__webglTexture=re[fe].texture}return q}function We(P,E,q){let le=r.TEXTURE_2D;(E.isDataArrayTexture||E.isCompressedArrayTexture)&&(le=r.TEXTURE_2D_ARRAY),E.isData3DTexture&&(le=r.TEXTURE_3D);const re=qe(P,E),fe=E.source;t.bindTexture(le,P.__webglTexture,r.TEXTURE0+q);const Me=n.get(fe);if(fe.version!==Me.__version||re===!0){t.activeTexture(r.TEXTURE0+q);const pe=pt.getPrimaries(pt.workingColorSpace),ye=E.colorSpace===Vn?null:pt.getPrimaries(E.colorSpace),N=E.colorSpace===Vn||pe===ye?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,E.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,E.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,E.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,N);const de=b(E)&&y(E.image)===!1;let ne=v(E.image,de,!1,u);ne=Ct(E,ne);const Oe=y(ne)||a,Re=s.convert(E.format,E.colorSpace);let Pe=s.convert(E.type),we=I(E.internalFormat,Re,Pe,E.colorSpace,E.isVideoTexture);_e(le,E,Oe);let be;const Ge=E.mipmaps,F=a&&E.isVideoTexture!==!0&&we!==af,ge=Me.__version===void 0||re===!0,ae=S(E,ne,Oe);if(E.isDepthTexture)we=r.DEPTH_COMPONENT,a?E.type===vn?we=r.DEPTH_COMPONENT32F:E.type===Dn?we=r.DEPTH_COMPONENT24:E.type===pr?we=r.DEPTH24_STENCIL8:we=r.DEPTH_COMPONENT16:E.type===vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),E.format===mr&&we===r.DEPTH_COMPONENT&&E.type!==va&&E.type!==Dn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),E.type=Dn,Pe=s.convert(E.type)),E.format===hs&&we===r.DEPTH_COMPONENT&&(we=r.DEPTH_STENCIL,E.type!==pr&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),E.type=pr,Pe=s.convert(E.type))),ge&&(F?t.texStorage2D(r.TEXTURE_2D,1,we,ne.width,ne.height):t.texImage2D(r.TEXTURE_2D,0,we,ne.width,ne.height,0,Re,Pe,null));else if(E.isDataTexture)if(Ge.length>0&&Oe){F&&ge&&t.texStorage2D(r.TEXTURE_2D,ae,we,Ge[0].width,Ge[0].height);for(let ee=0,he=Ge.length;ee>=1,he>>=1}}else if(Ge.length>0&&Oe){F&&ge&&t.texStorage2D(r.TEXTURE_2D,ae,we,Ge[0].width,Ge[0].height);for(let ee=0,he=Ge.length;ee0&&ge++,t.texStorage2D(r.TEXTURE_CUBE_MAP,ge,be,ne[0].width,ne[0].height));for(let ee=0;ee<6;ee++)if(de){Ge?t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,ne[ee].width,ne[ee].height,Pe,we,ne[ee].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,be,ne[ee].width,ne[ee].height,0,Pe,we,ne[ee].data);for(let he=0;he>fe),ne=Math.max(1,E.height>>fe);re===r.TEXTURE_3D||re===r.TEXTURE_2D_ARRAY?t.texImage3D(re,fe,ye,de,ne,E.depth,0,Me,pe,null):t.texImage2D(re,fe,ye,de,ne,0,Me,pe,null)}t.bindFramebuffer(r.FRAMEBUFFER,P),ot(E)?h.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,le,re,n.get(q).__webglTexture,0,ke(E)):(re===r.TEXTURE_2D||re>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&re<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,le,re,n.get(q).__webglTexture,fe),t.bindFramebuffer(r.FRAMEBUFFER,null)}function X(P,E,q){if(r.bindRenderbuffer(r.RENDERBUFFER,P),E.depthBuffer&&!E.stencilBuffer){let le=a===!0?r.DEPTH_COMPONENT24:r.DEPTH_COMPONENT16;if(q||ot(E)){const re=E.depthTexture;re&&re.isDepthTexture&&(re.type===vn?le=r.DEPTH_COMPONENT32F:re.type===Dn&&(le=r.DEPTH_COMPONENT24));const fe=ke(E);ot(E)?h.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,fe,le,E.width,E.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,fe,le,E.width,E.height)}else r.renderbufferStorage(r.RENDERBUFFER,le,E.width,E.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,P)}else if(E.depthBuffer&&E.stencilBuffer){const le=ke(E);q&&ot(E)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,le,r.DEPTH24_STENCIL8,E.width,E.height):ot(E)?h.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,le,r.DEPTH24_STENCIL8,E.width,E.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,E.width,E.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,P)}else{const le=E.isWebGLMultipleRenderTargets===!0?E.texture:[E.texture];for(let re=0;re0){q.__webglFramebuffer[pe]=[];for(let ye=0;ye0){q.__webglFramebuffer=[];for(let pe=0;pe0&&ot(P)===!1){const pe=fe?E:[E];q.__webglMultisampledFramebuffer=r.createFramebuffer(),q.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,q.__webglMultisampledFramebuffer);for(let ye=0;ye0)for(let ye=0;ye0)for(let ye=0;ye0&&ot(P)===!1){const E=P.isWebGLMultipleRenderTargets?P.texture:[P.texture],q=P.width,le=P.height;let re=r.COLOR_BUFFER_BIT;const fe=[],Me=P.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,pe=n.get(P),ye=P.isWebGLMultipleRenderTargets===!0;if(ye)for(let N=0;N0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&E.__useRenderToTexture!==!1}function Tt(P){const E=o.render.frame;_.get(P)!==E&&(_.set(P,E),P.update())}function Ct(P,E){const q=P.colorSpace,le=P.format,re=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||P.format===Nl||q!==an&&q!==Vn&&(pt.getTransfer(q)===At?a===!1?e.has("EXT_sRGB")===!0&&le===sn?(P.format=Nl,P.minFilter=En,P.generateMipmaps=!1):E=pf.sRGBToLinear(E):(le!==sn||re!==fi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",q)),E}this.allocateTextureUnit=ce,this.resetTextureUnits=Q,this.setTexture2D=se,this.setTexture2DArray=me,this.setTexture3D=ve,this.setTextureCube=J,this.rebindTextures=$e,this.setupRenderTarget=ze,this.updateRenderTargetMipmap=_t,this.updateMultisampleRenderTarget=Ke,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=Ye,this.useMultisampledRTT=ot}function dv(r,e,t){const n=t.isWebGL2;function i(s,o=Vn){let a;const l=pt.getTransfer(o);if(s===fi)return r.UNSIGNED_BYTE;if(s===nf)return r.UNSIGNED_SHORT_4_4_4_4;if(s===rf)return r.UNSIGNED_SHORT_5_5_5_1;if(s===Pl)return r.BYTE;if(s===tf)return r.SHORT;if(s===va)return r.UNSIGNED_SHORT;if(s===Ws)return r.INT;if(s===Dn)return r.UNSIGNED_INT;if(s===vn)return r.FLOAT;if(s===Qs)return n?r.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===zd)return r.ALPHA;if(s===sn)return r.RGBA;if(s===kd)return r.LUMINANCE;if(s===Hd)return r.LUMINANCE_ALPHA;if(s===mr)return r.DEPTH_COMPONENT;if(s===hs)return r.DEPTH_STENCIL;if(s===Nl)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===sf)return r.RED;if(s===Jl)return r.RED_INTEGER;if(s===of)return r.RG;if(s===xa)return r.RG_INTEGER;if(s===Js)return r.RGBA_INTEGER;if(s===La||s===Ca||s===Pa||s===Da)if(l===At)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===La)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===Ca)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Pa)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Da)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===La)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Ca)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Pa)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Da)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Dc||s===Ic||s===Nc||s===Fc)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Dc)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Ic)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Nc)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Fc)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===af)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Oc||s===Uc)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Oc)return l===At?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Uc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Bc||s===zc||s===kc||s===Hc||s===Vc||s===Gc||s===Wc||s===Xc||s===qc||s===jc||s===Yc||s===$c||s===Kc||s===Zc)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Bc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===zc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===kc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Hc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Vc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Gc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Wc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Xc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===qc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===jc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Yc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===$c)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Kc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Zc)return l===At?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Ia||s===Qc||s===Jc)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Ia)return l===At?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===Qc)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===Jc)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Vd||s===eu||s===tu||s===nu)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===Ia)return a.COMPRESSED_RED_RGTC1_EXT;if(s===eu)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===tu)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===nu)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===pr?n?r.UNSIGNED_INT_24_8:(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}}class pv extends _n{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class dr extends Bt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const mv={type:"move"};class il{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dr,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 dr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),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}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data: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;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const g of e.hand.values()){const m=t.getJointPose(g,n),d=this._getHandJoint(c,g);m!==null&&(d.matrix.fromArray(m.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,d.jointRadius=m.radius),d.visible=m!==null}const u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],h=u.position.distanceTo(f.position),p=.02,_=.005;c.inputState.pinching&&h>p+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=p-_&&(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),l.matrixWorldNeedsUpdate=!0,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));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,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(mv)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new dr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class _v extends xr{constructor(e,t){super();const n=this;let i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,f=null,h=null,p=null,_=null;const g=t.getContextAttributes();let m=null,d=null;const x=[],v=[],y=new Ue;let b=null;const M=new _n;M.layers.enable(1),M.viewport=new mt;const T=new _n;T.layers.enable(2),T.viewport=new mt;const I=[M,T],S=new pv;S.layers.enable(1),S.layers.enable(2);let A=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(J){let oe=x[J];return oe===void 0&&(oe=new il,x[J]=oe),oe.getTargetRaySpace()},this.getControllerGrip=function(J){let oe=x[J];return oe===void 0&&(oe=new il,x[J]=oe),oe.getGripSpace()},this.getHand=function(J){let oe=x[J];return oe===void 0&&(oe=new il,x[J]=oe),oe.getHandSpace()};function O(J){const oe=v.indexOf(J.inputSource);if(oe===-1)return;const Se=x[oe];Se!==void 0&&(Se.update(J.inputSource,J.frame,c||o),Se.dispatchEvent({type:J.type,data:J.inputSource}))}function W(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",D);for(let J=0;J=0&&(v[De]=null,x[De].disconnect(Se))}for(let oe=0;oe=v.length){v.push(Se),De=qe;break}else if(v[qe]===null){v[qe]=Se,De=qe;break}if(De===-1)break}const _e=x[De];_e&&_e.connect(Se)}}const V=new C,Z=new C;function Q(J,oe,Se){V.setFromMatrixPosition(oe.matrixWorld),Z.setFromMatrixPosition(Se.matrixWorld);const De=V.distanceTo(Z),_e=oe.projectionMatrix.elements,qe=Se.projectionMatrix.elements,We=_e[14]/(_e[10]-1),Fe=_e[14]/(_e[10]+1),Ye=(_e[9]+1)/_e[5],X=(_e[9]-1)/_e[5],Lt=(_e[8]-1)/_e[0],Ce=(qe[8]+1)/qe[0],$e=We*Lt,ze=We*Ce,_t=De/(-Lt+Ce),Ke=_t*-Lt;oe.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Ke),J.translateZ(_t),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert();const ke=We+_t,ot=Fe+_t,Tt=$e-Ke,Ct=ze+(De-Ke),P=Ye*Fe/ot*ke,E=X*Fe/ot*ke;J.projectionMatrix.makePerspective(Tt,Ct,P,E,ke,ot),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}function ce(J,oe){oe===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(oe.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(i===null)return;S.near=T.near=M.near=J.near,S.far=T.far=M.far=J.far,(A!==S.near||z!==S.far)&&(i.updateRenderState({depthNear:S.near,depthFar:S.far}),A=S.near,z=S.far);const oe=J.parent,Se=S.cameras;ce(S,oe);for(let De=0;De0&&(m.alphaTest.value=d.alphaTest);const x=e.get(d).envMap;if(x&&(m.envMap.value=x,m.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=d.reflectivity,m.ior.value=d.ior,m.refractionRatio.value=d.refractionRatio),d.lightMap){m.lightMap.value=d.lightMap;const v=r._useLegacyLights===!0?Math.PI:1;m.lightMapIntensity.value=d.lightMapIntensity*v,t(d.lightMap,m.lightMapTransform)}d.aoMap&&(m.aoMap.value=d.aoMap,m.aoMapIntensity.value=d.aoMapIntensity,t(d.aoMap,m.aoMapTransform))}function o(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,d.map&&(m.map.value=d.map,t(d.map,m.mapTransform))}function a(m,d){m.dashSize.value=d.dashSize,m.totalSize.value=d.dashSize+d.gapSize,m.scale.value=d.scale}function l(m,d,x,v){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.size.value=d.size*x,m.scale.value=v*.5,d.map&&(m.map.value=d.map,t(d.map,m.uvTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function c(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.rotation.value=d.rotation,d.map&&(m.map.value=d.map,t(d.map,m.mapTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function u(m,d){m.specular.value.copy(d.specular),m.shininess.value=Math.max(d.shininess,1e-4)}function f(m,d){d.gradientMap&&(m.gradientMap.value=d.gradientMap)}function h(m,d){m.metalness.value=d.metalness,d.metalnessMap&&(m.metalnessMap.value=d.metalnessMap,t(d.metalnessMap,m.metalnessMapTransform)),m.roughness.value=d.roughness,d.roughnessMap&&(m.roughnessMap.value=d.roughnessMap,t(d.roughnessMap,m.roughnessMapTransform)),e.get(d).envMap&&(m.envMapIntensity.value=d.envMapIntensity)}function p(m,d,x){m.ior.value=d.ior,d.sheen>0&&(m.sheenColor.value.copy(d.sheenColor).multiplyScalar(d.sheen),m.sheenRoughness.value=d.sheenRoughness,d.sheenColorMap&&(m.sheenColorMap.value=d.sheenColorMap,t(d.sheenColorMap,m.sheenColorMapTransform)),d.sheenRoughnessMap&&(m.sheenRoughnessMap.value=d.sheenRoughnessMap,t(d.sheenRoughnessMap,m.sheenRoughnessMapTransform))),d.clearcoat>0&&(m.clearcoat.value=d.clearcoat,m.clearcoatRoughness.value=d.clearcoatRoughness,d.clearcoatMap&&(m.clearcoatMap.value=d.clearcoatMap,t(d.clearcoatMap,m.clearcoatMapTransform)),d.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=d.clearcoatRoughnessMap,t(d.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),d.clearcoatNormalMap&&(m.clearcoatNormalMap.value=d.clearcoatNormalMap,t(d.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(d.clearcoatNormalScale),d.side===xn&&m.clearcoatNormalScale.value.negate())),d.iridescence>0&&(m.iridescence.value=d.iridescence,m.iridescenceIOR.value=d.iridescenceIOR,m.iridescenceThicknessMinimum.value=d.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=d.iridescenceThicknessRange[1],d.iridescenceMap&&(m.iridescenceMap.value=d.iridescenceMap,t(d.iridescenceMap,m.iridescenceMapTransform)),d.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=d.iridescenceThicknessMap,t(d.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),d.transmission>0&&(m.transmission.value=d.transmission,m.transmissionSamplerMap.value=x.texture,m.transmissionSamplerSize.value.set(x.width,x.height),d.transmissionMap&&(m.transmissionMap.value=d.transmissionMap,t(d.transmissionMap,m.transmissionMapTransform)),m.thickness.value=d.thickness,d.thicknessMap&&(m.thicknessMap.value=d.thicknessMap,t(d.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=d.attenuationDistance,m.attenuationColor.value.copy(d.attenuationColor)),d.anisotropy>0&&(m.anisotropyVector.value.set(d.anisotropy*Math.cos(d.anisotropyRotation),d.anisotropy*Math.sin(d.anisotropyRotation)),d.anisotropyMap&&(m.anisotropyMap.value=d.anisotropyMap,t(d.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=d.specularIntensity,m.specularColor.value.copy(d.specularColor),d.specularColorMap&&(m.specularColorMap.value=d.specularColorMap,t(d.specularColorMap,m.specularColorMapTransform)),d.specularIntensityMap&&(m.specularIntensityMap.value=d.specularIntensityMap,t(d.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,d){d.matcap&&(m.matcap.value=d.matcap)}function g(m,d){const x=e.get(d).light;m.referencePosition.value.setFromMatrixPosition(x.matrixWorld),m.nearDistance.value=x.shadow.camera.near,m.farDistance.value=x.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function vv(r,e,t,n){let i={},s={},o=[];const a=t.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(x,v){const y=v.program;n.uniformBlockBinding(x,y)}function c(x,v){let y=i[x.id];y===void 0&&(_(x),y=u(x),i[x.id]=y,x.addEventListener("dispose",m));const b=v.program;n.updateUBOMapping(x,b);const M=e.render.frame;s[x.id]!==M&&(h(x),s[x.id]=M)}function u(x){const v=f();x.__bindingPointIndex=v;const y=r.createBuffer(),b=x.__size,M=x.usage;return r.bindBuffer(r.UNIFORM_BUFFER,y),r.bufferData(r.UNIFORM_BUFFER,b,M),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,v,y),y}function f(){for(let x=0;x0){M=y%b;const O=b-M;M!==0&&O-A.boundary<0&&(y+=b-M,S.__offset=y)}y+=A.storage}return M=y%b,M>0&&(y+=b-M),x.__size=y,x.__cache={},this}function g(x){const v={boundary:0,storage:0};return typeof x=="number"?(v.boundary=4,v.storage=4):x.isVector2?(v.boundary=8,v.storage=8):x.isVector3||x.isColor?(v.boundary=16,v.storage=12):x.isVector4?(v.boundary=16,v.storage=16):x.isMatrix3?(v.boundary=48,v.storage=48):x.isMatrix4?(v.boundary=64,v.storage=64):x.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",x),v}function m(x){const v=x.target;v.removeEventListener("dispose",m);const y=o.indexOf(v.__bindingPointIndex);o.splice(y,1),r.deleteBuffer(i[v.id]),delete i[v.id],delete s[v.id]}function d(){for(const x in i)r.deleteBuffer(i[x]);o=[],i={},s={}}return{bind:l,update:c,dispose:d}}class Pf{constructor(e={}){const{canvas:t=mp(),context:n=null,depth:i=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let h;n!==null?h=n.getContextAttributes().alpha:h=o;const p=new Uint32Array(4),_=new Int32Array(4);let g=null,m=null;const d=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ht,this._useLegacyLights=!1,this.toneMapping=Yi,this.toneMappingExposure=1;const v=this;let y=!1,b=0,M=0,T=null,I=-1,S=null;const A=new mt,z=new mt;let O=null;const W=new tt(0);let D=0,V=t.width,Z=t.height,Q=1,ce=null,ie=null;const se=new mt(0,0,V,Z),me=new mt(0,0,V,Z);let ve=!1;const J=new nc;let oe=!1,Se=!1,De=null;const _e=new Ve,qe=new Ue,We=new C,Fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ye(){return T===null?Q:1}let X=n;function Lt(R,H){for(let j=0;j{function Ee(){if(K.forEach(function(Ie){Ke.get(Ie).currentProgram.isReady()&&K.delete(Ie)}),K.size===0){Y(R);return}setTimeout(Ee,10)}Ce.get("KHR_parallel_shader_compile")!==null?Ee():setTimeout(Ee,10)})};let nt=null;function gt(R){nt&&nt(R)}function Vt(){ft.stop()}function ht(){ft.start()}const ft=new wf;ft.setAnimationLoop(gt),typeof self<"u"&&ft.setContext(self),this.setAnimationLoop=function(R){nt=R,be.setAnimationLoop(R),R===null?ft.stop():ft.start()},be.addEventListener("sessionstart",Vt),be.addEventListener("sessionend",ht),this.render=function(R,H){if(H!==void 0&&H.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(y===!0)return;R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),H.parent===null&&H.matrixWorldAutoUpdate===!0&&H.updateMatrixWorld(),be.enabled===!0&&be.isPresenting===!0&&(be.cameraAutoUpdate===!0&&be.updateCamera(H),H=be.getCamera()),R.isScene===!0&&R.onBeforeRender(v,R,H,T),m=fe.get(R,x.length),m.init(),x.push(m),_e.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),J.setFromProjectionMatrix(_e),Se=this.localClippingEnabled,oe=Me.init(this.clippingPlanes,Se),g=re.get(R,d.length),g.init(),d.push(g),Sn(R,H,0,v.sortObjects),g.finish(),v.sortObjects===!0&&g.sort(ce,ie),this.info.render.frame++,oe===!0&&Me.beginShadows();const j=m.state.shadowsArray;if(pe.render(j,R,H),oe===!0&&Me.endShadows(),this.info.autoReset===!0&&this.info.reset(),ye.render(g,R),m.setupLights(v._useLegacyLights),H.isArrayCamera){const K=H.cameras;for(let Y=0,Ee=K.length;Y0?m=x[x.length-1]:m=null,d.pop(),d.length>0?g=d[d.length-1]:g=null};function Sn(R,H,j,K){if(R.visible===!1)return;if(R.layers.test(H.layers)){if(R.isGroup)j=R.renderOrder;else if(R.isLOD)R.autoUpdate===!0&&R.update(H);else if(R.isLight)m.pushLight(R),R.castShadow&&m.pushShadow(R);else if(R.isSprite){if(!R.frustumCulled||J.intersectsSprite(R)){K&&We.setFromMatrixPosition(R.matrixWorld).applyMatrix4(_e);const Ie=E.update(R),He=R.material;He.visible&&g.push(R,Ie,He,j,We.z,null)}}else if((R.isMesh||R.isLine||R.isPoints)&&(!R.frustumCulled||J.intersectsObject(R))){const Ie=E.update(R),He=R.material;if(K&&(R.boundingSphere!==void 0?(R.boundingSphere===null&&R.computeBoundingSphere(),We.copy(R.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),We.copy(Ie.boundingSphere.center)),We.applyMatrix4(R.matrixWorld).applyMatrix4(_e)),Array.isArray(He)){const Xe=Ie.groups;for(let et=0,je=Xe.length;et0&&ln(Y,Ee,H,j),K&&ze.viewport(A.copy(K)),Y.length>0&&Ii(Y,H,j),Ee.length>0&&Ii(Ee,H,j),Ie.length>0&&Ii(Ie,H,j),ze.buffers.depth.setTest(!0),ze.buffers.depth.setMask(!0),ze.buffers.color.setMask(!0),ze.setPolygonOffset(!1)}function ln(R,H,j,K){if((j.isScene===!0?j.overrideMaterial:null)!==null)return;const Ee=$e.isWebGL2;De===null&&(De=new Ki(1,1,{generateMipmaps:!0,type:Ce.has("EXT_color_buffer_half_float")?Qs:fi,minFilter:gr,samples:Ee?4:0})),v.getDrawingBufferSize(qe),Ee?De.setSize(qe.x,qe.y):De.setSize(da(qe.x),da(qe.y));const Ie=v.getRenderTarget();v.setRenderTarget(De),v.getClearColor(W),D=v.getClearAlpha(),D<1&&v.setClearColor(16777215,.5),v.clear();const He=v.toneMapping;v.toneMapping=Yi,Ii(R,j,K),ke.updateMultisampleRenderTarget(De),ke.updateRenderTargetMipmap(De);let Xe=!1;for(let et=0,je=H.length;et0),Ze=!!j.morphAttributes.position,xt=!!j.morphAttributes.normal,Gt=!!j.morphAttributes.color;let zt=Yi;K.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(zt=v.toneMapping);const cn=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,at=cn!==void 0?cn.length:0,Qe=Ke.get(K),Ji=m.state.lights;if(oe===!0&&(Se===!0||R!==S)){const te=R===S&&K.id===I;Me.setState(K,R,te)}let yt=!1;K.version===Qe.__version?(Qe.needsLights&&Qe.lightsStateVersion!==Ji.state.version||Qe.outputColorSpace!==He||Y.isBatchedMesh&&Qe.batching===!1||!Y.isBatchedMesh&&Qe.batching===!0||Y.isInstancedMesh&&Qe.instancing===!1||!Y.isInstancedMesh&&Qe.instancing===!0||Y.isSkinnedMesh&&Qe.skinning===!1||!Y.isSkinnedMesh&&Qe.skinning===!0||Y.isInstancedMesh&&Qe.instancingColor===!0&&Y.instanceColor===null||Y.isInstancedMesh&&Qe.instancingColor===!1&&Y.instanceColor!==null||Qe.envMap!==Xe||K.fog===!0&&Qe.fog!==Ee||Qe.numClippingPlanes!==void 0&&(Qe.numClippingPlanes!==Me.numPlanes||Qe.numIntersection!==Me.numIntersection)||Qe.vertexAlphas!==et||Qe.vertexTangents!==je||Qe.morphTargets!==Ze||Qe.morphNormals!==xt||Qe.morphColors!==Gt||Qe.toneMapping!==zt||$e.isWebGL2===!0&&Qe.morphTargetsCount!==at)&&(yt=!0):(yt=!0,Qe.__version=K.version);let Fn=Qe.currentProgram;yt===!0&&(Fn=ri(K,H,Y));let Er=!1,Qt=!1,nn=!1;const Wt=Fn.getUniforms(),w=Qe.uniforms;if(ze.useProgram(Fn.program)&&(Er=!0,Qt=!0,nn=!0),K.id!==I&&(I=K.id,Qt=!0),Er||S!==R){Wt.setValue(X,"projectionMatrix",R.projectionMatrix),Wt.setValue(X,"viewMatrix",R.matrixWorldInverse);const te=Wt.map.cameraPosition;te!==void 0&&te.setValue(X,We.setFromMatrixPosition(R.matrixWorld)),$e.logarithmicDepthBuffer&&Wt.setValue(X,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2)),(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial)&&Wt.setValue(X,"isOrthographic",R.isOrthographicCamera===!0),S!==R&&(S=R,Qt=!0,nn=!0)}if(Y.isSkinnedMesh){Wt.setOptional(X,Y,"bindMatrix"),Wt.setOptional(X,Y,"bindMatrixInverse");const te=Y.skeleton;te&&($e.floatVertexTextures?(te.boneTexture===null&&te.computeBoneTexture(),Wt.setValue(X,"boneTexture",te.boneTexture,ke)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Y.isBatchedMesh&&(Wt.setOptional(X,Y,"batchingTexture"),Wt.setValue(X,"batchingTexture",Y._matricesTexture,ke));const B=j.morphAttributes;if((B.position!==void 0||B.normal!==void 0||B.color!==void 0&&$e.isWebGL2===!0)&&N.update(Y,j,Fn),(Qt||Qe.receiveShadow!==Y.receiveShadow)&&(Qe.receiveShadow=Y.receiveShadow,Wt.setValue(X,"receiveShadow",Y.receiveShadow)),K.isMeshGouraudMaterial&&K.envMap!==null&&(w.envMap.value=Xe,w.flipEnvMap.value=Xe.isCubeTexture&&Xe.isRenderTargetTexture===!1?-1:1),Qt&&(Wt.setValue(X,"toneMappingExposure",v.toneMappingExposure),Qe.needsLights&&Ni(w,nn),Ee&&K.fog===!0&&le.refreshFogUniforms(w,Ee),le.refreshMaterialUniforms(w,K,Q,Z,De),oa.upload(X,br(Qe),w,ke)),K.isShaderMaterial&&K.uniformsNeedUpdate===!0&&(oa.upload(X,br(Qe),w,ke),K.uniformsNeedUpdate=!1),K.isSpriteMaterial&&Wt.setValue(X,"center",Y.center),Wt.setValue(X,"modelViewMatrix",Y.modelViewMatrix),Wt.setValue(X,"normalMatrix",Y.normalMatrix),Wt.setValue(X,"modelMatrix",Y.matrixWorld),K.isShaderMaterial||K.isRawShaderMaterial){const te=K.uniformsGroups;for(let G=0,ue=te.length;G0&&ke.useMultisampledRTT(R)===!1?Y=Ke.get(R).__webglMultisampledFramebuffer:Array.isArray(je)?Y=je[j]:Y=je,A.copy(R.viewport),z.copy(R.scissor),O=R.scissorTest}else A.copy(se).multiplyScalar(Q).floor(),z.copy(me).multiplyScalar(Q).floor(),O=ve;if(ze.bindFramebuffer(X.FRAMEBUFFER,Y)&&$e.drawBuffers&&K&&ze.drawBuffers(R,Y),ze.viewport(A),ze.scissor(z),ze.setScissorTest(O),Ee){const Xe=Ke.get(R.texture);X.framebufferTexture2D(X.FRAMEBUFFER,X.COLOR_ATTACHMENT0,X.TEXTURE_CUBE_MAP_POSITIVE_X+H,Xe.__webglTexture,j)}else if(Ie){const Xe=Ke.get(R.texture),et=H||0;X.framebufferTextureLayer(X.FRAMEBUFFER,X.COLOR_ATTACHMENT0,Xe.__webglTexture,j||0,et)}I=-1},this.readRenderTargetPixels=function(R,H,j,K,Y,Ee,Ie){if(!(R&&R.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let He=Ke.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He){ze.bindFramebuffer(X.FRAMEBUFFER,He);try{const Xe=R.texture,et=Xe.format,je=Xe.type;if(et!==sn&&Oe.convert(et)!==X.getParameter(X.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ze=je===Qs&&(Ce.has("EXT_color_buffer_half_float")||$e.isWebGL2&&Ce.has("EXT_color_buffer_float"));if(je!==fi&&Oe.convert(je)!==X.getParameter(X.IMPLEMENTATION_COLOR_READ_TYPE)&&!(je===vn&&($e.isWebGL2||Ce.has("OES_texture_float")||Ce.has("WEBGL_color_buffer_float")))&&!Ze){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H>=0&&H<=R.width-K&&j>=0&&j<=R.height-Y&&X.readPixels(H,j,K,Y,Oe.convert(et),Oe.convert(je),Ee)}finally{const Xe=T!==null?Ke.get(T).__webglFramebuffer:null;ze.bindFramebuffer(X.FRAMEBUFFER,Xe)}}},this.copyFramebufferToTexture=function(R,H,j=0){const K=Math.pow(2,-j),Y=Math.floor(H.image.width*K),Ee=Math.floor(H.image.height*K);ke.setTexture2D(H,0),X.copyTexSubImage2D(X.TEXTURE_2D,j,0,0,R.x,R.y,Y,Ee),ze.unbindTexture()},this.copyTextureToTexture=function(R,H,j,K=0){const Y=H.image.width,Ee=H.image.height,Ie=Oe.convert(j.format),He=Oe.convert(j.type);ke.setTexture2D(j,0),X.pixelStorei(X.UNPACK_FLIP_Y_WEBGL,j.flipY),X.pixelStorei(X.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),X.pixelStorei(X.UNPACK_ALIGNMENT,j.unpackAlignment),H.isDataTexture?X.texSubImage2D(X.TEXTURE_2D,K,R.x,R.y,Y,Ee,Ie,He,H.image.data):H.isCompressedTexture?X.compressedTexSubImage2D(X.TEXTURE_2D,K,R.x,R.y,H.mipmaps[0].width,H.mipmaps[0].height,Ie,H.mipmaps[0].data):X.texSubImage2D(X.TEXTURE_2D,K,R.x,R.y,Ie,He,H.image),K===0&&j.generateMipmaps&&X.generateMipmap(X.TEXTURE_2D),ze.unbindTexture()},this.copyTextureToTexture3D=function(R,H,j,K,Y=0){if(v.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ee=R.max.x-R.min.x+1,Ie=R.max.y-R.min.y+1,He=R.max.z-R.min.z+1,Xe=Oe.convert(K.format),et=Oe.convert(K.type);let je;if(K.isData3DTexture)ke.setTexture3D(K,0),je=X.TEXTURE_3D;else if(K.isDataArrayTexture)ke.setTexture2DArray(K,0),je=X.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}X.pixelStorei(X.UNPACK_FLIP_Y_WEBGL,K.flipY),X.pixelStorei(X.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),X.pixelStorei(X.UNPACK_ALIGNMENT,K.unpackAlignment);const Ze=X.getParameter(X.UNPACK_ROW_LENGTH),xt=X.getParameter(X.UNPACK_IMAGE_HEIGHT),Gt=X.getParameter(X.UNPACK_SKIP_PIXELS),zt=X.getParameter(X.UNPACK_SKIP_ROWS),cn=X.getParameter(X.UNPACK_SKIP_IMAGES),at=j.isCompressedTexture?j.mipmaps[0]:j.image;X.pixelStorei(X.UNPACK_ROW_LENGTH,at.width),X.pixelStorei(X.UNPACK_IMAGE_HEIGHT,at.height),X.pixelStorei(X.UNPACK_SKIP_PIXELS,R.min.x),X.pixelStorei(X.UNPACK_SKIP_ROWS,R.min.y),X.pixelStorei(X.UNPACK_SKIP_IMAGES,R.min.z),j.isDataTexture||j.isData3DTexture?X.texSubImage3D(je,Y,H.x,H.y,H.z,Ee,Ie,He,Xe,et,at.data):j.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),X.compressedTexSubImage3D(je,Y,H.x,H.y,H.z,Ee,Ie,He,Xe,at.data)):X.texSubImage3D(je,Y,H.x,H.y,H.z,Ee,Ie,He,Xe,et,at),X.pixelStorei(X.UNPACK_ROW_LENGTH,Ze),X.pixelStorei(X.UNPACK_IMAGE_HEIGHT,xt),X.pixelStorei(X.UNPACK_SKIP_PIXELS,Gt),X.pixelStorei(X.UNPACK_SKIP_ROWS,zt),X.pixelStorei(X.UNPACK_SKIP_IMAGES,cn),Y===0&&K.generateMipmaps&&X.generateMipmap(je),ze.unbindTexture()},this.initTexture=function(R){R.isCubeTexture?ke.setTextureCube(R,0):R.isData3DTexture?ke.setTexture3D(R,0):R.isDataArrayTexture||R.isCompressedArrayTexture?ke.setTexture2DArray(R,0):ke.setTexture2D(R,0),ze.unbindTexture()},this.resetState=function(){b=0,M=0,T=null,ze.reset(),Re.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ai}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===ec?"display-p3":"srgb",t.unpackColorSpace=pt.workingColorSpace===ya?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Ht?$i:cf}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===$i?Ht:an}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class xv extends Pf{}xv.prototype.isWebGL1Renderer=!0;class yv extends Bt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,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()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class bv{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Il,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Qn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}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;il)continue;h.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(h);Ie.far||t.push({distance:I,point:f.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{const d=Math.max(0,o.start),x=Math.min(m.count,o.start+o.count);for(let v=d,y=x-1;vl)continue;h.applyMatrix4(this.matrixWorld);const M=e.ray.origin.distanceTo(h);Me.far||t.push({distance:M,point:f.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;si.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class lc extends di{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new tt(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 tt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=uf,this.normalScale=new Ue(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}}class Di extends lc{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ue(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return tn(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 tt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new tt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new tt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=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 sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=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.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,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}}function Uo(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function Cv(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Pv(r){function e(i,s){return r[i]-r[s]}const t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function lh(r,e,t){const n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){const a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i}function Ff(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)}class lo{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){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let o;t:{i:if(!(e=s)){const a=t[1];e=s)break e}o=n,n=0;break t}break n}for(;n>>1;et;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const 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++){const 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&&Cv(i))for(let a=0,l=i.length;a!==l;++a){const 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(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Na,s=e.length-1;let o=1;for(let a=1;a0){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=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}_i.prototype.TimeBufferType=Float32Array;_i.prototype.ValueBufferType=Float32Array;_i.prototype.DefaultInterpolation=fs;class xs extends _i{}xs.prototype.ValueTypeName="bool";xs.prototype.ValueBufferType=Array;xs.prototype.DefaultInterpolation=eo;xs.prototype.InterpolantFactoryMethodLinear=void 0;xs.prototype.InterpolantFactoryMethodSmooth=void 0;class Of extends _i{}Of.prototype.ValueTypeName="color";class ms extends _i{}ms.prototype.ValueTypeName="number";class Fv extends lo{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t);let c=e*a;for(let u=c+a;c!==u;c+=4)mi.slerpFlat(s,0,o,c-a,o,c,l);return s}}class vr extends _i{InterpolantFactoryMethodLinear(e){return new Fv(this.times,this.values,this.getValueSize(),e)}}vr.prototype.ValueTypeName="quaternion";vr.prototype.DefaultInterpolation=fs;vr.prototype.InterpolantFactoryMethodSmooth=void 0;class ys extends _i{}ys.prototype.ValueTypeName="string";ys.prototype.ValueBufferType=Array;ys.prototype.DefaultInterpolation=eo;ys.prototype.InterpolantFactoryMethodLinear=void 0;ys.prototype.InterpolantFactoryMethodSmooth=void 0;class _s extends _i{}_s.prototype.ValueTypeName="vector";class Ov{constructor(e,t=-1,n,i=Gd){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Qn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(Bv(n[o]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(_i.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const s=t.length,o=[];for(let a=0;a1){const f=u[1];let h=i[f];h||(i[f]=h=[]),h.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(f,h,p,_,g){if(p.length!==0){const m=[],d=[];Ff(p,m,d,_),m.length!==0&&g.push(new f(h,m,d))}},i=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let f=0;f{t&&t(s),this.manager.itemEnd(e)},0),s;if(wi[e]!==void 0){wi[e].push({onLoad:t,onProgress:n,onError:i});return}wi[e]=[],wi[e].push({onLoad:t,onProgress:n,onError:i});const 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;const u=wi[e],f=c.body.getReader(),h=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),p=h?parseInt(h):0,_=p!==0;let g=0;const m=new ReadableStream({start(d){x();function x(){f.read().then(({done:v,value:y})=>{if(v)d.close();else{g+=y.byteLength;const b=new ProgressEvent("progress",{lengthComputable:_,loaded:g,total:p});for(let M=0,T=u.length;M{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const f=/charset="?([^;"\s]*)"?/i.exec(a),h=f&&f[1]?f[1].toLowerCase():void 0,p=new TextDecoder(h);return c.arrayBuffer().then(_=>p.decode(_))}}}).then(c=>{gs.add(e,c);const u=wi[e];delete wi[e];for(let f=0,h=u.length;f{const u=wi[e];if(u===void 0)throw this.manager.itemError(e),c;delete wi[e];for(let f=0,h=u.length;f{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Vv extends bs{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=gs.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=to("img");function l(){u(),gs.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(f){u(),i&&i(f),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class Gv extends bs{constructor(e){super(e)}load(e,t,n,i){const s=new on,o=new Vv(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},n,i),s}}class Ea extends Bt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new tt(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){const 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}}const al=new Ve,ch=new C,uh=new C;class cc{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ue(512,512),this.map=null,this.mapPass=null,this.matrix=new Ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new nc,this._frameExtents=new Ue(1,1),this._viewportCount=1,this._viewports=[new mt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;ch.setFromMatrixPosition(e.matrixWorld),t.position.copy(ch),uh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(uh),t.updateMatrixWorld(),al.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(al),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(al)}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(){const 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}}class Wv extends cc{constructor(){super(new _n(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=ds*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}}class Xv extends Ea{constructor(e,t,n=0,i=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Bt.DEFAULT_UP),this.updateMatrix(),this.target=new Bt,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Wv}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}}const hh=new Ve,Ds=new C,ll=new C;class qv extends cc{constructor(){super(new _n(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ue(4,2),this._viewportCount=6,this._viewports=[new mt(2,1,1,1),new mt(0,1,1,1),new mt(3,1,1,1),new mt(1,1,1,1),new mt(3,0,1,1),new mt(1,0,1,1)],this._cubeDirections=[new C(1,0,0),new C(-1,0,0),new C(0,0,1),new C(0,0,-1),new C(0,1,0),new C(0,-1,0)],this._cubeUps=[new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,0,1),new C(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Ds.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ds),ll.copy(n.position),ll.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(ll),n.updateMatrixWorld(),i.makeTranslation(-Ds.x,-Ds.y,-Ds.z),hh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hh)}}class jv extends Ea{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new qv}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}}class Yv extends cc{constructor(){super(new ao(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Bf extends Ea{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Bt.DEFAULT_UP),this.updateMatrix(),this.target=new Bt,this.shadow=new Yv}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class $v extends Ea{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ys{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=gs.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){gs.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){i&&i(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}const uc="\\[\\]\\.:\\/",Zv=new RegExp("["+uc+"]","g"),hc="[^"+uc+"]",Qv="[^"+uc.replace("\\.","")+"]",Jv=/((?:WC+[\/:])*)/.source.replace("WC",hc),ex=/(WCOD+)?/.source.replace("WCOD",Qv),tx=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",hc),nx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",hc),ix=new RegExp("^"+Jv+ex+tx+nx+"$"),rx=["material","materials","bones","map"];class sx{constructor(e,t,n){const i=n||vt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class vt{constructor(e,t,n){this.path=t,this.parsedPath=n||vt.parseTrackName(t),this.node=vt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new vt.Composite(e,t,n):new vt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Zv,"")}static parseTrackName(e){const t=ix.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const 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){const s=n.nodeName.substring(i+1);rx.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){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(s){for(let o=0;oMath.PI&&(ge-=we),ae<-Math.PI?ae+=we:ae>Math.PI&&(ae-=we),ge<=ae?a.theta=Math.max(ge,Math.min(ae,a.theta)):a.theta=a.theta>(ge+ae)/2?Math.max(ge,a.theta):Math.min(ae,a.theta)),a.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,a.phi)),a.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(u,n.dampingFactor):n.target.add(u),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&M||n.object.isOrthographicCamera?a.radius=ie(a.radius):a.radius=ie(a.radius*c),N.setFromSpherical(a),N.applyQuaternion(ne),F.copy(n.target).add(N),n.object.lookAt(n.target),n.enableDamping===!0?(l.theta*=1-n.dampingFactor,l.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(l.set(0,0,0),u.set(0,0,0));let ee=!1;if(n.zoomToCursor&&M){let he=null;if(n.object.isPerspectiveCamera){const Le=N.length();he=ie(Le*c);const nt=Le-he;n.object.position.addScaledVector(y,nt),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const Le=new C(b.x,b.y,0);Le.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/c)),n.object.updateProjectionMatrix(),ee=!0;const nt=new C(b.x,b.y,0);nt.unproject(n.object),n.object.position.sub(nt).add(Le),n.object.updateMatrixWorld(),he=N.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;he!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(he).add(n.object.position):(zo.origin.copy(n.object.position),zo.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(zo.direction))o||8*(1-Re.dot(n.object.quaternion))>o||Pe.distanceToSquared(n.target)>0?(n.dispatchEvent(ph),Oe.copy(n.object.position),Re.copy(n.object.quaternion),Pe.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",re),n.domElement.removeEventListener("pointerdown",Ke),n.domElement.removeEventListener("pointercancel",ot),n.domElement.removeEventListener("wheel",P),n.domElement.removeEventListener("pointermove",ke),n.domElement.removeEventListener("pointerup",ot),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener("keydown",E),n._domElementKeyEvents=null)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const o=1e-6,a=new fh,l=new fh;let c=1;const u=new C,f=new Ue,h=new Ue,p=new Ue,_=new Ue,g=new Ue,m=new Ue,d=new Ue,x=new Ue,v=new Ue,y=new C,b=new Ue;let M=!1;const T=[],I={};function S(N){return N!==null?2*Math.PI/60*n.autoRotateSpeed*N:2*Math.PI/60/60*n.autoRotateSpeed}function A(){return Math.pow(.95,n.zoomSpeed)}function z(N){l.theta-=N}function O(N){l.phi-=N}const W=function(){const N=new C;return function(ne,Oe){N.setFromMatrixColumn(Oe,0),N.multiplyScalar(-ne),u.add(N)}}(),D=function(){const N=new C;return function(ne,Oe){n.screenSpacePanning===!0?N.setFromMatrixColumn(Oe,1):(N.setFromMatrixColumn(Oe,0),N.crossVectors(n.object.up,N)),N.multiplyScalar(ne),u.add(N)}}(),V=function(){const N=new C;return function(ne,Oe){const Re=n.domElement;if(n.object.isPerspectiveCamera){const Pe=n.object.position;N.copy(Pe).sub(n.target);let we=N.length();we*=Math.tan(n.object.fov/2*Math.PI/180),W(2*ne*we/Re.clientHeight,n.object.matrix),D(2*Oe*we/Re.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(W(ne*(n.object.right-n.object.left)/n.object.zoom/Re.clientWidth,n.object.matrix),D(Oe*(n.object.top-n.object.bottom)/n.object.zoom/Re.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function Z(N){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c/=N:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function Q(N){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c*=N:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ce(N){if(!n.zoomToCursor)return;M=!0;const de=n.domElement.getBoundingClientRect(),ne=N.clientX-de.left,Oe=N.clientY-de.top,Re=de.width,Pe=de.height;b.x=ne/Re*2-1,b.y=-(Oe/Pe)*2+1,y.set(b.x,b.y,1).unproject(n.object).sub(n.object.position).normalize()}function ie(N){return Math.max(n.minDistance,Math.min(n.maxDistance,N))}function se(N){f.set(N.clientX,N.clientY)}function me(N){ce(N),d.set(N.clientX,N.clientY)}function ve(N){_.set(N.clientX,N.clientY)}function J(N){h.set(N.clientX,N.clientY),p.subVectors(h,f).multiplyScalar(n.rotateSpeed);const de=n.domElement;z(2*Math.PI*p.x/de.clientHeight),O(2*Math.PI*p.y/de.clientHeight),f.copy(h),n.update()}function oe(N){x.set(N.clientX,N.clientY),v.subVectors(x,d),v.y>0?Z(A()):v.y<0&&Q(A()),d.copy(x),n.update()}function Se(N){g.set(N.clientX,N.clientY),m.subVectors(g,_).multiplyScalar(n.panSpeed),V(m.x,m.y),_.copy(g),n.update()}function De(N){ce(N),N.deltaY<0?Q(A()):N.deltaY>0&&Z(A()),n.update()}function _e(N){let de=!1;switch(N.code){case n.keys.UP:N.ctrlKey||N.metaKey||N.shiftKey?O(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(0,n.keyPanSpeed),de=!0;break;case n.keys.BOTTOM:N.ctrlKey||N.metaKey||N.shiftKey?O(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(0,-n.keyPanSpeed),de=!0;break;case n.keys.LEFT:N.ctrlKey||N.metaKey||N.shiftKey?z(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(n.keyPanSpeed,0),de=!0;break;case n.keys.RIGHT:N.ctrlKey||N.metaKey||N.shiftKey?z(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):V(-n.keyPanSpeed,0),de=!0;break}de&&(N.preventDefault(),n.update())}function qe(){if(T.length===1)f.set(T[0].pageX,T[0].pageY);else{const N=.5*(T[0].pageX+T[1].pageX),de=.5*(T[0].pageY+T[1].pageY);f.set(N,de)}}function We(){if(T.length===1)_.set(T[0].pageX,T[0].pageY);else{const N=.5*(T[0].pageX+T[1].pageX),de=.5*(T[0].pageY+T[1].pageY);_.set(N,de)}}function Fe(){const N=T[0].pageX-T[1].pageX,de=T[0].pageY-T[1].pageY,ne=Math.sqrt(N*N+de*de);d.set(0,ne)}function Ye(){n.enableZoom&&Fe(),n.enablePan&&We()}function X(){n.enableZoom&&Fe(),n.enableRotate&&qe()}function Lt(N){if(T.length==1)h.set(N.pageX,N.pageY);else{const ne=ye(N),Oe=.5*(N.pageX+ne.x),Re=.5*(N.pageY+ne.y);h.set(Oe,Re)}p.subVectors(h,f).multiplyScalar(n.rotateSpeed);const de=n.domElement;z(2*Math.PI*p.x/de.clientHeight),O(2*Math.PI*p.y/de.clientHeight),f.copy(h)}function Ce(N){if(T.length===1)g.set(N.pageX,N.pageY);else{const de=ye(N),ne=.5*(N.pageX+de.x),Oe=.5*(N.pageY+de.y);g.set(ne,Oe)}m.subVectors(g,_).multiplyScalar(n.panSpeed),V(m.x,m.y),_.copy(g)}function $e(N){const de=ye(N),ne=N.pageX-de.x,Oe=N.pageY-de.y,Re=Math.sqrt(ne*ne+Oe*Oe);x.set(0,Re),v.set(0,Math.pow(x.y/d.y,n.zoomSpeed)),Z(v.y),d.copy(x)}function ze(N){n.enableZoom&&$e(N),n.enablePan&&Ce(N)}function _t(N){n.enableZoom&&$e(N),n.enableRotate&&Lt(N)}function Ke(N){n.enabled!==!1&&(T.length===0&&(n.domElement.setPointerCapture(N.pointerId),n.domElement.addEventListener("pointermove",ke),n.domElement.addEventListener("pointerup",ot)),fe(N),N.pointerType==="touch"?q(N):Tt(N))}function ke(N){n.enabled!==!1&&(N.pointerType==="touch"?le(N):Ct(N))}function ot(N){Me(N),T.length===0&&(n.domElement.releasePointerCapture(N.pointerId),n.domElement.removeEventListener("pointermove",ke),n.domElement.removeEventListener("pointerup",ot)),n.dispatchEvent(mh),s=i.NONE}function Tt(N){let de;switch(N.button){case 0:de=n.mouseButtons.LEFT;break;case 1:de=n.mouseButtons.MIDDLE;break;case 2:de=n.mouseButtons.RIGHT;break;default:de=-1}switch(de){case Mr.DOLLY:if(n.enableZoom===!1)return;me(N),s=i.DOLLY;break;case Mr.ROTATE:if(N.ctrlKey||N.metaKey||N.shiftKey){if(n.enablePan===!1)return;ve(N),s=i.PAN}else{if(n.enableRotate===!1)return;se(N),s=i.ROTATE}break;case Mr.PAN:if(N.ctrlKey||N.metaKey||N.shiftKey){if(n.enableRotate===!1)return;se(N),s=i.ROTATE}else{if(n.enablePan===!1)return;ve(N),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(cl)}function Ct(N){switch(s){case i.ROTATE:if(n.enableRotate===!1)return;J(N);break;case i.DOLLY:if(n.enableZoom===!1)return;oe(N);break;case i.PAN:if(n.enablePan===!1)return;Se(N);break}}function P(N){n.enabled===!1||n.enableZoom===!1||s!==i.NONE||(N.preventDefault(),n.dispatchEvent(cl),De(N),n.dispatchEvent(mh))}function E(N){n.enabled===!1||n.enablePan===!1||_e(N)}function q(N){switch(pe(N),T.length){case 1:switch(n.touches.ONE){case Tr.ROTATE:if(n.enableRotate===!1)return;qe(),s=i.TOUCH_ROTATE;break;case Tr.PAN:if(n.enablePan===!1)return;We(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(n.touches.TWO){case Tr.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ye(),s=i.TOUCH_DOLLY_PAN;break;case Tr.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;X(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&n.dispatchEvent(cl)}function le(N){switch(pe(N),s){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;Lt(N),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;Ce(N),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ze(N),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;_t(N),n.update();break;default:s=i.NONE}}function re(N){n.enabled!==!1&&N.preventDefault()}function fe(N){T.push(N)}function Me(N){delete I[N.pointerId];for(let de=0;de=2.0 are supported."));return}const c=new Gx(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function fx(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const lt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class dx{constructor(e){this.parser=e,this.name=lt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class Tx{constructor(e){this.parser=e,this.name=lt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ax{constructor(e){this.parser=e,this.name=lt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Rx{constructor(e){this.name=lt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,u=i.count,f=i.byteStride,h=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,f,h,i.mode,i.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(u*f);return o.decodeGltfBuffer(new Uint8Array(p),u,f,h,i.mode,i.filter),p})})}else return null}}class Lx{constructor(e){this.name=lt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==kn.TRIANGLES&&c.mode!==kn.TRIANGLE_STRIP&&c.mode!==kn.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(l[c]=u,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const u=c.pop(),f=u.isGroup?u.children:[u],h=c[0].count,p=[];for(const _ of f){const g=new Ve,m=new C,d=new mi,x=new C(1,1,1),v=new Tv(_.geometry,_.material,h);for(let y=0;y0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Vx=new Ve;class Gx{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new fx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,s=-1;typeof navigator<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||i&&s<98?this.textureLoader=new Gv(this.options.manager):this.textureLoader=new Kv(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Uf(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return sr(s,a,i),Gi(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,u]of o.children.entries())s(u,a.children[c])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&m.setY(S,M[T*l+1]),l>=3&&m.setZ(S,M[T*l+2]),l>=4&&m.setW(S,M[T*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const h=(s.samplers||{})[o.sampler]||{};return u.magFilter=yh[h.magFilter]||En,u.minFilter=yh[h.minFilter]||gr,u.wrapS=bh[h.wrapS]||us,u.wrapT=bh[h.wrapT]||us,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(f){c=!0;const h=new Blob([f],{type:o.mimeType});return l=a.createObjectURL(h),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(f){return new Promise(function(h,p){let _=h;t.isImageBitmapLoader===!0&&(_=function(g){const m=new on(g);m.needsUpdate=!0,h(m)}),t.load(Ys.resolveURL(f,s.path),_,void 0,p)})}).then(function(f){return c===!0&&a.revokeObjectURL(l),f.userData.mimeType=o.mimeType||Hx(o.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),f});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[lt.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[lt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[lt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new Nf,di.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new If,di.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return lc}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[lt.KHR_MATERIALS_UNLIT]){const f=i[lt.KHR_MATERIALS_UNLIT];o=f.getMaterialType(),c.push(f.extendParams(a,s,t))}else{const f=s.pbrMetallicRoughness||{};if(a.color=new tt(1,1,1),a.opacity=1,Array.isArray(f.baseColorFactor)){const h=f.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],an),a.opacity=h[3]}f.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",f.baseColorTexture,Ht)),a.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,a.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",f.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",f.metallicRoughnessTexture))),o=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Zn);const u=s.alphaMode||hl.OPAQUE;if(u===hl.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===hl.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Ri&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Ue(1,1),s.normalTexture.scale!==void 0)){const f=s.normalTexture.scale;a.normalScale.set(f,f)}if(s.occlusionTexture!==void 0&&o!==Ri&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Ri){const f=s.emissiveFactor;a.emissive=new tt().setRGB(f[0],f[1],f[2],an)}return s.emissiveTexture!==void 0&&o!==Ri&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,Ht)),Promise.all(c).then(function(){const f=new o(a);return s.name&&(f.name=s.name),Gi(f,s),t.associations.set(f,{materials:e}),s.extensions&&sr(i,f,s),f})}createUniqueName(e){const t=vt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[lt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Sh(l,a,t)})}const o=[];for(let a=0,l=e.length;a0&&zx(d,s),d.name=t.createUniqueName(s.name||"mesh_"+e),Gi(d,s),m.extensions&&sr(i,d,m),t.assignFinalMaterial(d),f.push(d)}for(let p=0,_=f.length;p<_;p++)t.associations.set(f[p],{meshes:e,primitives:p});if(f.length===1)return s.extensions&&sr(i,f[0],s),f[0];const h=new dr;s.extensions&&sr(i,h,s),t.associations.set(h,{meshes:e});for(let p=0,_=f.length;p<_;p++)h.add(f[p]);return h})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new _n(ff.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new ao(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Gi(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i1?u=new dr:c.length===1?u=c[0]:u=new Bt,u!==c[0])for(let f=0,h=c.length;f{const f=new Map;for(const[h,p]of i.associations)(h instanceof di||h instanceof on)&&f.set(h,p);return u.traverse(h=>{const p=i.associations.get(h);p!=null&&f.set(h,p)}),f};return i.associations=c(s),s})}_createAnimationTracks(e,t,n,i,s){const o=[],a=e.name?e.name:e.uuid,l=[];ki[s.path]===ki.weights?e.traverse(function(h){h.morphTargetInfluences&&l.push(h.name?h.name:h.uuid)}):l.push(a);let c;switch(ki[s.path]){case ki.weights:c=ms;break;case ki.rotation:c=vr;break;case ki.position:case ki.scale:c=_s;break;default:switch(n.itemSize){case 1:c=ms;break;case 2:case 3:default:c=_s;break}break}const u=i.interpolation!==void 0?Ox[i.interpolation]:fs,f=this._getArrayFromAccessor(n);for(let h=0,p=l.length;hl+1e3&&(u.update(1e3*c/(p-l),100),l=p,c=0,h)){var _=performance.memory;h.update(_.usedJSHeapSize/1048576,_.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,s){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),u=80*c,f=48*c,h=3*c,p=2*c,_=3*c,g=15*c,m=74*c,d=30*c,x=document.createElement("canvas");x.width=u,x.height=f,x.style.cssText="width:80px;height:48px";var v=x.getContext("2d");return v.font="bold "+9*c+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=s,v.fillRect(0,0,u,f),v.fillStyle=i,v.fillText(n,h,p),v.fillRect(_,g,m,d),v.fillStyle=s,v.globalAlpha=.9,v.fillRect(_,g,m,d),{dom:x,update:function(y,b){o=Math.min(o,y),a=Math.max(a,y),v.fillStyle=s,v.globalAlpha=1,v.fillRect(0,0,u,g),v.fillStyle=i,v.fillText(l(y)+" "+n+" ("+l(o)+"-"+l(a)+")",h,p),v.drawImage(x,_+c,g,m-c,d,_,g,m-c,d),v.fillRect(_+m-c,g,c,d),v.fillStyle=s,v.globalAlpha=.9,v.fillRect(_+m-c,g,c,l((1-y/b)*d))}}},t})})(Hf);var qx=Hf.exports;const jx=Xx(qx),Vf=0,Yx=1,Gf=2,Eh=2,dl=1.25,wh=1,_r=6*4+4+4,wa=65535,$x=Math.pow(2,-24),pl=Symbol("SKIP_GENERATION");function Wf(r){return r.index?r.index.count:r.attributes.position.count}function Ss(r){return Wf(r)/3}function Xf(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Kx(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Xf(t,n);r.setIndex(new Yt(i,1));for(let s=0;sa-l);for(let a=0;as.offset-o.offset),n=t[t.length-1];n.count=Math.min(e-n.offset,n.count);let i=0;return t.forEach(({count:s})=>i+=s),e!==i}function Ut(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Qx(r){r[0]=r[1]=r[2]=1/0,r[3]=r[4]=r[5]=-1/0}function Mh(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Th(r,e){e.set(r)}function Ah(r,e,t){let n,i;for(let s=0;s<3;s++){const o=s+3;n=r[s],i=e[s],t[s]=ni?n:i}}function ko(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;ot[n+3]&&(t[n+3]=a)}}function Ns(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function ml(r,e,t,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,f=1/0,h=1/0,p=1/0,_=-1/0,g=-1/0,m=-1/0;const d=i!==null;for(let x=e*6,v=(e+t)*6;xl&&(l=T),d&&y_&&(_=y);const I=r[x+2],S=r[x+3],A=I-S,z=I+S;Ac&&(c=z),d&&Ig&&(g=I);const O=r[x+4],W=r[x+5],D=O-W,V=O+W;Du&&(u=V),d&&Om&&(m=O)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=c,n[5]=u,d&&(i[0]=f,i[1]=h,i[2]=p,i[3]=_,i[4]=g,i[5]=m)}function Jx(r,e,t,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=e*6,f=(e+t)*6;ua&&(a=h);const p=r[u+2];pl&&(l=p);const _=r[u+4];_c&&(c=_)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=c}function ey(r,e){Qx(e);const t=r.attributes.position,n=r.index?r.index.array:null,i=Ss(r),s=new Float32Array(i*6),o=t.normalized,a=t.array,l=t.offset||0;let c=3;t.isInterleavedBufferAttribute&&(c=t.data.stride);const u=["getX","getY","getZ"];for(let f=0;fM&&(M=v),y>M&&(M=y);const T=(M-b)/2,I=d*2;s[p+I+0]=b+T,s[p+I+1]=T+(Math.abs(b)+T)*$x,be[d+3]&&(e[d+3]=M)}}return s}const Ti=32,ty=(r,e)=>r.candidate-e.candidate,Hi=new Array(Ti).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ho=new Float32Array(6);function ny(r,e,t,n,i,s){let o=-1,a=0;if(s===Vf)o=Mh(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===Yx)o=Mh(r),o!==-1&&(a=iy(t,n,i,o));else if(s===Gf){const l=Ns(r);let c=dl*i;const u=n*6,f=(n+i)*6;for(let h=0;h<3;h++){const p=e[h],m=(e[h+3]-p)/Ti;if(i=T.candidate?ko(y,t,T.rightCacheBounds):(ko(y,t,T.leftCacheBounds),T.count++)}}for(let y=0;y=Ti&&(M=Ti-1);const T=Hi[M];T.count++,ko(v,t,T.bounds)}const d=Hi[Ti-1];Th(d.bounds,d.rightCacheBounds);for(let v=Ti-2;v>=0;v--){const y=Hi[v],b=Hi[v+1];Ah(y.bounds,b.rightCacheBounds,y.rightCacheBounds)}let x=0;for(let v=0;v=l;)a--;if(o=l;)a--;if(o2**16,i=n?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),o=n?new Uint32Array(s):new Uint16Array(s);for(let a=0,l=o.length;a=i&&(f=!0,s&&(console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`),console.warn(t))),M<=o||I>=i)return x(b+M),y.offset=b,y.count=M,y;const S=ny(y.boundingData,T,_,b,M,a);if(S.axis===-1)return x(b+M),y.offset=b,y.count=M,y;const A=g(u,n,_,b,M,S);if(A===b||A===b+M)x(b+M),y.offset=b,y.count=M;else{y.splitAxis=S.axis;const z=new Vo,O=b,W=A-b;y.left=z,z.boundingData=new Float32Array(6),ml(_,O,W,z.boundingData,p),v(z,O,W,p,I+1);const D=new Vo,V=A,Z=M-W;y.right=D,D.boundingData=new Float32Array(6),ml(_,V,Z,D.boundingData,p),v(D,V,Z,p,I+1)}return y}}function ly(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=oy(t,e.useSharedArrayBuffer),Zx(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||Kx(t,e);const n=ay(r,e);let i,s,o;const a=[],l=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let f=0;fMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[p+6]=y/4,y=u(y,x),s[p+7]=v,y}}}class Pi{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;si?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;si?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}Pi.prototype.setFromBox=function(){const r=new C;return function(t,n){const i=n.min,s=n.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){r.x=i.x*l+s.x*(1-l),r.y=i.y*c+s.y*(1-c),r.z=i.z*u+s.z*(1-u);const f=t.dot(r);o=Math.min(f,o),a=Math.max(f,a)}this.min=o,this.max=a}}();const cy=function(){const r=new C,e=new C,t=new C;return function(i,s,o){const a=i.start,l=r,c=s.start,u=e;t.subVectors(a,c),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const f=t.dot(u),h=u.dot(l),p=u.dot(u),_=t.dot(l),m=l.dot(l)*p-h*h;let d,x;m!==0?d=(f*h-_*p)/m:d=0,x=(f+d*h)/p,o.x=d,o.y=x}}(),fc=function(){const r=new Ue,e=new C,t=new C;return function(i,s,o,a){cy(i,s,r);let l=r.x,c=r.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let u;l<0?u=i.start:u=i.end;let f;c<0?f=s.start:f=s.end;const h=e,p=t;if(i.closestPointToPoint(f,!0,e),s.closestPointToPoint(u,!0,t),h.distanceToSquared(f)<=p.distanceToSquared(u)){o.copy(h),a.copy(f);return}else{o.copy(u),a.copy(p);return}}}}(),uy=function(){const r=new C,e=new C,t=new ci,n=new Ci;return function(s,o){const{radius:a,center:l}=s,{a:c,b:u,c:f}=o;if(n.start=c,n.end=u,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=c,n.end=f,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=u,n.end=f,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;const g=o.getPlane(t);if(Math.abs(g.distanceToPoint(l))<=a){const d=g.projectPoint(l,e);if(o.containsPoint(d))return!0}return!1}}(),hy=1e-15;function _l(r){return Math.abs(r)new C),this.satBounds=new Array(4).fill().map(()=>new Pi),this.points=[this.a,this.b,this.c],this.sphere=new ni,this.plane=new ci,this.needsUpdate=!0}intersectsSphere(e){return uy(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);const c=s[1],u=o[1];c.subVectors(e,t),u.setFromPoints(c,i);const f=s[2],h=o[2];f.subVectors(t,n),h.setFromPoints(f,i);const p=s[3],_=o[3];p.subVectors(n,e),_.setFromPoints(p,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}ti.prototype.closestPointToSegment=function(){const r=new C,e=new C,t=new Ci;return function(i,s=null,o=null){const{start:a,end:l}=i,c=this.points;let u,f=1/0;for(let h=0;h<3;h++){const p=(h+1)%3;t.start.copy(c[h]),t.end.copy(c[p]),fc(t,i,r,e),u=r.distanceToSquared(e),u=2){(y===1?d.start:d.end).copy(p),v=2;break}if(v++,v===2&&y===-1)break}}return v}return function(m,d=null,x=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(r.copy(m),r.update(),m=r);const v=this.plane,y=m.plane;if(Math.abs(v.normal.dot(y.normal))>1-1e-10){const b=this.satBounds,M=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let S=0;S<4;S++){const A=b[S],z=M[S];if(n.setFromPoints(z,t),A.isSeparated(n))return!1}const T=m.satBounds,I=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let S=0;S<4;S++){const A=T[S],z=I[S];if(n.setFromPoints(z,e),A.isSeparated(n))return!1}for(let S=0;S<4;S++){const A=M[S];for(let z=0;z<4;z++){const O=I[z];if(s.crossVectors(A,O),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return d&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),d.start.set(0,0,0),d.end.set(0,0,0)),!0}else{const b=_(this,y,f);if(b===1&&m.containsPoint(f.end))return d&&(d.start.copy(f.end),d.end.copy(f.end)),!0;if(b!==2)return!1;const M=_(m,v,h);if(M===1&&this.containsPoint(h.end))return d&&(d.start.copy(h.end),d.end.copy(h.end)),!0;if(M!==2)return!1;if(f.delta(a),h.delta(l),a.dot(l)<0){let W=h.start;h.start=h.end,h.end=W}const T=f.start.dot(a),I=f.end.dot(a),S=h.start.dot(a),A=h.end.dot(a),z=I0?d.start.copy(f.start):d.start.copy(h.start),c.subVectors(f.end,h.end),c.dot(a)<0?d.end.copy(f.end):d.end.copy(h.end)),!0)}}}();ti.prototype.distanceToPoint=function(){const r=new C;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();ti.prototype.distanceToTriangle=function(){const r=new C,e=new C,t=["a","b","c"],n=new Ci,i=new Ci;return function(o,a=null,l=null){const c=a||l?n:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let f=0;f<3;f++){let h;const p=t[f],_=o[p];this.closestPointToPoint(_,r),h=_.distanceToSquared(r),hnew C),this.satAxes=new Array(3).fill().map(()=>new C),this.satBounds=new Array(3).fill().map(()=>new Pi),this.alignedSatBounds=new Array(3).fill().map(()=>new Pi),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}bn.prototype.update=function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let f=0;f<=1;f++){const h=1*c|2*u|4*f,p=i[h];p.x=c?n.x:t.x,p.y=u?n.y:t.y,p.z=f?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,o=this.satAxes,a=i[0];for(let c=0;c<3;c++){const u=o[c],f=s[c],h=1<new Ci),t=new Array(12).fill().map(()=>new Ci),n=new C,i=new C;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),c&&c.copy(i)),0;const u=a*a,f=o.min,h=o.max,p=this.points;let _=1/0;for(let m=0;m<8;m++){const d=p[m];i.copy(d).clamp(f,h);const x=d.distanceToSquared(i);if(x<_&&(_=x,l&&l.copy(d),c&&c.copy(i),xnew ti)}}const Gn=new fy;function wn(r,e){return e[r+15]===65535}function Tn(r,e){return e[r+6]}function In(r,e){return e[r+14]}function Wn(r){return r+8}function Nn(r,e){return e[r+6]}function pc(r,e){return e[r+7]}class dy{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const Rt=new dy;let qi,is;const Wr=[],Go=new dc(()=>new $t);function py(r,e,t,n,i,s){qi=Go.getPrimitive(),is=Go.getPrimitive(),Wr.push(qi,is),Rt.setBuffer(r._roots[e]);const o=Vl(0,r.geometry,t,n,i,s);Rt.clearBuffer(),Go.releasePrimitive(qi),Go.releasePrimitive(is),Wr.pop(),Wr.pop();const a=Wr.length;return a>0&&(is=Wr[a-1],qi=Wr[a-2]),o}function Vl(r,e,t,n,i=null,s=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=Rt;let u=r*2;if(wn(u,l)){const _=Tn(r,c),g=In(u,l);return Ut(r,a,qi),n(_,g,!1,o,s+r,qi)}else{let O=function(D){const{uint16Array:V,uint32Array:Z}=Rt;let Q=D*2;for(;!wn(Q,V);)D=Wn(D),Q=D*2;return Tn(D,Z)},W=function(D){const{uint16Array:V,uint32Array:Z}=Rt;let Q=D*2;for(;!wn(Q,V);)D=Nn(D,Z),Q=D*2;return Tn(D,Z)+In(Q,V)};var h=O,p=W;const _=Wn(r),g=Nn(r,c);let m=_,d=g,x,v,y,b;if(i&&(y=qi,b=is,Ut(m,a,y),Ut(d,a,b),x=i(y),v=i(b),v(Fs.copy(e).clamp(u.min,u.max),Fs.distanceToSquared(e)),intersectsBounds:(u,f,h)=>h{u.closestPointToPoint(e,Fs);const h=e.distanceToSquared(Fs);return h0&&c.normal.multiplyScalar(-1));const u={a:s,b:o,c:a,normal:new C,materialIndex:0};fn.getNormal(Xr,qr,jr,u.normal),c.face=u,c.faceIndex=s}return c}function Ma(r,e,t,n,i){const s=n*3;let o=s+0,a=s+1,l=s+2;const c=r.index;r.index&&(o=c.getX(o),a=c.getX(a),l=c.getX(l));const{position:u,normal:f,uv:h,uv1:p}=r.attributes,_=gy(t,u,f,h,p,o,a,l,e);return _?(_.faceIndex=n,i&&i.push(_),_):null}function jt(r,e,t,n){const i=r.a,s=r.b,o=r.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(c),o.y=n.getY(c),o.z=n.getZ(c)}function vy(r,e,t,n,i,s){const{geometry:o,_indirectBuffer:a}=r;for(let l=n,c=n+i;lM&&(M=O),WT&&(T=W),DI&&(I=D)}return l[h+0]!==v||l[h+1]!==y||l[h+2]!==b||l[h+3]!==M||l[h+4]!==T||l[h+5]!==I?(l[h+0]=v,l[h+1]=y,l[h+2]=b,l[h+3]=M,l[h+4]=T,l[h+5]=I,!0):!1}else{const d=h+8,x=o[h+6],v=d+p,y=x+p;let b=_,M=!1,T=!1;e?b||(M=e.has(v),T=e.has(y),b=!M&&!T):(M=!0,T=!0);const I=b||M,S=b||T;let A=!1;I&&(A=f(d,p,b));let z=!1;S&&(z=f(x,p,b));const O=A||z;if(O)for(let W=0;W<3;W++){const D=d+W,V=x+W,Z=l[D],Q=l[D+3],ce=l[V],ie=l[V+3];l[h+W]=Zie?Q:ie}return O}}}const Ph=new $t;function Qi(r,e,t,n){return Ut(r,e,Ph),t.intersectBox(Ph,n)}function Sy(r,e,t,n,i,s){const{geometry:o,_indirectBuffer:a}=r;for(let l=n,c=n+i;l=0;let p,_;h?(p=Wn(r),_=Nn(r,o)):(p=Nn(r,o),_=Wn(r));const m=Qi(p,i,n,Ih)?Wl(p,e,t,n):null;if(m){const v=m.point[u];if(h?v<=i[_+c]:v>=i[_+c+3])return m}const x=Qi(_,i,n,Ih)?Wl(_,e,t,n):null;return m&&x?m.distance<=x.distance?m:x:m||x||null}}const Yo=new $t,Yr=new ti,$r=new ti,Os=new Ve,Nh=new bn,$o=new bn;function Ry(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=Xl(0,r,t,n);return Rt.clearBuffer(),i}function Xl(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Nh.set(t.boundingBox.min,t.boundingBox.max,n),i=Nh),wn(l,o)){const u=e.geometry,f=u.index,h=u.attributes.position,p=t.index,_=t.attributes.position,g=Tn(r,a),m=In(l,o);if(Os.copy(n).invert(),t.boundsTree)return Ut(r,s,$o),$o.matrix.copy(Os),$o.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>$o.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let v=g*3,y=(m+g)*3;vvl.distanceToBox(b),intersectsBounds:(b,M,T)=>T{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>Us.distanceToBox(I),intersectsBounds:(I,S,A)=>A{for(let A=I,z=I+S;AM&&(M=D),VT&&(T=V),ZI&&(I=Z)}}return l[h+0]!==v||l[h+1]!==y||l[h+2]!==b||l[h+3]!==M||l[h+4]!==T||l[h+5]!==I?(l[h+0]=v,l[h+1]=y,l[h+2]=b,l[h+3]=M,l[h+4]=T,l[h+5]=I,!0):!1}else{const d=h+8,x=o[h+6],v=d+p,y=x+p;let b=_,M=!1,T=!1;e?b||(M=e.has(v),T=e.has(y),b=!M&&!T):(M=!0,T=!0);const I=b||M,S=b||T;let A=!1;I&&(A=f(d,p,b));let z=!1;S&&(z=f(x,p,b));const O=A||z;if(O)for(let W=0;W<3;W++){const D=d+W,V=x+W,Z=l[D],Q=l[D+3],ce=l[V],ie=l[V+3];l[h+W]=Zie?Q:ie}return O}}}const Fh=new C;function Fy(r,e,t,n,i){Rt.setBuffer(r._roots[e]),ql(0,r,t,n,i),Rt.clearBuffer()}function ql(r,e,t,n,i){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt,l=r*2;if(wn(l,o)){const u=Tn(r,a),f=In(l,o);Sy(e,t,n,u,f,i)}else{const u=Wn(r);Qi(u,s,n,Fh)&&ql(u,e,t,n,i);const f=Nn(r,a);Qi(f,s,n,Fh)&&ql(f,e,t,n,i)}}const Oh=new C,Oy=["x","y","z"];function Uy(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=jl(0,r,t,n);return Rt.clearBuffer(),i}function jl(r,e,t,n){const{float32Array:i,uint16Array:s,uint32Array:o}=Rt;let a=r*2;if(wn(a,s)){const c=Tn(r,o),u=In(a,s);return Ey(e,t,n,c,u)}else{const c=pc(r,o),u=Oy[c],h=n.direction[u]>=0;let p,_;h?(p=Wn(r),_=Nn(r,o)):(p=Nn(r,o),_=Wn(r));const m=Qi(p,i,n,Oh)?jl(p,e,t,n):null;if(m){const v=m.point[u];if(h?v<=i[_+c]:v>=i[_+c+3])return m}const x=Qi(_,i,n,Oh)?jl(_,e,t,n):null;return m&&x?m.distance<=x.distance?m:x:m||x||null}}const Zo=new $t,Kr=new ti,Zr=new ti,Bs=new Ve,Uh=new bn,Qo=new bn;function By(r,e,t,n){Rt.setBuffer(r._roots[e]);const i=Yl(0,r,t,n);return Rt.clearBuffer(),i}function Yl(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=Rt;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Uh.set(t.boundingBox.min,t.boundingBox.max,n),i=Uh),wn(l,o)){const u=e.geometry,f=u.index,h=u.attributes.position,p=t.index,_=t.attributes.position,g=Tn(r,a),m=In(l,o);if(Bs.copy(n).invert(),t.boundsTree)return Ut(r,s,Qo),Qo.matrix.copy(Bs),Qo.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Qo.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let v=g,y=m+g;vxl.distanceToBox(b),intersectsBounds:(b,M,T)=>T{if(e.boundsTree){const T=e.boundsTree;return T.shapecast({boundsTraverseOrder:I=>zs.distanceToBox(I),intersectsBounds:(I,S,A)=>A{for(let A=I,z=I+S;Anew $t),Qr=new $t,Jr=new $t,yl=new $t,bl=new $t;let Sl=!1;function Xy(r,e,t,n){if(Sl)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Sl=!0;const i=r._roots,s=e._roots;let o,a=0,l=0;const c=new Ve().copy(t).invert();for(let u=0,f=i.length;ul.slice()),index:o.array.slice(),indirectBuffer:s?s.slice():null}:a={roots:i,index:o.array,indirectBuffer:s},a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:o}=e,a=new mc(t,{...n,[pl]:!0});if(a._roots=s,a._indirectBuffer=o||null,n.setIndex){const l=t.getIndex();if(l===null){const c=new Yt(e.index,1,!1);t.setIndex(c)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:Vf,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[pl]:!1},t),t.useSharedArrayBuffer&&!Wy())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[pl]||(ly(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new $t)));const{_indirectBuffer:n}=this;this.resolveTriangleIndex=t.indirect?i=>n[i]:i=>i}refit(e=null){return(this.indirect?Ny:by)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){const c=a*2,u=s[c+15]===wa;if(u){const f=i[a+6],h=s[c+14];e(l,u,new Float32Array(n,a*4,6),f,h)}else{const f=a+_r/4,h=i[a+6],p=i[a+7];e(l,u,new Float32Array(n,a*4,6),p)||(o(f,l+1),o(h,l+1))}}}raycast(e,t=ei){const n=this._roots,i=this.geometry,s=[],o=t.isMaterial,a=Array.isArray(t),l=i.groups,c=o?t.side:t,u=this.indirect?Fy:My;for(let f=0,h=n.length;ff(h,p,_,g,m)?!0:n(h,p,this,a,_,g,t)}else o||(a?o=(f,h,p,_)=>n(f,h,this,a,p,_,t):o=(f,h,p)=>p);let l=!1,c=0;const u=this._roots;for(let f=0,h=u.length;f{const g=this.resolveTriangleIndex(_);jt(o,g*3,a,l)}:_=>{jt(o,_*3,a,l)},u=Gn.getPrimitive(),f=e.geometry.index,h=e.geometry.attributes.position,p=e.indirect?_=>{const g=e.resolveTriangleIndex(_);jt(u,g*3,f,h)}:_=>{jt(u,_*3,f,h)};if(s){const _=(g,m,d,x,v,y,b,M)=>{for(let T=d,I=d+x;Tea.intersectsBox(n),intersectsTriangle:n=>ea.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){return(this.indirect?Gy:Iy)(this,e,t,n,i,s,o)}closestPointToPoint(e,t={},n=0,i=1/0){return my(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Ut(0,new Float32Array(n),Bh),e.union(Bh)}),e}}function qy(r){switch(r){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function jy(r){switch(r){case 1:return sf;case 2:return of;case 3:return sn;case 4:return sn}}function zh(r){switch(r){case 1:return Jl;case 2:return xa;case 3:return Js;case 4:return Js}}class Yf extends pa{constructor(){super(),this.minFilter=Nt,this.magFilter=Nt,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const t=this.overrideItemSize,n=e.itemSize,i=e.count;if(t!==null){if(n*i%t!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");e.itemSize=t,e.count=i*n/t}const s=e.itemSize,o=e.count,a=e.normalized,l=e.array.constructor,c=l.BYTES_PER_ELEMENT;let u=this._forcedType,f=s;if(u===null)switch(l){case Float32Array:u=vn;break;case Uint8Array:case Uint16Array:case Uint32Array:u=Dn;break;case Int8Array:case Int16Array:case Int32Array:u=Ws;break}let h,p,_,g,m=qy(s);switch(u){case vn:_=1,p=jy(s),a&&c===1?(g=l,m+="8",l===Uint8Array?h=fi:(h=Pl,m+="_SNORM")):(g=Float32Array,m+="32F",h=vn);break;case Ws:m+=c*8+"I",_=a?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,p=zh(s),c===1?(g=Int8Array,h=Pl):c===2?(g=Int16Array,h=tf):(g=Int32Array,h=Ws);break;case Dn:m+=c*8+"UI",_=a?Math.pow(2,l.BYTES_PER_ELEMENT*8-1):1,p=zh(s),c===1?(g=Uint8Array,h=fi):c===2?(g=Uint16Array,h=va):(g=Uint32Array,h=Dn);break}f===3&&(p===sn||p===Js)&&(f=4);const d=Math.ceil(Math.sqrt(o)),x=f*d*d,v=new g(x),y=e.normalized;e.normalized=!1;for(let b=0;b=2&&(v[M+1]=e.getY(b)/_),s>=3&&(v[M+2]=e.getZ(b)/_,f===4&&(v[M+3]=1)),s>=4&&(v[M+3]=e.getW(b)/_)}e.normalized=y,this.internalFormat=m,this.format=p,this.type=h,this.image.width=d,this.image.height=d,this.image.data=v,this.needsUpdate=!0,this.dispose(),e.itemSize=n,e.count=i}}class Yy extends Yf{constructor(){super(),this._forcedType=Dn}}class Vs extends Yf{constructor(){super(),this._forcedType=vn}}class kh{constructor(){this.index=new Yy,this.position=new Vs,this.bvhBounds=new pa,this.bvhContents=new pa,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:t}=e;if(Ky(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(t.attributes.position),e.indirect){const n=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==n.length)if(t.index)this._cachedIndexAttr=t.index.clone();else{const i=Xf(Wf(t));this._cachedIndexAttr=new Yt(i,1,!1)}$y(t,n,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(t.index)}dispose(){const{index:e,position:t,bvhBounds:n,bvhContents:i}=this;e&&e.dispose(),t&&t.dispose(),n&&n.dispose(),i&&i.dispose()}}function $y(r,e,t){const n=t.array,i=r.index?r.index.array:null;for(let s=0,o=e.length;s=2&&e.setY(o,r.getY(i)),n>=3&&e.setZ(o,r.getZ(i)),n>=4&&e.setW(o,r.getW(i))}}else{const n=e.array,i=n.constructor,s=n.BYTES_PER_ELEMENT*r.itemSize*t;new i(n.buffer,s,r.array.length).set(r.array)}}function eb(r,e,t){const n=r.elements,i=e.elements;for(let s=0,o=i.length;s{n.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new yn),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new yn){let t=[];const{meshes:n,useGroups:i,_intermediateGeometry:s,_diffMap:o}=this;for(let a=0,l=n.length;a=2&&e.setY(o,r.getY(i)),n>=3&&e.setZ(o,r.getZ(i)),n>=4&&e.setW(o,r.getW(i))}}else{const n=e.array,i=n.constructor,s=n.BYTES_PER_ELEMENT*r.itemSize*t;new i(n.buffer,s,r.array.length).set(r.array)}}function Jy(r,e,t){const n=r.elements,i=e.elements;for(let s=0,o=i.length;s{n.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new yn),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new yn){let t=[];const{meshes:n,useGroups:i,_intermediateGeometry:s,_diffMap:o}=this;for(let a=0,l=n.length;ao.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(n)}name(e){return this._name=e,this.$name.innerHTML=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const t=this.parent.add(this.object,this.property,e);return t.name(this._name),this.destroy(),t}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.object[this.property]=e,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class sb extends pi{constructor(e,t,n){super(e,t,n,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function $l(r){let e,t;return(e=r.match(/(#|0x)?([a-f0-9]{6})/i))?t=e[2]:(e=r.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?t=parseInt(e[1]).toString(16).padStart(2,0)+parseInt(e[2]).toString(16).padStart(2,0)+parseInt(e[3]).toString(16).padStart(2,0):(e=r.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(t=e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),t?"#"+t:!1}const ob={isPrimitive:!0,match:r=>typeof r=="string",fromHexString:$l,toHexString:$l},no={isPrimitive:!0,match:r=>typeof r=="number",fromHexString:r=>parseInt(r.substring(1),16),toHexString:r=>"#"+r.toString(16).padStart(6,0)},ab={isPrimitive:!1,match:r=>Array.isArray(r),fromHexString(r,e,t=1){const n=no.fromHexString(r);e[0]=(n>>16&255)/255*t,e[1]=(n>>8&255)/255*t,e[2]=(n&255)/255*t},toHexString([r,e,t],n=1){n=255/n;const i=r*n<<16^e*n<<8^t*n<<0;return no.toHexString(i)}},lb={isPrimitive:!1,match:r=>Object(r)===r,fromHexString(r,e,t=1){const n=no.fromHexString(r);e.r=(n>>16&255)/255*t,e.g=(n>>8&255)/255*t,e.b=(n&255)/255*t},toHexString({r,g:e,b:t},n=1){n=255/n;const i=r*n<<16^e*n<<8^t*n<<0;return no.toHexString(i)}},cb=[ob,no,ab,lb];function ub(r){return cb.find(e=>e.match(r))}class hb extends pi{constructor(e,t,n,i){super(e,t,n,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=ub(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const s=$l(this.$text.value);s&&this._setValueFromHexString(s)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const t=this._format.fromHexString(e);this.setValue(t)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class Ml extends pi{constructor(e,t,n){super(e,t,n,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",i=>{i.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class fb extends pi{constructor(e,t,n,i,s,o){super(e,t,n,"number"),this._initInput(),this.min(i),this.max(s);const a=o!==void 0;this.step(a?o:this._getImplicitStep(),a),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,t=!0){return this._step=e,this._stepExplicit=t,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let t=(e-this._min)/(this._max-this._min);t=Math.max(0,Math.min(t,1)),this.$fill.style.width=t*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const t=()=>{let x=parseFloat(this.$input.value);isNaN(x)||(this._stepExplicit&&(x=this._snap(x)),this.setValue(this._clamp(x)))},n=x=>{const v=parseFloat(this.$input.value);isNaN(v)||(this._snapClampSetValue(v+x),this.$input.value=this.getValue())},i=x=>{x.key==="Enter"&&this.$input.blur(),x.code==="ArrowUp"&&(x.preventDefault(),n(this._step*this._arrowKeyMultiplier(x))),x.code==="ArrowDown"&&(x.preventDefault(),n(this._step*this._arrowKeyMultiplier(x)*-1))},s=x=>{this._inputFocused&&(x.preventDefault(),n(this._step*this._normalizeMouseWheel(x)))};let o=!1,a,l,c,u,f;const h=5,p=x=>{a=x.clientX,l=c=x.clientY,o=!0,u=this.getValue(),f=0,window.addEventListener("mousemove",_),window.addEventListener("mouseup",g)},_=x=>{if(o){const v=x.clientX-a,y=x.clientY-l;Math.abs(y)>h?(x.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(v)>h&&g()}if(!o){const v=x.clientY-c;f-=v*this._step*this._arrowKeyMultiplier(x),u+f>this._max?f=this._max-u:u+f{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",g)},m=()=>{this._inputFocused=!0},d=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",t),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",m),this.$input.addEventListener("blur",d)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(d,x,v,y,b)=>(d-x)/(v-x)*(b-y)+y,t=d=>{const x=this.$slider.getBoundingClientRect();let v=e(d,x.left,x.right,this._min,this._max);this._snapClampSetValue(v)},n=d=>{this._setDraggingStyle(!0),t(d.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=d=>{t(d.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let o=!1,a,l;const c=d=>{d.preventDefault(),this._setDraggingStyle(!0),t(d.touches[0].clientX),o=!1},u=d=>{d.touches.length>1||(this._hasScrollBar?(a=d.touches[0].clientX,l=d.touches[0].clientY,o=!0):c(d),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",h))},f=d=>{if(o){const x=d.touches[0].clientX-a,v=d.touches[0].clientY-l;Math.abs(x)>Math.abs(v)?c(d):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",h))}else d.preventDefault(),t(d.touches[0].clientX)},h=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",h)},p=this._callOnFinishChange.bind(this),_=400;let g;const m=d=>{if(Math.abs(d.deltaX)this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class db extends pi{constructor(e,t,n,i){super(e,t,n,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(i)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(t=>{const n=document.createElement("option");n.innerHTML=t,this.$select.appendChild(n)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),t=this._values.indexOf(e);return this.$select.selectedIndex=t,this.$display.innerHTML=t===-1?e:this._names[t],this}}class pb extends pi{constructor(e,t,n){super(e,t,n,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",i=>{i.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const mb=`.lil-gui { + */class pi{constructor(e,t,n,i,s="div"){this.parent=e,this.object=t,this.property=n,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(s),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),pi.nextNameID=pi.nextNameID||0,this.$name.id=`lil-gui-name-${++pi.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(n)}name(e){return this._name=e,this.$name.innerHTML=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const t=this.parent.add(this.object,this.property,e);return t.name(this._name),this.destroy(),t}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.object[this.property]=e,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class rb extends pi{constructor(e,t,n){super(e,t,n,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function $l(r){let e,t;return(e=r.match(/(#|0x)?([a-f0-9]{6})/i))?t=e[2]:(e=r.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?t=parseInt(e[1]).toString(16).padStart(2,0)+parseInt(e[2]).toString(16).padStart(2,0)+parseInt(e[3]).toString(16).padStart(2,0):(e=r.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(t=e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),t?"#"+t:!1}const sb={isPrimitive:!0,match:r=>typeof r=="string",fromHexString:$l,toHexString:$l},no={isPrimitive:!0,match:r=>typeof r=="number",fromHexString:r=>parseInt(r.substring(1),16),toHexString:r=>"#"+r.toString(16).padStart(6,0)},ob={isPrimitive:!1,match:r=>Array.isArray(r),fromHexString(r,e,t=1){const n=no.fromHexString(r);e[0]=(n>>16&255)/255*t,e[1]=(n>>8&255)/255*t,e[2]=(n&255)/255*t},toHexString([r,e,t],n=1){n=255/n;const i=r*n<<16^e*n<<8^t*n<<0;return no.toHexString(i)}},ab={isPrimitive:!1,match:r=>Object(r)===r,fromHexString(r,e,t=1){const n=no.fromHexString(r);e.r=(n>>16&255)/255*t,e.g=(n>>8&255)/255*t,e.b=(n&255)/255*t},toHexString({r,g:e,b:t},n=1){n=255/n;const i=r*n<<16^e*n<<8^t*n<<0;return no.toHexString(i)}},lb=[sb,no,ob,ab];function cb(r){return lb.find(e=>e.match(r))}class ub extends pi{constructor(e,t,n,i){super(e,t,n,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=cb(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const s=$l(this.$text.value);s&&this._setValueFromHexString(s)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const t=this._format.fromHexString(e);this.setValue(t)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class Ml extends pi{constructor(e,t,n){super(e,t,n,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",i=>{i.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class hb extends pi{constructor(e,t,n,i,s,o){super(e,t,n,"number"),this._initInput(),this.min(i),this.max(s);const a=o!==void 0;this.step(a?o:this._getImplicitStep(),a),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,t=!0){return this._step=e,this._stepExplicit=t,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let t=(e-this._min)/(this._max-this._min);t=Math.max(0,Math.min(t,1)),this.$fill.style.width=t*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const t=()=>{let x=parseFloat(this.$input.value);isNaN(x)||(this._stepExplicit&&(x=this._snap(x)),this.setValue(this._clamp(x)))},n=x=>{const v=parseFloat(this.$input.value);isNaN(v)||(this._snapClampSetValue(v+x),this.$input.value=this.getValue())},i=x=>{x.key==="Enter"&&this.$input.blur(),x.code==="ArrowUp"&&(x.preventDefault(),n(this._step*this._arrowKeyMultiplier(x))),x.code==="ArrowDown"&&(x.preventDefault(),n(this._step*this._arrowKeyMultiplier(x)*-1))},s=x=>{this._inputFocused&&(x.preventDefault(),n(this._step*this._normalizeMouseWheel(x)))};let o=!1,a,l,c,u,f;const h=5,p=x=>{a=x.clientX,l=c=x.clientY,o=!0,u=this.getValue(),f=0,window.addEventListener("mousemove",_),window.addEventListener("mouseup",g)},_=x=>{if(o){const v=x.clientX-a,y=x.clientY-l;Math.abs(y)>h?(x.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(v)>h&&g()}if(!o){const v=x.clientY-c;f-=v*this._step*this._arrowKeyMultiplier(x),u+f>this._max?f=this._max-u:u+f{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",g)},m=()=>{this._inputFocused=!0},d=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",t),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",m),this.$input.addEventListener("blur",d)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(d,x,v,y,b)=>(d-x)/(v-x)*(b-y)+y,t=d=>{const x=this.$slider.getBoundingClientRect();let v=e(d,x.left,x.right,this._min,this._max);this._snapClampSetValue(v)},n=d=>{this._setDraggingStyle(!0),t(d.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=d=>{t(d.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let o=!1,a,l;const c=d=>{d.preventDefault(),this._setDraggingStyle(!0),t(d.touches[0].clientX),o=!1},u=d=>{d.touches.length>1||(this._hasScrollBar?(a=d.touches[0].clientX,l=d.touches[0].clientY,o=!0):c(d),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",h))},f=d=>{if(o){const x=d.touches[0].clientX-a,v=d.touches[0].clientY-l;Math.abs(x)>Math.abs(v)?c(d):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",h))}else d.preventDefault(),t(d.touches[0].clientX)},h=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",h)},p=this._callOnFinishChange.bind(this),_=400;let g;const m=d=>{if(Math.abs(d.deltaX)this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class fb extends pi{constructor(e,t,n,i){super(e,t,n,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(i)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(t=>{const n=document.createElement("option");n.innerHTML=t,this.$select.appendChild(n)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),t=this._values.indexOf(e);return this.$select.selectedIndex=t,this.$display.innerHTML=t===-1?e:this._names[t],this}}class db extends pi{constructor(e,t,n){super(e,t,n,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",i=>{i.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const pb=`.lil-gui { font-family: var(--font-family); font-size: var(--font-size); line-height: 1; @@ -4336,10 +4336,10 @@ bool bvhIntersectFirstHit( @font-face { font-family: "lil-gui"; src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff"); -}`;function _b(r){const e=document.createElement("style");e.innerHTML=r;const t=document.querySelector("head link[rel=stylesheet], head style");t?document.head.insertBefore(e,t):document.head.appendChild(e)}let qh=!1;class _c{constructor({parent:e,autoPlace:t=e===void 0,container:n,width:i,title:s="Controls",closeFolders:o=!1,injectStyles:a=!0,touchStyles:l=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",c=>{(c.code==="Enter"||c.code==="Space")&&(c.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),l&&this.domElement.classList.add("allow-touch-styles"),!qh&&a&&(_b(mb),qh=!0),n?n.appendChild(this.domElement):t&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=o}add(e,t,n,i,s){if(Object(n)===n)return new db(this,e,t,n);const o=e[t];switch(typeof o){case"number":return new fb(this,e,t,n,i,s);case"boolean":return new sb(this,e,t);case"string":return new pb(this,e,t);case"function":return new Ml(this,e,t)}console.error(`gui.add failed +}`;function mb(r){const e=document.createElement("style");e.innerHTML=r;const t=document.querySelector("head link[rel=stylesheet], head style");t?document.head.insertBefore(e,t):document.head.appendChild(e)}let qh=!1;class _c{constructor({parent:e,autoPlace:t=e===void 0,container:n,width:i,title:s="Controls",closeFolders:o=!1,injectStyles:a=!0,touchStyles:l=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",c=>{(c.code==="Enter"||c.code==="Space")&&(c.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),l&&this.domElement.classList.add("allow-touch-styles"),!qh&&a&&(mb(pb),qh=!0),n?n.appendChild(this.domElement):t&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=o}add(e,t,n,i,s){if(Object(n)===n)return new fb(this,e,t,n);const o=e[t];switch(typeof o){case"number":return new hb(this,e,t,n,i,s);case"boolean":return new rb(this,e,t);case"string":return new db(this,e,t);case"function":return new Ml(this,e,t)}console.error(`gui.add failed property:`,t,` object:`,e,` - value:`,o)}addColor(e,t,n=1){return new hb(this,e,t,n)}addFolder(e){const t=new _c({parent:this,title:e});return this.root._closeFolders&&t.close(),t}load(e,t=!0){return e.controllers&&this.controllers.forEach(n=>{n instanceof Ml||n._name in e.controllers&&n.load(e.controllers[n._name])}),t&&e.folders&&this.folders.forEach(n=>{n._title in e.folders&&n.load(e.folders[n._title])}),this}save(e=!0){const t={controllers:{},folders:{}};return this.controllers.forEach(n=>{if(!(n instanceof Ml)){if(n._name in t.controllers)throw new Error(`Cannot save GUI with duplicate property "${n._name}"`);t.controllers[n._name]=n.save()}}),e&&this.folders.forEach(n=>{if(n._title in t.folders)throw new Error(`Cannot save GUI with duplicate folder "${n._title}"`);t.folders[n._title]=n.save()}),t}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const t=this.$children.clientHeight;this.$children.style.height=t+"px",this.domElement.classList.add("transition");const n=s=>{s.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",n))};this.$children.addEventListener("transitionend",n);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.innerHTML=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(n=>n.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(t=>{e=e.concat(t.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(t=>{e=e.concat(t.foldersRecursive())}),e}}const gb=`\r + value:`,o)}addColor(e,t,n=1){return new ub(this,e,t,n)}addFolder(e){const t=new _c({parent:this,title:e});return this.root._closeFolders&&t.close(),t}load(e,t=!0){return e.controllers&&this.controllers.forEach(n=>{n instanceof Ml||n._name in e.controllers&&n.load(e.controllers[n._name])}),t&&e.folders&&this.folders.forEach(n=>{n._title in e.folders&&n.load(e.folders[n._title])}),this}save(e=!0){const t={controllers:{},folders:{}};return this.controllers.forEach(n=>{if(!(n instanceof Ml)){if(n._name in t.controllers)throw new Error(`Cannot save GUI with duplicate property "${n._name}"`);t.controllers[n._name]=n.save()}}),e&&this.folders.forEach(n=>{if(n._title in t.folders)throw new Error(`Cannot save GUI with duplicate folder "${n._title}"`);t.folders[n._title]=n.save()}),t}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const t=this.$children.clientHeight;this.$children.style.height=t+"px",this.domElement.classList.add("transition");const n=s=>{s.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",n))};this.$children.addEventListener("transitionend",n);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.innerHTML=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(n=>n.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(t=>{e=e.concat(t.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(t=>{e=e.concat(t.foldersRecursive())}),e}}const _b=`\r //////////////////////////////////////////////////////\r // camera uniforms\r //////////////////////////////////////////////////////\r @@ -4884,7 +4884,7 @@ vec3 xyzToRgb(vec3 XYZ)\r }\r \r #endif // DISPERSION_ENABLED\r -`,vb=`\r +`,gb=`\r //////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r // "Coat" dielectric microfacet BSDF\r //////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r @@ -5047,7 +5047,7 @@ vec3 coat_brdf_albedo(in vec3 pW, in Basis basis, in vec3 winputL, inout uint rn return vec3(0.0);\r #endif // COAT_ENABLED\r }\r -`,xb=`#ifdef THIN_FILM_ENABLED\r +`,vb=`#ifdef THIN_FILM_ENABLED\r \r /*\r Simplified implementation of thin-film Fresnel, based on:\r @@ -5135,7 +5135,7 @@ vec3 FresnelThinFilm(float mui, float eta_fe, bool dielectric)\r vec3 FresnelThinFilmOverDielectric(float mui, float eta_fe) { return FresnelThinFilm(mui, eta_fe, true); }\r vec3 FresnelThinFilmOverConductor( float mui, float eta_fe) { return FresnelThinFilm(mui, eta_fe, false); }\r \r -#endif // THIN_FILM_ENABLED`,yb=`\r +#endif // THIN_FILM_ENABLED`,xb=`\r //////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r // "Metal" conductor microfacet BSDF\r //////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r @@ -5270,7 +5270,7 @@ vec3 metal_brdf_albedo(in vec3 pW, in Basis basis, in vec3 winputL, inout uint r \r \r \r -`,bb=`\r +`,yb=`\r //////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r // "Specular" dielectric microfacet BRDF\r //////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r @@ -5498,7 +5498,7 @@ vec3 specular_brdf_albedo(in vec3 pW, in Basis basis, in vec3 winputL, inout uin albedo /= float(num_samples);\r return albedo;\r }\r -`,Eb=`\r +`,bb=`\r //////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r // "Specular" dielectric microfacet BTDF\r //////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r @@ -5902,9 +5902,9 @@ vec3 fujii_materialx(in vec3 Albedo, float roughness, in vec3 V, in vec3 L)\r \r void ltc_coeffs(in vec3 wo, float r, inout float a, inout float b)\r {\r - float sinO = sqrt(1.0 - wo.z*wo.z); // for LTC elements\r - a = r*pow(sinO, 50.0)*0.5 + 1.0; // LTC M element a\r - b = r*pow(sinO, 4.0)*sqrt(wo.z); // LTC M element b\r + float sinO = sqrt(max(0.0, 1.0 - wo.z*wo.z)); // for LTC elements\r + a = r*pow(sinO, 50.0)*0.5 + 1.0; // LTC M element a\r + b = r*pow(sinO, 4.0)*sqrt(max(0.0, wo.z)); // LTC M element b\r }\r \r vec3 ltc_space(in vec3 wo, in vec3 w, bool to)\r @@ -5931,7 +5931,7 @@ float pdf_EON(in vec3 wo, in vec3 wi, float r)\r wh /= l_MIwl; // normalize wh\r float J = aI*aI / (l_MIwl*l_MIwl*l_MIwl); // |M^-1| / |M^-1 wl|^3\r float pdf_h = wh.z / PI; // wh sample PDF\r - return max(PDF_EPSILON, pdf_h * J); // wi sample PDF\r + return pdf_h * J; // wi sample PDF\r }\r \r vec4 sample_cosine_lobe(inout uint rndSeed)\r @@ -5956,7 +5956,7 @@ vec4 sample_EON(in vec3 wo, float r, inout uint rndSeed)\r float l_Mwh = length(wl); // |M wh| = 1/|M^-1 wl|\r wl /= l_Mwh; // normalize wl\r float J = (l_Mwh*l_Mwh*l_Mwh) / (a*a); // |M^-1| / |M^-1 wl|^3\r - float pdf_i = max(PDF_EPSILON, pdf_h * J); // wi sample PDF\r + float pdf_i = pdf_h * J; // wi sample PDF\r vec3 wi = ltc_space(wo, wl, false); // transform wi -> wl\r return vec4(wi, pdf_i);\r }\r @@ -6181,7 +6181,7 @@ vec3 diffuse_brdf_albedo(in vec3 pW, in Basis basis, in vec3 winputL, inout uint if (winputL.z < DENOM_TOLERANCE) return vec3(0.0);\r return base_weight * base_color;\r }\r -`,wb=`\r +`,Eb=`\r //////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r // OpenPBR BSDF\r //////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r @@ -6556,7 +6556,7 @@ vec3 openpbr_bsdf_sample(in vec3 pW, in Basis basis, in vec3 winputL, inout uint }\r \r \r -`,Mb=`\r +`,wb=`\r /////////////////////////////////////////////////////////////////////////\r // Raytracing routines\r /////////////////////////////////////////////////////////////////////////\r @@ -7196,9 +7196,9 @@ void main()\r gl_FragColor.rgb = L;\r gl_FragColor.a = accumulation_weight; // Implements Monte-Carlo accumulation via alpha blending\r }\r -`;function ia(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Kf={exports:{}};(function(r,e){(function(t){r.exports=t()})(function(){return function(){function t(n,i,s){function o(c,u){if(!i[c]){if(!n[c]){var f=typeof ia=="function"&&ia;if(!u&&f)return f(c,!0);if(a)return a(c,!0);var h=new Error("Cannot find module '"+c+"'");throw h.code="MODULE_NOT_FOUND",h}var p=i[c]={exports:{}};n[c][0].call(p.exports,function(_){var g=n[c][1][_];return o(g||_)},p,p.exports,t,n,i,s)}return i[c].exports}for(var a=typeof ia=="function"&&ia,l=0;l-1}function Er(L,U){var $=this.__data__,Te=xt($,L);return Te<0?(++this.size,$.push([L,U])):$[Te][1]=U,this}ln.prototype.clear=Ii,ln.prototype.delete=yr,ln.prototype.get=ri,ln.prototype.has=br,ln.prototype.set=Er;function Xn(L){var U=-1,$=L==null?0:L.length;for(this.clear();++U<$;){var Te=L[U];this.set(Te[0],Te[1])}}function Ni(){this.size=0,this.__data__={hash:new gt,map:new(he||ln),string:new gt}}function Ss(L){var U=Be(this,L).delete(L);return this.size-=U?1:0,U}function R(L){return Be(this,L).get(L)}function H(L){return Be(this,L).has(L)}function j(L,U){var $=Be(this,L),Te=$.size;return $.set(L,U),this.size+=$.size==Te?0:1,this}Xn.prototype.clear=Ni,Xn.prototype.delete=Ss,Xn.prototype.get=R,Xn.prototype.has=H,Xn.prototype.set=j;function K(L){var U=this.__data__=new ln(L);this.size=U.size}function Y(){this.__data__=new ln,this.size=0}function Se(L){var U=this.__data__,$=U.delete(L);return this.size=U.size,$}function Ie(L){return this.__data__.get(L)}function He(L){return this.__data__.has(L)}function Xe(L,U){var $=this.__data__;if($ instanceof ln){var Te=$.__data__;if(!he||Te.length1?$[ut-1]:void 0,Dt=ut>2?$[2]:void 0;for(wt=L.length>3&&typeof wt=="function"?(ut--,wt):void 0,Dt&&Pt($[0],$[1],Dt)&&(wt=ut<3?void 0:wt,ut=1),U=Object(U);++Te-1&&L%1==0&&L0){if(++U>=l)return arguments[0]}else U=0;return L.apply(void 0,arguments)}}function Jt(L){if(L!=null){try{return le.call(L)}catch{}try{return L+""}catch{}}return""}function dn(L,U){return L===U||L!==L&&U!==U}var An=at(function(){return arguments}())?at:function(L){return ws(L)&&re.call(L,"callee")&&!we.call(L,"callee")},qn=Array.isArray;function wr(L){return L!=null&&yc(L.length)&&!Ta(L)}function ed(L){return ws(L)&&wr(L)}var xc=ge||sd;function Ta(L){if(!er(L))return!1;var U=cn(L);return U==d||U==x||U==p||U==T}function yc(L){return typeof L=="number"&&L>-1&&L%1==0&&L<=u}function er(L){var U=typeof L;return L!=null&&(U=="object"||U=="function")}function ws(L){return L!=null&&typeof L=="object"}function td(L){if(!ws(L)||cn(L)!=M)return!1;var U=Re(L);if(U===null)return!0;var $=re.call(U,"constructor")&&U.constructor;return typeof $=="function"&&$ instanceof $&&le.call($)==pe}var bc=ze?ke(ze):Ji;function nd(L){return G(L,Ec(L))}function Ec(L){return wr(L)?et(L,!0):yt(L)}var id=ue(function(L,U,$){Fn(L,U,$)});function rd(L){return function(){return L}}function Sc(L){return L}function sd(){return!1}n.exports=id}).call(this)}).call(this,typeof Hl<"u"?Hl:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(t,n,i){/*! For license information please see shifty.js.LICENSE.txt */(function(s,o){typeof i=="object"&&typeof n=="object"?n.exports=o():typeof i=="object"?i.shifty=o():s.shifty=o()})(self,function(){return function(){var s={720:function(l,c,u){u.r(c),u.d(c,{Scene:function(){return Wt},Tweenable:function(){return ft},interpolate:function(){return Ji},processTweens:function(){return ae},setBezierFunction:function(){return $e},shouldScheduleUpdate:function(){return Le},tween:function(){return En},unsetBezierFunction:function(){return ze}});var f={};u.r(f),u.d(f,{bounce:function(){return _e},bouncePast:function(){return qe},easeFrom:function(){return Fe},easeFromTo:function(){return We},easeInBack:function(){return se},easeInCirc:function(){return Z},easeInCubic:function(){return d},easeInExpo:function(){return W},easeInOutBack:function(){return ve},easeInOutCirc:function(){return ce},easeInOutCubic:function(){return v},easeInOutExpo:function(){return V},easeInOutQuad:function(){return m},easeInOutQuart:function(){return M},easeInOutQuint:function(){return E},easeInOutSine:function(){return O},easeInQuad:function(){return _},easeInQuart:function(){return y},easeInQuint:function(){return T},easeInSine:function(){return A},easeOutBack:function(){return me},easeOutBounce:function(){return ie},easeOutCirc:function(){return Q},easeOutCubic:function(){return x},easeOutExpo:function(){return D},easeOutQuad:function(){return g},easeOutQuart:function(){return b},easeOutQuint:function(){return I},easeOutSine:function(){return z},easeTo:function(){return Ye},elastic:function(){return J},linear:function(){return p},swingFrom:function(){return Ee},swingFromTo:function(){return oe},swingTo:function(){return De}});var h={};u.r(h),u.d(h,{afterTween:function(){return xt},beforeTween:function(){return Ze},doesApply:function(){return et},tweenCreated:function(){return je}});var p=function(w){return w},_=function(w){return Math.pow(w,2)},g=function(w){return-(Math.pow(w-1,2)-1)},m=function(w){return(w/=.5)<1?.5*Math.pow(w,2):-.5*((w-=2)*w-2)},d=function(w){return Math.pow(w,3)},x=function(w){return Math.pow(w-1,3)+1},v=function(w){return(w/=.5)<1?.5*Math.pow(w,3):.5*(Math.pow(w-2,3)+2)},y=function(w){return Math.pow(w,4)},b=function(w){return-(Math.pow(w-1,4)-1)},M=function(w){return(w/=.5)<1?.5*Math.pow(w,4):-.5*((w-=2)*Math.pow(w,3)-2)},T=function(w){return Math.pow(w,5)},I=function(w){return Math.pow(w-1,5)+1},E=function(w){return(w/=.5)<1?.5*Math.pow(w,5):.5*(Math.pow(w-2,5)+2)},A=function(w){return 1-Math.cos(w*(Math.PI/2))},z=function(w){return Math.sin(w*(Math.PI/2))},O=function(w){return-.5*(Math.cos(Math.PI*w)-1)},W=function(w){return w===0?0:Math.pow(2,10*(w-1))},D=function(w){return w===1?1:1-Math.pow(2,-10*w)},V=function(w){return w===0?0:w===1?1:(w/=.5)<1?.5*Math.pow(2,10*(w-1)):.5*(2-Math.pow(2,-10*--w))},Z=function(w){return-(Math.sqrt(1-w*w)-1)},Q=function(w){return Math.sqrt(1-Math.pow(w-1,2))},ce=function(w){return(w/=.5)<1?-.5*(Math.sqrt(1-w*w)-1):.5*(Math.sqrt(1-(w-=2)*w)+1)},ie=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?7.5625*(w-=1.5/2.75)*w+.75:w<2.5/2.75?7.5625*(w-=2.25/2.75)*w+.9375:7.5625*(w-=2.625/2.75)*w+.984375},se=function(w){var B=1.70158;return w*w*((B+1)*w-B)},me=function(w){var B=1.70158;return(w-=1)*w*((B+1)*w+B)+1},ve=function(w){var B=1.70158;return(w/=.5)<1?w*w*((1+(B*=1.525))*w-B)*.5:.5*((w-=2)*w*((1+(B*=1.525))*w+B)+2)},J=function(w){return-1*Math.pow(4,-8*w)*Math.sin((6*w-1)*(2*Math.PI)/2)+1},oe=function(w){var B=1.70158;return(w/=.5)<1?w*w*((1+(B*=1.525))*w-B)*.5:.5*((w-=2)*w*((1+(B*=1.525))*w+B)+2)},Ee=function(w){var B=1.70158;return w*w*((B+1)*w-B)},De=function(w){var B=1.70158;return(w-=1)*w*((B+1)*w+B)+1},_e=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?7.5625*(w-=1.5/2.75)*w+.75:w<2.5/2.75?7.5625*(w-=2.25/2.75)*w+.9375:7.5625*(w-=2.625/2.75)*w+.984375},qe=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?2-(7.5625*(w-=1.5/2.75)*w+.75):w<2.5/2.75?2-(7.5625*(w-=2.25/2.75)*w+.9375):2-(7.5625*(w-=2.625/2.75)*w+.984375)},We=function(w){return(w/=.5)<1?.5*Math.pow(w,4):-.5*((w-=2)*Math.pow(w,3)-2)},Fe=function(w){return Math.pow(w,4)},Ye=function(w){return Math.pow(w,.25)};function X(w,B,te,G,ue,Ne){var Be,rt,dt,Ft,Et,Pt=0,kt=0,rn=0,gi=function(St){return((Pt*St+kt)*St+rn)*St},si=function(St){return(3*Pt*St+2*kt)*St+rn},oi=function(St){return St>=0?St:0-St};return Pt=1-(rn=3*B)-(kt=3*(G-B)-rn),dt=1-(Et=3*te)-(Ft=3*(ue-te)-Et),Be=w,rt=function(St){return 1/(200*St)}(Ne),function(St){return((dt*St+Ft)*St+Et)*St}(function(St,ai){var li,vi,Jt,dn,An,qn;for(Jt=St,qn=0;qn<8;qn++){if(dn=gi(Jt)-St,oi(dn)(vi=1))return vi;for(;lidn?li=Jt:vi=Jt,Jt=.5*(vi-li)+li}return Jt}(Be,rt))}var Lt,Ce=function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:.25,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.25,te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:.75,G=arguments.length>3&&arguments[3]!==void 0?arguments[3]:.75;return function(ue){return X(ue,w,B,te,G,1)}},$e=function(w,B,te,G,ue){var Ne=Ce(B,te,G,ue);return Ne.displayName=w,Ne.x1=B,Ne.y1=te,Ne.x2=G,Ne.y2=ue,ft.formulas[w]=Ne},ze=function(w){return delete ft.formulas[w]};function _t(w,B){if(!(w instanceof B))throw new TypeError("Cannot call a class as a function")}function Ke(w,B){for(var te=0;tew.length)&&(B=w.length);for(var te=0,G=new Array(B);tert?rt:B;w._hasEnded=dt>=rt;var Ft=Ne-(rt-dt),Et=w._filters.length>0;if(w._hasEnded)return w._render(Be,w._data,Ft),w.stop(!0);Et&&w._applyFilter(N),dt1&&arguments[1]!==void 0?arguments[1]:fe,te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Array.isArray(B)){var G=Ce.apply(void 0,ot(B));return G}var ue=ke(B);if(Ge[B])return Ge[B];if(ue===Oe||ue===ne)for(var Ne in w)te[Ne]=B;else for(var Be in w)te[Be]=B[Be]||fe;return te},Vt=function(w){w===we?(we=w._next)?we._previous=null:be=null:w===be?(be=w._previous)?be._next=null:we=null:(le=w._previous,re=w._next,le._next=re,re._previous=le),w._previous=w._next=null},ht=typeof Promise=="function"?Promise:null;Lt=Symbol.toStringTag;var ft=function(){function w(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;_t(this,w),S(this,Lt,"Promise"),this._config={},this._data={},this._delay=0,this._filters=[],this._next=null,this._previous=null,this._timestamp=null,this._hasEnded=!1,this._resolve=null,this._reject=null,this._currentState=G||{},this._originalState={},this._targetState={},this._start=Pe,this._render=Pe,this._promiseCtor=ht,ue&&this.setConfig(ue)}var B,te;return B=w,te=[{key:"_applyFilter",value:function(G){for(var ue=this._filters.length;ue>0;ue--){var Ne=this._filters[ue-ue][G];Ne&&Ne(this)}}},{key:"tween",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;return this._isPlaying&&this.stop(),!G&&this._config||this.setConfig(G),this._pausedAtTime=null,this._timestamp=w.now(),this._start(this.get(),this._data),this._delay&&this._render(this._currentState,this._data,0),this._resume(this._timestamp)}},{key:"setConfig",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ue=this._config;for(var Ne in G)ue[Ne]=G[Ne];var Be=ue.promise,rt=Be===void 0?this._promiseCtor:Be,dt=ue.start,Ft=dt===void 0?Pe:dt,Et=ue.finish,Pt=ue.render,kt=Pt===void 0?this._config.step||Pe:Pt,rn=ue.step,gi=rn===void 0?Pe:rn;this._data=ue.data||ue.attachment||this._data,this._isPlaying=!1,this._pausedAtTime=null,this._scheduleId=null,this._delay=G.delay||0,this._start=Ft,this._render=kt||gi,this._duration=ue.duration||500,this._promiseCtor=rt,Et&&(this._resolve=Et);var si=G.from,oi=G.to,St=oi===void 0?{}:oi,ai=this._currentState,li=this._originalState,vi=this._targetState;for(var Jt in si)ai[Jt]=si[Jt];var dn=!1;for(var An in ai){var qn=ai[An];dn||ke(qn)!==Oe||(dn=!0),li[An]=qn,vi[An]=St.hasOwnProperty(An)?St[An]:qn}if(this._easing=gt(this._currentState,ue.easing,this._easing),this._filters.length=0,dn){for(var wr in w.filters)w.filters[wr].doesApply(this)&&this._filters.push(w.filters[wr]);this._applyFilter(de)}return this}},{key:"then",value:function(G,ue){var Ne=this;return this._promise=new this._promiseCtor(function(Be,rt){Ne._resolve=Be,Ne._reject=rt}),this._promise.then(G,ue)}},{key:"catch",value:function(G){return this.then().catch(G)}},{key:"finally",value:function(G){return this.then().finally(G)}},{key:"get",value:function(){return P({},this._currentState)}},{key:"set",value:function(G){this._currentState=G}},{key:"pause",value:function(){if(this._isPlaying)return this._pausedAtTime=w.now(),this._isPlaying=!1,Vt(this),this}},{key:"resume",value:function(){return this._resume()}},{key:"_resume",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:w.now();return this._timestamp===null?this.tween():this._isPlaying?this._promise:(this._pausedAtTime&&(this._timestamp+=G-this._pausedAtTime,this._pausedAtTime=null),this._isPlaying=!0,we===null?(we=this,be=this):(this._previous=be,be._next=this,be=this),this)}},{key:"seek",value:function(G){G=Math.max(G,0);var ue=w.now();return this._timestamp+G===0||(this._timestamp=ue-G,ge(this,ue)),this}},{key:"stop",value:function(){var G=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(!this._isPlaying)return this;this._isPlaying=!1,Vt(this);var ue=this._filters.length>0;return G&&(ue&&this._applyFilter(N),F(1,this._currentState,this._originalState,this._targetState,1,0,this._easing),ue&&(this._applyFilter(pe),this._applyFilter(ye))),this._resolve&&this._resolve({data:this._data,state:this._currentState,tweenable:this}),this._resolve=null,this._reject=null,this}},{key:"cancel",value:function(){var G=arguments.length>0&&arguments[0]!==void 0&&arguments[0],ue=this._currentState,Ne=this._data,Be=this._isPlaying;return Be?(this._reject&&this._reject({data:Ne,state:ue,tweenable:this}),this._resolve=null,this._reject=null,this.stop(G)):this}},{key:"isPlaying",value:function(){return this._isPlaying}},{key:"hasEnded",value:function(){return this._hasEnded}},{key:"setScheduleFunction",value:function(G){w.setScheduleFunction(G)}},{key:"data",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;return G&&(this._data=P({},G)),this._data}},{key:"dispose",value:function(){for(var G in this)delete this[G]}}],te&&Ke(B.prototype,te),w}();function En(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},B=new ft;return B.tween(w),B.tweenable=B,B}S(ft,"now",function(){return q}),S(ft,"setScheduleFunction",function(w){return Re=w}),S(ft,"filters",{}),S(ft,"formulas",Ge),Le(!0);var ii,ln,Ii=/(\d|-|\.)/,yr=/([^\-0-9.]+)/g,ri=/[0-9.-]+/g,br=(ii=ri.source,ln=/,\s*/.source,new RegExp("rgba?\\(".concat(ii).concat(ln).concat(ii).concat(ln).concat(ii,"(").concat(ln).concat(ii,")?\\)"),"g")),Er=/^.*\(/,Xn=/#([0-9]|[a-f]){3,6}/gi,Ni="VAL",Ss=function(w,B){return w.map(function(te,G){return"_".concat(B,"_").concat(G)})};function R(w){return parseInt(w,16)}var H=function(w){return"rgb(".concat((B=w,(B=B.replace(/#/,"")).length===3&&(B=(B=B.split(""))[0]+B[0]+B[1]+B[1]+B[2]+B[2]),[R(B.substr(0,2)),R(B.substr(2,2)),R(B.substr(4,2))]).join(","),")");var B},j=function(w,B,te){var G=B.match(w),ue=B.replace(w,Ni);return G&&G.forEach(function(Ne){return ue=ue.replace(Ni,te(Ne))}),ue},K=function(w){for(var B in w){var te=w[B];typeof te=="string"&&te.match(Xn)&&(w[B]=j(Xn,te,H))}},Y=function(w){var B=w.match(ri),te=B.slice(0,3).map(Math.floor),G=w.match(Er)[0];if(B.length===3)return"".concat(G).concat(te.join(","),")");if(B.length===4)return"".concat(G).concat(te.join(","),",").concat(B[3],")");throw new Error("Invalid rgbChunk: ".concat(w))},Se=function(w){return w.match(ri)},Ie=function(w,B){var te={};return B.forEach(function(G){te[G]=w[G],delete w[G]}),te},He=function(w,B){return B.map(function(te){return w[te]})},Xe=function(w,B){return B.forEach(function(te){return w=w.replace(Ni,+te.toFixed(4))}),w},et=function(w){for(var B in w._currentState)if(typeof w._currentState[B]=="string")return!0;return!1};function je(w){var B=w._currentState;[B,w._originalState,w._targetState].forEach(K),w._tokenData=function(te){var G,ue,Ne={};for(var Be in te){var rt=te[Be];typeof rt=="string"&&(Ne[Be]={formatString:(G=rt,ue=void 0,ue=G.match(yr),ue?(ue.length===1||G.charAt(0).match(Ii))&&ue.unshift(""):ue=["",""],ue.join(Ni)),chunkNames:Ss(Se(rt),Be)})}return Ne}(B)}function Ze(w){var B=w._currentState,te=w._originalState,G=w._targetState,ue=w._easing,Ne=w._tokenData;(function(Be,rt){var dt=function(Et){var Pt=rt[Et].chunkNames,kt=Be[Et];if(typeof kt=="string"){var rn=kt.split(" "),gi=rn[rn.length-1];Pt.forEach(function(si,oi){return Be[si]=rn[oi]||gi})}else Pt.forEach(function(si){return Be[si]=kt});delete Be[Et]};for(var Ft in rt)dt(Ft)})(ue,Ne),[B,te,G].forEach(function(Be){return function(rt,dt){var Ft=function(Pt){Se(rt[Pt]).forEach(function(kt,rn){return rt[dt[Pt].chunkNames[rn]]=+kt}),delete rt[Pt]};for(var Et in dt)Ft(Et)}(Be,Ne)})}function xt(w){var B=w._currentState,te=w._originalState,G=w._targetState,ue=w._easing,Ne=w._tokenData;[B,te,G].forEach(function(Be){return function(rt,dt){for(var Ft in dt){var Et=dt[Ft],Pt=Et.chunkNames,kt=Et.formatString,rn=Xe(kt,He(Ie(rt,Pt),Pt));rt[Ft]=j(br,rn,Y)}}(Be,Ne)}),function(Be,rt){for(var dt in rt){var Ft=rt[dt].chunkNames,Et=Be[Ft[0]];Be[dt]=typeof Et=="string"?Ft.map(function(Pt){var kt=Be[Pt];return delete Be[Pt],kt}).join(" "):Et}}(ue,Ne)}function Gt(w,B){var te=Object.keys(w);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(w);B&&(G=G.filter(function(ue){return Object.getOwnPropertyDescriptor(w,ue).enumerable})),te.push.apply(te,G)}return te}function zt(w){for(var B=1;B4&&arguments[4]!==void 0?arguments[4]:0,Ne=zt({},w),Be=gt(w,G);for(var rt in at._filters.length=0,at.set({}),at._currentState=Ne,at._originalState=w,at._targetState=B,at._easing=Be,Qe)Qe[rt].doesApply(at)&&at._filters.push(Qe[rt]);at._applyFilter("tweenCreated"),at._applyFilter("beforeTween");var dt=F(te,Ne,w,B,1,ue,Be);return at._applyFilter("afterTween"),dt};function yt(w,B){(B==null||B>w.length)&&(B=w.length);for(var te=0,G=new Array(B);tec.strokeWidth&&(u=c.trailWidth);var f=50-u/2;return o.render(this._pathTemplate,{radius:f,"2radius":f*2})},a.prototype._trailString=function(c){return this._pathString(c)},n.exports=a},{"./shape":8,"./utils":10}],4:[function(t,n,i){var s=t("./shape"),o=t("./utils"),a=function(c,u){this._pathTemplate=u.vertical?"M {center},100 L {center},0":"M 0,{center} L 100,{center}",s.apply(this,arguments)};a.prototype=new s,a.prototype.constructor=a,a.prototype._initializeSvg=function(c,u){var f=u.vertical?"0 0 "+u.strokeWidth+" 100":"0 0 100 "+u.strokeWidth;c.setAttribute("viewBox",f),c.setAttribute("preserveAspectRatio","none")},a.prototype._pathString=function(c){return o.render(this._pathTemplate,{center:c.strokeWidth/2})},a.prototype._trailString=function(c){return this._pathString(c)},n.exports=a},{"./shape":8,"./utils":10}],5:[function(t,n,i){n.exports={Line:t("./line"),Circle:t("./circle"),SemiCircle:t("./semicircle"),Square:t("./square"),Path:t("./path"),Shape:t("./shape"),utils:t("./utils")}},{"./circle":3,"./line":4,"./path":6,"./semicircle":7,"./shape":8,"./square":9,"./utils":10}],6:[function(t,n,i){var s=t("shifty"),o=t("./utils"),a=s.Tweenable,l={easeIn:"easeInCubic",easeOut:"easeOutCubic",easeInOut:"easeInOutCubic"},c=function u(f,h){if(!(this instanceof u))throw new Error("Constructor was called without new keyword");h=o.extend({delay:0,duration:800,easing:"linear",from:{},to:{},step:function(){}},h);var p;o.isString(f)?p=document.querySelector(f):p=f,this.path=p,this._opts=h,this._tweenable=null;var _=this.path.getTotalLength();this.path.style.strokeDasharray=_+" "+_,this.set(0)};c.prototype.value=function(){var f=this._getComputedDashOffset(),h=this.path.getTotalLength(),p=1-f/h;return parseFloat(p.toFixed(6),10)},c.prototype.set=function(f){this.stop(),this.path.style.strokeDashoffset=this._progressToOffset(f);var h=this._opts.step;if(o.isFunction(h)){var p=this._easing(this._opts.easing),_=this._calculateTo(f,p),g=this._opts.shape||this;h(_,g,this._opts.attachment)}},c.prototype.stop=function(){this._stopTween(),this.path.style.strokeDashoffset=this._getComputedDashOffset()},c.prototype.animate=function(f,h,p){h=h||{},o.isFunction(h)&&(p=h,h={});var _=o.extend({},h),g=o.extend({},this._opts);h=o.extend(g,h);var m=this._easing(h.easing),d=this._resolveFromAndTo(f,m,_);this.stop(),this.path.getBoundingClientRect();var x=this._getComputedDashOffset(),v=this._progressToOffset(f),y=this;this._tweenable=new a,this._tweenable.tween({from:o.extend({offset:x},d.from),to:o.extend({offset:v},d.to),duration:h.duration,delay:h.delay,easing:m,step:function(b){y.path.style.strokeDashoffset=b.offset;var M=h.shape||y;h.step(b,M,h.attachment)}}).then(function(b){o.isFunction(p)&&p()}).catch(function(b){throw console.error("Error in tweening:",b),b})},c.prototype._getComputedDashOffset=function(){var f=window.getComputedStyle(this.path,null);return parseFloat(f.getPropertyValue("stroke-dashoffset"),10)},c.prototype._progressToOffset=function(f){var h=this.path.getTotalLength();return h-f*h},c.prototype._resolveFromAndTo=function(f,h,p){return p.from&&p.to?{from:p.from,to:p.to}:{from:this._calculateFrom(h),to:this._calculateTo(f,h)}},c.prototype._calculateFrom=function(f){return s.interpolate(this._opts.from,this._opts.to,this.value(),f)},c.prototype._calculateTo=function(f,h){return s.interpolate(this._opts.from,this._opts.to,f,h)},c.prototype._stopTween=function(){this._tweenable!==null&&(this._tweenable.stop(!0),this._tweenable=null)},c.prototype._easing=function(f){return l.hasOwnProperty(f)?l[f]:f},n.exports=c},{"./utils":10,shifty:2}],7:[function(t,n,i){var s=t("./shape"),o=t("./circle"),a=t("./utils"),l=function(u,f){this._pathTemplate="M 50,50 m -{radius},0 a {radius},{radius} 0 1 1 {2radius},0",this.containerAspectRatio=2,s.apply(this,arguments)};l.prototype=new s,l.prototype.constructor=l,l.prototype._initializeSvg=function(u,f){u.setAttribute("viewBox","0 0 100 50")},l.prototype._initializeTextContainer=function(u,f,h){u.text.style&&(h.style.top="auto",h.style.bottom="0",u.text.alignToBottom?a.setStyle(h,"transform","translate(-50%, 0)"):a.setStyle(h,"transform","translate(-50%, 50%)"))},l.prototype._pathString=o.prototype._pathString,l.prototype._trailString=o.prototype._trailString,n.exports=l},{"./circle":3,"./shape":8,"./utils":10}],8:[function(t,n,i){var s=t("./path"),o=t("./utils"),a="Object is destroyed",l=function c(u,f){if(!(this instanceof c))throw new Error("Constructor was called without new keyword");if(arguments.length!==0){this._opts=o.extend({color:"#555",strokeWidth:1,trailColor:null,trailWidth:null,fill:null,text:{style:{color:null,position:"absolute",left:"50%",top:"50%",padding:0,margin:0,transform:{prefix:!0,value:"translate(-50%, -50%)"}},autoStyleContainer:!0,alignToBottom:!0,value:null,className:"progressbar-text"},svgStyle:{display:"block",width:"100%"},warnings:!1},f,!0),o.isObject(f)&&f.svgStyle!==void 0&&(this._opts.svgStyle=f.svgStyle),o.isObject(f)&&o.isObject(f.text)&&f.text.style!==void 0&&(this._opts.text.style=f.text.style);var h=this._createSvgView(this._opts),p;if(o.isString(u)?p=document.querySelector(u):p=u,!p)throw new Error("Container does not exist: "+u);this._container=p,this._container.appendChild(h.svg),this._opts.warnings&&this._warnContainerAspectRatio(this._container),this._opts.svgStyle&&o.setStyles(h.svg,this._opts.svgStyle),this.svg=h.svg,this.path=h.path,this.trail=h.trail,this.text=null;var _=o.extend({attachment:void 0,shape:this},this._opts);this._progressPath=new s(h.path,_),o.isObject(this._opts.text)&&this._opts.text.value!==null&&this.setText(this._opts.text.value)}};l.prototype.animate=function(u,f,h){if(this._progressPath===null)throw new Error(a);this._progressPath.animate(u,f,h)},l.prototype.stop=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath.stop()},l.prototype.pause=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath._tweenable&&this._progressPath._tweenable.pause()},l.prototype.resume=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath._tweenable&&this._progressPath._tweenable.resume()},l.prototype.destroy=function(){if(this._progressPath===null)throw new Error(a);this.stop(),this.svg.parentNode.removeChild(this.svg),this.svg=null,this.path=null,this.trail=null,this._progressPath=null,this.text!==null&&(this.text.parentNode.removeChild(this.text),this.text=null)},l.prototype.set=function(u){if(this._progressPath===null)throw new Error(a);this._progressPath.set(u)},l.prototype.value=function(){if(this._progressPath===null)throw new Error(a);return this._progressPath===void 0?0:this._progressPath.value()},l.prototype.setText=function(u){if(this._progressPath===null)throw new Error(a);this.text===null&&(this.text=this._createTextContainer(this._opts,this._container),this._container.appendChild(this.text)),o.isObject(u)?(o.removeChildren(this.text),this.text.appendChild(u)):this.text.innerHTML=u},l.prototype._createSvgView=function(u){var f=document.createElementNS("http://www.w3.org/2000/svg","svg");this._initializeSvg(f,u);var h=null;(u.trailColor||u.trailWidth)&&(h=this._createTrail(u),f.appendChild(h));var p=this._createPath(u);return f.appendChild(p),{svg:f,path:p,trail:h}},l.prototype._initializeSvg=function(u,f){u.setAttribute("viewBox","0 0 100 100")},l.prototype._createPath=function(u){var f=this._pathString(u);return this._createPathElement(f,u)},l.prototype._createTrail=function(u){var f=this._trailString(u),h=o.extend({},u);return h.trailColor||(h.trailColor="#eee"),h.trailWidth||(h.trailWidth=h.strokeWidth),h.color=h.trailColor,h.strokeWidth=h.trailWidth,h.fill=null,this._createPathElement(f,h)},l.prototype._createPathElement=function(u,f){var h=document.createElementNS("http://www.w3.org/2000/svg","path");return h.setAttribute("d",u),h.setAttribute("stroke",f.color),h.setAttribute("stroke-width",f.strokeWidth),f.fill?h.setAttribute("fill",f.fill):h.setAttribute("fill-opacity","0"),h},l.prototype._createTextContainer=function(u,f){var h=document.createElement("div");h.className=u.text.className;var p=u.text.style;return p&&(u.text.autoStyleContainer&&(f.style.position="relative"),o.setStyles(h,p),p.color||(h.style.color=u.color)),this._initializeTextContainer(u,f,h),h},l.prototype._initializeTextContainer=function(c,u,f){},l.prototype._pathString=function(u){throw new Error("Override this function for each progress bar")},l.prototype._trailString=function(u){throw new Error("Override this function for each progress bar")},l.prototype._warnContainerAspectRatio=function(u){if(this.containerAspectRatio){var f=window.getComputedStyle(u,null),h=parseFloat(f.getPropertyValue("width"),10),p=parseFloat(f.getPropertyValue("height"),10);o.floatEquals(this.containerAspectRatio,h/p)||(console.warn("Incorrect aspect ratio of container","#"+u.id,"detected:",f.getPropertyValue("width")+"(width)","/",f.getPropertyValue("height")+"(height)","=",h/p),console.warn("Aspect ratio of should be",this.containerAspectRatio))}},n.exports=l},{"./path":6,"./utils":10}],9:[function(t,n,i){var s=t("./shape"),o=t("./utils"),a=function(c,u){this._pathTemplate="M 0,{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{strokeWidth}",this._trailTemplate="M {startMargin},{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{halfOfStrokeWidth}",s.apply(this,arguments)};a.prototype=new s,a.prototype.constructor=a,a.prototype._pathString=function(c){var u=100-c.strokeWidth/2;return o.render(this._pathTemplate,{width:u,strokeWidth:c.strokeWidth,halfOfStrokeWidth:c.strokeWidth/2})},a.prototype._trailString=function(c){var u=100-c.strokeWidth/2;return o.render(this._trailTemplate,{width:u,strokeWidth:c.strokeWidth,halfOfStrokeWidth:c.strokeWidth/2,startMargin:c.strokeWidth/2-c.trailWidth/2})},n.exports=a},{"./shape":8,"./utils":10}],10:[function(t,n,i){var s=t("lodash.merge"),o="Webkit Moz O ms".split(" "),a=.001;function l(v,y){var b=v;for(var M in y)if(y.hasOwnProperty(M)){var T=y[M],I="\\{"+M+"\\}",E=new RegExp(I,"g");b=b.replace(E,T)}return b}function c(v,y,b){for(var M=v.style,T=0;T{a.isMesh&&i.push(a)});if(i.length>0){const s=new rb(i);s.attributes=["position","color","normal","tangent","uv","uv2"],s.applyWorldTransforms=!1;let o=new Mn(s.generate(),new Ri),a=new mc(o.geometry,{strategy:Gf,maxLeafTris:1});this.result={scene:t.scene,bvh:a,mesh:o},console.log("==> loaded mesh ",e)}return this.result}}function Bn(r){return new C(r[0],r[1],r[2])}const k={scene_name:"standard-shader-ball",smooth_normals:!0,bounces:6,max_samples:1024,max_volume_steps:8,wireframe:!1,neutral_color:[.5,.5,.5],skyPower:.5,skyColor:[.8,.8,1],sunPower:.35,sunAngularSize:40,sunLatitude:40,sunLongitude:180,sunColor:[1,1,.8],base_weight:1,base_color:[.8,.8,.8],base_roughness:0,base_metalness:0,diffuse_mode:6,specular_weight:1,specular_color:[1,1,1],specular_roughness:.1,specular_anisotropy:0,specular_rotation:0,specular_ior:1.6,transmission_weight:0,transmission_color:[1,1,1],transmission_depth:0,transmission_scatter:[0,0,0],transmission_scatter_anisotropy:0,transmission_dispersion_abbe_number:20,transmission_dispersion_scale:0,subsurface_weight:0,subsurface_color:[.8,.8,.8],subsurface_radius:.2,subsurface_radius_scale:[1,.5,.25],subsurface_anisotropy:0,subsurface_mode:0,coat_weight:0,coat_color:[1,1,1],coat_roughness:0,coat_anisotropy:0,coat_rotation:0,coat_ior:1.3,coat_darkening:1,fuzz_weight:0,fuzz_color:[1,1,1],fuzz_roughness:.5,emission_luminance:0,emission_color:[1,1,1],thin_film_weight:0,thin_film_thickness:1e3,thin_film_ior:1.4,geometry_opacity:1,geometry_thin_walled:!1,reset_camera:function(){vc(k.scene_name)}};let qt,Mt,Ot,Li,Xi,as,_a,Je,Zf,io,ur=0,es,ts,Kl,Zl;var gn,gc,ro,Ks,Rb={"Standard Shader Ball":"standard-shader-ball",Glavius:"glavius",Terrain:"terrain","Bearded Man":"bearded-man"},Lb={"OpenPBR (orig, 3-float)":0,"OpenPBR (luminace)":1,"OpenPBR (average)":2,"OpenPBR (max value)":3,"OpenPBR (weighted average)":4,"SPI / Arnold v1":5,"Arnold v2":6,"Uniform scattering":7},Qf={Lambert:0,"ON Full (Mitsuba)":1,"ON Qualitative (QON)":2,"ON Qualitative - Energy Conserving (EQON exact)":3,"ON Qualitative - Energy Conserving (EQON approx)":4,"Fujii - Qualitative (FON)":5,"Fujii - Energy Conserving (EFON exact)":6,"Fujii - Energy Conserving (EFON approx)":7,"Fujii - MaterialX":8,"Chan Diffuse (Unreal)":9,"d'Eon sphere model":10},Qf={Lambert:0,"ON Full (Mitsuba)":1,"ON Qualitative (QON)":2,"ON Qualitative - Energy Conserving (EQON exact)":3,"ON Qualitative - Energy Conserving (EQON approx)":4,"Fujii - Qualitative (FON)":5,"Fujii - Energy Conserving (EFON exact)":6,"Fujii - Energy Conserving (EFON approx)":7,"Fujii - Energy Conserving (EFON exact, LTC sampling)":8,"Fujii - Energy Conserving (EFON approx, LTC sampling)":9,"Fujii - MaterialX":10,"Chan Diffuse (Unreal)":11,"d'Eon sphere model":12};Db();Zs();function Cb(){let r=(90-k.sunLatitude)*Math.PI/180,e=k.sunLongitude*Math.PI/180,t=Math.cos(r),n=Math.sin(r),i=Math.cos(e),s=Math.sin(e),o=n*i,a=n*s,l=t;k.sunDir=[o,l,a]}function Pb(){Li=new b0;const r=new Bf(16777215,1);return r.position.set(1,1,1),Li.add(r),Li.add(new K0(11583173,.5)),Li}function Db(){gn=new Tb.Circle("#progress_overlay",{color:"rgba(255, 128, 64, 0.75)",strokeWidth:5,trailColor:"rgba(255, 128, 64, 0.333)",trailWidth:3,svgStyle:{display:"block",width:"100%"},text:{value:"",className:"progressbar__label",style:{color:"rgba(169, 85, 42, 1.0)",position:"absolute",fontWeight:"bold",left:"50%",top:"50%",padding:0,margin:0,transform:{prefix:!0,value:"translate(-50%, -50%)"}},autoStyleContainer:!0,alignToBottom:!0},fill:null,duration:2e3,easing:"linear",from:{color:"rgba( 0, 0, 0, 0.0)"},to:{color:"rgba(32, 255, 32, 1.0)"},warnings:!0}),gn.set(0),gn.setText(""),ro=!1,es=null,ts=null,Kl=null,Zl=null,qt=new Pf({antialias:!0,preserveDrawingBuffer:!0}),qt.setPixelRatio(window.devicePixelRatio),qt.setClearColor(594970),qt.setSize(window.innerWidth,window.innerHeight),qt.outputEncoding=$i,document.body.appendChild(qt.domElement),Li=Pb(),as=new Yx,document.body.appendChild(as.dom);let r=document.getElementById("samples");r.style.visibility="visible";let e=document.getElementById("info");e.style.visibility="visible",Je=new Zi({defines:{BOUNCES:k.bounces,MAX_VOLUME_STEPS:k.max_volume_steps,COAT_ENABLED:!1,TRANSMISSION_ENABLED:!1,VOLUME_ENABLED:!1,DISPERSION_ENABLED:!1,THIN_FILM_ENABLED:!1},uniforms:{bvh_surface:{value:new kh},normalAttribute_surface:{value:new Vs},tangentAttribute_surface:{value:new Vs},has_normals_surface:{value:1},has_tangents_surface:{value:0},bvh_props:{value:new kh},normalAttribute_props:{value:new Vs},tangentAttribute_props:{value:new Vs},has_normals_props:{value:1},has_tangents_props:{value:0},cameraWorldMatrix:{value:new Ve},invProjectionMatrix:{value:new Ve},invModelMatrix:{value:new Ve},resolution:{value:new Ue},samples:{value:0},accumulation_weight:{value:1},wireframe:{value:k.wireframe},neutral_color:{value:new C().fromArray(k.neutral_color)},smooth_normals:{value:k.smooth_normals},skyPower:{value:k.skyPower},skyColor:{value:Bn(k.skyColor)},sunPower:{value:Math.pow(10,k.sunPower)},sunAngularSize:{value:k.sunAngularSize},sunColor:{value:Bn(k.sunColor)},sunDir:{value:Bn([0,0,0])},diffuse_mode:{value:k.diffuse_mode},base_weight:{value:k.base_weight},base_color:{value:Bn(k.base_color)},base_roughness:{value:k.base_roughness},base_metalness:{value:k.base_metalness},specular_weight:{value:k.specular_weight},specular_color:{value:Bn(k.specular_color)},specular_roughness:{value:k.specular_roughness},specular_anisotropy:{value:k.specular_anisotropy},specular_rotation:{value:k.specular_rotation},specular_ior:{value:k.specular_ior},transmission_weight:{value:k.transmission_weight},transmission_color:{value:Bn(k.transmission_color)},transmission_depth:{value:k.transmission_depth},transmission_scatter:{value:Bn(k.transmission_scatter)},transmission_scatter_anisotropy:{value:k.transmission_scatter_anisotropy},transmission_dispersion_abbe_number:{value:k.transmission_dispersion_abbe_number},transmission_dispersion_scale:{value:k.transmission_dispersion_scale},subsurface_weight:{value:k.subsurface_weight},subsurface_color:{value:Bn(k.subsurface_color)},subsurface_radius:{value:k.subsurface_radius},subsurface_radius_scale:{value:Bn(k.subsurface_radius_scale)},subsurface_anisotropy:{value:k.subsurface_anisotropy},subsurface_mode:{value:k.subsurface_mode},coat_weight:{value:k.coat_weight},coat_color:{value:Bn(k.coat_color)},coat_roughness:{value:k.coat_roughness},coat_anisotropy:{value:k.coat_anisotropy},coat_rotation:{value:k.coat_rotation},coat_ior:{value:k.coat_ior},coat_darkening:{value:k.coat_darkening},fuzz_weight:{value:k.fuzz_weight},fuzz_color:{value:Bn(k.fuzz_color)},fuzz_roughness:{value:k.fuzz_roughness},emission_luminance:{value:k.emission_luminance},emission_color:{value:Bn(k.emission_color)},thin_film_weight:{value:k.thin_film_weight},thin_film_thickness:{value:k.thin_film_thickness},thin_film_ior:{value:k.thin_film_ior},geometry_opacity:{value:k.geometry_opacity},geometry_thin_walled:{value:k.geometry_thin_walled}},vertexShader:` +`;function ia(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Kf={exports:{}};(function(r,e){(function(t){r.exports=t()})(function(){return function(){function t(n,i,s){function o(c,u){if(!i[c]){if(!n[c]){var f=typeof ia=="function"&&ia;if(!u&&f)return f(c,!0);if(a)return a(c,!0);var h=new Error("Cannot find module '"+c+"'");throw h.code="MODULE_NOT_FOUND",h}var p=i[c]={exports:{}};n[c][0].call(p.exports,function(_){var g=n[c][1][_];return o(g||_)},p,p.exports,t,n,i,s)}return i[c].exports}for(var a=typeof ia=="function"&&ia,l=0;l-1}function Sr(L,U){var $=this.__data__,Te=xt($,L);return Te<0?(++this.size,$.push([L,U])):$[Te][1]=U,this}ln.prototype.clear=Ii,ln.prototype.delete=yr,ln.prototype.get=ri,ln.prototype.has=br,ln.prototype.set=Sr;function Xn(L){var U=-1,$=L==null?0:L.length;for(this.clear();++U<$;){var Te=L[U];this.set(Te[0],Te[1])}}function Ni(){this.size=0,this.__data__={hash:new gt,map:new(he||ln),string:new gt}}function Es(L){var U=Be(this,L).delete(L);return this.size-=U?1:0,U}function R(L){return Be(this,L).get(L)}function H(L){return Be(this,L).has(L)}function j(L,U){var $=Be(this,L),Te=$.size;return $.set(L,U),this.size+=$.size==Te?0:1,this}Xn.prototype.clear=Ni,Xn.prototype.delete=Es,Xn.prototype.get=R,Xn.prototype.has=H,Xn.prototype.set=j;function K(L){var U=this.__data__=new ln(L);this.size=U.size}function Y(){this.__data__=new ln,this.size=0}function Ee(L){var U=this.__data__,$=U.delete(L);return this.size=U.size,$}function Ie(L){return this.__data__.get(L)}function He(L){return this.__data__.has(L)}function Xe(L,U){var $=this.__data__;if($ instanceof ln){var Te=$.__data__;if(!he||Te.length1?$[ut-1]:void 0,Dt=ut>2?$[2]:void 0;for(wt=L.length>3&&typeof wt=="function"?(ut--,wt):void 0,Dt&&Pt($[0],$[1],Dt)&&(wt=ut<3?void 0:wt,ut=1),U=Object(U);++Te-1&&L%1==0&&L0){if(++U>=l)return arguments[0]}else U=0;return L.apply(void 0,arguments)}}function Jt(L){if(L!=null){try{return le.call(L)}catch{}try{return L+""}catch{}}return""}function dn(L,U){return L===U||L!==L&&U!==U}var An=at(function(){return arguments}())?at:function(L){return ws(L)&&re.call(L,"callee")&&!we.call(L,"callee")},qn=Array.isArray;function wr(L){return L!=null&&yc(L.length)&&!Ta(L)}function Jf(L){return ws(L)&&wr(L)}var xc=ge||rd;function Ta(L){if(!er(L))return!1;var U=cn(L);return U==d||U==x||U==p||U==T}function yc(L){return typeof L=="number"&&L>-1&&L%1==0&&L<=u}function er(L){var U=typeof L;return L!=null&&(U=="object"||U=="function")}function ws(L){return L!=null&&typeof L=="object"}function ed(L){if(!ws(L)||cn(L)!=M)return!1;var U=Re(L);if(U===null)return!0;var $=re.call(U,"constructor")&&U.constructor;return typeof $=="function"&&$ instanceof $&&le.call($)==pe}var bc=ze?ke(ze):Ji;function td(L){return G(L,Sc(L))}function Sc(L){return wr(L)?et(L,!0):yt(L)}var nd=ue(function(L,U,$){Fn(L,U,$)});function id(L){return function(){return L}}function Ec(L){return L}function rd(){return!1}n.exports=nd}).call(this)}).call(this,typeof Hl<"u"?Hl:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(t,n,i){/*! For license information please see shifty.js.LICENSE.txt */(function(s,o){typeof i=="object"&&typeof n=="object"?n.exports=o():typeof i=="object"?i.shifty=o():s.shifty=o()})(self,function(){return function(){var s={720:function(l,c,u){u.r(c),u.d(c,{Scene:function(){return Wt},Tweenable:function(){return ft},interpolate:function(){return Ji},processTweens:function(){return ae},setBezierFunction:function(){return $e},shouldScheduleUpdate:function(){return Le},tween:function(){return Sn},unsetBezierFunction:function(){return ze}});var f={};u.r(f),u.d(f,{bounce:function(){return _e},bouncePast:function(){return qe},easeFrom:function(){return Fe},easeFromTo:function(){return We},easeInBack:function(){return se},easeInCirc:function(){return Z},easeInCubic:function(){return d},easeInExpo:function(){return W},easeInOutBack:function(){return ve},easeInOutCirc:function(){return ce},easeInOutCubic:function(){return v},easeInOutExpo:function(){return V},easeInOutQuad:function(){return m},easeInOutQuart:function(){return M},easeInOutQuint:function(){return S},easeInOutSine:function(){return O},easeInQuad:function(){return _},easeInQuart:function(){return y},easeInQuint:function(){return T},easeInSine:function(){return A},easeOutBack:function(){return me},easeOutBounce:function(){return ie},easeOutCirc:function(){return Q},easeOutCubic:function(){return x},easeOutExpo:function(){return D},easeOutQuad:function(){return g},easeOutQuart:function(){return b},easeOutQuint:function(){return I},easeOutSine:function(){return z},easeTo:function(){return Ye},elastic:function(){return J},linear:function(){return p},swingFrom:function(){return Se},swingFromTo:function(){return oe},swingTo:function(){return De}});var h={};u.r(h),u.d(h,{afterTween:function(){return xt},beforeTween:function(){return Ze},doesApply:function(){return et},tweenCreated:function(){return je}});var p=function(w){return w},_=function(w){return Math.pow(w,2)},g=function(w){return-(Math.pow(w-1,2)-1)},m=function(w){return(w/=.5)<1?.5*Math.pow(w,2):-.5*((w-=2)*w-2)},d=function(w){return Math.pow(w,3)},x=function(w){return Math.pow(w-1,3)+1},v=function(w){return(w/=.5)<1?.5*Math.pow(w,3):.5*(Math.pow(w-2,3)+2)},y=function(w){return Math.pow(w,4)},b=function(w){return-(Math.pow(w-1,4)-1)},M=function(w){return(w/=.5)<1?.5*Math.pow(w,4):-.5*((w-=2)*Math.pow(w,3)-2)},T=function(w){return Math.pow(w,5)},I=function(w){return Math.pow(w-1,5)+1},S=function(w){return(w/=.5)<1?.5*Math.pow(w,5):.5*(Math.pow(w-2,5)+2)},A=function(w){return 1-Math.cos(w*(Math.PI/2))},z=function(w){return Math.sin(w*(Math.PI/2))},O=function(w){return-.5*(Math.cos(Math.PI*w)-1)},W=function(w){return w===0?0:Math.pow(2,10*(w-1))},D=function(w){return w===1?1:1-Math.pow(2,-10*w)},V=function(w){return w===0?0:w===1?1:(w/=.5)<1?.5*Math.pow(2,10*(w-1)):.5*(2-Math.pow(2,-10*--w))},Z=function(w){return-(Math.sqrt(1-w*w)-1)},Q=function(w){return Math.sqrt(1-Math.pow(w-1,2))},ce=function(w){return(w/=.5)<1?-.5*(Math.sqrt(1-w*w)-1):.5*(Math.sqrt(1-(w-=2)*w)+1)},ie=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?7.5625*(w-=1.5/2.75)*w+.75:w<2.5/2.75?7.5625*(w-=2.25/2.75)*w+.9375:7.5625*(w-=2.625/2.75)*w+.984375},se=function(w){var B=1.70158;return w*w*((B+1)*w-B)},me=function(w){var B=1.70158;return(w-=1)*w*((B+1)*w+B)+1},ve=function(w){var B=1.70158;return(w/=.5)<1?w*w*((1+(B*=1.525))*w-B)*.5:.5*((w-=2)*w*((1+(B*=1.525))*w+B)+2)},J=function(w){return-1*Math.pow(4,-8*w)*Math.sin((6*w-1)*(2*Math.PI)/2)+1},oe=function(w){var B=1.70158;return(w/=.5)<1?w*w*((1+(B*=1.525))*w-B)*.5:.5*((w-=2)*w*((1+(B*=1.525))*w+B)+2)},Se=function(w){var B=1.70158;return w*w*((B+1)*w-B)},De=function(w){var B=1.70158;return(w-=1)*w*((B+1)*w+B)+1},_e=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?7.5625*(w-=1.5/2.75)*w+.75:w<2.5/2.75?7.5625*(w-=2.25/2.75)*w+.9375:7.5625*(w-=2.625/2.75)*w+.984375},qe=function(w){return w<1/2.75?7.5625*w*w:w<2/2.75?2-(7.5625*(w-=1.5/2.75)*w+.75):w<2.5/2.75?2-(7.5625*(w-=2.25/2.75)*w+.9375):2-(7.5625*(w-=2.625/2.75)*w+.984375)},We=function(w){return(w/=.5)<1?.5*Math.pow(w,4):-.5*((w-=2)*Math.pow(w,3)-2)},Fe=function(w){return Math.pow(w,4)},Ye=function(w){return Math.pow(w,.25)};function X(w,B,te,G,ue,Ne){var Be,rt,dt,Ft,St,Pt=0,kt=0,rn=0,gi=function(Et){return((Pt*Et+kt)*Et+rn)*Et},si=function(Et){return(3*Pt*Et+2*kt)*Et+rn},oi=function(Et){return Et>=0?Et:0-Et};return Pt=1-(rn=3*B)-(kt=3*(G-B)-rn),dt=1-(St=3*te)-(Ft=3*(ue-te)-St),Be=w,rt=function(Et){return 1/(200*Et)}(Ne),function(Et){return((dt*Et+Ft)*Et+St)*Et}(function(Et,ai){var li,vi,Jt,dn,An,qn;for(Jt=Et,qn=0;qn<8;qn++){if(dn=gi(Jt)-Et,oi(dn)(vi=1))return vi;for(;lidn?li=Jt:vi=Jt,Jt=.5*(vi-li)+li}return Jt}(Be,rt))}var Lt,Ce=function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:.25,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.25,te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:.75,G=arguments.length>3&&arguments[3]!==void 0?arguments[3]:.75;return function(ue){return X(ue,w,B,te,G,1)}},$e=function(w,B,te,G,ue){var Ne=Ce(B,te,G,ue);return Ne.displayName=w,Ne.x1=B,Ne.y1=te,Ne.x2=G,Ne.y2=ue,ft.formulas[w]=Ne},ze=function(w){return delete ft.formulas[w]};function _t(w,B){if(!(w instanceof B))throw new TypeError("Cannot call a class as a function")}function Ke(w,B){for(var te=0;tew.length)&&(B=w.length);for(var te=0,G=new Array(B);tert?rt:B;w._hasEnded=dt>=rt;var Ft=Ne-(rt-dt),St=w._filters.length>0;if(w._hasEnded)return w._render(Be,w._data,Ft),w.stop(!0);St&&w._applyFilter(N),dt1&&arguments[1]!==void 0?arguments[1]:fe,te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Array.isArray(B)){var G=Ce.apply(void 0,ot(B));return G}var ue=ke(B);if(Ge[B])return Ge[B];if(ue===Oe||ue===ne)for(var Ne in w)te[Ne]=B;else for(var Be in w)te[Be]=B[Be]||fe;return te},Vt=function(w){w===we?(we=w._next)?we._previous=null:be=null:w===be?(be=w._previous)?be._next=null:we=null:(le=w._previous,re=w._next,le._next=re,re._previous=le),w._previous=w._next=null},ht=typeof Promise=="function"?Promise:null;Lt=Symbol.toStringTag;var ft=function(){function w(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;_t(this,w),E(this,Lt,"Promise"),this._config={},this._data={},this._delay=0,this._filters=[],this._next=null,this._previous=null,this._timestamp=null,this._hasEnded=!1,this._resolve=null,this._reject=null,this._currentState=G||{},this._originalState={},this._targetState={},this._start=Pe,this._render=Pe,this._promiseCtor=ht,ue&&this.setConfig(ue)}var B,te;return B=w,te=[{key:"_applyFilter",value:function(G){for(var ue=this._filters.length;ue>0;ue--){var Ne=this._filters[ue-ue][G];Ne&&Ne(this)}}},{key:"tween",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;return this._isPlaying&&this.stop(),!G&&this._config||this.setConfig(G),this._pausedAtTime=null,this._timestamp=w.now(),this._start(this.get(),this._data),this._delay&&this._render(this._currentState,this._data,0),this._resume(this._timestamp)}},{key:"setConfig",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ue=this._config;for(var Ne in G)ue[Ne]=G[Ne];var Be=ue.promise,rt=Be===void 0?this._promiseCtor:Be,dt=ue.start,Ft=dt===void 0?Pe:dt,St=ue.finish,Pt=ue.render,kt=Pt===void 0?this._config.step||Pe:Pt,rn=ue.step,gi=rn===void 0?Pe:rn;this._data=ue.data||ue.attachment||this._data,this._isPlaying=!1,this._pausedAtTime=null,this._scheduleId=null,this._delay=G.delay||0,this._start=Ft,this._render=kt||gi,this._duration=ue.duration||500,this._promiseCtor=rt,St&&(this._resolve=St);var si=G.from,oi=G.to,Et=oi===void 0?{}:oi,ai=this._currentState,li=this._originalState,vi=this._targetState;for(var Jt in si)ai[Jt]=si[Jt];var dn=!1;for(var An in ai){var qn=ai[An];dn||ke(qn)!==Oe||(dn=!0),li[An]=qn,vi[An]=Et.hasOwnProperty(An)?Et[An]:qn}if(this._easing=gt(this._currentState,ue.easing,this._easing),this._filters.length=0,dn){for(var wr in w.filters)w.filters[wr].doesApply(this)&&this._filters.push(w.filters[wr]);this._applyFilter(de)}return this}},{key:"then",value:function(G,ue){var Ne=this;return this._promise=new this._promiseCtor(function(Be,rt){Ne._resolve=Be,Ne._reject=rt}),this._promise.then(G,ue)}},{key:"catch",value:function(G){return this.then().catch(G)}},{key:"finally",value:function(G){return this.then().finally(G)}},{key:"get",value:function(){return P({},this._currentState)}},{key:"set",value:function(G){this._currentState=G}},{key:"pause",value:function(){if(this._isPlaying)return this._pausedAtTime=w.now(),this._isPlaying=!1,Vt(this),this}},{key:"resume",value:function(){return this._resume()}},{key:"_resume",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:w.now();return this._timestamp===null?this.tween():this._isPlaying?this._promise:(this._pausedAtTime&&(this._timestamp+=G-this._pausedAtTime,this._pausedAtTime=null),this._isPlaying=!0,we===null?(we=this,be=this):(this._previous=be,be._next=this,be=this),this)}},{key:"seek",value:function(G){G=Math.max(G,0);var ue=w.now();return this._timestamp+G===0||(this._timestamp=ue-G,ge(this,ue)),this}},{key:"stop",value:function(){var G=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(!this._isPlaying)return this;this._isPlaying=!1,Vt(this);var ue=this._filters.length>0;return G&&(ue&&this._applyFilter(N),F(1,this._currentState,this._originalState,this._targetState,1,0,this._easing),ue&&(this._applyFilter(pe),this._applyFilter(ye))),this._resolve&&this._resolve({data:this._data,state:this._currentState,tweenable:this}),this._resolve=null,this._reject=null,this}},{key:"cancel",value:function(){var G=arguments.length>0&&arguments[0]!==void 0&&arguments[0],ue=this._currentState,Ne=this._data,Be=this._isPlaying;return Be?(this._reject&&this._reject({data:Ne,state:ue,tweenable:this}),this._resolve=null,this._reject=null,this.stop(G)):this}},{key:"isPlaying",value:function(){return this._isPlaying}},{key:"hasEnded",value:function(){return this._hasEnded}},{key:"setScheduleFunction",value:function(G){w.setScheduleFunction(G)}},{key:"data",value:function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;return G&&(this._data=P({},G)),this._data}},{key:"dispose",value:function(){for(var G in this)delete this[G]}}],te&&Ke(B.prototype,te),w}();function Sn(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},B=new ft;return B.tween(w),B.tweenable=B,B}E(ft,"now",function(){return q}),E(ft,"setScheduleFunction",function(w){return Re=w}),E(ft,"filters",{}),E(ft,"formulas",Ge),Le(!0);var ii,ln,Ii=/(\d|-|\.)/,yr=/([^\-0-9.]+)/g,ri=/[0-9.-]+/g,br=(ii=ri.source,ln=/,\s*/.source,new RegExp("rgba?\\(".concat(ii).concat(ln).concat(ii).concat(ln).concat(ii,"(").concat(ln).concat(ii,")?\\)"),"g")),Sr=/^.*\(/,Xn=/#([0-9]|[a-f]){3,6}/gi,Ni="VAL",Es=function(w,B){return w.map(function(te,G){return"_".concat(B,"_").concat(G)})};function R(w){return parseInt(w,16)}var H=function(w){return"rgb(".concat((B=w,(B=B.replace(/#/,"")).length===3&&(B=(B=B.split(""))[0]+B[0]+B[1]+B[1]+B[2]+B[2]),[R(B.substr(0,2)),R(B.substr(2,2)),R(B.substr(4,2))]).join(","),")");var B},j=function(w,B,te){var G=B.match(w),ue=B.replace(w,Ni);return G&&G.forEach(function(Ne){return ue=ue.replace(Ni,te(Ne))}),ue},K=function(w){for(var B in w){var te=w[B];typeof te=="string"&&te.match(Xn)&&(w[B]=j(Xn,te,H))}},Y=function(w){var B=w.match(ri),te=B.slice(0,3).map(Math.floor),G=w.match(Sr)[0];if(B.length===3)return"".concat(G).concat(te.join(","),")");if(B.length===4)return"".concat(G).concat(te.join(","),",").concat(B[3],")");throw new Error("Invalid rgbChunk: ".concat(w))},Ee=function(w){return w.match(ri)},Ie=function(w,B){var te={};return B.forEach(function(G){te[G]=w[G],delete w[G]}),te},He=function(w,B){return B.map(function(te){return w[te]})},Xe=function(w,B){return B.forEach(function(te){return w=w.replace(Ni,+te.toFixed(4))}),w},et=function(w){for(var B in w._currentState)if(typeof w._currentState[B]=="string")return!0;return!1};function je(w){var B=w._currentState;[B,w._originalState,w._targetState].forEach(K),w._tokenData=function(te){var G,ue,Ne={};for(var Be in te){var rt=te[Be];typeof rt=="string"&&(Ne[Be]={formatString:(G=rt,ue=void 0,ue=G.match(yr),ue?(ue.length===1||G.charAt(0).match(Ii))&&ue.unshift(""):ue=["",""],ue.join(Ni)),chunkNames:Es(Ee(rt),Be)})}return Ne}(B)}function Ze(w){var B=w._currentState,te=w._originalState,G=w._targetState,ue=w._easing,Ne=w._tokenData;(function(Be,rt){var dt=function(St){var Pt=rt[St].chunkNames,kt=Be[St];if(typeof kt=="string"){var rn=kt.split(" "),gi=rn[rn.length-1];Pt.forEach(function(si,oi){return Be[si]=rn[oi]||gi})}else Pt.forEach(function(si){return Be[si]=kt});delete Be[St]};for(var Ft in rt)dt(Ft)})(ue,Ne),[B,te,G].forEach(function(Be){return function(rt,dt){var Ft=function(Pt){Ee(rt[Pt]).forEach(function(kt,rn){return rt[dt[Pt].chunkNames[rn]]=+kt}),delete rt[Pt]};for(var St in dt)Ft(St)}(Be,Ne)})}function xt(w){var B=w._currentState,te=w._originalState,G=w._targetState,ue=w._easing,Ne=w._tokenData;[B,te,G].forEach(function(Be){return function(rt,dt){for(var Ft in dt){var St=dt[Ft],Pt=St.chunkNames,kt=St.formatString,rn=Xe(kt,He(Ie(rt,Pt),Pt));rt[Ft]=j(br,rn,Y)}}(Be,Ne)}),function(Be,rt){for(var dt in rt){var Ft=rt[dt].chunkNames,St=Be[Ft[0]];Be[dt]=typeof St=="string"?Ft.map(function(Pt){var kt=Be[Pt];return delete Be[Pt],kt}).join(" "):St}}(ue,Ne)}function Gt(w,B){var te=Object.keys(w);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(w);B&&(G=G.filter(function(ue){return Object.getOwnPropertyDescriptor(w,ue).enumerable})),te.push.apply(te,G)}return te}function zt(w){for(var B=1;B4&&arguments[4]!==void 0?arguments[4]:0,Ne=zt({},w),Be=gt(w,G);for(var rt in at._filters.length=0,at.set({}),at._currentState=Ne,at._originalState=w,at._targetState=B,at._easing=Be,Qe)Qe[rt].doesApply(at)&&at._filters.push(Qe[rt]);at._applyFilter("tweenCreated"),at._applyFilter("beforeTween");var dt=F(te,Ne,w,B,1,ue,Be);return at._applyFilter("afterTween"),dt};function yt(w,B){(B==null||B>w.length)&&(B=w.length);for(var te=0,G=new Array(B);tec.strokeWidth&&(u=c.trailWidth);var f=50-u/2;return o.render(this._pathTemplate,{radius:f,"2radius":f*2})},a.prototype._trailString=function(c){return this._pathString(c)},n.exports=a},{"./shape":8,"./utils":10}],4:[function(t,n,i){var s=t("./shape"),o=t("./utils"),a=function(c,u){this._pathTemplate=u.vertical?"M {center},100 L {center},0":"M 0,{center} L 100,{center}",s.apply(this,arguments)};a.prototype=new s,a.prototype.constructor=a,a.prototype._initializeSvg=function(c,u){var f=u.vertical?"0 0 "+u.strokeWidth+" 100":"0 0 100 "+u.strokeWidth;c.setAttribute("viewBox",f),c.setAttribute("preserveAspectRatio","none")},a.prototype._pathString=function(c){return o.render(this._pathTemplate,{center:c.strokeWidth/2})},a.prototype._trailString=function(c){return this._pathString(c)},n.exports=a},{"./shape":8,"./utils":10}],5:[function(t,n,i){n.exports={Line:t("./line"),Circle:t("./circle"),SemiCircle:t("./semicircle"),Square:t("./square"),Path:t("./path"),Shape:t("./shape"),utils:t("./utils")}},{"./circle":3,"./line":4,"./path":6,"./semicircle":7,"./shape":8,"./square":9,"./utils":10}],6:[function(t,n,i){var s=t("shifty"),o=t("./utils"),a=s.Tweenable,l={easeIn:"easeInCubic",easeOut:"easeOutCubic",easeInOut:"easeInOutCubic"},c=function u(f,h){if(!(this instanceof u))throw new Error("Constructor was called without new keyword");h=o.extend({delay:0,duration:800,easing:"linear",from:{},to:{},step:function(){}},h);var p;o.isString(f)?p=document.querySelector(f):p=f,this.path=p,this._opts=h,this._tweenable=null;var _=this.path.getTotalLength();this.path.style.strokeDasharray=_+" "+_,this.set(0)};c.prototype.value=function(){var f=this._getComputedDashOffset(),h=this.path.getTotalLength(),p=1-f/h;return parseFloat(p.toFixed(6),10)},c.prototype.set=function(f){this.stop(),this.path.style.strokeDashoffset=this._progressToOffset(f);var h=this._opts.step;if(o.isFunction(h)){var p=this._easing(this._opts.easing),_=this._calculateTo(f,p),g=this._opts.shape||this;h(_,g,this._opts.attachment)}},c.prototype.stop=function(){this._stopTween(),this.path.style.strokeDashoffset=this._getComputedDashOffset()},c.prototype.animate=function(f,h,p){h=h||{},o.isFunction(h)&&(p=h,h={});var _=o.extend({},h),g=o.extend({},this._opts);h=o.extend(g,h);var m=this._easing(h.easing),d=this._resolveFromAndTo(f,m,_);this.stop(),this.path.getBoundingClientRect();var x=this._getComputedDashOffset(),v=this._progressToOffset(f),y=this;this._tweenable=new a,this._tweenable.tween({from:o.extend({offset:x},d.from),to:o.extend({offset:v},d.to),duration:h.duration,delay:h.delay,easing:m,step:function(b){y.path.style.strokeDashoffset=b.offset;var M=h.shape||y;h.step(b,M,h.attachment)}}).then(function(b){o.isFunction(p)&&p()}).catch(function(b){throw console.error("Error in tweening:",b),b})},c.prototype._getComputedDashOffset=function(){var f=window.getComputedStyle(this.path,null);return parseFloat(f.getPropertyValue("stroke-dashoffset"),10)},c.prototype._progressToOffset=function(f){var h=this.path.getTotalLength();return h-f*h},c.prototype._resolveFromAndTo=function(f,h,p){return p.from&&p.to?{from:p.from,to:p.to}:{from:this._calculateFrom(h),to:this._calculateTo(f,h)}},c.prototype._calculateFrom=function(f){return s.interpolate(this._opts.from,this._opts.to,this.value(),f)},c.prototype._calculateTo=function(f,h){return s.interpolate(this._opts.from,this._opts.to,f,h)},c.prototype._stopTween=function(){this._tweenable!==null&&(this._tweenable.stop(!0),this._tweenable=null)},c.prototype._easing=function(f){return l.hasOwnProperty(f)?l[f]:f},n.exports=c},{"./utils":10,shifty:2}],7:[function(t,n,i){var s=t("./shape"),o=t("./circle"),a=t("./utils"),l=function(u,f){this._pathTemplate="M 50,50 m -{radius},0 a {radius},{radius} 0 1 1 {2radius},0",this.containerAspectRatio=2,s.apply(this,arguments)};l.prototype=new s,l.prototype.constructor=l,l.prototype._initializeSvg=function(u,f){u.setAttribute("viewBox","0 0 100 50")},l.prototype._initializeTextContainer=function(u,f,h){u.text.style&&(h.style.top="auto",h.style.bottom="0",u.text.alignToBottom?a.setStyle(h,"transform","translate(-50%, 0)"):a.setStyle(h,"transform","translate(-50%, 50%)"))},l.prototype._pathString=o.prototype._pathString,l.prototype._trailString=o.prototype._trailString,n.exports=l},{"./circle":3,"./shape":8,"./utils":10}],8:[function(t,n,i){var s=t("./path"),o=t("./utils"),a="Object is destroyed",l=function c(u,f){if(!(this instanceof c))throw new Error("Constructor was called without new keyword");if(arguments.length!==0){this._opts=o.extend({color:"#555",strokeWidth:1,trailColor:null,trailWidth:null,fill:null,text:{style:{color:null,position:"absolute",left:"50%",top:"50%",padding:0,margin:0,transform:{prefix:!0,value:"translate(-50%, -50%)"}},autoStyleContainer:!0,alignToBottom:!0,value:null,className:"progressbar-text"},svgStyle:{display:"block",width:"100%"},warnings:!1},f,!0),o.isObject(f)&&f.svgStyle!==void 0&&(this._opts.svgStyle=f.svgStyle),o.isObject(f)&&o.isObject(f.text)&&f.text.style!==void 0&&(this._opts.text.style=f.text.style);var h=this._createSvgView(this._opts),p;if(o.isString(u)?p=document.querySelector(u):p=u,!p)throw new Error("Container does not exist: "+u);this._container=p,this._container.appendChild(h.svg),this._opts.warnings&&this._warnContainerAspectRatio(this._container),this._opts.svgStyle&&o.setStyles(h.svg,this._opts.svgStyle),this.svg=h.svg,this.path=h.path,this.trail=h.trail,this.text=null;var _=o.extend({attachment:void 0,shape:this},this._opts);this._progressPath=new s(h.path,_),o.isObject(this._opts.text)&&this._opts.text.value!==null&&this.setText(this._opts.text.value)}};l.prototype.animate=function(u,f,h){if(this._progressPath===null)throw new Error(a);this._progressPath.animate(u,f,h)},l.prototype.stop=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath.stop()},l.prototype.pause=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath._tweenable&&this._progressPath._tweenable.pause()},l.prototype.resume=function(){if(this._progressPath===null)throw new Error(a);this._progressPath!==void 0&&this._progressPath._tweenable&&this._progressPath._tweenable.resume()},l.prototype.destroy=function(){if(this._progressPath===null)throw new Error(a);this.stop(),this.svg.parentNode.removeChild(this.svg),this.svg=null,this.path=null,this.trail=null,this._progressPath=null,this.text!==null&&(this.text.parentNode.removeChild(this.text),this.text=null)},l.prototype.set=function(u){if(this._progressPath===null)throw new Error(a);this._progressPath.set(u)},l.prototype.value=function(){if(this._progressPath===null)throw new Error(a);return this._progressPath===void 0?0:this._progressPath.value()},l.prototype.setText=function(u){if(this._progressPath===null)throw new Error(a);this.text===null&&(this.text=this._createTextContainer(this._opts,this._container),this._container.appendChild(this.text)),o.isObject(u)?(o.removeChildren(this.text),this.text.appendChild(u)):this.text.innerHTML=u},l.prototype._createSvgView=function(u){var f=document.createElementNS("http://www.w3.org/2000/svg","svg");this._initializeSvg(f,u);var h=null;(u.trailColor||u.trailWidth)&&(h=this._createTrail(u),f.appendChild(h));var p=this._createPath(u);return f.appendChild(p),{svg:f,path:p,trail:h}},l.prototype._initializeSvg=function(u,f){u.setAttribute("viewBox","0 0 100 100")},l.prototype._createPath=function(u){var f=this._pathString(u);return this._createPathElement(f,u)},l.prototype._createTrail=function(u){var f=this._trailString(u),h=o.extend({},u);return h.trailColor||(h.trailColor="#eee"),h.trailWidth||(h.trailWidth=h.strokeWidth),h.color=h.trailColor,h.strokeWidth=h.trailWidth,h.fill=null,this._createPathElement(f,h)},l.prototype._createPathElement=function(u,f){var h=document.createElementNS("http://www.w3.org/2000/svg","path");return h.setAttribute("d",u),h.setAttribute("stroke",f.color),h.setAttribute("stroke-width",f.strokeWidth),f.fill?h.setAttribute("fill",f.fill):h.setAttribute("fill-opacity","0"),h},l.prototype._createTextContainer=function(u,f){var h=document.createElement("div");h.className=u.text.className;var p=u.text.style;return p&&(u.text.autoStyleContainer&&(f.style.position="relative"),o.setStyles(h,p),p.color||(h.style.color=u.color)),this._initializeTextContainer(u,f,h),h},l.prototype._initializeTextContainer=function(c,u,f){},l.prototype._pathString=function(u){throw new Error("Override this function for each progress bar")},l.prototype._trailString=function(u){throw new Error("Override this function for each progress bar")},l.prototype._warnContainerAspectRatio=function(u){if(this.containerAspectRatio){var f=window.getComputedStyle(u,null),h=parseFloat(f.getPropertyValue("width"),10),p=parseFloat(f.getPropertyValue("height"),10);o.floatEquals(this.containerAspectRatio,h/p)||(console.warn("Incorrect aspect ratio of container","#"+u.id,"detected:",f.getPropertyValue("width")+"(width)","/",f.getPropertyValue("height")+"(height)","=",h/p),console.warn("Aspect ratio of should be",this.containerAspectRatio))}},n.exports=l},{"./path":6,"./utils":10}],9:[function(t,n,i){var s=t("./shape"),o=t("./utils"),a=function(c,u){this._pathTemplate="M 0,{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{strokeWidth}",this._trailTemplate="M {startMargin},{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{halfOfStrokeWidth}",s.apply(this,arguments)};a.prototype=new s,a.prototype.constructor=a,a.prototype._pathString=function(c){var u=100-c.strokeWidth/2;return o.render(this._pathTemplate,{width:u,strokeWidth:c.strokeWidth,halfOfStrokeWidth:c.strokeWidth/2})},a.prototype._trailString=function(c){var u=100-c.strokeWidth/2;return o.render(this._trailTemplate,{width:u,strokeWidth:c.strokeWidth,halfOfStrokeWidth:c.strokeWidth/2,startMargin:c.strokeWidth/2-c.trailWidth/2})},n.exports=a},{"./shape":8,"./utils":10}],10:[function(t,n,i){var s=t("lodash.merge"),o="Webkit Moz O ms".split(" "),a=.001;function l(v,y){var b=v;for(var M in y)if(y.hasOwnProperty(M)){var T=y[M],I="\\{"+M+"\\}",S=new RegExp(I,"g");b=b.replace(S,T)}return b}function c(v,y,b){for(var M=v.style,T=0;T{a.isMesh&&i.push(a)});if(i.length>0){const s=new ib(i);s.attributes=["position","color","normal","tangent","uv","uv2"],s.applyWorldTransforms=!1;let o=new Mn(s.generate(),new Ri),a=new mc(o.geometry,{strategy:Gf,maxLeafTris:1});this.result={scene:t.scene,bvh:a,mesh:o},console.log("==> loaded mesh ",e)}return this.result}}function Bn(r){return new C(r[0],r[1],r[2])}const k={scene_name:"standard-shader-ball",smooth_normals:!0,bounces:6,max_samples:1024,max_volume_steps:8,wireframe:!1,neutral_color:[.5,.5,.5],skyPower:.5,skyColor:[.8,.8,1],sunPower:.35,sunAngularSize:40,sunLatitude:40,sunLongitude:180,sunColor:[1,1,.8],base_weight:1,base_color:[.8,.8,.8],base_roughness:0,base_metalness:0,diffuse_mode:8,specular_weight:1,specular_color:[1,1,1],specular_roughness:.1,specular_anisotropy:0,specular_rotation:0,specular_ior:1.6,transmission_weight:0,transmission_color:[1,1,1],transmission_depth:0,transmission_scatter:[0,0,0],transmission_scatter_anisotropy:0,transmission_dispersion_abbe_number:20,transmission_dispersion_scale:0,subsurface_weight:0,subsurface_color:[.8,.8,.8],subsurface_radius:.2,subsurface_radius_scale:[1,.5,.25],subsurface_anisotropy:0,subsurface_mode:0,coat_weight:0,coat_color:[1,1,1],coat_roughness:0,coat_anisotropy:0,coat_rotation:0,coat_ior:1.3,coat_darkening:1,fuzz_weight:0,fuzz_color:[1,1,1],fuzz_roughness:.5,emission_luminance:0,emission_color:[1,1,1],thin_film_weight:0,thin_film_thickness:1e3,thin_film_ior:1.4,geometry_opacity:1,geometry_thin_walled:!1,reset_camera:function(){vc(k.scene_name)}};let qt,Mt,Ot,Li,Xi,as,_a,Je,Zf,io,ur=0,es,ts,Kl,Zl;var gn,gc,ro,Ks,Ab={"Standard Shader Ball":"standard-shader-ball",Glavenus:"glavenus",Terrain:"terrain","Bearded Man":"bearded-man"},Rb={"OpenPBR (orig, 3-float)":0,"OpenPBR (luminace)":1,"OpenPBR (average)":2,"OpenPBR (max value)":3,"OpenPBR (weighted average)":4,"SPI / Arnold v1":5,"Arnold v2":6,"Uniform scattering":7},Lb={Lambert:0,"ON Full (Mitsuba)":1,"ON Qualitative (QON)":2,"ON Qualitative - Energy Conserving (EQON exact)":3,"ON Qualitative - Energy Conserving (EQON approx)":4,"Fujii - Qualitative (FON)":5,"Fujii - Energy Conserving (EFON exact)":6,"Fujii - Energy Conserving (EFON approx)":7,"Fujii - Energy Conserving (EFON exact, LTC sampling)":8,"Fujii - Energy Conserving (EFON approx, LTC sampling)":9,"Fujii - MaterialX":10,"Chan Diffuse (Unreal)":11,"d'Eon sphere model":12};Db();Zs();function Cb(){let r=(90-k.sunLatitude)*Math.PI/180,e=k.sunLongitude*Math.PI/180,t=Math.cos(r),n=Math.sin(r),i=Math.cos(e),s=Math.sin(e),o=n*i,a=n*s,l=t;k.sunDir=[o,l,a]}function Pb(){Li=new yv;const r=new Bf(16777215,1);return r.position.set(1,1,1),Li.add(r),Li.add(new $v(11583173,.5)),Li}function Db(){gn=new Mb.Circle("#progress_overlay",{color:"rgba(255, 128, 64, 0.75)",strokeWidth:5,trailColor:"rgba(255, 128, 64, 0.333)",trailWidth:3,svgStyle:{display:"block",width:"100%"},text:{value:"",className:"progressbar__label",style:{color:"rgba(169, 85, 42, 1.0)",position:"absolute",fontWeight:"bold",left:"50%",top:"50%",padding:0,margin:0,transform:{prefix:!0,value:"translate(-50%, -50%)"}},autoStyleContainer:!0,alignToBottom:!0},fill:null,duration:2e3,easing:"linear",from:{color:"rgba( 0, 0, 0, 0.0)"},to:{color:"rgba(32, 255, 32, 1.0)"},warnings:!0}),gn.set(0),gn.setText(""),ro=!1,es=null,ts=null,Kl=null,Zl=null,qt=new Pf({antialias:!0,preserveDrawingBuffer:!0}),qt.setPixelRatio(window.devicePixelRatio),qt.setClearColor(594970),qt.setSize(window.innerWidth,window.innerHeight),qt.outputEncoding=$i,document.body.appendChild(qt.domElement),Li=Pb(),as=new jx,document.body.appendChild(as.dom);let r=document.getElementById("samples");r.style.visibility="visible";let e=document.getElementById("info");e.style.visibility="visible",Je=new Zi({defines:{BOUNCES:k.bounces,MAX_VOLUME_STEPS:k.max_volume_steps,COAT_ENABLED:!1,TRANSMISSION_ENABLED:!1,VOLUME_ENABLED:!1,DISPERSION_ENABLED:!1,THIN_FILM_ENABLED:!1},uniforms:{bvh_surface:{value:new kh},normalAttribute_surface:{value:new Vs},tangentAttribute_surface:{value:new Vs},has_normals_surface:{value:1},has_tangents_surface:{value:0},bvh_props:{value:new kh},normalAttribute_props:{value:new Vs},tangentAttribute_props:{value:new Vs},has_normals_props:{value:1},has_tangents_props:{value:0},cameraWorldMatrix:{value:new Ve},invProjectionMatrix:{value:new Ve},invModelMatrix:{value:new Ve},resolution:{value:new Ue},samples:{value:0},accumulation_weight:{value:1},wireframe:{value:k.wireframe},neutral_color:{value:new C().fromArray(k.neutral_color)},smooth_normals:{value:k.smooth_normals},skyPower:{value:k.skyPower},skyColor:{value:Bn(k.skyColor)},sunPower:{value:Math.pow(10,k.sunPower)},sunAngularSize:{value:k.sunAngularSize},sunColor:{value:Bn(k.sunColor)},sunDir:{value:Bn([0,0,0])},diffuse_mode:{value:k.diffuse_mode},base_weight:{value:k.base_weight},base_color:{value:Bn(k.base_color)},base_roughness:{value:k.base_roughness},base_metalness:{value:k.base_metalness},specular_weight:{value:k.specular_weight},specular_color:{value:Bn(k.specular_color)},specular_roughness:{value:k.specular_roughness},specular_anisotropy:{value:k.specular_anisotropy},specular_rotation:{value:k.specular_rotation},specular_ior:{value:k.specular_ior},transmission_weight:{value:k.transmission_weight},transmission_color:{value:Bn(k.transmission_color)},transmission_depth:{value:k.transmission_depth},transmission_scatter:{value:Bn(k.transmission_scatter)},transmission_scatter_anisotropy:{value:k.transmission_scatter_anisotropy},transmission_dispersion_abbe_number:{value:k.transmission_dispersion_abbe_number},transmission_dispersion_scale:{value:k.transmission_dispersion_scale},subsurface_weight:{value:k.subsurface_weight},subsurface_color:{value:Bn(k.subsurface_color)},subsurface_radius:{value:k.subsurface_radius},subsurface_radius_scale:{value:Bn(k.subsurface_radius_scale)},subsurface_anisotropy:{value:k.subsurface_anisotropy},subsurface_mode:{value:k.subsurface_mode},coat_weight:{value:k.coat_weight},coat_color:{value:Bn(k.coat_color)},coat_roughness:{value:k.coat_roughness},coat_anisotropy:{value:k.coat_anisotropy},coat_rotation:{value:k.coat_rotation},coat_ior:{value:k.coat_ior},coat_darkening:{value:k.coat_darkening},fuzz_weight:{value:k.fuzz_weight},fuzz_color:{value:Bn(k.fuzz_color)},fuzz_roughness:{value:k.fuzz_roughness},emission_luminance:{value:k.emission_luminance},emission_color:{value:Bn(k.emission_color)},thin_film_weight:{value:k.thin_film_weight},thin_film_thickness:{value:k.thin_film_thickness},thin_film_ior:{value:k.thin_film_ior},geometry_opacity:{value:k.geometry_opacity},geometry_thin_walled:{value:k.geometry_thin_walled}},vertexShader:` varying vec2 vUv; void main() { @@ -7210,6 +7210,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho `,fragmentShader:`precision highp isampler2D; precision highp usampler2D; precision highp int; + ${Zy} ${Qy} - ${Jy} - `+gb+vb+xb+bb+Eb+yb+Sb+wb+Mb}),Jf("standard-shader-ball")}function Jf(r){const e=new Ab;ro=!1,gn.setText("loading meshes..."),gn.animate(0),e.load(r+"/neutral_objects.glb").then(()=>{Li.add(e.result.scene),ts=e.result.mesh,Zl=e.result.bvh,Je.uniforms.bvh_props.value.updateFrom(Zl),Je.uniforms.has_normals_props.value=!1,Je.uniforms.has_tangents_props.value=!1,ts.geometry.attributes.normal&&(Je.uniforms.normalAttribute_props.value.updateFrom(ts.geometry.attributes.normal),Je.uniforms.has_normals_props.value=!0),ts.geometry.attributes.tangent&&(Je.uniforms.tangentAttribute_props.value.updateFrom(ts.geometry.attributes.tangent),Je.uniforms.has_tangents_props.value=!0),console.log(" has_normals_scene: ",Je.uniforms.has_normals_props),console.log(" has_tangents_scene: ",Je.uniforms.has_tangents_props),gn.animate(.5),e.reset(),e.load(r+"/openpbr_objects.glb").then(()=>{Li.add(e.result.scene),es=e.result.mesh,Kl=e.result.bvh,Je.uniforms.bvh_surface.value.updateFrom(Kl),Je.uniforms.has_normals_surface.value=!1,Je.uniforms.has_tangents_surface.value=!1,es.geometry.attributes.normal&&(Je.uniforms.normalAttribute_surface.value.updateFrom(es.geometry.attributes.normal),Je.uniforms.has_normals_surface.value=!0),es.geometry.attributes.tangent&&(Je.uniforms.tangentAttribute_surface.value.updateFrom(es.geometry.attributes.tangent),Je.uniforms.has_tangents_surface.value=!0),console.log(" has_normals_surface: ",Je.uniforms.has_normals_surface),console.log(" has_tangents_surface: ",Je.uniforms.has_tangents_surface),console.log("===> LOADED"),ro=!0,Ib(),gn.animate(1),document.getElementById("progress_overlay"),gc=performance.now()})})}function vc(r){let e=23.6701655,t=.01,n=1e3;Mt=new _n(e,window.innerWidth/window.innerHeight,t,n),Ot=new lx(Mt,qt.domElement),Ot.addEventListener("change",()=>{Ae()});let i=new Ve;r=="standard-shader-ball"?i.set(.9396926207859084,0,-.3420201433256687,0,-.2203032561704394,.7649214009184319,-.6052782217606094,0,.26161852717499334,.6441236297613865,.7187909959242699,0,6.531538924716362,19.5,17.948521838355774,1):r=="glavius"?i.set(.4848291963218869,-6938893903907228e-33,-.8746088556571293,0,-.07533009256065425,.9962839037303908,-.041758356319859954,0,.8713587249512548,.08613003638530015,.4830275243540376,0,23.076273094000275,6.7653774216248,14.822630983786677,1):r=="terrain"?i.set(.7242953632536803,-11102230246251565e-32,-.6894898307946385,0,-.4511571209928634,.7562050657737049,-.4739315886028461,0,.5213957028463604,.6543346991396579,.5477158228088388,0,8.561709328489492,11.460860759783042,8.95672568146927,1):r=="bearded-man"&&i.set(.6586894440882616,-13877787807814457e-33,.752414922929295,0,.13367205033823076,.9840924050751759,-.11702102901499911,0,-.7404458111199431,.17765736200156684,.648211279230448,0,-20.089277049402824,9.131027464916848,18.02162149148976,1),i.transpose(),Mt.matrixAutoUpdate=!1,Mt.applyMatrix4(i),Mt.matrixAutoUpdate=!0,Mt.updateMatrixWorld();let s=new C;Mt.getWorldDirection(s);let o=Mt.position.clone();o.addScaledVector(s,23.39613),Ot.target.copy(o),Ot.zoomSpeed=1.5,Ot.flySpeed=.01,Ot.update()}function jh(){return k.coat_weight!=0}function Vi(){return k.base_metalness==1?!1:k.transmission_weight>0&&k.transmission_depth>0||k.subsurface_weight>0}function ra(){return k.transmission_weight>0||k.subsurface_weight>0}function Yh(){return k.transmission_dispersion_scale>0}function $h(){return k.thin_film_weight>0}function Ib(){_a=new gh(Je),Je.transparent=!0,Je.depthWrite=!1,io=new Ki(1,1,{format:sn,type:vn}),Zf=new gh(new Ri({map:io.texture})),zn(),vc(k.scene_name),Xi=new _c({width:300});const r=Xi.addFolder("Material"),e=r.addFolder("Base");e.add(k,"base_weight",0,1).onChange(h=>{Ae()}),e.addColor(k,"base_color").onChange(h=>{Ae()}),e.add(k,"base_roughness",0,1).onChange(h=>{Ae()}),e.add(k,"base_metalness",0,1).onChange(h=>{Ae(),Vi()!=Je.defines.VOLUME_ENABLED&&(Je.defines.VOLUME_ENABLED=Vi(),zn())}),e.add(k,"diffuse_mode",Qf).onChange(h=>{Ae()});const t=r.addFolder("Specular");t.add(k,"specular_weight",0,1).onChange(h=>{Ae()}),t.addColor(k,"specular_color").onChange(h=>{Ae()}),t.add(k,"specular_roughness",0,1).onChange(h=>{Ae()}),t.add(k,"specular_ior",1,5).onChange(h=>{Ae()}),t.add(k,"specular_anisotropy",0,1).onChange(h=>{Ae()}),t.add(k,"specular_rotation",0,1).onChange(h=>{Ae()});const n=r.addFolder("Transmission");n.add(k,"transmission_weight",0,1).onChange(h=>{Ae(),Vi()!=Je.defines.VOLUME_ENABLED&&(Je.defines.VOLUME_ENABLED=Vi(),zn()),ra()!=Je.defines.TRANSMISSION_ENABLED&&(Je.defines.TRANSMISSION_ENABLED=ra(),zn())}),n.addColor(k,"transmission_color").onChange(h=>{Ae()}),n.add(k,"transmission_depth",0,1).onChange(h=>{Ae(),Vi()!=Je.defines.VOLUME_ENABLED&&(Je.defines.VOLUME_ENABLED=Vi(),zn())}),n.addColor(k,"transmission_scatter").onChange(h=>{Ae()}),n.add(k,"transmission_scatter_anisotropy",-1,1).onChange(h=>{Ae()}),n.add(k,"transmission_dispersion_abbe_number",9,91).onChange(h=>{Ae()}),n.add(k,"transmission_dispersion_scale",0,1).onChange(h=>{Ae(),Yh()!=Je.defines.DISPERSION_ENABLED&&(Je.defines.DISPERSION_ENABLED=Yh(),zn())}),n.close();const i=r.addFolder("Subsurface");i.add(k,"subsurface_weight",0,1).onChange(h=>{Ae(),Vi()!=Je.defines.VOLUME_ENABLED&&(Je.defines.VOLUME_ENABLED=Vi(),zn()),ra()!=Je.defines.TRANSMISSION_ENABLED&&(Je.defines.TRANSMISSION_ENABLED=ra(),zn())}),i.addColor(k,"subsurface_color").onChange(h=>{Ae()}),i.add(k,"subsurface_radius",0,1).onChange(h=>{Ae()}),i.addColor(k,"subsurface_radius_scale").onChange(h=>{Ae()}),i.add(k,"subsurface_anisotropy",-1,1).onChange(h=>{Ae()}),i.add(k,"subsurface_mode",Lb).onChange(h=>{Ae()}),i.close();const s=r.addFolder("Coat");s.add(k,"coat_weight",0,1).onChange(h=>{Ae(),jh()!=Je.defines.COAT_ENABLED&&(Je.defines.COAT_ENABLED=jh(),zn())}),s.addColor(k,"coat_color").onChange(h=>{Ae()}),s.add(k,"coat_roughness",0,1).onChange(h=>{Ae()}),s.add(k,"coat_ior",1,3).onChange(h=>{Ae()}),s.add(k,"coat_anisotropy",0,1).onChange(h=>{Ae()}),s.add(k,"coat_rotation",0,1).onChange(h=>{Ae()}),s.add(k,"coat_darkening",0,1).onChange(h=>{Ae()}),s.close();const o=r.addFolder("Fuzz");o.add(k,"fuzz_weight",0,1).onChange(h=>{Ae()}),o.addColor(k,"fuzz_color").onChange(h=>{Ae()}),o.add(k,"fuzz_roughness",0,1).onChange(h=>{Ae()}),o.close();const a=r.addFolder("Emission");a.add(k,"emission_luminance",0,10).onChange(h=>{Ae()}),a.addColor(k,"emission_color").onChange(h=>{Ae()}),a.close();const l=r.addFolder("Thin Film");l.add(k,"thin_film_weight",0,1).onChange(h=>{Ae(),$h()!=Je.defines.THIN_FILM_ENABLED&&(Je.defines.THIN_FILM_ENABLED=$h(),zn())}),l.add(k,"thin_film_thickness",0,2e3).onChange(h=>{Ae()}),l.add(k,"thin_film_ior",1,3).onChange(h=>{Ae()}),l.close();const c=r.addFolder("Geometry");c.add(k,"geometry_opacity",0,1).onChange(h=>{Ae()}),c.add(k,"geometry_thin_walled").onChange(h=>{Ae()}),c.close();const u=Xi.addFolder("Lighting");u.add(k,"skyPower",0,2).onChange(h=>{Ae()}),u.addColor(k,"skyColor").onChange(h=>{Ae()}),u.add(k,"sunPower",-4,4).onChange(h=>{Ae()}),u.add(k,"sunAngularSize",0,40).onChange(h=>{Ae()}),u.add(k,"sunLatitude",0,90).onChange(h=>{Ae()}),u.add(k,"sunLongitude",0,360).onChange(h=>{Ae()}),u.addColor(k,"sunColor").onChange(h=>{Ae()}),u.close();const f=Xi.addFolder("Renderer");f.add(k,"scene_name",Rb).onChange(h=>{console.log(h),Jf(h),Ae()}),f.add(k,"smooth_normals").onChange(h=>{Ae()}),f.add(k,"wireframe").onChange(h=>{Ae()}),f.addColor(k,"neutral_color").onChange(h=>{Ae()}),f.add(k,"bounces",0,100,1).onChange(h=>{Je.defines.BOUNCES=parseInt(h),Ae(),zn()}),f.add(k,"max_samples").onChange(h=>{Ae()}),f.add(k,"max_volume_steps",1,100,1).onChange(h=>{Je.defines.MAX_VOLUME_STEPS=parseInt(h),Ae(),zn()}),f.close(),Xi.add(k,"reset_camera"),Xi.open(),window.addEventListener("resize",Kh,!1),Kh()}function zn(){qt.setRenderTarget(io);let r=new ao(-1,1,1,-1,0,1);Nb(),qt.compileAsync(_a._mesh,r).then(t=>{console.log("shaders successfully compiled."),Fb()}).catch(t=>{console.log("shader compilation error: "+t)}).finally(()=>{})}function Nb(){let r=document.getElementById("progress_overlay");r.style.display="block",r.style.opacity=1,gn.set(0),gn.setText("shaders compiling..."),Ks=!0}function Fb(){gn.set(1),gc=performance.now(),Ks=!1}function Kh(){Mt.aspect=window.innerWidth/window.innerHeight,Mt.updateProjectionMatrix();const r=window.innerWidth,e=window.innerHeight;qt.setSize(r,e),qt.setPixelRatio(1),io.setSize(r,e),Ae()}function Pn(r){return new C(r[0],r[1],r[2])}function Ae(){Je&&(Je.needsUpdate=!0),ur=0}function Ob(r){let e=document.getElementById("progress_overlay");var t=setInterval(function(){e.style.opacity||(e.style.opacity=1),e.style.opacity>0?e.style.opacity-=.025:(e.style.display="none",e.style.opacity=0,clearInterval(t))},r)}function Zs(){if(!ro){console.log("not LOADED"),requestAnimationFrame(Zs);return}if(qt.domElement.style.imageRendering="auto",ur>=k.max_samples){requestAnimationFrame(Zs);return}if(!Ks&&ro){Mt.updateMatrixWorld();const r=_a.material.uniforms,e=window.innerWidth,t=window.innerHeight;r.cameraWorldMatrix.value.copy(Mt.matrixWorld),r.invProjectionMatrix.value.copy(Mt.projectionMatrixInverse),r.invModelMatrix.value.copy(Li.matrixWorld).invert();let n=new Ue(e,t);r.resolution.value.copy(n),r.accumulation_weight.value=1/(ur+1),r.samples.value=ur,r.wireframe.value=k.wireframe,r.neutral_color.value.copy(Pn(k.neutral_color)),r.smooth_normals.value=k.smooth_normals,r.base_weight.value=k.base_weight,r.base_color.value.copy(Pn(k.base_color)),r.base_roughness.value=k.base_roughness,r.base_metalness.value=k.base_metalness,r.diffuse_mode.value=k.diffuse_mode,r.specular_weight.value=k.specular_weight,r.specular_color.value.copy(Pn(k.specular_color)),r.specular_roughness.value=k.specular_roughness,r.specular_anisotropy.value=k.specular_anisotropy,r.specular_rotation.value=k.specular_rotation,r.specular_ior.value=k.specular_ior,r.transmission_weight.value=k.transmission_weight,r.transmission_color.value.copy(Pn(k.transmission_color)),r.transmission_depth.value=k.transmission_depth,r.transmission_scatter.value.copy(Pn(k.transmission_scatter)),r.transmission_scatter_anisotropy.value=k.transmission_scatter_anisotropy,r.transmission_dispersion_abbe_number.value=k.transmission_dispersion_abbe_number,r.transmission_dispersion_scale.value=k.transmission_dispersion_scale,r.subsurface_weight.value=k.subsurface_weight,r.subsurface_color.value.copy(Pn(k.subsurface_color)),r.subsurface_radius.value=k.subsurface_radius,r.subsurface_radius_scale.value.copy(Pn(k.subsurface_radius_scale)),r.subsurface_anisotropy.value=k.subsurface_anisotropy,r.subsurface_mode.value=k.subsurface_mode,r.coat_weight.value=k.coat_weight,r.coat_color.value.copy(Pn(k.coat_color)),r.coat_roughness.value=k.coat_roughness,r.coat_anisotropy.value=k.coat_anisotropy,r.coat_rotation.value=k.coat_rotation,r.coat_ior.value=k.coat_ior,r.coat_darkening.value=k.coat_darkening,r.fuzz_weight.value=k.fuzz_weight,r.fuzz_color.value.copy(Pn(k.fuzz_color)),r.fuzz_roughness.value=k.fuzz_roughness,r.emission_luminance.value=k.emission_luminance,r.emission_color.value.copy(Pn(k.emission_color)),r.thin_film_weight.value=k.thin_film_weight,r.thin_film_thickness.value=k.thin_film_thickness,r.thin_film_ior.value=k.thin_film_ior,r.geometry_opacity.value=k.geometry_opacity,r.geometry_thin_walled.value=k.geometry_thin_walled,r.skyPower.value=k.skyPower,r.skyColor.value.copy(Pn(k.skyColor)),r.sunPower.value=Math.pow(10,k.sunPower),r.sunAngularSize.value=k.sunAngularSize,r.sunColor.value.copy(Pn(k.sunColor)),Cb(),r.sunDir.value.copy(Pn(k.sunDir)),qt.autoClear=ur===0,qt.setRenderTarget(io),_a.render(qt),qt.setRenderTarget(null),Zf.render(qt),qt.autoClear=!0,ur++}else Ae(),Mt.updateProjectionMatrix(),Mt.clearViewOffset(),qt.render(Li,Mt);document.getElementById("samples").innerText=`samples: ${ur}`,Ks||document.getElementById("progress_overlay").style.display!="none"&&performance.now()-gc>300&&Ob(300),Ks&&(gn.value()<.01?gn.animate(1):gn.value()>.99&&(gn.set(0),gn.animate(1))),as.update(),requestAnimationFrame(Zs)}document.onkeydown=function(r){r=r||window.event;var e=r.which?r.which:r.keyCode;switch(e){case 122:{var t=document.body;"webkitCancelFullScreen"in document?t.webkitRequestFullScreen():"mozCancelFullScreen"in document?t.mozRequestFullScreen():console.assert(!1),Ot.update(),Ae();break}case 70:{vc(k.scene_name);break}case 72:{Xi.show(Xi._hidden),document.body.contains(as.dom)?document.body.removeChild(as.dom):document.body.appendChild(as.dom);let a=document.getElementById("info");a.style.visibility=="visible"?a.style.visibility="hidden":a.style.visibility="visible";let l=document.getElementById("samples");l.style.visibility=="visible"?l.style.visibility="hidden":l.style.visibility="visible";break}case 87:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();a.normalize();var n=new C;n.copy(a),n.multiplyScalar(Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Ae();break}case 65:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();var i=new C(1,0,0),s=i.transformDirection(Mt.matrix),n=new C;n.copy(s),n.multiplyScalar(-Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Ae();break}case 83:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();a.normalize();var n=new C;n.copy(a),n.multiplyScalar(-Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Ae();break}case 68:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();var i=new C(1,0,0),s=i.transformDirection(Mt.matrix),n=new C;n.copy(s),n.multiplyScalar(Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Ae();break}case 80:{var o=document.createElement("a");let a="openpbr-viewer-screenshot.png";o.download=a,qt.domElement.toBlob(function(l){o.href=URL.createObjectURL(l);var c=new MouseEvent("click");o.dispatchEvent(c),requestAnimationFrame(Zs)},"image/png",1);break}}}; + `+_b+gb+vb+yb+bb+xb+Sb+Eb+wb}),Qf(k.scene_name)}function Qf(r){const e=new Tb;ro=!1,gn.setText("loading meshes..."),gn.animate(0),e.load(r+"/neutral_objects.glb").then(()=>{Li.add(e.result.scene),ts=e.result.mesh,Zl=e.result.bvh,Je.uniforms.bvh_props.value.updateFrom(Zl),Je.uniforms.has_normals_props.value=!1,Je.uniforms.has_tangents_props.value=!1,ts.geometry.attributes.normal&&(Je.uniforms.normalAttribute_props.value.updateFrom(ts.geometry.attributes.normal),Je.uniforms.has_normals_props.value=!0),ts.geometry.attributes.tangent&&(Je.uniforms.tangentAttribute_props.value.updateFrom(ts.geometry.attributes.tangent),Je.uniforms.has_tangents_props.value=!0),console.log(" has_normals_scene: ",Je.uniforms.has_normals_props),console.log(" has_tangents_scene: ",Je.uniforms.has_tangents_props),gn.animate(.5),e.reset(),e.load(r+"/openpbr_objects.glb").then(()=>{Li.add(e.result.scene),es=e.result.mesh,Kl=e.result.bvh,Je.uniforms.bvh_surface.value.updateFrom(Kl),Je.uniforms.has_normals_surface.value=!1,Je.uniforms.has_tangents_surface.value=!1,es.geometry.attributes.normal&&(Je.uniforms.normalAttribute_surface.value.updateFrom(es.geometry.attributes.normal),Je.uniforms.has_normals_surface.value=!0),es.geometry.attributes.tangent&&(Je.uniforms.tangentAttribute_surface.value.updateFrom(es.geometry.attributes.tangent),Je.uniforms.has_tangents_surface.value=!0),console.log(" has_normals_surface: ",Je.uniforms.has_normals_surface),console.log(" has_tangents_surface: ",Je.uniforms.has_tangents_surface),console.log("===> LOADED"),ro=!0,Ib(),gn.animate(1),document.getElementById("progress_overlay"),gc=performance.now()})})}function vc(r){let e=23.6701655,t=.01,n=1e3;Mt=new _n(e,window.innerWidth/window.innerHeight,t,n),Ot=new ax(Mt,qt.domElement),Ot.addEventListener("change",()=>{Ae()});let i=new Ve;r=="standard-shader-ball"?i.set(.9396926207859084,0,-.3420201433256687,0,-.2203032561704394,.7649214009184319,-.6052782217606094,0,.26161852717499334,.6441236297613865,.7187909959242699,0,6.531538924716362,19.5,17.948521838355774,1):r=="glavenus"?i.set(.4848291963218869,-6938893903907228e-33,-.8746088556571293,0,-.07533009256065425,.9962839037303908,-.041758356319859954,0,.8713587249512548,.08613003638530015,.4830275243540376,0,23.076273094000275,6.7653774216248,14.822630983786677,1):r=="terrain"?i.set(.7242953632536803,-11102230246251565e-32,-.6894898307946385,0,-.4511571209928634,.7562050657737049,-.4739315886028461,0,.5213957028463604,.6543346991396579,.5477158228088388,0,8.561709328489492,11.460860759783042,8.95672568146927,1):r=="bearded-man"&&i.set(.6586894440882616,-13877787807814457e-33,.752414922929295,0,.13367205033823076,.9840924050751759,-.11702102901499911,0,-.7404458111199431,.17765736200156684,.648211279230448,0,-20.089277049402824,9.131027464916848,18.02162149148976,1),i.transpose(),Mt.matrixAutoUpdate=!1,Mt.applyMatrix4(i),Mt.matrixAutoUpdate=!0,Mt.updateMatrixWorld();let s=new C;Mt.getWorldDirection(s);let o=Mt.position.clone();o.addScaledVector(s,23.39613),Ot.target.copy(o),Ot.zoomSpeed=1.5,Ot.flySpeed=.01,Ot.update()}function jh(){return k.coat_weight!=0}function Vi(){return k.base_metalness==1?!1:k.transmission_weight>0&&k.transmission_depth>0||k.subsurface_weight>0}function ra(){return k.transmission_weight>0||k.subsurface_weight>0}function Yh(){return k.transmission_dispersion_scale>0}function $h(){return k.thin_film_weight>0}function Ib(){_a=new gh(Je),Je.transparent=!0,Je.depthWrite=!1,io=new Ki(1,1,{format:sn,type:vn}),Zf=new gh(new Ri({map:io.texture})),zn(),vc(k.scene_name),Xi=new _c({width:300});const r=Xi.addFolder("Material"),e=r.addFolder("Base");e.add(k,"base_weight",0,1).onChange(h=>{Ae()}),e.addColor(k,"base_color").onChange(h=>{Ae()}),e.add(k,"base_roughness",0,1).onChange(h=>{Ae()}),e.add(k,"base_metalness",0,1).onChange(h=>{Ae(),Vi()!=Je.defines.VOLUME_ENABLED&&(Je.defines.VOLUME_ENABLED=Vi(),zn())}),e.add(k,"diffuse_mode",Lb).onChange(h=>{Ae()});const t=r.addFolder("Specular");t.add(k,"specular_weight",0,1).onChange(h=>{Ae()}),t.addColor(k,"specular_color").onChange(h=>{Ae()}),t.add(k,"specular_roughness",0,1).onChange(h=>{Ae()}),t.add(k,"specular_ior",1,5).onChange(h=>{Ae()}),t.add(k,"specular_anisotropy",0,1).onChange(h=>{Ae()}),t.add(k,"specular_rotation",0,1).onChange(h=>{Ae()});const n=r.addFolder("Transmission");n.add(k,"transmission_weight",0,1).onChange(h=>{Ae(),Vi()!=Je.defines.VOLUME_ENABLED&&(Je.defines.VOLUME_ENABLED=Vi(),zn()),ra()!=Je.defines.TRANSMISSION_ENABLED&&(Je.defines.TRANSMISSION_ENABLED=ra(),zn())}),n.addColor(k,"transmission_color").onChange(h=>{Ae()}),n.add(k,"transmission_depth",0,1).onChange(h=>{Ae(),Vi()!=Je.defines.VOLUME_ENABLED&&(Je.defines.VOLUME_ENABLED=Vi(),zn())}),n.addColor(k,"transmission_scatter").onChange(h=>{Ae()}),n.add(k,"transmission_scatter_anisotropy",-1,1).onChange(h=>{Ae()}),n.add(k,"transmission_dispersion_abbe_number",9,91).onChange(h=>{Ae()}),n.add(k,"transmission_dispersion_scale",0,1).onChange(h=>{Ae(),Yh()!=Je.defines.DISPERSION_ENABLED&&(Je.defines.DISPERSION_ENABLED=Yh(),zn())}),n.close();const i=r.addFolder("Subsurface");i.add(k,"subsurface_weight",0,1).onChange(h=>{Ae(),Vi()!=Je.defines.VOLUME_ENABLED&&(Je.defines.VOLUME_ENABLED=Vi(),zn()),ra()!=Je.defines.TRANSMISSION_ENABLED&&(Je.defines.TRANSMISSION_ENABLED=ra(),zn())}),i.addColor(k,"subsurface_color").onChange(h=>{Ae()}),i.add(k,"subsurface_radius",0,1).onChange(h=>{Ae()}),i.addColor(k,"subsurface_radius_scale").onChange(h=>{Ae()}),i.add(k,"subsurface_anisotropy",-1,1).onChange(h=>{Ae()}),i.add(k,"subsurface_mode",Rb).onChange(h=>{Ae()}),i.close();const s=r.addFolder("Coat");s.add(k,"coat_weight",0,1).onChange(h=>{Ae(),jh()!=Je.defines.COAT_ENABLED&&(Je.defines.COAT_ENABLED=jh(),zn())}),s.addColor(k,"coat_color").onChange(h=>{Ae()}),s.add(k,"coat_roughness",0,1).onChange(h=>{Ae()}),s.add(k,"coat_ior",1,3).onChange(h=>{Ae()}),s.add(k,"coat_anisotropy",0,1).onChange(h=>{Ae()}),s.add(k,"coat_rotation",0,1).onChange(h=>{Ae()}),s.add(k,"coat_darkening",0,1).onChange(h=>{Ae()}),s.close();const o=r.addFolder("Fuzz");o.add(k,"fuzz_weight",0,1).onChange(h=>{Ae()}),o.addColor(k,"fuzz_color").onChange(h=>{Ae()}),o.add(k,"fuzz_roughness",0,1).onChange(h=>{Ae()}),o.close();const a=r.addFolder("Emission");a.add(k,"emission_luminance",0,10).onChange(h=>{Ae()}),a.addColor(k,"emission_color").onChange(h=>{Ae()}),a.close();const l=r.addFolder("Thin Film");l.add(k,"thin_film_weight",0,1).onChange(h=>{Ae(),$h()!=Je.defines.THIN_FILM_ENABLED&&(Je.defines.THIN_FILM_ENABLED=$h(),zn())}),l.add(k,"thin_film_thickness",0,2e3).onChange(h=>{Ae()}),l.add(k,"thin_film_ior",1,3).onChange(h=>{Ae()}),l.close();const c=r.addFolder("Geometry");c.add(k,"geometry_opacity",0,1).onChange(h=>{Ae()}),c.add(k,"geometry_thin_walled").onChange(h=>{Ae()}),c.close();const u=Xi.addFolder("Lighting");u.add(k,"skyPower",0,2).onChange(h=>{Ae()}),u.addColor(k,"skyColor").onChange(h=>{Ae()}),u.add(k,"sunPower",-4,4).onChange(h=>{Ae()}),u.add(k,"sunAngularSize",0,40).onChange(h=>{Ae()}),u.add(k,"sunLatitude",0,90).onChange(h=>{Ae()}),u.add(k,"sunLongitude",0,360).onChange(h=>{Ae()}),u.addColor(k,"sunColor").onChange(h=>{Ae()}),u.close();const f=Xi.addFolder("Renderer");f.add(k,"scene_name",Ab).onChange(h=>{console.log(h),Qf(h),Ae()}),f.add(k,"smooth_normals").onChange(h=>{Ae()}),f.add(k,"wireframe").onChange(h=>{Ae()}),f.addColor(k,"neutral_color").onChange(h=>{Ae()}),f.add(k,"bounces",0,100,1).onChange(h=>{Je.defines.BOUNCES=parseInt(h),Ae(),zn()}),f.add(k,"max_samples").onChange(h=>{Ae()}),f.add(k,"max_volume_steps",1,100,1).onChange(h=>{Je.defines.MAX_VOLUME_STEPS=parseInt(h),Ae(),zn()}),f.close(),Xi.add(k,"reset_camera"),Xi.open(),window.addEventListener("resize",Kh,!1),Kh()}function zn(){qt.setRenderTarget(io);let r=new ao(-1,1,1,-1,0,1);Nb(),qt.compileAsync(_a._mesh,r).then(t=>{console.log("shaders successfully compiled."),Fb()}).catch(t=>{console.log("shader compilation error: "+t)}).finally(()=>{})}function Nb(){let r=document.getElementById("progress_overlay");r.style.display="block",r.style.opacity=1,gn.set(0),gn.setText("shaders compiling..."),Ks=!0}function Fb(){gn.set(1),gc=performance.now(),Ks=!1}function Kh(){Mt.aspect=window.innerWidth/window.innerHeight,Mt.updateProjectionMatrix();const r=window.innerWidth,e=window.innerHeight;qt.setSize(r,e),qt.setPixelRatio(1),io.setSize(r,e),Ae()}function Pn(r){return new C(r[0],r[1],r[2])}function Ae(){Je&&(Je.needsUpdate=!0),ur=0}function Ob(r){let e=document.getElementById("progress_overlay");var t=setInterval(function(){e.style.opacity||(e.style.opacity=1),e.style.opacity>0?e.style.opacity-=.025:(e.style.display="none",e.style.opacity=0,clearInterval(t))},r)}function Zs(){if(!ro){console.log("not LOADED"),requestAnimationFrame(Zs);return}if(qt.domElement.style.imageRendering="auto",ur>=k.max_samples){requestAnimationFrame(Zs);return}if(!Ks&&ro){Mt.updateMatrixWorld();const r=_a.material.uniforms,e=window.innerWidth,t=window.innerHeight;r.cameraWorldMatrix.value.copy(Mt.matrixWorld),r.invProjectionMatrix.value.copy(Mt.projectionMatrixInverse),r.invModelMatrix.value.copy(Li.matrixWorld).invert();let n=new Ue(e,t);r.resolution.value.copy(n),r.accumulation_weight.value=1/(ur+1),r.samples.value=ur,r.wireframe.value=k.wireframe,r.neutral_color.value.copy(Pn(k.neutral_color)),r.smooth_normals.value=k.smooth_normals,r.base_weight.value=k.base_weight,r.base_color.value.copy(Pn(k.base_color)),r.base_roughness.value=k.base_roughness,r.base_metalness.value=k.base_metalness,r.diffuse_mode.value=k.diffuse_mode,r.specular_weight.value=k.specular_weight,r.specular_color.value.copy(Pn(k.specular_color)),r.specular_roughness.value=k.specular_roughness,r.specular_anisotropy.value=k.specular_anisotropy,r.specular_rotation.value=k.specular_rotation,r.specular_ior.value=k.specular_ior,r.transmission_weight.value=k.transmission_weight,r.transmission_color.value.copy(Pn(k.transmission_color)),r.transmission_depth.value=k.transmission_depth,r.transmission_scatter.value.copy(Pn(k.transmission_scatter)),r.transmission_scatter_anisotropy.value=k.transmission_scatter_anisotropy,r.transmission_dispersion_abbe_number.value=k.transmission_dispersion_abbe_number,r.transmission_dispersion_scale.value=k.transmission_dispersion_scale,r.subsurface_weight.value=k.subsurface_weight,r.subsurface_color.value.copy(Pn(k.subsurface_color)),r.subsurface_radius.value=k.subsurface_radius,r.subsurface_radius_scale.value.copy(Pn(k.subsurface_radius_scale)),r.subsurface_anisotropy.value=k.subsurface_anisotropy,r.subsurface_mode.value=k.subsurface_mode,r.coat_weight.value=k.coat_weight,r.coat_color.value.copy(Pn(k.coat_color)),r.coat_roughness.value=k.coat_roughness,r.coat_anisotropy.value=k.coat_anisotropy,r.coat_rotation.value=k.coat_rotation,r.coat_ior.value=k.coat_ior,r.coat_darkening.value=k.coat_darkening,r.fuzz_weight.value=k.fuzz_weight,r.fuzz_color.value.copy(Pn(k.fuzz_color)),r.fuzz_roughness.value=k.fuzz_roughness,r.emission_luminance.value=k.emission_luminance,r.emission_color.value.copy(Pn(k.emission_color)),r.thin_film_weight.value=k.thin_film_weight,r.thin_film_thickness.value=k.thin_film_thickness,r.thin_film_ior.value=k.thin_film_ior,r.geometry_opacity.value=k.geometry_opacity,r.geometry_thin_walled.value=k.geometry_thin_walled,r.skyPower.value=k.skyPower,r.skyColor.value.copy(Pn(k.skyColor)),r.sunPower.value=Math.pow(10,k.sunPower),r.sunAngularSize.value=k.sunAngularSize,r.sunColor.value.copy(Pn(k.sunColor)),Cb(),r.sunDir.value.copy(Pn(k.sunDir)),qt.autoClear=ur===0,qt.setRenderTarget(io),_a.render(qt),qt.setRenderTarget(null),Zf.render(qt),qt.autoClear=!0,ur++}else Ae(),Mt.updateProjectionMatrix(),Mt.clearViewOffset(),qt.render(Li,Mt);document.getElementById("samples").innerText=`samples: ${ur}`,Ks||document.getElementById("progress_overlay").style.display!="none"&&performance.now()-gc>300&&Ob(300),Ks&&(gn.value()<.01?gn.animate(1):gn.value()>.99&&(gn.set(0),gn.animate(1))),as.update(),requestAnimationFrame(Zs)}document.onkeydown=function(r){r=r||window.event;var e=r.which?r.which:r.keyCode;switch(e){case 122:{var t=document.body;"webkitCancelFullScreen"in document?t.webkitRequestFullScreen():"mozCancelFullScreen"in document?t.mozRequestFullScreen():console.assert(!1),Ot.update(),Ae();break}case 70:{vc(k.scene_name);break}case 72:{Xi.show(Xi._hidden),document.body.contains(as.dom)?document.body.removeChild(as.dom):document.body.appendChild(as.dom);let a=document.getElementById("info");a.style.visibility=="visible"?a.style.visibility="hidden":a.style.visibility="visible";let l=document.getElementById("samples");l.style.visibility=="visible"?l.style.visibility="hidden":l.style.visibility="visible";break}case 87:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();a.normalize();var n=new C;n.copy(a),n.multiplyScalar(Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Ae();break}case 65:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();var i=new C(1,0,0),s=i.transformDirection(Mt.matrix),n=new C;n.copy(s),n.multiplyScalar(-Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Ae();break}case 83:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();a.normalize();var n=new C;n.copy(a),n.multiplyScalar(-Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Ae();break}case 68:{let a=new C;a.copy(Ot.target),a.sub(Mt.position);let l=a.length();var i=new C(1,0,0),s=i.transformDirection(Mt.matrix),n=new C;n.copy(s),n.multiplyScalar(Ot.flySpeed*l),Mt.position.add(n),Ot.target.add(n),Ot.update(),Ae();break}case 80:{var o=document.createElement("a");let a="openpbr-viewer-screenshot.png";o.download=a,qt.domElement.toBlob(function(l){o.href=URL.createObjectURL(l);var c=new MouseEvent("click");o.dispatchEvent(c),requestAnimationFrame(Zs)},"image/png",1);break}}}; diff --git a/glavius/neutral_objects.glb b/glavenus/neutral_objects.glb similarity index 100% rename from glavius/neutral_objects.glb rename to glavenus/neutral_objects.glb diff --git a/glavius/openpbr_objects.glb b/glavenus/openpbr_objects.glb similarity index 100% rename from glavius/openpbr_objects.glb rename to glavenus/openpbr_objects.glb diff --git a/index.html b/index.html index 8b25498..68d600d 100644 --- a/index.html +++ b/index.html @@ -63,7 +63,7 @@ overflow:hidden; } - +