const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B1PtMIUq.js","assets/index-DOIp2aoq.css","assets/index-CMvlyyxu.js","assets/index-Bdi24PkQ.css","assets/index-CwQ-ysLn.js","assets/index-BoeEa7xH.css","assets/index-CRhmqMwz.js","assets/index-B7Erow2S.css","assets/index-BOUPxVBe.js","assets/index-WVFKiT6G.css","assets/index-DOdpM0HQ.js","assets/index-hWn6tbl7.css","assets/index-MgCr_Urj.js","assets/index-D0SeHWP2.css","assets/index-Be41ZfS7.js","assets/index-C2PFO5cD.css","assets/index-DnqmHVBx.js","assets/index-mpZwhQDb.css"])))=>i.map(i=>d[i]); (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const u of s)if(u.type==="childList")for(const f of u.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&n(f)}).observe(document,{childList:!0,subtree:!0});function t(s){const u={};return s.integrity&&(u.integrity=s.integrity),s.referrerPolicy&&(u.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?u.credentials="include":s.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function n(s){if(s.ep)return;s.ep=!0;const u=t(s);fetch(s.href,u)}})();function py(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var I_={exports:{}},Lp={};var jS;function $A(){if(jS)return Lp;jS=1;var r=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(n,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:r,type:n,key:f,ref:s!==void 0?s:null,props:u}}return Lp.Fragment=e,Lp.jsx=t,Lp.jsxs=t,Lp}var YS;function ew(){return YS||(YS=1,I_.exports=$A()),I_.exports}var he=ew(),O_={exports:{}},Up={},P_={exports:{}},z_={};var ZS;function tw(){return ZS||(ZS=1,(function(r){function e(Y,q){var ne=Y.length;Y.push(q);e:for(;0>>1,Ne=Y[be];if(0>>1;bes(Ae,ne))Fes(lt,Ae)?(Y[be]=lt,Y[Fe]=ne,be=Fe):(Y[be]=Ae,Y[oe]=ne,be=oe);else if(Fes(lt,ne))Y[be]=lt,Y[Fe]=ne,be=Fe;else break e}}return q}function s(Y,q){var ne=Y.sortIndex-q.sortIndex;return ne!==0?ne:Y.id-q.id}if(r.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;r.unstable_now=function(){return u.now()}}else{var f=Date,h=f.now();r.unstable_now=function(){return f.now()-h}}var m=[],g=[],_=1,x=null,b=3,M=!1,A=!1,R=!1,w=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function U(Y){for(var q=t(g);q!==null;){if(q.callback===null)n(g);else if(q.startTime<=Y)n(g),q.sortIndex=q.expirationTime,e(m,q);else break;q=t(g)}}function B(Y){if(R=!1,U(Y),!A)if(t(m)!==null)A=!0,z||(z=!0,se());else{var q=t(g);q!==null&&pe(B,q.startTime-Y)}}var z=!1,H=-1,W=5,I=-1;function P(){return w?!0:!(r.unstable_now()-IY&&P());){var be=x.callback;if(typeof be=="function"){x.callback=null,b=x.priorityLevel;var Ne=be(x.expirationTime<=Y);if(Y=r.unstable_now(),typeof Ne=="function"){x.callback=Ne,U(Y),q=!0;break t}x===t(m)&&n(m),U(Y)}else n(m);x=t(m)}if(x!==null)q=!0;else{var X=t(g);X!==null&&pe(B,X.startTime-Y),q=!1}}break e}finally{x=null,b=ne,M=!1}q=void 0}}finally{q?se():z=!1}}}var se;if(typeof D=="function")se=function(){D(Z)};else if(typeof MessageChannel<"u"){var te=new MessageChannel,fe=te.port2;te.port1.onmessage=Z,se=function(){fe.postMessage(null)}}else se=function(){E(Z,0)};function pe(Y,q){H=E(function(){Y(r.unstable_now())},q)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(Y){Y.callback=null},r.unstable_forceFrameRate=function(Y){0>Y||125be?(Y.sortIndex=ne,e(g,Y),t(m)===null&&Y===t(g)&&(R?(N(H),H=-1):R=!0,pe(B,ne-be))):(Y.sortIndex=Ne,e(m,Y),A||M||(A=!0,z||(z=!0,se()))),Y},r.unstable_shouldYield=P,r.unstable_wrapCallback=function(Y){var q=b;return function(){var ne=b;b=q;try{return Y.apply(this,arguments)}finally{b=ne}}}})(z_)),z_}var QS;function nE(){return QS||(QS=1,P_.exports=tw()),P_.exports}var B_={exports:{}},Qt={};var KS;function nw(){if(KS)return Qt;KS=1;var r=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=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,w={};function E(X,oe,Ae){this.props=X,this.context=oe,this.refs=w,this.updater=Ae||A}E.prototype.isReactComponent={},E.prototype.setState=function(X,oe){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,oe,"setState")},E.prototype.forceUpdate=function(X){this.updater.enqueueForceUpdate(this,X,"forceUpdate")};function N(){}N.prototype=E.prototype;function D(X,oe,Ae){this.props=X,this.context=oe,this.refs=w,this.updater=Ae||A}var U=D.prototype=new N;U.constructor=D,R(U,E.prototype),U.isPureReactComponent=!0;var B=Array.isArray;function z(){}var H={H:null,A:null,T:null,S:null},W=Object.prototype.hasOwnProperty;function I(X,oe,Ae){var Fe=Ae.ref;return{$$typeof:r,type:X,key:oe,ref:Fe!==void 0?Fe:null,props:Ae}}function P(X,oe){return I(X.type,oe,X.props)}function Z(X){return typeof X=="object"&&X!==null&&X.$$typeof===r}function se(X){var oe={"=":"=0",":":"=2"};return"$"+X.replace(/[=:]/g,function(Ae){return oe[Ae]})}var te=/\/+/g;function fe(X,oe){return typeof X=="object"&&X!==null&&X.key!=null?se(""+X.key):oe.toString(36)}function pe(X){switch(X.status){case"fulfilled":return X.value;case"rejected":throw X.reason;default:switch(typeof X.status=="string"?X.then(z,z):(X.status="pending",X.then(function(oe){X.status==="pending"&&(X.status="fulfilled",X.value=oe)},function(oe){X.status==="pending"&&(X.status="rejected",X.reason=oe)})),X.status){case"fulfilled":return X.value;case"rejected":throw X.reason}}throw X}function Y(X,oe,Ae,Fe,lt){var de=typeof X;(de==="undefined"||de==="boolean")&&(X=null);var Re=!1;if(X===null)Re=!0;else switch(de){case"bigint":case"string":case"number":Re=!0;break;case"object":switch(X.$$typeof){case r:case e:Re=!0;break;case _:return Re=X._init,Y(Re(X._payload),oe,Ae,Fe,lt)}}if(Re)return lt=lt(X),Re=Fe===""?"."+fe(X,0):Fe,B(lt)?(Ae="",Re!=null&&(Ae=Re.replace(te,"$&/")+"/"),Y(lt,oe,Ae,"",function(ht){return ht})):lt!=null&&(Z(lt)&&(lt=P(lt,Ae+(lt.key==null||X&&X.key===lt.key?"":(""+lt.key).replace(te,"$&/")+"/")+Re)),oe.push(lt)),1;Re=0;var tt=Fe===""?".":Fe+":";if(B(X))for(var st=0;st"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(e){console.error(e)}}return r(),F_.exports=iw(),F_.exports}var tM;function sw(){if(tM)return Up;tM=1;var r=nE(),e=Tm(),t=aw();function n(i){var a="https://react.dev/errors/"+i;if(1Ne||(i.current=be[Ne],be[Ne]=null,Ne--)}function Ae(i,a){Ne++,be[Ne]=i.current,i.current=a}var Fe=X(null),lt=X(null),de=X(null),Re=X(null);function tt(i,a){switch(Ae(de,a),Ae(lt,i),Ae(Fe,null),a.nodeType){case 9:case 11:i=(i=a.documentElement)&&(i=i.namespaceURI)?gS(i):0;break;default:if(i=a.tagName,a=a.namespaceURI)a=gS(a),i=vS(a,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}oe(Fe),Ae(Fe,i)}function st(){oe(Fe),oe(lt),oe(de)}function ht(i){i.memoizedState!==null&&Ae(Re,i);var a=Fe.current,c=vS(a,i.type);a!==c&&(Ae(lt,i),Ae(Fe,c))}function jt(i){lt.current===i&&(oe(Fe),oe(lt)),Re.current===i&&(oe(Re),Cp._currentValue=ne)}var tn,Nt;function Le(i){if(tn===void 0)try{throw Error()}catch(c){var a=c.stack.trim().match(/\n( *(at )?)/);tn=a&&a[1]||"",Nt=-1)":-1y||$[d]!==ve[y]){var De=` `+$[d].replace(" at new "," at ");return i.displayName&&De.includes("")&&(De=De.replace("",i.displayName)),De}while(1<=d&&0<=y);break}}}finally{He=!1,Error.prepareStackTrace=c}return(c=i?i.displayName||i.name:"")?Le(c):""}function nt(i,a){switch(i.tag){case 26:case 27:case 5:return Le(i.type);case 16:return Le("Lazy");case 13:return i.child!==a&&a!==null?Le("Suspense Fallback"):Le("Suspense");case 19:return Le("SuspenseList");case 0:case 15:return Oe(i.type,!1);case 11:return Oe(i.type.render,!1);case 1:return Oe(i.type,!0);case 31:return Le("Activity");default:return""}}function Q(i){try{var a="",c=null;do a+=nt(i,c),c=i,i=i.return;while(i);return a}catch(d){return` Error generating stack: `+d.message+` `+d.stack}}var Et=Object.prototype.hasOwnProperty,ot=r.unstable_scheduleCallback,Tt=r.unstable_cancelCallback,Qe=r.unstable_shouldYield,G=r.unstable_requestPaint,O=r.unstable_now,ae=r.unstable_getCurrentPriorityLevel,Te=r.unstable_ImmediatePriority,Ie=r.unstable_UserBlockingPriority,Ee=r.unstable_NormalPriority,dt=r.unstable_LowPriority,Ke=r.unstable_IdlePriority,vt=r.log,Dt=r.unstable_setDisableYieldValue,Ve=null,Ze=null;function ct(i){if(typeof vt=="function"&&Dt(i),Ze&&typeof Ze.setStrictMode=="function")try{Ze.setStrictMode(Ve,i)}catch{}}var K=Math.clz32?Math.clz32:J,me=Math.log,et=Math.LN2;function J(i){return i>>>=0,i===0?32:31-(me(i)/et|0)|0}var je=256,Ge=262144,at=4194304;function Xe(i){var a=i&42;if(a!==0)return a;switch(i&-i){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 i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Ue(i,a,c){var d=i.pendingLanes;if(d===0)return 0;var y=0,S=i.suspendedLanes,L=i.pingedLanes;i=i.warmLanes;var V=d&134217727;return V!==0?(d=V&~S,d!==0?y=Xe(d):(L&=V,L!==0?y=Xe(L):c||(c=V&~i,c!==0&&(y=Xe(c))))):(V=d&~S,V!==0?y=Xe(V):L!==0?y=Xe(L):c||(c=d&~i,c!==0&&(y=Xe(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 Ye(i,a){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&a)===0}function Ct(i,a){switch(i){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 Jt(){var i=at;return at<<=1,(at&62914560)===0&&(at=4194304),i}function nn(i){for(var a=[],c=0;31>c;c++)a.push(i);return a}function Jn(i,a){i.pendingLanes|=a,a!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Ci(i,a,c,d,y,S){var L=i.pendingLanes;i.pendingLanes=c,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=c,i.entangledLanes&=c,i.errorRecoveryDisabledLanes&=c,i.shellSuspendCounter=0;var V=i.entanglements,$=i.expirationTimes,ve=i.hiddenUpdates;for(c=L&~c;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var _n=/[\n"\\]/g;function Ft(i){return i.replace(_n,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function xi(i,a,c,d,y,S,L,V){i.name="",L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"?i.type=L:i.removeAttribute("type"),a!=null?L==="number"?(a===0&&i.value===""||i.value!=a)&&(i.value=""+Pt(a)):i.value!==""+Pt(a)&&(i.value=""+Pt(a)):L!=="submit"&&L!=="reset"||i.removeAttribute("value"),a!=null?Wn(i,L,Pt(a)):c!=null?Wn(i,L,Pt(c)):d!=null&&i.removeAttribute("value"),y==null&&S!=null&&(i.defaultChecked=!!S),y!=null&&(i.checked=y&&typeof y!="function"&&typeof y!="symbol"),V!=null&&typeof V!="function"&&typeof V!="symbol"&&typeof V!="boolean"?i.name=""+Pt(V):i.removeAttribute("name")}function Ls(i,a,c,d,y,S,L,V){if(S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.type=S),a!=null||c!=null){if(!(S!=="submit"&&S!=="reset"||a!=null)){In(i);return}c=c!=null?""+Pt(c):"",a=a!=null?""+Pt(a):c,V||a===i.value||(i.value=a),i.defaultValue=a}d=d??y,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=V?i.checked:!!d,i.defaultChecked=!!d,L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(i.name=L),In(i)}function Wn(i,a,c){a==="number"&&ut(i.ownerDocument)===i||i.defaultValue===""+c||(i.defaultValue=""+c)}function la(i,a,c,d){if(i=i.options,a){a={};for(var y=0;y"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),fd=!1;if(Ws)try{var Ol={};Object.defineProperty(Ol,"passive",{get:function(){fd=!0}}),window.addEventListener("test",Ol,Ol),window.removeEventListener("test",Ol,Ol)}catch{fd=!1}var Ga=null,pf=null,jo=null;function Wu(){if(jo)return jo;var i,a=pf,c=a.length,d,y="value"in Ga?Ga.value:Ga.textContent,S=y.length;for(i=0;i=kl),Jm=" ",Qu=!1;function Sf(i,a){switch(i){case"keyup":return Km.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yd(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Qo=!1;function $m(i,a){switch(i){case"compositionend":return yd(a);case"keypress":return a.which!==32?null:(Qu=!0,Jm);case"textInput":return i=a.data,i===Jm&&Qu?null:i;default:return null}}function _d(i,a){if(Qo)return i==="compositionend"||!Zo&&Sf(i,a)?(i=Wu(),jo=pf=Ga=null,Qo=!1,i):null;switch(i){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-i};i=d}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=$u(c)}}function Fn(i,a){return i&&a?i===a?!0:i&&i.nodeType===3?!1:a&&a.nodeType===3?Fn(i,a.parentNode):"contains"in i?i.contains(a):i.compareDocumentPosition?!!(i.compareDocumentPosition(a)&16):!1:!1}function ag(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var a=ut(i.document);a instanceof i.HTMLIFrameElement;){try{var c=typeof a.contentWindow.location.href=="string"}catch{c=!1}if(c)i=a.contentWindow;else break;a=ut(i.document)}return a}function wd(i){var a=i&&i.nodeName&&i.nodeName.toLowerCase();return a&&(a==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||a==="textarea"||i.contentEditable==="true")}var sg=Ws&&"documentMode"in document&&11>=document.documentMode,js=null,Ys=null,Xl=null,Ef=!1;function Wl(i,a,c){var d=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Ef||js==null||js!==ut(d)||(d=js,"selectionStart"in d&&wd(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}),Xl&&Hl(Xl,d)||(Xl=d,d=a0(Ys,"onSelect"),0>=L,y-=L,ti=1<<32-K(a)+y|c<ln?(bn=At,At=null):bn=At.sibling;var Nn=xe(le,At,ge[ln],Pe);if(Nn===null){At===null&&(At=bn);break}i&&At&&Nn.alternate===null&&a(le,At),ie=S(Nn,ie,ln),Rn===null?It=Nn:Rn.sibling=Nn,Rn=Nn,At=bn}if(ln===ge.length)return c(le,At),mn&&Qs(le,ln),It;if(At===null){for(;lnln?(bn=At,At=null):bn=At.sibling;var Su=xe(le,At,Nn.value,Pe);if(Su===null){At===null&&(At=bn);break}i&&At&&Su.alternate===null&&a(le,At),ie=S(Su,ie,ln),Rn===null?It=Su:Rn.sibling=Su,Rn=Su,At=bn}if(Nn.done)return c(le,At),mn&&Qs(le,ln),It;if(At===null){for(;!Nn.done;ln++,Nn=ge.next())Nn=Be(le,Nn.value,Pe),Nn!==null&&(ie=S(Nn,ie,ln),Rn===null?It=Nn:Rn.sibling=Nn,Rn=Nn);return mn&&Qs(le,ln),It}for(At=d(At);!Nn.done;ln++,Nn=ge.next())Nn=Ce(At,le,ln,Nn.value,Pe),Nn!==null&&(i&&Nn.alternate!==null&&At.delete(Nn.key===null?ln:Nn.key),ie=S(Nn,ie,ln),Rn===null?It=Nn:Rn.sibling=Nn,Rn=Nn);return i&&At.forEach(function(JA){return a(le,JA)}),mn&&Qs(le,ln),It}function Gn(le,ie,ge,Pe){if(typeof ge=="object"&&ge!==null&&ge.type===R&&ge.key===null&&(ge=ge.props.children),typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case M:e:{for(var It=ge.key;ie!==null;){if(ie.key===It){if(It=ge.type,It===R){if(ie.tag===7){c(le,ie.sibling),Pe=y(ie,ge.props.children),Pe.return=le,le=Pe;break e}}else if(ie.elementType===It||typeof It=="object"&&It!==null&&It.$$typeof===W&&tl(It)===ie.type){c(le,ie.sibling),Pe=y(ie,ge.props),ds(Pe,ge),Pe.return=le,le=Pe;break e}c(le,ie);break}else a(le,ie);ie=ie.sibling}ge.type===R?(Pe=ro(ge.props.children,le.mode,Pe,ge.key),Pe.return=le,le=Pe):(Pe=Zs(ge.type,ge.key,ge.props,null,le.mode,Pe),ds(Pe,ge),Pe.return=le,le=Pe)}return L(le);case A:e:{for(It=ge.key;ie!==null;){if(ie.key===It)if(ie.tag===4&&ie.stateNode.containerInfo===ge.containerInfo&&ie.stateNode.implementation===ge.implementation){c(le,ie.sibling),Pe=y(ie,ge.children||[]),Pe.return=le,le=Pe;break e}else{c(le,ie);break}else a(le,ie);ie=ie.sibling}Pe=Rf(ge,le.mode,Pe),Pe.return=le,le=Pe}return L(le);case W:return ge=tl(ge),Gn(le,ie,ge,Pe)}if(pe(ge))return Mt(le,ie,ge,Pe);if(se(ge)){if(It=se(ge),typeof It!="function")throw Error(n(150));return ge=It.call(ge),kt(le,ie,ge,Pe)}if(typeof ge.then=="function")return Gn(le,ie,uc(ge),Pe);if(ge.$$typeof===D)return Gn(le,ie,$l(le,ge),Pe);eu(le,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"||typeof ge=="bigint"?(ge=""+ge,ie!==null&&ie.tag===6?(c(le,ie.sibling),Pe=y(ie,ge),Pe.return=le,le=Pe):(c(le,ie),Pe=Cf(ge,le.mode,Pe),Pe.return=le,le=Pe),L(le)):c(le,ie)}return function(le,ie,ge,Pe){try{sl=0;var It=Gn(le,ie,ge,Pe);return al=null,It}catch(At){if(At===el||At===an)throw At;var Rn=ei(29,At,null,le.mode);return Rn.lanes=Pe,Rn.return=le,Rn}}}var Dr=Ff(!0),kf=Ff(!1),ha=!1;function cc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function zd(i,a){i=i.updateQueue,a.updateQueue===i&&(a.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Lr(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function po(i,a,c){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var y=d.pending;return y===null?a.next=a:(a.next=y.next,y.next=a),d.pending=a,a=fs(i),ao(i,null,c),a}return Hi(i,d,a,c),fs(i)}function mo(i,a,c){if(a=a.updateQueue,a!==null&&(a=a.shared,(c&4194048)!==0)){var d=a.lanes;d&=i.pendingLanes,c|=d,a.lanes=c,Kr(i,c)}}function Ut(i,a){var c=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,c===d)){var y=null,S=null;if(c=c.firstBaseUpdate,c!==null){do{var L={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};S===null?y=S=L:S=S.next=L,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},i.updateQueue=c;return}i=c.lastBaseUpdate,i===null?c.firstBaseUpdate=a:i.next=a,c.lastBaseUpdate=a}var Bd=!1;function fc(){if(Bd){var i=hs;if(i!==null)throw i}}function tu(i,a,c,d){Bd=!1;var y=i.updateQueue;ha=!1;var S=y.firstBaseUpdate,L=y.lastBaseUpdate,V=y.shared.pending;if(V!==null){y.shared.pending=null;var $=V,ve=$.next;$.next=null,L===null?S=ve:L.next=ve,L=$;var De=i.alternate;De!==null&&(De=De.updateQueue,V=De.lastBaseUpdate,V!==L&&(V===null?De.firstBaseUpdate=ve:V.next=ve,De.lastBaseUpdate=$))}if(S!==null){var Be=y.baseState;L=0,De=ve=$=null,V=S;do{var xe=V.lane&-536870913,Ce=xe!==V.lane;if(Ce?($t&xe)===xe:(d&xe)===xe){xe!==0&&xe===Nr&&(Bd=!0),De!==null&&(De=De.next={lane:0,tag:V.tag,payload:V.payload,callback:null,next:null});e:{var Mt=i,kt=V;xe=a;var Gn=c;switch(kt.tag){case 1:if(Mt=kt.payload,typeof Mt=="function"){Be=Mt.call(Gn,Be,xe);break e}Be=Mt;break e;case 3:Mt.flags=Mt.flags&-65537|128;case 0:if(Mt=kt.payload,xe=typeof Mt=="function"?Mt.call(Gn,Be,xe):Mt,xe==null)break e;Be=x({},Be,xe);break e;case 2:ha=!0}}xe=V.callback,xe!==null&&(i.flags|=64,Ce&&(i.flags|=8192),Ce=y.callbacks,Ce===null?y.callbacks=[xe]:Ce.push(xe))}else Ce={lane:xe,tag:V.tag,payload:V.payload,callback:V.callback,next:null},De===null?(ve=De=Ce,$=Be):De=De.next=Ce,L|=xe;if(V=V.next,V===null){if(V=y.shared.pending,V===null)break;Ce=V,V=Ce.next,Ce.next=null,y.lastBaseUpdate=Ce,y.shared.pending=null}}while(!0);De===null&&($=Be),y.baseState=$,y.firstBaseUpdate=ve,y.lastBaseUpdate=De,S===null&&(y.shared.lanes=0),cr|=L,i.lanes=L,i.memoizedState=Be}}function nu(i,a){if(typeof i!="function")throw Error(n(191,i));i.call(a)}function pg(i,a){var c=i.callbacks;if(c!==null)for(i.callbacks=null,i=0;iS?S:8;var L=Y.T,V={};Y.T=V,op(i,!1,a,c);try{var $=y(),ve=Y.S;if(ve!==null&&ve(V,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var De=Od($,d);mc(i,a,De,Ja(i))}else mc(i,a,d,Ja(i))}catch(Be){mc(i,a,{then:function(){},status:"rejected",reason:Be},Ja())}finally{q.p=S,L!==null&&V.types!==null&&(L.types=V.types),Y.T=L}}function o_(){}function sp(i,a,c,d){if(i.tag!==5)throw Error(n(476));var y=Vg(i).queue;kg(i,y,a,ne,c===null?o_:function(){return Hg(i),c(d)})}function Vg(i){var a=i.memoizedState;if(a!==null)return a;a={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ir,lastRenderedState:ne},next:null};var c={};return a.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ir,lastRenderedState:c},next:null},i.memoizedState=a,i=i.alternate,i!==null&&(i.memoizedState=a),a}function Hg(i){var a=Vg(i);a.next===null&&(a=i.alternate.memoizedState),mc(i,a.next.queue,{},Ja())}function rp(){return Vt(Cp)}function Gg(){return di().memoizedState}function Xg(){return di().memoizedState}function l_(i){for(var a=i.return;a!==null;){switch(a.tag){case 24:case 3:var c=Ja();i=Lr(c);var d=po(a,i,c);d!==null&&(rn(d,a,c),mo(d,a,c)),a={cache:Ld()},i.payload=a;return}a=a.return}}function u_(i,a,c){var d=Ja();c={lane:d,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Zf(i)?qg(a,c):(c=Af(i,a,c,d),c!==null&&(rn(c,i,d),jg(c,a,d)))}function Wg(i,a,c){var d=Ja();mc(i,a,c,d)}function mc(i,a,c,d){var y={lane:d,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(Zf(i))qg(a,y);else{var S=i.alternate;if(i.lanes===0&&(S===null||S.lanes===0)&&(S=a.lastRenderedReducer,S!==null))try{var L=a.lastRenderedState,V=S(L,c);if(y.hasEagerState=!0,y.eagerState=V,ca(V,L))return Hi(i,a,y,0),Gt===null&&ac(),!1}catch{}if(c=Af(i,a,y,d),c!==null)return rn(c,i,d),jg(c,a,d),!0}return!1}function op(i,a,c,d){if(d={lane:2,revertLane:Me(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Zf(i)){if(a)throw Error(n(479))}else a=Af(i,c,d,2),a!==null&&rn(a,i,2)}function Zf(i){var a=i.alternate;return i===Yt||a!==null&&a===Yt}function qg(i,a){au=ps=!0;var c=i.pending;c===null?a.next=a:(a.next=c.next,c.next=a),i.pending=a}function jg(i,a,c){if((c&4194048)!==0){var d=a.lanes;d&=i.pendingLanes,c|=d,a.lanes=c,Kr(i,c)}}var ru={readContext:Vt,use:go,useCallback:ni,useContext:ni,useEffect:ni,useImperativeHandle:ni,useLayoutEffect:ni,useInsertionEffect:ni,useMemo:ni,useReducer:ni,useRef:ni,useState:ni,useDebugValue:ni,useDeferredValue:ni,useTransition:ni,useSyncExternalStore:ni,useId:ni,useHostTransitionStatus:ni,useFormState:ni,useActionState:ni,useOptimistic:ni,useMemoCache:ni,useCacheRefresh:ni};ru.useEffectEvent=ni;var Yg={readContext:Vt,use:go,useCallback:function(i,a){return Di().memoizedState=[i,a===void 0?null:a],i},useContext:Vt,useEffect:Ng,useImperativeHandle:function(i,a,c){c=c!=null?c.concat([i]):null,jf(4194308,4,Og.bind(null,a,i),c)},useLayoutEffect:function(i,a){return jf(4194308,4,i,a)},useInsertionEffect:function(i,a){jf(4,2,i,a)},useMemo:function(i,a){var c=Di();a=a===void 0?null:a;var d=i();if(rl){ct(!0);try{i()}finally{ct(!1)}}return c.memoizedState=[d,a],d},useReducer:function(i,a,c){var d=Di();if(c!==void 0){var y=c(a);if(rl){ct(!0);try{c(a)}finally{ct(!1)}}}else y=a;return d.memoizedState=d.baseState=y,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:y},d.queue=i,i=i.dispatch=u_.bind(null,Yt,i),[d.memoizedState,i]},useRef:function(i){var a=Di();return i={current:i},a.memoizedState=i},useState:function(i){i=Zd(i);var a=i.queue,c=Wg.bind(null,Yt,a);return a.dispatch=c,[i.memoizedState,c]},useDebugValue:ip,useDeferredValue:function(i,a){var c=Di();return ap(c,i,a)},useTransition:function(){var i=Zd(!1);return i=kg.bind(null,Yt,i.queue,!0,!1),Di().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,a,c){var d=Yt,y=Di();if(mn){if(c===void 0)throw Error(n(407));c=c()}else{if(c=a(),Gt===null)throw Error(n(349));($t&127)!==0||_g(d,a,c)}y.memoizedState=c;var S={value:c,getSnapshot:a};return y.queue=S,Ng(bg.bind(null,d,S,i),[i]),d.flags|=2048,vo(9,{destroy:void 0},xg.bind(null,d,S,c,a),null),c},useId:function(){var i=Di(),a=Gt.identifierPrefix;if(mn){var c=Us,d=ti;c=(d&~(1<<32-K(d)-1)).toString(32)+c,a="_"+a+"R_"+c,c=Hf++,0<\/script>",S=S.removeChild(S.firstChild);break;case"select":S=typeof d.is=="string"?L.createElement("select",{is:d.is}):L.createElement("select"),d.multiple?S.multiple=!0:d.size&&(S.size=d.size);break;default:S=typeof d.is=="string"?L.createElement(y,{is:d.is}):L.createElement(y)}}S[$n]=a,S[Ri]=d;e:for(L=a.child;L!==null;){if(L.tag===5||L.tag===6)S.appendChild(L.stateNode);else if(L.tag!==4&&L.tag!==27&&L.child!==null){L.child.return=L,L=L.child;continue}if(L===a)break e;for(;L.sibling===null;){if(L.return===null||L.return===a)break e;L=L.return}L.sibling.return=L.return,L=L.sibling}a.stateNode=S;e:switch(ya(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&&sr(a)}}return Pn(a),_c(a,a.type,i===null?null:i.memoizedProps,a.pendingProps,c),null;case 6:if(i&&a.stateNode!=null)i.memoizedProps!==d&&sr(a);else{if(typeof d!="string"&&a.stateNode===null)throw Error(n(166));if(i=de.current,Kl(a)){if(i=a.stateNode,c=a.memoizedProps,d=null,y=li,y!==null)switch(y.tag){case 27:case 5:d=y.memoizedProps}i[$n]=a,i=!!(i.nodeValue===c||d!==null&&d.suppressHydrationWarning===!0||pS(i.nodeValue,c)),i||Js(a,!0)}else i=s0(i).createTextNode(d),i[$n]=a,a.stateNode=i}return Pn(a),null;case 31:if(c=a.memoizedState,i===null||i.memoizedState!==null){if(d=Kl(a),c!==null){if(i===null){if(!d)throw Error(n(318));if(i=a.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(557));i[$n]=a}else uo(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Pn(a),i=!1}else c=Lf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=c),i=!0;if(!i)return a.flags&256?(hi(a),a):(hi(a),null);if((a.flags&128)!==0)throw Error(n(558))}return Pn(a),null;case 13:if(d=a.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(y=Kl(a),d!==null&&d.dehydrated!==null){if(i===null){if(!y)throw Error(n(318));if(y=a.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(n(317));y[$n]=a}else uo(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Pn(a),y=!1}else y=Lf(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=y),y=!0;if(!y)return a.flags&256?(hi(a),a):(hi(a),null)}return hi(a),(a.flags&128)!==0?(a.lanes=c,a):(c=d!==null,i=i!==null&&i.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!==i&&c&&(a.child.flags|=8192),Or(a,a.updateQueue),Pn(a),null);case 4:return st(),i===null&&p_(a.stateNode.containerInfo),Pn(a),null;case 10:return tr(a.type),Pn(a),null;case 19:if(oe(gn),d=a.memoizedState,d===null)return Pn(a),null;if(y=(a.flags&128)!==0,S=d.rendering,S===null)if(y)rr(d,!1);else{if(ii!==0||i!==null&&(i.flags&128)!==0)for(i=a.child;i!==null;){if(S=ja(i),S!==null){for(a.flags|=128,rr(d,!1),i=S.updateQueue,a.updateQueue=i,Or(a,i),a.subtreeFlags=0,i=c,c=a.child;c!==null;)ql(c,i),c=c.sibling;return Ae(gn,gn.current&1|2),mn&&Qs(a,d.treeForkCount),a.child}i=i.sibling}d.tail!==null&&O()>mi&&(a.flags|=128,y=!0,rr(d,!1),a.lanes=4194304)}else{if(!y)if(i=ja(S),i!==null){if(a.flags|=128,y=!0,i=i.updateQueue,a.updateQueue=i,Or(a,i),rr(d,!0),d.tail===null&&d.tailMode==="hidden"&&!S.alternate&&!mn)return Pn(a),null}else 2*O()-d.renderingStartTime>mi&&c!==536870912&&(a.flags|=128,y=!0,rr(d,!1),a.lanes=4194304);d.isBackwards?(S.sibling=a.child,a.child=S):(i=d.last,i!==null?i.sibling=S:a.child=S,d.last=S)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=O(),i.sibling=null,c=gn.current,Ae(gn,y?c&1|2:c&1),mn&&Qs(a,d.treeForkCount),i):(Pn(a),null);case 22:case 23:return hi(a),hc(),d=a.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(a.flags|=8192):d&&(a.flags|=8192),d?(c&536870912)!==0&&(a.flags&128)===0&&(Pn(a),a.subtreeFlags&6&&(a.flags|=8192)):Pn(a),c=a.updateQueue,c!==null&&Or(a,c.retryQueue),c=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(c=i.memoizedState.cachePool.pool),d=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(d=a.memoizedState.cachePool.pool),d!==c&&(a.flags|=2048),i!==null&&oe(ho),null;case 24:return c=null,i!==null&&(c=i.memoizedState.cache),a.memoizedState.cache!==c&&(a.flags|=2048),tr(Si),Pn(a),null;case 25:return null;case 30:return null}throw Error(n(156,a.tag))}function gs(i,a){switch(Nf(a),a.tag){case 1:return i=a.flags,i&65536?(a.flags=i&-65537|128,a):null;case 3:return tr(Si),st(),i=a.flags,(i&65536)!==0&&(i&128)===0?(a.flags=i&-65537|128,a):null;case 26:case 27:case 5:return jt(a),null;case 31:if(a.memoizedState!==null){if(hi(a),a.alternate===null)throw Error(n(340));uo()}return i=a.flags,i&65536?(a.flags=i&-65537|128,a):null;case 13:if(hi(a),i=a.memoizedState,i!==null&&i.dehydrated!==null){if(a.alternate===null)throw Error(n(340));uo()}return i=a.flags,i&65536?(a.flags=i&-65537|128,a):null;case 19:return oe(gn),null;case 4:return st(),null;case 10:return tr(a.type),null;case 22:case 23:return hi(a),hc(),i!==null&&oe(ho),i=a.flags,i&65536?(a.flags=i&-65537|128,a):null;case 24:return tr(Si),null;case 25:return null;default:return null}}function Ya(i,a){switch(Nf(a),a.tag){case 3:tr(Si),st();break;case 26:case 27:case 5:jt(a);break;case 4:st();break;case 31:a.memoizedState!==null&&hi(a);break;case 13:hi(a);break;case 19:oe(gn);break;case 10:tr(a.type);break;case 22:case 23:hi(a),hc(),i!==null&&oe(ho);break;case 24:tr(Si)}}function vs(i,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&i)===i){d=void 0;var S=c.create,L=c.inst;d=S(),L.destroy=d}c=c.next}while(c!==y)}}catch(V){En(a,a.return,V)}}function Qi(i,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&i)===i){var L=d.inst,V=L.destroy;if(V!==void 0){L.destroy=void 0,y=a;var $=c,ve=V;try{ve()}catch(De){En(y,$,De)}}}d=d.next}while(d!==S)}}catch(De){En(a,a.return,De)}}function Is(i){var a=i.updateQueue;if(a!==null){var c=i.stateNode;try{pg(a,c)}catch(d){En(i,i.return,d)}}}function Xi(i,a,c){c.props=yo(i.type,i.memoizedProps),c.state=i.memoizedState;try{c.componentWillUnmount()}catch(d){En(i,a,d)}}function Pr(i,a){try{var c=i.ref;if(c!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof c=="function"?i.refCleanup=c(d):c.current=d}}catch(y){En(i,a,y)}}function Ki(i,a){var c=i.ref,d=i.refCleanup;if(c!==null)if(typeof d=="function")try{d()}catch(y){En(i,a,y)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(y){En(i,a,y)}else c.current=null}function bc(i){var a=i.type,c=i.memoizedProps,d=i.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){En(i,i.return,y)}}function Ui(i,a,c){try{var d=i.stateNode;SA(d,i.type,c,a),d[Ri]=a}catch(y){En(i,i.return,y)}}function Qn(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&vu(i.type)||i.tag===4}function dn(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Qn(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&vu(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function or(i,a,c){var d=i.tag;if(d===5||d===6)i=i.stateNode,a?(c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c).insertBefore(i,a):(a=c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c,a.appendChild(i),c=c._reactRootContainer,c!=null||a.onclick!==null||(a.onclick=Er));else if(d!==4&&(d===27&&vu(i.type)&&(c=i.stateNode,a=null),i=i.child,i!==null))for(or(i,a,c),i=i.sibling;i!==null;)or(i,a,c),i=i.sibling}function pa(i,a,c){var d=i.tag;if(d===5||d===6)i=i.stateNode,a?c.insertBefore(i,a):c.appendChild(i);else if(d!==4&&(d===27&&vu(i.type)&&(c=i.stateNode),i=i.child,i!==null))for(pa(i,a,c),i=i.sibling;i!==null;)pa(i,a,c),i=i.sibling}function oh(i){var a=i.stateNode,c=i.memoizedProps;try{for(var d=i.type,y=a.attributes;y.length;)a.removeAttributeNode(y[0]);ya(a,d,c),a[$n]=i,a[Ri]=c}catch(S){En(i,i.return,S)}}var ys=!1,Vn=!1,Os=!1,n0=typeof WeakSet=="function"?WeakSet:Set,Wi=null;function f_(i,a){if(i=i.containerInfo,v_=h0,i=ag(i),wd(i)){if("selectionStart"in i)var c={start:i.selectionStart,end:i.selectionEnd};else e:{c=(c=i.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 L=0,V=-1,$=-1,ve=0,De=0,Be=i,xe=null;t:for(;;){for(var Ce;Be!==c||y!==0&&Be.nodeType!==3||(V=L+y),Be!==S||d!==0&&Be.nodeType!==3||($=L+d),Be.nodeType===3&&(L+=Be.nodeValue.length),(Ce=Be.firstChild)!==null;)xe=Be,Be=Ce;for(;;){if(Be===i)break t;if(xe===c&&++ve===y&&(V=L),xe===S&&++De===d&&($=L),(Ce=Be.nextSibling)!==null)break;Be=xe,xe=Be.parentNode}Be=Ce}c=V===-1||$===-1?null:{start:V,end:$}}else c=null}c=c||{start:0,end:0}}else c=null;for(y_={focusedElem:i,selectionRange:c},h0=!1,Wi=a;Wi!==null;)if(a=Wi,i=a.child,(a.subtreeFlags&1028)!==0&&i!==null)i.return=a,Wi=i;else for(;Wi!==null;){switch(a=Wi,S=a.alternate,i=a.flags,a.tag){case 0:if((i&4)!==0&&(i=a.updateQueue,i=i!==null?i.events:null,i!==null))for(c=0;c title"))),ya(S,d,c),S[$n]=i,k(S),d=S;break e;case"link":var L=DS("link","href",y).get(d+(c.href||""));if(L){for(var V=0;VGn&&(L=Gn,Gn=kt,kt=L);var le=Gl(V,kt),ie=Gl(V,Gn);if(le&&ie&&(Ce.rangeCount!==1||Ce.anchorNode!==le.node||Ce.anchorOffset!==le.offset||Ce.focusNode!==ie.node||Ce.focusOffset!==ie.offset)){var ge=Be.createRange();ge.setStart(le.node,le.offset),Ce.removeAllRanges(),kt>Gn?(Ce.addRange(ge),Ce.extend(ie.node,ie.offset)):(ge.setEnd(ie.node,ie.offset),Ce.addRange(ge))}}}}for(Be=[],Ce=V;Ce=Ce.parentNode;)Ce.nodeType===1&&Be.push({element:Ce,left:Ce.scrollLeft,top:Ce.scrollTop});for(typeof V.focus=="function"&&V.focus(),V=0;Vc?32:c,Y.T=null,c=hu,hu=null;var S=Ka,L=Ms;if(Ln=0,cu=Ka=null,Ms=0,(wt&6)!==0)throw Error(n(331));var V=wt;if(wt|=4,wa(S.current),xp(S,S.current,L,c),wt=V,gt(0,!1),Ze&&typeof Ze.onPostCommitFiberRoot=="function")try{Ze.onPostCommitFiberRoot(Ve,S)}catch{}return!0}finally{q.p=y,Y.T=d,hr(i,a)}}function Mp(i,a,c){a=Xa(c,a),a=dp(i.stateNode,a,2),i=po(i,a,2),i!==null&&(Jn(i,2),We(i))}function En(i,a,c){if(i.tag===3)Mp(i,i,c);else for(;a!==null;){if(a.tag===3){Mp(a,i,c);break}else if(a.tag===1){var d=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(gi===null||!gi.has(d))){i=Xa(c,i),c=pp(2),d=po(a,c,2),d!==null&&(Kg(c,d,a,i),Jn(d,2),We(d));break}}a=a.return}}function Cc(i,a,c){var d=i.pingCache;if(d===null){d=i.pingCache=new Zt;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)||(bp=!0,y.add(c),i=o.bind(null,i,a,c),a.then(i,i))}function o(i,a,c){var d=i.pingCache;d!==null&&d.delete(a),i.pingedLanes|=i.suspendedLanes&c,i.warmLanes&=~c,Gt===i&&($t&c)===c&&(ii===4||ii===3&&($t&62914560)===$t&&300>O()-uu?(wt&2)===0&&Ao(i,0):Mc|=c,qn===$t&&(qn=0)),We(i)}function l(i,a){a===0&&(a=Jt()),i=fa(i,a),i!==null&&(Jn(i,a),We(i))}function p(i){var a=i.memoizedState,c=0;a!==null&&(c=a.retryLane),l(i,c)}function v(i,a){var c=0;switch(i.tag){case 31:case 13:var d=i.stateNode,y=i.memoizedState;y!==null&&(c=y.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(n(314))}d!==null&&d.delete(a),l(i,c)}function T(i,a){return ot(i,a)}var C=null,F=null,ee=!1,we=!1,ke=!1,it=0;function We(i){i!==F&&i.next===null&&(F===null?C=F=i:F=F.next=i),we=!0,ee||(ee=!0,ce())}function gt(i,a){if(!ke&&we){ke=!0;do for(var c=!1,d=C;d!==null;){if(i!==0){var y=d.pendingLanes;if(y===0)var S=0;else{var L=d.suspendedLanes,V=d.pingedLanes;S=(1<<31-K(42|i)+1)-1,S&=y&~(L&~V),S=S&201326741?S&201326741|1:S?S|2:0}S!==0&&(c=!0,_e(d,S))}else S=$t,S=Ue(d,d===Gt?S:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(S&3)===0||Ye(d,S)||(c=!0,_e(d,S));d=d.next}while(c);ke=!1}}function qt(){vi()}function vi(){we=ee=!1;var i=0;it!==0&&EA()&&(i=it);for(var a=O(),c=null,d=C;d!==null;){var y=d.next,S=gu(d,a);S===0?(d.next=null,c===null?C=y:c.next=y,y===null&&(F=c)):(c=d,(i!==0||(S&3)!==0)&&(we=!0)),d=y}Ln!==0&&Ln!==5||gt(i),it!==0&&(it=0)}function gu(i,a){for(var c=i.suspendedLanes,d=i.pingedLanes,y=i.expirationTimes,S=i.pendingLanes&-62914561;0V)break;var De=$.transferSize,Be=$.initiatorType;De&&mS(Be)&&($=$.responseEnd,L+=De*($"u"?null:document;function wS(i,a,c){var d=dh;if(d&&typeof a=="string"&&a){var y=Ft(a);y='link[rel="'+i+'"][href="'+y+'"]',typeof c=="string"&&(y+='[crossorigin="'+c+'"]'),AS.has(y)||(AS.add(y),i={rel:i,crossOrigin:c,href:a},d.querySelector(y)===null&&(a=d.createElement("link"),ya(a,"link",i),k(a),d.head.appendChild(a)))}}function UA(i){xl.D(i),wS("dns-prefetch",i,null)}function IA(i,a){xl.C(i,a),wS("preconnect",i,a)}function OA(i,a,c){xl.L(i,a,c);var d=dh;if(d&&i&&a){var y='link[rel="preload"][as="'+Ft(a)+'"]';a==="image"&&c&&c.imageSrcSet?(y+='[imagesrcset="'+Ft(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(y+='[imagesizes="'+Ft(c.imageSizes)+'"]')):y+='[href="'+Ft(i)+'"]';var S=y;switch(a){case"style":S=ph(i);break;case"script":S=mh(i)}pr.has(S)||(i=x({rel:"preload",href:a==="image"&&c&&c.imageSrcSet?void 0:i,as:a},c),pr.set(S,i),d.querySelector(y)!==null||a==="style"&&d.querySelector(Ap(S))||a==="script"&&d.querySelector(wp(S))||(a=d.createElement("link"),ya(a,"link",i),k(a),d.head.appendChild(a)))}}function PA(i,a){xl.m(i,a);var c=dh;if(c&&i){var d=a&&typeof a.as=="string"?a.as:"script",y='link[rel="modulepreload"][as="'+Ft(d)+'"][href="'+Ft(i)+'"]',S=y;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":S=mh(i)}if(!pr.has(S)&&(i=x({rel:"modulepreload",href:i},a),pr.set(S,i),c.querySelector(y)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(wp(S)))return}d=c.createElement("link"),ya(d,"link",i),k(d),c.head.appendChild(d)}}}function zA(i,a,c){xl.S(i,a,c);var d=dh;if(d&&i){var y=Xs(d).hoistableStyles,S=ph(i);a=a||"default";var L=y.get(S);if(!L){var V={loading:0,preload:null};if(L=d.querySelector(Ap(S)))V.loading=5;else{i=x({rel:"stylesheet",href:i,"data-precedence":a},c),(c=pr.get(S))&&T_(i,c);var $=L=d.createElement("link");k($),ya($,"link",i),$._p=new Promise(function(ve,De){$.onload=ve,$.onerror=De}),$.addEventListener("load",function(){V.loading|=1}),$.addEventListener("error",function(){V.loading|=2}),V.loading|=4,o0(L,a,d)}L={type:"stylesheet",instance:L,count:1,state:V},y.set(S,L)}}}function BA(i,a){xl.X(i,a);var c=dh;if(c&&i){var d=Xs(c).hoistableScripts,y=mh(i),S=d.get(y);S||(S=c.querySelector(wp(y)),S||(i=x({src:i,async:!0},a),(a=pr.get(y))&&A_(i,a),S=c.createElement("script"),k(S),ya(S,"link",i),c.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},d.set(y,S))}}function FA(i,a){xl.M(i,a);var c=dh;if(c&&i){var d=Xs(c).hoistableScripts,y=mh(i),S=d.get(y);S||(S=c.querySelector(wp(y)),S||(i=x({src:i,async:!0,type:"module"},a),(a=pr.get(y))&&A_(i,a),S=c.createElement("script"),k(S),ya(S,"link",i),c.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},d.set(y,S))}}function CS(i,a,c,d){var y=(y=de.current)?r0(y):null;if(!y)throw Error(n(446));switch(i){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(a=ph(c.href),c=Xs(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"){i=ph(c.href);var S=Xs(y).hoistableStyles,L=S.get(i);if(L||(y=y.ownerDocument||y,L={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},S.set(i,L),(S=y.querySelector(Ap(i)))&&!S._p&&(L.instance=S,L.state.loading=5),pr.has(i)||(c={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},pr.set(i,c),S||kA(y,i,c,L.state))),a&&d===null)throw Error(n(528,""));return L}if(a&&d!==null)throw Error(n(529,""));return null;case"script":return a=c.async,c=c.src,typeof c=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=mh(c),c=Xs(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(n(444,i))}}function ph(i){return'href="'+Ft(i)+'"'}function Ap(i){return'link[rel="stylesheet"]['+i+"]"}function RS(i){return x({},i,{"data-precedence":i.precedence,precedence:null})}function kA(i,a,c,d){i.querySelector('link[rel="preload"][as="style"]['+a+"]")?d.loading=1:(a=i.createElement("link"),d.preload=a,a.addEventListener("load",function(){return d.loading|=1}),a.addEventListener("error",function(){return d.loading|=2}),ya(a,"link",c),k(a),i.head.appendChild(a))}function mh(i){return'[src="'+Ft(i)+'"]'}function wp(i){return"script[async]"+i}function NS(i,a,c){if(a.count++,a.instance===null)switch(a.type){case"style":var d=i.querySelector('style[data-href~="'+Ft(c.href)+'"]');if(d)return a.instance=d,k(d),d;var y=x({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),k(d),ya(d,"style",y),o0(d,c.precedence,i),a.instance=d;case"stylesheet":y=ph(c.href);var S=i.querySelector(Ap(y));if(S)return a.state.loading|=4,a.instance=S,k(S),S;d=RS(c),(y=pr.get(y))&&T_(d,y),S=(i.ownerDocument||i).createElement("link"),k(S);var L=S;return L._p=new Promise(function(V,$){L.onload=V,L.onerror=$}),ya(S,"link",d),a.state.loading|=4,o0(S,c.precedence,i),a.instance=S;case"script":return S=mh(c.src),(y=i.querySelector(wp(S)))?(a.instance=y,k(y),y):(d=c,(y=pr.get(S))&&(d=x({},c),A_(d,y)),i=i.ownerDocument||i,y=i.createElement("script"),k(y),ya(y,"link",d),i.head.appendChild(y),a.instance=y);case"void":return null;default:throw Error(n(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(d=a.instance,a.state.loading|=4,o0(d,c.precedence,i));return a.instance}function o0(i,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,L=0;L title"):null)}function VA(i,a,c){if(c===1||a.itemProp!=null)return!1;switch(i){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"?(i=a.disabled,typeof a.precedence=="string"&&i==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 US(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function HA(i,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=ph(d.href),S=a.querySelector(Ap(y));if(S){a=S._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(i.count++,i=u0.bind(i),a.then(i,i)),c.state.loading|=4,c.instance=S,k(S);return}S=a.ownerDocument||a,d=RS(d),(y=pr.get(y))&&T_(d,y),S=S.createElement("link"),k(S);var L=S;L._p=new Promise(function(V,$){L.onload=V,L.onerror=$}),ya(S,"link",d),c.instance=S}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(c,a),(a=c.state.preload)&&(c.state.loading&3)===0&&(i.count++,c=u0.bind(i),a.addEventListener("load",c),a.addEventListener("error",c))}}var w_=0;function GA(i,a){return i.stylesheets&&i.count===0&&f0(i,i.stylesheets),0w_?50:800)+a);return i.unsuspend=c,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(y)}}:null}function u0(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)f0(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var c0=null;function f0(i,a){i.stylesheets=null,i.unsuspend!==null&&(i.count++,c0=new Map,a.forEach(XA,i),c0=null,u0.call(i))}function XA(i,a){if(!(a.state.loading&4)){var c=c0.get(i);if(c)var d=c.get(null);else{c=new Map,c0.set(i,c);for(var y=i.querySelectorAll("link[data-precedence],style[data-precedence]"),S=0;S"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(e){console.error(e)}}return r(),O_.exports=sw(),O_.exports}var ow=rw();const lw=py(ow),uw="modulepreload",cw=function(r){return"/"+r},iM={},Hr=function(e,t,n){let s=Promise.resolve();if(t&&t.length>0){let m=function(g){return Promise.all(g.map(_=>Promise.resolve(_).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),h=f?.nonce||f?.getAttribute("nonce");s=m(t.map(g=>{if(g=cw(g),g in iM)return;iM[g]=!0;const _=g.endsWith(".css"),x=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${g}"]${x}`))return;const b=document.createElement("link");if(b.rel=_?"stylesheet":uw,_||(b.as="script"),b.crossOrigin="",b.href=g,h&&b.setAttribute("nonce",h),document.head.appendChild(b),_)return new Promise((M,A)=>{b.addEventListener("load",M),b.addEventListener("error",()=>A(new Error(`Unable to preload CSS for ${g}`)))})}))}function u(f){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=f,window.dispatchEvent(h),!h.defaultPrevented)throw f}return s.then(f=>{for(const h of f||[])h.status==="rejected"&&u(h.reason);return e().catch(u)})},fw="assumption-toggle",hw="Assumption Toggle",dw="1.0.0",pw="glitch_assumption_toggle",mw="@nommo/assumption-toggle",gw="dist/assumption-toggle.js",vw="src/index.tsx",yw=["glitch-component","crt","logic"],_w={componentId:fw,displayName:hw,version:dw,folderName:pw,packageName:mw,entry:gw,source:vw,tags:yw},xw="ccd",bw="CCD Photon Explorer",Sw="0.1.0",Mw="glitch_ccd",Ew="@glitch-components/ccd",Tw="dist/index.html",Aw="src/index.tsx",ww=["internal","visualization","tooling"],Cw={componentId:xw,displayName:bw,version:Sw,folderName:Mw,packageName:Ew,entry:Tw,source:Aw,tags:ww},Rw="chess_analogy",Nw="Chess Move Set Lab",Dw="1.0.0",Lw="glitch_chess_analogy",Uw="@glitch-components/chess-analogy",Iw="dist/chess_analogy.js",Ow="src/index.tsx",Pw=["glitch-component","reference","2d","chess"],zw={componentId:Rw,displayName:Nw,version:Dw,folderName:Lw,packageName:Uw,entry:Iw,source:Ow,tags:Pw},Bw="gallery",Fw="Glitch Gallery",kw="0.1.0",Vw="glitch_gallery",Hw="@glitch-components/gallery",Gw="dist/index.html",Xw="src/index.tsx",Ww=["internal","tooling","preview"],qw={componentId:Bw,displayName:Fw,version:kw,folderName:Vw,packageName:Hw,entry:Gw,source:Xw,tags:Ww},jw="level-questions",Yw="Level Questions",Zw="1.0.0",Qw="glitch_level_questions",Kw="level-questions",Jw="dist/level-questions.js",$w="src/index.tsx",eC=["glitch-component","quiz","role-mapping"],tC={componentId:jw,displayName:Yw,version:Zw,folderName:Qw,packageName:Kw,entry:Jw,source:$w,tags:eC},nC="lightlane",iC="Lightlane Challenge",aC="0.1.0",sC="glitch_lightlane",rC="@nommo/lightlane",oC="dist/lightlane.js",lC="src/index.tsx",uC=["glitch-component","reference","3d"],cC={componentId:nC,displayName:iC,version:aC,folderName:sC,packageName:rC,entry:oC,source:lC,tags:uC},fC="migration-paradox",hC="The Migration Paradox",dC="1.0.0",pC="glitch_migration_paradox",mC="migration-paradox",gC="dist/migration-paradox.js",vC="src/index.tsx",yC=["glitch-component","paradox","narrative"],_C={componentId:fC,displayName:hC,version:dC,folderName:pC,packageName:mC,entry:gC,source:vC,tags:yC},xC="onboarding",bC="Glitch University Onboarding",SC="1.0.0",MC="glitch_onboarding",EC="@glitch-components/onboarding",TC="dist/onboarding.js",AC="src/index.tsx",wC=["glitch-component","onboarding","narrative"],CC={componentId:xC,displayName:bC,version:SC,folderName:MC,packageName:EC,entry:TC,source:AC,tags:wC},RC="onboarding2",NC="Facility Slideshow",DC="1.0.0",LC="glitch_onboarding2",UC="@glitch-components/onboarding2",IC="dist/onboarding2.js",OC="src/index.tsx",PC=["glitch-component","onboarding","slideshow"],zC={componentId:RC,displayName:NC,version:DC,folderName:LC,packageName:UC,entry:IC,source:OC,tags:PC},BC="sphere-paradox",FC="Create a Perfect Sphere",kC="1.0.0",VC="glitch_sphere_paradox",HC="sphere-paradox",GC="dist/sphere-paradox.js",XC="src/index.tsx",WC=["glitch-component","3d","paradox"],qC={componentId:BC,displayName:FC,version:kC,folderName:VC,packageName:HC,entry:GC,source:XC,tags:WC},jC="voxel-universe",YC="Voxel Universe",ZC="1.0.0",QC="glitch_voxel_universe",KC="@glitch-components/voxel-universe",JC="dist/voxel_universe.js",$C="src/index.tsx",e3=["glitch-component","voxel","geometry"],t3={componentId:jC,displayName:YC,version:ZC,folderName:QC,packageName:KC,entry:JC,source:$C,tags:e3};function kx(){return kx=Object.assign?Object.assign.bind():function(r){for(var e=1;e=0;--e)if(r[e]>=65535)return!0;return!1}const G3={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Hh(r,e){return new G3[r](e)}function FE(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function mm(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function kE(){const r=mm("canvas");return r.style.display="block",r}const aM={};let Bu=null;function X3(r){Bu=r}function W3(){return Bu}function gm(...r){const e="THREE."+r.shift();Bu?Bu("log",e,...r):console.log(e,...r)}function ft(...r){const e="THREE."+r.shift();Bu?Bu("warn",e,...r):console.warn(e,...r)}function Rt(...r){const e="THREE."+r.shift();Bu?Bu("error",e,...r):console.error(e,...r)}function Zh(...r){const e=r.join(" ");e in aM||(aM[e]=!0,ft(...r))}function q3(r,e,t){return new Promise(function(n,s){function u(){switch(r.clientWaitSync(e,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:s();break;case r.TIMEOUT_EXPIRED:setTimeout(u,t);break;default:n()}}setTimeout(u,t)})}let ko=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[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 n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let u=0,f=s.length;u>8&255]+Da[r>>16&255]+Da[r>>24&255]+"-"+Da[e&255]+Da[e>>8&255]+"-"+Da[e>>16&15|64]+Da[e>>24&255]+"-"+Da[t&63|128]+Da[t>>8&255]+"-"+Da[t>>16&255]+Da[t>>24&255]+Da[n&255]+Da[n>>8&255]+Da[n>>16&255]+Da[n>>24&255]).toLowerCase()}function Ht(r,e,t){return Math.max(e,Math.min(t,r))}function wb(r,e){return(r%e+e)%e}function j3(r,e,t,n,s){return n+(r-e)*(s-n)/(t-e)}function Y3(r,e,t){return r!==e?(t-r)/(e-r):0}function im(r,e,t){return(1-t)*r+t*e}function Z3(r,e,t,n){return im(r,e,1-Math.exp(-t*n))}function Q3(r,e=1){return e-Math.abs(wb(r,e*2)-e)}function K3(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function J3(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function $3(r,e){return r+Math.floor(Math.random()*(e-r+1))}function eR(r,e){return r+Math.random()*(e-r)}function tR(r){return r*(.5-Math.random())}function nR(r){r!==void 0&&(sM=r);let e=sM+=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 iR(r){return r*Jc}function aR(r){return r*Qh}function sR(r){return(r&r-1)===0&&r!==0}function rR(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function oR(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function lR(r,e,t,n,s){const u=Math.cos,f=Math.sin,h=u(t/2),m=f(t/2),g=u((e+n)/2),_=f((e+n)/2),x=u((e-n)/2),b=f((e-n)/2),M=u((n-e)/2),A=f((n-e)/2);switch(s){case"XYX":r.set(h*_,m*x,m*b,h*g);break;case"YZY":r.set(m*b,h*_,m*x,h*g);break;case"ZXZ":r.set(m*x,m*b,h*_,h*g);break;case"XZX":r.set(h*_,m*A,m*M,h*g);break;case"YXY":r.set(m*M,h*_,m*A,h*g);break;case"ZYZ":r.set(m*A,m*M,h*_,h*g);break;default:ft("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ns(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function on(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const uR={DEG2RAD:Jc,RAD2DEG:Qh,generateUUID:Vs,clamp:Ht,euclideanModulo:wb,mapLinear:j3,inverseLerp:Y3,lerp:im,damp:Z3,pingpong:Q3,smoothstep:K3,smootherstep:J3,randInt:$3,randFloat:eR,randFloatSpread:tR,seededRandom:nR,degToRad:iR,radToDeg:aR,isPowerOfTwo:sR,ceilPowerOfTwo:rR,floorPowerOfTwo:oR,setQuaternionFromProperEuler:lR,normalize:on,denormalize:ns};class ze{constructor(e=0,t=0){ze.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+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=Ht(this.x,e.x,t.x),this.y=Ht(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ht(this.x,e,t),this.y=Ht(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ht(n,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 n=this.dot(e)/t;return Math.acos(Ht(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),u=this.x-e.x,f=this.y-e.y;return this.x=u*n-f*s+e.x,this.y=u*s+f*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Pa{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,u,f,h){let m=n[s+0],g=n[s+1],_=n[s+2],x=n[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 w=m*b+g*M+_*A+x*R;w<0&&(b=-b,M=-M,A=-A,R=-R,w=-w);let E=1-h;if(w<.9995){const N=Math.acos(w),D=Math.sin(N);E=Math.sin(E*N)/D,h=Math.sin(h*N)/D,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 N=1/Math.sqrt(m*m+g*g+_*_+x*x);m*=N,g*=N,_*=N,x*=N}}e[t]=m,e[t+1]=g,e[t+2]=_,e[t+3]=x}static multiplyQuaternionsFlat(e,t,n,s,u,f){const h=n[s],m=n[s+1],g=n[s+2],_=n[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,n,s){return this._x=e,this._y=t,this._z=n,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 n=e._x,s=e._y,u=e._z,f=e._order,h=Math.cos,m=Math.sin,g=h(n/2),_=h(s/2),x=h(u/2),b=m(n/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:ft("Quaternion: .setFromEuler() encountered an unknown order: "+f)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=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=n+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(n>h&&n>x){const M=2*Math.sqrt(1+n-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-n-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-n-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 n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ht(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);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 n=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=n*_+f*h+s*g-u*m,this._y=s*_+f*m+u*h-n*g,this._z=u*_+f*g+n*m-s*h,this._w=f*_-n*h-s*m-u*g,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,s=e._y,u=e._z,f=e._w,h=this.dot(e);h<0&&(n=-n,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+n*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+n*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,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),u=Math.sqrt(n);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 j{constructor(e=0,t=0,n=0){j.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(rM.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(rM.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,u=e.elements;return this.x=u[0]*t+u[3]*n+u[6]*s,this.y=u[1]*t+u[4]*n+u[7]*s,this.z=u[2]*t+u[5]*n+u[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,u=e.elements,f=1/(u[3]*t+u[7]*n+u[11]*s+u[15]);return this.x=(u[0]*t+u[4]*n+u[8]*s+u[12])*f,this.y=(u[1]*t+u[5]*n+u[9]*s+u[13])*f,this.z=(u[2]*t+u[6]*n+u[10]*s+u[14])*f,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,u=e.x,f=e.y,h=e.z,m=e.w,g=2*(f*s-h*n),_=2*(h*t-u*s),x=2*(u*n-f*t);return this.x=t+m*g+f*x-h*_,this.y=n+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,n=this.y,s=this.z,u=e.elements;return this.x=u[0]*t+u[4]*n+u[8]*s,this.y=u[1]*t+u[5]*n+u[9]*s,this.z=u[2]*t+u[6]*n+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=Ht(this.x,e.x,t.x),this.y=Ht(this.y,e.y,t.y),this.z=Ht(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ht(this.x,e,t),this.y=Ht(this.y,e,t),this.z=Ht(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ht(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,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-n*m,this.z=n*h-s*f,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return k_.copy(this).projectOnVector(e),this.sub(k_)}reflect(e){return this.sub(k_.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ht(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+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,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const k_=new j,rM=new Pa;class en{constructor(e,t,n,s,u,f,h,m,g){en.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,u,f,h,m,g)}set(e,t,n,s,u,f,h,m,g){const _=this.elements;return _[0]=e,_[1]=s,_[2]=h,_[3]=t,_[4]=u,_[5]=m,_[6]=n,_[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,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,u=this.elements,f=n[0],h=n[3],m=n[6],g=n[1],_=n[4],x=n[7],b=n[2],M=n[5],A=n[8],R=s[0],w=s[3],E=s[6],N=s[1],D=s[4],U=s[7],B=s[2],z=s[5],H=s[8];return u[0]=f*R+h*N+m*B,u[3]=f*w+h*D+m*z,u[6]=f*E+h*U+m*H,u[1]=g*R+_*N+x*B,u[4]=g*w+_*D+x*z,u[7]=g*E+_*U+x*H,u[2]=b*R+M*N+A*B,u[5]=b*w+M*D+A*z,u[8]=b*E+M*U+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],n=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-n*u*_+n*h*m+s*u*g-s*f*m}invert(){const e=this.elements,t=e[0],n=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+n*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-_*n)*R,e[2]=(h*n-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]=(n*m-g*t)*R,e[8]=(f*t-n*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,n,s,u,f,h){const m=Math.cos(u),g=Math.sin(u);return this.set(n*m,n*g,-n*(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(V_.makeScale(e,t)),this}rotate(e){return this.premultiply(V_.makeRotation(-e)),this}translate(e,t){return this.premultiply(V_.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const V_=new en,oM=new en().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),lM=new en().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function cR(){const r={enabled:!0,workingColorSpace:zu,spaces:{},convert:function(s,u,f){return this.enabled===!1||u===f||!u||!f||(this.spaces[u].transfer===zn&&(s.r=Nl(s.r),s.g=Nl(s.g),s.b=Nl(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===zn&&(s.r=Wh(s.r),s.g=Wh(s.g),s.b=Wh(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===Cl?dm: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 Zh("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(s,u)},toWorkingColorSpace:function(s,u){return Zh("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(s,u)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return r.define({[zu]:{primaries:e,whitePoint:n,transfer:dm,toXYZ:oM,fromXYZ:lM,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ia},outputColorSpaceConfig:{drawingBufferColorSpace:Ia}},[Ia]:{primaries:e,whitePoint:n,transfer:zn,toXYZ:oM,fromXYZ:lM,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ia}}}),r}const Sn=cR();function Nl(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Wh(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let vh;class VE{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{vh===void 0&&(vh=mm("canvas")),vh.width=e.width,vh.height=e.height;const s=vh.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=vh}return n.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=mm("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),u=s.data;for(let f=0;f1),this.pmremVersion=0}get width(){return this.source.getSize(G_).x}get height(){return this.source.getSize(G_).y}get depth(){return this.source.getSize(G_).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 n=e[t];if(n===void 0){ft(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){ft(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==vy)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case um:e.x=e.x-Math.floor(e.x);break;case Rs:e.x=e.x<0?0:1;break;case cm: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 um:e.y=e.y-Math.floor(e.y);break;case Rs:e.y=e.y<0?0:1;break;case cm: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++}}wi.DEFAULT_IMAGE=null;wi.DEFAULT_MAPPING=vy;wi.DEFAULT_ANISOTROPY=1;class jn{constructor(e=0,t=0,n=0,s=1){jn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,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,n,s){return this.x=e,this.y=t,this.z=n,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,n=this.y,s=this.z,u=this.w,f=e.elements;return this.x=f[0]*t+f[4]*n+f[8]*s+f[12]*u,this.y=f[1]*t+f[5]*n+f[9]*s+f[13]*u,this.z=f[2]*t+f[6]*n+f[10]*s+f[14]*u,this.w=f[3]*t+f[7]*n+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,n,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],w=m[6],E=m[10];if(Math.abs(_-b)<.01&&Math.abs(x-R)<.01&&Math.abs(A-w)<.01){if(Math.abs(_+b)<.1&&Math.abs(x+R)<.1&&Math.abs(A+w)<.1&&Math.abs(g+M+E-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const D=(g+1)/2,U=(M+1)/2,B=(E+1)/2,z=(_+b)/4,H=(x+R)/4,W=(A+w)/4;return D>U&&D>B?D<.01?(n=0,s=.707106781,u=.707106781):(n=Math.sqrt(D),s=z/n,u=H/n):U>B?U<.01?(n=.707106781,s=0,u=.707106781):(s=Math.sqrt(U),n=z/s,u=W/s):B<.01?(n=.707106781,s=.707106781,u=0):(u=Math.sqrt(B),n=H/u,s=W/u),this.set(n,s,u,t),this}let N=Math.sqrt((w-A)*(w-A)+(x-R)*(x-R)+(b-_)*(b-_));return Math.abs(N)<.001&&(N=1),this.x=(w-A)/N,this.y=(x-R)/N,this.z=(b-_)/N,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=Ht(this.x,e.x,t.x),this.y=Ht(this.y,e.y,t.y),this.z=Ht(this.z,e.z,t.z),this.w=Ht(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ht(this.x,e,t),this.y=Ht(this.y,e,t),this.z=Ht(this.z,e,t),this.w=Ht(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ht(n,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,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Cb extends ko{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:oi,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new jn(0,0,e,t),this.scissorTest=!1,this.viewport=new jn(0,0,e,t);const s={width:e,height:t,depth:n.depth},u=new wi(s);this.textures=[];const f=n.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,n=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,Gr),Gr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ip),x0.subVectors(this.max,Ip),yh.subVectors(e.a,Ip),_h.subVectors(e.b,Ip),xh.subVectors(e.c,Ip),Mu.subVectors(_h,yh),Eu.subVectors(xh,_h),Rc.subVectors(yh,xh);let t=[0,-Mu.z,Mu.y,0,-Eu.z,Eu.y,0,-Rc.z,Rc.y,Mu.z,0,-Mu.x,Eu.z,0,-Eu.x,Rc.z,0,-Rc.x,-Mu.y,Mu.x,0,-Eu.y,Eu.x,0,-Rc.y,Rc.x,0];return!X_(t,yh,_h,xh,x0)||(t=[1,0,0,0,1,0,0,0,1],!X_(t,yh,_h,xh,x0))?!1:(b0.crossVectors(Mu,Eu),t=[b0.x,b0.y,b0.z],X_(t,yh,_h,xh,x0))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Gr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Gr).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:(bl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),bl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),bl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),bl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),bl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),bl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),bl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),bl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(bl),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 bl=[new j,new j,new j,new j,new j,new j,new j,new j],Gr=new j,_0=new za,yh=new j,_h=new j,xh=new j,Mu=new j,Eu=new j,Rc=new j,Ip=new j,x0=new j,b0=new j,Nc=new j;function X_(r,e,t,n,s){for(let u=0,f=r.length-3;u<=f;u+=3){Nc.fromArray(r,u);const h=s.x*Math.abs(Nc.x)+s.y*Math.abs(Nc.y)+s.z*Math.abs(Nc.z),m=e.dot(Nc),g=t.dot(Nc),_=n.dot(Nc);if(Math.max(-Math.max(m,g,_),Math.min(m,g,_))>h)return!1}return!0}const mR=new za,Op=new j,W_=new j;class _a{constructor(e=new j,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 n=this.center;t!==void 0?n.copy(t):mR.setFromPoints(e).getCenter(n);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;Op.subVectors(e,this.center);const t=Op.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Op,s/n),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):(W_.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Op.copy(e.center).add(W_)),this.expandByPoint(Op.copy(e.center).sub(W_))),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 Sl=new j,q_=new j,S0=new j,Tu=new j,j_=new j,M0=new j,Y_=new j;class of{constructor(e=new j,t=new j(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,Sl)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Sl.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Sl.copy(this.origin).addScaledVector(this.direction,t),Sl.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){q_.copy(e).add(t).multiplyScalar(.5),S0.copy(t).sub(e).normalize(),Tu.copy(this.origin).sub(q_);const u=e.distanceTo(t)*.5,f=-this.direction.dot(S0),h=Tu.dot(this.direction),m=-Tu.dot(S0),g=Tu.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 n&&n.copy(this.origin).addScaledVector(this.direction,x),s&&s.copy(q_).addScaledVector(S0,b),M}intersectSphere(e,t){Sl.subVectors(e.center,this.origin);const n=Sl.dot(this.direction),s=Sl.dot(Sl)-n*n,u=e.radius*e.radius;if(s>u)return null;const f=Math.sqrt(u-s),h=n-f,m=n+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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,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?(n=(e.min.x-b.x)*g,s=(e.max.x-b.x)*g):(n=(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)*_),n>f||u>s||((u>n||isNaN(n))&&(n=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),n>m||h>s)||((h>n||n!==n)&&(n=h),(m=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Sl)!==null}intersectTriangle(e,t,n,s,u){j_.subVectors(t,e),M0.subVectors(n,e),Y_.crossVectors(j_,M0);let f=this.direction.dot(Y_),h;if(f>0){if(s)return null;h=1}else if(f<0)h=-1,f=-f;else return null;Tu.subVectors(this.origin,e);const m=h*this.direction.dot(M0.crossVectors(Tu,M0));if(m<0)return null;const g=h*this.direction.dot(j_.cross(Tu));if(g<0||m+g>f)return null;const _=-h*Tu.dot(Y_);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 Xt{constructor(e,t,n,s,u,f,h,m,g,_,x,b,M,A,R,w){Xt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,u,f,h,m,g,_,x,b,M,A,R,w)}set(e,t,n,s,u,f,h,m,g,_,x,b,M,A,R,w){const E=this.elements;return E[0]=e,E[4]=t,E[8]=n,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]=w,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 Xt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,n=e.elements,s=1/bh.setFromMatrixColumn(e,0).length(),u=1/bh.setFromMatrixColumn(e,1).length(),f=1/bh.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*u,t[5]=n[5]*u,t[6]=n[6]*u,t[7]=0,t[8]=n[8]*f,t[9]=n[9]*f,t[10]=n[10]*f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,s=e.y,u=e.z,f=Math.cos(n),h=Math.sin(n),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(gR,e,vR)}lookAt(e,t,n){const s=this.elements;return Bs.subVectors(e,t),Bs.lengthSq()===0&&(Bs.z=1),Bs.normalize(),Au.crossVectors(n,Bs),Au.lengthSq()===0&&(Math.abs(n.z)===1?Bs.x+=1e-4:Bs.z+=1e-4,Bs.normalize(),Au.crossVectors(n,Bs)),Au.normalize(),E0.crossVectors(Bs,Au),s[0]=Au.x,s[4]=E0.x,s[8]=Bs.x,s[1]=Au.y,s[5]=E0.y,s[9]=Bs.y,s[2]=Au.z,s[6]=E0.z,s[10]=Bs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,u=this.elements,f=n[0],h=n[4],m=n[8],g=n[12],_=n[1],x=n[5],b=n[9],M=n[13],A=n[2],R=n[6],w=n[10],E=n[14],N=n[3],D=n[7],U=n[11],B=n[15],z=s[0],H=s[4],W=s[8],I=s[12],P=s[1],Z=s[5],se=s[9],te=s[13],fe=s[2],pe=s[6],Y=s[10],q=s[14],ne=s[3],be=s[7],Ne=s[11],X=s[15];return u[0]=f*z+h*P+m*fe+g*ne,u[4]=f*H+h*Z+m*pe+g*be,u[8]=f*W+h*se+m*Y+g*Ne,u[12]=f*I+h*te+m*q+g*X,u[1]=_*z+x*P+b*fe+M*ne,u[5]=_*H+x*Z+b*pe+M*be,u[9]=_*W+x*se+b*Y+M*Ne,u[13]=_*I+x*te+b*q+M*X,u[2]=A*z+R*P+w*fe+E*ne,u[6]=A*H+R*Z+w*pe+E*be,u[10]=A*W+R*se+w*Y+E*Ne,u[14]=A*I+R*te+w*q+E*X,u[3]=N*z+D*P+U*fe+B*ne,u[7]=N*H+D*Z+U*pe+B*be,u[11]=N*W+D*se+U*Y+B*Ne,u[15]=N*I+D*te+U*q+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],n=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],w=e[11],E=e[15],N=m*M-g*b,D=h*M-g*x,U=h*b-m*x,B=f*M-g*_,z=f*b-m*_,H=f*x-h*_;return t*(R*N-w*D+E*U)-n*(A*N-w*B+E*z)+s*(A*D-R*B+E*H)-u*(A*U-R*z+w*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,n){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]=n),this}invert(){const e=this.elements,t=e[0],n=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],w=e[14],E=e[15],N=x*w*g-R*b*g+R*m*M-h*w*M-x*m*E+h*b*E,D=A*b*g-_*w*g-A*m*M+f*w*M+_*m*E-f*b*E,U=_*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*w-f*x*w,z=t*N+n*D+s*U+u*B;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const H=1/z;return e[0]=N*H,e[1]=(R*b*u-x*w*u-R*s*M+n*w*M+x*s*E-n*b*E)*H,e[2]=(h*w*u-R*m*u+R*s*g-n*w*g-h*s*E+n*m*E)*H,e[3]=(x*m*u-h*b*u-x*s*g+n*b*g+h*s*M-n*m*M)*H,e[4]=D*H,e[5]=(_*w*u-A*b*u+A*s*M-t*w*M-_*s*E+t*b*E)*H,e[6]=(A*m*u-f*w*u-A*s*g+t*w*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]=U*H,e[9]=(A*x*u-_*R*u-A*n*M+t*R*M+_*n*E-t*x*E)*H,e[10]=(f*R*u-A*h*u+A*n*g-t*R*g-f*n*E+t*h*E)*H,e[11]=(_*h*u-f*x*u-_*n*g+t*x*g+f*n*M-t*h*M)*H,e[12]=B*H,e[13]=(_*R*s-A*x*s+A*n*b-t*R*b-_*n*w+t*x*w)*H,e[14]=(A*h*s-f*R*s-A*n*m+t*R*m+f*n*w-t*h*w)*H,e[15]=(f*x*s-_*h*s+_*n*m-t*x*m-f*n*b+t*h*b)*H,this}scale(e){const t=this.elements,n=e.x,s=e.y,u=e.z;return t[0]*=n,t[4]*=s,t[8]*=u,t[1]*=n,t[5]*=s,t[9]*=u,t[2]*=n,t[6]*=s,t[10]*=u,t[3]*=n,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],n=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,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),s=Math.sin(t),u=1-n,f=e.x,h=e.y,m=e.z,g=u*f,_=u*h;return this.set(g*f+n,g*h-s*m,g*m+s*h,0,g*h+s*m,_*h+n,_*m-s*f,0,g*m-s*h,_*m+s*f,u*m*m+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,u,f){return this.set(1,n,u,0,e,1,f,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){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*_,w=f*x,E=h*x,N=m*g,D=m*_,U=m*x,B=n.x,z=n.y,H=n.z;return s[0]=(1-(R+E))*B,s[1]=(M+U)*B,s[2]=(A-D)*B,s[3]=0,s[4]=(M-U)*z,s[5]=(1-(b+E))*z,s[6]=(w+N)*z,s[7]=0,s[8]=(A+D)*H,s[9]=(w-N)*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,n){const s=this.elements;if(e.x=s[12],e.y=s[13],e.z=s[14],this.determinant()===0)return n.set(1,1,1),t.identity(),this;let u=bh.set(s[0],s[1],s[2]).length();const f=bh.set(s[4],s[5],s[6]).length(),h=bh.set(s[8],s[9],s[10]).length();this.determinant()<0&&(u=-u),Xr.copy(this);const g=1/u,_=1/f,x=1/h;return Xr.elements[0]*=g,Xr.elements[1]*=g,Xr.elements[2]*=g,Xr.elements[4]*=_,Xr.elements[5]*=_,Xr.elements[6]*=_,Xr.elements[8]*=x,Xr.elements[9]*=x,Xr.elements[10]*=x,t.setFromRotationMatrix(Xr),n.x=u,n.y=f,n.z=h,this}makePerspective(e,t,n,s,u,f,h=ks,m=!1){const g=this.elements,_=2*u/(t-e),x=2*u/(n-s),b=(t+e)/(t-e),M=(n+s)/(n-s);let A,R;if(m)A=u/(f-u),R=f*u/(f-u);else if(h===ks)A=-(f+u)/(f-u),R=-2*f*u/(f-u);else if(h===Yh)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,n,s,u,f,h=ks,m=!1){const g=this.elements,_=2/(t-e),x=2/(n-s),b=-(t+e)/(t-e),M=-(n+s)/(n-s);let A,R;if(m)A=1/(f-u),R=f/(f-u);else if(h===ks)A=-2/(f-u),R=-(f+u)/(f-u);else if(h===Yh)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,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const bh=new j,Xr=new Xt,gR=new j(0,0,0),vR=new j(1,1,1),Au=new j,E0=new j,Bs=new j,uM=new Xt,cM=new Pa;class Gs{constructor(e=0,t=0,n=0,s=Gs.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,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,n,s=this._order){return this._x=e,this._y=t,this._z=n,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,n=!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(Ht(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(-Ht(_,-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(Ht(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(-Ht(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(Ht(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(-Ht(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:ft("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return uM.makeRotationFromQuaternion(e),this.setFromRotationMatrix(uM,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return cM.setFromEuler(this),this.setFromQuaternion(cM,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}}Gs.DEFAULT_ORDER="XYZ";class Kh{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(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&&(n.geometries=h),m.length>0&&(n.materials=m),g.length>0&&(n.textures=g),_.length>0&&(n.images=_),x.length>0&&(n.shapes=x),b.length>0&&(n.skeletons=b),M.length>0&&(n.animations=M),A.length>0&&(n.nodes=A)}return n.object=s,n;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 n=0;n0?s.multiplyScalar(1/Math.sqrt(u)):s.set(0,0,0)}static getBarycoord(e,t,n,s,u){Wr.subVectors(s,t),El.subVectors(n,t),Q_.subVectors(e,t);const f=Wr.dot(Wr),h=Wr.dot(El),m=Wr.dot(Q_),g=El.dot(El),_=El.dot(Q_),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,n,s){return this.getBarycoord(e,t,n,s,Tl)===null?!1:Tl.x>=0&&Tl.y>=0&&Tl.x+Tl.y<=1}static getInterpolation(e,t,n,s,u,f,h,m){return this.getBarycoord(e,t,n,s,Tl)===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,Tl.x),m.addScaledVector(f,Tl.y),m.addScaledVector(h,Tl.z),m)}static getInterpolatedAttribute(e,t,n,s,u,f){return ex.setScalar(0),tx.setScalar(0),nx.setScalar(0),ex.fromBufferAttribute(e,t),tx.fromBufferAttribute(e,n),nx.fromBufferAttribute(e,s),f.setScalar(0),f.addScaledVector(ex,u.x),f.addScaledVector(tx,u.y),f.addScaledVector(nx,u.z),f}static isFrontFacing(e,t,n,s){return Wr.subVectors(n,t),El.subVectors(e,t),Wr.cross(El).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),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 Wr.subVectors(this.c,this.b),El.subVectors(this.a,this.b),Wr.cross(El).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Cs.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Cs.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,u){return Cs.getInterpolation(e,this.a,this.b,this.c,t,n,s,u)}containsPoint(e){return Cs.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Cs.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,u=this.c;let f,h;Eh.subVectors(s,n),Th.subVectors(u,n),K_.subVectors(e,n);const m=Eh.dot(K_),g=Th.dot(K_);if(m<=0&&g<=0)return t.copy(n);J_.subVectors(e,s);const _=Eh.dot(J_),x=Th.dot(J_);if(_>=0&&x<=_)return t.copy(s);const b=m*x-_*g;if(b<=0&&m>=0&&_<=0)return f=m/(m-_),t.copy(n).addScaledVector(Eh,f);$_.subVectors(e,u);const M=Eh.dot($_),A=Th.dot($_);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(n).addScaledVector(Th,h);const w=_*A-M*x;if(w<=0&&x-_>=0&&M-A>=0)return gM.subVectors(u,s),h=(x-_)/(x-_+(M-A)),t.copy(s).addScaledVector(gM,h);const E=1/(w+R+b);return f=R*E,h=b*E,t.copy(n).addScaledVector(Eh,f).addScaledVector(Th,h)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const HE={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},wu={h:0,s:0,l:0},A0={h:0,s:0,l:0};function ix(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}class yt{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const 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,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ia){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Sn.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Sn.workingColorSpace){return this.r=e,this.g=t,this.b=n,Sn.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Sn.workingColorSpace){if(e=wb(e,1),t=Ht(t,0,1),n=Ht(n,0,1),t===0)this.r=this.g=this.b=n;else{const u=n<=.5?n*(1+t):n+t-n*t,f=2*n-u;this.r=ix(f,u,e+1/3),this.g=ix(f,u,e),this.b=ix(f,u,e-1/3)}return Sn.colorSpaceToWorking(this,s),this}setStyle(e,t=Ia){function n(u){u!==void 0&&parseFloat(u)<1&&ft("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 n(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 n(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 n(u[4]),this.setHSL(parseFloat(u[1])/360,parseFloat(u[2])/100,parseFloat(u[3])/100,t);break;default:ft("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);ft("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ia){const n=HE[e.toLowerCase()];return n!==void 0?this.setHex(n,t):ft("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=Nl(e.r),this.g=Nl(e.g),this.b=Nl(e.b),this}copyLinearToSRGB(e){return this.r=Wh(e.r),this.g=Wh(e.g),this.b=Wh(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ia){return Sn.workingToColorSpace(La.copy(this),e),Math.round(Ht(La.r*255,0,255))*65536+Math.round(Ht(La.g*255,0,255))*256+Math.round(Ht(La.b*255,0,255))}getHexString(e=Ia){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Sn.workingColorSpace){Sn.workingToColorSpace(La.copy(this),t);const n=La.r,s=La.g,u=La.b,f=Math.max(n,s,u),h=Math.min(n,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 n: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 n=e[t];if(n===void 0){ft(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){ft(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Kc&&(n.blending=this.blending),this.side!==Ll&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==vv&&(n.blendSrc=this.blendSrc),this.blendDst!==yv&&(n.blendDst=this.blendDst),this.blendEquation!==Du&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==ef&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==qx&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Wc&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Wc&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Wc&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function 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&&(n.textures=u),f.length>0&&(n.images=f)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let u=0;u!==s;++u)n[u]=t[u].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.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 Vu extends Ba{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new yt(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 Gs,this.combine=Am,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 Rl=MR();function MR(){const r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),s=new Uint32Array(512);for(let m=0;m<256;++m){const g=m-127;g<-27?(n[m]=0,n[m|256]=32768,s[m]=24,s[m|256]=24):g<-14?(n[m]=1024>>-g-14,n[m|256]=1024>>-g-14|32768,s[m]=-g-1,s[m|256]=-g-1):g<=15?(n[m]=g+15<<10,n[m|256]=g+15<<10|32768,s[m]=13,s[m|256]=13):g<128?(n[m]=31744,n[m|256]=64512,s[m]=24,s[m|256]=24):(n[m]=31744,n[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:n,shiftTable:s,mantissaTable:u,exponentTable:f,offsetTable:h}}function As(r){Math.abs(r)>65504&&ft("DataUtils.toHalfFloat(): Value out of range."),r=Ht(r,-65504,65504),Rl.floatView[0]=r;const e=Rl.uint32View[0],t=e>>23&511;return Rl.baseTable[t]+((e&8388607)>>Rl.shiftTable[t])}function Yp(r){const e=r>>10;return Rl.uint32View[0]=Rl.mantissaTable[Rl.offsetTable[e]+(r&1023)]+Rl.exponentTable[e],Rl.floatView[0]}class ER{static toHalfFloat(e){return As(e)}static fromHalfFloat(e){return Yp(e)}}const ji=new j,w0=new ze;let TR=0;class Xn{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:TR++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=pm,this.updateRanges=[],this.gpuType=is,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,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,u=this.itemSize;st.count&&ft("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 za);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Rt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new j(-1/0,-1/0,-1/0),new j(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n0&&(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 n=this.attributes;for(const m in n){const g=n[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 n=e.index;n!==null&&this.setIndex(n.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[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let u=0,f=s.length;u(e.far-e.near)**2))&&(vM.copy(u).invert(),Dc.copy(e.ray).applyMatrix4(vM),!(n.boundingBox!==null&&Dc.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Dc)))}_computeIntersections(e,t,n){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:U0.clone(),object:r}}function I0(r,e,t,n,s,u,f,h,m,g){r.getVertexPosition(h,R0),r.getVertexPosition(m,N0),r.getVertexPosition(g,D0);const _=UR(r,e,t,n,R0,N0,D0,_M);if(_){const x=new j;Cs.getBarycoord(_M,R0,N0,D0,x),s&&(_.uv=Cs.getInterpolatedAttribute(s,h,m,g,x,new ze)),u&&(_.uv1=Cs.getInterpolatedAttribute(u,h,m,g,x,new ze)),f&&(_.normal=Cs.getInterpolatedAttribute(f,h,m,g,x,new j),_.normal.dot(n.direction)>0&&_.normal.multiplyScalar(-1));const b={a:h,b:m,c:g,normal:new j,materialIndex:0};Cs.getNormal(R0,N0,D0,b.normal),_.face=b,_.barycoord=x}return _}class lf extends Kt{constructor(e=1,t=1,n=1,s=1,u=1,f=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,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,n,t,e,f,u,0),A("z","y","x",1,-1,n,t,-e,f,u,1),A("x","z","y",1,1,e,n,t,s,f,2),A("x","z","y",1,-1,e,n,-t,s,f,3),A("x","y","z",1,-1,e,t,n,s,u,4),A("x","y","z",-1,-1,e,t,-n,s,u,5),this.setIndex(m),this.setAttribute("position",new bt(g,3)),this.setAttribute("normal",new bt(_,3)),this.setAttribute("uv",new bt(x,2));function A(R,w,E,N,D,U,B,z,H,W,I){const P=U/H,Z=B/W,se=U/2,te=B/2,fe=z/2,pe=H+1,Y=W+1;let q=0,ne=0;const be=new j;for(let Ne=0;Ne0?1:-1,_.push(be.x,be.y,be.z),x.push(oe/H),x.push(1-Ne/W),q+=1}}for(let Ne=0;Ne0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Ry extends Cn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xt,this.projectionMatrix=new Xt,this.projectionMatrixInverse=new Xt,this.coordinateSystem=ks,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 Cu=new j,xM=new ze,bM=new ze;class zi extends Ry{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,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=Qh*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Jc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Qh*2*Math.atan(Math.tan(Jc*.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,n){Cu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Cu.x,Cu.y).multiplyScalar(-e/Cu.z),Cu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Cu.x,Cu.y).multiplyScalar(-e/Cu.z)}getViewSize(e,t){return this.getViewBounds(e,xM,bM),t.subVectors(bM,xM)}setViewOffset(e,t,n,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=n,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(Jc*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,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*n/g,s*=f.width/m,n*=f.height/g}const h=this.filmOffset;h!==0&&(u+=e*h/this.getFilmWidth()),this.projectionMatrix.makePerspective(u,u+s,t,t-n,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 wh=-90,Ch=1;class WE extends Cn{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new zi(wh,Ch,e,t);s.layers=this.layers,this.add(s);const u=new zi(wh,Ch,e,t);u.layers=this.layers,this.add(u);const f=new zi(wh,Ch,e,t);f.layers=this.layers,this.add(f);const h=new zi(wh,Ch,e,t);h.layers=this.layers,this.add(h);const m=new zi(wh,Ch,e,t);m.layers=this.layers,this.add(m);const g=new zi(wh,Ch,e,t);g.layers=this.layers,this.add(g)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,u,f,h,m]=t;for(const g of t)this.remove(g);if(e===ks)n.up.set(0,1,0),n.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===Yh)n.up.set(0,-1,0),n.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:n,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=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,s),e.render(t,u),e.setRenderTarget(n,1,s),e.render(t,f),e.setRenderTarget(n,2,s),e.render(t,h),e.setRenderTarget(n,3,s),e.render(t,m),e.setRenderTarget(n,4,s),e.render(t,g),n.texture.generateMipmaps=R,e.setRenderTarget(n,5,s),e.render(t,_),e.setRenderTarget(x,b,M),e.xr.enabled=A,n.texture.needsPMREMUpdate=!0}}class Cm extends wi{constructor(e=[],t=zo,n,s,u,f,h,m,g,_){super(e,t,n,s,u,f,h,m,g,_),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Db extends Hs{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new Cm(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 n={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 lf(5,5,5),u=new yr({name:"CubemapFromEquirect",uniforms:Jh(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:as,blending:Po});u.uniforms.tEquirect.value=t;const f=new Yi(s,u),h=t.minFilter;return t.minFilter===Io&&(t.minFilter=oi),new WE(1,10,this).update(e,f),t.minFilter=h,f.geometry.dispose(),f.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const u=e.getRenderTarget();for(let f=0;f<6;f++)e.setRenderTarget(this,f),e.clear(t,n,s);e.setRenderTarget(u)}}class Gh extends Cn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const zR={type:"move"};class pv{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gh,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 Gh,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new j,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new j),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gh,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new j,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new j),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let 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 w=t.getJointPose(R,n),E=this._getHandJoint(g,R);w!==null&&(E.matrix.fromArray(w.transform.matrix),E.matrix.decompose(E.position,E.rotation,E.scale),E.matrixWorldNeedsUpdate=!0,E.jointRadius=w.radius),E.visible=w!==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,n),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,n),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(zR)))}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 n=new Gh;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Ny{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new yt(e),this.density=t}clone(){return new Ny(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Dy{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new yt(e),this.near=t,this.far=n}clone(){return new Dy(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Lb extends Cn{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 Gs,this.environmentIntensity=1,this.environmentRotation=new Gs,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 Ly{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=pm,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,n){e*=this.stride,n*=t.stride;for(let s=0,u=this.stride;se.far||t.push({distance:m,point:Bp.clone(),uv:Cs.getInterpolation(Bp,O0,kp,P0,SM,rx,MM,new ze),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 z0(r,e,t,n,s,u){Lh.subVectors(r,t).addScalar(.5).multiply(n),s!==void 0?(Fp.x=u*Lh.x-s*Lh.y,Fp.y=s*Lh.x+u*Lh.y):Fp.copy(Lh),r.copy(e),r.x+=Fp.x,r.y+=Fp.y,r.applyMatrix4(qE)}const B0=new j,EM=new j;class YE extends Cn{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 n=0,s=t.length;n0){let n,s;for(n=1,s=t.length;n0){B0.setFromMatrixPosition(this.matrixWorld);const s=e.ray.origin.distanceTo(B0);this.getObjectForDistance(s).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){B0.setFromMatrixPosition(e.matrixWorld),EM.setFromMatrixPosition(this.matrixWorld);const n=B0.distanceTo(EM)/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(n,u)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||HR.getNormalMatrix(e),s=this.coplanarPoint(ux).applyMatrix4(e),u=this.normal.applyMatrix3(n).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 Lc=new _a,GR=new ze(.5,.5),V0=new j;class ad{constructor(e=new wl,t=new wl,n=new wl,s=new wl,u=new wl,f=new wl){this.planes=[e,t,n,s,u,f]}set(e,t,n,s,u,f){const h=this.planes;return h[0].copy(e),h[1].copy(t),h[2].copy(n),h[3].copy(s),h[4].copy(u),h[5].copy(f),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ks,n=!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],w=u[10],E=u[11],N=u[12],D=u[13],U=u[14],B=u[15];if(s[0].setComponents(g-f,M-_,E-A,B-N).normalize(),s[1].setComponents(g+f,M+_,E+A,B+N).normalize(),s[2].setComponents(g+h,M+x,E+R,B+D).normalize(),s[3].setComponents(g-h,M-x,E-R,B-D).normalize(),n)s[4].setComponents(m,b,w,U).normalize(),s[5].setComponents(g-m,M-b,E-w,B-U).normalize();else if(s[4].setComponents(g-m,M-b,E-w,B-U).normalize(),t===ks)s[5].setComponents(g+m,M+b,E+w,B+U).normalize();else if(t===Yh)s[5].setComponents(m,b,w,U).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(),Lc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Lc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Lc)}intersectsSprite(e){Lc.center.set(0,0,0);const t=GR.distanceTo(e.center);return Lc.radius=.7071067811865476+t,Lc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Lc)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let u=0;u<6;u++)if(t[u].distanceToPoint(n)0?e.max.x:e.min.x,V0.y=s.normal.y>0?e.max.y:e.min.y,V0.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(V0)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const No=new Xt,Do=new ad;class Iy{constructor(){this.coordinateSystem=ks}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n=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=n,h.index=s}reset(){this.list.length=0,this.index=0}}const Ts=new Xt,jR=new yt(1,1,1),UM=new ad,YR=new Iy,H0=new za,Uc=new _a,Gp=new j,IM=new j,ZR=new j,fx=new qR,Ua=new Yi,G0=[];function QR(r,e,t=0){const n=e.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==e.array.constructor){const s=r.count;for(let u=0;u65535?new Uint32Array(s):new Uint16Array(s);t.setIndex(new Xn(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 n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const s=e.getAttribute(n),u=t.getAttribute(n);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 za);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,s=t.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let s=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(cx),s=this._availableInstanceIds.shift(),this._instanceInfo[s]=n):(s=this._instanceInfo.length,this._instanceInfo.push(n));const u=this._matricesTexture;Ts.identity().toArray(u.image.data,s*16),u.needsUpdate=!0;const f=this._colorsTexture;return f&&(jR.toArray(f.image.data,s*4),f.needsUpdate=!0),this._visibilityChanged=!0,s}addGeometry(e,t=-1,n=-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=n===-1?f.count:n),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(cx),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 n=this.geometry,s=n.getIndex()!==null,u=n.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 n.attributes){const x=t.getAttribute(_),b=n.getAttribute(_);QR(x,b,m);const M=x.itemSize;for(let A=x.count,R=g;A=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let s=0,u=n.length;sh).sort((f,h)=>n[f].vertexStart-n[h].vertexStart),u=this.geometry;for(let f=0,h=n.length;f=this._geometryCount)return null;const n=this.geometry,s=this._geometryInfo[e];if(s.boundingBox===null){const u=new za,f=n.index,h=n.attributes.position;for(let m=s.start,g=s.start+s.count;m=this._geometryCount)return null;const n=this.geometry,s=this._geometryInfo[e];if(s.boundingSphere===null){const u=new _a;this.getBoundingBoxAt(e,H0),H0.getCenter(u.center);const f=n.index,h=n.attributes.position;let m=0;for(let g=s.start,_=s.start+s.count;g<_;g++){let x=g;f&&(x=f.getX(x)),Gp.fromBufferAttribute(h,x),m=Math.max(m,u.center.distanceToSquared(Gp))}u.radius=Math.sqrt(m),s.boundingSphere=u}return t.copy(s.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,s=this._matricesTexture.image.data;return t.toArray(s,e*16),n.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 n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(cx);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(eh.active);if(Math.max(...n.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(...n.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 Kt,this._initializeGeometry(u));const f=this.geometry;u.index&&Ic(u.index.array,f.index.array);for(const h in u.attributes)Ic(u.attributes[h].array,f.attributes[h].array)}raycast(e,t){const n=this._instanceInfo,s=this._geometryInfo,u=this.matrixWorld,f=this.geometry;Ua.material=this.material,Ua.geometry.index=f.index,Ua.geometry.attributes=f.attributes,Ua.geometry.boundingBox===null&&(Ua.geometry.boundingBox=new za),Ua.geometry.boundingSphere===null&&(Ua.geometry.boundingSphere=new _a);for(let h=0,m=n.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,n,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=n.isArrayCamera?YR:UM;b&&!n.isArrayCamera&&(Ts.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),UM.setFromProjectionMatrix(Ts,n.coordinateSystem,n.reversedDepth));let w=0;if(this.sortObjects){Ts.copy(this.matrixWorld).invert(),Gp.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Ts),IM.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Ts);for(let D=0,U=m.length;D0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let u=0,f=s.length;un)return;hx.applyMatrix4(r.matrixWorld);const g=e.ray.origin.distanceTo(hx);if(!(ge.far))return{distance:g,point:PM.clone().applyMatrix4(r.matrixWorld),index:f,face:null,faceIndex:null,barycoord:null,object:r}}const zM=new j,BM=new j;class Vo extends Fu{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,n=[];for(let s=0,u=t.count;s0){const s=t[n[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 eT extends wi{constructor(e,t,n,s,u=oi,f=oi,h,m,g){super(e,t,n,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 KR extends eT{constructor(e,t,n,s,u,f,h,m){super({},e,t,n,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 JR extends wi{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Bi,this.minFilter=Bi,this.generateMipmaps=!1,this.needsUpdate=!0}}class Oy extends wi{constructor(e,t,n,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:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class $R extends Oy{constructor(e,t,n,s,u,f){super(e,t,n,u,f),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=Rs,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class eN extends Oy{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,zo),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class tN extends wi{constructor(e,t,n,s,u,f,h,m,g){super(e,t,n,s,u,f,h,m,g),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ed extends wi{constructor(e,t,n=vr,s,u,f,h=Bi,m=Bi,g,_=Fo,x=1){if(_!==Fo&&_!==Uu)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,_,n,g),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Iu(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 tT extends ed{constructor(e,t=vr,n=zo,s,u,f=Bi,h=Bi,m,g=Fo){const _={width:e,height:e,depth:1},x=[_,_,_,_,_,_];super(e,e,t,n,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 Pb extends wi{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Py extends Kt{constructor(e=1,t=1,n=4,s=8,u=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:s,heightSegments:u},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),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=n*2+u,R=s+1,w=new j,E=new j;for(let N=0;N<=A;N++){let D=0,U=0,B=0,z=0;if(N<=n){const I=N/n,P=I*Math.PI/2;U=-_-e*Math.cos(P),B=e*Math.sin(P),z=-e*Math.cos(P),D=I*x}else if(N<=n+u){const I=(N-n)/u;U=-_+I*t,B=e,z=0,D=x+I*b}else{const I=(N-n-u)/n,P=I*Math.PI/2;U=_+e*Math.sin(P),B=e*Math.cos(P),z=e*Math.sin(P),D=x+b+I*x}const H=Math.max(0,Math.min(1,D/M));let W=0;N===0?W=.5/s:N===A&&(W=-.5/s);for(let I=0;I<=s;I++){const P=I/s,Z=P*Math.PI*2,se=Math.sin(Z),te=Math.cos(Z);E.x=-B*te,E.y=U,E.z=B*se,h.push(E.x,E.y,E.z),w.set(-B*te,z,B*se),w.normalize(),m.push(w.x,w.y,w.z),g.push(P+W,H)}if(N>0){const I=(N-1)*R;for(let P=0;P0&&D(!0),t>0&&D(!1)),this.setIndex(_),this.setAttribute("position",new bt(x,3)),this.setAttribute("normal",new bt(b,3)),this.setAttribute("uv",new bt(M,2));function N(){const U=new j,B=new j;let z=0;const H=(t-e)/n;for(let W=0;W<=u;W++){const I=[],P=W/u,Z=P*(t-e)+e;for(let se=0;se<=s;se++){const te=se/s,fe=te*m+h,pe=Math.sin(fe),Y=Math.cos(fe);B.x=Z*pe,B.y=-P*n+w,B.z=Z*Y,x.push(B.x,B.y,B.z),U.set(pe,H,Y).normalize(),b.push(U.x,U.y,U.z),M.push(te,1-P),I.push(A++)}R.push(I)}for(let W=0;W0||I!==0)&&(_.push(P,Z,te),z+=3),(t>0||I!==u-1)&&(_.push(Z,se,te),z+=3)}g.addGroup(E,z,0),E+=z}function D(U){const B=A,z=new ze,H=new j;let W=0;const I=U===!0?e:t,P=U===!0?1:-1;for(let se=1;se<=s;se++)x.push(0,w*P,0),b.push(0,P,0),M.push(.5,.5),A++;const Z=A;for(let se=0;se<=s;se++){const fe=se/s*m+h,pe=Math.cos(fe),Y=Math.sin(fe);H.x=I*Y,H.y=w*P,H.z=I*pe,x.push(H.x,H.y,H.z),b.push(0,P,0),z.x=pe*.5+.5,z.y=Y*.5*P+.5,M.push(z.x,z.y),A++}for(let se=0;se.9&&H<.1&&(D<.2&&(f[N+0]+=1),U<.2&&(f[N+2]+=1),B<.2&&(f[N+4]+=1))}}function b(N){u.push(N.x,N.y,N.z)}function M(N,D){const U=N*3;D.x=e[U+0],D.y=e[U+1],D.z=e[U+2]}function A(){const N=new j,D=new j,U=new j,B=new j,z=new ze,H=new ze,W=new ze;for(let I=0,P=0;I0)m=s-1;else{m=s;break}if(s=m,n[s]===f)return s/(u-1);const _=n[s],b=n[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 ze:new j);return m.copy(h).sub(f).normalize(),m}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new j,s=[],u=[],f=[],h=new j,m=new Xt;for(let M=0;M<=e;M++){const A=M/e;s[M]=this.getTangentAt(A,new j)}u[0]=new j,f[0]=new j;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=_,n.set(1,0,0)),x<=g&&(g=x,n.set(0,1,0)),b<=g&&n.set(0,0,1),h.crossVectors(s[0],n).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(Ht(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(Ht(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 Fy extends Zr{constructor(e=0,t=0,n=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=n,this.yRadius=s,this.aStartAngle=u,this.aEndAngle=f,this.aClockwise=h,this.aRotation=m}getPoint(e,t=new ze){const n=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]:(K0.subVectors(s[0],s[1]).add(s[0]),g=K0);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 n.set(VM(h,m.x,g.x,_.x,x.x),VM(h,m.y,g.y,_.y,x.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const f=s[u]-n,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 n=0,s=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;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 $c extends ly{constructor(e){super(e),this.uuid=Vs(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,s=this.holes.length;n80*t){h=r[0],m=r[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 vm(u,f,t,h,m,g,0),f}function lT(r,e,t,n,s){let u;if(s===TN(r,e,t,n)>0)for(let f=e;f=e;f-=n)u=HM(f/n|0,r[f],r[f+1],u);return u&&td(u,u.next)&&(_m(u),u=u.next),u}function af(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(td(t,t.next)||_i(t.prev,t,t.next)===0)){if(_m(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function vm(r,e,t,n,s,u,f){if(!r)return;!f&&u&&_N(r,n,s,u);let h=r;for(;r.prev!==r.next;){const m=r.prev,g=r.next;if(u?fN(r,n,s,u):cN(r)){e.push(m.i,r.i,g.i),_m(r),r=g.next,h=g.next;continue}if(r=g,r===h){f?f===1?(r=hN(af(r),e),vm(r,e,t,n,s,u,2)):f===2&&dN(r,e,t,n,s,u):vm(af(r),e,t,n,s,u,1);break}}}function cN(r){const e=r.prev,t=r,n=r.next;if(_i(e,t,n)>=0)return!1;const s=e.x,u=t.x,f=n.x,h=e.y,m=t.y,g=n.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=n.next;for(;A!==e;){if(A.x>=_&&A.x<=b&&A.y>=x&&A.y<=M&&Zp(s,h,u,m,f,g,A.x,A.y)&&_i(A.prev,A,A.next)>=0)return!1;A=A.next}return!0}function fN(r,e,t,n){const s=r.prev,u=r,f=r.next;if(_i(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),w=Math.max(_,x,b),E=Zx(M,A,e,t,n),N=Zx(R,w,e,t,n);let D=r.prevZ,U=r.nextZ;for(;D&&D.z>=E&&U&&U.z<=N;){if(D.x>=M&&D.x<=R&&D.y>=A&&D.y<=w&&D!==s&&D!==f&&Zp(h,_,m,x,g,b,D.x,D.y)&&_i(D.prev,D,D.next)>=0||(D=D.prevZ,U.x>=M&&U.x<=R&&U.y>=A&&U.y<=w&&U!==s&&U!==f&&Zp(h,_,m,x,g,b,U.x,U.y)&&_i(U.prev,U,U.next)>=0))return!1;U=U.nextZ}for(;D&&D.z>=E;){if(D.x>=M&&D.x<=R&&D.y>=A&&D.y<=w&&D!==s&&D!==f&&Zp(h,_,m,x,g,b,D.x,D.y)&&_i(D.prev,D,D.next)>=0)return!1;D=D.prevZ}for(;U&&U.z<=N;){if(U.x>=M&&U.x<=R&&U.y>=A&&U.y<=w&&U!==s&&U!==f&&Zp(h,_,m,x,g,b,U.x,U.y)&&_i(U.prev,U,U.next)>=0)return!1;U=U.nextZ}return!0}function hN(r,e){let t=r;do{const n=t.prev,s=t.next.next;!td(n,s)&&cT(n,t,t.next,s)&&ym(n,s)&&ym(s,n)&&(e.push(n.i,t.i,s.i),_m(t),_m(t.next),t=r=s),t=t.next}while(t!==r);return af(t)}function dN(r,e,t,n,s,u){let f=r;do{let h=f.next.next;for(;h!==f.prev;){if(f.i!==h.i&&SN(f,h)){let m=fT(f,h);f=af(f,f.next),m=af(m,m.next),vm(f,e,t,n,s,u,0),vm(m,e,t,n,s,u,0);return}h=h.next}f=f.next}while(f!==r)}function pN(r,e,t,n){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<=n&&x>u&&(u=x,f=t.x=t.x&&t.x>=m&&n!==t.x&&uT(sf.x||t.x===f.x&&yN(f,t)))&&(f=t,_=x)}t=t.next}while(t!==h);return f}function yN(r,e){return _i(r.prev,r,e.prev)<0&&_i(e.next,r,r.next)<0}function _N(r,e,t,n){let s=r;do s.z===0&&(s.z=Zx(s.x,s.y,e,t,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,xN(s)}function xN(r){let e,t=1;do{let n=r,s;r=null;let u=null;for(e=0;n;){e++;let f=n,h=0;for(let g=0;g0||m>0&&f;)h!==0&&(m===0||!f||n.z<=f.z)?(s=n,n=n.nextZ,h--):(s=f,f=f.nextZ,m--),u?u.nextZ=s:r=s,s.prevZ=u,u=s;n=f}u.nextZ=null,t*=2}while(e>1);return r}function Zx(r,e,t,n,s){return r=(r-t)*s|0,e=(e-n)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function bN(r){let e=r,t=r;do(e.x=(r-f)*(u-h)&&(r-f)*(n-h)>=(t-f)*(e-h)&&(t-f)*(u-h)>=(s-f)*(n-h)}function Zp(r,e,t,n,s,u,f,h){return!(r===f&&e===h)&&uT(r,e,t,n,s,u,f,h)}function SN(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!MN(r,e)&&(ym(r,e)&&ym(e,r)&&EN(r,e)&&(_i(r.prev,r,e.prev)||_i(r,e.prev,e))||td(r,e)&&_i(r.prev,r,r.next)>0&&_i(e.prev,e,e.next)>0)}function _i(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function td(r,e){return r.x===e.x&&r.y===e.y}function cT(r,e,t,n){const s=$0(_i(r,e,t)),u=$0(_i(r,e,n)),f=$0(_i(t,n,r)),h=$0(_i(t,n,e));return!!(s!==u&&f!==h||s===0&&J0(r,t,e)||u===0&&J0(r,n,e)||f===0&&J0(t,r,n)||h===0&&J0(t,e,n))}function J0(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function $0(r){return r>0?1:r<0?-1:0}function MN(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&cT(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function ym(r,e){return _i(r.prev,r,r.next)<0?_i(r,e,r.next)>=0&&_i(r,r.prev,e)>=0:_i(r,e,r.prev)<0||_i(r,r.next,e)<0}function EN(r,e){let t=r,n=!1;const s=(r.x+e.x)/2,u=(r.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&&(n=!n),t=t.next;while(t!==r);return n}function fT(r,e){const t=Qx(r.i,r.x,r.y),n=Qx(e.i,e.x,e.y),s=r.next,u=e.prev;return r.next=e,e.prev=r,t.next=s,s.prev=t,n.next=t,t.prev=n,u.next=n,n.prev=u,n}function HM(r,e,t,n){const s=Qx(r,e,t);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function _m(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Qx(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function TN(r,e,t,n){let s=0;for(let u=e,f=t-n;u2&&r[e-1].equals(r[0])&&r.pop()}function XM(r,e){for(let t=0;tNumber.EPSILON){const Te=Math.sqrt(O),Ie=Math.sqrt(Qe*Qe+G*G),Ee=He.x-Tt/Te,dt=He.y+ot/Te,Ke=Oe.x-G/Ie,vt=Oe.y+Qe/Ie,Dt=((Ke-Ee)*G-(vt-dt)*Qe)/(ot*G-Tt*Qe);nt=Ee+ot*Dt-Le.x,Q=dt+Tt*Dt-Le.y;const Ve=nt*nt+Q*Q;if(Ve<=2)return new ze(nt,Q);Et=Math.sqrt(Ve/2)}else{let Te=!1;ot>Number.EPSILON?Qe>Number.EPSILON&&(Te=!0):ot<-Number.EPSILON?Qe<-Number.EPSILON&&(Te=!0):Math.sign(Tt)===Math.sign(G)&&(Te=!0),Te?(nt=-Tt,Q=ot,Et=Math.sqrt(O)):(nt=ot,Q=Tt,Et=Math.sqrt(O/2))}return new ze(nt/Et,Q/Et)}const be=[];for(let Le=0,He=pe.length,Oe=He-1,nt=Le+1;Le=0;Le--){const He=Le/w,Oe=M*Math.cos(He*Math.PI/2),nt=A*Math.sin(He*Math.PI/2)+R;for(let Q=0,Et=pe.length;Q=0;){const nt=Oe;let Q=Oe-1;Q<0&&(Q=Le.length-1);for(let Et=0,ot=_+w*2;Et0)&&M.push(D,U,z),(E!==n-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 mT extends Ba{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new yt(16777215),this.specular=new yt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ku,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gs,this.combine=Am,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 gT extends Ba{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new yt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ku,this.normalScale=new ze(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 vT extends Ba{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ku,this.normalScale=new ze(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 yT extends Ba{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ku,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gs,this.combine=Am,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 Wb extends Ba{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=NE,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 qb extends Ba{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 _T extends Ba{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new yt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ku,this.normalScale=new ze(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 xT extends ss{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 Qc(r,e){return!r||r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)}function bT(r){function e(s,u){return r[s]-r[u]}const t=r.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function Kx(r,e,t){const n=r.length,s=new r.constructor(n);for(let u=0,f=0;f!==n;++u){const h=t[u]*e;for(let m=0;m!==e;++m)s[f++]=r[h+m]}return s}function jb(r,e,t,n){let s=1,u=r[0];for(;u!==void 0&&u[n]===void 0;)u=r[s++];if(u===void 0)return;let f=u[n];if(f!==void 0)if(Array.isArray(f))do f=u[n],f!==void 0&&(e.push(u.time),t.push(...f)),u=r[s++];while(u!==void 0);else if(f.toArray!==void 0)do f=u[n],f!==void 0&&(e.push(u.time),f.toArray(t,t.length)),u=r[s++];while(u!==void 0);else do f=u[n],f!==void 0&&(e.push(u.time),t.push(f)),u=r[s++];while(u!==void 0)}function NN(r,e,t,n,s=30){const u=r.clone();u.name=e;const f=[];for(let m=0;m=n)){x.push(g.times[M]);for(let R=0;R<_;++R)b.push(g.values[M*_+R])}}x.length!==0&&(g.times=Qc(x,g.times.constructor),g.values=Qc(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+_,N=E+x-_;R=h.values.slice(E,N)}else{const E=h.createInterpolant(),N=_,D=x-_;E.evaluate(u),R=E.resultBuffer.slice(N,D)}m==="quaternion"&&new Pa().fromArray(R).normalize().conjugate().toArray(R);const w=g.times.length;for(let E=0;E=u)){const h=t[1];e=u)break t}f=n,n=0;break n}break e}for(;n>>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=n.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&&(Rt("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,s=this.values,u=n.length;u===0&&(Rt("KeyframeTrack: Track is empty.",this),e=!1);let f=null;for(let h=0;h!==u;h++){const m=n[h];if(typeof m=="number"&&isNaN(m)){Rt("KeyframeTrack: Time is not a valid number.",this,h,m),e=!1;break}if(f!==null&&f>m){Rt("KeyframeTrack: Out of order keys.",this,h,m,f),e=!1;break}f=m}if(s!==void 0&&FE(s))for(let h=0,m=s.length;h!==m;++h){const g=s[h];if(isNaN(g)){Rt("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(),n=this.getValueSize(),s=this.getInterpolation()===dv,u=e.length-1;let f=1;for(let h=1;h0){e[f]=e[u];for(let h=u*n,m=f*n,g=0;g!==n;++g)t[m+g]=t[h+g];++f}return f!==e.length?(this.times=e.slice(0,f),this.values=t.slice(0,f*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}_r.prototype.ValueTypeName="";_r.prototype.TimeBufferType=Float32Array;_r.prototype.ValueBufferType=Float32Array;_r.prototype.DefaultInterpolation=ay;class uf extends _r{constructor(e,t,n){super(e,t,n)}}uf.prototype.ValueTypeName="bool";uf.prototype.ValueBufferType=Array;uf.prototype.DefaultInterpolation=fm;uf.prototype.InterpolantFactoryMethodLinear=void 0;uf.prototype.InterpolantFactoryMethodSmooth=void 0;class Zb extends _r{constructor(e,t,n,s){super(e,t,n,s)}}Zb.prototype.ValueTypeName="color";class xm extends _r{constructor(e,t,n,s){super(e,t,n,s)}}xm.prototype.ValueTypeName="number";class ET extends Um{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const u=this.resultBuffer,f=this.sampleValues,h=this.valueSize,m=(n-t)/(s-t);let g=e*h;for(let _=g+h;g!==_;g+=4)Pa.slerpFlat(u,0,f,g-h,f,g,m);return u}}class Im extends _r{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new ET(this.times,this.values,this.getValueSize(),e)}}Im.prototype.ValueTypeName="quaternion";Im.prototype.InterpolantFactoryMethodSmooth=void 0;class cf extends _r{constructor(e,t,n){super(e,t,n)}}cf.prototype.ValueTypeName="string";cf.prototype.ValueBufferType=Array;cf.prototype.DefaultInterpolation=fm;cf.prototype.InterpolantFactoryMethodLinear=void 0;cf.prototype.InterpolantFactoryMethodSmooth=void 0;class bm extends _r{constructor(e,t,n,s){super(e,t,n,s)}}bm.prototype.ValueTypeName="vector";class Sm{constructor(e="",t=-1,n=[],s=Ey){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=Vs(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,s=1/(e.fps||1);for(let f=0,h=n.length;f!==h;++f)t.push(IN(n[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=[],n=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=n.length;u!==f;++u)t.push(_r.toJSON(n[u]));return s}static CreateFromMorphTargetSequence(e,t,n,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,n));return f}static parseAnimation(e,t){if(ft("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Rt("AnimationClip: No animation in JSONLoader data."),null;const n=function(x,b,M,A,R){if(M.length!==0){const w=[],E=[];jb(M,w,E,A),w.length!==0&&R.push(new x(b,w,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(Al[e]!==void 0){Al[e].push({onLoad:t,onProgress:n,onError:s});return}Al[e]=[],Al[e].push({onLoad:t,onProgress:n,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&&ft("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||g.body===void 0||g.body.getReader===void 0)return g;const _=Al[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 w=new ReadableStream({start(E){N();function N(){x.read().then(({done:D,value:U})=>{if(D)E.close();else{R+=U.byteLength;const B=new ProgressEvent("progress",{lengthComputable:A,loaded:R,total:M});for(let z=0,H=_.length;z{E.error(D)})}}});return new Response(w)}else throw new ON(`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=>{Oo.add(`file:${e}`,g);const _=Al[e];delete Al[e];for(let x=0,b=_.length;x{const _=Al[e];if(_===void 0)throw this.manager.itemError(e),g;delete Al[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 PN extends Ns{constructor(e){super(e)}load(e,t,n,s){const u=this,f=new Ul(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):Rt(m),u.manager.itemError(e)}},n,s)}parse(e){const t=[];for(let n=0;n0: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=n(f.value);break;case"c":s.uniforms[u].value=new yt().setHex(f.value);break;case"v2":s.uniforms[u].value=new ze().fromArray(f.value);break;case"v3":s.uniforms[u].value=new j().fromArray(f.value);break;case"v4":s.uniforms[u].value=new jn().fromArray(f.value);break;case"m3":s.uniforms[u].value=new en().fromArray(f.value);break;case"m4":s.uniforms[u].value=new Xt().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=n(e.map)),e.matcap!==void 0&&(s.matcap=n(e.matcap)),e.alphaMap!==void 0&&(s.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(s.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(s.bumpScale=e.bumpScale),e.normalMap!==void 0&&(s.normalMap=n(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 ze().fromArray(u)}return e.displacementMap!==void 0&&(s.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(s.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(s.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(s.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(s.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(s.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(s.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(s.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(s.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(s.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(s.envMap=n(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=n(e.lightMap)),e.lightMapIntensity!==void 0&&(s.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(s.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(s.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(s.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(s.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(s.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(s.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(s.clearcoatNormalScale=new ze().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(s.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(s.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(s.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(s.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(s.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(s.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(s.sheenRoughnessMap=n(e.sheenRoughnessMap)),s}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return Zy.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:dT,SpriteMaterial:Ub,RawShaderMaterial:Gb,ShaderMaterial:yr,PointsMaterial:Ob,MeshPhysicalMaterial:pT,MeshStandardMaterial:Xb,MeshPhongMaterial:mT,MeshToonMaterial:gT,MeshNormalMaterial:vT,MeshLambertMaterial:yT,MeshDepthMaterial:Wb,MeshDistanceMaterial:qb,MeshBasicMaterial:Vu,MeshMatcapMaterial:_T,LineDashedMaterial:xT,LineBasicMaterial:ss,Material:Ba};return new t[e]}}class Jx{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 UT extends Kt{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 IT extends Ns{constructor(e){super(e)}load(e,t,n,s){const u=this,f=new Ul(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):Rt(m),u.manager.itemError(e)}},n,s)}parse(e){const t={},n={};function s(M,A){if(t[A]!==void 0)return t[A];const w=M.interleavedBuffers[A],E=u(M,w.buffer),N=Hh(w.type,E),D=new Ly(N,w.stride);return D.uuid=w.uuid,t[A]=D,D}function u(M,A){if(n[A]!==void 0)return n[A];const w=M.arrayBuffers[A],E=new Uint32Array(w).buffer;return n[A]=E,E}const f=e.isInstancedBufferGeometry?new UT:new Kt,h=e.data.index;if(h!==void 0){const M=Hh(h.type,h.array);f.setIndex(new Xn(M,1))}const m=e.data.attributes;for(const M in m){const A=m[M];let R;if(A.isInterleavedBufferAttribute){const w=s(e.data,A.data);R=new nf(w,A.itemSize,A.offset,A.normalized)}else{const w=Hh(A.type,A.array),E=A.isInstancedBufferAttribute?$h:Xn;R=new E(w,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 w=0,E=A.length;w0){const m=new Qb(t);u=new Mm(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 Mm(this.manager),s.setCrossOrigin(this.crossOrigin);for(let f=0,h=e.length;f{let E=null,N=null;return w.boundingBox!==void 0&&(E=new za().fromJSON(w.boundingBox)),w.boundingSphere!==void 0&&(N=new _a().fromJSON(w.boundingSphere)),{...w,boundingBox:E,boundingSphere:N}}),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 _a().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(f.boundingBox=new za().fromJSON(e.boundingBox));break;case"LOD":f=new YE;break;case"Line":f=new Fu(h(e.geometry),m(e.material));break;case"LineLoop":f=new JE(h(e.geometry),m(e.material));break;case"LineSegments":f=new Vo(h(e.geometry),m(e.material));break;case"PointCloud":case"Points":f=new $E(h(e.geometry),m(e.material));break;case"Sprite":f=new jE(m(e.material));break;case"Group":f=new Gh;break;case"Bone":f=new Ib;break;default:f=new Cn}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"&&ft("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&ft("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const u=this,f=Oo.get(`image-bitmap:${e}`);if(f!==void 0){if(u.manager.itemStart(e),f.then){f.then(g=>{if(yx.has(f)===!0)s&&s(yx.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 Oo.add(`image-bitmap:${e}`,g),t&&t(g),u.manager.itemEnd(e),g}).catch(function(g){s&&s(g),yx.set(m,g),Oo.remove(`image-bitmap:${e}`),u.manager.itemError(e),u.manager.itemEnd(e)});Oo.add(`image-bitmap:${e}`,m),u.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let ev;class $b{static getContext(){return ev===void 0&&(ev=new(window.AudioContext||window.webkitAudioContext)),ev}static setContext(e){ev=e}}class jN extends Ns{constructor(e){super(e)}load(e,t,n,s){const u=this,f=new Ul(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);$b.getContext().decodeAudioData(g,function(x){t(x)}).catch(h)}catch(g){h(g)}},n,s);function h(m){s?s(m):Rt(m),u.manager.itemError(e)}}}const KM=new Xt,JM=new Xt,Oc=new Xt;class YN{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new zi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new zi,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,Oc.copy(e.projectionMatrix);const s=t.eyeSep/2,u=s*t.near/t.focus,f=t.near*Math.tan(Jc*t.fov*.5)/t.zoom;let h,m;JM.elements[12]=-s,KM.elements[12]=s,h=-f*t.aspect+u,m=f*t.aspect+u,Oc.elements[0]=2*t.near/(m-h),Oc.elements[8]=(m+h)/(m-h),this.cameraL.projectionMatrix.copy(Oc),h=-f*t.aspect-u,m=f*t.aspect-u,Oc.elements[0]=2*t.near/(m-h),Oc.elements[8]=(m+h)/(m-h),this.cameraR.projectionMatrix.copy(Oc)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(JM),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(KM)}}class OT extends zi{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class eS{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 Pc=new j,_x=new Pa,ZN=new j,zc=new j,Bc=new j;class QN extends Cn{constructor(){super(),this.type="AudioListener",this.context=$b.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new eS}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(Pc,_x,ZN),zc.set(0,0,-1).applyQuaternion(_x),Bc.set(0,1,0).applyQuaternion(_x),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Pc.x,n),t.positionY.linearRampToValueAtTime(Pc.y,n),t.positionZ.linearRampToValueAtTime(Pc.z,n),t.forwardX.linearRampToValueAtTime(zc.x,n),t.forwardY.linearRampToValueAtTime(zc.y,n),t.forwardZ.linearRampToValueAtTime(zc.z,n),t.upX.linearRampToValueAtTime(Bc.x,n),t.upY.linearRampToValueAtTime(Bc.y,n),t.upZ.linearRampToValueAtTime(Bc.z,n)}else t.setPosition(Pc.x,Pc.y,Pc.z),t.setOrientation(zc.x,zc.y,zc.z,Bc.x,Bc.y,Bc.z)}}let PT=class extends Cn{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){ft("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){ft("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){ft("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){ft("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(n,s,this._addIndex*t,1,t);for(let m=t,g=t+t;m!==g;++m)if(n[m]!==n[m+t]){h.setValue(n,s);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,s=n*this._origIndex;e.getValue(t,s);for(let u=n,f=s;u!==f;++u)t[u]=t[s+u%n];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 n=e;n=.5)for(let f=0;f!==u;++f)e[t+f]=e[n+f]}_slerp(e,t,n,s){Pa.slerpFlat(e,t,e,t,e,n,s)}_slerpAdditive(e,t,n,s,u){const f=this._workIndex*u;Pa.multiplyQuaternionsFlat(e,f,e,t,e,n),Pa.slerpFlat(e,t,e,t,e,f,s)}_lerp(e,t,n,s,u){const f=1-s;for(let h=0;h!==u;++h){const m=t+h;e[m]=e[m]*f+e[n+h]*s}}_lerpAdditive(e,t,n,s,u){for(let f=0;f!==u;++f){const h=t+f;e[h]=e[h]+e[n+f]*s}}}const tS="\\[\\]\\.:\\/",eD=new RegExp("["+tS+"]","g"),nS="[^"+tS+"]",tD="[^"+tS.replace("\\.","")+"]",nD=/((?:WC+[\/:])*)/.source.replace("WC",nS),iD=/(WCOD+)?/.source.replace("WCOD",tD),aD=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",nS),sD=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",nS),rD=new RegExp("^"+nD+iD+aD+sD+"$"),oD=["material","materials","bones","map"];class lD{constructor(e,t,n){const s=n||wn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,u=n.length;s!==u;++s)n[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class wn{constructor(e,t,n){this.path=t,this.parsedPath=n||wn.parseTrackName(t),this.node=wn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new wn.Composite(e,t,n):new wn(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(eD,"")}static parseTrackName(e){const t=rD.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const u=n.nodeName.substring(s+1);oD.indexOf(u)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=u)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(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=n[M],w=R[x],E=R[_];R[_]=w,R[x]=E}}}this.nCachedObjects_=u}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,s=n.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 w=n[A];w[x]=w[b],w.pop()}}}this.nCachedObjects_=u}subscribe_(e,t){const n=this._bindingsIndicesByPath;let s=n[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,n[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 wn(A,e,t)}return x}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const s=this._paths,u=this._parsedPaths,f=this._bindings,h=f.length-1,m=f[h],g=e[h];t[g]=n,f[n]=m,f.pop(),u[n]=u[h],u.pop(),s[n]=s[h],s.pop()}}}class BT{constructor(e,t,n=null,s=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=s;const u=t.tracks,f=u.length,h=new Array(f),m={endingStart:Yc,endingEnd:Yc};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=CE,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,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!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,n=!1){return e.crossFadeFrom(this,t,n)}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,n){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+n,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,n,s){if(!this.enabled){this._updateWeight(e);return}const u=this._startTime;if(u!==null){const m=(e-u)*n;m<0||n===0?t=0:(this._startTime=null,t=n*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 Ab:for(let _=0,x=m.length;_!==x;++_)m[_].evaluate(f),g[_].accumulateAdditive(h);break;case Ey: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 n=this._weightInterpolant;if(n!==null){const s=n.evaluate(e)[0];t*=s,e>n.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 n=this._timeScaleInterpolant;if(n!==null){const s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let s=this.time+e,u=this._loopCount;const f=n===RE;if(e===0)return u===-1?s:f&&(u&1)===1?t-s:s;if(n===wE){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,n){const s=this._interpolantSettings;n?(s.endingStart=Zc,s.endingEnd=Zc):(e?s.endingStart=this.zeroSlopeAtStart?Zc:Yc:s.endingStart=hm,t?s.endingEnd=this.zeroSlopeAtEnd?Zc:Yc:s.endingEnd=hm)}_scheduleFading(e,t,n){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]=n,this}}const cD=new Float32Array(1);class fD extends ko{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,s=e._clip.tracks,u=s.length,f=e._propertyBindings,h=e._interpolants,m=n.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 zT(wn.create(n,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 n=(e._localRoot||this._root).uuid,s=e._clip.uuid,u=this._actionsByClip[s];this._bindAction(e,u&&u.knownActions[0]),this._addInactiveAction(e,s,n)}const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const u=t[n];u.useCount++===0&&(this._lendBinding(u),u.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const u=t[n];--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;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,s=this.time+=e,u=Math.sign(e),f=this._accuIndex^=1;for(let g=0;g!==n;++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,n1).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 i1=new j,tv=new j,Oh=new j,Ph=new j,xx=new j,bD=new j,SD=new j;class MD{constructor(e=new j,t=new j){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){i1.subVectors(e,this.start),tv.subVectors(this.end,this.start);const n=tv.dot(tv);let u=tv.dot(i1)/n;return t&&(u=Ht(u,0,1)),u}closestPointToPoint(e,t,n){const s=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(s).add(this.start)}distanceSqToLine3(e,t=bD,n=SD){const s=10000000000000001e-32;let u,f;const h=this.start,m=e.start,g=this.end,_=e.end;Oh.subVectors(g,h),Ph.subVectors(_,m),xx.subVectors(h,m);const x=Oh.dot(Oh),b=Ph.dot(Ph),M=Ph.dot(xx);if(x<=s&&b<=s)return t.copy(h),n.copy(m),t.sub(n),t.dot(t);if(x<=s)u=0,f=M/b,f=Ht(f,0,1);else{const A=Oh.dot(xx);if(b<=s)f=0,u=Ht(-A/x,0,1);else{const R=Oh.dot(Ph),w=x*b-R*R;w!==0?u=Ht((R*M-A*b)/w,0,1):u=0,f=(R*u+M)/b,f<0?(f=0,u=Ht(-A/x,0,1)):f>1&&(f=1,u=Ht((R-A)/x,0,1))}}return t.copy(h).add(Oh.multiplyScalar(u)),n.copy(m).add(Ph.multiplyScalar(f)),t.sub(n),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 a1=new j;class ED extends Cn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Kt,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{u1.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(u1,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),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 zD extends Vo{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],s=new Kt;s.setAttribute("position",new bt(t,3)),s.setAttribute("color",new bt(n,3));const u=new ss({vertexColors:!0,toneMapped:!1});super(s,u),this.type="AxesHelper"}setColors(e,t,n){const s=new yt,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(n),s.toArray(u,12),s.toArray(u,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class BD{constructor(){this.type="ShapePath",this.color=new yt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ly,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,s){return this.currentPath.quadraticCurveTo(e,t,n,s),this}bezierCurveTo(e,t,n,s,u,f){return this.currentPath.bezierCurveTo(e,t,n,s,u,f),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(E){const N=[];for(let D=0,U=E.length;DNumber.EPSILON){if(P<0&&(H=N[z],I=-I,W=N[B],P=-P),E.yW.y)continue;if(E.y===H.y){if(E.x===H.x)return!0}else{const Z=P*(E.x-H.x)-I*(E.y-H.y);if(Z===0)return!0;if(Z<0)continue;U=!U}}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 U}const s=jr.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 $c,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,N=u.length;E1){let E=!1,N=0;for(let D=0,U=b.length;D0&&E===!1&&(M=x)}let w;for(let E=0,N=b.length;Ee?(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2):(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0),r}function VD(r,e){const t=r.image&&r.image.width?r.image.width/r.image.height:1;return t>e?(r.repeat.x=e/t,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0):(r.repeat.x=1,r.repeat.y=t/e,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2),r}function HD(r){return r.repeat.x=1,r.repeat.y=1,r.offset.x=0,r.offset.y=0,r}function tb(r,e,t,n){const s=GD(n);switch(t){case Eb:return r*e;case by:return r*e/s.components*s.byteLength;case wm:return r*e/s.components*s.byteLength;case tf:return r*e*2/s.components*s.byteLength;case Sy:return r*e*2/s.components*s.byteLength;case Tb:return r*e*3/s.components*s.byteLength;case Oa:return r*e*4/s.components*s.byteLength;case My:return r*e*4/s.components*s.byteLength;case $p:case em:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case tm:case nm:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case wv:case Rv:return Math.max(r,16)*Math.max(e,8)/4;case Av:case Cv:return Math.max(r,8)*Math.max(e,8)/2;case Nv:case Dv:case Uv:case Iv:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*8;case Lv:case Ov:case Pv:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case zv:return Math.floor((r+3)/4)*Math.floor((e+3)/4)*16;case Bv:return Math.floor((r+4)/5)*Math.floor((e+3)/4)*16;case Fv:return Math.floor((r+4)/5)*Math.floor((e+4)/5)*16;case kv:return Math.floor((r+5)/6)*Math.floor((e+4)/5)*16;case Vv:return Math.floor((r+5)/6)*Math.floor((e+5)/6)*16;case Hv:return Math.floor((r+7)/8)*Math.floor((e+4)/5)*16;case Gv:return Math.floor((r+7)/8)*Math.floor((e+5)/6)*16;case Xv:return Math.floor((r+7)/8)*Math.floor((e+7)/8)*16;case Wv:return Math.floor((r+9)/10)*Math.floor((e+4)/5)*16;case qv:return Math.floor((r+9)/10)*Math.floor((e+5)/6)*16;case jv:return Math.floor((r+9)/10)*Math.floor((e+7)/8)*16;case Yv:return Math.floor((r+9)/10)*Math.floor((e+9)/10)*16;case Zv:return Math.floor((r+11)/12)*Math.floor((e+9)/10)*16;case Qv:return Math.floor((r+11)/12)*Math.floor((e+11)/12)*16;case Kv:case Jv:case $v:return Math.ceil(r/4)*Math.ceil(e/4)*16;case ey:case ty:return Math.ceil(r/4)*Math.ceil(e/4)*8;case ny:case iy:return Math.ceil(r/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function GD(r){switch(r){case ts:case xb:return{byteLength:1,components:1};case qh:case bb:case Bo:return{byteLength:2,components:1};case _y:case xy:return{byteLength:2,components:4};case vr:case yy:case is:return{byteLength:4,components:1};case Sb:case Mb:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}class XD{static contain(e,t){return kD(e,t)}static cover(e,t){return VD(e,t)}static fill(e){return HD(e)}static getByteLength(e,t,n,s){return tb(e,t,n,s)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:my}}));typeof window<"u"&&(window.__THREE__?ft("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=my);function VT(){let r=null,e=!1,t=null,n=null;function s(u,f){t(u,f),n=r.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(s),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(u){t=u},setContext:function(u){r=u}}}function WD(r){const e=new WeakMap;function t(h,m){const g=h.array,_=h.usage,x=g.byteLength,b=r.createBuffer();r.bindBuffer(m,b),r.bufferData(m,g,_),h.onUploadCallback();let M;if(g instanceof Float32Array)M=r.FLOAT;else if(typeof Float16Array<"u"&&g instanceof Float16Array)M=r.HALF_FLOAT;else if(g instanceof Uint16Array)h.isFloat16BufferAttribute?M=r.HALF_FLOAT:M=r.UNSIGNED_SHORT;else if(g instanceof Int16Array)M=r.SHORT;else if(g instanceof Uint32Array)M=r.UNSIGNED_INT;else if(g instanceof Int32Array)M=r.INT;else if(g instanceof Int8Array)M=r.BYTE;else if(g instanceof Uint8Array)M=r.UNSIGNED_BYTE;else if(g instanceof Uint8ClampedArray)M=r.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 n(h,m,g){const _=m.array,x=m.updateRanges;if(r.bindBuffer(g,h),x.length===0)r.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`,lL=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,uL=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,cL=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,fL=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,hL=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,dL=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,pL=`#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`,mL=`#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`,gL=`#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`,vL=`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`,yL=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,_L=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,xL=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,bL=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,SL="gl_FragColor = linearToOutputTexel( gl_FragColor );",ML=`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 ); }`,EL=`#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`,TL=`#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`,AL=`#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`,wL=`#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`,CL=`#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`,RL=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,NL=`#ifdef USE_FOG varying float vFogDepth; #endif`,DL=`#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`,LL=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,UL=`#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 }`,IL=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,OL=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,PL=`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`,zL=`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`,BL=`#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`,FL=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,kL=`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`,VL=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,HL=`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`,GL=`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`,XL=`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 ); }`,WL=` 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`,qL=`#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`,jL=`#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`,YL=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,ZL=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,QL=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,KL=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,JL=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,$L=`#ifdef USE_MAP uniform sampler2D map; #endif`,eU=`#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`,tU=`#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`,nU=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,iU=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,aU=`#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`,sU=`#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`,rU=`#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`,oU=`#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`,lU=`#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`,uU=`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;`,cU=`#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`,fU=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,hU=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,dU=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,pU=`#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`,mU=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,gU=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,vU=`#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`,yU=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,_U=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,xU=`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 ); }`,bU=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,SU=`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;`,MU=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,EU=`#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`,TU=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,AU=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,wU=`#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`,CU=`#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`,RU=`#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`,NU=`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; }`,DU=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,LU=`#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`,UU=`#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`,IU=`#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`,OU=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,PU=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,zU=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,BU=`#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; }`,FU=`#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`,kU=`#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`,VU=`#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`,HU=`#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`,GU=`#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`,XU=`#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 WU=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,qU=`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 }`,jU=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,YU=`#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 }`,ZU=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,QU=`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 }`,KU=`#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; }`,JU=`#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 }`,$U=`#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; }`,eI=`#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 ); }`,tI=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,nI=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,iI=`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 }`,aI=`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 }`,sI=`#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 }`,rI=`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 }`,oI=`#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 }`,lI=`#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 }`,uI=`#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; }`,cI=`#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 }`,fI=`#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 }`,hI=`#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 }`,dI=`#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 }`,pI=`#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 }`,mI=`#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 }`,gI=`#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 }`,vI=`#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 }`,yI=`#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 }`,_I=`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 }`,xI=`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 }`,bI=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,SI=`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 }`,MI=`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 }`,EI=`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 }`,un={alphahash_fragment:qD,alphahash_pars_fragment:jD,alphamap_fragment:YD,alphamap_pars_fragment:ZD,alphatest_fragment:QD,alphatest_pars_fragment:KD,aomap_fragment:JD,aomap_pars_fragment:$D,batching_pars_vertex:eL,batching_vertex:tL,begin_vertex:nL,beginnormal_vertex:iL,bsdfs:aL,iridescence_fragment:sL,bumpmap_pars_fragment:rL,clipping_planes_fragment:oL,clipping_planes_pars_fragment:lL,clipping_planes_pars_vertex:uL,clipping_planes_vertex:cL,color_fragment:fL,color_pars_fragment:hL,color_pars_vertex:dL,color_vertex:pL,common:mL,cube_uv_reflection_fragment:gL,defaultnormal_vertex:vL,displacementmap_pars_vertex:yL,displacementmap_vertex:_L,emissivemap_fragment:xL,emissivemap_pars_fragment:bL,colorspace_fragment:SL,colorspace_pars_fragment:ML,envmap_fragment:EL,envmap_common_pars_fragment:TL,envmap_pars_fragment:AL,envmap_pars_vertex:wL,envmap_physical_pars_fragment:BL,envmap_vertex:CL,fog_vertex:RL,fog_pars_vertex:NL,fog_fragment:DL,fog_pars_fragment:LL,gradientmap_pars_fragment:UL,lightmap_pars_fragment:IL,lights_lambert_fragment:OL,lights_lambert_pars_fragment:PL,lights_pars_begin:zL,lights_toon_fragment:FL,lights_toon_pars_fragment:kL,lights_phong_fragment:VL,lights_phong_pars_fragment:HL,lights_physical_fragment:GL,lights_physical_pars_fragment:XL,lights_fragment_begin:WL,lights_fragment_maps:qL,lights_fragment_end:jL,logdepthbuf_fragment:YL,logdepthbuf_pars_fragment:ZL,logdepthbuf_pars_vertex:QL,logdepthbuf_vertex:KL,map_fragment:JL,map_pars_fragment:$L,map_particle_fragment:eU,map_particle_pars_fragment:tU,metalnessmap_fragment:nU,metalnessmap_pars_fragment:iU,morphinstance_vertex:aU,morphcolor_vertex:sU,morphnormal_vertex:rU,morphtarget_pars_vertex:oU,morphtarget_vertex:lU,normal_fragment_begin:uU,normal_fragment_maps:cU,normal_pars_fragment:fU,normal_pars_vertex:hU,normal_vertex:dU,normalmap_pars_fragment:pU,clearcoat_normal_fragment_begin:mU,clearcoat_normal_fragment_maps:gU,clearcoat_pars_fragment:vU,iridescence_pars_fragment:yU,opaque_fragment:_U,packing:xU,premultiplied_alpha_fragment:bU,project_vertex:SU,dithering_fragment:MU,dithering_pars_fragment:EU,roughnessmap_fragment:TU,roughnessmap_pars_fragment:AU,shadowmap_pars_fragment:wU,shadowmap_pars_vertex:CU,shadowmap_vertex:RU,shadowmask_pars_fragment:NU,skinbase_vertex:DU,skinning_pars_vertex:LU,skinning_vertex:UU,skinnormal_vertex:IU,specularmap_fragment:OU,specularmap_pars_fragment:PU,tonemapping_fragment:zU,tonemapping_pars_fragment:BU,transmission_fragment:FU,transmission_pars_fragment:kU,uv_pars_fragment:VU,uv_pars_vertex:HU,uv_vertex:GU,worldpos_vertex:XU,background_vert:WU,background_frag:qU,backgroundCube_vert:jU,backgroundCube_frag:YU,cube_vert:ZU,cube_frag:QU,depth_vert:KU,depth_frag:JU,distance_vert:$U,distance_frag:eI,equirect_vert:tI,equirect_frag:nI,linedashed_vert:iI,linedashed_frag:aI,meshbasic_vert:sI,meshbasic_frag:rI,meshlambert_vert:oI,meshlambert_frag:lI,meshmatcap_vert:uI,meshmatcap_frag:cI,meshnormal_vert:fI,meshnormal_frag:hI,meshphong_vert:dI,meshphong_frag:pI,meshphysical_vert:mI,meshphysical_frag:gI,meshtoon_vert:vI,meshtoon_frag:yI,points_vert:_I,points_frag:xI,shadow_vert:bI,shadow_frag:SI,sprite_vert:MI,sprite_frag:EI},pt={common:{diffuse:{value:new yt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new en},alphaMap:{value:null},alphaMapTransform:{value:new en},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new en}},envmap:{envMap:{value:null},envMapRotation:{value:new en},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 en}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new en}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new en},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new en},normalScale:{value:new ze(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new en},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new en}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new en}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new en}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new yt(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 yt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new en},alphaTest:{value:0},uvTransform:{value:new en}},sprite:{diffuse:{value:new yt(16777215)},opacity:{value:1},center:{value:new ze(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new en},alphaMap:{value:null},alphaMapTransform:{value:new en},alphaTest:{value:0}}},qr={basic:{uniforms:es([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.fog]),vertexShader:un.meshbasic_vert,fragmentShader:un.meshbasic_frag},lambert:{uniforms:es([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,pt.lights,{emissive:{value:new yt(0)}}]),vertexShader:un.meshlambert_vert,fragmentShader:un.meshlambert_frag},phong:{uniforms:es([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,pt.lights,{emissive:{value:new yt(0)},specular:{value:new yt(1118481)},shininess:{value:30}}]),vertexShader:un.meshphong_vert,fragmentShader:un.meshphong_frag},standard:{uniforms:es([pt.common,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.roughnessmap,pt.metalnessmap,pt.fog,pt.lights,{emissive:{value:new yt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:un.meshphysical_vert,fragmentShader:un.meshphysical_frag},toon:{uniforms:es([pt.common,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.gradientmap,pt.fog,pt.lights,{emissive:{value:new yt(0)}}]),vertexShader:un.meshtoon_vert,fragmentShader:un.meshtoon_frag},matcap:{uniforms:es([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,{matcap:{value:null}}]),vertexShader:un.meshmatcap_vert,fragmentShader:un.meshmatcap_frag},points:{uniforms:es([pt.points,pt.fog]),vertexShader:un.points_vert,fragmentShader:un.points_frag},dashed:{uniforms:es([pt.common,pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:un.linedashed_vert,fragmentShader:un.linedashed_frag},depth:{uniforms:es([pt.common,pt.displacementmap]),vertexShader:un.depth_vert,fragmentShader:un.depth_frag},normal:{uniforms:es([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,{opacity:{value:1}}]),vertexShader:un.meshnormal_vert,fragmentShader:un.meshnormal_frag},sprite:{uniforms:es([pt.sprite,pt.fog]),vertexShader:un.sprite_vert,fragmentShader:un.sprite_frag},background:{uniforms:{uvTransform:{value:new en},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:un.background_vert,fragmentShader:un.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new en}},vertexShader:un.backgroundCube_vert,fragmentShader:un.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:un.cube_vert,fragmentShader:un.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:un.equirect_vert,fragmentShader:un.equirect_frag},distance:{uniforms:es([pt.common,pt.displacementmap,{referencePosition:{value:new j},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:un.distance_vert,fragmentShader:un.distance_frag},shadow:{uniforms:es([pt.lights,pt.fog,{color:{value:new yt(0)},opacity:{value:1}}]),vertexShader:un.shadow_vert,fragmentShader:un.shadow_frag}};qr.physical={uniforms:es([qr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new en},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new en},clearcoatNormalScale:{value:new ze(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new en},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new en},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new en},sheen:{value:0},sheenColor:{value:new yt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new en},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new en},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new en},transmissionSamplerSize:{value:new ze},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new en},attenuationDistance:{value:0},attenuationColor:{value:new yt(0)},specularColor:{value:new yt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new en},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new en},anisotropyVector:{value:new ze},anisotropyMap:{value:null},anisotropyMapTransform:{value:new en}}]),vertexShader:un.meshphysical_vert,fragmentShader:un.meshphysical_frag};const ov={r:0,b:0,g:0},Vc=new Gs,TI=new Xt;function AI(r,e,t,n,s,u,f){const h=new yt(0);let m=u===!0?0:1,g,_,x=null,b=0,M=null;function A(D){let U=D.isScene===!0?D.background:null;return U&&U.isTexture&&(U=(D.backgroundBlurriness>0?t:e).get(U)),U}function R(D){let U=!1;const B=A(D);B===null?E(h,m):B&&B.isColor&&(E(B,1),U=!0);const z=r.xr.getEnvironmentBlendMode();z==="additive"?n.buffers.color.setClear(0,0,0,1,f):z==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,f),(r.autoClear||U)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function w(D,U){const B=A(U);B&&(B.isCubeTexture||B.mapping===id)?(_===void 0&&(_=new Yi(new lf(1,1,1),new yr({name:"BackgroundCubeMaterial",uniforms:Jh(qr.backgroundCube.uniforms),vertexShader:qr.backgroundCube.vertexShader,fragmentShader:qr.backgroundCube.fragmentShader,side:as,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),_.geometry.deleteAttribute("normal"),_.geometry.deleteAttribute("uv"),_.onBeforeRender=function(z,H,W){this.matrixWorld.copyPosition(W.matrixWorld)},Object.defineProperty(_.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(_)),Vc.copy(U.backgroundRotation),Vc.x*=-1,Vc.y*=-1,Vc.z*=-1,B.isCubeTexture&&B.isRenderTargetTexture===!1&&(Vc.y*=-1,Vc.z*=-1),_.material.uniforms.envMap.value=B,_.material.uniforms.flipEnvMap.value=B.isCubeTexture&&B.isRenderTargetTexture===!1?-1:1,_.material.uniforms.backgroundBlurriness.value=U.backgroundBlurriness,_.material.uniforms.backgroundIntensity.value=U.backgroundIntensity,_.material.uniforms.backgroundRotation.value.setFromMatrix4(TI.makeRotationFromEuler(Vc)),_.material.toneMapped=Sn.getTransfer(B.colorSpace)!==zn,(x!==B||b!==B.version||M!==r.toneMapping)&&(_.material.needsUpdate=!0,x=B,b=B.version,M=r.toneMapping),_.layers.enableAll(),D.unshift(_,_.geometry,_.material,0,0,null)):B&&B.isTexture&&(g===void 0&&(g=new Yi(new sd(2,2),new yr({name:"BackgroundMaterial",uniforms:Jh(qr.background.uniforms),vertexShader:qr.background.vertexShader,fragmentShader:qr.background.fragmentShader,side:Ll,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=U.backgroundIntensity,g.material.toneMapped=Sn.getTransfer(B.colorSpace)!==zn,B.matrixAutoUpdate===!0&&B.updateMatrix(),g.material.uniforms.uvTransform.value.copy(B.matrix),(x!==B||b!==B.version||M!==r.toneMapping)&&(g.material.needsUpdate=!0,x=B,b=B.version,M=r.toneMapping),g.layers.enableAll(),D.unshift(g,g.geometry,g.material,0,0,null))}function E(D,U){D.getRGB(ov,GE(r)),n.buffers.color.setClear(ov.r,ov.g,ov.b,U,f)}function N(){_!==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(D,U=1){h.set(D),m=U,E(h,m)},getClearAlpha:function(){return m},setClearAlpha:function(D){m=D,E(h,m)},render:R,addToRenderList:w,dispose:N}}function wI(r,e){const t=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},s=b(null);let u=s,f=!1;function h(P,Z,se,te,fe){let pe=!1;const Y=x(te,se,Z);u!==Y&&(u=Y,g(u.object)),pe=M(P,te,se,fe),pe&&A(P,te,se,fe),fe!==null&&e.update(fe,r.ELEMENT_ARRAY_BUFFER),(pe||f)&&(f=!1,U(P,Z,se,te),fe!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,e.get(fe).buffer))}function m(){return r.createVertexArray()}function g(P){return r.bindVertexArray(P)}function _(P){return r.deleteVertexArray(P)}function x(P,Z,se){const te=se.wireframe===!0;let fe=n[P.id];fe===void 0&&(fe={},n[P.id]=fe);let pe=fe[Z.id];pe===void 0&&(pe={},fe[Z.id]=pe);let Y=pe[te];return Y===void 0&&(Y=b(m()),pe[te]=Y),Y}function b(P){const Z=[],se=[],te=[];for(let fe=0;fe=0){const Ne=fe[ne];let X=pe[ne];if(X===void 0&&(ne==="instanceMatrix"&&P.instanceMatrix&&(X=P.instanceMatrix),ne==="instanceColor"&&P.instanceColor&&(X=P.instanceColor)),Ne===void 0||Ne.attribute!==X||X&&Ne.data!==X.data)return!0;Y++}return u.attributesNum!==Y||u.index!==te}function A(P,Z,se,te){const fe={},pe=Z.attributes;let Y=0;const q=se.getAttributes();for(const ne in q)if(q[ne].location>=0){let Ne=pe[ne];Ne===void 0&&(ne==="instanceMatrix"&&P.instanceMatrix&&(Ne=P.instanceMatrix),ne==="instanceColor"&&P.instanceColor&&(Ne=P.instanceColor));const X={};X.attribute=Ne,Ne&&Ne.data&&(X.data=Ne.data),fe[ne]=X,Y++}u.attributes=fe,u.attributesNum=Y,u.index=te}function R(){const P=u.newAttributes;for(let Z=0,se=P.length;Z=0){let be=fe[q];if(be===void 0&&(q==="instanceMatrix"&&P.instanceMatrix&&(be=P.instanceMatrix),q==="instanceColor"&&P.instanceColor&&(be=P.instanceColor)),be!==void 0){const Ne=be.normalized,X=be.itemSize,oe=e.get(be);if(oe===void 0)continue;const Ae=oe.buffer,Fe=oe.type,lt=oe.bytesPerElement,de=Fe===r.INT||Fe===r.UNSIGNED_INT||be.gpuType===yy;if(be.isInterleavedBufferAttribute){const Re=be.data,tt=Re.stride,st=be.offset;if(Re.isInstancedInterleavedBuffer){for(let ht=0;ht0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";H="mediump"}return H==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let g=t.precision!==void 0?t.precision:"highp";const _=m(g);_!==g&&(ft("WebGLRenderer:",g,"not supported, using",_,"instead."),g=_);const x=t.logarithmicDepthBuffer===!0,b=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),M=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),A=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),R=r.getParameter(r.MAX_TEXTURE_SIZE),w=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),E=r.getParameter(r.MAX_VERTEX_ATTRIBS),N=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),D=r.getParameter(r.MAX_VARYING_VECTORS),U=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),B=r.getParameter(r.MAX_SAMPLES),z=r.getParameter(r.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:w,maxAttributes:E,maxVertexUniforms:N,maxVaryings:D,maxFragmentUniforms:U,maxSamples:B,samples:z}}function NI(r){const e=this;let t=null,n=0,s=!1,u=!1;const f=new wl,h=new en,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||n!==0||s;return s=b,n=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,w=x.clipShadows,E=r.get(x);if(!s||A===null||A.length===0||u&&!w)u?_(null):g();else{const N=u?0:n,D=N*4;let U=E.clippingState||null;m.value=U,U=_(A,b,D,M);for(let B=0;B!==D;++B)U[B]=t[B];E.clippingState=U,this.numIntersection=R?this.numPlanes:0,this.numPlanes+=N}};function g(){m.value!==t&&(m.value=t,m.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function _(x,b,M,A){const R=x!==null?x.length:0;let w=null;if(R!==0){if(w=m.value,A!==!0||w===null){const E=M+R*4,N=b.matrixWorldInverse;h.getNormalMatrix(N),(w===null||w.length0){const g=new Db(m.height);return g.fromEquirectangularTexture(r,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:n,dispose:u}}const Ou=4,c1=[.125,.215,.35,.446,.526,.582],qc=20,LI=256,Wp=new Dl,f1=new yt;let Mx=null,Ex=0,Tx=0,Ax=!1;const UI=new j;class nb{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,n=.1,s=100,u={}){const{size:f=256,position:h=UI}=u;Mx=this._renderer.getRenderTarget(),Ex=this._renderer.getActiveCubeFace(),Tx=this._renderer.getActiveMipmapLevel(),Ax=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(f);const m=this._allocateTargets();return m.depthBuffer=!0,this._sceneToCubeUV(e,n,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=p1(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=d1(),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=N}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===zo||e.mapping===Pu;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=p1()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=d1());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;zh(t,0,0,3*m,2*m),n.setRenderTarget(t),n.render(f,Wp)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let u=1;uA-Ou?n-A+Ou:0),E=4*(this._cubeSize-R);m.envMap.value=e.texture,m.roughness.value=M,m.mipInt.value=A-t,zh(u,w,E,3*R,2*R),s.setRenderTarget(u),s.render(h,Wp),m.envMap.value=u.texture,m.roughness.value=0,m.mipInt.value=A-n,zh(e,w,E,3*R,2*R),s.setRenderTarget(e),s.render(h,Wp)}_blur(e,t,n,s,u){const f=this._pingPongRenderTarget;this._halfBlur(e,f,t,n,s,"latitudinal",u),this._halfBlur(f,e,n,n,s,"longitudinal",u)}_halfBlur(e,t,n,s,u,f,h){const m=this._renderer,g=this._blurMaterial;f!=="latitudinal"&&f!=="longitudinal"&&Rt("blur direction must be either latitudinal or longitudinal!");const _=3,x=this._lodMeshes[s];x.material=g;const b=g.uniforms,M=this._sizeLods[n]-1,A=isFinite(u)?Math.PI/(2*M):2*Math.PI/(2*qc-1),R=u/A,w=isFinite(u)?1+Math.floor(_*R):qc;w>qc&&ft(`sigmaRadians, ${u}, is too large and will clip, as it requested ${w} samples when the maximum is set to ${qc}`);const E=[];let N=0;for(let H=0;HD-Ou?s-D+Ou:0),z=4*(this._cubeSize-U);zh(t,B,z,3*U,2*U),m.setRenderTarget(t),m.render(x,Wp)}}function II(r){const e=[],t=[],n=[];let s=r;const u=r-Ou+1+c1.length;for(let f=0;fr-Ou?m=c1[f-r+Ou-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,w=2,E=1,N=new Float32Array(R*A*M),D=new Float32Array(w*A*M),U=new Float32Array(E*A*M);for(let z=0;z2?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];N.set(I,R*A*z),D.set(b,w*A*z);const P=[z,z,z,z,z,z];U.set(P,E*A*z)}const B=new Kt;B.setAttribute("position",new Xn(N,R)),B.setAttribute("uv",new Xn(D,w)),B.setAttribute("faceIndex",new Xn(U,E)),n.push(new Yi(B,null)),s>Ou&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function h1(r,e,t){const n=new Hs(r,e,t);return n.texture.mapping=id,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function zh(r,e,t,n,s){r.viewport.set(e,t,n,s),r.scissor.set(e,t,n,s)}function OI(r,e,t){return new yr({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:LI,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Qy(),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:Po,depthTest:!1,depthWrite:!1})}function PI(r,e,t){const n=new Float32Array(qc),s=new j(0,1,0);return new yr({name:"SphericalGaussianBlur",defines:{n:qc,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Qy(),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:Po,depthTest:!1,depthWrite:!1})}function d1(){return new yr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Qy(),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:Po,depthTest:!1,depthWrite:!1})}function p1(){return new yr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Qy(),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:Po,depthTest:!1,depthWrite:!1})}function Qy(){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 zI(r){let e=new WeakMap,t=null;function n(h){if(h&&h.isTexture){const m=h.mapping,g=m===om||m===lm,_=m===zo||m===Pu;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 nb(r)),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 nb(r)),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(U/e.maxTextureSize),U=e.maxTextureSize);const z=new Float32Array(U*B*4*x),H=new wy(z,U,B,x);H.type=is,H.needsUpdate=!0;const W=D*4;for(let P=0;P #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 Yi(h,m),_=new Dl(-1,1,1,-1,0,1);let x=null,b=null,M=!1,A,R=null,w=[],E=!1;this.setSize=function(N,D){u.setSize(N,D),f.setSize(N,D);for(let U=0;U0&&w[0].isRenderPass===!0;const D=u.width,U=u.height;for(let B=0;B0)return r;const s=e*t;let u=m1[s];if(u===void 0&&(u=new Float32Array(s),m1[s]=u),e!==0){n.toArray(u,0);for(let f=1,h=0;f!==e;++f)h+=t,r[f].toArray(u,h)}return u}function ea(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t0&&(this.seq=s.concat(u))}setValue(e,t,n,s){const u=this.map[t];u!==void 0&&u.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let u=0,f=t.length;u!==f;++u){const h=t[u],m=n[h.id];m.needsUpdate!==!1&&h.setValue(e,m.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,u=e.length;s!==u;++s){const f=e[s];f.id in t&&n.push(f)}return n}}function b1(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}const PO=37297;let zO=0;function BO(r,e){const t=r.split(` `),n=[],s=Math.max(e-6,0),u=Math.min(e+6,t.length);for(let f=s;f":" "} ${h}: ${t[f]}`)}return n.join(` `)}const S1=new en;function FO(r){Sn._getMatrix(S1,Sn.workingColorSpace,r);const e=`mat3( ${S1.elements.map(t=>t.toFixed(4))} )`;switch(Sn.getTransfer(r)){case dm:return[e,"LinearTransferOETF"];case zn:return[e,"sRGBTransferOETF"];default:return ft("WebGLProgram: Unsupported color space: ",r),[e,"LinearTransferOETF"]}}function M1(r,e,t){const n=r.getShaderParameter(e,r.COMPILE_STATUS),u=(r.getShaderInfoLog(e)||"").trim();if(n&&u==="")return"";const f=/ERROR: 0:(\d+)/.exec(u);if(f){const h=parseInt(f[1]);return t.toUpperCase()+` `+u+` `+BO(r.getShaderSource(e),h)}else return u}function kO(r,e){const t=FO(e);return[`vec4 ${r}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}const VO={[db]:"Linear",[pb]:"Reinhard",[mb]:"Cineon",[gy]:"ACESFilmic",[vb]:"AgX",[yb]:"Neutral",[gb]:"Custom"};function HO(r,e){const t=VO[e];return t===void 0?(ft("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+r+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const lv=new j;function GO(){Sn.getLuminanceCoefficients(lv);const r=lv.x.toFixed(4),e=lv.y.toFixed(4),t=lv.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${r}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function XO(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Qp).join(` `)}function WO(r){const e=[];for(const t in r){const n=r[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` `)}function qO(r,e){const t={},n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function ab(r){return r.replace(jO,ZO)}const YO=new Map;function ZO(r,e){let t=un[e];if(t===void 0){const n=YO.get(e);if(n!==void 0)t=un[n],ft('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return ab(t)}const QO=/#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 A1(r){return r.replace(QO,KO)}function KO(r,e,t,n){let s="";for(let u=parseInt(e);u0&&(w+=` `),E=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,A].filter(Qp).join(` `),E.length>0&&(E+=` `)):(w=[w1(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(Qp).join(` `),E=[w1(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!==gr?"#define TONE_MAPPING":"",t.toneMapping!==gr?un.tonemapping_pars_fragment:"",t.toneMapping!==gr?HO("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",un.colorspace_pars_fragment,kO("linearToOutputTexel",t.outputColorSpace),GO(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Qp).join(` `)),f=ab(f),f=E1(f,t),f=T1(f,t),h=ab(h),h=E1(h,t),h=T1(h,t),f=A1(f),h=A1(h),t.isRawShaderMaterial!==!0&&(N=`#version 300 es `,w=[M,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+w,E=["#define varying in",t.glslVersion===jx?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===jx?"":"#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 D=N+w+f,U=N+E+h,B=b1(s,s.VERTEX_SHADER,D),z=b1(s,s.FRAGMENT_SHADER,U);s.attachShader(R,B),s.attachShader(R,z),t.index0AttributeName!==void 0?s.bindAttribLocation(R,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(R,0,"position"),s.linkProgram(R);function H(Z){if(r.debug.checkShaderErrors){const se=s.getProgramInfoLog(R)||"",te=s.getShaderInfoLog(B)||"",fe=s.getShaderInfoLog(z)||"",pe=se.trim(),Y=te.trim(),q=fe.trim();let ne=!0,be=!0;if(s.getProgramParameter(R,s.LINK_STATUS)===!1)if(ne=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(s,R,B,z);else{const Ne=M1(s,B,"vertex"),X=M1(s,z,"fragment");Rt("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(R,s.VALIDATE_STATUS)+` Material Name: `+Z.name+` Material Type: `+Z.type+` Program Info Log: `+pe+` `+Ne+` `+X)}else pe!==""?ft("WebGLProgram: Program Info Log:",pe):(Y===""||q==="")&&(be=!1);be&&(Z.diagnostics={runnable:ne,programLog:pe,vertexShader:{log:Y,prefix:w},fragmentShader:{log:q,prefix:E}})}s.deleteShader(B),s.deleteShader(z),W=new mv(s,R),I=qO(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 P=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=s.getProgramParameter(R,PO)),P},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(R),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=zO++,this.cacheKey=e,this.usedTimes=1,this.program=R,this.vertexShader=B,this.fragmentShader=z,this}let lP=0;class uP{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,s=this._getShaderStage(t),u=this._getShaderStage(n),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 n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new cP(e),t.set(e,n)),n}}class cP{constructor(e){this.id=lP++,this.code=e,this.usedTimes=0}}function fP(r,e,t,n,s,u,f){const h=new Kh,m=new uP,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 w(I,P,Z,se,te){const fe=se.fog,pe=te.geometry,Y=I.isMeshStandardMaterial?se.environment:null,q=(I.isMeshStandardMaterial?t:e).get(I.envMap||Y),ne=q&&q.mapping===id?q.image.height:null,be=A[I.type];I.precision!==null&&(M=s.getMaxPrecision(I.precision),M!==I.precision&&ft("WebGLProgram.getParameters:",I.precision,"not supported, using",M,"instead."));const Ne=pe.morphAttributes.position||pe.morphAttributes.normal||pe.morphAttributes.color,X=Ne!==void 0?Ne.length:0;let oe=0;pe.morphAttributes.position!==void 0&&(oe=1),pe.morphAttributes.normal!==void 0&&(oe=2),pe.morphAttributes.color!==void 0&&(oe=3);let Ae,Fe,lt,de;if(be){const nn=qr[be];Ae=nn.vertexShader,Fe=nn.fragmentShader}else Ae=I.vertexShader,Fe=I.fragmentShader,m.update(I),lt=m.getVertexShaderID(I),de=m.getFragmentShaderID(I);const Re=r.getRenderTarget(),tt=r.state.buffers.depth.getReversed(),st=te.isInstancedMesh===!0,ht=te.isBatchedMesh===!0,jt=!!I.map,tn=!!I.matcap,Nt=!!q,Le=!!I.aoMap,He=!!I.lightMap,Oe=!!I.bumpMap,nt=!!I.normalMap,Q=!!I.displacementMap,Et=!!I.emissiveMap,ot=!!I.metalnessMap,Tt=!!I.roughnessMap,Qe=I.anisotropy>0,G=I.clearcoat>0,O=I.dispersion>0,ae=I.iridescence>0,Te=I.sheen>0,Ie=I.transmission>0,Ee=Qe&&!!I.anisotropyMap,dt=G&&!!I.clearcoatMap,Ke=G&&!!I.clearcoatNormalMap,vt=G&&!!I.clearcoatRoughnessMap,Dt=ae&&!!I.iridescenceMap,Ve=ae&&!!I.iridescenceThicknessMap,Ze=Te&&!!I.sheenColorMap,ct=Te&&!!I.sheenRoughnessMap,K=!!I.specularMap,me=!!I.specularColorMap,et=!!I.specularIntensityMap,J=Ie&&!!I.transmissionMap,je=Ie&&!!I.thicknessMap,Ge=!!I.gradientMap,at=!!I.alphaMap,Xe=I.alphaTest>0,Ue=!!I.alphaHash,Ye=!!I.extensions;let Ct=gr;I.toneMapped&&(Re===null||Re.isXRRenderTarget===!0)&&(Ct=r.toneMapping);const Jt={shaderID:be,shaderType:I.type,shaderName:I.name,vertexShader:Ae,fragmentShader:Fe,defines:I.defines,customVertexShaderID:lt,customFragmentShaderID:de,isRawShaderMaterial:I.isRawShaderMaterial===!0,glslVersion:I.glslVersion,precision:M,batching:ht,batchingColor:ht&&te._colorsTexture!==null,instancing:st,instancingColor:st&&te.instanceColor!==null,instancingMorph:st&&te.morphTexture!==null,outputColorSpace:Re===null?r.outputColorSpace:Re.isXRRenderTarget===!0?Re.texture.colorSpace:zu,alphaToCoverage:!!I.alphaToCoverage,map:jt,matcap:tn,envMap:Nt,envMapMode:Nt&&q.mapping,envMapCubeUVHeight:ne,aoMap:Le,lightMap:He,bumpMap:Oe,normalMap:nt,displacementMap:Q,emissiveMap:Et,normalMapObjectSpace:nt&&I.normalMapType===DE,normalMapTangentSpace:nt&&I.normalMapType===ku,metalnessMap:ot,roughnessMap:Tt,anisotropy:Qe,anisotropyMap:Ee,clearcoat:G,clearcoatMap:dt,clearcoatNormalMap:Ke,clearcoatRoughnessMap:vt,dispersion:O,iridescence:ae,iridescenceMap:Dt,iridescenceThicknessMap:Ve,sheen:Te,sheenColorMap:Ze,sheenRoughnessMap:ct,specularMap:K,specularColorMap:me,specularIntensityMap:et,transmission:Ie,transmissionMap:J,thicknessMap:je,gradientMap:Ge,opaque:I.transparent===!1&&I.blending===Kc&&I.alphaToCoverage===!1,alphaMap:at,alphaTest:Xe,alphaHash:Ue,combine:I.combine,mapUv:jt&&R(I.map.channel),aoMapUv:Le&&R(I.aoMap.channel),lightMapUv:He&&R(I.lightMap.channel),bumpMapUv:Oe&&R(I.bumpMap.channel),normalMapUv:nt&&R(I.normalMap.channel),displacementMapUv:Q&&R(I.displacementMap.channel),emissiveMapUv:Et&&R(I.emissiveMap.channel),metalnessMapUv:ot&&R(I.metalnessMap.channel),roughnessMapUv:Tt&&R(I.roughnessMap.channel),anisotropyMapUv:Ee&&R(I.anisotropyMap.channel),clearcoatMapUv:dt&&R(I.clearcoatMap.channel),clearcoatNormalMapUv:Ke&&R(I.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:vt&&R(I.clearcoatRoughnessMap.channel),iridescenceMapUv:Dt&&R(I.iridescenceMap.channel),iridescenceThicknessMapUv:Ve&&R(I.iridescenceThicknessMap.channel),sheenColorMapUv:Ze&&R(I.sheenColorMap.channel),sheenRoughnessMapUv:ct&&R(I.sheenRoughnessMap.channel),specularMapUv:K&&R(I.specularMap.channel),specularColorMapUv:me&&R(I.specularColorMap.channel),specularIntensityMapUv:et&&R(I.specularIntensityMap.channel),transmissionMapUv:J&&R(I.transmissionMap.channel),thicknessMapUv:je&&R(I.thicknessMap.channel),alphaMapUv:at&&R(I.alphaMap.channel),vertexTangents:!!pe.attributes.tangent&&(nt||Qe),vertexColors:I.vertexColors,vertexAlphas:I.vertexColors===!0&&!!pe.attributes.color&&pe.attributes.color.itemSize===4,pointsUvs:te.isPoints===!0&&!!pe.attributes.uv&&(jt||at),fog:!!fe,useFog:I.fog===!0,fogExp2:!!fe&&fe.isFogExp2,flatShading:I.flatShading===!0&&I.wireframe===!1,sizeAttenuation:I.sizeAttenuation===!0,logarithmicDepthBuffer:b,reversedDepthBuffer:tt,skinning:te.isSkinnedMesh===!0,morphTargets:pe.morphAttributes.position!==void 0,morphNormals:pe.morphAttributes.normal!==void 0,morphColors:pe.morphAttributes.color!==void 0,morphTargetsCount:X,morphTextureStride:oe,numDirLights:P.directional.length,numPointLights:P.point.length,numSpotLights:P.spot.length,numSpotLightMaps:P.spotLightMap.length,numRectAreaLights:P.rectArea.length,numHemiLights:P.hemi.length,numDirLightShadows:P.directionalShadowMap.length,numPointLightShadows:P.pointShadowMap.length,numSpotLightShadows:P.spotShadowMap.length,numSpotLightShadowsWithMaps:P.numSpotLightShadowsWithMaps,numLightProbes:P.numLightProbes,numClippingPlanes:f.numPlanes,numClipIntersection:f.numIntersection,dithering:I.dithering,shadowMapEnabled:r.shadowMap.enabled&&Z.length>0,shadowMapType:r.shadowMap.type,toneMapping:Ct,decodeVideoTexture:jt&&I.map.isVideoTexture===!0&&Sn.getTransfer(I.map.colorSpace)===zn,decodeVideoTextureEmissive:Et&&I.emissiveMap.isVideoTexture===!0&&Sn.getTransfer(I.emissiveMap.colorSpace)===zn,premultipliedAlpha:I.premultipliedAlpha,doubleSided:I.side===Uo,flipSided:I.side===as,useDepthPacking:I.depthPacking>=0,depthPacking:I.depthPacking||0,index0AttributeName:I.index0AttributeName,extensionClipCullDistance:Ye&&I.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ye&&I.extensions.multiDraw===!0||ht)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:I.customProgramCacheKey()};return Jt.vertexUv1s=g.has(1),Jt.vertexUv2s=g.has(2),Jt.vertexUv3s=g.has(3),g.clear(),Jt}function E(I){const P=[];if(I.shaderID?P.push(I.shaderID):(P.push(I.customVertexShaderID),P.push(I.customFragmentShaderID)),I.defines!==void 0)for(const Z in I.defines)P.push(Z),P.push(I.defines[Z]);return I.isRawShaderMaterial===!1&&(N(P,I),D(P,I),P.push(r.outputColorSpace)),P.push(I.customProgramCacheKey),P.join()}function N(I,P){I.push(P.precision),I.push(P.outputColorSpace),I.push(P.envMapMode),I.push(P.envMapCubeUVHeight),I.push(P.mapUv),I.push(P.alphaMapUv),I.push(P.lightMapUv),I.push(P.aoMapUv),I.push(P.bumpMapUv),I.push(P.normalMapUv),I.push(P.displacementMapUv),I.push(P.emissiveMapUv),I.push(P.metalnessMapUv),I.push(P.roughnessMapUv),I.push(P.anisotropyMapUv),I.push(P.clearcoatMapUv),I.push(P.clearcoatNormalMapUv),I.push(P.clearcoatRoughnessMapUv),I.push(P.iridescenceMapUv),I.push(P.iridescenceThicknessMapUv),I.push(P.sheenColorMapUv),I.push(P.sheenRoughnessMapUv),I.push(P.specularMapUv),I.push(P.specularColorMapUv),I.push(P.specularIntensityMapUv),I.push(P.transmissionMapUv),I.push(P.thicknessMapUv),I.push(P.combine),I.push(P.fogExp2),I.push(P.sizeAttenuation),I.push(P.morphTargetsCount),I.push(P.morphAttributeCount),I.push(P.numDirLights),I.push(P.numPointLights),I.push(P.numSpotLights),I.push(P.numSpotLightMaps),I.push(P.numHemiLights),I.push(P.numRectAreaLights),I.push(P.numDirLightShadows),I.push(P.numPointLightShadows),I.push(P.numSpotLightShadows),I.push(P.numSpotLightShadowsWithMaps),I.push(P.numLightProbes),I.push(P.shadowMapType),I.push(P.toneMapping),I.push(P.numClippingPlanes),I.push(P.numClipIntersection),I.push(P.depthPacking)}function D(I,P){h.disableAll(),P.instancing&&h.enable(0),P.instancingColor&&h.enable(1),P.instancingMorph&&h.enable(2),P.matcap&&h.enable(3),P.envMap&&h.enable(4),P.normalMapObjectSpace&&h.enable(5),P.normalMapTangentSpace&&h.enable(6),P.clearcoat&&h.enable(7),P.iridescence&&h.enable(8),P.alphaTest&&h.enable(9),P.vertexColors&&h.enable(10),P.vertexAlphas&&h.enable(11),P.vertexUv1s&&h.enable(12),P.vertexUv2s&&h.enable(13),P.vertexUv3s&&h.enable(14),P.vertexTangents&&h.enable(15),P.anisotropy&&h.enable(16),P.alphaHash&&h.enable(17),P.batching&&h.enable(18),P.dispersion&&h.enable(19),P.batchingColor&&h.enable(20),P.gradientMap&&h.enable(21),I.push(h.mask),h.disableAll(),P.fog&&h.enable(0),P.useFog&&h.enable(1),P.flatShading&&h.enable(2),P.logarithmicDepthBuffer&&h.enable(3),P.reversedDepthBuffer&&h.enable(4),P.skinning&&h.enable(5),P.morphTargets&&h.enable(6),P.morphNormals&&h.enable(7),P.morphColors&&h.enable(8),P.premultipliedAlpha&&h.enable(9),P.shadowMapEnabled&&h.enable(10),P.doubleSided&&h.enable(11),P.flipSided&&h.enable(12),P.useDepthPacking&&h.enable(13),P.dithering&&h.enable(14),P.transmission&&h.enable(15),P.sheen&&h.enable(16),P.opaque&&h.enable(17),P.pointsUvs&&h.enable(18),P.decodeVideoTexture&&h.enable(19),P.decodeVideoTextureEmissive&&h.enable(20),P.alphaToCoverage&&h.enable(21),I.push(h.mask)}function U(I){const P=A[I.type];let Z;if(P){const se=qr[P];Z=XE.clone(se.uniforms)}else Z=I.uniforms;return Z}function B(I,P){let Z=x.get(P);return Z!==void 0?++Z.usedTimes:(Z=new oP(r,P,I,u),_.push(Z),x.set(P,Z)),Z}function z(I){if(--I.usedTimes===0){const P=_.indexOf(I);_[P]=_[_.length-1],_.pop(),x.delete(I.cacheKey),I.destroy()}}function H(I){m.remove(I)}function W(){m.dispose()}return{getParameters:w,getProgramCacheKey:E,getUniforms:U,acquireProgram:B,releaseProgram:z,releaseShaderCache:H,programs:_,dispose:W}}function hP(){let r=new WeakMap;function e(f){return r.has(f)}function t(f){let h=r.get(f);return h===void 0&&(h={},r.set(f,h)),h}function n(f){r.delete(f)}function s(f,h,m){r.get(f)[h]=m}function u(){r=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:u}}function dP(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function C1(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function R1(){const r=[];let e=0;const t=[],n=[],s=[];function u(){e=0,t.length=0,n.length=0,s.length=0}function f(x,b,M,A,R,w){let E=r[e];return E===void 0?(E={id:x.id,object:x,geometry:b,material:M,groupOrder:A,renderOrder:x.renderOrder,z:R,group:w},r[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=w),e++,E}function h(x,b,M,A,R,w){const E=f(x,b,M,A,R,w);M.transmission>0?n.push(E):M.transparent===!0?s.push(E):t.push(E)}function m(x,b,M,A,R,w){const E=f(x,b,M,A,R,w);M.transmission>0?n.unshift(E):M.transparent===!0?s.unshift(E):t.unshift(E)}function g(x,b){t.length>1&&t.sort(x||dP),n.length>1&&n.sort(b||C1),s.length>1&&s.sort(b||C1)}function _(){for(let x=e,b=r.length;x=u.length?(f=new R1,u.push(f)):f=u[s],f}function t(){r=new WeakMap}return{get:e,dispose:t}}function mP(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new j,color:new yt};break;case"SpotLight":t={position:new j,direction:new j,color:new yt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new j,color:new yt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new j,skyColor:new yt,groundColor:new yt};break;case"RectAreaLight":t={color:new yt,position:new j,halfWidth:new j,halfHeight:new j};break}return r[e.id]=t,t}}}function gP(){const r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}let vP=0;function yP(r,e){return(e.castShadow?2:0)-(r.castShadow?2:0)+(e.map?1:0)-(r.map?1:0)}function _P(r){const e=new mP,t=gP(),n={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++)n.probe.push(new j);const s=new j,u=new Xt,f=new Xt;function h(g){let _=0,x=0,b=0;for(let I=0;I<9;I++)n.probe[I].set(0,0,0);let M=0,A=0,R=0,w=0,E=0,N=0,D=0,U=0,B=0,z=0,H=0;g.sort(yP);for(let I=0,P=g.length;I0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=pt.LTC_FLOAT_1,n.rectAreaLTC2=pt.LTC_FLOAT_2):(n.rectAreaLTC1=pt.LTC_HALF_1,n.rectAreaLTC2=pt.LTC_HALF_2)),n.ambient[0]=_,n.ambient[1]=x,n.ambient[2]=b;const W=n.hash;(W.directionalLength!==M||W.pointLength!==A||W.spotLength!==R||W.rectAreaLength!==w||W.hemiLength!==E||W.numDirectionalShadows!==N||W.numPointShadows!==D||W.numSpotShadows!==U||W.numSpotMaps!==B||W.numLightProbes!==H)&&(n.directional.length=M,n.spot.length=R,n.rectArea.length=w,n.point.length=A,n.hemi.length=E,n.directionalShadow.length=N,n.directionalShadowMap.length=N,n.pointShadow.length=D,n.pointShadowMap.length=D,n.spotShadow.length=U,n.spotShadowMap.length=U,n.directionalShadowMatrix.length=N,n.pointShadowMatrix.length=D,n.spotLightMatrix.length=U+B-z,n.spotLightMap.length=B,n.numSpotLightShadowsWithMaps=z,n.numLightProbes=H,W.directionalLength=M,W.pointLength=A,W.spotLength=R,W.rectAreaLength=w,W.hemiLength=E,W.numDirectionalShadows=N,W.numPointShadows=D,W.numSpotShadows=U,W.numSpotMaps=B,W.numLightProbes=H,n.version=vP++)}function m(g,_){let x=0,b=0,M=0,A=0,R=0;const w=_.matrixWorldInverse;for(let E=0,N=g.length;E=f.length?(h=new N1(r),f.push(h)):h=f[u],h}function n(){e=new WeakMap}return{get:t,dispose:n}}const bP=`void main() { gl_Position = vec4( position, 1.0 ); }`,SP=`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 ); }`,MP=[new j(1,0,0),new j(-1,0,0),new j(0,1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1)],EP=[new j(0,-1,0),new j(0,-1,0),new j(0,0,1),new j(0,0,-1),new j(0,-1,0),new j(0,-1,0)],D1=new Xt,qp=new j,Cx=new j;function TP(r,e,t){let n=new ad;const s=new ze,u=new ze,f=new jn,h=new Wb,m=new qb,g={},_=t.maxTextureSize,x={[Ll]:as,[as]:Ll,[Uo]:Uo},b=new yr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ze},radius:{value:4}},vertexShader:bP,fragmentShader:SP}),M=b.clone();M.defines.HORIZONTAL_PASS=1;const A=new Kt;A.setAttribute("position",new Xn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const R=new Yi(A,b),w=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Xh;let E=this.type;this.render=function(z,H,W){if(w.enabled===!1||w.autoUpdate===!1&&w.needsUpdate===!1||z.length===0)return;z.type===Kp&&(ft("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),z.type=Xh);const I=r.getRenderTarget(),P=r.getActiveCubeFace(),Z=r.getActiveMipmapLevel(),se=r.state;se.setBlending(Po),se.buffers.depth.getReversed()===!0?se.buffers.color.setClear(0,0,0,0):se.buffers.color.setClear(1,1,1,1),se.buffers.depth.setTest(!0),se.setScissorTest(!1);const te=E!==this.type;te&&H.traverse(function(fe){fe.material&&(Array.isArray(fe.material)?fe.material.forEach(pe=>pe.needsUpdate=!0):fe.material.needsUpdate=!0)});for(let fe=0,pe=z.length;fe_||s.y>_)&&(s.x>_&&(u.x=Math.floor(_/ne.x),s.x=u.x*ne.x,q.mapSize.x=u.x),s.y>_&&(u.y=Math.floor(_/ne.y),s.y=u.y*ne.y,q.mapSize.y=u.y)),q.map===null||te===!0){if(q.map!==null&&(q.map.depthTexture!==null&&(q.map.depthTexture.dispose(),q.map.depthTexture=null),q.map.dispose()),this.type===jc){if(Y.isPointLight){ft("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}q.map=new Hs(s.x,s.y,{format:tf,type:Bo,minFilter:oi,magFilter:oi,generateMipmaps:!1}),q.map.texture.name=Y.name+".shadowMap",q.map.depthTexture=new ed(s.x,s.y,is),q.map.depthTexture.name=Y.name+".shadowMapDepth",q.map.depthTexture.format=Fo,q.map.depthTexture.compareFunction=null,q.map.depthTexture.minFilter=Bi,q.map.depthTexture.magFilter=Bi}else{Y.isPointLight?(q.map=new Db(s.x),q.map.depthTexture=new tT(s.x,vr)):(q.map=new Hs(s.x,s.y),q.map.depthTexture=new ed(s.x,s.y,vr)),q.map.depthTexture.name=Y.name+".shadowMap",q.map.depthTexture.format=Fo;const Ne=r.state.buffers.depth.getReversed();this.type===Xh?(q.map.depthTexture.compareFunction=Ne?Ay:Ty,q.map.depthTexture.minFilter=oi,q.map.depthTexture.magFilter=oi):(q.map.depthTexture.compareFunction=null,q.map.depthTexture.minFilter=Bi,q.map.depthTexture.magFilter=Bi)}q.camera.updateProjectionMatrix()}const be=q.map.isWebGLCubeRenderTarget?6:1;for(let Ne=0;Ne0||H.map&&H.alphaTest>0||H.alphaToCoverage===!0){const se=P.uuid,te=H.uuid;let fe=g[se];fe===void 0&&(fe={},g[se]=fe);let pe=fe[te];pe===void 0&&(pe=P.clone(),fe[te]=pe,H.addEventListener("dispose",B)),P=pe}if(P.visible=H.visible,P.wireframe=H.wireframe,I===jc?P.side=H.shadowSide!==null?H.shadowSide:H.side:P.side=H.shadowSide!==null?H.shadowSide:x[H.side],P.alphaMap=H.alphaMap,P.alphaTest=H.alphaToCoverage===!0?.5:H.alphaTest,P.map=H.map,P.clipShadows=H.clipShadows,P.clippingPlanes=H.clippingPlanes,P.clipIntersection=H.clipIntersection,P.displacementMap=H.displacementMap,P.displacementScale=H.displacementScale,P.displacementBias=H.displacementBias,P.wireframeLinewidth=H.wireframeLinewidth,P.linewidth=H.linewidth,W.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const se=r.properties.get(P);se.light=W}return P}function U(z,H,W,I,P){if(z.visible===!1)return;if(z.layers.test(H.layers)&&(z.isMesh||z.isLine||z.isPoints)&&(z.castShadow||z.receiveShadow&&P===jc)&&(!z.frustumCulled||n.intersectsObject(z))){z.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,z.matrixWorld);const te=e.update(z),fe=z.material;if(Array.isArray(fe)){const pe=te.groups;for(let Y=0,q=pe.length;Y=1):ne.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(ne)[1]),Y=q>=2);let be=null,Ne={};const X=r.getParameter(r.SCISSOR_BOX),oe=r.getParameter(r.VIEWPORT),Ae=new jn().fromArray(X),Fe=new jn().fromArray(oe);function lt(J,je,Ge,at){const Xe=new Uint8Array(4),Ue=r.createTexture();r.bindTexture(J,Ue),r.texParameteri(J,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(J,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Ye=0;Ye"u"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new ze,_=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):mm("canvas")}function R(G,O,ae){let Te=1;const Ie=Qe(G);if((Ie.width>ae||Ie.height>ae)&&(Te=ae/Math.max(Ie.width,Ie.height)),Te<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 Ee=Math.floor(Te*Ie.width),dt=Math.floor(Te*Ie.height);x===void 0&&(x=A(Ee,dt));const Ke=O?A(Ee,dt):x;return Ke.width=Ee,Ke.height=dt,Ke.getContext("2d").drawImage(G,0,0,Ee,dt),ft("WebGLRenderer: Texture has been resized from ("+Ie.width+"x"+Ie.height+") to ("+Ee+"x"+dt+")."),Ke}else return"data"in G&&ft("WebGLRenderer: Image in DataTexture is too big ("+Ie.width+"x"+Ie.height+")."),G;return G}function w(G){return G.generateMipmaps}function E(G){r.generateMipmap(G)}function N(G){return G.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:G.isWebGL3DRenderTarget?r.TEXTURE_3D:G.isWebGLArrayRenderTarget||G.isCompressedArrayTexture?r.TEXTURE_2D_ARRAY:r.TEXTURE_2D}function D(G,O,ae,Te,Ie=!1){if(G!==null){if(r[G]!==void 0)return r[G];ft("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+G+"'")}let Ee=O;if(O===r.RED&&(ae===r.FLOAT&&(Ee=r.R32F),ae===r.HALF_FLOAT&&(Ee=r.R16F),ae===r.UNSIGNED_BYTE&&(Ee=r.R8)),O===r.RED_INTEGER&&(ae===r.UNSIGNED_BYTE&&(Ee=r.R8UI),ae===r.UNSIGNED_SHORT&&(Ee=r.R16UI),ae===r.UNSIGNED_INT&&(Ee=r.R32UI),ae===r.BYTE&&(Ee=r.R8I),ae===r.SHORT&&(Ee=r.R16I),ae===r.INT&&(Ee=r.R32I)),O===r.RG&&(ae===r.FLOAT&&(Ee=r.RG32F),ae===r.HALF_FLOAT&&(Ee=r.RG16F),ae===r.UNSIGNED_BYTE&&(Ee=r.RG8)),O===r.RG_INTEGER&&(ae===r.UNSIGNED_BYTE&&(Ee=r.RG8UI),ae===r.UNSIGNED_SHORT&&(Ee=r.RG16UI),ae===r.UNSIGNED_INT&&(Ee=r.RG32UI),ae===r.BYTE&&(Ee=r.RG8I),ae===r.SHORT&&(Ee=r.RG16I),ae===r.INT&&(Ee=r.RG32I)),O===r.RGB_INTEGER&&(ae===r.UNSIGNED_BYTE&&(Ee=r.RGB8UI),ae===r.UNSIGNED_SHORT&&(Ee=r.RGB16UI),ae===r.UNSIGNED_INT&&(Ee=r.RGB32UI),ae===r.BYTE&&(Ee=r.RGB8I),ae===r.SHORT&&(Ee=r.RGB16I),ae===r.INT&&(Ee=r.RGB32I)),O===r.RGBA_INTEGER&&(ae===r.UNSIGNED_BYTE&&(Ee=r.RGBA8UI),ae===r.UNSIGNED_SHORT&&(Ee=r.RGBA16UI),ae===r.UNSIGNED_INT&&(Ee=r.RGBA32UI),ae===r.BYTE&&(Ee=r.RGBA8I),ae===r.SHORT&&(Ee=r.RGBA16I),ae===r.INT&&(Ee=r.RGBA32I)),O===r.RGB&&(ae===r.UNSIGNED_INT_5_9_9_9_REV&&(Ee=r.RGB9_E5),ae===r.UNSIGNED_INT_10F_11F_11F_REV&&(Ee=r.R11F_G11F_B10F)),O===r.RGBA){const dt=Ie?dm:Sn.getTransfer(Te);ae===r.FLOAT&&(Ee=r.RGBA32F),ae===r.HALF_FLOAT&&(Ee=r.RGBA16F),ae===r.UNSIGNED_BYTE&&(Ee=dt===zn?r.SRGB8_ALPHA8:r.RGBA8),ae===r.UNSIGNED_SHORT_4_4_4_4&&(Ee=r.RGBA4),ae===r.UNSIGNED_SHORT_5_5_5_1&&(Ee=r.RGB5_A1)}return(Ee===r.R16F||Ee===r.R32F||Ee===r.RG16F||Ee===r.RG32F||Ee===r.RGBA16F||Ee===r.RGBA32F)&&e.get("EXT_color_buffer_float"),Ee}function U(G,O){let ae;return G?O===null||O===vr||O===jh?ae=r.DEPTH24_STENCIL8:O===is?ae=r.DEPTH32F_STENCIL8:O===qh&&(ae=r.DEPTH24_STENCIL8,ft("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===vr||O===jh?ae=r.DEPTH_COMPONENT24:O===is?ae=r.DEPTH_COMPONENT32F:O===qh&&(ae=r.DEPTH_COMPONENT16),ae}function B(G,O){return w(G)===!0||G.isFramebufferTexture&&G.minFilter!==Bi&&G.minFilter!==oi?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 z(G){const O=G.target;O.removeEventListener("dispose",z),W(O),O.isVideoTexture&&_.delete(O)}function H(G){const O=G.target;O.removeEventListener("dispose",H),P(O)}function W(G){const O=n.get(G);if(O.__webglInit===void 0)return;const ae=G.source,Te=b.get(ae);if(Te){const Ie=Te[O.__cacheKey];Ie.usedTimes--,Ie.usedTimes===0&&I(G),Object.keys(Te).length===0&&b.delete(ae)}n.remove(G)}function I(G){const O=n.get(G);r.deleteTexture(O.__webglTexture);const ae=G.source,Te=b.get(ae);delete Te[O.__cacheKey],f.memory.textures--}function P(G){const O=n.get(G);if(G.depthTexture&&(G.depthTexture.dispose(),n.remove(G.depthTexture)),G.isWebGLCubeRenderTarget)for(let Te=0;Te<6;Te++){if(Array.isArray(O.__webglFramebuffer[Te]))for(let Ie=0;Ie=s.maxTextures&&ft("WebGLTextures: Trying to use "+G+" texture units while this GPU supports only "+s.maxTextures),Z+=1,G}function fe(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 pe(G,O){const ae=n.get(G);if(G.isVideoTexture&&ot(G),G.isRenderTargetTexture===!1&&G.isExternalTexture!==!0&&G.version>0&&ae.__version!==G.version){const Te=G.image;if(Te===null)ft("WebGLRenderer: Texture marked for update but no image data found.");else if(Te.complete===!1)ft("WebGLRenderer: Texture marked for update but image is incomplete");else{de(ae,G,O);return}}else G.isExternalTexture&&(ae.__webglTexture=G.sourceTexture?G.sourceTexture:null);t.bindTexture(r.TEXTURE_2D,ae.__webglTexture,r.TEXTURE0+O)}function Y(G,O){const ae=n.get(G);if(G.isRenderTargetTexture===!1&&G.version>0&&ae.__version!==G.version){de(ae,G,O);return}else G.isExternalTexture&&(ae.__webglTexture=G.sourceTexture?G.sourceTexture:null);t.bindTexture(r.TEXTURE_2D_ARRAY,ae.__webglTexture,r.TEXTURE0+O)}function q(G,O){const ae=n.get(G);if(G.isRenderTargetTexture===!1&&G.version>0&&ae.__version!==G.version){de(ae,G,O);return}t.bindTexture(r.TEXTURE_3D,ae.__webglTexture,r.TEXTURE0+O)}function ne(G,O){const ae=n.get(G);if(G.isCubeDepthTexture!==!0&&G.version>0&&ae.__version!==G.version){Re(ae,G,O);return}t.bindTexture(r.TEXTURE_CUBE_MAP,ae.__webglTexture,r.TEXTURE0+O)}const be={[um]:r.REPEAT,[Rs]:r.CLAMP_TO_EDGE,[cm]:r.MIRRORED_REPEAT},Ne={[Bi]:r.NEAREST,[_b]:r.NEAREST_MIPMAP_NEAREST,[Vh]:r.NEAREST_MIPMAP_LINEAR,[oi]:r.LINEAR,[Jp]:r.LINEAR_MIPMAP_NEAREST,[Io]:r.LINEAR_MIPMAP_LINEAR},X={[LE]:r.NEVER,[zE]:r.ALWAYS,[UE]:r.LESS,[Ty]:r.LEQUAL,[IE]:r.EQUAL,[Ay]:r.GEQUAL,[OE]:r.GREATER,[PE]:r.NOTEQUAL};function oe(G,O){if(O.type===is&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===oi||O.magFilter===Jp||O.magFilter===Vh||O.magFilter===Io||O.minFilter===oi||O.minFilter===Jp||O.minFilter===Vh||O.minFilter===Io)&&ft("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(G,r.TEXTURE_WRAP_S,be[O.wrapS]),r.texParameteri(G,r.TEXTURE_WRAP_T,be[O.wrapT]),(G===r.TEXTURE_3D||G===r.TEXTURE_2D_ARRAY)&&r.texParameteri(G,r.TEXTURE_WRAP_R,be[O.wrapR]),r.texParameteri(G,r.TEXTURE_MAG_FILTER,Ne[O.magFilter]),r.texParameteri(G,r.TEXTURE_MIN_FILTER,Ne[O.minFilter]),O.compareFunction&&(r.texParameteri(G,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(G,r.TEXTURE_COMPARE_FUNC,X[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===Bi||O.minFilter!==Vh&&O.minFilter!==Io||O.type===is&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||n.get(O).__currentAnisotropy){const ae=e.get("EXT_texture_filter_anisotropic");r.texParameterf(G,ae.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,s.getMaxAnisotropy())),n.get(O).__currentAnisotropy=O.anisotropy}}}function Ae(G,O){let ae=!1;G.__webglInit===void 0&&(G.__webglInit=!0,O.addEventListener("dispose",z));const Te=O.source;let Ie=b.get(Te);Ie===void 0&&(Ie={},b.set(Te,Ie));const Ee=fe(O);if(Ee!==G.__cacheKey){Ie[Ee]===void 0&&(Ie[Ee]={texture:r.createTexture(),usedTimes:0},f.memory.textures++,ae=!0),Ie[Ee].usedTimes++;const dt=Ie[G.__cacheKey];dt!==void 0&&(Ie[G.__cacheKey].usedTimes--,dt.usedTimes===0&&I(O)),G.__cacheKey=Ee,G.__webglTexture=Ie[Ee].texture}return ae}function Fe(G,O,ae){return Math.floor(Math.floor(G/ae)/O)}function lt(G,O,ae,Te){const Ee=G.updateRanges;if(Ee.length===0)t.texSubImage2D(r.TEXTURE_2D,0,0,0,O.width,O.height,ae,Te,O.data);else{Ee.sort((Ve,Ze)=>Ve.start-Ze.start);let dt=0;for(let Ve=1;Ve0){J&&je&&t.texStorage2D(r.TEXTURE_2D,at,K,et[0].width,et[0].height);for(let Xe=0,Ue=et.length;Xe0){const Ye=tb(me.width,me.height,O.format,O.type);for(const Ct of O.layerUpdates){const Jt=me.data.subarray(Ct*Ye/me.data.BYTES_PER_ELEMENT,(Ct+1)*Ye/me.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Xe,0,0,Ct,me.width,me.height,1,Ze,Jt)}O.clearLayerUpdates()}else t.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Xe,0,0,0,me.width,me.height,Ve.depth,Ze,me.data)}else t.compressedTexImage3D(r.TEXTURE_2D_ARRAY,Xe,K,me.width,me.height,Ve.depth,0,me.data,0,0);else ft("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else J?Ge&&t.texSubImage3D(r.TEXTURE_2D_ARRAY,Xe,0,0,0,me.width,me.height,Ve.depth,Ze,ct,me.data):t.texImage3D(r.TEXTURE_2D_ARRAY,Xe,K,me.width,me.height,Ve.depth,0,Ze,ct,me.data)}else{J&&je&&t.texStorage2D(r.TEXTURE_2D,at,K,et[0].width,et[0].height);for(let Xe=0,Ue=et.length;Xe0){const Xe=tb(Ve.width,Ve.height,O.format,O.type);for(const Ue of O.layerUpdates){const Ye=Ve.data.subarray(Ue*Xe/Ve.data.BYTES_PER_ELEMENT,(Ue+1)*Xe/Ve.data.BYTES_PER_ELEMENT);t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,Ue,Ve.width,Ve.height,1,Ze,ct,Ye)}O.clearLayerUpdates()}else t.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,Ve.width,Ve.height,Ve.depth,Ze,ct,Ve.data)}else t.texImage3D(r.TEXTURE_2D_ARRAY,0,K,Ve.width,Ve.height,Ve.depth,0,Ze,ct,Ve.data);else if(O.isData3DTexture)J?(je&&t.texStorage3D(r.TEXTURE_3D,at,K,Ve.width,Ve.height,Ve.depth),Ge&&t.texSubImage3D(r.TEXTURE_3D,0,0,0,0,Ve.width,Ve.height,Ve.depth,Ze,ct,Ve.data)):t.texImage3D(r.TEXTURE_3D,0,K,Ve.width,Ve.height,Ve.depth,0,Ze,ct,Ve.data);else if(O.isFramebufferTexture){if(je)if(J)t.texStorage2D(r.TEXTURE_2D,at,K,Ve.width,Ve.height);else{let Xe=Ve.width,Ue=Ve.height;for(let Ye=0;Ye>=1,Ue>>=1}}else if(et.length>0){if(J&&je){const Xe=Qe(et[0]);t.texStorage2D(r.TEXTURE_2D,at,K,Xe.width,Xe.height)}for(let Xe=0,Ue=et.length;Xe0&&at++;const Ue=Qe(Ze[0]);t.texStorage2D(r.TEXTURE_CUBE_MAP,at,et,Ue.width,Ue.height)}for(let Ue=0;Ue<6;Ue++)if(Ve){J?Ge&&t.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,0,0,0,Ze[Ue].width,Ze[Ue].height,K,me,Ze[Ue].data):t.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,0,et,Ze[Ue].width,Ze[Ue].height,0,K,me,Ze[Ue].data);for(let Ye=0;Ye>Ee),ct=Math.max(1,O.height>>Ee);Ie===r.TEXTURE_3D||Ie===r.TEXTURE_2D_ARRAY?t.texImage3D(Ie,Ee,vt,Ze,ct,O.depth,0,dt,Ke,null):t.texImage2D(Ie,Ee,vt,Ze,ct,0,dt,Ke,null)}t.bindFramebuffer(r.FRAMEBUFFER,G),Et(O)?h.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Te,Ie,Ve.__webglTexture,0,Q(O)):(Ie===r.TEXTURE_2D||Ie>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&Ie<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,Te,Ie,Ve.__webglTexture,Ee),t.bindFramebuffer(r.FRAMEBUFFER,null)}function st(G,O,ae){if(r.bindRenderbuffer(r.RENDERBUFFER,G),O.depthBuffer){const Te=O.depthTexture,Ie=Te&&Te.isDepthTexture?Te.type:null,Ee=U(O.stencilBuffer,Ie),dt=O.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT;Et(O)?h.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Q(O),Ee,O.width,O.height):ae?r.renderbufferStorageMultisample(r.RENDERBUFFER,Q(O),Ee,O.width,O.height):r.renderbufferStorage(r.RENDERBUFFER,Ee,O.width,O.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,dt,r.RENDERBUFFER,G)}else{const Te=O.textures;for(let Ie=0;Ie{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,Te.removeEventListener("dispose",Ie)};Te.addEventListener("dispose",Ie),O.__depthDisposeCallback=Ie}O.__boundDepthTexture=Te}if(G.depthTexture&&!O.__autoAllocateDepthBuffer)if(ae)for(let Te=0;Te<6;Te++)ht(O.__webglFramebuffer[Te],G,Te);else{const Te=G.texture.mipmaps;Te&&Te.length>0?ht(O.__webglFramebuffer[0],G,0):ht(O.__webglFramebuffer,G,0)}else if(ae){O.__webglDepthbuffer=[];for(let Te=0;Te<6;Te++)if(t.bindFramebuffer(r.FRAMEBUFFER,O.__webglFramebuffer[Te]),O.__webglDepthbuffer[Te]===void 0)O.__webglDepthbuffer[Te]=r.createRenderbuffer(),st(O.__webglDepthbuffer[Te],G,!1);else{const Ie=G.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Ee=O.__webglDepthbuffer[Te];r.bindRenderbuffer(r.RENDERBUFFER,Ee),r.framebufferRenderbuffer(r.FRAMEBUFFER,Ie,r.RENDERBUFFER,Ee)}}else{const Te=G.texture.mipmaps;if(Te&&Te.length>0?t.bindFramebuffer(r.FRAMEBUFFER,O.__webglFramebuffer[0]):t.bindFramebuffer(r.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=r.createRenderbuffer(),st(O.__webglDepthbuffer,G,!1);else{const Ie=G.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Ee=O.__webglDepthbuffer;r.bindRenderbuffer(r.RENDERBUFFER,Ee),r.framebufferRenderbuffer(r.FRAMEBUFFER,Ie,r.RENDERBUFFER,Ee)}}t.bindFramebuffer(r.FRAMEBUFFER,null)}function tn(G,O,ae){const Te=n.get(G);O!==void 0&&tt(Te.__webglFramebuffer,G,G.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),ae!==void 0&&jt(G)}function Nt(G){const O=G.texture,ae=n.get(G),Te=n.get(O);G.addEventListener("dispose",H);const Ie=G.textures,Ee=G.isWebGLCubeRenderTarget===!0,dt=Ie.length>1;if(dt||(Te.__webglTexture===void 0&&(Te.__webglTexture=r.createTexture()),Te.__version=O.version,f.memory.textures++),Ee){ae.__webglFramebuffer=[];for(let Ke=0;Ke<6;Ke++)if(O.mipmaps&&O.mipmaps.length>0){ae.__webglFramebuffer[Ke]=[];for(let vt=0;vt0){ae.__webglFramebuffer=[];for(let Ke=0;Ke0&&Et(G)===!1){ae.__webglMultisampledFramebuffer=r.createFramebuffer(),ae.__webglColorRenderbuffer=[],t.bindFramebuffer(r.FRAMEBUFFER,ae.__webglMultisampledFramebuffer);for(let Ke=0;Ke0)for(let vt=0;vt0)for(let vt=0;vt0){if(Et(G)===!1){const O=G.textures,ae=G.width,Te=G.height;let Ie=r.COLOR_BUFFER_BIT;const Ee=G.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,dt=n.get(G),Ke=O.length>1;if(Ke)for(let Dt=0;Dt0?t.bindFramebuffer(r.DRAW_FRAMEBUFFER,dt.__webglFramebuffer[0]):t.bindFramebuffer(r.DRAW_FRAMEBUFFER,dt.__webglFramebuffer);for(let Dt=0;Dt0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function ot(G){const O=f.render.frame;_.get(G)!==O&&(_.set(G,O),G.update())}function Tt(G,O){const ae=G.colorSpace,Te=G.format,Ie=G.type;return G.isCompressedTexture===!0||G.isVideoTexture===!0||ae!==zu&&ae!==Cl&&(Sn.getTransfer(ae)===zn?(Te!==Oa||Ie!==ts)&&ft("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Rt("WebGLTextures: Unsupported texture color space:",ae)),O}function Qe(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=te,this.resetTextureUnits=se,this.setTexture2D=pe,this.setTexture2DArray=Y,this.setTexture3D=q,this.setTextureCube=ne,this.rebindTextures=tn,this.setupRenderTarget=Nt,this.updateRenderTargetMipmap=Le,this.updateMultisampleRenderTarget=nt,this.setupDepthRenderbuffer=jt,this.setupFrameBufferTexture=tt,this.useMultisampledRTT=Et,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function qT(r,e){function t(n,s=Cl){let u;const f=Sn.getTransfer(s);if(n===ts)return r.UNSIGNED_BYTE;if(n===_y)return r.UNSIGNED_SHORT_4_4_4_4;if(n===xy)return r.UNSIGNED_SHORT_5_5_5_1;if(n===Sb)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===Mb)return r.UNSIGNED_INT_10F_11F_11F_REV;if(n===xb)return r.BYTE;if(n===bb)return r.SHORT;if(n===qh)return r.UNSIGNED_SHORT;if(n===yy)return r.INT;if(n===vr)return r.UNSIGNED_INT;if(n===is)return r.FLOAT;if(n===Bo)return r.HALF_FLOAT;if(n===Eb)return r.ALPHA;if(n===Tb)return r.RGB;if(n===Oa)return r.RGBA;if(n===Fo)return r.DEPTH_COMPONENT;if(n===Uu)return r.DEPTH_STENCIL;if(n===by)return r.RED;if(n===wm)return r.RED_INTEGER;if(n===tf)return r.RG;if(n===Sy)return r.RG_INTEGER;if(n===My)return r.RGBA_INTEGER;if(n===$p||n===em||n===tm||n===nm)if(f===zn)if(u=e.get("WEBGL_compressed_texture_s3tc_srgb"),u!==null){if(n===$p)return u.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===em)return u.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===tm)return u.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===nm)return u.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(u=e.get("WEBGL_compressed_texture_s3tc"),u!==null){if(n===$p)return u.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===em)return u.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===tm)return u.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===nm)return u.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Av||n===wv||n===Cv||n===Rv)if(u=e.get("WEBGL_compressed_texture_pvrtc"),u!==null){if(n===Av)return u.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===wv)return u.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Cv)return u.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Rv)return u.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Nv||n===Dv||n===Lv||n===Uv||n===Iv||n===Ov||n===Pv)if(u=e.get("WEBGL_compressed_texture_etc"),u!==null){if(n===Nv||n===Dv)return f===zn?u.COMPRESSED_SRGB8_ETC2:u.COMPRESSED_RGB8_ETC2;if(n===Lv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:u.COMPRESSED_RGBA8_ETC2_EAC;if(n===Uv)return u.COMPRESSED_R11_EAC;if(n===Iv)return u.COMPRESSED_SIGNED_R11_EAC;if(n===Ov)return u.COMPRESSED_RG11_EAC;if(n===Pv)return u.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===zv||n===Bv||n===Fv||n===kv||n===Vv||n===Hv||n===Gv||n===Xv||n===Wv||n===qv||n===jv||n===Yv||n===Zv||n===Qv)if(u=e.get("WEBGL_compressed_texture_astc"),u!==null){if(n===zv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:u.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Bv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:u.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Fv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:u.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===kv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:u.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Vv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:u.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Hv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:u.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Gv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:u.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Xv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:u.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Wv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:u.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===qv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:u.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===jv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:u.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Yv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:u.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Zv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:u.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Qv)return f===zn?u.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:u.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Kv||n===Jv||n===$v)if(u=e.get("EXT_texture_compression_bptc"),u!==null){if(n===Kv)return f===zn?u.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:u.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Jv)return u.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===$v)return u.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===ey||n===ty||n===ny||n===iy)if(u=e.get("EXT_texture_compression_rgtc"),u!==null){if(n===ey)return u.COMPRESSED_RED_RGTC1_EXT;if(n===ty)return u.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ny)return u.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===iy)return u.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===jh?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:t}}const RP=` void main() { gl_Position = vec4( position, 1.0 ); }`,NP=` 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 DP{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Pb(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new yr({vertexShader:RP,fragmentShader:NP,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Yi(new sd(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class LP extends ko{constructor(e,t){super();const n=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",w=new DP,E={},N=t.getContextAttributes();let D=null,U=null;const B=[],z=[],H=new ze;let W=null;const I=new zi;I.viewport=new jn;const P=new zi;P.viewport=new jn;const Z=[I,P],se=new OT;let te=null,fe=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(de){let Re=B[de];return Re===void 0&&(Re=new pv,B[de]=Re),Re.getTargetRaySpace()},this.getControllerGrip=function(de){let Re=B[de];return Re===void 0&&(Re=new pv,B[de]=Re),Re.getGripSpace()},this.getHand=function(de){let Re=B[de];return Re===void 0&&(Re=new pv,B[de]=Re),Re.getHandSpace()};function pe(de){const Re=z.indexOf(de.inputSource);if(Re===-1)return;const tt=B[Re];tt!==void 0&&(tt.update(de.inputSource,de.frame,g||f),tt.dispatchEvent({type:de.type,data:de.inputSource}))}function Y(){s.removeEventListener("select",pe),s.removeEventListener("selectstart",pe),s.removeEventListener("selectend",pe),s.removeEventListener("squeeze",pe),s.removeEventListener("squeezestart",pe),s.removeEventListener("squeezeend",pe),s.removeEventListener("end",Y),s.removeEventListener("inputsourceschange",q);for(let de=0;de=0&&(z[st]=null,B[st].disconnect(tt))}for(let Re=0;Re=z.length){z.push(tt),st=jt;break}else if(z[jt]===null){z[jt]=tt,st=jt;break}if(st===-1)break}const ht=B[st];ht&&ht.connect(tt)}}const ne=new j,be=new j;function Ne(de,Re,tt){ne.setFromMatrixPosition(Re.matrixWorld),be.setFromMatrixPosition(tt.matrixWorld);const st=ne.distanceTo(be),ht=Re.projectionMatrix.elements,jt=tt.projectionMatrix.elements,tn=ht[14]/(ht[10]-1),Nt=ht[14]/(ht[10]+1),Le=(ht[9]+1)/ht[5],He=(ht[9]-1)/ht[5],Oe=(ht[8]-1)/ht[0],nt=(jt[8]+1)/jt[0],Q=tn*Oe,Et=tn*nt,ot=st/(-Oe+nt),Tt=ot*-Oe;if(Re.matrixWorld.decompose(de.position,de.quaternion,de.scale),de.translateX(Tt),de.translateZ(ot),de.matrixWorld.compose(de.position,de.quaternion,de.scale),de.matrixWorldInverse.copy(de.matrixWorld).invert(),ht[10]===-1)de.projectionMatrix.copy(Re.projectionMatrix),de.projectionMatrixInverse.copy(Re.projectionMatrixInverse);else{const Qe=tn+ot,G=Nt+ot,O=Q-Tt,ae=Et+(st-Tt),Te=Le*Nt/G*Qe,Ie=He*Nt/G*Qe;de.projectionMatrix.makePerspective(O,ae,Te,Ie,Qe,G),de.projectionMatrixInverse.copy(de.projectionMatrix).invert()}}function X(de,Re){Re===null?de.matrixWorld.copy(de.matrix):de.matrixWorld.multiplyMatrices(Re.matrixWorld,de.matrix),de.matrixWorldInverse.copy(de.matrixWorld).invert()}this.updateCamera=function(de){if(s===null)return;let Re=de.near,tt=de.far;w.texture!==null&&(w.depthNear>0&&(Re=w.depthNear),w.depthFar>0&&(tt=w.depthFar)),se.near=P.near=I.near=Re,se.far=P.far=I.far=tt,(te!==se.near||fe!==se.far)&&(s.updateRenderState({depthNear:se.near,depthFar:se.far}),te=se.near,fe=se.far),se.layers.mask=de.layers.mask|6,I.layers.mask=se.layers.mask&3,P.layers.mask=se.layers.mask&5;const st=de.parent,ht=se.cameras;X(se,st);for(let jt=0;jt0&&(w.alphaTest.value=E.alphaTest);const N=e.get(E),D=N.envMap,U=N.envMapRotation;D&&(w.envMap.value=D,Hc.copy(U),Hc.x*=-1,Hc.y*=-1,Hc.z*=-1,D.isCubeTexture&&D.isRenderTargetTexture===!1&&(Hc.y*=-1,Hc.z*=-1),w.envMapRotation.value.setFromMatrix4(UP.makeRotationFromEuler(Hc)),w.flipEnvMap.value=D.isCubeTexture&&D.isRenderTargetTexture===!1?-1:1,w.reflectivity.value=E.reflectivity,w.ior.value=E.ior,w.refractionRatio.value=E.refractionRatio),E.lightMap&&(w.lightMap.value=E.lightMap,w.lightMapIntensity.value=E.lightMapIntensity,t(E.lightMap,w.lightMapTransform)),E.aoMap&&(w.aoMap.value=E.aoMap,w.aoMapIntensity.value=E.aoMapIntensity,t(E.aoMap,w.aoMapTransform))}function f(w,E){w.diffuse.value.copy(E.color),w.opacity.value=E.opacity,E.map&&(w.map.value=E.map,t(E.map,w.mapTransform))}function h(w,E){w.dashSize.value=E.dashSize,w.totalSize.value=E.dashSize+E.gapSize,w.scale.value=E.scale}function m(w,E,N,D){w.diffuse.value.copy(E.color),w.opacity.value=E.opacity,w.size.value=E.size*N,w.scale.value=D*.5,E.map&&(w.map.value=E.map,t(E.map,w.uvTransform)),E.alphaMap&&(w.alphaMap.value=E.alphaMap,t(E.alphaMap,w.alphaMapTransform)),E.alphaTest>0&&(w.alphaTest.value=E.alphaTest)}function g(w,E){w.diffuse.value.copy(E.color),w.opacity.value=E.opacity,w.rotation.value=E.rotation,E.map&&(w.map.value=E.map,t(E.map,w.mapTransform)),E.alphaMap&&(w.alphaMap.value=E.alphaMap,t(E.alphaMap,w.alphaMapTransform)),E.alphaTest>0&&(w.alphaTest.value=E.alphaTest)}function _(w,E){w.specular.value.copy(E.specular),w.shininess.value=Math.max(E.shininess,1e-4)}function x(w,E){E.gradientMap&&(w.gradientMap.value=E.gradientMap)}function b(w,E){w.metalness.value=E.metalness,E.metalnessMap&&(w.metalnessMap.value=E.metalnessMap,t(E.metalnessMap,w.metalnessMapTransform)),w.roughness.value=E.roughness,E.roughnessMap&&(w.roughnessMap.value=E.roughnessMap,t(E.roughnessMap,w.roughnessMapTransform)),E.envMap&&(w.envMapIntensity.value=E.envMapIntensity)}function M(w,E,N){w.ior.value=E.ior,E.sheen>0&&(w.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),w.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(w.sheenColorMap.value=E.sheenColorMap,t(E.sheenColorMap,w.sheenColorMapTransform)),E.sheenRoughnessMap&&(w.sheenRoughnessMap.value=E.sheenRoughnessMap,t(E.sheenRoughnessMap,w.sheenRoughnessMapTransform))),E.clearcoat>0&&(w.clearcoat.value=E.clearcoat,w.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(w.clearcoatMap.value=E.clearcoatMap,t(E.clearcoatMap,w.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(w.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,t(E.clearcoatRoughnessMap,w.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(w.clearcoatNormalMap.value=E.clearcoatNormalMap,t(E.clearcoatNormalMap,w.clearcoatNormalMapTransform),w.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===as&&w.clearcoatNormalScale.value.negate())),E.dispersion>0&&(w.dispersion.value=E.dispersion),E.iridescence>0&&(w.iridescence.value=E.iridescence,w.iridescenceIOR.value=E.iridescenceIOR,w.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],w.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(w.iridescenceMap.value=E.iridescenceMap,t(E.iridescenceMap,w.iridescenceMapTransform)),E.iridescenceThicknessMap&&(w.iridescenceThicknessMap.value=E.iridescenceThicknessMap,t(E.iridescenceThicknessMap,w.iridescenceThicknessMapTransform))),E.transmission>0&&(w.transmission.value=E.transmission,w.transmissionSamplerMap.value=N.texture,w.transmissionSamplerSize.value.set(N.width,N.height),E.transmissionMap&&(w.transmissionMap.value=E.transmissionMap,t(E.transmissionMap,w.transmissionMapTransform)),w.thickness.value=E.thickness,E.thicknessMap&&(w.thicknessMap.value=E.thicknessMap,t(E.thicknessMap,w.thicknessMapTransform)),w.attenuationDistance.value=E.attenuationDistance,w.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(w.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(w.anisotropyMap.value=E.anisotropyMap,t(E.anisotropyMap,w.anisotropyMapTransform))),w.specularIntensity.value=E.specularIntensity,w.specularColor.value.copy(E.specularColor),E.specularColorMap&&(w.specularColorMap.value=E.specularColorMap,t(E.specularColorMap,w.specularColorMapTransform)),E.specularIntensityMap&&(w.specularIntensityMap.value=E.specularIntensityMap,t(E.specularIntensityMap,w.specularIntensityMapTransform))}function A(w,E){E.matcap&&(w.matcap.value=E.matcap)}function R(w,E){const N=e.get(E).light;w.referencePosition.value.setFromMatrixPosition(N.matrixWorld),w.nearDistance.value=N.shadow.camera.near,w.farDistance.value=N.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function OP(r,e,t,n){let s={},u={},f=[];const h=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function m(N,D){const U=D.program;n.uniformBlockBinding(N,U)}function g(N,D){let U=s[N.id];U===void 0&&(A(N),U=_(N),s[N.id]=U,N.addEventListener("dispose",w));const B=D.program;n.updateUBOMapping(N,B);const z=e.render.frame;u[N.id]!==z&&(b(N),u[N.id]=z)}function _(N){const D=x();N.__bindingPointIndex=D;const U=r.createBuffer(),B=N.__size,z=N.usage;return r.bindBuffer(r.UNIFORM_BUFFER,U),r.bufferData(r.UNIFORM_BUFFER,B,z),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,D,U),U}function x(){for(let N=0;N0&&(U+=B-z),N.__size=U,N.__cache={},this}function R(N){const D={boundary:0,storage:0};return typeof N=="number"||typeof N=="boolean"?(D.boundary=4,D.storage=4):N.isVector2?(D.boundary=8,D.storage=8):N.isVector3||N.isColor?(D.boundary=16,D.storage=12):N.isVector4?(D.boundary=16,D.storage=16):N.isMatrix3?(D.boundary=48,D.storage=48):N.isMatrix4?(D.boundary=64,D.storage=64):N.isTexture?ft("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ft("WebGLRenderer: Unsupported uniform value type.",N),D}function w(N){const D=N.target;D.removeEventListener("dispose",w);const U=f.indexOf(D.__bindingPointIndex);f.splice(U,1),r.deleteBuffer(s[D.id]),delete s[D.id],delete u[D.id]}function E(){for(const N in s)r.deleteBuffer(s[N]);f=[],s={},u={}}return{bind:m,update:g,dispose:E}}const PP=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 Lo=null;function zP(){return Lo===null&&(Lo=new Yr(PP,16,16,tf,Bo),Lo.name="DFG_LUT",Lo.minFilter=oi,Lo.magFilter=oi,Lo.wrapS=Rs,Lo.wrapT=Rs,Lo.generateMipmaps=!1,Lo.needsUpdate=!0),Lo}class jT{constructor(e={}){const{canvas:t=kE(),context:n=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=ts}=e;this.isWebGLRenderer=!0;let A;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");A=n.getContextAttributes().alpha}else A=f;const R=M,w=new Set([My,Sy,wm]),E=new Set([ts,vr,qh,jh,_y,xy]),N=new Uint32Array(4),D=new Int32Array(4);let U=null,B=null;const z=[],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=gr,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let P=!1;this._outputColorSpace=Ia;let Z=0,se=0,te=null,fe=-1,pe=null;const Y=new jn,q=new jn;let ne=null;const be=new yt(0);let Ne=0,X=t.width,oe=t.height,Ae=1,Fe=null,lt=null;const de=new jn(0,0,X,oe),Re=new jn(0,0,X,oe);let tt=!1;const st=new ad;let ht=!1,jt=!1;const tn=new Xt,Nt=new j,Le=new jn,He={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Oe=!1;function nt(){return te===null?Ae:1}let Q=n;function Et(k,re){return t.getContext(k,re)}try{const k={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${my}`),t.addEventListener("webglcontextlost",Ct,!1),t.addEventListener("webglcontextrestored",Jt,!1),t.addEventListener("webglcontextcreationerror",nn,!1),Q===null){const re="webgl2";if(Q=Et(re,k),Q===null)throw Et(re)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(k){throw Rt("WebGLRenderer: "+k.message),k}let ot,Tt,Qe,G,O,ae,Te,Ie,Ee,dt,Ke,vt,Dt,Ve,Ze,ct,K,me,et,J,je,Ge,at,Xe;function Ue(){ot=new BI(Q),ot.init(),Ge=new qT(Q,ot),Tt=new RI(Q,ot,e,Ge),Qe=new wP(Q,ot),Tt.reversedDepthBuffer&&b&&Qe.buffers.depth.setReversed(!0),G=new VI(Q),O=new hP,ae=new CP(Q,ot,Qe,O,Tt,Ge,G),Te=new DI(I),Ie=new zI(I),Ee=new WD(Q),at=new wI(Q,Ee),dt=new FI(Q,Ee,G,at),Ke=new GI(Q,dt,Ee,G),et=new HI(Q,Tt,ae),ct=new NI(O),vt=new fP(I,Te,Ie,ot,Tt,at,ct),Dt=new IP(I,O),Ve=new pP,Ze=new xP(ot),me=new AI(I,Te,Ie,Qe,Ke,A,m),K=new TP(I,Ke,Tt),Xe=new OP(Q,G,Tt,Qe),J=new CI(Q,ot,G),je=new kI(Q,ot,G),G.programs=vt.programs,I.capabilities=Tt,I.extensions=ot,I.properties=O,I.renderLists=Ve,I.shadowMap=K,I.state=Qe,I.info=G}Ue(),R!==ts&&(W=new WI(R,t.width,t.height,s,u));const Ye=new LP(I,Q);this.xr=Ye,this.getContext=function(){return Q},this.getContextAttributes=function(){return Q.getContextAttributes()},this.forceContextLoss=function(){const k=ot.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){const k=ot.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return Ae},this.setPixelRatio=function(k){k!==void 0&&(Ae=k,this.setSize(X,oe,!1))},this.getSize=function(k){return k.set(X,oe)},this.setSize=function(k,re,Se=!0){if(Ye.isPresenting){ft("WebGLRenderer: Can't change size while VR device is presenting.");return}X=k,oe=re,t.width=Math.floor(k*Ae),t.height=Math.floor(re*Ae),Se===!0&&(t.style.width=k+"px",t.style.height=re+"px"),W!==null&&W.setSize(t.width,t.height),this.setViewport(0,0,k,re)},this.getDrawingBufferSize=function(k){return k.set(X*Ae,oe*Ae).floor()},this.setDrawingBufferSize=function(k,re,Se){X=k,oe=re,Ae=Se,t.width=Math.floor(k*Se),t.height=Math.floor(re*Se),this.setViewport(0,0,k,re)},this.setEffects=function(k){if(R===ts){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(k){for(let re=0;re{function Je(){if(ye.forEach(function(mt){O.get(mt).currentProgram.isReady()&&ye.delete(mt)}),ye.size===0){ue(k);return}setTimeout(Je,10)}ot.get("KHR_parallel_shader_compile")!==null?Je():setTimeout(Je,10)})};let Ho=null;function Jr(k){Ho&&Ho(k)}function xr(){na.stop()}function Go(){na.start()}const na=new VT;na.setAnimationLoop(Jr),typeof self<"u"&&na.setContext(self),this.setAnimationLoop=function(k){Ho=k,Ye.setAnimationLoop(k),k===null?na.stop():na.start()},Ye.addEventListener("sessionstart",xr),Ye.addEventListener("sessionend",Go),this.render=function(k,re){if(re!==void 0&&re.isCamera!==!0){Rt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;const Se=Ye.enabled===!0&&Ye.isPresenting===!0,ye=W!==null&&(te===null||Se)&&W.begin(I,te);if(k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),re.parent===null&&re.matrixWorldAutoUpdate===!0&&re.updateMatrixWorld(),Ye.enabled===!0&&Ye.isPresenting===!0&&(W===null||W.isCompositing()===!1)&&(Ye.cameraAutoUpdate===!0&&Ye.updateCamera(re),re=Ye.getCamera()),k.isScene===!0&&k.onBeforeRender(I,k,re,te),B=Ze.get(k,H.length),B.init(re),H.push(B),tn.multiplyMatrices(re.projectionMatrix,re.matrixWorldInverse),st.setFromProjectionMatrix(tn,ks,re.reversedDepth),jt=this.localClippingEnabled,ht=ct.init(this.clippingPlanes,jt),U=Ve.get(k,z.length),U.init(),z.push(U),Ye.enabled===!0&&Ye.isPresenting===!0){const mt=I.xr.getDepthSensingMesh();mt!==null&&Fa(mt,re,-1/0,I.sortObjects)}Fa(k,re,0,I.sortObjects),U.finish(),I.sortObjects===!0&&U.sort(Fe,lt),Oe=Ye.enabled===!1||Ye.isPresenting===!1||Ye.hasDepthSensing()===!1,Oe&&me.addToRenderList(U,k),this.info.render.frame++,ht===!0&&ct.beginShadows();const ue=B.state.shadowsArray;if(K.render(ue,k,re),ht===!0&&ct.endShadows(),this.info.autoReset===!0&&this.info.reset(),(ye&&W.hasRenderPass())===!1){const mt=U.opaque,qe=U.transmissive;if(B.setupLights(),re.isArrayCamera){const _t=re.cameras;if(qe.length>0)for(let xt=0,Lt=_t.length;xt0&&Ri(mt,qe,k,re),Oe&&me.render(k),$n(U,k,re)}te!==null&&se===0&&(ae.updateMultisampleRenderTarget(te),ae.updateRenderTargetMipmap(te)),ye&&W.end(I),k.isScene===!0&&k.onAfterRender(I,k,re),at.resetDefaultState(),fe=-1,pe=null,H.pop(),H.length>0?(B=H[H.length-1],ht===!0&&ct.setGlobalState(I.clippingPlanes,B.state.camera)):B=null,z.pop(),z.length>0?U=z[z.length-1]:U=null};function Fa(k,re,Se,ye){if(k.visible===!1)return;if(k.layers.test(re.layers)){if(k.isGroup)Se=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(re);else if(k.isLight)B.pushLight(k),k.castShadow&&B.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||st.intersectsSprite(k)){ye&&Le.setFromMatrixPosition(k.matrixWorld).applyMatrix4(tn);const mt=Ke.update(k),qe=k.material;qe.visible&&U.push(k,mt,qe,Se,Le.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(!k.frustumCulled||st.intersectsObject(k))){const mt=Ke.update(k),qe=k.material;if(ye&&(k.boundingSphere!==void 0?(k.boundingSphere===null&&k.computeBoundingSphere(),Le.copy(k.boundingSphere.center)):(mt.boundingSphere===null&&mt.computeBoundingSphere(),Le.copy(mt.boundingSphere.center)),Le.applyMatrix4(k.matrixWorld).applyMatrix4(tn)),Array.isArray(qe)){const _t=mt.groups;for(let xt=0,Lt=_t.length;xt0&&ka(ue,re,Se),Je.length>0&&ka(Je,re,Se),mt.length>0&&ka(mt,re,Se),Qe.buffers.depth.setTest(!0),Qe.buffers.depth.setMask(!0),Qe.buffers.color.setMask(!0),Qe.setPolygonOffset(!1)}function Ri(k,re,Se,ye){if((Se.isScene===!0?Se.overrideMaterial:null)!==null)return;if(B.state.transmissionRenderTarget[ye.id]===void 0){const Pt=ot.has("EXT_color_buffer_half_float")||ot.has("EXT_color_buffer_float");B.state.transmissionRenderTarget[ye.id]=new Hs(1,1,{generateMipmaps:!0,type:Pt?Bo:ts,minFilter:Io,samples:Tt.samples,stencilBuffer:u,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Sn.workingColorSpace})}const Je=B.state.transmissionRenderTarget[ye.id],mt=ye.viewport||Y;Je.setSize(mt.z*I.transmissionResolutionScale,mt.w*I.transmissionResolutionScale);const qe=I.getRenderTarget(),_t=I.getActiveCubeFace(),xt=I.getActiveMipmapLevel();I.setRenderTarget(Je),I.getClearColor(be),Ne=I.getClearAlpha(),Ne<1&&I.setClearColor(16777215,.5),I.clear(),Oe&&me.render(Se);const Lt=I.toneMapping;I.toneMapping=gr;const St=ye.viewport;if(ye.viewport!==void 0&&(ye.viewport=void 0),B.setupLightsView(ye),ht===!0&&ct.setGlobalState(I.clippingPlanes,ye),ka(k,Se,ye),ae.updateMultisampleRenderTarget(Je),ae.updateRenderTargetMipmap(Je),ot.has("WEBGL_multisampled_render_to_texture")===!1){let Pt=!1;for(let Mn=0,Bn=re.length;Mn0),St=!!Se.morphAttributes.position,Pt=!!Se.morphAttributes.normal,Mn=!!Se.morphAttributes.color;let Bn=gr;ye.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(Bn=I.toneMapping);const In=Se.morphAttributes.position||Se.morphAttributes.normal||Se.morphAttributes.color,Wt=In!==void 0?In.length:0,ut=O.get(ye),_n=B.state.lights;if(ht===!0&&(jt===!0||k!==pe)){const Fi=k===pe&&ye.id===fe;ct.setState(ye,k,Fi)}let Ft=!1;ye.version===ut.__version?(ut.needsLights&&ut.lightsStateVersion!==_n.state.version||ut.outputColorSpace!==qe||ue.isBatchedMesh&&ut.batching===!1||!ue.isBatchedMesh&&ut.batching===!0||ue.isBatchedMesh&&ut.batchingColor===!0&&ue.colorTexture===null||ue.isBatchedMesh&&ut.batchingColor===!1&&ue.colorTexture!==null||ue.isInstancedMesh&&ut.instancing===!1||!ue.isInstancedMesh&&ut.instancing===!0||ue.isSkinnedMesh&&ut.skinning===!1||!ue.isSkinnedMesh&&ut.skinning===!0||ue.isInstancedMesh&&ut.instancingColor===!0&&ue.instanceColor===null||ue.isInstancedMesh&&ut.instancingColor===!1&&ue.instanceColor!==null||ue.isInstancedMesh&&ut.instancingMorph===!0&&ue.morphTexture===null||ue.isInstancedMesh&&ut.instancingMorph===!1&&ue.morphTexture!==null||ut.envMap!==_t||ye.fog===!0&&ut.fog!==Je||ut.numClippingPlanes!==void 0&&(ut.numClippingPlanes!==ct.numPlanes||ut.numIntersection!==ct.numIntersection)||ut.vertexAlphas!==xt||ut.vertexTangents!==Lt||ut.morphTargets!==St||ut.morphNormals!==Pt||ut.morphColors!==Mn||ut.toneMapping!==Bn||ut.morphTargetsCount!==Wt)&&(Ft=!0):(Ft=!0,ut.__version=ye.version);let xi=ut.currentProgram;Ft===!0&&(xi=Ha(ye,re,ue));let Ls=!1,Wn=!1,la=!1;const An=xi.getUniforms(),Ni=ut.uniforms;if(Qe.useProgram(xi.program)&&(Ls=!0,Wn=!0,la=!0),ye.id!==fe&&(fe=ye.id,Wn=!0),Ls||pe!==k){Qe.buffers.depth.getReversed()&&k.reversedDepth!==!0&&(k._reversedDepth=!0,k.updateProjectionMatrix()),An.setValue(Q,"projectionMatrix",k.projectionMatrix),An.setValue(Q,"viewMatrix",k.matrixWorldInverse);const ki=An.map.cameraPosition;ki!==void 0&&ki.setValue(Q,Nt.setFromMatrixPosition(k.matrixWorld)),Tt.logarithmicDepthBuffer&&An.setValue(Q,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),(ye.isMeshPhongMaterial||ye.isMeshToonMaterial||ye.isMeshLambertMaterial||ye.isMeshBasicMaterial||ye.isMeshStandardMaterial||ye.isShaderMaterial)&&An.setValue(Q,"isOrthographic",k.isOrthographicCamera===!0),pe!==k&&(pe=k,Wn=!0,la=!0)}if(ut.needsLights&&(_n.state.directionalShadowMap.length>0&&An.setValue(Q,"directionalShadowMap",_n.state.directionalShadowMap,ae),_n.state.spotShadowMap.length>0&&An.setValue(Q,"spotShadowMap",_n.state.spotShadowMap,ae),_n.state.pointShadowMap.length>0&&An.setValue(Q,"pointShadowMap",_n.state.pointShadowMap,ae)),ue.isSkinnedMesh){An.setOptional(Q,ue,"bindMatrix"),An.setOptional(Q,ue,"bindMatrixInverse");const Fi=ue.skeleton;Fi&&(Fi.boneTexture===null&&Fi.computeBoneTexture(),An.setValue(Q,"boneTexture",Fi.boneTexture,ae))}ue.isBatchedMesh&&(An.setOptional(Q,ue,"batchingTexture"),An.setValue(Q,"batchingTexture",ue._matricesTexture,ae),An.setOptional(Q,ue,"batchingIdTexture"),An.setValue(Q,"batchingIdTexture",ue._indirectTexture,ae),An.setOptional(Q,ue,"batchingColorTexture"),ue._colorsTexture!==null&&An.setValue(Q,"batchingColorTexture",ue._colorsTexture,ae));const bi=Se.morphAttributes;if((bi.position!==void 0||bi.normal!==void 0||bi.color!==void 0)&&et.update(ue,Se,xi),(Wn||ut.receiveShadow!==ue.receiveShadow)&&(ut.receiveShadow=ue.receiveShadow,An.setValue(Q,"receiveShadow",ue.receiveShadow)),ye.isMeshGouraudMaterial&&ye.envMap!==null&&(Ni.envMap.value=_t,Ni.flipEnvMap.value=_t.isCubeTexture&&_t.isRenderTargetTexture===!1?-1:1),ye.isMeshStandardMaterial&&ye.envMap===null&&re.environment!==null&&(Ni.envMapIntensity.value=re.environmentIntensity),Ni.dfgLUT!==void 0&&(Ni.dfgLUT.value=zP()),Wn&&(An.setValue(Q,"toneMappingExposure",I.toneMappingExposure),ut.needsLights&&br(Ni,la),Je&&ye.fog===!0&&Dt.refreshFogUniforms(Ni,Je),Dt.refreshMaterialUniforms(Ni,ye,Ae,oe,B.state.transmissionRenderTarget[k.id]),mv.upload(Q,$r(ut),Ni,ae)),ye.isShaderMaterial&&ye.uniformsNeedUpdate===!0&&(mv.upload(Q,$r(ut),Ni,ae),ye.uniformsNeedUpdate=!1),ye.isSpriteMaterial&&An.setValue(Q,"center",ue.center),An.setValue(Q,"modelViewMatrix",ue.modelViewMatrix),An.setValue(Q,"normalMatrix",ue.normalMatrix),An.setValue(Q,"modelMatrix",ue.matrixWorld),ye.isShaderMaterial||ye.isRawShaderMaterial){const Fi=ye.uniformsGroups;for(let ki=0,Wo=Fi.length;ki0&&ae.useMultisampledRTT(k)===!1?ye=O.get(k).__webglMultisampledFramebuffer:Array.isArray(xt)?ye=xt[Se]:ye=xt,Y.copy(k.viewport),q.copy(k.scissor),ne=k.scissorTest}else Y.copy(de).multiplyScalar(Ae).floor(),q.copy(Re).multiplyScalar(Ae).floor(),ne=tt;if(Se!==0&&(ye=Mr),Qe.bindFramebuffer(Q.FRAMEBUFFER,ye)&&Qe.drawBuffers(k,ye),Qe.viewport(Y),Qe.scissor(q),Qe.setScissorTest(ne),ue){const qe=O.get(k.texture);Q.framebufferTexture2D(Q.FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_CUBE_MAP_POSITIVE_X+re,qe.__webglTexture,Se)}else if(Je){const qe=re;for(let _t=0;_t=0&&re<=k.width-ye&&Se>=0&&Se<=k.height-ue&&(k.textures.length>1&&Q.readBuffer(Q.COLOR_ATTACHMENT0+qe),Q.readPixels(re,Se,ye,ue,Ge.convert(Lt),Ge.convert(St),Je))}finally{const xt=te!==null?O.get(te).__webglFramebuffer:null;Qe.bindFramebuffer(Q.FRAMEBUFFER,xt)}}},this.readRenderTargetPixelsAsync=async function(k,re,Se,ye,ue,Je,mt,qe=0){if(!(k&&k.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let _t=O.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&mt!==void 0&&(_t=_t[mt]),_t)if(re>=0&&re<=k.width-ye&&Se>=0&&Se<=k.height-ue){Qe.bindFramebuffer(Q.FRAMEBUFFER,_t);const xt=k.textures[qe],Lt=xt.format,St=xt.type;if(!Tt.textureFormatReadable(Lt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Tt.textureTypeReadable(St))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Pt=Q.createBuffer();Q.bindBuffer(Q.PIXEL_PACK_BUFFER,Pt),Q.bufferData(Q.PIXEL_PACK_BUFFER,Je.byteLength,Q.STREAM_READ),k.textures.length>1&&Q.readBuffer(Q.COLOR_ATTACHMENT0+qe),Q.readPixels(re,Se,ye,ue,Ge.convert(Lt),Ge.convert(St),0);const Mn=te!==null?O.get(te).__webglFramebuffer:null;Qe.bindFramebuffer(Q.FRAMEBUFFER,Mn);const Bn=Q.fenceSync(Q.SYNC_GPU_COMMANDS_COMPLETE,0);return Q.flush(),await q3(Q,Bn,4),Q.bindBuffer(Q.PIXEL_PACK_BUFFER,Pt),Q.getBufferSubData(Q.PIXEL_PACK_BUFFER,0,Je),Q.deleteBuffer(Pt),Q.deleteSync(Bn),Je}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(k,re=null,Se=0){const ye=Math.pow(2,-Se),ue=Math.floor(k.image.width*ye),Je=Math.floor(k.image.height*ye),mt=re!==null?re.x:0,qe=re!==null?re.y:0;ae.setTexture2D(k,0),Q.copyTexSubImage2D(Q.TEXTURE_2D,Se,0,0,mt,qe,ue,Je),Qe.unbindTexture()};const eo=Q.createFramebuffer(),Xs=Q.createFramebuffer();this.copyTextureToTexture=function(k,re,Se=null,ye=null,ue=0,Je=null){Je===null&&(ue!==0?(Zh("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Je=ue,ue=0):Je=0);let mt,qe,_t,xt,Lt,St,Pt,Mn,Bn;const In=k.isCompressedTexture?k.mipmaps[Je]:k.image;if(Se!==null)mt=Se.max.x-Se.min.x,qe=Se.max.y-Se.min.y,_t=Se.isBox3?Se.max.z-Se.min.z:1,xt=Se.min.x,Lt=Se.min.y,St=Se.isBox3?Se.min.z:0;else{const bi=Math.pow(2,-ue);mt=Math.floor(In.width*bi),qe=Math.floor(In.height*bi),k.isDataArrayTexture?_t=In.depth:k.isData3DTexture?_t=Math.floor(In.depth*bi):_t=1,xt=0,Lt=0,St=0}ye!==null?(Pt=ye.x,Mn=ye.y,Bn=ye.z):(Pt=0,Mn=0,Bn=0);const Wt=Ge.convert(re.format),ut=Ge.convert(re.type);let _n;re.isData3DTexture?(ae.setTexture3D(re,0),_n=Q.TEXTURE_3D):re.isDataArrayTexture||re.isCompressedArrayTexture?(ae.setTexture2DArray(re,0),_n=Q.TEXTURE_2D_ARRAY):(ae.setTexture2D(re,0),_n=Q.TEXTURE_2D),Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL,re.flipY),Q.pixelStorei(Q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,re.premultiplyAlpha),Q.pixelStorei(Q.UNPACK_ALIGNMENT,re.unpackAlignment);const Ft=Q.getParameter(Q.UNPACK_ROW_LENGTH),xi=Q.getParameter(Q.UNPACK_IMAGE_HEIGHT),Ls=Q.getParameter(Q.UNPACK_SKIP_PIXELS),Wn=Q.getParameter(Q.UNPACK_SKIP_ROWS),la=Q.getParameter(Q.UNPACK_SKIP_IMAGES);Q.pixelStorei(Q.UNPACK_ROW_LENGTH,In.width),Q.pixelStorei(Q.UNPACK_IMAGE_HEIGHT,In.height),Q.pixelStorei(Q.UNPACK_SKIP_PIXELS,xt),Q.pixelStorei(Q.UNPACK_SKIP_ROWS,Lt),Q.pixelStorei(Q.UNPACK_SKIP_IMAGES,St);const An=k.isDataArrayTexture||k.isData3DTexture,Ni=re.isDataArrayTexture||re.isData3DTexture;if(k.isDepthTexture){const bi=O.get(k),Fi=O.get(re),ki=O.get(bi.__renderTarget),Wo=O.get(Fi.__renderTarget);Qe.bindFramebuffer(Q.READ_FRAMEBUFFER,ki.__webglFramebuffer),Qe.bindFramebuffer(Q.DRAW_FRAMEBUFFER,Wo.__webglFramebuffer);for(let rs=0;rs<_t;rs++)An&&(Q.framebufferTextureLayer(Q.READ_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,O.get(k).__webglTexture,ue,St+rs),Q.framebufferTextureLayer(Q.DRAW_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,O.get(re).__webglTexture,Je,Bn+rs)),Q.blitFramebuffer(xt,Lt,mt,qe,Pt,Mn,mt,qe,Q.DEPTH_BUFFER_BIT,Q.NEAREST);Qe.bindFramebuffer(Q.READ_FRAMEBUFFER,null),Qe.bindFramebuffer(Q.DRAW_FRAMEBUFFER,null)}else if(ue!==0||k.isRenderTargetTexture||O.has(k)){const bi=O.get(k),Fi=O.get(re);Qe.bindFramebuffer(Q.READ_FRAMEBUFFER,eo),Qe.bindFramebuffer(Q.DRAW_FRAMEBUFFER,Xs);for(let ki=0;ki<_t;ki++)An?Q.framebufferTextureLayer(Q.READ_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,bi.__webglTexture,ue,St+ki):Q.framebufferTexture2D(Q.READ_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_2D,bi.__webglTexture,ue),Ni?Q.framebufferTextureLayer(Q.DRAW_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Fi.__webglTexture,Je,Bn+ki):Q.framebufferTexture2D(Q.DRAW_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_2D,Fi.__webglTexture,Je),ue!==0?Q.blitFramebuffer(xt,Lt,mt,qe,Pt,Mn,mt,qe,Q.COLOR_BUFFER_BIT,Q.NEAREST):Ni?Q.copyTexSubImage3D(_n,Je,Pt,Mn,Bn+ki,xt,Lt,mt,qe):Q.copyTexSubImage2D(_n,Je,Pt,Mn,xt,Lt,mt,qe);Qe.bindFramebuffer(Q.READ_FRAMEBUFFER,null),Qe.bindFramebuffer(Q.DRAW_FRAMEBUFFER,null)}else Ni?k.isDataTexture||k.isData3DTexture?Q.texSubImage3D(_n,Je,Pt,Mn,Bn,mt,qe,_t,Wt,ut,In.data):re.isCompressedArrayTexture?Q.compressedTexSubImage3D(_n,Je,Pt,Mn,Bn,mt,qe,_t,Wt,In.data):Q.texSubImage3D(_n,Je,Pt,Mn,Bn,mt,qe,_t,Wt,ut,In):k.isDataTexture?Q.texSubImage2D(Q.TEXTURE_2D,Je,Pt,Mn,mt,qe,Wt,ut,In.data):k.isCompressedTexture?Q.compressedTexSubImage2D(Q.TEXTURE_2D,Je,Pt,Mn,In.width,In.height,Wt,In.data):Q.texSubImage2D(Q.TEXTURE_2D,Je,Pt,Mn,mt,qe,Wt,ut,In);Q.pixelStorei(Q.UNPACK_ROW_LENGTH,Ft),Q.pixelStorei(Q.UNPACK_IMAGE_HEIGHT,xi),Q.pixelStorei(Q.UNPACK_SKIP_PIXELS,Ls),Q.pixelStorei(Q.UNPACK_SKIP_ROWS,Wn),Q.pixelStorei(Q.UNPACK_SKIP_IMAGES,la),Je===0&&re.generateMipmaps&&Q.generateMipmap(_n),Qe.unbindTexture()},this.initRenderTarget=function(k){O.get(k).__webglFramebuffer===void 0&&ae.setupRenderTarget(k)},this.initTexture=function(k){k.isCubeTexture?ae.setTextureCube(k,0):k.isData3DTexture?ae.setTexture3D(k,0):k.isDataArrayTexture||k.isCompressedArrayTexture?ae.setTexture2DArray(k,0):ae.setTexture2D(k,0),Qe.unbindTexture()},this.resetState=function(){Z=0,se=0,te=null,Qe.reset(),at.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ks}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Sn._getDrawingBufferColorSpace(e),t.unpackColorSpace=Sn._getUnpackColorSpace()}}const BP=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:gy,AddEquation:Du,AddOperation:TE,AdditiveAnimationBlendMode:Ab,AdditiveBlending:Hx,AgXToneMapping:vb,AlphaFormat:Eb,AlwaysCompare:zE,AlwaysDepth:xv,AlwaysStencilFunc:qx,AmbientLight:NT,AnimationAction:BT,AnimationClip:Sm,AnimationLoader:PN,AnimationMixer:fD,AnimationObjectGroup:uD,AnimationUtils:LN,ArcCurve:iT,ArrayCamera:OT,ArrowHelper:PD,AttachedBindMode:Wx,Audio:PT,AudioAnalyser:$N,AudioContext:$b,AudioListener:QN,AudioLoader:jN,AxesHelper:zD,BackSide:as,BasicDepthPacking:NE,BasicShadowMap:sE,BatchedMesh:KE,Bone:Ib,BooleanKeyframeTrack:uf,Box2:xD,Box3:za,Box3Helper:ID,BoxGeometry:lf,BoxHelper:UD,BufferAttribute:Xn,BufferGeometry:Kt,BufferGeometryLoader:IT,ByteType:xb,Cache:Oo,Camera:Ry,CameraHelper:LD,CanvasTexture:tN,CapsuleGeometry:Py,CatmullRomCurve3:aT,CineonToneMapping:mb,CircleGeometry:zy,ClampToEdgeWrapping:Rs,Clock:eS,Color:yt,ColorKeyframeTrack:Zb,ColorManagement:Sn,CompressedArrayTexture:$R,CompressedCubeTexture:eN,CompressedTexture:Oy,CompressedTextureLoader:zN,ConeGeometry:Nm,ConstantAlphaFactor:SE,ConstantColorFactor:xE,Controls:FD,CubeCamera:WE,CubeDepthTexture:tT,CubeReflectionMapping:zo,CubeRefractionMapping:Pu,CubeTexture:Cm,CubeTextureLoader:BN,CubeUVReflectionMapping:id,CubicBezierCurve:Bb,CubicBezierCurve3:sT,CubicInterpolant:ST,CullFaceBack:Vx,CullFaceFront:aE,CullFaceFrontBack:n3,CullFaceNone:iE,Curve:Zr,CurvePath:oT,CustomBlending:rE,CustomToneMapping:gb,CylinderGeometry:Rm,Cylindrical:_D,Data3DTexture:Cy,DataArrayTexture:wy,DataTexture:Yr,DataTextureLoader:FN,DataUtils:ER,DecrementStencilOp:x3,DecrementWrapStencilOp:S3,DefaultLoadingManager:TT,DepthFormat:Fo,DepthStencilFormat:Uu,DepthTexture:ed,DetachedBindMode:AE,DirectionalLight:RT,DirectionalLightHelper:DD,DiscreteInterpolant:MT,DodecahedronGeometry:By,DoubleSide:Uo,DstAlphaFactor:mE,DstColorFactor:vE,DynamicCopyUsage:z3,DynamicDrawUsage:D3,DynamicReadUsage:I3,EdgesGeometry:nT,EllipseCurve:Fy,EqualCompare:IE,EqualDepth:Sv,EqualStencilFunc:A3,EquirectangularReflectionMapping:om,EquirectangularRefractionMapping:lm,Euler:Gs,EventDispatcher:ko,ExternalTexture:Pb,ExtrudeGeometry:ky,FileLoader:Ul,Float16BufferAttribute:DR,Float32BufferAttribute:bt,FloatType:is,Fog:Dy,FogExp2:Ny,FramebufferTexture:JR,FrontSide:Ll,Frustum:ad,FrustumArray:Iy,GLBufferAttribute:gD,GLSL1:F3,GLSL3:jx,GreaterCompare:OE,GreaterDepth:Ev,GreaterEqualCompare:Ay,GreaterEqualDepth:Mv,GreaterEqualStencilFunc:N3,GreaterStencilFunc:C3,GridHelper:RD,Group:Gh,HalfFloatType:Bo,HemisphereLight:AT,HemisphereLightHelper:CD,IcosahedronGeometry:Vy,ImageBitmapLoader:qN,ImageLoader:Mm,ImageUtils:VE,IncrementStencilOp:_3,IncrementWrapStencilOp:b3,InstancedBufferAttribute:$h,InstancedBufferGeometry:UT,InstancedInterleavedBuffer:mD,InstancedMesh:QE,Int16BufferAttribute:RR,Int32BufferAttribute:NR,Int8BufferAttribute:AR,IntType:yy,InterleavedBuffer:Ly,InterleavedBufferAttribute:nf,Interpolant:Um,InterpolateDiscrete:fm,InterpolateLinear:ay,InterpolateSmooth:dv,InterpolationSamplingMode:H3,InterpolationSamplingType:V3,InvertStencilOp:M3,KeepStencilOp:Wc,KeyframeTrack:_r,LOD:YE,LatheGeometry:Hy,Layers:Kh,LessCompare:UE,LessDepth:bv,LessEqualCompare:Ty,LessEqualDepth:ef,LessEqualStencilFunc:w3,LessStencilFunc:T3,Light:Gu,LightProbe:LT,Line:Fu,Line3:MD,LineBasicMaterial:ss,LineCurve:Fb,LineCurve3:rT,LineDashedMaterial:xT,LineLoop:JE,LineSegments:Vo,LinearFilter:oi,LinearInterpolant:Yb,LinearMipMapLinearFilter:r3,LinearMipMapNearestFilter:s3,LinearMipmapLinearFilter:Io,LinearMipmapNearestFilter:Jp,LinearSRGBColorSpace:zu,LinearToneMapping:db,LinearTransfer:dm,Loader:Ns,LoaderUtils:Jx,LoadingManager:Qb,LoopOnce:wE,LoopPingPong:RE,LoopRepeat:CE,MOUSE:Gc,Material:Ba,MaterialLoader:Zy,MathUtils:uR,Matrix2:aS,Matrix3:en,Matrix4:Xt,MaxEquation:cE,Mesh:Yi,MeshBasicMaterial:Vu,MeshDepthMaterial:Wb,MeshDistanceMaterial:qb,MeshLambertMaterial:yT,MeshMatcapMaterial:_T,MeshNormalMaterial:vT,MeshPhongMaterial:mT,MeshPhysicalMaterial:pT,MeshStandardMaterial:Xb,MeshToonMaterial:gT,MinEquation:uE,MirroredRepeatWrapping:cm,MixOperation:EE,MultiplyBlending:Xx,MultiplyOperation:Am,NearestFilter:Bi,NearestMipMapLinearFilter:a3,NearestMipMapNearestFilter:i3,NearestMipmapLinearFilter:Vh,NearestMipmapNearestFilter:_b,NeutralToneMapping:yb,NeverCompare:LE,NeverDepth:_v,NeverStencilFunc:E3,NoBlending:Po,NoColorSpace:Cl,NoNormalPacking:p3,NoToneMapping:gr,NormalAnimationBlendMode:Ey,NormalBlending:Kc,NormalGAPacking:g3,NormalRGPacking:m3,NotEqualCompare:PE,NotEqualDepth:Tv,NotEqualStencilFunc:R3,NumberKeyframeTrack:xm,Object3D:Cn,ObjectLoader:XN,ObjectSpaceNormalMap:DE,OctahedronGeometry:Dm,OneFactor:hE,OneMinusConstantAlphaFactor:ME,OneMinusConstantColorFactor:bE,OneMinusDstAlphaFactor:gE,OneMinusDstColorFactor:yE,OneMinusSrcAlphaFactor:yv,OneMinusSrcColorFactor:pE,OrthographicCamera:Dl,PCFShadowMap:Xh,PCFSoftShadowMap:Kp,PMREMGenerator:nb,Path:ly,PerspectiveCamera:zi,Plane:wl,PlaneGeometry:sd,PlaneHelper:OD,PointLight:CT,PointLightHelper:AD,Points:$E,PointsMaterial:Ob,PolarGridHelper:ND,PolyhedronGeometry:Hu,PositionalAudio:JN,PropertyBinding:wn,PropertyMixer:zT,QuadraticBezierCurve:kb,QuadraticBezierCurve3:Vb,Quaternion:Pa,QuaternionKeyframeTrack:Im,QuaternionLinearInterpolant:ET,R11_EAC_Format:Uv,RED_GREEN_RGTC2_Format:ny,RED_RGTC1_Format:ey,REVISION:my,RG11_EAC_Format:Ov,RGBADepthPacking:f3,RGBAFormat:Oa,RGBAIntegerFormat:My,RGBA_ASTC_10x10_Format:Yv,RGBA_ASTC_10x5_Format:Wv,RGBA_ASTC_10x6_Format:qv,RGBA_ASTC_10x8_Format:jv,RGBA_ASTC_12x10_Format:Zv,RGBA_ASTC_12x12_Format:Qv,RGBA_ASTC_4x4_Format:zv,RGBA_ASTC_5x4_Format:Bv,RGBA_ASTC_5x5_Format:Fv,RGBA_ASTC_6x5_Format:kv,RGBA_ASTC_6x6_Format:Vv,RGBA_ASTC_8x5_Format:Hv,RGBA_ASTC_8x6_Format:Gv,RGBA_ASTC_8x8_Format:Xv,RGBA_BPTC_Format:Kv,RGBA_ETC2_EAC_Format:Lv,RGBA_PVRTC_2BPPV1_Format:Rv,RGBA_PVRTC_4BPPV1_Format:Cv,RGBA_S3TC_DXT1_Format:em,RGBA_S3TC_DXT3_Format:tm,RGBA_S3TC_DXT5_Format:nm,RGBDepthPacking:h3,RGBFormat:Tb,RGBIntegerFormat:o3,RGB_BPTC_SIGNED_Format:Jv,RGB_BPTC_UNSIGNED_Format:$v,RGB_ETC1_Format:Nv,RGB_ETC2_Format:Dv,RGB_PVRTC_2BPPV1_Format:wv,RGB_PVRTC_4BPPV1_Format:Av,RGB_S3TC_DXT1_Format:$p,RGDepthPacking:d3,RGFormat:tf,RGIntegerFormat:Sy,RawShaderMaterial:Gb,Ray:of,Raycaster:FT,RectAreaLight:DT,RedFormat:by,RedIntegerFormat:wm,ReinhardToneMapping:pb,RenderTarget:Cb,RenderTarget3D:hD,RepeatWrapping:um,ReplaceStencilOp:y3,ReverseSubtractEquation:lE,RingGeometry:Gy,SIGNED_R11_EAC_Format:Iv,SIGNED_RED_GREEN_RGTC2_Format:iy,SIGNED_RED_RGTC1_Format:ty,SIGNED_RG11_EAC_Format:Pv,SRGBColorSpace:Ia,SRGBTransfer:zn,Scene:Lb,ShaderChunk:un,ShaderLib:qr,ShaderMaterial:yr,ShadowMaterial:dT,Shape:$c,ShapeGeometry:Xy,ShapePath:BD,ShapeUtils:jr,ShortType:bb,Skeleton:Uy,SkeletonHelper:TD,SkinnedMesh:ZE,Source:Iu,Sphere:_a,SphereGeometry:Lm,Spherical:eb,SphericalHarmonics3:Jb,SplineCurve:Hb,SpotLight:wT,SpotLightHelper:ED,Sprite:jE,SpriteMaterial:Ub,SrcAlphaFactor:vv,SrcAlphaSaturateFactor:_E,SrcColorFactor:dE,StaticCopyUsage:P3,StaticDrawUsage:pm,StaticReadUsage:U3,StereoCamera:YN,StreamCopyUsage:B3,StreamDrawUsage:L3,StreamReadUsage:O3,StringKeyframeTrack:cf,SubtractEquation:oE,SubtractiveBlending:Gx,TOUCH:Xc,TangentSpaceNormalMap:ku,TetrahedronGeometry:Wy,Texture:wi,TextureLoader:kN,TextureUtils:XD,Timer:vD,TimestampQuery:k3,TorusGeometry:qy,TorusKnotGeometry:jy,Triangle:Cs,TriangleFanDrawMode:c3,TriangleStripDrawMode:u3,TrianglesDrawMode:l3,TubeGeometry:Yy,UVMapping:vy,Uint16BufferAttribute:Rb,Uint32BufferAttribute:Nb,Uint8BufferAttribute:wR,Uint8ClampedBufferAttribute:CR,Uniform:iS,UniformsGroup:pD,UniformsLib:pt,UniformsUtils:XE,UnsignedByteType:ts,UnsignedInt101111Type:Mb,UnsignedInt248Type:jh,UnsignedInt5999Type:Sb,UnsignedIntType:vr,UnsignedShort4444Type:_y,UnsignedShort5551Type:xy,UnsignedShortType:qh,VSMShadowMap:jc,Vector2:ze,Vector3:j,Vector4:jn,VectorKeyframeTrack:bm,VideoFrameTexture:KR,VideoTexture:eT,WebGL3DRenderTarget:pR,WebGLArrayRenderTarget:dR,WebGLCoordinateSystem:ks,WebGLCubeRenderTarget:Db,WebGLRenderTarget:Hs,WebGLRenderer:jT,WebGLUtils:qT,WebGPUCoordinateSystem:Yh,WebXRController:pv,WireframeGeometry:hT,WrapAroundEnding:hm,ZeroCurvatureEnding:Yc,ZeroFactor:fE,ZeroSlopeEnding:Zc,ZeroStencilOp:v3,createCanvasElement:kE,error:Rt,getConsoleFunction:W3,log:gm,setConsoleFunction:X3,warn:ft,warnOnce:Zh},Symbol.toStringTag,{value:"Module"}));var Rx={exports:{}},Nx={},Dx={exports:{}},Lx={};var L1;function FP(){if(L1)return Lx;L1=1;var r=Tm();function e(x,b){return x===b&&(x!==0||1/x===1/b)||x!==x&&b!==b}var t=typeof Object.is=="function"?Object.is:e,n=r.useState,s=r.useEffect,u=r.useLayoutEffect,f=r.useDebugValue;function h(x,b){var M=b(),A=n({inst:{value:M,getSnapshot:b}}),R=A[0].inst,w=A[1];return u(function(){R.value=M,R.getSnapshot=b,m(R)&&w({inst:R})},[x,M,b]),s(function(){return m(R)&&w({inst:R}),x(function(){m(R)&&w({inst:R})})},[x]),f(M),M}function m(x){var b=x.getSnapshot;x=x.value;try{var M=b();return!t(x,M)}catch{return!0}}function g(x,b){return b()}var _=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:h;return Lx.useSyncExternalStore=r.useSyncExternalStore!==void 0?r.useSyncExternalStore:_,Lx}var U1;function kP(){return U1||(U1=1,Dx.exports=FP()),Dx.exports}var I1;function VP(){if(I1)return Nx;I1=1;var r=Tm(),e=kP();function t(g,_){return g===_&&(g!==0||1/g===1/_)||g!==g&&_!==_}var n=typeof Object.is=="function"?Object.is:t,s=e.useSyncExternalStore,u=r.useRef,f=r.useEffect,h=r.useMemo,m=r.useDebugValue;return Nx.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(z){if(!N){if(N=!0,D=z,z=b(z),M!==void 0&&R.hasValue){var H=R.value;if(M(H,z))return U=H}return U=z}if(H=U,n(D,z))return H;var W=b(z);return M!==void 0&&M(H,W)?(D=z,H):(D=z,U=W)}var N=!1,D,U,B=x===void 0?null:x;return[function(){return E(_())},B===null?void 0:function(){return E(B())}]},[_,x,b,M]);var w=s(g,A[0],A[1]);return f(function(){R.hasValue=!0,R.value=w},[w]),m(w),w},Nx}var O1;function HP(){return O1||(O1=1,Rx.exports=VP()),Rx.exports}var GP=HP();const XP=py(GP),P1=r=>{let e;const t=new Set,n=(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:n,getState:s,getInitialState:()=>m,subscribe:g=>(t.add(g),()=>t.delete(g))},m=e=r(n,s,h);return h},WP=(r=>r?P1(r):P1),{useSyncExternalStoreWithSelector:qP}=XP,jP=r=>r;function YP(r,e=jP,t){const n=qP(r.subscribe,r.getState,r.getInitialState,e,t);return hb.useDebugValue(n),n}const z1=(r,e)=>{const t=WP(r),n=(s,u=e)=>YP(t,s,u);return Object.assign(n,t),n},ZP=((r,e)=>r?z1(r,e):z1);var sb=nE();const QP=py(sb);function sS(r,e,t){if(!r)return;if(t(r)===!0)return r;let n=e?r.return:r.child;for(;n;){const s=sS(n,e,t);if(s)return s;n=e?null:n.sibling}}function YT(r){try{return Object.defineProperties(r,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return r}}const rS=YT(rt.createContext(null));class ZT extends rt.Component{render(){return rt.createElement(rS.Provider,{value:this._reactInternals},this.props.children)}}function QT(){const r=rt.useContext(rS);if(r===null)throw new Error("its-fine: useFiber must be called within a !");const e=rt.useId();return rt.useMemo(()=>{for(const t of[r,r?.alternate]){if(!t)continue;const n=sS(t,!1,s=>{let u=s.memoizedState;for(;u;){if(u.memoizedState===e)return!0;u=u.next}});if(n)return n}},[r,e])}const KP=Symbol.for("react.context"),JP=r=>r!==null&&typeof r=="object"&&"$$typeof"in r&&r.$$typeof===KP;function $P(){const r=QT(),[e]=rt.useState(()=>new Map);e.clear();let t=r;for(;t;){const n=t.type;JP(n)&&n!==rS&&!e.has(n)&&e.set(n,rt.use(YT(n))),t=t.return}return e}function ez(){const r=$P();return rt.useMemo(()=>Array.from(r.keys()).reduce((e,t)=>n=>rt.createElement(e,null,rt.createElement(t.Provider,{...n,value:r.get(t)})),e=>rt.createElement(ZT,{...e})),[r])}function KT(r){let e=r.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const JT=r=>r&&r.isOrthographicCamera,tz=r=>r&&r.hasOwnProperty("current"),nz=r=>r!=null&&(typeof r=="string"||typeof r=="number"||r.isColor),Om=((r,e)=>typeof window<"u"&&(((r=window.document)==null?void 0:r.createElement)||((e=window.navigator)==null?void 0:e.product)==="ReactNative"))()?rt.useLayoutEffect:rt.useEffect;function $T(r){const e=rt.useRef(r);return Om(()=>{e.current=r},[r]),e}function iz(){const r=QT(),e=ez();return rt.useMemo(()=>({children:t})=>{const s=!!sS(r,!0,u=>u.type===rt.StrictMode)?rt.StrictMode:rt.Fragment;return he.jsx(s,{children:he.jsx(e,{children:t})})},[r,e])}function az({set:r}){return Om(()=>(r(new Promise(()=>null)),()=>r(!1)),[r]),null}const sz=(r=>(r=class extends rt.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}},r.getDerivedStateFromError=()=>({error:!0}),r))();function eA(r){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(r)?Math.min(Math.max(r[0],t),r[1]):r}function Bh(r){var e;return(e=r.__r3f)==null?void 0:e.root.getState()}const yi={obj:r=>r===Object(r)&&!yi.arr(r)&&typeof r!="function",fun:r=>typeof r=="function",str:r=>typeof r=="string",num:r=>typeof r=="number",boo:r=>typeof r=="boolean",und:r=>r===void 0,nul:r=>r===null,arr:r=>Array.isArray(r),equ(r,e,{arrays:t="shallow",objects:n="reference",strict:s=!0}={}){if(typeof r!=typeof e||!!r!=!!e)return!1;if(yi.str(r)||yi.num(r)||yi.boo(r))return r===e;const u=yi.obj(r);if(u&&n==="reference")return r===e;const f=yi.arr(r);if(f&&t==="reference")return r===e;if((f||u)&&r===e)return!0;let h;for(h in r)if(!(h in e))return!1;if(u&&t==="shallow"&&n==="shallow"){for(h in s?e:r)if(!yi.equ(r[h],e[h],{strict:s,objects:"reference"}))return!1}else for(h in s?e:r)if(r[h]!==e[h])return!1;if(yi.und(h)){if(f&&r.length===0&&e.length===0||u&&Object.keys(r).length===0&&Object.keys(e).length===0)return!0;if(r!==e)return!1}return!0}};function rz(r){r.type!=="Scene"&&(r.dispose==null||r.dispose());for(const e in r){const t=r[e];t?.type!=="Scene"&&(t==null||t.dispose==null||t.dispose())}}const tA=["children","key","ref"];function oz(r){const e={};for(const t in r)tA.includes(t)||(e[t]=r[t]);return e}function uy(r,e,t,n){const s=r;let u=s?.__r3f;return u||(u={root:e,type:t,parent:null,children:[],props:oz(n),object:s,eventCount:0,handlers:{},isHidden:!1},s&&(s.__r3f=u)),u}function Em(r,e){if(!e.includes("-"))return{root:r,key:e,target:r[e]};if(e in r)return{root:r,key:e,target:r[e]};let t=r;const n=e.split("-");for(const s of n){if(typeof t!="object"||t===null){if(t!==void 0){const u=n.slice(n.indexOf(s)).join("-");return{root:t,key:u,target:void 0}}return{root:r,key:e,target:void 0}}e=s,r=t,t=t[e]}return{root:r,key:e,target:t}}const B1=/-\d+$/;function cy(r,e){if(yi.str(e.props.attach)){if(B1.test(e.props.attach)){const s=e.props.attach.replace(B1,""),{root:u,key:f}=Em(r.object,s);Array.isArray(u[f])||(u[f]=[])}const{root:t,key:n}=Em(r.object,e.props.attach);e.previousAttach=t[n],t[n]=e.object}else yi.fun(e.props.attach)&&(e.previousAttach=e.props.attach(r.object,e.object))}function fy(r,e){if(yi.str(e.props.attach)){const{root:t,key:n}=Em(r.object,e.props.attach),s=e.previousAttach;s===void 0?delete t[n]:t[n]=s}else e.previousAttach==null||e.previousAttach(r.object,e.object);delete e.previousAttach}const rb=[...tA,"args","dispose","attach","object","onUpdate","dispose"],F1=new Map;function lz(r){let e=F1.get(r.constructor);try{e||(e=new r.constructor,F1.set(r.constructor,e))}catch{}return e}function uz(r,e){const t={};for(const n in e)if(!rb.includes(n)&&!yi.equ(e[n],r.props[n])){t[n]=e[n];for(const s in e)s.startsWith(`${n}-`)&&(t[s]=e[s])}for(const n in r.props){if(rb.includes(n)||e.hasOwnProperty(n))continue;const{root:s,key:u}=Em(r.object,n);if(s.constructor&&s.constructor.length===0){const f=lz(s);yi.und(f)||(t[u]=f[u])}else t[u]=0}return t}const cz=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],fz=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function Lu(r,e){var t;const n=r.__r3f,s=n&&KT(n).getState(),u=n?.eventCount;for(const h in e){let m=e[h];if(rb.includes(h))continue;if(n&&fz.test(h)){typeof m=="function"?n.handlers[h]=m:delete n.handlers[h],n.eventCount=Object.keys(n.handlers).length;continue}if(m===void 0)continue;let{root:g,key:_,target:x}=Em(r,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 Kh&&m instanceof Kh)x.mask=m.mask;else if(x instanceof yt&&nz(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&&cz.includes(_)&&(f=g[_])!=null&&f.isTexture&&g[_].format===Oa&&g[_].type===ts&&(g[_].colorSpace=Ia)}}if(n!=null&&n.parent&&s!=null&&s.internal&&(t=n.object)!=null&&t.isObject3D&&u!==n.eventCount){const h=n.object,m=s.internal.interaction.indexOf(h);m>-1&&s.internal.interaction.splice(m,1),n.eventCount&&h.raycast!==null&&s.internal.interaction.push(h)}return n&&n.props.attach===void 0&&(n.object.isBufferGeometry?n.props.attach="geometry":n.object.isMaterial&&(n.props.attach="material")),n&&od(n),r}function od(r){var e;if(!r.parent)return;r.props.onUpdate==null||r.props.onUpdate(r.object);const t=(e=r.root)==null||e.getState==null?void 0:e.getState();t&&t.internal.frames===0&&t.invalidate()}function hz(r,e){r.manual||(JT(r)?(r.left=e.width/-2,r.right=e.width/2,r.top=e.height/2,r.bottom=e.height/-2):r.aspect=e.width/e.height,r.updateProjectionMatrix())}const ws=r=>r?.isObject3D;function uv(r){return(r.eventObject||r.object).uuid+"/"+r.index+r.instanceId}function nA(r,e,t,n){const s=t.get(e);s&&(t.delete(e),t.size===0&&(r.delete(n),s.target.releasePointerCapture(n)))}function dz(r,e){const{internal:t}=r.getState();t.interaction=t.interaction.filter(n=>n!==e),t.initialHits=t.initialHits.filter(n=>n!==e),t.hovered.forEach((n,s)=>{(n.eventObject===e||n.object===e)&&t.hovered.delete(s)}),t.capturedMap.forEach((n,s)=>{nA(t.capturedMap,e,n,s)})}function pz(r){function e(m){const{internal:g}=r.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 n(m,g){const _=r.getState(),x=new Set,b=[],M=g?g(_.internal.interaction):_.internal.interaction;for(let E=0;E{const D=Bh(E.object),U=Bh(N.object);return!D||!U?E.distance-N.distance:U.events.priority-D.events.priority||E.distance-N.distance}).filter(E=>{const N=uv(E);return x.has(N)?!1:(x.add(N),!0)});_.events.filter&&(R=_.events.filter(R,_));for(const E of R){let N=E.object;for(;N;){var w;(w=N.__r3f)!=null&&w.eventCount&&b.push({...E,eventObject:N}),N=N.parent}}if("pointerId"in m&&_.internal.capturedMap.has(m.pointerId))for(let E of _.internal.capturedMap.get(m.pointerId).values())x.has(uv(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=Bh(M.object);if(A||M.object.traverseAncestors(R=>{const w=Bh(R);if(w)return A=w,!1}),A){const{raycaster:R,pointer:w,camera:E,internal:N}=A,D=new j(w.x,w.y,0).unproject(E),U=I=>{var P,Z;return(P=(Z=N.capturedMap.get(I))==null?void 0:Z.has(M.eventObject))!=null?P:!1},B=I=>{const P={intersection:M,target:g.target};N.capturedMap.has(I)?N.capturedMap.get(I).set(M.eventObject,P):N.capturedMap.set(I,new Map([[M.eventObject,P]])),g.target.setPointerCapture(I)},z=I=>{const P=N.capturedMap.get(I);P&&nA(N.capturedMap,M.eventObject,P,I)};let H={};for(let I in g){let P=g[I];typeof P!="function"&&(H[I]=P)}let W={...M,...H,pointer:w,intersections:m,stopped:b.stopped,delta:_,unprojectedPoint:D,ray:R.ray,camera:E,stopPropagation(){const I="pointerId"in g&&N.capturedMap.get(g.pointerId);if((!I||I.has(M.eventObject))&&(W.stopped=b.stopped=!0,N.hovered.size&&Array.from(N.hovered.values()).find(P=>P.eventObject===M.eventObject))){const P=m.slice(0,m.indexOf(M));u([...P,M])}},target:{hasPointerCapture:U,setPointerCapture:B,releasePointerCapture:z},currentTarget:{hasPointerCapture:U,setPointerCapture:B,releasePointerCapture:z},nativeEvent:g};if(x(W),b.stopped===!0)break}}}return m}function u(m){const{internal:g}=r.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(uv(_)),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:_}=r.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}=r.getState();b.lastEvent.current=_;const M=m==="onPointerMove",A=m==="onClick"||m==="onContextMenu"||m==="onDoubleClick",w=n(_,M?t:void 0),E=A?e(_):0;m==="onPointerDown"&&(b.initialClick=[_.offsetX,_.offsetY],b.initialHits=w.map(D=>D.eventObject)),A&&!w.length&&E<=2&&(f(_,b.interaction),x&&x(_)),M&&u(w);function N(D){const U=D.eventObject,B=U.__r3f;if(!(B!=null&&B.eventCount))return;const z=B.handlers;if(M){if(z.onPointerOver||z.onPointerEnter||z.onPointerOut||z.onPointerLeave){const H=uv(D),W=b.hovered.get(H);W?W.stopped&&D.stopPropagation():(b.hovered.set(H,D),z.onPointerOver==null||z.onPointerOver(D),z.onPointerEnter==null||z.onPointerEnter(D))}z.onPointerMove==null||z.onPointerMove(D)}else{const H=z[m];H?(!A||b.initialHits.includes(U))&&(f(_,b.interaction.filter(W=>!b.initialHits.includes(W))),H(D)):A&&b.initialHits.includes(U)&&f(_,b.interaction.filter(W=>!b.initialHits.includes(W)))}}s(w,_,E,N)}}return{handlePointer:h}}const k1=r=>!!(r!=null&&r.render),iA=rt.createContext(null),mz=(r,e)=>{const t=ZP((h,m)=>{const g=new j,_=new j,x=new j;function b(E=m().camera,N=_,D=m().size){const{width:U,height:B,top:z,left:H}=D,W=U/B;N.isVector3?x.copy(N):x.set(...N);const I=E.getWorldPosition(g).distanceTo(x);if(JT(E))return{width:U/E.zoom,height:B/E.zoom,top:z,left:H,factor:1,distance:I,aspect:W};{const P=E.fov*Math.PI/180,Z=2*Math.tan(P/2)*I,se=Z*(U/B);return{width:se,height:Z,top:z,left:H,factor:U/se,distance:I,aspect:W}}}let M;const A=E=>h(N=>({performance:{...N.performance,current:E}})),R=new ze;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)=>r(m(),E),advance:(E,N)=>e(E,N,m()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new eS,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(N=>({...N,events:{...N.events,...E}})),setSize:(E,N,D=0,U=0)=>{const B=m().camera,z={width:E,height:N,top:D,left:U};h(H=>({size:z,viewport:{...H.viewport,...b(B,_,z)}}))},setDpr:E=>h(N=>{const D=eA(E);return{viewport:{...N.viewport,dpr:D,initialDpr:N.viewport.initialDpr||D}}}),setFrameloop:(E="always")=>{const N=m().clock;N.stop(),N.elapsedTime=0,E!=="never"&&(N.start(),N.elapsedTime=0),h(()=>({frameloop:E}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:rt.createRef(),active:!1,frames:0,priority:0,subscribe:(E,N,D)=>{const U=m().internal;return U.priority=U.priority+(N>0?1:0),U.subscribers.push({ref:E,priority:N,store:D}),U.subscribers=U.subscribers.sort((B,z)=>B.priority-z.priority),()=>{const B=m().internal;B!=null&&B.subscribers&&(B.priority=B.priority-(N>0?1:0),B.subscribers=B.subscribers.filter(z=>z.ref!==E))}}}}}),n=t.getState();let s=n.size,u=n.viewport.dpr,f=n.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,hz(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=>r(h)),t};function aA(){const r=rt.useContext(iA);if(!r)throw new Error("R3F: Hooks can only be used within the Canvas component!");return r}function Nu(r=t=>t,e){return aA()(r,e)}function gz(r,e=0){const t=aA(),n=t.getState().internal.subscribe,s=$T(r);return Om(()=>n(s,e,t),[e,n,t]),null}const vz=1,yz=8,_z=32,xz=2;var bz={version:"9.5.0"};function Sz(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var V1={exports:{}},H1={exports:{}},G1;function Mz(){return G1||(G1=1,(function(r){r.exports=function(e){function t(o,l,p,v){return new Ld(o,l,p,v)}function n(){}function s(o){var l="https://react.dev/errors/"+o;if(1cl||(o.current=$f[cl],$f[cl]=null,cl--)}function A(o,l){cl++,$f[cl]=o.current,o.current=l}function R(o){return o>>>=0,o===0?32:31-(eh(o)/Jg|0)|0}function w(o){var l=o&42;if(l!==0)return l;switch(o&-o){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 o&261888;case 262144:case 524288:case 1048576:case 2097152:return o&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return o&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return o}}function E(o,l,p){var v=o.pendingLanes;if(v===0)return 0;var T=0,C=o.suspendedLanes,F=o.pingedLanes;o=o.warmLanes;var ee=v&134217727;return ee!==0?(v=ee&~C,v!==0?T=w(v):(F&=ee,F!==0?T=w(F):p||(p=ee&~o,p!==0&&(T=w(p))))):(ee=v&~C,ee!==0?T=w(ee):F!==0?T=w(F):p||(p=v&~o,p!==0&&(T=w(p)))),T===0?0:l!==0&&l!==T&&(l&C)===0&&(C=T&-T,p=l&-l,C>=p||C===32&&(p&4194048)!==0)?l:T}function N(o,l){return(o.pendingLanes&~(o.suspendedLanes&~o.pingedLanes)&l)===0}function D(o,l){switch(o){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 U(){var o=ou;return ou<<=1,(ou&62914560)===0&&(ou=4194304),o}function B(o){for(var l=[],p=0;31>p;p++)l.push(o);return l}function z(o,l){o.pendingLanes|=l,l!==268435456&&(o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0)}function H(o,l,p,v,T,C){var F=o.pendingLanes;o.pendingLanes=p,o.suspendedLanes=0,o.pingedLanes=0,o.warmLanes=0,o.expiredLanes&=p,o.entangledLanes&=p,o.errorRecoveryDisabledLanes&=p,o.shellSuspendCounter=0;var ee=o.entanglements,we=o.expirationTimes,ke=o.hiddenUpdates;for(p=F&~p;0)":-1T||we[v]!==ke[T]){var it=` `+we[v].replace(" at new "," at ");return o.displayName&&it.includes("")&&(it=it.replace("",o.displayName)),it}while(1<=v&&0<=T);break}}}finally{_c=!1,Error.prepareStackTrace=p}return(p=o?o.displayName||o.name:"")?pe(p):""}function q(o,l){switch(o.tag){case 26:case 27:case 5:return pe(o.type);case 16:return pe("Lazy");case 13:return o.child!==l&&l!==null?pe("Suspense Fallback"):pe("Suspense");case 19:return pe("SuspenseList");case 0:case 15:return Y(o.type,!1);case 11:return Y(o.type.render,!1);case 1:return Y(o.type,!0);case 31:return pe("Activity");default:return""}}function ne(o){try{var l="",p=null;do l+=q(o,p),p=o,o=o.return;while(o);return l}catch(v){return` Error generating stack: `+v.message+` `+v.stack}}function be(o,l){if(typeof o=="object"&&o!==null){var p=yp.get(o);return p!==void 0?p:(l={value:o,source:l,stack:ne(l)},yp.set(o,l),l)}return{value:o,source:l,stack:ne(l)}}function Ne(o,l){Or[rr++]=xc,Or[rr++]=Pn,Pn=o,xc=l}function X(o,l,p){gs[Ya++]=Qi,gs[Ya++]=Is,gs[Ya++]=vs,vs=o;var v=Qi;o=Is;var T=32-Ta(v)-1;v&=~(1<>=F,T-=F,Qi=1<<32-Ta(l)+T|p<xn?(qi=zt,zt=null):qi=zt.sibling;var Tn=gt(_e,zt,Me[xn],$e);if(Tn===null){zt===null&&(zt=qi);break}o&&zt&&Tn.alternate===null&&l(_e,zt),ce=C(Tn,ce,xn),ri===null?Ot=Tn:ri.sibling=Tn,ri=Tn,zt=qi}if(xn===Me.length)return p(_e,zt),dn&&Ne(_e,xn),Ot;if(zt===null){for(;xnxn?(qi=zt,zt=null):qi=zt.sibling;var Es=gt(_e,zt,Tn.value,$e);if(Es===null){zt===null&&(zt=qi);break}o&&zt&&Es.alternate===null&&l(_e,zt),ce=C(Es,ce,xn),ri===null?Ot=Es:ri.sibling=Es,ri=Es,zt=qi}if(Tn.done)return p(_e,zt),dn&&Ne(_e,xn),Ot;if(zt===null){for(;!Tn.done;xn++,Tn=Me.next())Tn=We(_e,Tn.value,$e),Tn!==null&&(ce=C(Tn,ce,xn),ri===null?Ot=Tn:ri.sibling=Tn,ri=Tn);return dn&&Ne(_e,xn),Ot}for(zt=v(zt);!Tn.done;xn++,Tn=Me.next())Tn=qt(zt,_e,xn,Tn.value,$e),Tn!==null&&(o&&Tn.alternate!==null&&zt.delete(Tn.key===null?xn:Tn.key),ce=C(Tn,ce,xn),ri===null?Ot=Tn:ri.sibling=Tn,ri=Tn);return o&&zt.forEach(function(h_){return l(_e,h_)}),dn&&Ne(_e,xn),Ot}function Ro(_e,ce,Me,$e){if(typeof Me=="object"&&Me!==null&&Me.type===il&&Me.key===null&&(Me=Me.props.children),typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case ir:e:{for(var Ot=Me.key;ce!==null;){if(ce.key===Ot){if(Ot=Me.type,Ot===il){if(ce.tag===7){p(_e,ce.sibling),$e=T(ce,Me.props.children),$e.return=_e,_e=$e;break e}}else if(ce.elementType===Ot||typeof Ot=="object"&&Ot!==null&&Ot.$$typeof===ha&&Jt(Ot)===ce.type){p(_e,ce.sibling),$e=T(ce,Me.props),Qr($e,Me),$e.return=_e,_e=$e;break e}p(_e,ce);break}else l(_e,ce);ce=ce.sibling}Me.type===il?($e=hs(Me.props.children,_e.mode,$e,Me.key),$e.return=_e,_e=$e):($e=Nr(Me.type,Me.key,Me.props,null,_e.mode,$e),Qr($e,Me),$e.return=_e,_e=$e)}return F(_e);case nl:e:{for(Ot=Me.key;ce!==null;){if(ce.key===Ot)if(ce.tag===4&&ce.stateNode.containerInfo===Me.containerInfo&&ce.stateNode.implementation===Me.implementation){p(_e,ce.sibling),$e=T(ce,Me.children||[]),$e.return=_e,_e=$e;break e}else{p(_e,ce);break}else l(_e,ce);ce=ce.sibling}$e=Od(Me,_e.mode,$e),$e.return=_e,_e=$e}return F(_e);case ha:return Me=Jt(Me),Ro(_e,ce,Me,$e)}if(mo(Me))return vi(_e,ce,Me,$e);if(_(Me)){if(Ot=_(Me),typeof Ot!="function")throw Error(s(150));return Me=Ot.call(Me),gu(_e,ce,Me,$e)}if(typeof Me.then=="function")return Ro(_e,ce,Ci(Me),$e);if(Me.$$typeof===ds)return Ro(_e,ce,O(_e,Me),$e);Kr(_e,Me)}return typeof Me=="string"&&Me!==""||typeof Me=="number"||typeof Me=="bigint"?(Me=""+Me,ce!==null&&ce.tag===6?(p(_e,ce.sibling),$e=T(ce,Me),$e.return=_e,_e=$e):(p(_e,ce),$e=Ud(Me,_e.mode,$e),$e.return=_e,_e=$e),F(_e)):p(_e,ce)}return function(_e,ce,Me,$e){try{dl=0;var Ot=Ro(_e,ce,Me,$e);return bo=null,Ot}catch(zt){if(zt===Oi||zt===bs)throw zt;var ri=t(29,zt,null,_e.mode);return ri.lanes=$e,ri.return=_e,ri}}}function Jr(){for(var o=ur,l=pl=ur=0;lC?C:8);var F=Ut.T,ee={};Ut.T=ee,vf(o,!1,l,p);try{var we=T(),ke=Ut.S;if(ke!==null&&ke(ee,we),we!==null&&typeof we=="object"&&typeof we.then=="function"){var it=je(we,v);Zu(o,l,it,Yn(o))}else Zu(o,l,v,Yn(o))}catch(We){Zu(o,l,{then:function(){},status:"rejected",reason:We},Yn())}finally{hn(C),F!==null&&ee.types!==null&&(F.types=ee.types),Ut.T=F}}function km(o){var l=o.memoizedState;if(l!==null)return l;l={memoizedState:ol,baseState:ol,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wn,lastRenderedState:ol},next:null};var p={};return l.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wn,lastRenderedState:p},next:null},o.memoizedState=l,o=o.alternate,o!==null&&(o.memoizedState=l),l}function dd(){return G(ll)}function gf(){return ut().memoizedState}function Vm(){return ut().memoizedState}function e_(o){for(var l=o.return;l!==null;){switch(l.tag){case 24:case 3:var p=Yn();o=Va(p);var v=Ha(l,o,p);v!==null&&(ti(v,l,p),$r(v,l,p)),l={cache:Te()},o.payload=l;return}l=l.return}}function t_(o,l,p){var v=Yn();p={lane:v,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},yf(o)?Gm(l,p):(p=Go(o,l,p,v),p!==null&&(ti(p,o,v),Xm(p,l,v)))}function Hm(o,l,p){var v=Yn();Zu(o,l,p,v)}function Zu(o,l,p,v){var T={lane:v,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null};if(yf(o))Gm(l,T);else{var C=o.alternate;if(o.lanes===0&&(C===null||C.lanes===0)&&(C=l.lastRenderedReducer,C!==null))try{var F=l.lastRenderedState,ee=C(F,p);if(T.hasEagerState=!0,T.eagerState=ee,pi(ee,F))return xr(o,l,T,0),rn===null&&Jr(),!1}catch{}if(p=Go(o,l,T,v),p!==null)return ti(p,o,v),Xm(p,l,v),!0}return!1}function vf(o,l,p,v){if(v={lane:2,revertLane:me(),gesture:null,action:v,hasEagerState:!1,eagerState:null,next:null},yf(o)){if(l)throw Error(s(479))}else l=Go(o,p,v,2),l!==null&&ti(l,o,2)}function yf(o){var l=o.alternate;return o===Zt||l!==null&&l===Zt}function Gm(o,l){$t=sn=!0;var p=o.pending;p===null?l.next=l:(l.next=p.next,p.next=l),o.pending=l}function Xm(o,l,p){if((p&4194048)!==0){var v=l.lanes;v&=o.pendingLanes,p|=v,l.lanes=p,I(o,p)}}function pd(o,l,p,v){l=o.memoizedState,p=p(v,l),p=p==null?l:Bf({},l,p),o.memoizedState=p,o.lanes===0&&(o.updateQueue.baseState=p)}function _f(o,l,p,v,T,C,F){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(v,C,F):l.prototype&&l.prototype.isPureReactComponent?!Ue(p,v)||!Ue(T,C):!0}function Wm(o,l,p,v){o=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,v),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,v),l.state!==o&&Mc.enqueueReplaceState(l,l.state,null)}function Yo(o,l){var p=l;if("ref"in l){p={};for(var v in l)v!=="ref"&&(p[v]=l[v])}if(o=o.defaultProps){p===l&&(p=Bf({},p));for(var T in o)p[T]===void 0&&(p[T]=o[T])}return p}function xf(o,l){try{var p=o.onUncaughtError;p(l.value,{componentStack:l.stack})}catch(v){setTimeout(function(){throw v})}}function md(o,l,p){try{var v=o.onCaughtError;v(p.value,{componentStack:p.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(T){setTimeout(function(){throw T})}}function gd(o,l,p){return p=Va(p),p.tag=3,p.payload={element:null},p.callback=function(){xf(o,l)},p}function qm(o){return o=Va(o),o.tag=3,o}function jm(o,l,p,v){var T=p.type.getDerivedStateFromError;if(typeof T=="function"){var C=v.value;o.payload=function(){return T(C)},o.callback=function(){md(l,p,v)}}var F=p.stateNode;F!==null&&typeof F.componentDidCatch=="function"&&(o.callback=function(){md(l,p,v),typeof T!="function"&&(kr===null?kr=new Set([this]):kr.add(this));var ee=v.stack;this.componentDidCatch(v.value,{componentStack:ee!==null?ee:""})})}function n_(o,l,p,v,T){if(p.flags|=32768,v!==null&&typeof v=="object"&&typeof v.then=="function"){if(l=p.alternate,l!==null&&ot(l,p,T,!0),p=wa.current,p!==null){switch(p.tag){case 31:case 13:return Ca===null?Ql():p.alternate===null&&si===0&&(si=3),p.flags&=-257,p.flags|=65536,p.lanes=T,v===lr?p.flags|=16384:(l=p.updateQueue,l===null?p.updateQueue=new Set([v]):l.add(v),$l(o,v,T)),!1;case 22:return p.flags|=65536,v===lr?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)),$l(o,v,T)),!1}throw Error(s(435,p.tag))}return $l(o,v,T),Ql(),!1}if(dn)return l=wa.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=T,v!==oh&&(o=Error(s(422),{cause:v}),He(be(o,p)))):(v!==oh&&(l=Error(s(423),{cause:v}),He(be(l,p))),o=o.current.alternate,o.flags|=65536,T&=-T,o.lanes|=T,v=be(v,p),T=gd(o.stateNode,v,T),Xo(o,T),si!==4&&(si=2)),!1;var C=Error(s(520),{cause:v});if(C=be(C,p),Tc===null?Tc=[C]:Tc.push(C),si!==4&&(si=2),l===null)return!0;v=be(v,p),p=l;do{switch(p.tag){case 3:return p.flags|=65536,o=T&-T,p.lanes|=o,o=gd(p.stateNode,v,o),Xo(p,o),!1;case 1:if(l=p.type,C=p.stateNode,(p.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||C!==null&&typeof C.componentDidCatch=="function"&&(kr===null||!kr.has(C))))return p.flags|=65536,T&=-T,p.lanes|=T,T=qm(T),jm(T,o,p,v),Xo(p,T),!1}p=p.return}while(p!==null);return!1}function Zi(o,l,p,v){l.child=o===null?xp(l,null,p,v):Ji(l,o.child,p,v)}function Ym(o,l,p,v,T){p=p.render;var C=l.ref;if("ref"in v){var F={};for(var ee in v)ee!=="ref"&&(F[ee]=v[ee])}else F=v;return Qe(l),v=xt(o,l,p,F,C,T),ee=Mn(),o!==null&&!qn?(Bn(o,l,T),qs(o,l,T)):(dn&&ee&&oe(l),l.flags|=1,Zi(o,l,v,T),l.child)}function Zm(o,l,p,v,T){if(o===null){var C=p.type;return typeof C=="function"&&!$o(C)&&C.defaultProps===void 0&&p.compare===null?(l.tag=15,l.type=C,Qm(o,l,C,v,T)):(o=Nr(p.type,null,v,l,l.mode,T),o.ref=l.ref,o.return=l,l.child=o)}if(C=o.child,!Ku(o,T)){var F=C.memoizedProps;if(p=p.compare,p=p!==null?p:Ue,p(F,v)&&o.ref===l.ref)return qs(o,l,T)}return l.flags|=1,o=qa(C,v),o.ref=l.ref,o.return=l,l.child=o}function Qm(o,l,p,v,T){if(o!==null){var C=o.memoizedProps;if(Ue(C,v)&&o.ref===l.ref)if(qn=!1,l.pendingProps=v=C,Ku(o,T))(o.flags&131072)!==0&&(qn=!0);else return l.lanes=o.lanes,qs(o,l,T)}return Sf(o,l,p,v,T)}function Km(o,l,p,v){var T=v.children,C=o!==null?o.memoizedState:null;if(o===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),v.mode==="hidden"){if((l.flags&128)!==0){if(C=C!==null?C.baseLanes|p:p,o!==null){for(v=l.child=o.child,T=0;v!==null;)T=T|v.lanes|v.childLanes,v=v.sibling;v=T&~C}else v=0,l.child=null;return kl(o,l,C,p,v)}if((p&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},o!==null&&at(l,C!==null?C.cachePool:null),C!==null?eo(l,C):Xs(),ye(l);else return v=l.lanes=536870912,kl(o,l,C!==null?C.baseLanes|p:p,p,v)}else C!==null?(at(l,C.cachePool),eo(l,C),ue(),l.memoizedState=null):(o!==null&&at(l,null),Xs(),ue());return Zi(o,l,T,p),l.child}function Zo(o,l){return o!==null&&o.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function kl(o,l,p,v,T){var C=Ge();return C=C===null?null:{parent:hi?Kn._currentValue:Kn._currentValue2,pool:C},l.memoizedState={baseLanes:p,cachePool:C},o!==null&&at(l,null),Xs(),ye(l),o!==null&&ot(o,l,v,!0),l.childLanes=T,null}function bf(o,l){return l=io({mode:l.mode,children:l.children},o.mode),l.ref=o.ref,o.child=l,l.return=o,l}function vd(o,l,p){return Ji(l,o.child,null,p),o=bf(l,l.pendingProps),o.flags|=2,Je(l),l.memoizedState=null,o}function Jm(o,l,p){var v=l.pendingProps,T=(l.flags&128)!==0;if(l.flags&=-129,o===null){if(dn){if(v.mode==="hidden")return o=bf(l,v),l.lanes=536870912,Zo(null,o);if(Se(l),(o=Qn)?(o=ap(o,pa),o!==null&&(l.memoizedState={dehydrated:o,treeContext:vs!==null?{id:Qi,overflow:Is}:null,retryLane:536870912,hydrationErrors:null},p=Id(o),p.return=l,l.child=p,Ui=l,Qn=null)):o=null,o===null)throw st(l);return l.lanes=536870912,null}return bf(l,v)}var C=o.memoizedState;if(C!==null){var F=C.dehydrated;if(Se(l),T)if(l.flags&256)l.flags&=-257,l=vd(o,l,p);else if(l.memoizedState!==null)l.child=o.child,l.flags|=128,l=null;else throw Error(s(558));else if(qn||ot(o,l,p,!1),T=(p&o.childLanes)!==0,qn||T){if(v=rn,v!==null&&(F=P(v,p),F!==0&&F!==C.retryLane))throw C.retryLane=F,na(o,F),ti(v,o,F),ga;Ql(),l=vd(o,l,p)}else o=C.treeContext,Zn&&(Qn=Og(F),Ui=l,dn=!0,or=null,pa=!1,o!==null&&Fe(l,o)),l=bf(l,v),l.flags|=4096;return l}return o=qa(o.child,{mode:v.mode,children:v.children}),o.ref=l.ref,l.child=o,o.return=l,o}function Qu(o,l){var p=l.ref;if(p===null)o!==null&&o.ref!==null&&(l.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(s(284));(o===null||o.ref!==p)&&(l.flags|=4194816)}}function Sf(o,l,p,v,T){return Qe(l),p=xt(o,l,p,v,void 0,T),v=Mn(),o!==null&&!qn?(Bn(o,l,T),qs(o,l,T)):(dn&&v&&oe(l),l.flags|=1,Zi(o,l,p,T),l.child)}function yd(o,l,p,v,T,C){return Qe(l),l.updateQueue=null,p=St(l,v,p,T),Lt(o),v=Mn(),o!==null&&!qn?(Bn(o,l,C),qs(o,l,C)):(dn&&v&&oe(l),l.flags|=1,Zi(o,l,p,C),l.child)}function Qo(o,l,p,v,T){if(Qe(l),l.stateNode===null){var C=ar,F=p.contextType;typeof F=="object"&&F!==null&&(C=G(F)),C=new p(v,C),l.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,C.updater=Mc,l.stateNode=C,C._reactInternals=l,C=l.stateNode,C.props=v,C.state=l.memoizedState,C.refs={},Ri(l),F=p.contextType,C.context=typeof F=="object"&&F!==null?G(F):ar,C.state=l.memoizedState,F=p.getDerivedStateFromProps,typeof F=="function"&&(pd(l,p,F,v),C.state=l.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(F=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),F!==C.state&&Mc.enqueueReplaceState(C,C.state,null),br(l,v,C,T),Ds(),C.state=l.memoizedState),typeof C.componentDidMount=="function"&&(l.flags|=4194308),v=!0}else if(o===null){C=l.stateNode;var ee=l.memoizedProps,we=Yo(p,ee);C.props=we;var ke=C.context,it=p.contextType;F=ar,typeof it=="object"&&it!==null&&(F=G(it));var We=p.getDerivedStateFromProps;it=typeof We=="function"||typeof C.getSnapshotBeforeUpdate=="function",ee=l.pendingProps!==ee,it||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(ee||ke!==F)&&Wm(l,C,v,F),Za=!1;var gt=l.memoizedState;C.state=gt,br(l,v,C,T),Ds(),ke=l.memoizedState,ee||gt!==ke||Za?(typeof We=="function"&&(pd(l,p,We,v),ke=l.memoizedState),(we=Za||_f(l,p,we,v,gt,ke,F))?(it||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(l.flags|=4194308)):(typeof C.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=v,l.memoizedState=ke),C.props=v,C.state=ke,C.context=F,v=we):(typeof C.componentDidMount=="function"&&(l.flags|=4194308),v=!1)}else{C=l.stateNode,ka(o,l),F=l.memoizedProps,it=Yo(p,F),C.props=it,We=l.pendingProps,gt=C.context,ke=p.contextType,we=ar,typeof ke=="object"&&ke!==null&&(we=G(ke)),ee=p.getDerivedStateFromProps,(ke=typeof ee=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(F!==We||gt!==we)&&Wm(l,C,v,we),Za=!1,gt=l.memoizedState,C.state=gt,br(l,v,C,T),Ds();var qt=l.memoizedState;F!==We||gt!==qt||Za||o!==null&&o.dependencies!==null&&Tt(o.dependencies)?(typeof ee=="function"&&(pd(l,p,ee,v),qt=l.memoizedState),(it=Za||_f(l,p,it,v,gt,qt,we)||o!==null&&o.dependencies!==null&&Tt(o.dependencies))?(ke||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(v,qt,we),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(v,qt,we)),typeof C.componentDidUpdate=="function"&&(l.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof C.componentDidUpdate!="function"||F===o.memoizedProps&>===o.memoizedState||(l.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||F===o.memoizedProps&>===o.memoizedState||(l.flags|=1024),l.memoizedProps=v,l.memoizedState=qt),C.props=v,C.state=qt,C.context=we,v=it):(typeof C.componentDidUpdate!="function"||F===o.memoizedProps&>===o.memoizedState||(l.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||F===o.memoizedProps&>===o.memoizedState||(l.flags|=1024),v=!1)}return C=v,Qu(o,l),v=(l.flags&128)!==0,C||v?(C=l.stateNode,p=v&&typeof p.getDerivedStateFromError!="function"?null:C.render(),l.flags|=1,o!==null&&v?(l.child=Ji(l,o.child,null,T),l.child=Ji(l,null,p,T)):Zi(o,l,p,T),l.memoizedState=C.state,o=l.child):o=qs(o,l,T),o}function $m(o,l,p,v){return Nt(),l.flags|=256,Zi(o,l,p,v),l.child}function _d(o){return{baseLanes:o,cachePool:Xe()}}function xd(o,l,p){return o=o!==null?o.childLanes&~p:0,l&&(o|=va),o}function bd(o,l,p){var v=l.pendingProps,T=!1,C=(l.flags&128)!==0,F;if((F=C)||(F=o!==null&&o.memoizedState===null?!1:(ui.current&2)!==0),F&&(T=!0,l.flags&=-129),F=(l.flags&32)!==0,l.flags&=-33,o===null){if(dn){if(T?re(l):ue(),(o=Qn)?(o=Fg(o,pa),o!==null&&(l.memoizedState={dehydrated:o,treeContext:vs!==null?{id:Qi,overflow:Is}:null,retryLane:536870912,hydrationErrors:null},p=Id(o),p.return=l,l.child=p,Ui=l,Qn=null)):o=null,o===null)throw st(l);return qf(o)?l.lanes=32:l.lanes=536870912,null}var ee=v.children;return v=v.fallback,T?(ue(),T=l.mode,ee=io({mode:"hidden",children:ee},T),v=hs(v,T,p,null),ee.return=l,v.return=l,ee.sibling=v,l.child=ee,v=l.child,v.memoizedState=_d(p),v.childLanes=xd(o,F,p),l.memoizedState=gl,Zo(null,v)):(re(l),Mf(l,ee))}var we=o.memoizedState;if(we!==null&&(ee=we.dehydrated,ee!==null)){if(C)l.flags&256?(re(l),l.flags&=-257,l=Ko(o,l,p)):l.memoizedState!==null?(ue(),l.child=o.child,l.flags|=128,l=null):(ue(),ee=v.fallback,T=l.mode,v=io({mode:"visible",children:v.children},T),ee=hs(ee,T,p,null),ee.flags|=2,v.return=l,ee.return=l,v.sibling=ee,l.child=v,Ji(l,o.child,null,p),v=l.child,v.memoizedState=_d(p),v.childLanes=xd(o,F,p),l.memoizedState=gl,l=Zo(null,v));else if(re(l),qf(ee))F=jf(ee).digest,v=Error(s(419)),v.stack="",v.digest=F,He({value:v,source:null,stack:null}),l=Ko(o,l,p);else if(qn||ot(o,l,p,!1),F=(p&o.childLanes)!==0,qn||F){if(F=rn,F!==null&&(v=P(F,p),v!==0&&v!==we.retryLane))throw we.retryLane=v,na(o,v),ti(F,o,v),ga;vo(ee)||Ql(),l=Ko(o,l,p)}else vo(ee)?(l.flags|=192,l.child=o.child,l=null):(o=we.treeContext,Zn&&(Qn=Pg(ee),Ui=l,dn=!0,or=null,pa=!1,o!==null&&Fe(l,o)),l=Mf(l,v.children),l.flags|=4096);return l}return T?(ue(),ee=v.fallback,T=l.mode,we=o.child,C=we.sibling,v=qa(we,{mode:"hidden",children:v.children}),v.subtreeFlags=we.subtreeFlags&65011712,C!==null?ee=qa(C,ee):(ee=hs(ee,T,p,null),ee.flags|=2),ee.return=l,v.return=l,v.sibling=ee,l.child=v,Zo(null,v),v=l.child,ee=o.child.memoizedState,ee===null?ee=_d(p):(T=ee.cachePool,T!==null?(we=hi?Kn._currentValue:Kn._currentValue2,T=T.parent!==we?{parent:we,pool:we}:T):T=Xe(),ee={baseLanes:ee.baseLanes|p,cachePool:T}),v.memoizedState=ee,v.childLanes=xd(o,F,p),l.memoizedState=gl,Zo(o.child,v)):(re(l),p=o.child,o=p.sibling,p=qa(p,{mode:"visible",children:v.children}),p.return=l,p.sibling=null,o!==null&&(F=l.deletions,F===null?(l.deletions=[o],l.flags|=16):F.push(o)),l.child=p,l.memoizedState=null,p)}function Mf(o,l){return l=io({mode:"visible",children:l},o.mode),l.return=o,o.child=l}function io(o,l){return o=t(22,o,null,l),o.lanes=0,o}function Ko(o,l,p){return Ji(l,o.child,null,p),o=Mf(l,l.pendingProps.children),o.flags|=2,l.memoizedState=null,o}function eg(o,l,p){o.lanes|=l;var v=o.alternate;v!==null&&(v.lanes|=l),Q(o.return,l,p)}function Vl(o,l,p,v,T,C){var F=o.memoizedState;F===null?o.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:v,tail:p,tailMode:T,treeForkCount:C}:(F.isBackwards=l,F.rendering=null,F.renderingStartTime=0,F.last=v,F.tail=p,F.tailMode=T,F.treeForkCount=C)}function Sd(o,l,p){var v=l.pendingProps,T=v.revealOrder,C=v.tail;v=v.children;var F=ui.current,ee=(F&2)!==0;if(ee?(F=F&1|2,l.flags|=128):F&=1,A(ui,F),Zi(o,l,v,p),v=dn?xc:0,!ee&&o!==null&&(o.flags&128)!==0)e:for(o=l.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&eg(o,p,l);else if(o.tag===19)eg(o,p,l);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===l)break e;for(;o.sibling===null;){if(o.return===null||o.return===l)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}switch(T){case"forwards":for(p=l.child,T=null;p!==null;)o=p.alternate,o!==null&&mt(o)===null&&(T=p),p=p.sibling;p=T,p===null?(T=l.child,l.child=null):(T=p.sibling,p.sibling=null),Vl(l,!1,T,p,C,v);break;case"backwards":case"unstable_legacy-backwards":for(p=null,T=l.child,l.child=null;T!==null;){if(o=T.alternate,o!==null&&mt(o)===null){l.child=T;break}o=T.sibling,T.sibling=p,p=T,T=o}Vl(l,!0,p,null,C,v);break;case"together":Vl(l,!1,null,null,void 0,v);break;default:l.memoizedState=null}return l.child}function qs(o,l,p){if(o!==null&&(l.dependencies=o.dependencies),Fr|=l.lanes,(p&l.childLanes)===0)if(o!==null){if(ot(o,l,p,!1),(p&l.childLanes)===0)return null}else return null;if(o!==null&&l.child!==o.child)throw Error(s(153));if(l.child!==null){for(o=l.child,p=qa(o,o.pendingProps),l.child=p,p.return=l;o.sibling!==null;)o=o.sibling,p=p.sibling=qa(o,o.pendingProps),p.return=l;p.sibling=null}return l.child}function Ku(o,l){return(o.lanes&l)!==0?!0:(o=o.dependencies,!!(o!==null&&Tt(o)))}function Md(o,l,p){switch(l.tag){case 3:lt(l,l.stateNode.containerInfo),Oe(l,Kn,o.memoizedState.cache),Nt();break;case 27:case 5:Re(l);break;case 4:lt(l,l.stateNode.containerInfo);break;case 10:Oe(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,Se(l),null;break;case 13:var v=l.memoizedState;if(v!==null)return v.dehydrated!==null?(re(l),l.flags|=128,null):(p&l.child.childLanes)!==0?bd(o,l,p):(re(l),o=qs(o,l,p),o!==null?o.sibling:null);re(l);break;case 19:var T=(o.flags&128)!==0;if(v=(p&l.childLanes)!==0,v||(ot(o,l,p,!1),v=(p&l.childLanes)!==0),T){if(v)return Sd(o,l,p);l.flags|=128}if(T=l.memoizedState,T!==null&&(T.rendering=null,T.tail=null,T.lastEffect=null),A(ui,ui.current),v)break;return null;case 22:return l.lanes=0,Km(o,l,p,l.pendingProps);case 24:Oe(l,Kn,o.memoizedState.cache)}return qs(o,l,p)}function Ed(o,l,p){if(o!==null)if(o.memoizedProps!==l.pendingProps)qn=!0;else{if(!Ku(o,p)&&(l.flags&128)===0)return qn=!1,Md(o,l,p);qn=(o.flags&131072)!==0}else qn=!1,dn&&(l.flags&1048576)!==0&&X(l,xc,l.index);switch(l.lanes=0,l.tag){case 16:e:{var v=l.pendingProps;if(o=Jt(l.elementType),l.type=o,typeof o=="function")$o(o)?(v=Yo(o,v),l.tag=1,l=Qo(null,l,o,v,p)):(l.tag=0,l=Sf(null,l,o,v,p));else{if(o!=null){var T=o.$$typeof;if(T===eu){l.tag=11,l=Ym(null,l,o,v,p);break e}else if(T===kf){l.tag=14,l=Zm(null,l,o,v,p);break e}}throw l=x(o)||o,Error(s(306,l,""))}}return l;case 0:return Sf(o,l,l.type,l.pendingProps,p);case 1:return v=l.type,T=Yo(v,l.pendingProps),Qo(o,l,v,T,p);case 3:e:{if(lt(l,l.stateNode.containerInfo),o===null)throw Error(s(387));var C=l.pendingProps;T=l.memoizedState,v=T.element,ka(o,l),br(l,C,null,p);var F=l.memoizedState;if(C=F.cache,Oe(l,Kn,C),C!==T.cache&&Et(l,[Kn],p,!0),Ds(),C=F.element,Zn&&T.isDehydrated)if(T={element:C,isDehydrated:!1,cache:F.cache},l.updateQueue.baseState=T,l.memoizedState=T,l.flags&256){l=$m(o,l,C,p);break e}else if(C!==v){v=be(Error(s(424)),l),He(v),l=$m(o,l,C,p);break e}else for(Zn&&(Qn=Ig(l.stateNode.containerInfo),Ui=l,dn=!0,or=null,pa=!0),p=xp(l,null,C,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Nt(),C===v){l=qs(o,l,p);break e}Zi(o,l,C,p)}l=l.child}return l;case 26:if(ms)return Qu(o,l),o===null?(p=up(l.type,null,l.pendingProps,null))?l.memoizedState=p:dn||(l.stateNode=Kf(l.type,l.pendingProps,Ki.current,l)):l.memoizedState=up(l.type,o.memoizedProps,l.pendingProps,o.memoizedState),null;case 27:if(Li)return Re(l),o===null&&Li&&dn&&(v=l.stateNode=Jf(l.type,l.pendingProps,Ki.current,Xi.current,!1),Ui=l,pa=!0,Qn=ip(l.type,v,Qn)),Zi(o,l,l.pendingProps.children,p),Qu(o,l),o===null&&(l.flags|=4194304),l.child;case 5:return o===null&&dn&&(Yg(l.type,l.pendingProps,Xi.current),(T=v=Qn)&&(v=zg(v,l.type,l.pendingProps,pa),v!==null?(l.stateNode=v,Ui=l,Qn=Ug(v),pa=!1,T=!0):T=!1),T||st(l)),Re(l),T=l.type,C=l.pendingProps,F=o!==null?o.memoizedProps:null,v=C.children,da(T,C)?v=null:F!==null&&da(T,F)&&(l.flags|=32),l.memoizedState!==null&&(T=xt(o,l,Pt,null,null,p),hi?ll._currentValue=T:ll._currentValue2=T),Qu(o,l),Zi(o,l,v,p),l.child;case 6:return o===null&&dn&&(lp(l.pendingProps,Xi.current),(o=p=Qn)&&(p=Bg(p,l.pendingProps,pa),p!==null?(l.stateNode=p,Ui=l,Qn=null,o=!0):o=!1),o||st(l)),null;case 13:return bd(o,l,p);case 4:return lt(l,l.stateNode.containerInfo),v=l.pendingProps,o===null?l.child=Ji(l,null,v,p):Zi(o,l,v,p),l.child;case 11:return Ym(o,l,l.type,l.pendingProps,p);case 7:return Zi(o,l,l.pendingProps,p),l.child;case 8:return Zi(o,l,l.pendingProps.children,p),l.child;case 12:return Zi(o,l,l.pendingProps.children,p),l.child;case 10:return v=l.pendingProps,Oe(l,l.type,v.value),Zi(o,l,v.children,p),l.child;case 9:return T=l.type._context,v=l.pendingProps.children,Qe(l),T=G(T),v=v(T),l.flags|=1,Zi(o,l,v,p),l.child;case 14:return Zm(o,l,l.type,l.pendingProps,p);case 15:return Qm(o,l,l.type,l.pendingProps,p);case 19:return Sd(o,l,p);case 31:return Jm(o,l,p);case 22:return Km(o,l,p,l.pendingProps);case 24:return Qe(l),v=G(Kn),o===null?(T=Ge(),T===null&&(T=rn,C=Te(),T.pooledCache=C,C.refCount++,C!==null&&(T.pooledCacheLanes|=p),T=C),l.memoizedState={parent:v,cache:T},Ri(l),Oe(l,Kn,T)):((o.lanes&p)!==0&&(ka(o,l),br(l,null,null,p),Ds()),T=o.memoizedState,C=l.memoizedState,T.parent!==v?(T={parent:v,cache:v},l.memoizedState=T,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=T),Oe(l,Kn,v)):(v=C.cache,Oe(l,Kn,v),v!==T.cache&&Et(l,[Kn],p,!0))),Zi(o,l,l.pendingProps.children,p),l.child;case 29:throw l.pendingProps}throw Error(s(156,l.tag))}function os(o){o.flags|=4}function Ju(o){ja&&(o.flags|=8)}function tg(o,l){if(o!==null&&o.child===l.child)return!1;if((l.flags&16)!==0)return!0;for(o=l.child;o!==null;){if((o.flags&8218)!==0||(o.subtreeFlags&8218)!==0)return!0;o=o.sibling}return!1}function Td(o,l,p,v){if(gn)for(p=l.child;p!==null;){if(p.tag===5||p.tag===6)hc(o,p.stateNode);else if(!(p.tag===4||Li&&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(ja)for(var T=l.child;T!==null;){if(T.tag===5){var C=T.stateNode;p&&v&&(C=Rg(C,T.type,T.memoizedProps)),hc(o,C)}else if(T.tag===6)C=T.stateNode,p&&v&&(C=tp(C,T.memoizedProps)),hc(o,C);else if(T.tag!==4){if(T.tag===22&&T.memoizedState!==null)C=T.child,C!==null&&(C.return=T),Td(o,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 ng(o,l,p,v){var T=!1;if(ja)for(var C=l.child;C!==null;){if(C.tag===5){var F=C.stateNode;p&&v&&(F=Rg(F,C.type,C.memoizedProps)),$d(o,F)}else if(C.tag===6)F=C.stateNode,p&&v&&(F=tp(F,C.memoizedProps)),$d(o,F);else if(C.tag!==4){if(C.tag===22&&C.memoizedState!==null)T=C.child,T!==null&&(T.return=C),ng(o,C,!0,!0),T=!0;else if(C.child!==null){C.child.return=C,C=C.child;continue}}if(C===l)break;for(;C.sibling===null;){if(C.return===null||C.return===l)return T;C=C.return}C.sibling.return=C.return,C=C.sibling}return T}function ig(o,l){if(ja&&tg(o,l)){o=l.stateNode;var p=o.containerInfo,v=Jd();ng(v,l,!1,!1),o.pendingChildren=v,os(l),Cg(p,v)}}function Ad(o,l,p,v){if(gn)o.memoizedProps!==v&&os(l);else if(ja){var T=o.stateNode,C=o.memoizedProps;if((o=tg(o,l))||C!==v){var F=Xi.current;C=wg(T,p,C,v,!o,null),C===T?l.stateNode=T:(Ju(l),Ma(C,p,v,F)&&os(l),l.stateNode=C,o&&Td(C,l,!1,!1))}else l.stateNode=T}}function ca(o,l,p,v,T){if((o.mode&32)!==0&&(p===null?dc(l,v):su(l,p,v))){if(o.flags|=16777216,(T&335544128)===T||Vd(l,v))if(ni(o.stateNode,l,v))o.flags|=8192;else if(mn())o.flags|=8192;else throw ma=lr,uh}else o.flags&=-16777217}function Hl(o,l){if(dp(l)){if(o.flags|=16777216,!pp(l))if(mn())o.flags|=8192;else throw ma=lr,uh}else o.flags&=-16777217}function $u(o,l){l!==null&&(o.flags|=4),o.flags&16384&&(l=o.tag!==22?U():536870912,o.lanes|=l,pu|=l)}function Gl(o,l){if(!dn)switch(o.tailMode){case"hidden":l=o.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?o.tail=null:p.sibling=null;break;case"collapsed":p=o.tail;for(var v=null;p!==null;)p.alternate!==null&&(v=p),p=p.sibling;v===null?l||o.tail===null?o.tail=null:o.tail.sibling=null:v.sibling=null}}function Fn(o){var l=o.alternate!==null&&o.alternate.child===o.child,p=0,v=0;if(l)for(var T=o.child;T!==null;)p|=T.lanes|T.childLanes,v|=T.subtreeFlags&65011712,v|=T.flags&65011712,T.return=o,T=T.sibling;else for(T=o.child;T!==null;)p|=T.lanes|T.childLanes,v|=T.subtreeFlags,v|=T.flags,T.return=o,T=T.sibling;return o.subtreeFlags|=v,o.childLanes=p,l}function ag(o,l,p){var v=l.pendingProps;switch(Ae(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Fn(l),null;case 1:return Fn(l),null;case 3:return p=l.stateNode,v=null,o!==null&&(v=o.memoizedState.cache),l.memoizedState.cache!==v&&(l.flags|=2048),nt(Kn),de(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(o===null||o.child===null)&&(tn(l)?os(l):o===null||o.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Le())),ig(o,l),Fn(l),null;case 26:if(ms){var T=l.type,C=l.memoizedState;return o===null?(os(l),C!==null?(Fn(l),Hl(l,C)):(Fn(l),ca(l,T,null,v,p))):C?C!==o.memoizedState?(os(l),Fn(l),Hl(l,C)):(Fn(l),l.flags&=-16777217):(C=o.memoizedProps,gn?C!==v&&os(l):Ad(o,l,T,v),Fn(l),ca(l,T,C,v,p)),null}case 27:if(Li){if(tt(l),p=Ki.current,T=l.type,o!==null&&l.stateNode!=null)gn?o.memoizedProps!==v&&os(l):Ad(o,l,T,v);else{if(!v){if(l.stateNode===null)throw Error(s(166));return Fn(l),null}o=Xi.current,tn(l)?ht(l,o):(o=Jf(T,v,p,o,!0),l.stateNode=o,os(l))}return Fn(l),null}case 5:if(tt(l),T=l.type,o!==null&&l.stateNode!=null)Ad(o,l,T,v);else{if(!v){if(l.stateNode===null)throw Error(s(166));return Fn(l),null}if(C=Xi.current,tn(l))ht(l,C),Wg(l.stateNode,T,v,C)&&(l.flags|=64);else{var F=Fd(T,v,Ki.current,C,l);Ju(l),Td(F,l,!1,!1),l.stateNode=F,Ma(F,T,v,C)&&os(l)}}return Fn(l),ca(l,l.type,o===null?null:o.memoizedProps,l.pendingProps,p),null;case 6:if(o&&l.stateNode!=null)p=o.memoizedProps,gn?p!==v&&os(l):ja&&(p!==v?(o=Ki.current,p=Xi.current,Ju(l),l.stateNode=Ur(v,o,p,l)):l.stateNode=o.stateNode);else{if(typeof v!="string"&&l.stateNode===null)throw Error(s(166));if(o=Ki.current,p=Xi.current,tn(l)){if(!Zn)throw Error(s(176));if(o=l.stateNode,p=l.memoizedProps,v=null,T=Ui,T!==null)switch(T.tag){case 27:case 5:v=T.memoizedProps}o_(o,p,l,v)||st(l,!0)}else Ju(l),l.stateNode=Ur(v,o,p,l)}return Fn(l),null;case 31:if(p=l.memoizedState,o===null||o.memoizedState!==null){if(v=tn(l),p!==null){if(o===null){if(!v)throw Error(s(318));if(!Zn)throw Error(s(556));if(o=l.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(s(557));sp(o,l)}else Nt(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Fn(l),o=!1}else p=Le(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=p),o=!0;if(!o)return l.flags&256?(Je(l),l):(Je(l),null);if((l.flags&128)!==0)throw Error(s(558))}return Fn(l),null;case 13:if(v=l.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(T=tn(l),v!==null&&v.dehydrated!==null){if(o===null){if(!T)throw Error(s(318));if(!Zn)throw Error(s(344));if(T=l.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(s(317));Vg(T,l)}else Nt(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Fn(l),T=!1}else T=Le(),o!==null&&o.memoizedState!==null&&(o.memoizedState.hydrationErrors=T),T=!0;if(!T)return l.flags&256?(Je(l),l):(Je(l),null)}return Je(l),(l.flags&128)!==0?(l.lanes=p,l):(p=v!==null,o=o!==null&&o.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),C=null,v.memoizedState!==null&&v.memoizedState.cachePool!==null&&(C=v.memoizedState.cachePool.pool),C!==T&&(v.flags|=2048)),p!==o&&p&&(l.child.flags|=8192),$u(l,l.updateQueue),Fn(l),null);case 4:return de(),ig(o,l),o===null&&On(l.stateNode.containerInfo),Fn(l),null;case 10:return nt(l.type),Fn(l),null;case 19:if(M(ui),v=l.memoizedState,v===null)return Fn(l),null;if(T=(l.flags&128)!==0,C=v.rendering,C===null)if(T)Gl(v,!1);else{if(si!==0||o!==null&&(o.flags&128)!==0)for(o=l.child;o!==null;){if(C=mt(o),C!==null){for(l.flags|=128,Gl(v,!1),o=C.updateQueue,l.updateQueue=o,$u(l,o),l.subtreeFlags=0,o=p,p=l.child;p!==null;)Of(p,o),p=p.sibling;return A(ui,ui.current&1|2),dn&&Ne(l,v.treeForkCount),l.child}o=o.sibling}v.tail!==null&&aa()>Co&&(l.flags|=128,T=!0,Gl(v,!1),l.lanes=4194304)}else{if(!T)if(o=mt(C),o!==null){if(l.flags|=128,T=!0,o=o.updateQueue,l.updateQueue=o,$u(l,o),Gl(v,!0),v.tail===null&&v.tailMode==="hidden"&&!C.alternate&&!dn)return Fn(l),null}else 2*aa()-v.renderingStartTime>Co&&p!==536870912&&(l.flags|=128,T=!0,Gl(v,!1),l.lanes=4194304);v.isBackwards?(C.sibling=l.child,l.child=C):(o=v.last,o!==null?o.sibling=C:l.child=C,v.last=C)}return v.tail!==null?(o=v.tail,v.rendering=o,v.tail=o.sibling,v.renderingStartTime=aa(),o.sibling=null,p=ui.current,A(ui,T?p&1|2:p&1),dn&&Ne(l,v.treeForkCount),o):(Fn(l),null);case 22:case 23:return Je(l),k(),v=l.memoizedState!==null,o!==null?o.memoizedState!==null!==v&&(l.flags|=8192):v&&(l.flags|=8192),v?(p&536870912)!==0&&(l.flags&128)===0&&(Fn(l),l.subtreeFlags&6&&(l.flags|=8192)):Fn(l),p=l.updateQueue,p!==null&&$u(l,p.retryQueue),p=null,o!==null&&o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(p=o.memoizedState.cachePool.pool),v=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(v=l.memoizedState.cachePool.pool),v!==p&&(l.flags|=2048),o!==null&&M(xo),null;case 24:return p=null,o!==null&&(p=o.memoizedState.cache),l.memoizedState.cache!==p&&(l.flags|=2048),nt(Kn),Fn(l),null;case 25:return null;case 30:return null}throw Error(s(156,l.tag))}function wd(o,l){switch(Ae(l),l.tag){case 1:return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 3:return nt(Kn),de(),o=l.flags,(o&65536)!==0&&(o&128)===0?(l.flags=o&-65537|128,l):null;case 26:case 27:case 5:return tt(l),null;case 31:if(l.memoizedState!==null){if(Je(l),l.alternate===null)throw Error(s(340));Nt()}return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 13:if(Je(l),o=l.memoizedState,o!==null&&o.dehydrated!==null){if(l.alternate===null)throw Error(s(340));Nt()}return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 19:return M(ui),null;case 4:return de(),null;case 10:return nt(l.type),null;case 22:case 23:return Je(l),k(),o!==null&&M(xo),o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 24:return nt(Kn),null;case 25:return null;default:return null}}function sg(o,l){switch(Ae(l),l.tag){case 3:nt(Kn),de();break;case 26:case 27:case 5:tt(l);break;case 4:de();break;case 31:l.memoizedState!==null&&Je(l);break;case 13:Je(l);break;case 19:M(ui);break;case 10:nt(l.type);break;case 22:case 23:Je(l),k(),o!==null&&M(xo);break;case 24:nt(Kn)}}function js(o,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&o)===o){v=void 0;var C=p.create,F=p.inst;v=C(),F.destroy=v}p=p.next}while(p!==T)}}catch(ee){Vt(l,l.return,ee)}}function Ys(o,l,p){try{var v=l.updateQueue,T=v!==null?v.lastEffect:null;if(T!==null){var C=T.next;v=C;do{if((v.tag&o)===o){var F=v.inst,ee=F.destroy;if(ee!==void 0){F.destroy=void 0,T=l;var we=p,ke=ee;try{ke()}catch(it){Vt(T,we,it)}}}v=v.next}while(v!==C)}}catch(it){Vt(l,l.return,it)}}function Xl(o){var l=o.updateQueue;if(l!==null){var p=o.stateNode;try{Mr(l,p)}catch(v){Vt(o,o.return,v)}}}function Ef(o,l,p){p.props=Yo(o.type,o.memoizedProps),p.state=o.memoizedState;try{p.componentWillUnmount()}catch(v){Vt(o,l,v)}}function Wl(o,l){try{var p=o.ref;if(p!==null){switch(o.tag){case 26:case 27:case 5:var v=nu(o.stateNode);break;case 30:v=o.stateNode;break;default:v=o.stateNode}typeof p=="function"?o.refCleanup=p(v):p.current=v}}catch(T){Vt(o,l,T)}}function ia(o,l){var p=o.ref,v=o.refCleanup;if(p!==null)if(typeof v=="function")try{v()}catch(T){Vt(o,l,T)}finally{o.refCleanup=null,o=o.alternate,o!=null&&(o.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(T){Vt(o,l,T)}else p.current=null}function Jo(o){var l=o.type,p=o.memoizedProps,v=o.stateNode;try{_g(v,l,p,o)}catch(T){Vt(o,o.return,T)}}function ec(o,l,p){try{xg(o.stateNode,o.type,p,l,o)}catch(v){Vt(o,o.return,v)}}function Cd(o){return o.tag===5||o.tag===3||(ms?o.tag===26:!1)||(Li?o.tag===27&&ul(o.type):!1)||o.tag===4}function Tr(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||Cd(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(Li&&o.tag===27&&ul(o.type)||o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Tf(o,l,p){var v=o.tag;if(v===5||v===6)o=o.stateNode,l?Sg(p,o,l):Yd(p,o);else if(v!==4&&(Li&&v===27&&ul(o.type)&&(p=o.stateNode,l=null),o=o.child,o!==null))for(Tf(o,l,p),o=o.sibling;o!==null;)Tf(o,l,p),o=o.sibling}function tc(o,l,p){var v=o.tag;if(v===5||v===6)o=o.stateNode,l?bg(p,o,l):jd(p,o);else if(v!==4&&(Li&&v===27&&ul(o.type)&&(p=o.stateNode),o=o.child,o!==null))for(tc(o,l,p),o=o.sibling;o!==null;)tc(o,l,p),o=o.sibling}function Rd(o,l,p){o=o.containerInfo;try{ep(o,p)}catch(v){Vt(l,l.return,v)}}function rg(o){var l=o.stateNode,p=o.memoizedProps;try{Mi(o.type,p,l,o)}catch(v){Vt(o,o.return,v)}}function i_(o,l){for(Vf(o.containerInfo),mi=l;mi!==null;)if(o=mi,l=o.child,(o.subtreeFlags&1028)!==0&&l!==null)l.return=o,mi=l;else for(;mi!==null;){o=mi;var p=o.alternate;switch(l=o.flags,o.tag){case 0:if((l&4)!==0&&(l=o.updateQueue,l=l!==null?l.events:null,l!==null))for(var v=0;v";case fu:return":has("+(Yl(o)||"")+")";case hu:return'[role="'+o.value+'"]';case Eo:return'"'+o.value+'"';case Ec:return'[data-testname="'+o.value+'"]';default:throw Error(s(365))}}function Zl(o,l){var p=[];o=[o,0];for(var v=0;vp?32:p;p=Ut.T;var T=ps();try{hn(v),Ut.T=null,v=hh,hh=null;var C=Vr,F=hr;if(Ti=0,_l=Vr=null,hr=0,(cn&6)!==0)throw Error(s(331));var ee=cn;if(cn|=4,Rf(C.current),wf(C,C.current,F,v),cn=ee,Ke(0,!1),Aa&&typeof Aa.onPostCommitFiberRoot=="function")try{Aa.onPostCommitFiberRoot(hl,C)}catch{}return!0}finally{hn(T),Ut.T=p,If(o,l)}}function fo(o,l,p){l=be(p,l),l=gd(o.stateNode,l,2),o=Ha(o,l,2),o!==null&&(z(o,2),dt(o))}function Vt(o,l,p){if(o.tag===3)fo(o,o,p);else for(;l!==null;){if(l.tag===3){fo(l,o,p);break}else if(l.tag===1){var v=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof v.componentDidCatch=="function"&&(kr===null||!kr.has(v))){o=be(p,o),p=qm(2),v=Ha(l,p,2),v!==null&&(jm(p,v,l,o),z(v,2),dt(v));break}}l=l.return}}function $l(o,l,p){var v=o.pingCache;if(v===null){v=o.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)||(Ao=!0,T.add(p),o=fg.bind(null,o,l,p),l.then(o,o))}function fg(o,l,p){var v=o.pingCache;v!==null&&v.delete(l),o.pingedLanes|=o.suspendedLanes&p,o.warmLanes&=~p,rn===o&&(pn&p)===p&&(si===4||si===3&&(pn&62914560)===pn&&300>aa()-Ac?(cn&2)===0&&li(o,0):du|=p,pu===pn&&(pu=0)),dt(o)}function hg(o,l){l===0&&(l=U()),o=na(o,l),o!==null&&(z(o,l),dt(o))}function a_(o){var l=o.memoizedState,p=0;l!==null&&(p=l.retryLane),hg(o,p)}function s_(o,l){var p=0;switch(o.tag){case 31:case 13:var v=o.stateNode,T=o.memoizedState;T!==null&&(p=T.retryLane);break;case 19:v=o.stateNode;break;case 22:v=o.stateNode._retryCache;break;default:throw Error(s(314))}v!==null&&v.delete(l),hg(o,p)}function Si(o,l){return vc(o,l)}function Ld(o,l,p,v){this.tag=o,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 $o(o){return o=o.prototype,!(!o||!o.isReactComponent)}function qa(o,l){var p=o.alternate;return p===null?(p=t(o.tag,l,o.key,o.mode),p.elementType=o.elementType,p.type=o.type,p.stateNode=o.stateNode,p.alternate=o,o.alternate=p):(p.pendingProps=l,p.type=o.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=o.flags&65011712,p.childLanes=o.childLanes,p.lanes=o.lanes,p.child=o.child,p.memoizedProps=o.memoizedProps,p.memoizedState=o.memoizedState,p.updateQueue=o.updateQueue,l=o.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=o.sibling,p.index=o.index,p.ref=o.ref,p.refCleanup=o.refCleanup,p}function Of(o,l){o.flags&=65011714;var p=o.alternate;return p===null?(o.childLanes=0,o.lanes=l,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=p.childLanes,o.lanes=p.lanes,o.child=p.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=p.memoizedProps,o.memoizedState=p.memoizedState,o.updateQueue=p.updateQueue,o.type=p.type,l=p.dependencies,o.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),o}function Nr(o,l,p,v,T,C){var F=0;if(v=o,typeof o=="function")$o(o)&&(F=1);else if(typeof o=="string")F=ms&&Li?Qf(o,p,Xi.current)?26:mp(o)?27:5:ms?Qf(o,p,Xi.current)?26:5:Li&&mp(o)?27:5;else e:switch(o){case cc:return o=t(31,p,l,T),o.elementType=cc,o.lanes=C,o;case il:return hs(p.children,T,C,l);case al:F=8,T|=24;break;case sl:return o=t(12,p,l,T|2),o.elementType=sl,o.lanes=C,o;case Ff:return o=t(13,p,l,T),o.elementType=Ff,o.lanes=C,o;case Dr:return o=t(19,p,l,T),o.elementType=Dr,o.lanes=C,o;default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case ds:F=10;break e;case uc:F=9;break e;case eu:F=11;break e;case kf:F=14;break e;case ha:F=16,v=null;break e}F=29,p=Error(s(130,o===null?"null":typeof o,"")),v=null}return l=t(F,p,l,T),l.elementType=o,l.type=v,l.lanes=C,l}function hs(o,l,p,v){return o=t(7,o,v,l),o.lanes=p,o}function Ud(o,l,p){return o=t(6,o,null,l),o.lanes=p,o}function Id(o){var l=t(18,null,null,0);return l.stateNode=o,l}function Od(o,l,p){return l=t(4,o.children!==null?o.children:[],o.key,l),l.lanes=p,l.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},l}function dg(o,l,p,v,T,C,F,ee,we){this.tag=1,this.containerInfo=o,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=Ea,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=C,this.onRecoverableError=F,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=we,this.incompleteTransitions=new Map}function ho(o,l,p,v,T,C,F,ee,we,ke,it,We){return o=new dg(o,l,p,F,we,ke,it,We,ee),l=1,C===!0&&(l|=24),C=t(3,null,null,l),o.current=C,C.stateNode=o,l=Te(),l.refCount++,o.pooledCache=l,l.refCount++,C.memoizedState={element:v,isDehydrated:p,cache:l},Ri(C),o}function Pf(o){return o?(o=ar,o):ar}function oc(o){var l=o._reactInternals;if(l===void 0)throw typeof o.render=="function"?Error(s(188)):(o=Object.keys(o).join(","),Error(s(268,o)));return o=h(l),o=o!==null?m(o):null,o===null?null:nu(o.stateNode)}function Pd(o,l,p,v,T,C){T=Pf(T),v.context===null?v.context=T:v.pendingContext=T,v=Va(l),v.payload={element:p},C=C===void 0?null:C,C!==null&&(v.callback=C),p=Ha(o,v,l),p!==null&&(ti(p,o,l),$r(p,o,l))}function el(o,l){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var p=o.retryLane;o.retryLane=p!==0&&p=ke&&C>=We&&T<=it&&F<=gt){o.splice(l,1);break}else if(v!==ke||p.width!==we.width||gtF){if(!(C!==We||p.height!==we.height||itT)){ke>v&&(we.width+=ke-v,we.x=v),itC&&(we.height+=We-C,we.y=C),gtp&&(p=ee)),ee ")+` No matching component was found for: `)+o.join(" > ")}return null},an.getPublicRootInstance=function(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 27:case 5:return nu(o.child.stateNode);default:return o.child.stateNode}},an.injectIntoDevTools=function(){var o={bundleType:0,version:Bd,rendererPackageName:fc,currentDispatcherRef:Ut,reconcilerVersion:"19.2.0"};if(tu!==null&&(o.rendererConfig=tu),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")o=!1;else{var l=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(l.isDisabled||!l.supportsFiber)o=!0;else{try{hl=l.inject(o),Aa=l}catch{}o=!!l.checkDCE}}return o},an.isAlreadyRendering=function(){return(cn&6)!==0},an.observeVisibleRects=function(o,l,p,v){if(!Di)throw Error(s(363));o=ba(o,l);var T=Wf(o,p,v).disconnect;return{disconnect:function(){T()}}},an.shouldError=function(){return null},an.shouldSuspend=function(){return!1},an.startHostTransition=function(o,l,p,v){if(o.tag!==5)throw Error(s(476));var T=km(o).queue;Fm(o,T,l,ol,p===null?n:function(){var C=km(o);return C.next===null&&(C=o.alternate.memoizedState),Zu(o,C.next.queue,{},Yn()),p(v)})},an.updateContainer=function(o,l,p,v){var T=l.current,C=Yn();return Pd(T,C,o,l,p,v),C},an.updateContainerSync=function(o,l,p,v){return Pd(l.current,2,o,l,p,v),2},an},r.exports.default=r.exports,Object.defineProperty(r.exports,"__esModule",{value:!0})})(H1)),H1.exports}var X1;function Ez(){return X1||(X1=1,V1.exports=Mz()),V1.exports}var Tz=Ez();const Az=Sz(Tz);function wz(r){const e=Az(r);return e.injectIntoDevTools(),e}const sA=0,nd={},Cz=/^three(?=[A-Z])/,Jy=r=>`${r[0].toUpperCase()}${r.slice(1)}`;let Rz=0;const Nz=r=>typeof r=="function";function Dz(r){if(Nz(r)){const e=`${Rz++}`;return nd[e]=r,e}else Object.assign(nd,r)}function rA(r,e){const t=Jy(r),n=nd[t];if(r!=="primitive"&&!n)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(r==="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 Lz(r,e,t){var n;return r=Jy(r)in nd?r:r.replace(Cz,""),rA(r,e),r==="primitive"&&(n=e.object)!=null&&n.__r3f&&delete e.object.__r3f,uy(e.object,t,r,e)}function Uz(r){if(!r.isHidden){var e;r.props.attach&&(e=r.parent)!=null&&e.object?fy(r.parent,r):ws(r.object)&&(r.object.visible=!1),r.isHidden=!0,od(r)}}function oA(r){if(r.isHidden){var e;r.props.attach&&(e=r.parent)!=null&&e.object?cy(r.parent,r):ws(r.object)&&r.props.visible!==!1&&(r.object.visible=!0),r.isHidden=!1,od(r)}}function oS(r,e,t){const n=e.root.getState();if(!(!r.parent&&r.object!==n.scene)){if(!e.object){var s,u;const f=nd[Jy(e.type)];e.object=(s=e.props.object)!=null?s:new f(...(u=e.props.args)!=null?u:[]),e.object.__r3f=e}if(Lu(e.object,e.props),e.props.attach)cy(r,e);else if(ws(e.object)&&ws(r.object)){const f=r.object.children.indexOf(t?.object);if(t&&f!==-1){const h=r.object.children.indexOf(e.object);if(h!==-1){r.object.children.splice(h,1);const m=h{try{r.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<"u"?e():sb.unstable_scheduleCallback(sb.unstable_IdlePriority,e)}}function ob(r,e,t){if(!e)return;e.parent=null;const n=r.children.indexOf(e);n!==-1&&r.children.splice(n,1),e.props.attach?fy(r,e):ws(e.object)&&ws(r.object)&&(r.object.remove(e.object),dz(KT(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];ob(e,f,s)}e.children.length=0,delete e.object.__r3f,s&&e.type!=="primitive"&&e.object.type!=="Scene"&&lA(e.object),t===void 0&&od(e)}function Iz(r,e){for(const t of[r,r.alternate])if(t!==null)if(typeof t.ref=="function"){t.refCleanup==null||t.refCleanup();const n=t.ref(e);typeof n=="function"&&(t.refCleanup=n)}else t.ref&&(t.ref.current=e)}const gv=[];function Oz(){for(const[t]of gv){const n=t.parent;if(n){t.props.attach?fy(n,t):ws(t.object)&&ws(n.object)&&n.object.remove(t.object);for(const s of t.children)s.props.attach?fy(t,s):ws(s.object)&&ws(t.object)&&t.object.remove(s.object)}t.isHidden&&oA(t),t.object.__r3f&&delete t.object.__r3f,t.type!=="primitive"&&lA(t.object)}for(const[t,n,s]of gv){t.props=n;const u=t.parent;if(u){var r,e;const f=nd[Jy(t.type)];t.object=(r=t.props.object)!=null?r:new f(...(e=t.props.args)!=null?e:[]),t.object.__r3f=t,Iz(s,t.object),Lu(t.object,t.props),t.props.attach?cy(u,t):ws(t.object)&&ws(u.object)&&u.object.add(t.object);for(const h of t.children)h.props.attach?cy(t,h):ws(h.object)&&ws(t.object)&&t.object.add(h.object);od(t)}}gv.length=0}const Ix=()=>{},q1={};let cv=sA;const Pz=0,zz=4,lb=wz({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:Lz,removeChild:ob,appendChild:Ux,appendInitialChild:Ux,insertBefore:W1,appendChildToContainer(r,e){const t=r.getState().scene.__r3f;!e||!t||Ux(t,e)},removeChildFromContainer(r,e){const t=r.getState().scene.__r3f;!e||!t||ob(t,e)},insertInContainerBefore(r,e,t){const n=r.getState().scene.__r3f;!e||!t||!n||W1(n,e,t)},getRootHostContext:()=>q1,getChildHostContext:()=>q1,commitUpdate(r,e,t,n,s){var u,f,h;rA(e,n);let m=!1;if((r.type==="primitive"&&t.object!==n.object||((u=n.args)==null?void 0:u.length)!==((f=t.args)==null?void 0:f.length)||(h=n.args)!=null&&h.some((_,x)=>{var b;return _!==((b=t.args)==null?void 0:b[x])}))&&(m=!0),m)gv.push([r,{...n},s]);else{const _=uz(r,n);Object.keys(_).length&&(Object.assign(r.props,_),Lu(r.object,_))}(s.sibling===null||(s.flags&zz)===Pz)&&Oz()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:r=>r?.object,prepareForCommit:()=>null,preparePortalMount:r=>uy(r.getState().scene,r,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:Uz,unhideInstance:oA,createTextInstance:Ix,hideTextInstance:Ix,unhideTextInstance:Ix,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:rt.createContext(null),setCurrentUpdatePriority(r){cv=r},getCurrentUpdatePriority(){return cv},resolveUpdatePriority(){var r;if(cv!==sA)return cv;switch(typeof window<"u"&&((r=window.event)==null?void 0:r.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return xz;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return yz;default:return _z}},resetFormInstance(){},rendererPackageName:"@react-three/fiber",rendererVersion:bz.version,applyViewTransitionName(r,e,t){},restoreViewTransitionName(r,e){},cancelViewTransitionName(r,e,t){},cancelRootViewTransitionName(r){},restoreRootViewTransitionName(r){},InstanceMeasurement:null,measureInstance:r=>null,wasInstanceInViewport:r=>!0,hasInstanceChanged:(r,e)=>!1,hasInstanceAffectedParent:(r,e)=>!1,suspendOnActiveViewTransition(r,e){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(r){},createViewTransitionInstance:r=>null,getCurrentGestureOffset(r){throw new Error("startGestureTransition is not yet supported in react-three-fiber.")},cloneMutableInstance(r,e){return r},cloneMutableTextInstance(r){return r},cloneRootViewTransitionContainer(r){throw new Error("Not implemented.")},removeRootViewTransitionClone(r,e){throw new Error("Not implemented.")},createFragmentInstance:r=>null,updateFragmentInstanceFiber(r,e){},commitNewChildToFragmentInstance(r,e){},deleteChildFromFragmentInstance(r,e){},measureClonedInstance:r=>null,maySuspendCommitOnUpdate:(r,e,t)=>!1,maySuspendCommitInSyncRender:(r,e)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(r,e)=>null}),sf=new Map,Fh={objects:"shallow",strict:!1};function Bz(r,e){if(!e&&typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement&&r.parentElement){const{width:t,height:n,top:s,left:u}=r.parentElement.getBoundingClientRect();return{width:t,height:n,top:s,left:u}}else if(!e&&typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height,top:0,left:0};return{width:0,height:0,top:0,left:0,...e}}function Fz(r){const e=sf.get(r),t=e?.fiber,n=e?.store;e&&console.warn("R3F.createRoot should only be called once!");const s=typeof reportError=="function"?reportError:console.error,u=n||mz(fb,Y1),f=t||lb.createContainer(u,vz,null,!1,null,"",s,s,s,null);e||sf.set(r,{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:w,onCreated:E,shadows:N=!1,linear:D=!1,flat:U=!1,legacy:B=!1,orthographic:z=!1,frameloop:H="always",dpr:W=[1,2],performance:I,raycaster:P,camera:Z,onPointerMissed:se}=x,te=u.getState(),fe=te.gl;if(!te.gl){const X={canvas:r,powerPreference:"high-performance",antialias:!0,alpha:!0},oe=typeof M=="function"?await M(X):M;k1(oe)?fe=oe:fe=new jT({...X,...M}),te.set({gl:fe})}let pe=te.raycaster;pe||te.set({raycaster:pe=new FT});const{params:Y,...q}=P||{};if(yi.equ(q,pe,Fh)||Lu(pe,{...q}),yi.equ(Y,pe.params,Fh)||Lu(pe,{params:{...pe.params,...Y}}),!te.camera||te.camera===m&&!yi.equ(m,Z,Fh)){m=Z;const X=Z?.isCamera,oe=X?Z:z?new Dl(0,0,0,0,.1,1e3):new zi(75,0,.1,1e3);X||(oe.position.z=5,Z&&(Lu(oe,Z),oe.manual||("aspect"in Z||"left"in Z||"right"in Z||"bottom"in Z||"top"in Z)&&(oe.manual=!0,oe.updateProjectionMatrix())),!te.camera&&!(Z!=null&&Z.rotation)&&oe.lookAt(0,0,0)),te.set({camera:oe}),pe.camera=oe}if(!te.scene){let X;R!=null&&R.isScene?(X=R,uy(X,u,"",{})):(X=new Lb,uy(X,u,"",{}),R&&Lu(X,R)),te.set({scene:X})}w&&!te.events.handlers&&te.set({events:w(u)});const ne=Bz(r,A);if(yi.equ(ne,te.size,Fh)||te.setSize(ne.width,ne.height,ne.top,ne.left),W&&te.viewport.dpr!==eA(W)&&te.setDpr(W),te.frameloop!==H&&te.setFrameloop(H),te.onPointerMissed||te.set({onPointerMissed:se}),I&&!yi.equ(I,te.performance,Fh)&&te.set(X=>({performance:{...X.performance,...I}})),!te.xr){var be;const X=(Fe,lt)=>{const de=u.getState();de.frameloop!=="never"&&Y1(Fe,!0,de,lt)},oe=()=>{const Fe=u.getState();Fe.gl.xr.enabled=Fe.gl.xr.isPresenting,Fe.gl.xr.setAnimationLoop(Fe.gl.xr.isPresenting?X:null),Fe.gl.xr.isPresenting||fb(Fe)},Ae={connect(){const Fe=u.getState().gl;Fe.xr.addEventListener("sessionstart",oe),Fe.xr.addEventListener("sessionend",oe)},disconnect(){const Fe=u.getState().gl;Fe.xr.removeEventListener("sessionstart",oe),Fe.xr.removeEventListener("sessionend",oe)}};typeof((be=fe.xr)==null?void 0:be.addEventListener)=="function"&&Ae.connect(),te.set({xr:Ae})}if(fe.shadowMap){const X=fe.shadowMap.enabled,oe=fe.shadowMap.type;if(fe.shadowMap.enabled=!!N,yi.boo(N))fe.shadowMap.type=Kp;else if(yi.str(N)){var Ne;const Ae={basic:sE,percentage:Xh,soft:Kp,variance:jc};fe.shadowMap.type=(Ne=Ae[N])!=null?Ne:Kp}else yi.obj(N)&&Object.assign(fe.shadowMap,N);(X!==fe.shadowMap.enabled||oe!==fe.shadowMap.type)&&(fe.shadowMap.needsUpdate=!0)}return Sn.enabled=!B,g||(fe.outputColorSpace=D?zu:Ia,fe.toneMapping=U?gr:gy),te.legacy!==B&&te.set(()=>({legacy:B})),te.linear!==D&&te.set(()=>({linear:D})),te.flat!==U&&te.set(()=>({flat:U})),M&&!yi.fun(M)&&!k1(M)&&!yi.equ(M,fe,Fh)&&Lu(fe,M),h=E,g=!0,b(),this},render(x){return!g&&!_&&this.configure(),_.then(()=>{lb.updateContainer(he.jsx(kz,{store:u,children:x,onCreated:h,rootElement:r}),f,null,()=>{})}),u},unmount(){uA(r)}}}function kz({store:r,children:e,onCreated:t,rootElement:n}){return Om(()=>{const s=r.getState();s.set(u=>({internal:{...u.internal,active:!0}})),t&&t(s),r.getState().events.connected||s.events.connect==null||s.events.connect(n)},[]),he.jsx(iA.Provider,{value:r,children:e})}function uA(r,e){const t=sf.get(r),n=t?.fiber;if(n){const s=t?.store.getState();s&&(s.internal.active=!1),lb.updateContainer(null,n,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(),rz(s.scene),sf.delete(r)}catch{}},500)})}}const Vz=new Set,Hz=new Set,Gz=new Set;function Ox(r,e){if(r.size)for(const{callback:t}of r.values())t(e)}function rm(r,e){switch(r){case"before":return Ox(Vz,e);case"after":return Ox(Hz,e);case"tail":return Ox(Gz,e)}}let Px,zx;function ub(r,e,t){let n=e.clock.getDelta();e.frameloop==="never"&&typeof r=="number"&&(n=r-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=r),Px=e.internal.subscribers;for(let s=0;s0)&&!((e=kh.gl.xr)!=null&&e.isPresenting)&&(Bx+=ub(r,kh))}if(cb=!1,rm("after",r),Bx===0)return rm("tail",r),hy=!1,cancelAnimationFrame(j1)}function fb(r,e=1){var t;if(!r)return sf.forEach(n=>fb(n.store.getState(),e));(t=r.gl.xr)!=null&&t.isPresenting||!r.internal.active||r.frameloop==="never"||(e>1?r.internal.frames=Math.min(60,r.internal.frames+e):cb?r.internal.frames=2:r.internal.frames=1,hy||(hy=!0,requestAnimationFrame(cA)))}function Y1(r,e=!0,t,n){if(e&&rm("before",r),t)ub(r,t,n);else for(const s of sf.values())ub(r,s.store.getState());e&&rm("after",r)}const Fx={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 Xz(r){const{handlePointer:e}=pz(r);return{priority:1,enabled:!0,compute(t,n,s){n.pointer.set(t.offsetX/n.size.width*2-1,-(t.offsetY/n.size.height)*2+1),n.raycaster.setFromCamera(n.pointer,n.camera)},connected:void 0,handlers:Object.keys(Fx).reduce((t,n)=>({...t,[n]:e(n)}),{}),update:()=>{var t;const{events:n,internal:s}=r.getState();(t=s.lastEvent)!=null&&t.current&&n.handlers&&n.handlers.onPointerMove(s.lastEvent.current)},connect:t=>{const{set:n,events:s}=r.getState();if(s.disconnect==null||s.disconnect(),n(u=>({events:{...u.events,connected:t}})),s.handlers)for(const u in s.handlers){const f=s.handlers[u],[h,m]=Fx[u];t.addEventListener(h,f,{passive:m})}},disconnect:()=>{const{set:t,events:n}=r.getState();if(n.connected){if(n.handlers)for(const s in n.handlers){const u=n.handlers[s],[f]=Fx[s];n.connected.removeEventListener(f,u)}t(s=>({events:{...s.events,connected:void 0}}))}}}}function Z1(r,e){let t;return(...n)=>{window.clearTimeout(t),t=window.setTimeout(()=>r(...n),e)}}function Wz({debounce:r,scroll:e,polyfill:t,offsetSize:n}={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]=rt.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),h=rt.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:u,orientationHandler:null}),m=r?typeof r=="number"?r:r.scroll:null,g=r?typeof r=="number"?r:r.resize:null,_=rt.useRef(!1);rt.useEffect(()=>(_.current=!0,()=>{_.current=!1}));const[x,b,M]=rt.useMemo(()=>{const E=()=>{if(!h.current.element)return;const{left:N,top:D,width:U,height:B,bottom:z,right:H,x:W,y:I}=h.current.element.getBoundingClientRect(),P={left:N,top:D,width:U,height:B,bottom:z,right:H,x:W,y:I};h.current.element instanceof HTMLElement&&n&&(P.height=h.current.element.offsetHeight,P.width=h.current.element.offsetWidth),Object.freeze(P),_.current&&!Zz(h.current.lastBounds,P)&&f(h.current.lastBounds=P)};return[E,g?Z1(E,g):E,m?Z1(E,m):E]},[f,n,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 w=E=>{!E||E===h.current.element||(A(),h.current.element=E,h.current.scrollContainers=fA(E),R())};return jz(M,!!e),qz(b),rt.useEffect(()=>{A(),R()},[e,M,b]),rt.useEffect(()=>A,[]),[w,u,x]}function qz(r){rt.useEffect(()=>{const e=r;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[r])}function jz(r,e){rt.useEffect(()=>{if(e){const t=r;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",t,!0)}}},[r,e])}function fA(r){const e=[];if(!r||r===document.body)return e;const{overflow:t,overflowX:n,overflowY:s}=window.getComputedStyle(r);return[t,n,s].some(u=>u==="auto"||u==="scroll")&&e.push(r),[...e,...fA(r.parentElement)]}const Yz=["x","y","top","bottom","left","right","width","height"],Zz=(r,e)=>Yz.every(t=>r[t]===e[t]);function Qz({ref:r,children:e,fallback:t,resize:n,style:s,gl:u,events:f=Xz,eventSource:h,eventPrefix:m,shadows:g,linear:_,flat:x,legacy:b,orthographic:M,frameloop:A,dpr:R,performance:w,raycaster:E,camera:N,scene:D,onPointerMissed:U,onCreated:B,...z}){rt.useMemo(()=>Dz(BP),[]);const H=iz(),[W,I]=Wz({scroll:!0,debounce:{scroll:50,resize:0},...n}),P=rt.useRef(null),Z=rt.useRef(null);rt.useImperativeHandle(r,()=>P.current);const se=$T(U),[te,fe]=rt.useState(!1),[pe,Y]=rt.useState(!1);if(te)throw te;if(pe)throw pe;const q=rt.useRef(null);Om(()=>{const be=P.current;if(I.width>0&&I.height>0&&be){q.current||(q.current=Fz(be));async function Ne(){await q.current.configure({gl:u,scene:D,events:f,shadows:g,linear:_,flat:x,legacy:b,orthographic:M,frameloop:A,dpr:R,performance:w,raycaster:E,camera:N,size:I,onPointerMissed:(...X)=>se.current==null?void 0:se.current(...X),onCreated:X=>{X.events.connect==null||X.events.connect(h?tz(h)?h.current:h:Z.current),m&&X.setEvents({compute:(oe,Ae)=>{const Fe=oe[m+"X"],lt=oe[m+"Y"];Ae.pointer.set(Fe/Ae.size.width*2-1,-(lt/Ae.size.height)*2+1),Ae.raycaster.setFromCamera(Ae.pointer,Ae.camera)}}),B?.(X)}}),q.current.render(he.jsx(H,{children:he.jsx(sz,{set:Y,children:he.jsx(rt.Suspense,{fallback:he.jsx(az,{set:fe}),children:e??null})})}))}Ne()}}),rt.useEffect(()=>{const be=P.current;if(be)return()=>uA(be)},[]);const ne=h?"none":"auto";return he.jsx("div",{ref:Z,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:ne,...s},...z,children:he.jsx("div",{ref:W,style:{width:"100%",height:"100%"},children:he.jsx("canvas",{ref:P,style:{display:"block"},children:t})})})}function Kz(r){return he.jsx(ZT,{children:he.jsx(Qz,{...r})})}var Jz=Object.defineProperty,$z=(r,e,t)=>e in r?Jz(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,e4=(r,e,t)=>($z(r,e+"",t),t);class t4{constructor(){e4(this,"_listeners")}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const s=this._listeners[e];if(s!==void 0){const u=s.indexOf(t);u!==-1&&s.splice(u,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let u=0,f=s.length;ue in r?n4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Bt=(r,e,t)=>(i4(r,typeof e!="symbol"?e+"":e,t),t);const fv=new of,Q1=new wl,a4=Math.cos(70*(Math.PI/180)),K1=(r,e)=>(r%e+e)%e;let s4=class extends t4{constructor(e,t){super(),Bt(this,"object"),Bt(this,"domElement"),Bt(this,"enabled",!0),Bt(this,"target",new j),Bt(this,"minDistance",0),Bt(this,"maxDistance",1/0),Bt(this,"minZoom",0),Bt(this,"maxZoom",1/0),Bt(this,"minPolarAngle",0),Bt(this,"maxPolarAngle",Math.PI),Bt(this,"minAzimuthAngle",-1/0),Bt(this,"maxAzimuthAngle",1/0),Bt(this,"enableDamping",!1),Bt(this,"dampingFactor",.05),Bt(this,"enableZoom",!0),Bt(this,"zoomSpeed",1),Bt(this,"enableRotate",!0),Bt(this,"rotateSpeed",1),Bt(this,"enablePan",!0),Bt(this,"panSpeed",1),Bt(this,"screenSpacePanning",!0),Bt(this,"keyPanSpeed",7),Bt(this,"zoomToCursor",!1),Bt(this,"autoRotate",!1),Bt(this,"autoRotateSpeed",2),Bt(this,"reverseOrbit",!1),Bt(this,"reverseHorizontalOrbit",!1),Bt(this,"reverseVerticalOrbit",!1),Bt(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Bt(this,"mouseButtons",{LEFT:Gc.ROTATE,MIDDLE:Gc.DOLLY,RIGHT:Gc.PAN}),Bt(this,"touches",{ONE:Xc.ROTATE,TWO:Xc.DOLLY_PAN}),Bt(this,"target0"),Bt(this,"position0"),Bt(this,"zoom0"),Bt(this,"_domElementKeyEvents",null),Bt(this,"getPolarAngle"),Bt(this,"getAzimuthalAngle"),Bt(this,"setPolarAngle"),Bt(this,"setAzimuthalAngle"),Bt(this,"getDistance"),Bt(this,"getZoomScale"),Bt(this,"listenToKeyEvents"),Bt(this,"stopListenToKeyEvents"),Bt(this,"saveState"),Bt(this,"reset"),Bt(this,"update"),Bt(this,"connect"),Bt(this,"dispose"),Bt(this,"dollyIn"),Bt(this,"dollyOut"),Bt(this,"getScale"),Bt(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>_.phi,this.getAzimuthalAngle=()=>_.theta,this.setPolarAngle=K=>{let me=K1(K,2*Math.PI),et=_.phi;et<0&&(et+=2*Math.PI),me<0&&(me+=2*Math.PI);let J=Math.abs(me-et);2*Math.PI-J{let me=K1(K,2*Math.PI),et=_.theta;et<0&&(et+=2*Math.PI),me<0&&(me+=2*Math.PI);let J=Math.abs(me-et);2*Math.PI-Jn.object.position.distanceTo(n.target),this.listenToKeyEvents=K=>{K.addEventListener("keydown",Ee),this._domElementKeyEvents=K},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",Ee),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(s),n.update(),m=h.NONE},this.update=(()=>{const K=new j,me=new j(0,1,0),et=new Pa().setFromUnitVectors(e.up,me),J=et.clone().invert(),je=new j,Ge=new Pa,at=2*Math.PI;return function(){const Ue=n.object.position;et.setFromUnitVectors(e.up,me),J.copy(et).invert(),K.copy(Ue).sub(n.target),K.applyQuaternion(et),_.setFromVector3(K),n.autoRotate&&m===h.NONE&&fe(se()),n.enableDamping?(_.theta+=x.theta*n.dampingFactor,_.phi+=x.phi*n.dampingFactor):(_.theta+=x.theta,_.phi+=x.phi);let Ye=n.minAzimuthAngle,Ct=n.maxAzimuthAngle;isFinite(Ye)&&isFinite(Ct)&&(Ye<-Math.PI?Ye+=at:Ye>Math.PI&&(Ye-=at),Ct<-Math.PI?Ct+=at:Ct>Math.PI&&(Ct-=at),Ye<=Ct?_.theta=Math.max(Ye,Math.min(Ct,_.theta)):_.theta=_.theta>(Ye+Ct)/2?Math.max(Ye,_.theta):Math.min(Ct,_.theta)),_.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,_.phi)),_.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(M,n.dampingFactor):n.target.add(M),n.zoomToCursor&&I||n.object.isOrthographicCamera?_.radius=Ae(_.radius):_.radius=Ae(_.radius*b),K.setFromSpherical(_),K.applyQuaternion(J),Ue.copy(n.target).add(K),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(x.theta*=1-n.dampingFactor,x.phi*=1-n.dampingFactor,M.multiplyScalar(1-n.dampingFactor)):(x.set(0,0,0),M.set(0,0,0));let Jt=!1;if(n.zoomToCursor&&I){let nn=null;if(n.object instanceof zi&&n.object.isPerspectiveCamera){const Jn=K.length();nn=Ae(Jn*b);const Ci=Jn-nn;n.object.position.addScaledVector(H,Ci),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const Jn=new j(W.x,W.y,0);Jn.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/b)),n.object.updateProjectionMatrix(),Jt=!0;const Ci=new j(W.x,W.y,0);Ci.unproject(n.object),n.object.position.sub(Ci).add(Jn),n.object.updateMatrixWorld(),nn=K.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;nn!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(nn).add(n.object.position):(fv.origin.copy(n.object.position),fv.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(fv.direction))g||8*(1-Ge.dot(n.object.quaternion))>g?(n.dispatchEvent(s),je.copy(n.object.position),Ge.copy(n.object.quaternion),Jt=!1,!0):!1}})(),this.connect=K=>{n.domElement=K,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",vt),n.domElement.addEventListener("pointerdown",Qe),n.domElement.addEventListener("pointercancel",O),n.domElement.addEventListener("wheel",Ie)},this.dispose=()=>{var K,me,et,J,je,Ge;n.domElement&&(n.domElement.style.touchAction="auto"),(K=n.domElement)==null||K.removeEventListener("contextmenu",vt),(me=n.domElement)==null||me.removeEventListener("pointerdown",Qe),(et=n.domElement)==null||et.removeEventListener("pointercancel",O),(J=n.domElement)==null||J.removeEventListener("wheel",Ie),(je=n.domElement)==null||je.ownerDocument.removeEventListener("pointermove",G),(Ge=n.domElement)==null||Ge.ownerDocument.removeEventListener("pointerup",O),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",Ee)};const n=this,s={type:"change"},u={type:"start"},f={type:"end"},h={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let m=h.NONE;const g=1e-6,_=new eb,x=new eb;let b=1;const M=new j,A=new ze,R=new ze,w=new ze,E=new ze,N=new ze,D=new ze,U=new ze,B=new ze,z=new ze,H=new j,W=new ze;let I=!1;const P=[],Z={};function se(){return 2*Math.PI/60/60*n.autoRotateSpeed}function te(){return Math.pow(.95,n.zoomSpeed)}function fe(K){n.reverseOrbit||n.reverseHorizontalOrbit?x.theta+=K:x.theta-=K}function pe(K){n.reverseOrbit||n.reverseVerticalOrbit?x.phi+=K:x.phi-=K}const Y=(()=>{const K=new j;return function(et,J){K.setFromMatrixColumn(J,0),K.multiplyScalar(-et),M.add(K)}})(),q=(()=>{const K=new j;return function(et,J){n.screenSpacePanning===!0?K.setFromMatrixColumn(J,1):(K.setFromMatrixColumn(J,0),K.crossVectors(n.object.up,K)),K.multiplyScalar(et),M.add(K)}})(),ne=(()=>{const K=new j;return function(et,J){const je=n.domElement;if(je&&n.object instanceof zi&&n.object.isPerspectiveCamera){const Ge=n.object.position;K.copy(Ge).sub(n.target);let at=K.length();at*=Math.tan(n.object.fov/2*Math.PI/180),Y(2*et*at/je.clientHeight,n.object.matrix),q(2*J*at/je.clientHeight,n.object.matrix)}else je&&n.object instanceof Dl&&n.object.isOrthographicCamera?(Y(et*(n.object.right-n.object.left)/n.object.zoom/je.clientWidth,n.object.matrix),q(J*(n.object.top-n.object.bottom)/n.object.zoom/je.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function be(K){n.object instanceof zi&&n.object.isPerspectiveCamera||n.object instanceof Dl&&n.object.isOrthographicCamera?b=K:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function Ne(K){be(b/K)}function X(K){be(b*K)}function oe(K){if(!n.zoomToCursor||!n.domElement)return;I=!0;const me=n.domElement.getBoundingClientRect(),et=K.clientX-me.left,J=K.clientY-me.top,je=me.width,Ge=me.height;W.x=et/je*2-1,W.y=-(J/Ge)*2+1,H.set(W.x,W.y,1).unproject(n.object).sub(n.object.position).normalize()}function Ae(K){return Math.max(n.minDistance,Math.min(n.maxDistance,K))}function Fe(K){A.set(K.clientX,K.clientY)}function lt(K){oe(K),U.set(K.clientX,K.clientY)}function de(K){E.set(K.clientX,K.clientY)}function Re(K){R.set(K.clientX,K.clientY),w.subVectors(R,A).multiplyScalar(n.rotateSpeed);const me=n.domElement;me&&(fe(2*Math.PI*w.x/me.clientHeight),pe(2*Math.PI*w.y/me.clientHeight)),A.copy(R),n.update()}function tt(K){B.set(K.clientX,K.clientY),z.subVectors(B,U),z.y>0?Ne(te()):z.y<0&&X(te()),U.copy(B),n.update()}function st(K){N.set(K.clientX,K.clientY),D.subVectors(N,E).multiplyScalar(n.panSpeed),ne(D.x,D.y),E.copy(N),n.update()}function ht(K){oe(K),K.deltaY<0?X(te()):K.deltaY>0&&Ne(te()),n.update()}function jt(K){let me=!1;switch(K.code){case n.keys.UP:ne(0,n.keyPanSpeed),me=!0;break;case n.keys.BOTTOM:ne(0,-n.keyPanSpeed),me=!0;break;case n.keys.LEFT:ne(n.keyPanSpeed,0),me=!0;break;case n.keys.RIGHT:ne(-n.keyPanSpeed,0),me=!0;break}me&&(K.preventDefault(),n.update())}function tn(){if(P.length==1)A.set(P[0].pageX,P[0].pageY);else{const K=.5*(P[0].pageX+P[1].pageX),me=.5*(P[0].pageY+P[1].pageY);A.set(K,me)}}function Nt(){if(P.length==1)E.set(P[0].pageX,P[0].pageY);else{const K=.5*(P[0].pageX+P[1].pageX),me=.5*(P[0].pageY+P[1].pageY);E.set(K,me)}}function Le(){const K=P[0].pageX-P[1].pageX,me=P[0].pageY-P[1].pageY,et=Math.sqrt(K*K+me*me);U.set(0,et)}function He(){n.enableZoom&&Le(),n.enablePan&&Nt()}function Oe(){n.enableZoom&&Le(),n.enableRotate&&tn()}function nt(K){if(P.length==1)R.set(K.pageX,K.pageY);else{const et=ct(K),J=.5*(K.pageX+et.x),je=.5*(K.pageY+et.y);R.set(J,je)}w.subVectors(R,A).multiplyScalar(n.rotateSpeed);const me=n.domElement;me&&(fe(2*Math.PI*w.x/me.clientHeight),pe(2*Math.PI*w.y/me.clientHeight)),A.copy(R)}function Q(K){if(P.length==1)N.set(K.pageX,K.pageY);else{const me=ct(K),et=.5*(K.pageX+me.x),J=.5*(K.pageY+me.y);N.set(et,J)}D.subVectors(N,E).multiplyScalar(n.panSpeed),ne(D.x,D.y),E.copy(N)}function Et(K){const me=ct(K),et=K.pageX-me.x,J=K.pageY-me.y,je=Math.sqrt(et*et+J*J);B.set(0,je),z.set(0,Math.pow(B.y/U.y,n.zoomSpeed)),Ne(z.y),U.copy(B)}function ot(K){n.enableZoom&&Et(K),n.enablePan&&Q(K)}function Tt(K){n.enableZoom&&Et(K),n.enableRotate&&nt(K)}function Qe(K){var me,et;n.enabled!==!1&&(P.length===0&&((me=n.domElement)==null||me.ownerDocument.addEventListener("pointermove",G),(et=n.domElement)==null||et.ownerDocument.addEventListener("pointerup",O)),Dt(K),K.pointerType==="touch"?dt(K):ae(K))}function G(K){n.enabled!==!1&&(K.pointerType==="touch"?Ke(K):Te(K))}function O(K){var me,et,J;Ve(K),P.length===0&&((me=n.domElement)==null||me.releasePointerCapture(K.pointerId),(et=n.domElement)==null||et.ownerDocument.removeEventListener("pointermove",G),(J=n.domElement)==null||J.ownerDocument.removeEventListener("pointerup",O)),n.dispatchEvent(f),m=h.NONE}function ae(K){let me;switch(K.button){case 0:me=n.mouseButtons.LEFT;break;case 1:me=n.mouseButtons.MIDDLE;break;case 2:me=n.mouseButtons.RIGHT;break;default:me=-1}switch(me){case Gc.DOLLY:if(n.enableZoom===!1)return;lt(K),m=h.DOLLY;break;case Gc.ROTATE:if(K.ctrlKey||K.metaKey||K.shiftKey){if(n.enablePan===!1)return;de(K),m=h.PAN}else{if(n.enableRotate===!1)return;Fe(K),m=h.ROTATE}break;case Gc.PAN:if(K.ctrlKey||K.metaKey||K.shiftKey){if(n.enableRotate===!1)return;Fe(K),m=h.ROTATE}else{if(n.enablePan===!1)return;de(K),m=h.PAN}break;default:m=h.NONE}m!==h.NONE&&n.dispatchEvent(u)}function Te(K){if(n.enabled!==!1)switch(m){case h.ROTATE:if(n.enableRotate===!1)return;Re(K);break;case h.DOLLY:if(n.enableZoom===!1)return;tt(K);break;case h.PAN:if(n.enablePan===!1)return;st(K);break}}function Ie(K){n.enabled===!1||n.enableZoom===!1||m!==h.NONE&&m!==h.ROTATE||(K.preventDefault(),n.dispatchEvent(u),ht(K),n.dispatchEvent(f))}function Ee(K){n.enabled===!1||n.enablePan===!1||jt(K)}function dt(K){switch(Ze(K),P.length){case 1:switch(n.touches.ONE){case Xc.ROTATE:if(n.enableRotate===!1)return;tn(),m=h.TOUCH_ROTATE;break;case Xc.PAN:if(n.enablePan===!1)return;Nt(),m=h.TOUCH_PAN;break;default:m=h.NONE}break;case 2:switch(n.touches.TWO){case Xc.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;He(),m=h.TOUCH_DOLLY_PAN;break;case Xc.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Oe(),m=h.TOUCH_DOLLY_ROTATE;break;default:m=h.NONE}break;default:m=h.NONE}m!==h.NONE&&n.dispatchEvent(u)}function Ke(K){switch(Ze(K),m){case h.TOUCH_ROTATE:if(n.enableRotate===!1)return;nt(K),n.update();break;case h.TOUCH_PAN:if(n.enablePan===!1)return;Q(K),n.update();break;case h.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ot(K),n.update();break;case h.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Tt(K),n.update();break;default:m=h.NONE}}function vt(K){n.enabled!==!1&&K.preventDefault()}function Dt(K){P.push(K)}function Ve(K){delete Z[K.pointerId];for(let me=0;me{X(K),n.update()},this.dollyOut=(K=te())=>{Ne(K),n.update()},this.getScale=()=>b,this.setScale=K=>{be(K),n.update()},this.getZoomScale=()=>te(),t!==void 0&&this.connect(t),this.update()}};const r4=rt.forwardRef(({makeDefault:r,camera:e,regress:t,domElement:n,enableDamping:s=!0,keyEvents:u=!1,onChange:f,onStart:h,onEnd:m,...g},_)=>{const x=Nu(z=>z.invalidate),b=Nu(z=>z.camera),M=Nu(z=>z.gl),A=Nu(z=>z.events),R=Nu(z=>z.setEvents),w=Nu(z=>z.set),E=Nu(z=>z.get),N=Nu(z=>z.performance),D=e||b,U=n||A.connected||M.domElement,B=rt.useMemo(()=>new s4(D),[D]);return gz(()=>{B.enabled&&B.update()},-1),rt.useEffect(()=>(u&&B.connect(u===!0?U:u),B.connect(U),()=>{B.dispose()}),[u,U,t,B,x]),rt.useEffect(()=>{const z=I=>{x(),t&&N.regress(),f&&f(I)},H=I=>{h&&h(I)},W=I=>{m&&m(I)};return B.addEventListener("change",z),B.addEventListener("start",H),B.addEventListener("end",W),()=>{B.removeEventListener("start",H),B.removeEventListener("end",W),B.removeEventListener("change",z)}},[f,h,m,B,x,R]),rt.useEffect(()=>{if(r){const z=E().controls;return w({controls:B}),()=>w({controls:z})}},[r,B]),rt.createElement("primitive",kx({ref:_,object:B,enableDamping:s},g))}),o4=Object.assign({"../../glitch_assumption_toggle/src/index.tsx":()=>Hr(()=>import("./index-B1PtMIUq.js"),__vite__mapDeps([0,1])),"../../glitch_ccd/src/index.tsx":()=>Hr(()=>import("./index-CMvlyyxu.js"),__vite__mapDeps([2,3])),"../../glitch_chess_analogy/src/index.tsx":()=>Hr(()=>import("./index-CwQ-ysLn.js"),__vite__mapDeps([4,5])),"./index.tsx":()=>Hr(()=>import("./index-CDPygLjY.js"),[]),"../../glitch_level_questions/src/index.tsx":()=>Hr(()=>import("./index-CRhmqMwz.js"),__vite__mapDeps([6,7])),"../../glitch_lightlane/src/index.tsx":()=>Hr(()=>import("./index-C370CA0j.js"),[]),"../../glitch_migration_paradox/src/index.tsx":()=>Hr(()=>import("./index-BOUPxVBe.js"),__vite__mapDeps([8,9])),"../../glitch_onboarding/src/index.tsx":()=>Hr(()=>import("./index-DOdpM0HQ.js"),__vite__mapDeps([10,11])),"../../glitch_onboarding2/src/index.tsx":()=>Hr(()=>import("./index-MgCr_Urj.js"),__vite__mapDeps([12,13])),"../../glitch_sphere_paradox/src/index.tsx":()=>Hr(()=>import("./index-Be41ZfS7.js"),__vite__mapDeps([14,15])),"../../glitch_voxel_universe/src/index.tsx":()=>Hr(()=>import("./index-DnqmHVBx.js"),__vite__mapDeps([16,17]))}),l4=Object.assign({"../../glitch_assumption_toggle/glitch.manifest.json":_w,"../../glitch_ccd/glitch.manifest.json":Cw,"../../glitch_chess_analogy/glitch.manifest.json":zw,"../glitch.manifest.json":qw,"../../glitch_level_questions/glitch.manifest.json":tC,"../../glitch_lightlane/glitch.manifest.json":cC,"../../glitch_migration_paradox/glitch.manifest.json":_C,"../../glitch_onboarding/glitch.manifest.json":CC,"../../glitch_onboarding2/glitch.manifest.json":zC,"../../glitch_sphere_paradox/glitch.manifest.json":qC,"../../glitch_voxel_universe/glitch.manifest.json":t3}),$y=new Set(["glitch_gallery"]),lS=Object.fromEntries(Object.entries(o4).map(([r,e])=>[gA(r),e]).filter(([r])=>!$y.has(r))),u4=Object.fromEntries(Object.entries(l4).map(([r,e])=>[gA(r),e]).filter(([r])=>!$y.has(r))),uS=Object.keys(lS).sort((r,e)=>r.localeCompare(e)),c4=[{folder:"glitch_epicycles",note:"No exported GlitchComponent entry point yet."},{folder:"glitch_threshold_theory",note:"Standalone HTML experiment, not a React GlitchComponent."}],hA=new Set(["glitch_lightlane"]),dA=[{id:"fluid",label:"Fluid",width:null,height:null,note:"Host size"},{id:"desktop",label:"Desktop",width:1440,height:900,note:"1440×900"},{id:"tablet",label:"Tablet",width:834,height:1112,note:"834×1112"},{id:"mobile",label:"Mobile",width:390,height:844,note:"390×844"},{id:"narrow",label:"Narrow",width:320,height:640,note:"320×640"}],f4={primary:"#7dff9b",accent:"#ffb84d",bg:"#050505",bgSecondary:"#101613",text:"#f3ffee",textMuted:"#8cc99a",border:"rgba(125, 255, 155, 0.22)"},h4=new URL("/assets/blblblbl-D60GLrQ8.mp3",import.meta.url).href,d4=new URL("/assets/blblblbl-BrzQxThI.m4a",import.meta.url).href,p4={glitch_assumption_toggle:{"machine.compute_step":[h4,d4]}},J1={"ui.button_click":[{frequency:640,durationMs:55,gain:.025,type:"square"},{frequency:880,durationMs:40,gain:.018,type:"triangle",delayMs:36}],"ui.button_hover":[{frequency:540,durationMs:40,gain:.012,type:"sine"}],"machine.compute_start":[{frequency:240,durationMs:90,gain:.02,type:"sawtooth"},{frequency:320,durationMs:90,gain:.018,type:"sawtooth",delayMs:82},{frequency:430,durationMs:90,gain:.016,type:"triangle",delayMs:164}],"machine.compute_step":[{frequency:780,durationMs:26,gain:.009,type:"square"}],"machine.compute_done":[{frequency:520,durationMs:80,gain:.018,type:"triangle"},{frequency:780,durationMs:110,gain:.018,type:"triangle",delayMs:70}],"machine.verdict_stable":[{frequency:440,durationMs:90,gain:.016,type:"triangle"},{frequency:554,durationMs:90,gain:.016,type:"triangle",delayMs:65},{frequency:659,durationMs:140,gain:.015,type:"triangle",delayMs:130}],"machine.verdict_alert":[{frequency:180,durationMs:120,gain:.022,type:"sawtooth"},{frequency:140,durationMs:140,gain:.02,type:"sawtooth",delayMs:100}]},pA=Object.fromEntries(dA.map(r=>[r.id,r])),dy=uS.map(r=>{const e=u4[r];return{folder:r,componentId:e?.componentId??rf(r).replace(/\s+/g,"-").toLowerCase(),displayName:e?.displayName??rf(r),version:e?.version??"0.0.0",packageName:e?.packageName??r,tags:e?.tags??[],description:e?.description,thumbnailLabel:e?.thumbnailLabel,kind:hA.has(r)?"canvas":"standard"}}).filter(r=>!($y.has(r.folder)||r.componentId==="gallery"||r.packageName==="@glitch-components/gallery")),m4=Object.fromEntries(dy.map(r=>[r.folder,r])),mA="preview";let jp=null;class g4 extends hb.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e){e.resetKey!==this.props.resetKey&&this.state.error&&this.setState({error:null})}render(){return this.state.error?he.jsxs("div",{className:"gallery-state gallery-state-error",children:[he.jsx("span",{className:"gallery-badge gallery-badge-danger",children:"Render Error"}),he.jsx("h3",{children:"Component crashed while rendering."}),he.jsx("pre",{className:"gallery-pre",children:this.state.error.stack??this.state.error.message})]}):this.props.children}}function gA(r){const e=r.split("/");return e[e.length-3]??r}function rf(r){return r.replace(/^glitch[_-]?/i,"").replace(/[_-]+/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function v4(r,e){const t=e.metadata??{},n=rf(r).replace(/\s+/g,"-").toLowerCase();return{name:t.name??n,displayName:t.displayName??rf(r),version:t.version??"0.0.0",description:t.description,tags:t.tags??[],paramSchema:t.paramSchema??{},defaultParams:t.defaultParams??{}}}function vA(){if(typeof window>"u")return dy[0]?.folder??"";const r=new URLSearchParams(window.location.search).get("component");return r&&!$y.has(r)&&uS.includes(r)?r:dy[0]?.folder??""}function $1(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("mode")===mA}function y4(){if(typeof window>"u")return"fluid";const r=new URLSearchParams(window.location.search).get("viewport");return r&&r in pA?r:"fluid"}async function yA(r){const e=lS[r];if(!e)throw new Error("Missing loader for this component folder.");const t=await e();return{Component:t.default,kind:hA.has(r)?"canvas":"standard",metadata:v4(r,t)}}function _4(r){return r.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function eE(r){if(r===void 0)return"undefined";try{return JSON.stringify(r,null,2)}catch(e){return`Could not serialize payload: ${String(e)}`}}function x4(r,e){return String(r.value)===e}function hv(r,e){if(r.type==="boolean")return!!e;if(r.type==="number"||r.type==="range"){const t=Number(e);return Number.isFinite(t)?t:r.default??0}return r.type==="select"&&typeof e=="string"&&r.options?r.options.find(n=>x4(n,e))?.value??e:e}function b4(r){let e=0;for(let n=0;ne.charAt(0).toUpperCase()).join("")}function M4(){if(typeof window>"u")return null;const r=window.AudioContext||window.webkitAudioContext;return r?(jp||(jp=new r),jp.state==="suspended"&&jp.resume(),jp):null}function E4(r,e){const t=r.currentTime+(e.delayMs??0)/1e3,n=t+e.durationMs/1e3,s=r.createOscillator(),u=r.createGain();s.type=e.type??"triangle",s.frequency.setValueAtTime(e.frequency,t),u.gain.setValueAtTime(1e-4,t),u.gain.exponentialRampToValueAtTime(e.gain??.02,t+.008),u.gain.exponentialRampToValueAtTime(1e-4,n),s.connect(u),u.connect(r.destination),s.start(t),s.stop(n+.02)}function tE(r){const e=M4();if(!e)return;const t=J1[r]??J1["ui.button_click"];for(const n of t)E4(e,n)}function T4(r,e){return p4[r]?.[e]??[]}function A4({entry:r,hostBridge:e,params:t,previewKey:n,onComplete:s,onProgress:u}){const h={config:{id:`${r.metadata.name}-gallery`,name:r.metadata.name,version:r.metadata.version,params:t},theme:f4,host:e,onComplete:s,onProgress:u},m=r.Component;return r.kind==="canvas"?he.jsx("div",{className:"gallery-canvas-shell",children:he.jsxs(Kz,{camera:{position:[8,8,8],fov:45},children:[he.jsx(m,{...h}),he.jsx(r4,{makeDefault:!0})]})},n):he.jsx("div",{className:"gallery-standard-shell",children:he.jsx(m,{...h})},n)}function w4({paramKey:r,schema:e,value:t,onChange:n}){const s=e.label??rf(r),u=`gallery-param-${r}`;if(e.type==="boolean")return he.jsxs("label",{className:"gallery-control gallery-checkbox",htmlFor:u,children:[he.jsxs("span",{className:"gallery-control-copy",children:[he.jsx("span",{className:"gallery-control-label",children:s}),e.description?he.jsx("span",{className:"gallery-control-help",children:e.description}):null]}),he.jsx("input",{checked:!!t,id:u,type:"checkbox",onChange:f=>n(r,f.currentTarget.checked)})]});if(e.type==="select")return he.jsxs("label",{className:"gallery-control",htmlFor:u,children:[he.jsx("span",{className:"gallery-control-label",children:s}),e.description?he.jsx("span",{className:"gallery-control-help",children:e.description}):null,he.jsx("select",{className:"gallery-input",id:u,value:String(t??""),onChange:f=>n(r,hv(e,f.currentTarget.value)),children:(e.options??[]).map(f=>he.jsx("option",{value:String(f.value),children:f.label},`${r}-${f.label}-${f.value}`))})]});if(e.type==="range"){const f=typeof t=="number"?t:Number(e.default??0);return he.jsxs("div",{className:"gallery-control",children:[he.jsx("label",{className:"gallery-control-label",htmlFor:u,children:s}),e.description?he.jsx("span",{className:"gallery-control-help",children:e.description}):null,he.jsxs("div",{className:"gallery-range-row",children:[he.jsx("input",{className:"gallery-range",id:u,max:e.max,min:e.min,step:e.step,type:"range",value:f,onChange:h=>n(r,hv(e,h.currentTarget.value))}),he.jsx("input",{className:"gallery-number",max:e.max,min:e.min,step:e.step,type:"number",value:f,onChange:h=>n(r,hv(e,h.currentTarget.value))})]})]})}return e.type==="number"?he.jsxs("label",{className:"gallery-control",htmlFor:u,children:[he.jsx("span",{className:"gallery-control-label",children:s}),e.description?he.jsx("span",{className:"gallery-control-help",children:e.description}):null,he.jsx("input",{className:"gallery-input",id:u,max:e.max,min:e.min,step:e.step,type:"number",value:typeof t=="number"?t:Number(e.default??0),onChange:f=>n(r,hv(e,f.currentTarget.value))})]}):he.jsxs("label",{className:"gallery-control",htmlFor:u,children:[he.jsx("span",{className:"gallery-control-label",children:s}),e.description?he.jsx("span",{className:"gallery-control-help",children:e.description}):null,he.jsx("input",{className:"gallery-input",id:u,type:e.type==="color"?"color":"text",value:typeof t=="string"?t:String(t??""),onChange:f=>n(r,f.currentTarget.value)})]})}function C4(){return rt.useEffect(()=>{if(typeof document>"u")return;const r=$1()?"preview":"shell";return document.body.dataset.galleryMode=r,()=>{delete document.body.dataset.galleryMode}},[]),$1()?he.jsx(N4,{}):he.jsx(R4,{})}function R4(){const[r,e]=rt.useState(vA),[t,n]=rt.useState(y4),[s,u]=rt.useState({}),[f,h]=rt.useState({}),[m,g]=rt.useState({}),[_,x]=rt.useState(null),[b,M]=rt.useState(null),[A,R]=rt.useState([]),[w,E]=rt.useState(0),N=rt.useRef(null),[D,U]=rt.useState(!1),B=rt.useCallback((q,ne)=>{R(be=>[{id:Date.now()+be.length,kind:q,payload:ne,timestamp:_4(new Date)},...be].slice(0,32))},[]),z=rt.useCallback(async q=>{if(s[q])return s[q];if(!lS[q])return h(ne=>({...ne,[q]:{status:"error",error:"Missing loader for this component folder."}})),null;h(ne=>({...ne,[q]:{status:"loading"}}));try{const ne=await yA(q);return u(be=>({...be,[q]:ne})),g(be=>be[q]?be:{...be,[q]:{...ne.metadata.defaultParams}}),h(be=>({...be,[q]:{status:"idle"}})),ne}catch(ne){const be=ne instanceof Error?ne.message:String(ne);return h(Ne=>({...Ne,[q]:{status:"error",error:be}})),B("system",{component:q,error:be,type:"load-error"}),null}},[B,s]);rt.useEffect(()=>{if(!r)return;const q=window.setTimeout(()=>{z(r)},0);return()=>window.clearTimeout(q)},[z,r]),rt.useEffect(()=>{if(!r||typeof window>"u")return;const q=new URL(window.location.href);q.searchParams.set("component",r),q.searchParams.set("viewport",t),window.history.replaceState({},"",q)},[r,t]),rt.useEffect(()=>{const q=window.setTimeout(()=>{x(null),M(null),R([]),E(ne=>ne+1),U(!1)},0);return()=>window.clearTimeout(q)},[r]);const H=rt.useCallback(q=>{N.current?.contentWindow&&N.current.contentWindow.postMessage({source:"glitch-gallery-shell",type:"sync",payload:q},window.location.origin)},[]);rt.useEffect(()=>{const q=ne=>{if(!(ne.origin!==window.location.origin||!ne.data||ne.data.source!=="glitch-gallery-preview")){if(ne.data.type==="ready"){U(!0);return}if(ne.data.type==="progress"){x(ne.data.percent),B("progress",{percent:ne.data.percent});return}if(ne.data.type==="complete"){M(ne.data.payload),B("complete",ne.data.payload);return}ne.data.type==="log"&&B(ne.data.kind,ne.data.payload)}};return window.addEventListener("message",q),()=>window.removeEventListener("message",q)},[B]);const W=r?s[r]:void 0,I=r?m4[r]:void 0,P=r?f[r]:void 0,Z=pA[t],se=rt.useMemo(()=>r?m[r]??W?.metadata.defaultParams??{}:{},[m,W?.metadata.defaultParams,r]);rt.useEffect(()=>{!r||!D||H({component:r,params:se,revision:w})},[H,D,w,se,r]);const te=rt.useCallback((q,ne)=>{r&&g(be=>({...be,[r]:{...be[r]??{},[q]:ne}}))},[r]),fe=rt.useCallback(()=>{!r||!W||(g(q=>({...q,[r]:{...W.metadata.defaultParams}})),E(q=>q+1),B("system",{component:r,type:"params-reset"}))},[B,W,r]),pe=rt.useCallback(()=>{r&&(E(q=>q+1),B("system",{component:r,type:"preview-remount"}))},[B,r]),Y=rt.useMemo(()=>{if(typeof window>"u")return"";const q=new URL(window.location.href);return q.search="",q.searchParams.set("mode",mA),q.searchParams.set("component",r),q.toString()},[r]);return he.jsxs("div",{className:"gallery-shell","data-gallery-shell":"true",children:[he.jsxs("aside",{className:"gallery-sidebar",children:[he.jsxs("div",{className:"gallery-sidebar-header",children:[he.jsx("span",{className:"gallery-eyebrow",children:"Dev Host"}),he.jsx("h1",{children:"Glitch Gallery"}),he.jsx("div",{className:"gallery-viewport-switcher gallery-sidebar-viewport-switcher","data-gallery-viewport-switcher":"true",children:dA.map(q=>he.jsxs("button",{className:`gallery-viewport-button gallery-viewport-button-compact${t===q.id?" is-active":""}`,"data-gallery-viewport":q.id,type:"button",onClick:()=>n(q.id),children:[q.label," : ",q.width?`${q.width}px`:"Fluid"]},q.id))})]}),he.jsx("div",{className:"gallery-section",children:he.jsxs("div",{className:"gallery-selected-card",children:[he.jsx("span",{className:"gallery-eyebrow",children:"Selected"}),he.jsx("h2",{className:"gallery-selected-title",children:W?.metadata.displayName??I?.displayName??rf(r)}),he.jsx("p",{className:"gallery-selected-subtitle",children:W?.metadata.description??I?.description??"Gallery loads components lazily and hosts them with the same sound bridge/event logging model used for Glitch University testing."}),he.jsxs("div",{className:"gallery-toolbar-actions gallery-sidebar-actions",children:[he.jsx("button",{className:"gallery-button",type:"button",onClick:pe,children:"Remount Preview"}),he.jsx("button",{className:"gallery-button",type:"button",onClick:fe,disabled:!W,children:"Reset Params"})]})]})}),he.jsxs("div",{className:"gallery-section",children:[he.jsxs("div",{className:"gallery-section-header",children:[he.jsx("h2",{children:"GlitchComponents"}),he.jsx("span",{className:"gallery-badge",children:uS.length})]}),he.jsx("div",{className:"gallery-list","data-gallery-component-list":"true",children:dy.map(q=>{const ne=q.folder,be=s[ne],Ne=r===ne,X=f[ne]?.status??"idle";return he.jsxs("button",{className:`gallery-list-item${Ne?" is-active":""}`,"data-gallery-component":ne,type:"button",onClick:()=>e(ne),style:b4(ne),children:[he.jsx("span",{className:"gallery-list-thumb","aria-hidden":"true",children:he.jsxs("span",{className:"gallery-list-thumb-frame",children:[he.jsx("span",{className:"gallery-list-thumb-type",children:q.kind==="canvas"?"Canvas":"Standard"}),he.jsx("strong",{children:q.thumbnailLabel??S4(q.componentId)}),he.jsx("span",{className:"gallery-list-thumb-id",children:q.componentId})]})}),he.jsxs("span",{className:"gallery-list-copy",children:[he.jsx("span",{className:"gallery-list-title",children:be?.metadata.displayName??q.displayName}),he.jsx("span",{className:"gallery-list-subtitle",children:ne}),he.jsx("span",{className:"gallery-list-note",children:q.tags.slice(0,3).join(" · ")||"No tags exported"})]}),he.jsxs("span",{className:"gallery-list-status",children:[he.jsxs("span",{className:"gallery-badge gallery-badge-muted",children:["v",q.version]}),X==="loading"?he.jsx("span",{className:"gallery-badge",children:"Loading"}):null,X==="error"?he.jsx("span",{className:"gallery-badge gallery-badge-danger",children:"Error"}):null]})]},ne)})})]}),he.jsxs("div",{className:"gallery-section",children:[he.jsx("div",{className:"gallery-section-header",children:he.jsx("h2",{children:"Not Yet Exported"})}),he.jsx("div",{className:"gallery-list",children:c4.map(q=>he.jsxs("div",{className:"gallery-list-item is-disabled",children:[he.jsxs("span",{className:"gallery-list-copy",children:[he.jsx("span",{className:"gallery-list-title",children:rf(q.folder)}),he.jsx("span",{className:"gallery-list-subtitle",children:q.folder}),he.jsx("span",{className:"gallery-list-note",children:q.note})]}),he.jsx("span",{className:"gallery-badge gallery-badge-muted",children:"Raw"})]},q.folder))})]})]}),he.jsx("main",{className:"gallery-main",children:he.jsxs("div",{className:"gallery-grid",children:[he.jsxs("section",{className:"gallery-preview-panel",children:[he.jsxs("div",{className:"gallery-panel-header",children:[he.jsx("span",{className:"gallery-badge",children:r}),he.jsxs("div",{className:"gallery-stage-badges",children:[he.jsx("span",{className:"gallery-badge gallery-badge-muted",children:Z.width?`${Z.width}px`:"Fluid"}),_!==null?he.jsxs("span",{className:"gallery-badge gallery-badge-accent",children:[Math.round(_),"%"]}):null]})]}),he.jsx("div",{className:"gallery-stage","data-gallery-stage":r,children:he.jsx("div",{className:`gallery-stage-viewport${Z.width?"":" is-fluid"}`,"data-gallery-preview-viewport":t,style:Z.width?{"--gallery-preview-width":`${Z.width}px`,"--gallery-preview-height":`${Z.height}px`}:void 0,children:P?.status==="error"?he.jsxs("div",{className:"gallery-state gallery-state-error",children:[he.jsx("span",{className:"gallery-badge gallery-badge-danger",children:"Load Error"}),he.jsx("h3",{children:"Unable to import this component."}),he.jsx("pre",{className:"gallery-pre",children:P.error})]}):W?he.jsx("iframe",{ref:N,className:"gallery-preview-frame","data-gallery-preview-frame":r,src:Y,title:`${r} preview`},r):he.jsxs("div",{className:"gallery-state",children:[he.jsx("span",{className:"gallery-badge",children:"Loading"}),he.jsx("h3",{children:"Importing component metadata…"}),he.jsx("p",{children:"The gallery keeps the catalog light and only imports the selected component bundle."})]})})})]}),he.jsxs("aside",{className:"gallery-inspector",children:[he.jsxs("section",{className:"gallery-panel",children:[he.jsx("div",{className:"gallery-section-header",children:he.jsx("h3",{children:"Metadata"})}),W?he.jsxs("dl",{className:"gallery-metadata",children:[he.jsxs("div",{children:[he.jsx("dt",{children:"Name"}),he.jsx("dd",{children:W.metadata.name})]}),he.jsxs("div",{children:[he.jsx("dt",{children:"Version"}),he.jsx("dd",{children:W.metadata.version??I?.version})]}),he.jsxs("div",{children:[he.jsx("dt",{children:"Wrapper"}),he.jsx("dd",{children:W.kind==="canvas"?"Canvas host":"Standard host"})]}),he.jsxs("div",{children:[he.jsx("dt",{children:"Package"}),he.jsx("dd",{children:I?.packageName??"Unknown"})]}),he.jsxs("div",{children:[he.jsx("dt",{children:"Viewport"}),he.jsx("dd",{children:Z.width?`${Z.width}px fixed width`:"Fluid host width"})]}),he.jsxs("div",{children:[he.jsx("dt",{children:"Tags"}),he.jsx("dd",{children:W.metadata.tags?.length?W.metadata.tags.join(", "):I?.tags.length?I.tags.join(", "):"None exported"})]})]}):he.jsx("p",{className:"gallery-muted",children:"Metadata appears after the module loads."})]}),he.jsxs("section",{className:"gallery-panel gallery-panel-scroll",children:[he.jsxs("div",{className:"gallery-section-header",children:[he.jsx("h3",{children:"Params"}),W?he.jsx("span",{className:"gallery-badge",children:Object.keys(W.metadata.paramSchema).length}):null]}),W&&Object.keys(W.metadata.paramSchema).length>0?he.jsx("div",{className:"gallery-controls gallery-controls-scroll",children:Object.entries(W.metadata.paramSchema).map(([q,ne])=>he.jsx(w4,{onChange:te,paramKey:q,schema:ne,value:se[q]??ne.default},q))}):he.jsx("p",{className:"gallery-muted",children:"This component does not expose parameter controls."})]}),he.jsxs("section",{className:"gallery-panel",children:[he.jsx("div",{className:"gallery-section-header",children:he.jsx("h3",{children:"Latest Result"})}),b?he.jsx("pre",{className:"gallery-pre",children:eE(b)}):he.jsx("p",{className:"gallery-muted",children:"No completion payload yet."})]}),he.jsxs("section",{className:"gallery-panel",children:[he.jsxs("div",{className:"gallery-section-header",children:[he.jsx("h3",{children:"Event Log"}),he.jsx("button",{className:"gallery-button gallery-button-quiet",type:"button",onClick:()=>R([]),children:"Clear"})]}),A.length>0?he.jsx("div",{className:"gallery-log-list",children:A.map(q=>he.jsxs("article",{className:"gallery-log-item",children:[he.jsxs("div",{className:"gallery-log-header",children:[he.jsx("span",{className:`gallery-badge gallery-badge-${q.kind}`,children:q.kind}),he.jsx("span",{className:"gallery-log-time",children:q.timestamp})]}),he.jsx("pre",{className:"gallery-pre",children:eE(q.payload)})]},q.id))}):he.jsx("p",{className:"gallery-muted",children:"Progress, completion, host events, and sound calls appear here."})]})]})]})})]})}function N4(){const[r,e]=rt.useState(vA),[t,n]=rt.useState(null),[s,u]=rt.useState(null),[f,h]=rt.useState({}),[m,g]=rt.useState(0),_=rt.useRef({}),x=rt.useCallback(M=>{typeof window>"u"||window.parent===window||window.parent.postMessage(M,window.location.origin)},[]);rt.useEffect(()=>{x({source:"glitch-gallery-preview",type:"ready"})},[x]),rt.useEffect(()=>{const M=A=>{if(A.origin!==window.location.origin||!A.data||A.data.source!=="glitch-gallery-shell"||A.data.type!=="sync")return;const R=A.data.payload;e(R.component),h(R.params),g(R.revision)};return window.addEventListener("message",M),()=>window.removeEventListener("message",M)},[]),rt.useEffect(()=>{let M=!1;return yA(r).then(A=>{M||(n(A),u(null),h(R=>Object.keys(R).length>0?R:{...A.metadata.defaultParams}))}).catch(A=>{if(M)return;const R=A instanceof Error?A.message:String(A);n(null),u(R),x({source:"glitch-gallery-preview",type:"log",kind:"system",payload:{type:"load-error",component:r,error:R}})}),()=>{M=!0}},[x,r]);const b=rt.useMemo(()=>({playSound(M,A){const R=`${r}:${M}`,w=T4(r,M);let E=!1;if(w.length>0&&typeof window<"u"){E=!0;const[N]=w,D=_.current[R]??new Audio(N);_.current[R]=D,D.pause(),D.currentTime=0;const U=D.play();U&&U.catch(()=>{tE(M)})}E||tE(M),x({source:"glitch-gallery-preview",type:"log",kind:"sound",payload:{id:M,payload:A}})},stopSound(M,A){const R=`${r}:${M}`,w=_.current[R];w&&(w.pause(),w.currentTime=0),x({source:"glitch-gallery-preview",type:"log",kind:"sound",payload:{id:`stop:${M}`,payload:A}})},emit(M,A){x({source:"glitch-gallery-preview",type:"log",kind:"host",payload:{type:M,payload:A}})}}),[x]);return s?he.jsx("div",{className:"gallery-runtime-root",children:he.jsxs("div",{className:"gallery-state gallery-state-error",children:[he.jsx("span",{className:"gallery-badge gallery-badge-danger",children:"Load Error"}),he.jsx("h3",{children:"Unable to import this component."}),he.jsx("pre",{className:"gallery-pre",children:s})]})}):t?he.jsx("div",{className:"gallery-runtime-root","data-gallery-runtime":r,children:he.jsx(g4,{resetKey:`${r}:${m}`,children:he.jsx(A4,{entry:t,hostBridge:b,onComplete:M=>{x({source:"glitch-gallery-preview",type:"complete",payload:M})},onProgress:M=>{x({source:"glitch-gallery-preview",type:"progress",percent:M})},params:f,previewKey:`${r}:${m}`})})}):he.jsx("div",{className:"gallery-runtime-root",children:he.jsxs("div",{className:"gallery-state",children:[he.jsx("span",{className:"gallery-badge",children:"Loading"}),he.jsx("h3",{children:"Importing preview runtime…"})]})})}lw.createRoot(document.getElementById("root")).render(he.jsx(C4,{}));export{PD as A,as as B,yt as C,Uo as D,Ny as F,C4 as G,QE as I,uR as M,Dl as O,zi as P,Pa as Q,my as R,yr as S,Xc as T,iS as U,j as V,jT as W,kx as _,gz as a,ze as b,ow as c,XE as d,Dz as e,wl as f,Kz as g,r4 as h,Cn as i,he as j,FD as k,Gc as l,eb as m,of as n,Lb as o,Kp as p,qy as q,rt as r,Xb as s,Yi as t,Nu as u,lf as v,Vu as w,NT as x,RT as y,CT as z};