function $x(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var b_={exports:{}},Ap={};var Lb;function AA(){if(Lb)return Ap;Lb=1;var o=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,s,u){var f=null;if(u!==void 0&&(f=""+u),s.key!==void 0&&(f=""+s.key),"key"in s){u={};for(var h in s)h!=="key"&&(u[h]=s[h])}else u=s;return s=u.ref,{$$typeof:o,type:i,key:f,ref:s!==void 0?s:null,props:u}}return Ap.Fragment=e,Ap.jsx=t,Ap.jsxs=t,Ap}var Ib;function wA(){return Ib||(Ib=1,b_.exports=AA()),b_.exports}var Bs=wA(),M_={exports:{}},qt={};var Ob;function CA(){if(Ob)return qt;Ob=1;var o=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),f=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),b=Symbol.iterator;function M(X){return X===null||typeof X!="object"?null:(X=b&&X[b]||X["@@iterator"],typeof X=="function"?X:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,C={};function E(X,se,Ee){this.props=X,this.context=se,this.refs=C,this.updater=Ee||A}E.prototype.isReactComponent={},E.prototype.setState=function(X,se){if(typeof X!="object"&&typeof X!="function"&&X!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,X,se,"setState")},E.prototype.forceUpdate=function(X){this.updater.enqueueForceUpdate(this,X,"forceUpdate")};function D(){}D.prototype=E.prototype;function U(X,se,Ee){this.props=X,this.context=se,this.refs=C,this.updater=Ee||A}var L=U.prototype=new D;L.constructor=U,R(L,E.prototype),L.isPureReactComponent=!0;var B=Array.isArray;function P(){}var H={H:null,A:null,T:null,S:null},W=Object.prototype.hasOwnProperty;function I(X,se,Ee){var Oe=Ee.ref;return{$$typeof:o,type:X,key:se,ref:Oe!==void 0?Oe:null,props:Ee}}function z(X,se){return I(X.type,se,X.props)}function j(X){return typeof X=="object"&&X!==null&&X.$$typeof===o}function ae(X){var se={"=":"=0",":":"=2"};return"$"+X.replace(/[=:]/g,function(Ee){return se[Ee]})}var $=/\/+/g;function ue(X,se){return typeof X=="object"&&X!==null&&X.key!=null?ae(""+X.key):se.toString(36)}function he(X){switch(X.status){case"fulfilled":return X.value;case"rejected":throw X.reason;default:switch(typeof X.status=="string"?X.then(P,P):(X.status="pending",X.then(function(se){X.status==="pending"&&(X.status="fulfilled",X.value=se)},function(se){X.status==="pending"&&(X.status="rejected",X.reason=se)})),X.status){case"fulfilled":return X.value;case"rejected":throw X.reason}}throw X}function q(X,se,Ee,Oe,nt){var fe=typeof X;(fe==="undefined"||fe==="boolean")&&(X=null);var Te=!1;if(X===null)Te=!0;else switch(fe){case"bigint":case"string":case"number":Te=!0;break;case"object":switch(X.$$typeof){case o:case e:Te=!0;break;case _:return Te=X._init,q(Te(X._payload),se,Ee,Oe,nt)}}if(Te)return nt=nt(X),Te=Oe===""?"."+ue(X,0):Oe,B(nt)?(Ee="",Te!=null&&(Ee=Te.replace($,"$&/")+"/"),q(nt,se,Ee,"",function(ut){return ut})):nt!=null&&(j(nt)&&(nt=z(nt,Ee+(nt.key==null||X&&X.key===nt.key?"":(""+nt.key).replace($,"$&/")+"/")+Te)),se.push(nt)),1;Te=0;var Je=Oe===""?".":Oe+":";if(B(X))for(var et=0;et>>1,Ce=q[Ae];if(0>>1;Aes(Ee,ce))Oes(nt,Ee)?(q[Ae]=nt,q[Oe]=ce,Ae=Oe):(q[Ae]=Ee,q[se]=ce,Ae=se);else if(Oes(nt,ce))q[Ae]=nt,q[Oe]=ce,Ae=Oe;else break e}}return K}function s(q,K){var ce=q.sortIndex-K.sortIndex;return ce!==0?ce:q.id-K.id}if(o.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;o.unstable_now=function(){return u.now()}}else{var f=Date,h=f.now();o.unstable_now=function(){return f.now()-h}}var m=[],g=[],_=1,x=null,b=3,M=!1,A=!1,R=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,D=typeof clearTimeout=="function"?clearTimeout:null,U=typeof setImmediate<"u"?setImmediate:null;function L(q){for(var K=t(g);K!==null;){if(K.callback===null)i(g);else if(K.startTime<=q)i(g),K.sortIndex=K.expirationTime,e(m,K);else break;K=t(g)}}function B(q){if(R=!1,L(q),!A)if(t(m)!==null)A=!0,P||(P=!0,ae());else{var K=t(g);K!==null&&he(B,K.startTime-q)}}var P=!1,H=-1,W=5,I=-1;function z(){return C?!0:!(o.unstable_now()-Iq&&z());){var Ae=x.callback;if(typeof Ae=="function"){x.callback=null,b=x.priorityLevel;var Ce=Ae(x.expirationTime<=q);if(q=o.unstable_now(),typeof Ce=="function"){x.callback=Ce,L(q),K=!0;break t}x===t(m)&&i(m),L(q)}else i(m);x=t(m)}if(x!==null)K=!0;else{var X=t(g);X!==null&&he(B,X.startTime-q),K=!1}}break e}finally{x=null,b=ce,M=!1}K=void 0}}finally{K?ae():P=!1}}}var ae;if(typeof U=="function")ae=function(){U(j)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,ue=$.port2;$.port1.onmessage=j,ae=function(){ue.postMessage(null)}}else ae=function(){E(j,0)};function he(q,K){H=E(function(){q(o.unstable_now())},K)}o.unstable_IdlePriority=5,o.unstable_ImmediatePriority=1,o.unstable_LowPriority=4,o.unstable_NormalPriority=3,o.unstable_Profiling=null,o.unstable_UserBlockingPriority=2,o.unstable_cancelCallback=function(q){q.callback=null},o.unstable_forceFrameRate=function(q){0>q||125Ae?(q.sortIndex=ce,e(g,q),t(m)===null&&q===t(g)&&(R?(D(H),H=-1):R=!0,he(B,ce-Ae))):(q.sortIndex=Ce,e(m,q),A||M||(A=!0,P||(P=!0,ae()))),q},o.unstable_shouldYield=z,o.unstable_wrapCallback=function(q){var K=b;return function(){var ce=b;b=K;try{return q.apply(this,arguments)}finally{b=ce}}}})(A_)),A_}var Bb;function z1(){return Bb||(Bb=1,T_.exports=RA()),T_.exports}var w_={exports:{}},Ca={};var Fb;function DA(){if(Fb)return Ca;Fb=1;var o=ym();function e(m){var g="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(o)}catch(e){console.error(e)}}return o(),w_.exports=DA(),w_.exports}var kb;function UA(){if(kb)return wp;kb=1;var o=z1(),e=ym(),t=NA();function i(n){var a="https://react.dev/errors/"+n;if(1Ce||(n.current=Ae[Ce],Ae[Ce]=null,Ce--)}function Ee(n,a){Ce++,Ae[Ce]=n.current,n.current=a}var Oe=X(null),nt=X(null),fe=X(null),Te=X(null);function Je(n,a){switch(Ee(fe,a),Ee(nt,n),Ee(Oe,null),a.nodeType){case 9:case 11:n=(n=a.documentElement)&&(n=n.namespaceURI)?nb(n):0;break;default:if(n=a.tagName,a=a.namespaceURI)a=nb(a),n=ib(a,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}se(Oe),Ee(Oe,n)}function et(){se(Oe),se(nt),se(fe)}function ut(n){n.memoizedState!==null&&Ee(Te,n);var a=Oe.current,c=ib(a,n.type);a!==c&&(Ee(nt,n),Ee(Oe,c))}function Jt(n){nt.current===n&&(se(Oe),se(nt)),Te.current===n&&(se(Te),bp._currentValue=ce)}var on,Dt;function Re(n){if(on===void 0)try{throw Error()}catch(c){var a=c.stack.trim().match(/\n( *(at )?)/);on=a&&a[1]||"",Dt=-1)":-1y||Q[d]!==pe[y]){var we=` `+Q[d].replace(" at new "," at ");return n.displayName&&we.includes("")&&(we=we.replace("",n.displayName)),we}while(1<=d&&0<=y);break}}}finally{Ve=!1,Error.prepareStackTrace=c}return(c=n?n.displayName||n.name:"")?Re(c):""}function Ke(n,a){switch(n.tag){case 26:case 27:case 5:return Re(n.type);case 16:return Re("Lazy");case 13:return n.child!==a&&a!==null?Re("Suspense Fallback"):Re("Suspense");case 19:return Re("SuspenseList");case 0:case 15:return Ue(n.type,!1);case 11:return Ue(n.type.render,!1);case 1:return Ue(n.type,!0);case 31:return Re("Activity");default:return""}}function Z(n){try{var a="",c=null;do a+=Ke(n,c),c=n,n=n.return;while(n);return a}catch(d){return` Error generating stack: `+d.message+` `+d.stack}}var St=Object.prototype.hasOwnProperty,tt=o.unstable_scheduleCallback,Mt=o.unstable_cancelCallback,We=o.unstable_shouldYield,G=o.unstable_requestPaint,O=o.unstable_now,ne=o.unstable_getCurrentPriorityLevel,Se=o.unstable_ImmediatePriority,Le=o.unstable_UserBlockingPriority,be=o.unstable_NormalPriority,ct=o.unstable_LowPriority,Ze=o.unstable_IdlePriority,gt=o.log,wt=o.unstable_setDisableYieldValue,Be=null,Xe=null;function ft(n){if(typeof gt=="function"&&wt(n),Xe&&typeof Xe.setStrictMode=="function")try{Xe.setStrictMode(Be,n)}catch{}}var lt=Math.clz32?Math.clz32:te,$e=Math.log,Zt=Math.LN2;function te(n){return n>>>=0,n===0?32:31-($e(n)/Zt|0)|0}var it=256,Ge=262144,st=4194304;function Fe(n){var a=n&42;if(a!==0)return a;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function Ne(n,a,c){var d=n.pendingLanes;if(d===0)return 0;var y=0,S=n.suspendedLanes,N=n.pingedLanes;n=n.warmLanes;var k=d&134217727;return k!==0?(d=k&~S,d!==0?y=Fe(d):(N&=k,N!==0?y=Fe(N):c||(c=k&~n,c!==0&&(y=Fe(c))))):(k=d&~S,k!==0?y=Fe(k):N!==0?y=Fe(N):c||(c=d&~n,c!==0&&(y=Fe(c)))),y===0?0:a!==0&&a!==y&&(a&S)===0&&(S=y&-y,c=a&-a,S>=c||S===32&&(c&4194048)!==0)?a:y}function je(n,a){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&a)===0}function Bt(n,a){switch(n){case 1:case 2:case 4:case 8:case 64:return a+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function dn(){var n=st;return st<<=1,(st&62914560)===0&&(st=4194304),n}function gn(n){for(var a=[],c=0;31>c;c++)a.push(n);return a}function Xi(n,a){n.pendingLanes|=a,a!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function va(n,a,c,d,y,S){var N=n.pendingLanes;n.pendingLanes=c,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=c,n.entangledLanes&=c,n.errorRecoveryDisabledLanes&=c,n.shellSuspendCounter=0;var k=n.entanglements,Q=n.expirationTimes,pe=n.hiddenUpdates;for(c=N&~c;0"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var vn=/[\n"\\]/g;function Ot(n){return n.replace(vn,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function vi(n,a,c,d,y,S,N,k){n.name="",N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?n.type=N:n.removeAttribute("type"),a!=null?N==="number"?(a===0&&n.value===""||n.value!=a)&&(n.value=""+Ut(a)):n.value!==""+Ut(a)&&(n.value=""+Ut(a)):N!=="submit"&&N!=="reset"||n.removeAttribute("value"),a!=null?Gn(n,N,Ut(a)):c!=null?Gn(n,N,Ut(c)):d!=null&&n.removeAttribute("value"),y==null&&S!=null&&(n.defaultChecked=!!S),y!=null&&(n.checked=y&&typeof y!="function"&&typeof y!="symbol"),k!=null&&typeof k!="function"&&typeof k!="symbol"&&typeof k!="boolean"?n.name=""+Ut(k):n.removeAttribute("name")}function Ds(n,a,c,d,y,S,N,k){if(S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(n.type=S),a!=null||c!=null){if(!(S!=="submit"&&S!=="reset"||a!=null)){Un(n);return}c=c!=null?""+Ut(c):"",a=a!=null?""+Ut(a):c,k||a===n.value||(n.value=a),n.defaultValue=a}d=d??y,d=typeof d!="function"&&typeof d!="symbol"&&!!d,n.checked=k?n.checked:!!d,n.defaultChecked=!!d,N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"&&(n.name=N),Un(n)}function Gn(n,a,c){a==="number"&&at(n.ownerDocument)===n||n.defaultValue===""+c||(n.defaultValue=""+c)}function sa(n,a,c,d){if(n=n.options,a){a={};for(var y=0;y"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),sd=!1;if(Xs)try{var Nl={};Object.defineProperty(Nl,"passive",{get:function(){sd=!0}}),window.addEventListener("test",Nl,Nl),window.removeEventListener("test",Nl,Nl)}catch{sd=!1}var Va=null,rf=null,Wo=null;function ku(){if(Wo)return Wo;var n,a=rf,c=a.length,d,y="value"in Va?Va.value:Va.textContent,S=y.length;for(n=0;n=zl),Wm=" ",qu=!1;function pf(n,a){switch(n){case"keyup":return Xm.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function hd(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Zo=!1;function qm(n,a){switch(n){case"compositionend":return hd(a);case"keypress":return a.which!==32?null:(qu=!0,Wm);case"textInput":return n=a.data,n===Wm&&qu?null:n;default:return null}}function dd(n,a){if(Zo)return n==="compositionend"||!Yo&&pf(n,a)?(n=ku(),Wo=rf=Va=null,Zo=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1=a)return{node:c,offset:a-n};n=d}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=ju(c)}}function Pn(n,a){return n&&a?n===a?!0:n&&n.nodeType===3?!1:a&&a.nodeType===3?Pn(n,a.parentNode):"contains"in n?n.contains(a):n.compareDocumentPosition?!!(n.compareDocumentPosition(a)&16):!1:!1}function Jm(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var a=at(n.document);a instanceof n.HTMLIFrameElement;){try{var c=typeof a.contentWindow.location.href=="string"}catch{c=!1}if(c)n=a.contentWindow;else break;a=at(n.document)}return a}function Sd(n){var a=n&&n.nodeName&&n.nodeName.toLowerCase();return a&&(a==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||a==="textarea"||n.contentEditable==="true")}var Km=Xs&&"documentMode"in document&&11>=document.documentMode,qs=null,Ys=null,Vl=null,gf=!1;function kl(n,a,c){var d=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;gf||qs==null||qs!==at(d)||(d=qs,"selectionStart"in d&&Sd(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),Vl&&Bl(Vl,d)||(Vl=d,d=Jg(Ys,"onSelect"),0>=N,y-=N,Kn=1<<32-lt(a)+y|c<nn?(_n=bt,bt=null):_n=bt.sibling;var Cn=ve(re,bt,de[nn],De);if(Cn===null){bt===null&&(bt=_n);break}n&&bt&&Cn.alternate===null&&a(re,bt),ee=S(Cn,ee,nn),wn===null?Rt=Cn:wn.sibling=Cn,wn=Cn,bt=_n}if(nn===de.length)return c(re,bt),fn&&js(re,nn),Rt;if(bt===null){for(;nnnn?(_n=bt,bt=null):_n=bt.sibling;var yu=ve(re,bt,Cn.value,De);if(yu===null){bt===null&&(bt=_n);break}n&&bt&&yu.alternate===null&&a(re,bt),ee=S(yu,ee,nn),wn===null?Rt=yu:wn.sibling=yu,wn=yu,bt=_n}if(Cn.done)return c(re,bt),fn&&js(re,nn),Rt;if(bt===null){for(;!Cn.done;nn++,Cn=de.next())Cn=Ie(re,Cn.value,De),Cn!==null&&(ee=S(Cn,ee,nn),wn===null?Rt=Cn:wn.sibling=Cn,wn=Cn);return fn&&js(re,nn),Rt}for(bt=d(bt);!Cn.done;nn++,Cn=de.next())Cn=Me(bt,re,nn,Cn.value,De),Cn!==null&&(n&&Cn.alternate!==null&&bt.delete(Cn.key===null?nn:Cn.key),ee=S(Cn,ee,nn),wn===null?Rt=Cn:wn.sibling=Cn,wn=Cn);return n&&bt.forEach(function(TA){return a(re,TA)}),fn&&js(re,nn),Rt}function kn(re,ee,de,De){if(typeof de=="object"&&de!==null&&de.type===R&&de.key===null&&(de=de.props.children),typeof de=="object"&&de!==null){switch(de.$$typeof){case M:e:{for(var Rt=de.key;ee!==null;){if(ee.key===Rt){if(Rt=de.type,Rt===R){if(ee.tag===7){c(re,ee.sibling),De=y(ee,de.props.children),De.return=re,re=De;break e}}else if(ee.elementType===Rt||typeof Rt=="object"&&Rt!==null&&Rt.$$typeof===W&&$o(Rt)===ee.type){c(re,ee.sibling),De=y(ee,de.props),cs(De,de),De.return=re,re=De;break e}c(re,ee);break}else a(re,ee);ee=ee.sibling}de.type===R?(De=ao(de.props.children,re.mode,De,de.key),De.return=re,re=De):(De=Zs(de.type,de.key,de.props,null,re.mode,De),cs(De,de),De.return=re,re=De)}return N(re);case A:e:{for(Rt=de.key;ee!==null;){if(ee.key===Rt)if(ee.tag===4&&ee.stateNode.containerInfo===de.containerInfo&&ee.stateNode.implementation===de.implementation){c(re,ee.sibling),De=y(ee,de.children||[]),De.return=re,re=De;break e}else{c(re,ee);break}else a(re,ee);ee=ee.sibling}De=Sf(de,re.mode,De),De.return=re,re=De}return N(re);case W:return de=$o(de),kn(re,ee,de,De)}if(he(de))return xt(re,ee,de,De);if(ae(de)){if(Rt=ae(de),typeof Rt!="function")throw Error(i(150));return de=Rt.call(de),zt(re,ee,de,De)}if(typeof de.then=="function")return kn(re,ee,sc(de),De);if(de.$$typeof===U)return kn(re,ee,jl(re,de),De);Ql(re,de)}return typeof de=="string"&&de!==""||typeof de=="number"||typeof de=="bigint"?(de=""+de,ee!==null&&ee.tag===6?(c(re,ee.sibling),De=y(ee,de),De.return=re,re=De):(c(re,ee),De=xf(de,re.mode,De),De.return=re,re=De),N(re)):c(re,ee)}return function(re,ee,de,De){try{il=0;var Rt=kn(re,ee,de,De);return nl=null,Rt}catch(bt){if(bt===Ko||bt===Kt)throw bt;var wn=Jn(29,bt,null,re.mode);return wn.lanes=De,wn.return=re,wn}}}var Dr=Nf(!0),Uf=Nf(!1),ua=!1;function rc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Nd(n,a){n=n.updateQueue,a.updateQueue===n&&(a.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Nr(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function fo(n,a,c){var d=n.updateQueue;if(d===null)return null;if(d=d.shared,(Et&2)!==0){var y=d.pending;return y===null?a.next=a:(a.next=y.next,y.next=a),d.pending=a,a=ls(n),no(n,null,c),a}return Pi(n,d,a,c),ls(n)}function ho(n,a,c){if(a=a.updateQueue,a!==null&&(a=a.shared,(c&4194048)!==0)){var d=a.lanes;d&=n.pendingLanes,c|=d,a.lanes=c,jr(n,c)}}function Ct(n,a){var c=n.updateQueue,d=n.alternate;if(d!==null&&(d=d.updateQueue,c===d)){var y=null,S=null;if(c=c.firstBaseUpdate,c!==null){do{var N={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};S===null?y=S=N:S=S.next=N,c=c.next}while(c!==null);S===null?y=S=a:S=S.next=a}else y=S=a;c={baseState:d.baseState,firstBaseUpdate:y,lastBaseUpdate:S,shared:d.shared,callbacks:d.callbacks},n.updateQueue=c;return}n=c.lastBaseUpdate,n===null?c.firstBaseUpdate=a:n.next=a,c.lastBaseUpdate=a}var Ud=!1;function oc(){if(Ud){var n=us;if(n!==null)throw n}}function Jl(n,a,c,d){Ud=!1;var y=n.updateQueue;ua=!1;var S=y.firstBaseUpdate,N=y.lastBaseUpdate,k=y.shared.pending;if(k!==null){y.shared.pending=null;var Q=k,pe=Q.next;Q.next=null,N===null?S=pe:N.next=pe,N=Q;var we=n.alternate;we!==null&&(we=we.updateQueue,k=we.lastBaseUpdate,k!==N&&(k===null?we.firstBaseUpdate=pe:k.next=pe,we.lastBaseUpdate=Q))}if(S!==null){var Ie=y.baseState;N=0,we=pe=Q=null,k=S;do{var ve=k.lane&-536870913,Me=ve!==k.lane;if(Me?(jt&ve)===ve:(d&ve)===ve){ve!==0&&ve===Rr&&(Ud=!0),we!==null&&(we=we.next={lane:0,tag:k.tag,payload:k.payload,callback:null,next:null});e:{var xt=n,zt=k;ve=a;var kn=c;switch(zt.tag){case 1:if(xt=zt.payload,typeof xt=="function"){Ie=xt.call(kn,Ie,ve);break e}Ie=xt;break e;case 3:xt.flags=xt.flags&-65537|128;case 0:if(xt=zt.payload,ve=typeof xt=="function"?xt.call(kn,Ie,ve):xt,ve==null)break e;Ie=x({},Ie,ve);break e;case 2:ua=!0}}ve=k.callback,ve!==null&&(n.flags|=64,Me&&(n.flags|=8192),Me=y.callbacks,Me===null?y.callbacks=[ve]:Me.push(ve))}else Me={lane:ve,tag:k.tag,payload:k.payload,callback:k.callback,next:null},we===null?(pe=we=Me,Q=Ie):we=we.next=Me,N|=ve;if(k=k.next,k===null){if(k=y.shared.pending,k===null)break;Me=k,k=Me.next,Me.next=null,y.lastBaseUpdate=Me,y.shared.pending=null}}while(!0);we===null&&(Q=Ie),y.baseState=Q,y.firstBaseUpdate=pe,y.lastBaseUpdate=we,S===null&&(y.shared.lanes=0),ur|=N,n.lanes=N,n.memoizedState=Ie}}function Kl(n,a){if(typeof n!="function")throw Error(i(191,n));n.call(a)}function og(n,a){var c=n.callbacks;if(c!==null)for(n.callbacks=null,n=0;nS?S:8;var N=q.T,k={};q.T=k,tp(n,!1,a,c);try{var Q=y(),pe=q.S;if(pe!==null&&pe(k,Q),Q!==null&&typeof Q=="object"&&typeof Q.then=="function"){var we=Rd(Q,d);fc(n,a,we,ja(n))}else fc(n,a,d,ja(n))}catch(Ie){fc(n,a,{then:function(){},status:"rejected",reason:Ie},ja())}finally{K.p=S,N!==null&&k.types!==null&&(N.types=k.types),q.T=N}}function jy(){}function $d(n,a,c,d){if(n.tag!==5)throw Error(i(476));var y=Ig(n).queue;Lg(n,y,a,ce,c===null?jy:function(){return Og(n),c(d)})}function Ig(n){var a=n.memoizedState;if(a!==null)return a;a={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lr,lastRenderedState:ce},next:null};var c={};return a.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lr,lastRenderedState:c},next:null},n.memoizedState=a,n=n.alternate,n!==null&&(n.memoizedState=a),a}function Og(n){var a=Ig(n);a.next===null&&(a=n.alternate.memoizedState),fc(n,a.next.queue,{},ja())}function ep(){return Pt(bp)}function zg(){return ci().memoizedState}function Pg(){return ci().memoizedState}function Qy(n){for(var a=n.return;a!==null;){switch(a.tag){case 24:case 3:var c=ja();n=Nr(c);var d=fo(a,n,c);d!==null&&(en(d,a,c),ho(d,a,c)),a={cache:Ad()},n.payload=a;return}a=a.return}}function Jy(n,a,c){var d=ja();c={lane:d,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},kf(n)?Fg(a,c):(c=yf(n,a,c,d),c!==null&&(en(c,n,d),Vg(c,a,d)))}function Bg(n,a,c){var d=ja();fc(n,a,c,d)}function fc(n,a,c,d){var y={lane:d,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(kf(n))Fg(a,y);else{var S=n.alternate;if(n.lanes===0&&(S===null||S.lanes===0)&&(S=a.lastRenderedReducer,S!==null))try{var N=a.lastRenderedState,k=S(N,c);if(y.hasEagerState=!0,y.eagerState=k,oa(k,N))return Pi(n,a,y,0),Vt===null&&ec(),!1}catch{}if(c=yf(n,a,y,d),c!==null)return en(c,n,d),Vg(c,a,d),!0}return!1}function tp(n,a,c,d){if(d={lane:2,revertLane:_e(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},kf(n)){if(a)throw Error(i(479))}else a=yf(n,c,d,2),a!==null&&en(a,n,2)}function kf(n){var a=n.alternate;return n===Xt||a!==null&&a===Xt}function Fg(n,a){eu=fs=!0;var c=n.pending;c===null?a.next=a:(a.next=c.next,c.next=a),n.pending=a}function Vg(n,a,c){if((c&4194048)!==0){var d=a.lanes;d&=n.pendingLanes,c|=d,a.lanes=c,jr(n,c)}}var nu={readContext:Pt,use:po,useCallback:$n,useContext:$n,useEffect:$n,useImperativeHandle:$n,useLayoutEffect:$n,useInsertionEffect:$n,useMemo:$n,useReducer:$n,useRef:$n,useState:$n,useDebugValue:$n,useDeferredValue:$n,useTransition:$n,useSyncExternalStore:$n,useId:$n,useHostTransitionStatus:$n,useFormState:$n,useActionState:$n,useOptimistic:$n,useMemoCache:$n,useCacheRefresh:$n};nu.useEffectEvent=$n;var kg={readContext:Pt,use:po,useCallback:function(n,a){return wi().memoizedState=[n,a===void 0?null:a],n},useContext:Pt,useEffect:Mg,useImperativeHandle:function(n,a,c){c=c!=null?c.concat([n]):null,Ff(4194308,4,Cg.bind(null,a,n),c)},useLayoutEffect:function(n,a){return Ff(4194308,4,n,a)},useInsertionEffect:function(n,a){Ff(4,2,n,a)},useMemo:function(n,a){var c=wi();a=a===void 0?null:a;var d=n();if(al){ft(!0);try{n()}finally{ft(!1)}}return c.memoizedState=[d,a],d},useReducer:function(n,a,c){var d=wi();if(c!==void 0){var y=c(a);if(al){ft(!0);try{c(a)}finally{ft(!1)}}}else y=a;return d.memoizedState=d.baseState=y,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:y},d.queue=n,n=n.dispatch=Jy.bind(null,Xt,n),[d.memoizedState,n]},useRef:function(n){var a=wi();return n={current:n},a.memoizedState=n},useState:function(n){n=Gd(n);var a=n.queue,c=Bg.bind(null,Xt,a);return a.dispatch=c,[n.memoizedState,c]},useDebugValue:Jd,useDeferredValue:function(n,a){var c=wi();return Kd(c,n,a)},useTransition:function(){var n=Gd(!1);return n=Lg.bind(null,Xt,n.queue,!0,!1),wi().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,a,c){var d=Xt,y=wi();if(fn){if(c===void 0)throw Error(i(407));c=c()}else{if(c=a(),Vt===null)throw Error(i(349));(jt&127)!==0||hg(d,a,c)}y.memoizedState=c;var S={value:c,getSnapshot:a};return y.queue=S,Mg(pg.bind(null,d,S,n),[n]),d.flags|=2048,mo(9,{destroy:void 0},dg.bind(null,d,S,c,a),null),c},useId:function(){var n=wi(),a=Vt.identifierPrefix;if(fn){var c=Ns,d=Kn;c=(d&~(1<<32-lt(d)-1)).toString(32)+c,a="_"+a+"R_"+c,c=If++,0<\/script>",S=S.removeChild(S.firstChild);break;case"select":S=typeof d.is=="string"?N.createElement("select",{is:d.is}):N.createElement("select"),d.multiple?S.multiple=!0:d.size&&(S.size=d.size);break;default:S=typeof d.is=="string"?N.createElement(y,{is:d.is}):N.createElement(y)}}S[Qn]=a,S[Ti]=d;e:for(N=a.child;N!==null;){if(N.tag===5||N.tag===6)S.appendChild(N.stateNode);else if(N.tag!==4&&N.tag!==27&&N.child!==null){N.child.return=N,N=N.child;continue}if(N===a)break e;for(;N.sibling===null;){if(N.return===null||N.return===a)break e;N=N.return}N.sibling.return=N.return,N=N.sibling}a.stateNode=S;e:switch(ma(S,y,d),y){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&ar(a)}}return In(a),mc(a,a.type,n===null?null:n.memoizedProps,a.pendingProps,c),null;case 6:if(n&&a.stateNode!=null)n.memoizedProps!==d&&ar(a);else{if(typeof d!="string"&&a.stateNode===null)throw Error(i(166));if(n=fe.current,Yl(a)){if(n=a.stateNode,c=a.memoizedProps,d=null,y=si,y!==null)switch(y.tag){case 27:case 5:d=y.memoizedProps}n[Qn]=a,n=!!(n.nodeValue===c||d!==null&&d.suppressHydrationWarning===!0||eb(n.nodeValue,c)),n||Js(a,!0)}else n=Kg(n).createTextNode(d),n[Qn]=a,a.stateNode=n}return In(a),null;case 31:if(c=a.memoizedState,n===null||n.memoizedState!==null){if(d=Yl(a),c!==null){if(n===null){if(!d)throw Error(i(318));if(n=a.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(557));n[Qn]=a}else oo(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;In(a),n=!1}else c=Ef(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=c),n=!0;if(!n)return a.flags&256?(ui(a),a):(ui(a),null);if((a.flags&128)!==0)throw Error(i(558))}return In(a),null;case 13:if(d=a.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(y=Yl(a),d!==null&&d.dehydrated!==null){if(n===null){if(!y)throw Error(i(318));if(y=a.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(i(317));y[Qn]=a}else oo(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;In(a),y=!1}else y=Ef(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=y),y=!0;if(!y)return a.flags&256?(ui(a),a):(ui(a),null)}return ui(a),(a.flags&128)!==0?(a.lanes=c,a):(c=d!==null,n=n!==null&&n.memoizedState!==null,c&&(d=a.child,y=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(y=d.alternate.memoizedState.cachePool.pool),S=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(S=d.memoizedState.cachePool.pool),S!==y&&(d.flags|=2048)),c!==n&&c&&(a.child.flags|=8192),Ir(a,a.updateQueue),In(a),null);case 4:return et(),n===null&&n_(a.stateNode.containerInfo),In(a),null;case 10:return er(a.type),In(a),null;case 19:if(se(hn),d=a.memoizedState,d===null)return In(a),null;if(y=(a.flags&128)!==0,S=d.rendering,S===null)if(y)sr(d,!1);else{if(ei!==0||n!==null&&(n.flags&128)!==0)for(n=a.child;n!==null;){if(S=Xa(n),S!==null){for(a.flags|=128,sr(d,!1),n=S.updateQueue,a.updateQueue=n,Ir(a,n),a.subtreeFlags=0,n=c,c=a.child;c!==null;)Hl(c,n),c=c.sibling;return Ee(hn,hn.current&1|2),fn&&js(a,d.treeForkCount),a.child}n=n.sibling}d.tail!==null&&O()>hi&&(a.flags|=128,y=!0,sr(d,!1),a.lanes=4194304)}else{if(!y)if(n=Xa(S),n!==null){if(a.flags|=128,y=!0,n=n.updateQueue,a.updateQueue=n,Ir(a,n),sr(d,!0),d.tail===null&&d.tailMode==="hidden"&&!S.alternate&&!fn)return In(a),null}else 2*O()-d.renderingStartTime>hi&&c!==536870912&&(a.flags|=128,y=!0,sr(d,!1),a.lanes=4194304);d.isBackwards?(S.sibling=a.child,a.child=S):(n=d.last,n!==null?n.sibling=S:a.child=S,d.last=S)}return d.tail!==null?(n=d.tail,d.rendering=n,d.tail=n.sibling,d.renderingStartTime=O(),n.sibling=null,c=hn.current,Ee(hn,y?c&1|2:c&1),fn&&js(a,d.treeForkCount),n):(In(a),null);case 22:case 23:return ui(a),lc(),d=a.memoizedState!==null,n!==null?n.memoizedState!==null!==d&&(a.flags|=8192):d&&(a.flags|=8192),d?(c&536870912)!==0&&(a.flags&128)===0&&(In(a),a.subtreeFlags&6&&(a.flags|=8192)):In(a),c=a.updateQueue,c!==null&&Ir(a,c.retryQueue),c=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(c=n.memoizedState.cachePool.pool),d=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(d=a.memoizedState.cachePool.pool),d!==c&&(a.flags|=2048),n!==null&&se(co),null;case 24:return c=null,n!==null&&(c=n.memoizedState.cache),a.memoizedState.cache!==c&&(a.flags|=2048),er(_i),In(a),null;case 25:return null;case 30:return null}throw Error(i(156,a.tag))}function ds(n,a){switch(bf(a),a.tag){case 1:return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 3:return er(_i),et(),n=a.flags,(n&65536)!==0&&(n&128)===0?(a.flags=n&-65537|128,a):null;case 26:case 27:case 5:return Jt(a),null;case 31:if(a.memoizedState!==null){if(ui(a),a.alternate===null)throw Error(i(340));oo()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 13:if(ui(a),n=a.memoizedState,n!==null&&n.dehydrated!==null){if(a.alternate===null)throw Error(i(340));oo()}return n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 19:return se(hn),null;case 4:return et(),null;case 10:return er(a.type),null;case 22:case 23:return ui(a),lc(),n!==null&&se(co),n=a.flags,n&65536?(a.flags=n&-65537|128,a):null;case 24:return er(_i),null;case 25:return null;default:return null}}function Wa(n,a){switch(bf(a),a.tag){case 3:er(_i),et();break;case 26:case 27:case 5:Jt(a);break;case 4:et();break;case 31:a.memoizedState!==null&&ui(a);break;case 13:ui(a);break;case 19:se(hn);break;case 10:er(a.type);break;case 22:case 23:ui(a),lc(),n!==null&&se(co);break;case 24:er(_i)}}function ps(n,a){try{var c=a.updateQueue,d=c!==null?c.lastEffect:null;if(d!==null){var y=d.next;c=y;do{if((c.tag&n)===n){d=void 0;var S=c.create,N=c.inst;d=S(),N.destroy=d}c=c.next}while(c!==y)}}catch(k){bn(a,a.return,k)}}function qi(n,a,c){try{var d=a.updateQueue,y=d!==null?d.lastEffect:null;if(y!==null){var S=y.next;d=S;do{if((d.tag&n)===n){var N=d.inst,k=N.destroy;if(k!==void 0){N.destroy=void 0,y=a;var Q=c,pe=k;try{pe()}catch(we){bn(y,Q,we)}}}d=d.next}while(d!==S)}}catch(we){bn(a,a.return,we)}}function Us(n){var a=n.updateQueue;if(a!==null){var c=n.stateNode;try{og(a,c)}catch(d){bn(n,n.return,d)}}}function Fi(n,a,c){c.props=go(n.type,n.memoizedProps),c.state=n.memoizedState;try{c.componentWillUnmount()}catch(d){bn(n,a,d)}}function Or(n,a){try{var c=n.ref;if(c!==null){switch(n.tag){case 26:case 27:case 5:var d=n.stateNode;break;case 30:d=n.stateNode;break;default:d=n.stateNode}typeof c=="function"?n.refCleanup=c(d):c.current=d}}catch(y){bn(n,a,y)}}function Yi(n,a){var c=n.ref,d=n.refCleanup;if(c!==null)if(typeof d=="function")try{d()}catch(y){bn(n,a,y)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(y){bn(n,a,y)}else c.current=null}function vc(n){var a=n.type,c=n.memoizedProps,d=n.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":c.autoFocus&&d.focus();break e;case"img":c.src?d.src=c.src:c.srcSet&&(d.srcset=c.srcSet)}}catch(y){bn(n,n.return,y)}}function Ri(n,a,c){try{var d=n.stateNode;jT(d,n.type,c,a),d[Ti]=a}catch(y){bn(n,n.return,y)}}function Zn(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&du(n.type)||n.tag===4}function un(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Zn(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&du(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function rr(n,a,c){var d=n.tag;if(d===5||d===6)n=n.stateNode,a?(c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c).insertBefore(n,a):(a=c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c,a.appendChild(n),c=c._reactRootContainer,c!=null||a.onclick!==null||(a.onclick=Mr));else if(d!==4&&(d===27&&du(n.type)&&(c=n.stateNode,a=null),n=n.child,n!==null))for(rr(n,a,c),n=n.sibling;n!==null;)rr(n,a,c),n=n.sibling}function fa(n,a,c){var d=n.tag;if(d===5||d===6)n=n.stateNode,a?c.insertBefore(n,a):c.appendChild(n);else if(d!==4&&(d===27&&du(n.type)&&(c=n.stateNode),n=n.child,n!==null))for(fa(n,a,c),n=n.sibling;n!==null;)fa(n,a,c),n=n.sibling}function $f(n){var a=n.stateNode,c=n.memoizedProps;try{for(var d=n.type,y=a.attributes;y.length;)a.removeAttributeNode(y[0]);ma(a,d,c),a[Qn]=n,a[Ti]=c}catch(S){bn(n,n.return,S)}}var ms=!1,Fn=!1,Ls=!1,jg=typeof WeakSet=="function"?WeakSet:Set,Vi=null;function $y(n,a){if(n=n.containerInfo,s_=s0,n=Jm(n),Sd(n)){if("selectionStart"in n)var c={start:n.selectionStart,end:n.selectionEnd};else e:{c=(c=n.ownerDocument)&&c.defaultView||window;var d=c.getSelection&&c.getSelection();if(d&&d.rangeCount!==0){c=d.anchorNode;var y=d.anchorOffset,S=d.focusNode;d=d.focusOffset;try{c.nodeType,S.nodeType}catch{c=null;break e}var N=0,k=-1,Q=-1,pe=0,we=0,Ie=n,ve=null;t:for(;;){for(var Me;Ie!==c||y!==0&&Ie.nodeType!==3||(k=N+y),Ie!==S||d!==0&&Ie.nodeType!==3||(Q=N+d),Ie.nodeType===3&&(N+=Ie.nodeValue.length),(Me=Ie.firstChild)!==null;)ve=Ie,Ie=Me;for(;;){if(Ie===n)break t;if(ve===c&&++pe===y&&(k=N),ve===S&&++we===d&&(Q=N),(Me=Ie.nextSibling)!==null)break;Ie=ve,ve=Ie.parentNode}Ie=Me}c=k===-1||Q===-1?null:{start:k,end:Q}}else c=null}c=c||{start:0,end:0}}else c=null;for(r_={focusedElem:n,selectionRange:c},s0=!1,Vi=a;Vi!==null;)if(a=Vi,n=a.child,(a.subtreeFlags&1028)!==0&&n!==null)n.return=a,Vi=n;else for(;Vi!==null;){switch(a=Vi,S=a.alternate,n=a.flags,a.tag){case 0:if((n&4)!==0&&(n=a.updateQueue,n=n!==null?n.events:null,n!==null))for(c=0;c title"))),ma(S,d,c),S[Qn]=n,V(S),d=S;break e;case"link":var N=vb("link","href",y).get(d+(c.href||""));if(N){for(var k=0;kkn&&(N=kn,kn=zt,zt=N);var re=Fl(k,zt),ee=Fl(k,kn);if(re&&ee&&(Me.rangeCount!==1||Me.anchorNode!==re.node||Me.anchorOffset!==re.offset||Me.focusNode!==ee.node||Me.focusOffset!==ee.offset)){var de=Ie.createRange();de.setStart(re.node,re.offset),Me.removeAllRanges(),zt>kn?(Me.addRange(de),Me.extend(ee.node,ee.offset)):(de.setEnd(ee.node,ee.offset),Me.addRange(de))}}}}for(Ie=[],Me=k;Me=Me.parentNode;)Me.nodeType===1&&Ie.push({element:Me,left:Me.scrollLeft,top:Me.scrollTop});for(typeof k.focus=="function"&&k.focus(),k=0;kc?32:c,q.T=null,c=lu,lu=null;var S=Za,N=xs;if(Dn=0,ru=Za=null,xs=0,(Et&6)!==0)throw Error(i(331));var k=Et;if(Et|=4,Ta(S.current),pp(S,S.current,N,c),Et=k,dt(0,!1),Xe&&typeof Xe.onPostCommitFiberRoot=="function")try{Xe.onPostCommitFiberRoot(Be,S)}catch{}return!0}finally{K.p=y,q.T=d,fr(n,a)}}function vp(n,a,c){a=ka(c,a),a=op(n.stateNode,a,2),n=fo(n,a,2),n!==null&&(Xi(n,2),ke(n))}function bn(n,a,c){if(n.tag===3)vp(n,n,c);else for(;a!==null;){if(a.tag===3){vp(a,n,c);break}else if(a.tag===1){var d=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(di===null||!di.has(d))){n=ka(c,n),c=lp(2),d=fo(a,c,2),d!==null&&(Xg(c,d,a,n),Xi(d,2),ke(d));break}}a=a.return}}function Ec(n,a,c){var d=n.pingCache;if(d===null){d=n.pingCache=new Wt;var y=new Set;d.set(a,y)}else y=d.get(a),y===void 0&&(y=new Set,d.set(a,y));y.has(c)||(mp=!0,y.add(c),n=r.bind(null,n,a,c),a.then(n,n))}function r(n,a,c){var d=n.pingCache;d!==null&&d.delete(a),n.pingedLanes|=n.suspendedLanes&c,n.warmLanes&=~c,Vt===n&&(jt&c)===c&&(ei===4||ei===3&&(jt&62914560)===jt&&300>O()-su?(Et&2)===0&&Eo(n,0):_c|=c,Xn===jt&&(Xn=0)),ke(n)}function l(n,a){a===0&&(a=dn()),n=la(n,a),n!==null&&(Xi(n,a),ke(n))}function p(n){var a=n.memoizedState,c=0;a!==null&&(c=a.retryLane),l(n,c)}function v(n,a){var c=0;switch(n.tag){case 31:case 13:var d=n.stateNode,y=n.memoizedState;y!==null&&(c=y.retryLane);break;case 19:d=n.stateNode;break;case 22:d=n.stateNode._retryCache;break;default:throw Error(i(314))}d!==null&&d.delete(a),l(n,c)}function T(n,a){return tt(n,a)}var w=null,F=null,J=!1,xe=!1,ze=!1,Qe=0;function ke(n){n!==F&&n.next===null&&(F===null?w=F=n:F=F.next=n),xe=!0,J||(J=!0,le())}function dt(n,a){if(!ze&&xe){ze=!0;do for(var c=!1,d=w;d!==null;){if(n!==0){var y=d.pendingLanes;if(y===0)var S=0;else{var N=d.suspendedLanes,k=d.pingedLanes;S=(1<<31-lt(42|n)+1)-1,S&=y&~(N&~k),S=S&201326741?S&201326741|1:S?S|2:0}S!==0&&(c=!0,ge(d,S))}else S=jt,S=Ne(d,d===Vt?S:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(S&3)===0||je(d,S)||(c=!0,ge(d,S));d=d.next}while(c);ze=!1}}function Gt(){pi()}function pi(){xe=J=!1;var n=0;Qe!==0&&JT()&&(n=Qe);for(var a=O(),c=null,d=w;d!==null;){var y=d.next,S=hu(d,a);S===0?(d.next=null,c===null?w=y:c.next=y,y===null&&(F=c)):(c=d,(n!==0||(S&3)!==0)&&(xe=!0)),d=y}Dn!==0&&Dn!==5||dt(n),Qe!==0&&(Qe=0)}function hu(n,a){for(var c=n.suspendedLanes,d=n.pingedLanes,y=n.expirationTimes,S=n.pendingLanes&-62914561;0k)break;var we=Q.transferSize,Ie=Q.initiatorType;we&&tb(Ie)&&(Q=Q.responseEnd,N+=we*(Q"u"?null:document;function db(n,a,c){var d=sh;if(d&&typeof a=="string"&&a){var y=Ot(a);y='link[rel="'+n+'"][href="'+y+'"]',typeof c=="string"&&(y+='[crossorigin="'+c+'"]'),hb.has(y)||(hb.add(y),n={rel:n,crossOrigin:c,href:a},d.querySelector(y)===null&&(a=d.createElement("link"),ma(a,"link",n),V(a),d.head.appendChild(a)))}}function rA(n){yl.D(n),db("dns-prefetch",n,null)}function oA(n,a){yl.C(n,a),db("preconnect",n,a)}function lA(n,a,c){yl.L(n,a,c);var d=sh;if(d&&n&&a){var y='link[rel="preload"][as="'+Ot(a)+'"]';a==="image"&&c&&c.imageSrcSet?(y+='[imagesrcset="'+Ot(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(y+='[imagesizes="'+Ot(c.imageSizes)+'"]')):y+='[href="'+Ot(n)+'"]';var S=y;switch(a){case"style":S=rh(n);break;case"script":S=oh(n)}dr.has(S)||(n=x({rel:"preload",href:a==="image"&&c&&c.imageSrcSet?void 0:n,as:a},c),dr.set(S,n),d.querySelector(y)!==null||a==="style"&&d.querySelector(xp(S))||a==="script"&&d.querySelector(Sp(S))||(a=d.createElement("link"),ma(a,"link",n),V(a),d.head.appendChild(a)))}}function uA(n,a){yl.m(n,a);var c=sh;if(c&&n){var d=a&&typeof a.as=="string"?a.as:"script",y='link[rel="modulepreload"][as="'+Ot(d)+'"][href="'+Ot(n)+'"]',S=y;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":S=oh(n)}if(!dr.has(S)&&(n=x({rel:"modulepreload",href:n},a),dr.set(S,n),c.querySelector(y)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(Sp(S)))return}d=c.createElement("link"),ma(d,"link",n),V(d),c.head.appendChild(d)}}}function cA(n,a,c){yl.S(n,a,c);var d=sh;if(d&&n){var y=Gs(d).hoistableStyles,S=rh(n);a=a||"default";var N=y.get(S);if(!N){var k={loading:0,preload:null};if(N=d.querySelector(xp(S)))k.loading=5;else{n=x({rel:"stylesheet",href:n,"data-precedence":a},c),(c=dr.get(S))&&d_(n,c);var Q=N=d.createElement("link");V(Q),ma(Q,"link",n),Q._p=new Promise(function(pe,we){Q.onload=pe,Q.onerror=we}),Q.addEventListener("load",function(){k.loading|=1}),Q.addEventListener("error",function(){k.loading|=2}),k.loading|=4,e0(N,a,d)}N={type:"stylesheet",instance:N,count:1,state:k},y.set(S,N)}}}function fA(n,a){yl.X(n,a);var c=sh;if(c&&n){var d=Gs(c).hoistableScripts,y=oh(n),S=d.get(y);S||(S=c.querySelector(Sp(y)),S||(n=x({src:n,async:!0},a),(a=dr.get(y))&&p_(n,a),S=c.createElement("script"),V(S),ma(S,"link",n),c.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},d.set(y,S))}}function hA(n,a){yl.M(n,a);var c=sh;if(c&&n){var d=Gs(c).hoistableScripts,y=oh(n),S=d.get(y);S||(S=c.querySelector(Sp(y)),S||(n=x({src:n,async:!0,type:"module"},a),(a=dr.get(y))&&p_(n,a),S=c.createElement("script"),V(S),ma(S,"link",n),c.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},d.set(y,S))}}function pb(n,a,c,d){var y=(y=fe.current)?$g(y):null;if(!y)throw Error(i(446));switch(n){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(a=rh(c.href),c=Gs(y).hoistableStyles,d=c.get(a),d||(d={type:"style",instance:null,count:0,state:null},c.set(a,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(c.rel==="stylesheet"&&typeof c.href=="string"&&typeof c.precedence=="string"){n=rh(c.href);var S=Gs(y).hoistableStyles,N=S.get(n);if(N||(y=y.ownerDocument||y,N={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},S.set(n,N),(S=y.querySelector(xp(n)))&&!S._p&&(N.instance=S,N.state.loading=5),dr.has(n)||(c={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},dr.set(n,c),S||dA(y,n,c,N.state))),a&&d===null)throw Error(i(528,""));return N}if(a&&d!==null)throw Error(i(529,""));return null;case"script":return a=c.async,c=c.src,typeof c=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=oh(c),c=Gs(y).hoistableScripts,d=c.get(a),d||(d={type:"script",instance:null,count:0,state:null},c.set(a,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,n))}}function rh(n){return'href="'+Ot(n)+'"'}function xp(n){return'link[rel="stylesheet"]['+n+"]"}function mb(n){return x({},n,{"data-precedence":n.precedence,precedence:null})}function dA(n,a,c,d){n.querySelector('link[rel="preload"][as="style"]['+a+"]")?d.loading=1:(a=n.createElement("link"),d.preload=a,a.addEventListener("load",function(){return d.loading|=1}),a.addEventListener("error",function(){return d.loading|=2}),ma(a,"link",c),V(a),n.head.appendChild(a))}function oh(n){return'[src="'+Ot(n)+'"]'}function Sp(n){return"script[async]"+n}function gb(n,a,c){if(a.count++,a.instance===null)switch(a.type){case"style":var d=n.querySelector('style[data-href~="'+Ot(c.href)+'"]');if(d)return a.instance=d,V(d),d;var y=x({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return d=(n.ownerDocument||n).createElement("style"),V(d),ma(d,"style",y),e0(d,c.precedence,n),a.instance=d;case"stylesheet":y=rh(c.href);var S=n.querySelector(xp(y));if(S)return a.state.loading|=4,a.instance=S,V(S),S;d=mb(c),(y=dr.get(y))&&d_(d,y),S=(n.ownerDocument||n).createElement("link"),V(S);var N=S;return N._p=new Promise(function(k,Q){N.onload=k,N.onerror=Q}),ma(S,"link",d),a.state.loading|=4,e0(S,c.precedence,n),a.instance=S;case"script":return S=oh(c.src),(y=n.querySelector(Sp(S)))?(a.instance=y,V(y),y):(d=c,(y=dr.get(S))&&(d=x({},c),p_(d,y)),n=n.ownerDocument||n,y=n.createElement("script"),V(y),ma(y,"link",d),n.head.appendChild(y),a.instance=y);case"void":return null;default:throw Error(i(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(d=a.instance,a.state.loading|=4,e0(d,c.precedence,n));return a.instance}function e0(n,a,c){for(var d=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),y=d.length?d[d.length-1]:null,S=y,N=0;N title"):null)}function pA(n,a,c){if(c===1||a.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(n=a.disabled,typeof a.precedence=="string"&&n==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function _b(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function mA(n,a,c,d){if(c.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(c.state.loading&4)===0){if(c.instance===null){var y=rh(d.href),S=a.querySelector(xp(y));if(S){a=S._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(n.count++,n=n0.bind(n),a.then(n,n)),c.state.loading|=4,c.instance=S,V(S);return}S=a.ownerDocument||a,d=mb(d),(y=dr.get(y))&&d_(d,y),S=S.createElement("link"),V(S);var N=S;N._p=new Promise(function(k,Q){N.onload=k,N.onerror=Q}),ma(S,"link",d),c.instance=S}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(c,a),(a=c.state.preload)&&(c.state.loading&3)===0&&(n.count++,c=n0.bind(n),a.addEventListener("load",c),a.addEventListener("error",c))}}var m_=0;function gA(n,a){return n.stylesheets&&n.count===0&&a0(n,n.stylesheets),0m_?50:800)+a);return n.unsuspend=c,function(){n.unsuspend=null,clearTimeout(d),clearTimeout(y)}}:null}function n0(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)a0(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var i0=null;function a0(n,a){n.stylesheets=null,n.unsuspend!==null&&(n.count++,i0=new Map,a.forEach(vA,n),i0=null,n0.call(n))}function vA(n,a){if(!(a.state.loading&4)){var c=i0.get(n);if(c)var d=c.get(null);else{c=new Map,i0.set(n,c);for(var y=n.querySelectorAll("link[data-precedence],style[data-precedence]"),S=0;S"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(o)}catch(e){console.error(e)}}return o(),E_.exports=UA(),E_.exports}var LO=LA();const ay="182",IA={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},OA={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},P1=0,Cx=1,B1=2,zA=3,F1=0,zh=1,Xp=2,kc=3,Cl=0,ts=1,No=2,Io=0,Wc=1,Rx=2,Dx=3,Nx=4,V1=5,wu=100,k1=101,H1=102,G1=103,X1=104,W1=200,q1=201,Y1=202,Z1=203,lv=204,uv=205,j1=206,Q1=207,J1=208,K1=209,$1=210,eE=211,tE=212,nE=213,iE=214,cv=0,fv=1,hv=2,Zc=3,dv=4,pv=5,mv=6,gv=7,_m=0,aE=1,sE=2,mr=0,eS=1,tS=2,nS=3,sy=4,iS=5,aS=6,sS=7,Ux="attached",rE="detached",ry=300,Oo=301,Uu=302,em=303,tm=304,jh=306,nm=1e3,As=1001,im=1002,Li=1003,rS=1004,PA=1004,Lh=1005,BA=1005,ai=1006,Wp=1007,FA=1007,Uo=1008,VA=1008,Ka=1009,oS=1010,lS=1011,Bh=1012,oy=1013,gr=1014,es=1015,zo=1016,ly=1017,uy=1018,Fh=1020,uS=35902,cS=35899,fS=1021,hS=1022,La=1023,Po=1026,Ru=1027,cy=1028,xm=1029,jc=1030,fy=1031,kA=1032,hy=1033,qp=33776,Yp=33777,Zp=33778,jp=33779,vv=35840,yv=35841,_v=35842,xv=35843,Sv=36196,bv=37492,Mv=37496,Ev=37488,Tv=37489,Av=37490,wv=37491,Cv=37808,Rv=37809,Dv=37810,Nv=37811,Uv=37812,Lv=37813,Iv=37814,Ov=37815,zv=37816,Pv=37817,Bv=37818,Fv=37819,Vv=37820,kv=37821,Hv=36492,Gv=36494,Xv=36495,Wv=36283,qv=36284,Yv=36285,Zv=36286,oE=2200,lE=2201,uE=2202,am=2300,jv=2301,av=2302,Hc=2400,Gc=2401,sm=2402,dy=2500,dS=2501,HA=0,GA=1,XA=2,cE=3200,WA=3201,qA=3202,YA=3203,zu=0,fE=1,Tl="",Ua="srgb",Lu="srgb-linear",rm="linear",On="srgb",ZA="",jA="rg",QA="ga",JA=0,Fc=7680,KA=7681,$A=7682,ew=7683,tw=34055,nw=34056,iw=5386,aw=512,sw=513,rw=514,ow=515,lw=516,uw=517,cw=518,Lx=519,hE=512,dE=513,pE=514,py=515,mE=516,gE=517,my=518,vE=519,om=35044,fw=35048,hw=35040,dw=35045,pw=35049,mw=35041,gw=35046,vw=35050,yw=35042,_w="100",Ix="300 es",Fs=2e3,Vh=2001,xw={COMPUTE:"compute",RENDER:"render"},Sw={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},bw={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function yE(o){for(let e=o.length-1;e>=0;--e)if(o[e]>=65535)return!0;return!1}const Mw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ih(o,e){return new Mw[o](e)}function _E(o){return ArrayBuffer.isView(o)&&!(o instanceof DataView)}function lm(o){return document.createElementNS("http://www.w3.org/1999/xhtml",o)}function xE(){const o=lm("canvas");return o.style.display="block",o}const Gb={};let Iu=null;function Ew(o){Iu=o}function Tw(){return Iu}function um(...o){const e="THREE."+o.shift();Iu?Iu("log",e,...o):console.log(e,...o)}function rt(...o){const e="THREE."+o.shift();Iu?Iu("warn",e,...o):console.warn(e,...o)}function Tt(...o){const e="THREE."+o.shift();Iu?Iu("error",e,...o):console.error(e,...o)}function kh(...o){const e=o.join(" ");e in Gb||(Gb[e]=!0,rt(...o))}function Aw(o,e,t){return new Promise(function(i,s){function u(){switch(o.clientWaitSync(e,o.SYNC_FLUSH_COMMANDS_BIT,0)){case o.WAIT_FAILED:s();break;case o.TIMEOUT_EXPIRED:setTimeout(u,t);break;default:i()}}setTimeout(u,t)})}class Bo{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const u=s.indexOf(t);u!==-1&&s.splice(u,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let u=0,f=s.length;u>8&255]+Ra[o>>16&255]+Ra[o>>24&255]+"-"+Ra[e&255]+Ra[e>>8&255]+"-"+Ra[e>>16&15|64]+Ra[e>>24&255]+"-"+Ra[t&63|128]+Ra[t>>8&255]+"-"+Ra[t>>16&255]+Ra[t>>24&255]+Ra[i&255]+Ra[i>>8&255]+Ra[i>>16&255]+Ra[i>>24&255]).toLowerCase()}function Ft(o,e,t){return Math.max(e,Math.min(t,o))}function pS(o,e){return(o%e+e)%e}function ww(o,e,t,i,s){return i+(o-e)*(s-i)/(t-e)}function Cw(o,e,t){return o!==e?(t-o)/(e-o):0}function Qp(o,e,t){return(1-t)*o+t*e}function Rw(o,e,t,i){return Qp(o,e,1-Math.exp(-t*i))}function Dw(o,e=1){return e-Math.abs(pS(o,e*2)-e)}function Nw(o,e,t){return o<=e?0:o>=t?1:(o=(o-e)/(t-e),o*o*(3-2*o))}function Uw(o,e,t){return o<=e?0:o>=t?1:(o=(o-e)/(t-e),o*o*o*(o*(o*6-15)+10))}function Lw(o,e){return o+Math.floor(Math.random()*(e-o+1))}function Iw(o,e){return o+Math.random()*(e-o)}function Ow(o){return o*(.5-Math.random())}function zw(o){o!==void 0&&(Xb=o);let e=Xb+=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 Pw(o){return o*qc}function Bw(o){return o*Hh}function Fw(o){return(o&o-1)===0&&o!==0}function Vw(o){return Math.pow(2,Math.ceil(Math.log(o)/Math.LN2))}function kw(o){return Math.pow(2,Math.floor(Math.log(o)/Math.LN2))}function Hw(o,e,t,i,s){const u=Math.cos,f=Math.sin,h=u(t/2),m=f(t/2),g=u((e+i)/2),_=f((e+i)/2),x=u((e-i)/2),b=f((e-i)/2),M=u((i-e)/2),A=f((i-e)/2);switch(s){case"XYX":o.set(h*_,m*x,m*b,h*g);break;case"YZY":o.set(m*b,h*_,m*x,h*g);break;case"ZXZ":o.set(m*x,m*b,h*_,h*g);break;case"XZX":o.set(h*_,m*A,m*M,h*g);break;case"YXY":o.set(m*M,h*_,m*A,h*g);break;case"ZYZ":o.set(m*A,m*M,h*_,h*g);break;default:rt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function $a(o,e){switch(e.constructor){case Float32Array:return o;case Uint32Array:return o/4294967295;case Uint16Array:return o/65535;case Uint8Array:return o/255;case Int32Array:return Math.max(o/2147483647,-1);case Int16Array:return Math.max(o/32767,-1);case Int8Array:return Math.max(o/127,-1);default:throw new Error("Invalid component type.")}}function tn(o,e){switch(e.constructor){case Float32Array:return o;case Uint32Array:return Math.round(o*4294967295);case Uint16Array:return Math.round(o*65535);case Uint8Array:return Math.round(o*255);case Int32Array:return Math.round(o*2147483647);case Int16Array:return Math.round(o*32767);case Int8Array:return Math.round(o*127);default:throw new Error("Invalid component type.")}}const SE={DEG2RAD:qc,RAD2DEG:Hh,generateUUID:Vs,clamp:Ft,euclideanModulo:pS,mapLinear:ww,inverseLerp:Cw,lerp:Qp,damp:Rw,pingpong:Dw,smoothstep:Nw,smootherstep:Uw,randInt:Lw,randFloat:Iw,randFloatSpread:Ow,seededRandom:zw,degToRad:Pw,radToDeg:Bw,isPowerOfTwo:Fw,ceilPowerOfTwo:Vw,floorPowerOfTwo:kw,setQuaternionFromProperEuler:Hw,normalize:tn,denormalize:$a};class Pe{constructor(e=0,t=0){Pe.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,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[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=Ft(this.x,e.x,t.x),this.y=Ft(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ft(this.x,e,t),this.y=Ft(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ft(i,e,t))}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 i=this.dot(e)/t;return Math.acos(Ft(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,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 i=Math.cos(t),s=Math.sin(t),u=this.x-e.x,f=this.y-e.y;return this.x=u*i-f*s+e.x,this.y=u*s+f*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ws{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,u,f,h){let m=i[s+0],g=i[s+1],_=i[s+2],x=i[s+3],b=u[f+0],M=u[f+1],A=u[f+2],R=u[f+3];if(h<=0){e[t+0]=m,e[t+1]=g,e[t+2]=_,e[t+3]=x;return}if(h>=1){e[t+0]=b,e[t+1]=M,e[t+2]=A,e[t+3]=R;return}if(x!==R||m!==b||g!==M||_!==A){let C=m*b+g*M+_*A+x*R;C<0&&(b=-b,M=-M,A=-A,R=-R,C=-C);let E=1-h;if(C<.9995){const D=Math.acos(C),U=Math.sin(D);E=Math.sin(E*D)/U,h=Math.sin(h*D)/U,m=m*E+b*h,g=g*E+M*h,_=_*E+A*h,x=x*E+R*h}else{m=m*E+b*h,g=g*E+M*h,_=_*E+A*h,x=x*E+R*h;const D=1/Math.sqrt(m*m+g*g+_*_+x*x);m*=D,g*=D,_*=D,x*=D}}e[t]=m,e[t+1]=g,e[t+2]=_,e[t+3]=x}static multiplyQuaternionsFlat(e,t,i,s,u,f){const h=i[s],m=i[s+1],g=i[s+2],_=i[s+3],x=u[f],b=u[f+1],M=u[f+2],A=u[f+3];return e[t]=h*A+_*x+m*M-g*b,e[t+1]=m*A+_*b+g*x-h*M,e[t+2]=g*A+_*M+h*b-m*x,e[t+3]=_*A-h*x-m*b-g*M,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,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,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=!0){const i=e._x,s=e._y,u=e._z,f=e._order,h=Math.cos,m=Math.sin,g=h(i/2),_=h(s/2),x=h(u/2),b=m(i/2),M=m(s/2),A=m(u/2);switch(f){case"XYZ":this._x=b*_*x+g*M*A,this._y=g*M*x-b*_*A,this._z=g*_*A+b*M*x,this._w=g*_*x-b*M*A;break;case"YXZ":this._x=b*_*x+g*M*A,this._y=g*M*x-b*_*A,this._z=g*_*A-b*M*x,this._w=g*_*x+b*M*A;break;case"ZXY":this._x=b*_*x-g*M*A,this._y=g*M*x+b*_*A,this._z=g*_*A+b*M*x,this._w=g*_*x-b*M*A;break;case"ZYX":this._x=b*_*x-g*M*A,this._y=g*M*x+b*_*A,this._z=g*_*A-b*M*x,this._w=g*_*x+b*M*A;break;case"YZX":this._x=b*_*x+g*M*A,this._y=g*M*x+b*_*A,this._z=g*_*A-b*M*x,this._w=g*_*x-b*M*A;break;case"XZY":this._x=b*_*x-g*M*A,this._y=g*M*x-b*_*A,this._z=g*_*A+b*M*x,this._w=g*_*x+b*M*A;break;default:rt("Quaternion: .setFromEuler() encountered an unknown order: "+f)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],u=t[8],f=t[1],h=t[5],m=t[9],g=t[2],_=t[6],x=t[10],b=i+h+x;if(b>0){const M=.5/Math.sqrt(b+1);this._w=.25/M,this._x=(_-m)*M,this._y=(u-g)*M,this._z=(f-s)*M}else if(i>h&&i>x){const M=2*Math.sqrt(1+i-h-x);this._w=(_-m)/M,this._x=.25*M,this._y=(s+f)/M,this._z=(u+g)/M}else if(h>x){const M=2*Math.sqrt(1+h-i-x);this._w=(u-g)/M,this._x=(s+f)/M,this._y=.25*M,this._z=(m+_)/M}else{const M=2*Math.sqrt(1+x-i-h);this._w=(f-s)/M,this._x=(u+g)/M,this._y=(m+_)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ft(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),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 i=e._x,s=e._y,u=e._z,f=e._w,h=t._x,m=t._y,g=t._z,_=t._w;return this._x=i*_+f*h+s*g-u*m,this._y=s*_+f*m+u*h-i*g,this._z=u*_+f*g+i*m-s*h,this._w=f*_-i*h-s*m-u*g,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let i=e._x,s=e._y,u=e._z,f=e._w,h=this.dot(e);h<0&&(i=-i,s=-s,u=-u,f=-f,h=-h);let m=1-t;if(h<.9995){const g=Math.acos(h),_=Math.sin(g);m=Math.sin(m*g)/_,t=Math.sin(t*g)/_,this._x=this._x*m+i*t,this._y=this._y*m+s*t,this._z=this._z*m+u*t,this._w=this._w*m+f*t,this._onChangeCallback()}else this._x=this._x*m+i*t,this._y=this._y*m+s*t,this._z=this._z*m+u*t,this._w=this._w*m+f*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),u=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),u*Math.sin(t),u*Math.cos(t))}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._onChangeCallback(),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 Y{constructor(e=0,t=0,i=0){Y.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,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(Wb.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wb.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,u=e.elements;return this.x=u[0]*t+u[3]*i+u[6]*s,this.y=u[1]*t+u[4]*i+u[7]*s,this.z=u[2]*t+u[5]*i+u[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,u=e.elements,f=1/(u[3]*t+u[7]*i+u[11]*s+u[15]);return this.x=(u[0]*t+u[4]*i+u[8]*s+u[12])*f,this.y=(u[1]*t+u[5]*i+u[9]*s+u[13])*f,this.z=(u[2]*t+u[6]*i+u[10]*s+u[14])*f,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,u=e.x,f=e.y,h=e.z,m=e.w,g=2*(f*s-h*i),_=2*(h*t-u*s),x=2*(u*i-f*t);return this.x=t+m*g+f*x-h*_,this.y=i+m*_+h*g-u*x,this.z=s+m*x+u*_-f*g,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,i=this.y,s=this.z,u=e.elements;return this.x=u[0]*t+u[4]*i+u[8]*s,this.y=u[1]*t+u[5]*i+u[9]*s,this.z=u[2]*t+u[6]*i+u[10]*s,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=Ft(this.x,e.x,t.x),this.y=Ft(this.y,e.y,t.y),this.z=Ft(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ft(this.x,e,t),this.y=Ft(this.y,e,t),this.z=Ft(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ft(i,e,t))}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,u=e.z,f=t.x,h=t.y,m=t.z;return this.x=s*m-u*h,this.y=u*f-i*m,this.z=i*h-s*f,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return C_.copy(this).projectOnVector(e),this.sub(C_)}reflect(e){return this.sub(C_.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 i=this.dot(e)/t;return Math.acos(Ft(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}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,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,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()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const C_=new Y,Wb=new ws;class Qt{constructor(e,t,i,s,u,f,h,m,g){Qt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,u,f,h,m,g)}set(e,t,i,s,u,f,h,m,g){const _=this.elements;return _[0]=e,_[1]=s,_[2]=h,_[3]=t,_[4]=u,_[5]=m,_[6]=i,_[7]=f,_[8]=g,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,s=t.elements,u=this.elements,f=i[0],h=i[3],m=i[6],g=i[1],_=i[4],x=i[7],b=i[2],M=i[5],A=i[8],R=s[0],C=s[3],E=s[6],D=s[1],U=s[4],L=s[7],B=s[2],P=s[5],H=s[8];return u[0]=f*R+h*D+m*B,u[3]=f*C+h*U+m*P,u[6]=f*E+h*L+m*H,u[1]=g*R+_*D+x*B,u[4]=g*C+_*U+x*P,u[7]=g*E+_*L+x*H,u[2]=b*R+M*D+A*B,u[5]=b*C+M*U+A*P,u[8]=b*E+M*L+A*H,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],i=e[1],s=e[2],u=e[3],f=e[4],h=e[5],m=e[6],g=e[7],_=e[8];return t*f*_-t*h*g-i*u*_+i*h*m+s*u*g-s*f*m}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],u=e[3],f=e[4],h=e[5],m=e[6],g=e[7],_=e[8],x=_*f-h*g,b=h*m-_*u,M=g*u-f*m,A=t*x+i*b+s*M;if(A===0)return this.set(0,0,0,0,0,0,0,0,0);const R=1/A;return e[0]=x*R,e[1]=(s*g-_*i)*R,e[2]=(h*i-s*f)*R,e[3]=b*R,e[4]=(_*t-s*m)*R,e[5]=(s*u-h*t)*R,e[6]=M*R,e[7]=(i*m-g*t)*R,e[8]=(f*t-i*u)*R,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,i,s,u,f,h){const m=Math.cos(u),g=Math.sin(u);return this.set(i*m,i*g,-i*(m*f+g*h)+f+e,-s*g,s*m,-s*(-g*f+m*h)+h+t,0,0,1),this}scale(e,t){return this.premultiply(R_.makeScale(e,t)),this}rotate(e){return this.premultiply(R_.makeRotation(-e)),this}translate(e,t){return this.premultiply(R_.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),i=Math.sin(e);return this.set(t,-i,0,i,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,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const R_=new Qt,qb=new Qt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Yb=new Qt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Gw(){const o={enabled:!0,workingColorSpace:Lu,spaces:{},convert:function(s,u,f){return this.enabled===!1||u===f||!u||!f||(this.spaces[u].transfer===On&&(s.r=wl(s.r),s.g=wl(s.g),s.b=wl(s.b)),this.spaces[u].primaries!==this.spaces[f].primaries&&(s.applyMatrix3(this.spaces[u].toXYZ),s.applyMatrix3(this.spaces[f].fromXYZ)),this.spaces[f].transfer===On&&(s.r=Ph(s.r),s.g=Ph(s.g),s.b=Ph(s.b))),s},workingToColorSpace:function(s,u){return this.convert(s,this.workingColorSpace,u)},colorSpaceToWorking:function(s,u){return this.convert(s,u,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Tl?rm:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,u=this.workingColorSpace){return s.fromArray(this.spaces[u].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,u,f){return s.copy(this.spaces[u].toXYZ).multiply(this.spaces[f].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,u){return kh("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),o.workingToColorSpace(s,u)},toWorkingColorSpace:function(s,u){return kh("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),o.colorSpaceToWorking(s,u)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return o.define({[Lu]:{primaries:e,whitePoint:i,transfer:rm,toXYZ:qb,fromXYZ:Yb,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ua},outputColorSpaceConfig:{drawingBufferColorSpace:Ua}},[Ua]:{primaries:e,whitePoint:i,transfer:On,toXYZ:qb,fromXYZ:Yb,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ua}}}),o}const xn=Gw();function wl(o){return o<.04045?o*.0773993808:Math.pow(o*.9478672986+.0521327014,2.4)}function Ph(o){return o<.0031308?o*12.92:1.055*Math.pow(o,.41666)-.055}let uh;class bE{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{uh===void 0&&(uh=lm("canvas")),uh.width=e.width,uh.height=e.height;const s=uh.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=uh}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=lm("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),u=s.data;for(let f=0;f1),this.pmremVersion=0}get width(){return this.source.getSize(N_).x}get height(){return this.source.getSize(N_).y}get depth(){return this.source.getSize(N_).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){rt(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){rt(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ry)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case nm:e.x=e.x-Math.floor(e.x);break;case As:e.x=e.x<0?0:1;break;case im: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 nm:e.y=e.y-Math.floor(e.y);break;case As:e.y=e.y<0?0:1;break;case im: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)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Ei.DEFAULT_IMAGE=null;Ei.DEFAULT_MAPPING=ry;Ei.DEFAULT_ANISOTROPY=1;class Wn{constructor(e=0,t=0,i=0,s=1){Wn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=s}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,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,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,i=this.y,s=this.z,u=this.w,f=e.elements;return this.x=f[0]*t+f[4]*i+f[8]*s+f[12]*u,this.y=f[1]*t+f[5]*i+f[9]*s+f[13]*u,this.z=f[2]*t+f[6]*i+f[10]*s+f[14]*u,this.w=f[3]*t+f[7]*i+f[11]*s+f[15]*u,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,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,i,s,u;const m=e.elements,g=m[0],_=m[4],x=m[8],b=m[1],M=m[5],A=m[9],R=m[2],C=m[6],E=m[10];if(Math.abs(_-b)<.01&&Math.abs(x-R)<.01&&Math.abs(A-C)<.01){if(Math.abs(_+b)<.1&&Math.abs(x+R)<.1&&Math.abs(A+C)<.1&&Math.abs(g+M+E-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const U=(g+1)/2,L=(M+1)/2,B=(E+1)/2,P=(_+b)/4,H=(x+R)/4,W=(A+C)/4;return U>L&&U>B?U<.01?(i=0,s=.707106781,u=.707106781):(i=Math.sqrt(U),s=P/i,u=H/i):L>B?L<.01?(i=.707106781,s=0,u=.707106781):(s=Math.sqrt(L),i=P/s,u=W/s):B<.01?(i=.707106781,s=.707106781,u=0):(u=Math.sqrt(B),i=H/u,s=W/u),this.set(i,s,u,t),this}let D=Math.sqrt((C-A)*(C-A)+(x-R)*(x-R)+(b-_)*(b-_));return Math.abs(D)<.001&&(D=1),this.x=(C-A)/D,this.y=(x-R)/D,this.z=(b-_)/D,this.w=Math.acos((g+M+E-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],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=Ft(this.x,e.x,t.x),this.y=Ft(this.y,e.y,t.y),this.z=Ft(this.z,e.z,t.z),this.w=Ft(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ft(this.x,e,t),this.y=Ft(this.y,e,t),this.z=Ft(this.z,e,t),this.w=Ft(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Ft(i,e,t))}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,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 mS extends Bo{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ai,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Wn(0,0,e,t),this.scissorTest=!1,this.viewport=new Wn(0,0,e,t);const s={width:e,height:t,depth:i.depth},u=new Ei(s);this.textures=[];const f=i.count;for(let h=0;h1);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.textures.length=0;for(let t=0,i=e.textures.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,kr),kr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Cp),d0.subVectors(this.max,Cp),ch.subVectors(e.a,Cp),fh.subVectors(e.b,Cp),hh.subVectors(e.c,Cp),_u.subVectors(fh,ch),xu.subVectors(hh,fh),Tc.subVectors(ch,hh);let t=[0,-_u.z,_u.y,0,-xu.z,xu.y,0,-Tc.z,Tc.y,_u.z,0,-_u.x,xu.z,0,-xu.x,Tc.z,0,-Tc.x,-_u.y,_u.x,0,-xu.y,xu.x,0,-Tc.y,Tc.x,0];return!U_(t,ch,fh,hh,d0)||(t=[1,0,0,0,1,0,0,0,1],!U_(t,ch,fh,hh,d0))?!1:(p0.crossVectors(_u,xu),t=[p0.x,p0.y,p0.z],U_(t,ch,fh,hh,d0))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(kr).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:(_l[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_l[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_l[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_l[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_l[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_l[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_l[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_l[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_l),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const _l=[new Y,new Y,new Y,new Y,new Y,new Y,new Y,new Y],kr=new Y,h0=new Ia,ch=new Y,fh=new Y,hh=new Y,_u=new Y,xu=new Y,Tc=new Y,Cp=new Y,d0=new Y,p0=new Y,Ac=new Y;function U_(o,e,t,i,s){for(let u=0,f=o.length-3;u<=f;u+=3){Ac.fromArray(o,u);const h=s.x*Math.abs(Ac.x)+s.y*Math.abs(Ac.y)+s.z*Math.abs(Ac.z),m=e.dot(Ac),g=t.dot(Ac),_=i.dot(Ac);if(Math.max(-Math.max(m,g,_),Math.min(m,g,_))>h)return!1}return!0}const Zw=new Ia,Rp=new Y,L_=new Y;class ga{constructor(e=new Y,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;t!==void 0?i.copy(t):Zw.setFromPoints(e).getCenter(i);let s=0;for(let u=0,f=e.length;uthis.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;Rp.subVectors(e,this.center);const t=Rp.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(Rp,s/i),this.radius+=s}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):(L_.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Rp.copy(e.center).add(L_)),this.expandByPoint(Rp.copy(e.center).sub(L_))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const xl=new Y,I_=new Y,m0=new Y,Su=new Y,O_=new Y,g0=new Y,z_=new Y;class Qh{constructor(e=new Y,t=new Y(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,xl)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=xl.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(xl.copy(this.origin).addScaledVector(this.direction,t),xl.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){I_.copy(e).add(t).multiplyScalar(.5),m0.copy(t).sub(e).normalize(),Su.copy(this.origin).sub(I_);const u=e.distanceTo(t)*.5,f=-this.direction.dot(m0),h=Su.dot(this.direction),m=-Su.dot(m0),g=Su.lengthSq(),_=Math.abs(1-f*f);let x,b,M,A;if(_>0)if(x=f*m-h,b=f*h-m,A=u*_,x>=0)if(b>=-A)if(b<=A){const R=1/_;x*=R,b*=R,M=x*(x+f*b+2*h)+b*(f*x+b+2*m)+g}else b=u,x=Math.max(0,-(f*b+h)),M=-x*x+b*(b+2*m)+g;else b=-u,x=Math.max(0,-(f*b+h)),M=-x*x+b*(b+2*m)+g;else b<=-A?(x=Math.max(0,-(-f*u+h)),b=x>0?-u:Math.min(Math.max(-u,-m),u),M=-x*x+b*(b+2*m)+g):b<=A?(x=0,b=Math.min(Math.max(-u,-m),u),M=b*(b+2*m)+g):(x=Math.max(0,-(f*u+h)),b=x>0?u:Math.min(Math.max(-u,-m),u),M=-x*x+b*(b+2*m)+g);else b=f>0?-u:u,x=Math.max(0,-(f*b+h)),M=-x*x+b*(b+2*m)+g;return i&&i.copy(this.origin).addScaledVector(this.direction,x),s&&s.copy(I_).addScaledVector(m0,b),M}intersectSphere(e,t){xl.subVectors(e.center,this.origin);const i=xl.dot(this.direction),s=xl.dot(xl)-i*i,u=e.radius*e.radius;if(s>u)return null;const f=Math.sqrt(u-s),h=i-f,m=i+f;return m<0?null:h<0?this.at(m,t):this.at(h,t)}intersectsSphere(e){return e.radius<0?!1: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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,u,f,h,m;const g=1/this.direction.x,_=1/this.direction.y,x=1/this.direction.z,b=this.origin;return g>=0?(i=(e.min.x-b.x)*g,s=(e.max.x-b.x)*g):(i=(e.max.x-b.x)*g,s=(e.min.x-b.x)*g),_>=0?(u=(e.min.y-b.y)*_,f=(e.max.y-b.y)*_):(u=(e.max.y-b.y)*_,f=(e.min.y-b.y)*_),i>f||u>s||((u>i||isNaN(i))&&(i=u),(f=0?(h=(e.min.z-b.z)*x,m=(e.max.z-b.z)*x):(h=(e.max.z-b.z)*x,m=(e.min.z-b.z)*x),i>m||h>s)||((h>i||i!==i)&&(i=h),(m=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,xl)!==null}intersectTriangle(e,t,i,s,u){O_.subVectors(t,e),g0.subVectors(i,e),z_.crossVectors(O_,g0);let f=this.direction.dot(z_),h;if(f>0){if(s)return null;h=1}else if(f<0)h=-1,f=-f;else return null;Su.subVectors(this.origin,e);const m=h*this.direction.dot(g0.crossVectors(Su,g0));if(m<0)return null;const g=h*this.direction.dot(O_.cross(Su));if(g<0||m+g>f)return null;const _=-h*Su.dot(z_);return _<0?null:this.at(_/f,u)}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 kt{constructor(e,t,i,s,u,f,h,m,g,_,x,b,M,A,R,C){kt.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,i,s,u,f,h,m,g,_,x,b,M,A,R,C)}set(e,t,i,s,u,f,h,m,g,_,x,b,M,A,R,C){const E=this.elements;return E[0]=e,E[4]=t,E[8]=i,E[12]=s,E[1]=u,E[5]=f,E[9]=h,E[13]=m,E[2]=g,E[6]=_,E[10]=x,E[14]=b,E[3]=M,E[7]=A,E[11]=R,E[15]=C,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 kt().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,s=1/dh.setFromMatrixColumn(e,0).length(),u=1/dh.setFromMatrixColumn(e,1).length(),f=1/dh.setFromMatrixColumn(e,2).length();return t[0]=i[0]*s,t[1]=i[1]*s,t[2]=i[2]*s,t[3]=0,t[4]=i[4]*u,t[5]=i[5]*u,t[6]=i[6]*u,t[7]=0,t[8]=i[8]*f,t[9]=i[9]*f,t[10]=i[10]*f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,s=e.y,u=e.z,f=Math.cos(i),h=Math.sin(i),m=Math.cos(s),g=Math.sin(s),_=Math.cos(u),x=Math.sin(u);if(e.order==="XYZ"){const b=f*_,M=f*x,A=h*_,R=h*x;t[0]=m*_,t[4]=-m*x,t[8]=g,t[1]=M+A*g,t[5]=b-R*g,t[9]=-h*m,t[2]=R-b*g,t[6]=A+M*g,t[10]=f*m}else if(e.order==="YXZ"){const b=m*_,M=m*x,A=g*_,R=g*x;t[0]=b+R*h,t[4]=A*h-M,t[8]=f*g,t[1]=f*x,t[5]=f*_,t[9]=-h,t[2]=M*h-A,t[6]=R+b*h,t[10]=f*m}else if(e.order==="ZXY"){const b=m*_,M=m*x,A=g*_,R=g*x;t[0]=b-R*h,t[4]=-f*x,t[8]=A+M*h,t[1]=M+A*h,t[5]=f*_,t[9]=R-b*h,t[2]=-f*g,t[6]=h,t[10]=f*m}else if(e.order==="ZYX"){const b=f*_,M=f*x,A=h*_,R=h*x;t[0]=m*_,t[4]=A*g-M,t[8]=b*g+R,t[1]=m*x,t[5]=R*g+b,t[9]=M*g-A,t[2]=-g,t[6]=h*m,t[10]=f*m}else if(e.order==="YZX"){const b=f*m,M=f*g,A=h*m,R=h*g;t[0]=m*_,t[4]=R-b*x,t[8]=A*x+M,t[1]=x,t[5]=f*_,t[9]=-h*_,t[2]=-g*_,t[6]=M*x+A,t[10]=b-R*x}else if(e.order==="XZY"){const b=f*m,M=f*g,A=h*m,R=h*g;t[0]=m*_,t[4]=-x,t[8]=g*_,t[1]=b*x+R,t[5]=f*_,t[9]=M*x-A,t[2]=A*x-M,t[6]=h*_,t[10]=R*x+b}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(jw,e,Qw)}lookAt(e,t,i){const s=this.elements;return zs.subVectors(e,t),zs.lengthSq()===0&&(zs.z=1),zs.normalize(),bu.crossVectors(i,zs),bu.lengthSq()===0&&(Math.abs(i.z)===1?zs.x+=1e-4:zs.z+=1e-4,zs.normalize(),bu.crossVectors(i,zs)),bu.normalize(),v0.crossVectors(zs,bu),s[0]=bu.x,s[4]=v0.x,s[8]=zs.x,s[1]=bu.y,s[5]=v0.y,s[9]=zs.y,s[2]=bu.z,s[6]=v0.z,s[10]=zs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,u=this.elements,f=i[0],h=i[4],m=i[8],g=i[12],_=i[1],x=i[5],b=i[9],M=i[13],A=i[2],R=i[6],C=i[10],E=i[14],D=i[3],U=i[7],L=i[11],B=i[15],P=s[0],H=s[4],W=s[8],I=s[12],z=s[1],j=s[5],ae=s[9],$=s[13],ue=s[2],he=s[6],q=s[10],K=s[14],ce=s[3],Ae=s[7],Ce=s[11],X=s[15];return u[0]=f*P+h*z+m*ue+g*ce,u[4]=f*H+h*j+m*he+g*Ae,u[8]=f*W+h*ae+m*q+g*Ce,u[12]=f*I+h*$+m*K+g*X,u[1]=_*P+x*z+b*ue+M*ce,u[5]=_*H+x*j+b*he+M*Ae,u[9]=_*W+x*ae+b*q+M*Ce,u[13]=_*I+x*$+b*K+M*X,u[2]=A*P+R*z+C*ue+E*ce,u[6]=A*H+R*j+C*he+E*Ae,u[10]=A*W+R*ae+C*q+E*Ce,u[14]=A*I+R*$+C*K+E*X,u[3]=D*P+U*z+L*ue+B*ce,u[7]=D*H+U*j+L*he+B*Ae,u[11]=D*W+U*ae+L*q+B*Ce,u[15]=D*I+U*$+L*K+B*X,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],i=e[4],s=e[8],u=e[12],f=e[1],h=e[5],m=e[9],g=e[13],_=e[2],x=e[6],b=e[10],M=e[14],A=e[3],R=e[7],C=e[11],E=e[15],D=m*M-g*b,U=h*M-g*x,L=h*b-m*x,B=f*M-g*_,P=f*b-m*_,H=f*x-h*_;return t*(R*D-C*U+E*L)-i*(A*D-C*B+E*P)+s*(A*U-R*B+E*H)-u*(A*L-R*P+C*H)}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,i){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],u=e[3],f=e[4],h=e[5],m=e[6],g=e[7],_=e[8],x=e[9],b=e[10],M=e[11],A=e[12],R=e[13],C=e[14],E=e[15],D=x*C*g-R*b*g+R*m*M-h*C*M-x*m*E+h*b*E,U=A*b*g-_*C*g-A*m*M+f*C*M+_*m*E-f*b*E,L=_*R*g-A*x*g+A*h*M-f*R*M-_*h*E+f*x*E,B=A*x*m-_*R*m-A*h*b+f*R*b+_*h*C-f*x*C,P=t*D+i*U+s*L+u*B;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const H=1/P;return e[0]=D*H,e[1]=(R*b*u-x*C*u-R*s*M+i*C*M+x*s*E-i*b*E)*H,e[2]=(h*C*u-R*m*u+R*s*g-i*C*g-h*s*E+i*m*E)*H,e[3]=(x*m*u-h*b*u-x*s*g+i*b*g+h*s*M-i*m*M)*H,e[4]=U*H,e[5]=(_*C*u-A*b*u+A*s*M-t*C*M-_*s*E+t*b*E)*H,e[6]=(A*m*u-f*C*u-A*s*g+t*C*g+f*s*E-t*m*E)*H,e[7]=(f*b*u-_*m*u+_*s*g-t*b*g-f*s*M+t*m*M)*H,e[8]=L*H,e[9]=(A*x*u-_*R*u-A*i*M+t*R*M+_*i*E-t*x*E)*H,e[10]=(f*R*u-A*h*u+A*i*g-t*R*g-f*i*E+t*h*E)*H,e[11]=(_*h*u-f*x*u-_*i*g+t*x*g+f*i*M-t*h*M)*H,e[12]=B*H,e[13]=(_*R*s-A*x*s+A*i*b-t*R*b-_*i*C+t*x*C)*H,e[14]=(A*h*s-f*R*s-A*i*m+t*R*m+f*i*C-t*h*C)*H,e[15]=(f*x*s-_*h*s+_*i*m-t*x*m-f*i*b+t*h*b)*H,this}scale(e){const t=this.elements,i=e.x,s=e.y,u=e.z;return t[0]*=i,t[4]*=s,t[8]*=u,t[1]*=i,t[5]*=s,t[9]*=u,t[2]*=i,t[6]*=s,t[10]*=u,t[3]*=i,t[7]*=s,t[11]*=u,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,s))}makeTranslation(e,t,i){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,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),s=Math.sin(t),u=1-i,f=e.x,h=e.y,m=e.z,g=u*f,_=u*h;return this.set(g*f+i,g*h-s*m,g*m+s*h,0,g*h+s*m,_*h+i,_*m-s*f,0,g*m-s*h,_*m+s*f,u*m*m+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,s,u,f){return this.set(1,i,u,0,e,1,f,0,t,s,1,0,0,0,0,1),this}compose(e,t,i){const s=this.elements,u=t._x,f=t._y,h=t._z,m=t._w,g=u+u,_=f+f,x=h+h,b=u*g,M=u*_,A=u*x,R=f*_,C=f*x,E=h*x,D=m*g,U=m*_,L=m*x,B=i.x,P=i.y,H=i.z;return s[0]=(1-(R+E))*B,s[1]=(M+L)*B,s[2]=(A-U)*B,s[3]=0,s[4]=(M-L)*P,s[5]=(1-(b+E))*P,s[6]=(C+D)*P,s[7]=0,s[8]=(A+U)*H,s[9]=(C-D)*H,s[10]=(1-(b+R))*H,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,i){const s=this.elements;if(e.x=s[12],e.y=s[13],e.z=s[14],this.determinant()===0)return i.set(1,1,1),t.identity(),this;let u=dh.set(s[0],s[1],s[2]).length();const f=dh.set(s[4],s[5],s[6]).length(),h=dh.set(s[8],s[9],s[10]).length();this.determinant()<0&&(u=-u),Hr.copy(this);const g=1/u,_=1/f,x=1/h;return Hr.elements[0]*=g,Hr.elements[1]*=g,Hr.elements[2]*=g,Hr.elements[4]*=_,Hr.elements[5]*=_,Hr.elements[6]*=_,Hr.elements[8]*=x,Hr.elements[9]*=x,Hr.elements[10]*=x,t.setFromRotationMatrix(Hr),i.x=u,i.y=f,i.z=h,this}makePerspective(e,t,i,s,u,f,h=Fs,m=!1){const g=this.elements,_=2*u/(t-e),x=2*u/(i-s),b=(t+e)/(t-e),M=(i+s)/(i-s);let A,R;if(m)A=u/(f-u),R=f*u/(f-u);else if(h===Fs)A=-(f+u)/(f-u),R=-2*f*u/(f-u);else if(h===Vh)A=-f/(f-u),R=-f*u/(f-u);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+h);return g[0]=_,g[4]=0,g[8]=b,g[12]=0,g[1]=0,g[5]=x,g[9]=M,g[13]=0,g[2]=0,g[6]=0,g[10]=A,g[14]=R,g[3]=0,g[7]=0,g[11]=-1,g[15]=0,this}makeOrthographic(e,t,i,s,u,f,h=Fs,m=!1){const g=this.elements,_=2/(t-e),x=2/(i-s),b=-(t+e)/(t-e),M=-(i+s)/(i-s);let A,R;if(m)A=1/(f-u),R=f/(f-u);else if(h===Fs)A=-2/(f-u),R=-(f+u)/(f-u);else if(h===Vh)A=-1/(f-u),R=-u/(f-u);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+h);return g[0]=_,g[4]=0,g[8]=0,g[12]=b,g[1]=0,g[5]=x,g[9]=0,g[13]=M,g[2]=0,g[6]=0,g[10]=A,g[14]=R,g[3]=0,g[7]=0,g[11]=0,g[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<16;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const dh=new Y,Hr=new kt,jw=new Y(0,0,0),Qw=new Y(1,1,1),bu=new Y,v0=new Y,zs=new Y,Zb=new kt,jb=new ws;class Hs{constructor(e=0,t=0,i=0,s=Hs.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=s}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,i,s=this._order){return this._x=e,this._y=t,this._z=i,this._order=s,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,i=!0){const s=e.elements,u=s[0],f=s[4],h=s[8],m=s[1],g=s[5],_=s[9],x=s[2],b=s[6],M=s[10];switch(t){case"XYZ":this._y=Math.asin(Ft(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-_,M),this._z=Math.atan2(-f,u)):(this._x=Math.atan2(b,g),this._z=0);break;case"YXZ":this._x=Math.asin(-Ft(_,-1,1)),Math.abs(_)<.9999999?(this._y=Math.atan2(h,M),this._z=Math.atan2(m,g)):(this._y=Math.atan2(-x,u),this._z=0);break;case"ZXY":this._x=Math.asin(Ft(b,-1,1)),Math.abs(b)<.9999999?(this._y=Math.atan2(-x,M),this._z=Math.atan2(-f,g)):(this._y=0,this._z=Math.atan2(m,u));break;case"ZYX":this._y=Math.asin(-Ft(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(b,M),this._z=Math.atan2(m,u)):(this._x=0,this._z=Math.atan2(-f,g));break;case"YZX":this._z=Math.asin(Ft(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(-_,g),this._y=Math.atan2(-x,u)):(this._x=0,this._y=Math.atan2(h,M));break;case"XZY":this._z=Math.asin(-Ft(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(b,g),this._y=Math.atan2(h,u)):(this._x=Math.atan2(-_,M),this._y=0);break;default:rt("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Zb.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Zb,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return jb.setFromEuler(this),this.setFromQuaternion(jb,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}}Hs.DEFAULT_ORDER="XYZ";class Gh{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(h=>({...h,boundingBox:h.boundingBox?h.boundingBox.toJSON():void 0,boundingSphere:h.boundingSphere?h.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(h=>({...h})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function u(h,m){return h[m.uuid]===void 0&&(h[m.uuid]=m.toJSON(e)),m.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=u(e.geometries,this.geometry);const h=this.geometry.parameters;if(h!==void 0&&h.shapes!==void 0){const m=h.shapes;if(Array.isArray(m))for(let g=0,_=m.length;g<_;g++){const x=m[g];u(e.shapes,x)}else u(e.shapes,m)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(u(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const h=[];for(let m=0,g=this.material.length;m0){s.children=[];for(let h=0;h0){s.animations=[];for(let h=0;h0&&(i.geometries=h),m.length>0&&(i.materials=m),g.length>0&&(i.textures=g),_.length>0&&(i.images=_),x.length>0&&(i.shapes=x),b.length>0&&(i.skeletons=b),M.length>0&&(i.animations=M),A.length>0&&(i.nodes=A)}return i.object=s,i;function f(h){const m=[];for(const g in h){const _=h[g];delete _.metadata,m.push(_)}return m}}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 i=0;i0?s.multiplyScalar(1/Math.sqrt(u)):s.set(0,0,0)}static getBarycoord(e,t,i,s,u){Gr.subVectors(s,t),bl.subVectors(i,t),B_.subVectors(e,t);const f=Gr.dot(Gr),h=Gr.dot(bl),m=Gr.dot(B_),g=bl.dot(bl),_=bl.dot(B_),x=f*g-h*h;if(x===0)return u.set(0,0,0),null;const b=1/x,M=(g*m-h*_)*b,A=(f*_-h*m)*b;return u.set(1-M-A,A,M)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,Ml)===null?!1:Ml.x>=0&&Ml.y>=0&&Ml.x+Ml.y<=1}static getInterpolation(e,t,i,s,u,f,h,m){return this.getBarycoord(e,t,i,s,Ml)===null?(m.x=0,m.y=0,"z"in m&&(m.z=0),"w"in m&&(m.w=0),null):(m.setScalar(0),m.addScaledVector(u,Ml.x),m.addScaledVector(f,Ml.y),m.addScaledVector(h,Ml.z),m)}static getInterpolatedAttribute(e,t,i,s,u,f){return H_.setScalar(0),G_.setScalar(0),X_.setScalar(0),H_.fromBufferAttribute(e,t),G_.fromBufferAttribute(e,i),X_.fromBufferAttribute(e,s),f.setScalar(0),f.addScaledVector(H_,u.x),f.addScaledVector(G_,u.y),f.addScaledVector(X_,u.z),f}static isFrontFacing(e,t,i,s){return Gr.subVectors(i,t),bl.subVectors(e,t),Gr.cross(bl).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),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 Gr.subVectors(this.c,this.b),bl.subVectors(this.a,this.b),Gr.cross(bl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ts.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ts.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,u){return Ts.getInterpolation(e,this.a,this.b,this.c,t,i,s,u)}containsPoint(e){return Ts.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ts.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,u=this.c;let f,h;gh.subVectors(s,i),vh.subVectors(u,i),F_.subVectors(e,i);const m=gh.dot(F_),g=vh.dot(F_);if(m<=0&&g<=0)return t.copy(i);V_.subVectors(e,s);const _=gh.dot(V_),x=vh.dot(V_);if(_>=0&&x<=_)return t.copy(s);const b=m*x-_*g;if(b<=0&&m>=0&&_<=0)return f=m/(m-_),t.copy(i).addScaledVector(gh,f);k_.subVectors(e,u);const M=gh.dot(k_),A=vh.dot(k_);if(A>=0&&M<=A)return t.copy(u);const R=M*g-m*A;if(R<=0&&g>=0&&A<=0)return h=g/(g-A),t.copy(i).addScaledVector(vh,h);const C=_*A-M*x;if(C<=0&&x-_>=0&&M-A>=0)return tM.subVectors(u,s),h=(x-_)/(x-_+(M-A)),t.copy(s).addScaledVector(tM,h);const E=1/(C+R+b);return f=R*E,h=b*E,t.copy(i).addScaledVector(gh,f).addScaledVector(vh,h)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ME={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},Mu={h:0,s:0,l:0},_0={h:0,s:0,l:0};function W_(o,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?o+(e-o)*6*t:t<1/2?e:t<2/3?o+(e-o)*6*(2/3-t):o}class pt{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ua){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,xn.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=xn.workingColorSpace){return this.r=e,this.g=t,this.b=i,xn.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=xn.workingColorSpace){if(e=pS(e,1),t=Ft(t,0,1),i=Ft(i,0,1),t===0)this.r=this.g=this.b=i;else{const u=i<=.5?i*(1+t):i+t-i*t,f=2*i-u;this.r=W_(f,u,e+1/3),this.g=W_(f,u,e),this.b=W_(f,u,e-1/3)}return xn.colorSpaceToWorking(this,s),this}setStyle(e,t=Ua){function i(u){u!==void 0&&parseFloat(u)<1&&rt("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let u;const f=s[1],h=s[2];switch(f){case"rgb":case"rgba":if(u=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(h))return i(u[4]),this.setRGB(Math.min(255,parseInt(u[1],10))/255,Math.min(255,parseInt(u[2],10))/255,Math.min(255,parseInt(u[3],10))/255,t);if(u=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(h))return i(u[4]),this.setRGB(Math.min(100,parseInt(u[1],10))/100,Math.min(100,parseInt(u[2],10))/100,Math.min(100,parseInt(u[3],10))/100,t);break;case"hsl":case"hsla":if(u=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(h))return i(u[4]),this.setHSL(parseFloat(u[1])/360,parseFloat(u[2])/100,parseFloat(u[3])/100,t);break;default:rt("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const u=s[1],f=u.length;if(f===3)return this.setRGB(parseInt(u.charAt(0),16)/15,parseInt(u.charAt(1),16)/15,parseInt(u.charAt(2),16)/15,t);if(f===6)return this.setHex(parseInt(u,16),t);rt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ua){const i=ME[e.toLowerCase()];return i!==void 0?this.setHex(i,t):rt("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=wl(e.r),this.g=wl(e.g),this.b=wl(e.b),this}copyLinearToSRGB(e){return this.r=Ph(e.r),this.g=Ph(e.g),this.b=Ph(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ua){return xn.workingToColorSpace(Da.copy(this),e),Math.round(Ft(Da.r*255,0,255))*65536+Math.round(Ft(Da.g*255,0,255))*256+Math.round(Ft(Da.b*255,0,255))}getHexString(e=Ua){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=xn.workingColorSpace){xn.workingToColorSpace(Da.copy(this),t);const i=Da.r,s=Da.g,u=Da.b,f=Math.max(i,s,u),h=Math.min(i,s,u);let m,g;const _=(h+f)/2;if(h===f)m=0,g=0;else{const x=f-h;switch(g=_<=.5?x/(f+h):x/(2-f-h),f){case i:m=(s-u)/x+(s0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){rt(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){rt(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Wc&&(i.blending=this.blending),this.side!==Cl&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==lv&&(i.blendSrc=this.blendSrc),this.blendDst!==uv&&(i.blendDst=this.blendDst),this.blendEquation!==wu&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Zc&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Lx&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Fc&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Fc&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Fc&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(u){const f=[];for(const h in u){const m=u[h];delete m.metadata,f.push(m)}return f}if(t){const u=s(e.textures),f=s(e.images);u.length>0&&(i.textures=u),f.length>0&&(i.images=f)}return i}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 i=null;if(t!==null){const s=t.length;i=new Array(s);for(let u=0;u!==s;++u)i[u]=t[u].clone()}return this.clippingPlanes=i,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.allowOverride=e.allowOverride,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 Pu extends Oa{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new pt(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.envMapRotation=new Hs,this.combine=_m,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.envMapRotation.copy(e.envMapRotation),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 Al=nC();function nC(){const o=new ArrayBuffer(4),e=new Float32Array(o),t=new Uint32Array(o),i=new Uint32Array(512),s=new Uint32Array(512);for(let m=0;m<256;++m){const g=m-127;g<-27?(i[m]=0,i[m|256]=32768,s[m]=24,s[m|256]=24):g<-14?(i[m]=1024>>-g-14,i[m|256]=1024>>-g-14|32768,s[m]=-g-1,s[m|256]=-g-1):g<=15?(i[m]=g+15<<10,i[m|256]=g+15<<10|32768,s[m]=13,s[m|256]=13):g<128?(i[m]=31744,i[m|256]=64512,s[m]=24,s[m|256]=24):(i[m]=31744,i[m|256]=64512,s[m]=13,s[m|256]=13)}const u=new Uint32Array(2048),f=new Uint32Array(64),h=new Uint32Array(64);for(let m=1;m<1024;++m){let g=m<<13,_=0;for(;(g&8388608)===0;)g<<=1,_-=8388608;g&=-8388609,_+=947912704,u[m]=g|_}for(let m=1024;m<2048;++m)u[m]=939524096+(m-1024<<13);for(let m=1;m<31;++m)f[m]=m<<23;f[31]=1199570944,f[32]=2147483648;for(let m=33;m<63;++m)f[m]=2147483648+(m-32<<23);f[63]=3347054592;for(let m=1;m<64;++m)m!==32&&(h[m]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:s,mantissaTable:u,exponentTable:f,offsetTable:h}}function Ms(o){Math.abs(o)>65504&&rt("DataUtils.toHalfFloat(): Value out of range."),o=Ft(o,-65504,65504),Al.floatView[0]=o;const e=Al.uint32View[0],t=e>>23&511;return Al.baseTable[t]+((e&8388607)>>Al.shiftTable[t])}function kp(o){const e=o>>10;return Al.uint32View[0]=Al.mantissaTable[Al.offsetTable[e]+(o&1023)]+Al.exponentTable[e],Al.floatView[0]}class iC{static toHalfFloat(e){return Ms(e)}static fromHalfFloat(e){return kp(e)}}const Hi=new Y,x0=new Pe;let aC=0;class Hn{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:aC++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=om,this.updateRanges=[],this.gpuType=es,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}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,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,u=this.itemSize;st.count&&rt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ia);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Tt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Y(-1/0,-1/0,-1/0),new Y(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0){const m=this.parameters;for(const g in m)m[g]!==void 0&&(e[g]=m[g]);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 i=this.attributes;for(const m in i){const g=i[m];e.data.attributes[m]=g.toJSON(e.data)}const s={};let u=!1;for(const m in this.morphAttributes){const g=this.morphAttributes[m],_=[];for(let x=0,b=g.length;x0&&(s[m]=_,u=!0)}u&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const f=this.groups;f.length>0&&(e.data.groups=JSON.parse(JSON.stringify(f)));const h=this.boundingSphere;return h!==null&&(e.data.boundingSphere=h.toJSON()),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 i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const g in s){const _=s[g];this.setAttribute(g,_.clone(t))}const u=e.morphAttributes;for(const g in u){const _=[],x=u[g];for(let b=0,M=x.length;b0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let u=0,f=s.length;u(e.far-e.near)**2))&&(nM.copy(u).invert(),wc.copy(e.ray).applyMatrix4(nM),!(i.boundingBox!==null&&wc.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,wc)))}_computeIntersections(e,t,i){let s;const u=this.geometry,f=this.material,h=u.index,m=u.attributes.position,g=u.attributes.uv,_=u.attributes.uv1,x=u.attributes.normal,b=u.groups,M=u.drawRange;if(h!==null)if(Array.isArray(f))for(let A=0,R=b.length;At.far?null:{distance:g,point:A0.clone(),object:o}}function w0(o,e,t,i,s,u,f,h,m,g){o.getVertexPosition(h,b0),o.getVertexPosition(m,M0),o.getVertexPosition(g,E0);const _=hC(o,e,t,i,b0,M0,E0,aM);if(_){const x=new Y;Ts.getBarycoord(aM,b0,M0,E0,x),s&&(_.uv=Ts.getInterpolatedAttribute(s,h,m,g,x,new Pe)),u&&(_.uv1=Ts.getInterpolatedAttribute(u,h,m,g,x,new Pe)),f&&(_.normal=Ts.getInterpolatedAttribute(f,h,m,g,x,new Y),_.normal.dot(i.direction)>0&&_.normal.multiplyScalar(-1));const b={a:h,b:m,c:g,normal:new Y,materialIndex:0};Ts.getNormal(b0,M0,E0,b.normal),_.face=b,_.barycoord=x}return _}class $c extends Yt{constructor(e=1,t=1,i=1,s=1,u=1,f=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:s,heightSegments:u,depthSegments:f};const h=this;s=Math.floor(s),u=Math.floor(u),f=Math.floor(f);const m=[],g=[],_=[],x=[];let b=0,M=0;A("z","y","x",-1,-1,i,t,e,f,u,0),A("z","y","x",1,-1,i,t,-e,f,u,1),A("x","z","y",1,1,e,i,t,s,f,2),A("x","z","y",1,-1,e,i,-t,s,f,3),A("x","y","z",1,-1,e,t,i,s,u,4),A("x","y","z",-1,-1,e,t,-i,s,u,5),this.setIndex(m),this.setAttribute("position",new yt(g,3)),this.setAttribute("normal",new yt(_,3)),this.setAttribute("uv",new yt(x,2));function A(R,C,E,D,U,L,B,P,H,W,I){const z=L/H,j=B/W,ae=L/2,$=B/2,ue=P/2,he=H+1,q=W+1;let K=0,ce=0;const Ae=new Y;for(let Ce=0;Ce0?1:-1,_.push(Ae.x,Ae.y,Ae.z),x.push(se/H),x.push(1-Ce/W),K+=1}}for(let Ce=0;Ce0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class yy extends An{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new kt,this.projectionMatrix=new kt,this.projectionMatrixInverse=new kt,this.coordinateSystem=Fs,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}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)}}const Eu=new Y,sM=new Pe,rM=new Pe;class aa extends yy{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,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=Hh*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(qc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Hh*2*Math.atan(Math.tan(qc*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Eu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Eu.x,Eu.y).multiplyScalar(-e/Eu.z),Eu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Eu.x,Eu.y).multiplyScalar(-e/Eu.z)}getViewSize(e,t){return this.getViewBounds(e,sM,rM),t.subVectors(rM,sM)}setViewOffset(e,t,i,s,u,f){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=i,this.view.offsetY=s,this.view.width=u,this.view.height=f,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(qc*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,u=-.5*s;const f=this.view;if(this.view!==null&&this.view.enabled){const m=f.fullWidth,g=f.fullHeight;u+=f.offsetX*s/m,t-=f.offsetY*i/g,s*=f.width/m,i*=f.height/g}const h=this.filmOffset;h!==0&&(u+=e*h/this.getFilmWidth()),this.projectionMatrix.makePerspective(u,u+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),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 _h=-90,xh=1;class AE extends An{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new aa(_h,xh,e,t);s.layers=this.layers,this.add(s);const u=new aa(_h,xh,e,t);u.layers=this.layers,this.add(u);const f=new aa(_h,xh,e,t);f.layers=this.layers,this.add(f);const h=new aa(_h,xh,e,t);h.layers=this.layers,this.add(h);const m=new aa(_h,xh,e,t);m.layers=this.layers,this.add(m);const g=new aa(_h,xh,e,t);g.layers=this.layers,this.add(g)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,u,f,h,m]=t;for(const g of t)this.remove(g);if(e===Fs)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),u.up.set(0,0,-1),u.lookAt(0,1,0),f.up.set(0,0,1),f.lookAt(0,-1,0),h.up.set(0,1,0),h.lookAt(0,0,1),m.up.set(0,1,0),m.lookAt(0,0,-1);else if(e===Vh)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),u.up.set(0,0,1),u.lookAt(0,1,0),f.up.set(0,0,-1),f.lookAt(0,-1,0),h.up.set(0,-1,0),h.lookAt(0,0,1),m.up.set(0,-1,0),m.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const g of t)this.add(g),g.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[u,f,h,m,g,_]=this.children,x=e.getRenderTarget(),b=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),A=e.xr.enabled;e.xr.enabled=!1;const R=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,s),e.render(t,u),e.setRenderTarget(i,1,s),e.render(t,f),e.setRenderTarget(i,2,s),e.render(t,h),e.setRenderTarget(i,3,s),e.render(t,m),e.setRenderTarget(i,4,s),e.render(t,g),i.texture.generateMipmaps=R,e.setRenderTarget(i,5,s),e.render(t,_),e.setRenderTarget(x,b,M),e.xr.enabled=A,i.texture.needsPMREMUpdate=!0}}class Sm extends Ei{constructor(e=[],t=Oo,i,s,u,f,h,m,g,_){super(e,t,i,s,u,f,h,m,g,_),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class yS extends ks{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new Sm(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}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 i={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},s=new $c(5,5,5),u=new vr({name:"CubemapFromEquirect",uniforms:Xh(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:ts,blending:Io});u.uniforms.tEquirect.value=t;const f=new Gi(s,u),h=t.minFilter;return t.minFilter===Uo&&(t.minFilter=ai),new AE(1,10,this).update(e,f),t.minFilter=h,f.geometry.dispose(),f.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const u=e.getRenderTarget();for(let f=0;f<6;f++)e.setRenderTarget(this,f),e.clear(t,i,s);e.setRenderTarget(u)}}class Oh extends An{constructor(){super(),this.isGroup=!0,this.type="Group"}}const gC={type:"move"};class sv{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Oh,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 Oh,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Y,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Y),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Oh,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Y,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Y),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 i of e.hand.values())this._getHandJoint(t,i)}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,i){let s=null,u=null,f=null;const h=this._targetRay,m=this._grip,g=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(g&&e.hand){f=!0;for(const R of e.hand.values()){const C=t.getJointPose(R,i),E=this._getHandJoint(g,R);C!==null&&(E.matrix.fromArray(C.transform.matrix),E.matrix.decompose(E.position,E.rotation,E.scale),E.matrixWorldNeedsUpdate=!0,E.jointRadius=C.radius),E.visible=C!==null}const _=g.joints["index-finger-tip"],x=g.joints["thumb-tip"],b=_.position.distanceTo(x.position),M=.02,A=.005;g.inputState.pinching&&b>M+A?(g.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!g.inputState.pinching&&b<=M-A&&(g.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else m!==null&&e.gripSpace&&(u=t.getPose(e.gripSpace,i),u!==null&&(m.matrix.fromArray(u.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,u.linearVelocity?(m.hasLinearVelocity=!0,m.linearVelocity.copy(u.linearVelocity)):m.hasLinearVelocity=!1,u.angularVelocity?(m.hasAngularVelocity=!0,m.angularVelocity.copy(u.angularVelocity)):m.hasAngularVelocity=!1));h!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&u!==null&&(s=u),s!==null&&(h.matrix.fromArray(s.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,s.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(s.linearVelocity)):h.hasLinearVelocity=!1,s.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(s.angularVelocity)):h.hasAngularVelocity=!1,this.dispatchEvent(gC)))}return h!==null&&(h.visible=s!==null),m!==null&&(m.visible=u!==null),g!==null&&(g.visible=f!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Oh;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class _y{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new pt(e),this.density=t}clone(){return new _y(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class xy{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new pt(e),this.near=t,this.far=i}clone(){return new xy(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class _S extends An{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Hs,this.environmentIntensity=1,this.environmentRotation=new Hs,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,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),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.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Sy{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=om,this.updateRanges=[],this.version=0,this.uuid=Vs()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}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,i){e*=this.stride,i*=t.stride;for(let s=0,u=this.stride;se.far||t.push({distance:m,point:Up.clone(),uv:Ts.getInterpolation(Up,C0,Ip,R0,oM,Z_,lM,new Pe),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function D0(o,e,t,i,s,u){Eh.subVectors(o,t).addScalar(.5).multiply(i),s!==void 0?(Lp.x=u*Eh.x-s*Eh.y,Lp.y=s*Eh.x+u*Eh.y):Lp.copy(Eh),o.copy(e),o.x+=Lp.x,o.y+=Lp.y,o.applyMatrix4(wE)}const N0=new Y,uM=new Y;class RE extends An{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,s=t.length;i0){let i,s;for(i=1,s=t.length;i0){N0.setFromMatrixPosition(this.matrixWorld);const s=e.ray.origin.distanceTo(N0);this.getObjectForDistance(s).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){N0.setFromMatrixPosition(e.matrixWorld),uM.setFromMatrixPosition(this.matrixWorld);const i=N0.distanceTo(uM)/e.zoom;t[0].object.visible=!0;let s,u;for(s=1,u=t.length;s=f)t[s-1].object.visible=!1,t[s].object.visible=!0;else break}for(this._currentLevel=s-1;s1?null:t.copy(e.start).addScaledVector(i,u)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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 i=t||SC.getNormalMatrix(e),s=this.coplanarPoint(J_).applyMatrix4(e),u=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(u),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 Cc=new ga,bC=new Pe(.5,.5),I0=new Y;class Jh{constructor(e=new Au,t=new Au,i=new Au,s=new Au,u=new Au,f=new Au){this.planes=[e,t,i,s,u,f]}set(e,t,i,s,u,f){const h=this.planes;return h[0].copy(e),h[1].copy(t),h[2].copy(i),h[3].copy(s),h[4].copy(u),h[5].copy(f),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Fs,i=!1){const s=this.planes,u=e.elements,f=u[0],h=u[1],m=u[2],g=u[3],_=u[4],x=u[5],b=u[6],M=u[7],A=u[8],R=u[9],C=u[10],E=u[11],D=u[12],U=u[13],L=u[14],B=u[15];if(s[0].setComponents(g-f,M-_,E-A,B-D).normalize(),s[1].setComponents(g+f,M+_,E+A,B+D).normalize(),s[2].setComponents(g+h,M+x,E+R,B+U).normalize(),s[3].setComponents(g-h,M-x,E-R,B-U).normalize(),i)s[4].setComponents(m,b,C,L).normalize(),s[5].setComponents(g-m,M-b,E-C,B-L).normalize();else if(s[4].setComponents(g-m,M-b,E-C,B-L).normalize(),t===Fs)s[5].setComponents(g+m,M+b,E+C,B+L).normalize();else if(t===Vh)s[5].setComponents(m,b,C,L).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(),Cc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Cc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Cc)}intersectsSprite(e){Cc.center.set(0,0,0);const t=bC.distanceTo(e.center);return Cc.radius=.7071067811865476+t,Cc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Cc)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let u=0;u<6;u++)if(t[u].distanceToPoint(i)0?e.max.x:e.min.x,I0.y=s.normal.y>0?e.max.y:e.min.y,I0.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(I0)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Co=new kt,Ro=new Jh;class My{constructor(){this.coordinateSystem=Fs}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i=u.length&&u.push({start:-1,count:-1,z:-1,index:-1});const h=u[this.index];f.push(h),this.index++,h.start=e,h.count=t,h.z=i,h.index=s}reset(){this.list.length=0,this.index=0}}const bs=new kt,AC=new pt(1,1,1),yM=new Jh,wC=new My,O0=new Ia,Rc=new ga,Pp=new Y,_M=new Y,CC=new Y,$_=new TC,Na=new Gi,z0=[];function RC(o,e,t=0){const i=e.itemSize;if(o.isInterleavedBufferAttribute||o.array.constructor!==e.array.constructor){const s=o.count;for(let u=0;u65535?new Uint32Array(s):new Uint16Array(s);t.setIndex(new Hn(u,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const s=e.getAttribute(i),u=t.getAttribute(i);if(s.itemSize!==u.itemSize||s.normalized!==u.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ia);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,s=t.length;i=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const i={visible:!0,active:!0,geometryIndex:e};let s=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(K_),s=this._availableInstanceIds.shift(),this._instanceInfo[s]=i):(s=this._instanceInfo.length,this._instanceInfo.push(i));const u=this._matricesTexture;bs.identity().toArray(u.image.data,s*16),u.needsUpdate=!0;const f=this._colorsTexture;return f&&(AC.toArray(f.image.data,s*4),f.needsUpdate=!0),this._visibilityChanged=!0,s}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const s={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},u=this._geometryInfo;s.vertexStart=this._nextVertexStart,s.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const f=e.getIndex();if(f!==null&&(s.indexStart=this._nextIndexStart,s.reservedIndexCount=i===-1?f.count:i),s.indexStart!==-1&&s.indexStart+s.reservedIndexCount>this._maxIndexCount||s.vertexStart+s.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let m;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(K_),m=this._availableGeometryIds.shift(),u[m]=s):(m=this._geometryCount,this._geometryCount++,u.push(s)),this.setGeometryAt(m,e),this._nextIndexStart=s.indexStart+s.reservedIndexCount,this._nextVertexStart=s.vertexStart+s.reservedVertexCount,m}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,s=i.getIndex()!==null,u=i.getIndex(),f=t.getIndex(),h=this._geometryInfo[e];if(s&&f.count>h.reservedIndexCount||t.attributes.position.count>h.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const m=h.vertexStart,g=h.reservedVertexCount;h.vertexCount=t.getAttribute("position").count;for(const _ in i.attributes){const x=t.getAttribute(_),b=i.getAttribute(_);RC(x,b,m);const M=x.itemSize;for(let A=x.count,R=g;A=t.length||t[e].active===!1)return this;const i=this._instanceInfo;for(let s=0,u=i.length;sh).sort((f,h)=>i[f].vertexStart-i[h].vertexStart),u=this.geometry;for(let f=0,h=i.length;f=this._geometryCount)return null;const i=this.geometry,s=this._geometryInfo[e];if(s.boundingBox===null){const u=new Ia,f=i.index,h=i.attributes.position;for(let m=s.start,g=s.start+s.count;m=this._geometryCount)return null;const i=this.geometry,s=this._geometryInfo[e];if(s.boundingSphere===null){const u=new ga;this.getBoundingBoxAt(e,O0),O0.getCenter(u.center);const f=i.index,h=i.attributes.position;let m=0;for(let g=s.start,_=s.start+s.count;g<_;g++){let x=g;f&&(x=f.getX(x)),Pp.fromBufferAttribute(h,x),m=Math.max(m,u.center.distanceToSquared(Pp))}u.radius=Math.sqrt(m),s.boundingSphere=u}return t.copy(s.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const i=this._matricesTexture,s=this._matricesTexture.image.data;return t.toArray(s,e*16),i.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const i=this._geometryInfo[e];return t.vertexStart=i.vertexStart,t.vertexCount=i.vertexCount,t.reservedVertexCount=i.reservedVertexCount,t.indexStart=i.indexStart,t.indexCount=i.indexCount,t.reservedIndexCount=i.reservedIndexCount,t.start=i.start,t.count=i.count,t}setInstanceCount(e){const t=this._availableInstanceIds,i=this._instanceInfo;for(t.sort(K_);t[t.length-1]===i.length-1;)i.pop(),t.pop();if(eh.active);if(Math.max(...i.map(h=>h.vertexStart+h.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(m=>m.indexStart+m.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const u=this.geometry;u.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Yt,this._initializeGeometry(u));const f=this.geometry;u.index&&Dc(u.index.array,f.index.array);for(const h in u.attributes)Dc(u.attributes[h].array,f.attributes[h].array)}raycast(e,t){const i=this._instanceInfo,s=this._geometryInfo,u=this.matrixWorld,f=this.geometry;Na.material=this.material,Na.geometry.index=f.index,Na.geometry.attributes=f.attributes,Na.geometry.boundingBox===null&&(Na.geometry.boundingBox=new Ia),Na.geometry.boundingSphere===null&&(Na.geometry.boundingSphere=new ga);for(let h=0,m=i.length;h({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,i,s,u){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const f=s.getIndex(),h=f===null?1:f.array.BYTES_PER_ELEMENT,m=this._instanceInfo,g=this._multiDrawStarts,_=this._multiDrawCounts,x=this._geometryInfo,b=this.perObjectFrustumCulled,M=this._indirectTexture,A=M.image.data,R=i.isArrayCamera?wC:yM;b&&!i.isArrayCamera&&(bs.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),yM.setFromProjectionMatrix(bs,i.coordinateSystem,i.reversedDepth));let C=0;if(this.sortObjects){bs.copy(this.matrixWorld).invert(),Pp.setFromMatrixPosition(i.matrixWorld).applyMatrix4(bs),_M.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(bs);for(let U=0,L=m.length;U0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let u=0,f=s.length;ui)return;ex.applyMatrix4(o.matrixWorld);const g=e.ray.origin.distanceTo(ex);if(!(ge.far))return{distance:g,point:SM.clone().applyMatrix4(o.matrixWorld),index:f,face:null,faceIndex:null,barycoord:null,object:o}}const bM=new Y,MM=new Y;class Fo extends Ou{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,u=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let u=0,f=s.length;us.far)return;u.push({distance:g,distanceToRay:Math.sqrt(h),point:m,index:e,face:null,faceIndex:null,barycoord:null,object:f})}}class OE extends Ei{constructor(e,t,i,s,u=ai,f=ai,h,m,g){super(e,t,i,s,u,f,h,m,g),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const _=this;function x(){_.needsUpdate=!0,_._requestVideoFrameCallbackId=e.requestVideoFrameCallback(x)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(x))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class DC extends OE{constructor(e,t,i,s,u,f,h,m){super({},e,t,i,s,u,f,h,m),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class NC extends Ei{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Li,this.minFilter=Li,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ey extends Ei{constructor(e,t,i,s,u,f,h,m,g,_,x,b){super(null,f,h,m,g,_,s,u,x,b),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class UC extends Ey{constructor(e,t,i,s,u,f){super(e,t,i,u,f),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=As,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class LC extends Ey{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Oo),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class IC extends Ei{constructor(e,t,i,s,u,f,h,m,g){super(e,t,i,s,u,f,h,m,g),this.isCanvasTexture=!0,this.needsUpdate=!0}}class qh extends Ei{constructor(e,t,i=gr,s,u,f,h=Li,m=Li,g,_=Po,x=1){if(_!==Po&&_!==Ru)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const b={width:e,height:t,depth:x};super(b,s,u,f,h,m,_,i,g),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Du(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class zE extends qh{constructor(e,t=gr,i=Oo,s,u,f=Li,h=Li,m,g=Po){const _={width:e,height:e,depth:1},x=[_,_,_,_,_,_];super(e,e,t,i,s,u,f,h,m,g),this.image=x,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class MS extends Ei{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Ty extends Yt{constructor(e=1,t=1,i=4,s=8,u=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:s,heightSegments:u},t=Math.max(0,t),i=Math.max(1,Math.floor(i)),s=Math.max(3,Math.floor(s)),u=Math.max(1,Math.floor(u));const f=[],h=[],m=[],g=[],_=t/2,x=Math.PI/2*e,b=t,M=2*x+b,A=i*2+u,R=s+1,C=new Y,E=new Y;for(let D=0;D<=A;D++){let U=0,L=0,B=0,P=0;if(D<=i){const I=D/i,z=I*Math.PI/2;L=-_-e*Math.cos(z),B=e*Math.sin(z),P=-e*Math.cos(z),U=I*x}else if(D<=i+u){const I=(D-i)/u;L=-_+I*t,B=e,P=0,U=x+I*b}else{const I=(D-i-u)/i,z=I*Math.PI/2;L=_+e*Math.sin(z),B=e*Math.cos(z),P=e*Math.sin(z),U=x+b+I*x}const H=Math.max(0,Math.min(1,U/M));let W=0;D===0?W=.5/s:D===A&&(W=-.5/s);for(let I=0;I<=s;I++){const z=I/s,j=z*Math.PI*2,ae=Math.sin(j),$=Math.cos(j);E.x=-B*$,E.y=L,E.z=B*ae,h.push(E.x,E.y,E.z),C.set(-B*$,P,B*ae),C.normalize(),m.push(C.x,C.y,C.z),g.push(z+W,H)}if(D>0){const I=(D-1)*R;for(let z=0;z0&&U(!0),t>0&&U(!1)),this.setIndex(_),this.setAttribute("position",new yt(x,3)),this.setAttribute("normal",new yt(b,3)),this.setAttribute("uv",new yt(M,2));function D(){const L=new Y,B=new Y;let P=0;const H=(t-e)/i;for(let W=0;W<=u;W++){const I=[],z=W/u,j=z*(t-e)+e;for(let ae=0;ae<=s;ae++){const $=ae/s,ue=$*m+h,he=Math.sin(ue),q=Math.cos(ue);B.x=j*he,B.y=-z*i+C,B.z=j*q,x.push(B.x,B.y,B.z),L.set(he,H,q).normalize(),b.push(L.x,L.y,L.z),M.push($,1-z),I.push(A++)}R.push(I)}for(let W=0;W0||I!==0)&&(_.push(z,j,$),P+=3),(t>0||I!==u-1)&&(_.push(j,ae,$),P+=3)}g.addGroup(E,P,0),E+=P}function U(L){const B=A,P=new Pe,H=new Y;let W=0;const I=L===!0?e:t,z=L===!0?1:-1;for(let ae=1;ae<=s;ae++)x.push(0,C*z,0),b.push(0,z,0),M.push(.5,.5),A++;const j=A;for(let ae=0;ae<=s;ae++){const ue=ae/s*m+h,he=Math.cos(ue),q=Math.sin(ue);H.x=I*q,H.y=C*z,H.z=I*he,x.push(H.x,H.y,H.z),b.push(0,z,0),P.x=he*.5+.5,P.y=q*.5*z+.5,M.push(P.x,P.y),A++}for(let ae=0;ae.9&&H<.1&&(U<.2&&(f[D+0]+=1),L<.2&&(f[D+2]+=1),B<.2&&(f[D+4]+=1))}}function b(D){u.push(D.x,D.y,D.z)}function M(D,U){const L=D*3;U.x=e[L+0],U.y=e[L+1],U.z=e[L+2]}function A(){const D=new Y,U=new Y,L=new Y,B=new Y,P=new Pe,H=new Pe,W=new Pe;for(let I=0,z=0;I0)m=s-1;else{m=s;break}if(s=m,i[s]===f)return s/(u-1);const _=i[s],b=i[s+1]-_,M=(f-_)/b;return(s+M)/(u-1)}getTangent(e,t){let s=e-1e-4,u=e+1e-4;s<0&&(s=0),u>1&&(u=1);const f=this.getPoint(s),h=this.getPoint(u),m=t||(f.isVector2?new Pe:new Y);return m.copy(h).sub(f).normalize(),m}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new Y,s=[],u=[],f=[],h=new Y,m=new kt;for(let M=0;M<=e;M++){const A=M/e;s[M]=this.getTangentAt(A,new Y)}u[0]=new Y,f[0]=new Y;let g=Number.MAX_VALUE;const _=Math.abs(s[0].x),x=Math.abs(s[0].y),b=Math.abs(s[0].z);_<=g&&(g=_,i.set(1,0,0)),x<=g&&(g=x,i.set(0,1,0)),b<=g&&i.set(0,0,1),h.crossVectors(s[0],i).normalize(),u[0].crossVectors(s[0],h),f[0].crossVectors(s[0],u[0]);for(let M=1;M<=e;M++){if(u[M]=u[M-1].clone(),f[M]=f[M-1].clone(),h.crossVectors(s[M-1],s[M]),h.length()>Number.EPSILON){h.normalize();const A=Math.acos(Ft(s[M-1].dot(s[M]),-1,1));u[M].applyMatrix4(m.makeRotationAxis(h,A))}f[M].crossVectors(s[M],u[M])}if(t===!0){let M=Math.acos(Ft(u[0].dot(u[e]),-1,1));M/=e,s[0].dot(h.crossVectors(u[0],u[e]))>0&&(M=-M);for(let A=1;A<=e;A++)u[A].applyMatrix4(m.makeRotationAxis(s[A],M*A)),f[A].crossVectors(s[A],u[A])}return{tangents:s,normals:u,binormals:f}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Cy extends Yr{constructor(e=0,t=0,i=1,s=1,u=0,f=Math.PI*2,h=!1,m=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=u,this.aEndAngle=f,this.aClockwise=h,this.aRotation=m}getPoint(e,t=new Pe){const i=t,s=Math.PI*2;let u=this.aEndAngle-this.aStartAngle;const f=Math.abs(u)s;)u-=s;u0?0:(Math.floor(Math.abs(h)/u)+1)*u:m===0&&h===u-1&&(h=u-2,m=1);let g,_;this.closed||h>0?g=s[(h-1)%u]:(X0.subVectors(s[0],s[1]).add(s[0]),g=X0);const x=s[h%u],b=s[(h+1)%u];if(this.closed||h+2s.length-2?s.length-1:f+1],x=s[f>s.length-3?s.length-1:f+2];return i.set(AM(h,m.x,g.x,_.x,x.x),AM(h,m.y,g.y,_.y,x.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const f=s[u]-i,h=this.curves[u],m=h.getLength(),g=m===0?0:1-f/m;return h.getPointAt(g,t)}u++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const x=g.getPoint(0);x.equals(this.currentPoint)||this.lineTo(x.x,x.y)}this.curves.push(g);const _=g.getPoint(1);return this.currentPoint.copy(_),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Yc extends $v{constructor(e){super(e),this.uuid=Vs(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){h=o[0],m=o[1];let _=h,x=m;for(let b=t;b_&&(_=M),A>x&&(x=A)}g=Math.max(_-h,x-m),g=g!==0?32767/g:0}return cm(u,f,t,h,m,g,0),f}function GE(o,e,t,i,s){let u;if(s===a3(o,e,t,i)>0)for(let f=e;f=e;f-=i)u=wM(f/i|0,o[f],o[f+1],u);return u&&Yh(u,u.next)&&(hm(u),u=u.next),u}function Jc(o,e){if(!o)return o;e||(e=o);let t=o,i;do if(i=!1,!t.steiner&&(Yh(t,t.next)||gi(t.prev,t,t.next)===0)){if(hm(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function cm(o,e,t,i,s,u,f){if(!o)return;!f&&u&&KC(o,i,s,u);let h=o;for(;o.prev!==o.next;){const m=o.prev,g=o.next;if(u?XC(o,i,s,u):GC(o)){e.push(m.i,o.i,g.i),hm(o),o=g.next,h=g.next;continue}if(o=g,o===h){f?f===1?(o=WC(Jc(o),e),cm(o,e,t,i,s,u,2)):f===2&&qC(o,e,t,i,s,u):cm(Jc(o),e,t,i,s,u,1);break}}}function GC(o){const e=o.prev,t=o,i=o.next;if(gi(e,t,i)>=0)return!1;const s=e.x,u=t.x,f=i.x,h=e.y,m=t.y,g=i.y,_=Math.min(s,u,f),x=Math.min(h,m,g),b=Math.max(s,u,f),M=Math.max(h,m,g);let A=i.next;for(;A!==e;){if(A.x>=_&&A.x<=b&&A.y>=x&&A.y<=M&&Hp(s,h,u,m,f,g,A.x,A.y)&&gi(A.prev,A,A.next)>=0)return!1;A=A.next}return!0}function XC(o,e,t,i){const s=o.prev,u=o,f=o.next;if(gi(s,u,f)>=0)return!1;const h=s.x,m=u.x,g=f.x,_=s.y,x=u.y,b=f.y,M=Math.min(h,m,g),A=Math.min(_,x,b),R=Math.max(h,m,g),C=Math.max(_,x,b),E=zx(M,A,e,t,i),D=zx(R,C,e,t,i);let U=o.prevZ,L=o.nextZ;for(;U&&U.z>=E&&L&&L.z<=D;){if(U.x>=M&&U.x<=R&&U.y>=A&&U.y<=C&&U!==s&&U!==f&&Hp(h,_,m,x,g,b,U.x,U.y)&&gi(U.prev,U,U.next)>=0||(U=U.prevZ,L.x>=M&&L.x<=R&&L.y>=A&&L.y<=C&&L!==s&&L!==f&&Hp(h,_,m,x,g,b,L.x,L.y)&&gi(L.prev,L,L.next)>=0))return!1;L=L.nextZ}for(;U&&U.z>=E;){if(U.x>=M&&U.x<=R&&U.y>=A&&U.y<=C&&U!==s&&U!==f&&Hp(h,_,m,x,g,b,U.x,U.y)&&gi(U.prev,U,U.next)>=0)return!1;U=U.prevZ}for(;L&&L.z<=D;){if(L.x>=M&&L.x<=R&&L.y>=A&&L.y<=C&&L!==s&&L!==f&&Hp(h,_,m,x,g,b,L.x,L.y)&&gi(L.prev,L,L.next)>=0)return!1;L=L.nextZ}return!0}function WC(o,e){let t=o;do{const i=t.prev,s=t.next.next;!Yh(i,s)&&WE(i,t,t.next,s)&&fm(i,s)&&fm(s,i)&&(e.push(i.i,t.i,s.i),hm(t),hm(t.next),t=o=s),t=t.next}while(t!==o);return Jc(t)}function qC(o,e,t,i,s,u){let f=o;do{let h=f.next.next;for(;h!==f.prev;){if(f.i!==h.i&&t3(f,h)){let m=qE(f,h);f=Jc(f,f.next),m=Jc(m,m.next),cm(f,e,t,i,s,u,0),cm(m,e,t,i,s,u,0);return}h=h.next}f=f.next}while(f!==o)}function YC(o,e,t,i){const s=[];for(let u=0,f=e.length;u=t.next.y&&t.next.y!==t.y){const x=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(x<=i&&x>u&&(u=x,f=t.x=t.x&&t.x>=m&&i!==t.x&&XE(sf.x||t.x===f.x&&JC(f,t)))&&(f=t,_=x)}t=t.next}while(t!==h);return f}function JC(o,e){return gi(o.prev,o,e.prev)<0&&gi(e.next,o,o.next)<0}function KC(o,e,t,i){let s=o;do s.z===0&&(s.z=zx(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==o);s.prevZ.nextZ=null,s.prevZ=null,$C(s)}function $C(o){let e,t=1;do{let i=o,s;o=null;let u=null;for(e=0;i;){e++;let f=i,h=0;for(let g=0;g0||m>0&&f;)h!==0&&(m===0||!f||i.z<=f.z)?(s=i,i=i.nextZ,h--):(s=f,f=f.nextZ,m--),u?u.nextZ=s:o=s,s.prevZ=u,u=s;i=f}u.nextZ=null,t*=2}while(e>1);return o}function zx(o,e,t,i,s){return o=(o-t)*s|0,e=(e-i)*s|0,o=(o|o<<8)&16711935,o=(o|o<<4)&252645135,o=(o|o<<2)&858993459,o=(o|o<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,o|e<<1}function e3(o){let e=o,t=o;do(e.x=(o-f)*(u-h)&&(o-f)*(i-h)>=(t-f)*(e-h)&&(t-f)*(u-h)>=(s-f)*(i-h)}function Hp(o,e,t,i,s,u,f,h){return!(o===f&&e===h)&&XE(o,e,t,i,s,u,f,h)}function t3(o,e){return o.next.i!==e.i&&o.prev.i!==e.i&&!n3(o,e)&&(fm(o,e)&&fm(e,o)&&i3(o,e)&&(gi(o.prev,o,e.prev)||gi(o,e.prev,e))||Yh(o,e)&&gi(o.prev,o,o.next)>0&&gi(e.prev,e,e.next)>0)}function gi(o,e,t){return(e.y-o.y)*(t.x-e.x)-(e.x-o.x)*(t.y-e.y)}function Yh(o,e){return o.x===e.x&&o.y===e.y}function WE(o,e,t,i){const s=q0(gi(o,e,t)),u=q0(gi(o,e,i)),f=q0(gi(t,i,o)),h=q0(gi(t,i,e));return!!(s!==u&&f!==h||s===0&&W0(o,t,e)||u===0&&W0(o,i,e)||f===0&&W0(t,o,i)||h===0&&W0(t,e,i))}function W0(o,e,t){return e.x<=Math.max(o.x,t.x)&&e.x>=Math.min(o.x,t.x)&&e.y<=Math.max(o.y,t.y)&&e.y>=Math.min(o.y,t.y)}function q0(o){return o>0?1:o<0?-1:0}function n3(o,e){let t=o;do{if(t.i!==o.i&&t.next.i!==o.i&&t.i!==e.i&&t.next.i!==e.i&&WE(t,t.next,o,e))return!0;t=t.next}while(t!==o);return!1}function fm(o,e){return gi(o.prev,o,o.next)<0?gi(o,e,o.next)>=0&&gi(o,o.prev,e)>=0:gi(o,e,o.prev)<0||gi(o,o.next,e)<0}function i3(o,e){let t=o,i=!1;const s=(o.x+e.x)/2,u=(o.y+e.y)/2;do t.y>u!=t.next.y>u&&t.next.y!==t.y&&s<(t.next.x-t.x)*(u-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==o);return i}function qE(o,e){const t=Px(o.i,o.x,o.y),i=Px(e.i,e.x,e.y),s=o.next,u=e.prev;return o.next=e,e.prev=o,t.next=s,s.prev=t,i.next=t,t.prev=i,u.next=i,i.prev=u,i}function wM(o,e,t,i){const s=Px(o,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function hm(o){o.next.prev=o.prev,o.prev.next=o.next,o.prevZ&&(o.prevZ.nextZ=o.nextZ),o.nextZ&&(o.nextZ.prevZ=o.prevZ)}function Px(o,e,t){return{i:o,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function a3(o,e,t,i){let s=0;for(let u=e,f=t-i;u2&&o[e-1].equals(o[0])&&o.pop()}function RM(o,e){for(let t=0;tNumber.EPSILON){const Se=Math.sqrt(O),Le=Math.sqrt(We*We+G*G),be=Ve.x-Mt/Se,ct=Ve.y+tt/Se,Ze=Ue.x-G/Le,gt=Ue.y+We/Le,wt=((Ze-be)*G-(gt-ct)*We)/(tt*G-Mt*We);Ke=be+tt*wt-Re.x,Z=ct+Mt*wt-Re.y;const Be=Ke*Ke+Z*Z;if(Be<=2)return new Pe(Ke,Z);St=Math.sqrt(Be/2)}else{let Se=!1;tt>Number.EPSILON?We>Number.EPSILON&&(Se=!0):tt<-Number.EPSILON?We<-Number.EPSILON&&(Se=!0):Math.sign(Mt)===Math.sign(G)&&(Se=!0),Se?(Ke=-Mt,Z=tt,St=Math.sqrt(O)):(Ke=tt,Z=Mt,St=Math.sqrt(O/2))}return new Pe(Ke/St,Z/St)}const Ae=[];for(let Re=0,Ve=he.length,Ue=Ve-1,Ke=Re+1;Re=0;Re--){const Ve=Re/C,Ue=M*Math.cos(Ve*Math.PI/2),Ke=A*Math.sin(Ve*Math.PI/2)+R;for(let Z=0,St=he.length;Z=0;){const Ke=Ue;let Z=Ue-1;Z<0&&(Z=Re.length-1);for(let St=0,tt=_+C*2;St0)&&M.push(U,L,P),(E!==i-1||m0!=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 dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=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.dispersion=e.dispersion,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}}class jE extends Oa{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new pt(16777215),this.specular=new pt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zu,this.normalScale=new Pe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Hs,this.combine=_m,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class QE extends Oa{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new pt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zu,this.normalScale=new Pe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class JE extends Oa{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zu,this.normalScale=new Pe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class KE extends Oa{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new pt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zu,this.normalScale=new Pe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Hs,this.combine=_m,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class LS extends Oa{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=cE,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 IS extends Oa{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}}class $E extends Oa{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new pt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zu,this.normalScale=new Pe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class eT extends ns{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Xc(o,e){return!o||o.constructor===e?o:typeof e.BYTES_PER_ELEMENT=="number"?new e(o):Array.prototype.slice.call(o)}function tT(o){function e(s,u){return o[s]-o[u]}const t=o.length,i=new Array(t);for(let s=0;s!==t;++s)i[s]=s;return i.sort(e),i}function Bx(o,e,t){const i=o.length,s=new o.constructor(i);for(let u=0,f=0;f!==i;++u){const h=t[u]*e;for(let m=0;m!==e;++m)s[f++]=o[h+m]}return s}function OS(o,e,t,i){let s=1,u=o[0];for(;u!==void 0&&u[i]===void 0;)u=o[s++];if(u===void 0)return;let f=u[i];if(f!==void 0)if(Array.isArray(f))do f=u[i],f!==void 0&&(e.push(u.time),t.push(...f)),u=o[s++];while(u!==void 0);else if(f.toArray!==void 0)do f=u[i],f!==void 0&&(e.push(u.time),f.toArray(t,t.length)),u=o[s++];while(u!==void 0);else do f=u[i],f!==void 0&&(e.push(u.time),t.push(f)),u=o[s++];while(u!==void 0)}function u3(o,e,t,i,s=30){const u=o.clone();u.name=e;const f=[];for(let m=0;m=i)){x.push(g.times[M]);for(let R=0;R<_;++R)b.push(g.values[M*_+R])}}x.length!==0&&(g.times=Xc(x,g.times.constructor),g.values=Xc(b,g.values.constructor),f.push(g))}u.tracks=f;let h=1/0;for(let m=0;mu.tracks[m].times[0]&&(h=u.tracks[m].times[0]);for(let m=0;m=h.times[A]){const E=A*x+_,D=E+x-_;R=h.values.slice(E,D)}else{const E=h.createInterpolant(),D=_,U=x-_;E.evaluate(u),R=E.resultBuffer.slice(D,U)}m==="quaternion"&&new ws().fromArray(R).normalize().conjugate().toArray(R);const C=g.times.length;for(let E=0;E=u)){const h=t[1];e=u)break t}f=i,i=0;break n}break e}for(;i>>1;et;)--f;if(++f,u!==0||f!==s){u>=f&&(f=Math.max(f,1),u=f-1);const h=this.getValueSize();this.times=i.slice(u,f),this.values=this.values.slice(u*h,f*h)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Tt("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,s=this.values,u=i.length;u===0&&(Tt("KeyframeTrack: Track is empty.",this),e=!1);let f=null;for(let h=0;h!==u;h++){const m=i[h];if(typeof m=="number"&&isNaN(m)){Tt("KeyframeTrack: Time is not a valid number.",this,h,m),e=!1;break}if(f!==null&&f>m){Tt("KeyframeTrack: Out of order keys.",this,h,m,f),e=!1;break}f=m}if(s!==void 0&&_E(s))for(let h=0,m=s.length;h!==m;++h){const g=s[h];if(isNaN(g)){Tt("KeyframeTrack: Value is not a valid number.",this,h,g),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),s=this.getInterpolation()===av,u=e.length-1;let f=1;for(let h=1;h0){e[f]=e[u];for(let h=u*i,m=f*i,g=0;g!==i;++g)t[m+g]=t[h+g];++f}return f!==e.length?(this.times=e.slice(0,f),this.values=t.slice(0,f*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,s=new i(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}yr.prototype.ValueTypeName="";yr.prototype.TimeBufferType=Float32Array;yr.prototype.ValueBufferType=Float32Array;yr.prototype.DefaultInterpolation=jv;class ef extends yr{constructor(e,t,i){super(e,t,i)}}ef.prototype.ValueTypeName="bool";ef.prototype.ValueBufferType=Array;ef.prototype.DefaultInterpolation=am;ef.prototype.InterpolantFactoryMethodLinear=void 0;ef.prototype.InterpolantFactoryMethodSmooth=void 0;class PS extends yr{constructor(e,t,i,s){super(e,t,i,s)}}PS.prototype.ValueTypeName="color";class dm extends yr{constructor(e,t,i,s){super(e,t,i,s)}}dm.prototype.ValueTypeName="number";class aT extends Am{constructor(e,t,i,s){super(e,t,i,s)}interpolate_(e,t,i,s){const u=this.resultBuffer,f=this.sampleValues,h=this.valueSize,m=(i-t)/(s-t);let g=e*h;for(let _=g+h;g!==_;g+=4)ws.slerpFlat(u,0,f,g-h,f,g,m);return u}}class wm extends yr{constructor(e,t,i,s){super(e,t,i,s)}InterpolantFactoryMethodLinear(e){return new aT(this.times,this.values,this.getValueSize(),e)}}wm.prototype.ValueTypeName="quaternion";wm.prototype.InterpolantFactoryMethodSmooth=void 0;class tf extends yr{constructor(e,t,i){super(e,t,i)}}tf.prototype.ValueTypeName="string";tf.prototype.ValueBufferType=Array;tf.prototype.DefaultInterpolation=am;tf.prototype.InterpolantFactoryMethodLinear=void 0;tf.prototype.InterpolantFactoryMethodSmooth=void 0;class pm extends yr{constructor(e,t,i,s){super(e,t,i,s)}}pm.prototype.ValueTypeName="vector";class mm{constructor(e="",t=-1,i=[],s=dy){this.name=e,this.tracks=i,this.duration=t,this.blendMode=s,this.uuid=Vs(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,s=1/(e.fps||1);for(let f=0,h=i.length;f!==h;++f)t.push(d3(i[f]).scale(s));const u=new this(e.name,e.duration,t,e.blendMode);return u.uuid=e.uuid,u.userData=JSON.parse(e.userData||"{}"),u}static toJSON(e){const t=[],i=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let u=0,f=i.length;u!==f;++u)t.push(yr.toJSON(i[u]));return s}static CreateFromMorphTargetSequence(e,t,i,s){const u=t.length,f=[];for(let h=0;h1){const x=_[1];let b=s[x];b||(s[x]=b=[]),b.push(g)}}const f=[];for(const h in s)f.push(this.CreateFromMorphTargetSequence(h,s[h],t,i));return f}static parseAnimation(e,t){if(rt("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Tt("AnimationClip: No animation in JSONLoader data."),null;const i=function(x,b,M,A,R){if(M.length!==0){const C=[],E=[];OS(M,C,E,A),C.length!==0&&R.push(new x(b,C,E))}},s=[],u=e.name||"default",f=e.fps||30,h=e.blendMode;let m=e.length||-1;const g=e.hierarchy||[];for(let x=0;x{t&&t(u),this.manager.itemEnd(e)},0),u;if(El[e]!==void 0){El[e].push({onLoad:t,onProgress:i,onError:s});return}El[e]=[],El[e].push({onLoad:t,onProgress:i,onError:s});const f=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),h=this.mimeType,m=this.responseType;fetch(f).then(g=>{if(g.status===200||g.status===0){if(g.status===0&&rt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||g.body===void 0||g.body.getReader===void 0)return g;const _=El[e],x=g.body.getReader(),b=g.headers.get("X-File-Size")||g.headers.get("Content-Length"),M=b?parseInt(b):0,A=M!==0;let R=0;const C=new ReadableStream({start(E){D();function D(){x.read().then(({done:U,value:L})=>{if(U)E.close();else{R+=L.byteLength;const B=new ProgressEvent("progress",{lengthComputable:A,loaded:R,total:M});for(let P=0,H=_.length;P{E.error(U)})}}});return new Response(C)}else throw new p3(`fetch for "${g.url}" responded with ${g.status}: ${g.statusText}`,g)}).then(g=>{switch(m){case"arraybuffer":return g.arrayBuffer();case"blob":return g.blob();case"document":return g.text().then(_=>new DOMParser().parseFromString(_,h));case"json":return g.json();default:if(h==="")return g.text();{const x=/charset="?([^;"\s]*)"?/i.exec(h),b=x&&x[1]?x[1].toLowerCase():void 0,M=new TextDecoder(b);return g.arrayBuffer().then(A=>M.decode(A))}}}).then(g=>{Lo.add(`file:${e}`,g);const _=El[e];delete El[e];for(let x=0,b=_.length;x{const _=El[e];if(_===void 0)throw this.manager.itemError(e),g;delete El[e];for(let x=0,b=_.length;x{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class m3 extends Cs{constructor(e){super(e)}load(e,t,i,s){const u=this,f=new Rl(this.manager);f.setPath(this.path),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(h){try{t(u.parse(JSON.parse(h)))}catch(m){s?s(m):Tt(m),u.manager.itemError(e)}},i,s)}parse(e){const t=[];for(let i=0;i0:s.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const u in e.uniforms){const f=e.uniforms[u];switch(s.uniforms[u]={},f.type){case"t":s.uniforms[u].value=i(f.value);break;case"c":s.uniforms[u].value=new pt().setHex(f.value);break;case"v2":s.uniforms[u].value=new Pe().fromArray(f.value);break;case"v3":s.uniforms[u].value=new Y().fromArray(f.value);break;case"v4":s.uniforms[u].value=new Wn().fromArray(f.value);break;case"m3":s.uniforms[u].value=new Qt().fromArray(f.value);break;case"m4":s.uniforms[u].value=new kt().fromArray(f.value);break;default:s.uniforms[u].value=f.value}}if(e.defines!==void 0&&(s.defines=e.defines),e.vertexShader!==void 0&&(s.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(s.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(s.glslVersion=e.glslVersion),e.extensions!==void 0)for(const u in e.extensions)s.extensions[u]=e.extensions[u];if(e.lights!==void 0&&(s.lights=e.lights),e.clipping!==void 0&&(s.clipping=e.clipping),e.size!==void 0&&(s.size=e.size),e.sizeAttenuation!==void 0&&(s.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(s.map=i(e.map)),e.matcap!==void 0&&(s.matcap=i(e.matcap)),e.alphaMap!==void 0&&(s.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(s.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(s.bumpScale=e.bumpScale),e.normalMap!==void 0&&(s.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(s.normalMapType=e.normalMapType),e.normalScale!==void 0){let u=e.normalScale;Array.isArray(u)===!1&&(u=[u,u]),s.normalScale=new Pe().fromArray(u)}return e.displacementMap!==void 0&&(s.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(s.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(s.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(s.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(s.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(s.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(s.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(s.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(s.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(s.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(s.envMap=i(e.envMap)),e.envMapRotation!==void 0&&s.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(s.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(s.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(s.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(s.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(s.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(s.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(s.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(s.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(s.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(s.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(s.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(s.clearcoatNormalScale=new Pe().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(s.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(s.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(s.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(s.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(s.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(s.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(s.sheenRoughnessMap=i(e.sheenRoughnessMap)),s}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return By.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:ZE,SpriteMaterial:xS,RawShaderMaterial:DS,ShaderMaterial:vr,PointsMaterial:bS,MeshPhysicalMaterial:US,MeshStandardMaterial:NS,MeshPhongMaterial:jE,MeshToonMaterial:QE,MeshNormalMaterial:JE,MeshLambertMaterial:KE,MeshDepthMaterial:LS,MeshDistanceMaterial:IS,MeshBasicMaterial:Pu,MeshMatcapMaterial:$E,LineDashedMaterial:eT,LineBasicMaterial:ns,Material:Oa};return new t[e]}}class Fx{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class dT extends Yt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class pT extends Cs{constructor(e){super(e)}load(e,t,i,s){const u=this,f=new Rl(u.manager);f.setPath(u.path),f.setRequestHeader(u.requestHeader),f.setWithCredentials(u.withCredentials),f.load(e,function(h){try{t(u.parse(JSON.parse(h)))}catch(m){s?s(m):Tt(m),u.manager.itemError(e)}},i,s)}parse(e){const t={},i={};function s(M,A){if(t[A]!==void 0)return t[A];const C=M.interleavedBuffers[A],E=u(M,C.buffer),D=Ih(C.type,E),U=new Sy(D,C.stride);return U.uuid=C.uuid,t[A]=U,U}function u(M,A){if(i[A]!==void 0)return i[A];const C=M.arrayBuffers[A],E=new Uint32Array(C).buffer;return i[A]=E,E}const f=e.isInstancedBufferGeometry?new dT:new Yt,h=e.data.index;if(h!==void 0){const M=Ih(h.type,h.array);f.setIndex(new Hn(M,1))}const m=e.data.attributes;for(const M in m){const A=m[M];let R;if(A.isInterleavedBufferAttribute){const C=s(e.data,A.data);R=new Qc(C,A.itemSize,A.offset,A.normalized)}else{const C=Ih(A.type,A.array),E=A.isInstancedBufferAttribute?Wh:Hn;R=new E(C,A.itemSize,A.normalized)}A.name!==void 0&&(R.name=A.name),A.usage!==void 0&&R.setUsage(A.usage),f.setAttribute(M,R)}const g=e.data.morphAttributes;if(g)for(const M in g){const A=g[M],R=[];for(let C=0,E=A.length;C0){const m=new BS(t);u=new gm(m),u.setCrossOrigin(this.crossOrigin);for(let g=0,_=e.length;g<_;g++){const x=e[g],b=x.url;if(Array.isArray(b)){const M=[];for(let A=0,R=b.length;A0){s=new gm(this.manager),s.setCrossOrigin(this.crossOrigin);for(let f=0,h=e.length;f{let E=null,D=null;return C.boundingBox!==void 0&&(E=new Ia().fromJSON(C.boundingBox)),C.boundingSphere!==void 0&&(D=new ga().fromJSON(C.boundingSphere)),{...C,boundingBox:E,boundingSphere:D}}),f._instanceInfo=e.instanceInfo,f._availableInstanceIds=e._availableInstanceIds,f._availableGeometryIds=e._availableGeometryIds,f._nextIndexStart=e.nextIndexStart,f._nextVertexStart=e.nextVertexStart,f._geometryCount=e.geometryCount,f._maxInstanceCount=e.maxInstanceCount,f._maxVertexCount=e.maxVertexCount,f._maxIndexCount=e.maxIndexCount,f._geometryInitialized=e.geometryInitialized,f._matricesTexture=g(e.matricesTexture.uuid),f._indirectTexture=g(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(f._colorsTexture=g(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(f.boundingSphere=new ga().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(f.boundingBox=new Ia().fromJSON(e.boundingBox));break;case"LOD":f=new RE;break;case"Line":f=new Ou(h(e.geometry),m(e.material));break;case"LineLoop":f=new LE(h(e.geometry),m(e.material));break;case"LineSegments":f=new Fo(h(e.geometry),m(e.material));break;case"PointCloud":case"Points":f=new IE(h(e.geometry),m(e.material));break;case"Sprite":f=new CE(m(e.material));break;case"Group":f=new Oh;break;case"Bone":f=new SS;break;default:f=new An}if(f.uuid=e.uuid,e.name!==void 0&&(f.name=e.name),e.matrix!==void 0?(f.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(f.matrixAutoUpdate=e.matrixAutoUpdate),f.matrixAutoUpdate&&f.matrix.decompose(f.position,f.quaternion,f.scale)):(e.position!==void 0&&f.position.fromArray(e.position),e.rotation!==void 0&&f.rotation.fromArray(e.rotation),e.quaternion!==void 0&&f.quaternion.fromArray(e.quaternion),e.scale!==void 0&&f.scale.fromArray(e.scale)),e.up!==void 0&&f.up.fromArray(e.up),e.castShadow!==void 0&&(f.castShadow=e.castShadow),e.receiveShadow!==void 0&&(f.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(f.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(f.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(f.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(f.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&f.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(f.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(f.visible=e.visible),e.frustumCulled!==void 0&&(f.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(f.renderOrder=e.renderOrder),e.userData!==void 0&&(f.userData=e.userData),e.layers!==void 0&&(f.layers.mask=e.layers),e.children!==void 0){const b=e.children;for(let M=0;M"u"&&rt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&rt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const u=this,f=Lo.get(`image-bitmap:${e}`);if(f!==void 0){if(u.manager.itemStart(e),f.then){f.then(g=>{if(rx.has(f)===!0)s&&s(rx.get(f)),u.manager.itemError(e),u.manager.itemEnd(e);else return t&&t(g),u.manager.itemEnd(e),g});return}return setTimeout(function(){t&&t(f),u.manager.itemEnd(e)},0),f}const h={};h.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",h.headers=this.requestHeader,h.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const m=fetch(e,h).then(function(g){return g.blob()}).then(function(g){return createImageBitmap(g,Object.assign(u.options,{colorSpaceConversion:"none"}))}).then(function(g){return Lo.add(`image-bitmap:${e}`,g),t&&t(g),u.manager.itemEnd(e),g}).catch(function(g){s&&s(g),rx.set(m,g),Lo.remove(`image-bitmap:${e}`),u.manager.itemError(e),u.manager.itemEnd(e)});Lo.add(`image-bitmap:${e}`,m),u.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let Y0;class kS{static getContext(){return Y0===void 0&&(Y0=new(window.AudioContext||window.webkitAudioContext)),Y0}static setContext(e){Y0=e}}class A3 extends Cs{constructor(e){super(e)}load(e,t,i,s){const u=this,f=new Rl(this.manager);f.setResponseType("arraybuffer"),f.setPath(this.path),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(m){try{const g=m.slice(0);kS.getContext().decodeAudioData(g,function(x){t(x)}).catch(h)}catch(g){h(g)}},i,s);function h(m){s?s(m):Tt(m),u.manager.itemError(e)}}}const zM=new kt,PM=new kt,Nc=new kt;class w3{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new aa,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new aa,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Nc.copy(e.projectionMatrix);const s=t.eyeSep/2,u=s*t.near/t.focus,f=t.near*Math.tan(qc*t.fov*.5)/t.zoom;let h,m;PM.elements[12]=-s,zM.elements[12]=s,h=-f*t.aspect+u,m=f*t.aspect+u,Nc.elements[0]=2*t.near/(m-h),Nc.elements[8]=(m+h)/(m-h),this.cameraL.projectionMatrix.copy(Nc),h=-f*t.aspect-u,m=f*t.aspect-u,Nc.elements[0]=2*t.near/(m-h),Nc.elements[8]=(m+h)/(m-h),this.cameraR.projectionMatrix.copy(Nc)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(PM),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(zM)}}class mT extends aa{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class HS{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const Uc=new Y,ox=new ws,C3=new Y,Lc=new Y,Ic=new Y;class R3 extends An{constructor(){super(),this.type="AudioListener",this.context=kS.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new HS}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Uc,ox,C3),Lc.set(0,0,-1).applyQuaternion(ox),Ic.set(0,1,0).applyQuaternion(ox),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Uc.x,i),t.positionY.linearRampToValueAtTime(Uc.y,i),t.positionZ.linearRampToValueAtTime(Uc.z,i),t.forwardX.linearRampToValueAtTime(Lc.x,i),t.forwardY.linearRampToValueAtTime(Lc.y,i),t.forwardZ.linearRampToValueAtTime(Lc.z,i),t.upX.linearRampToValueAtTime(Ic.x,i),t.upY.linearRampToValueAtTime(Ic.y,i),t.upZ.linearRampToValueAtTime(Ic.z,i)}else t.setPosition(Uc.x,Uc.y,Uc.z),t.setOrientation(Lc.x,Lc.y,Lc.z,Ic.x,Ic.y,Ic.z)}}class gT extends An{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){rt("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){rt("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){rt("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){rt("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,s,this._addIndex*t,1,t);for(let m=t,g=t+t;m!==g;++m)if(i[m]!==i[m+t]){h.setValue(i,s);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,s=i*this._origIndex;e.getValue(t,s);for(let u=i,f=s;u!==f;++u)t[u]=t[s+u%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let f=0;f!==u;++f)e[t+f]=e[i+f]}_slerp(e,t,i,s){ws.slerpFlat(e,t,e,t,e,i,s)}_slerpAdditive(e,t,i,s,u){const f=this._workIndex*u;ws.multiplyQuaternionsFlat(e,f,e,t,e,i),ws.slerpFlat(e,t,e,t,e,f,s)}_lerp(e,t,i,s,u){const f=1-s;for(let h=0;h!==u;++h){const m=t+h;e[m]=e[m]*f+e[i+h]*s}}_lerpAdditive(e,t,i,s,u){for(let f=0;f!==u;++f){const h=t+f;e[h]=e[h]+e[i+f]*s}}}const GS="\\[\\]\\.:\\/",L3=new RegExp("["+GS+"]","g"),XS="[^"+GS+"]",I3="[^"+GS.replace("\\.","")+"]",O3=/((?:WC+[\/:])*)/.source.replace("WC",XS),z3=/(WCOD+)?/.source.replace("WCOD",I3),P3=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",XS),B3=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",XS),F3=new RegExp("^"+O3+z3+P3+B3+"$"),V3=["material","materials","bones","map"];class k3{constructor(e,t,i){const s=i||Tn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,s=this._bindings[i];s!==void 0&&s.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let s=this._targetGroup.nCachedObjects_,u=i.length;s!==u;++s)i[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Tn{constructor(e,t,i){this.path=t,this.parsedPath=i||Tn.parseTrackName(t),this.node=Tn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Tn.Composite(e,t,i):new Tn(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(L3,"")}static parseTrackName(e){const t=F3.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=i.nodeName&&i.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const u=i.nodeName.substring(s+1);V3.indexOf(u)!==-1&&(i.nodeName=i.nodeName.substring(0,s),i.objectName=u)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(u){for(let f=0;f=u){const x=u++,b=e[x];t[b.uuid]=_,e[_]=b,t[g]=x,e[x]=m;for(let M=0,A=s;M!==A;++M){const R=i[M],C=R[x],E=R[_];R[_]=C,R[x]=E}}}this.nCachedObjects_=u}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,s=i.length;let u=this.nCachedObjects_,f=e.length;for(let h=0,m=arguments.length;h!==m;++h){const g=arguments[h],_=g.uuid,x=t[_];if(x!==void 0)if(delete t[_],x0&&(t[M.uuid]=x),e[x]=M,e.pop();for(let A=0,R=s;A!==R;++A){const C=i[A];C[x]=C[b],C.pop()}}}this.nCachedObjects_=u}subscribe_(e,t){const i=this._bindingsIndicesByPath;let s=i[e];const u=this._bindings;if(s!==void 0)return u[s];const f=this._paths,h=this._parsedPaths,m=this._objects,g=m.length,_=this.nCachedObjects_,x=new Array(g);s=u.length,i[e]=s,f.push(e),h.push(t),u.push(x);for(let b=_,M=m.length;b!==M;++b){const A=m[b];x[b]=new Tn(A,e,t)}return x}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const s=this._paths,u=this._parsedPaths,f=this._bindings,h=f.length-1,m=f[h],g=e[h];t[g]=i,f[i]=m,f.pop(),u[i]=u[h],u.pop(),s[i]=s[h],s.pop()}}}class yT{constructor(e,t,i=null,s=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=s;const u=t.tracks,f=u.length,h=new Array(f),m={endingStart:Hc,endingEnd:Hc};for(let g=0;g!==f;++g){const _=u[g].createInterpolant(null);h[g]=_,_.settings=m}this._interpolantSettings=m,this._interpolants=h,this._propertyBindings=new Array(f),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=lE,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i=!1){if(e.fadeOut(t),this.fadeIn(t),i===!0){const s=this._clip.duration,u=e._clip.duration,f=u/s,h=s/u;e.warp(1,f,t),this.warp(h,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const s=this._mixer,u=s.time,f=this.timeScale;let h=this._timeScaleInterpolant;h===null&&(h=s._lendControlInterpolant(),this._timeScaleInterpolant=h);const m=h.parameterPositions,g=h.sampleValues;return m[0]=u,m[1]=u+i,g[0]=e/f,g[1]=t/f,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,s){if(!this.enabled){this._updateWeight(e);return}const u=this._startTime;if(u!==null){const m=(e-u)*i;m<0||i===0?t=0:(this._startTime=null,t=i*m)}t*=this._updateTimeScale(e);const f=this._updateTime(t),h=this._updateWeight(e);if(h>0){const m=this._interpolants,g=this._propertyBindings;switch(this.blendMode){case dS:for(let _=0,x=m.length;_!==x;++_)m[_].evaluate(f),g[_].accumulateAdditive(h);break;case dy:default:for(let _=0,x=m.length;_!==x;++_)m[_].evaluate(f),g[_].accumulate(s,h)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const s=i.evaluate(e)[0];t*=s,e>i.parameterPositions[1]&&(this.stopFading(),s===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const s=i.evaluate(e)[0];t*=s,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let s=this.time+e,u=this._loopCount;const f=i===uE;if(e===0)return u===-1?s:f&&(u&1)===1?t-s:s;if(i===oE){u===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(u===-1&&(e>=0?(u=0,this._setEndings(!0,this.repetitions===0,f)):this._setEndings(this.repetitions===0,!0,f)),s>=t||s<0){const h=Math.floor(s/t);s-=t*h,u+=Math.abs(h);const m=this.repetitions-u;if(m<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=e>0?t:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(m===1){const g=e<0;this._setEndings(g,!g,f)}else this._setEndings(!1,!1,f);this._loopCount=u,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:h})}}else this.time=s;if(f&&(u&1)===1)return t-s}return s}_setEndings(e,t,i){const s=this._interpolantSettings;i?(s.endingStart=Gc,s.endingEnd=Gc):(e?s.endingStart=this.zeroSlopeAtStart?Gc:Hc:s.endingStart=sm,t?s.endingEnd=this.zeroSlopeAtEnd?Gc:Hc:s.endingEnd=sm)}_scheduleFading(e,t,i){const s=this._mixer,u=s.time;let f=this._weightInterpolant;f===null&&(f=s._lendControlInterpolant(),this._weightInterpolant=f);const h=f.parameterPositions,m=f.sampleValues;return h[0]=u,m[0]=t,h[1]=u+e,m[1]=i,this}}const G3=new Float32Array(1);class X3 extends Bo{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,s=e._clip.tracks,u=s.length,f=e._propertyBindings,h=e._interpolants,m=i.uuid,g=this._bindingsByRootAndName;let _=g[m];_===void 0&&(_={},g[m]=_);for(let x=0;x!==u;++x){const b=s[x],M=b.name;let A=_[M];if(A!==void 0)++A.referenceCount,f[x]=A;else{if(A=f[x],A!==void 0){A._cacheIndex===null&&(++A.referenceCount,this._addInactiveBinding(A,m,M));continue}const R=t&&t._propertyBindings[x].binding.parsedPath;A=new vT(Tn.create(i,M,R),b.ValueTypeName,b.getValueSize()),++A.referenceCount,this._addInactiveBinding(A,m,M),f[x]=A}h[x].resultBuffer=A.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,s=e._clip.uuid,u=this._actionsByClip[s];this._bindAction(e,u&&u.knownActions[0]),this._addInactiveAction(e,s,i)}const t=e._propertyBindings;for(let i=0,s=t.length;i!==s;++i){const u=t[i];u.useCount++===0&&(this._lendBinding(u),u.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,s=t.length;i!==s;++i){const u=t[i];--u.useCount===0&&(u.restoreOriginalState(),this._takeBackBinding(u))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,s=this.time+=e,u=Math.sign(e),f=this._accuIndex^=1;for(let g=0;g!==i;++g)t[g]._update(s,e,u,f);const h=this._bindings,m=this._nActiveBindings;for(let g=0;g!==m;++g)h[g].apply(f);return this}setTime(e){this.time=0;for(let t=0;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}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}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))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kM).distanceTo(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}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 HM=new Y,Z0=new Y,wh=new Y,Ch=new Y,lx=new Y,tR=new Y,nR=new Y;class iR{constructor(e=new Y,t=new Y){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){HM.subVectors(e,this.start),Z0.subVectors(this.end,this.start);const i=Z0.dot(Z0);let u=Z0.dot(HM)/i;return t&&(u=Ft(u,0,1)),u}closestPointToPoint(e,t,i){const s=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(s).add(this.start)}distanceSqToLine3(e,t=tR,i=nR){const s=10000000000000001e-32;let u,f;const h=this.start,m=e.start,g=this.end,_=e.end;wh.subVectors(g,h),Ch.subVectors(_,m),lx.subVectors(h,m);const x=wh.dot(wh),b=Ch.dot(Ch),M=Ch.dot(lx);if(x<=s&&b<=s)return t.copy(h),i.copy(m),t.sub(i),t.dot(t);if(x<=s)u=0,f=M/b,f=Ft(f,0,1);else{const A=wh.dot(lx);if(b<=s)f=0,u=Ft(-A/x,0,1);else{const R=wh.dot(Ch),C=x*b-R*R;C!==0?u=Ft((R*M-A*b)/C,0,1):u=0,f=(R*u+M)/b,f<0?(f=0,u=Ft(-A/x,0,1)):f>1&&(f=1,u=Ft((R-A)/x,0,1))}}return t.copy(h).add(wh.multiplyScalar(u)),i.copy(m).add(Ch.multiplyScalar(f)),t.sub(i),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const GM=new Y;class aR extends An{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new Yt,s=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let f=0,h=1,m=32;f1)for(let x=0;x.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{ZM.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(ZM,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class vR extends Fo{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],s=new Yt;s.setAttribute("position",new yt(t,3)),s.setAttribute("color",new yt(i,3));const u=new ns({vertexColors:!0,toneMapped:!1});super(s,u),this.type="AxesHelper"}setColors(e,t,i){const s=new pt,u=this.geometry.attributes.color.array;return s.set(e),s.toArray(u,0),s.toArray(u,3),s.set(t),s.toArray(u,6),s.toArray(u,9),s.set(i),s.toArray(u,12),s.toArray(u,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class yR{constructor(){this.type="ShapePath",this.color=new pt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new $v,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,s){return this.currentPath.quadraticCurveTo(e,t,i,s),this}bezierCurveTo(e,t,i,s,u,f){return this.currentPath.bezierCurveTo(e,t,i,s,u,f),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(E){const D=[];for(let U=0,L=E.length;UNumber.EPSILON){if(z<0&&(H=D[P],I=-I,W=D[B],z=-z),E.yW.y)continue;if(E.y===H.y){if(E.x===H.x)return!0}else{const j=z*(E.x-H.x)-I*(E.y-H.y);if(j===0)return!0;if(j<0)continue;L=!L}}else{if(E.y!==H.y)continue;if(W.x<=E.x&&E.x<=H.x||H.x<=E.x&&E.x<=W.x)return!0}}return L}const s=Wr.isClockWise,u=this.subPaths;if(u.length===0)return[];let f,h,m;const g=[];if(u.length===1)return h=u[0],m=new Yc,m.curves=h.curves,g.push(m),g;let _=!s(u[0].getPoints());_=e?!_:_;const x=[],b=[];let M=[],A=0,R;b[A]=void 0,M[A]=[];for(let E=0,D=u.length;E1){let E=!1,D=0;for(let U=0,L=b.length;U0&&E===!1&&(M=x)}let C;for(let E=0,D=b.length;Ee?(o.repeat.x=1,o.repeat.y=t/e,o.offset.x=0,o.offset.y=(1-o.repeat.y)/2):(o.repeat.x=e/t,o.repeat.y=1,o.offset.x=(1-o.repeat.x)/2,o.offset.y=0),o}function SR(o,e){const t=o.image&&o.image.width?o.image.width/o.image.height:1;return t>e?(o.repeat.x=e/t,o.repeat.y=1,o.offset.x=(1-o.repeat.x)/2,o.offset.y=0):(o.repeat.x=1,o.repeat.y=t/e,o.offset.x=0,o.offset.y=(1-o.repeat.y)/2),o}function bR(o){return o.repeat.x=1,o.repeat.y=1,o.offset.x=0,o.offset.y=0,o}function kx(o,e,t,i){const s=MR(i);switch(t){case fS:return o*e;case cy:return o*e/s.components*s.byteLength;case xm:return o*e/s.components*s.byteLength;case jc:return o*e*2/s.components*s.byteLength;case fy:return o*e*2/s.components*s.byteLength;case hS:return o*e*3/s.components*s.byteLength;case La:return o*e*4/s.components*s.byteLength;case hy:return o*e*4/s.components*s.byteLength;case qp:case Yp:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*8;case Zp:case jp:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*16;case yv:case xv:return Math.max(o,16)*Math.max(e,8)/4;case vv:case _v:return Math.max(o,8)*Math.max(e,8)/2;case Sv:case bv:case Ev:case Tv:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*8;case Mv:case Av:case wv:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*16;case Cv:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*16;case Rv:return Math.floor((o+4)/5)*Math.floor((e+3)/4)*16;case Dv:return Math.floor((o+4)/5)*Math.floor((e+4)/5)*16;case Nv:return Math.floor((o+5)/6)*Math.floor((e+4)/5)*16;case Uv:return Math.floor((o+5)/6)*Math.floor((e+5)/6)*16;case Lv:return Math.floor((o+7)/8)*Math.floor((e+4)/5)*16;case Iv:return Math.floor((o+7)/8)*Math.floor((e+5)/6)*16;case Ov:return Math.floor((o+7)/8)*Math.floor((e+7)/8)*16;case zv:return Math.floor((o+9)/10)*Math.floor((e+4)/5)*16;case Pv:return Math.floor((o+9)/10)*Math.floor((e+5)/6)*16;case Bv:return Math.floor((o+9)/10)*Math.floor((e+7)/8)*16;case Fv:return Math.floor((o+9)/10)*Math.floor((e+9)/10)*16;case Vv:return Math.floor((o+11)/12)*Math.floor((e+9)/10)*16;case kv:return Math.floor((o+11)/12)*Math.floor((e+11)/12)*16;case Hv:case Gv:case Xv:return Math.ceil(o/4)*Math.ceil(e/4)*16;case Wv:case qv:return Math.ceil(o/4)*Math.ceil(e/4)*8;case Yv:case Zv:return Math.ceil(o/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function MR(o){switch(o){case Ka:case oS:return{byteLength:1,components:1};case Bh:case lS:case zo:return{byteLength:2,components:1};case ly:case uy:return{byteLength:2,components:4};case gr:case oy:case es:return{byteLength:4,components:1};case uS:case cS:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${o}.`)}class ER{static contain(e,t){return xR(e,t)}static cover(e,t){return SR(e,t)}static fill(e){return bR(e)}static getByteLength(e,t,i,s){return kx(e,t,i,s)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ay}}));typeof window<"u"&&(window.__THREE__?rt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ay);function ST(){let o=null,e=!1,t=null,i=null;function s(u,f){t(u,f),i=o.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(i=o.requestAnimationFrame(s),e=!0)},stop:function(){o.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(u){t=u},setContext:function(u){o=u}}}function TR(o){const e=new WeakMap;function t(h,m){const g=h.array,_=h.usage,x=g.byteLength,b=o.createBuffer();o.bindBuffer(m,b),o.bufferData(m,g,_),h.onUploadCallback();let M;if(g instanceof Float32Array)M=o.FLOAT;else if(typeof Float16Array<"u"&&g instanceof Float16Array)M=o.HALF_FLOAT;else if(g instanceof Uint16Array)h.isFloat16BufferAttribute?M=o.HALF_FLOAT:M=o.UNSIGNED_SHORT;else if(g instanceof Int16Array)M=o.SHORT;else if(g instanceof Uint32Array)M=o.UNSIGNED_INT;else if(g instanceof Int32Array)M=o.INT;else if(g instanceof Int8Array)M=o.BYTE;else if(g instanceof Uint8Array)M=o.UNSIGNED_BYTE;else if(g instanceof Uint8ClampedArray)M=o.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+g);return{buffer:b,type:M,bytesPerElement:g.BYTES_PER_ELEMENT,version:h.version,size:x}}function i(h,m,g){const _=m.array,x=m.updateRanges;if(o.bindBuffer(g,h),x.length===0)o.bufferSubData(g,0,_);else{x.sort((M,A)=>M.start-A.start);let b=0;for(let M=1;M 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; float clipOpacity = 1.0; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); if ( clipOpacity == 0.0 ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES float unionClipOpacity = 1.0; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); } #pragma unroll_loop_end clipOpacity *= 1.0 - unionClipOpacity; #endif diffuseColor.a *= clipOpacity; if ( diffuseColor.a == 0.0 ) discard; #else #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif #endif`,HR=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,GR=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,XR=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,WR=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,qR=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,YR=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,ZR=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif #ifdef USE_BATCHING_COLOR vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); vColor.xyz *= batchingColor.xyz; #endif`,jR=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 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 ); } 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`,QR=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,JR=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif #ifdef USE_BATCHING mat3 bm = mat3( batchingMatrix ); transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); transformedNormal = bm * transformedNormal; #ifdef USE_TANGENT transformedTangent = bm * transformedTangent; #endif #endif #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); transformedNormal = im * transformedNormal; #ifdef USE_TANGENT transformedTangent = im * transformedTangent; #endif #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,KR=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,$R=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,eD=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,tD=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,nD="gl_FragColor = linearToOutputTexel( gl_FragColor );",iD=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); } vec4 sRGBTransferOETF( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`,aD=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,sD=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,rD=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,oD=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,lD=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,uD=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,cD=`#ifdef USE_FOG varying float vFogDepth; #endif`,fD=`#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`,hD=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,dD=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else 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 }`,pD=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,mD=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,gD=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,vD=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; #endif vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = pointLight.position - geometryPosition; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = spotLight.position - geometryPosition; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`,yD=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,_D=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,xD=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,SD=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,bD=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,MD=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb; material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); material.metalness = metalnessFactor; vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = vec3( 0.04 ); material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } 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`,ED=`uniform sampler2D dfgLUT; struct PhysicalMaterial { vec3 diffuseColor; vec3 diffuseContribution; vec3 specularColor; vec3 specularColorBlended; float roughness; float metalness; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; vec3 iridescenceFresnelDielectric; vec3 iridescenceFresnelMetallic; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); float v = 0.5 / ( gv + gl ); return v; } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColorBlended; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float rInv = 1.0 / ( roughness + 0.1 ); float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; float DG = exp( a * dotNV + b ); return saturate( DG ); } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif float dotNV = saturate( dot( normal, viewDir ) ); vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; float Ess_V = dfgV.x + dfgV.y; float Ess_L = dfgL.x + dfgL.y; float Ems_V = 1.0 - Ess_V; float Ems_L = 1.0 - Ess_L; vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); float compensationFactor = Ems_V * Ems_L; vec3 multiScatter = Fms * compensationFactor; return singleScatter + multiScatter; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); irradiance *= sheenEnergyComp; #endif reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); #ifdef USE_SHEEN float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; diffuse *= sheenEnergyComp; #endif reflectedLight.indirectDiffuse += diffuse; } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; #endif vec3 singleScatteringDielectric = vec3( 0.0 ); vec3 multiScatteringDielectric = vec3( 0.0 ); vec3 singleScatteringMetallic = vec3( 0.0 ); vec3 multiScatteringMetallic = vec3( 0.0 ); #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); #endif vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; vec3 indirectSpecular = radiance * singleScattering; indirectSpecular += multiScattering * cosineWeightedIrradiance; vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; #ifdef USE_SHEEN float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; indirectSpecular *= sheenEnergyComp; indirectDiffuse *= sheenEnergyComp; #endif reflectedLight.indirectSpecular += indirectSpecular; reflectedLight.indirectDiffuse += indirectDiffuse; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #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 ); }`,TD=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,AD=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`,wD=`#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`,CD=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,RD=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,DD=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,ND=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,UD=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,LD=`#ifdef USE_MAP uniform sampler2D map; #endif`,ID=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,OD=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,zD=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,PD=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,BD=`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } #endif`,FD=`#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,VD=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #endif`,kD=`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; #endif uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #endif`,HD=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #endif`,GD=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal *= faceDirection; #endif #endif #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) #ifdef USE_TANGENT mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn = getTangentFrame( - vViewPosition, normal, #if defined( USE_NORMALMAP ) vNormalMapUv #elif defined( USE_CLEARCOAT_NORMALMAP ) vClearcoatNormalMapUv #else vUv #endif ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn[0] *= faceDirection; tbn[1] *= faceDirection; #endif #endif #ifdef USE_CLEARCOAT_NORMALMAP #ifdef USE_TANGENT mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 nonPerturbedNormal = normal;`,XD=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,WD=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,qD=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,YD=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,ZD=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef USE_NORMALMAP_OBJECTSPACE uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( uv.st ); vec2 st1 = dFdy( uv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } #endif`,jD=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,QD=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,JD=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif`,KD=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,$D=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,eN=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; const float Inv255 = 1. / 255.; const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); vec4 packDepthToRGBA( const in float v ) { if( v <= 0.0 ) return vec4( 0., 0., 0., 0. ); if( v >= 1.0 ) return vec4( 1., 1., 1., 1. ); float vuf; float af = modf( v * PackFactors.a, vuf ); float bf = modf( vuf * ShiftRight8, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); } vec3 packDepthToRGB( const in float v ) { if( v <= 0.0 ) return vec3( 0., 0., 0. ); if( v >= 1.0 ) return vec3( 1., 1., 1. ); float vuf; float bf = modf( v * PackFactors.b, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec3( vuf * Inv255, gf * PackUpscale, bf ); } vec2 packDepthToRG( const in float v ) { if( v <= 0.0 ) return vec2( 0., 0. ); if( v >= 1.0 ) return vec2( 1., 1. ); float vuf; float gf = modf( v * 256., vuf ); return vec2( vuf * Inv255, gf ); } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors4 ); } float unpackRGBToDepth( const in vec3 v ) { return dot( v, UnpackFactors3 ); } float unpackRGToDepth( const in vec2 v ) { return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; } vec4 pack2HalfToRGBA( const in vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( const in vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { return depth * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * depth - far ); }`,tN=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,nN=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,iN=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,aN=`#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`,sN=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,rN=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,oN=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; #else uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; #endif varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; #else uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; #endif struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; #elif defined( SHADOWMAP_TYPE_BASIC ) uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; #endif varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #if defined( SHADOWMAP_TYPE_PCF ) float interleavedGradientNoise( vec2 position ) { return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); } vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { const float goldenAngle = 2.399963229728653; float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); float theta = float( sampleIndex ) * goldenAngle + phi; return vec2( cos( theta ), sin( theta ) ) * r; } #endif #if defined( SHADOWMAP_TYPE_PCF ) float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float radius = shadowRadius * texelSize.x; float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718; shadow = ( texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) ) * 0.2; } return mix( 1.0, shadow, shadowIntensity ); } #elif defined( SHADOWMAP_TYPE_VSM ) float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; float mean = distribution.x; float variance = distribution.y * distribution.y; #ifdef USE_REVERSED_DEPTH_BUFFER float hard_shadow = step( mean, shadowCoord.z ); #else float hard_shadow = step( shadowCoord.z, mean ); #endif if ( hard_shadow == 1.0 ) { shadow = 1.0; } else { variance = max( variance, 0.0000001 ); float d = shadowCoord.z - mean; float p_max = variance / ( variance + d * d ); p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); shadow = max( hard_shadow, p_max ); } } return mix( 1.0, shadow, shadowIntensity ); } #else float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { float depth = texture2D( shadowMap, shadowCoord.xy ).r; #ifdef USE_REVERSED_DEPTH_BUFFER shadow = step( depth, shadowCoord.z ); #else shadow = step( shadowCoord.z, depth ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; vec3 bd3D = normalize( lightToPosition ); vec3 absVec = abs( lightToPosition ); float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; float texelSize = shadowRadius / shadowMapSize.x; vec3 absDir = abs( bd3D ); vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); tangent = normalize( cross( bd3D, tangent ) ); vec3 bitangent = cross( bd3D, tangent ); float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718; shadow = ( texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) ) ) * 0.2; } return mix( 1.0, shadow, shadowIntensity ); } #elif defined( SHADOWMAP_TYPE_BASIC ) float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; vec3 bd3D = normalize( lightToPosition ); vec3 absVec = abs( lightToPosition ); float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; float depth = textureCube( shadowMap, bd3D ).r; #ifdef USE_REVERSED_DEPTH_BUFFER shadow = step( depth, dp ); #else shadow = step( dp, depth ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif #endif #endif`,lN=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,uN=`#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 #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,cN=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,fN=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,hN=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; mat4 getBoneMatrix( const in float i ) { int size = textureSize( boneTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } #endif`,dN=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,pN=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,mN=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,gN=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,vN=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,yN=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return saturate( toneMappingExposure * color ); } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 CineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( vec3( 1.6605, - 0.1246, - 0.0182 ), vec3( - 0.5876, 1.1329, - 0.1006 ), vec3( - 0.0728, - 0.0083, 1.1187 ) ); const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( vec3( 0.6274, 0.0691, 0.0164 ), vec3( 0.3293, 0.9195, 0.0880 ), vec3( 0.0433, 0.0113, 0.8956 ) ); vec3 agxDefaultContrastApprox( vec3 x ) { vec3 x2 = x * x; vec3 x4 = x2 * x2; return + 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232; } vec3 AgXToneMapping( vec3 color ) { const mat3 AgXInsetMatrix = mat3( vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) ); const mat3 AgXOutsetMatrix = mat3( vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) ); const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; color *= toneMappingExposure; color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; color = AgXInsetMatrix * color; color = max( color, 1e-10 ); color = log2( color ); color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); color = clamp( color, 0.0, 1.0 ); color = agxDefaultContrastApprox( color ); color = AgXOutsetMatrix * color; color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); color = LINEAR_REC2020_TO_LINEAR_SRGB * color; color = clamp( color, 0.0, 1.0 ); return color; } vec3 NeutralToneMapping( vec3 color ) { const float StartCompression = 0.8 - 0.04; const float Desaturation = 0.15; color *= toneMappingExposure; float x = min( color.r, min( color.g, color.b ) ); float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; color -= offset; float peak = max( color.r, max( color.g, color.b ) ); if ( peak < StartCompression ) return color; float d = 1. - StartCompression; float newPeak = 1. - d * d / ( peak + d - StartCompression ); color *= newPeak / peak; float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,_N=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,xN=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; float w0( float a ) { return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); } float w1( float a ) { return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); } float w2( float a ){ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); } float w3( float a ) { return ( 1.0 / 6.0 ) * ( a * a * a ); } float g0( float a ) { return w0( a ) + w1( a ); } float g1( float a ) { return w2( a ) + w3( a ); } float h0( float a ) { return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); } float h1( float a ) { return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); } vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { uv = uv * texelSize.zw + 0.5; vec2 iuv = floor( uv ); vec2 fuv = fract( uv ); float g0x = g0( fuv.x ); float g1x = g1( fuv.x ); float h0x = h0( fuv.x ); float h1x = h1( fuv.x ); float h0y = h0( fuv.y ); float h1y = h1( fuv.y ); vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); } vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); vec2 fLodSizeInv = 1.0 / fLodSize; vec2 cLodSizeInv = 1.0 / cLodSize; vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); return mix( fSample, cSample, fract( lod ) ); } vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); } vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return vec3( 1.0 ); } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec4 transmittedLight; vec3 transmittance; #ifdef USE_DISPERSION float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); for ( int i = 0; i < 3; i ++ ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); transmittedLight[ i ] = transmissionSample[ i ]; transmittedLight.a += transmissionSample.a; transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; } transmittedLight.a /= 3.0; #else vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); #endif vec3 attenuatedColor = transmittance * transmittedLight.rgb; vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } #endif`,SN=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP varying vec2 vNormalMapUv; #endif #ifdef USE_EMISSIVEMAP varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SHEEN_COLORMAP varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_SPECULARMAP varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,bN=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP uniform mat3 mapTransform; varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP uniform mat3 alphaMapTransform; varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP uniform mat3 lightMapTransform; varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP uniform mat3 aoMapTransform; varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP uniform mat3 bumpMapTransform; varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP uniform mat3 normalMapTransform; varying vec2 vNormalMapUv; #endif #ifdef USE_DISPLACEMENTMAP uniform mat3 displacementMapTransform; varying vec2 vDisplacementMapUv; #endif #ifdef USE_EMISSIVEMAP uniform mat3 emissiveMapTransform; varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP uniform mat3 metalnessMapTransform; varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP uniform mat3 roughnessMapTransform; varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP uniform mat3 anisotropyMapTransform; varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP uniform mat3 clearcoatMapTransform; varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform mat3 clearcoatNormalMapTransform; varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform mat3 clearcoatRoughnessMapTransform; varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_SHEEN_COLORMAP uniform mat3 sheenColorMapTransform; varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform mat3 sheenRoughnessMapTransform; varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP uniform mat3 iridescenceMapTransform; varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform mat3 iridescenceThicknessMapTransform; varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SPECULARMAP uniform mat3 specularMapTransform; varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP uniform mat3 specularColorMapTransform; varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform mat3 specularIntensityMapTransform; varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,MN=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; #endif #ifdef USE_ALPHAMAP vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; #endif #ifdef USE_LIGHTMAP vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; #endif #ifdef USE_AOMAP vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; #endif #ifdef USE_BUMPMAP vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; #endif #ifdef USE_NORMALMAP vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_DISPLACEMENTMAP vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; #endif #ifdef USE_EMISSIVEMAP vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; #endif #ifdef USE_METALNESSMAP vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ROUGHNESSMAP vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ANISOTROPYMAP vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOATMAP vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_NORMALMAP vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCEMAP vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_COLORMAP vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_ROUGHNESSMAP vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULARMAP vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_COLORMAP vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_INTENSITYMAP vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; #endif #ifdef USE_TRANSMISSIONMAP vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; #endif`,EN=`#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; #endif #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const TN=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,AN=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,wN=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,CN=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,RN=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,DN=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,NN=`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,UN=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include #ifdef USE_REVERSED_DEPTH_BUFFER float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; #else float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; #endif #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`,LN=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,IN=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); }`,ON=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,zN=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,PN=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`,BN=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,FN=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,VN=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,kN=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,HN=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,GN=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,XN=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,WN=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,qN=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,YN=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,ZN=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,jN=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,QN=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_DISPERSION uniform float dispersion; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,JN=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,KN=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,$N=`uniform float size; uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv; uniform mat3 uvTransform; #endif void main() { #ifdef USE_POINTS_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif #include #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,eU=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,tU=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,nU=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,iU=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix[ 3 ]; vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,aU=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,an={alphahash_fragment:AR,alphahash_pars_fragment:wR,alphamap_fragment:CR,alphamap_pars_fragment:RR,alphatest_fragment:DR,alphatest_pars_fragment:NR,aomap_fragment:UR,aomap_pars_fragment:LR,batching_pars_vertex:IR,batching_vertex:OR,begin_vertex:zR,beginnormal_vertex:PR,bsdfs:BR,iridescence_fragment:FR,bumpmap_pars_fragment:VR,clipping_planes_fragment:kR,clipping_planes_pars_fragment:HR,clipping_planes_pars_vertex:GR,clipping_planes_vertex:XR,color_fragment:WR,color_pars_fragment:qR,color_pars_vertex:YR,color_vertex:ZR,common:jR,cube_uv_reflection_fragment:QR,defaultnormal_vertex:JR,displacementmap_pars_vertex:KR,displacementmap_vertex:$R,emissivemap_fragment:eD,emissivemap_pars_fragment:tD,colorspace_fragment:nD,colorspace_pars_fragment:iD,envmap_fragment:aD,envmap_common_pars_fragment:sD,envmap_pars_fragment:rD,envmap_pars_vertex:oD,envmap_physical_pars_fragment:yD,envmap_vertex:lD,fog_vertex:uD,fog_pars_vertex:cD,fog_fragment:fD,fog_pars_fragment:hD,gradientmap_pars_fragment:dD,lightmap_pars_fragment:pD,lights_lambert_fragment:mD,lights_lambert_pars_fragment:gD,lights_pars_begin:vD,lights_toon_fragment:_D,lights_toon_pars_fragment:xD,lights_phong_fragment:SD,lights_phong_pars_fragment:bD,lights_physical_fragment:MD,lights_physical_pars_fragment:ED,lights_fragment_begin:TD,lights_fragment_maps:AD,lights_fragment_end:wD,logdepthbuf_fragment:CD,logdepthbuf_pars_fragment:RD,logdepthbuf_pars_vertex:DD,logdepthbuf_vertex:ND,map_fragment:UD,map_pars_fragment:LD,map_particle_fragment:ID,map_particle_pars_fragment:OD,metalnessmap_fragment:zD,metalnessmap_pars_fragment:PD,morphinstance_vertex:BD,morphcolor_vertex:FD,morphnormal_vertex:VD,morphtarget_pars_vertex:kD,morphtarget_vertex:HD,normal_fragment_begin:GD,normal_fragment_maps:XD,normal_pars_fragment:WD,normal_pars_vertex:qD,normal_vertex:YD,normalmap_pars_fragment:ZD,clearcoat_normal_fragment_begin:jD,clearcoat_normal_fragment_maps:QD,clearcoat_pars_fragment:JD,iridescence_pars_fragment:KD,opaque_fragment:$D,packing:eN,premultiplied_alpha_fragment:tN,project_vertex:nN,dithering_fragment:iN,dithering_pars_fragment:aN,roughnessmap_fragment:sN,roughnessmap_pars_fragment:rN,shadowmap_pars_fragment:oN,shadowmap_pars_vertex:lN,shadowmap_vertex:uN,shadowmask_pars_fragment:cN,skinbase_vertex:fN,skinning_pars_vertex:hN,skinning_vertex:dN,skinnormal_vertex:pN,specularmap_fragment:mN,specularmap_pars_fragment:gN,tonemapping_fragment:vN,tonemapping_pars_fragment:yN,transmission_fragment:_N,transmission_pars_fragment:xN,uv_pars_fragment:SN,uv_pars_vertex:bN,uv_vertex:MN,worldpos_vertex:EN,background_vert:TN,background_frag:AN,backgroundCube_vert:wN,backgroundCube_frag:CN,cube_vert:RN,cube_frag:DN,depth_vert:NN,depth_frag:UN,distance_vert:LN,distance_frag:IN,equirect_vert:ON,equirect_frag:zN,linedashed_vert:PN,linedashed_frag:BN,meshbasic_vert:FN,meshbasic_frag:VN,meshlambert_vert:kN,meshlambert_frag:HN,meshmatcap_vert:GN,meshmatcap_frag:XN,meshnormal_vert:WN,meshnormal_frag:qN,meshphong_vert:YN,meshphong_frag:ZN,meshphysical_vert:jN,meshphysical_frag:QN,meshtoon_vert:JN,meshtoon_frag:KN,points_vert:$N,points_frag:eU,shadow_vert:tU,shadow_frag:nU,sprite_vert:iU,sprite_frag:aU},ot={common:{diffuse:{value:new pt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Qt},alphaMap:{value:null},alphaMapTransform:{value:new Qt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Qt}},envmap:{envMap:{value:null},envMapRotation:{value:new Qt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Qt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Qt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Qt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Qt},normalScale:{value:new Pe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Qt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Qt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Qt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Qt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new pt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 pt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Qt},alphaTest:{value:0},uvTransform:{value:new Qt}},sprite:{diffuse:{value:new pt(16777215)},opacity:{value:1},center:{value:new Pe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Qt},alphaMap:{value:null},alphaMapTransform:{value:new Qt},alphaTest:{value:0}}},Xr={basic:{uniforms:Ja([ot.common,ot.specularmap,ot.envmap,ot.aomap,ot.lightmap,ot.fog]),vertexShader:an.meshbasic_vert,fragmentShader:an.meshbasic_frag},lambert:{uniforms:Ja([ot.common,ot.specularmap,ot.envmap,ot.aomap,ot.lightmap,ot.emissivemap,ot.bumpmap,ot.normalmap,ot.displacementmap,ot.fog,ot.lights,{emissive:{value:new pt(0)}}]),vertexShader:an.meshlambert_vert,fragmentShader:an.meshlambert_frag},phong:{uniforms:Ja([ot.common,ot.specularmap,ot.envmap,ot.aomap,ot.lightmap,ot.emissivemap,ot.bumpmap,ot.normalmap,ot.displacementmap,ot.fog,ot.lights,{emissive:{value:new pt(0)},specular:{value:new pt(1118481)},shininess:{value:30}}]),vertexShader:an.meshphong_vert,fragmentShader:an.meshphong_frag},standard:{uniforms:Ja([ot.common,ot.envmap,ot.aomap,ot.lightmap,ot.emissivemap,ot.bumpmap,ot.normalmap,ot.displacementmap,ot.roughnessmap,ot.metalnessmap,ot.fog,ot.lights,{emissive:{value:new pt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag},toon:{uniforms:Ja([ot.common,ot.aomap,ot.lightmap,ot.emissivemap,ot.bumpmap,ot.normalmap,ot.displacementmap,ot.gradientmap,ot.fog,ot.lights,{emissive:{value:new pt(0)}}]),vertexShader:an.meshtoon_vert,fragmentShader:an.meshtoon_frag},matcap:{uniforms:Ja([ot.common,ot.bumpmap,ot.normalmap,ot.displacementmap,ot.fog,{matcap:{value:null}}]),vertexShader:an.meshmatcap_vert,fragmentShader:an.meshmatcap_frag},points:{uniforms:Ja([ot.points,ot.fog]),vertexShader:an.points_vert,fragmentShader:an.points_frag},dashed:{uniforms:Ja([ot.common,ot.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:an.linedashed_vert,fragmentShader:an.linedashed_frag},depth:{uniforms:Ja([ot.common,ot.displacementmap]),vertexShader:an.depth_vert,fragmentShader:an.depth_frag},normal:{uniforms:Ja([ot.common,ot.bumpmap,ot.normalmap,ot.displacementmap,{opacity:{value:1}}]),vertexShader:an.meshnormal_vert,fragmentShader:an.meshnormal_frag},sprite:{uniforms:Ja([ot.sprite,ot.fog]),vertexShader:an.sprite_vert,fragmentShader:an.sprite_frag},background:{uniforms:{uvTransform:{value:new Qt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:an.background_vert,fragmentShader:an.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Qt}},vertexShader:an.backgroundCube_vert,fragmentShader:an.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:an.cube_vert,fragmentShader:an.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:an.equirect_vert,fragmentShader:an.equirect_frag},distance:{uniforms:Ja([ot.common,ot.displacementmap,{referencePosition:{value:new Y},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:an.distance_vert,fragmentShader:an.distance_frag},shadow:{uniforms:Ja([ot.lights,ot.fog,{color:{value:new pt(0)},opacity:{value:1}}]),vertexShader:an.shadow_vert,fragmentShader:an.shadow_frag}};Xr.physical={uniforms:Ja([Xr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Qt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Qt},clearcoatNormalScale:{value:new Pe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Qt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Qt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Qt},sheen:{value:0},sheenColor:{value:new pt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Qt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Qt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Qt},transmissionSamplerSize:{value:new Pe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Qt},attenuationDistance:{value:0},attenuationColor:{value:new pt(0)},specularColor:{value:new pt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Qt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Qt},anisotropyVector:{value:new Pe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Qt}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag};const ev={r:0,b:0,g:0},Pc=new Hs,sU=new kt;function rU(o,e,t,i,s,u,f){const h=new pt(0);let m=u===!0?0:1,g,_,x=null,b=0,M=null;function A(U){let L=U.isScene===!0?U.background:null;return L&&L.isTexture&&(L=(U.backgroundBlurriness>0?t:e).get(L)),L}function R(U){let L=!1;const B=A(U);B===null?E(h,m):B&&B.isColor&&(E(B,1),L=!0);const P=o.xr.getEnvironmentBlendMode();P==="additive"?i.buffers.color.setClear(0,0,0,1,f):P==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,f),(o.autoClear||L)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),o.clear(o.autoClearColor,o.autoClearDepth,o.autoClearStencil))}function C(U,L){const B=A(L);B&&(B.isCubeTexture||B.mapping===jh)?(_===void 0&&(_=new Gi(new $c(1,1,1),new vr({name:"BackgroundCubeMaterial",uniforms:Xh(Xr.backgroundCube.uniforms),vertexShader:Xr.backgroundCube.vertexShader,fragmentShader:Xr.backgroundCube.fragmentShader,side:ts,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),_.geometry.deleteAttribute("normal"),_.geometry.deleteAttribute("uv"),_.onBeforeRender=function(P,H,W){this.matrixWorld.copyPosition(W.matrixWorld)},Object.defineProperty(_.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(_)),Pc.copy(L.backgroundRotation),Pc.x*=-1,Pc.y*=-1,Pc.z*=-1,B.isCubeTexture&&B.isRenderTargetTexture===!1&&(Pc.y*=-1,Pc.z*=-1),_.material.uniforms.envMap.value=B,_.material.uniforms.flipEnvMap.value=B.isCubeTexture&&B.isRenderTargetTexture===!1?-1:1,_.material.uniforms.backgroundBlurriness.value=L.backgroundBlurriness,_.material.uniforms.backgroundIntensity.value=L.backgroundIntensity,_.material.uniforms.backgroundRotation.value.setFromMatrix4(sU.makeRotationFromEuler(Pc)),_.material.toneMapped=xn.getTransfer(B.colorSpace)!==On,(x!==B||b!==B.version||M!==o.toneMapping)&&(_.material.needsUpdate=!0,x=B,b=B.version,M=o.toneMapping),_.layers.enableAll(),U.unshift(_,_.geometry,_.material,0,0,null)):B&&B.isTexture&&(g===void 0&&(g=new Gi(new Kh(2,2),new vr({name:"BackgroundMaterial",uniforms:Xh(Xr.background.uniforms),vertexShader:Xr.background.vertexShader,fragmentShader:Xr.background.fragmentShader,side:Cl,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),g.geometry.deleteAttribute("normal"),Object.defineProperty(g.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(g)),g.material.uniforms.t2D.value=B,g.material.uniforms.backgroundIntensity.value=L.backgroundIntensity,g.material.toneMapped=xn.getTransfer(B.colorSpace)!==On,B.matrixAutoUpdate===!0&&B.updateMatrix(),g.material.uniforms.uvTransform.value.copy(B.matrix),(x!==B||b!==B.version||M!==o.toneMapping)&&(g.material.needsUpdate=!0,x=B,b=B.version,M=o.toneMapping),g.layers.enableAll(),U.unshift(g,g.geometry,g.material,0,0,null))}function E(U,L){U.getRGB(ev,EE(o)),i.buffers.color.setClear(ev.r,ev.g,ev.b,L,f)}function D(){_!==void 0&&(_.geometry.dispose(),_.material.dispose(),_=void 0),g!==void 0&&(g.geometry.dispose(),g.material.dispose(),g=void 0)}return{getClearColor:function(){return h},setClearColor:function(U,L=1){h.set(U),m=L,E(h,m)},getClearAlpha:function(){return m},setClearAlpha:function(U){m=U,E(h,m)},render:R,addToRenderList:C,dispose:D}}function oU(o,e){const t=o.getParameter(o.MAX_VERTEX_ATTRIBS),i={},s=b(null);let u=s,f=!1;function h(z,j,ae,$,ue){let he=!1;const q=x($,ae,j);u!==q&&(u=q,g(u.object)),he=M(z,$,ae,ue),he&&A(z,$,ae,ue),ue!==null&&e.update(ue,o.ELEMENT_ARRAY_BUFFER),(he||f)&&(f=!1,L(z,j,ae,$),ue!==null&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,e.get(ue).buffer))}function m(){return o.createVertexArray()}function g(z){return o.bindVertexArray(z)}function _(z){return o.deleteVertexArray(z)}function x(z,j,ae){const $=ae.wireframe===!0;let ue=i[z.id];ue===void 0&&(ue={},i[z.id]=ue);let he=ue[j.id];he===void 0&&(he={},ue[j.id]=he);let q=he[$];return q===void 0&&(q=b(m()),he[$]=q),q}function b(z){const j=[],ae=[],$=[];for(let ue=0;ue=0){const Ce=ue[ce];let X=he[ce];if(X===void 0&&(ce==="instanceMatrix"&&z.instanceMatrix&&(X=z.instanceMatrix),ce==="instanceColor"&&z.instanceColor&&(X=z.instanceColor)),Ce===void 0||Ce.attribute!==X||X&&Ce.data!==X.data)return!0;q++}return u.attributesNum!==q||u.index!==$}function A(z,j,ae,$){const ue={},he=j.attributes;let q=0;const K=ae.getAttributes();for(const ce in K)if(K[ce].location>=0){let Ce=he[ce];Ce===void 0&&(ce==="instanceMatrix"&&z.instanceMatrix&&(Ce=z.instanceMatrix),ce==="instanceColor"&&z.instanceColor&&(Ce=z.instanceColor));const X={};X.attribute=Ce,Ce&&Ce.data&&(X.data=Ce.data),ue[ce]=X,q++}u.attributes=ue,u.attributesNum=q,u.index=$}function R(){const z=u.newAttributes;for(let j=0,ae=z.length;j=0){let Ae=ue[K];if(Ae===void 0&&(K==="instanceMatrix"&&z.instanceMatrix&&(Ae=z.instanceMatrix),K==="instanceColor"&&z.instanceColor&&(Ae=z.instanceColor)),Ae!==void 0){const Ce=Ae.normalized,X=Ae.itemSize,se=e.get(Ae);if(se===void 0)continue;const Ee=se.buffer,Oe=se.type,nt=se.bytesPerElement,fe=Oe===o.INT||Oe===o.UNSIGNED_INT||Ae.gpuType===oy;if(Ae.isInterleavedBufferAttribute){const Te=Ae.data,Je=Te.stride,et=Ae.offset;if(Te.isInstancedInterleavedBuffer){for(let ut=0;ut0&&o.getShaderPrecisionFormat(o.FRAGMENT_SHADER,o.HIGH_FLOAT).precision>0)return"highp";H="mediump"}return H==="mediump"&&o.getShaderPrecisionFormat(o.VERTEX_SHADER,o.MEDIUM_FLOAT).precision>0&&o.getShaderPrecisionFormat(o.FRAGMENT_SHADER,o.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let g=t.precision!==void 0?t.precision:"highp";const _=m(g);_!==g&&(rt("WebGLRenderer:",g,"not supported, using",_,"instead."),g=_);const x=t.logarithmicDepthBuffer===!0,b=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),M=o.getParameter(o.MAX_TEXTURE_IMAGE_UNITS),A=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS),R=o.getParameter(o.MAX_TEXTURE_SIZE),C=o.getParameter(o.MAX_CUBE_MAP_TEXTURE_SIZE),E=o.getParameter(o.MAX_VERTEX_ATTRIBS),D=o.getParameter(o.MAX_VERTEX_UNIFORM_VECTORS),U=o.getParameter(o.MAX_VARYING_VECTORS),L=o.getParameter(o.MAX_FRAGMENT_UNIFORM_VECTORS),B=o.getParameter(o.MAX_SAMPLES),P=o.getParameter(o.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:u,getMaxPrecision:m,textureFormatReadable:f,textureTypeReadable:h,precision:g,logarithmicDepthBuffer:x,reversedDepthBuffer:b,maxTextures:M,maxVertexTextures:A,maxTextureSize:R,maxCubemapSize:C,maxAttributes:E,maxVertexUniforms:D,maxVaryings:U,maxFragmentUniforms:L,maxSamples:B,samples:P}}function cU(o){const e=this;let t=null,i=0,s=!1,u=!1;const f=new Au,h=new Qt,m={value:null,needsUpdate:!1};this.uniform=m,this.numPlanes=0,this.numIntersection=0,this.init=function(x,b){const M=x.length!==0||b||i!==0||s;return s=b,i=x.length,M},this.beginShadows=function(){u=!0,_(null)},this.endShadows=function(){u=!1},this.setGlobalState=function(x,b){t=_(x,b,0)},this.setState=function(x,b,M){const A=x.clippingPlanes,R=x.clipIntersection,C=x.clipShadows,E=o.get(x);if(!s||A===null||A.length===0||u&&!C)u?_(null):g();else{const D=u?0:i,U=D*4;let L=E.clippingState||null;m.value=L,L=_(A,b,U,M);for(let B=0;B!==U;++B)L[B]=t[B];E.clippingState=L,this.numIntersection=R?this.numPlanes:0,this.numPlanes+=D}};function g(){m.value!==t&&(m.value=t,m.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function _(x,b,M,A){const R=x!==null?x.length:0;let C=null;if(R!==0){if(C=m.value,A!==!0||C===null){const E=M+R*4,D=b.matrixWorldInverse;h.getNormalMatrix(D),(C===null||C.length0){const g=new yS(m.height);return g.fromEquirectangularTexture(o,f),e.set(f,g),f.addEventListener("dispose",s),t(g.texture,f.mapping)}else return null}}return f}function s(f){const h=f.target;h.removeEventListener("dispose",s);const m=e.get(h);m!==void 0&&(e.delete(h),m.dispose())}function u(){e=new WeakMap}return{get:i,dispose:u}}const Nu=4,jM=[.125,.215,.35,.446,.526,.582],Vc=20,hU=256,Fp=new $h,QM=new pt;let fx=null,hx=0,dx=0,px=!1;const dU=new Y;class Hx{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,s=100,u={}){const{size:f=256,position:h=dU}=u;fx=this._renderer.getRenderTarget(),hx=this._renderer.getActiveCubeFace(),dx=this._renderer.getActiveMipmapLevel(),px=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(f);const m=this._allocateTargets();return m.depthBuffer=!0,this._sceneToCubeUV(e,i,s,m,h),t>0&&this._blur(m,0,0,t),this._applyPMREM(m),this._cleanup(m),m}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=$M(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=KM(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.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._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?B:0,B,B),x.setRenderTarget(s),E&&x.render(R,m),x.render(e,m)}x.toneMapping=M,x.autoClear=b,e.background=D}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===Oo||e.mapping===Uu;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=$M()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=KM());const u=s?this._cubemapMaterial:this._equirectMaterial,f=this._lodMeshes[0];f.material=u;const h=u.uniforms;h.envMap.value=e;const m=this._cubeSize;Rh(t,0,0,3*m,2*m),i.setRenderTarget(t),i.render(f,Fp)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let u=1;uA-Nu?i-A+Nu:0),E=4*(this._cubeSize-R);m.envMap.value=e.texture,m.roughness.value=M,m.mipInt.value=A-t,Rh(u,C,E,3*R,2*R),s.setRenderTarget(u),s.render(h,Fp),m.envMap.value=u.texture,m.roughness.value=0,m.mipInt.value=A-i,Rh(e,C,E,3*R,2*R),s.setRenderTarget(e),s.render(h,Fp)}_blur(e,t,i,s,u){const f=this._pingPongRenderTarget;this._halfBlur(e,f,t,i,s,"latitudinal",u),this._halfBlur(f,e,i,i,s,"longitudinal",u)}_halfBlur(e,t,i,s,u,f,h){const m=this._renderer,g=this._blurMaterial;f!=="latitudinal"&&f!=="longitudinal"&&Tt("blur direction must be either latitudinal or longitudinal!");const _=3,x=this._lodMeshes[s];x.material=g;const b=g.uniforms,M=this._sizeLods[i]-1,A=isFinite(u)?Math.PI/(2*M):2*Math.PI/(2*Vc-1),R=u/A,C=isFinite(u)?1+Math.floor(_*R):Vc;C>Vc&&rt(`sigmaRadians, ${u}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Vc}`);const E=[];let D=0;for(let H=0;HU-Nu?s-U+Nu:0),P=4*(this._cubeSize-L);Rh(t,B,P,3*L,2*L),m.setRenderTarget(t),m.render(x,Fp)}}function pU(o){const e=[],t=[],i=[];let s=o;const u=o-Nu+1+jM.length;for(let f=0;fo-Nu?m=jM[f-o+Nu-1]:f===0&&(m=0),t.push(m);const g=1/(h-2),_=-g,x=1+g,b=[_,_,x,_,x,x,_,_,x,x,_,x],M=6,A=6,R=3,C=2,E=1,D=new Float32Array(R*A*M),U=new Float32Array(C*A*M),L=new Float32Array(E*A*M);for(let P=0;P2?0:-1,I=[H,W,0,H+2/3,W,0,H+2/3,W+1,0,H,W,0,H+2/3,W+1,0,H,W+1,0];D.set(I,R*A*P),U.set(b,C*A*P);const z=[P,P,P,P,P,P];L.set(z,E*A*P)}const B=new Yt;B.setAttribute("position",new Hn(D,R)),B.setAttribute("uv",new Hn(U,C)),B.setAttribute("faceIndex",new Hn(L,E)),i.push(new Gi(B,null)),s>Nu&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function JM(o,e,t){const i=new ks(o,e,t);return i.texture.mapping=jh,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Rh(o,e,t,i,s){o.viewport.set(e,t,i,s),o.scissor.set(e,t,i,s)}function mU(o,e,t){return new vr({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:hU,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${o}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Fy(),fragmentShader:` precision highp float; precision highp int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform float roughness; uniform float mipInt; #define ENVMAP_TYPE_CUBE_UV #include #define PI 3.14159265359 // Van der Corput radical inverse float radicalInverse_VdC(uint bits) { bits = (bits << 16u) | (bits >> 16u); bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); return float(bits) * 2.3283064365386963e-10; // / 0x100000000 } // Hammersley sequence vec2 hammersley(uint i, uint N) { return vec2(float(i) / float(N), radicalInverse_VdC(i)); } // GGX VNDF importance sampling (Eric Heitz 2018) // "Sampling the GGX Distribution of Visible Normals" // https://jcgt.org/published/0007/04/01/ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { float alpha = roughness * roughness; // Section 3.2: Transform view direction to hemisphere configuration vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z)); // Section 4.1: Orthonormal basis float lensq = Vh.x * Vh.x + Vh.y * Vh.y; vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0); vec3 T2 = cross(Vh, T1); // Section 4.2: Parameterization of projected area float r = sqrt(Xi.x); float phi = 2.0 * PI * Xi.y; float t1 = r * cos(phi); float t2 = r * sin(phi); float s = 0.5 * (1.0 + Vh.z); t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; // Section 4.3: Reprojection onto hemisphere vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh; // Section 3.4: Transform back to ellipsoid configuration return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); } void main() { vec3 N = normalize(vOutputDirection); vec3 V = N; // Assume view direction equals normal for pre-filtering vec3 prefilteredColor = vec3(0.0); float totalWeight = 0.0; // For very low roughness, just sample the environment directly if (roughness < 0.001) { gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); return; } // Tangent space basis for VNDF sampling vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); vec3 tangent = normalize(cross(up, N)); vec3 bitangent = cross(N, tangent); for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); // For PMREM, V = N, so in tangent space V is always (0, 0, 1) vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); // Transform H back to world space vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); vec3 L = normalize(2.0 * dot(V, H) * H - V); float NdotL = max(dot(N, L), 0.0); if(NdotL > 0.0) { // Sample environment at fixed mip level // VNDF importance sampling handles the distribution filtering vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); // Weight by NdotL for the split-sum approximation // VNDF PDF naturally accounts for the visible microfacet distribution prefilteredColor += sampleColor * NdotL; totalWeight += NdotL; } } if (totalWeight > 0.0) { prefilteredColor = prefilteredColor / totalWeight; } gl_FragColor = vec4(prefilteredColor, 1.0); } `,blending:Io,depthTest:!1,depthWrite:!1})}function gU(o,e,t){const i=new Float32Array(Vc),s=new Y(0,1,0);return new vr({name:"SphericalGaussianBlur",defines:{n:Vc,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${o}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Fy(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:Io,depthTest:!1,depthWrite:!1})}function KM(){return new vr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Fy(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:Io,depthTest:!1,depthWrite:!1})}function $M(){return new vr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Fy(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:Io,depthTest:!1,depthWrite:!1})}function Fy(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function vU(o){let e=new WeakMap,t=null;function i(h){if(h&&h.isTexture){const m=h.mapping,g=m===em||m===tm,_=m===Oo||m===Uu;if(g||_){let x=e.get(h);const b=x!==void 0?x.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==b)return t===null&&(t=new Hx(o)),x=g?t.fromEquirectangular(h,x):t.fromCubemap(h,x),x.texture.pmremVersion=h.pmremVersion,e.set(h,x),x.texture;if(x!==void 0)return x.texture;{const M=h.image;return g&&M&&M.height>0||_&&M&&s(M)?(t===null&&(t=new Hx(o)),x=g?t.fromEquirectangular(h):t.fromCubemap(h),x.texture.pmremVersion=h.pmremVersion,e.set(h,x),h.addEventListener("dispose",u),x.texture):null}}}return h}function s(h){let m=0;const g=6;for(let _=0;_e.maxTextureSize&&(B=Math.ceil(L/e.maxTextureSize),L=e.maxTextureSize);const P=new Float32Array(L*B*4*x),H=new gy(P,L,B,x);H.type=es,H.needsUpdate=!0;const W=U*4;for(let z=0;z #include void main() { gl_FragColor = texture2D( tDiffuse, vUv ); #ifdef LINEAR_TONE_MAPPING gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); #elif defined( REINHARD_TONE_MAPPING ) gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); #elif defined( CINEON_TONE_MAPPING ) gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); #elif defined( ACES_FILMIC_TONE_MAPPING ) gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); #elif defined( AGX_TONE_MAPPING ) gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); #elif defined( NEUTRAL_TONE_MAPPING ) gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); #elif defined( CUSTOM_TONE_MAPPING ) gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); #endif #ifdef SRGB_TRANSFER gl_FragColor = sRGBTransferOETF( gl_FragColor ); #endif }`,depthTest:!1,depthWrite:!1}),g=new Gi(h,m),_=new $h(-1,1,1,-1,0,1);let x=null,b=null,M=!1,A,R=null,C=[],E=!1;this.setSize=function(D,U){u.setSize(D,U),f.setSize(D,U);for(let L=0;L0&&C[0].isRenderPass===!0;const U=u.width,L=u.height;for(let B=0;B0)return o;const s=e*t;let u=e1[s];if(u===void 0&&(u=new Float32Array(s),e1[s]=u),e!==0){i.toArray(u,0);for(let f=1,h=0;f!==e;++f)h+=t,o[f].toArray(u,h)}return u}function Qi(o,e){if(o.length!==e.length)return!1;for(let t=0,i=o.length;t0&&(this.seq=s.concat(u))}setValue(e,t,i,s){const u=this.map[t];u!==void 0&&u.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let u=0,f=t.length;u!==f;++u){const h=t[u],m=i[h.id];m.needsUpdate!==!1&&h.setValue(e,m.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,u=e.length;s!==u;++s){const f=e[s];f.id in t&&i.push(f)}return i}}function r1(o,e,t){const i=o.createShader(e);return o.shaderSource(i,t),o.compileShader(i),i}const gL=37297;let vL=0;function yL(o,e){const t=o.split(` `),i=[],s=Math.max(e-6,0),u=Math.min(e+6,t.length);for(let f=s;f":" "} ${h}: ${t[f]}`)}return i.join(` `)}const o1=new Qt;function _L(o){xn._getMatrix(o1,xn.workingColorSpace,o);const e=`mat3( ${o1.elements.map(t=>t.toFixed(4))} )`;switch(xn.getTransfer(o)){case rm:return[e,"LinearTransferOETF"];case On:return[e,"sRGBTransferOETF"];default:return rt("WebGLProgram: Unsupported color space: ",o),[e,"LinearTransferOETF"]}}function l1(o,e,t){const i=o.getShaderParameter(e,o.COMPILE_STATUS),u=(o.getShaderInfoLog(e)||"").trim();if(i&&u==="")return"";const f=/ERROR: 0:(\d+)/.exec(u);if(f){const h=parseInt(f[1]);return t.toUpperCase()+` `+u+` `+yL(o.getShaderSource(e),h)}else return u}function xL(o,e){const t=_L(e);return[`vec4 ${o}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}const SL={[eS]:"Linear",[tS]:"Reinhard",[nS]:"Cineon",[sy]:"ACESFilmic",[aS]:"AgX",[sS]:"Neutral",[iS]:"Custom"};function bL(o,e){const t=SL[e];return t===void 0?(rt("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+o+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+o+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const tv=new Y;function ML(){xn.getLuminanceCoefficients(tv);const o=tv.x.toFixed(4),e=tv.y.toFixed(4),t=tv.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${o}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function EL(o){return[o.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",o.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Gp).join(` `)}function TL(o){const e=[];for(const t in o){const i=o[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function AL(o,e){const t={},i=o.getProgramParameter(e,o.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Xx(o){return o.replace(wL,RL)}const CL=new Map;function RL(o,e){let t=an[e];if(t===void 0){const i=CL.get(e);if(i!==void 0)t=an[i],rt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Xx(t)}const DL=/#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 f1(o){return o.replace(DL,NL)}function NL(o,e,t,i){let s="";for(let u=parseInt(e);u0&&(C+=` `),E=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A].filter(Gp).join(` `),E.length>0&&(E+=` `)):(C=[h1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",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 "+_:"",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?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+m:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","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","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#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","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Gp).join(` `),E=[h1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+g:"",t.envMap?"#define "+_:"",t.envMap?"#define "+x:"",b?"#define CUBEUV_TEXEL_WIDTH "+b.texelWidth:"",b?"#define CUBEUV_TEXEL_HEIGHT "+b.texelHeight:"",b?"#define CUBEUV_MAX_MIP "+b.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.dispersion?"#define USE_DISPERSION":"",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||t.batchingColor?"#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 "+m:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==mr?"#define TONE_MAPPING":"",t.toneMapping!==mr?an.tonemapping_pars_fragment:"",t.toneMapping!==mr?bL("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",an.colorspace_pars_fragment,xL("linearToOutputTexel",t.outputColorSpace),ML(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Gp).join(` `)),f=Xx(f),f=u1(f,t),f=c1(f,t),h=Xx(h),h=u1(h,t),h=c1(h,t),f=f1(f),h=f1(h),t.isRawShaderMaterial!==!0&&(D=`#version 300 es `,C=[M,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+C,E=["#define varying in",t.glslVersion===Ix?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Ix?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` `+E);const U=D+C+f,L=D+E+h,B=r1(s,s.VERTEX_SHADER,U),P=r1(s,s.FRAGMENT_SHADER,L);s.attachShader(R,B),s.attachShader(R,P),t.index0AttributeName!==void 0?s.bindAttribLocation(R,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(R,0,"position"),s.linkProgram(R);function H(j){if(o.debug.checkShaderErrors){const ae=s.getProgramInfoLog(R)||"",$=s.getShaderInfoLog(B)||"",ue=s.getShaderInfoLog(P)||"",he=ae.trim(),q=$.trim(),K=ue.trim();let ce=!0,Ae=!0;if(s.getProgramParameter(R,s.LINK_STATUS)===!1)if(ce=!1,typeof o.debug.onShaderError=="function")o.debug.onShaderError(s,R,B,P);else{const Ce=l1(s,B,"vertex"),X=l1(s,P,"fragment");Tt("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(R,s.VALIDATE_STATUS)+` Material Name: `+j.name+` Material Type: `+j.type+` Program Info Log: `+he+` `+Ce+` `+X)}else he!==""?rt("WebGLProgram: Program Info Log:",he):(q===""||K==="")&&(Ae=!1);Ae&&(j.diagnostics={runnable:ce,programLog:he,vertexShader:{log:q,prefix:C},fragmentShader:{log:K,prefix:E}})}s.deleteShader(B),s.deleteShader(P),W=new rv(s,R),I=AL(s,R)}let W;this.getUniforms=function(){return W===void 0&&H(this),W};let I;this.getAttributes=function(){return I===void 0&&H(this),I};let z=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return z===!1&&(z=s.getProgramParameter(R,gL)),z},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(R),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=vL++,this.cacheKey=e,this.usedTimes=1,this.program=R,this.vertexShader=B,this.fragmentShader=P,this}let HL=0;class GL{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,s=this._getShaderStage(t),u=this._getShaderStage(i),f=this._getShaderCacheForMaterial(e);return f.has(s)===!1&&(f.add(s),s.usedTimes++),f.has(u)===!1&&(f.add(u),u.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.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 i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new XL(e),t.set(e,i)),i}}class XL{constructor(e){this.id=HL++,this.code=e,this.usedTimes=0}}function WL(o,e,t,i,s,u,f){const h=new Gh,m=new GL,g=new Set,_=[],x=new Map,b=s.logarithmicDepthBuffer;let M=s.precision;const A={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 R(I){return g.add(I),I===0?"uv":`uv${I}`}function C(I,z,j,ae,$){const ue=ae.fog,he=$.geometry,q=I.isMeshStandardMaterial?ae.environment:null,K=(I.isMeshStandardMaterial?t:e).get(I.envMap||q),ce=K&&K.mapping===jh?K.image.height:null,Ae=A[I.type];I.precision!==null&&(M=s.getMaxPrecision(I.precision),M!==I.precision&&rt("WebGLProgram.getParameters:",I.precision,"not supported, using",M,"instead."));const Ce=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,X=Ce!==void 0?Ce.length:0;let se=0;he.morphAttributes.position!==void 0&&(se=1),he.morphAttributes.normal!==void 0&&(se=2),he.morphAttributes.color!==void 0&&(se=3);let Ee,Oe,nt,fe;if(Ae){const gn=Xr[Ae];Ee=gn.vertexShader,Oe=gn.fragmentShader}else Ee=I.vertexShader,Oe=I.fragmentShader,m.update(I),nt=m.getVertexShaderID(I),fe=m.getFragmentShaderID(I);const Te=o.getRenderTarget(),Je=o.state.buffers.depth.getReversed(),et=$.isInstancedMesh===!0,ut=$.isBatchedMesh===!0,Jt=!!I.map,on=!!I.matcap,Dt=!!K,Re=!!I.aoMap,Ve=!!I.lightMap,Ue=!!I.bumpMap,Ke=!!I.normalMap,Z=!!I.displacementMap,St=!!I.emissiveMap,tt=!!I.metalnessMap,Mt=!!I.roughnessMap,We=I.anisotropy>0,G=I.clearcoat>0,O=I.dispersion>0,ne=I.iridescence>0,Se=I.sheen>0,Le=I.transmission>0,be=We&&!!I.anisotropyMap,ct=G&&!!I.clearcoatMap,Ze=G&&!!I.clearcoatNormalMap,gt=G&&!!I.clearcoatRoughnessMap,wt=ne&&!!I.iridescenceMap,Be=ne&&!!I.iridescenceThicknessMap,Xe=Se&&!!I.sheenColorMap,ft=Se&&!!I.sheenRoughnessMap,lt=!!I.specularMap,$e=!!I.specularColorMap,Zt=!!I.specularIntensityMap,te=Le&&!!I.transmissionMap,it=Le&&!!I.thicknessMap,Ge=!!I.gradientMap,st=!!I.alphaMap,Fe=I.alphaTest>0,Ne=!!I.alphaHash,je=!!I.extensions;let Bt=mr;I.toneMapped&&(Te===null||Te.isXRRenderTarget===!0)&&(Bt=o.toneMapping);const dn={shaderID:Ae,shaderType:I.type,shaderName:I.name,vertexShader:Ee,fragmentShader:Oe,defines:I.defines,customVertexShaderID:nt,customFragmentShaderID:fe,isRawShaderMaterial:I.isRawShaderMaterial===!0,glslVersion:I.glslVersion,precision:M,batching:ut,batchingColor:ut&&$._colorsTexture!==null,instancing:et,instancingColor:et&&$.instanceColor!==null,instancingMorph:et&&$.morphTexture!==null,outputColorSpace:Te===null?o.outputColorSpace:Te.isXRRenderTarget===!0?Te.texture.colorSpace:Lu,alphaToCoverage:!!I.alphaToCoverage,map:Jt,matcap:on,envMap:Dt,envMapMode:Dt&&K.mapping,envMapCubeUVHeight:ce,aoMap:Re,lightMap:Ve,bumpMap:Ue,normalMap:Ke,displacementMap:Z,emissiveMap:St,normalMapObjectSpace:Ke&&I.normalMapType===fE,normalMapTangentSpace:Ke&&I.normalMapType===zu,metalnessMap:tt,roughnessMap:Mt,anisotropy:We,anisotropyMap:be,clearcoat:G,clearcoatMap:ct,clearcoatNormalMap:Ze,clearcoatRoughnessMap:gt,dispersion:O,iridescence:ne,iridescenceMap:wt,iridescenceThicknessMap:Be,sheen:Se,sheenColorMap:Xe,sheenRoughnessMap:ft,specularMap:lt,specularColorMap:$e,specularIntensityMap:Zt,transmission:Le,transmissionMap:te,thicknessMap:it,gradientMap:Ge,opaque:I.transparent===!1&&I.blending===Wc&&I.alphaToCoverage===!1,alphaMap:st,alphaTest:Fe,alphaHash:Ne,combine:I.combine,mapUv:Jt&&R(I.map.channel),aoMapUv:Re&&R(I.aoMap.channel),lightMapUv:Ve&&R(I.lightMap.channel),bumpMapUv:Ue&&R(I.bumpMap.channel),normalMapUv:Ke&&R(I.normalMap.channel),displacementMapUv:Z&&R(I.displacementMap.channel),emissiveMapUv:St&&R(I.emissiveMap.channel),metalnessMapUv:tt&&R(I.metalnessMap.channel),roughnessMapUv:Mt&&R(I.roughnessMap.channel),anisotropyMapUv:be&&R(I.anisotropyMap.channel),clearcoatMapUv:ct&&R(I.clearcoatMap.channel),clearcoatNormalMapUv:Ze&&R(I.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:gt&&R(I.clearcoatRoughnessMap.channel),iridescenceMapUv:wt&&R(I.iridescenceMap.channel),iridescenceThicknessMapUv:Be&&R(I.iridescenceThicknessMap.channel),sheenColorMapUv:Xe&&R(I.sheenColorMap.channel),sheenRoughnessMapUv:ft&&R(I.sheenRoughnessMap.channel),specularMapUv:lt&&R(I.specularMap.channel),specularColorMapUv:$e&&R(I.specularColorMap.channel),specularIntensityMapUv:Zt&&R(I.specularIntensityMap.channel),transmissionMapUv:te&&R(I.transmissionMap.channel),thicknessMapUv:it&&R(I.thicknessMap.channel),alphaMapUv:st&&R(I.alphaMap.channel),vertexTangents:!!he.attributes.tangent&&(Ke||We),vertexColors:I.vertexColors,vertexAlphas:I.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!he.attributes.uv&&(Jt||st),fog:!!ue,useFog:I.fog===!0,fogExp2:!!ue&&ue.isFogExp2,flatShading:I.flatShading===!0&&I.wireframe===!1,sizeAttenuation:I.sizeAttenuation===!0,logarithmicDepthBuffer:b,reversedDepthBuffer:Je,skinning:$.isSkinnedMesh===!0,morphTargets:he.morphAttributes.position!==void 0,morphNormals:he.morphAttributes.normal!==void 0,morphColors:he.morphAttributes.color!==void 0,morphTargetsCount:X,morphTextureStride:se,numDirLights:z.directional.length,numPointLights:z.point.length,numSpotLights:z.spot.length,numSpotLightMaps:z.spotLightMap.length,numRectAreaLights:z.rectArea.length,numHemiLights:z.hemi.length,numDirLightShadows:z.directionalShadowMap.length,numPointLightShadows:z.pointShadowMap.length,numSpotLightShadows:z.spotShadowMap.length,numSpotLightShadowsWithMaps:z.numSpotLightShadowsWithMaps,numLightProbes:z.numLightProbes,numClippingPlanes:f.numPlanes,numClipIntersection:f.numIntersection,dithering:I.dithering,shadowMapEnabled:o.shadowMap.enabled&&j.length>0,shadowMapType:o.shadowMap.type,toneMapping:Bt,decodeVideoTexture:Jt&&I.map.isVideoTexture===!0&&xn.getTransfer(I.map.colorSpace)===On,decodeVideoTextureEmissive:St&&I.emissiveMap.isVideoTexture===!0&&xn.getTransfer(I.emissiveMap.colorSpace)===On,premultipliedAlpha:I.premultipliedAlpha,doubleSided:I.side===No,flipSided:I.side===ts,useDepthPacking:I.depthPacking>=0,depthPacking:I.depthPacking||0,index0AttributeName:I.index0AttributeName,extensionClipCullDistance:je&&I.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(je&&I.extensions.multiDraw===!0||ut)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:I.customProgramCacheKey()};return dn.vertexUv1s=g.has(1),dn.vertexUv2s=g.has(2),dn.vertexUv3s=g.has(3),g.clear(),dn}function E(I){const z=[];if(I.shaderID?z.push(I.shaderID):(z.push(I.customVertexShaderID),z.push(I.customFragmentShaderID)),I.defines!==void 0)for(const j in I.defines)z.push(j),z.push(I.defines[j]);return I.isRawShaderMaterial===!1&&(D(z,I),U(z,I),z.push(o.outputColorSpace)),z.push(I.customProgramCacheKey),z.join()}function D(I,z){I.push(z.precision),I.push(z.outputColorSpace),I.push(z.envMapMode),I.push(z.envMapCubeUVHeight),I.push(z.mapUv),I.push(z.alphaMapUv),I.push(z.lightMapUv),I.push(z.aoMapUv),I.push(z.bumpMapUv),I.push(z.normalMapUv),I.push(z.displacementMapUv),I.push(z.emissiveMapUv),I.push(z.metalnessMapUv),I.push(z.roughnessMapUv),I.push(z.anisotropyMapUv),I.push(z.clearcoatMapUv),I.push(z.clearcoatNormalMapUv),I.push(z.clearcoatRoughnessMapUv),I.push(z.iridescenceMapUv),I.push(z.iridescenceThicknessMapUv),I.push(z.sheenColorMapUv),I.push(z.sheenRoughnessMapUv),I.push(z.specularMapUv),I.push(z.specularColorMapUv),I.push(z.specularIntensityMapUv),I.push(z.transmissionMapUv),I.push(z.thicknessMapUv),I.push(z.combine),I.push(z.fogExp2),I.push(z.sizeAttenuation),I.push(z.morphTargetsCount),I.push(z.morphAttributeCount),I.push(z.numDirLights),I.push(z.numPointLights),I.push(z.numSpotLights),I.push(z.numSpotLightMaps),I.push(z.numHemiLights),I.push(z.numRectAreaLights),I.push(z.numDirLightShadows),I.push(z.numPointLightShadows),I.push(z.numSpotLightShadows),I.push(z.numSpotLightShadowsWithMaps),I.push(z.numLightProbes),I.push(z.shadowMapType),I.push(z.toneMapping),I.push(z.numClippingPlanes),I.push(z.numClipIntersection),I.push(z.depthPacking)}function U(I,z){h.disableAll(),z.instancing&&h.enable(0),z.instancingColor&&h.enable(1),z.instancingMorph&&h.enable(2),z.matcap&&h.enable(3),z.envMap&&h.enable(4),z.normalMapObjectSpace&&h.enable(5),z.normalMapTangentSpace&&h.enable(6),z.clearcoat&&h.enable(7),z.iridescence&&h.enable(8),z.alphaTest&&h.enable(9),z.vertexColors&&h.enable(10),z.vertexAlphas&&h.enable(11),z.vertexUv1s&&h.enable(12),z.vertexUv2s&&h.enable(13),z.vertexUv3s&&h.enable(14),z.vertexTangents&&h.enable(15),z.anisotropy&&h.enable(16),z.alphaHash&&h.enable(17),z.batching&&h.enable(18),z.dispersion&&h.enable(19),z.batchingColor&&h.enable(20),z.gradientMap&&h.enable(21),I.push(h.mask),h.disableAll(),z.fog&&h.enable(0),z.useFog&&h.enable(1),z.flatShading&&h.enable(2),z.logarithmicDepthBuffer&&h.enable(3),z.reversedDepthBuffer&&h.enable(4),z.skinning&&h.enable(5),z.morphTargets&&h.enable(6),z.morphNormals&&h.enable(7),z.morphColors&&h.enable(8),z.premultipliedAlpha&&h.enable(9),z.shadowMapEnabled&&h.enable(10),z.doubleSided&&h.enable(11),z.flipSided&&h.enable(12),z.useDepthPacking&&h.enable(13),z.dithering&&h.enable(14),z.transmission&&h.enable(15),z.sheen&&h.enable(16),z.opaque&&h.enable(17),z.pointsUvs&&h.enable(18),z.decodeVideoTexture&&h.enable(19),z.decodeVideoTextureEmissive&&h.enable(20),z.alphaToCoverage&&h.enable(21),I.push(h.mask)}function L(I){const z=A[I.type];let j;if(z){const ae=Xr[z];j=TE.clone(ae.uniforms)}else j=I.uniforms;return j}function B(I,z){let j=x.get(z);return j!==void 0?++j.usedTimes:(j=new kL(o,z,I,u),_.push(j),x.set(z,j)),j}function P(I){if(--I.usedTimes===0){const z=_.indexOf(I);_[z]=_[_.length-1],_.pop(),x.delete(I.cacheKey),I.destroy()}}function H(I){m.remove(I)}function W(){m.dispose()}return{getParameters:C,getProgramCacheKey:E,getUniforms:L,acquireProgram:B,releaseProgram:P,releaseShaderCache:H,programs:_,dispose:W}}function qL(){let o=new WeakMap;function e(f){return o.has(f)}function t(f){let h=o.get(f);return h===void 0&&(h={},o.set(f,h)),h}function i(f){o.delete(f)}function s(f,h,m){o.get(f)[h]=m}function u(){o=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:u}}function YL(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.material.id!==e.material.id?o.material.id-e.material.id:o.z!==e.z?o.z-e.z:o.id-e.id}function d1(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.z!==e.z?e.z-o.z:o.id-e.id}function p1(){const o=[];let e=0;const t=[],i=[],s=[];function u(){e=0,t.length=0,i.length=0,s.length=0}function f(x,b,M,A,R,C){let E=o[e];return E===void 0?(E={id:x.id,object:x,geometry:b,material:M,groupOrder:A,renderOrder:x.renderOrder,z:R,group:C},o[e]=E):(E.id=x.id,E.object=x,E.geometry=b,E.material=M,E.groupOrder=A,E.renderOrder=x.renderOrder,E.z=R,E.group=C),e++,E}function h(x,b,M,A,R,C){const E=f(x,b,M,A,R,C);M.transmission>0?i.push(E):M.transparent===!0?s.push(E):t.push(E)}function m(x,b,M,A,R,C){const E=f(x,b,M,A,R,C);M.transmission>0?i.unshift(E):M.transparent===!0?s.unshift(E):t.unshift(E)}function g(x,b){t.length>1&&t.sort(x||YL),i.length>1&&i.sort(b||d1),s.length>1&&s.sort(b||d1)}function _(){for(let x=e,b=o.length;x=u.length?(f=new p1,u.push(f)):f=u[s],f}function t(){o=new WeakMap}return{get:e,dispose:t}}function jL(){const o={};return{get:function(e){if(o[e.id]!==void 0)return o[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new Y,color:new pt};break;case"SpotLight":t={position:new Y,direction:new Y,color:new pt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Y,color:new pt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Y,skyColor:new pt,groundColor:new pt};break;case"RectAreaLight":t={color:new pt,position:new Y,halfWidth:new Y,halfHeight:new Y};break}return o[e.id]=t,t}}}function QL(){const o={};return{get:function(e){if(o[e.id]!==void 0)return o[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pe,shadowCameraNear:1,shadowCameraFar:1e3};break}return o[e.id]=t,t}}}let JL=0;function KL(o,e){return(e.castShadow?2:0)-(o.castShadow?2:0)+(e.map?1:0)-(o.map?1:0)}function $L(o){const e=new jL,t=QL(),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 g=0;g<9;g++)i.probe.push(new Y);const s=new Y,u=new kt,f=new kt;function h(g){let _=0,x=0,b=0;for(let I=0;I<9;I++)i.probe[I].set(0,0,0);let M=0,A=0,R=0,C=0,E=0,D=0,U=0,L=0,B=0,P=0,H=0;g.sort(KL);for(let I=0,z=g.length;I0&&(o.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ot.LTC_FLOAT_1,i.rectAreaLTC2=ot.LTC_FLOAT_2):(i.rectAreaLTC1=ot.LTC_HALF_1,i.rectAreaLTC2=ot.LTC_HALF_2)),i.ambient[0]=_,i.ambient[1]=x,i.ambient[2]=b;const W=i.hash;(W.directionalLength!==M||W.pointLength!==A||W.spotLength!==R||W.rectAreaLength!==C||W.hemiLength!==E||W.numDirectionalShadows!==D||W.numPointShadows!==U||W.numSpotShadows!==L||W.numSpotMaps!==B||W.numLightProbes!==H)&&(i.directional.length=M,i.spot.length=R,i.rectArea.length=C,i.point.length=A,i.hemi.length=E,i.directionalShadow.length=D,i.directionalShadowMap.length=D,i.pointShadow.length=U,i.pointShadowMap.length=U,i.spotShadow.length=L,i.spotShadowMap.length=L,i.directionalShadowMatrix.length=D,i.pointShadowMatrix.length=U,i.spotLightMatrix.length=L+B-P,i.spotLightMap.length=B,i.numSpotLightShadowsWithMaps=P,i.numLightProbes=H,W.directionalLength=M,W.pointLength=A,W.spotLength=R,W.rectAreaLength=C,W.hemiLength=E,W.numDirectionalShadows=D,W.numPointShadows=U,W.numSpotShadows=L,W.numSpotMaps=B,W.numLightProbes=H,i.version=JL++)}function m(g,_){let x=0,b=0,M=0,A=0,R=0;const C=_.matrixWorldInverse;for(let E=0,D=g.length;E=f.length?(h=new m1(o),f.push(h)):h=f[u],h}function i(){e=new WeakMap}return{get:t,dispose:i}}const tI=`void main() { gl_Position = vec4( position, 1.0 ); }`,nI=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); }`,iI=[new Y(1,0,0),new Y(-1,0,0),new Y(0,1,0),new Y(0,-1,0),new Y(0,0,1),new Y(0,0,-1)],aI=[new Y(0,-1,0),new Y(0,-1,0),new Y(0,0,1),new Y(0,0,-1),new Y(0,-1,0),new Y(0,-1,0)],g1=new kt,Vp=new Y,gx=new Y;function sI(o,e,t){let i=new Jh;const s=new Pe,u=new Pe,f=new Wn,h=new LS,m=new IS,g={},_=t.maxTextureSize,x={[Cl]:ts,[ts]:Cl,[No]:No},b=new vr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Pe},radius:{value:4}},vertexShader:tI,fragmentShader:nI}),M=b.clone();M.defines.HORIZONTAL_PASS=1;const A=new Yt;A.setAttribute("position",new Hn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const R=new Gi(A,b),C=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=zh;let E=this.type;this.render=function(P,H,W){if(C.enabled===!1||C.autoUpdate===!1&&C.needsUpdate===!1||P.length===0)return;P.type===Xp&&(rt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),P.type=zh);const I=o.getRenderTarget(),z=o.getActiveCubeFace(),j=o.getActiveMipmapLevel(),ae=o.state;ae.setBlending(Io),ae.buffers.depth.getReversed()===!0?ae.buffers.color.setClear(0,0,0,0):ae.buffers.color.setClear(1,1,1,1),ae.buffers.depth.setTest(!0),ae.setScissorTest(!1);const $=E!==this.type;$&&H.traverse(function(ue){ue.material&&(Array.isArray(ue.material)?ue.material.forEach(he=>he.needsUpdate=!0):ue.material.needsUpdate=!0)});for(let ue=0,he=P.length;ue_||s.y>_)&&(s.x>_&&(u.x=Math.floor(_/ce.x),s.x=u.x*ce.x,K.mapSize.x=u.x),s.y>_&&(u.y=Math.floor(_/ce.y),s.y=u.y*ce.y,K.mapSize.y=u.y)),K.map===null||$===!0){if(K.map!==null&&(K.map.depthTexture!==null&&(K.map.depthTexture.dispose(),K.map.depthTexture=null),K.map.dispose()),this.type===kc){if(q.isPointLight){rt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}K.map=new ks(s.x,s.y,{format:jc,type:zo,minFilter:ai,magFilter:ai,generateMipmaps:!1}),K.map.texture.name=q.name+".shadowMap",K.map.depthTexture=new qh(s.x,s.y,es),K.map.depthTexture.name=q.name+".shadowMapDepth",K.map.depthTexture.format=Po,K.map.depthTexture.compareFunction=null,K.map.depthTexture.minFilter=Li,K.map.depthTexture.magFilter=Li}else{q.isPointLight?(K.map=new yS(s.x),K.map.depthTexture=new zE(s.x,gr)):(K.map=new ks(s.x,s.y),K.map.depthTexture=new qh(s.x,s.y,gr)),K.map.depthTexture.name=q.name+".shadowMap",K.map.depthTexture.format=Po;const Ce=o.state.buffers.depth.getReversed();this.type===zh?(K.map.depthTexture.compareFunction=Ce?my:py,K.map.depthTexture.minFilter=ai,K.map.depthTexture.magFilter=ai):(K.map.depthTexture.compareFunction=null,K.map.depthTexture.minFilter=Li,K.map.depthTexture.magFilter=Li)}K.camera.updateProjectionMatrix()}const Ae=K.map.isWebGLCubeRenderTarget?6:1;for(let Ce=0;Ce0||H.map&&H.alphaTest>0||H.alphaToCoverage===!0){const ae=z.uuid,$=H.uuid;let ue=g[ae];ue===void 0&&(ue={},g[ae]=ue);let he=ue[$];he===void 0&&(he=z.clone(),ue[$]=he,H.addEventListener("dispose",B)),z=he}if(z.visible=H.visible,z.wireframe=H.wireframe,I===kc?z.side=H.shadowSide!==null?H.shadowSide:H.side:z.side=H.shadowSide!==null?H.shadowSide:x[H.side],z.alphaMap=H.alphaMap,z.alphaTest=H.alphaToCoverage===!0?.5:H.alphaTest,z.map=H.map,z.clipShadows=H.clipShadows,z.clippingPlanes=H.clippingPlanes,z.clipIntersection=H.clipIntersection,z.displacementMap=H.displacementMap,z.displacementScale=H.displacementScale,z.displacementBias=H.displacementBias,z.wireframeLinewidth=H.wireframeLinewidth,z.linewidth=H.linewidth,W.isPointLight===!0&&z.isMeshDistanceMaterial===!0){const ae=o.properties.get(z);ae.light=W}return z}function L(P,H,W,I,z){if(P.visible===!1)return;if(P.layers.test(H.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&z===kc)&&(!P.frustumCulled||i.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,P.matrixWorld);const $=e.update(P),ue=P.material;if(Array.isArray(ue)){const he=$.groups;for(let q=0,K=he.length;q=1):ce.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(ce)[1]),q=K>=2);let Ae=null,Ce={};const X=o.getParameter(o.SCISSOR_BOX),se=o.getParameter(o.VIEWPORT),Ee=new Wn().fromArray(X),Oe=new Wn().fromArray(se);function nt(te,it,Ge,st){const Fe=new Uint8Array(4),Ne=o.createTexture();o.bindTexture(te,Ne),o.texParameteri(te,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(te,o.TEXTURE_MAG_FILTER,o.NEAREST);for(let je=0;je"u"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new Pe,_=new WeakMap;let x;const b=new WeakMap;let M=!1;try{M=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function A(G,O){return M?new OffscreenCanvas(G,O):lm("canvas")}function R(G,O,ne){let Se=1;const Le=We(G);if((Le.width>ne||Le.height>ne)&&(Se=ne/Math.max(Le.width,Le.height)),Se<1)if(typeof HTMLImageElement<"u"&&G instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&G instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&G instanceof ImageBitmap||typeof VideoFrame<"u"&&G instanceof VideoFrame){const be=Math.floor(Se*Le.width),ct=Math.floor(Se*Le.height);x===void 0&&(x=A(be,ct));const Ze=O?A(be,ct):x;return Ze.width=be,Ze.height=ct,Ze.getContext("2d").drawImage(G,0,0,be,ct),rt("WebGLRenderer: Texture has been resized from ("+Le.width+"x"+Le.height+") to ("+be+"x"+ct+")."),Ze}else return"data"in G&&rt("WebGLRenderer: Image in DataTexture is too big ("+Le.width+"x"+Le.height+")."),G;return G}function C(G){return G.generateMipmaps}function E(G){o.generateMipmap(G)}function D(G){return G.isWebGLCubeRenderTarget?o.TEXTURE_CUBE_MAP:G.isWebGL3DRenderTarget?o.TEXTURE_3D:G.isWebGLArrayRenderTarget||G.isCompressedArrayTexture?o.TEXTURE_2D_ARRAY:o.TEXTURE_2D}function U(G,O,ne,Se,Le=!1){if(G!==null){if(o[G]!==void 0)return o[G];rt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+G+"'")}let be=O;if(O===o.RED&&(ne===o.FLOAT&&(be=o.R32F),ne===o.HALF_FLOAT&&(be=o.R16F),ne===o.UNSIGNED_BYTE&&(be=o.R8)),O===o.RED_INTEGER&&(ne===o.UNSIGNED_BYTE&&(be=o.R8UI),ne===o.UNSIGNED_SHORT&&(be=o.R16UI),ne===o.UNSIGNED_INT&&(be=o.R32UI),ne===o.BYTE&&(be=o.R8I),ne===o.SHORT&&(be=o.R16I),ne===o.INT&&(be=o.R32I)),O===o.RG&&(ne===o.FLOAT&&(be=o.RG32F),ne===o.HALF_FLOAT&&(be=o.RG16F),ne===o.UNSIGNED_BYTE&&(be=o.RG8)),O===o.RG_INTEGER&&(ne===o.UNSIGNED_BYTE&&(be=o.RG8UI),ne===o.UNSIGNED_SHORT&&(be=o.RG16UI),ne===o.UNSIGNED_INT&&(be=o.RG32UI),ne===o.BYTE&&(be=o.RG8I),ne===o.SHORT&&(be=o.RG16I),ne===o.INT&&(be=o.RG32I)),O===o.RGB_INTEGER&&(ne===o.UNSIGNED_BYTE&&(be=o.RGB8UI),ne===o.UNSIGNED_SHORT&&(be=o.RGB16UI),ne===o.UNSIGNED_INT&&(be=o.RGB32UI),ne===o.BYTE&&(be=o.RGB8I),ne===o.SHORT&&(be=o.RGB16I),ne===o.INT&&(be=o.RGB32I)),O===o.RGBA_INTEGER&&(ne===o.UNSIGNED_BYTE&&(be=o.RGBA8UI),ne===o.UNSIGNED_SHORT&&(be=o.RGBA16UI),ne===o.UNSIGNED_INT&&(be=o.RGBA32UI),ne===o.BYTE&&(be=o.RGBA8I),ne===o.SHORT&&(be=o.RGBA16I),ne===o.INT&&(be=o.RGBA32I)),O===o.RGB&&(ne===o.UNSIGNED_INT_5_9_9_9_REV&&(be=o.RGB9_E5),ne===o.UNSIGNED_INT_10F_11F_11F_REV&&(be=o.R11F_G11F_B10F)),O===o.RGBA){const ct=Le?rm:xn.getTransfer(Se);ne===o.FLOAT&&(be=o.RGBA32F),ne===o.HALF_FLOAT&&(be=o.RGBA16F),ne===o.UNSIGNED_BYTE&&(be=ct===On?o.SRGB8_ALPHA8:o.RGBA8),ne===o.UNSIGNED_SHORT_4_4_4_4&&(be=o.RGBA4),ne===o.UNSIGNED_SHORT_5_5_5_1&&(be=o.RGB5_A1)}return(be===o.R16F||be===o.R32F||be===o.RG16F||be===o.RG32F||be===o.RGBA16F||be===o.RGBA32F)&&e.get("EXT_color_buffer_float"),be}function L(G,O){let ne;return G?O===null||O===gr||O===Fh?ne=o.DEPTH24_STENCIL8:O===es?ne=o.DEPTH32F_STENCIL8:O===Bh&&(ne=o.DEPTH24_STENCIL8,rt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===gr||O===Fh?ne=o.DEPTH_COMPONENT24:O===es?ne=o.DEPTH_COMPONENT32F:O===Bh&&(ne=o.DEPTH_COMPONENT16),ne}function B(G,O){return C(G)===!0||G.isFramebufferTexture&&G.minFilter!==Li&&G.minFilter!==ai?Math.log2(Math.max(O.width,O.height))+1:G.mipmaps!==void 0&&G.mipmaps.length>0?G.mipmaps.length:G.isCompressedTexture&&Array.isArray(G.image)?O.mipmaps.length:1}function P(G){const O=G.target;O.removeEventListener("dispose",P),W(O),O.isVideoTexture&&_.delete(O)}function H(G){const O=G.target;O.removeEventListener("dispose",H),z(O)}function W(G){const O=i.get(G);if(O.__webglInit===void 0)return;const ne=G.source,Se=b.get(ne);if(Se){const Le=Se[O.__cacheKey];Le.usedTimes--,Le.usedTimes===0&&I(G),Object.keys(Se).length===0&&b.delete(ne)}i.remove(G)}function I(G){const O=i.get(G);o.deleteTexture(O.__webglTexture);const ne=G.source,Se=b.get(ne);delete Se[O.__cacheKey],f.memory.textures--}function z(G){const O=i.get(G);if(G.depthTexture&&(G.depthTexture.dispose(),i.remove(G.depthTexture)),G.isWebGLCubeRenderTarget)for(let Se=0;Se<6;Se++){if(Array.isArray(O.__webglFramebuffer[Se]))for(let Le=0;Le=s.maxTextures&&rt("WebGLTextures: Trying to use "+G+" texture units while this GPU supports only "+s.maxTextures),j+=1,G}function ue(G){const O=[];return O.push(G.wrapS),O.push(G.wrapT),O.push(G.wrapR||0),O.push(G.magFilter),O.push(G.minFilter),O.push(G.anisotropy),O.push(G.internalFormat),O.push(G.format),O.push(G.type),O.push(G.generateMipmaps),O.push(G.premultiplyAlpha),O.push(G.flipY),O.push(G.unpackAlignment),O.push(G.colorSpace),O.join()}function he(G,O){const ne=i.get(G);if(G.isVideoTexture&&tt(G),G.isRenderTargetTexture===!1&&G.isExternalTexture!==!0&&G.version>0&&ne.__version!==G.version){const Se=G.image;if(Se===null)rt("WebGLRenderer: Texture marked for update but no image data found.");else if(Se.complete===!1)rt("WebGLRenderer: Texture marked for update but image is incomplete");else{fe(ne,G,O);return}}else G.isExternalTexture&&(ne.__webglTexture=G.sourceTexture?G.sourceTexture:null);t.bindTexture(o.TEXTURE_2D,ne.__webglTexture,o.TEXTURE0+O)}function q(G,O){const ne=i.get(G);if(G.isRenderTargetTexture===!1&&G.version>0&&ne.__version!==G.version){fe(ne,G,O);return}else G.isExternalTexture&&(ne.__webglTexture=G.sourceTexture?G.sourceTexture:null);t.bindTexture(o.TEXTURE_2D_ARRAY,ne.__webglTexture,o.TEXTURE0+O)}function K(G,O){const ne=i.get(G);if(G.isRenderTargetTexture===!1&&G.version>0&&ne.__version!==G.version){fe(ne,G,O);return}t.bindTexture(o.TEXTURE_3D,ne.__webglTexture,o.TEXTURE0+O)}function ce(G,O){const ne=i.get(G);if(G.isCubeDepthTexture!==!0&&G.version>0&&ne.__version!==G.version){Te(ne,G,O);return}t.bindTexture(o.TEXTURE_CUBE_MAP,ne.__webglTexture,o.TEXTURE0+O)}const Ae={[nm]:o.REPEAT,[As]:o.CLAMP_TO_EDGE,[im]:o.MIRRORED_REPEAT},Ce={[Li]:o.NEAREST,[rS]:o.NEAREST_MIPMAP_NEAREST,[Lh]:o.NEAREST_MIPMAP_LINEAR,[ai]:o.LINEAR,[Wp]:o.LINEAR_MIPMAP_NEAREST,[Uo]:o.LINEAR_MIPMAP_LINEAR},X={[hE]:o.NEVER,[vE]:o.ALWAYS,[dE]:o.LESS,[py]:o.LEQUAL,[pE]:o.EQUAL,[my]:o.GEQUAL,[mE]:o.GREATER,[gE]:o.NOTEQUAL};function se(G,O){if(O.type===es&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===ai||O.magFilter===Wp||O.magFilter===Lh||O.magFilter===Uo||O.minFilter===ai||O.minFilter===Wp||O.minFilter===Lh||O.minFilter===Uo)&&rt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),o.texParameteri(G,o.TEXTURE_WRAP_S,Ae[O.wrapS]),o.texParameteri(G,o.TEXTURE_WRAP_T,Ae[O.wrapT]),(G===o.TEXTURE_3D||G===o.TEXTURE_2D_ARRAY)&&o.texParameteri(G,o.TEXTURE_WRAP_R,Ae[O.wrapR]),o.texParameteri(G,o.TEXTURE_MAG_FILTER,Ce[O.magFilter]),o.texParameteri(G,o.TEXTURE_MIN_FILTER,Ce[O.minFilter]),O.compareFunction&&(o.texParameteri(G,o.TEXTURE_COMPARE_MODE,o.COMPARE_REF_TO_TEXTURE),o.texParameteri(G,o.TEXTURE_COMPARE_FUNC,X[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===Li||O.minFilter!==Lh&&O.minFilter!==Uo||O.type===es&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||i.get(O).__currentAnisotropy){const ne=e.get("EXT_texture_filter_anisotropic");o.texParameterf(G,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,s.getMaxAnisotropy())),i.get(O).__currentAnisotropy=O.anisotropy}}}function Ee(G,O){let ne=!1;G.__webglInit===void 0&&(G.__webglInit=!0,O.addEventListener("dispose",P));const Se=O.source;let Le=b.get(Se);Le===void 0&&(Le={},b.set(Se,Le));const be=ue(O);if(be!==G.__cacheKey){Le[be]===void 0&&(Le[be]={texture:o.createTexture(),usedTimes:0},f.memory.textures++,ne=!0),Le[be].usedTimes++;const ct=Le[G.__cacheKey];ct!==void 0&&(Le[G.__cacheKey].usedTimes--,ct.usedTimes===0&&I(O)),G.__cacheKey=be,G.__webglTexture=Le[be].texture}return ne}function Oe(G,O,ne){return Math.floor(Math.floor(G/ne)/O)}function nt(G,O,ne,Se){const be=G.updateRanges;if(be.length===0)t.texSubImage2D(o.TEXTURE_2D,0,0,0,O.width,O.height,ne,Se,O.data);else{be.sort((Be,Xe)=>Be.start-Xe.start);let ct=0;for(let Be=1;Be0){te&&it&&t.texStorage2D(o.TEXTURE_2D,st,lt,Zt[0].width,Zt[0].height);for(let Fe=0,Ne=Zt.length;Fe0){const je=kx($e.width,$e.height,O.format,O.type);for(const Bt of O.layerUpdates){const dn=$e.data.subarray(Bt*je/$e.data.BYTES_PER_ELEMENT,(Bt+1)*je/$e.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(o.TEXTURE_2D_ARRAY,Fe,0,0,Bt,$e.width,$e.height,1,Xe,dn)}O.clearLayerUpdates()}else t.compressedTexSubImage3D(o.TEXTURE_2D_ARRAY,Fe,0,0,0,$e.width,$e.height,Be.depth,Xe,$e.data)}else t.compressedTexImage3D(o.TEXTURE_2D_ARRAY,Fe,lt,$e.width,$e.height,Be.depth,0,$e.data,0,0);else rt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else te?Ge&&t.texSubImage3D(o.TEXTURE_2D_ARRAY,Fe,0,0,0,$e.width,$e.height,Be.depth,Xe,ft,$e.data):t.texImage3D(o.TEXTURE_2D_ARRAY,Fe,lt,$e.width,$e.height,Be.depth,0,Xe,ft,$e.data)}else{te&&it&&t.texStorage2D(o.TEXTURE_2D,st,lt,Zt[0].width,Zt[0].height);for(let Fe=0,Ne=Zt.length;Fe0){const Fe=kx(Be.width,Be.height,O.format,O.type);for(const Ne of O.layerUpdates){const je=Be.data.subarray(Ne*Fe/Be.data.BYTES_PER_ELEMENT,(Ne+1)*Fe/Be.data.BYTES_PER_ELEMENT);t.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,Ne,Be.width,Be.height,1,Xe,ft,je)}O.clearLayerUpdates()}else t.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,0,Be.width,Be.height,Be.depth,Xe,ft,Be.data)}else t.texImage3D(o.TEXTURE_2D_ARRAY,0,lt,Be.width,Be.height,Be.depth,0,Xe,ft,Be.data);else if(O.isData3DTexture)te?(it&&t.texStorage3D(o.TEXTURE_3D,st,lt,Be.width,Be.height,Be.depth),Ge&&t.texSubImage3D(o.TEXTURE_3D,0,0,0,0,Be.width,Be.height,Be.depth,Xe,ft,Be.data)):t.texImage3D(o.TEXTURE_3D,0,lt,Be.width,Be.height,Be.depth,0,Xe,ft,Be.data);else if(O.isFramebufferTexture){if(it)if(te)t.texStorage2D(o.TEXTURE_2D,st,lt,Be.width,Be.height);else{let Fe=Be.width,Ne=Be.height;for(let je=0;je>=1,Ne>>=1}}else if(Zt.length>0){if(te&&it){const Fe=We(Zt[0]);t.texStorage2D(o.TEXTURE_2D,st,lt,Fe.width,Fe.height)}for(let Fe=0,Ne=Zt.length;Fe0&&st++;const Ne=We(Xe[0]);t.texStorage2D(o.TEXTURE_CUBE_MAP,st,Zt,Ne.width,Ne.height)}for(let Ne=0;Ne<6;Ne++)if(Be){te?Ge&&t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,0,0,Xe[Ne].width,Xe[Ne].height,lt,$e,Xe[Ne].data):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,Zt,Xe[Ne].width,Xe[Ne].height,0,lt,$e,Xe[Ne].data);for(let je=0;je>be),ft=Math.max(1,O.height>>be);Le===o.TEXTURE_3D||Le===o.TEXTURE_2D_ARRAY?t.texImage3D(Le,be,gt,Xe,ft,O.depth,0,ct,Ze,null):t.texImage2D(Le,be,gt,Xe,ft,0,ct,Ze,null)}t.bindFramebuffer(o.FRAMEBUFFER,G),St(O)?h.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,Se,Le,Be.__webglTexture,0,Z(O)):(Le===o.TEXTURE_2D||Le>=o.TEXTURE_CUBE_MAP_POSITIVE_X&&Le<=o.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&o.framebufferTexture2D(o.FRAMEBUFFER,Se,Le,Be.__webglTexture,be),t.bindFramebuffer(o.FRAMEBUFFER,null)}function et(G,O,ne){if(o.bindRenderbuffer(o.RENDERBUFFER,G),O.depthBuffer){const Se=O.depthTexture,Le=Se&&Se.isDepthTexture?Se.type:null,be=L(O.stencilBuffer,Le),ct=O.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT;St(O)?h.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,Z(O),be,O.width,O.height):ne?o.renderbufferStorageMultisample(o.RENDERBUFFER,Z(O),be,O.width,O.height):o.renderbufferStorage(o.RENDERBUFFER,be,O.width,O.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,ct,o.RENDERBUFFER,G)}else{const Se=O.textures;for(let Le=0;Le{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,Se.removeEventListener("dispose",Le)};Se.addEventListener("dispose",Le),O.__depthDisposeCallback=Le}O.__boundDepthTexture=Se}if(G.depthTexture&&!O.__autoAllocateDepthBuffer)if(ne)for(let Se=0;Se<6;Se++)ut(O.__webglFramebuffer[Se],G,Se);else{const Se=G.texture.mipmaps;Se&&Se.length>0?ut(O.__webglFramebuffer[0],G,0):ut(O.__webglFramebuffer,G,0)}else if(ne){O.__webglDepthbuffer=[];for(let Se=0;Se<6;Se++)if(t.bindFramebuffer(o.FRAMEBUFFER,O.__webglFramebuffer[Se]),O.__webglDepthbuffer[Se]===void 0)O.__webglDepthbuffer[Se]=o.createRenderbuffer(),et(O.__webglDepthbuffer[Se],G,!1);else{const Le=G.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT,be=O.__webglDepthbuffer[Se];o.bindRenderbuffer(o.RENDERBUFFER,be),o.framebufferRenderbuffer(o.FRAMEBUFFER,Le,o.RENDERBUFFER,be)}}else{const Se=G.texture.mipmaps;if(Se&&Se.length>0?t.bindFramebuffer(o.FRAMEBUFFER,O.__webglFramebuffer[0]):t.bindFramebuffer(o.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=o.createRenderbuffer(),et(O.__webglDepthbuffer,G,!1);else{const Le=G.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT,be=O.__webglDepthbuffer;o.bindRenderbuffer(o.RENDERBUFFER,be),o.framebufferRenderbuffer(o.FRAMEBUFFER,Le,o.RENDERBUFFER,be)}}t.bindFramebuffer(o.FRAMEBUFFER,null)}function on(G,O,ne){const Se=i.get(G);O!==void 0&&Je(Se.__webglFramebuffer,G,G.texture,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,0),ne!==void 0&&Jt(G)}function Dt(G){const O=G.texture,ne=i.get(G),Se=i.get(O);G.addEventListener("dispose",H);const Le=G.textures,be=G.isWebGLCubeRenderTarget===!0,ct=Le.length>1;if(ct||(Se.__webglTexture===void 0&&(Se.__webglTexture=o.createTexture()),Se.__version=O.version,f.memory.textures++),be){ne.__webglFramebuffer=[];for(let Ze=0;Ze<6;Ze++)if(O.mipmaps&&O.mipmaps.length>0){ne.__webglFramebuffer[Ze]=[];for(let gt=0;gt0){ne.__webglFramebuffer=[];for(let Ze=0;Ze0&&St(G)===!1){ne.__webglMultisampledFramebuffer=o.createFramebuffer(),ne.__webglColorRenderbuffer=[],t.bindFramebuffer(o.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Ze=0;Ze0)for(let gt=0;gt0)for(let gt=0;gt0){if(St(G)===!1){const O=G.textures,ne=G.width,Se=G.height;let Le=o.COLOR_BUFFER_BIT;const be=G.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT,ct=i.get(G),Ze=O.length>1;if(Ze)for(let wt=0;wt0?t.bindFramebuffer(o.DRAW_FRAMEBUFFER,ct.__webglFramebuffer[0]):t.bindFramebuffer(o.DRAW_FRAMEBUFFER,ct.__webglFramebuffer);for(let wt=0;wt0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function tt(G){const O=f.render.frame;_.get(G)!==O&&(_.set(G,O),G.update())}function Mt(G,O){const ne=G.colorSpace,Se=G.format,Le=G.type;return G.isCompressedTexture===!0||G.isVideoTexture===!0||ne!==Lu&&ne!==Tl&&(xn.getTransfer(ne)===On?(Se!==La||Le!==Ka)&&rt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Tt("WebGLTextures: Unsupported texture color space:",ne)),O}function We(G){return typeof HTMLImageElement<"u"&&G instanceof HTMLImageElement?(g.width=G.naturalWidth||G.width,g.height=G.naturalHeight||G.height):typeof VideoFrame<"u"&&G instanceof VideoFrame?(g.width=G.displayWidth,g.height=G.displayHeight):(g.width=G.width,g.height=G.height),g}this.allocateTextureUnit=$,this.resetTextureUnits=ae,this.setTexture2D=he,this.setTexture2DArray=q,this.setTexture3D=K,this.setTextureCube=ce,this.rebindTextures=on,this.setupRenderTarget=Dt,this.updateRenderTargetMipmap=Re,this.updateMultisampleRenderTarget=Ke,this.setupDepthRenderbuffer=Jt,this.setupFrameBufferTexture=Je,this.useMultisampledRTT=St,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function AT(o,e){function t(i,s=Tl){let u;const f=xn.getTransfer(s);if(i===Ka)return o.UNSIGNED_BYTE;if(i===ly)return o.UNSIGNED_SHORT_4_4_4_4;if(i===uy)return o.UNSIGNED_SHORT_5_5_5_1;if(i===uS)return o.UNSIGNED_INT_5_9_9_9_REV;if(i===cS)return o.UNSIGNED_INT_10F_11F_11F_REV;if(i===oS)return o.BYTE;if(i===lS)return o.SHORT;if(i===Bh)return o.UNSIGNED_SHORT;if(i===oy)return o.INT;if(i===gr)return o.UNSIGNED_INT;if(i===es)return o.FLOAT;if(i===zo)return o.HALF_FLOAT;if(i===fS)return o.ALPHA;if(i===hS)return o.RGB;if(i===La)return o.RGBA;if(i===Po)return o.DEPTH_COMPONENT;if(i===Ru)return o.DEPTH_STENCIL;if(i===cy)return o.RED;if(i===xm)return o.RED_INTEGER;if(i===jc)return o.RG;if(i===fy)return o.RG_INTEGER;if(i===hy)return o.RGBA_INTEGER;if(i===qp||i===Yp||i===Zp||i===jp)if(f===On)if(u=e.get("WEBGL_compressed_texture_s3tc_srgb"),u!==null){if(i===qp)return u.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Yp)return u.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Zp)return u.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===jp)return u.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(u=e.get("WEBGL_compressed_texture_s3tc"),u!==null){if(i===qp)return u.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Yp)return u.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Zp)return u.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===jp)return u.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===vv||i===yv||i===_v||i===xv)if(u=e.get("WEBGL_compressed_texture_pvrtc"),u!==null){if(i===vv)return u.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===yv)return u.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===_v)return u.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===xv)return u.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Sv||i===bv||i===Mv||i===Ev||i===Tv||i===Av||i===wv)if(u=e.get("WEBGL_compressed_texture_etc"),u!==null){if(i===Sv||i===bv)return f===On?u.COMPRESSED_SRGB8_ETC2:u.COMPRESSED_RGB8_ETC2;if(i===Mv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:u.COMPRESSED_RGBA8_ETC2_EAC;if(i===Ev)return u.COMPRESSED_R11_EAC;if(i===Tv)return u.COMPRESSED_SIGNED_R11_EAC;if(i===Av)return u.COMPRESSED_RG11_EAC;if(i===wv)return u.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Cv||i===Rv||i===Dv||i===Nv||i===Uv||i===Lv||i===Iv||i===Ov||i===zv||i===Pv||i===Bv||i===Fv||i===Vv||i===kv)if(u=e.get("WEBGL_compressed_texture_astc"),u!==null){if(i===Cv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:u.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Rv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:u.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Dv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:u.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Nv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:u.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Uv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:u.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Lv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:u.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Iv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:u.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Ov)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:u.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===zv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:u.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Pv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:u.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Bv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:u.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Fv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:u.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Vv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:u.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===kv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:u.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Hv||i===Gv||i===Xv)if(u=e.get("EXT_texture_compression_bptc"),u!==null){if(i===Hv)return f===On?u.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:u.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Gv)return u.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Xv)return u.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Wv||i===qv||i===Yv||i===Zv)if(u=e.get("EXT_texture_compression_rgtc"),u!==null){if(i===Wv)return u.COMPRESSED_RED_RGTC1_EXT;if(i===qv)return u.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Yv)return u.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Zv)return u.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Fh?o.UNSIGNED_INT_24_8:o[i]!==void 0?o[i]:null}return{convert:t}}const uI=` void main() { gl_Position = vec4( position, 1.0 ); }`,cI=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; void main() { vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); if ( coord.x >= 1.0 ) { gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; } else { gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; } }`;class fI{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new MS(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new vr({vertexShader:uI,fragmentShader:cI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Gi(new Kh(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class hI extends Bo{constructor(e,t){super();const i=this;let s=null,u=1,f=null,h="local-floor",m=1,g=null,_=null,x=null,b=null,M=null,A=null;const R=typeof XRWebGLBinding<"u",C=new fI,E={},D=t.getContextAttributes();let U=null,L=null;const B=[],P=[],H=new Pe;let W=null;const I=new aa;I.viewport=new Wn;const z=new aa;z.viewport=new Wn;const j=[I,z],ae=new mT;let $=null,ue=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(fe){let Te=B[fe];return Te===void 0&&(Te=new sv,B[fe]=Te),Te.getTargetRaySpace()},this.getControllerGrip=function(fe){let Te=B[fe];return Te===void 0&&(Te=new sv,B[fe]=Te),Te.getGripSpace()},this.getHand=function(fe){let Te=B[fe];return Te===void 0&&(Te=new sv,B[fe]=Te),Te.getHandSpace()};function he(fe){const Te=P.indexOf(fe.inputSource);if(Te===-1)return;const Je=B[Te];Je!==void 0&&(Je.update(fe.inputSource,fe.frame,g||f),Je.dispatchEvent({type:fe.type,data:fe.inputSource}))}function q(){s.removeEventListener("select",he),s.removeEventListener("selectstart",he),s.removeEventListener("selectend",he),s.removeEventListener("squeeze",he),s.removeEventListener("squeezestart",he),s.removeEventListener("squeezeend",he),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",K);for(let fe=0;fe=0&&(P[et]=null,B[et].disconnect(Je))}for(let Te=0;Te=P.length){P.push(Je),et=Jt;break}else if(P[Jt]===null){P[Jt]=Je,et=Jt;break}if(et===-1)break}const ut=B[et];ut&&ut.connect(Je)}}const ce=new Y,Ae=new Y;function Ce(fe,Te,Je){ce.setFromMatrixPosition(Te.matrixWorld),Ae.setFromMatrixPosition(Je.matrixWorld);const et=ce.distanceTo(Ae),ut=Te.projectionMatrix.elements,Jt=Je.projectionMatrix.elements,on=ut[14]/(ut[10]-1),Dt=ut[14]/(ut[10]+1),Re=(ut[9]+1)/ut[5],Ve=(ut[9]-1)/ut[5],Ue=(ut[8]-1)/ut[0],Ke=(Jt[8]+1)/Jt[0],Z=on*Ue,St=on*Ke,tt=et/(-Ue+Ke),Mt=tt*-Ue;if(Te.matrixWorld.decompose(fe.position,fe.quaternion,fe.scale),fe.translateX(Mt),fe.translateZ(tt),fe.matrixWorld.compose(fe.position,fe.quaternion,fe.scale),fe.matrixWorldInverse.copy(fe.matrixWorld).invert(),ut[10]===-1)fe.projectionMatrix.copy(Te.projectionMatrix),fe.projectionMatrixInverse.copy(Te.projectionMatrixInverse);else{const We=on+tt,G=Dt+tt,O=Z-Mt,ne=St+(et-Mt),Se=Re*Dt/G*We,Le=Ve*Dt/G*We;fe.projectionMatrix.makePerspective(O,ne,Se,Le,We,G),fe.projectionMatrixInverse.copy(fe.projectionMatrix).invert()}}function X(fe,Te){Te===null?fe.matrixWorld.copy(fe.matrix):fe.matrixWorld.multiplyMatrices(Te.matrixWorld,fe.matrix),fe.matrixWorldInverse.copy(fe.matrixWorld).invert()}this.updateCamera=function(fe){if(s===null)return;let Te=fe.near,Je=fe.far;C.texture!==null&&(C.depthNear>0&&(Te=C.depthNear),C.depthFar>0&&(Je=C.depthFar)),ae.near=z.near=I.near=Te,ae.far=z.far=I.far=Je,($!==ae.near||ue!==ae.far)&&(s.updateRenderState({depthNear:ae.near,depthFar:ae.far}),$=ae.near,ue=ae.far),ae.layers.mask=fe.layers.mask|6,I.layers.mask=ae.layers.mask&3,z.layers.mask=ae.layers.mask&5;const et=fe.parent,ut=ae.cameras;X(ae,et);for(let Jt=0;Jt0&&(C.alphaTest.value=E.alphaTest);const D=e.get(E),U=D.envMap,L=D.envMapRotation;U&&(C.envMap.value=U,Bc.copy(L),Bc.x*=-1,Bc.y*=-1,Bc.z*=-1,U.isCubeTexture&&U.isRenderTargetTexture===!1&&(Bc.y*=-1,Bc.z*=-1),C.envMapRotation.value.setFromMatrix4(dI.makeRotationFromEuler(Bc)),C.flipEnvMap.value=U.isCubeTexture&&U.isRenderTargetTexture===!1?-1:1,C.reflectivity.value=E.reflectivity,C.ior.value=E.ior,C.refractionRatio.value=E.refractionRatio),E.lightMap&&(C.lightMap.value=E.lightMap,C.lightMapIntensity.value=E.lightMapIntensity,t(E.lightMap,C.lightMapTransform)),E.aoMap&&(C.aoMap.value=E.aoMap,C.aoMapIntensity.value=E.aoMapIntensity,t(E.aoMap,C.aoMapTransform))}function f(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform))}function h(C,E){C.dashSize.value=E.dashSize,C.totalSize.value=E.dashSize+E.gapSize,C.scale.value=E.scale}function m(C,E,D,U){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.size.value=E.size*D,C.scale.value=U*.5,E.map&&(C.map.value=E.map,t(E.map,C.uvTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function g(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.rotation.value=E.rotation,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function _(C,E){C.specular.value.copy(E.specular),C.shininess.value=Math.max(E.shininess,1e-4)}function x(C,E){E.gradientMap&&(C.gradientMap.value=E.gradientMap)}function b(C,E){C.metalness.value=E.metalness,E.metalnessMap&&(C.metalnessMap.value=E.metalnessMap,t(E.metalnessMap,C.metalnessMapTransform)),C.roughness.value=E.roughness,E.roughnessMap&&(C.roughnessMap.value=E.roughnessMap,t(E.roughnessMap,C.roughnessMapTransform)),E.envMap&&(C.envMapIntensity.value=E.envMapIntensity)}function M(C,E,D){C.ior.value=E.ior,E.sheen>0&&(C.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),C.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(C.sheenColorMap.value=E.sheenColorMap,t(E.sheenColorMap,C.sheenColorMapTransform)),E.sheenRoughnessMap&&(C.sheenRoughnessMap.value=E.sheenRoughnessMap,t(E.sheenRoughnessMap,C.sheenRoughnessMapTransform))),E.clearcoat>0&&(C.clearcoat.value=E.clearcoat,C.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(C.clearcoatMap.value=E.clearcoatMap,t(E.clearcoatMap,C.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(C.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,t(E.clearcoatRoughnessMap,C.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(C.clearcoatNormalMap.value=E.clearcoatNormalMap,t(E.clearcoatNormalMap,C.clearcoatNormalMapTransform),C.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===ts&&C.clearcoatNormalScale.value.negate())),E.dispersion>0&&(C.dispersion.value=E.dispersion),E.iridescence>0&&(C.iridescence.value=E.iridescence,C.iridescenceIOR.value=E.iridescenceIOR,C.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],C.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(C.iridescenceMap.value=E.iridescenceMap,t(E.iridescenceMap,C.iridescenceMapTransform)),E.iridescenceThicknessMap&&(C.iridescenceThicknessMap.value=E.iridescenceThicknessMap,t(E.iridescenceThicknessMap,C.iridescenceThicknessMapTransform))),E.transmission>0&&(C.transmission.value=E.transmission,C.transmissionSamplerMap.value=D.texture,C.transmissionSamplerSize.value.set(D.width,D.height),E.transmissionMap&&(C.transmissionMap.value=E.transmissionMap,t(E.transmissionMap,C.transmissionMapTransform)),C.thickness.value=E.thickness,E.thicknessMap&&(C.thicknessMap.value=E.thicknessMap,t(E.thicknessMap,C.thicknessMapTransform)),C.attenuationDistance.value=E.attenuationDistance,C.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(C.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(C.anisotropyMap.value=E.anisotropyMap,t(E.anisotropyMap,C.anisotropyMapTransform))),C.specularIntensity.value=E.specularIntensity,C.specularColor.value.copy(E.specularColor),E.specularColorMap&&(C.specularColorMap.value=E.specularColorMap,t(E.specularColorMap,C.specularColorMapTransform)),E.specularIntensityMap&&(C.specularIntensityMap.value=E.specularIntensityMap,t(E.specularIntensityMap,C.specularIntensityMapTransform))}function A(C,E){E.matcap&&(C.matcap.value=E.matcap)}function R(C,E){const D=e.get(E).light;C.referencePosition.value.setFromMatrixPosition(D.matrixWorld),C.nearDistance.value=D.shadow.camera.near,C.farDistance.value=D.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function mI(o,e,t,i){let s={},u={},f=[];const h=o.getParameter(o.MAX_UNIFORM_BUFFER_BINDINGS);function m(D,U){const L=U.program;i.uniformBlockBinding(D,L)}function g(D,U){let L=s[D.id];L===void 0&&(A(D),L=_(D),s[D.id]=L,D.addEventListener("dispose",C));const B=U.program;i.updateUBOMapping(D,B);const P=e.render.frame;u[D.id]!==P&&(b(D),u[D.id]=P)}function _(D){const U=x();D.__bindingPointIndex=U;const L=o.createBuffer(),B=D.__size,P=D.usage;return o.bindBuffer(o.UNIFORM_BUFFER,L),o.bufferData(o.UNIFORM_BUFFER,B,P),o.bindBuffer(o.UNIFORM_BUFFER,null),o.bindBufferBase(o.UNIFORM_BUFFER,U,L),L}function x(){for(let D=0;D0&&(L+=B-P),D.__size=L,D.__cache={},this}function R(D){const U={boundary:0,storage:0};return typeof D=="number"||typeof D=="boolean"?(U.boundary=4,U.storage=4):D.isVector2?(U.boundary=8,U.storage=8):D.isVector3||D.isColor?(U.boundary=16,U.storage=12):D.isVector4?(U.boundary=16,U.storage=16):D.isMatrix3?(U.boundary=48,U.storage=48):D.isMatrix4?(U.boundary=64,U.storage=64):D.isTexture?rt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):rt("WebGLRenderer: Unsupported uniform value type.",D),U}function C(D){const U=D.target;U.removeEventListener("dispose",C);const L=f.indexOf(U.__bindingPointIndex);f.splice(L,1),o.deleteBuffer(s[U.id]),delete s[U.id],delete u[U.id]}function E(){for(const D in s)o.deleteBuffer(s[D]);f=[],s={},u={}}return{bind:m,update:g,dispose:E}}const gI=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Do=null;function vI(){return Do===null&&(Do=new qr(gI,16,16,jc,zo),Do.name="DFG_LUT",Do.minFilter=ai,Do.magFilter=ai,Do.wrapS=As,Do.wrapT=As,Do.generateMipmaps=!1,Do.needsUpdate=!0),Do}class wT{constructor(e={}){const{canvas:t=xE(),context:i=null,depth:s=!0,stencil:u=!1,alpha:f=!1,antialias:h=!1,premultipliedAlpha:m=!0,preserveDrawingBuffer:g=!1,powerPreference:_="default",failIfMajorPerformanceCaveat:x=!1,reversedDepthBuffer:b=!1,outputBufferType:M=Ka}=e;this.isWebGLRenderer=!0;let A;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");A=i.getContextAttributes().alpha}else A=f;const R=M,C=new Set([hy,fy,xm]),E=new Set([Ka,gr,Bh,Fh,ly,uy]),D=new Uint32Array(4),U=new Int32Array(4);let L=null,B=null;const P=[],H=[];let W=null;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.toneMapping=mr,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let z=!1;this._outputColorSpace=Ua;let j=0,ae=0,$=null,ue=-1,he=null;const q=new Wn,K=new Wn;let ce=null;const Ae=new pt(0);let Ce=0,X=t.width,se=t.height,Ee=1,Oe=null,nt=null;const fe=new Wn(0,0,X,se),Te=new Wn(0,0,X,se);let Je=!1;const et=new Jh;let ut=!1,Jt=!1;const on=new kt,Dt=new Y,Re=new Wn,Ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ue=!1;function Ke(){return $===null?Ee:1}let Z=i;function St(V,ie){return t.getContext(V,ie)}try{const V={alpha:!0,depth:s,stencil:u,antialias:h,premultipliedAlpha:m,preserveDrawingBuffer:g,powerPreference:_,failIfMajorPerformanceCaveat:x};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ay}`),t.addEventListener("webglcontextlost",Bt,!1),t.addEventListener("webglcontextrestored",dn,!1),t.addEventListener("webglcontextcreationerror",gn,!1),Z===null){const ie="webgl2";if(Z=St(ie,V),Z===null)throw St(ie)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(V){throw Tt("WebGLRenderer: "+V.message),V}let tt,Mt,We,G,O,ne,Se,Le,be,ct,Ze,gt,wt,Be,Xe,ft,lt,$e,Zt,te,it,Ge,st,Fe;function Ne(){tt=new yU(Z),tt.init(),Ge=new AT(Z,tt),Mt=new uU(Z,tt,e,Ge),We=new oI(Z,tt),Mt.reversedDepthBuffer&&b&&We.buffers.depth.setReversed(!0),G=new SU(Z),O=new qL,ne=new lI(Z,tt,We,O,Mt,Ge,G),Se=new fU(I),Le=new vU(I),be=new TR(Z),st=new oU(Z,be),ct=new _U(Z,be,G,st),Ze=new MU(Z,ct,be,G),Zt=new bU(Z,Mt,ne),ft=new cU(O),gt=new WL(I,Se,Le,tt,Mt,st,ft),wt=new pI(I,O),Be=new ZL,Xe=new eI(tt),$e=new rU(I,Se,Le,We,Ze,A,m),lt=new sI(I,Ze,Mt),Fe=new mI(Z,G,Mt,We),te=new lU(Z,tt,G),it=new xU(Z,tt,G),G.programs=gt.programs,I.capabilities=Mt,I.extensions=tt,I.properties=O,I.renderLists=Be,I.shadowMap=lt,I.state=We,I.info=G}Ne(),R!==Ka&&(W=new TU(R,t.width,t.height,s,u));const je=new hI(I,Z);this.xr=je,this.getContext=function(){return Z},this.getContextAttributes=function(){return Z.getContextAttributes()},this.forceContextLoss=function(){const V=tt.get("WEBGL_lose_context");V&&V.loseContext()},this.forceContextRestore=function(){const V=tt.get("WEBGL_lose_context");V&&V.restoreContext()},this.getPixelRatio=function(){return Ee},this.setPixelRatio=function(V){V!==void 0&&(Ee=V,this.setSize(X,se,!1))},this.getSize=function(V){return V.set(X,se)},this.setSize=function(V,ie,ye=!0){if(je.isPresenting){rt("WebGLRenderer: Can't change size while VR device is presenting.");return}X=V,se=ie,t.width=Math.floor(V*Ee),t.height=Math.floor(ie*Ee),ye===!0&&(t.style.width=V+"px",t.style.height=ie+"px"),W!==null&&W.setSize(t.width,t.height),this.setViewport(0,0,V,ie)},this.getDrawingBufferSize=function(V){return V.set(X*Ee,se*Ee).floor()},this.setDrawingBufferSize=function(V,ie,ye){X=V,se=ie,Ee=ye,t.width=Math.floor(V*ye),t.height=Math.floor(ie*ye),this.setViewport(0,0,V,ie)},this.setEffects=function(V){if(R===Ka){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(V){for(let ie=0;ie{function qe(){if(me.forEach(function(ht){O.get(ht).currentProgram.isReady()&&me.delete(ht)}),me.size===0){oe(V);return}setTimeout(qe,10)}tt.get("KHR_parallel_shader_compile")!==null?qe():setTimeout(qe,10)})};let Vo=null;function Qr(V){Vo&&Vo(V)}function _r(){Ki.stop()}function ko(){Ki.start()}const Ki=new ST;Ki.setAnimationLoop(Qr),typeof self<"u"&&Ki.setContext(self),this.setAnimationLoop=function(V){Vo=V,je.setAnimationLoop(V),V===null?Ki.stop():Ki.start()},je.addEventListener("sessionstart",_r),je.addEventListener("sessionend",ko),this.render=function(V,ie){if(ie!==void 0&&ie.isCamera!==!0){Tt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;const ye=je.enabled===!0&&je.isPresenting===!0,me=W!==null&&($===null||ye)&&W.begin(I,$);if(V.matrixWorldAutoUpdate===!0&&V.updateMatrixWorld(),ie.parent===null&&ie.matrixWorldAutoUpdate===!0&&ie.updateMatrixWorld(),je.enabled===!0&&je.isPresenting===!0&&(W===null||W.isCompositing()===!1)&&(je.cameraAutoUpdate===!0&&je.updateCamera(ie),ie=je.getCamera()),V.isScene===!0&&V.onBeforeRender(I,V,ie,$),B=Xe.get(V,H.length),B.init(ie),H.push(B),on.multiplyMatrices(ie.projectionMatrix,ie.matrixWorldInverse),et.setFromProjectionMatrix(on,Fs,ie.reversedDepth),Jt=this.localClippingEnabled,ut=ft.init(this.clippingPlanes,Jt),L=Be.get(V,P.length),L.init(),P.push(L),je.enabled===!0&&je.isPresenting===!0){const ht=I.xr.getDepthSensingMesh();ht!==null&&za(ht,ie,-1/0,I.sortObjects)}za(V,ie,0,I.sortObjects),L.finish(),I.sortObjects===!0&&L.sort(Oe,nt),Ue=je.enabled===!1||je.isPresenting===!1||je.hasDepthSensing()===!1,Ue&&$e.addToRenderList(L,V),this.info.render.frame++,ut===!0&&ft.beginShadows();const oe=B.state.shadowsArray;if(lt.render(oe,V,ie),ut===!0&&ft.endShadows(),this.info.autoReset===!0&&this.info.reset(),(me&&W.hasRenderPass())===!1){const ht=L.opaque,He=L.transmissive;if(B.setupLights(),ie.isArrayCamera){const mt=ie.cameras;if(He.length>0)for(let vt=0,At=mt.length;vt0&&Ti(ht,He,V,ie),Ue&&$e.render(V),Qn(L,V,ie)}$!==null&&ae===0&&(ne.updateMultisampleRenderTarget($),ne.updateRenderTargetMipmap($)),me&&W.end(I),V.isScene===!0&&V.onAfterRender(I,V,ie),st.resetDefaultState(),ue=-1,he=null,H.pop(),H.length>0?(B=H[H.length-1],ut===!0&&ft.setGlobalState(I.clippingPlanes,B.state.camera)):B=null,P.pop(),P.length>0?L=P[P.length-1]:L=null};function za(V,ie,ye,me){if(V.visible===!1)return;if(V.layers.test(ie.layers)){if(V.isGroup)ye=V.renderOrder;else if(V.isLOD)V.autoUpdate===!0&&V.update(ie);else if(V.isLight)B.pushLight(V),V.castShadow&&B.pushShadow(V);else if(V.isSprite){if(!V.frustumCulled||et.intersectsSprite(V)){me&&Re.setFromMatrixPosition(V.matrixWorld).applyMatrix4(on);const ht=Ze.update(V),He=V.material;He.visible&&L.push(V,ht,He,ye,Re.z,null)}}else if((V.isMesh||V.isLine||V.isPoints)&&(!V.frustumCulled||et.intersectsObject(V))){const ht=Ze.update(V),He=V.material;if(me&&(V.boundingSphere!==void 0?(V.boundingSphere===null&&V.computeBoundingSphere(),Re.copy(V.boundingSphere.center)):(ht.boundingSphere===null&&ht.computeBoundingSphere(),Re.copy(ht.boundingSphere.center)),Re.applyMatrix4(V.matrixWorld).applyMatrix4(on)),Array.isArray(He)){const mt=ht.groups;for(let vt=0,At=mt.length;vt0&&Pa(oe,ie,ye),qe.length>0&&Pa(qe,ie,ye),ht.length>0&&Pa(ht,ie,ye),We.buffers.depth.setTest(!0),We.buffers.depth.setMask(!0),We.buffers.color.setMask(!0),We.setPolygonOffset(!1)}function Ti(V,ie,ye,me){if((ye.isScene===!0?ye.overrideMaterial:null)!==null)return;if(B.state.transmissionRenderTarget[me.id]===void 0){const Ut=tt.has("EXT_color_buffer_half_float")||tt.has("EXT_color_buffer_float");B.state.transmissionRenderTarget[me.id]=new ks(1,1,{generateMipmaps:!0,type:Ut?zo:Ka,minFilter:Uo,samples:Mt.samples,stencilBuffer:u,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:xn.workingColorSpace})}const qe=B.state.transmissionRenderTarget[me.id],ht=me.viewport||q;qe.setSize(ht.z*I.transmissionResolutionScale,ht.w*I.transmissionResolutionScale);const He=I.getRenderTarget(),mt=I.getActiveCubeFace(),vt=I.getActiveMipmapLevel();I.setRenderTarget(qe),I.getClearColor(Ae),Ce=I.getClearAlpha(),Ce<1&&I.setClearColor(16777215,.5),I.clear(),Ue&&$e.render(ye);const At=I.toneMapping;I.toneMapping=mr;const _t=me.viewport;if(me.viewport!==void 0&&(me.viewport=void 0),B.setupLightsView(me),ut===!0&&ft.setGlobalState(I.clippingPlanes,me),Pa(V,ye,me),ne.updateMultisampleRenderTarget(qe),ne.updateRenderTargetMipmap(qe),tt.has("WEBGL_multisampled_render_to_texture")===!1){let Ut=!1;for(let Sn=0,zn=ie.length;Sn0),_t=!!ye.morphAttributes.position,Ut=!!ye.morphAttributes.normal,Sn=!!ye.morphAttributes.color;let zn=mr;me.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(zn=I.toneMapping);const Un=ye.morphAttributes.position||ye.morphAttributes.normal||ye.morphAttributes.color,Ht=Un!==void 0?Un.length:0,at=O.get(me),vn=B.state.lights;if(ut===!0&&(Jt===!0||V!==he)){const Ii=V===he&&me.id===ue;ft.setState(me,V,Ii)}let Ot=!1;me.version===at.__version?(at.needsLights&&at.lightsStateVersion!==vn.state.version||at.outputColorSpace!==He||oe.isBatchedMesh&&at.batching===!1||!oe.isBatchedMesh&&at.batching===!0||oe.isBatchedMesh&&at.batchingColor===!0&&oe.colorTexture===null||oe.isBatchedMesh&&at.batchingColor===!1&&oe.colorTexture!==null||oe.isInstancedMesh&&at.instancing===!1||!oe.isInstancedMesh&&at.instancing===!0||oe.isSkinnedMesh&&at.skinning===!1||!oe.isSkinnedMesh&&at.skinning===!0||oe.isInstancedMesh&&at.instancingColor===!0&&oe.instanceColor===null||oe.isInstancedMesh&&at.instancingColor===!1&&oe.instanceColor!==null||oe.isInstancedMesh&&at.instancingMorph===!0&&oe.morphTexture===null||oe.isInstancedMesh&&at.instancingMorph===!1&&oe.morphTexture!==null||at.envMap!==mt||me.fog===!0&&at.fog!==qe||at.numClippingPlanes!==void 0&&(at.numClippingPlanes!==ft.numPlanes||at.numIntersection!==ft.numIntersection)||at.vertexAlphas!==vt||at.vertexTangents!==At||at.morphTargets!==_t||at.morphNormals!==Ut||at.morphColors!==Sn||at.toneMapping!==zn||at.morphTargetsCount!==Ht)&&(Ot=!0):(Ot=!0,at.__version=me.version);let vi=at.currentProgram;Ot===!0&&(vi=Fa(me,ie,oe));let Ds=!1,Gn=!1,sa=!1;const En=vi.getUniforms(),Ai=at.uniforms;if(We.useProgram(vi.program)&&(Ds=!0,Gn=!0,sa=!0),me.id!==ue&&(ue=me.id,Gn=!0),Ds||he!==V){We.buffers.depth.getReversed()&&V.reversedDepth!==!0&&(V._reversedDepth=!0,V.updateProjectionMatrix()),En.setValue(Z,"projectionMatrix",V.projectionMatrix),En.setValue(Z,"viewMatrix",V.matrixWorldInverse);const Oi=En.map.cameraPosition;Oi!==void 0&&Oi.setValue(Z,Dt.setFromMatrixPosition(V.matrixWorld)),Mt.logarithmicDepthBuffer&&En.setValue(Z,"logDepthBufFC",2/(Math.log(V.far+1)/Math.LN2)),(me.isMeshPhongMaterial||me.isMeshToonMaterial||me.isMeshLambertMaterial||me.isMeshBasicMaterial||me.isMeshStandardMaterial||me.isShaderMaterial)&&En.setValue(Z,"isOrthographic",V.isOrthographicCamera===!0),he!==V&&(he=V,Gn=!0,sa=!0)}if(at.needsLights&&(vn.state.directionalShadowMap.length>0&&En.setValue(Z,"directionalShadowMap",vn.state.directionalShadowMap,ne),vn.state.spotShadowMap.length>0&&En.setValue(Z,"spotShadowMap",vn.state.spotShadowMap,ne),vn.state.pointShadowMap.length>0&&En.setValue(Z,"pointShadowMap",vn.state.pointShadowMap,ne)),oe.isSkinnedMesh){En.setOptional(Z,oe,"bindMatrix"),En.setOptional(Z,oe,"bindMatrixInverse");const Ii=oe.skeleton;Ii&&(Ii.boneTexture===null&&Ii.computeBoneTexture(),En.setValue(Z,"boneTexture",Ii.boneTexture,ne))}oe.isBatchedMesh&&(En.setOptional(Z,oe,"batchingTexture"),En.setValue(Z,"batchingTexture",oe._matricesTexture,ne),En.setOptional(Z,oe,"batchingIdTexture"),En.setValue(Z,"batchingIdTexture",oe._indirectTexture,ne),En.setOptional(Z,oe,"batchingColorTexture"),oe._colorsTexture!==null&&En.setValue(Z,"batchingColorTexture",oe._colorsTexture,ne));const yi=ye.morphAttributes;if((yi.position!==void 0||yi.normal!==void 0||yi.color!==void 0)&&Zt.update(oe,ye,vi),(Gn||at.receiveShadow!==oe.receiveShadow)&&(at.receiveShadow=oe.receiveShadow,En.setValue(Z,"receiveShadow",oe.receiveShadow)),me.isMeshGouraudMaterial&&me.envMap!==null&&(Ai.envMap.value=mt,Ai.flipEnvMap.value=mt.isCubeTexture&&mt.isRenderTargetTexture===!1?-1:1),me.isMeshStandardMaterial&&me.envMap===null&&ie.environment!==null&&(Ai.envMapIntensity.value=ie.environmentIntensity),Ai.dfgLUT!==void 0&&(Ai.dfgLUT.value=vI()),Gn&&(En.setValue(Z,"toneMappingExposure",I.toneMappingExposure),at.needsLights&&xr(Ai,sa),qe&&me.fog===!0&&wt.refreshFogUniforms(Ai,qe),wt.refreshMaterialUniforms(Ai,me,Ee,se,B.state.transmissionRenderTarget[V.id]),rv.upload(Z,Jr(at),Ai,ne)),me.isShaderMaterial&&me.uniformsNeedUpdate===!0&&(rv.upload(Z,Jr(at),Ai,ne),me.uniformsNeedUpdate=!1),me.isSpriteMaterial&&En.setValue(Z,"center",oe.center),En.setValue(Z,"modelViewMatrix",oe.modelViewMatrix),En.setValue(Z,"normalMatrix",oe.normalMatrix),En.setValue(Z,"modelMatrix",oe.matrixWorld),me.isShaderMaterial||me.isRawShaderMaterial){const Ii=me.uniformsGroups;for(let Oi=0,Go=Ii.length;Oi0&&ne.useMultisampledRTT(V)===!1?me=O.get(V).__webglMultisampledFramebuffer:Array.isArray(vt)?me=vt[ye]:me=vt,q.copy(V.viewport),K.copy(V.scissor),ce=V.scissorTest}else q.copy(fe).multiplyScalar(Ee).floor(),K.copy(Te).multiplyScalar(Ee).floor(),ce=Je;if(ye!==0&&(me=br),We.bindFramebuffer(Z.FRAMEBUFFER,me)&&We.drawBuffers(V,me),We.viewport(q),We.scissor(K),We.setScissorTest(ce),oe){const He=O.get(V.texture);Z.framebufferTexture2D(Z.FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Z.TEXTURE_CUBE_MAP_POSITIVE_X+ie,He.__webglTexture,ye)}else if(qe){const He=ie;for(let mt=0;mt=0&&ie<=V.width-me&&ye>=0&&ye<=V.height-oe&&(V.textures.length>1&&Z.readBuffer(Z.COLOR_ATTACHMENT0+He),Z.readPixels(ie,ye,me,oe,Ge.convert(At),Ge.convert(_t),qe))}finally{const vt=$!==null?O.get($).__webglFramebuffer:null;We.bindFramebuffer(Z.FRAMEBUFFER,vt)}}},this.readRenderTargetPixelsAsync=async function(V,ie,ye,me,oe,qe,ht,He=0){if(!(V&&V.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let mt=O.get(V).__webglFramebuffer;if(V.isWebGLCubeRenderTarget&&ht!==void 0&&(mt=mt[ht]),mt)if(ie>=0&&ie<=V.width-me&&ye>=0&&ye<=V.height-oe){We.bindFramebuffer(Z.FRAMEBUFFER,mt);const vt=V.textures[He],At=vt.format,_t=vt.type;if(!Mt.textureFormatReadable(At))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Mt.textureTypeReadable(_t))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ut=Z.createBuffer();Z.bindBuffer(Z.PIXEL_PACK_BUFFER,Ut),Z.bufferData(Z.PIXEL_PACK_BUFFER,qe.byteLength,Z.STREAM_READ),V.textures.length>1&&Z.readBuffer(Z.COLOR_ATTACHMENT0+He),Z.readPixels(ie,ye,me,oe,Ge.convert(At),Ge.convert(_t),0);const Sn=$!==null?O.get($).__webglFramebuffer:null;We.bindFramebuffer(Z.FRAMEBUFFER,Sn);const zn=Z.fenceSync(Z.SYNC_GPU_COMMANDS_COMPLETE,0);return Z.flush(),await Aw(Z,zn,4),Z.bindBuffer(Z.PIXEL_PACK_BUFFER,Ut),Z.getBufferSubData(Z.PIXEL_PACK_BUFFER,0,qe),Z.deleteBuffer(Ut),Z.deleteSync(zn),qe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(V,ie=null,ye=0){const me=Math.pow(2,-ye),oe=Math.floor(V.image.width*me),qe=Math.floor(V.image.height*me),ht=ie!==null?ie.x:0,He=ie!==null?ie.y:0;ne.setTexture2D(V,0),Z.copyTexSubImage2D(Z.TEXTURE_2D,ye,0,0,ht,He,oe,qe),We.unbindTexture()};const Kr=Z.createFramebuffer(),Gs=Z.createFramebuffer();this.copyTextureToTexture=function(V,ie,ye=null,me=null,oe=0,qe=null){qe===null&&(oe!==0?(kh("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),qe=oe,oe=0):qe=0);let ht,He,mt,vt,At,_t,Ut,Sn,zn;const Un=V.isCompressedTexture?V.mipmaps[qe]:V.image;if(ye!==null)ht=ye.max.x-ye.min.x,He=ye.max.y-ye.min.y,mt=ye.isBox3?ye.max.z-ye.min.z:1,vt=ye.min.x,At=ye.min.y,_t=ye.isBox3?ye.min.z:0;else{const yi=Math.pow(2,-oe);ht=Math.floor(Un.width*yi),He=Math.floor(Un.height*yi),V.isDataArrayTexture?mt=Un.depth:V.isData3DTexture?mt=Math.floor(Un.depth*yi):mt=1,vt=0,At=0,_t=0}me!==null?(Ut=me.x,Sn=me.y,zn=me.z):(Ut=0,Sn=0,zn=0);const Ht=Ge.convert(ie.format),at=Ge.convert(ie.type);let vn;ie.isData3DTexture?(ne.setTexture3D(ie,0),vn=Z.TEXTURE_3D):ie.isDataArrayTexture||ie.isCompressedArrayTexture?(ne.setTexture2DArray(ie,0),vn=Z.TEXTURE_2D_ARRAY):(ne.setTexture2D(ie,0),vn=Z.TEXTURE_2D),Z.pixelStorei(Z.UNPACK_FLIP_Y_WEBGL,ie.flipY),Z.pixelStorei(Z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ie.premultiplyAlpha),Z.pixelStorei(Z.UNPACK_ALIGNMENT,ie.unpackAlignment);const Ot=Z.getParameter(Z.UNPACK_ROW_LENGTH),vi=Z.getParameter(Z.UNPACK_IMAGE_HEIGHT),Ds=Z.getParameter(Z.UNPACK_SKIP_PIXELS),Gn=Z.getParameter(Z.UNPACK_SKIP_ROWS),sa=Z.getParameter(Z.UNPACK_SKIP_IMAGES);Z.pixelStorei(Z.UNPACK_ROW_LENGTH,Un.width),Z.pixelStorei(Z.UNPACK_IMAGE_HEIGHT,Un.height),Z.pixelStorei(Z.UNPACK_SKIP_PIXELS,vt),Z.pixelStorei(Z.UNPACK_SKIP_ROWS,At),Z.pixelStorei(Z.UNPACK_SKIP_IMAGES,_t);const En=V.isDataArrayTexture||V.isData3DTexture,Ai=ie.isDataArrayTexture||ie.isData3DTexture;if(V.isDepthTexture){const yi=O.get(V),Ii=O.get(ie),Oi=O.get(yi.__renderTarget),Go=O.get(Ii.__renderTarget);We.bindFramebuffer(Z.READ_FRAMEBUFFER,Oi.__webglFramebuffer),We.bindFramebuffer(Z.DRAW_FRAMEBUFFER,Go.__webglFramebuffer);for(let is=0;is"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:h;return xx.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:_,xx}var y1;function xI(){return y1||(y1=1,_x.exports=_I()),_x.exports}var _1;function SI(){if(_1)return yx;_1=1;var o=ym(),e=xI();function t(g,_){return g===_&&(g!==0||1/g===1/_)||g!==g&&_!==_}var i=typeof Object.is=="function"?Object.is:t,s=e.useSyncExternalStore,u=o.useRef,f=o.useEffect,h=o.useMemo,m=o.useDebugValue;return yx.useSyncExternalStoreWithSelector=function(g,_,x,b,M){var A=u(null);if(A.current===null){var R={hasValue:!1,value:null};A.current=R}else R=A.current;A=h(function(){function E(P){if(!D){if(D=!0,U=P,P=b(P),M!==void 0&&R.hasValue){var H=R.value;if(M(H,P))return L=H}return L=P}if(H=L,i(U,P))return H;var W=b(P);return M!==void 0&&M(H,W)?(U=P,H):(U=P,L=W)}var D=!1,U,L,B=x===void 0?null:x;return[function(){return E(_())},B===null?void 0:function(){return E(B())}]},[_,x,b,M]);var C=s(g,A[0],A[1]);return f(function(){R.hasValue=!0,R.value=C},[C]),m(C),C},yx}var x1;function bI(){return x1||(x1=1,vx.exports=SI()),vx.exports}var MI=bI();const EI=$x(MI),S1=o=>{let e;const t=new Set,i=(g,_)=>{const x=typeof g=="function"?g(e):g;if(!Object.is(x,e)){const b=e;e=_??(typeof x!="object"||x===null)?x:Object.assign({},e,x),t.forEach(M=>M(e,b))}},s=()=>e,h={setState:i,getState:s,getInitialState:()=>m,subscribe:g=>(t.add(g),()=>t.delete(g))},m=e=o(i,s,h);return h},TI=(o=>o?S1(o):S1),{useSyncExternalStoreWithSelector:AI}=EI,wI=o=>o;function CI(o,e=wI,t){const i=AI(o.subscribe,o.getState,o.getInitialState,e,t);return O1.useDebugValue(i),i}const b1=(o,e)=>{const t=TI(o),i=(s,u=e)=>CI(t,s,u);return Object.assign(i,t),i},RI=((o,e)=>o?b1(o,e):b1);var Wx=z1();const DI=$x(Wx);function YS(o,e,t){if(!o)return;if(t(o)===!0)return o;let i=e?o.return:o.child;for(;i;){const s=YS(i,e,t);if(s)return s;i=e?null:i.sibling}}function CT(o){try{return Object.defineProperties(o,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return o}}const ZS=CT(It.createContext(null));class RT extends It.Component{render(){return It.createElement(ZS.Provider,{value:this._reactInternals},this.props.children)}}function DT(){const o=It.useContext(ZS);if(o===null)throw new Error("its-fine: useFiber must be called within a !");const e=It.useId();return It.useMemo(()=>{for(const t of[o,o?.alternate]){if(!t)continue;const i=YS(t,!1,s=>{let u=s.memoizedState;for(;u;){if(u.memoizedState===e)return!0;u=u.next}});if(i)return i}},[o,e])}const NI=Symbol.for("react.context"),UI=o=>o!==null&&typeof o=="object"&&"$$typeof"in o&&o.$$typeof===NI;function LI(){const o=DT(),[e]=It.useState(()=>new Map);e.clear();let t=o;for(;t;){const i=t.type;UI(i)&&i!==ZS&&!e.has(i)&&e.set(i,It.use(CT(i))),t=t.return}return e}function II(){const o=LI();return It.useMemo(()=>Array.from(o.keys()).reduce((e,t)=>i=>It.createElement(e,null,It.createElement(t.Provider,{...i,value:o.get(t)})),e=>It.createElement(RT,{...e})),[o])}function NT(o){let e=o.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const UT=o=>o&&o.isOrthographicCamera,OI=o=>o&&o.hasOwnProperty("current"),zI=o=>o!=null&&(typeof o=="string"||typeof o=="number"||o.isColor),Cm=((o,e)=>typeof window<"u"&&(((o=window.document)==null?void 0:o.createElement)||((e=window.navigator)==null?void 0:e.product)==="ReactNative"))()?It.useLayoutEffect:It.useEffect;function LT(o){const e=It.useRef(o);return Cm(()=>{e.current=o},[o]),e}function PI(){const o=DT(),e=II();return It.useMemo(()=>({children:t})=>{const s=!!YS(o,!0,u=>u.type===It.StrictMode)?It.StrictMode:It.Fragment;return Bs.jsx(s,{children:Bs.jsx(e,{children:t})})},[o,e])}function BI({set:o}){return Cm(()=>(o(new Promise(()=>null)),()=>o(!1)),[o]),null}const FI=(o=>(o=class extends It.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}},o.getDerivedStateFromError=()=>({error:!0}),o))();function IT(o){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(o)?Math.min(Math.max(o[0],t),o[1]):o}function Dh(o){var e;return(e=o.__r3f)==null?void 0:e.root.getState()}const mi={obj:o=>o===Object(o)&&!mi.arr(o)&&typeof o!="function",fun:o=>typeof o=="function",str:o=>typeof o=="string",num:o=>typeof o=="number",boo:o=>typeof o=="boolean",und:o=>o===void 0,nul:o=>o===null,arr:o=>Array.isArray(o),equ(o,e,{arrays:t="shallow",objects:i="reference",strict:s=!0}={}){if(typeof o!=typeof e||!!o!=!!e)return!1;if(mi.str(o)||mi.num(o)||mi.boo(o))return o===e;const u=mi.obj(o);if(u&&i==="reference")return o===e;const f=mi.arr(o);if(f&&t==="reference")return o===e;if((f||u)&&o===e)return!0;let h;for(h in o)if(!(h in e))return!1;if(u&&t==="shallow"&&i==="shallow"){for(h in s?e:o)if(!mi.equ(o[h],e[h],{strict:s,objects:"reference"}))return!1}else for(h in s?e:o)if(o[h]!==e[h])return!1;if(mi.und(h)){if(f&&o.length===0&&e.length===0||u&&Object.keys(o).length===0&&Object.keys(e).length===0)return!0;if(o!==e)return!1}return!0}};function VI(o){o.type!=="Scene"&&(o.dispose==null||o.dispose());for(const e in o){const t=o[e];t?.type!=="Scene"&&(t==null||t.dispose==null||t.dispose())}}const OT=["children","key","ref"];function kI(o){const e={};for(const t in o)OT.includes(t)||(e[t]=o[t]);return e}function ey(o,e,t,i){const s=o;let u=s?.__r3f;return u||(u={root:e,type:t,parent:null,children:[],props:kI(i),object:s,eventCount:0,handlers:{},isHidden:!1},s&&(s.__r3f=u)),u}function vm(o,e){if(!e.includes("-"))return{root:o,key:e,target:o[e]};if(e in o)return{root:o,key:e,target:o[e]};let t=o;const i=e.split("-");for(const s of i){if(typeof t!="object"||t===null){if(t!==void 0){const u=i.slice(i.indexOf(s)).join("-");return{root:t,key:u,target:void 0}}return{root:o,key:e,target:void 0}}e=s,o=t,t=t[e]}return{root:o,key:e,target:t}}const M1=/-\d+$/;function ty(o,e){if(mi.str(e.props.attach)){if(M1.test(e.props.attach)){const s=e.props.attach.replace(M1,""),{root:u,key:f}=vm(o.object,s);Array.isArray(u[f])||(u[f]=[])}const{root:t,key:i}=vm(o.object,e.props.attach);e.previousAttach=t[i],t[i]=e.object}else mi.fun(e.props.attach)&&(e.previousAttach=e.props.attach(o.object,e.object))}function ny(o,e){if(mi.str(e.props.attach)){const{root:t,key:i}=vm(o.object,e.props.attach),s=e.previousAttach;s===void 0?delete t[i]:t[i]=s}else e.previousAttach==null||e.previousAttach(o.object,e.object);delete e.previousAttach}const qx=[...OT,"args","dispose","attach","object","onUpdate","dispose"],E1=new Map;function HI(o){let e=E1.get(o.constructor);try{e||(e=new o.constructor,E1.set(o.constructor,e))}catch{}return e}function GI(o,e){const t={};for(const i in e)if(!qx.includes(i)&&!mi.equ(e[i],o.props[i])){t[i]=e[i];for(const s in e)s.startsWith(`${i}-`)&&(t[s]=e[s])}for(const i in o.props){if(qx.includes(i)||e.hasOwnProperty(i))continue;const{root:s,key:u}=vm(o.object,i);if(s.constructor&&s.constructor.length===0){const f=HI(s);mi.und(f)||(t[u]=f[u])}else t[u]=0}return t}const XI=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],WI=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function Cu(o,e){var t;const i=o.__r3f,s=i&&NT(i).getState(),u=i?.eventCount;for(const h in e){let m=e[h];if(qx.includes(h))continue;if(i&&WI.test(h)){typeof m=="function"?i.handlers[h]=m:delete i.handlers[h],i.eventCount=Object.keys(i.handlers).length;continue}if(m===void 0)continue;let{root:g,key:_,target:x}=vm(o,h);if(x===void 0&&(typeof g!="object"||g===null))throw Error(`R3F: Cannot set "${h}". Ensure it is an object before setting "${_}".`);if(x instanceof Gh&&m instanceof Gh)x.mask=m.mask;else if(x instanceof pt&&zI(m))x.set(m);else if(x!==null&&typeof x=="object"&&typeof x.set=="function"&&typeof x.copy=="function"&&m!=null&&m.constructor&&x.constructor===m.constructor)x.copy(m);else if(x!==null&&typeof x=="object"&&typeof x.set=="function"&&Array.isArray(m))typeof x.fromArray=="function"?x.fromArray(m):x.set(...m);else if(x!==null&&typeof x=="object"&&typeof x.set=="function"&&typeof m=="number")typeof x.setScalar=="function"?x.setScalar(m):x.set(m);else{var f;g[_]=m,s&&!s.linear&&XI.includes(_)&&(f=g[_])!=null&&f.isTexture&&g[_].format===La&&g[_].type===Ka&&(g[_].colorSpace=Ua)}}if(i!=null&&i.parent&&s!=null&&s.internal&&(t=i.object)!=null&&t.isObject3D&&u!==i.eventCount){const h=i.object,m=s.internal.interaction.indexOf(h);m>-1&&s.internal.interaction.splice(m,1),i.eventCount&&h.raycast!==null&&s.internal.interaction.push(h)}return i&&i.props.attach===void 0&&(i.object.isBufferGeometry?i.props.attach="geometry":i.object.isMaterial&&(i.props.attach="material")),i&&td(i),o}function td(o){var e;if(!o.parent)return;o.props.onUpdate==null||o.props.onUpdate(o.object);const t=(e=o.root)==null||e.getState==null?void 0:e.getState();t&&t.internal.frames===0&&t.invalidate()}function qI(o,e){o.manual||(UT(o)?(o.left=e.width/-2,o.right=e.width/2,o.top=e.height/2,o.bottom=e.height/-2):o.aspect=e.width/e.height,o.updateProjectionMatrix())}const Es=o=>o?.isObject3D;function nv(o){return(o.eventObject||o.object).uuid+"/"+o.index+o.instanceId}function zT(o,e,t,i){const s=t.get(e);s&&(t.delete(e),t.size===0&&(o.delete(i),s.target.releasePointerCapture(i)))}function YI(o,e){const{internal:t}=o.getState();t.interaction=t.interaction.filter(i=>i!==e),t.initialHits=t.initialHits.filter(i=>i!==e),t.hovered.forEach((i,s)=>{(i.eventObject===e||i.object===e)&&t.hovered.delete(s)}),t.capturedMap.forEach((i,s)=>{zT(t.capturedMap,e,i,s)})}function ZI(o){function e(m){const{internal:g}=o.getState(),_=m.offsetX-g.initialClick[0],x=m.offsetY-g.initialClick[1];return Math.round(Math.sqrt(_*_+x*x))}function t(m){return m.filter(g=>["Move","Over","Enter","Out","Leave"].some(_=>{var x;return(x=g.__r3f)==null?void 0:x.handlers["onPointer"+_]}))}function i(m,g){const _=o.getState(),x=new Set,b=[],M=g?g(_.internal.interaction):_.internal.interaction;for(let E=0;E{const U=Dh(E.object),L=Dh(D.object);return!U||!L?E.distance-D.distance:L.events.priority-U.events.priority||E.distance-D.distance}).filter(E=>{const D=nv(E);return x.has(D)?!1:(x.add(D),!0)});_.events.filter&&(R=_.events.filter(R,_));for(const E of R){let D=E.object;for(;D;){var C;(C=D.__r3f)!=null&&C.eventCount&&b.push({...E,eventObject:D}),D=D.parent}}if("pointerId"in m&&_.internal.capturedMap.has(m.pointerId))for(let E of _.internal.capturedMap.get(m.pointerId).values())x.has(nv(E.intersection))||b.push(E.intersection);return b}function s(m,g,_,x){if(m.length){const b={stopped:!1};for(const M of m){let A=Dh(M.object);if(A||M.object.traverseAncestors(R=>{const C=Dh(R);if(C)return A=C,!1}),A){const{raycaster:R,pointer:C,camera:E,internal:D}=A,U=new Y(C.x,C.y,0).unproject(E),L=I=>{var z,j;return(z=(j=D.capturedMap.get(I))==null?void 0:j.has(M.eventObject))!=null?z:!1},B=I=>{const z={intersection:M,target:g.target};D.capturedMap.has(I)?D.capturedMap.get(I).set(M.eventObject,z):D.capturedMap.set(I,new Map([[M.eventObject,z]])),g.target.setPointerCapture(I)},P=I=>{const z=D.capturedMap.get(I);z&&zT(D.capturedMap,M.eventObject,z,I)};let H={};for(let I in g){let z=g[I];typeof z!="function"&&(H[I]=z)}let W={...M,...H,pointer:C,intersections:m,stopped:b.stopped,delta:_,unprojectedPoint:U,ray:R.ray,camera:E,stopPropagation(){const I="pointerId"in g&&D.capturedMap.get(g.pointerId);if((!I||I.has(M.eventObject))&&(W.stopped=b.stopped=!0,D.hovered.size&&Array.from(D.hovered.values()).find(z=>z.eventObject===M.eventObject))){const z=m.slice(0,m.indexOf(M));u([...z,M])}},target:{hasPointerCapture:L,setPointerCapture:B,releasePointerCapture:P},currentTarget:{hasPointerCapture:L,setPointerCapture:B,releasePointerCapture:P},nativeEvent:g};if(x(W),b.stopped===!0)break}}}return m}function u(m){const{internal:g}=o.getState();for(const _ of g.hovered.values())if(!m.length||!m.find(x=>x.object===_.object&&x.index===_.index&&x.instanceId===_.instanceId)){const b=_.eventObject.__r3f;if(g.hovered.delete(nv(_)),b!=null&&b.eventCount){const M=b.handlers,A={..._,intersections:m};M.onPointerOut==null||M.onPointerOut(A),M.onPointerLeave==null||M.onPointerLeave(A)}}}function f(m,g){for(let _=0;_u([]);case"onLostPointerCapture":return g=>{const{internal:_}=o.getState();"pointerId"in g&&_.capturedMap.has(g.pointerId)&&requestAnimationFrame(()=>{_.capturedMap.has(g.pointerId)&&(_.capturedMap.delete(g.pointerId),u([]))})}}return function(_){const{onPointerMissed:x,internal:b}=o.getState();b.lastEvent.current=_;const M=m==="onPointerMove",A=m==="onClick"||m==="onContextMenu"||m==="onDoubleClick",C=i(_,M?t:void 0),E=A?e(_):0;m==="onPointerDown"&&(b.initialClick=[_.offsetX,_.offsetY],b.initialHits=C.map(U=>U.eventObject)),A&&!C.length&&E<=2&&(f(_,b.interaction),x&&x(_)),M&&u(C);function D(U){const L=U.eventObject,B=L.__r3f;if(!(B!=null&&B.eventCount))return;const P=B.handlers;if(M){if(P.onPointerOver||P.onPointerEnter||P.onPointerOut||P.onPointerLeave){const H=nv(U),W=b.hovered.get(H);W?W.stopped&&U.stopPropagation():(b.hovered.set(H,U),P.onPointerOver==null||P.onPointerOver(U),P.onPointerEnter==null||P.onPointerEnter(U))}P.onPointerMove==null||P.onPointerMove(U)}else{const H=P[m];H?(!A||b.initialHits.includes(L))&&(f(_,b.interaction.filter(W=>!b.initialHits.includes(W))),H(U)):A&&b.initialHits.includes(L)&&f(_,b.interaction.filter(W=>!b.initialHits.includes(W)))}}s(C,_,E,D)}}return{handlePointer:h}}const T1=o=>!!(o!=null&&o.render),PT=It.createContext(null),jI=(o,e)=>{const t=RI((h,m)=>{const g=new Y,_=new Y,x=new Y;function b(E=m().camera,D=_,U=m().size){const{width:L,height:B,top:P,left:H}=U,W=L/B;D.isVector3?x.copy(D):x.set(...D);const I=E.getWorldPosition(g).distanceTo(x);if(UT(E))return{width:L/E.zoom,height:B/E.zoom,top:P,left:H,factor:1,distance:I,aspect:W};{const z=E.fov*Math.PI/180,j=2*Math.tan(z/2)*I,ae=j*(L/B);return{width:ae,height:j,top:P,left:H,factor:L/ae,distance:I,aspect:W}}}let M;const A=E=>h(D=>({performance:{...D.performance,current:E}})),R=new Pe;return{set:h,get:m,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(E=1)=>o(m(),E),advance:(E,D)=>e(E,D,m()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new HS,pointer:R,mouse:R,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const E=m();M&&clearTimeout(M),E.performance.current!==E.performance.min&&A(E.performance.min),M=setTimeout(()=>A(m().performance.max),E.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:b},setEvents:E=>h(D=>({...D,events:{...D.events,...E}})),setSize:(E,D,U=0,L=0)=>{const B=m().camera,P={width:E,height:D,top:U,left:L};h(H=>({size:P,viewport:{...H.viewport,...b(B,_,P)}}))},setDpr:E=>h(D=>{const U=IT(E);return{viewport:{...D.viewport,dpr:U,initialDpr:D.viewport.initialDpr||U}}}),setFrameloop:(E="always")=>{const D=m().clock;D.stop(),D.elapsedTime=0,E!=="never"&&(D.start(),D.elapsedTime=0),h(()=>({frameloop:E}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:It.createRef(),active:!1,frames:0,priority:0,subscribe:(E,D,U)=>{const L=m().internal;return L.priority=L.priority+(D>0?1:0),L.subscribers.push({ref:E,priority:D,store:U}),L.subscribers=L.subscribers.sort((B,P)=>B.priority-P.priority),()=>{const B=m().internal;B!=null&&B.subscribers&&(B.priority=B.priority-(D>0?1:0),B.subscribers=B.subscribers.filter(P=>P.ref!==E))}}}}}),i=t.getState();let s=i.size,u=i.viewport.dpr,f=i.camera;return t.subscribe(()=>{const{camera:h,size:m,viewport:g,gl:_,set:x}=t.getState();if(m.width!==s.width||m.height!==s.height||g.dpr!==u){s=m,u=g.dpr,qI(h,m),g.dpr>0&&_.setPixelRatio(g.dpr);const b=typeof HTMLCanvasElement<"u"&&_.domElement instanceof HTMLCanvasElement;_.setSize(m.width,m.height,b)}h!==f&&(f=h,x(b=>({viewport:{...b.viewport,...b.viewport.getCurrentViewport(h)}})))}),t.subscribe(h=>o(h)),t};function QI(){const o=It.useContext(PT);if(!o)throw new Error("R3F: Hooks can only be used within the Canvas component!");return o}function BT(o,e=0){const t=QI(),i=t.getState().internal.subscribe,s=LT(o);return Cm(()=>i(s,e,t),[e,i,t]),null}const JI=1,KI=8,$I=32,eO=2;var tO={version:"9.5.0"};function nO(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var A1={exports:{}},w1={exports:{}},C1;function iO(){return C1||(C1=1,(function(o){o.exports=function(e){function t(r,l,p,v){return new Ad(r,l,p,v)}function i(){}function s(r){var l="https://react.dev/errors/"+r;if(1ll||(r.current=Wf[ll],Wf[ll]=null,ll--)}function A(r,l){ll++,Wf[ll]=r.current,r.current=l}function R(r){return r>>>=0,r===0?32:31-(qf(r)/Wg|0)|0}function C(r){var l=r&42;if(l!==0)return l;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function E(r,l,p){var v=r.pendingLanes;if(v===0)return 0;var T=0,w=r.suspendedLanes,F=r.pingedLanes;r=r.warmLanes;var J=v&134217727;return J!==0?(v=J&~w,v!==0?T=C(v):(F&=J,F!==0?T=C(F):p||(p=J&~r,p!==0&&(T=C(p))))):(J=v&~w,J!==0?T=C(J):F!==0?T=C(F):p||(p=v&~r,p!==0&&(T=C(p)))),T===0?0:l!==0&&l!==T&&(l&w)===0&&(w=T&-T,p=l&-l,w>=p||w===32&&(p&4194048)!==0)?l:T}function D(r,l){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&l)===0}function U(r,l){switch(r){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function L(){var r=iu;return iu<<=1,(iu&62914560)===0&&(iu=4194304),r}function B(r){for(var l=[],p=0;31>p;p++)l.push(r);return l}function P(r,l){r.pendingLanes|=l,l!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function H(r,l,p,v,T,w){var F=r.pendingLanes;r.pendingLanes=p,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=p,r.entangledLanes&=p,r.errorRecoveryDisabledLanes&=p,r.shellSuspendCounter=0;var J=r.entanglements,xe=r.expirationTimes,ze=r.hiddenUpdates;for(p=F&~p;0)":-1T||xe[v]!==ze[T]){var Qe=` `+xe[v].replace(" at new "," at ");return r.displayName&&Qe.includes("")&&(Qe=Qe.replace("",r.displayName)),Qe}while(1<=v&&0<=T);break}}}finally{mc=!1,Error.prepareStackTrace=p}return(p=r?r.displayName||r.name:"")?he(p):""}function K(r,l){switch(r.tag){case 26:case 27:case 5:return he(r.type);case 16:return he("Lazy");case 13:return r.child!==l&&l!==null?he("Suspense Fallback"):he("Suspense");case 19:return he("SuspenseList");case 0:case 15:return q(r.type,!1);case 11:return q(r.type.render,!1);case 1:return q(r.type,!0);case 31:return he("Activity");default:return""}}function ce(r){try{var l="",p=null;do l+=K(r,p),p=r,r=r.return;while(r);return l}catch(v){return` Error generating stack: `+v.message+` `+v.stack}}function Ae(r,l){if(typeof r=="object"&&r!==null){var p=hp.get(r);return p!==void 0?p:(l={value:r,source:l,stack:ce(l)},hp.set(r,l),l)}return{value:r,source:l,stack:ce(l)}}function Ce(r,l){Ir[sr++]=gc,Ir[sr++]=In,In=r,gc=l}function X(r,l,p){ds[Wa++]=qi,ds[Wa++]=Us,ds[Wa++]=ps,ps=r;var v=qi;r=Us;var T=32-Ma(v)-1;v&=~(1<>=F,T-=F,qi=1<<32-Ma(l)+T|p<yn?(ki=Lt,Lt=null):ki=Lt.sibling;var Mn=dt(ge,Lt,_e[yn],Ye);if(Mn===null){Lt===null&&(Lt=ki);break}r&&Lt&&Mn.alternate===null&&l(ge,Lt),le=w(Mn,le,yn),ii===null?Nt=Mn:ii.sibling=Mn,ii=Mn,Lt=ki}if(yn===_e.length)return p(ge,Lt),un&&Ce(ge,yn),Nt;if(Lt===null){for(;yn<_e.length;yn++)Lt=ke(ge,_e[yn],Ye),Lt!==null&&(le=w(Lt,le,yn),ii===null?Nt=Lt:ii.sibling=Lt,ii=Lt);return un&&Ce(ge,yn),Nt}for(Lt=v(Lt);yn<_e.length;yn++)ki=Gt(Lt,ge,yn,_e[yn],Ye),ki!==null&&(r&&ki.alternate!==null&&Lt.delete(ki.key===null?yn:ki.key),le=w(ki,le,yn),ii===null?Nt=ki:ii.sibling=ki,ii=ki);return r&&Lt.forEach(function(Ss){return l(ge,Ss)}),un&&Ce(ge,yn),Nt}function hu(ge,le,_e,Ye){if(_e==null)throw Error(s(151));for(var Nt=null,ii=null,Lt=le,yn=le=0,ki=null,Mn=_e.next();Lt!==null&&!Mn.done;yn++,Mn=_e.next()){Lt.index>yn?(ki=Lt,Lt=null):ki=Lt.sibling;var Ss=dt(ge,Lt,Mn.value,Ye);if(Ss===null){Lt===null&&(Lt=ki);break}r&&Lt&&Ss.alternate===null&&l(ge,Lt),le=w(Ss,le,yn),ii===null?Nt=Ss:ii.sibling=Ss,ii=Ss,Lt=ki}if(Mn.done)return p(ge,Lt),un&&Ce(ge,yn),Nt;if(Lt===null){for(;!Mn.done;yn++,Mn=_e.next())Mn=ke(ge,Mn.value,Ye),Mn!==null&&(le=w(Mn,le,yn),ii===null?Nt=Mn:ii.sibling=Mn,ii=Mn);return un&&Ce(ge,yn),Nt}for(Lt=v(Lt);!Mn.done;yn++,Mn=_e.next())Mn=Gt(Lt,ge,yn,Mn.value,Ye),Mn!==null&&(r&&Mn.alternate!==null&&Lt.delete(Mn.key===null?yn:Mn.key),le=w(Mn,le,yn),ii===null?Nt=Mn:ii.sibling=Mn,ii=Mn);return r&&Lt.forEach(function(e_){return l(ge,e_)}),un&&Ce(ge,yn),Nt}function wo(ge,le,_e,Ye){if(typeof _e=="object"&&_e!==null&&_e.type===tl&&_e.key===null&&(_e=_e.props.children),typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case nr:e:{for(var Nt=_e.key;le!==null;){if(le.key===Nt){if(Nt=_e.type,Nt===tl){if(le.tag===7){p(ge,le.sibling),Ye=T(le,_e.props.children),Ye.return=ge,ge=Ye;break e}}else if(le.elementType===Nt||typeof Nt=="object"&&Nt!==null&&Nt.$$typeof===ua&&dn(Nt)===le.type){p(ge,le.sibling),Ye=T(le,_e.props),Zr(Ye,_e),Ye.return=ge,ge=Ye;break e}p(ge,le);break}else l(ge,le);le=le.sibling}_e.type===tl?(Ye=us(_e.props.children,ge.mode,Ye,_e.key),Ye.return=ge,ge=Ye):(Ye=Rr(_e.type,_e.key,_e.props,null,ge.mode,Ye),Zr(Ye,_e),Ye.return=ge,ge=Ye)}return F(ge);case el:e:{for(Nt=_e.key;le!==null;){if(le.key===Nt)if(le.tag===4&&le.stateNode.containerInfo===_e.containerInfo&&le.stateNode.implementation===_e.implementation){p(ge,le.sibling),Ye=T(le,_e.children||[]),Ye.return=ge,ge=Ye;break e}else{p(ge,le);break}else l(ge,le);le=le.sibling}Ye=Rd(_e,ge.mode,Ye),Ye.return=ge,ge=Ye}return F(ge);case ua:return _e=dn(_e),wo(ge,le,_e,Ye)}if(ho(_e))return pi(ge,le,_e,Ye);if(_(_e)){if(Nt=_(_e),typeof Nt!="function")throw Error(s(150));return _e=Nt.call(_e),hu(ge,le,_e,Ye)}if(typeof _e.then=="function")return wo(ge,le,va(_e),Ye);if(_e.$$typeof===cs)return wo(ge,le,O(ge,_e),Ye);jr(ge,_e)}return typeof _e=="string"&&_e!==""||typeof _e=="number"||typeof _e=="bigint"?(_e=""+_e,le!==null&&le.tag===6?(p(ge,le.sibling),Ye=T(le,_e),Ye.return=ge,ge=Ye):(p(ge,le),Ye=wd(_e,ge.mode,Ye),Ye.return=ge,ge=Ye),F(ge)):p(ge,le)}return function(ge,le,_e,Ye){try{fl=0;var Nt=wo(ge,le,_e,Ye);return _o=null,Nt}catch(Lt){if(Lt===Ni||Lt===ys)throw Lt;var ii=t(29,Lt,null,ge.mode);return ii.lanes=Ye,ii.return=ge,ii}}}function Qr(){for(var r=lr,l=hl=lr=0;lw?w:8);var F=Ct.T,J={};Ct.T=J,uf(r,!1,l,p);try{var xe=T(),ze=Ct.S;if(ze!==null&&ze(J,xe),xe!==null&&typeof xe=="object"&&typeof xe.then=="function"){var Qe=it(xe,v);Wu(r,l,Qe,qn(r))}else Wu(r,l,v,qn(r))}catch(ke){Wu(r,l,{then:function(){},status:"rejected",reason:ke},qn())}finally{ln(w),F!==null&&J.types!==null&&(F.types=J.types),Ct.T=F}}function Lm(r){var l=r.memoizedState;if(l!==null)return l;l={memoizedState:sl,baseState:sl,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gn,lastRenderedState:sl},next:null};var p={};return l.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gn,lastRenderedState:p},next:null},r.memoizedState=l,r=r.alternate,r!==null&&(r.memoizedState=l),l}function od(){return G(rl)}function lf(){return at().memoizedState}function Im(){return at().memoizedState}function Hy(r){for(var l=r.return;l!==null;){switch(l.tag){case 24:case 3:var p=qn();r=Ba(p);var v=Fa(l,r,p);v!==null&&(Kn(v,l,p),Jr(v,l,p)),l={cache:Se()},r.payload=l;return}l=l.return}}function Gy(r,l,p){var v=qn();p={lane:v,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},cf(r)?zm(l,p):(p=ko(r,l,p,v),p!==null&&(Kn(p,r,v),Pm(p,l,v)))}function Om(r,l,p){var v=qn();Wu(r,l,p,v)}function Wu(r,l,p,v){var T={lane:v,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null};if(cf(r))zm(l,T);else{var w=r.alternate;if(r.lanes===0&&(w===null||w.lanes===0)&&(w=l.lastRenderedReducer,w!==null))try{var F=l.lastRenderedState,J=w(F,p);if(T.hasEagerState=!0,T.eagerState=J,fi(J,F))return _r(r,l,T,0),en===null&&Qr(),!1}catch{}if(p=ko(r,l,T,v),p!==null)return Kn(p,r,v),Pm(p,l,v),!0}return!1}function uf(r,l,p,v){if(v={lane:2,revertLane:$e(),gesture:null,action:v,hasEagerState:!1,eagerState:null,next:null},cf(r)){if(l)throw Error(s(479))}else l=ko(r,p,v,2),l!==null&&Kn(l,r,2)}function cf(r){var l=r.alternate;return r===Wt||l!==null&&l===Wt}function zm(r,l){jt=$t=!0;var p=r.pending;p===null?l.next=l:(l.next=p.next,p.next=l),r.pending=l}function Pm(r,l,p){if((p&4194048)!==0){var v=l.lanes;v&=r.pendingLanes,p|=v,l.lanes=p,I(r,p)}}function ld(r,l,p,v){l=r.memoizedState,p=p(v,l),p=p==null?l:Df({},l,p),r.memoizedState=p,r.lanes===0&&(r.updateQueue.baseState=p)}function ff(r,l,p,v,T,w,F){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(v,w,F):l.prototype&&l.prototype.isPureReactComponent?!Ne(p,v)||!Ne(T,w):!0}function Bm(r,l,p,v){r=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,v),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,v),l.state!==r&&_c.enqueueReplaceState(l,l.state,null)}function qo(r,l){var p=l;if("ref"in l){p={};for(var v in l)v!=="ref"&&(p[v]=l[v])}if(r=r.defaultProps){p===l&&(p=Df({},p));for(var T in r)p[T]===void 0&&(p[T]=r[T])}return p}function hf(r,l){try{var p=r.onUncaughtError;p(l.value,{componentStack:l.stack})}catch(v){setTimeout(function(){throw v})}}function ud(r,l,p){try{var v=r.onCaughtError;v(p.value,{componentStack:p.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(T){setTimeout(function(){throw T})}}function cd(r,l,p){return p=Ba(p),p.tag=3,p.payload={element:null},p.callback=function(){hf(r,l)},p}function Fm(r){return r=Ba(r),r.tag=3,r}function Vm(r,l,p,v){var T=p.type.getDerivedStateFromError;if(typeof T=="function"){var w=v.value;r.payload=function(){return T(w)},r.callback=function(){ud(l,p,v)}}var F=p.stateNode;F!==null&&typeof F.componentDidCatch=="function"&&(r.callback=function(){ud(l,p,v),typeof T!="function"&&(Fr===null?Fr=new Set([this]):Fr.add(this));var J=v.stack;this.componentDidCatch(v.value,{componentStack:J!==null?J:""})})}function Xy(r,l,p,v,T){if(p.flags|=32768,v!==null&&typeof v=="object"&&typeof v.then=="function"){if(l=p.alternate,l!==null&&tt(l,p,T,!0),p=Ta.current,p!==null){switch(p.tag){case 31:case 13:return Aa===null?ql():p.alternate===null&&ni===0&&(ni=3),p.flags&=-257,p.flags|=65536,p.lanes=T,v===or?p.flags|=16384:(l=p.updateQueue,l===null?p.updateQueue=new Set([v]):l.add(v),jl(r,v,T)),!1;case 22:return p.flags|=65536,v===or?p.flags|=16384:(l=p.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([v])},p.updateQueue=l):(p=l.retryQueue,p===null?l.retryQueue=new Set([v]):p.add(v)),jl(r,v,T)),!1}throw Error(s(435,p.tag))}return jl(r,v,T),ql(),!1}if(un)return l=Ta.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=T,v!==$f&&(r=Error(s(422),{cause:v}),Ve(Ae(r,p)))):(v!==$f&&(l=Error(s(423),{cause:v}),Ve(Ae(l,p))),r=r.current.alternate,r.flags|=65536,T&=-T,r.lanes|=T,v=Ae(v,p),T=cd(r.stateNode,v,T),Ho(r,T),ni!==4&&(ni=2)),!1;var w=Error(s(520),{cause:v});if(w=Ae(w,p),Sc===null?Sc=[w]:Sc.push(w),ni!==4&&(ni=2),l===null)return!0;v=Ae(v,p),p=l;do{switch(p.tag){case 3:return p.flags|=65536,r=T&-T,p.lanes|=r,r=cd(p.stateNode,v,r),Ho(p,r),!1;case 1:if(l=p.type,w=p.stateNode,(p.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Fr===null||!Fr.has(w))))return p.flags|=65536,T&=-T,p.lanes|=T,T=Fm(T),Vm(T,r,p,v),Ho(p,T),!1}p=p.return}while(p!==null);return!1}function Wi(r,l,p,v){l.child=r===null?pp(l,null,p,v):Zi(l,r.child,p,v)}function km(r,l,p,v,T){p=p.render;var w=l.ref;if("ref"in v){var F={};for(var J in v)J!=="ref"&&(F[J]=v[J])}else F=v;return We(l),v=vt(r,l,p,F,w,T),J=Sn(),r!==null&&!Xn?(zn(r,l,T),Ws(r,l,T)):(un&&J&&se(l),l.flags|=1,Wi(r,l,v,T),l.child)}function Hm(r,l,p,v,T){if(r===null){var w=p.type;return typeof w=="function"&&!Jo(w)&&w.defaultProps===void 0&&p.compare===null?(l.tag=15,l.type=w,Gm(r,l,w,v,T)):(r=Rr(p.type,null,v,l,l.mode,T),r.ref=l.ref,r.return=l,l.child=r)}if(w=r.child,!Yu(r,T)){var F=w.memoizedProps;if(p=p.compare,p=p!==null?p:Ne,p(F,v)&&r.ref===l.ref)return Ws(r,l,T)}return l.flags|=1,r=Ga(w,v),r.ref=l.ref,r.return=l,l.child=r}function Gm(r,l,p,v,T){if(r!==null){var w=r.memoizedProps;if(Ne(w,v)&&r.ref===l.ref)if(Xn=!1,l.pendingProps=v=w,Yu(r,T))(r.flags&131072)!==0&&(Xn=!0);else return l.lanes=r.lanes,Ws(r,l,T)}return pf(r,l,p,v,T)}function Xm(r,l,p,v){var T=v.children,w=r!==null?r.memoizedState:null;if(r===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),v.mode==="hidden"){if((l.flags&128)!==0){if(w=w!==null?w.baseLanes|p:p,r!==null){for(v=l.child=r.child,T=0;v!==null;)T=T|v.lanes|v.childLanes,v=v.sibling;v=T&~w}else v=0,l.child=null;return zl(r,l,w,p,v)}if((p&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},r!==null&&st(l,w!==null?w.cachePool:null),w!==null?Kr(l,w):Gs(),me(l);else return v=l.lanes=536870912,zl(r,l,w!==null?w.baseLanes|p:p,p,v)}else w!==null?(st(l,w.cachePool),Kr(l,w),oe(),l.memoizedState=null):(r!==null&&st(l,null),Gs(),oe());return Wi(r,l,T,p),l.child}function Yo(r,l){return r!==null&&r.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function zl(r,l,p,v,T){var w=Ge();return w=w===null?null:{parent:ui?jn._currentValue:jn._currentValue2,pool:w},l.memoizedState={baseLanes:p,cachePool:w},r!==null&&st(l,null),Gs(),me(l),r!==null&&tt(r,l,v,!0),l.childLanes=T,null}function df(r,l){return l=to({mode:l.mode,children:l.children},r.mode),l.ref=r.ref,r.child=l,l.return=r,l}function fd(r,l,p){return Zi(l,r.child,null,p),r=df(l,l.pendingProps),r.flags|=2,qe(l),l.memoizedState=null,r}function Wm(r,l,p){var v=l.pendingProps,T=(l.flags&128)!==0;if(l.flags&=-129,r===null){if(un){if(v.mode==="hidden")return r=df(l,v),l.lanes=536870912,Yo(null,r);if(ye(l),(r=Zn)?(r=Kd(r,fa),r!==null&&(l.memoizedState={dehydrated:r,treeContext:ps!==null?{id:qi,overflow:Us}:null,retryLane:536870912,hydrationErrors:null},p=Cd(r),p.return=l,l.child=p,Ri=l,Zn=null)):r=null,r===null)throw et(l);return l.lanes=536870912,null}return df(l,v)}var w=r.memoizedState;if(w!==null){var F=w.dehydrated;if(ye(l),T)if(l.flags&256)l.flags&=-257,l=fd(r,l,p);else if(l.memoizedState!==null)l.child=r.child,l.flags|=128,l=null;else throw Error(s(558));else if(Xn||tt(r,l,p,!1),T=(p&r.childLanes)!==0,Xn||T){if(v=en,v!==null&&(F=z(v,p),F!==0&&F!==w.retryLane))throw w.retryLane=F,Ki(r,F),Kn(v,r,F),da;ql(),l=fd(r,l,p)}else r=w.treeContext,Yn&&(Zn=Cg(F),Ri=l,un=!0,rr=null,fa=!1,r!==null&&Oe(l,r)),l=df(l,v),l.flags|=4096;return l}return r=Ga(r.child,{mode:v.mode,children:v.children}),r.ref=l.ref,l.child=r,r.return=l,r}function qu(r,l){var p=l.ref;if(p===null)r!==null&&r.ref!==null&&(l.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(s(284));(r===null||r.ref!==p)&&(l.flags|=4194816)}}function pf(r,l,p,v,T){return We(l),p=vt(r,l,p,v,void 0,T),v=Sn(),r!==null&&!Xn?(zn(r,l,T),Ws(r,l,T)):(un&&v&&se(l),l.flags|=1,Wi(r,l,p,T),l.child)}function hd(r,l,p,v,T,w){return We(l),l.updateQueue=null,p=_t(l,v,p,T),At(r),v=Sn(),r!==null&&!Xn?(zn(r,l,w),Ws(r,l,w)):(un&&v&&se(l),l.flags|=1,Wi(r,l,p,w),l.child)}function Zo(r,l,p,v,T){if(We(l),l.stateNode===null){var w=ir,F=p.contextType;typeof F=="object"&&F!==null&&(w=G(F)),w=new p(v,w),l.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,w.updater=_c,l.stateNode=w,w._reactInternals=l,w=l.stateNode,w.props=v,w.state=l.memoizedState,w.refs={},Ti(l),F=p.contextType,w.context=typeof F=="object"&&F!==null?G(F):ir,w.state=l.memoizedState,F=p.getDerivedStateFromProps,typeof F=="function"&&(ld(l,p,F,v),w.state=l.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof w.getSnapshotBeforeUpdate=="function"||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(F=w.state,typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount(),F!==w.state&&_c.enqueueReplaceState(w,w.state,null),xr(l,v,w,T),Rs(),w.state=l.memoizedState),typeof w.componentDidMount=="function"&&(l.flags|=4194308),v=!0}else if(r===null){w=l.stateNode;var J=l.memoizedProps,xe=qo(p,J);w.props=xe;var ze=w.context,Qe=p.contextType;F=ir,typeof Qe=="object"&&Qe!==null&&(F=G(Qe));var ke=p.getDerivedStateFromProps;Qe=typeof ke=="function"||typeof w.getSnapshotBeforeUpdate=="function",J=l.pendingProps!==J,Qe||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(J||ze!==F)&&Bm(l,w,v,F),qa=!1;var dt=l.memoizedState;w.state=dt,xr(l,v,w,T),Rs(),ze=l.memoizedState,J||dt!==ze||qa?(typeof ke=="function"&&(ld(l,p,ke,v),ze=l.memoizedState),(xe=qa||ff(l,p,xe,v,dt,ze,F))?(Qe||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(l.flags|=4194308)):(typeof w.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=v,l.memoizedState=ze),w.props=v,w.state=ze,w.context=F,v=xe):(typeof w.componentDidMount=="function"&&(l.flags|=4194308),v=!1)}else{w=l.stateNode,Pa(r,l),F=l.memoizedProps,Qe=qo(p,F),w.props=Qe,ke=l.pendingProps,dt=w.context,ze=p.contextType,xe=ir,typeof ze=="object"&&ze!==null&&(xe=G(ze)),J=p.getDerivedStateFromProps,(ze=typeof J=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(F!==ke||dt!==xe)&&Bm(l,w,v,xe),qa=!1,dt=l.memoizedState,w.state=dt,xr(l,v,w,T),Rs();var Gt=l.memoizedState;F!==ke||dt!==Gt||qa||r!==null&&r.dependencies!==null&&Mt(r.dependencies)?(typeof J=="function"&&(ld(l,p,J,v),Gt=l.memoizedState),(Qe=qa||ff(l,p,Qe,v,dt,Gt,xe)||r!==null&&r.dependencies!==null&&Mt(r.dependencies))?(ze||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(v,Gt,xe),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(v,Gt,xe)),typeof w.componentDidUpdate=="function"&&(l.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof w.componentDidUpdate!="function"||F===r.memoizedProps&&dt===r.memoizedState||(l.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||F===r.memoizedProps&&dt===r.memoizedState||(l.flags|=1024),l.memoizedProps=v,l.memoizedState=Gt),w.props=v,w.state=Gt,w.context=xe,v=Qe):(typeof w.componentDidUpdate!="function"||F===r.memoizedProps&&dt===r.memoizedState||(l.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||F===r.memoizedProps&&dt===r.memoizedState||(l.flags|=1024),v=!1)}return w=v,qu(r,l),v=(l.flags&128)!==0,w||v?(w=l.stateNode,p=v&&typeof p.getDerivedStateFromError!="function"?null:w.render(),l.flags|=1,r!==null&&v?(l.child=Zi(l,r.child,null,T),l.child=Zi(l,null,p,T)):Wi(r,l,p,T),l.memoizedState=w.state,r=l.child):r=Ws(r,l,T),r}function qm(r,l,p,v){return Dt(),l.flags|=256,Wi(r,l,p,v),l.child}function dd(r){return{baseLanes:r,cachePool:Fe()}}function pd(r,l,p){return r=r!==null?r.childLanes&~p:0,l&&(r|=pa),r}function md(r,l,p){var v=l.pendingProps,T=!1,w=(l.flags&128)!==0,F;if((F=w)||(F=r!==null&&r.memoizedState===null?!1:(ri.current&2)!==0),F&&(T=!0,l.flags&=-129),F=(l.flags&32)!==0,l.flags&=-33,r===null){if(un){if(T?ie(l):oe(),(r=Zn)?(r=Ug(r,fa),r!==null&&(l.memoizedState={dehydrated:r,treeContext:ps!==null?{id:qi,overflow:Us}:null,retryLane:536870912,hydrationErrors:null},p=Cd(r),p.return=l,l.child=p,Ri=l,Zn=null)):r=null,r===null)throw et(l);return Bf(r)?l.lanes=32:l.lanes=536870912,null}var J=v.children;return v=v.fallback,T?(oe(),T=l.mode,J=to({mode:"hidden",children:J},T),v=us(v,T,p,null),J.return=l,v.return=l,J.sibling=v,l.child=J,v=l.child,v.memoizedState=dd(p),v.childLanes=pd(r,F,p),l.memoizedState=pl,Yo(null,v)):(ie(l),mf(l,J))}var xe=r.memoizedState;if(xe!==null&&(J=xe.dehydrated,J!==null)){if(w)l.flags&256?(ie(l),l.flags&=-257,l=jo(r,l,p)):l.memoizedState!==null?(oe(),l.child=r.child,l.flags|=128,l=null):(oe(),J=v.fallback,T=l.mode,v=to({mode:"visible",children:v.children},T),J=us(J,T,p,null),J.flags|=2,v.return=l,J.return=l,v.sibling=J,l.child=v,Zi(l,r.child,null,p),v=l.child,v.memoizedState=dd(p),v.childLanes=pd(r,F,p),l.memoizedState=pl,l=Yo(null,v));else if(ie(l),Bf(J))F=Ff(J).digest,v=Error(s(419)),v.stack="",v.digest=F,Ve({value:v,source:null,stack:null}),l=jo(r,l,p);else if(Xn||tt(r,l,p,!1),F=(p&r.childLanes)!==0,Xn||F){if(F=en,F!==null&&(v=z(F,p),v!==0&&v!==xe.retryLane))throw xe.retryLane=v,Ki(r,v),Kn(F,r,v),da;mo(J)||ql(),l=jo(r,l,p)}else mo(J)?(l.flags|=192,l.child=r.child,l=null):(r=xe.treeContext,Yn&&(Zn=Rg(J),Ri=l,un=!0,rr=null,fa=!1,r!==null&&Oe(l,r)),l=mf(l,v.children),l.flags|=4096);return l}return T?(oe(),J=v.fallback,T=l.mode,xe=r.child,w=xe.sibling,v=Ga(xe,{mode:"hidden",children:v.children}),v.subtreeFlags=xe.subtreeFlags&65011712,w!==null?J=Ga(w,J):(J=us(J,T,p,null),J.flags|=2),J.return=l,v.return=l,v.sibling=J,l.child=v,Yo(null,v),v=l.child,J=r.child.memoizedState,J===null?J=dd(p):(T=J.cachePool,T!==null?(xe=ui?jn._currentValue:jn._currentValue2,T=T.parent!==xe?{parent:xe,pool:xe}:T):T=Fe(),J={baseLanes:J.baseLanes|p,cachePool:T}),v.memoizedState=J,v.childLanes=pd(r,F,p),l.memoizedState=pl,Yo(r.child,v)):(ie(l),p=r.child,r=p.sibling,p=Ga(p,{mode:"visible",children:v.children}),p.return=l,p.sibling=null,r!==null&&(F=l.deletions,F===null?(l.deletions=[r],l.flags|=16):F.push(r)),l.child=p,l.memoizedState=null,p)}function mf(r,l){return l=to({mode:"visible",children:l},r.mode),l.return=r,r.child=l}function to(r,l){return r=t(22,r,null,l),r.lanes=0,r}function jo(r,l,p){return Zi(l,r.child,null,p),r=mf(l,l.pendingProps.children),r.flags|=2,l.memoizedState=null,r}function Ym(r,l,p){r.lanes|=l;var v=r.alternate;v!==null&&(v.lanes|=l),Z(r.return,l,p)}function Pl(r,l,p,v,T,w){var F=r.memoizedState;F===null?r.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:v,tail:p,tailMode:T,treeForkCount:w}:(F.isBackwards=l,F.rendering=null,F.renderingStartTime=0,F.last=v,F.tail=p,F.tailMode=T,F.treeForkCount=w)}function gd(r,l,p){var v=l.pendingProps,T=v.revealOrder,w=v.tail;v=v.children;var F=ri.current,J=(F&2)!==0;if(J?(F=F&1|2,l.flags|=128):F&=1,A(ri,F),Wi(r,l,v,p),v=un?gc:0,!J&&r!==null&&(r.flags&128)!==0)e:for(r=l.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Ym(r,p,l);else if(r.tag===19)Ym(r,p,l);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===l)break e;for(;r.sibling===null;){if(r.return===null||r.return===l)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(T){case"forwards":for(p=l.child,T=null;p!==null;)r=p.alternate,r!==null&&ht(r)===null&&(T=p),p=p.sibling;p=T,p===null?(T=l.child,l.child=null):(T=p.sibling,p.sibling=null),Pl(l,!1,T,p,w,v);break;case"backwards":case"unstable_legacy-backwards":for(p=null,T=l.child,l.child=null;T!==null;){if(r=T.alternate,r!==null&&ht(r)===null){l.child=T;break}r=T.sibling,T.sibling=p,p=T,T=r}Pl(l,!0,p,null,w,v);break;case"together":Pl(l,!1,null,null,void 0,v);break;default:l.memoizedState=null}return l.child}function Ws(r,l,p){if(r!==null&&(l.dependencies=r.dependencies),Br|=l.lanes,(p&l.childLanes)===0)if(r!==null){if(tt(r,l,p,!1),(p&l.childLanes)===0)return null}else return null;if(r!==null&&l.child!==r.child)throw Error(s(153));if(l.child!==null){for(r=l.child,p=Ga(r,r.pendingProps),l.child=p,p.return=l;r.sibling!==null;)r=r.sibling,p=p.sibling=Ga(r,r.pendingProps),p.return=l;p.sibling=null}return l.child}function Yu(r,l){return(r.lanes&l)!==0?!0:(r=r.dependencies,!!(r!==null&&Mt(r)))}function vd(r,l,p){switch(l.tag){case 3:nt(l,l.stateNode.containerInfo),Ue(l,jn,r.memoizedState.cache),Dt();break;case 27:case 5:Te(l);break;case 4:nt(l,l.stateNode.containerInfo);break;case 10:Ue(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,ye(l),null;break;case 13:var v=l.memoizedState;if(v!==null)return v.dehydrated!==null?(ie(l),l.flags|=128,null):(p&l.child.childLanes)!==0?md(r,l,p):(ie(l),r=Ws(r,l,p),r!==null?r.sibling:null);ie(l);break;case 19:var T=(r.flags&128)!==0;if(v=(p&l.childLanes)!==0,v||(tt(r,l,p,!1),v=(p&l.childLanes)!==0),T){if(v)return gd(r,l,p);l.flags|=128}if(T=l.memoizedState,T!==null&&(T.rendering=null,T.tail=null,T.lastEffect=null),A(ri,ri.current),v)break;return null;case 22:return l.lanes=0,Xm(r,l,p,l.pendingProps);case 24:Ue(l,jn,r.memoizedState.cache)}return Ws(r,l,p)}function yd(r,l,p){if(r!==null)if(r.memoizedProps!==l.pendingProps)Xn=!0;else{if(!Yu(r,p)&&(l.flags&128)===0)return Xn=!1,vd(r,l,p);Xn=(r.flags&131072)!==0}else Xn=!1,un&&(l.flags&1048576)!==0&&X(l,gc,l.index);switch(l.lanes=0,l.tag){case 16:e:{var v=l.pendingProps;if(r=dn(l.elementType),l.type=r,typeof r=="function")Jo(r)?(v=qo(r,v),l.tag=1,l=Zo(null,l,r,v,p)):(l.tag=0,l=pf(null,l,r,v,p));else{if(r!=null){var T=r.$$typeof;if(T===Ql){l.tag=11,l=km(null,l,r,v,p);break e}else if(T===Uf){l.tag=14,l=Hm(null,l,r,v,p);break e}}throw l=x(r)||r,Error(s(306,l,""))}}return l;case 0:return pf(r,l,l.type,l.pendingProps,p);case 1:return v=l.type,T=qo(v,l.pendingProps),Zo(r,l,v,T,p);case 3:e:{if(nt(l,l.stateNode.containerInfo),r===null)throw Error(s(387));var w=l.pendingProps;T=l.memoizedState,v=T.element,Pa(r,l),xr(l,w,null,p);var F=l.memoizedState;if(w=F.cache,Ue(l,jn,w),w!==T.cache&&St(l,[jn],p,!0),Rs(),w=F.element,Yn&&T.isDehydrated)if(T={element:w,isDehydrated:!1,cache:F.cache},l.updateQueue.baseState=T,l.memoizedState=T,l.flags&256){l=qm(r,l,w,p);break e}else if(w!==v){v=Ae(Error(s(424)),l),Ve(v),l=qm(r,l,w,p);break e}else for(Yn&&(Zn=wg(l.stateNode.containerInfo),Ri=l,un=!0,rr=null,fa=!0),p=pp(l,null,w,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Dt(),w===v){l=Ws(r,l,p);break e}Wi(r,l,w,p)}l=l.child}return l;case 26:if(hs)return qu(r,l),r===null?(p=ip(l.type,null,l.pendingProps,null))?l.memoizedState=p:un||(l.stateNode=Gf(l.type,l.pendingProps,Yi.current,l)):l.memoizedState=ip(l.type,r.memoizedProps,l.pendingProps,r.memoizedState),null;case 27:if(Ci)return Te(l),r===null&&Ci&&un&&(v=l.stateNode=Xf(l.type,l.pendingProps,Yi.current,Fi.current,!1),Ri=l,fa=!0,Zn=Jd(l.type,v,Zn)),Wi(r,l,l.pendingProps.children,p),qu(r,l),r===null&&(l.flags|=4194304),l.child;case 5:return r===null&&un&&(kg(l.type,l.pendingProps,Fi.current),(T=v=Zn)&&(v=Dg(v,l.type,l.pendingProps,fa),v!==null?(l.stateNode=v,Ri=l,Zn=Ag(v),fa=!1,T=!0):T=!1),T||et(l)),Te(l),T=l.type,w=l.pendingProps,F=r!==null?r.memoizedProps:null,v=w.children,ca(T,w)?v=null:F!==null&&ca(T,F)&&(l.flags|=32),l.memoizedState!==null&&(T=vt(r,l,Ut,null,null,p),ui?rl._currentValue=T:rl._currentValue2=T),qu(r,l),Wi(r,l,v,p),l.child;case 6:return r===null&&un&&(np(l.pendingProps,Fi.current),(r=p=Zn)&&(p=Ng(p,l.pendingProps,fa),p!==null?(l.stateNode=p,Ri=l,Zn=null,r=!0):r=!1),r||et(l)),null;case 13:return md(r,l,p);case 4:return nt(l,l.stateNode.containerInfo),v=l.pendingProps,r===null?l.child=Zi(l,null,v,p):Wi(r,l,v,p),l.child;case 11:return km(r,l,l.type,l.pendingProps,p);case 7:return Wi(r,l,l.pendingProps,p),l.child;case 8:return Wi(r,l,l.pendingProps.children,p),l.child;case 12:return Wi(r,l,l.pendingProps.children,p),l.child;case 10:return v=l.pendingProps,Ue(l,l.type,v.value),Wi(r,l,v.children,p),l.child;case 9:return T=l.type._context,v=l.pendingProps.children,We(l),T=G(T),v=v(T),l.flags|=1,Wi(r,l,v,p),l.child;case 14:return Hm(r,l,l.type,l.pendingProps,p);case 15:return Gm(r,l,l.type,l.pendingProps,p);case 19:return gd(r,l,p);case 31:return Wm(r,l,p);case 22:return Xm(r,l,p,l.pendingProps);case 24:return We(l),v=G(jn),r===null?(T=Ge(),T===null&&(T=en,w=Se(),T.pooledCache=w,w.refCount++,w!==null&&(T.pooledCacheLanes|=p),T=w),l.memoizedState={parent:v,cache:T},Ti(l),Ue(l,jn,T)):((r.lanes&p)!==0&&(Pa(r,l),xr(l,null,null,p),Rs()),T=r.memoizedState,w=l.memoizedState,T.parent!==v?(T={parent:v,cache:v},l.memoizedState=T,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=T),Ue(l,jn,v)):(v=w.cache,Ue(l,jn,v),v!==T.cache&&St(l,[jn],p,!0))),Wi(r,l,l.pendingProps.children,p),l.child;case 29:throw l.pendingProps}throw Error(s(156,l.tag))}function as(r){r.flags|=4}function Zu(r){Xa&&(r.flags|=8)}function Zm(r,l){if(r!==null&&r.child===l.child)return!1;if((l.flags&16)!==0)return!0;for(r=l.child;r!==null;){if((r.flags&8218)!==0||(r.subtreeFlags&8218)!==0)return!0;r=r.sibling}return!1}function _d(r,l,p,v){if(hn)for(p=l.child;p!==null;){if(p.tag===5||p.tag===6)lc(r,p.stateNode);else if(!(p.tag===4||Ci&&p.tag===27)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===l)break;for(;p.sibling===null;){if(p.return===null||p.return===l)return;p=p.return}p.sibling.return=p.return,p=p.sibling}else if(Xa)for(var T=l.child;T!==null;){if(T.tag===5){var w=T.stateNode;p&&v&&(w=bg(w,T.type,T.memoizedProps)),lc(r,w)}else if(T.tag===6)w=T.stateNode,p&&v&&(w=jd(w,T.memoizedProps)),lc(r,w);else if(T.tag!==4){if(T.tag===22&&T.memoizedState!==null)w=T.child,w!==null&&(w.return=T),_d(r,T,!0,!0);else if(T.child!==null){T.child.return=T,T=T.child;continue}}if(T===l)break;for(;T.sibling===null;){if(T.return===null||T.return===l)return;T=T.return}T.sibling.return=T.return,T=T.sibling}}function jm(r,l,p,v){var T=!1;if(Xa)for(var w=l.child;w!==null;){if(w.tag===5){var F=w.stateNode;p&&v&&(F=bg(F,w.type,w.memoizedProps)),Yd(r,F)}else if(w.tag===6)F=w.stateNode,p&&v&&(F=jd(F,w.memoizedProps)),Yd(r,F);else if(w.tag!==4){if(w.tag===22&&w.memoizedState!==null)T=w.child,T!==null&&(T.return=w),jm(r,w,!0,!0),T=!0;else if(w.child!==null){w.child.return=w,w=w.child;continue}}if(w===l)break;for(;w.sibling===null;){if(w.return===null||w.return===l)return T;w=w.return}w.sibling.return=w.return,w=w.sibling}return T}function Qm(r,l){if(Xa&&Zm(r,l)){r=l.stateNode;var p=r.containerInfo,v=qd();jm(v,l,!1,!1),r.pendingChildren=v,as(l),Sg(p,v)}}function xd(r,l,p,v){if(hn)r.memoizedProps!==v&&as(l);else if(Xa){var T=r.stateNode,w=r.memoizedProps;if((r=Zm(r,l))||w!==v){var F=Fi.current;w=xg(T,p,w,v,!r,null),w===T?l.stateNode=T:(Zu(l),Sa(w,p,v,F)&&as(l),l.stateNode=w,r&&_d(w,l,!1,!1))}else l.stateNode=T}}function oa(r,l,p,v,T){if((r.mode&32)!==0&&(p===null?uc(l,v):tu(l,p,v))){if(r.flags|=16777216,(T&335544128)===T||Od(l,v))if($n(r.stateNode,l,v))r.flags|=8192;else if(fn())r.flags|=8192;else throw ha=or,th}else r.flags&=-16777217}function Bl(r,l){if(op(l)){if(r.flags|=16777216,!lp(l))if(fn())r.flags|=8192;else throw ha=or,th}else r.flags&=-16777217}function ju(r,l){l!==null&&(r.flags|=4),r.flags&16384&&(l=r.tag!==22?L():536870912,r.lanes|=l,cu|=l)}function Fl(r,l){if(!un)switch(r.tailMode){case"hidden":l=r.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?r.tail=null:p.sibling=null;break;case"collapsed":p=r.tail;for(var v=null;p!==null;)p.alternate!==null&&(v=p),p=p.sibling;v===null?l||r.tail===null?r.tail=null:r.tail.sibling=null:v.sibling=null}}function Pn(r){var l=r.alternate!==null&&r.alternate.child===r.child,p=0,v=0;if(l)for(var T=r.child;T!==null;)p|=T.lanes|T.childLanes,v|=T.subtreeFlags&65011712,v|=T.flags&65011712,T.return=r,T=T.sibling;else for(T=r.child;T!==null;)p|=T.lanes|T.childLanes,v|=T.subtreeFlags,v|=T.flags,T.return=r,T=T.sibling;return r.subtreeFlags|=v,r.childLanes=p,l}function Jm(r,l,p){var v=l.pendingProps;switch(Ee(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pn(l),null;case 1:return Pn(l),null;case 3:return p=l.stateNode,v=null,r!==null&&(v=r.memoizedState.cache),l.memoizedState.cache!==v&&(l.flags|=2048),Ke(jn),fe(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(r===null||r.child===null)&&(on(l)?as(l):r===null||r.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Re())),Qm(r,l),Pn(l),null;case 26:if(hs){var T=l.type,w=l.memoizedState;return r===null?(as(l),w!==null?(Pn(l),Bl(l,w)):(Pn(l),oa(l,T,null,v,p))):w?w!==r.memoizedState?(as(l),Pn(l),Bl(l,w)):(Pn(l),l.flags&=-16777217):(w=r.memoizedProps,hn?w!==v&&as(l):xd(r,l,T,v),Pn(l),oa(l,T,w,v,p)),null}case 27:if(Ci){if(Je(l),p=Yi.current,T=l.type,r!==null&&l.stateNode!=null)hn?r.memoizedProps!==v&&as(l):xd(r,l,T,v);else{if(!v){if(l.stateNode===null)throw Error(s(166));return Pn(l),null}r=Fi.current,on(l)?ut(l,r):(r=Xf(T,v,p,r,!0),l.stateNode=r,as(l))}return Pn(l),null}case 5:if(Je(l),T=l.type,r!==null&&l.stateNode!=null)xd(r,l,T,v);else{if(!v){if(l.stateNode===null)throw Error(s(166));return Pn(l),null}if(w=Fi.current,on(l))ut(l,w),Bg(l.stateNode,T,v,w)&&(l.flags|=64);else{var F=Ld(T,v,Yi.current,w,l);Zu(l),_d(F,l,!1,!1),l.stateNode=F,Sa(F,T,v,w)&&as(l)}}return Pn(l),oa(l,l.type,r===null?null:r.memoizedProps,l.pendingProps,p),null;case 6:if(r&&l.stateNode!=null)p=r.memoizedProps,hn?p!==v&&as(l):Xa&&(p!==v?(r=Yi.current,p=Fi.current,Zu(l),l.stateNode=Ur(v,r,p,l)):l.stateNode=r.stateNode);else{if(typeof v!="string"&&l.stateNode===null)throw Error(s(166));if(r=Yi.current,p=Fi.current,on(l)){if(!Yn)throw Error(s(176));if(r=l.stateNode,p=l.memoizedProps,v=null,T=Ri,T!==null)switch(T.tag){case 27:case 5:v=T.memoizedProps}jy(r,p,l,v)||et(l,!0)}else Zu(l),l.stateNode=Ur(v,r,p,l)}return Pn(l),null;case 31:if(p=l.memoizedState,r===null||r.memoizedState!==null){if(v=on(l),p!==null){if(r===null){if(!v)throw Error(s(318));if(!Yn)throw Error(s(556));if(r=l.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(557));$d(r,l)}else Dt(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Pn(l),r=!1}else p=Re(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=p),r=!0;if(!r)return l.flags&256?(qe(l),l):(qe(l),null);if((l.flags&128)!==0)throw Error(s(558))}return Pn(l),null;case 13:if(v=l.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(T=on(l),v!==null&&v.dehydrated!==null){if(r===null){if(!T)throw Error(s(318));if(!Yn)throw Error(s(344));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(s(317));Ig(T,l)}else Dt(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Pn(l),T=!1}else T=Re(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=T),T=!0;if(!T)return l.flags&256?(qe(l),l):(qe(l),null)}return qe(l),(l.flags&128)!==0?(l.lanes=p,l):(p=v!==null,r=r!==null&&r.memoizedState!==null,p&&(v=l.child,T=null,v.alternate!==null&&v.alternate.memoizedState!==null&&v.alternate.memoizedState.cachePool!==null&&(T=v.alternate.memoizedState.cachePool.pool),w=null,v.memoizedState!==null&&v.memoizedState.cachePool!==null&&(w=v.memoizedState.cachePool.pool),w!==T&&(v.flags|=2048)),p!==r&&p&&(l.child.flags|=8192),ju(l,l.updateQueue),Pn(l),null);case 4:return fe(),Qm(r,l),r===null&&Ln(l.stateNode.containerInfo),Pn(l),null;case 10:return Ke(l.type),Pn(l),null;case 19:if(M(ri),v=l.memoizedState,v===null)return Pn(l),null;if(T=(l.flags&128)!==0,w=v.rendering,w===null)if(T)Fl(v,!1);else{if(ni!==0||r!==null&&(r.flags&128)!==0)for(r=l.child;r!==null;){if(w=ht(r),w!==null){for(l.flags|=128,Fl(v,!1),r=w.updateQueue,l.updateQueue=r,ju(l,r),l.subtreeFlags=0,r=p,p=l.child;p!==null;)wf(p,r),p=p.sibling;return A(ri,ri.current&1|2),un&&Ce(l,v.treeForkCount),l.child}r=r.sibling}v.tail!==null&&ea()>Ao&&(l.flags|=128,T=!0,Fl(v,!1),l.lanes=4194304)}else{if(!T)if(r=ht(w),r!==null){if(l.flags|=128,T=!0,r=r.updateQueue,l.updateQueue=r,ju(l,r),Fl(v,!0),v.tail===null&&v.tailMode==="hidden"&&!w.alternate&&!un)return Pn(l),null}else 2*ea()-v.renderingStartTime>Ao&&p!==536870912&&(l.flags|=128,T=!0,Fl(v,!1),l.lanes=4194304);v.isBackwards?(w.sibling=l.child,l.child=w):(r=v.last,r!==null?r.sibling=w:l.child=w,v.last=w)}return v.tail!==null?(r=v.tail,v.rendering=r,v.tail=r.sibling,v.renderingStartTime=ea(),r.sibling=null,p=ri.current,A(ri,T?p&1|2:p&1),un&&Ce(l,v.treeForkCount),r):(Pn(l),null);case 22:case 23:return qe(l),V(),v=l.memoizedState!==null,r!==null?r.memoizedState!==null!==v&&(l.flags|=8192):v&&(l.flags|=8192),v?(p&536870912)!==0&&(l.flags&128)===0&&(Pn(l),l.subtreeFlags&6&&(l.flags|=8192)):Pn(l),p=l.updateQueue,p!==null&&ju(l,p.retryQueue),p=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(p=r.memoizedState.cachePool.pool),v=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(v=l.memoizedState.cachePool.pool),v!==p&&(l.flags|=2048),r!==null&&M(yo),null;case 24:return p=null,r!==null&&(p=r.memoizedState.cache),l.memoizedState.cache!==p&&(l.flags|=2048),Ke(jn),Pn(l),null;case 25:return null;case 30:return null}throw Error(s(156,l.tag))}function Sd(r,l){switch(Ee(l),l.tag){case 1:return r=l.flags,r&65536?(l.flags=r&-65537|128,l):null;case 3:return Ke(jn),fe(),r=l.flags,(r&65536)!==0&&(r&128)===0?(l.flags=r&-65537|128,l):null;case 26:case 27:case 5:return Je(l),null;case 31:if(l.memoizedState!==null){if(qe(l),l.alternate===null)throw Error(s(340));Dt()}return r=l.flags,r&65536?(l.flags=r&-65537|128,l):null;case 13:if(qe(l),r=l.memoizedState,r!==null&&r.dehydrated!==null){if(l.alternate===null)throw Error(s(340));Dt()}return r=l.flags,r&65536?(l.flags=r&-65537|128,l):null;case 19:return M(ri),null;case 4:return fe(),null;case 10:return Ke(l.type),null;case 22:case 23:return qe(l),V(),r!==null&&M(yo),r=l.flags,r&65536?(l.flags=r&-65537|128,l):null;case 24:return Ke(jn),null;case 25:return null;default:return null}}function Km(r,l){switch(Ee(l),l.tag){case 3:Ke(jn),fe();break;case 26:case 27:case 5:Je(l);break;case 4:fe();break;case 31:l.memoizedState!==null&&qe(l);break;case 13:qe(l);break;case 19:M(ri);break;case 10:Ke(l.type);break;case 22:case 23:qe(l),V(),r!==null&&M(yo);break;case 24:Ke(jn)}}function qs(r,l){try{var p=l.updateQueue,v=p!==null?p.lastEffect:null;if(v!==null){var T=v.next;p=T;do{if((p.tag&r)===r){v=void 0;var w=p.create,F=p.inst;v=w(),F.destroy=v}p=p.next}while(p!==T)}}catch(J){Pt(l,l.return,J)}}function Ys(r,l,p){try{var v=l.updateQueue,T=v!==null?v.lastEffect:null;if(T!==null){var w=T.next;v=w;do{if((v.tag&r)===r){var F=v.inst,J=F.destroy;if(J!==void 0){F.destroy=void 0,T=l;var xe=p,ze=J;try{ze()}catch(Qe){Pt(T,xe,Qe)}}}v=v.next}while(v!==w)}}catch(Qe){Pt(l,l.return,Qe)}}function Vl(r){var l=r.updateQueue;if(l!==null){var p=r.stateNode;try{br(l,p)}catch(v){Pt(r,r.return,v)}}}function gf(r,l,p){p.props=qo(r.type,r.memoizedProps),p.state=r.memoizedState;try{p.componentWillUnmount()}catch(v){Pt(r,l,v)}}function kl(r,l){try{var p=r.ref;if(p!==null){switch(r.tag){case 26:case 27:case 5:var v=Kl(r.stateNode);break;case 30:v=r.stateNode;break;default:v=r.stateNode}typeof p=="function"?r.refCleanup=p(v):p.current=v}}catch(T){Pt(r,l,T)}}function $i(r,l){var p=r.ref,v=r.refCleanup;if(p!==null)if(typeof v=="function")try{v()}catch(T){Pt(r,l,T)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(T){Pt(r,l,T)}else p.current=null}function Qo(r){var l=r.type,p=r.memoizedProps,v=r.stateNode;try{hg(v,l,p,r)}catch(T){Pt(r,r.return,T)}}function Qu(r,l,p){try{dg(r.stateNode,r.type,p,l,r)}catch(v){Pt(r,r.return,v)}}function bd(r){return r.tag===5||r.tag===3||(hs?r.tag===26:!1)||(Ci?r.tag===27&&ol(r.type):!1)||r.tag===4}function Er(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||bd(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(Ci&&r.tag===27&&ol(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function vf(r,l,p){var v=r.tag;if(v===5||v===6)r=r.stateNode,l?mg(p,r,l):Hd(p,r);else if(v!==4&&(Ci&&v===27&&ol(r.type)&&(p=r.stateNode,l=null),r=r.child,r!==null))for(vf(r,l,p),r=r.sibling;r!==null;)vf(r,l,p),r=r.sibling}function Ju(r,l,p){var v=r.tag;if(v===5||v===6)r=r.stateNode,l?pg(p,r,l):kd(p,r);else if(v!==4&&(Ci&&v===27&&ol(r.type)&&(p=r.stateNode),r=r.child,r!==null))for(Ju(r,l,p),r=r.sibling;r!==null;)Ju(r,l,p),r=r.sibling}function Md(r,l,p){r=r.containerInfo;try{Zd(r,p)}catch(v){Pt(l,l.return,v)}}function $m(r){var l=r.stateNode,p=r.memoizedProps;try{xi(r.type,p,l,r)}catch(v){Pt(r,r.return,v)}}function Wy(r,l){for(Lf(r.containerInfo),hi=l;hi!==null;)if(r=hi,l=r.child,(r.subtreeFlags&1028)!==0&&l!==null)l.return=r,hi=l;else for(;hi!==null;){r=hi;var p=r.alternate;switch(l=r.flags,r.tag){case 0:if((l&4)!==0&&(l=r.updateQueue,l=l!==null?l.events:null,l!==null))for(var v=0;v";case ou:return":has("+(Xl(r)||"")+")";case lu:return'[role="'+r.value+'"]';case bo:return'"'+r.value+'"';case xc:return'[data-testname="'+r.value+'"]';default:throw Error(s(365))}}function Wl(r,l){var p=[];r=[r,0];for(var v=0;vp?32:p;p=Ct.T;var T=fs();try{ln(v),Ct.T=null,v=ah,ah=null;var w=Vr,F=fr;if(bi=0,vl=Vr=null,fr=0,(sn&6)!==0)throw Error(s(331));var J=sn;if(sn|=4,Sf(w.current),_f(w,w.current,F,v),sn=J,Ze(0,!1),Ea&&typeof Ea.onPostCommitFiberRoot=="function")try{Ea.onPostCommitFiberRoot(cl,w)}catch{}return!0}finally{ln(T),Ct.T=p,Af(r,l)}}function uo(r,l,p){l=Ae(p,l),l=cd(r.stateNode,l,2),r=Fa(r,l,2),r!==null&&(P(r,2),ct(r))}function Pt(r,l,p){if(r.tag===3)uo(r,r,p);else for(;l!==null;){if(l.tag===3){uo(l,r,p);break}else if(l.tag===1){var v=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof v.componentDidCatch=="function"&&(Fr===null||!Fr.has(v))){r=Ae(p,r),p=Fm(2),v=Fa(l,p,2),v!==null&&(Vm(p,v,l,r),P(v,2),ct(v));break}}l=l.return}}function jl(r,l,p){var v=r.pingCache;if(v===null){v=r.pingCache=new ja;var T=new Set;v.set(l,T)}else T=v.get(l),T===void 0&&(T=new Set,v.set(l,T));T.has(p)||(Eo=!0,T.add(p),r=ag.bind(null,r,l,p),l.then(r,r))}function ag(r,l,p){var v=r.pingCache;v!==null&&v.delete(l),r.pingedLanes|=r.suspendedLanes&p,r.warmLanes&=~p,en===r&&(cn&p)===p&&(ni===4||ni===3&&(cn&62914560)===cn&&300>ea()-bc?(sn&2)===0&&si(r,0):uu|=p,cu===cn&&(cu=0)),ct(r)}function sg(r,l){l===0&&(l=L()),r=Ki(r,l),r!==null&&(P(r,l),ct(r))}function qy(r){var l=r.memoizedState,p=0;l!==null&&(p=l.retryLane),sg(r,p)}function Yy(r,l){var p=0;switch(r.tag){case 31:case 13:var v=r.stateNode,T=r.memoizedState;T!==null&&(p=T.retryLane);break;case 19:v=r.stateNode;break;case 22:v=r.stateNode._retryCache;break;default:throw Error(s(314))}v!==null&&v.delete(l),sg(r,p)}function _i(r,l){return dc(r,l)}function Ad(r,l,p,v){this.tag=r,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=v,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Jo(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Ga(r,l){var p=r.alternate;return p===null?(p=t(r.tag,l,r.key,r.mode),p.elementType=r.elementType,p.type=r.type,p.stateNode=r.stateNode,p.alternate=r,r.alternate=p):(p.pendingProps=l,p.type=r.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=r.flags&65011712,p.childLanes=r.childLanes,p.lanes=r.lanes,p.child=r.child,p.memoizedProps=r.memoizedProps,p.memoizedState=r.memoizedState,p.updateQueue=r.updateQueue,l=r.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=r.sibling,p.index=r.index,p.ref=r.ref,p.refCleanup=r.refCleanup,p}function wf(r,l){r.flags&=65011714;var p=r.alternate;return p===null?(r.childLanes=0,r.lanes=l,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=p.childLanes,r.lanes=p.lanes,r.child=p.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=p.memoizedProps,r.memoizedState=p.memoizedState,r.updateQueue=p.updateQueue,r.type=p.type,l=p.dependencies,r.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),r}function Rr(r,l,p,v,T,w){var F=0;if(v=r,typeof r=="function")Jo(r)&&(F=1);else if(typeof r=="string")F=hs&&Ci?Hf(r,p,Fi.current)?26:up(r)?27:5:hs?Hf(r,p,Fi.current)?26:5:Ci&&up(r)?27:5;else e:switch(r){case rc:return r=t(31,p,l,T),r.elementType=rc,r.lanes=w,r;case tl:return us(p.children,T,w,l);case nl:F=8,T|=24;break;case il:return r=t(12,p,l,T|2),r.elementType=il,r.lanes=w,r;case Nf:return r=t(13,p,l,T),r.elementType=Nf,r.lanes=w,r;case Dr:return r=t(19,p,l,T),r.elementType=Dr,r.lanes=w,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case cs:F=10;break e;case sc:F=9;break e;case Ql:F=11;break e;case Uf:F=14;break e;case ua:F=16,v=null;break e}F=29,p=Error(s(130,r===null?"null":typeof r,"")),v=null}return l=t(F,p,l,T),l.elementType=r,l.type=v,l.lanes=w,l}function us(r,l,p,v){return r=t(7,r,v,l),r.lanes=p,r}function wd(r,l,p){return r=t(6,r,null,l),r.lanes=p,r}function Cd(r){var l=t(18,null,null,0);return l.stateNode=r,l}function Rd(r,l,p){return l=t(4,r.children!==null?r.children:[],r.key,l),l.lanes=p,l.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},l}function rg(r,l,p,v,T,w,F,J,xe){this.tag=1,this.containerInfo=r,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=ba,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=B(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=B(0),this.hiddenUpdates=B(null),this.identifierPrefix=v,this.onUncaughtError=T,this.onCaughtError=w,this.onRecoverableError=F,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=xe,this.incompleteTransitions=new Map}function co(r,l,p,v,T,w,F,J,xe,ze,Qe,ke){return r=new rg(r,l,p,F,xe,ze,Qe,ke,J),l=1,w===!0&&(l|=24),w=t(3,null,null,l),r.current=w,w.stateNode=r,l=Se(),l.refCount++,r.pooledCache=l,l.refCount++,w.memoizedState={element:v,isDehydrated:p,cache:l},Ti(w),r}function Cf(r){return r?(r=ir,r):ir}function ic(r){var l=r._reactInternals;if(l===void 0)throw typeof r.render=="function"?Error(s(188)):(r=Object.keys(r).join(","),Error(s(268,r)));return r=h(l),r=r!==null?m(r):null,r===null?null:Kl(r.stateNode)}function Dd(r,l,p,v,T,w){T=Cf(T),v.context===null?v.context=T:v.pendingContext=T,v=Ba(l),v.payload={element:p},w=w===void 0?null:w,w!==null&&(v.callback=w),p=Fa(r,v,l),p!==null&&(Kn(p,r,l),Jr(p,r,l))}function Ko(r,l){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var p=r.retryLane;r.retryLane=p!==0&&p=ze&&w>=ke&&T<=Qe&&F<=dt){r.splice(l,1);break}else if(v!==ze||p.width!==xe.width||dtF){if(!(w!==ke||p.height!==xe.height||QeT)){ze>v&&(xe.width+=ze-v,xe.x=v),Qew&&(xe.height+=ke-w,xe.y=w),dtp&&(p=J)),J ")+` No matching component was found for: `)+r.join(" > ")}return null},Kt.getPublicRootInstance=function(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 27:case 5:return Kl(r.child.stateNode);default:return r.child.stateNode}},Kt.injectIntoDevTools=function(){var r={bundleType:0,version:Ud,rendererPackageName:oc,currentDispatcherRef:Ct,reconcilerVersion:"19.2.0"};if(Jl!==null&&(r.rendererConfig=Jl),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")r=!1;else{var l=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(l.isDisabled||!l.supportsFiber)r=!0;else{try{cl=l.inject(r),Ea=l}catch{}r=!!l.checkDCE}}return r},Kt.isAlreadyRendering=function(){return(sn&6)!==0},Kt.observeVisibleRects=function(r,l,p,v){if(!wi)throw Error(s(363));r=_a(r,l);var T=Pf(r,p,v).disconnect;return{disconnect:function(){T()}}},Kt.shouldError=function(){return null},Kt.shouldSuspend=function(){return!1},Kt.startHostTransition=function(r,l,p,v){if(r.tag!==5)throw Error(s(476));var T=Lm(r).queue;Um(r,T,l,sl,p===null?i:function(){var w=Lm(r);return w.next===null&&(w=r.alternate.memoizedState),Wu(r,w.next.queue,{},qn()),p(v)})},Kt.updateContainer=function(r,l,p,v){var T=l.current,w=qn();return Dd(T,w,r,l,p,v),w},Kt.updateContainerSync=function(r,l,p,v){return Dd(l.current,2,r,l,p,v),2},Kt},o.exports.default=o.exports,Object.defineProperty(o.exports,"__esModule",{value:!0})})(w1)),w1.exports}var R1;function aO(){return R1||(R1=1,A1.exports=iO()),A1.exports}var sO=aO();const rO=nO(sO);function oO(o){const e=rO(o);return e.injectIntoDevTools(),e}const FT=0,Zh={},lO=/^three(?=[A-Z])/,ky=o=>`${o[0].toUpperCase()}${o.slice(1)}`;let uO=0;const cO=o=>typeof o=="function";function fO(o){if(cO(o)){const e=`${uO++}`;return Zh[e]=o,e}else Object.assign(Zh,o)}function VT(o,e){const t=ky(o),i=Zh[t];if(o!=="primitive"&&!i)throw new Error(`R3F: ${t} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(o==="primitive"&&!e.object)throw new Error("R3F: Primitives without 'object' are invalid!");if(e.args!==void 0&&!Array.isArray(e.args))throw new Error("R3F: The args prop must be an array!")}function hO(o,e,t){var i;return o=ky(o)in Zh?o:o.replace(lO,""),VT(o,e),o==="primitive"&&(i=e.object)!=null&&i.__r3f&&delete e.object.__r3f,ey(e.object,t,o,e)}function dO(o){if(!o.isHidden){var e;o.props.attach&&(e=o.parent)!=null&&e.object?ny(o.parent,o):Es(o.object)&&(o.object.visible=!1),o.isHidden=!0,td(o)}}function kT(o){if(o.isHidden){var e;o.props.attach&&(e=o.parent)!=null&&e.object?ty(o.parent,o):Es(o.object)&&o.props.visible!==!1&&(o.object.visible=!0),o.isHidden=!1,td(o)}}function jS(o,e,t){const i=e.root.getState();if(!(!o.parent&&o.object!==i.scene)){if(!e.object){var s,u;const f=Zh[ky(e.type)];e.object=(s=e.props.object)!=null?s:new f(...(u=e.props.args)!=null?u:[]),e.object.__r3f=e}if(Cu(e.object,e.props),e.props.attach)ty(o,e);else if(Es(e.object)&&Es(o.object)){const f=o.object.children.indexOf(t?.object);if(t&&f!==-1){const h=o.object.children.indexOf(e.object);if(h!==-1){o.object.children.splice(h,1);const m=h{try{o.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<"u"?e():Wx.unstable_scheduleCallback(Wx.unstable_IdlePriority,e)}}function Yx(o,e,t){if(!e)return;e.parent=null;const i=o.children.indexOf(e);i!==-1&&o.children.splice(i,1),e.props.attach?ny(o,e):Es(e.object)&&Es(o.object)&&(o.object.remove(e.object),YI(NT(e),e.object));const s=e.props.dispose!==null&&t!==!1;for(let u=e.children.length-1;u>=0;u--){const f=e.children[u];Yx(e,f,s)}e.children.length=0,delete e.object.__r3f,s&&e.type!=="primitive"&&e.object.type!=="Scene"&&HT(e.object),t===void 0&&td(e)}function pO(o,e){for(const t of[o,o.alternate])if(t!==null)if(typeof t.ref=="function"){t.refCleanup==null||t.refCleanup();const i=t.ref(e);typeof i=="function"&&(t.refCleanup=i)}else t.ref&&(t.ref.current=e)}const ov=[];function mO(){for(const[t]of ov){const i=t.parent;if(i){t.props.attach?ny(i,t):Es(t.object)&&Es(i.object)&&i.object.remove(t.object);for(const s of t.children)s.props.attach?ny(t,s):Es(s.object)&&Es(t.object)&&t.object.remove(s.object)}t.isHidden&&kT(t),t.object.__r3f&&delete t.object.__r3f,t.type!=="primitive"&&HT(t.object)}for(const[t,i,s]of ov){t.props=i;const u=t.parent;if(u){var o,e;const f=Zh[ky(t.type)];t.object=(o=t.props.object)!=null?o:new f(...(e=t.props.args)!=null?e:[]),t.object.__r3f=t,pO(s,t.object),Cu(t.object,t.props),t.props.attach?ty(u,t):Es(t.object)&&Es(u.object)&&u.object.add(t.object);for(const h of t.children)h.props.attach?ty(t,h):Es(h.object)&&Es(t.object)&&t.object.add(h.object);td(t)}}ov.length=0}const bx=()=>{},N1={};let iv=FT;const gO=0,vO=4,Zx=oO({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:hO,removeChild:Yx,appendChild:Sx,appendInitialChild:Sx,insertBefore:D1,appendChildToContainer(o,e){const t=o.getState().scene.__r3f;!e||!t||Sx(t,e)},removeChildFromContainer(o,e){const t=o.getState().scene.__r3f;!e||!t||Yx(t,e)},insertInContainerBefore(o,e,t){const i=o.getState().scene.__r3f;!e||!t||!i||D1(i,e,t)},getRootHostContext:()=>N1,getChildHostContext:()=>N1,commitUpdate(o,e,t,i,s){var u,f,h;VT(e,i);let m=!1;if((o.type==="primitive"&&t.object!==i.object||((u=i.args)==null?void 0:u.length)!==((f=t.args)==null?void 0:f.length)||(h=i.args)!=null&&h.some((_,x)=>{var b;return _!==((b=t.args)==null?void 0:b[x])}))&&(m=!0),m)ov.push([o,{...i},s]);else{const _=GI(o,i);Object.keys(_).length&&(Object.assign(o.props,_),Cu(o.object,_))}(s.sibling===null||(s.flags&vO)===gO)&&mO()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:o=>o?.object,prepareForCommit:()=>null,preparePortalMount:o=>ey(o.getState().scene,o,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:dO,unhideInstance:kT,createTextInstance:bx,hideTextInstance:bx,unhideTextInstance:bx,scheduleTimeout:typeof setTimeout=="function"?setTimeout:void 0,cancelTimeout:typeof clearTimeout=="function"?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:It.createContext(null),setCurrentUpdatePriority(o){iv=o},getCurrentUpdatePriority(){return iv},resolveUpdatePriority(){var o;if(iv!==FT)return iv;switch(typeof window<"u"&&((o=window.event)==null?void 0:o.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return eO;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return KI;default:return $I}},resetFormInstance(){},rendererPackageName:"@react-three/fiber",rendererVersion:tO.version,applyViewTransitionName(o,e,t){},restoreViewTransitionName(o,e){},cancelViewTransitionName(o,e,t){},cancelRootViewTransitionName(o){},restoreRootViewTransitionName(o){},InstanceMeasurement:null,measureInstance:o=>null,wasInstanceInViewport:o=>!0,hasInstanceChanged:(o,e)=>!1,hasInstanceAffectedParent:(o,e)=>!1,suspendOnActiveViewTransition(o,e){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(o){},createViewTransitionInstance:o=>null,getCurrentGestureOffset(o){throw new Error("startGestureTransition is not yet supported in react-three-fiber.")},cloneMutableInstance(o,e){return o},cloneMutableTextInstance(o){return o},cloneRootViewTransitionContainer(o){throw new Error("Not implemented.")},removeRootViewTransitionClone(o,e){throw new Error("Not implemented.")},createFragmentInstance:o=>null,updateFragmentInstanceFiber(o,e){},commitNewChildToFragmentInstance(o,e){},deleteChildFromFragmentInstance(o,e){},measureClonedInstance:o=>null,maySuspendCommitOnUpdate:(o,e,t)=>!1,maySuspendCommitInSyncRender:(o,e)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(o,e)=>null}),Kc=new Map,Nh={objects:"shallow",strict:!1};function yO(o,e){if(!e&&typeof HTMLCanvasElement<"u"&&o instanceof HTMLCanvasElement&&o.parentElement){const{width:t,height:i,top:s,left:u}=o.parentElement.getBoundingClientRect();return{width:t,height:i,top:s,left:u}}else if(!e&&typeof OffscreenCanvas<"u"&&o instanceof OffscreenCanvas)return{width:o.width,height:o.height,top:0,left:0};return{width:0,height:0,top:0,left:0,...e}}function _O(o){const e=Kc.get(o),t=e?.fiber,i=e?.store;e&&console.warn("R3F.createRoot should only be called once!");const s=typeof reportError=="function"?reportError:console.error,u=i||jI(Jx,L1),f=t||Zx.createContainer(u,JI,null,!1,null,"",s,s,s,null);e||Kc.set(o,{fiber:f,store:u});let h,m,g=!1,_=null;return{async configure(x={}){let b;_=new Promise(X=>b=X);let{gl:M,size:A,scene:R,events:C,onCreated:E,shadows:D=!1,linear:U=!1,flat:L=!1,legacy:B=!1,orthographic:P=!1,frameloop:H="always",dpr:W=[1,2],performance:I,raycaster:z,camera:j,onPointerMissed:ae}=x,$=u.getState(),ue=$.gl;if(!$.gl){const X={canvas:o,powerPreference:"high-performance",antialias:!0,alpha:!0},se=typeof M=="function"?await M(X):M;T1(se)?ue=se:ue=new wT({...X,...M}),$.set({gl:ue})}let he=$.raycaster;he||$.set({raycaster:he=new _T});const{params:q,...K}=z||{};if(mi.equ(K,he,Nh)||Cu(he,{...K}),mi.equ(q,he.params,Nh)||Cu(he,{params:{...he.params,...q}}),!$.camera||$.camera===m&&!mi.equ(m,j,Nh)){m=j;const X=j?.isCamera,se=X?j:P?new $h(0,0,0,0,.1,1e3):new aa(75,0,.1,1e3);X||(se.position.z=5,j&&(Cu(se,j),se.manual||("aspect"in j||"left"in j||"right"in j||"bottom"in j||"top"in j)&&(se.manual=!0,se.updateProjectionMatrix())),!$.camera&&!(j!=null&&j.rotation)&&se.lookAt(0,0,0)),$.set({camera:se}),he.camera=se}if(!$.scene){let X;R!=null&&R.isScene?(X=R,ey(X,u,"",{})):(X=new _S,ey(X,u,"",{}),R&&Cu(X,R)),$.set({scene:X})}C&&!$.events.handlers&&$.set({events:C(u)});const ce=yO(o,A);if(mi.equ(ce,$.size,Nh)||$.setSize(ce.width,ce.height,ce.top,ce.left),W&&$.viewport.dpr!==IT(W)&&$.setDpr(W),$.frameloop!==H&&$.setFrameloop(H),$.onPointerMissed||$.set({onPointerMissed:ae}),I&&!mi.equ(I,$.performance,Nh)&&$.set(X=>({performance:{...X.performance,...I}})),!$.xr){var Ae;const X=(Oe,nt)=>{const fe=u.getState();fe.frameloop!=="never"&&L1(Oe,!0,fe,nt)},se=()=>{const Oe=u.getState();Oe.gl.xr.enabled=Oe.gl.xr.isPresenting,Oe.gl.xr.setAnimationLoop(Oe.gl.xr.isPresenting?X:null),Oe.gl.xr.isPresenting||Jx(Oe)},Ee={connect(){const Oe=u.getState().gl;Oe.xr.addEventListener("sessionstart",se),Oe.xr.addEventListener("sessionend",se)},disconnect(){const Oe=u.getState().gl;Oe.xr.removeEventListener("sessionstart",se),Oe.xr.removeEventListener("sessionend",se)}};typeof((Ae=ue.xr)==null?void 0:Ae.addEventListener)=="function"&&Ee.connect(),$.set({xr:Ee})}if(ue.shadowMap){const X=ue.shadowMap.enabled,se=ue.shadowMap.type;if(ue.shadowMap.enabled=!!D,mi.boo(D))ue.shadowMap.type=Xp;else if(mi.str(D)){var Ce;const Ee={basic:F1,percentage:zh,soft:Xp,variance:kc};ue.shadowMap.type=(Ce=Ee[D])!=null?Ce:Xp}else mi.obj(D)&&Object.assign(ue.shadowMap,D);(X!==ue.shadowMap.enabled||se!==ue.shadowMap.type)&&(ue.shadowMap.needsUpdate=!0)}return xn.enabled=!B,g||(ue.outputColorSpace=U?Lu:Ua,ue.toneMapping=L?mr:sy),$.legacy!==B&&$.set(()=>({legacy:B})),$.linear!==U&&$.set(()=>({linear:U})),$.flat!==L&&$.set(()=>({flat:L})),M&&!mi.fun(M)&&!T1(M)&&!mi.equ(M,ue,Nh)&&Cu(ue,M),h=E,g=!0,b(),this},render(x){return!g&&!_&&this.configure(),_.then(()=>{Zx.updateContainer(Bs.jsx(xO,{store:u,children:x,onCreated:h,rootElement:o}),f,null,()=>{})}),u},unmount(){GT(o)}}}function xO({store:o,children:e,onCreated:t,rootElement:i}){return Cm(()=>{const s=o.getState();s.set(u=>({internal:{...u.internal,active:!0}})),t&&t(s),o.getState().events.connected||s.events.connect==null||s.events.connect(i)},[]),Bs.jsx(PT.Provider,{value:o,children:e})}function GT(o,e){const t=Kc.get(o),i=t?.fiber;if(i){const s=t?.store.getState();s&&(s.internal.active=!1),Zx.updateContainer(null,i,null,()=>{s&&setTimeout(()=>{try{var u,f,h,m;s.events.disconnect==null||s.events.disconnect(),(u=s.gl)==null||(f=u.renderLists)==null||f.dispose==null||f.dispose(),(h=s.gl)==null||h.forceContextLoss==null||h.forceContextLoss(),(m=s.gl)!=null&&m.xr&&s.xr.disconnect(),VI(s.scene),Kc.delete(o)}catch{}},500)})}}const SO=new Set,bO=new Set,MO=new Set;function Mx(o,e){if(o.size)for(const{callback:t}of o.values())t(e)}function $p(o,e){switch(o){case"before":return Mx(SO,e);case"after":return Mx(bO,e);case"tail":return Mx(MO,e)}}let Ex,Tx;function jx(o,e,t){let i=e.clock.getDelta();e.frameloop==="never"&&typeof o=="number"&&(i=o-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=o),Ex=e.internal.subscribers;for(let s=0;s0)&&!((e=Uh.gl.xr)!=null&&e.isPresenting)&&(Ax+=jx(o,Uh))}if(Qx=!1,$p("after",o),Ax===0)return $p("tail",o),iy=!1,cancelAnimationFrame(U1)}function Jx(o,e=1){var t;if(!o)return Kc.forEach(i=>Jx(i.store.getState(),e));(t=o.gl.xr)!=null&&t.isPresenting||!o.internal.active||o.frameloop==="never"||(e>1?o.internal.frames=Math.min(60,o.internal.frames+e):Qx?o.internal.frames=2:o.internal.frames=1,iy||(iy=!0,requestAnimationFrame(XT)))}function L1(o,e=!0,t,i){if(e&&$p("before",o),t)jx(o,t,i);else for(const s of Kc.values())jx(o,s.store.getState());e&&$p("after",o)}const wx={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function EO(o){const{handlePointer:e}=ZI(o);return{priority:1,enabled:!0,compute(t,i,s){i.pointer.set(t.offsetX/i.size.width*2-1,-(t.offsetY/i.size.height)*2+1),i.raycaster.setFromCamera(i.pointer,i.camera)},connected:void 0,handlers:Object.keys(wx).reduce((t,i)=>({...t,[i]:e(i)}),{}),update:()=>{var t;const{events:i,internal:s}=o.getState();(t=s.lastEvent)!=null&&t.current&&i.handlers&&i.handlers.onPointerMove(s.lastEvent.current)},connect:t=>{const{set:i,events:s}=o.getState();if(s.disconnect==null||s.disconnect(),i(u=>({events:{...u.events,connected:t}})),s.handlers)for(const u in s.handlers){const f=s.handlers[u],[h,m]=wx[u];t.addEventListener(h,f,{passive:m})}},disconnect:()=>{const{set:t,events:i}=o.getState();if(i.connected){if(i.handlers)for(const s in i.handlers){const u=i.handlers[s],[f]=wx[s];i.connected.removeEventListener(f,u)}t(s=>({events:{...s.events,connected:void 0}}))}}}}function I1(o,e){let t;return(...i)=>{window.clearTimeout(t),t=window.setTimeout(()=>o(...i),e)}}function TO({debounce:o,scroll:e,polyfill:t,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){const s=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!s)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[u,f]=It.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),h=It.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:u,orientationHandler:null}),m=o?typeof o=="number"?o:o.scroll:null,g=o?typeof o=="number"?o:o.resize:null,_=It.useRef(!1);It.useEffect(()=>(_.current=!0,()=>{_.current=!1}));const[x,b,M]=It.useMemo(()=>{const E=()=>{if(!h.current.element)return;const{left:D,top:U,width:L,height:B,bottom:P,right:H,x:W,y:I}=h.current.element.getBoundingClientRect(),z={left:D,top:U,width:L,height:B,bottom:P,right:H,x:W,y:I};h.current.element instanceof HTMLElement&&i&&(z.height=h.current.element.offsetHeight,z.width=h.current.element.offsetWidth),Object.freeze(z),_.current&&!RO(h.current.lastBounds,z)&&f(h.current.lastBounds=z)};return[E,g?I1(E,g):E,m?I1(E,m):E]},[f,i,m,g]);function A(){h.current.scrollContainers&&(h.current.scrollContainers.forEach(E=>E.removeEventListener("scroll",M,!0)),h.current.scrollContainers=null),h.current.resizeObserver&&(h.current.resizeObserver.disconnect(),h.current.resizeObserver=null),h.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",h.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",h.current.orientationHandler))}function R(){h.current.element&&(h.current.resizeObserver=new s(M),h.current.resizeObserver.observe(h.current.element),e&&h.current.scrollContainers&&h.current.scrollContainers.forEach(E=>E.addEventListener("scroll",M,{capture:!0,passive:!0})),h.current.orientationHandler=()=>{M()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",h.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",h.current.orientationHandler))}const C=E=>{!E||E===h.current.element||(A(),h.current.element=E,h.current.scrollContainers=WT(E),R())};return wO(M,!!e),AO(b),It.useEffect(()=>{A(),R()},[e,M,b]),It.useEffect(()=>A,[]),[C,u,x]}function AO(o){It.useEffect(()=>{const e=o;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[o])}function wO(o,e){It.useEffect(()=>{if(e){const t=o;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",t,!0)}}},[o,e])}function WT(o){const e=[];if(!o||o===document.body)return e;const{overflow:t,overflowX:i,overflowY:s}=window.getComputedStyle(o);return[t,i,s].some(u=>u==="auto"||u==="scroll")&&e.push(o),[...e,...WT(o.parentElement)]}const CO=["x","y","top","bottom","left","right","width","height"],RO=(o,e)=>CO.every(t=>o[t]===e[t]);function DO({ref:o,children:e,fallback:t,resize:i,style:s,gl:u,events:f=EO,eventSource:h,eventPrefix:m,shadows:g,linear:_,flat:x,legacy:b,orthographic:M,frameloop:A,dpr:R,performance:C,raycaster:E,camera:D,scene:U,onPointerMissed:L,onCreated:B,...P}){It.useMemo(()=>fO(yI),[]);const H=PI(),[W,I]=TO({scroll:!0,debounce:{scroll:50,resize:0},...i}),z=It.useRef(null),j=It.useRef(null);It.useImperativeHandle(o,()=>z.current);const ae=LT(L),[$,ue]=It.useState(!1),[he,q]=It.useState(!1);if($)throw $;if(he)throw he;const K=It.useRef(null);Cm(()=>{const Ae=z.current;if(I.width>0&&I.height>0&&Ae){K.current||(K.current=_O(Ae));async function Ce(){await K.current.configure({gl:u,scene:U,events:f,shadows:g,linear:_,flat:x,legacy:b,orthographic:M,frameloop:A,dpr:R,performance:C,raycaster:E,camera:D,size:I,onPointerMissed:(...X)=>ae.current==null?void 0:ae.current(...X),onCreated:X=>{X.events.connect==null||X.events.connect(h?OI(h)?h.current:h:j.current),m&&X.setEvents({compute:(se,Ee)=>{const Oe=se[m+"X"],nt=se[m+"Y"];Ee.pointer.set(Oe/Ee.size.width*2-1,-(nt/Ee.size.height)*2+1),Ee.raycaster.setFromCamera(Ee.pointer,Ee.camera)}}),B?.(X)}}),K.current.render(Bs.jsx(H,{children:Bs.jsx(FI,{set:q,children:Bs.jsx(It.Suspense,{fallback:Bs.jsx(BI,{set:ue}),children:e??null})})}))}Ce()}}),It.useEffect(()=>{const Ae=z.current;if(Ae)return()=>GT(Ae)},[]);const ce=h?"none":"auto";return Bs.jsx("div",{ref:j,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:ce,...s},...P,children:Bs.jsx("div",{ref:W,style:{width:"100%",height:"100%"},children:Bs.jsx("canvas",{ref:z,style:{display:"block"},children:t})})})}function OO(o){return Bs.jsx(RT,{children:Bs.jsx(DO,{...o})})}function Kx(){return Kx=Object.assign?Object.assign.bind():function(o){for(var e=1;e",` float updateTime = time / 50.0; float noise = snoise(vec3(position / 2.0 + updateTime * 5.0)); vec3 transformed = vec3(position * (noise * pow(distort, 2.0) + radius)); `)}get time(){return this._time.value}set time(e){this._time.value=e}get distort(){return this._distort.value}set distort(e){this._distort.value=e}get radius(){return this._radius.value}set radius(e){this._radius.value=e}}const zO=It.forwardRef(({speed:o=1,...e},t)=>{const[i]=It.useState(()=>new UO);return BT(s=>i&&(i.time=s.clock.elapsedTime*o)),It.createElement("primitive",Kx({object:i,ref:t,attach:"material"},e))}),PO=It.forwardRef(({children:o,enabled:e=!0,speed:t=1,rotationIntensity:i=1,floatIntensity:s=1,floatingRange:u=[-.1,.1],autoInvalidate:f=!1,...h},m)=>{const g=It.useRef(null);It.useImperativeHandle(m,()=>g.current,[]);const _=It.useRef(Math.random()*1e4);return BT(x=>{var b,M;if(!e||t===0)return;f&&x.invalidate();const A=_.current+x.clock.elapsedTime;g.current.rotation.x=Math.cos(A/4*t)/8*i,g.current.rotation.y=Math.sin(A/4*t)/8*i,g.current.rotation.z=Math.sin(A/4*t)/20*i;let R=Math.sin(A/4*t)/10;R=SE.mapLinear(R,-.1,.1,(b=u?.[0])!==null&&b!==void 0?b:-.1,(M=u?.[1])!==null&&M!==void 0?M:.1),g.current.position.y=R*s,g.current.updateMatrix()}),It.createElement("group",h,It.createElement("group",{ref:g,matrixAutoUpdate:!1},o))});export{OO as C,PO as F,zO as M,O1 as R,LO as c,Bs as j,It as r,BT as u};