(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const f of u.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function t(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(a){if(a.ep)return;a.ep=!0;const u=t(a);fetch(a.href,u)}})();function nS(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var T_={exports:{}},wp={};var Ib;function CA(){if(Ib)return wp;Ib=1;var o=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,a,u){var f=null;if(u!==void 0&&(f=""+u),a.key!==void 0&&(f=""+a.key),"key"in a){u={};for(var d in a)d!=="key"&&(u[d]=a[d])}else u=a;return a=u.ref,{$$typeof:o,type:i,key:f,ref:a!==void 0?a:null,props:u}}return wp.Fragment=e,wp.jsx=t,wp.jsxs=t,wp}var Ob;function RA(){return Ob||(Ob=1,T_.exports=CA()),T_.exports}var Mn=RA(),A_={exports:{}},qt={};var Pb;function DA(){if(Pb)return qt;Pb=1;var o=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),f=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),x=Symbol.iterator;function M(X){return X===null||typeof X!="object"?null:(X=x&&X[x]||X["@@iterator"],typeof X=="function"?X:null)}var T={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D=Object.assign,w={};function A(X,ee,Ee){this.props=X,this.context=ee,this.refs=w,this.updater=Ee||T}A.prototype.isReactComponent={},A.prototype.setState=function(X,ee){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,ee,"setState")},A.prototype.forceUpdate=function(X){this.updater.enqueueForceUpdate(this,X,"forceUpdate")};function R(){}R.prototype=A.prototype;function L(X,ee,Ee){this.props=X,this.context=ee,this.refs=w,this.updater=Ee||T}var I=L.prototype=new R;I.constructor=L,D(I,A.prototype),I.isPureReactComponent=!0;var V=Array.isArray;function z(){}var H={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function P(X,ee,Ee){var Oe=Ee.ref;return{$$typeof:o,type:X,key:ee,ref:Oe!==void 0?Oe:null,props:Ee}}function Q(X,ee){return P(X.type,ee,X.props)}function W(X){return typeof X=="object"&&X!==null&&X.$$typeof===o}function te(X){var ee={"=":"=0",":":"=2"};return"$"+X.replace(/[=:]/g,function(Ee){return ee[Ee]})}var $=/\/+/g;function ue(X,ee){return typeof X=="object"&&X!==null&&X.key!=null?te(""+X.key):ee.toString(36)}function se(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(ee){X.status==="pending"&&(X.status="fulfilled",X.value=ee)},function(ee){X.status==="pending"&&(X.status="rejected",X.reason=ee)})),X.status){case"fulfilled":return X.value;case"rejected":throw X.reason}}throw X}function q(X,ee,Ee,Oe,st){var ce=typeof X;(ce==="undefined"||ce==="boolean")&&(X=null);var Ce=!1;if(X===null)Ce=!0;else switch(ce){case"bigint":case"string":case"number":Ce=!0;break;case"object":switch(X.$$typeof){case o:case e:Ce=!0;break;case _:return Ce=X._init,q(Ce(X._payload),ee,Ee,Oe,st)}}if(Ce)return st=st(X),Ce=Oe===""?"."+ue(X,0):Oe,V(st)?(Ee="",Ce!=null&&(Ee=Ce.replace($,"$&/")+"/"),q(st,ee,Ee,"",function(yt){return yt})):st!=null&&(W(st)&&(st=Q(st,Ee+(st.key==null||X&&X.key===st.key?"":(""+st.key).replace($,"$&/")+"/")+Ce)),ee.push(st)),1;Ce=0;var Be=Oe===""?".":Oe+":";if(V(X))for(var et=0;et>>1,Ue=q[_e];if(0>>1;_ea(Ee,ye))Oea(st,Ee)?(q[_e]=st,q[Oe]=ye,_e=Oe):(q[_e]=Ee,q[ee]=ye,_e=ee);else if(Oea(st,ye))q[_e]=st,q[Oe]=ye,_e=Oe;else break e}}return j}function a(q,j){var ye=q.sortIndex-j.sortIndex;return ye!==0?ye:q.id-j.id}if(o.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;o.unstable_now=function(){return u.now()}}else{var f=Date,d=f.now();o.unstable_now=function(){return f.now()-d}}var m=[],g=[],_=1,S=null,x=3,M=!1,T=!1,D=!1,w=!1,A=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;function I(q){for(var j=t(g);j!==null;){if(j.callback===null)i(g);else if(j.startTime<=q)i(g),j.sortIndex=j.expirationTime,e(m,j);else break;j=t(g)}}function V(q){if(D=!1,I(q),!T)if(t(m)!==null)T=!0,z||(z=!0,te());else{var j=t(g);j!==null&&se(V,j.startTime-q)}}var z=!1,H=-1,U=5,P=-1;function Q(){return w?!0:!(o.unstable_now()-Pq&&Q());){var _e=S.callback;if(typeof _e=="function"){S.callback=null,x=S.priorityLevel;var Ue=_e(S.expirationTime<=q);if(q=o.unstable_now(),typeof Ue=="function"){S.callback=Ue,I(q),j=!0;break t}S===t(m)&&i(m),I(q)}else i(m);S=t(m)}if(S!==null)j=!0;else{var X=t(g);X!==null&&se(V,X.startTime-q),j=!1}}break e}finally{S=null,x=ye,M=!1}j=void 0}}finally{j?te():z=!1}}}var te;if(typeof L=="function")te=function(){L(W)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,ue=$.port2;$.port1.onmessage=W,te=function(){ue.postMessage(null)}}else te=function(){A(W,0)};function se(q,j){H=A(function(){q(o.unstable_now())},j)}o.unstable_IdlePriority=5,o.unstable_ImmediatePriority=1,o.unstable_LowPriority=4,o.unstable_NormalPriority=3,o.unstable_Profiling=null,o.unstable_UserBlockingPriority=2,o.unstable_cancelCallback=function(q){q.callback=null},o.unstable_forceFrameRate=function(q){0>q||125_e?(q.sortIndex=ye,e(g,q),t(m)===null&&q===t(g)&&(D?(R(H),H=-1):D=!0,se(V,ye-_e))):(q.sortIndex=Ue,e(m,q),T||M||(T=!0,z||(z=!0,te()))),q},o.unstable_shouldYield=Q,o.unstable_wrapCallback=function(q){var j=x;return function(){var ye=x;x=j;try{return q.apply(this,arguments)}finally{x=ye}}}})(R_)),R_}var Fb;function B1(){return Fb||(Fb=1,C_.exports=NA()),C_.exports}var D_={exports:{}},Ds={};var Vb;function LA(){if(Vb)return Ds;Vb=1;var o=xm();function e(m){var g="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(o)}catch(e){console.error(e)}}return o(),D_.exports=LA(),D_.exports}var Hb;function IA(){if(Hb)return Cp;Hb=1;var o=B1(),e=xm(),t=UA();function i(n){var s="https://react.dev/errors/"+n;if(1Ue||(n.current=_e[Ue],_e[Ue]=null,Ue--)}function Ee(n,s){Ue++,_e[Ue]=n.current,n.current=s}var Oe=X(null),st=X(null),ce=X(null),Ce=X(null);function Be(n,s){switch(Ee(ce,s),Ee(st,n),Ee(Oe,null),s.nodeType){case 9:case 11:n=(n=s.documentElement)&&(n=n.namespaceURI)?ib(n):0;break;default:if(n=s.tagName,s=s.namespaceURI)s=ib(s),n=sb(s,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}ee(Oe),Ee(Oe,n)}function et(){ee(Oe),ee(st),ee(ce)}function yt(n){n.memoizedState!==null&&Ee(Ce,n);var s=Oe.current,c=sb(s,n.type);s!==c&&(Ee(st,n),Ee(Oe,c))}function wt(n){st.current===n&&(ee(Oe),ee(st)),Ce.current===n&&(ee(Ce),Mp._currentValue=ye)}var on,Dt;function Re(n){if(on===void 0)try{throw Error()}catch(c){var s=c.stack.trim().match(/\n( *(at )?)/);on=s&&s[1]||"",Dt=-1)":-1y||J[h]!==pe[y]){var we=` `+J[h].replace(" at new "," at ");return n.displayName&&we.includes("")&&(we=we.replace("",n.displayName)),we}while(1<=h&&0<=y);break}}}finally{Ve=!1,Error.prepareStackTrace=c}return(c=n?n.displayName||n.name:"")?Re(c):""}function Je(n,s){switch(n.tag){case 26:case 27:case 5:return Re(n.type);case 16:return Re("Lazy");case 13:return n.child!==s&&s!==null?Re("Suspense Fallback"):Re("Suspense");case 19:return Re("SuspenseList");case 0:case 15:return Ne(n.type,!1);case 11:return Ne(n.type.render,!1);case 1:return Ne(n.type,!0);case 31:return Re("Activity");default:return""}}function Z(n){try{var s="",c=null;do s+=Je(n,c),c=n,n=n.return;while(n);return s}catch(h){return` Error generating stack: `+h.message+` `+h.stack}}var xt=Object.prototype.hasOwnProperty,nt=o.unstable_scheduleCallback,Mt=o.unstable_cancelCallback,We=o.unstable_shouldYield,G=o.unstable_requestPaint,O=o.unstable_now,re=o.unstable_getCurrentPriorityLevel,be=o.unstable_ImmediatePriority,Le=o.unstable_UserBlockingPriority,Te=o.unstable_NormalPriority,rt=o.unstable_LowPriority,qe=o.unstable_IdlePriority,St=o.log,At=o.unstable_setDisableYieldValue,Fe=null,ke=null;function ft(n){if(typeof St=="function"&&At(n),ke&&typeof ke.setStrictMode=="function")try{ke.setStrictMode(Fe,n)}catch{}}var ot=Math.clz32?Math.clz32:ae,ct=Math.log,Zt=Math.LN2;function ae(n){return n>>>=0,n===0?32:31-(ct(n)/Zt|0)|0}var je=256,Xe=262144,ut=4194304;function He(n){var s=n&42;if(s!==0)return s;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function Ae(n,s,c){var h=n.pendingLanes;if(h===0)return 0;var y=0,b=n.suspendedLanes,N=n.pingedLanes;n=n.warmLanes;var F=h&134217727;return F!==0?(h=F&~b,h!==0?y=He(h):(N&=F,N!==0?y=He(N):c||(c=F&~n,c!==0&&(y=He(c))))):(F=h&~b,F!==0?y=He(F):N!==0?y=He(N):c||(c=h&~n,c!==0&&(y=He(c)))),y===0?0:s!==0&&s!==y&&(s&b)===0&&(b=y&-y,c=s&-s,b>=c||b===32&&(c&4194048)!==0)?s:y}function dt(n,s){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&s)===0}function zt(n,s){switch(n){case 1:case 2:case 4:case 8:case 64:return s+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 s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function dn(){var n=ut;return ut<<=1,(ut&62914560)===0&&(ut=4194304),n}function gn(n){for(var s=[],c=0;31>c;c++)s.push(n);return s}function Ji(n,s){n.pendingLanes|=s,s!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function _s(n,s,c,h,y,b){var N=n.pendingLanes;n.pendingLanes=c,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=c,n.entangledLanes&=c,n.errorRecoveryDisabledLanes&=c,n.shellSuspendCounter=0;var F=n.entanglements,J=n.expirationTimes,pe=n.hiddenUpdates;for(c=N&~c;0"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var Ii=/[\n"\\]/g;function It(n){return n.replace(Ii,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function Oi(n,s,c,h,y,b,N,F){n.name="",N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?n.type=N:n.removeAttribute("type"),s!=null?N==="number"?(s===0&&n.value===""||n.value!=s)&&(n.value=""+jt(s)):n.value!==""+jt(s)&&(n.value=""+jt(s)):N!=="submit"&&N!=="reset"||n.removeAttribute("value"),s!=null?Ai(n,N,jt(s)):c!=null?Ai(n,N,jt(c)):h!=null&&n.removeAttribute("value"),y==null&&b!=null&&(n.defaultChecked=!!b),y!=null&&(n.checked=y&&typeof y!="function"&&typeof y!="symbol"),F!=null&&typeof F!="function"&&typeof F!="symbol"&&typeof F!="boolean"?n.name=""+jt(F):n.removeAttribute("name")}function os(n,s,c,h,y,b,N,F){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(n.type=b),s!=null||c!=null){if(!(b!=="submit"&&b!=="reset"||s!=null)){vn(n);return}c=c!=null?""+jt(c):"",s=s!=null?""+jt(s):c,F||s===n.value||(n.value=s),n.defaultValue=s}h=h??y,h=typeof h!="function"&&typeof h!="symbol"&&!!h,n.checked=F?n.checked:!!h,n.defaultChecked=!!h,N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"&&(n.name=N),vn(n)}function Ai(n,s,c){s==="number"&&$e(n.ownerDocument)===n||n.defaultValue===""+c||(n.defaultValue=""+c)}function Ki(n,s,c,h){if(n=n.options,s){s={};for(var y=0;y"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),rd=!1;if(Wa)try{var Nl={};Object.defineProperty(Nl,"passive",{get:function(){rd=!0}}),window.addEventListener("test",Nl,Nl),window.removeEventListener("test",Nl,Nl)}catch{rd=!1}var Bs=null,lf=null,Xo=null;function Hu(){if(Xo)return Xo;var n,s=lf,c=s.length,h,y="value"in Bs?Bs.value:Bs.textContent,b=y.length;for(n=0;n=Pl),Wm=" ",Yu=!1;function gf(n,s){switch(n){case"keyup":return Xm.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function dd(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Yo=!1;function qm(n,s){switch(n){case"compositionend":return dd(s);case"keypress":return s.which!==32?null:(Yu=!0,Wm);case"textInput":return n=s.data,n===Wm&&Yu?null:n;default:return null}}function pd(n,s){if(Yo)return n==="compositionend"||!qo&&gf(n,s)?(n=Hu(),Xo=lf=Bs=null,Yo=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:c,offset:s-n};n=h}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=Qu(c)}}function Bn(n,s){return n&&s?n===s?!0:n&&n.nodeType===3?!1:s&&s.nodeType===3?Bn(n,s.parentNode):"contains"in n?n.contains(s):n.compareDocumentPosition?!!(n.compareDocumentPosition(s)&16):!1:!1}function Jm(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var s=$e(n.document);s instanceof n.HTMLIFrameElement;){try{var c=typeof s.contentWindow.location.href=="string"}catch{c=!1}if(c)n=s.contentWindow;else break;s=$e(n.document)}return s}function bd(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s&&(s==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||s==="textarea"||n.contentEditable==="true")}var Km=Wa&&"documentMode"in document&&11>=document.documentMode,Ya=null,Za=null,Vl=null,yf=!1;function kl(n,s,c){var h=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;yf||Ya==null||Ya!==$e(h)||(h=Ya,"selectionStart"in h&&bd(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),Vl&&Bl(Vl,h)||(Vl=h,h=Jg(Za,"onSelect"),0>=N,y-=N,Kn=1<<32-ot(s)+y|c<nn?(_n=bt,bt=null):_n=bt.sibling;var Rn=ve(oe,bt,he[nn],De);if(Rn===null){bt===null&&(bt=_n);break}n&&bt&&Rn.alternate===null&&s(oe,bt),ne=b(Rn,ne,nn),Cn===null?Rt=Rn:Cn.sibling=Rn,Cn=Rn,bt=_n}if(nn===he.length)return c(oe,bt),fn&&Qa(oe,nn),Rt;if(bt===null){for(;nnnn?(_n=bt,bt=null):_n=bt.sibling;var yu=ve(oe,bt,Rn.value,De);if(yu===null){bt===null&&(bt=_n);break}n&&bt&&yu.alternate===null&&s(oe,bt),ne=b(yu,ne,nn),Cn===null?Rt=yu:Cn.sibling=yu,Cn=yu,bt=_n}if(Rn.done)return c(oe,bt),fn&&Qa(oe,nn),Rt;if(bt===null){for(;!Rn.done;nn++,Rn=he.next())Rn=Ie(oe,Rn.value,De),Rn!==null&&(ne=b(Rn,ne,nn),Cn===null?Rt=Rn:Cn.sibling=Rn,Cn=Rn);return fn&&Qa(oe,nn),Rt}for(bt=h(bt);!Rn.done;nn++,Rn=he.next())Rn=Me(bt,oe,nn,Rn.value,De),Rn!==null&&(n&&Rn.alternate!==null&&bt.delete(Rn.key===null?nn:Rn.key),ne=b(Rn,ne,nn),Cn===null?Rt=Rn:Cn.sibling=Rn,Cn=Rn);return n&&bt.forEach(function(wA){return s(oe,wA)}),fn&&Qa(oe,nn),Rt}function Hn(oe,ne,he,De){if(typeof he=="object"&&he!==null&&he.type===D&&he.key===null&&(he=he.props.children),typeof he=="object"&&he!==null){switch(he.$$typeof){case M:e:{for(var Rt=he.key;ne!==null;){if(ne.key===Rt){if(Rt=he.type,Rt===D){if(ne.tag===7){c(oe,ne.sibling),De=y(ne,he.props.children),De.return=oe,oe=De;break e}}else if(ne.elementType===Rt||typeof Rt=="object"&&Rt!==null&&Rt.$$typeof===U&&Ko(Rt)===ne.type){c(oe,ne.sibling),De=y(ne,he.props),ha(De,he),De.return=oe,oe=De;break e}c(oe,ne);break}else s(oe,ne);ne=ne.sibling}he.type===D?(De=ao(he.props.children,oe.mode,De,he.key),De.return=oe,oe=De):(De=ja(he.type,he.key,he.props,null,oe.mode,De),ha(De,he),De.return=oe,oe=De)}return N(oe);case T:e:{for(Rt=he.key;ne!==null;){if(ne.key===Rt)if(ne.tag===4&&ne.stateNode.containerInfo===he.containerInfo&&ne.stateNode.implementation===he.implementation){c(oe,ne.sibling),De=y(ne,he.children||[]),De.return=oe,oe=De;break e}else{c(oe,ne);break}else s(oe,ne);ne=ne.sibling}De=Mf(he,oe.mode,De),De.return=oe,oe=De}return N(oe);case U:return he=Ko(he),Hn(oe,ne,he,De)}if(se(he))return vt(oe,ne,he,De);if(te(he)){if(Rt=te(he),typeof Rt!="function")throw Error(i(150));return he=Rt.call(he),Ot(oe,ne,he,De)}if(typeof he.then=="function")return Hn(oe,ne,rc(he),De);if(he.$$typeof===L)return Hn(oe,ne,jl(oe,he),De);Ql(oe,he)}return typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint"?(he=""+he,ne!==null&&ne.tag===6?(c(oe,ne.sibling),De=y(ne,he),De.return=oe,oe=De):(c(oe,ne),De=bf(he,oe.mode,De),De.return=oe,oe=De),N(oe)):c(oe,ne)}return function(oe,ne,he,De){try{nl=0;var Rt=Hn(oe,ne,he,De);return tl=null,Rt}catch(bt){if(bt===Jo||bt===Kt)throw bt;var Cn=Jn(29,bt,null,oe.mode);return Cn.lanes=De,Cn.return=oe,Cn}}}var Ir=Uf(!0),If=Uf(!1),fs=!1;function oc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ld(n,s){n=n.updateQueue,s.updateQueue===n&&(s.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Or(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function ho(n,s,c){var h=n.updateQueue;if(h===null)return null;if(h=h.shared,(Et&2)!==0){var y=h.pending;return y===null?s.next=s:(s.next=y.next,y.next=s),h.pending=s,s=ca(n),io(n,null,c),s}return zi(n,h,s,c),ca(n)}function po(n,s,c){if(s=s.updateQueue,s!==null&&(s=s.shared,(c&4194048)!==0)){var h=s.lanes;h&=n.pendingLanes,c|=h,s.lanes=c,Sr(n,c)}}function Ct(n,s){var c=n.updateQueue,h=n.alternate;if(h!==null&&(h=h.updateQueue,c===h)){var y=null,b=null;if(c=c.firstBaseUpdate,c!==null){do{var N={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};b===null?y=b=N:b=b.next=N,c=c.next}while(c!==null);b===null?y=b=s:b=b.next=s}else y=b=s;c={baseState:h.baseState,firstBaseUpdate:y,lastBaseUpdate:b,shared:h.shared,callbacks:h.callbacks},n.updateQueue=c;return}n=c.lastBaseUpdate,n===null?c.firstBaseUpdate=s:n.next=s,c.lastBaseUpdate=s}var Ud=!1;function lc(){if(Ud){var n=fa;if(n!==null)throw n}}function Jl(n,s,c,h){Ud=!1;var y=n.updateQueue;fs=!1;var b=y.firstBaseUpdate,N=y.lastBaseUpdate,F=y.shared.pending;if(F!==null){y.shared.pending=null;var J=F,pe=J.next;J.next=null,N===null?b=pe:N.next=pe,N=J;var we=n.alternate;we!==null&&(we=we.updateQueue,F=we.lastBaseUpdate,F!==N&&(F===null?we.firstBaseUpdate=pe:F.next=pe,we.lastBaseUpdate=J))}if(b!==null){var Ie=y.baseState;N=0,we=pe=J=null,F=b;do{var ve=F.lane&-536870913,Me=ve!==F.lane;if(Me?(Qt&ve)===ve:(h&ve)===ve){ve!==0&&ve===Ur&&(Ud=!0),we!==null&&(we=we.next={lane:0,tag:F.tag,payload:F.payload,callback:null,next:null});e:{var vt=n,Ot=F;ve=s;var Hn=c;switch(Ot.tag){case 1:if(vt=Ot.payload,typeof vt=="function"){Ie=vt.call(Hn,Ie,ve);break e}Ie=vt;break e;case 3:vt.flags=vt.flags&-65537|128;case 0:if(vt=Ot.payload,ve=typeof vt=="function"?vt.call(Hn,Ie,ve):vt,ve==null)break e;Ie=S({},Ie,ve);break e;case 2:fs=!0}}ve=F.callback,ve!==null&&(n.flags|=64,Me&&(n.flags|=8192),Me=y.callbacks,Me===null?y.callbacks=[ve]:Me.push(ve))}else Me={lane:ve,tag:F.tag,payload:F.payload,callback:F.callback,next:null},we===null?(pe=we=Me,J=Ie):we=we.next=Me,N|=ve;if(F=F.next,F===null){if(F=y.shared.pending,F===null)break;Me=F,F=Me.next,Me.next=null,y.lastBaseUpdate=Me,y.shared.pending=null}}while(!0);we===null&&(J=Ie),y.baseState=J,y.firstBaseUpdate=pe,y.lastBaseUpdate=we,b===null&&(y.shared.lanes=0),cr|=N,n.lanes=N,n.memoizedState=Ie}}function Kl(n,s){if(typeof n!="function")throw Error(i(191,n));n.call(s)}function og(n,s){var c=n.callbacks;if(c!==null)for(n.callbacks=null,n=0;nb?b:8;var N=q.T,F={};q.T=F,np(n,!1,s,c);try{var J=y(),pe=q.S;if(pe!==null&&pe(F,J),J!==null&&typeof J=="object"&&typeof J.then=="function"){var we=Dd(J,h);hc(n,s,we,Ys(n))}else hc(n,s,h,Ys(n))}catch(Ie){hc(n,s,{then:function(){},status:"rejected",reason:Ie},Ys())}finally{j.p=b,N!==null&&F.types!==null&&(N.types=F.types),q.T=N}}function Ky(){}function ep(n,s,c,h){if(n.tag!==5)throw Error(i(476));var y=Ig(n).queue;Ug(n,y,s,ye,c===null?Ky:function(){return Og(n),c(h)})}function Ig(n){var s=n.memoizedState;if(s!==null)return s;s={memoizedState:ye,baseState:ye,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zr,lastRenderedState:ye},next:null};var c={};return s.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zr,lastRenderedState:c},next:null},n.memoizedState=s,n=n.alternate,n!==null&&(n.memoizedState=s),s}function Og(n){var s=Ig(n);s.next===null&&(s=n.alternate.memoizedState),hc(n,s.next.queue,{},Ys())}function tp(){return Pt(Mp)}function Pg(){return di().memoizedState}function zg(){return di().memoizedState}function $y(n){for(var s=n.return;s!==null;){switch(s.tag){case 24:case 3:var c=Ys();n=Or(c);var h=ho(s,n,c);h!==null&&(en(h,s,c),po(h,s,c)),s={cache:wd()},n.payload=s;return}s=s.return}}function e_(n,s,c){var h=Ys();c={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Gf(n)?Fg(s,c):(c=xf(n,s,c,h),c!==null&&(en(c,n,h),Vg(c,s,h)))}function Bg(n,s,c){var h=Ys();hc(n,s,c,h)}function hc(n,s,c,h){var y={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(Gf(n))Fg(s,y);else{var b=n.alternate;if(n.lanes===0&&(b===null||b.lanes===0)&&(b=s.lastRenderedReducer,b!==null))try{var N=s.lastRenderedState,F=b(N,c);if(y.hasEagerState=!0,y.eagerState=F,us(F,N))return zi(n,s,y,0),Ft===null&&tc(),!1}catch{}if(c=xf(n,s,y,h),c!==null)return en(c,n,h),Vg(c,s,h),!0}return!1}function np(n,s,c,h){if(h={lane:2,revertLane:xe(),gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},Gf(n)){if(s)throw Error(i(479))}else s=xf(n,c,h,2),s!==null&&en(s,n,2)}function Gf(n){var s=n.alternate;return n===Xt||s!==null&&s===Xt}function Fg(n,s){eu=da=!0;var c=n.pending;c===null?s.next=s:(s.next=c.next,c.next=s),n.pending=s}function Vg(n,s,c){if((c&4194048)!==0){var h=s.lanes;h&=n.pendingLanes,c|=h,s.lanes=c,Sr(n,c)}}var nu={readContext:Pt,use:mo,useCallback:$n,useContext:$n,useEffect:$n,useImperativeHandle:$n,useLayoutEffect:$n,useInsertionEffect:$n,useMemo:$n,useReducer:$n,useRef:$n,useState:$n,useDebugValue:$n,useDeferredValue:$n,useTransition:$n,useSyncExternalStore:$n,useId:$n,useHostTransitionStatus:$n,useFormState:$n,useActionState:$n,useOptimistic:$n,useMemoCache:$n,useCacheRefresh:$n};nu.useEffectEvent=$n;var kg={readContext:Pt,use:mo,useCallback:function(n,s){return wi().memoizedState=[n,s===void 0?null:s],n},useContext:Pt,useEffect:Mg,useImperativeHandle:function(n,s,c){c=c!=null?c.concat([n]):null,kf(4194308,4,Cg.bind(null,s,n),c)},useLayoutEffect:function(n,s){return kf(4194308,4,n,s)},useInsertionEffect:function(n,s){kf(4,2,n,s)},useMemo:function(n,s){var c=wi();s=s===void 0?null:s;var h=n();if(il){ft(!0);try{n()}finally{ft(!1)}}return c.memoizedState=[h,s],h},useReducer:function(n,s,c){var h=wi();if(c!==void 0){var y=c(s);if(il){ft(!0);try{c(s)}finally{ft(!1)}}}else y=s;return h.memoizedState=h.baseState=y,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:y},h.queue=n,n=n.dispatch=e_.bind(null,Xt,n),[h.memoizedState,n]},useRef:function(n){var s=wi();return n={current:n},s.memoizedState=n},useState:function(n){n=Xd(n);var s=n.queue,c=Bg.bind(null,Xt,s);return s.dispatch=c,[n.memoizedState,c]},useDebugValue:Kd,useDeferredValue:function(n,s){var c=wi();return $d(c,n,s)},useTransition:function(){var n=Xd(!1);return n=Ug.bind(null,Xt,n.queue,!0,!1),wi().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,s,c){var h=Xt,y=wi();if(fn){if(c===void 0)throw Error(i(407));c=c()}else{if(c=s(),Ft===null)throw Error(i(349));(Qt&127)!==0||hg(h,s,c)}y.memoizedState=c;var b={value:c,getSnapshot:s};return y.queue=b,Mg(pg.bind(null,h,b,n),[n]),h.flags|=2048,go(9,{destroy:void 0},dg.bind(null,h,b,c,s),null),c},useId:function(){var n=wi(),s=Ft.identifierPrefix;if(fn){var c=Ua,h=Kn;c=(h&~(1<<32-ot(h)-1)).toString(32)+c,s="_"+s+"R_"+c,c=Pf++,0<\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof h.is=="string"?N.createElement("select",{is:h.is}):N.createElement("select"),h.multiple?b.multiple=!0:h.size&&(b.size=h.size);break;default:b=typeof h.is=="string"?N.createElement(y,{is:h.is}):N.createElement(y)}}b[Qn]=s,b[ci]=h;e:for(N=s.child;N!==null;){if(N.tag===5||N.tag===6)b.appendChild(N.stateNode);else if(N.tag!==4&&N.tag!==27&&N.child!==null){N.child.return=N,N=N.child;continue}if(N===s)break e;for(;N.sibling===null;){if(N.return===null||N.return===s)break e;N=N.return}N.sibling.return=N.return,N=N.sibling}s.stateNode=b;e:switch(vs(b,y,h),y){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}h&&ar(s)}}return In(s),gc(s,s.type,n===null?null:n.memoizedProps,s.pendingProps,c),null;case 6:if(n&&s.stateNode!=null)n.memoizedProps!==h&&ar(s);else{if(typeof h!="string"&&s.stateNode===null)throw Error(i(166));if(n=ce.current,Yl(s)){if(n=s.stateNode,c=s.memoizedProps,h=null,y=ri,y!==null)switch(y.tag){case 27:case 5:h=y.memoizedProps}n[Qn]=s,n=!!(n.nodeValue===c||h!==null&&h.suppressHydrationWarning===!0||tb(n.nodeValue,c)),n||Ka(s,!0)}else n=Kg(n).createTextNode(h),n[Qn]=s,s.stateNode=n}return In(s),null;case 31:if(c=s.memoizedState,n===null||n.memoizedState!==null){if(h=Yl(s),c!==null){if(n===null){if(!h)throw Error(i(318));if(n=s.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(557));n[Qn]=s}else lo(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;In(s),n=!1}else c=Af(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=c),n=!0;if(!n)return s.flags&256?(hi(s),s):(hi(s),null);if((s.flags&128)!==0)throw Error(i(558))}return In(s),null;case 13:if(h=s.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(y=Yl(s),h!==null&&h.dehydrated!==null){if(n===null){if(!y)throw Error(i(318));if(y=s.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(i(317));y[Qn]=s}else lo(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;In(s),y=!1}else y=Af(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=y),y=!0;if(!y)return s.flags&256?(hi(s),s):(hi(s),null)}return hi(s),(s.flags&128)!==0?(s.lanes=c,s):(c=h!==null,n=n!==null&&n.memoizedState!==null,c&&(h=s.child,y=null,h.alternate!==null&&h.alternate.memoizedState!==null&&h.alternate.memoizedState.cachePool!==null&&(y=h.alternate.memoizedState.cachePool.pool),b=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(b=h.memoizedState.cachePool.pool),b!==y&&(h.flags|=2048)),c!==n&&c&&(s.child.flags|=8192),Br(s,s.updateQueue),In(s),null);case 4:return et(),n===null&&a_(s.stateNode.containerInfo),In(s),null;case 10:return tr(s.type),In(s),null;case 19:if(ee(hn),h=s.memoizedState,h===null)return In(s),null;if(y=(s.flags&128)!==0,b=h.rendering,b===null)if(y)rr(h,!1);else{if(ei!==0||n!==null&&(n.flags&128)!==0)for(n=s.child;n!==null;){if(b=Hs(n),b!==null){for(s.flags|=128,rr(h,!1),n=b.updateQueue,s.updateQueue=n,Br(s,n),s.subtreeFlags=0,n=c,c=s.child;c!==null;)Hl(c,n),c=c.sibling;return Ee(hn,hn.current&1|2),fn&&Qa(s,h.treeForkCount),s.child}n=n.sibling}h.tail!==null&&O()>mi&&(s.flags|=128,y=!0,rr(h,!1),s.lanes=4194304)}else{if(!y)if(n=Hs(b),n!==null){if(s.flags|=128,y=!0,n=n.updateQueue,s.updateQueue=n,Br(s,n),rr(h,!0),h.tail===null&&h.tailMode==="hidden"&&!b.alternate&&!fn)return In(s),null}else 2*O()-h.renderingStartTime>mi&&c!==536870912&&(s.flags|=128,y=!0,rr(h,!1),s.lanes=4194304);h.isBackwards?(b.sibling=s.child,s.child=b):(n=h.last,n!==null?n.sibling=b:s.child=b,h.last=b)}return h.tail!==null?(n=h.tail,h.rendering=n,h.tail=n.sibling,h.renderingStartTime=O(),n.sibling=null,c=hn.current,Ee(hn,y?c&1|2:c&1),fn&&Qa(s,h.treeForkCount),n):(In(s),null);case 22:case 23:return hi(s),uc(),h=s.memoizedState!==null,n!==null?n.memoizedState!==null!==h&&(s.flags|=8192):h&&(s.flags|=8192),h?(c&536870912)!==0&&(s.flags&128)===0&&(In(s),s.subtreeFlags&6&&(s.flags|=8192)):In(s),c=s.updateQueue,c!==null&&Br(s,c.retryQueue),c=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(c=n.memoizedState.cachePool.pool),h=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),h!==c&&(s.flags|=2048),n!==null&&ee(fo),null;case 24:return c=null,n!==null&&(c=n.memoizedState.cache),s.memoizedState.cache!==c&&(s.flags|=2048),tr(xi),In(s),null;case 25:return null;case 30:return null}throw Error(i(156,s.tag))}function ma(n,s){switch(Ef(s),s.tag){case 1:return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 3:return tr(xi),et(),n=s.flags,(n&65536)!==0&&(n&128)===0?(s.flags=n&-65537|128,s):null;case 26:case 27:case 5:return wt(s),null;case 31:if(s.memoizedState!==null){if(hi(s),s.alternate===null)throw Error(i(340));lo()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 13:if(hi(s),n=s.memoizedState,n!==null&&n.dehydrated!==null){if(s.alternate===null)throw Error(i(340));lo()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 19:return ee(hn),null;case 4:return et(),null;case 10:return tr(s.type),null;case 22:case 23:return hi(s),uc(),n!==null&&ee(fo),n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 24:return tr(xi),null;case 25:return null;default:return null}}function Gs(n,s){switch(Ef(s),s.tag){case 3:tr(xi),et();break;case 26:case 27:case 5:wt(s);break;case 4:et();break;case 31:s.memoizedState!==null&&hi(s);break;case 13:hi(s);break;case 19:ee(hn);break;case 10:tr(s.type);break;case 22:case 23:hi(s),uc(),n!==null&&ee(fo);break;case 24:tr(xi)}}function ga(n,s){try{var c=s.updateQueue,h=c!==null?c.lastEffect:null;if(h!==null){var y=h.next;c=y;do{if((c.tag&n)===n){h=void 0;var b=c.create,N=c.inst;h=b(),N.destroy=h}c=c.next}while(c!==y)}}catch(F){bn(s,s.return,F)}}function Wi(n,s,c){try{var h=s.updateQueue,y=h!==null?h.lastEffect:null;if(y!==null){var b=y.next;h=b;do{if((h.tag&n)===n){var N=h.inst,F=N.destroy;if(F!==void 0){N.destroy=void 0,y=s;var J=c,pe=F;try{pe()}catch(we){bn(y,J,we)}}}h=h.next}while(h!==b)}}catch(we){bn(s,s.return,we)}}function Ia(n){var s=n.updateQueue;if(s!==null){var c=n.stateNode;try{og(s,c)}catch(h){bn(n,n.return,h)}}}function Fi(n,s,c){c.props=vo(n.type,n.memoizedProps),c.state=n.memoizedState;try{c.componentWillUnmount()}catch(h){bn(n,s,h)}}function Fr(n,s){try{var c=n.ref;if(c!==null){switch(n.tag){case 26:case 27:case 5:var h=n.stateNode;break;case 30:h=n.stateNode;break;default:h=n.stateNode}typeof c=="function"?n.refCleanup=c(h):c.current=h}}catch(y){bn(n,s,y)}}function qi(n,s){var c=n.ref,h=n.refCleanup;if(c!==null)if(typeof h=="function")try{h()}catch(y){bn(n,s,y)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(y){bn(n,s,y)}else c.current=null}function yc(n){var s=n.type,c=n.memoizedProps,h=n.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":c.autoFocus&&h.focus();break e;case"img":c.src?h.src=c.src:c.srcSet&&(h.srcset=c.srcSet)}}catch(y){bn(n,n.return,y)}}function Ri(n,s,c){try{var h=n.stateNode;JT(h,n.type,c,s),h[ci]=s}catch(y){bn(n,n.return,y)}}function Zn(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&du(n.type)||n.tag===4}function un(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Zn(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&du(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function or(n,s,c){var h=n.tag;if(h===5||h===6)n=n.stateNode,s?(c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c).insertBefore(n,s):(s=c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c,s.appendChild(n),c=c._reactRootContainer,c!=null||s.onclick!==null||(s.onclick=wr));else if(h!==4&&(h===27&&du(n.type)&&(c=n.stateNode,s=null),n=n.child,n!==null))for(or(n,s,c),n=n.sibling;n!==null;)or(n,s,c),n=n.sibling}function ds(n,s,c){var h=n.tag;if(h===5||h===6)n=n.stateNode,s?c.insertBefore(n,s):c.appendChild(n);else if(h!==4&&(h===27&&du(n.type)&&(c=n.stateNode),n=n.child,n!==null))for(ds(n,s,c),n=n.sibling;n!==null;)ds(n,s,c),n=n.sibling}function th(n){var s=n.stateNode,c=n.memoizedProps;try{for(var h=n.type,y=s.attributes;y.length;)s.removeAttributeNode(y[0]);vs(s,h,c),s[Qn]=n,s[ci]=c}catch(b){bn(n,n.return,b)}}var va=!1,Vn=!1,Oa=!1,jg=typeof WeakSet=="function"?WeakSet:Set,Vi=null;function n_(n,s){if(n=n.containerInfo,l_=a0,n=Jm(n),bd(n)){if("selectionStart"in n)var c={start:n.selectionStart,end:n.selectionEnd};else e:{c=(c=n.ownerDocument)&&c.defaultView||window;var h=c.getSelection&&c.getSelection();if(h&&h.rangeCount!==0){c=h.anchorNode;var y=h.anchorOffset,b=h.focusNode;h=h.focusOffset;try{c.nodeType,b.nodeType}catch{c=null;break e}var N=0,F=-1,J=-1,pe=0,we=0,Ie=n,ve=null;t:for(;;){for(var Me;Ie!==c||y!==0&&Ie.nodeType!==3||(F=N+y),Ie!==b||h!==0&&Ie.nodeType!==3||(J=N+h),Ie.nodeType===3&&(N+=Ie.nodeValue.length),(Me=Ie.firstChild)!==null;)ve=Ie,Ie=Me;for(;;){if(Ie===n)break t;if(ve===c&&++pe===y&&(F=N),ve===b&&++we===h&&(J=N),(Me=Ie.nextSibling)!==null)break;Ie=ve,ve=Ie.parentNode}Ie=Me}c=F===-1||J===-1?null:{start:F,end:J}}else c=null}c=c||{start:0,end:0}}else c=null;for(u_={focusedElem:n,selectionRange:c},a0=!1,Vi=s;Vi!==null;)if(s=Vi,n=s.child,(s.subtreeFlags&1028)!==0&&n!==null)n.return=s,Vi=n;else for(;Vi!==null;){switch(s=Vi,b=s.alternate,n=s.flags,s.tag){case 0:if((n&4)!==0&&(n=s.updateQueue,n=n!==null?n.events:null,n!==null))for(c=0;c title"))),vs(b,h,c),b[Qn]=n,ie(b),h=b;break e;case"link":var N=yb("link","href",y).get(h+(c.href||""));if(N){for(var F=0;FHn&&(N=Hn,Hn=Ot,Ot=N);var oe=Fl(F,Ot),ne=Fl(F,Hn);if(oe&&ne&&(Me.rangeCount!==1||Me.anchorNode!==oe.node||Me.anchorOffset!==oe.offset||Me.focusNode!==ne.node||Me.focusOffset!==ne.offset)){var he=Ie.createRange();he.setStart(oe.node,oe.offset),Me.removeAllRanges(),Ot>Hn?(Me.addRange(he),Me.extend(ne.node,ne.offset)):(he.setEnd(ne.node,ne.offset),Me.addRange(he))}}}}for(Ie=[],Me=F;Me=Me.parentNode;)Me.nodeType===1&&Ie.push({element:Me,left:Me.scrollLeft,top:Me.scrollTop});for(typeof F.focus=="function"&&F.focus(),F=0;Fc?32:c,q.T=null,c=lu,lu=null;var b=qs,N=ba;if(Nn=0,ru=qs=null,ba=0,(Et&6)!==0)throw Error(i(331));var F=Et;if(Et|=4,ws(b.current),mp(b,b.current,N,c),Et=F,ht(0,!1),ke&&typeof ke.onPostCommitFiberRoot=="function")try{ke.onPostCommitFiberRoot(Fe,b)}catch{}return!0}finally{j.p=y,q.T=h,hr(n,s)}}function yp(n,s,c){s=Fs(c,s),s=lp(n.stateNode,s,2),n=ho(n,s,2),n!==null&&(Ji(n,2),Ge(n))}function bn(n,s,c){if(n.tag===3)yp(n,n,c);else for(;s!==null;){if(s.tag===3){yp(s,n,c);break}else if(s.tag===1){var h=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(gi===null||!gi.has(h))){n=Fs(c,n),c=up(2),h=ho(s,c,2),h!==null&&(Xg(c,h,s,n),Ji(h,2),Ge(h));break}}s=s.return}}function Tc(n,s,c){var h=n.pingCache;if(h===null){h=n.pingCache=new Wt;var y=new Set;h.set(s,y)}else y=h.get(s),y===void 0&&(y=new Set,h.set(s,y));y.has(c)||(gp=!0,y.add(c),n=r.bind(null,n,s,c),s.then(n,n))}function r(n,s,c){var h=n.pingCache;h!==null&&h.delete(s),n.pingedLanes|=n.suspendedLanes&c,n.warmLanes&=~c,Ft===n&&(Qt&c)===c&&(ei===4||ei===3&&(Qt&62914560)===Qt&&300>O()-au?(Et&2)===0&&To(n,0):xc|=c,Xn===Qt&&(Xn=0)),Ge(n)}function l(n,s){s===0&&(s=dn()),n=cs(n,s),n!==null&&(Ji(n,s),Ge(n))}function p(n){var s=n.memoizedState,c=0;s!==null&&(c=s.retryLane),l(n,c)}function v(n,s){var c=0;switch(n.tag){case 31:case 13:var h=n.stateNode,y=n.memoizedState;y!==null&&(c=y.retryLane);break;case 19:h=n.stateNode;break;case 22:h=n.stateNode._retryCache;break;default:throw Error(i(314))}h!==null&&h.delete(s),l(n,c)}function E(n,s){return nt(n,s)}var C=null,B=null,K=!1,Se=!1,Pe=!1,Qe=0;function Ge(n){n!==B&&n.next===null&&(B===null?C=B=n:B=B.next=n),Se=!0,K||(K=!0,le())}function ht(n,s){if(!Pe&&Se){Pe=!0;do for(var c=!1,h=C;h!==null;){if(n!==0){var y=h.pendingLanes;if(y===0)var b=0;else{var N=h.suspendedLanes,F=h.pingedLanes;b=(1<<31-ot(42|n)+1)-1,b&=y&~(N&~F),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(c=!0,me(h,b))}else b=Qt,b=Ae(h,h===Ft?b:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),(b&3)===0||dt(h,b)||(c=!0,me(h,b));h=h.next}while(c);Pe=!1}}function Gt(){vi()}function vi(){Se=K=!1;var n=0;Qe!==0&&$T()&&(n=Qe);for(var s=O(),c=null,h=C;h!==null;){var y=h.next,b=hu(h,s);b===0?(h.next=null,c===null?C=y:c.next=y,y===null&&(B=c)):(c=h,(n!==0||(b&3)!==0)&&(Se=!0)),h=y}Nn!==0&&Nn!==5||ht(n),Qe!==0&&(Qe=0)}function hu(n,s){for(var c=n.suspendedLanes,h=n.pingedLanes,y=n.expirationTimes,b=n.pendingLanes&-62914561;0F)break;var we=J.transferSize,Ie=J.initiatorType;we&&nb(Ie)&&(J=J.responseEnd,N+=we*(J"u"?null:document;function pb(n,s,c){var h=oh;if(h&&typeof s=="string"&&s){var y=It(s);y='link[rel="'+n+'"][href="'+y+'"]',typeof c=="string"&&(y+='[crossorigin="'+c+'"]'),db.has(y)||(db.add(y),n={rel:n,crossOrigin:c,href:s},h.querySelector(y)===null&&(s=h.createElement("link"),vs(s,"link",n),ie(s),h.head.appendChild(s)))}}function lA(n){vl.D(n),pb("dns-prefetch",n,null)}function uA(n,s){vl.C(n,s),pb("preconnect",n,s)}function cA(n,s,c){vl.L(n,s,c);var h=oh;if(h&&n&&s){var y='link[rel="preload"][as="'+It(s)+'"]';s==="image"&&c&&c.imageSrcSet?(y+='[imagesrcset="'+It(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(y+='[imagesizes="'+It(c.imageSizes)+'"]')):y+='[href="'+It(n)+'"]';var b=y;switch(s){case"style":b=lh(n);break;case"script":b=uh(n)}pr.has(b)||(n=S({rel:"preload",href:s==="image"&&c&&c.imageSrcSet?void 0:n,as:s},c),pr.set(b,n),h.querySelector(y)!==null||s==="style"&&h.querySelector(Sp(b))||s==="script"&&h.querySelector(bp(b))||(s=h.createElement("link"),vs(s,"link",n),ie(s),h.head.appendChild(s)))}}function fA(n,s){vl.m(n,s);var c=oh;if(c&&n){var h=s&&typeof s.as=="string"?s.as:"script",y='link[rel="modulepreload"][as="'+It(h)+'"][href="'+It(n)+'"]',b=y;switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=uh(n)}if(!pr.has(b)&&(n=S({rel:"modulepreload",href:n},s),pr.set(b,n),c.querySelector(y)===null)){switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(bp(b)))return}h=c.createElement("link"),vs(h,"link",n),ie(h),c.head.appendChild(h)}}}function hA(n,s,c){vl.S(n,s,c);var h=oh;if(h&&n){var y=k(h).hoistableStyles,b=lh(n);s=s||"default";var N=y.get(b);if(!N){var F={loading:0,preload:null};if(N=h.querySelector(Sp(b)))F.loading=5;else{n=S({rel:"stylesheet",href:n,"data-precedence":s},c),(c=pr.get(b))&&g_(n,c);var J=N=h.createElement("link");ie(J),vs(J,"link",n),J._p=new Promise(function(pe,we){J.onload=pe,J.onerror=we}),J.addEventListener("load",function(){F.loading|=1}),J.addEventListener("error",function(){F.loading|=2}),F.loading|=4,e0(N,s,h)}N={type:"stylesheet",instance:N,count:1,state:F},y.set(b,N)}}}function dA(n,s){vl.X(n,s);var c=oh;if(c&&n){var h=k(c).hoistableScripts,y=uh(n),b=h.get(y);b||(b=c.querySelector(bp(y)),b||(n=S({src:n,async:!0},s),(s=pr.get(y))&&v_(n,s),b=c.createElement("script"),ie(b),vs(b,"link",n),c.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},h.set(y,b))}}function pA(n,s){vl.M(n,s);var c=oh;if(c&&n){var h=k(c).hoistableScripts,y=uh(n),b=h.get(y);b||(b=c.querySelector(bp(y)),b||(n=S({src:n,async:!0,type:"module"},s),(s=pr.get(y))&&v_(n,s),b=c.createElement("script"),ie(b),vs(b,"link",n),c.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},h.set(y,b))}}function mb(n,s,c,h){var y=(y=ce.current)?$g(y):null;if(!y)throw Error(i(446));switch(n){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(s=lh(c.href),c=k(y).hoistableStyles,h=c.get(s),h||(h={type:"style",instance:null,count:0,state:null},c.set(s,h)),h):{type:"void",instance:null,count:0,state:null};case"link":if(c.rel==="stylesheet"&&typeof c.href=="string"&&typeof c.precedence=="string"){n=lh(c.href);var b=k(y).hoistableStyles,N=b.get(n);if(N||(y=y.ownerDocument||y,N={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(n,N),(b=y.querySelector(Sp(n)))&&!b._p&&(N.instance=b,N.state.loading=5),pr.has(n)||(c={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},pr.set(n,c),b||mA(y,n,c,N.state))),s&&h===null)throw Error(i(528,""));return N}if(s&&h!==null)throw Error(i(529,""));return null;case"script":return s=c.async,c=c.src,typeof c=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=uh(c),c=k(y).hoistableScripts,h=c.get(s),h||(h={type:"script",instance:null,count:0,state:null},c.set(s,h)),h):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,n))}}function lh(n){return'href="'+It(n)+'"'}function Sp(n){return'link[rel="stylesheet"]['+n+"]"}function gb(n){return S({},n,{"data-precedence":n.precedence,precedence:null})}function mA(n,s,c,h){n.querySelector('link[rel="preload"][as="style"]['+s+"]")?h.loading=1:(s=n.createElement("link"),h.preload=s,s.addEventListener("load",function(){return h.loading|=1}),s.addEventListener("error",function(){return h.loading|=2}),vs(s,"link",c),ie(s),n.head.appendChild(s))}function uh(n){return'[src="'+It(n)+'"]'}function bp(n){return"script[async]"+n}function vb(n,s,c){if(s.count++,s.instance===null)switch(s.type){case"style":var h=n.querySelector('style[data-href~="'+It(c.href)+'"]');if(h)return s.instance=h,ie(h),h;var y=S({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return h=(n.ownerDocument||n).createElement("style"),ie(h),vs(h,"style",y),e0(h,c.precedence,n),s.instance=h;case"stylesheet":y=lh(c.href);var b=n.querySelector(Sp(y));if(b)return s.state.loading|=4,s.instance=b,ie(b),b;h=gb(c),(y=pr.get(y))&&g_(h,y),b=(n.ownerDocument||n).createElement("link"),ie(b);var N=b;return N._p=new Promise(function(F,J){N.onload=F,N.onerror=J}),vs(b,"link",h),s.state.loading|=4,e0(b,c.precedence,n),s.instance=b;case"script":return b=uh(c.src),(y=n.querySelector(bp(b)))?(s.instance=y,ie(y),y):(h=c,(y=pr.get(b))&&(h=S({},c),v_(h,y)),n=n.ownerDocument||n,y=n.createElement("script"),ie(y),vs(y,"link",h),n.head.appendChild(y),s.instance=y);case"void":return null;default:throw Error(i(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(h=s.instance,s.state.loading|=4,e0(h,c.precedence,n));return s.instance}function e0(n,s,c){for(var h=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),y=h.length?h[h.length-1]:null,b=y,N=0;N title"):null)}function gA(n,s,c){if(c===1||s.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;return s.rel==="stylesheet"?(n=s.disabled,typeof s.precedence=="string"&&n==null):!0;case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function xb(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function vA(n,s,c,h){if(c.type==="stylesheet"&&(typeof h.media!="string"||matchMedia(h.media).matches!==!1)&&(c.state.loading&4)===0){if(c.instance===null){var y=lh(h.href),b=s.querySelector(Sp(y));if(b){s=b._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(n.count++,n=n0.bind(n),s.then(n,n)),c.state.loading|=4,c.instance=b,ie(b);return}b=s.ownerDocument||s,h=gb(h),(y=pr.get(y))&&g_(h,y),b=b.createElement("link"),ie(b);var N=b;N._p=new Promise(function(F,J){N.onload=F,N.onerror=J}),vs(b,"link",h),c.instance=b}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(c,s),(s=c.state.preload)&&(c.state.loading&3)===0&&(n.count++,c=n0.bind(n),s.addEventListener("load",c),s.addEventListener("error",c))}}var y_=0;function yA(n,s){return n.stylesheets&&n.count===0&&s0(n,n.stylesheets),0y_?50:800)+s);return n.unsuspend=c,function(){n.unsuspend=null,clearTimeout(h),clearTimeout(y)}}:null}function n0(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)s0(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var i0=null;function s0(n,s){n.stylesheets=null,n.unsuspend!==null&&(n.count++,i0=new Map,s.forEach(_A,n),i0=null,n0.call(n))}function _A(n,s){if(!(s.state.loading&4)){var c=i0.get(n);if(c)var h=c.get(null);else{c=new Map,i0.set(n,c);for(var y=n.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(o)}catch(e){console.error(e)}}return o(),w_.exports=IA(),w_.exports}var PA=OA();const ry="183",zA={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},BA={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},F1=0,Nx=1,V1=2,FA=3,k1=0,Bh=1,Wp=2,Hc=3,wl=0,$s=1,Uo=2,Po=0,qc=1,Lx=2,Ux=3,Ix=4,H1=5,VA=6,wu=100,G1=101,X1=102,W1=103,q1=104,Y1=200,Z1=201,j1=202,Q1=203,cv=204,fv=205,J1=206,K1=207,$1=208,eE=209,tE=210,nE=211,iE=212,sE=213,aE=214,hv=0,dv=1,pv=2,jc=3,mv=4,gv=5,vv=6,yv=7,Sm=0,rE=1,oE=2,gr=0,iS=1,sS=2,aS=3,oy=4,rS=5,oS=6,lS=7,Ox="attached",lE="detached",ly=300,zo=301,Lu=302,qp=303,Yp=304,jh=306,im=1e3,Ca=1001,sm=1002,Ui=1003,uS=1004,kA=1004,Oh=1005,HA=1005,si=1006,Zp=1007,GA=1007,Io=1008,XA=1008,Qs=1009,cS=1010,fS=1011,Vh=1012,uy=1013,vr=1014,Ks=1015,Bo=1016,cy=1017,fy=1018,kh=1020,hS=35902,dS=35899,pS=1021,mS=1022,Os=1023,Fo=1026,Ru=1027,hy=1028,bm=1029,Qc=1030,dy=1031,WA=1032,py=1033,jp=33776,Qp=33777,Jp=33778,Kp=33779,_v=35840,xv=35841,Sv=35842,bv=35843,Mv=36196,Ev=37492,Tv=37496,Av=37488,wv=37489,Cv=37490,Rv=37491,Dv=37808,Nv=37809,Lv=37810,Uv=37811,Iv=37812,Ov=37813,Pv=37814,zv=37815,Bv=37816,Fv=37817,Vv=37818,kv=37819,Hv=37820,Gv=37821,Xv=36492,Wv=36494,qv=36495,Yv=36283,Zv=36284,jv=36285,Qv=36286,uE=2200,cE=2201,fE=2202,am=2300,Jv=2301,rv=2302,Px=2303,Gc=2400,Xc=2401,rm=2402,my=2500,gS=2501,qA=0,YA=1,ZA=2,hE=3200,jA=3201,QA=3202,JA=3203,Pu=0,dE=1,El="",Is="srgb",Uu="srgb-linear",om="linear",On="srgb",KA="",$A="rg",ew="ga",tw=0,Vc=7680,nw=7681,iw=7682,sw=7683,aw=34055,rw=34056,ow=5386,lw=512,uw=513,cw=514,fw=515,hw=516,dw=517,pw=518,zx=519,pE=512,mE=513,gE=514,gy=515,vE=516,yE=517,vy=518,_E=519,lm=35044,mw=35048,gw=35040,vw=35045,yw=35049,_w=35041,xw=35046,Sw=35050,bw=35042,Mw="100",Bx="300 es",Va=2e3,Jc=2001,Ew={COMPUTE:"compute",RENDER:"render"},Tw={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},Aw={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},ww={TEXTURE_COMPARE:"depthTextureCompare"};function Cw(o){for(let e=o.length-1;e>=0;--e)if(o[e]>=65535)return!0;return!1}const Rw={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ph(o,e){return new Rw[o](e)}function xE(o){return ArrayBuffer.isView(o)&&!(o instanceof DataView)}function um(o){return document.createElementNS("http://www.w3.org/1999/xhtml",o)}function SE(){const o=um("canvas");return o.style.display="block",o}const Xb={};let Iu=null;function Dw(o){Iu=o}function Nw(){return Iu}function cm(...o){const e="THREE."+o.shift();Iu?Iu("log",e,...o):console.log(e,...o)}function bE(o){const e=o[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=o[1];t&&t.isStackTrace?o[0]+=" "+t.getLocation():o[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return o}function at(...o){o=bE(o);const e="THREE."+o.shift();if(Iu)Iu("warn",e,...o);else{const t=o[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...o)}}function Tt(...o){o=bE(o);const e="THREE."+o.shift();if(Iu)Iu("error",e,...o);else{const t=o[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...o)}}function fm(...o){const e=o.join(" ");e in Xb||(Xb[e]=!0,at(...o))}function Lw(o,e,t){return new Promise(function(i,a){function u(){switch(o.clientWaitSync(e,o.SYNC_FLUSH_COMMANDS_BIT,0)){case o.WAIT_FAILED:a();break;case o.TIMEOUT_EXPIRED:setTimeout(u,t);break;default:i()}}setTimeout(u,t)})}const Uw={[hv]:dv,[pv]:vv,[mv]:yv,[jc]:gv,[dv]:hv,[vv]:pv,[yv]:mv,[gv]:jc};class Vo{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const a=i[e];if(a!==void 0){const u=a.indexOf(t);u!==-1&&a.splice(u,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const a=i.slice(0);for(let u=0,f=a.length;u>8&255]+Ns[o>>16&255]+Ns[o>>24&255]+"-"+Ns[e&255]+Ns[e>>8&255]+"-"+Ns[e>>16&15|64]+Ns[e>>24&255]+"-"+Ns[t&63|128]+Ns[t>>8&255]+"-"+Ns[t>>16&255]+Ns[t>>24&255]+Ns[i&255]+Ns[i>>8&255]+Ns[i>>16&255]+Ns[i>>24&255]).toLowerCase()}function Bt(o,e,t){return Math.max(e,Math.min(t,o))}function vS(o,e){return(o%e+e)%e}function Iw(o,e,t,i,a){return i+(o-e)*(a-i)/(t-e)}function Ow(o,e,t){return o!==e?(t-o)/(e-o):0}function $p(o,e,t){return(1-t)*o+t*e}function Pw(o,e,t,i){return $p(o,e,1-Math.exp(-t*i))}function zw(o,e=1){return e-Math.abs(vS(o,e*2)-e)}function Bw(o,e,t){return o<=e?0:o>=t?1:(o=(o-e)/(t-e),o*o*(3-2*o))}function Fw(o,e,t){return o<=e?0:o>=t?1:(o=(o-e)/(t-e),o*o*o*(o*(o*6-15)+10))}function Vw(o,e){return o+Math.floor(Math.random()*(e-o+1))}function kw(o,e){return o+Math.random()*(e-o)}function Hw(o){return o*(.5-Math.random())}function Gw(o){o!==void 0&&(Wb=o);let e=Wb+=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 Xw(o){return o*Yc}function Ww(o){return o*Hh}function qw(o){return(o&o-1)===0&&o!==0}function Yw(o){return Math.pow(2,Math.ceil(Math.log(o)/Math.LN2))}function Zw(o){return Math.pow(2,Math.floor(Math.log(o)/Math.LN2))}function jw(o,e,t,i,a){const u=Math.cos,f=Math.sin,d=u(t/2),m=f(t/2),g=u((e+i)/2),_=f((e+i)/2),S=u((e-i)/2),x=f((e-i)/2),M=u((i-e)/2),T=f((i-e)/2);switch(a){case"XYX":o.set(d*_,m*S,m*x,d*g);break;case"YZY":o.set(m*x,d*_,m*S,d*g);break;case"ZXZ":o.set(m*S,m*x,d*_,d*g);break;case"XZX":o.set(d*_,m*T,m*M,d*g);break;case"YXY":o.set(m*M,d*_,m*T,d*g);break;case"ZYZ":o.set(m*T,m*M,d*_,d*g);break;default:at("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+a)}}function Js(o,e){switch(e.constructor){case Float32Array:return o;case Uint32Array:return o/4294967295;case Uint16Array:return o/65535;case Uint8Array:return o/255;case Int32Array:return Math.max(o/2147483647,-1);case Int16Array:return Math.max(o/32767,-1);case Int8Array:return Math.max(o/127,-1);default:throw new Error("Invalid component type.")}}function tn(o,e){switch(e.constructor){case Float32Array:return o;case Uint32Array:return Math.round(o*4294967295);case Uint16Array:return Math.round(o*65535);case Uint8Array:return Math.round(o*255);case Int32Array:return Math.round(o*2147483647);case Int16Array:return Math.round(o*32767);case Int8Array:return Math.round(o*127);default:throw new Error("Invalid component type.")}}const Qw={DEG2RAD:Yc,RAD2DEG:Hh,generateUUID:ka,clamp:Bt,euclideanModulo:vS,mapLinear:Iw,inverseLerp:Ow,lerp:$p,damp:Pw,pingpong:zw,smoothstep:Bw,smootherstep:Fw,randInt:Vw,randFloat:kw,randFloatSpread:Hw,seededRandom:Gw,degToRad:Xw,radToDeg:Ww,isPowerOfTwo:qw,ceilPowerOfTwo:Yw,floorPowerOfTwo:Zw,setQuaternionFromProperEuler:jw,normalize:tn,denormalize:Js};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,i=this.y,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6],this.y=a[1]*t+a[4]*i+a[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=Bt(this.x,e.x,t.x),this.y=Bt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Bt(this.x,e,t),this.y=Bt(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Bt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Bt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),a=Math.sin(t),u=this.x-e.x,f=this.y-e.y;return this.x=u*i-f*a+e.x,this.y=u*a+f*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ea{constructor(e=0,t=0,i=0,a=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=a}static slerpFlat(e,t,i,a,u,f,d){let m=i[a+0],g=i[a+1],_=i[a+2],S=i[a+3],x=u[f+0],M=u[f+1],T=u[f+2],D=u[f+3];if(S!==D||m!==x||g!==M||_!==T){let w=m*x+g*M+_*T+S*D;w<0&&(x=-x,M=-M,T=-T,D=-D,w=-w);let A=1-d;if(w<.9995){const R=Math.acos(w),L=Math.sin(R);A=Math.sin(A*R)/L,d=Math.sin(d*R)/L,m=m*A+x*d,g=g*A+M*d,_=_*A+T*d,S=S*A+D*d}else{m=m*A+x*d,g=g*A+M*d,_=_*A+T*d,S=S*A+D*d;const R=1/Math.sqrt(m*m+g*g+_*_+S*S);m*=R,g*=R,_*=R,S*=R}}e[t]=m,e[t+1]=g,e[t+2]=_,e[t+3]=S}static multiplyQuaternionsFlat(e,t,i,a,u,f){const d=i[a],m=i[a+1],g=i[a+2],_=i[a+3],S=u[f],x=u[f+1],M=u[f+2],T=u[f+3];return e[t]=d*T+_*S+m*M-g*x,e[t+1]=m*T+_*x+g*S-d*M,e[t+2]=g*T+_*M+d*x-m*S,e[t+3]=_*T-d*S-m*x-g*M,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,a){return this._x=e,this._y=t,this._z=i,this._w=a,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,a=e._y,u=e._z,f=e._order,d=Math.cos,m=Math.sin,g=d(i/2),_=d(a/2),S=d(u/2),x=m(i/2),M=m(a/2),T=m(u/2);switch(f){case"XYZ":this._x=x*_*S+g*M*T,this._y=g*M*S-x*_*T,this._z=g*_*T+x*M*S,this._w=g*_*S-x*M*T;break;case"YXZ":this._x=x*_*S+g*M*T,this._y=g*M*S-x*_*T,this._z=g*_*T-x*M*S,this._w=g*_*S+x*M*T;break;case"ZXY":this._x=x*_*S-g*M*T,this._y=g*M*S+x*_*T,this._z=g*_*T+x*M*S,this._w=g*_*S-x*M*T;break;case"ZYX":this._x=x*_*S-g*M*T,this._y=g*M*S+x*_*T,this._z=g*_*T-x*M*S,this._w=g*_*S+x*M*T;break;case"YZX":this._x=x*_*S+g*M*T,this._y=g*M*S+x*_*T,this._z=g*_*T-x*M*S,this._w=g*_*S-x*M*T;break;case"XZY":this._x=x*_*S-g*M*T,this._y=g*M*S-x*_*T,this._z=g*_*T+x*M*S,this._w=g*_*S+x*M*T;break;default:at("Quaternion: .setFromEuler() encountered an unknown order: "+f)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,a=Math.sin(i);return this._x=e.x*a,this._y=e.y*a,this._z=e.z*a,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],a=t[4],u=t[8],f=t[1],d=t[5],m=t[9],g=t[2],_=t[6],S=t[10],x=i+d+S;if(x>0){const M=.5/Math.sqrt(x+1);this._w=.25/M,this._x=(_-m)*M,this._y=(u-g)*M,this._z=(f-a)*M}else if(i>d&&i>S){const M=2*Math.sqrt(1+i-d-S);this._w=(_-m)/M,this._x=.25*M,this._y=(a+f)/M,this._z=(u+g)/M}else if(d>S){const M=2*Math.sqrt(1+d-i-S);this._w=(u-g)/M,this._x=(a+f)/M,this._y=.25*M,this._z=(m+_)/M}else{const M=2*Math.sqrt(1+S-i-d);this._w=(f-a)/M,this._x=(u+g)/M,this._y=(m+_)/M,this._z=.25*M}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Bt(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const a=Math.min(1,t/i);return this.slerp(e,a),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,a=e._y,u=e._z,f=e._w,d=t._x,m=t._y,g=t._z,_=t._w;return this._x=i*_+f*d+a*g-u*m,this._y=a*_+f*m+u*d-i*g,this._z=u*_+f*g+i*m-a*d,this._w=f*_-i*d-a*m-u*g,this._onChangeCallback(),this}slerp(e,t){let i=e._x,a=e._y,u=e._z,f=e._w,d=this.dot(e);d<0&&(i=-i,a=-a,u=-u,f=-f,d=-d);let m=1-t;if(d<.9995){const g=Math.acos(d),_=Math.sin(g);m=Math.sin(m*g)/_,t=Math.sin(t*g)/_,this._x=this._x*m+i*t,this._y=this._y*m+a*t,this._z=this._z*m+u*t,this._w=this._w*m+f*t,this._onChangeCallback()}else this._x=this._x*m+i*t,this._y=this._y*m+a*t,this._z=this._z*m+u*t,this._w=this._w*m+f*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),a=Math.sqrt(1-i),u=Math.sqrt(i);return this.set(a*Math.sin(e),a*Math.cos(e),u*Math.sin(t),u*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Y{constructor(e=0,t=0,i=0){Y.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(qb.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(qb.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,a=this.z,u=e.elements;return this.x=u[0]*t+u[3]*i+u[6]*a,this.y=u[1]*t+u[4]*i+u[7]*a,this.z=u[2]*t+u[5]*i+u[8]*a,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,a=this.z,u=e.elements,f=1/(u[3]*t+u[7]*i+u[11]*a+u[15]);return this.x=(u[0]*t+u[4]*i+u[8]*a+u[12])*f,this.y=(u[1]*t+u[5]*i+u[9]*a+u[13])*f,this.z=(u[2]*t+u[6]*i+u[10]*a+u[14])*f,this}applyQuaternion(e){const t=this.x,i=this.y,a=this.z,u=e.x,f=e.y,d=e.z,m=e.w,g=2*(f*a-d*i),_=2*(d*t-u*a),S=2*(u*i-f*t);return this.x=t+m*g+f*S-d*_,this.y=i+m*_+d*g-u*S,this.z=a+m*S+u*_-f*g,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,a=this.z,u=e.elements;return this.x=u[0]*t+u[4]*i+u[8]*a,this.y=u[1]*t+u[5]*i+u[9]*a,this.z=u[2]*t+u[6]*i+u[10]*a,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=Bt(this.x,e.x,t.x),this.y=Bt(this.y,e.y,t.y),this.z=Bt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Bt(this.x,e,t),this.y=Bt(this.y,e,t),this.z=Bt(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Bt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,a=e.y,u=e.z,f=t.x,d=t.y,m=t.z;return this.x=a*m-u*d,this.y=u*f-i*m,this.z=i*d-a*f,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return N_.copy(this).projectOnVector(e),this.sub(N_)}reflect(e){return this.sub(N_.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Bt(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,a=this.z-e.z;return t*t+i*i+a*a}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const a=Math.sin(t)*e;return this.x=a*Math.sin(i),this.y=Math.cos(t)*e,this.z=a*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),a=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=a,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const N_=new Y,qb=new ea;class Jt{constructor(e,t,i,a,u,f,d,m,g){Jt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,a,u,f,d,m,g)}set(e,t,i,a,u,f,d,m,g){const _=this.elements;return _[0]=e,_[1]=a,_[2]=d,_[3]=t,_[4]=u,_[5]=m,_[6]=i,_[7]=f,_[8]=g,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,a=t.elements,u=this.elements,f=i[0],d=i[3],m=i[6],g=i[1],_=i[4],S=i[7],x=i[2],M=i[5],T=i[8],D=a[0],w=a[3],A=a[6],R=a[1],L=a[4],I=a[7],V=a[2],z=a[5],H=a[8];return u[0]=f*D+d*R+m*V,u[3]=f*w+d*L+m*z,u[6]=f*A+d*I+m*H,u[1]=g*D+_*R+S*V,u[4]=g*w+_*L+S*z,u[7]=g*A+_*I+S*H,u[2]=x*D+M*R+T*V,u[5]=x*w+M*L+T*z,u[8]=x*A+M*I+T*H,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],a=e[2],u=e[3],f=e[4],d=e[5],m=e[6],g=e[7],_=e[8];return t*f*_-t*d*g-i*u*_+i*d*m+a*u*g-a*f*m}invert(){const e=this.elements,t=e[0],i=e[1],a=e[2],u=e[3],f=e[4],d=e[5],m=e[6],g=e[7],_=e[8],S=_*f-d*g,x=d*m-_*u,M=g*u-f*m,T=t*S+i*x+a*M;if(T===0)return this.set(0,0,0,0,0,0,0,0,0);const D=1/T;return e[0]=S*D,e[1]=(a*g-_*i)*D,e[2]=(d*i-a*f)*D,e[3]=x*D,e[4]=(_*t-a*m)*D,e[5]=(a*u-d*t)*D,e[6]=M*D,e[7]=(i*m-g*t)*D,e[8]=(f*t-i*u)*D,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,a,u,f,d){const m=Math.cos(u),g=Math.sin(u);return this.set(i*m,i*g,-i*(m*f+g*d)+f+e,-a*g,a*m,-a*(-g*f+m*d)+d+t,0,0,1),this}scale(e,t){return this.premultiply(L_.makeScale(e,t)),this}rotate(e){return this.premultiply(L_.makeRotation(-e)),this}translate(e,t){return this.premultiply(L_.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let a=0;a<9;a++)if(t[a]!==i[a])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const L_=new Jt,Yb=new Jt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Zb=new Jt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Jw(){const o={enabled:!0,workingColorSpace:Uu,spaces:{},convert:function(a,u,f){return this.enabled===!1||u===f||!u||!f||(this.spaces[u].transfer===On&&(a.r=Al(a.r),a.g=Al(a.g),a.b=Al(a.b)),this.spaces[u].primaries!==this.spaces[f].primaries&&(a.applyMatrix3(this.spaces[u].toXYZ),a.applyMatrix3(this.spaces[f].fromXYZ)),this.spaces[f].transfer===On&&(a.r=Fh(a.r),a.g=Fh(a.g),a.b=Fh(a.b))),a},workingToColorSpace:function(a,u){return this.convert(a,this.workingColorSpace,u)},colorSpaceToWorking:function(a,u){return this.convert(a,u,this.workingColorSpace)},getPrimaries:function(a){return this.spaces[a].primaries},getTransfer:function(a){return a===El?om:this.spaces[a].transfer},getToneMappingMode:function(a){return this.spaces[a].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(a,u=this.workingColorSpace){return a.fromArray(this.spaces[u].luminanceCoefficients)},define:function(a){Object.assign(this.spaces,a)},_getMatrix:function(a,u,f){return a.copy(this.spaces[u].toXYZ).multiply(this.spaces[f].fromXYZ)},_getDrawingBufferColorSpace:function(a){return this.spaces[a].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(a=this.workingColorSpace){return this.spaces[a].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(a,u){return fm("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),o.workingToColorSpace(a,u)},toWorkingColorSpace:function(a,u){return fm("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),o.colorSpaceToWorking(a,u)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return o.define({[Uu]:{primaries:e,whitePoint:i,transfer:om,toXYZ:Yb,fromXYZ:Zb,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Is},outputColorSpaceConfig:{drawingBufferColorSpace:Is}},[Is]:{primaries:e,whitePoint:i,transfer:On,toXYZ:Yb,fromXYZ:Zb,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Is}}}),o}const xn=Jw();function Al(o){return o<.04045?o*.0773993808:Math.pow(o*.9478672986+.0521327014,2.4)}function Fh(o){return o<.0031308?o*12.92:1.055*Math.pow(o,.41666)-.055}let fh;class ME{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{fh===void 0&&(fh=um("canvas")),fh.width=e.width,fh.height=e.height;const a=fh.getContext("2d");e instanceof ImageData?a.putImageData(e,0,0):a.drawImage(e,0,0,e.width,e.height),i=fh}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=um("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const a=i.getImageData(0,0,e.width,e.height),u=a.data;for(let f=0;f1),this.pmremVersion=0}get width(){return this.source.getSize(I_).x}get height(){return this.source.getSize(I_).y}get depth(){return this.source.getSize(I_).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){at(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const a=this[t];if(a===void 0){at(`Texture.setValues(): property '${t}' does not exist.`);continue}a&&i&&a.isVector2&&i.isVector2||a&&i&&a.isVector3&&i.isVector3||a&&i&&a.isMatrix3&&i.isMatrix3?a.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ly)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case im:e.x=e.x-Math.floor(e.x);break;case Ca:e.x=e.x<0?0:1;break;case sm: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 im:e.y=e.y-Math.floor(e.y);break;case Ca:e.y=e.y<0?0:1;break;case sm: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++}}Ti.DEFAULT_IMAGE=null;Ti.DEFAULT_MAPPING=ly;Ti.DEFAULT_ANISOTROPY=1;class Wn{constructor(e=0,t=0,i=0,a=1){Wn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=a}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,a){return this.x=e,this.y=t,this.z=i,this.w=a,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,a=this.z,u=this.w,f=e.elements;return this.x=f[0]*t+f[4]*i+f[8]*a+f[12]*u,this.y=f[1]*t+f[5]*i+f[9]*a+f[13]*u,this.z=f[2]*t+f[6]*i+f[10]*a+f[14]*u,this.w=f[3]*t+f[7]*i+f[11]*a+f[15]*u,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,a,u;const m=e.elements,g=m[0],_=m[4],S=m[8],x=m[1],M=m[5],T=m[9],D=m[2],w=m[6],A=m[10];if(Math.abs(_-x)<.01&&Math.abs(S-D)<.01&&Math.abs(T-w)<.01){if(Math.abs(_+x)<.1&&Math.abs(S+D)<.1&&Math.abs(T+w)<.1&&Math.abs(g+M+A-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const L=(g+1)/2,I=(M+1)/2,V=(A+1)/2,z=(_+x)/4,H=(S+D)/4,U=(T+w)/4;return L>I&&L>V?L<.01?(i=0,a=.707106781,u=.707106781):(i=Math.sqrt(L),a=z/i,u=H/i):I>V?I<.01?(i=.707106781,a=0,u=.707106781):(a=Math.sqrt(I),i=z/a,u=U/a):V<.01?(i=.707106781,a=.707106781,u=0):(u=Math.sqrt(V),i=H/u,a=U/u),this.set(i,a,u,t),this}let R=Math.sqrt((w-T)*(w-T)+(S-D)*(S-D)+(x-_)*(x-_));return Math.abs(R)<.001&&(R=1),this.x=(w-T)/R,this.y=(S-D)/R,this.z=(x-_)/R,this.w=Math.acos((g+M+A-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=Bt(this.x,e.x,t.x),this.y=Bt(this.y,e.y,t.y),this.z=Bt(this.z,e.z,t.z),this.w=Bt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Bt(this.x,e,t),this.y=Bt(this.y,e,t),this.z=Bt(this.z,e,t),this.w=Bt(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Bt(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class yS extends Vo{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:si,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Wn(0,0,e,t),this.scissorTest=!1,this.viewport=new Wn(0,0,e,t),this.textures=[];const a={width:e,height:t,depth:i.depth},u=new Ti(a),f=i.count;for(let d=0;d1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(a.userData=this.userData),a.layers=this.layers.mask,a.matrix=this.matrix.toArray(),a.up=this.up.toArray(),this.pivot!==null&&(a.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(a.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(a.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(a.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(a.type="InstancedMesh",a.count=this.count,a.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(a.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(a.type="BatchedMesh",a.perObjectFrustumCulled=this.perObjectFrustumCulled,a.sortObjects=this.sortObjects,a.drawRanges=this._drawRanges,a.reservedRanges=this._reservedRanges,a.geometryInfo=this._geometryInfo.map(d=>({...d,boundingBox:d.boundingBox?d.boundingBox.toJSON():void 0,boundingSphere:d.boundingSphere?d.boundingSphere.toJSON():void 0})),a.instanceInfo=this._instanceInfo.map(d=>({...d})),a.availableInstanceIds=this._availableInstanceIds.slice(),a.availableGeometryIds=this._availableGeometryIds.slice(),a.nextIndexStart=this._nextIndexStart,a.nextVertexStart=this._nextVertexStart,a.geometryCount=this._geometryCount,a.maxInstanceCount=this._maxInstanceCount,a.maxVertexCount=this._maxVertexCount,a.maxIndexCount=this._maxIndexCount,a.geometryInitialized=this._geometryInitialized,a.matricesTexture=this._matricesTexture.toJSON(e),a.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(a.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(a.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(a.boundingBox=this.boundingBox.toJSON()));function u(d,m){return d[m.uuid]===void 0&&(d[m.uuid]=m.toJSON(e)),m.uuid}if(this.isScene)this.background&&(this.background.isColor?a.background=this.background.toJSON():this.background.isTexture&&(a.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(a.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){a.geometry=u(e.geometries,this.geometry);const d=this.geometry.parameters;if(d!==void 0&&d.shapes!==void 0){const m=d.shapes;if(Array.isArray(m))for(let g=0,_=m.length;g<_;g++){const S=m[g];u(e.shapes,S)}else u(e.shapes,m)}}if(this.isSkinnedMesh&&(a.bindMode=this.bindMode,a.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(u(e.skeletons,this.skeleton),a.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const d=[];for(let m=0,g=this.material.length;m0){a.children=[];for(let d=0;d0){a.animations=[];for(let d=0;d0&&(i.geometries=d),m.length>0&&(i.materials=m),g.length>0&&(i.textures=g),_.length>0&&(i.images=_),S.length>0&&(i.shapes=S),x.length>0&&(i.skeletons=x),M.length>0&&(i.animations=M),T.length>0&&(i.nodes=T)}return i.object=a,i;function f(d){const m=[];for(const g in d){const _=d[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),e.pivot!==null&&(this.pivot=e.pivot.clone()),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.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;iM+T?(g.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!g.inputState.pinching&&x<=M-T&&(g.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else m!==null&&e.gripSpace&&(u=t.getPose(e.gripSpace,i),u!==null&&(m.matrix.fromArray(u.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,u.linearVelocity?(m.hasLinearVelocity=!0,m.linearVelocity.copy(u.linearVelocity)):m.hasLinearVelocity=!1,u.angularVelocity?(m.hasAngularVelocity=!0,m.angularVelocity.copy(u.angularVelocity)):m.hasAngularVelocity=!1));d!==null&&(a=t.getPose(e.targetRaySpace,i),a===null&&u!==null&&(a=u),a!==null&&(d.matrix.fromArray(a.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,a.linearVelocity?(d.hasLinearVelocity=!0,d.linearVelocity.copy(a.linearVelocity)):d.hasLinearVelocity=!1,a.angularVelocity?(d.hasAngularVelocity=!0,d.angularVelocity.copy(a.angularVelocity)):d.hasAngularVelocity=!1,this.dispatchEvent(lC)))}return d!==null&&(d.visible=a!==null),m!==null&&(m.visible=u!==null),g!==null&&(g.visible=f!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new zh;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const EE={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},xu={h:0,s:0,l:0},p0={h:0,s:0,l:0};function P_(o,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?o+(e-o)*6*t:t<1/2?e:t<2/3?o+(e-o)*6*(2/3-t):o}class pt{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const a=e;a&&a.isColor?this.copy(a):typeof a=="number"?this.setHex(a):typeof a=="string"&&this.setStyle(a)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Is){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,xn.colorSpaceToWorking(this,t),this}setRGB(e,t,i,a=xn.workingColorSpace){return this.r=e,this.g=t,this.b=i,xn.colorSpaceToWorking(this,a),this}setHSL(e,t,i,a=xn.workingColorSpace){if(e=vS(e,1),t=Bt(t,0,1),i=Bt(i,0,1),t===0)this.r=this.g=this.b=i;else{const u=i<=.5?i*(1+t):i+t-i*t,f=2*i-u;this.r=P_(f,u,e+1/3),this.g=P_(f,u,e),this.b=P_(f,u,e-1/3)}return xn.colorSpaceToWorking(this,a),this}setStyle(e,t=Is){function i(u){u!==void 0&&parseFloat(u)<1&&at("Color: Alpha component of "+e+" will be ignored.")}let a;if(a=/^(\w+)\(([^\)]*)\)/.exec(e)){let u;const f=a[1],d=a[2];switch(f){case"rgb":case"rgba":if(u=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(d))return i(u[4]),this.setRGB(Math.min(255,parseInt(u[1],10))/255,Math.min(255,parseInt(u[2],10))/255,Math.min(255,parseInt(u[3],10))/255,t);if(u=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(d))return i(u[4]),this.setRGB(Math.min(100,parseInt(u[1],10))/100,Math.min(100,parseInt(u[2],10))/100,Math.min(100,parseInt(u[3],10))/100,t);break;case"hsl":case"hsla":if(u=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(d))return i(u[4]),this.setHSL(parseFloat(u[1])/360,parseFloat(u[2])/100,parseFloat(u[3])/100,t);break;default:at("Color: Unknown color model "+e)}}else if(a=/^\#([A-Fa-f\d]+)$/.exec(e)){const u=a[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);at("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Is){const i=EE[e.toLowerCase()];return i!==void 0?this.setHex(i,t):at("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=Al(e.r),this.g=Al(e.g),this.b=Al(e.b),this}copyLinearToSRGB(e){return this.r=Fh(e.r),this.g=Fh(e.g),this.b=Fh(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Is){return xn.workingToColorSpace(Ls.copy(this),e),Math.round(Bt(Ls.r*255,0,255))*65536+Math.round(Bt(Ls.g*255,0,255))*256+Math.round(Bt(Ls.b*255,0,255))}getHexString(e=Is){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=xn.workingColorSpace){xn.workingToColorSpace(Ls.copy(this),t);const i=Ls.r,a=Ls.g,u=Ls.b,f=Math.max(i,a,u),d=Math.min(i,a,u);let m,g;const _=(d+f)/2;if(d===f)m=0,g=0;else{const S=f-d;switch(g=_<=.5?S/(f+d):S/(2-f-d),f){case i:m=(a-u)/S+(a0&&(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}}const qr=new Y,_l=new Y,z_=new Y,xl=new Y,mh=new Y,gh=new Y,nM=new Y,B_=new Y,F_=new Y,V_=new Y,k_=new Wn,H_=new Wn,G_=new Wn;class wa{constructor(e=new Y,t=new Y,i=new Y){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,a){a.subVectors(i,t),qr.subVectors(e,t),a.cross(qr);const u=a.lengthSq();return u>0?a.multiplyScalar(1/Math.sqrt(u)):a.set(0,0,0)}static getBarycoord(e,t,i,a,u){qr.subVectors(a,t),_l.subVectors(i,t),z_.subVectors(e,t);const f=qr.dot(qr),d=qr.dot(_l),m=qr.dot(z_),g=_l.dot(_l),_=_l.dot(z_),S=f*g-d*d;if(S===0)return u.set(0,0,0),null;const x=1/S,M=(g*m-d*_)*x,T=(f*_-d*m)*x;return u.set(1-M-T,T,M)}static containsPoint(e,t,i,a){return this.getBarycoord(e,t,i,a,xl)===null?!1:xl.x>=0&&xl.y>=0&&xl.x+xl.y<=1}static getInterpolation(e,t,i,a,u,f,d,m){return this.getBarycoord(e,t,i,a,xl)===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,xl.x),m.addScaledVector(f,xl.y),m.addScaledVector(d,xl.z),m)}static getInterpolatedAttribute(e,t,i,a,u,f){return k_.setScalar(0),H_.setScalar(0),G_.setScalar(0),k_.fromBufferAttribute(e,t),H_.fromBufferAttribute(e,i),G_.fromBufferAttribute(e,a),f.setScalar(0),f.addScaledVector(k_,u.x),f.addScaledVector(H_,u.y),f.addScaledVector(G_,u.z),f}static isFrontFacing(e,t,i,a){return qr.subVectors(i,t),_l.subVectors(e,t),qr.cross(_l).dot(a)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,a){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[a]),this}setFromAttributeAndIndices(e,t,i,a){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,a),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 qr.subVectors(this.c,this.b),_l.subVectors(this.a,this.b),qr.cross(_l).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return wa.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return wa.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,a,u){return wa.getInterpolation(e,this.a,this.b,this.c,t,i,a,u)}containsPoint(e){return wa.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return wa.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,a=this.b,u=this.c;let f,d;mh.subVectors(a,i),gh.subVectors(u,i),B_.subVectors(e,i);const m=mh.dot(B_),g=gh.dot(B_);if(m<=0&&g<=0)return t.copy(i);F_.subVectors(e,a);const _=mh.dot(F_),S=gh.dot(F_);if(_>=0&&S<=_)return t.copy(a);const x=m*S-_*g;if(x<=0&&m>=0&&_<=0)return f=m/(m-_),t.copy(i).addScaledVector(mh,f);V_.subVectors(e,u);const M=mh.dot(V_),T=gh.dot(V_);if(T>=0&&M<=T)return t.copy(u);const D=M*g-m*T;if(D<=0&&g>=0&&T<=0)return d=g/(g-T),t.copy(i).addScaledVector(gh,d);const w=_*T-M*S;if(w<=0&&S-_>=0&&M-T>=0)return nM.subVectors(u,a),d=(S-_)/(S-_+(M-T)),t.copy(a).addScaledVector(nM,d);const A=1/(w+D+x);return f=D*A,d=x*A,t.copy(i).addScaledVector(mh,f).addScaledVector(gh,d)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ps{constructor(e=new Y(1/0,1/0,1/0),t=new Y(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.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,Yr),Yr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Dp),g0.subVectors(this.max,Dp),vh.subVectors(e.a,Dp),yh.subVectors(e.b,Dp),_h.subVectors(e.c,Dp),Su.subVectors(yh,vh),bu.subVectors(_h,yh),Ac.subVectors(vh,_h);let t=[0,-Su.z,Su.y,0,-bu.z,bu.y,0,-Ac.z,Ac.y,Su.z,0,-Su.x,bu.z,0,-bu.x,Ac.z,0,-Ac.x,-Su.y,Su.x,0,-bu.y,bu.x,0,-Ac.y,Ac.x,0];return!X_(t,vh,yh,_h,g0)||(t=[1,0,0,0,1,0,0,0,1],!X_(t,vh,yh,_h,g0))?!1:(v0.crossVectors(Su,bu),t=[v0.x,v0.y,v0.z],X_(t,vh,yh,_h,g0))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Yr).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:(Sl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Sl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Sl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Sl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Sl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Sl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Sl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Sl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Sl),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 Sl=[new Y,new Y,new Y,new Y,new Y,new Y,new Y,new Y],Yr=new Y,m0=new Ps,vh=new Y,yh=new Y,_h=new Y,Su=new Y,bu=new Y,Ac=new Y,Dp=new Y,g0=new Y,v0=new Y,wc=new Y;function X_(o,e,t,i,a){for(let u=0,f=o.length-3;u<=f;u+=3){wc.fromArray(o,u);const d=a.x*Math.abs(wc.x)+a.y*Math.abs(wc.y)+a.z*Math.abs(wc.z),m=e.dot(wc),g=t.dot(wc),_=i.dot(wc);if(Math.max(-Math.max(m,g,_),Math.min(m,g,_))>d)return!1}return!0}const Tl=uC();function uC(){const o=new ArrayBuffer(4),e=new Float32Array(o),t=new Uint32Array(o),i=new Uint32Array(512),a=new Uint32Array(512);for(let m=0;m<256;++m){const g=m-127;g<-27?(i[m]=0,i[m|256]=32768,a[m]=24,a[m|256]=24):g<-14?(i[m]=1024>>-g-14,i[m|256]=1024>>-g-14|32768,a[m]=-g-1,a[m|256]=-g-1):g<=15?(i[m]=g+15<<10,i[m|256]=g+15<<10|32768,a[m]=13,a[m|256]=13):g<128?(i[m]=31744,i[m|256]=64512,a[m]=24,a[m|256]=24):(i[m]=31744,i[m|256]=64512,a[m]=13,a[m|256]=13)}const u=new Uint32Array(2048),f=new Uint32Array(64),d=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&&(d[m]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:a,mantissaTable:u,exponentTable:f,offsetTable:d}}function Ta(o){Math.abs(o)>65504&&at("DataUtils.toHalfFloat(): Value out of range."),o=Bt(o,-65504,65504),Tl.floatView[0]=o;const e=Tl.uint32View[0],t=e>>23&511;return Tl.baseTable[t]+((e&8388607)>>Tl.shiftTable[t])}function Hp(o){const e=o>>10;return Tl.uint32View[0]=Tl.mantissaTable[Tl.offsetTable[e]+(o&1023)]+Tl.exponentTable[e],Tl.floatView[0]}class cC{static toHalfFloat(e){return Ta(e)}static fromHalfFloat(e){return Hp(e)}}const Hi=new Y,y0=new ze;let fC=0;class Gn{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:fC++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=lm,this.updateRanges=[],this.gpuType=Ks,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let a=0,u=this.itemSize;athis.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;Np.subVectors(e,this.center);const t=Np.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),a=(i-this.radius)*.5;this.center.addScaledVector(Np,a/i),this.radius+=a}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(Np.copy(e.center).add(W_)),this.expandByPoint(Np.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}}let _C=0;const mr=new kt,q_=new wn,xh=new Y,Fa=new Ps,Lp=new Ps,ss=new Y;class Yt extends Vo{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:_C++}),this.uuid=ka(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Cw(e)?SS:xS)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const u=new Jt().getNormalMatrix(e);i.applyNormalMatrix(u),i.needsUpdate=!0}const a=this.attributes.tangent;return a!==void 0&&(a.transformDirection(e),a.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return mr.makeRotationFromQuaternion(e),this.applyMatrix4(mr),this}rotateX(e){return mr.makeRotationX(e),this.applyMatrix4(mr),this}rotateY(e){return mr.makeRotationY(e),this.applyMatrix4(mr),this}rotateZ(e){return mr.makeRotationZ(e),this.applyMatrix4(mr),this}translate(e,t,i){return mr.makeTranslation(e,t,i),this.applyMatrix4(mr),this}scale(e,t,i){return mr.makeScale(e,t,i),this.applyMatrix4(mr),this}lookAt(e){return q_.lookAt(e),q_.updateMatrix(),this.applyMatrix4(q_.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(xh).negate(),this.translate(xh.x,xh.y,xh.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let a=0,u=e.length;at.count&&at("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 Ps);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Tt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Y(-1/0,-1/0,-1/0),new Y(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,a=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0){const m=this.parameters;for(const g in m)m[g]!==void 0&&(e[g]=m[g]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const m in i){const g=i[m];e.data.attributes[m]=g.toJSON(e.data)}const a={};let u=!1;for(const m in this.morphAttributes){const g=this.morphAttributes[m],_=[];for(let S=0,x=g.length;S0&&(a[m]=_,u=!0)}u&&(e.data.morphAttributes=a,e.data.morphTargetsRelative=this.morphTargetsRelative);const f=this.groups;f.length>0&&(e.data.groups=JSON.parse(JSON.stringify(f)));const d=this.boundingSphere;return d!==null&&(e.data.boundingSphere=d.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const a=e.attributes;for(const g in a){const _=a[g];this.setAttribute(g,_.clone(t))}const u=e.morphAttributes;for(const g in u){const _=[],S=u[g];for(let x=0,M=S.length;x0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){at(`Material: parameter '${t}' has value of undefined.`);continue}const a=this[t];if(a===void 0){at(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}a&&a.isColor?a.set(i):a&&a.isVector3&&i&&i.isVector3?a.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==qc&&(i.blending=this.blending),this.side!==wl&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==cv&&(i.blendSrc=this.blendSrc),this.blendDst!==fv&&(i.blendDst=this.blendDst),this.blendEquation!==wu&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==jc&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==zx&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Vc&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Vc&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Vc&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function a(u){const f=[];for(const d in u){const m=u[d];delete m.metadata,f.push(m)}return f}if(t){const u=a(e.textures),f=a(e.images);u.length>0&&(i.textures=u),f.length>0&&(i.images=f)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const a=t.length;i=new Array(a);for(let u=0;u!==a;++u)i[u]=t[u].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class bS extends zs{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new pt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Sh;const Up=new Y,bh=new Y,Mh=new Y,Eh=new ze,Ip=new ze,TE=new kt,_0=new Y,Op=new Y,x0=new Y,iM=new ze,Y_=new ze,sM=new ze;class AE extends wn{constructor(e=new bS){if(super(),this.isSprite=!0,this.type="Sprite",Sh===void 0){Sh=new Yt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new by(t,5);Sh.setIndex([0,1,2,0,2,3]),Sh.setAttribute("position",new Kc(i,3,0,!1)),Sh.setAttribute("uv",new Kc(i,2,3,!1))}this.geometry=Sh,this.material=e,this.center=new ze(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Tt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),bh.setFromMatrixScale(this.matrixWorld),TE.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Mh.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&bh.multiplyScalar(-Mh.z);const i=this.material.rotation;let a,u;i!==0&&(u=Math.cos(i),a=Math.sin(i));const f=this.center;S0(_0.set(-.5,-.5,0),Mh,f,bh,a,u),S0(Op.set(.5,-.5,0),Mh,f,bh,a,u),S0(x0.set(.5,.5,0),Mh,f,bh,a,u),iM.set(0,0),Y_.set(1,0),sM.set(1,1);let d=e.ray.intersectTriangle(_0,Op,x0,!1,Up);if(d===null&&(S0(Op.set(-.5,.5,0),Mh,f,bh,a,u),Y_.set(0,1),d=e.ray.intersectTriangle(_0,x0,Op,!1,Up),d===null))return;const m=e.ray.origin.distanceTo(Up);me.far||t.push({distance:m,point:Up.clone(),uv:wa.getInterpolation(Up,_0,Op,x0,iM,Y_,sM,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 S0(o,e,t,i,a,u){Eh.subVectors(o,t).addScalar(.5).multiply(i),a!==void 0?(Ip.x=u*Eh.x-a*Eh.y,Ip.y=a*Eh.x+u*Eh.y):Ip.copy(Eh),o.copy(e),o.x+=Ip.x,o.y+=Ip.y,o.applyMatrix4(TE)}const b0=new Y,aM=new Y;class wE extends wn{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,a=t.length;i0){let i,a;for(i=1,a=t.length;i0){b0.setFromMatrixPosition(this.matrixWorld);const a=e.ray.origin.distanceTo(b0);this.getObjectForDistance(a).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){b0.setFromMatrixPosition(e.matrixWorld),aM.setFromMatrixPosition(this.matrixWorld);const i=b0.distanceTo(aM)/e.zoom;t[0].object.visible=!0;let a,u;for(a=1,u=t.length;a=f)t[a-1].object.visible=!1,t[a].object.visible=!0;else break}for(this._currentLevel=a-1;a0)if(S=f*m-d,x=f*d-m,T=u*_,S>=0)if(x>=-T)if(x<=T){const D=1/_;S*=D,x*=D,M=S*(S+f*x+2*d)+x*(f*S+x+2*m)+g}else x=u,S=Math.max(0,-(f*x+d)),M=-S*S+x*(x+2*m)+g;else x=-u,S=Math.max(0,-(f*x+d)),M=-S*S+x*(x+2*m)+g;else x<=-T?(S=Math.max(0,-(-f*u+d)),x=S>0?-u:Math.min(Math.max(-u,-m),u),M=-S*S+x*(x+2*m)+g):x<=T?(S=0,x=Math.min(Math.max(-u,-m),u),M=x*(x+2*m)+g):(S=Math.max(0,-(f*u+d)),x=S>0?u:Math.min(Math.max(-u,-m),u),M=-S*S+x*(x+2*m)+g);else x=f>0?-u:u,S=Math.max(0,-(f*x+d)),M=-S*S+x*(x+2*m)+g;return i&&i.copy(this.origin).addScaledVector(this.direction,S),a&&a.copy(Z_).addScaledVector(M0,x),M}intersectSphere(e,t){bl.subVectors(e.center,this.origin);const i=bl.dot(this.direction),a=bl.dot(bl)-i*i,u=e.radius*e.radius;if(a>u)return null;const f=Math.sqrt(u-a),d=i-f,m=i+f;return m<0?null:d<0?this.at(m,t):this.at(d,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,a,u,f,d,m;const g=1/this.direction.x,_=1/this.direction.y,S=1/this.direction.z,x=this.origin;return g>=0?(i=(e.min.x-x.x)*g,a=(e.max.x-x.x)*g):(i=(e.max.x-x.x)*g,a=(e.min.x-x.x)*g),_>=0?(u=(e.min.y-x.y)*_,f=(e.max.y-x.y)*_):(u=(e.max.y-x.y)*_,f=(e.min.y-x.y)*_),i>f||u>a||((u>i||isNaN(i))&&(i=u),(f=0?(d=(e.min.z-x.z)*S,m=(e.max.z-x.z)*S):(d=(e.max.z-x.z)*S,m=(e.min.z-x.z)*S),i>m||d>a)||((d>i||i!==i)&&(i=d),(m=0?i:a,t)}intersectsBox(e){return this.intersectBox(e,bl)!==null}intersectTriangle(e,t,i,a,u){j_.subVectors(t,e),E0.subVectors(i,e),Q_.crossVectors(j_,E0);let f=this.direction.dot(Q_),d;if(f>0){if(a)return null;d=1}else if(f<0)d=-1,f=-f;else return null;Mu.subVectors(this.origin,e);const m=d*this.direction.dot(E0.crossVectors(Mu,E0));if(m<0)return null;const g=d*this.direction.dot(j_.cross(Mu));if(g<0||m+g>f)return null;const _=-d*Mu.dot(Q_);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 zu extends zs{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new pt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ga,this.combine=Sm,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 rM=new kt,Cc=new Qh,T0=new ys,oM=new Y,A0=new Y,w0=new Y,C0=new Y,J_=new Y,R0=new Y,lM=new Y,D0=new Y;class Gi extends wn{constructor(e=new Yt,t=new zu){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const a=t[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let u=0,f=a.length;u(e.far-e.near)**2))&&(rM.copy(u).invert(),Cc.copy(e.ray).applyMatrix4(rM),!(i.boundingBox!==null&&Cc.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Cc)))}_computeIntersections(e,t,i){let a;const u=this.geometry,f=this.material,d=u.index,m=u.attributes.position,g=u.attributes.uv,_=u.attributes.uv1,S=u.attributes.normal,x=u.groups,M=u.drawRange;if(d!==null)if(Array.isArray(f))for(let T=0,D=x.length;Tt.far?null:{distance:g,point:D0.clone(),object:o}}function N0(o,e,t,i,a,u,f,d,m,g){o.getVertexPosition(d,A0),o.getVertexPosition(m,w0),o.getVertexPosition(g,C0);const _=SC(o,e,t,i,A0,w0,C0,lM);if(_){const S=new Y;wa.getBarycoord(lM,A0,w0,C0,S),a&&(_.uv=wa.getInterpolatedAttribute(a,d,m,g,S,new ze)),u&&(_.uv1=wa.getInterpolatedAttribute(u,d,m,g,S,new ze)),f&&(_.normal=wa.getInterpolatedAttribute(f,d,m,g,S,new Y),_.normal.dot(i.direction)>0&&_.normal.multiplyScalar(-1));const x={a:d,b:m,c:g,normal:new Y,materialIndex:0};wa.getNormal(A0,w0,C0,x.normal),_.face=x,_.barycoord=S}return _}const uM=new Y,cM=new Wn,fM=new Wn,bC=new Y,hM=new kt,L0=new Y,K_=new ys,dM=new kt,$_=new Qh;class CE extends Gi{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Ox,this.bindMatrix=new kt,this.bindMatrixInverse=new kt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ps),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i1?null:t.copy(e.start).addScaledVector(i,u)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||AC.getNormalMatrix(e),a=this.coplanarPoint(ex).applyMatrix4(e),u=this.normal.applyMatrix3(i).normalize();return this.constant=-a.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 Rc=new ys,wC=new ze(.5,.5),I0=new Y;class Jh{constructor(e=new Au,t=new Au,i=new Au,a=new Au,u=new Au,f=new Au){this.planes=[e,t,i,a,u,f]}set(e,t,i,a,u,f){const d=this.planes;return d[0].copy(e),d[1].copy(t),d[2].copy(i),d[3].copy(a),d[4].copy(u),d[5].copy(f),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Va,i=!1){const a=this.planes,u=e.elements,f=u[0],d=u[1],m=u[2],g=u[3],_=u[4],S=u[5],x=u[6],M=u[7],T=u[8],D=u[9],w=u[10],A=u[11],R=u[12],L=u[13],I=u[14],V=u[15];if(a[0].setComponents(g-f,M-_,A-T,V-R).normalize(),a[1].setComponents(g+f,M+_,A+T,V+R).normalize(),a[2].setComponents(g+d,M+S,A+D,V+L).normalize(),a[3].setComponents(g-d,M-S,A-D,V-L).normalize(),i)a[4].setComponents(m,x,w,I).normalize(),a[5].setComponents(g-m,M-x,A-w,V-I).normalize();else if(a[4].setComponents(g-m,M-x,A-w,V-I).normalize(),t===Va)a[5].setComponents(g+m,M+x,A+w,V+I).normalize();else if(t===Jc)a[5].setComponents(m,x,w,I).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(),Rc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Rc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Rc)}intersectsSprite(e){Rc.center.set(0,0,0);const t=wC.distanceTo(e.center);return Rc.radius=.7071067811865476+t,Rc.applyMatrix4(e.matrixWorld),this.intersectsSphere(Rc)}intersectsSphere(e){const t=this.planes,i=e.center,a=-e.radius;for(let u=0;u<6;u++)if(t[u].distanceToPoint(i)0?e.max.x:e.min.x,I0.y=a.normal.y>0?e.max.y:e.min.y,I0.z=a.normal.z>0?e.max.z:e.min.z,a.distanceToPoint(I0)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Ro=new kt,Do=new Jh;class Ey{constructor(){this.coordinateSystem=Va}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let i=0;i=u.length&&u.push({start:-1,count:-1,z:-1,index:-1});const d=u[this.index];f.push(d),this.index++,d.start=e,d.count=t,d.z=i,d.index=a}reset(){this.list.length=0,this.index=0}}const Ea=new kt,NC=new pt(1,1,1),vM=new Jh,LC=new Ey,O0=new Ps,Dc=new ys,Bp=new Y,yM=new Y,UC=new Y,nx=new DC,Us=new Gi,P0=[];function IC(o,e,t=0){const i=e.itemSize;if(o.isInterleavedBufferAttribute||o.array.constructor!==e.array.constructor){const a=o.count;for(let u=0;u65535?new Uint32Array(a):new Uint16Array(a);t.setIndex(new Gn(u,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in t.attributes){if(!e.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const a=e.getAttribute(i),u=t.getAttribute(i);if(a.itemSize!==u.itemSize||a.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 Ps);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let i=0,a=t.length;i=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const i={visible:!0,active:!0,geometryIndex:e};let a=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(tx),a=this._availableInstanceIds.shift(),this._instanceInfo[a]=i):(a=this._instanceInfo.length,this._instanceInfo.push(i));const u=this._matricesTexture;Ea.identity().toArray(u.image.data,a*16),u.needsUpdate=!0;const f=this._colorsTexture;return f&&(NC.toArray(f.image.data,a*4),f.needsUpdate=!0),this._visibilityChanged=!0,a}addGeometry(e,t=-1,i=-1){this._initializeGeometry(e),this._validateGeometry(e);const a={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;a.vertexStart=this._nextVertexStart,a.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const f=e.getIndex();if(f!==null&&(a.indexStart=this._nextIndexStart,a.reservedIndexCount=i===-1?f.count:i),a.indexStart!==-1&&a.indexStart+a.reservedIndexCount>this._maxIndexCount||a.vertexStart+a.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(tx),m=this._availableGeometryIds.shift(),u[m]=a):(m=this._geometryCount,this._geometryCount++,u.push(a)),this.setGeometryAt(m,e),this._nextIndexStart=a.indexStart+a.reservedIndexCount,this._nextVertexStart=a.vertexStart+a.reservedVertexCount,m}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const i=this.geometry,a=i.getIndex()!==null,u=i.getIndex(),f=t.getIndex(),d=this._geometryInfo[e];if(a&&f.count>d.reservedIndexCount||t.attributes.position.count>d.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const m=d.vertexStart,g=d.reservedVertexCount;d.vertexCount=t.getAttribute("position").count;for(const _ in i.attributes){const S=t.getAttribute(_),x=i.getAttribute(_);IC(S,x,m);const M=S.itemSize;for(let T=S.count,D=g;T=t.length||t[e].active===!1)return this;const i=this._instanceInfo;for(let a=0,u=i.length;ad).sort((f,d)=>i[f].vertexStart-i[d].vertexStart),u=this.geometry;for(let f=0,d=i.length;f=this._geometryCount)return null;const i=this.geometry,a=this._geometryInfo[e];if(a.boundingBox===null){const u=new Ps,f=i.index,d=i.attributes.position;for(let m=a.start,g=a.start+a.count;m=this._geometryCount)return null;const i=this.geometry,a=this._geometryInfo[e];if(a.boundingSphere===null){const u=new ys;this.getBoundingBoxAt(e,O0),O0.getCenter(u.center);const f=i.index,d=i.attributes.position;let m=0;for(let g=a.start,_=a.start+a.count;g<_;g++){let S=g;f&&(S=f.getX(S)),Bp.fromBufferAttribute(d,S),m=Math.max(m,u.center.distanceToSquared(Bp))}u.radius=Math.sqrt(m),a.boundingSphere=u}return t.copy(a.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const i=this._matricesTexture,a=this._matricesTexture.image.data;return t.toArray(a,e*16),i.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const i=this._geometryInfo[e];return t.vertexStart=i.vertexStart,t.vertexCount=i.vertexCount,t.reservedVertexCount=i.reservedVertexCount,t.indexStart=i.indexStart,t.indexCount=i.indexCount,t.reservedIndexCount=i.reservedIndexCount,t.start=i.start,t.count=i.count,t}setInstanceCount(e){const t=this._availableInstanceIds,i=this._instanceInfo;for(t.sort(tx);t[t.length-1]===i.length-1;)i.pop(),t.pop();if(ed.active);if(Math.max(...i.map(d=>d.vertexStart+d.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(m=>m.indexStart+m.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const u=this.geometry;u.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Yt,this._initializeGeometry(u));const f=this.geometry;u.index&&Nc(u.index.array,f.index.array);for(const d in u.attributes)Nc(u.attributes[d].array,f.attributes[d].array)}raycast(e,t){const i=this._instanceInfo,a=this._geometryInfo,u=this.matrixWorld,f=this.geometry;Us.material=this.material,Us.geometry.index=f.index,Us.geometry.attributes=f.attributes,Us.geometry.boundingBox===null&&(Us.geometry.boundingBox=new Ps),Us.geometry.boundingSphere===null&&(Us.geometry.boundingSphere=new ys);for(let d=0,m=i.length;d({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,i,a,u){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const f=a.getIndex();let d=f===null?1:f.array.BYTES_PER_ELEMENT,m=1;u.wireframe&&(m=2,d=a.attributes.position.count>65535?4:2);const g=this._instanceInfo,_=this._multiDrawStarts,S=this._multiDrawCounts,x=this._geometryInfo,M=this.perObjectFrustumCulled,T=this._indirectTexture,D=T.image.data,w=i.isArrayCamera?LC:vM;M&&!i.isArrayCamera&&(Ea.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),vM.setFromProjectionMatrix(Ea,i.coordinateSystem,i.reversedDepth));let A=0;if(this.sortObjects){Ea.copy(this.matrixWorld).invert(),Bp.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Ea),yM.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(Ea);for(let I=0,V=g.length;I0){const a=t[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let u=0,f=a.length;ui)return;ix.applyMatrix4(o.matrixWorld);const g=e.ray.origin.distanceTo(ix);if(!(ge.far))return{distance:g,point:xM.clone().applyMatrix4(o.matrixWorld),index:f,face:null,faceIndex:null,barycoord:null,object:o}}const SM=new Y,bM=new Y;class ko extends Ou{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let a=0,u=t.count;a0){const a=t[i[0]];if(a!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let u=0,f=a.length;ua.far)return;u.push({distance:g,distanceToRay:Math.sqrt(d),point:m,index:e,face:null,faceIndex:null,barycoord:null,object:f})}}class UE extends Ti{constructor(e,t,i,a,u=si,f=si,d,m,g){super(e,t,i,a,u,f,d,m,g),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const _=this;function S(){_.needsUpdate=!0,_._requestVideoFrameCallbackId=e.requestVideoFrameCallback(S)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(S))}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 OC extends UE{constructor(e,t,i,a,u,f,d,m){super({},e,t,i,a,u,f,d,m),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class PC extends Ti{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ui,this.minFilter=Ui,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ty extends Ti{constructor(e,t,i,a,u,f,d,m,g,_,S,x){super(null,f,d,m,g,_,a,u,S,x),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class zC extends Ty{constructor(e,t,i,a,u,f){super(e,t,i,u,f),this.isCompressedArrayTexture=!0,this.image.depth=a,this.wrapR=Ca,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class BC extends Ty{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,zo),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Mm extends Ti{constructor(e=[],t=zo,i,a,u,f,d,m,g,_){super(e,t,i,a,u,f,d,m,g,_),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class FC extends Ti{constructor(e,t,i,a,u,f,d,m,g){super(e,t,i,a,u,f,d,m,g),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Wh extends Ti{constructor(e,t,i=vr,a,u,f,d=Ui,m=Ui,g,_=Fo,S=1){if(_!==Fo&&_!==Ru)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const x={width:e,height:t,depth:S};super(x,a,u,f,d,m,_,i,g),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Du(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class IE extends Wh{constructor(e,t=vr,i=zo,a,u,f=Ui,d=Ui,m,g=Fo){const _={width:e,height:e,depth:1},S=[_,_,_,_,_,_];super(e,e,t,i,a,u,f,d,m,g),this.image=S,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class TS extends Ti{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class tf extends Yt{constructor(e=1,t=1,i=1,a=1,u=1,f=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:a,heightSegments:u,depthSegments:f};const d=this;a=Math.floor(a),u=Math.floor(u),f=Math.floor(f);const m=[],g=[],_=[],S=[];let x=0,M=0;T("z","y","x",-1,-1,i,t,e,f,u,0),T("z","y","x",1,-1,i,t,-e,f,u,1),T("x","z","y",1,1,e,i,t,a,f,2),T("x","z","y",1,-1,e,i,-t,a,f,3),T("x","y","z",1,-1,e,t,i,a,u,4),T("x","y","z",-1,-1,e,t,-i,a,u,5),this.setIndex(m),this.setAttribute("position",new gt(g,3)),this.setAttribute("normal",new gt(_,3)),this.setAttribute("uv",new gt(S,2));function T(D,w,A,R,L,I,V,z,H,U,P){const Q=I/H,W=V/U,te=I/2,$=V/2,ue=z/2,se=H+1,q=U+1;let j=0,ye=0;const _e=new Y;for(let Ue=0;Ue0?1:-1,_.push(_e.x,_e.y,_e.z),S.push(ee/H),S.push(1-Ue/U),j+=1}}for(let Ue=0;Ue0){const P=(R-1)*D;for(let Q=0;Q0&&L(!0),t>0&&L(!1)),this.setIndex(_),this.setAttribute("position",new gt(S,3)),this.setAttribute("normal",new gt(x,3)),this.setAttribute("uv",new gt(M,2));function R(){const I=new Y,V=new Y;let z=0;const H=(t-e)/i;for(let U=0;U<=u;U++){const P=[],Q=U/u,W=Q*(t-e)+e;for(let te=0;te<=a;te++){const $=te/a,ue=$*m+d,se=Math.sin(ue),q=Math.cos(ue);V.x=W*se,V.y=-Q*i+w,V.z=W*q,S.push(V.x,V.y,V.z),I.set(se,H,q).normalize(),x.push(I.x,I.y,I.z),M.push($,1-Q),P.push(T++)}D.push(P)}for(let U=0;U0||P!==0)&&(_.push(Q,W,$),z+=3),(t>0||P!==u-1)&&(_.push(W,te,$),z+=3)}g.addGroup(A,z,0),A+=z}function L(I){const V=T,z=new ze,H=new Y;let U=0;const P=I===!0?e:t,Q=I===!0?1:-1;for(let te=1;te<=a;te++)S.push(0,w*Q,0),x.push(0,Q,0),M.push(.5,.5),T++;const W=T;for(let te=0;te<=a;te++){const ue=te/a*m+d,se=Math.cos(ue),q=Math.sin(ue);H.x=P*q,H.y=w*Q,H.z=P*se,S.push(H.x,H.y,H.z),x.push(0,Q,0),z.x=se*.5+.5,z.y=q*.5*Q+.5,M.push(z.x,z.y),T++}for(let te=0;te.9&&H<.1&&(L<.2&&(f[R+0]+=1),I<.2&&(f[R+2]+=1),V<.2&&(f[R+4]+=1))}}function x(R){u.push(R.x,R.y,R.z)}function M(R,L){const I=R*3;L.x=e[I+0],L.y=e[I+1],L.z=e[I+2]}function T(){const R=new Y,L=new Y,I=new Y,V=new Y,z=new ze,H=new ze,U=new ze;for(let P=0,Q=0;P0)m=a-1;else{m=a;break}if(a=m,i[a]===f)return a/(u-1);const _=i[a],x=i[a+1]-_,M=(f-_)/x;return(a+M)/(u-1)}getTangent(e,t){let a=e-1e-4,u=e+1e-4;a<0&&(a=0),u>1&&(u=1);const f=this.getPoint(a),d=this.getPoint(u),m=t||(f.isVector2?new ze:new Y);return m.copy(d).sub(f).normalize(),m}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new Y,a=[],u=[],f=[],d=new Y,m=new kt;for(let M=0;M<=e;M++){const T=M/e;a[M]=this.getTangentAt(T,new Y)}u[0]=new Y,f[0]=new Y;let g=Number.MAX_VALUE;const _=Math.abs(a[0].x),S=Math.abs(a[0].y),x=Math.abs(a[0].z);_<=g&&(g=_,i.set(1,0,0)),S<=g&&(g=S,i.set(0,1,0)),x<=g&&i.set(0,0,1),d.crossVectors(a[0],i).normalize(),u[0].crossVectors(a[0],d),f[0].crossVectors(a[0],u[0]);for(let M=1;M<=e;M++){if(u[M]=u[M-1].clone(),f[M]=f[M-1].clone(),d.crossVectors(a[M-1],a[M]),d.length()>Number.EPSILON){d.normalize();const T=Math.acos(Bt(a[M-1].dot(a[M]),-1,1));u[M].applyMatrix4(m.makeRotationAxis(d,T))}f[M].crossVectors(a[M],u[M])}if(t===!0){let M=Math.acos(Bt(u[0].dot(u[e]),-1,1));M/=e,a[0].dot(d.crossVectors(u[0],u[e]))>0&&(M=-M);for(let T=1;T<=e;T++)u[T].applyMatrix4(m.makeRotationAxis(a[T],M*T)),f[T].crossVectors(a[T],u[T])}return{tangents:a,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 Ry extends Jr{constructor(e=0,t=0,i=1,a=1,u=0,f=Math.PI*2,d=!1,m=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=a,this.aStartAngle=u,this.aEndAngle=f,this.aClockwise=d,this.aRotation=m}getPoint(e,t=new ze){const i=t,a=Math.PI*2;let u=this.aEndAngle-this.aStartAngle;const f=Math.abs(u)a;)u-=a;u0?0:(Math.floor(Math.abs(d)/u)+1)*u:m===0&&d===u-1&&(d=u-2,m=1);let g,_;this.closed||d>0?g=a[(d-1)%u]:(X0.subVectors(a[0],a[1]).add(a[0]),g=X0);const S=a[d%u],x=a[(d+1)%u];if(this.closed||d+2a.length-2?a.length-1:f+1],S=a[f>a.length-3?a.length-1:f+2];return i.set(TM(d,m.x,g.x,_.x,S.x),TM(d,m.y,g.y,_.y,S.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const f=a[u]-i,d=this.curves[u],m=d.getLength(),g=m===0?0:1-f/m;return d.getPointAt(g,t)}u++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,a=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const S=g.getPoint(0);S.equals(this.currentPoint)||this.lineTo(S.x,S.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 Zc extends ty{constructor(e){super(e),this.uuid=ka(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,a=this.holes.length;i80*t){d=o[0],m=o[1];let _=d,S=m;for(let x=t;x_&&(_=M),T>S&&(S=T)}g=Math.max(_-d,S-m),g=g!==0?32767/g:0}return hm(u,f,t,d,m,g,0),f}function kE(o,e,t,i,a){let u;if(a===u3(o,e,t,i)>0)for(let f=e;f=e;f-=i)u=AM(f/i|0,o[f],o[f+1],u);return u&&qh(u,u.next)&&(pm(u),u=u.next),u}function $c(o,e){if(!o)return o;e||(e=o);let t=o,i;do if(i=!1,!t.steiner&&(qh(t,t.next)||_i(t.prev,t,t.next)===0)){if(pm(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function hm(o,e,t,i,a,u,f){if(!o)return;!f&&u&&i3(o,i,a,u);let d=o;for(;o.prev!==o.next;){const m=o.prev,g=o.next;if(u?jC(o,i,a,u):ZC(o)){e.push(m.i,o.i,g.i),pm(o),o=g.next,d=g.next;continue}if(o=g,o===d){f?f===1?(o=QC($c(o),e),hm(o,e,t,i,a,u,2)):f===2&&JC(o,e,t,i,a,u):hm($c(o),e,t,i,a,u,1);break}}}function ZC(o){const e=o.prev,t=o,i=o.next;if(_i(e,t,i)>=0)return!1;const a=e.x,u=t.x,f=i.x,d=e.y,m=t.y,g=i.y,_=Math.min(a,u,f),S=Math.min(d,m,g),x=Math.max(a,u,f),M=Math.max(d,m,g);let T=i.next;for(;T!==e;){if(T.x>=_&&T.x<=x&&T.y>=S&&T.y<=M&&Gp(a,d,u,m,f,g,T.x,T.y)&&_i(T.prev,T,T.next)>=0)return!1;T=T.next}return!0}function jC(o,e,t,i){const a=o.prev,u=o,f=o.next;if(_i(a,u,f)>=0)return!1;const d=a.x,m=u.x,g=f.x,_=a.y,S=u.y,x=f.y,M=Math.min(d,m,g),T=Math.min(_,S,x),D=Math.max(d,m,g),w=Math.max(_,S,x),A=Vx(M,T,e,t,i),R=Vx(D,w,e,t,i);let L=o.prevZ,I=o.nextZ;for(;L&&L.z>=A&&I&&I.z<=R;){if(L.x>=M&&L.x<=D&&L.y>=T&&L.y<=w&&L!==a&&L!==f&&Gp(d,_,m,S,g,x,L.x,L.y)&&_i(L.prev,L,L.next)>=0||(L=L.prevZ,I.x>=M&&I.x<=D&&I.y>=T&&I.y<=w&&I!==a&&I!==f&&Gp(d,_,m,S,g,x,I.x,I.y)&&_i(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;L&&L.z>=A;){if(L.x>=M&&L.x<=D&&L.y>=T&&L.y<=w&&L!==a&&L!==f&&Gp(d,_,m,S,g,x,L.x,L.y)&&_i(L.prev,L,L.next)>=0)return!1;L=L.prevZ}for(;I&&I.z<=R;){if(I.x>=M&&I.x<=D&&I.y>=T&&I.y<=w&&I!==a&&I!==f&&Gp(d,_,m,S,g,x,I.x,I.y)&&_i(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function QC(o,e){let t=o;do{const i=t.prev,a=t.next.next;!qh(i,a)&&GE(i,t,t.next,a)&&dm(i,a)&&dm(a,i)&&(e.push(i.i,t.i,a.i),pm(t),pm(t.next),t=o=a),t=t.next}while(t!==o);return $c(t)}function JC(o,e,t,i,a,u){let f=o;do{let d=f.next.next;for(;d!==f.prev;){if(f.i!==d.i&&r3(f,d)){let m=XE(f,d);f=$c(f,f.next),m=$c(m,m.next),hm(f,e,t,i,a,u,0),hm(m,e,t,i,a,u,0);return}d=d.next}f=f.next}while(f!==o)}function KC(o,e,t,i){const a=[];for(let u=0,f=e.length;u=t.next.y&&t.next.y!==t.y){const S=t.x+(a-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(S<=i&&S>u&&(u=S,f=t.x=t.x&&t.x>=m&&i!==t.x&&HE(af.x||t.x===f.x&&n3(f,t)))&&(f=t,_=S)}t=t.next}while(t!==d);return f}function n3(o,e){return _i(o.prev,o,e.prev)<0&&_i(e.next,o,o.next)<0}function i3(o,e,t,i){let a=o;do a.z===0&&(a.z=Vx(a.x,a.y,e,t,i)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==o);a.prevZ.nextZ=null,a.prevZ=null,s3(a)}function s3(o){let e,t=1;do{let i=o,a;o=null;let u=null;for(e=0;i;){e++;let f=i,d=0;for(let g=0;g0||m>0&&f;)d!==0&&(m===0||!f||i.z<=f.z)?(a=i,i=i.nextZ,d--):(a=f,f=f.nextZ,m--),u?u.nextZ=a:o=a,a.prevZ=u,u=a;i=f}u.nextZ=null,t*=2}while(e>1);return o}function Vx(o,e,t,i,a){return o=(o-t)*a|0,e=(e-i)*a|0,o=(o|o<<8)&16711935,o=(o|o<<4)&252645135,o=(o|o<<2)&858993459,o=(o|o<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,o|e<<1}function a3(o){let e=o,t=o;do(e.x=(o-f)*(u-d)&&(o-f)*(i-d)>=(t-f)*(e-d)&&(t-f)*(u-d)>=(a-f)*(i-d)}function Gp(o,e,t,i,a,u,f,d){return!(o===f&&e===d)&&HE(o,e,t,i,a,u,f,d)}function r3(o,e){return o.next.i!==e.i&&o.prev.i!==e.i&&!o3(o,e)&&(dm(o,e)&&dm(e,o)&&l3(o,e)&&(_i(o.prev,o,e.prev)||_i(o,e.prev,e))||qh(o,e)&&_i(o.prev,o,o.next)>0&&_i(e.prev,e,e.next)>0)}function _i(o,e,t){return(e.y-o.y)*(t.x-e.x)-(e.x-o.x)*(t.y-e.y)}function qh(o,e){return o.x===e.x&&o.y===e.y}function GE(o,e,t,i){const a=q0(_i(o,e,t)),u=q0(_i(o,e,i)),f=q0(_i(t,i,o)),d=q0(_i(t,i,e));return!!(a!==u&&f!==d||a===0&&W0(o,t,e)||u===0&&W0(o,i,e)||f===0&&W0(t,o,i)||d===0&&W0(t,e,i))}function W0(o,e,t){return e.x<=Math.max(o.x,t.x)&&e.x>=Math.min(o.x,t.x)&&e.y<=Math.max(o.y,t.y)&&e.y>=Math.min(o.y,t.y)}function q0(o){return o>0?1:o<0?-1:0}function o3(o,e){let t=o;do{if(t.i!==o.i&&t.next.i!==o.i&&t.i!==e.i&&t.next.i!==e.i&&GE(t,t.next,o,e))return!0;t=t.next}while(t!==o);return!1}function dm(o,e){return _i(o.prev,o,o.next)<0?_i(o,e,o.next)>=0&&_i(o,o.prev,e)>=0:_i(o,e,o.prev)<0||_i(o,o.next,e)<0}function l3(o,e){let t=o,i=!1;const a=(o.x+e.x)/2,u=(o.y+e.y)/2;do t.y>u!=t.next.y>u&&t.next.y!==t.y&&a<(t.next.x-t.x)*(u-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==o);return i}function XE(o,e){const t=kx(o.i,o.x,o.y),i=kx(e.i,e.x,e.y),a=o.next,u=e.prev;return o.next=e,e.prev=o,t.next=a,a.prev=t,i.next=t,t.prev=i,u.next=i,i.prev=u,i}function AM(o,e,t,i){const a=kx(o,e,t);return i?(a.next=i.next,a.prev=i,i.next.prev=a,i.next=a):(a.prev=a,a.next=a),a}function pm(o){o.next.prev=o.prev,o.prev.next=o.next,o.prevZ&&(o.prevZ.nextZ=o.nextZ),o.nextZ&&(o.nextZ.prevZ=o.prevZ)}function kx(o,e,t){return{i:o,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function u3(o,e,t,i){let a=0;for(let u=e,f=t-i;u2&&o[e-1].equals(o[0])&&o.pop()}function CM(o,e){for(let t=0;tNumber.EPSILON){const be=Math.sqrt(O),Le=Math.sqrt(We*We+G*G),Te=Ve.x-Mt/be,rt=Ve.y+nt/be,qe=Ne.x-G/Le,St=Ne.y+We/Le,At=((qe-Te)*G-(St-rt)*We)/(nt*G-Mt*We);Je=Te+nt*At-Re.x,Z=rt+Mt*At-Re.y;const Fe=Je*Je+Z*Z;if(Fe<=2)return new ze(Je,Z);xt=Math.sqrt(Fe/2)}else{let be=!1;nt>Number.EPSILON?We>Number.EPSILON&&(be=!0):nt<-Number.EPSILON?We<-Number.EPSILON&&(be=!0):Math.sign(Mt)===Math.sign(G)&&(be=!0),be?(Je=-Mt,Z=nt,xt=Math.sqrt(O)):(Je=nt,Z=Mt,xt=Math.sqrt(O/2))}return new ze(Je/xt,Z/xt)}const _e=[];for(let Re=0,Ve=se.length,Ne=Ve-1,Je=Re+1;Re=0;Re--){const Ve=Re/w,Ne=M*Math.cos(Ve*Math.PI/2),Je=T*Math.sin(Ve*Math.PI/2)+D;for(let Z=0,xt=se.length;Z=0;){const Je=Ne;let Z=Ne-1;Z<0&&(Z=Re.length-1);for(let xt=0,nt=_+w*2;xt0)&&M.push(L,I,z),(A!==i-1||m0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const a in this.extensions)this.extensions[a]===!0&&(i[a]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class LS extends yr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class US extends zs{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new pt(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pu,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ga,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class jE extends US{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ze(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Bt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new pt(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new pt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new pt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get 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 QE extends zs{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new pt(16777215),this.specular=new pt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pu,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 Ga,this.combine=Sm,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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 JE extends zs{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new pt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pu,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 KE extends zs{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pu,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 $E extends zs{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new pt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new pt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pu,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 Ga,this.combine=Sm,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=e.envMapIntensity,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 IS extends zs{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=hE,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 OS extends zs{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 eT extends zs{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new pt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pu,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 tT extends ta{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 Wc(o,e){return!o||o.constructor===e?o:typeof e.BYTES_PER_ELEMENT=="number"?new e(o):Array.prototype.slice.call(o)}function nT(o){function e(a,u){return o[a]-o[u]}const t=o.length,i=new Array(t);for(let a=0;a!==t;++a)i[a]=a;return i.sort(e),i}function Hx(o,e,t){const i=o.length,a=new o.constructor(i);for(let u=0,f=0;f!==i;++u){const d=t[u]*e;for(let m=0;m!==e;++m)a[f++]=o[d+m]}return a}function PS(o,e,t,i){let a=1,u=o[0];for(;u!==void 0&&u[i]===void 0;)u=o[a++];if(u===void 0)return;let f=u[i];if(f!==void 0)if(Array.isArray(f))do f=u[i],f!==void 0&&(e.push(u.time),t.push(...f)),u=o[a++];while(u!==void 0);else if(f.toArray!==void 0)do f=u[i],f!==void 0&&(e.push(u.time),f.toArray(t,t.length)),u=o[a++];while(u!==void 0);else do f=u[i],f!==void 0&&(e.push(u.time),t.push(f)),u=o[a++];while(u!==void 0)}function v3(o,e,t,i,a=30){const u=o.clone();u.name=e;const f=[];for(let m=0;m=i)){S.push(g.times[M]);for(let D=0;D<_;++D)x.push(g.values[M*_+D])}}S.length!==0&&(g.times=Wc(S,g.times.constructor),g.values=Wc(x,g.values.constructor),f.push(g))}u.tracks=f;let d=1/0;for(let m=0;mu.tracks[m].times[0]&&(d=u.tracks[m].times[0]);for(let m=0;m=d.times[T]){const A=T*S+_,R=A+S-_;D=d.values.slice(A,R)}else{const A=d.createInterpolant(),R=_,L=S-_;A.evaluate(u),D=A.resultBuffer.slice(R,L)}m==="quaternion"&&new ea().fromArray(D).normalize().conjugate().toArray(D);const w=g.times.length;for(let A=0;A=u)){const d=t[1];e=u)break t}f=i,i=0;break n}break e}for(;i>>1;et;)--f;if(++f,u!==0||f!==a){u>=f&&(f=Math.max(f,1),u=f-1);const d=this.getValueSize();this.times=i.slice(u,f),this.values=this.values.slice(u*d,f*d)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Tt("KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,a=this.values,u=i.length;u===0&&(Tt("KeyframeTrack: Track is empty.",this),e=!1);let f=null;for(let d=0;d!==u;d++){const m=i[d];if(typeof m=="number"&&isNaN(m)){Tt("KeyframeTrack: Time is not a valid number.",this,d,m),e=!1;break}if(f!==null&&f>m){Tt("KeyframeTrack: Out of order keys.",this,d,m,f),e=!1;break}f=m}if(a!==void 0&&xE(a))for(let d=0,m=a.length;d!==m;++d){const g=a[d];if(isNaN(g)){Tt("KeyframeTrack: Value is not a valid number.",this,d,g),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),a=this.getInterpolation()===rv,u=e.length-1;let f=1;for(let d=1;d0){e[f]=e[u];for(let d=u*i,m=f*i,g=0;g!==i;++g)t[m+g]=t[d+g];++f}return f!==e.length?(this.times=e.slice(0,f),this.values=t.slice(0,f*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,a=new i(this.name,e,t);return a.createInterpolant=this.createInterpolant,a}}_r.prototype.ValueTypeName="";_r.prototype.TimeBufferType=Float32Array;_r.prototype.ValueBufferType=Float32Array;_r.prototype.DefaultInterpolation=Jv;class nf extends _r{constructor(e,t,i){super(e,t,i)}}nf.prototype.ValueTypeName="bool";nf.prototype.ValueBufferType=Array;nf.prototype.DefaultInterpolation=am;nf.prototype.InterpolantFactoryMethodLinear=void 0;nf.prototype.InterpolantFactoryMethodSmooth=void 0;class BS extends _r{constructor(e,t,i,a){super(e,t,i,a)}}BS.prototype.ValueTypeName="color";class mm extends _r{constructor(e,t,i,a){super(e,t,i,a)}}mm.prototype.ValueTypeName="number";class rT extends $h{constructor(e,t,i,a){super(e,t,i,a)}interpolate_(e,t,i,a){const u=this.resultBuffer,f=this.sampleValues,d=this.valueSize,m=(i-t)/(a-t);let g=e*d;for(let _=g+d;g!==_;g+=4)ea.slerpFlat(u,0,f,g-d,f,g,m);return u}}class Cm extends _r{constructor(e,t,i,a){super(e,t,i,a)}InterpolantFactoryMethodLinear(e){return new rT(this.times,this.values,this.getValueSize(),e)}}Cm.prototype.ValueTypeName="quaternion";Cm.prototype.InterpolantFactoryMethodSmooth=void 0;class sf extends _r{constructor(e,t,i){super(e,t,i)}}sf.prototype.ValueTypeName="string";sf.prototype.ValueBufferType=Array;sf.prototype.DefaultInterpolation=am;sf.prototype.InterpolantFactoryMethodLinear=void 0;sf.prototype.InterpolantFactoryMethodSmooth=void 0;class gm extends _r{constructor(e,t,i,a){super(e,t,i,a)}}gm.prototype.ValueTypeName="vector";class vm{constructor(e="",t=-1,i=[],a=my){this.name=e,this.tracks=i,this.duration=t,this.blendMode=a,this.uuid=ka(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,a=1/(e.fps||1);for(let f=0,d=i.length;f!==d;++f)t.push(S3(i[f]).scale(a));const u=new this(e.name,e.duration,t,e.blendMode);return u.uuid=e.uuid,u.userData=JSON.parse(e.userData||"{}"),u}static toJSON(e){const t=[],i=e.tracks,a={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let u=0,f=i.length;u!==f;++u)t.push(_r.toJSON(i[u]));return a}static CreateFromMorphTargetSequence(e,t,i,a){const u=t.length,f=[];for(let d=0;d1){const S=_[1];let x=a[S];x||(a[S]=x=[]),x.push(g)}}const f=[];for(const d in a)f.push(this.CreateFromMorphTargetSequence(d,a[d],t,i));return f}static parseAnimation(e,t){if(at("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Tt("AnimationClip: No animation in JSONLoader data."),null;const i=function(S,x,M,T,D){if(M.length!==0){const w=[],A=[];PS(M,w,A,T),w.length!==0&&D.push(new S(x,w,A))}},a=[],u=e.name||"default",f=e.fps||30,d=e.blendMode;let m=e.length||-1;const g=e.hierarchy||[];for(let S=0;S{t&&t(u),this.manager.itemEnd(e)},0),u;if(Ml[e]!==void 0){Ml[e].push({onLoad:t,onProgress:i,onError:a});return}Ml[e]=[],Ml[e].push({onLoad:t,onProgress:i,onError:a});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}),d=this.mimeType,m=this.responseType;fetch(f).then(g=>{if(g.status===200||g.status===0){if(g.status===0&&at("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||g.body===void 0||g.body.getReader===void 0)return g;const _=Ml[e],S=g.body.getReader(),x=g.headers.get("X-File-Size")||g.headers.get("Content-Length"),M=x?parseInt(x):0,T=M!==0;let D=0;const w=new ReadableStream({start(A){R();function R(){S.read().then(({done:L,value:I})=>{if(L)A.close();else{D+=I.byteLength;const V=new ProgressEvent("progress",{lengthComputable:T,loaded:D,total:M});for(let z=0,H=_.length;z{A.error(L)})}}});return new Response(w)}else throw new b3(`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(_,d));case"json":return g.json();default:if(d==="")return g.text();{const S=/charset="?([^;"\s]*)"?/i.exec(d),x=S&&S[1]?S[1].toLowerCase():void 0,M=new TextDecoder(x);return g.arrayBuffer().then(T=>M.decode(T))}}}).then(g=>{Oo.add(`file:${e}`,g);const _=Ml[e];delete Ml[e];for(let S=0,x=_.length;S{const _=Ml[e];if(_===void 0)throw this.manager.itemError(e),g;delete Ml[e];for(let S=0,x=_.length;S{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class M3 extends Ra{constructor(e){super(e)}load(e,t,i,a){const u=this,f=new Cl(this.manager);f.setPath(this.path),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(d){try{t(u.parse(JSON.parse(d)))}catch(m){a?a(m):Tt(m),u.manager.itemError(e)}},i,a)}parse(e){const t=[];for(let i=0;i0:a.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const u in e.uniforms){const f=e.uniforms[u];switch(a.uniforms[u]={},f.type){case"t":a.uniforms[u].value=i(f.value);break;case"c":a.uniforms[u].value=new pt().setHex(f.value);break;case"v2":a.uniforms[u].value=new ze().fromArray(f.value);break;case"v3":a.uniforms[u].value=new Y().fromArray(f.value);break;case"v4":a.uniforms[u].value=new Wn().fromArray(f.value);break;case"m3":a.uniforms[u].value=new Jt().fromArray(f.value);break;case"m4":a.uniforms[u].value=new kt().fromArray(f.value);break;default:a.uniforms[u].value=f.value}}if(e.defines!==void 0&&(a.defines=e.defines),e.vertexShader!==void 0&&(a.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(a.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(a.glslVersion=e.glslVersion),e.extensions!==void 0)for(const u in e.extensions)a.extensions[u]=e.extensions[u];if(e.lights!==void 0&&(a.lights=e.lights),e.clipping!==void 0&&(a.clipping=e.clipping),e.size!==void 0&&(a.size=e.size),e.sizeAttenuation!==void 0&&(a.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(a.map=i(e.map)),e.matcap!==void 0&&(a.matcap=i(e.matcap)),e.alphaMap!==void 0&&(a.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(a.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(a.bumpScale=e.bumpScale),e.normalMap!==void 0&&(a.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(a.normalMapType=e.normalMapType),e.normalScale!==void 0){let u=e.normalScale;Array.isArray(u)===!1&&(u=[u,u]),a.normalScale=new ze().fromArray(u)}return e.displacementMap!==void 0&&(a.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(a.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(a.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(a.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(a.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(a.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(a.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(a.specularMap=i(e.specularMap)),e.specularIntensityMap!==void 0&&(a.specularIntensityMap=i(e.specularIntensityMap)),e.specularColorMap!==void 0&&(a.specularColorMap=i(e.specularColorMap)),e.envMap!==void 0&&(a.envMap=i(e.envMap)),e.envMapRotation!==void 0&&a.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(a.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(a.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(a.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(a.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(a.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(a.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(a.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(a.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(a.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(a.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(a.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(a.clearcoatNormalScale=new ze().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(a.iridescenceMap=i(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(a.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(a.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(a.thicknessMap=i(e.thicknessMap)),e.anisotropyMap!==void 0&&(a.anisotropyMap=i(e.anisotropyMap)),e.sheenColorMap!==void 0&&(a.sheenColorMap=i(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(a.sheenRoughnessMap=i(e.sheenRoughnessMap)),a}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return Vy.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:qE,SpriteMaterial:bS,RawShaderMaterial:LS,ShaderMaterial:yr,PointsMaterial:ES,MeshPhysicalMaterial:jE,MeshStandardMaterial:US,MeshPhongMaterial:QE,MeshToonMaterial:JE,MeshNormalMaterial:KE,MeshLambertMaterial:$E,MeshDepthMaterial:IS,MeshDistanceMaterial:OS,MeshBasicMaterial:zu,MeshMatcapMaterial:eT,LineDashedMaterial:tT,LineBasicMaterial:ta,Material:zs};return new t[e]}}class Gx{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 mT extends Yt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class gT extends Ra{constructor(e){super(e)}load(e,t,i,a){const u=this,f=new Cl(u.manager);f.setPath(u.path),f.setRequestHeader(u.requestHeader),f.setWithCredentials(u.withCredentials),f.load(e,function(d){try{t(u.parse(JSON.parse(d)))}catch(m){a?a(m):Tt(m),u.manager.itemError(e)}},i,a)}parse(e){const t={},i={};function a(M,T){if(t[T]!==void 0)return t[T];const w=M.interleavedBuffers[T],A=u(M,w.buffer),R=Ph(w.type,A),L=new by(R,w.stride);return L.uuid=w.uuid,t[T]=L,L}function u(M,T){if(i[T]!==void 0)return i[T];const w=M.arrayBuffers[T],A=new Uint32Array(w).buffer;return i[T]=A,A}const f=e.isInstancedBufferGeometry?new mT:new Yt,d=e.data.index;if(d!==void 0){const M=Ph(d.type,d.array);f.setIndex(new Gn(M,1))}const m=e.data.attributes;for(const M in m){const T=m[M];let D;if(T.isInterleavedBufferAttribute){const w=a(e.data,T.data);D=new Kc(w,T.itemSize,T.offset,T.normalized)}else{const w=Ph(T.type,T.array),A=T.isInstancedBufferAttribute?Xh:Gn;D=new A(w,T.itemSize,T.normalized)}T.name!==void 0&&(D.name=T.name),T.usage!==void 0&&D.setUsage(T.usage),f.setAttribute(M,D)}const g=e.data.morphAttributes;if(g)for(const M in g){const T=g[M],D=[];for(let w=0,A=T.length;w0){const m=new FS(t);u=new ym(m),u.setCrossOrigin(this.crossOrigin);for(let g=0,_=e.length;g<_;g++){const S=e[g],x=S.url;if(Array.isArray(x)){const M=[];for(let T=0,D=x.length;T0){a=new ym(this.manager),a.setCrossOrigin(this.crossOrigin);for(let f=0,d=e.length;f{let A=null,R=null;return w.boundingBox!==void 0&&(A=new Ps().fromJSON(w.boundingBox)),w.boundingSphere!==void 0&&(R=new ys().fromJSON(w.boundingSphere)),{...w,boundingBox:A,boundingSphere:R}}),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 ys().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(f.boundingBox=new Ps().fromJSON(e.boundingBox));break;case"LOD":f=new wE;break;case"Line":f=new Ou(d(e.geometry),m(e.material));break;case"LineLoop":f=new NE(d(e.geometry),m(e.material));break;case"LineSegments":f=new ko(d(e.geometry),m(e.material));break;case"PointCloud":case"Points":f=new LE(d(e.geometry),m(e.material));break;case"Sprite":f=new AE(m(e.material));break;case"Group":f=new zh;break;case"Bone":f=new MS;break;default:f=new wn}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.pivot!==void 0&&(f.pivot=new Y().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(f.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(f.morphTargetInfluences=e.morphTargetInfluences.slice()),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.static!==void 0&&(f.static=e.static),e.userData!==void 0&&(f.userData=e.userData),e.layers!==void 0&&(f.layers.mask=e.layers),e.children!==void 0){const x=e.children;for(let M=0;M"u"&&at("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&at("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,i,a){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(ux.has(f)===!0)a&&a(ux.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 d={};d.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",d.headers=this.requestHeader,d.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const m=fetch(e,d).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){a&&a(g),ux.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 j0;class HS{static getContext(){return j0===void 0&&(j0=new(window.AudioContext||window.webkitAudioContext)),j0}static setContext(e){j0=e}}class I3 extends Ra{constructor(e){super(e)}load(e,t,i,a){const u=this,f=new Cl(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);HS.getContext().decodeAudioData(g,function(S){t(S)}).catch(d)}catch(g){d(g)}},i,a);function d(m){a?a(m):Tt(m),u.manager.itemError(e)}}}const BM=new kt,FM=new kt,Lc=new kt;class O3{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new as,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new as,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,Lc.copy(e.projectionMatrix);const a=t.eyeSep/2,u=a*t.near/t.focus,f=t.near*Math.tan(Yc*t.fov*.5)/t.zoom;let d,m;FM.elements[12]=-a,BM.elements[12]=a,d=-f*t.aspect+u,m=f*t.aspect+u,Lc.elements[0]=2*t.near/(m-d),Lc.elements[8]=(m+d)/(m-d),this.cameraL.projectionMatrix.copy(Lc),d=-f*t.aspect-u,m=f*t.aspect-u,Lc.elements[0]=2*t.near/(m-d),Lc.elements[8]=(m+d)/(m-d),this.cameraR.projectionMatrix.copy(Lc)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(FM),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(BM)}}const wh=-90,Ch=1;class vT extends wn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const a=new as(wh,Ch,e,t);a.layers=this.layers,this.add(a);const u=new as(wh,Ch,e,t);u.layers=this.layers,this.add(u);const f=new as(wh,Ch,e,t);f.layers=this.layers,this.add(f);const d=new as(wh,Ch,e,t);d.layers=this.layers,this.add(d);const m=new as(wh,Ch,e,t);m.layers=this.layers,this.add(m);const g=new as(wh,Ch,e,t);g.layers=this.layers,this.add(g)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,a,u,f,d,m]=t;for(const g of t)this.remove(g);if(e===Va)i.up.set(0,1,0),i.lookAt(1,0,0),a.up.set(0,1,0),a.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),d.up.set(0,1,0),d.lookAt(0,0,1),m.up.set(0,1,0),m.lookAt(0,0,-1);else if(e===Jc)i.up.set(0,-1,0),i.lookAt(-1,0,0),a.up.set(0,-1,0),a.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),d.up.set(0,-1,0),d.lookAt(0,0,1),m.up.set(0,-1,0),m.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const g of t)this.add(g),g.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:a}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[u,f,d,m,g,_]=this.children,S=e.getRenderTarget(),x=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),T=e.xr.enabled;e.xr.enabled=!1;const D=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let w=!1;e.isWebGLRenderer===!0?w=e.state.buffers.depth.getReversed():w=e.reversedDepthBuffer,e.setRenderTarget(i,0,a),w&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(i,1,a),w&&e.autoClear===!1&&e.clearDepth(),e.render(t,f),e.setRenderTarget(i,2,a),w&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(i,3,a),w&&e.autoClear===!1&&e.clearDepth(),e.render(t,m),e.setRenderTarget(i,4,a),w&&e.autoClear===!1&&e.clearDepth(),e.render(t,g),i.texture.generateMipmaps=D,e.setRenderTarget(i,5,a),w&&e.autoClear===!1&&e.clearDepth(),e.render(t,_),e.setRenderTarget(S,x,M),e.xr.enabled=T,i.texture.needsPMREMUpdate=!0}}class yT extends as{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class _T{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=P3.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function P3(){this._document.hidden===!1&&this.reset()}const Uc=new Y,cx=new ea,z3=new Y,Ic=new Y,Oc=new Y;class B3 extends wn{constructor(){super(),this.type="AudioListener",this.context=HS.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new _T}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),this._timer.update();const t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(Uc,cx,z3),Ic.set(0,0,-1).applyQuaternion(cx),Oc.set(0,1,0).applyQuaternion(cx),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Uc.x,i),t.positionY.linearRampToValueAtTime(Uc.y,i),t.positionZ.linearRampToValueAtTime(Uc.z,i),t.forwardX.linearRampToValueAtTime(Ic.x,i),t.forwardY.linearRampToValueAtTime(Ic.y,i),t.forwardZ.linearRampToValueAtTime(Ic.z,i),t.upX.linearRampToValueAtTime(Oc.x,i),t.upY.linearRampToValueAtTime(Oc.y,i),t.upZ.linearRampToValueAtTime(Oc.z,i)}else t.setPosition(Uc.x,Uc.y,Uc.z),t.setOrientation(Ic.x,Ic.y,Ic.z,Oc.x,Oc.y,Oc.z)}}class xT extends wn{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){at("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){at("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){at("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){at("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(i,a,this._addIndex*t,1,t);for(let m=t,g=t+t;m!==g;++m)if(i[m]!==i[m+t]){d.setValue(i,a);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,a=i*this._origIndex;e.getValue(t,a);for(let u=i,f=a;u!==f;++u)t[u]=t[a+u%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i=.5)for(let f=0;f!==u;++f)e[t+f]=e[i+f]}_slerp(e,t,i,a){ea.slerpFlat(e,t,e,t,e,i,a)}_slerpAdditive(e,t,i,a,u){const f=this._workIndex*u;ea.multiplyQuaternionsFlat(e,f,e,t,e,i),ea.slerpFlat(e,t,e,t,e,f,a)}_lerp(e,t,i,a,u){const f=1-a;for(let d=0;d!==u;++d){const m=t+d;e[m]=e[m]*f+e[i+d]*a}}_lerpAdditive(e,t,i,a,u){for(let f=0;f!==u;++f){const d=t+f;e[d]=e[d]+e[i+f]*a}}}const GS="\\[\\]\\.:\\/",H3=new RegExp("["+GS+"]","g"),XS="[^"+GS+"]",G3="[^"+GS.replace("\\.","")+"]",X3=/((?:WC+[\/:])*)/.source.replace("WC",XS),W3=/(WCOD+)?/.source.replace("WCOD",G3),q3=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",XS),Y3=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",XS),Z3=new RegExp("^"+X3+W3+q3+Y3+"$"),j3=["material","materials","bones","map"];class Q3{constructor(e,t,i){const a=i||An.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,a)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,a=this._bindings[i];a!==void 0&&a.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let a=this._targetGroup.nCachedObjects_,u=i.length;a!==u;++a)i[a].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class An{constructor(e,t,i){this.path=t,this.parsedPath=i||An.parseTrackName(t),this.node=An.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new An.Composite(e,t,i):new An(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(H3,"")}static parseTrackName(e){const t=Z3.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},a=i.nodeName&&i.nodeName.lastIndexOf(".");if(a!==void 0&&a!==-1){const u=i.nodeName.substring(a+1);j3.indexOf(u)!==-1&&(i.nodeName=i.nodeName.substring(0,a),i.objectName=u)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(u){for(let f=0;f=u){const S=u++,x=e[S];t[x.uuid]=_,e[_]=x,t[g]=S,e[S]=m;for(let M=0,T=a;M!==T;++M){const D=i[M],w=D[S],A=D[_];D[_]=w,D[S]=A}}}this.nCachedObjects_=u}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,a=i.length;let u=this.nCachedObjects_,f=e.length;for(let d=0,m=arguments.length;d!==m;++d){const g=arguments[d],_=g.uuid,S=t[_];if(S!==void 0)if(delete t[_],S0&&(t[M.uuid]=S),e[S]=M,e.pop();for(let T=0,D=a;T!==D;++T){const w=i[T];w[S]=w[x],w.pop()}}}this.nCachedObjects_=u}subscribe_(e,t){const i=this._bindingsIndicesByPath;let a=i[e];const u=this._bindings;if(a!==void 0)return u[a];const f=this._paths,d=this._parsedPaths,m=this._objects,g=m.length,_=this.nCachedObjects_,S=new Array(g);a=u.length,i[e]=a,f.push(e),d.push(t),u.push(S);for(let x=_,M=m.length;x!==M;++x){const T=m[x];S[x]=new An(T,e,t)}return S}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const a=this._paths,u=this._parsedPaths,f=this._bindings,d=f.length-1,m=f[d],g=e[d];t[g]=i,f[i]=m,f.pop(),u[i]=u[d],u.pop(),a[i]=a[d],a.pop()}}}class bT{constructor(e,t,i=null,a=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=a;const u=t.tracks,f=u.length,d=new Array(f),m={endingStart:Gc,endingEnd:Gc};for(let g=0;g!==f;++g){const _=u[g].createInterpolant(null);d[g]=_,_.settings=m}this._interpolantSettings=m,this._interpolants=d,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,i=!1){if(e.fadeOut(t),this.fadeIn(t),i===!0){const a=this._clip.duration,u=e._clip.duration,f=u/a,d=a/u;e.warp(1,f,t),this.warp(d,1,t)}return this}crossFadeTo(e,t,i=!1){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const a=this._mixer,u=a.time,f=this.timeScale;let d=this._timeScaleInterpolant;d===null&&(d=a._lendControlInterpolant(),this._timeScaleInterpolant=d);const m=d.parameterPositions,g=d.sampleValues;return m[0]=u,m[1]=u+i,g[0]=e/f,g[1]=t/f,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,a){if(!this.enabled){this._updateWeight(e);return}const u=this._startTime;if(u!==null){const m=(e-u)*i;m<0||i===0?t=0:(this._startTime=null,t=i*m)}t*=this._updateTimeScale(e);const f=this._updateTime(t),d=this._updateWeight(e);if(d>0){const m=this._interpolants,g=this._propertyBindings;switch(this.blendMode){case gS:for(let _=0,S=m.length;_!==S;++_)m[_].evaluate(f),g[_].accumulateAdditive(d);break;case my:default:for(let _=0,S=m.length;_!==S;++_)m[_].evaluate(f),g[_].accumulate(a,d)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const a=i.evaluate(e)[0];t*=a,e>i.parameterPositions[1]&&(this.stopFading(),a===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const a=i.evaluate(e)[0];t*=a,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let a=this.time+e,u=this._loopCount;const f=i===fE;if(e===0)return u===-1?a:f&&(u&1)===1?t-a:a;if(i===uE){u===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(a>=t)a=t;else if(a<0)a=0;else{this.time=a;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=a,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)),a>=t||a<0){const d=Math.floor(a/t);a-=t*d,u+=Math.abs(d);const m=this.repetitions-u;if(m<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a=e>0?t:0,this.time=a,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=a,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d})}}else this.time=a;if(f&&(u&1)===1)return t-a}return a}_setEndings(e,t,i){const a=this._interpolantSettings;i?(a.endingStart=Xc,a.endingEnd=Xc):(e?a.endingStart=this.zeroSlopeAtStart?Xc:Gc:a.endingStart=rm,t?a.endingEnd=this.zeroSlopeAtEnd?Xc:Gc:a.endingEnd=rm)}_scheduleFading(e,t,i){const a=this._mixer,u=a.time;let f=this._weightInterpolant;f===null&&(f=a._lendControlInterpolant(),this._weightInterpolant=f);const d=f.parameterPositions,m=f.sampleValues;return d[0]=u,m[0]=t,d[1]=u+e,m[1]=i,this}}const K3=new Float32Array(1);class $3 extends Vo{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){const i=e._localRoot||this._root,a=e._clip.tracks,u=a.length,f=e._propertyBindings,d=e._interpolants,m=i.uuid,g=this._bindingsByRootAndName;let _=g[m];_===void 0&&(_={},g[m]=_);for(let S=0;S!==u;++S){const x=a[S],M=x.name;let T=_[M];if(T!==void 0)++T.referenceCount,f[S]=T;else{if(T=f[S],T!==void 0){T._cacheIndex===null&&(++T.referenceCount,this._addInactiveBinding(T,m,M));continue}const D=t&&t._propertyBindings[S].binding.parsedPath;T=new ST(An.create(i,M,D),x.ValueTypeName,x.getValueSize()),++T.referenceCount,this._addInactiveBinding(T,m,M),f[S]=T}d[S].resultBuffer=T.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,a=e._clip.uuid,u=this._actionsByClip[a];this._bindAction(e,u&&u.knownActions[0]),this._addInactiveAction(e,a,i)}const t=e._propertyBindings;for(let i=0,a=t.length;i!==a;++i){const u=t[i];u.useCount++===0&&(this._lendBinding(u),u.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,a=t.length;i!==a;++i){const u=t[i];--u.useCount===0&&(u.restoreOriginalState(),this._takeBackBinding(u))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,a=this.time+=e,u=Math.sign(e),f=this._accuIndex^=1;for(let g=0;g!==i;++g)t[g]._update(a,e,u,f);const d=this._bindings,m=this._nActiveBindings;for(let g=0;g!==m;++g)d[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,GM).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 XM=new Y,Q0=new Y,Rh=new Y,Dh=new Y,fx=new Y,lR=new Y,uR=new Y;class cR{constructor(e=new Y,t=new Y){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){XM.subVectors(e,this.start),Q0.subVectors(this.end,this.start);const i=Q0.dot(Q0);let u=Q0.dot(XM)/i;return t&&(u=Bt(u,0,1)),u}closestPointToPoint(e,t,i){const a=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(a).add(this.start)}distanceSqToLine3(e,t=lR,i=uR){const a=10000000000000001e-32;let u,f;const d=this.start,m=e.start,g=this.end,_=e.end;Rh.subVectors(g,d),Dh.subVectors(_,m),fx.subVectors(d,m);const S=Rh.dot(Rh),x=Dh.dot(Dh),M=Dh.dot(fx);if(S<=a&&x<=a)return t.copy(d),i.copy(m),t.sub(i),t.dot(t);if(S<=a)u=0,f=M/x,f=Bt(f,0,1);else{const T=Rh.dot(fx);if(x<=a)f=0,u=Bt(-T/S,0,1);else{const D=Rh.dot(Dh),w=S*x-D*D;w!==0?u=Bt((D*M-T*x)/w,0,1):u=0,f=(D*u+M)/x,f<0?(f=0,u=Bt(-T/S,0,1)):f>1&&(f=1,u=Bt((D-T)/S,0,1))}}return t.copy(d).addScaledVector(Rh,u),i.copy(m).addScaledVector(Dh,f),t.distanceToSquared(i)}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 WM=new Y;class fR extends wn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const i=new Yt,a=[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,d=1,m=32;f1)for(let S=0;S.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{QM.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(QM,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class ER extends ko{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],a=new Yt;a.setAttribute("position",new gt(t,3)),a.setAttribute("color",new gt(i,3));const u=new ta({vertexColors:!0,toneMapped:!1});super(a,u),this.type="AxesHelper"}setColors(e,t,i){const a=new pt,u=this.geometry.attributes.color.array;return a.set(e),a.toArray(u,0),a.toArray(u,3),a.set(t),a.toArray(u,6),a.toArray(u,9),a.set(i),a.toArray(u,12),a.toArray(u,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class TR{constructor(){this.type="ShapePath",this.color=new pt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ty,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,a){return this.currentPath.quadraticCurveTo(e,t,i,a),this}bezierCurveTo(e,t,i,a,u,f){return this.currentPath.bezierCurveTo(e,t,i,a,u,f),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(A){const R=[];for(let L=0,I=A.length;LNumber.EPSILON){if(Q<0&&(H=R[z],P=-P,U=R[V],Q=-Q),A.yU.y)continue;if(A.y===H.y){if(A.x===H.x)return!0}else{const W=Q*(A.x-H.x)-P*(A.y-H.y);if(W===0)return!0;if(W<0)continue;I=!I}}else{if(A.y!==H.y)continue;if(U.x<=A.x&&A.x<=H.x||H.x<=A.x&&A.x<=U.x)return!0}}return I}const a=jr.isClockWise,u=this.subPaths;if(u.length===0)return[];let f,d,m;const g=[];if(u.length===1)return d=u[0],m=new Zc,m.curves=d.curves,g.push(m),g;let _=!a(u[0].getPoints());_=e?!_:_;const S=[],x=[];let M=[],T=0,D;x[T]=void 0,M[T]=[];for(let A=0,R=u.length;A1){let A=!1,R=0;for(let L=0,I=x.length;L0&&A===!1&&(M=S)}let w;for(let A=0,R=x.length;Ae?(o.repeat.x=1,o.repeat.y=t/e,o.offset.x=0,o.offset.y=(1-o.repeat.y)/2):(o.repeat.x=e/t,o.repeat.y=1,o.offset.x=(1-o.repeat.x)/2,o.offset.y=0),o}function CR(o,e){const t=o.image&&o.image.width?o.image.width/o.image.height:1;return t>e?(o.repeat.x=e/t,o.repeat.y=1,o.offset.x=(1-o.repeat.x)/2,o.offset.y=0):(o.repeat.x=1,o.repeat.y=t/e,o.offset.x=0,o.offset.y=(1-o.repeat.y)/2),o}function RR(o){return o.repeat.x=1,o.repeat.y=1,o.offset.x=0,o.offset.y=0,o}function Wx(o,e,t,i){const a=DR(i);switch(t){case pS:return o*e;case hy:return o*e/a.components*a.byteLength;case bm:return o*e/a.components*a.byteLength;case Qc:return o*e*2/a.components*a.byteLength;case dy:return o*e*2/a.components*a.byteLength;case mS:return o*e*3/a.components*a.byteLength;case Os:return o*e*4/a.components*a.byteLength;case py:return o*e*4/a.components*a.byteLength;case jp:case Qp:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*8;case Jp:case Kp:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*16;case xv:case bv:return Math.max(o,16)*Math.max(e,8)/4;case _v:case Sv:return Math.max(o,8)*Math.max(e,8)/2;case Mv:case Ev:case Av:case wv:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*8;case Tv:case Cv:case Rv:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*16;case Dv:return Math.floor((o+3)/4)*Math.floor((e+3)/4)*16;case Nv:return Math.floor((o+4)/5)*Math.floor((e+3)/4)*16;case Lv:return Math.floor((o+4)/5)*Math.floor((e+4)/5)*16;case Uv:return Math.floor((o+5)/6)*Math.floor((e+4)/5)*16;case Iv:return Math.floor((o+5)/6)*Math.floor((e+5)/6)*16;case Ov:return Math.floor((o+7)/8)*Math.floor((e+4)/5)*16;case Pv:return Math.floor((o+7)/8)*Math.floor((e+5)/6)*16;case zv:return Math.floor((o+7)/8)*Math.floor((e+7)/8)*16;case Bv:return Math.floor((o+9)/10)*Math.floor((e+4)/5)*16;case Fv:return Math.floor((o+9)/10)*Math.floor((e+5)/6)*16;case Vv:return Math.floor((o+9)/10)*Math.floor((e+7)/8)*16;case kv:return Math.floor((o+9)/10)*Math.floor((e+9)/10)*16;case Hv:return Math.floor((o+11)/12)*Math.floor((e+9)/10)*16;case Gv:return Math.floor((o+11)/12)*Math.floor((e+11)/12)*16;case Xv:case Wv:case qv:return Math.ceil(o/4)*Math.ceil(e/4)*16;case Yv:case Zv:return Math.ceil(o/4)*Math.ceil(e/4)*8;case jv:case Qv:return Math.ceil(o/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function DR(o){switch(o){case Qs:case cS:return{byteLength:1,components:1};case Vh:case fS:case Bo:return{byteLength:2,components:1};case cy:case fy:return{byteLength:2,components:4};case vr:case uy:case Ks:return{byteLength:4,components:1};case hS:case dS:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${o}.`)}class NR{static contain(e,t){return wR(e,t)}static cover(e,t){return CR(e,t)}static fill(e){return RR(e)}static getByteLength(e,t,i,a){return Wx(e,t,i,a)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ry}}));typeof window<"u"&&(window.__THREE__?at("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ry);function AT(){let o=null,e=!1,t=null,i=null;function a(u,f){t(u,f),i=o.requestAnimationFrame(a)}return{start:function(){e!==!0&&t!==null&&(i=o.requestAnimationFrame(a),e=!0)},stop:function(){o.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(u){t=u},setContext:function(u){o=u}}}function LR(o){const e=new WeakMap;function t(d,m){const g=d.array,_=d.usage,S=g.byteLength,x=o.createBuffer();o.bindBuffer(m,x),o.bufferData(m,g,_),d.onUploadCallback();let M;if(g instanceof Float32Array)M=o.FLOAT;else if(typeof Float16Array<"u"&&g instanceof Float16Array)M=o.HALF_FLOAT;else if(g instanceof Uint16Array)d.isFloat16BufferAttribute?M=o.HALF_FLOAT:M=o.UNSIGNED_SHORT;else if(g instanceof Int16Array)M=o.SHORT;else if(g instanceof Uint32Array)M=o.UNSIGNED_INT;else if(g instanceof Int32Array)M=o.INT;else if(g instanceof Int8Array)M=o.BYTE;else if(g instanceof Uint8Array)M=o.UNSIGNED_BYTE;else if(g instanceof Uint8ClampedArray)M=o.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+g);return{buffer:x,type:M,bytesPerElement:g.BYTES_PER_ELEMENT,version:d.version,size:S}}function i(d,m,g){const _=m.array,S=m.updateRanges;if(o.bindBuffer(g,d),S.length===0)o.bufferSubData(g,0,_);else{S.sort((M,T)=>M.start-T.start);let x=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`,jR=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,QR=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,JR=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,KR=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #endif`,$R=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; #endif`,eD=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; #endif`,tD=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec4( 1.0 ); #endif #ifdef USE_COLOR_ALPHA vColor *= color; #elif defined( USE_COLOR ) vColor.rgb *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.rgb *= instanceColor.rgb; #endif #ifdef USE_BATCHING_COLOR vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); #endif`,nD=`#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`,iD=`#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`,sD=`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`,aD=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,rD=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,oD=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,lD=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,uD="gl_FragColor = linearToOutputTexel( gl_FragColor );",cD=`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 ); }`,fD=`#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 ) ); #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 #endif`,hD=`#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`,dD=`#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`,pD=`#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`,mD=`#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`,gD=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,vD=`#ifdef USE_FOG varying float vFogDepth; #endif`,yD=`#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`,_D=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,xD=`#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 }`,SD=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,bD=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,MD=`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`,ED=`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`,TD=`#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`,AD=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,wD=`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`,CD=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,RD=`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`,DD=`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`,ND=`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 + ( material.specularF90 - 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 ); #ifdef USE_CLEARCOAT vec3 Ncc = geometryClearcoatNormal; vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); mat3 mInvClearcoat = mat3( vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), vec3( 0, 1, 0 ), vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) ); vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); #endif } #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 ); }`,LD=` 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`,UD=`#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( ENVMAP_TYPE_CUBE_UV ) #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #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`,ID=`#if defined( RE_IndirectDiffuse ) #if defined( LAMBERT ) || defined( PHONG ) irradiance += iblIrradiance; #endif 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`,OD=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,PD=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,zD=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,BD=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,FD=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,VD=`#ifdef USE_MAP uniform sampler2D map; #endif`,kD=`#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`,HD=`#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`,GD=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,XD=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,WD=`#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`,qD=`#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`,YD=`#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`,ZD=`#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`,jD=`#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`,QD=`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;`,JD=`#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`,KD=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,$D=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,eN=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,tN=`#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`,nN=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,iN=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,sN=`#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`,aN=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,rN=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,oN=`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 ) { #ifdef USE_REVERSED_DEPTH_BUFFER return depth * ( far - near ) - far; #else return depth * ( near - far ) - near; #endif } 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 ) { #ifdef USE_REVERSED_DEPTH_BUFFER return ( near * far ) / ( ( near - far ) * depth - near ); #else return ( near * far ) / ( ( far - near ) * depth - far ); #endif }`,lN=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,uN=`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;`,cN=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,fN=`#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`,hN=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,dN=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,pN=`#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 ) * PI2; 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; #ifdef USE_REVERSED_DEPTH_BUFFER shadowCoord.z -= shadowBias; #else shadowCoord.z += shadowBias; #endif 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; #ifdef USE_REVERSED_DEPTH_BUFFER shadowCoord.z -= shadowBias; #else shadowCoord.z += shadowBias; #endif 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 ) { #ifdef USE_REVERSED_DEPTH_BUFFER float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp -= shadowBias; #else float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; #endif 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 ) * PI2; vec2 sample0 = vogelDiskSample( 0, 5, phi ); vec2 sample1 = vogelDiskSample( 1, 5, phi ); vec2 sample2 = vogelDiskSample( 2, 5, phi ); vec2 sample3 = vogelDiskSample( 3, 5, phi ); vec2 sample4 = vogelDiskSample( 4, 5, phi ); shadow = ( texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.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 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; vec3 bd3D = normalize( lightToPosition ); float depth = textureCube( shadowMap, bd3D ).r; #ifdef USE_REVERSED_DEPTH_BUFFER depth = 1.0 - depth; #endif shadow = step( dp, depth ); } return mix( 1.0, shadow, shadowIntensity ); } #endif #endif #endif`,mN=`#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`,gN=`#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`,vN=`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; }`,yN=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,_N=`#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`,xN=`#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`,SN=`#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`,bN=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,MN=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,EN=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,TN=`#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; }`,AN=`#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`,wN=`#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`,CN=`#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`,RN=`#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`,DN=`#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`,NN=`#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 LN=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,UN=`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 }`,IN=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,ON=`#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 }`,PN=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,zN=`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 }`,BN=`#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; }`,FN=`#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 }`,VN=`#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; }`,kN=`#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 ); }`,HN=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,GN=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,XN=`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 }`,WN=`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 }`,qN=`#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 }`,YN=`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 }`,ZN=`#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 }`,jN=`#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 #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 }`,QN=`#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; }`,JN=`#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 }`,KN=`#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 }`,$N=`#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 }`,eL=`#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 }`,tL=`#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 #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 }`,nL=`#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 }`,iL=`#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 }`,sL=`#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 }`,aL=`#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 }`,rL=`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 }`,oL=`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 }`,lL=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,uL=`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 #include }`,cL=`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 }`,fL=`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 }`,sn={alphahash_fragment:UR,alphahash_pars_fragment:IR,alphamap_fragment:OR,alphamap_pars_fragment:PR,alphatest_fragment:zR,alphatest_pars_fragment:BR,aomap_fragment:FR,aomap_pars_fragment:VR,batching_pars_vertex:kR,batching_vertex:HR,begin_vertex:GR,beginnormal_vertex:XR,bsdfs:WR,iridescence_fragment:qR,bumpmap_pars_fragment:YR,clipping_planes_fragment:ZR,clipping_planes_pars_fragment:jR,clipping_planes_pars_vertex:QR,clipping_planes_vertex:JR,color_fragment:KR,color_pars_fragment:$R,color_pars_vertex:eD,color_vertex:tD,common:nD,cube_uv_reflection_fragment:iD,defaultnormal_vertex:sD,displacementmap_pars_vertex:aD,displacementmap_vertex:rD,emissivemap_fragment:oD,emissivemap_pars_fragment:lD,colorspace_fragment:uD,colorspace_pars_fragment:cD,envmap_fragment:fD,envmap_common_pars_fragment:hD,envmap_pars_fragment:dD,envmap_pars_vertex:pD,envmap_physical_pars_fragment:TD,envmap_vertex:mD,fog_vertex:gD,fog_pars_vertex:vD,fog_fragment:yD,fog_pars_fragment:_D,gradientmap_pars_fragment:xD,lightmap_pars_fragment:SD,lights_lambert_fragment:bD,lights_lambert_pars_fragment:MD,lights_pars_begin:ED,lights_toon_fragment:AD,lights_toon_pars_fragment:wD,lights_phong_fragment:CD,lights_phong_pars_fragment:RD,lights_physical_fragment:DD,lights_physical_pars_fragment:ND,lights_fragment_begin:LD,lights_fragment_maps:UD,lights_fragment_end:ID,logdepthbuf_fragment:OD,logdepthbuf_pars_fragment:PD,logdepthbuf_pars_vertex:zD,logdepthbuf_vertex:BD,map_fragment:FD,map_pars_fragment:VD,map_particle_fragment:kD,map_particle_pars_fragment:HD,metalnessmap_fragment:GD,metalnessmap_pars_fragment:XD,morphinstance_vertex:WD,morphcolor_vertex:qD,morphnormal_vertex:YD,morphtarget_pars_vertex:ZD,morphtarget_vertex:jD,normal_fragment_begin:QD,normal_fragment_maps:JD,normal_pars_fragment:KD,normal_pars_vertex:$D,normal_vertex:eN,normalmap_pars_fragment:tN,clearcoat_normal_fragment_begin:nN,clearcoat_normal_fragment_maps:iN,clearcoat_pars_fragment:sN,iridescence_pars_fragment:aN,opaque_fragment:rN,packing:oN,premultiplied_alpha_fragment:lN,project_vertex:uN,dithering_fragment:cN,dithering_pars_fragment:fN,roughnessmap_fragment:hN,roughnessmap_pars_fragment:dN,shadowmap_pars_fragment:pN,shadowmap_pars_vertex:mN,shadowmap_vertex:gN,shadowmask_pars_fragment:vN,skinbase_vertex:yN,skinning_pars_vertex:_N,skinning_vertex:xN,skinnormal_vertex:SN,specularmap_fragment:bN,specularmap_pars_fragment:MN,tonemapping_fragment:EN,tonemapping_pars_fragment:TN,transmission_fragment:AN,transmission_pars_fragment:wN,uv_pars_fragment:CN,uv_pars_vertex:RN,uv_vertex:DN,worldpos_vertex:NN,background_vert:LN,background_frag:UN,backgroundCube_vert:IN,backgroundCube_frag:ON,cube_vert:PN,cube_frag:zN,depth_vert:BN,depth_frag:FN,distance_vert:VN,distance_frag:kN,equirect_vert:HN,equirect_frag:GN,linedashed_vert:XN,linedashed_frag:WN,meshbasic_vert:qN,meshbasic_frag:YN,meshlambert_vert:ZN,meshlambert_frag:jN,meshmatcap_vert:QN,meshmatcap_frag:JN,meshnormal_vert:KN,meshnormal_frag:$N,meshphong_vert:eL,meshphong_frag:tL,meshphysical_vert:nL,meshphysical_frag:iL,meshtoon_vert:sL,meshtoon_frag:aL,points_vert:rL,points_frag:oL,shadow_vert:lL,shadow_frag:uL,sprite_vert:cL,sprite_frag:fL},lt={common:{diffuse:{value:new pt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Jt},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Jt}},envmap:{envMap:{value:null},envMapRotation:{value:new Jt},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 Jt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Jt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Jt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Jt},normalScale:{value:new ze(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Jt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Jt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Jt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Jt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new pt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new pt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0},uvTransform:{value:new Jt}},sprite:{diffuse:{value:new pt(16777215)},opacity:{value:1},center:{value:new ze(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Jt},alphaMap:{value:null},alphaMapTransform:{value:new Jt},alphaTest:{value:0}}},Zr={basic:{uniforms:js([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.fog]),vertexShader:sn.meshbasic_vert,fragmentShader:sn.meshbasic_frag},lambert:{uniforms:js([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,lt.lights,{emissive:{value:new pt(0)},envMapIntensity:{value:1}}]),vertexShader:sn.meshlambert_vert,fragmentShader:sn.meshlambert_frag},phong:{uniforms:js([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,lt.lights,{emissive:{value:new pt(0)},specular:{value:new pt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:sn.meshphong_vert,fragmentShader:sn.meshphong_frag},standard:{uniforms:js([lt.common,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.roughnessmap,lt.metalnessmap,lt.fog,lt.lights,{emissive:{value:new pt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag},toon:{uniforms:js([lt.common,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.gradientmap,lt.fog,lt.lights,{emissive:{value:new pt(0)}}]),vertexShader:sn.meshtoon_vert,fragmentShader:sn.meshtoon_frag},matcap:{uniforms:js([lt.common,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,{matcap:{value:null}}]),vertexShader:sn.meshmatcap_vert,fragmentShader:sn.meshmatcap_frag},points:{uniforms:js([lt.points,lt.fog]),vertexShader:sn.points_vert,fragmentShader:sn.points_frag},dashed:{uniforms:js([lt.common,lt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:sn.linedashed_vert,fragmentShader:sn.linedashed_frag},depth:{uniforms:js([lt.common,lt.displacementmap]),vertexShader:sn.depth_vert,fragmentShader:sn.depth_frag},normal:{uniforms:js([lt.common,lt.bumpmap,lt.normalmap,lt.displacementmap,{opacity:{value:1}}]),vertexShader:sn.meshnormal_vert,fragmentShader:sn.meshnormal_frag},sprite:{uniforms:js([lt.sprite,lt.fog]),vertexShader:sn.sprite_vert,fragmentShader:sn.sprite_frag},background:{uniforms:{uvTransform:{value:new Jt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:sn.background_vert,fragmentShader:sn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Jt}},vertexShader:sn.backgroundCube_vert,fragmentShader:sn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:sn.cube_vert,fragmentShader:sn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:sn.equirect_vert,fragmentShader:sn.equirect_frag},distance:{uniforms:js([lt.common,lt.displacementmap,{referencePosition:{value:new Y},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:sn.distance_vert,fragmentShader:sn.distance_frag},shadow:{uniforms:js([lt.lights,lt.fog,{color:{value:new pt(0)},opacity:{value:1}}]),vertexShader:sn.shadow_vert,fragmentShader:sn.shadow_frag}};Zr.physical={uniforms:js([Zr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Jt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Jt},clearcoatNormalScale:{value:new ze(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Jt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Jt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Jt},sheen:{value:0},sheenColor:{value:new pt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Jt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Jt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Jt},transmissionSamplerSize:{value:new ze},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Jt},attenuationDistance:{value:0},attenuationColor:{value:new pt(0)},specularColor:{value:new pt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Jt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Jt},anisotropyVector:{value:new ze},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Jt}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag};const nv={r:0,b:0,g:0},Bc=new Ga,hL=new kt;function dL(o,e,t,i,a,u){const f=new pt(0);let d=a===!0?0:1,m,g,_=null,S=0,x=null;function M(R){let L=R.isScene===!0?R.background:null;if(L&&L.isTexture){const I=R.backgroundBlurriness>0;L=e.get(L,I)}return L}function T(R){let L=!1;const I=M(R);I===null?w(f,d):I&&I.isColor&&(w(I,1),L=!0);const V=o.xr.getEnvironmentBlendMode();V==="additive"?t.buffers.color.setClear(0,0,0,1,u):V==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,u),(o.autoClear||L)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),o.clear(o.autoClearColor,o.autoClearDepth,o.autoClearStencil))}function D(R,L){const I=M(L);I&&(I.isCubeTexture||I.mapping===jh)?(g===void 0&&(g=new Gi(new tf(1,1,1),new yr({name:"BackgroundCubeMaterial",uniforms:Yh(Zr.backgroundCube.uniforms),vertexShader:Zr.backgroundCube.vertexShader,fragmentShader:Zr.backgroundCube.fragmentShader,side:$s,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),g.geometry.deleteAttribute("normal"),g.geometry.deleteAttribute("uv"),g.onBeforeRender=function(V,z,H){this.matrixWorld.copyPosition(H.matrixWorld)},Object.defineProperty(g.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(g)),Bc.copy(L.backgroundRotation),Bc.x*=-1,Bc.y*=-1,Bc.z*=-1,I.isCubeTexture&&I.isRenderTargetTexture===!1&&(Bc.y*=-1,Bc.z*=-1),g.material.uniforms.envMap.value=I,g.material.uniforms.flipEnvMap.value=I.isCubeTexture&&I.isRenderTargetTexture===!1?-1:1,g.material.uniforms.backgroundBlurriness.value=L.backgroundBlurriness,g.material.uniforms.backgroundIntensity.value=L.backgroundIntensity,g.material.uniforms.backgroundRotation.value.setFromMatrix4(hL.makeRotationFromEuler(Bc)),g.material.toneMapped=xn.getTransfer(I.colorSpace)!==On,(_!==I||S!==I.version||x!==o.toneMapping)&&(g.material.needsUpdate=!0,_=I,S=I.version,x=o.toneMapping),g.layers.enableAll(),R.unshift(g,g.geometry,g.material,0,0,null)):I&&I.isTexture&&(m===void 0&&(m=new Gi(new Kh(2,2),new yr({name:"BackgroundMaterial",uniforms:Yh(Zr.background.uniforms),vertexShader:Zr.background.vertexShader,fragmentShader:Zr.background.fragmentShader,side:wl,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),m.geometry.deleteAttribute("normal"),Object.defineProperty(m.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(m)),m.material.uniforms.t2D.value=I,m.material.uniforms.backgroundIntensity.value=L.backgroundIntensity,m.material.toneMapped=xn.getTransfer(I.colorSpace)!==On,I.matrixAutoUpdate===!0&&I.updateMatrix(),m.material.uniforms.uvTransform.value.copy(I.matrix),(_!==I||S!==I.version||x!==o.toneMapping)&&(m.material.needsUpdate=!0,_=I,S=I.version,x=o.toneMapping),m.layers.enableAll(),R.unshift(m,m.geometry,m.material,0,0,null))}function w(R,L){R.getRGB(nv,YE(o)),t.buffers.color.setClear(nv.r,nv.g,nv.b,L,u)}function A(){g!==void 0&&(g.geometry.dispose(),g.material.dispose(),g=void 0),m!==void 0&&(m.geometry.dispose(),m.material.dispose(),m=void 0)}return{getClearColor:function(){return f},setClearColor:function(R,L=1){f.set(R),d=L,w(f,d)},getClearAlpha:function(){return d},setClearAlpha:function(R){d=R,w(f,d)},render:T,addToRenderList:D,dispose:A}}function pL(o,e){const t=o.getParameter(o.MAX_VERTEX_ATTRIBS),i={},a=x(null);let u=a,f=!1;function d(W,te,$,ue,se){let q=!1;const j=S(W,ue,$,te);u!==j&&(u=j,g(u.object)),q=M(W,ue,$,se),q&&T(W,ue,$,se),se!==null&&e.update(se,o.ELEMENT_ARRAY_BUFFER),(q||f)&&(f=!1,I(W,te,$,ue),se!==null&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,e.get(se).buffer))}function m(){return o.createVertexArray()}function g(W){return o.bindVertexArray(W)}function _(W){return o.deleteVertexArray(W)}function S(W,te,$,ue){const se=ue.wireframe===!0;let q=i[te.id];q===void 0&&(q={},i[te.id]=q);const j=W.isInstancedMesh===!0?W.id:0;let ye=q[j];ye===void 0&&(ye={},q[j]=ye);let _e=ye[$.id];_e===void 0&&(_e={},ye[$.id]=_e);let Ue=_e[se];return Ue===void 0&&(Ue=x(m()),_e[se]=Ue),Ue}function x(W){const te=[],$=[],ue=[];for(let se=0;se=0){const X=se[_e];let ee=q[_e];if(ee===void 0&&(_e==="instanceMatrix"&&W.instanceMatrix&&(ee=W.instanceMatrix),_e==="instanceColor"&&W.instanceColor&&(ee=W.instanceColor)),X===void 0||X.attribute!==ee||ee&&X.data!==ee.data)return!0;j++}return u.attributesNum!==j||u.index!==ue}function T(W,te,$,ue){const se={},q=te.attributes;let j=0;const ye=$.getAttributes();for(const _e in ye)if(ye[_e].location>=0){let X=q[_e];X===void 0&&(_e==="instanceMatrix"&&W.instanceMatrix&&(X=W.instanceMatrix),_e==="instanceColor"&&W.instanceColor&&(X=W.instanceColor));const ee={};ee.attribute=X,X&&X.data&&(ee.data=X.data),se[_e]=ee,j++}u.attributes=se,u.attributesNum=j,u.index=ue}function D(){const W=u.newAttributes;for(let te=0,$=W.length;te<$;te++)W[te]=0}function w(W){A(W,0)}function A(W,te){const $=u.newAttributes,ue=u.enabledAttributes,se=u.attributeDivisors;$[W]=1,ue[W]===0&&(o.enableVertexAttribArray(W),ue[W]=1),se[W]!==te&&(o.vertexAttribDivisor(W,te),se[W]=te)}function R(){const W=u.newAttributes,te=u.enabledAttributes;for(let $=0,ue=te.length;$=0){let Ue=se[ye];if(Ue===void 0&&(ye==="instanceMatrix"&&W.instanceMatrix&&(Ue=W.instanceMatrix),ye==="instanceColor"&&W.instanceColor&&(Ue=W.instanceColor)),Ue!==void 0){const X=Ue.normalized,ee=Ue.itemSize,Ee=e.get(Ue);if(Ee===void 0)continue;const Oe=Ee.buffer,st=Ee.type,ce=Ee.bytesPerElement,Ce=st===o.INT||st===o.UNSIGNED_INT||Ue.gpuType===uy;if(Ue.isInterleavedBufferAttribute){const Be=Ue.data,et=Be.stride,yt=Ue.offset;if(Be.isInstancedInterleavedBuffer){for(let wt=0;wt<_e.locationSize;wt++)A(_e.location+wt,Be.meshPerAttribute);W.isInstancedMesh!==!0&&ue._maxInstanceCount===void 0&&(ue._maxInstanceCount=Be.meshPerAttribute*Be.count)}else for(let wt=0;wt<_e.locationSize;wt++)w(_e.location+wt);o.bindBuffer(o.ARRAY_BUFFER,Oe);for(let wt=0;wt<_e.locationSize;wt++)L(_e.location+wt,ee/_e.locationSize,st,X,et*ce,(yt+ee/_e.locationSize*wt)*ce,Ce)}else{if(Ue.isInstancedBufferAttribute){for(let Be=0;Be<_e.locationSize;Be++)A(_e.location+Be,Ue.meshPerAttribute);W.isInstancedMesh!==!0&&ue._maxInstanceCount===void 0&&(ue._maxInstanceCount=Ue.meshPerAttribute*Ue.count)}else for(let Be=0;Be<_e.locationSize;Be++)w(_e.location+Be);o.bindBuffer(o.ARRAY_BUFFER,Oe);for(let Be=0;Be<_e.locationSize;Be++)L(_e.location+Be,ee/_e.locationSize,st,X,ee*ce,ee/_e.locationSize*Be*ce,Ce)}}else if(j!==void 0){const X=j[ye];if(X!==void 0)switch(X.length){case 2:o.vertexAttrib2fv(_e.location,X);break;case 3:o.vertexAttrib3fv(_e.location,X);break;case 4:o.vertexAttrib4fv(_e.location,X);break;default:o.vertexAttrib1fv(_e.location,X)}}}}R()}function V(){P();for(const W in i){const te=i[W];for(const $ in te){const ue=te[$];for(const se in ue){const q=ue[se];for(const j in q)_(q[j].object),delete q[j];delete ue[se]}}delete i[W]}}function z(W){if(i[W.id]===void 0)return;const te=i[W.id];for(const $ in te){const ue=te[$];for(const se in ue){const q=ue[se];for(const j in q)_(q[j].object),delete q[j];delete ue[se]}}delete i[W.id]}function H(W){for(const te in i){const $=i[te];for(const ue in $){const se=$[ue];if(se[W.id]===void 0)continue;const q=se[W.id];for(const j in q)_(q[j].object),delete q[j];delete se[W.id]}}}function U(W){for(const te in i){const $=i[te],ue=W.isInstancedMesh===!0?W.id:0,se=$[ue];if(se!==void 0){for(const q in se){const j=se[q];for(const ye in j)_(j[ye].object),delete j[ye];delete se[q]}delete $[ue],Object.keys($).length===0&&delete i[te]}}}function P(){Q(),f=!0,u!==a&&(u=a,g(u.object))}function Q(){a.geometry=null,a.program=null,a.wireframe=!1}return{setup:d,reset:P,resetDefaultState:Q,dispose:V,releaseStatesOfGeometry:z,releaseStatesOfObject:U,releaseStatesOfProgram:H,initAttributes:D,enableAttribute:w,disableUnusedAttributes:R}}function mL(o,e,t){let i;function a(g){i=g}function u(g,_){o.drawArrays(i,g,_),t.update(_,i,1)}function f(g,_,S){S!==0&&(o.drawArraysInstanced(i,g,_,S),t.update(_,i,S))}function d(g,_,S){if(S===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,g,0,_,0,S);let M=0;for(let T=0;T0&&o.getShaderPrecisionFormat(o.FRAGMENT_SHADER,o.HIGH_FLOAT).precision>0)return"highp";H="mediump"}return H==="mediump"&&o.getShaderPrecisionFormat(o.VERTEX_SHADER,o.MEDIUM_FLOAT).precision>0&&o.getShaderPrecisionFormat(o.FRAGMENT_SHADER,o.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let g=t.precision!==void 0?t.precision:"highp";const _=m(g);_!==g&&(at("WebGLRenderer:",g,"not supported, using",_,"instead."),g=_);const S=t.logarithmicDepthBuffer===!0,x=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),M=o.getParameter(o.MAX_TEXTURE_IMAGE_UNITS),T=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS),D=o.getParameter(o.MAX_TEXTURE_SIZE),w=o.getParameter(o.MAX_CUBE_MAP_TEXTURE_SIZE),A=o.getParameter(o.MAX_VERTEX_ATTRIBS),R=o.getParameter(o.MAX_VERTEX_UNIFORM_VECTORS),L=o.getParameter(o.MAX_VARYING_VECTORS),I=o.getParameter(o.MAX_FRAGMENT_UNIFORM_VECTORS),V=o.getParameter(o.MAX_SAMPLES),z=o.getParameter(o.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:u,getMaxPrecision:m,textureFormatReadable:f,textureTypeReadable:d,precision:g,logarithmicDepthBuffer:S,reversedDepthBuffer:x,maxTextures:M,maxVertexTextures:T,maxTextureSize:D,maxCubemapSize:w,maxAttributes:A,maxVertexUniforms:R,maxVaryings:L,maxFragmentUniforms:I,maxSamples:V,samples:z}}function vL(o){const e=this;let t=null,i=0,a=!1,u=!1;const f=new Au,d=new Jt,m={value:null,needsUpdate:!1};this.uniform=m,this.numPlanes=0,this.numIntersection=0,this.init=function(S,x){const M=S.length!==0||x||i!==0||a;return a=x,i=S.length,M},this.beginShadows=function(){u=!0,_(null)},this.endShadows=function(){u=!1},this.setGlobalState=function(S,x){t=_(S,x,0)},this.setState=function(S,x,M){const T=S.clippingPlanes,D=S.clipIntersection,w=S.clipShadows,A=o.get(S);if(!a||T===null||T.length===0||u&&!w)u?_(null):g();else{const R=u?0:i,L=R*4;let I=A.clippingState||null;m.value=I,I=_(T,x,L,M);for(let V=0;V!==L;++V)I[V]=t[V];A.clippingState=I,this.numIntersection=D?this.numPlanes:0,this.numPlanes+=R}};function g(){m.value!==t&&(m.value=t,m.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function _(S,x,M,T){const D=S!==null?S.length:0;let w=null;if(D!==0){if(w=m.value,T!==!0||w===null){const A=M+D*4,R=x.matrixWorldInverse;d.getNormalMatrix(R),(w===null||w.length0&&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=t1(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=e1(),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?V:0,V,V),S.setRenderTarget(a),A&&S.render(D,m),S.render(e,m)}S.toneMapping=M,S.autoClear=x,e.background=R}_textureToCubeUV(e,t){const i=this._renderer,a=e.mapping===zo||e.mapping===Lu;a?(this._cubemapMaterial===null&&(this._cubemapMaterial=t1()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=e1());const u=a?this._cubemapMaterial:this._equirectMaterial,f=this._lodMeshes[0];f.material=u;const d=u.uniforms;d.envMap.value=e;const m=this._cubeSize;Nh(t,0,0,3*m,2*m),i.setRenderTarget(t),i.render(f,Vp)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const a=this._lodMeshes.length;for(let u=1;uT-Nu?i-T+Nu:0),A=4*(this._cubeSize-D);m.envMap.value=e.texture,m.roughness.value=M,m.mipInt.value=T-t,Nh(u,w,A,3*D,2*D),a.setRenderTarget(u),a.render(d,Vp),m.envMap.value=u.texture,m.roughness.value=0,m.mipInt.value=T-i,Nh(e,w,A,3*D,2*D),a.setRenderTarget(e),a.render(d,Vp)}_blur(e,t,i,a,u){const f=this._pingPongRenderTarget;this._halfBlur(e,f,t,i,a,"latitudinal",u),this._halfBlur(f,e,i,i,a,"longitudinal",u)}_halfBlur(e,t,i,a,u,f,d){const m=this._renderer,g=this._blurMaterial;f!=="latitudinal"&&f!=="longitudinal"&&Tt("blur direction must be either latitudinal or longitudinal!");const _=3,S=this._lodMeshes[a];S.material=g;const x=g.uniforms,M=this._sizeLods[i]-1,T=isFinite(u)?Math.PI/(2*M):2*Math.PI/(2*kc-1),D=u/T,w=isFinite(u)?1+Math.floor(_*D):kc;w>kc&&at(`sigmaRadians, ${u}, is too large and will clip, as it requested ${w} samples when the maximum is set to ${kc}`);const A=[];let R=0;for(let H=0;HL-Nu?a-L+Nu:0),z=4*(this._cubeSize-I);Nh(t,V,z,3*I,2*I),m.setRenderTarget(t),m.render(S,Vp)}}function xL(o){const e=[],t=[],i=[];let a=o;const u=o-Nu+1+JM.length;for(let f=0;fo-Nu?m=JM[f-o+Nu-1]:f===0&&(m=0),t.push(m);const g=1/(d-2),_=-g,S=1+g,x=[_,_,S,_,S,S,_,_,S,S,_,S],M=6,T=6,D=3,w=2,A=1,R=new Float32Array(D*T*M),L=new Float32Array(w*T*M),I=new Float32Array(A*T*M);for(let z=0;z2?0:-1,P=[H,U,0,H+2/3,U,0,H+2/3,U+1,0,H,U,0,H+2/3,U+1,0,H,U+1,0];R.set(P,D*T*z),L.set(x,w*T*z);const Q=[z,z,z,z,z,z];I.set(Q,A*T*z)}const V=new Yt;V.setAttribute("position",new Gn(R,D)),V.setAttribute("uv",new Gn(L,w)),V.setAttribute("faceIndex",new Gn(I,A)),i.push(new Gi(V,null)),a>Nu&&a--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function $M(o,e,t){const i=new Ha(o,e,t);return i.texture.mapping=jh,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Nh(o,e,t,i,a){o.viewport.set(e,t,i,a),o.scissor.set(e,t,i,a)}function SL(o,e,t){return new yr({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:yL,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${o}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ky(),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 4.1: Orthonormal basis vec3 T1 = vec3(1.0, 0.0, 0.0); vec3 T2 = cross(V, 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 + V.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)) * V; // 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 bL(o,e,t){const i=new Float32Array(kc),a=new Y(0,1,0);return new yr({name:"SphericalGaussianBlur",defines:{n:kc,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${o}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:a}},vertexShader:ky(),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 e1(){return new yr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ky(),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 t1(){return new yr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ky(),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 ky(){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 ); } `}class YS extends Ha{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},a=[i,i,i,i,i,i];this.texture=new Mm(a),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},a=new tf(5,5,5),u=new yr({name:"CubemapFromEquirect",uniforms:Yh(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:$s,blending:Po});u.uniforms.tEquirect.value=t;const f=new Gi(a,u),d=t.minFilter;return t.minFilter===Io&&(t.minFilter=si),new vT(1,10,this).update(e,f),t.minFilter=d,f.geometry.dispose(),f.material.dispose(),this}clear(e,t=!0,i=!0,a=!0){const u=e.getRenderTarget();for(let f=0;f<6;f++)e.setRenderTarget(this,f),e.clear(t,i,a);e.setRenderTarget(u)}}function ML(o){let e=new WeakMap,t=new WeakMap,i=null;function a(x,M=!1){return x==null?null:M?f(x):u(x)}function u(x){if(x&&x.isTexture){const M=x.mapping;if(M===qp||M===Yp)if(e.has(x)){const T=e.get(x).texture;return d(T,x.mapping)}else{const T=x.image;if(T&&T.height>0){const D=new YS(T.height);return D.fromEquirectangularTexture(o,x),e.set(x,D),x.addEventListener("dispose",g),d(D.texture,x.mapping)}else return null}}return x}function f(x){if(x&&x.isTexture){const M=x.mapping,T=M===qp||M===Yp,D=M===zo||M===Lu;if(T||D){let w=t.get(x);const A=w!==void 0?w.texture.pmremVersion:0;if(x.isRenderTargetTexture&&x.pmremVersion!==A)return i===null&&(i=new qx(o)),w=T?i.fromEquirectangular(x,w):i.fromCubemap(x,w),w.texture.pmremVersion=x.pmremVersion,t.set(x,w),w.texture;if(w!==void 0)return w.texture;{const R=x.image;return T&&R&&R.height>0||D&&R&&m(R)?(i===null&&(i=new qx(o)),w=T?i.fromEquirectangular(x):i.fromCubemap(x),w.texture.pmremVersion=x.pmremVersion,t.set(x,w),x.addEventListener("dispose",_),w.texture):null}}}return x}function d(x,M){return M===qp?x.mapping=zo:M===Yp&&(x.mapping=Lu),x}function m(x){let M=0;const T=6;for(let D=0;D=65535?SS:xS)(x,1);w.version=D;const A=u.get(S);A&&e.remove(A),u.set(S,w)}function _(S){const x=u.get(S);if(x){const M=S.index;M!==null&&x.versione.maxTextureSize&&(z=Math.ceil(V/e.maxTextureSize),V=e.maxTextureSize);const H=new Float32Array(V*z*4*S),U=new yy(H,V,z,S);U.type=Ks,U.needsUpdate=!0;const P=I*4;for(let W=0;W #include void main() { gl_FragColor = texture2D( tDiffuse, vUv ); #ifdef LINEAR_TONE_MAPPING gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); #elif defined( REINHARD_TONE_MAPPING ) gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); #elif defined( CINEON_TONE_MAPPING ) gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); #elif defined( ACES_FILMIC_TONE_MAPPING ) gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); #elif defined( AGX_TONE_MAPPING ) gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); #elif defined( NEUTRAL_TONE_MAPPING ) gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); #elif defined( CUSTOM_TONE_MAPPING ) gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); #endif #ifdef SRGB_TRANSFER gl_FragColor = sRGBTransferOETF( gl_FragColor ); #endif }`,depthTest:!1,depthWrite:!1}),g=new Gi(d,m),_=new ed(-1,1,1,-1,0,1);let S=null,x=null,M=!1,T,D=null,w=[],A=!1;this.setSize=function(R,L){u.setSize(R,L),f.setSize(R,L);for(let I=0;I0&&w[0].isRenderPass===!0;const L=u.width,I=u.height;for(let V=0;V0)return o;const a=e*t;let u=n1[a];if(u===void 0&&(u=new Float32Array(a),n1[a]=u),e!==0){i.toArray(u,0);for(let f=1,d=0;f!==e;++f)d+=t,o[f].toArray(u,d)}return u}function ji(o,e){if(o.length!==e.length)return!1;for(let t=0,i=o.length;t0&&(this.seq=a.concat(u))}setValue(e,t,i,a){const u=this.map[t];u!==void 0&&u.setValue(e,i,a)}setOptional(e,t,i){const a=t[i];a!==void 0&&this.setValue(e,i,a)}static upload(e,t,i,a){for(let u=0,f=t.length;u!==f;++u){const d=t[u],m=i[d.id];m.needsUpdate!==!1&&d.setValue(e,m.value,a)}}static seqWithValue(e,t){const i=[];for(let a=0,u=e.length;a!==u;++a){const f=e[a];f.id in t&&i.push(f)}return i}}function l1(o,e,t){const i=o.createShader(e);return o.shaderSource(i,t),o.compileShader(i),i}const bU=37297;let MU=0;function EU(o,e){const t=o.split(` `),i=[],a=Math.max(e-6,0),u=Math.min(e+6,t.length);for(let f=a;f":" "} ${d}: ${t[f]}`)}return i.join(` `)}const u1=new Jt;function TU(o){xn._getMatrix(u1,xn.workingColorSpace,o);const e=`mat3( ${u1.elements.map(t=>t.toFixed(4))} )`;switch(xn.getTransfer(o)){case om:return[e,"LinearTransferOETF"];case On:return[e,"sRGBTransferOETF"];default:return at("WebGLProgram: Unsupported color space: ",o),[e,"LinearTransferOETF"]}}function c1(o,e,t){const i=o.getShaderParameter(e,o.COMPILE_STATUS),u=(o.getShaderInfoLog(e)||"").trim();if(i&&u==="")return"";const f=/ERROR: 0:(\d+)/.exec(u);if(f){const d=parseInt(f[1]);return t.toUpperCase()+` `+u+` `+EU(o.getShaderSource(e),d)}else return u}function AU(o,e){const t=TU(e);return[`vec4 ${o}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}const wU={[iS]:"Linear",[sS]:"Reinhard",[aS]:"Cineon",[oy]:"ACESFilmic",[oS]:"AgX",[lS]:"Neutral",[rS]:"Custom"};function CU(o,e){const t=wU[e];return t===void 0?(at("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+o+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+o+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const iv=new Y;function RU(){xn.getLuminanceCoefficients(iv);const o=iv.x.toFixed(4),e=iv.y.toFixed(4),t=iv.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${o}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function DU(o){return[o.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",o.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Xp).join(` `)}function NU(o){const e=[];for(const t in o){const i=o[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function LU(o,e){const t={},i=o.getProgramParameter(e,o.ACTIVE_ATTRIBUTES);for(let a=0;a/gm;function Zx(o){return o.replace(UU,OU)}const IU=new Map;function OU(o,e){let t=sn[e];if(t===void 0){const i=IU.get(e);if(i!==void 0)t=sn[i],at('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Zx(t)}const PU=/#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 d1(o){return o.replace(PU,zU)}function zU(o,e,t,i){let a="";for(let u=parseInt(e);u0&&(w+=` `),A=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T].filter(Xp).join(` `),A.length>0&&(A+=` `)):(w=[p1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,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(Xp).join(` `),A=[p1(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,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 "+S:"",x?"#define CUBEUV_TEXEL_WIDTH "+x.texelWidth:"",x?"#define CUBEUV_TEXEL_HEIGHT "+x.texelHeight:"",x?"#define CUBEUV_MAX_MIP "+x.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?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#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?sn.tonemapping_pars_fragment:"",t.toneMapping!==gr?CU("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",sn.colorspace_pars_fragment,AU("linearToOutputTexel",t.outputColorSpace),RU(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Xp).join(` `)),f=Zx(f),f=f1(f,t),f=h1(f,t),d=Zx(d),d=f1(d,t),d=h1(d,t),f=d1(f),d=d1(d),t.isRawShaderMaterial!==!0&&(R=`#version 300 es `,w=[M,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+w,A=["#define varying in",t.glslVersion===Bx?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Bx?"":"#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(` `)+` `+A);const L=R+w+f,I=R+A+d,V=l1(a,a.VERTEX_SHADER,L),z=l1(a,a.FRAGMENT_SHADER,I);a.attachShader(D,V),a.attachShader(D,z),t.index0AttributeName!==void 0?a.bindAttribLocation(D,0,t.index0AttributeName):t.morphTargets===!0&&a.bindAttribLocation(D,0,"position"),a.linkProgram(D);function H(W){if(o.debug.checkShaderErrors){const te=a.getProgramInfoLog(D)||"",$=a.getShaderInfoLog(V)||"",ue=a.getShaderInfoLog(z)||"",se=te.trim(),q=$.trim(),j=ue.trim();let ye=!0,_e=!0;if(a.getProgramParameter(D,a.LINK_STATUS)===!1)if(ye=!1,typeof o.debug.onShaderError=="function")o.debug.onShaderError(a,D,V,z);else{const Ue=c1(a,V,"vertex"),X=c1(a,z,"fragment");Tt("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(D,a.VALIDATE_STATUS)+` Material Name: `+W.name+` Material Type: `+W.type+` Program Info Log: `+se+` `+Ue+` `+X)}else se!==""?at("WebGLProgram: Program Info Log:",se):(q===""||j==="")&&(_e=!1);_e&&(W.diagnostics={runnable:ye,programLog:se,vertexShader:{log:q,prefix:w},fragmentShader:{log:j,prefix:A}})}a.deleteShader(V),a.deleteShader(z),U=new lv(a,D),P=LU(a,D)}let U;this.getUniforms=function(){return U===void 0&&H(this),U};let P;this.getAttributes=function(){return P===void 0&&H(this),P};let Q=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return Q===!1&&(Q=a.getProgramParameter(D,bU)),Q},this.destroy=function(){i.releaseStatesOfProgram(this),a.deleteProgram(D),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=MU++,this.cacheKey=e,this.usedTimes=1,this.program=D,this.vertexShader=V,this.fragmentShader=z,this}let ZU=0;class jU{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,a=this._getShaderStage(t),u=this._getShaderStage(i),f=this._getShaderCacheForMaterial(e);return f.has(a)===!1&&(f.add(a),a.usedTimes++),f.has(u)===!1&&(f.add(u),u.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new QU(e),t.set(e,i)),i}}class QU{constructor(e){this.id=ZU++,this.code=e,this.usedTimes=0}}function JU(o,e,t,i,a,u){const f=new Gh,d=new jU,m=new Set,g=[],_=new Map,S=i.logarithmicDepthBuffer;let x=i.precision;const M={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 T(U){return m.add(U),U===0?"uv":`uv${U}`}function D(U,P,Q,W,te){const $=W.fog,ue=te.geometry,se=U.isMeshStandardMaterial||U.isMeshLambertMaterial||U.isMeshPhongMaterial?W.environment:null,q=U.isMeshStandardMaterial||U.isMeshLambertMaterial&&!U.envMap||U.isMeshPhongMaterial&&!U.envMap,j=e.get(U.envMap||se,q),ye=j&&j.mapping===jh?j.image.height:null,_e=M[U.type];U.precision!==null&&(x=i.getMaxPrecision(U.precision),x!==U.precision&&at("WebGLProgram.getParameters:",U.precision,"not supported, using",x,"instead."));const Ue=ue.morphAttributes.position||ue.morphAttributes.normal||ue.morphAttributes.color,X=Ue!==void 0?Ue.length:0;let ee=0;ue.morphAttributes.position!==void 0&&(ee=1),ue.morphAttributes.normal!==void 0&&(ee=2),ue.morphAttributes.color!==void 0&&(ee=3);let Ee,Oe,st,ce;if(_e){const gn=Zr[_e];Ee=gn.vertexShader,Oe=gn.fragmentShader}else Ee=U.vertexShader,Oe=U.fragmentShader,d.update(U),st=d.getVertexShaderID(U),ce=d.getFragmentShaderID(U);const Ce=o.getRenderTarget(),Be=o.state.buffers.depth.getReversed(),et=te.isInstancedMesh===!0,yt=te.isBatchedMesh===!0,wt=!!U.map,on=!!U.matcap,Dt=!!j,Re=!!U.aoMap,Ve=!!U.lightMap,Ne=!!U.bumpMap,Je=!!U.normalMap,Z=!!U.displacementMap,xt=!!U.emissiveMap,nt=!!U.metalnessMap,Mt=!!U.roughnessMap,We=U.anisotropy>0,G=U.clearcoat>0,O=U.dispersion>0,re=U.iridescence>0,be=U.sheen>0,Le=U.transmission>0,Te=We&&!!U.anisotropyMap,rt=G&&!!U.clearcoatMap,qe=G&&!!U.clearcoatNormalMap,St=G&&!!U.clearcoatRoughnessMap,At=re&&!!U.iridescenceMap,Fe=re&&!!U.iridescenceThicknessMap,ke=be&&!!U.sheenColorMap,ft=be&&!!U.sheenRoughnessMap,ot=!!U.specularMap,ct=!!U.specularColorMap,Zt=!!U.specularIntensityMap,ae=Le&&!!U.transmissionMap,je=Le&&!!U.thicknessMap,Xe=!!U.gradientMap,ut=!!U.alphaMap,He=U.alphaTest>0,Ae=!!U.alphaHash,dt=!!U.extensions;let zt=gr;U.toneMapped&&(Ce===null||Ce.isXRRenderTarget===!0)&&(zt=o.toneMapping);const dn={shaderID:_e,shaderType:U.type,shaderName:U.name,vertexShader:Ee,fragmentShader:Oe,defines:U.defines,customVertexShaderID:st,customFragmentShaderID:ce,isRawShaderMaterial:U.isRawShaderMaterial===!0,glslVersion:U.glslVersion,precision:x,batching:yt,batchingColor:yt&&te._colorsTexture!==null,instancing:et,instancingColor:et&&te.instanceColor!==null,instancingMorph:et&&te.morphTexture!==null,outputColorSpace:Ce===null?o.outputColorSpace:Ce.isXRRenderTarget===!0?Ce.texture.colorSpace:Uu,alphaToCoverage:!!U.alphaToCoverage,map:wt,matcap:on,envMap:Dt,envMapMode:Dt&&j.mapping,envMapCubeUVHeight:ye,aoMap:Re,lightMap:Ve,bumpMap:Ne,normalMap:Je,displacementMap:Z,emissiveMap:xt,normalMapObjectSpace:Je&&U.normalMapType===dE,normalMapTangentSpace:Je&&U.normalMapType===Pu,metalnessMap:nt,roughnessMap:Mt,anisotropy:We,anisotropyMap:Te,clearcoat:G,clearcoatMap:rt,clearcoatNormalMap:qe,clearcoatRoughnessMap:St,dispersion:O,iridescence:re,iridescenceMap:At,iridescenceThicknessMap:Fe,sheen:be,sheenColorMap:ke,sheenRoughnessMap:ft,specularMap:ot,specularColorMap:ct,specularIntensityMap:Zt,transmission:Le,transmissionMap:ae,thicknessMap:je,gradientMap:Xe,opaque:U.transparent===!1&&U.blending===qc&&U.alphaToCoverage===!1,alphaMap:ut,alphaTest:He,alphaHash:Ae,combine:U.combine,mapUv:wt&&T(U.map.channel),aoMapUv:Re&&T(U.aoMap.channel),lightMapUv:Ve&&T(U.lightMap.channel),bumpMapUv:Ne&&T(U.bumpMap.channel),normalMapUv:Je&&T(U.normalMap.channel),displacementMapUv:Z&&T(U.displacementMap.channel),emissiveMapUv:xt&&T(U.emissiveMap.channel),metalnessMapUv:nt&&T(U.metalnessMap.channel),roughnessMapUv:Mt&&T(U.roughnessMap.channel),anisotropyMapUv:Te&&T(U.anisotropyMap.channel),clearcoatMapUv:rt&&T(U.clearcoatMap.channel),clearcoatNormalMapUv:qe&&T(U.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:St&&T(U.clearcoatRoughnessMap.channel),iridescenceMapUv:At&&T(U.iridescenceMap.channel),iridescenceThicknessMapUv:Fe&&T(U.iridescenceThicknessMap.channel),sheenColorMapUv:ke&&T(U.sheenColorMap.channel),sheenRoughnessMapUv:ft&&T(U.sheenRoughnessMap.channel),specularMapUv:ot&&T(U.specularMap.channel),specularColorMapUv:ct&&T(U.specularColorMap.channel),specularIntensityMapUv:Zt&&T(U.specularIntensityMap.channel),transmissionMapUv:ae&&T(U.transmissionMap.channel),thicknessMapUv:je&&T(U.thicknessMap.channel),alphaMapUv:ut&&T(U.alphaMap.channel),vertexTangents:!!ue.attributes.tangent&&(Je||We),vertexColors:U.vertexColors,vertexAlphas:U.vertexColors===!0&&!!ue.attributes.color&&ue.attributes.color.itemSize===4,pointsUvs:te.isPoints===!0&&!!ue.attributes.uv&&(wt||ut),fog:!!$,useFog:U.fog===!0,fogExp2:!!$&&$.isFogExp2,flatShading:U.wireframe===!1&&(U.flatShading===!0||ue.attributes.normal===void 0&&Je===!1&&(U.isMeshLambertMaterial||U.isMeshPhongMaterial||U.isMeshStandardMaterial||U.isMeshPhysicalMaterial)),sizeAttenuation:U.sizeAttenuation===!0,logarithmicDepthBuffer:S,reversedDepthBuffer:Be,skinning:te.isSkinnedMesh===!0,morphTargets:ue.morphAttributes.position!==void 0,morphNormals:ue.morphAttributes.normal!==void 0,morphColors:ue.morphAttributes.color!==void 0,morphTargetsCount:X,morphTextureStride:ee,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:u.numPlanes,numClipIntersection:u.numIntersection,dithering:U.dithering,shadowMapEnabled:o.shadowMap.enabled&&Q.length>0,shadowMapType:o.shadowMap.type,toneMapping:zt,decodeVideoTexture:wt&&U.map.isVideoTexture===!0&&xn.getTransfer(U.map.colorSpace)===On,decodeVideoTextureEmissive:xt&&U.emissiveMap.isVideoTexture===!0&&xn.getTransfer(U.emissiveMap.colorSpace)===On,premultipliedAlpha:U.premultipliedAlpha,doubleSided:U.side===Uo,flipSided:U.side===$s,useDepthPacking:U.depthPacking>=0,depthPacking:U.depthPacking||0,index0AttributeName:U.index0AttributeName,extensionClipCullDistance:dt&&U.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(dt&&U.extensions.multiDraw===!0||yt)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:U.customProgramCacheKey()};return dn.vertexUv1s=m.has(1),dn.vertexUv2s=m.has(2),dn.vertexUv3s=m.has(3),m.clear(),dn}function w(U){const P=[];if(U.shaderID?P.push(U.shaderID):(P.push(U.customVertexShaderID),P.push(U.customFragmentShaderID)),U.defines!==void 0)for(const Q in U.defines)P.push(Q),P.push(U.defines[Q]);return U.isRawShaderMaterial===!1&&(A(P,U),R(P,U),P.push(o.outputColorSpace)),P.push(U.customProgramCacheKey),P.join()}function A(U,P){U.push(P.precision),U.push(P.outputColorSpace),U.push(P.envMapMode),U.push(P.envMapCubeUVHeight),U.push(P.mapUv),U.push(P.alphaMapUv),U.push(P.lightMapUv),U.push(P.aoMapUv),U.push(P.bumpMapUv),U.push(P.normalMapUv),U.push(P.displacementMapUv),U.push(P.emissiveMapUv),U.push(P.metalnessMapUv),U.push(P.roughnessMapUv),U.push(P.anisotropyMapUv),U.push(P.clearcoatMapUv),U.push(P.clearcoatNormalMapUv),U.push(P.clearcoatRoughnessMapUv),U.push(P.iridescenceMapUv),U.push(P.iridescenceThicknessMapUv),U.push(P.sheenColorMapUv),U.push(P.sheenRoughnessMapUv),U.push(P.specularMapUv),U.push(P.specularColorMapUv),U.push(P.specularIntensityMapUv),U.push(P.transmissionMapUv),U.push(P.thicknessMapUv),U.push(P.combine),U.push(P.fogExp2),U.push(P.sizeAttenuation),U.push(P.morphTargetsCount),U.push(P.morphAttributeCount),U.push(P.numDirLights),U.push(P.numPointLights),U.push(P.numSpotLights),U.push(P.numSpotLightMaps),U.push(P.numHemiLights),U.push(P.numRectAreaLights),U.push(P.numDirLightShadows),U.push(P.numPointLightShadows),U.push(P.numSpotLightShadows),U.push(P.numSpotLightShadowsWithMaps),U.push(P.numLightProbes),U.push(P.shadowMapType),U.push(P.toneMapping),U.push(P.numClippingPlanes),U.push(P.numClipIntersection),U.push(P.depthPacking)}function R(U,P){f.disableAll(),P.instancing&&f.enable(0),P.instancingColor&&f.enable(1),P.instancingMorph&&f.enable(2),P.matcap&&f.enable(3),P.envMap&&f.enable(4),P.normalMapObjectSpace&&f.enable(5),P.normalMapTangentSpace&&f.enable(6),P.clearcoat&&f.enable(7),P.iridescence&&f.enable(8),P.alphaTest&&f.enable(9),P.vertexColors&&f.enable(10),P.vertexAlphas&&f.enable(11),P.vertexUv1s&&f.enable(12),P.vertexUv2s&&f.enable(13),P.vertexUv3s&&f.enable(14),P.vertexTangents&&f.enable(15),P.anisotropy&&f.enable(16),P.alphaHash&&f.enable(17),P.batching&&f.enable(18),P.dispersion&&f.enable(19),P.batchingColor&&f.enable(20),P.gradientMap&&f.enable(21),U.push(f.mask),f.disableAll(),P.fog&&f.enable(0),P.useFog&&f.enable(1),P.flatShading&&f.enable(2),P.logarithmicDepthBuffer&&f.enable(3),P.reversedDepthBuffer&&f.enable(4),P.skinning&&f.enable(5),P.morphTargets&&f.enable(6),P.morphNormals&&f.enable(7),P.morphColors&&f.enable(8),P.premultipliedAlpha&&f.enable(9),P.shadowMapEnabled&&f.enable(10),P.doubleSided&&f.enable(11),P.flipSided&&f.enable(12),P.useDepthPacking&&f.enable(13),P.dithering&&f.enable(14),P.transmission&&f.enable(15),P.sheen&&f.enable(16),P.opaque&&f.enable(17),P.pointsUvs&&f.enable(18),P.decodeVideoTexture&&f.enable(19),P.decodeVideoTextureEmissive&&f.enable(20),P.alphaToCoverage&&f.enable(21),U.push(f.mask)}function L(U){const P=M[U.type];let Q;if(P){const W=Zr[P];Q=ZE.clone(W.uniforms)}else Q=U.uniforms;return Q}function I(U,P){let Q=_.get(P);return Q!==void 0?++Q.usedTimes:(Q=new YU(o,P,U,a),g.push(Q),_.set(P,Q)),Q}function V(U){if(--U.usedTimes===0){const P=g.indexOf(U);g[P]=g[g.length-1],g.pop(),_.delete(U.cacheKey),U.destroy()}}function z(U){d.remove(U)}function H(){d.dispose()}return{getParameters:D,getProgramCacheKey:w,getUniforms:L,acquireProgram:I,releaseProgram:V,releaseShaderCache:z,programs:g,dispose:H}}function KU(){let o=new WeakMap;function e(f){return o.has(f)}function t(f){let d=o.get(f);return d===void 0&&(d={},o.set(f,d)),d}function i(f){o.delete(f)}function a(f,d,m){o.get(f)[d]=m}function u(){o=new WeakMap}return{has:e,get:t,remove:i,update:a,dispose:u}}function $U(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.material.id!==e.material.id?o.material.id-e.material.id:o.materialVariant!==e.materialVariant?o.materialVariant-e.materialVariant:o.z!==e.z?o.z-e.z:o.id-e.id}function m1(o,e){return o.groupOrder!==e.groupOrder?o.groupOrder-e.groupOrder:o.renderOrder!==e.renderOrder?o.renderOrder-e.renderOrder:o.z!==e.z?e.z-o.z:o.id-e.id}function g1(){const o=[];let e=0;const t=[],i=[],a=[];function u(){e=0,t.length=0,i.length=0,a.length=0}function f(x){let M=0;return x.isInstancedMesh&&(M+=2),x.isSkinnedMesh&&(M+=1),M}function d(x,M,T,D,w,A){let R=o[e];return R===void 0?(R={id:x.id,object:x,geometry:M,material:T,materialVariant:f(x),groupOrder:D,renderOrder:x.renderOrder,z:w,group:A},o[e]=R):(R.id=x.id,R.object=x,R.geometry=M,R.material=T,R.materialVariant=f(x),R.groupOrder=D,R.renderOrder=x.renderOrder,R.z=w,R.group=A),e++,R}function m(x,M,T,D,w,A){const R=d(x,M,T,D,w,A);T.transmission>0?i.push(R):T.transparent===!0?a.push(R):t.push(R)}function g(x,M,T,D,w,A){const R=d(x,M,T,D,w,A);T.transmission>0?i.unshift(R):T.transparent===!0?a.unshift(R):t.unshift(R)}function _(x,M){t.length>1&&t.sort(x||$U),i.length>1&&i.sort(M||m1),a.length>1&&a.sort(M||m1)}function S(){for(let x=e,M=o.length;x=u.length?(f=new g1,u.push(f)):f=u[a],f}function t(){o=new WeakMap}return{get:e,dispose:t}}function tI(){const o={};return{get:function(e){if(o[e.id]!==void 0)return o[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new Y,color:new pt};break;case"SpotLight":t={position:new Y,direction:new Y,color:new pt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Y,color:new pt,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Y,skyColor:new pt,groundColor:new pt};break;case"RectAreaLight":t={color:new pt,position:new Y,halfWidth:new Y,halfHeight:new Y};break}return o[e.id]=t,t}}}function nI(){const o={};return{get:function(e){if(o[e.id]!==void 0)return o[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new 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 o[e.id]=t,t}}}let iI=0;function sI(o,e){return(e.castShadow?2:0)-(o.castShadow?2:0)+(e.map?1:0)-(o.map?1:0)}function aI(o){const e=new tI,t=nI(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let g=0;g<9;g++)i.probe.push(new Y);const a=new Y,u=new kt,f=new kt;function d(g){let _=0,S=0,x=0;for(let P=0;P<9;P++)i.probe[P].set(0,0,0);let M=0,T=0,D=0,w=0,A=0,R=0,L=0,I=0,V=0,z=0,H=0;g.sort(sI);for(let P=0,Q=g.length;P0&&(o.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=lt.LTC_FLOAT_1,i.rectAreaLTC2=lt.LTC_FLOAT_2):(i.rectAreaLTC1=lt.LTC_HALF_1,i.rectAreaLTC2=lt.LTC_HALF_2)),i.ambient[0]=_,i.ambient[1]=S,i.ambient[2]=x;const U=i.hash;(U.directionalLength!==M||U.pointLength!==T||U.spotLength!==D||U.rectAreaLength!==w||U.hemiLength!==A||U.numDirectionalShadows!==R||U.numPointShadows!==L||U.numSpotShadows!==I||U.numSpotMaps!==V||U.numLightProbes!==H)&&(i.directional.length=M,i.spot.length=D,i.rectArea.length=w,i.point.length=T,i.hemi.length=A,i.directionalShadow.length=R,i.directionalShadowMap.length=R,i.pointShadow.length=L,i.pointShadowMap.length=L,i.spotShadow.length=I,i.spotShadowMap.length=I,i.directionalShadowMatrix.length=R,i.pointShadowMatrix.length=L,i.spotLightMatrix.length=I+V-z,i.spotLightMap.length=V,i.numSpotLightShadowsWithMaps=z,i.numLightProbes=H,U.directionalLength=M,U.pointLength=T,U.spotLength=D,U.rectAreaLength=w,U.hemiLength=A,U.numDirectionalShadows=R,U.numPointShadows=L,U.numSpotShadows=I,U.numSpotMaps=V,U.numLightProbes=H,i.version=iI++)}function m(g,_){let S=0,x=0,M=0,T=0,D=0;const w=_.matrixWorldInverse;for(let A=0,R=g.length;A=f.length?(d=new v1(o),f.push(d)):d=f[u],d}function i(){e=new WeakMap}return{get:t,dispose:i}}const oI=`void main() { gl_Position = vec4( position, 1.0 ); }`,lI=`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 ); }`,uI=[new Y(1,0,0),new Y(-1,0,0),new Y(0,1,0),new Y(0,-1,0),new Y(0,0,1),new Y(0,0,-1)],cI=[new Y(0,-1,0),new Y(0,-1,0),new Y(0,0,1),new Y(0,0,-1),new Y(0,-1,0),new Y(0,-1,0)],y1=new kt,kp=new Y,_x=new Y;function fI(o,e,t){let i=new Jh;const a=new ze,u=new ze,f=new Wn,d=new IS,m=new OS,g={},_=t.maxTextureSize,S={[wl]:$s,[$s]:wl,[Uo]:Uo},x=new yr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ze},radius:{value:4}},vertexShader:oI,fragmentShader:lI}),M=x.clone();M.defines.HORIZONTAL_PASS=1;const T=new Yt;T.setAttribute("position",new Gn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const D=new Gi(T,x),w=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Bh;let A=this.type;this.render=function(z,H,U){if(w.enabled===!1||w.autoUpdate===!1&&w.needsUpdate===!1||z.length===0)return;this.type===Wp&&(at("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Bh);const P=o.getRenderTarget(),Q=o.getActiveCubeFace(),W=o.getActiveMipmapLevel(),te=o.state;te.setBlending(Po),te.buffers.depth.getReversed()===!0?te.buffers.color.setClear(0,0,0,0):te.buffers.color.setClear(1,1,1,1),te.buffers.depth.setTest(!0),te.setScissorTest(!1);const $=A!==this.type;$&&H.traverse(function(ue){ue.material&&(Array.isArray(ue.material)?ue.material.forEach(se=>se.needsUpdate=!0):ue.material.needsUpdate=!0)});for(let ue=0,se=z.length;ue_||a.y>_)&&(a.x>_&&(u.x=Math.floor(_/ye.x),a.x=u.x*ye.x,j.mapSize.x=u.x),a.y>_&&(u.y=Math.floor(_/ye.y),a.y=u.y*ye.y,j.mapSize.y=u.y));const _e=o.state.buffers.depth.getReversed();if(j.camera._reversedDepth=_e,j.map===null||$===!0){if(j.map!==null&&(j.map.depthTexture!==null&&(j.map.depthTexture.dispose(),j.map.depthTexture=null),j.map.dispose()),this.type===Hc){if(q.isPointLight){at("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}j.map=new Ha(a.x,a.y,{format:Qc,type:Bo,minFilter:si,magFilter:si,generateMipmaps:!1}),j.map.texture.name=q.name+".shadowMap",j.map.depthTexture=new Wh(a.x,a.y,Ks),j.map.depthTexture.name=q.name+".shadowMapDepth",j.map.depthTexture.format=Fo,j.map.depthTexture.compareFunction=null,j.map.depthTexture.minFilter=Ui,j.map.depthTexture.magFilter=Ui}else q.isPointLight?(j.map=new YS(a.x),j.map.depthTexture=new IE(a.x,vr)):(j.map=new Ha(a.x,a.y),j.map.depthTexture=new Wh(a.x,a.y,vr)),j.map.depthTexture.name=q.name+".shadowMap",j.map.depthTexture.format=Fo,this.type===Bh?(j.map.depthTexture.compareFunction=_e?vy:gy,j.map.depthTexture.minFilter=si,j.map.depthTexture.magFilter=si):(j.map.depthTexture.compareFunction=null,j.map.depthTexture.minFilter=Ui,j.map.depthTexture.magFilter=Ui);j.camera.updateProjectionMatrix()}const Ue=j.map.isWebGLCubeRenderTarget?6:1;for(let X=0;X0||H.map&&H.alphaTest>0||H.alphaToCoverage===!0){const te=Q.uuid,$=H.uuid;let ue=g[te];ue===void 0&&(ue={},g[te]=ue);let se=ue[$];se===void 0&&(se=Q.clone(),ue[$]=se,H.addEventListener("dispose",V)),Q=se}if(Q.visible=H.visible,Q.wireframe=H.wireframe,P===Hc?Q.side=H.shadowSide!==null?H.shadowSide:H.side:Q.side=H.shadowSide!==null?H.shadowSide:S[H.side],Q.alphaMap=H.alphaMap,Q.alphaTest=H.alphaToCoverage===!0?.5:H.alphaTest,Q.map=H.map,Q.clipShadows=H.clipShadows,Q.clippingPlanes=H.clippingPlanes,Q.clipIntersection=H.clipIntersection,Q.displacementMap=H.displacementMap,Q.displacementScale=H.displacementScale,Q.displacementBias=H.displacementBias,Q.wireframeLinewidth=H.wireframeLinewidth,Q.linewidth=H.linewidth,U.isPointLight===!0&&Q.isMeshDistanceMaterial===!0){const te=o.properties.get(Q);te.light=U}return Q}function I(z,H,U,P,Q){if(z.visible===!1)return;if(z.layers.test(H.layers)&&(z.isMesh||z.isLine||z.isPoints)&&(z.castShadow||z.receiveShadow&&Q===Hc)&&(!z.frustumCulled||i.intersectsObject(z))){z.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,z.matrixWorld);const $=e.update(z),ue=z.material;if(Array.isArray(ue)){const se=$.groups;for(let q=0,j=se.length;q=1):ye.indexOf("OpenGL ES")!==-1&&(j=parseFloat(/^OpenGL ES (\d)/.exec(ye)[1]),q=j>=2);let _e=null,Ue={};const X=o.getParameter(o.SCISSOR_BOX),ee=o.getParameter(o.VIEWPORT),Ee=new Wn().fromArray(X),Oe=new Wn().fromArray(ee);function st(ae,je,Xe,ut){const He=new Uint8Array(4),Ae=o.createTexture();o.bindTexture(ae,Ae),o.texParameteri(ae,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(ae,o.TEXTURE_MAG_FILTER,o.NEAREST);for(let dt=0;dt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new ze,_=new WeakMap;let S;const x=new WeakMap;let M=!1;try{M=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function T(G,O){return M?new OffscreenCanvas(G,O):um("canvas")}function D(G,O,re){let be=1;const Le=We(G);if((Le.width>re||Le.height>re)&&(be=re/Math.max(Le.width,Le.height)),be<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 Te=Math.floor(be*Le.width),rt=Math.floor(be*Le.height);S===void 0&&(S=T(Te,rt));const qe=O?T(Te,rt):S;return qe.width=Te,qe.height=rt,qe.getContext("2d").drawImage(G,0,0,Te,rt),at("WebGLRenderer: Texture has been resized from ("+Le.width+"x"+Le.height+") to ("+Te+"x"+rt+")."),qe}else return"data"in G&&at("WebGLRenderer: Image in DataTexture is too big ("+Le.width+"x"+Le.height+")."),G;return G}function w(G){return G.generateMipmaps}function A(G){o.generateMipmap(G)}function R(G){return G.isWebGLCubeRenderTarget?o.TEXTURE_CUBE_MAP:G.isWebGL3DRenderTarget?o.TEXTURE_3D:G.isWebGLArrayRenderTarget||G.isCompressedArrayTexture?o.TEXTURE_2D_ARRAY:o.TEXTURE_2D}function L(G,O,re,be,Le=!1){if(G!==null){if(o[G]!==void 0)return o[G];at("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+G+"'")}let Te=O;if(O===o.RED&&(re===o.FLOAT&&(Te=o.R32F),re===o.HALF_FLOAT&&(Te=o.R16F),re===o.UNSIGNED_BYTE&&(Te=o.R8)),O===o.RED_INTEGER&&(re===o.UNSIGNED_BYTE&&(Te=o.R8UI),re===o.UNSIGNED_SHORT&&(Te=o.R16UI),re===o.UNSIGNED_INT&&(Te=o.R32UI),re===o.BYTE&&(Te=o.R8I),re===o.SHORT&&(Te=o.R16I),re===o.INT&&(Te=o.R32I)),O===o.RG&&(re===o.FLOAT&&(Te=o.RG32F),re===o.HALF_FLOAT&&(Te=o.RG16F),re===o.UNSIGNED_BYTE&&(Te=o.RG8)),O===o.RG_INTEGER&&(re===o.UNSIGNED_BYTE&&(Te=o.RG8UI),re===o.UNSIGNED_SHORT&&(Te=o.RG16UI),re===o.UNSIGNED_INT&&(Te=o.RG32UI),re===o.BYTE&&(Te=o.RG8I),re===o.SHORT&&(Te=o.RG16I),re===o.INT&&(Te=o.RG32I)),O===o.RGB_INTEGER&&(re===o.UNSIGNED_BYTE&&(Te=o.RGB8UI),re===o.UNSIGNED_SHORT&&(Te=o.RGB16UI),re===o.UNSIGNED_INT&&(Te=o.RGB32UI),re===o.BYTE&&(Te=o.RGB8I),re===o.SHORT&&(Te=o.RGB16I),re===o.INT&&(Te=o.RGB32I)),O===o.RGBA_INTEGER&&(re===o.UNSIGNED_BYTE&&(Te=o.RGBA8UI),re===o.UNSIGNED_SHORT&&(Te=o.RGBA16UI),re===o.UNSIGNED_INT&&(Te=o.RGBA32UI),re===o.BYTE&&(Te=o.RGBA8I),re===o.SHORT&&(Te=o.RGBA16I),re===o.INT&&(Te=o.RGBA32I)),O===o.RGB&&(re===o.UNSIGNED_INT_5_9_9_9_REV&&(Te=o.RGB9_E5),re===o.UNSIGNED_INT_10F_11F_11F_REV&&(Te=o.R11F_G11F_B10F)),O===o.RGBA){const rt=Le?om:xn.getTransfer(be);re===o.FLOAT&&(Te=o.RGBA32F),re===o.HALF_FLOAT&&(Te=o.RGBA16F),re===o.UNSIGNED_BYTE&&(Te=rt===On?o.SRGB8_ALPHA8:o.RGBA8),re===o.UNSIGNED_SHORT_4_4_4_4&&(Te=o.RGBA4),re===o.UNSIGNED_SHORT_5_5_5_1&&(Te=o.RGB5_A1)}return(Te===o.R16F||Te===o.R32F||Te===o.RG16F||Te===o.RG32F||Te===o.RGBA16F||Te===o.RGBA32F)&&e.get("EXT_color_buffer_float"),Te}function I(G,O){let re;return G?O===null||O===vr||O===kh?re=o.DEPTH24_STENCIL8:O===Ks?re=o.DEPTH32F_STENCIL8:O===Vh&&(re=o.DEPTH24_STENCIL8,at("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===vr||O===kh?re=o.DEPTH_COMPONENT24:O===Ks?re=o.DEPTH_COMPONENT32F:O===Vh&&(re=o.DEPTH_COMPONENT16),re}function V(G,O){return w(G)===!0||G.isFramebufferTexture&&G.minFilter!==Ui&&G.minFilter!==si?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),U(O),O.isVideoTexture&&_.delete(O)}function H(G){const O=G.target;O.removeEventListener("dispose",H),Q(O)}function U(G){const O=i.get(G);if(O.__webglInit===void 0)return;const re=G.source,be=x.get(re);if(be){const Le=be[O.__cacheKey];Le.usedTimes--,Le.usedTimes===0&&P(G),Object.keys(be).length===0&&x.delete(re)}i.remove(G)}function P(G){const O=i.get(G);o.deleteTexture(O.__webglTexture);const re=G.source,be=x.get(re);delete be[O.__cacheKey],f.memory.textures--}function Q(G){const O=i.get(G);if(G.depthTexture&&(G.depthTexture.dispose(),i.remove(G.depthTexture)),G.isWebGLCubeRenderTarget)for(let be=0;be<6;be++){if(Array.isArray(O.__webglFramebuffer[be]))for(let Le=0;Le=a.maxTextures&&at("WebGLTextures: Trying to use "+G+" texture units while this GPU supports only "+a.maxTextures),W+=1,G}function ue(G){const O=[];return O.push(G.wrapS),O.push(G.wrapT),O.push(G.wrapR||0),O.push(G.magFilter),O.push(G.minFilter),O.push(G.anisotropy),O.push(G.internalFormat),O.push(G.format),O.push(G.type),O.push(G.generateMipmaps),O.push(G.premultiplyAlpha),O.push(G.flipY),O.push(G.unpackAlignment),O.push(G.colorSpace),O.join()}function se(G,O){const re=i.get(G);if(G.isVideoTexture&&nt(G),G.isRenderTargetTexture===!1&&G.isExternalTexture!==!0&&G.version>0&&re.__version!==G.version){const be=G.image;if(be===null)at("WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)at("WebGLRenderer: Texture marked for update but image is incomplete");else{ce(re,G,O);return}}else G.isExternalTexture&&(re.__webglTexture=G.sourceTexture?G.sourceTexture:null);t.bindTexture(o.TEXTURE_2D,re.__webglTexture,o.TEXTURE0+O)}function q(G,O){const re=i.get(G);if(G.isRenderTargetTexture===!1&&G.version>0&&re.__version!==G.version){ce(re,G,O);return}else G.isExternalTexture&&(re.__webglTexture=G.sourceTexture?G.sourceTexture:null);t.bindTexture(o.TEXTURE_2D_ARRAY,re.__webglTexture,o.TEXTURE0+O)}function j(G,O){const re=i.get(G);if(G.isRenderTargetTexture===!1&&G.version>0&&re.__version!==G.version){ce(re,G,O);return}t.bindTexture(o.TEXTURE_3D,re.__webglTexture,o.TEXTURE0+O)}function ye(G,O){const re=i.get(G);if(G.isCubeDepthTexture!==!0&&G.version>0&&re.__version!==G.version){Ce(re,G,O);return}t.bindTexture(o.TEXTURE_CUBE_MAP,re.__webglTexture,o.TEXTURE0+O)}const _e={[im]:o.REPEAT,[Ca]:o.CLAMP_TO_EDGE,[sm]:o.MIRRORED_REPEAT},Ue={[Ui]:o.NEAREST,[uS]:o.NEAREST_MIPMAP_NEAREST,[Oh]:o.NEAREST_MIPMAP_LINEAR,[si]:o.LINEAR,[Zp]:o.LINEAR_MIPMAP_NEAREST,[Io]:o.LINEAR_MIPMAP_LINEAR},X={[pE]:o.NEVER,[_E]:o.ALWAYS,[mE]:o.LESS,[gy]:o.LEQUAL,[gE]:o.EQUAL,[vy]:o.GEQUAL,[vE]:o.GREATER,[yE]:o.NOTEQUAL};function ee(G,O){if(O.type===Ks&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===si||O.magFilter===Zp||O.magFilter===Oh||O.magFilter===Io||O.minFilter===si||O.minFilter===Zp||O.minFilter===Oh||O.minFilter===Io)&&at("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),o.texParameteri(G,o.TEXTURE_WRAP_S,_e[O.wrapS]),o.texParameteri(G,o.TEXTURE_WRAP_T,_e[O.wrapT]),(G===o.TEXTURE_3D||G===o.TEXTURE_2D_ARRAY)&&o.texParameteri(G,o.TEXTURE_WRAP_R,_e[O.wrapR]),o.texParameteri(G,o.TEXTURE_MAG_FILTER,Ue[O.magFilter]),o.texParameteri(G,o.TEXTURE_MIN_FILTER,Ue[O.minFilter]),O.compareFunction&&(o.texParameteri(G,o.TEXTURE_COMPARE_MODE,o.COMPARE_REF_TO_TEXTURE),o.texParameteri(G,o.TEXTURE_COMPARE_FUNC,X[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===Ui||O.minFilter!==Oh&&O.minFilter!==Io||O.type===Ks&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||i.get(O).__currentAnisotropy){const re=e.get("EXT_texture_filter_anisotropic");o.texParameterf(G,re.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,a.getMaxAnisotropy())),i.get(O).__currentAnisotropy=O.anisotropy}}}function Ee(G,O){let re=!1;G.__webglInit===void 0&&(G.__webglInit=!0,O.addEventListener("dispose",z));const be=O.source;let Le=x.get(be);Le===void 0&&(Le={},x.set(be,Le));const Te=ue(O);if(Te!==G.__cacheKey){Le[Te]===void 0&&(Le[Te]={texture:o.createTexture(),usedTimes:0},f.memory.textures++,re=!0),Le[Te].usedTimes++;const rt=Le[G.__cacheKey];rt!==void 0&&(Le[G.__cacheKey].usedTimes--,rt.usedTimes===0&&P(O)),G.__cacheKey=Te,G.__webglTexture=Le[Te].texture}return re}function Oe(G,O,re){return Math.floor(Math.floor(G/re)/O)}function st(G,O,re,be){const Te=G.updateRanges;if(Te.length===0)t.texSubImage2D(o.TEXTURE_2D,0,0,0,O.width,O.height,re,be,O.data);else{Te.sort((Fe,ke)=>Fe.start-ke.start);let rt=0;for(let Fe=1;Fe0){ae&&je&&t.texStorage2D(o.TEXTURE_2D,ut,ot,Zt[0].width,Zt[0].height);for(let He=0,Ae=Zt.length;He0){const dt=Wx(ct.width,ct.height,O.format,O.type);for(const zt of O.layerUpdates){const dn=ct.data.subarray(zt*dt/ct.data.BYTES_PER_ELEMENT,(zt+1)*dt/ct.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(o.TEXTURE_2D_ARRAY,He,0,0,zt,ct.width,ct.height,1,ke,dn)}O.clearLayerUpdates()}else t.compressedTexSubImage3D(o.TEXTURE_2D_ARRAY,He,0,0,0,ct.width,ct.height,Fe.depth,ke,ct.data)}else t.compressedTexImage3D(o.TEXTURE_2D_ARRAY,He,ot,ct.width,ct.height,Fe.depth,0,ct.data,0,0);else at("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ae?Xe&&t.texSubImage3D(o.TEXTURE_2D_ARRAY,He,0,0,0,ct.width,ct.height,Fe.depth,ke,ft,ct.data):t.texImage3D(o.TEXTURE_2D_ARRAY,He,ot,ct.width,ct.height,Fe.depth,0,ke,ft,ct.data)}else{ae&&je&&t.texStorage2D(o.TEXTURE_2D,ut,ot,Zt[0].width,Zt[0].height);for(let He=0,Ae=Zt.length;He0){const He=Wx(Fe.width,Fe.height,O.format,O.type);for(const Ae of O.layerUpdates){const dt=Fe.data.subarray(Ae*He/Fe.data.BYTES_PER_ELEMENT,(Ae+1)*He/Fe.data.BYTES_PER_ELEMENT);t.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,Ae,Fe.width,Fe.height,1,ke,ft,dt)}O.clearLayerUpdates()}else t.texSubImage3D(o.TEXTURE_2D_ARRAY,0,0,0,0,Fe.width,Fe.height,Fe.depth,ke,ft,Fe.data)}else t.texImage3D(o.TEXTURE_2D_ARRAY,0,ot,Fe.width,Fe.height,Fe.depth,0,ke,ft,Fe.data);else if(O.isData3DTexture)ae?(je&&t.texStorage3D(o.TEXTURE_3D,ut,ot,Fe.width,Fe.height,Fe.depth),Xe&&t.texSubImage3D(o.TEXTURE_3D,0,0,0,0,Fe.width,Fe.height,Fe.depth,ke,ft,Fe.data)):t.texImage3D(o.TEXTURE_3D,0,ot,Fe.width,Fe.height,Fe.depth,0,ke,ft,Fe.data);else if(O.isFramebufferTexture){if(je)if(ae)t.texStorage2D(o.TEXTURE_2D,ut,ot,Fe.width,Fe.height);else{let He=Fe.width,Ae=Fe.height;for(let dt=0;dt>=1,Ae>>=1}}else if(Zt.length>0){if(ae&&je){const He=We(Zt[0]);t.texStorage2D(o.TEXTURE_2D,ut,ot,He.width,He.height)}for(let He=0,Ae=Zt.length;He0&&ut++;const Ae=We(ke[0]);t.texStorage2D(o.TEXTURE_CUBE_MAP,ut,Zt,Ae.width,Ae.height)}for(let Ae=0;Ae<6;Ae++)if(Fe){ae?Xe&&t.texSubImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,ke[Ae].width,ke[Ae].height,ot,ct,ke[Ae].data):t.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,Zt,ke[Ae].width,ke[Ae].height,0,ot,ct,ke[Ae].data);for(let dt=0;dt>Te),ft=Math.max(1,O.height>>Te);Le===o.TEXTURE_3D||Le===o.TEXTURE_2D_ARRAY?t.texImage3D(Le,Te,St,ke,ft,O.depth,0,rt,qe,null):t.texImage2D(Le,Te,St,ke,ft,0,rt,qe,null)}t.bindFramebuffer(o.FRAMEBUFFER,G),xt(O)?d.framebufferTexture2DMultisampleEXT(o.FRAMEBUFFER,be,Le,Fe.__webglTexture,0,Z(O)):(Le===o.TEXTURE_2D||Le>=o.TEXTURE_CUBE_MAP_POSITIVE_X&&Le<=o.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&o.framebufferTexture2D(o.FRAMEBUFFER,be,Le,Fe.__webglTexture,Te),t.bindFramebuffer(o.FRAMEBUFFER,null)}function et(G,O,re){if(o.bindRenderbuffer(o.RENDERBUFFER,G),O.depthBuffer){const be=O.depthTexture,Le=be&&be.isDepthTexture?be.type:null,Te=I(O.stencilBuffer,Le),rt=O.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT;xt(O)?d.renderbufferStorageMultisampleEXT(o.RENDERBUFFER,Z(O),Te,O.width,O.height):re?o.renderbufferStorageMultisample(o.RENDERBUFFER,Z(O),Te,O.width,O.height):o.renderbufferStorage(o.RENDERBUFFER,Te,O.width,O.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,rt,o.RENDERBUFFER,G)}else{const be=O.textures;for(let Le=0;Le{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,be.removeEventListener("dispose",Le)};be.addEventListener("dispose",Le),O.__depthDisposeCallback=Le}O.__boundDepthTexture=be}if(G.depthTexture&&!O.__autoAllocateDepthBuffer)if(re)for(let be=0;be<6;be++)yt(O.__webglFramebuffer[be],G,be);else{const be=G.texture.mipmaps;be&&be.length>0?yt(O.__webglFramebuffer[0],G,0):yt(O.__webglFramebuffer,G,0)}else if(re){O.__webglDepthbuffer=[];for(let be=0;be<6;be++)if(t.bindFramebuffer(o.FRAMEBUFFER,O.__webglFramebuffer[be]),O.__webglDepthbuffer[be]===void 0)O.__webglDepthbuffer[be]=o.createRenderbuffer(),et(O.__webglDepthbuffer[be],G,!1);else{const Le=G.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT,Te=O.__webglDepthbuffer[be];o.bindRenderbuffer(o.RENDERBUFFER,Te),o.framebufferRenderbuffer(o.FRAMEBUFFER,Le,o.RENDERBUFFER,Te)}}else{const be=G.texture.mipmaps;if(be&&be.length>0?t.bindFramebuffer(o.FRAMEBUFFER,O.__webglFramebuffer[0]):t.bindFramebuffer(o.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=o.createRenderbuffer(),et(O.__webglDepthbuffer,G,!1);else{const Le=G.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT,Te=O.__webglDepthbuffer;o.bindRenderbuffer(o.RENDERBUFFER,Te),o.framebufferRenderbuffer(o.FRAMEBUFFER,Le,o.RENDERBUFFER,Te)}}t.bindFramebuffer(o.FRAMEBUFFER,null)}function on(G,O,re){const be=i.get(G);O!==void 0&&Be(be.__webglFramebuffer,G,G.texture,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,0),re!==void 0&&wt(G)}function Dt(G){const O=G.texture,re=i.get(G),be=i.get(O);G.addEventListener("dispose",H);const Le=G.textures,Te=G.isWebGLCubeRenderTarget===!0,rt=Le.length>1;if(rt||(be.__webglTexture===void 0&&(be.__webglTexture=o.createTexture()),be.__version=O.version,f.memory.textures++),Te){re.__webglFramebuffer=[];for(let qe=0;qe<6;qe++)if(O.mipmaps&&O.mipmaps.length>0){re.__webglFramebuffer[qe]=[];for(let St=0;St0){re.__webglFramebuffer=[];for(let qe=0;qe0&&xt(G)===!1){re.__webglMultisampledFramebuffer=o.createFramebuffer(),re.__webglColorRenderbuffer=[],t.bindFramebuffer(o.FRAMEBUFFER,re.__webglMultisampledFramebuffer);for(let qe=0;qe0)for(let St=0;St0)for(let St=0;St0){if(xt(G)===!1){const O=G.textures,re=G.width,be=G.height;let Le=o.COLOR_BUFFER_BIT;const Te=G.stencilBuffer?o.DEPTH_STENCIL_ATTACHMENT:o.DEPTH_ATTACHMENT,rt=i.get(G),qe=O.length>1;if(qe)for(let At=0;At0?t.bindFramebuffer(o.DRAW_FRAMEBUFFER,rt.__webglFramebuffer[0]):t.bindFramebuffer(o.DRAW_FRAMEBUFFER,rt.__webglFramebuffer);for(let At=0;At0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function nt(G){const O=f.render.frame;_.get(G)!==O&&(_.set(G,O),G.update())}function Mt(G,O){const re=G.colorSpace,be=G.format,Le=G.type;return G.isCompressedTexture===!0||G.isVideoTexture===!0||re!==Uu&&re!==El&&(xn.getTransfer(re)===On?(be!==Os||Le!==Qs)&&at("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Tt("WebGLTextures: Unsupported texture color space:",re)),O}function We(G){return typeof HTMLImageElement<"u"&&G instanceof HTMLImageElement?(g.width=G.naturalWidth||G.width,g.height=G.naturalHeight||G.height):typeof VideoFrame<"u"&&G instanceof VideoFrame?(g.width=G.displayWidth,g.height=G.displayHeight):(g.width=G.width,g.height=G.height),g}this.allocateTextureUnit=$,this.resetTextureUnits=te,this.setTexture2D=se,this.setTexture2DArray=q,this.setTexture3D=j,this.setTextureCube=ye,this.rebindTextures=on,this.setupRenderTarget=Dt,this.updateRenderTargetMipmap=Re,this.updateMultisampleRenderTarget=Je,this.setupDepthRenderbuffer=wt,this.setupFrameBufferTexture=Be,this.useMultisampledRTT=xt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function NT(o,e){function t(i,a=El){let u;const f=xn.getTransfer(a);if(i===Qs)return o.UNSIGNED_BYTE;if(i===cy)return o.UNSIGNED_SHORT_4_4_4_4;if(i===fy)return o.UNSIGNED_SHORT_5_5_5_1;if(i===hS)return o.UNSIGNED_INT_5_9_9_9_REV;if(i===dS)return o.UNSIGNED_INT_10F_11F_11F_REV;if(i===cS)return o.BYTE;if(i===fS)return o.SHORT;if(i===Vh)return o.UNSIGNED_SHORT;if(i===uy)return o.INT;if(i===vr)return o.UNSIGNED_INT;if(i===Ks)return o.FLOAT;if(i===Bo)return o.HALF_FLOAT;if(i===pS)return o.ALPHA;if(i===mS)return o.RGB;if(i===Os)return o.RGBA;if(i===Fo)return o.DEPTH_COMPONENT;if(i===Ru)return o.DEPTH_STENCIL;if(i===hy)return o.RED;if(i===bm)return o.RED_INTEGER;if(i===Qc)return o.RG;if(i===dy)return o.RG_INTEGER;if(i===py)return o.RGBA_INTEGER;if(i===jp||i===Qp||i===Jp||i===Kp)if(f===On)if(u=e.get("WEBGL_compressed_texture_s3tc_srgb"),u!==null){if(i===jp)return u.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Qp)return u.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Jp)return u.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Kp)return u.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(u=e.get("WEBGL_compressed_texture_s3tc"),u!==null){if(i===jp)return u.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Qp)return u.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Jp)return u.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Kp)return u.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===_v||i===xv||i===Sv||i===bv)if(u=e.get("WEBGL_compressed_texture_pvrtc"),u!==null){if(i===_v)return u.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===xv)return u.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Sv)return u.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===bv)return u.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Mv||i===Ev||i===Tv||i===Av||i===wv||i===Cv||i===Rv)if(u=e.get("WEBGL_compressed_texture_etc"),u!==null){if(i===Mv||i===Ev)return f===On?u.COMPRESSED_SRGB8_ETC2:u.COMPRESSED_RGB8_ETC2;if(i===Tv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:u.COMPRESSED_RGBA8_ETC2_EAC;if(i===Av)return u.COMPRESSED_R11_EAC;if(i===wv)return u.COMPRESSED_SIGNED_R11_EAC;if(i===Cv)return u.COMPRESSED_RG11_EAC;if(i===Rv)return u.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Dv||i===Nv||i===Lv||i===Uv||i===Iv||i===Ov||i===Pv||i===zv||i===Bv||i===Fv||i===Vv||i===kv||i===Hv||i===Gv)if(u=e.get("WEBGL_compressed_texture_astc"),u!==null){if(i===Dv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:u.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Nv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:u.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Lv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:u.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Uv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:u.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Iv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:u.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Ov)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:u.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Pv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:u.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===zv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:u.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Bv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:u.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Fv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:u.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Vv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:u.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===kv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:u.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Hv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:u.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Gv)return f===On?u.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:u.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Xv||i===Wv||i===qv)if(u=e.get("EXT_texture_compression_bptc"),u!==null){if(i===Xv)return f===On?u.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:u.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Wv)return u.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===qv)return u.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Yv||i===Zv||i===jv||i===Qv)if(u=e.get("EXT_texture_compression_rgtc"),u!==null){if(i===Yv)return u.COMPRESSED_RED_RGTC1_EXT;if(i===Zv)return u.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===jv)return u.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Qv)return u.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===kh?o.UNSIGNED_INT_24_8:o[i]!==void 0?o[i]:null}return{convert:t}}const pI=` void main() { gl_Position = vec4( position, 1.0 ); }`,mI=` 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 gI{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new TS(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new yr({vertexShader:pI,fragmentShader:mI,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Gi(new Kh(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class vI extends Vo{constructor(e,t){super();const i=this;let a=null,u=1,f=null,d="local-floor",m=1,g=null,_=null,S=null,x=null,M=null,T=null;const D=typeof XRWebGLBinding<"u",w=new gI,A={},R=t.getContextAttributes();let L=null,I=null;const V=[],z=[],H=new ze;let U=null;const P=new as;P.viewport=new Wn;const Q=new as;Q.viewport=new Wn;const W=[P,Q],te=new yT;let $=null,ue=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ce){let Ce=V[ce];return Ce===void 0&&(Ce=new ov,V[ce]=Ce),Ce.getTargetRaySpace()},this.getControllerGrip=function(ce){let Ce=V[ce];return Ce===void 0&&(Ce=new ov,V[ce]=Ce),Ce.getGripSpace()},this.getHand=function(ce){let Ce=V[ce];return Ce===void 0&&(Ce=new ov,V[ce]=Ce),Ce.getHandSpace()};function se(ce){const Ce=z.indexOf(ce.inputSource);if(Ce===-1)return;const Be=V[Ce];Be!==void 0&&(Be.update(ce.inputSource,ce.frame,g||f),Be.dispatchEvent({type:ce.type,data:ce.inputSource}))}function q(){a.removeEventListener("select",se),a.removeEventListener("selectstart",se),a.removeEventListener("selectend",se),a.removeEventListener("squeeze",se),a.removeEventListener("squeezestart",se),a.removeEventListener("squeezeend",se),a.removeEventListener("end",q),a.removeEventListener("inputsourceschange",j);for(let ce=0;ce=0&&(z[et]=null,V[et].disconnect(Be))}for(let Ce=0;Ce=z.length){z.push(Be),et=wt;break}else if(z[wt]===null){z[wt]=Be,et=wt;break}if(et===-1)break}const yt=V[et];yt&&yt.connect(Be)}}const ye=new Y,_e=new Y;function Ue(ce,Ce,Be){ye.setFromMatrixPosition(Ce.matrixWorld),_e.setFromMatrixPosition(Be.matrixWorld);const et=ye.distanceTo(_e),yt=Ce.projectionMatrix.elements,wt=Be.projectionMatrix.elements,on=yt[14]/(yt[10]-1),Dt=yt[14]/(yt[10]+1),Re=(yt[9]+1)/yt[5],Ve=(yt[9]-1)/yt[5],Ne=(yt[8]-1)/yt[0],Je=(wt[8]+1)/wt[0],Z=on*Ne,xt=on*Je,nt=et/(-Ne+Je),Mt=nt*-Ne;if(Ce.matrixWorld.decompose(ce.position,ce.quaternion,ce.scale),ce.translateX(Mt),ce.translateZ(nt),ce.matrixWorld.compose(ce.position,ce.quaternion,ce.scale),ce.matrixWorldInverse.copy(ce.matrixWorld).invert(),yt[10]===-1)ce.projectionMatrix.copy(Ce.projectionMatrix),ce.projectionMatrixInverse.copy(Ce.projectionMatrixInverse);else{const We=on+nt,G=Dt+nt,O=Z-Mt,re=xt+(et-Mt),be=Re*Dt/G*We,Le=Ve*Dt/G*We;ce.projectionMatrix.makePerspective(O,re,be,Le,We,G),ce.projectionMatrixInverse.copy(ce.projectionMatrix).invert()}}function X(ce,Ce){Ce===null?ce.matrixWorld.copy(ce.matrix):ce.matrixWorld.multiplyMatrices(Ce.matrixWorld,ce.matrix),ce.matrixWorldInverse.copy(ce.matrixWorld).invert()}this.updateCamera=function(ce){if(a===null)return;let Ce=ce.near,Be=ce.far;w.texture!==null&&(w.depthNear>0&&(Ce=w.depthNear),w.depthFar>0&&(Be=w.depthFar)),te.near=Q.near=P.near=Ce,te.far=Q.far=P.far=Be,($!==te.near||ue!==te.far)&&(a.updateRenderState({depthNear:te.near,depthFar:te.far}),$=te.near,ue=te.far),te.layers.mask=ce.layers.mask|6,P.layers.mask=te.layers.mask&-5,Q.layers.mask=te.layers.mask&-3;const et=ce.parent,yt=te.cameras;X(te,et);for(let wt=0;wt0&&(w.alphaTest.value=A.alphaTest);const R=e.get(A),L=R.envMap,I=R.envMapRotation;L&&(w.envMap.value=L,Fc.copy(I),Fc.x*=-1,Fc.y*=-1,Fc.z*=-1,L.isCubeTexture&&L.isRenderTargetTexture===!1&&(Fc.y*=-1,Fc.z*=-1),w.envMapRotation.value.setFromMatrix4(yI.makeRotationFromEuler(Fc)),w.flipEnvMap.value=L.isCubeTexture&&L.isRenderTargetTexture===!1?-1:1,w.reflectivity.value=A.reflectivity,w.ior.value=A.ior,w.refractionRatio.value=A.refractionRatio),A.lightMap&&(w.lightMap.value=A.lightMap,w.lightMapIntensity.value=A.lightMapIntensity,t(A.lightMap,w.lightMapTransform)),A.aoMap&&(w.aoMap.value=A.aoMap,w.aoMapIntensity.value=A.aoMapIntensity,t(A.aoMap,w.aoMapTransform))}function f(w,A){w.diffuse.value.copy(A.color),w.opacity.value=A.opacity,A.map&&(w.map.value=A.map,t(A.map,w.mapTransform))}function d(w,A){w.dashSize.value=A.dashSize,w.totalSize.value=A.dashSize+A.gapSize,w.scale.value=A.scale}function m(w,A,R,L){w.diffuse.value.copy(A.color),w.opacity.value=A.opacity,w.size.value=A.size*R,w.scale.value=L*.5,A.map&&(w.map.value=A.map,t(A.map,w.uvTransform)),A.alphaMap&&(w.alphaMap.value=A.alphaMap,t(A.alphaMap,w.alphaMapTransform)),A.alphaTest>0&&(w.alphaTest.value=A.alphaTest)}function g(w,A){w.diffuse.value.copy(A.color),w.opacity.value=A.opacity,w.rotation.value=A.rotation,A.map&&(w.map.value=A.map,t(A.map,w.mapTransform)),A.alphaMap&&(w.alphaMap.value=A.alphaMap,t(A.alphaMap,w.alphaMapTransform)),A.alphaTest>0&&(w.alphaTest.value=A.alphaTest)}function _(w,A){w.specular.value.copy(A.specular),w.shininess.value=Math.max(A.shininess,1e-4)}function S(w,A){A.gradientMap&&(w.gradientMap.value=A.gradientMap)}function x(w,A){w.metalness.value=A.metalness,A.metalnessMap&&(w.metalnessMap.value=A.metalnessMap,t(A.metalnessMap,w.metalnessMapTransform)),w.roughness.value=A.roughness,A.roughnessMap&&(w.roughnessMap.value=A.roughnessMap,t(A.roughnessMap,w.roughnessMapTransform)),A.envMap&&(w.envMapIntensity.value=A.envMapIntensity)}function M(w,A,R){w.ior.value=A.ior,A.sheen>0&&(w.sheenColor.value.copy(A.sheenColor).multiplyScalar(A.sheen),w.sheenRoughness.value=A.sheenRoughness,A.sheenColorMap&&(w.sheenColorMap.value=A.sheenColorMap,t(A.sheenColorMap,w.sheenColorMapTransform)),A.sheenRoughnessMap&&(w.sheenRoughnessMap.value=A.sheenRoughnessMap,t(A.sheenRoughnessMap,w.sheenRoughnessMapTransform))),A.clearcoat>0&&(w.clearcoat.value=A.clearcoat,w.clearcoatRoughness.value=A.clearcoatRoughness,A.clearcoatMap&&(w.clearcoatMap.value=A.clearcoatMap,t(A.clearcoatMap,w.clearcoatMapTransform)),A.clearcoatRoughnessMap&&(w.clearcoatRoughnessMap.value=A.clearcoatRoughnessMap,t(A.clearcoatRoughnessMap,w.clearcoatRoughnessMapTransform)),A.clearcoatNormalMap&&(w.clearcoatNormalMap.value=A.clearcoatNormalMap,t(A.clearcoatNormalMap,w.clearcoatNormalMapTransform),w.clearcoatNormalScale.value.copy(A.clearcoatNormalScale),A.side===$s&&w.clearcoatNormalScale.value.negate())),A.dispersion>0&&(w.dispersion.value=A.dispersion),A.iridescence>0&&(w.iridescence.value=A.iridescence,w.iridescenceIOR.value=A.iridescenceIOR,w.iridescenceThicknessMinimum.value=A.iridescenceThicknessRange[0],w.iridescenceThicknessMaximum.value=A.iridescenceThicknessRange[1],A.iridescenceMap&&(w.iridescenceMap.value=A.iridescenceMap,t(A.iridescenceMap,w.iridescenceMapTransform)),A.iridescenceThicknessMap&&(w.iridescenceThicknessMap.value=A.iridescenceThicknessMap,t(A.iridescenceThicknessMap,w.iridescenceThicknessMapTransform))),A.transmission>0&&(w.transmission.value=A.transmission,w.transmissionSamplerMap.value=R.texture,w.transmissionSamplerSize.value.set(R.width,R.height),A.transmissionMap&&(w.transmissionMap.value=A.transmissionMap,t(A.transmissionMap,w.transmissionMapTransform)),w.thickness.value=A.thickness,A.thicknessMap&&(w.thicknessMap.value=A.thicknessMap,t(A.thicknessMap,w.thicknessMapTransform)),w.attenuationDistance.value=A.attenuationDistance,w.attenuationColor.value.copy(A.attenuationColor)),A.anisotropy>0&&(w.anisotropyVector.value.set(A.anisotropy*Math.cos(A.anisotropyRotation),A.anisotropy*Math.sin(A.anisotropyRotation)),A.anisotropyMap&&(w.anisotropyMap.value=A.anisotropyMap,t(A.anisotropyMap,w.anisotropyMapTransform))),w.specularIntensity.value=A.specularIntensity,w.specularColor.value.copy(A.specularColor),A.specularColorMap&&(w.specularColorMap.value=A.specularColorMap,t(A.specularColorMap,w.specularColorMapTransform)),A.specularIntensityMap&&(w.specularIntensityMap.value=A.specularIntensityMap,t(A.specularIntensityMap,w.specularIntensityMapTransform))}function T(w,A){A.matcap&&(w.matcap.value=A.matcap)}function D(w,A){const R=e.get(A).light;w.referencePosition.value.setFromMatrixPosition(R.matrixWorld),w.nearDistance.value=R.shadow.camera.near,w.farDistance.value=R.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:a}}function xI(o,e,t,i){let a={},u={},f=[];const d=o.getParameter(o.MAX_UNIFORM_BUFFER_BINDINGS);function m(R,L){const I=L.program;i.uniformBlockBinding(R,I)}function g(R,L){let I=a[R.id];I===void 0&&(T(R),I=_(R),a[R.id]=I,R.addEventListener("dispose",w));const V=L.program;i.updateUBOMapping(R,V);const z=e.render.frame;u[R.id]!==z&&(x(R),u[R.id]=z)}function _(R){const L=S();R.__bindingPointIndex=L;const I=o.createBuffer(),V=R.__size,z=R.usage;return o.bindBuffer(o.UNIFORM_BUFFER,I),o.bufferData(o.UNIFORM_BUFFER,V,z),o.bindBuffer(o.UNIFORM_BUFFER,null),o.bindBufferBase(o.UNIFORM_BUFFER,L,I),I}function S(){for(let R=0;R0&&(I+=V-z),R.__size=I,R.__cache={},this}function D(R){const L={boundary:0,storage:0};return typeof R=="number"||typeof R=="boolean"?(L.boundary=4,L.storage=4):R.isVector2?(L.boundary=8,L.storage=8):R.isVector3||R.isColor?(L.boundary=16,L.storage=12):R.isVector4?(L.boundary=16,L.storage=16):R.isMatrix3?(L.boundary=48,L.storage=48):R.isMatrix4?(L.boundary=64,L.storage=64):R.isTexture?at("WebGLRenderer: Texture samplers can not be part of an uniforms group."):at("WebGLRenderer: Unsupported uniform value type.",R),L}function w(R){const L=R.target;L.removeEventListener("dispose",w);const I=f.indexOf(L.__bindingPointIndex);f.splice(I,1),o.deleteBuffer(a[L.id]),delete a[L.id],delete u[L.id]}function A(){for(const R in a)o.deleteBuffer(a[R]);f=[],a={},u={}}return{bind:m,update:g,dispose:A}}const SI=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 bI(){return Lo===null&&(Lo=new Qr(SI,16,16,Qc,Bo),Lo.name="DFG_LUT",Lo.minFilter=si,Lo.magFilter=si,Lo.wrapS=Ca,Lo.wrapT=Ca,Lo.generateMipmaps=!1,Lo.needsUpdate=!0),Lo}class LT{constructor(e={}){const{canvas:t=SE(),context:i=null,depth:a=!0,stencil:u=!1,alpha:f=!1,antialias:d=!1,premultipliedAlpha:m=!0,preserveDrawingBuffer:g=!1,powerPreference:_="default",failIfMajorPerformanceCaveat:S=!1,reversedDepthBuffer:x=!1,outputBufferType:M=Qs}=e;this.isWebGLRenderer=!0;let T;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");T=i.getContextAttributes().alpha}else T=f;const D=M,w=new Set([py,dy,bm]),A=new Set([Qs,vr,Vh,kh,cy,fy]),R=new Uint32Array(4),L=new Int32Array(4);let I=null,V=null;const z=[],H=[];let U=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 P=this;let Q=!1;this._outputColorSpace=Is;let W=0,te=0,$=null,ue=-1,se=null;const q=new Wn,j=new Wn;let ye=null;const _e=new pt(0);let Ue=0,X=t.width,ee=t.height,Ee=1,Oe=null,st=null;const ce=new Wn(0,0,X,ee),Ce=new Wn(0,0,X,ee);let Be=!1;const et=new Jh;let yt=!1,wt=!1;const on=new kt,Dt=new Y,Re=new Wn,Ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ne=!1;function Je(){return $===null?Ee:1}let Z=i;function xt(k,ie){return t.getContext(k,ie)}try{const k={alpha:!0,depth:a,stencil:u,antialias:d,premultipliedAlpha:m,preserveDrawingBuffer:g,powerPreference:_,failIfMajorPerformanceCaveat:S};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ry}`),t.addEventListener("webglcontextlost",dt,!1),t.addEventListener("webglcontextrestored",zt,!1),t.addEventListener("webglcontextcreationerror",dn,!1),Z===null){const ie="webgl2";if(Z=xt(ie,k),Z===null)throw xt(ie)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(k){throw Tt("WebGLRenderer: "+k.message),k}let nt,Mt,We,G,O,re,be,Le,Te,rt,qe,St,At,Fe,ke,ft,ot,ct,Zt,ae,je,Xe,ut;function He(){nt=new EL(Z),nt.init(),je=new NT(Z,nt),Mt=new gL(Z,nt,e,je),We=new hI(Z,nt),Mt.reversedDepthBuffer&&x&&We.buffers.depth.setReversed(!0),G=new wL(Z),O=new KU,re=new dI(Z,nt,We,O,Mt,je,G),be=new ML(P),Le=new LR(Z),Xe=new pL(Z,Le),Te=new TL(Z,Le,G,Xe),rt=new RL(Z,Te,Le,Xe,G),ct=new CL(Z,Mt,re),ke=new vL(O),qe=new JU(P,be,nt,Mt,Xe,ke),St=new _I(P,O),At=new eI,Fe=new rI(nt),ot=new dL(P,be,We,rt,T,m),ft=new fI(P,rt,Mt),ut=new xI(Z,G,Mt,We),Zt=new mL(Z,nt,G),ae=new AL(Z,nt,G),G.programs=qe.programs,P.capabilities=Mt,P.extensions=nt,P.properties=O,P.renderLists=At,P.shadowMap=ft,P.state=We,P.info=G}He(),D!==Qs&&(U=new NL(D,t.width,t.height,a,u));const Ae=new vI(P,Z);this.xr=Ae,this.getContext=function(){return Z},this.getContextAttributes=function(){return Z.getContextAttributes()},this.forceContextLoss=function(){const k=nt.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){const k=nt.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return Ee},this.setPixelRatio=function(k){k!==void 0&&(Ee=k,this.setSize(X,ee,!1))},this.getSize=function(k){return k.set(X,ee)},this.setSize=function(k,ie,ge=!0){if(Ae.isPresenting){at("WebGLRenderer: Can't change size while VR device is presenting.");return}X=k,ee=ie,t.width=Math.floor(k*Ee),t.height=Math.floor(ie*Ee),ge===!0&&(t.style.width=k+"px",t.style.height=ie+"px"),U!==null&&U.setSize(t.width,t.height),this.setViewport(0,0,k,ie)},this.getDrawingBufferSize=function(k){return k.set(X*Ee,ee*Ee).floor()},this.setDrawingBufferSize=function(k,ie,ge){X=k,ee=ie,Ee=ge,t.width=Math.floor(k*ge),t.height=Math.floor(ie*ge),this.setViewport(0,0,k,ie)},this.setEffects=function(k){if(D===Qs){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(k){for(let ie=0;ie{function Ze(){if(de.forEach(function(tt){O.get(tt).currentProgram.isReady()&&de.delete(tt)}),de.size===0){fe(k);return}setTimeout(Ze,10)}nt.get("KHR_parallel_shader_compile")!==null?Ze():setTimeout(Ze,10)})};let Sr=null;function Vu(k){Sr&&Sr(k)}function br(){na.stop()}function Mr(){na.start()}const na=new AT;na.setAnimationLoop(Vu),typeof self<"u"&&na.setContext(self),this.setAnimationLoop=function(k){Sr=k,Ae.setAnimationLoop(k),k===null?na.stop():na.start()},Ae.addEventListener("sessionstart",br),Ae.addEventListener("sessionend",Mr),this.render=function(k,ie){if(ie!==void 0&&ie.isCamera!==!0){Tt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(Q===!0)return;const ge=Ae.enabled===!0&&Ae.isPresenting===!0,de=U!==null&&($===null||ge)&&U.begin(P,$);if(k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),ie.parent===null&&ie.matrixWorldAutoUpdate===!0&&ie.updateMatrixWorld(),Ae.enabled===!0&&Ae.isPresenting===!0&&(U===null||U.isCompositing()===!1)&&(Ae.cameraAutoUpdate===!0&&Ae.updateCamera(ie),ie=Ae.getCamera()),k.isScene===!0&&k.onBeforeRender(P,k,ie,$),V=Fe.get(k,H.length),V.init(ie),H.push(V),on.multiplyMatrices(ie.projectionMatrix,ie.matrixWorldInverse),et.setFromProjectionMatrix(on,Va,ie.reversedDepth),wt=this.localClippingEnabled,yt=ke.init(this.clippingPlanes,wt),I=At.get(k,z.length),I.init(),z.push(I),Ae.enabled===!0&&Ae.isPresenting===!0){const tt=P.xr.getDepthSensingMesh();tt!==null&&ia(tt,ie,-1/0,P.sortObjects)}ia(k,ie,0,P.sortObjects),I.finish(),P.sortObjects===!0&&I.sort(Oe,st),Ne=Ae.enabled===!1||Ae.isPresenting===!1||Ae.hasDepthSensing()===!1,Ne&&ot.addToRenderList(I,k),this.info.render.frame++,yt===!0&&ke.beginShadows();const fe=V.state.shadowsArray;if(ft.render(fe,k,ie),yt===!0&&ke.endShadows(),this.info.autoReset===!0&&this.info.reset(),(de&&U.hasRenderPass())===!1){const tt=I.opaque,it=I.transmissive;if(V.setupLights(),ie.isArrayCamera){const Ke=ie.cameras;if(it.length>0)for(let _t=0,Ut=Ke.length;_t0&&Qn(tt,it,k,ie),Ne&&ot.render(k),sa(I,k,ie)}$!==null&&te===0&&(re.updateMultisampleRenderTarget($),re.updateRenderTargetMipmap($)),de&&U.end(P),k.isScene===!0&&k.onAfterRender(P,k,ie),Xe.resetDefaultState(),ue=-1,se=null,H.pop(),H.length>0?(V=H[H.length-1],yt===!0&&ke.setGlobalState(P.clippingPlanes,V.state.camera)):V=null,z.pop(),z.length>0?I=z[z.length-1]:I=null};function ia(k,ie,ge,de){if(k.visible===!1)return;if(k.layers.test(ie.layers)){if(k.isGroup)ge=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(ie);else if(k.isLight)V.pushLight(k),k.castShadow&&V.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||et.intersectsSprite(k)){de&&Re.setFromMatrixPosition(k.matrixWorld).applyMatrix4(on);const tt=rt.update(k),it=k.material;it.visible&&I.push(k,tt,it,ge,Re.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(!k.frustumCulled||et.intersectsObject(k))){const tt=rt.update(k),it=k.material;if(de&&(k.boundingSphere!==void 0?(k.boundingSphere===null&&k.computeBoundingSphere(),Re.copy(k.boundingSphere.center)):(tt.boundingSphere===null&&tt.computeBoundingSphere(),Re.copy(tt.boundingSphere.center)),Re.applyMatrix4(k.matrixWorld).applyMatrix4(on)),Array.isArray(it)){const Ke=tt.groups;for(let _t=0,Ut=Ke.length;_t0&&ci(fe,ie,ge),Ze.length>0&&ci(Ze,ie,ge),tt.length>0&&ci(tt,ie,ge),We.buffers.depth.setTest(!0),We.buffers.depth.setMask(!0),We.buffers.color.setMask(!0),We.setPolygonOffset(!1)}function Qn(k,ie,ge,de){if((ge.isScene===!0?ge.overrideMaterial:null)!==null)return;if(V.state.transmissionRenderTarget[de.id]===void 0){const mt=nt.has("EXT_color_buffer_half_float")||nt.has("EXT_color_buffer_float");V.state.transmissionRenderTarget[de.id]=new Ha(1,1,{generateMipmaps:!0,type:mt?Bo:Qs,minFilter:Io,samples:Mt.samples,stencilBuffer:u,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:xn.workingColorSpace})}const Ze=V.state.transmissionRenderTarget[de.id],tt=de.viewport||q;Ze.setSize(tt.z*P.transmissionResolutionScale,tt.w*P.transmissionResolutionScale);const it=P.getRenderTarget(),Ke=P.getActiveCubeFace(),_t=P.getActiveMipmapLevel();P.setRenderTarget(Ze),P.getClearColor(_e),Ue=P.getClearAlpha(),Ue<1&&P.setClearColor(16777215,.5),P.clear(),Ne&&ot.render(ge);const Ut=P.toneMapping;P.toneMapping=gr;const Ht=de.viewport;if(de.viewport!==void 0&&(de.viewport=void 0),V.setupLightsView(de),yt===!0&&ke.setGlobalState(P.clippingPlanes,de),ci(k,ge,de),re.updateMultisampleRenderTarget(Ze),re.updateRenderTargetMipmap(Ze),nt.has("WEBGL_multisampled_render_to_texture")===!1){let mt=!1;for(let jt=0,Pn=ie.length;jt0),mt=!!ge.morphAttributes.position,jt=!!ge.morphAttributes.normal,Pn=!!ge.morphAttributes.color;let zn=gr;de.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(zn=P.toneMapping);const vn=ge.morphAttributes.position||ge.morphAttributes.normal||ge.morphAttributes.color,Sn=vn!==void 0?vn.length:0,$e=O.get(de),Ii=V.state.lights;if(yt===!0&&(wt===!0||k!==se)){const fi=k===se&&de.id===ue;ke.setState(de,k,fi)}let It=!1;de.version===$e.__version?($e.needsLights&&$e.lightsStateVersion!==Ii.state.version||$e.outputColorSpace!==it||fe.isBatchedMesh&&$e.batching===!1||!fe.isBatchedMesh&&$e.batching===!0||fe.isBatchedMesh&&$e.batchingColor===!0&&fe.colorTexture===null||fe.isBatchedMesh&&$e.batchingColor===!1&&fe.colorTexture!==null||fe.isInstancedMesh&&$e.instancing===!1||!fe.isInstancedMesh&&$e.instancing===!0||fe.isSkinnedMesh&&$e.skinning===!1||!fe.isSkinnedMesh&&$e.skinning===!0||fe.isInstancedMesh&&$e.instancingColor===!0&&fe.instanceColor===null||fe.isInstancedMesh&&$e.instancingColor===!1&&fe.instanceColor!==null||fe.isInstancedMesh&&$e.instancingMorph===!0&&fe.morphTexture===null||fe.isInstancedMesh&&$e.instancingMorph===!1&&fe.morphTexture!==null||$e.envMap!==_t||de.fog===!0&&$e.fog!==Ze||$e.numClippingPlanes!==void 0&&($e.numClippingPlanes!==ke.numPlanes||$e.numIntersection!==ke.numIntersection)||$e.vertexAlphas!==Ut||$e.vertexTangents!==Ht||$e.morphTargets!==mt||$e.morphNormals!==jt||$e.morphColors!==Pn||$e.toneMapping!==zn||$e.morphTargetsCount!==Sn)&&(It=!0):(It=!0,$e.__version=de.version);let Oi=$e.currentProgram;It===!0&&(Oi=rs(de,ie,fe));let os=!1,Ai=!1,Ki=!1;const En=Oi.getUniforms(),ai=$e.uniforms;if(We.useProgram(Oi.program)&&(os=!0,Ai=!0,Ki=!0),de.id!==ue&&(ue=de.id,Ai=!0),os||se!==k){We.buffers.depth.getReversed()&&k.reversedDepth!==!0&&(k._reversedDepth=!0,k.updateProjectionMatrix()),En.setValue(Z,"projectionMatrix",k.projectionMatrix),En.setValue(Z,"viewMatrix",k.matrixWorldInverse);const aa=En.map.cameraPosition;aa!==void 0&&aa.setValue(Z,Dt.setFromMatrixPosition(k.matrixWorld)),Mt.logarithmicDepthBuffer&&En.setValue(Z,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),(de.isMeshPhongMaterial||de.isMeshToonMaterial||de.isMeshLambertMaterial||de.isMeshBasicMaterial||de.isMeshStandardMaterial||de.isShaderMaterial)&&En.setValue(Z,"isOrthographic",k.isOrthographicCamera===!0),se!==k&&(se=k,Ai=!0,Ki=!0)}if($e.needsLights&&(Ii.state.directionalShadowMap.length>0&&En.setValue(Z,"directionalShadowMap",Ii.state.directionalShadowMap,re),Ii.state.spotShadowMap.length>0&&En.setValue(Z,"spotShadowMap",Ii.state.spotShadowMap,re),Ii.state.pointShadowMap.length>0&&En.setValue(Z,"pointShadowMap",Ii.state.pointShadowMap,re)),fe.isSkinnedMesh){En.setOptional(Z,fe,"bindMatrix"),En.setOptional(Z,fe,"bindMatrixInverse");const fi=fe.skeleton;fi&&(fi.boneTexture===null&&fi.computeBoneTexture(),En.setValue(Z,"boneTexture",fi.boneTexture,re))}fe.isBatchedMesh&&(En.setOptional(Z,fe,"batchingTexture"),En.setValue(Z,"batchingTexture",fe._matricesTexture,re),En.setOptional(Z,fe,"batchingIdTexture"),En.setValue(Z,"batchingIdTexture",fe._indirectTexture,re),En.setOptional(Z,fe,"batchingColorTexture"),fe._colorsTexture!==null&&En.setValue(Z,"batchingColorTexture",fe._colorsTexture,re));const $i=ge.morphAttributes;if(($i.position!==void 0||$i.normal!==void 0||$i.color!==void 0)&&ct.update(fe,ge,Oi),(Ai||$e.receiveShadow!==fe.receiveShadow)&&($e.receiveShadow=fe.receiveShadow,En.setValue(Z,"receiveShadow",fe.receiveShadow)),(de.isMeshStandardMaterial||de.isMeshLambertMaterial||de.isMeshPhongMaterial)&&de.envMap===null&&ie.environment!==null&&(ai.envMapIntensity.value=ie.environmentIntensity),ai.dfgLUT!==void 0&&(ai.dfgLUT.value=bI()),Ai&&(En.setValue(Z,"toneMappingExposure",P.toneMappingExposure),$e.needsLights&&La(ai,Ki),Ze&&de.fog===!0&&St.refreshFogUniforms(ai,Ze),St.refreshMaterialUniforms(ai,de,Ee,ee,V.state.transmissionRenderTarget[k.id]),lv.upload(Z,Na($e),ai,re)),de.isShaderMaterial&&de.uniformsNeedUpdate===!0&&(lv.upload(Z,Na($e),ai,re),de.uniformsNeedUpdate=!1),de.isSpriteMaterial&&En.setValue(Z,"center",fe.center),En.setValue(Z,"modelViewMatrix",fe.modelViewMatrix),En.setValue(Z,"normalMatrix",fe.normalMatrix),En.setValue(Z,"modelMatrix",fe.matrixWorld),de.isShaderMaterial||de.isRawShaderMaterial){const fi=de.uniformsGroups;for(let aa=0,Xa=fi.length;aa0&&re.useMultisampledRTT(k)===!1?de=O.get(k).__webglMultisampledFramebuffer:Array.isArray(_t)?de=_t[ge]:de=_t,q.copy(k.viewport),j.copy(k.scissor),ye=k.scissorTest}else q.copy(ce).multiplyScalar(Ee).floor(),j.copy(Ce).multiplyScalar(Ee).floor(),ye=Be;if(ge!==0&&(de=Tr),We.bindFramebuffer(Z.FRAMEBUFFER,de)&&We.drawBuffers(k,de),We.viewport(q),We.scissor(j),We.setScissorTest(ye),fe){const it=O.get(k.texture);Z.framebufferTexture2D(Z.FRAMEBUFFER,Z.COLOR_ATTACHMENT0,Z.TEXTURE_CUBE_MAP_POSITIVE_X+ie,it.__webglTexture,ge)}else if(Ze){const it=ie;for(let Ke=0;Ke1&&Z.readBuffer(Z.COLOR_ATTACHMENT0+it),!Mt.textureFormatReadable(Ut)){Tt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Mt.textureTypeReadable(Ht)){Tt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ie>=0&&ie<=k.width-de&&ge>=0&&ge<=k.height-fe&&Z.readPixels(ie,ge,de,fe,je.convert(Ut),je.convert(Ht),Ze)}finally{const _t=$!==null?O.get($).__webglFramebuffer:null;We.bindFramebuffer(Z.FRAMEBUFFER,_t)}}},this.readRenderTargetPixelsAsync=async function(k,ie,ge,de,fe,Ze,tt,it=0){if(!(k&&k.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ke=O.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&tt!==void 0&&(Ke=Ke[tt]),Ke)if(ie>=0&&ie<=k.width-de&&ge>=0&&ge<=k.height-fe){We.bindFramebuffer(Z.FRAMEBUFFER,Ke);const _t=k.textures[it],Ut=_t.format,Ht=_t.type;if(k.textures.length>1&&Z.readBuffer(Z.COLOR_ATTACHMENT0+it),!Mt.textureFormatReadable(Ut))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Mt.textureTypeReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const mt=Z.createBuffer();Z.bindBuffer(Z.PIXEL_PACK_BUFFER,mt),Z.bufferData(Z.PIXEL_PACK_BUFFER,Ze.byteLength,Z.STREAM_READ),Z.readPixels(ie,ge,de,fe,je.convert(Ut),je.convert(Ht),0);const jt=$!==null?O.get($).__webglFramebuffer:null;We.bindFramebuffer(Z.FRAMEBUFFER,jt);const Pn=Z.fenceSync(Z.SYNC_GPU_COMMANDS_COMPLETE,0);return Z.flush(),await Lw(Z,Pn,4),Z.bindBuffer(Z.PIXEL_PACK_BUFFER,mt),Z.getBufferSubData(Z.PIXEL_PACK_BUFFER,0,Ze),Z.deleteBuffer(mt),Z.deleteSync(Pn),Ze}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(k,ie=null,ge=0){const de=Math.pow(2,-ge),fe=Math.floor(k.image.width*de),Ze=Math.floor(k.image.height*de),tt=ie!==null?ie.x:0,it=ie!==null?ie.y:0;re.setTexture2D(k,0),Z.copyTexSubImage2D(Z.TEXTURE_2D,ge,0,0,tt,it,fe,Ze),We.unbindTexture()};const Ar=Z.createFramebuffer(),$r=Z.createFramebuffer();this.copyTextureToTexture=function(k,ie,ge=null,de=null,fe=0,Ze=0){let tt,it,Ke,_t,Ut,Ht,mt,jt,Pn;const zn=k.isCompressedTexture?k.mipmaps[Ze]:k.image;if(ge!==null)tt=ge.max.x-ge.min.x,it=ge.max.y-ge.min.y,Ke=ge.isBox3?ge.max.z-ge.min.z:1,_t=ge.min.x,Ut=ge.min.y,Ht=ge.isBox3?ge.min.z:0;else{const ai=Math.pow(2,-fe);tt=Math.floor(zn.width*ai),it=Math.floor(zn.height*ai),k.isDataArrayTexture?Ke=zn.depth:k.isData3DTexture?Ke=Math.floor(zn.depth*ai):Ke=1,_t=0,Ut=0,Ht=0}de!==null?(mt=de.x,jt=de.y,Pn=de.z):(mt=0,jt=0,Pn=0);const vn=je.convert(ie.format),Sn=je.convert(ie.type);let $e;ie.isData3DTexture?(re.setTexture3D(ie,0),$e=Z.TEXTURE_3D):ie.isDataArrayTexture||ie.isCompressedArrayTexture?(re.setTexture2DArray(ie,0),$e=Z.TEXTURE_2D_ARRAY):(re.setTexture2D(ie,0),$e=Z.TEXTURE_2D),Z.pixelStorei(Z.UNPACK_FLIP_Y_WEBGL,ie.flipY),Z.pixelStorei(Z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ie.premultiplyAlpha),Z.pixelStorei(Z.UNPACK_ALIGNMENT,ie.unpackAlignment);const Ii=Z.getParameter(Z.UNPACK_ROW_LENGTH),It=Z.getParameter(Z.UNPACK_IMAGE_HEIGHT),Oi=Z.getParameter(Z.UNPACK_SKIP_PIXELS),os=Z.getParameter(Z.UNPACK_SKIP_ROWS),Ai=Z.getParameter(Z.UNPACK_SKIP_IMAGES);Z.pixelStorei(Z.UNPACK_ROW_LENGTH,zn.width),Z.pixelStorei(Z.UNPACK_IMAGE_HEIGHT,zn.height),Z.pixelStorei(Z.UNPACK_SKIP_PIXELS,_t),Z.pixelStorei(Z.UNPACK_SKIP_ROWS,Ut),Z.pixelStorei(Z.UNPACK_SKIP_IMAGES,Ht);const Ki=k.isDataArrayTexture||k.isData3DTexture,En=ie.isDataArrayTexture||ie.isData3DTexture;if(k.isDepthTexture){const ai=O.get(k),$i=O.get(ie),fi=O.get(ai.__renderTarget),aa=O.get($i.__renderTarget);We.bindFramebuffer(Z.READ_FRAMEBUFFER,fi.__webglFramebuffer),We.bindFramebuffer(Z.DRAW_FRAMEBUFFER,aa.__webglFramebuffer);for(let Xa=0;Xa"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:d;return Mx.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:_,Mx}var x1;function TI(){return x1||(x1=1,bx.exports=EI()),bx.exports}var S1;function AI(){if(S1)return Sx;S1=1;var o=xm(),e=TI();function t(g,_){return g===_&&(g!==0||1/g===1/_)||g!==g&&_!==_}var i=typeof Object.is=="function"?Object.is:t,a=e.useSyncExternalStore,u=o.useRef,f=o.useEffect,d=o.useMemo,m=o.useDebugValue;return Sx.useSyncExternalStoreWithSelector=function(g,_,S,x,M){var T=u(null);if(T.current===null){var D={hasValue:!1,value:null};T.current=D}else D=T.current;T=d(function(){function A(z){if(!R){if(R=!0,L=z,z=x(z),M!==void 0&&D.hasValue){var H=D.value;if(M(H,z))return I=H}return I=z}if(H=I,i(L,z))return H;var U=x(z);return M!==void 0&&M(H,U)?(L=z,H):(L=z,I=U)}var R=!1,L,I,V=S===void 0?null:S;return[function(){return A(_())},V===null?void 0:function(){return A(V())}]},[_,S,x,M]);var w=a(g,T[0],T[1]);return f(function(){D.hasValue=!0,D.value=w},[w]),m(w),w},Sx}var b1;function wI(){return b1||(b1=1,xx.exports=AI()),xx.exports}var CI=wI();const RI=nS(CI),M1=o=>{let e;const t=new Set,i=(g,_)=>{const S=typeof g=="function"?g(e):g;if(!Object.is(S,e)){const x=e;e=_??(typeof S!="object"||S===null)?S:Object.assign({},e,S),t.forEach(M=>M(e,x))}},a=()=>e,d={setState:i,getState:a,getInitialState:()=>m,subscribe:g=>(t.add(g),()=>t.delete(g))},m=e=o(i,a,d);return d},DI=(o=>o?M1(o):M1),{useSyncExternalStoreWithSelector:NI}=RI,LI=o=>o;function UI(o,e=LI,t){const i=NI(o.subscribe,o.getState,o.getInitialState,e,t);return z1.useDebugValue(i),i}const E1=(o,e)=>{const t=DI(o),i=(a,u=e)=>UI(t,a,u);return Object.assign(i,t),i},II=((o,e)=>o?E1(o,e):E1);var jx=B1();const OI=nS(jx);function ZS(o,e,t){if(!o)return;if(t(o)===!0)return o;let i=e?o.return:o.child;for(;i;){const a=ZS(i,e,t);if(a)return a;i=e?null:i.sibling}}function UT(o){try{return Object.defineProperties(o,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return o}}const jS=UT(Vt.createContext(null));class IT extends Vt.Component{render(){return Vt.createElement(jS.Provider,{value:this._reactInternals},this.props.children)}}function OT(){const o=Vt.useContext(jS);if(o===null)throw new Error("its-fine: useFiber must be called within a !");const e=Vt.useId();return Vt.useMemo(()=>{for(const t of[o,o?.alternate]){if(!t)continue;const i=ZS(t,!1,a=>{let u=a.memoizedState;for(;u;){if(u.memoizedState===e)return!0;u=u.next}});if(i)return i}},[o,e])}const PI=Symbol.for("react.context"),zI=o=>o!==null&&typeof o=="object"&&"$$typeof"in o&&o.$$typeof===PI;function BI(){const o=OT(),[e]=Vt.useState(()=>new Map);e.clear();let t=o;for(;t;){const i=t.type;zI(i)&&i!==jS&&!e.has(i)&&e.set(i,Vt.use(UT(i))),t=t.return}return e}function FI(){const o=BI();return Vt.useMemo(()=>Array.from(o.keys()).reduce((e,t)=>i=>Vt.createElement(e,null,Vt.createElement(t.Provider,{...i,value:o.get(t)})),e=>Vt.createElement(IT,{...e})),[o])}function PT(o){let e=o.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const zT=o=>o&&o.isOrthographicCamera,VI=o=>o&&o.hasOwnProperty("current"),kI=o=>o!=null&&(typeof o=="string"||typeof o=="number"||o.isColor),Gy=((o,e)=>typeof window<"u"&&(((o=window.document)==null?void 0:o.createElement)||((e=window.navigator)==null?void 0:e.product)==="ReactNative"))()?Vt.useLayoutEffect:Vt.useEffect;function HI(o){const e=Vt.useRef(o);return Gy(()=>{e.current=o},[o]),e}function GI(){const o=OT(),e=FI();return Vt.useMemo(()=>({children:t})=>{const a=!!ZS(o,!0,u=>u.type===Vt.StrictMode)?Vt.StrictMode:Vt.Fragment;return Mn.jsx(a,{children:Mn.jsx(e,{children:t})})},[o,e])}function XI({set:o}){return Gy(()=>(o(new Promise(()=>null)),()=>o(!1)),[o]),null}const WI=(o=>(o=class extends Vt.Component{constructor(...t){super(...t),this.state={error:!1}}componentDidCatch(t){this.props.set(t)}render(){return this.state.error?null:this.props.children}},o.getDerivedStateFromError=()=>({error:!0}),o))();function BT(o){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(o)?Math.min(Math.max(o[0],t),o[1]):o}function Lh(o){var e;return(e=o.__r3f)==null?void 0:e.root.getState()}const yi={obj:o=>o===Object(o)&&!yi.arr(o)&&typeof o!="function",fun:o=>typeof o=="function",str:o=>typeof o=="string",num:o=>typeof o=="number",boo:o=>typeof o=="boolean",und:o=>o===void 0,nul:o=>o===null,arr:o=>Array.isArray(o),equ(o,e,{arrays:t="shallow",objects:i="reference",strict:a=!0}={}){if(typeof o!=typeof e||!!o!=!!e)return!1;if(yi.str(o)||yi.num(o)||yi.boo(o))return o===e;const u=yi.obj(o);if(u&&i==="reference")return o===e;const f=yi.arr(o);if(f&&t==="reference")return o===e;if((f||u)&&o===e)return!0;let d;for(d in o)if(!(d in e))return!1;if(u&&t==="shallow"&&i==="shallow"){for(d in a?e:o)if(!yi.equ(o[d],e[d],{strict:a,objects:"reference"}))return!1}else for(d in a?e:o)if(o[d]!==e[d])return!1;if(yi.und(d)){if(f&&o.length===0&&e.length===0||u&&Object.keys(o).length===0&&Object.keys(e).length===0)return!0;if(o!==e)return!1}return!0}};function qI(o){o.type!=="Scene"&&(o.dispose==null||o.dispose());for(const e in o){const t=o[e];t?.type!=="Scene"&&(t==null||t.dispose==null||t.dispose())}}const FT=["children","key","ref"];function YI(o){const e={};for(const t in o)FT.includes(t)||(e[t]=o[t]);return e}function ny(o,e,t,i){const a=o;let u=a?.__r3f;return u||(u={root:e,type:t,parent:null,children:[],props:YI(i),object:a,eventCount:0,handlers:{},isHidden:!1},a&&(a.__r3f=u)),u}function _m(o,e){if(!e.includes("-"))return{root:o,key:e,target:o[e]};if(e in o)return{root:o,key:e,target:o[e]};let t=o;const i=e.split("-");for(const a of i){if(typeof t!="object"||t===null){if(t!==void 0){const u=i.slice(i.indexOf(a)).join("-");return{root:t,key:u,target:void 0}}return{root:o,key:e,target:void 0}}e=a,o=t,t=t[e]}return{root:o,key:e,target:t}}const T1=/-\d+$/;function iy(o,e){if(yi.str(e.props.attach)){if(T1.test(e.props.attach)){const a=e.props.attach.replace(T1,""),{root:u,key:f}=_m(o.object,a);Array.isArray(u[f])||(u[f]=[])}const{root:t,key:i}=_m(o.object,e.props.attach);e.previousAttach=t[i],t[i]=e.object}else yi.fun(e.props.attach)&&(e.previousAttach=e.props.attach(o.object,e.object))}function sy(o,e){if(yi.str(e.props.attach)){const{root:t,key:i}=_m(o.object,e.props.attach),a=e.previousAttach;a===void 0?delete t[i]:t[i]=a}else e.previousAttach==null||e.previousAttach(o.object,e.object);delete e.previousAttach}const Qx=[...FT,"args","dispose","attach","object","onUpdate","dispose"],A1=new Map;function ZI(o){let e=A1.get(o.constructor);try{e||(e=new o.constructor,A1.set(o.constructor,e))}catch{}return e}function jI(o,e){const t={};for(const i in e)if(!Qx.includes(i)&&!yi.equ(e[i],o.props[i])){t[i]=e[i];for(const a in e)a.startsWith(`${i}-`)&&(t[a]=e[a])}for(const i in o.props){if(Qx.includes(i)||e.hasOwnProperty(i))continue;const{root:a,key:u}=_m(o.object,i);if(a.constructor&&a.constructor.length===0){const f=ZI(a);yi.und(f)||(t[u]=f[u])}else t[u]=0}return t}const QI=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],JI=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function Cu(o,e){var t;const i=o.__r3f,a=i&&PT(i).getState(),u=i?.eventCount;for(const d in e){let m=e[d];if(Qx.includes(d))continue;if(i&&JI.test(d)){typeof m=="function"?i.handlers[d]=m:delete i.handlers[d],i.eventCount=Object.keys(i.handlers).length;continue}if(m===void 0)continue;let{root:g,key:_,target:S}=_m(o,d);if(S===void 0&&(typeof g!="object"||g===null))throw Error(`R3F: Cannot set "${d}". Ensure it is an object before setting "${_}".`);if(S instanceof Gh&&m instanceof Gh)S.mask=m.mask;else if(S instanceof pt&&kI(m))S.set(m);else if(S!==null&&typeof S=="object"&&typeof S.set=="function"&&typeof S.copy=="function"&&m!=null&&m.constructor&&S.constructor===m.constructor)S.copy(m);else if(S!==null&&typeof S=="object"&&typeof S.set=="function"&&Array.isArray(m))typeof S.fromArray=="function"?S.fromArray(m):S.set(...m);else if(S!==null&&typeof S=="object"&&typeof S.set=="function"&&typeof m=="number")typeof S.setScalar=="function"?S.setScalar(m):S.set(m);else{var f;g[_]=m,a&&!a.linear&&QI.includes(_)&&(f=g[_])!=null&&f.isTexture&&g[_].format===Os&&g[_].type===Qs&&(g[_].colorSpace=Is)}}if(i!=null&&i.parent&&a!=null&&a.internal&&(t=i.object)!=null&&t.isObject3D&&u!==i.eventCount){const d=i.object,m=a.internal.interaction.indexOf(d);m>-1&&a.internal.interaction.splice(m,1),i.eventCount&&d.raycast!==null&&a.internal.interaction.push(d)}return i&&i.props.attach===void 0&&(i.object.isBufferGeometry?i.props.attach="geometry":i.object.isMaterial&&(i.props.attach="material")),i&&nd(i),o}function nd(o){var e;if(!o.parent)return;o.props.onUpdate==null||o.props.onUpdate(o.object);const t=(e=o.root)==null||e.getState==null?void 0:e.getState();t&&t.internal.frames===0&&t.invalidate()}function KI(o,e){o.manual||(zT(o)?(o.left=e.width/-2,o.right=e.width/2,o.top=e.height/2,o.bottom=e.height/-2):o.aspect=e.width/e.height,o.updateProjectionMatrix())}const Aa=o=>o?.isObject3D;function sv(o){return(o.eventObject||o.object).uuid+"/"+o.index+o.instanceId}function VT(o,e,t,i){const a=t.get(e);a&&(t.delete(e),t.size===0&&(o.delete(i),a.target.releasePointerCapture(i)))}function $I(o,e){const{internal:t}=o.getState();t.interaction=t.interaction.filter(i=>i!==e),t.initialHits=t.initialHits.filter(i=>i!==e),t.hovered.forEach((i,a)=>{(i.eventObject===e||i.object===e)&&t.hovered.delete(a)}),t.capturedMap.forEach((i,a)=>{VT(t.capturedMap,e,i,a)})}function eO(o){function e(m){const{internal:g}=o.getState(),_=m.offsetX-g.initialClick[0],S=m.offsetY-g.initialClick[1];return Math.round(Math.sqrt(_*_+S*S))}function t(m){return m.filter(g=>["Move","Over","Enter","Out","Leave"].some(_=>{var S;return(S=g.__r3f)==null?void 0:S.handlers["onPointer"+_]}))}function i(m,g){const _=o.getState(),S=new Set,x=[],M=g?g(_.internal.interaction):_.internal.interaction;for(let A=0;A{const L=Lh(A.object),I=Lh(R.object);return!L||!I?A.distance-R.distance:I.events.priority-L.events.priority||A.distance-R.distance}).filter(A=>{const R=sv(A);return S.has(R)?!1:(S.add(R),!0)});_.events.filter&&(D=_.events.filter(D,_));for(const A of D){let R=A.object;for(;R;){var w;(w=R.__r3f)!=null&&w.eventCount&&x.push({...A,eventObject:R}),R=R.parent}}if("pointerId"in m&&_.internal.capturedMap.has(m.pointerId))for(let A of _.internal.capturedMap.get(m.pointerId).values())S.has(sv(A.intersection))||x.push(A.intersection);return x}function a(m,g,_,S){if(m.length){const x={stopped:!1};for(const M of m){let T=Lh(M.object);if(T||M.object.traverseAncestors(D=>{const w=Lh(D);if(w)return T=w,!1}),T){const{raycaster:D,pointer:w,camera:A,internal:R}=T,L=new Y(w.x,w.y,0).unproject(A),I=P=>{var Q,W;return(Q=(W=R.capturedMap.get(P))==null?void 0:W.has(M.eventObject))!=null?Q:!1},V=P=>{const Q={intersection:M,target:g.target};R.capturedMap.has(P)?R.capturedMap.get(P).set(M.eventObject,Q):R.capturedMap.set(P,new Map([[M.eventObject,Q]])),g.target.setPointerCapture(P)},z=P=>{const Q=R.capturedMap.get(P);Q&&VT(R.capturedMap,M.eventObject,Q,P)};let H={};for(let P in g){let Q=g[P];typeof Q!="function"&&(H[P]=Q)}let U={...M,...H,pointer:w,intersections:m,stopped:x.stopped,delta:_,unprojectedPoint:L,ray:D.ray,camera:A,stopPropagation(){const P="pointerId"in g&&R.capturedMap.get(g.pointerId);if((!P||P.has(M.eventObject))&&(U.stopped=x.stopped=!0,R.hovered.size&&Array.from(R.hovered.values()).find(Q=>Q.eventObject===M.eventObject))){const Q=m.slice(0,m.indexOf(M));u([...Q,M])}},target:{hasPointerCapture:I,setPointerCapture:V,releasePointerCapture:z},currentTarget:{hasPointerCapture:I,setPointerCapture:V,releasePointerCapture:z},nativeEvent:g};if(S(U),x.stopped===!0)break}}}return m}function u(m){const{internal:g}=o.getState();for(const _ of g.hovered.values())if(!m.length||!m.find(S=>S.object===_.object&&S.index===_.index&&S.instanceId===_.instanceId)){const x=_.eventObject.__r3f;if(g.hovered.delete(sv(_)),x!=null&&x.eventCount){const M=x.handlers,T={..._,intersections:m};M.onPointerOut==null||M.onPointerOut(T),M.onPointerLeave==null||M.onPointerLeave(T)}}}function f(m,g){for(let _=0;_u([]);case"onLostPointerCapture":return g=>{const{internal:_}=o.getState();"pointerId"in g&&_.capturedMap.has(g.pointerId)&&requestAnimationFrame(()=>{_.capturedMap.has(g.pointerId)&&(_.capturedMap.delete(g.pointerId),u([]))})}}return function(_){const{onPointerMissed:S,internal:x}=o.getState();x.lastEvent.current=_;const M=m==="onPointerMove",T=m==="onClick"||m==="onContextMenu"||m==="onDoubleClick",w=i(_,M?t:void 0),A=T?e(_):0;m==="onPointerDown"&&(x.initialClick=[_.offsetX,_.offsetY],x.initialHits=w.map(L=>L.eventObject)),T&&!w.length&&A<=2&&(f(_,x.interaction),S&&S(_)),M&&u(w);function R(L){const I=L.eventObject,V=I.__r3f;if(!(V!=null&&V.eventCount))return;const z=V.handlers;if(M){if(z.onPointerOver||z.onPointerEnter||z.onPointerOut||z.onPointerLeave){const H=sv(L),U=x.hovered.get(H);U?U.stopped&&L.stopPropagation():(x.hovered.set(H,L),z.onPointerOver==null||z.onPointerOver(L),z.onPointerEnter==null||z.onPointerEnter(L))}z.onPointerMove==null||z.onPointerMove(L)}else{const H=z[m];H?(!T||x.initialHits.includes(I))&&(f(_,x.interaction.filter(U=>!x.initialHits.includes(U))),H(L)):T&&x.initialHits.includes(I)&&f(_,x.interaction.filter(U=>!x.initialHits.includes(U)))}}a(w,_,A,R)}}return{handlePointer:d}}const w1=o=>!!(o!=null&&o.render),tO=Vt.createContext(null),nO=(o,e)=>{const t=II((d,m)=>{const g=new Y,_=new Y,S=new Y;function x(A=m().camera,R=_,L=m().size){const{width:I,height:V,top:z,left:H}=L,U=I/V;R.isVector3?S.copy(R):S.set(...R);const P=A.getWorldPosition(g).distanceTo(S);if(zT(A))return{width:I/A.zoom,height:V/A.zoom,top:z,left:H,factor:1,distance:P,aspect:U};{const Q=A.fov*Math.PI/180,W=2*Math.tan(Q/2)*P,te=W*(I/V);return{width:te,height:W,top:z,left:H,factor:I/te,distance:P,aspect:U}}}let M;const T=A=>d(R=>({performance:{...R.performance,current:A}})),D=new ze;return{set:d,get:m,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(A=1)=>o(m(),A),advance:(A,R)=>e(A,R,m()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new ET,pointer:D,mouse:D,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const A=m();M&&clearTimeout(M),A.performance.current!==A.performance.min&&T(A.performance.min),M=setTimeout(()=>T(m().performance.max),A.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:x},setEvents:A=>d(R=>({...R,events:{...R.events,...A}})),setSize:(A,R,L=0,I=0)=>{const V=m().camera,z={width:A,height:R,top:L,left:I};d(H=>({size:z,viewport:{...H.viewport,...x(V,_,z)}}))},setDpr:A=>d(R=>{const L=BT(A);return{viewport:{...R.viewport,dpr:L,initialDpr:R.viewport.initialDpr||L}}}),setFrameloop:(A="always")=>{const R=m().clock;R.stop(),R.elapsedTime=0,A!=="never"&&(R.start(),R.elapsedTime=0),d(()=>({frameloop:A}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:Vt.createRef(),active:!1,frames:0,priority:0,subscribe:(A,R,L)=>{const I=m().internal;return I.priority=I.priority+(R>0?1:0),I.subscribers.push({ref:A,priority:R,store:L}),I.subscribers=I.subscribers.sort((V,z)=>V.priority-z.priority),()=>{const V=m().internal;V!=null&&V.subscribers&&(V.priority=V.priority-(R>0?1:0),V.subscribers=V.subscribers.filter(z=>z.ref!==A))}}}}}),i=t.getState();let a=i.size,u=i.viewport.dpr,f=i.camera;return t.subscribe(()=>{const{camera:d,size:m,viewport:g,gl:_,set:S}=t.getState();if(m.width!==a.width||m.height!==a.height||g.dpr!==u){a=m,u=g.dpr,KI(d,m),g.dpr>0&&_.setPixelRatio(g.dpr);const x=typeof HTMLCanvasElement<"u"&&_.domElement instanceof HTMLCanvasElement;_.setSize(m.width,m.height,x)}d!==f&&(f=d,S(x=>({viewport:{...x.viewport,...x.viewport.getCurrentViewport(d)}})))}),t.subscribe(d=>o(d)),t};const iO=1,sO=8,aO=32,rO=2;var oO={version:"9.5.0"};function lO(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var C1={exports:{}},R1={exports:{}},D1;function uO(){return D1||(D1=1,(function(o){o.exports=function(e){function t(r,l,p,v){return new wd(r,l,p,v)}function i(){}function a(r){var l="https://react.dev/errors/"+r;if(1ol||(r.current=Yf[ol],Yf[ol]=null,ol--)}function T(r,l){ol++,Yf[ol]=r.current,r.current=l}function D(r){return r>>>=0,r===0?32:31-(Zf(r)/Wg|0)|0}function w(r){var l=r&42;if(l!==0)return l;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function A(r,l,p){var v=r.pendingLanes;if(v===0)return 0;var E=0,C=r.suspendedLanes,B=r.pingedLanes;r=r.warmLanes;var K=v&134217727;return K!==0?(v=K&~C,v!==0?E=w(v):(B&=K,B!==0?E=w(B):p||(p=K&~r,p!==0&&(E=w(p))))):(K=v&~C,K!==0?E=w(K):B!==0?E=w(B):p||(p=v&~r,p!==0&&(E=w(p)))),E===0?0:l!==0&&l!==E&&(l&C)===0&&(C=E&-E,p=l&-l,C>=p||C===32&&(p&4194048)!==0)?l:E}function R(r,l){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&l)===0}function L(r,l){switch(r){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function I(){var r=iu;return iu<<=1,(iu&62914560)===0&&(iu=4194304),r}function V(r){for(var l=[],p=0;31>p;p++)l.push(r);return l}function z(r,l){r.pendingLanes|=l,l!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function H(r,l,p,v,E,C){var B=r.pendingLanes;r.pendingLanes=p,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=p,r.entangledLanes&=p,r.errorRecoveryDisabledLanes&=p,r.shellSuspendCounter=0;var K=r.entanglements,Se=r.expirationTimes,Pe=r.hiddenUpdates;for(p=B&~p;0)":-1E||Se[v]!==Pe[E]){var Qe=` `+Se[v].replace(" at new "," at ");return r.displayName&&Qe.includes("")&&(Qe=Qe.replace("",r.displayName)),Qe}while(1<=v&&0<=E);break}}}finally{gc=!1,Error.prepareStackTrace=p}return(p=r?r.displayName||r.name:"")?se(p):""}function j(r,l){switch(r.tag){case 26:case 27:case 5:return se(r.type);case 16:return se("Lazy");case 13:return r.child!==l&&l!==null?se("Suspense Fallback"):se("Suspense");case 19:return se("SuspenseList");case 0:case 15:return q(r.type,!1);case 11:return q(r.type.render,!1);case 1:return q(r.type,!0);case 31:return se("Activity");default:return""}}function ye(r){try{var l="",p=null;do l+=j(r,p),p=r,r=r.return;while(r);return l}catch(v){return` Error generating stack: `+v.message+` `+v.stack}}function _e(r,l){if(typeof r=="object"&&r!==null){var p=dp.get(r);return p!==void 0?p:(l={value:r,source:l,stack:ye(l)},dp.set(r,l),l)}return{value:r,source:l,stack:ye(l)}}function Ue(r,l){Br[rr++]=vc,Br[rr++]=In,In=r,vc=l}function X(r,l,p){ma[Gs++]=Wi,ma[Gs++]=Ia,ma[Gs++]=ga,ga=r;var v=Wi;r=Ia;var E=32-Ts(v)-1;v&=~(1<>=B,E-=B,Wi=1<<32-Ts(l)+E|p<yn?(ki=Lt,Lt=null):ki=Lt.sibling;var Tn=ht(me,Lt,xe[yn],Ye);if(Tn===null){Lt===null&&(Lt=ki);break}r&&Lt&&Tn.alternate===null&&l(me,Lt),le=C(Tn,le,yn),ii===null?Nt=Tn:ii.sibling=Tn,ii=Tn,Lt=ki}if(yn===xe.length)return p(me,Lt),un&&Ue(me,yn),Nt;if(Lt===null){for(;ynyn?(ki=Lt,Lt=null):ki=Lt.sibling;var Ma=ht(me,Lt,Tn.value,Ye);if(Ma===null){Lt===null&&(Lt=ki);break}r&&Lt&&Ma.alternate===null&&l(me,Lt),le=C(Ma,le,yn),ii===null?Nt=Ma:ii.sibling=Ma,ii=Ma,Lt=ki}if(Tn.done)return p(me,Lt),un&&Ue(me,yn),Nt;if(Lt===null){for(;!Tn.done;yn++,Tn=xe.next())Tn=Ge(me,Tn.value,Ye),Tn!==null&&(le=C(Tn,le,yn),ii===null?Nt=Tn:ii.sibling=Tn,ii=Tn);return un&&Ue(me,yn),Nt}for(Lt=v(Lt);!Tn.done;yn++,Tn=xe.next())Tn=Gt(Lt,me,yn,Tn.value,Ye),Tn!==null&&(r&&Tn.alternate!==null&&Lt.delete(Tn.key===null?yn:Tn.key),le=C(Tn,le,yn),ii===null?Nt=Tn:ii.sibling=Tn,ii=Tn);return r&&Lt.forEach(function(i_){return l(me,i_)}),un&&Ue(me,yn),Nt}function Co(me,le,xe,Ye){if(typeof xe=="object"&&xe!==null&&xe.type===el&&xe.key===null&&(xe=xe.props.children),typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case ir:e:{for(var Nt=xe.key;le!==null;){if(le.key===Nt){if(Nt=xe.type,Nt===el){if(le.tag===7){p(me,le.sibling),Ye=E(le,xe.props.children),Ye.return=me,me=Ye;break e}}else if(le.elementType===Nt||typeof Nt=="object"&&Nt!==null&&Nt.$$typeof===fs&&dn(Nt)===le.type){p(me,le.sibling),Ye=E(le,xe.props),xr(Ye,xe),Ye.return=me,me=Ye;break e}p(me,le);break}else l(me,le);le=le.sibling}xe.type===el?(Ye=fa(xe.props.children,me.mode,Ye,xe.key),Ye.return=me,me=Ye):(Ye=Ur(xe.type,xe.key,xe.props,null,me.mode,Ye),xr(Ye,xe),Ye.return=me,me=Ye)}return B(me);case $o:e:{for(Nt=xe.key;le!==null;){if(le.key===Nt)if(le.tag===4&&le.stateNode.containerInfo===xe.containerInfo&&le.stateNode.implementation===xe.implementation){p(me,le.sibling),Ye=E(le,xe.children||[]),Ye.return=me,me=Ye;break e}else{p(me,le);break}else l(me,le);le=le.sibling}Ye=Dd(xe,me.mode,Ye),Ye.return=me,me=Ye}return B(me);case fs:return xe=dn(xe),Co(me,le,xe,Ye)}if(po(xe))return vi(me,le,xe,Ye);if(_(xe)){if(Nt=_(xe),typeof Nt!="function")throw Error(a(150));return xe=Nt.call(xe),hu(me,le,xe,Ye)}if(typeof xe.then=="function")return Co(me,le,_s(xe),Ye);if(xe.$$typeof===ha)return Co(me,le,O(me,xe),Ye);Sr(me,xe)}return typeof xe=="string"&&xe!==""||typeof xe=="number"||typeof xe=="bigint"?(xe=""+xe,le!==null&&le.tag===6?(p(me,le.sibling),Ye=E(le,xe),Ye.return=me,me=Ye):(p(me,le),Ye=Cd(xe,me.mode,Ye),Ye.return=me,me=Ye),B(me)):p(me,le)}return function(me,le,xe,Ye){try{cl=0;var Nt=Co(me,le,xe,Ye);return xo=null,Nt}catch(Lt){if(Lt===Ni||Lt===xa)throw Lt;var ii=t(29,Lt,null,me.mode);return ii.lanes=Ye,ii.return=me,ii}}}function br(){for(var r=ur,l=fl=ur=0;lC?C:8);var B=Ct.T,K={};Ct.T=K,ff(r,!1,l,p);try{var Se=E(),Pe=Ct.S;if(Pe!==null&&Pe(K,Se),Se!==null&&typeof Se=="object"&&typeof Se.then=="function"){var Qe=je(Se,v);qu(r,l,Qe,qn(r))}else qu(r,l,v,qn(r))}catch(Ge){qu(r,l,{then:function(){},status:"rejected",reason:Ge},qn())}finally{ln(C),B!==null&&K.types!==null&&(B.types=K.types),Ct.T=B}}function Um(r){var l=r.memoizedState;if(l!==null)return l;l={memoizedState:sl,baseState:sl,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ai,lastRenderedState:sl},next:null};var p={};return l.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ai,lastRenderedState:p},next:null},r.memoizedState=l,r=r.alternate,r!==null&&(r.memoizedState=l),l}function ld(){return G(al)}function cf(){return $e().memoizedState}function Im(){return $e().memoizedState}function Wy(r){for(var l=r.return;l!==null;){switch(l.tag){case 24:case 3:var p=qn();r=rs(p);var v=Na(l,r,p);v!==null&&(Kn(v,l,p),Kr(v,l,p)),l={cache:be()},r.payload=l;return}l=l.return}}function qy(r,l,p){var v=qn();p={lane:v,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},hf(r)?Pm(l,p):(p=na(r,l,p,v),p!==null&&(Kn(p,r,v),zm(p,l,v)))}function Om(r,l,p){var v=qn();qu(r,l,p,v)}function qu(r,l,p,v){var E={lane:v,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null};if(hf(r))Pm(l,E);else{var C=r.alternate;if(r.lanes===0&&(C===null||C.lanes===0)&&(C=l.lastRenderedReducer,C!==null))try{var B=l.lastRenderedState,K=C(B,p);if(E.hasEagerState=!0,E.eagerState=K,pi(K,B))return Mr(r,l,E,0),en===null&&br(),!1}catch{}if(p=na(r,l,E,v),p!==null)return Kn(p,r,v),zm(p,l,v),!0}return!1}function ff(r,l,p,v){if(v={lane:2,revertLane:ct(),gesture:null,action:v,hasEagerState:!1,eagerState:null,next:null},hf(r)){if(l)throw Error(a(479))}else l=na(r,p,v,2),l!==null&&Kn(l,r,2)}function hf(r){var l=r.alternate;return r===Wt||l!==null&&l===Wt}function Pm(r,l){Qt=$t=!0;var p=r.pending;p===null?l.next=l:(l.next=p.next,p.next=l),r.pending=l}function zm(r,l,p){if((p&4194048)!==0){var v=l.lanes;v&=r.pendingLanes,p|=v,l.lanes=p,P(r,p)}}function ud(r,l,p,v){l=r.memoizedState,p=p(v,l),p=p==null?l:Lf({},l,p),r.memoizedState=p,r.lanes===0&&(r.updateQueue.baseState=p)}function df(r,l,p,v,E,C,B){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(v,C,B):l.prototype&&l.prototype.isPureReactComponent?!Ae(p,v)||!Ae(E,C):!0}function Bm(r,l,p,v){r=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,v),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,v),l.state!==r&&xc.enqueueReplaceState(l,l.state,null)}function Wo(r,l){var p=l;if("ref"in l){p={};for(var v in l)v!=="ref"&&(p[v]=l[v])}if(r=r.defaultProps){p===l&&(p=Lf({},p));for(var E in r)p[E]===void 0&&(p[E]=r[E])}return p}function pf(r,l){try{var p=r.onUncaughtError;p(l.value,{componentStack:l.stack})}catch(v){setTimeout(function(){throw v})}}function cd(r,l,p){try{var v=r.onCaughtError;v(p.value,{componentStack:p.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(E){setTimeout(function(){throw E})}}function fd(r,l,p){return p=rs(p),p.tag=3,p.payload={element:null},p.callback=function(){pf(r,l)},p}function Fm(r){return r=rs(r),r.tag=3,r}function Vm(r,l,p,v){var E=p.type.getDerivedStateFromError;if(typeof E=="function"){var C=v.value;r.payload=function(){return E(C)},r.callback=function(){cd(l,p,v)}}var B=p.stateNode;B!==null&&typeof B.componentDidCatch=="function"&&(r.callback=function(){cd(l,p,v),typeof E!="function"&&(Gr===null?Gr=new Set([this]):Gr.add(this));var K=v.stack;this.componentDidCatch(v.value,{componentStack:K!==null?K:""})})}function Yy(r,l,p,v,E){if(p.flags|=32768,v!==null&&typeof v=="object"&&typeof v.then=="function"){if(l=p.alternate,l!==null&&nt(l,p,E,!0),p=ws.current,p!==null){switch(p.tag){case 31:case 13:return Cs===null?ql():p.alternate===null&&ni===0&&(ni=3),p.flags&=-257,p.flags|=65536,p.lanes=E,v===lr?p.flags|=16384:(l=p.updateQueue,l===null?p.updateQueue=new Set([v]):l.add(v),jl(r,v,E)),!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)),jl(r,v,E)),!1}throw Error(a(435,p.tag))}return jl(r,v,E),ql(),!1}if(un)return l=ws.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=E,v!==th&&(r=Error(a(422),{cause:v}),Ve(_e(r,p)))):(v!==th&&(l=Error(a(423),{cause:v}),Ve(_e(l,p))),r=r.current.alternate,r.flags|=65536,E&=-E,r.lanes|=E,v=_e(v,p),E=fd(r.stateNode,v,E),Rl(r,E),ni!==4&&(ni=2)),!1;var C=Error(a(520),{cause:v});if(C=_e(C,p),bc===null?bc=[C]:bc.push(C),ni!==4&&(ni=2),l===null)return!0;v=_e(v,p),p=l;do{switch(p.tag){case 3:return p.flags|=65536,r=E&-E,p.lanes|=r,r=fd(p.stateNode,v,r),Rl(p,r),!1;case 1:if(l=p.type,C=p.stateNode,(p.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||C!==null&&typeof C.componentDidCatch=="function"&&(Gr===null||!Gr.has(C))))return p.flags|=65536,E&=-E,p.lanes|=E,E=Fm(E),Vm(E,r,p,v),Rl(p,E),!1}p=p.return}while(p!==null);return!1}function Xi(r,l,p,v){l.child=r===null?mp(l,null,p,v):Yi(l,r.child,p,v)}function km(r,l,p,v,E){p=p.render;var C=l.ref;if("ref"in v){var B={};for(var K in v)K!=="ref"&&(B[K]=v[K])}else B=v;return We(l),v=Ut(r,l,p,B,C,E),K=Pn(),r!==null&&!Xn?(zn(r,l,E),qa(r,l,E)):(un&&K&&ee(l),l.flags|=1,Xi(r,l,v,E),l.child)}function Hm(r,l,p,v,E){if(r===null){var C=p.type;return typeof C=="function"&&!Qo(C)&&C.defaultProps===void 0&&p.compare===null?(l.tag=15,l.type=C,Gm(r,l,C,v,E)):(r=Ur(p.type,null,v,l,l.mode,E),r.ref=l.ref,r.return=l,l.child=r)}if(C=r.child,!Zu(r,E)){var B=C.memoizedProps;if(p=p.compare,p=p!==null?p:Ae,p(B,v)&&r.ref===l.ref)return qa(r,l,E)}return l.flags|=1,r=ks(C,v),r.ref=l.ref,r.return=l,l.child=r}function Gm(r,l,p,v,E){if(r!==null){var C=r.memoizedProps;if(Ae(C,v)&&r.ref===l.ref)if(Xn=!1,l.pendingProps=v=C,Zu(r,E))(r.flags&131072)!==0&&(Xn=!0);else return l.lanes=r.lanes,qa(r,l,E)}return gf(r,l,p,v,E)}function Xm(r,l,p,v){var E=v.children,C=r!==null?r.memoizedState:null;if(r===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),v.mode==="hidden"){if((l.flags&128)!==0){if(C=C!==null?C.baseLanes|p:p,r!==null){for(v=l.child=r.child,E=0;v!==null;)E=E|v.lanes|v.childLanes,v=v.sibling;v=E&~C}else v=0,l.child=null;return Pl(r,l,C,p,v)}if((p&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},r!==null&&ut(l,C!==null?C.cachePool:null),C!==null?$r(l,C):k(),fe(l);else return v=l.lanes=536870912,Pl(r,l,C!==null?C.baseLanes|p:p,p,v)}else C!==null?(ut(l,C.cachePool),$r(l,C),Ze(),l.memoizedState=null):(r!==null&&ut(l,null),k(),Ze());return Xi(r,l,E,p),l.child}function qo(r,l){return r!==null&&r.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function Pl(r,l,p,v,E){var C=Xe();return C=C===null?null:{parent:hi?jn._currentValue:jn._currentValue2,pool:C},l.memoizedState={baseLanes:p,cachePool:C},r!==null&&ut(l,null),k(),fe(l),r!==null&&nt(r,l,v,!0),l.childLanes=E,null}function mf(r,l){return l=no({mode:l.mode,children:l.children},r.mode),l.ref=r.ref,r.child=l,l.return=r,l}function hd(r,l,p){return Yi(l,r.child,null,p),r=mf(l,l.pendingProps),r.flags|=2,tt(l),l.memoizedState=null,r}function Wm(r,l,p){var v=l.pendingProps,E=(l.flags&128)!==0;if(l.flags&=-129,r===null){if(un){if(v.mode==="hidden")return r=mf(l,v),l.lanes=536870912,qo(null,r);if(de(l),(r=Zn)?(r=$d(r,ds),r!==null&&(l.memoizedState={dehydrated:r,treeContext:ga!==null?{id:Wi,overflow:Ia}:null,retryLane:536870912,hydrationErrors:null},p=Rd(r),p.return=l,l.child=p,Ri=l,Zn=null)):r=null,r===null)throw et(l);return l.lanes=536870912,null}return mf(l,v)}var C=r.memoizedState;if(C!==null){var B=C.dehydrated;if(de(l),E)if(l.flags&256)l.flags&=-257,l=hd(r,l,p);else if(l.memoizedState!==null)l.child=r.child,l.flags|=128,l=null;else throw Error(a(558));else if(Xn||nt(r,l,p,!1),E=(p&r.childLanes)!==0,Xn||E){if(v=en,v!==null&&(B=Q(v,p),B!==0&&B!==C.retryLane))throw C.retryLane=B,ia(r,B),Kn(v,r,B),ms;ql(),l=hd(r,l,p)}else r=C.treeContext,Yn&&(Zn=Cg(B),Ri=l,un=!0,or=null,ds=!1,r!==null&&Oe(l,r)),l=mf(l,v),l.flags|=4096;return l}return r=ks(r.child,{mode:v.mode,children:v.children}),r.ref=l.ref,l.child=r,r.return=l,r}function Yu(r,l){var p=l.ref;if(p===null)r!==null&&r.ref!==null&&(l.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(a(284));(r===null||r.ref!==p)&&(l.flags|=4194816)}}function gf(r,l,p,v,E){return We(l),p=Ut(r,l,p,v,void 0,E),v=Pn(),r!==null&&!Xn?(zn(r,l,E),qa(r,l,E)):(un&&v&&ee(l),l.flags|=1,Xi(r,l,p,E),l.child)}function dd(r,l,p,v,E,C){return We(l),l.updateQueue=null,p=mt(l,v,p,E),Ht(r),v=Pn(),r!==null&&!Xn?(zn(r,l,C),qa(r,l,C)):(un&&v&&ee(l),l.flags|=1,Xi(r,l,p,C),l.child)}function Yo(r,l,p,v,E){if(We(l),l.stateNode===null){var C=sr,B=p.contextType;typeof B=="object"&&B!==null&&(C=G(B)),C=new p(v,C),l.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,C.updater=xc,l.stateNode=C,C._reactInternals=l,C=l.stateNode,C.props=v,C.state=l.memoizedState,C.refs={},ci(l),B=p.contextType,C.context=typeof B=="object"&&B!==null?G(B):sr,C.state=l.memoizedState,B=p.getDerivedStateFromProps,typeof B=="function"&&(ud(l,p,B,v),C.state=l.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(B=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),B!==C.state&&xc.enqueueReplaceState(C,C.state,null),Er(l,v,C,E),La(),C.state=l.memoizedState),typeof C.componentDidMount=="function"&&(l.flags|=4194308),v=!0}else if(r===null){C=l.stateNode;var K=l.memoizedProps,Se=Wo(p,K);C.props=Se;var Pe=C.context,Qe=p.contextType;B=sr,typeof Qe=="object"&&Qe!==null&&(B=G(Qe));var Ge=p.getDerivedStateFromProps;Qe=typeof Ge=="function"||typeof C.getSnapshotBeforeUpdate=="function",K=l.pendingProps!==K,Qe||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(K||Pe!==B)&&Bm(l,C,v,B),Xs=!1;var ht=l.memoizedState;C.state=ht,Er(l,v,C,E),La(),Pe=l.memoizedState,K||ht!==Pe||Xs?(typeof Ge=="function"&&(ud(l,p,Ge,v),Pe=l.memoizedState),(Se=Xs||df(l,p,Se,v,ht,Pe,B))?(Qe||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=Pe),C.props=v,C.state=Pe,C.context=B,v=Se):(typeof C.componentDidMount=="function"&&(l.flags|=4194308),v=!1)}else{C=l.stateNode,Da(r,l),B=l.memoizedProps,Qe=Wo(p,B),C.props=Qe,Ge=l.pendingProps,ht=C.context,Pe=p.contextType,Se=sr,typeof Pe=="object"&&Pe!==null&&(Se=G(Pe)),K=p.getDerivedStateFromProps,(Pe=typeof K=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(B!==Ge||ht!==Se)&&Bm(l,C,v,Se),Xs=!1,ht=l.memoizedState,C.state=ht,Er(l,v,C,E),La();var Gt=l.memoizedState;B!==Ge||ht!==Gt||Xs||r!==null&&r.dependencies!==null&&Mt(r.dependencies)?(typeof K=="function"&&(ud(l,p,K,v),Gt=l.memoizedState),(Qe=Xs||df(l,p,Qe,v,ht,Gt,Se)||r!==null&&r.dependencies!==null&&Mt(r.dependencies))?(Pe||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(v,Gt,Se),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(v,Gt,Se)),typeof C.componentDidUpdate=="function"&&(l.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof C.componentDidUpdate!="function"||B===r.memoizedProps&&ht===r.memoizedState||(l.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||B===r.memoizedProps&&ht===r.memoizedState||(l.flags|=1024),l.memoizedProps=v,l.memoizedState=Gt),C.props=v,C.state=Gt,C.context=Se,v=Qe):(typeof C.componentDidUpdate!="function"||B===r.memoizedProps&&ht===r.memoizedState||(l.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||B===r.memoizedProps&&ht===r.memoizedState||(l.flags|=1024),v=!1)}return C=v,Yu(r,l),v=(l.flags&128)!==0,C||v?(C=l.stateNode,p=v&&typeof p.getDerivedStateFromError!="function"?null:C.render(),l.flags|=1,r!==null&&v?(l.child=Yi(l,r.child,null,E),l.child=Yi(l,null,p,E)):Xi(r,l,p,E),l.memoizedState=C.state,r=l.child):r=qa(r,l,E),r}function qm(r,l,p,v){return Dt(),l.flags|=256,Xi(r,l,p,v),l.child}function pd(r){return{baseLanes:r,cachePool:He()}}function md(r,l,p){return r=r!==null?r.childLanes&~p:0,l&&(r|=gs),r}function gd(r,l,p){var v=l.pendingProps,E=!1,C=(l.flags&128)!==0,B;if((B=C)||(B=r!==null&&r.memoizedState===null?!1:(oi.current&2)!==0),B&&(E=!0,l.flags&=-129),B=(l.flags&32)!==0,l.flags&=-33,r===null){if(un){if(E?ge(l):Ze(),(r=Zn)?(r=Lg(r,ds),r!==null&&(l.memoizedState={dehydrated:r,treeContext:ga!==null?{id:Wi,overflow:Ia}:null,retryLane:536870912,hydrationErrors:null},p=Rd(r),p.return=l,l.child=p,Ri=l,Zn=null)):r=null,r===null)throw et(l);return Vf(r)?l.lanes=32:l.lanes=536870912,null}var K=v.children;return v=v.fallback,E?(Ze(),E=l.mode,K=no({mode:"hidden",children:K},E),v=fa(v,E,p,null),K.return=l,v.return=l,K.sibling=v,l.child=K,v=l.child,v.memoizedState=pd(p),v.childLanes=md(r,B,p),l.memoizedState=dl,qo(null,v)):(ge(l),vf(l,K))}var Se=r.memoizedState;if(Se!==null&&(K=Se.dehydrated,K!==null)){if(C)l.flags&256?(ge(l),l.flags&=-257,l=Zo(r,l,p)):l.memoizedState!==null?(Ze(),l.child=r.child,l.flags|=128,l=null):(Ze(),K=v.fallback,E=l.mode,v=no({mode:"visible",children:v.children},E),K=fa(K,E,p,null),K.flags|=2,v.return=l,K.return=l,v.sibling=K,l.child=v,Yi(l,r.child,null,p),v=l.child,v.memoizedState=pd(p),v.childLanes=md(r,B,p),l.memoizedState=dl,l=qo(null,v));else if(ge(l),Vf(K))B=kf(K).digest,v=Error(a(419)),v.stack="",v.digest=B,Ve({value:v,source:null,stack:null}),l=Zo(r,l,p);else if(Xn||nt(r,l,p,!1),B=(p&r.childLanes)!==0,Xn||B){if(B=en,B!==null&&(v=Q(B,p),v!==0&&v!==Se.retryLane))throw Se.retryLane=v,ia(r,v),Kn(B,r,v),ms;go(K)||ql(),l=Zo(r,l,p)}else go(K)?(l.flags|=192,l.child=r.child,l=null):(r=Se.treeContext,Yn&&(Zn=Rg(K),Ri=l,un=!0,or=null,ds=!1,r!==null&&Oe(l,r)),l=vf(l,v.children),l.flags|=4096);return l}return E?(Ze(),K=v.fallback,E=l.mode,Se=r.child,C=Se.sibling,v=ks(Se,{mode:"hidden",children:v.children}),v.subtreeFlags=Se.subtreeFlags&65011712,C!==null?K=ks(C,K):(K=fa(K,E,p,null),K.flags|=2),K.return=l,v.return=l,v.sibling=K,l.child=v,qo(null,v),v=l.child,K=r.child.memoizedState,K===null?K=pd(p):(E=K.cachePool,E!==null?(Se=hi?jn._currentValue:jn._currentValue2,E=E.parent!==Se?{parent:Se,pool:Se}:E):E=He(),K={baseLanes:K.baseLanes|p,cachePool:E}),v.memoizedState=K,v.childLanes=md(r,B,p),l.memoizedState=dl,qo(r.child,v)):(ge(l),p=r.child,r=p.sibling,p=ks(p,{mode:"visible",children:v.children}),p.return=l,p.sibling=null,r!==null&&(B=l.deletions,B===null?(l.deletions=[r],l.flags|=16):B.push(r)),l.child=p,l.memoizedState=null,p)}function vf(r,l){return l=no({mode:"visible",children:l},r.mode),l.return=r,r.child=l}function no(r,l){return r=t(22,r,null,l),r.lanes=0,r}function Zo(r,l,p){return Yi(l,r.child,null,p),r=vf(l,l.pendingProps.children),r.flags|=2,l.memoizedState=null,r}function Ym(r,l,p){r.lanes|=l;var v=r.alternate;v!==null&&(v.lanes|=l),Z(r.return,l,p)}function zl(r,l,p,v,E,C){var B=r.memoizedState;B===null?r.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:v,tail:p,tailMode:E,treeForkCount:C}:(B.isBackwards=l,B.rendering=null,B.renderingStartTime=0,B.last=v,B.tail=p,B.tailMode=E,B.treeForkCount=C)}function vd(r,l,p){var v=l.pendingProps,E=v.revealOrder,C=v.tail;v=v.children;var B=oi.current,K=(B&2)!==0;if(K?(B=B&1|2,l.flags|=128):B&=1,T(oi,B),Xi(r,l,v,p),v=un?vc:0,!K&&r!==null&&(r.flags&128)!==0)e:for(r=l.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Ym(r,p,l);else if(r.tag===19)Ym(r,p,l);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===l)break e;for(;r.sibling===null;){if(r.return===null||r.return===l)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(E){case"forwards":for(p=l.child,E=null;p!==null;)r=p.alternate,r!==null&&it(r)===null&&(E=p),p=p.sibling;p=E,p===null?(E=l.child,l.child=null):(E=p.sibling,p.sibling=null),zl(l,!1,E,p,C,v);break;case"backwards":case"unstable_legacy-backwards":for(p=null,E=l.child,l.child=null;E!==null;){if(r=E.alternate,r!==null&&it(r)===null){l.child=E;break}r=E.sibling,E.sibling=p,p=E,E=r}zl(l,!0,p,null,C,v);break;case"together":zl(l,!1,null,null,void 0,v);break;default:l.memoizedState=null}return l.child}function qa(r,l,p){if(r!==null&&(l.dependencies=r.dependencies),Hr|=l.lanes,(p&l.childLanes)===0)if(r!==null){if(nt(r,l,p,!1),(p&l.childLanes)===0)return null}else return null;if(r!==null&&l.child!==r.child)throw Error(a(153));if(l.child!==null){for(r=l.child,p=ks(r,r.pendingProps),l.child=p,p.return=l;r.sibling!==null;)r=r.sibling,p=p.sibling=ks(r,r.pendingProps),p.return=l;p.sibling=null}return l.child}function Zu(r,l){return(r.lanes&l)!==0?!0:(r=r.dependencies,!!(r!==null&&Mt(r)))}function yd(r,l,p){switch(l.tag){case 3:st(l,l.stateNode.containerInfo),Ne(l,jn,r.memoizedState.cache),Dt();break;case 27:case 5:Ce(l);break;case 4:st(l,l.stateNode.containerInfo);break;case 10:Ne(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,de(l),null;break;case 13:var v=l.memoizedState;if(v!==null)return v.dehydrated!==null?(ge(l),l.flags|=128,null):(p&l.child.childLanes)!==0?gd(r,l,p):(ge(l),r=qa(r,l,p),r!==null?r.sibling:null);ge(l);break;case 19:var E=(r.flags&128)!==0;if(v=(p&l.childLanes)!==0,v||(nt(r,l,p,!1),v=(p&l.childLanes)!==0),E){if(v)return vd(r,l,p);l.flags|=128}if(E=l.memoizedState,E!==null&&(E.rendering=null,E.tail=null,E.lastEffect=null),T(oi,oi.current),v)break;return null;case 22:return l.lanes=0,Xm(r,l,p,l.pendingProps);case 24:Ne(l,jn,r.memoizedState.cache)}return qa(r,l,p)}function _d(r,l,p){if(r!==null)if(r.memoizedProps!==l.pendingProps)Xn=!0;else{if(!Zu(r,p)&&(l.flags&128)===0)return Xn=!1,yd(r,l,p);Xn=(r.flags&131072)!==0}else Xn=!1,un&&(l.flags&1048576)!==0&&X(l,vc,l.index);switch(l.lanes=0,l.tag){case 16:e:{var v=l.pendingProps;if(r=dn(l.elementType),l.type=r,typeof r=="function")Qo(r)?(v=Wo(r,v),l.tag=1,l=Yo(null,l,r,v,p)):(l.tag=0,l=gf(null,l,r,v,p));else{if(r!=null){var E=r.$$typeof;if(E===Ql){l.tag=11,l=km(null,l,r,v,p);break e}else if(E===If){l.tag=14,l=Hm(null,l,r,v,p);break e}}throw l=S(r)||r,Error(a(306,l,""))}}return l;case 0:return gf(r,l,l.type,l.pendingProps,p);case 1:return v=l.type,E=Wo(v,l.pendingProps),Yo(r,l,v,E,p);case 3:e:{if(st(l,l.stateNode.containerInfo),r===null)throw Error(a(387));var C=l.pendingProps;E=l.memoizedState,v=E.element,Da(r,l),Er(l,C,null,p);var B=l.memoizedState;if(C=B.cache,Ne(l,jn,C),C!==E.cache&&xt(l,[jn],p,!0),La(),C=B.element,Yn&&E.isDehydrated)if(E={element:C,isDehydrated:!1,cache:B.cache},l.updateQueue.baseState=E,l.memoizedState=E,l.flags&256){l=qm(r,l,C,p);break e}else if(C!==v){v=_e(Error(a(424)),l),Ve(v),l=qm(r,l,C,p);break e}else for(Yn&&(Zn=wg(l.stateNode.containerInfo),Ri=l,un=!0,or=null,ds=!0),p=mp(l,null,C,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Dt(),C===v){l=qa(r,l,p);break e}Xi(r,l,C,p)}l=l.child}return l;case 26:if(pa)return Yu(r,l),r===null?(p=sp(l.type,null,l.pendingProps,null))?l.memoizedState=p:un||(l.stateNode=Wf(l.type,l.pendingProps,qi.current,l)):l.memoizedState=sp(l.type,r.memoizedProps,l.pendingProps,r.memoizedState),null;case 27:if(Ci)return Ce(l),r===null&&Ci&&un&&(v=l.stateNode=qf(l.type,l.pendingProps,qi.current,Fi.current,!1),Ri=l,ds=!0,Zn=Kd(l.type,v,Zn)),Xi(r,l,l.pendingProps.children,p),Yu(r,l),r===null&&(l.flags|=4194304),l.child;case 5:return r===null&&un&&(kg(l.type,l.pendingProps,Fi.current),(E=v=Zn)&&(v=Dg(v,l.type,l.pendingProps,ds),v!==null?(l.stateNode=v,Ri=l,Zn=Ag(v),ds=!1,E=!0):E=!1),E||et(l)),Ce(l),E=l.type,C=l.pendingProps,B=r!==null?r.memoizedProps:null,v=C.children,hs(E,C)?v=null:B!==null&&hs(E,B)&&(l.flags|=32),l.memoizedState!==null&&(E=Ut(r,l,jt,null,null,p),hi?al._currentValue=E:al._currentValue2=E),Yu(r,l),Xi(r,l,v,p),l.child;case 6:return r===null&&un&&(ip(l.pendingProps,Fi.current),(r=p=Zn)&&(p=Ng(p,l.pendingProps,ds),p!==null?(l.stateNode=p,Ri=l,Zn=null,r=!0):r=!1),r||et(l)),null;case 13:return gd(r,l,p);case 4:return st(l,l.stateNode.containerInfo),v=l.pendingProps,r===null?l.child=Yi(l,null,v,p):Xi(r,l,v,p),l.child;case 11:return km(r,l,l.type,l.pendingProps,p);case 7:return Xi(r,l,l.pendingProps,p),l.child;case 8:return Xi(r,l,l.pendingProps.children,p),l.child;case 12:return Xi(r,l,l.pendingProps.children,p),l.child;case 10:return v=l.pendingProps,Ne(l,l.type,v.value),Xi(r,l,v.children,p),l.child;case 9:return E=l.type._context,v=l.pendingProps.children,We(l),E=G(E),v=v(E),l.flags|=1,Xi(r,l,v,p),l.child;case 14:return Hm(r,l,l.type,l.pendingProps,p);case 15:return Gm(r,l,l.type,l.pendingProps,p);case 19:return vd(r,l,p);case 31:return Wm(r,l,p);case 22:return Xm(r,l,p,l.pendingProps);case 24:return We(l),v=G(jn),r===null?(E=Xe(),E===null&&(E=en,C=be(),E.pooledCache=C,C.refCount++,C!==null&&(E.pooledCacheLanes|=p),E=C),l.memoizedState={parent:v,cache:E},ci(l),Ne(l,jn,E)):((r.lanes&p)!==0&&(Da(r,l),Er(l,null,null,p),La()),E=r.memoizedState,C=l.memoizedState,E.parent!==v?(E={parent:v,cache:v},l.memoizedState=E,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=E),Ne(l,jn,v)):(v=C.cache,Ne(l,jn,v),v!==E.cache&&xt(l,[jn],p,!0))),Xi(r,l,l.pendingProps.children,p),l.child;case 29:throw l.pendingProps}throw Error(a(156,l.tag))}function ra(r){r.flags|=4}function ju(r){Hs&&(r.flags|=8)}function Zm(r,l){if(r!==null&&r.child===l.child)return!1;if((l.flags&16)!==0)return!0;for(r=l.child;r!==null;){if((r.flags&8218)!==0||(r.subtreeFlags&8218)!==0)return!0;r=r.sibling}return!1}function xd(r,l,p,v){if(hn)for(p=l.child;p!==null;){if(p.tag===5||p.tag===6)uc(r,p.stateNode);else if(!(p.tag===4||Ci&&p.tag===27)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===l)break;for(;p.sibling===null;){if(p.return===null||p.return===l)return;p=p.return}p.sibling.return=p.return,p=p.sibling}else if(Hs)for(var E=l.child;E!==null;){if(E.tag===5){var C=E.stateNode;p&&v&&(C=bg(C,E.type,E.memoizedProps)),uc(r,C)}else if(E.tag===6)C=E.stateNode,p&&v&&(C=Qd(C,E.memoizedProps)),uc(r,C);else if(E.tag!==4){if(E.tag===22&&E.memoizedState!==null)C=E.child,C!==null&&(C.return=E),xd(r,E,!0,!0);else if(E.child!==null){E.child.return=E,E=E.child;continue}}if(E===l)break;for(;E.sibling===null;){if(E.return===null||E.return===l)return;E=E.return}E.sibling.return=E.return,E=E.sibling}}function jm(r,l,p,v){var E=!1;if(Hs)for(var C=l.child;C!==null;){if(C.tag===5){var B=C.stateNode;p&&v&&(B=bg(B,C.type,C.memoizedProps)),Zd(r,B)}else if(C.tag===6)B=C.stateNode,p&&v&&(B=Qd(B,C.memoizedProps)),Zd(r,B);else if(C.tag!==4){if(C.tag===22&&C.memoizedState!==null)E=C.child,E!==null&&(E.return=C),jm(r,C,!0,!0),E=!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 E;C=C.return}C.sibling.return=C.return,C=C.sibling}return E}function Qm(r,l){if(Hs&&Zm(r,l)){r=l.stateNode;var p=r.containerInfo,v=Yd();jm(v,l,!1,!1),r.pendingChildren=v,ra(l),Sg(p,v)}}function Sd(r,l,p,v){if(hn)r.memoizedProps!==v&&ra(l);else if(Hs){var E=r.stateNode,C=r.memoizedProps;if((r=Zm(r,l))||C!==v){var B=Fi.current;C=xg(E,p,C,v,!r,null),C===E?l.stateNode=E:(ju(l),Ms(C,p,v,B)&&ra(l),l.stateNode=C,r&&xd(C,l,!1,!1))}else l.stateNode=E}}function us(r,l,p,v,E){if((r.mode&32)!==0&&(p===null?cc(l,v):tu(l,p,v))){if(r.flags|=16777216,(E&335544128)===E||Pd(l,v))if($n(r.stateNode,l,v))r.flags|=8192;else if(fn())r.flags|=8192;else throw ps=lr,ih}else r.flags&=-16777217}function Bl(r,l){if(lp(l)){if(r.flags|=16777216,!up(l))if(fn())r.flags|=8192;else throw ps=lr,ih}else r.flags&=-16777217}function Qu(r,l){l!==null&&(r.flags|=4),r.flags&16384&&(l=r.tag!==22?I():536870912,r.lanes|=l,cu|=l)}function Fl(r,l){if(!un)switch(r.tailMode){case"hidden":l=r.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?r.tail=null:p.sibling=null;break;case"collapsed":p=r.tail;for(var v=null;p!==null;)p.alternate!==null&&(v=p),p=p.sibling;v===null?l||r.tail===null?r.tail=null:r.tail.sibling=null:v.sibling=null}}function Bn(r){var l=r.alternate!==null&&r.alternate.child===r.child,p=0,v=0;if(l)for(var E=r.child;E!==null;)p|=E.lanes|E.childLanes,v|=E.subtreeFlags&65011712,v|=E.flags&65011712,E.return=r,E=E.sibling;else for(E=r.child;E!==null;)p|=E.lanes|E.childLanes,v|=E.subtreeFlags,v|=E.flags,E.return=r,E=E.sibling;return r.subtreeFlags|=v,r.childLanes=p,l}function Jm(r,l,p){var v=l.pendingProps;switch(Ee(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Bn(l),null;case 1:return Bn(l),null;case 3:return p=l.stateNode,v=null,r!==null&&(v=r.memoizedState.cache),l.memoizedState.cache!==v&&(l.flags|=2048),Je(jn),ce(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(r===null||r.child===null)&&(on(l)?ra(l):r===null||r.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Re())),Qm(r,l),Bn(l),null;case 26:if(pa){var E=l.type,C=l.memoizedState;return r===null?(ra(l),C!==null?(Bn(l),Bl(l,C)):(Bn(l),us(l,E,null,v,p))):C?C!==r.memoizedState?(ra(l),Bn(l),Bl(l,C)):(Bn(l),l.flags&=-16777217):(C=r.memoizedProps,hn?C!==v&&ra(l):Sd(r,l,E,v),Bn(l),us(l,E,C,v,p)),null}case 27:if(Ci){if(Be(l),p=qi.current,E=l.type,r!==null&&l.stateNode!=null)hn?r.memoizedProps!==v&&ra(l):Sd(r,l,E,v);else{if(!v){if(l.stateNode===null)throw Error(a(166));return Bn(l),null}r=Fi.current,on(l)?yt(l,r):(r=qf(E,v,p,r,!0),l.stateNode=r,ra(l))}return Bn(l),null}case 5:if(Be(l),E=l.type,r!==null&&l.stateNode!=null)Sd(r,l,E,v);else{if(!v){if(l.stateNode===null)throw Error(a(166));return Bn(l),null}if(C=Fi.current,on(l))yt(l,C),Bg(l.stateNode,E,v,C)&&(l.flags|=64);else{var B=Id(E,v,qi.current,C,l);ju(l),xd(B,l,!1,!1),l.stateNode=B,Ms(B,E,v,C)&&ra(l)}}return Bn(l),us(l,l.type,r===null?null:r.memoizedProps,l.pendingProps,p),null;case 6:if(r&&l.stateNode!=null)p=r.memoizedProps,hn?p!==v&&ra(l):Hs&&(p!==v?(r=qi.current,p=Fi.current,ju(l),l.stateNode=Pr(v,r,p,l)):l.stateNode=r.stateNode);else{if(typeof v!="string"&&l.stateNode===null)throw Error(a(166));if(r=qi.current,p=Fi.current,on(l)){if(!Yn)throw Error(a(176));if(r=l.stateNode,p=l.memoizedProps,v=null,E=Ri,E!==null)switch(E.tag){case 27:case 5:v=E.memoizedProps}Ky(r,p,l,v)||et(l,!0)}else ju(l),l.stateNode=Pr(v,r,p,l)}return Bn(l),null;case 31:if(p=l.memoizedState,r===null||r.memoizedState!==null){if(v=on(l),p!==null){if(r===null){if(!v)throw Error(a(318));if(!Yn)throw Error(a(556));if(r=l.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(a(557));ep(r,l)}else Dt(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Bn(l),r=!1}else p=Re(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=p),r=!0;if(!r)return l.flags&256?(tt(l),l):(tt(l),null);if((l.flags&128)!==0)throw Error(a(558))}return Bn(l),null;case 13:if(v=l.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(E=on(l),v!==null&&v.dehydrated!==null){if(r===null){if(!E)throw Error(a(318));if(!Yn)throw Error(a(344));if(E=l.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(a(317));Ig(E,l)}else Dt(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Bn(l),E=!1}else E=Re(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=E),E=!0;if(!E)return l.flags&256?(tt(l),l):(tt(l),null)}return tt(l),(l.flags&128)!==0?(l.lanes=p,l):(p=v!==null,r=r!==null&&r.memoizedState!==null,p&&(v=l.child,E=null,v.alternate!==null&&v.alternate.memoizedState!==null&&v.alternate.memoizedState.cachePool!==null&&(E=v.alternate.memoizedState.cachePool.pool),C=null,v.memoizedState!==null&&v.memoizedState.cachePool!==null&&(C=v.memoizedState.cachePool.pool),C!==E&&(v.flags|=2048)),p!==r&&p&&(l.child.flags|=8192),Qu(l,l.updateQueue),Bn(l),null);case 4:return ce(),Qm(r,l),r===null&&Un(l.stateNode.containerInfo),Bn(l),null;case 10:return Je(l.type),Bn(l),null;case 19:if(M(oi),v=l.memoizedState,v===null)return Bn(l),null;if(E=(l.flags&128)!==0,C=v.rendering,C===null)if(E)Fl(v,!1);else{if(ni!==0||r!==null&&(r.flags&128)!==0)for(r=l.child;r!==null;){if(C=it(r),C!==null){for(l.flags|=128,Fl(v,!1),r=C.updateQueue,l.updateQueue=r,Qu(l,r),l.subtreeFlags=0,r=p,p=l.child;p!==null;)Rf(p,r),p=p.sibling;return T(oi,oi.current&1|2),un&&Ue(l,v.treeForkCount),l.child}r=r.sibling}v.tail!==null&&ts()>wo&&(l.flags|=128,E=!0,Fl(v,!1),l.lanes=4194304)}else{if(!E)if(r=it(C),r!==null){if(l.flags|=128,E=!0,r=r.updateQueue,l.updateQueue=r,Qu(l,r),Fl(v,!0),v.tail===null&&v.tailMode==="hidden"&&!C.alternate&&!un)return Bn(l),null}else 2*ts()-v.renderingStartTime>wo&&p!==536870912&&(l.flags|=128,E=!0,Fl(v,!1),l.lanes=4194304);v.isBackwards?(C.sibling=l.child,l.child=C):(r=v.last,r!==null?r.sibling=C:l.child=C,v.last=C)}return v.tail!==null?(r=v.tail,v.rendering=r,v.tail=r.sibling,v.renderingStartTime=ts(),r.sibling=null,p=oi.current,T(oi,E?p&1|2:p&1),un&&Ue(l,v.treeForkCount),r):(Bn(l),null);case 22:case 23:return tt(l),ie(),v=l.memoizedState!==null,r!==null?r.memoizedState!==null!==v&&(l.flags|=8192):v&&(l.flags|=8192),v?(p&536870912)!==0&&(l.flags&128)===0&&(Bn(l),l.subtreeFlags&6&&(l.flags|=8192)):Bn(l),p=l.updateQueue,p!==null&&Qu(l,p.retryQueue),p=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(p=r.memoizedState.cachePool.pool),v=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(v=l.memoizedState.cachePool.pool),v!==p&&(l.flags|=2048),r!==null&&M(_o),null;case 24:return p=null,r!==null&&(p=r.memoizedState.cache),l.memoizedState.cache!==p&&(l.flags|=2048),Je(jn),Bn(l),null;case 25:return null;case 30:return null}throw Error(a(156,l.tag))}function bd(r,l){switch(Ee(l),l.tag){case 1:return r=l.flags,r&65536?(l.flags=r&-65537|128,l):null;case 3:return Je(jn),ce(),r=l.flags,(r&65536)!==0&&(r&128)===0?(l.flags=r&-65537|128,l):null;case 26:case 27:case 5:return Be(l),null;case 31:if(l.memoizedState!==null){if(tt(l),l.alternate===null)throw Error(a(340));Dt()}return r=l.flags,r&65536?(l.flags=r&-65537|128,l):null;case 13:if(tt(l),r=l.memoizedState,r!==null&&r.dehydrated!==null){if(l.alternate===null)throw Error(a(340));Dt()}return r=l.flags,r&65536?(l.flags=r&-65537|128,l):null;case 19:return M(oi),null;case 4:return ce(),null;case 10:return Je(l.type),null;case 22:case 23:return tt(l),ie(),r!==null&&M(_o),r=l.flags,r&65536?(l.flags=r&-65537|128,l):null;case 24:return Je(jn),null;case 25:return null;default:return null}}function Km(r,l){switch(Ee(l),l.tag){case 3:Je(jn),ce();break;case 26:case 27:case 5:Be(l);break;case 4:ce();break;case 31:l.memoizedState!==null&&tt(l);break;case 13:tt(l);break;case 19:M(oi);break;case 10:Je(l.type);break;case 22:case 23:tt(l),ie(),r!==null&&M(_o);break;case 24:Je(jn)}}function Ya(r,l){try{var p=l.updateQueue,v=p!==null?p.lastEffect:null;if(v!==null){var E=v.next;p=E;do{if((p.tag&r)===r){v=void 0;var C=p.create,B=p.inst;v=C(),B.destroy=v}p=p.next}while(p!==E)}}catch(K){Pt(l,l.return,K)}}function Za(r,l,p){try{var v=l.updateQueue,E=v!==null?v.lastEffect:null;if(E!==null){var C=E.next;v=C;do{if((v.tag&r)===r){var B=v.inst,K=B.destroy;if(K!==void 0){B.destroy=void 0,E=l;var Se=p,Pe=K;try{Pe()}catch(Qe){Pt(E,Se,Qe)}}}v=v.next}while(v!==C)}}catch(Qe){Pt(l,l.return,Qe)}}function Vl(r){var l=r.updateQueue;if(l!==null){var p=r.stateNode;try{Ar(l,p)}catch(v){Pt(r,r.return,v)}}}function yf(r,l,p){p.props=Wo(r.type,r.memoizedProps),p.state=r.memoizedState;try{p.componentWillUnmount()}catch(v){Pt(r,l,v)}}function kl(r,l){try{var p=r.ref;if(p!==null){switch(r.tag){case 26:case 27:case 5:var v=Kl(r.stateNode);break;case 30:v=r.stateNode;break;default:v=r.stateNode}typeof p=="function"?r.refCleanup=p(v):p.current=v}}catch(E){Pt(r,l,E)}}function es(r,l){var p=r.ref,v=r.refCleanup;if(p!==null)if(typeof v=="function")try{v()}catch(E){Pt(r,l,E)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(E){Pt(r,l,E)}else p.current=null}function jo(r){var l=r.type,p=r.memoizedProps,v=r.stateNode;try{hg(v,l,p,r)}catch(E){Pt(r,r.return,E)}}function Ju(r,l,p){try{dg(r.stateNode,r.type,p,l,r)}catch(v){Pt(r,r.return,v)}}function Md(r){return r.tag===5||r.tag===3||(pa?r.tag===26:!1)||(Ci?r.tag===27&&rl(r.type):!1)||r.tag===4}function Cr(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Md(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(Ci&&r.tag===27&&rl(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function _f(r,l,p){var v=r.tag;if(v===5||v===6)r=r.stateNode,l?mg(p,r,l):Gd(p,r);else if(v!==4&&(Ci&&v===27&&rl(r.type)&&(p=r.stateNode,l=null),r=r.child,r!==null))for(_f(r,l,p),r=r.sibling;r!==null;)_f(r,l,p),r=r.sibling}function Ku(r,l,p){var v=r.tag;if(v===5||v===6)r=r.stateNode,l?pg(p,r,l):Hd(p,r);else if(v!==4&&(Ci&&v===27&&rl(r.type)&&(p=r.stateNode),r=r.child,r!==null))for(Ku(r,l,p),r=r.sibling;r!==null;)Ku(r,l,p),r=r.sibling}function Ed(r,l,p){r=r.containerInfo;try{jd(r,p)}catch(v){Pt(l,l.return,v)}}function $m(r){var l=r.stateNode,p=r.memoizedProps;try{Si(r.type,p,l,r)}catch(v){Pt(r,r.return,v)}}function Zy(r,l){for(Of(r.containerInfo),mi=l;mi!==null;)if(r=mi,l=r.child,(r.subtreeFlags&1028)!==0&&l!==null)l.return=r,mi=l;else for(;mi!==null;){r=mi;var p=r.alternate;switch(l=r.flags,r.tag){case 0:if((l&4)!==0&&(l=r.updateQueue,l=l!==null?l.events:null,l!==null))for(var v=0;v";case ou:return":has("+(Xl(r)||"")+")";case lu:return'[role="'+r.value+'"]';case Mo:return'"'+r.value+'"';case Sc:return'[data-testname="'+r.value+'"]';default:throw Error(a(365))}}function Wl(r,l){var p=[];r=[r,0];for(var v=0;vp?32:p;p=Ct.T;var E=da();try{ln(v),Ct.T=null,v=rh,rh=null;var C=Xr,B=hr;if(Mi=0,gl=Xr=null,hr=0,(an&6)!==0)throw Error(a(331));var K=an;if(an|=4,Mf(C.current),Sf(C,C.current,B,v),an=K,qe(0,!1),As&&typeof As.onPostCommitFiberRoot=="function")try{As.onPostCommitFiberRoot(ul,C)}catch{}return!0}finally{ln(E),Ct.T=p,Cf(r,l)}}function co(r,l,p){l=_e(p,l),l=fd(r.stateNode,l,2),r=Na(r,l,2),r!==null&&(z(r,2),rt(r))}function Pt(r,l,p){if(r.tag===3)co(r,r,p);else for(;l!==null;){if(l.tag===3){co(l,r,p);break}else if(l.tag===1){var v=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof v.componentDidCatch=="function"&&(Gr===null||!Gr.has(v))){r=_e(p,r),p=Fm(2),v=Na(l,p,2),v!==null&&(Vm(p,v,l,r),z(v,2),rt(v));break}}l=l.return}}function jl(r,l,p){var v=r.pingCache;if(v===null){v=r.pingCache=new Ys;var E=new Set;v.set(l,E)}else E=v.get(l),E===void 0&&(E=new Set,v.set(l,E));E.has(p)||(To=!0,E.add(p),r=sg.bind(null,r,l,p),l.then(r,r))}function sg(r,l,p){var v=r.pingCache;v!==null&&v.delete(l),r.pingedLanes|=r.suspendedLanes&p,r.warmLanes&=~p,en===r&&(cn&p)===p&&(ni===4||ni===3&&(cn&62914560)===cn&&300>ts()-Mc?(an&2)===0&&ri(r,0):uu|=p,cu===cn&&(cu=0)),rt(r)}function ag(r,l){l===0&&(l=I()),r=ia(r,l),r!==null&&(z(r,l),rt(r))}function jy(r){var l=r.memoizedState,p=0;l!==null&&(p=l.retryLane),ag(r,p)}function Qy(r,l){var p=0;switch(r.tag){case 31:case 13:var v=r.stateNode,E=r.memoizedState;E!==null&&(p=E.retryLane);break;case 19:v=r.stateNode;break;case 22:v=r.stateNode._retryCache;break;default:throw Error(a(314))}v!==null&&v.delete(l),ag(r,p)}function xi(r,l){return pc(r,l)}function wd(r,l,p,v){this.tag=r,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=v,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Qo(r){return r=r.prototype,!(!r||!r.isReactComponent)}function ks(r,l){var p=r.alternate;return p===null?(p=t(r.tag,l,r.key,r.mode),p.elementType=r.elementType,p.type=r.type,p.stateNode=r.stateNode,p.alternate=r,r.alternate=p):(p.pendingProps=l,p.type=r.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=r.flags&65011712,p.childLanes=r.childLanes,p.lanes=r.lanes,p.child=r.child,p.memoizedProps=r.memoizedProps,p.memoizedState=r.memoizedState,p.updateQueue=r.updateQueue,l=r.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=r.sibling,p.index=r.index,p.ref=r.ref,p.refCleanup=r.refCleanup,p}function Rf(r,l){r.flags&=65011714;var p=r.alternate;return p===null?(r.childLanes=0,r.lanes=l,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=p.childLanes,r.lanes=p.lanes,r.child=p.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=p.memoizedProps,r.memoizedState=p.memoizedState,r.updateQueue=p.updateQueue,r.type=p.type,l=p.dependencies,r.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),r}function Ur(r,l,p,v,E,C){var B=0;if(v=r,typeof r=="function")Qo(r)&&(B=1);else if(typeof r=="string")B=pa&&Ci?Xf(r,p,Fi.current)?26:cp(r)?27:5:pa?Xf(r,p,Fi.current)?26:5:Ci&&cp(r)?27:5;else e:switch(r){case oc:return r=t(31,p,l,E),r.elementType=oc,r.lanes=C,r;case el:return fa(p.children,E,C,l);case tl:B=8,E|=24;break;case nl:return r=t(12,p,l,E|2),r.elementType=nl,r.lanes=C,r;case Uf:return r=t(13,p,l,E),r.elementType=Uf,r.lanes=C,r;case Ir:return r=t(19,p,l,E),r.elementType=Ir,r.lanes=C,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case ha:B=10;break e;case rc:B=9;break e;case Ql:B=11;break e;case If:B=14;break e;case fs:B=16,v=null;break e}B=29,p=Error(a(130,r===null?"null":typeof r,"")),v=null}return l=t(B,p,l,E),l.elementType=r,l.type=v,l.lanes=C,l}function fa(r,l,p,v){return r=t(7,r,v,l),r.lanes=p,r}function Cd(r,l,p){return r=t(6,r,null,l),r.lanes=p,r}function Rd(r){var l=t(18,null,null,0);return l.stateNode=r,l}function Dd(r,l,p){return l=t(4,r.children!==null?r.children:[],r.key,l),l.lanes=p,l.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},l}function rg(r,l,p,v,E,C,B,K,Se){this.tag=1,this.containerInfo=r,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=Es,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=V(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=V(0),this.hiddenUpdates=V(null),this.identifierPrefix=v,this.onUncaughtError=E,this.onCaughtError=C,this.onRecoverableError=B,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Se,this.incompleteTransitions=new Map}function fo(r,l,p,v,E,C,B,K,Se,Pe,Qe,Ge){return r=new rg(r,l,p,B,Se,Pe,Qe,Ge,K),l=1,C===!0&&(l|=24),C=t(3,null,null,l),r.current=C,C.stateNode=r,l=be(),l.refCount++,r.pooledCache=l,l.refCount++,C.memoizedState={element:v,isDehydrated:p,cache:l},ci(C),r}function Df(r){return r?(r=sr,r):sr}function sc(r){var l=r._reactInternals;if(l===void 0)throw typeof r.render=="function"?Error(a(188)):(r=Object.keys(r).join(","),Error(a(268,r)));return r=d(l),r=r!==null?m(r):null,r===null?null:Kl(r.stateNode)}function Nd(r,l,p,v,E,C){E=Df(E),v.context===null?v.context=E:v.pendingContext=E,v=rs(l),v.payload={element:p},C=C===void 0?null:C,C!==null&&(v.callback=C),p=Na(r,v,l),p!==null&&(Kn(p,r,l),Kr(p,r,l))}function Jo(r,l){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var p=r.retryLane;r.retryLane=p!==0&&p=Pe&&C>=Ge&&E<=Qe&&B<=ht){r.splice(l,1);break}else if(v!==Pe||p.width!==Se.width||htB){if(!(C!==Ge||p.height!==Se.height||QeE)){Pe>v&&(Se.width+=Pe-v,Se.x=v),QeC&&(Se.height+=Ge-C,Se.y=C),htp&&(p=K)),K ")+` No matching component was found for: `)+r.join(" > ")}return null},Kt.getPublicRootInstance=function(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 27:case 5:return Kl(r.child.stateNode);default:return r.child.stateNode}},Kt.injectIntoDevTools=function(){var r={bundleType:0,version:Ud,rendererPackageName:lc,currentDispatcherRef:Ct,reconcilerVersion:"19.2.0"};if(Jl!==null&&(r.rendererConfig=Jl),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")r=!1;else{var l=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(l.isDisabled||!l.supportsFiber)r=!0;else{try{ul=l.inject(r),As=l}catch{}r=!!l.checkDCE}}return r},Kt.isAlreadyRendering=function(){return(an&6)!==0},Kt.observeVisibleRects=function(r,l,p,v){if(!wi)throw Error(a(363));r=Ss(r,l);var E=Ff(r,p,v).disconnect;return{disconnect:function(){E()}}},Kt.shouldError=function(){return null},Kt.shouldSuspend=function(){return!1},Kt.startHostTransition=function(r,l,p,v){if(r.tag!==5)throw Error(a(476));var E=Um(r).queue;Lm(r,E,l,sl,p===null?i:function(){var C=Um(r);return C.next===null&&(C=r.alternate.memoizedState),qu(r,C.next.queue,{},qn()),p(v)})},Kt.updateContainer=function(r,l,p,v){var E=l.current,C=qn();return Nd(E,C,r,l,p,v),C},Kt.updateContainerSync=function(r,l,p,v){return Nd(l.current,2,r,l,p,v),2},Kt},o.exports.default=o.exports,Object.defineProperty(o.exports,"__esModule",{value:!0})})(R1)),R1.exports}var N1;function cO(){return N1||(N1=1,C1.exports=uO()),C1.exports}var fO=cO();const hO=lO(fO);function dO(o){const e=hO(o);return e.injectIntoDevTools(),e}const kT=0,Zh={},pO=/^three(?=[A-Z])/,Xy=o=>`${o[0].toUpperCase()}${o.slice(1)}`;let mO=0;const gO=o=>typeof o=="function";function vO(o){if(gO(o)){const e=`${mO++}`;return Zh[e]=o,e}else Object.assign(Zh,o)}function HT(o,e){const t=Xy(o),i=Zh[t];if(o!=="primitive"&&!i)throw new Error(`R3F: ${t} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(o==="primitive"&&!e.object)throw new Error("R3F: Primitives without 'object' are invalid!");if(e.args!==void 0&&!Array.isArray(e.args))throw new Error("R3F: The args prop must be an array!")}function yO(o,e,t){var i;return o=Xy(o)in Zh?o:o.replace(pO,""),HT(o,e),o==="primitive"&&(i=e.object)!=null&&i.__r3f&&delete e.object.__r3f,ny(e.object,t,o,e)}function _O(o){if(!o.isHidden){var e;o.props.attach&&(e=o.parent)!=null&&e.object?sy(o.parent,o):Aa(o.object)&&(o.object.visible=!1),o.isHidden=!0,nd(o)}}function GT(o){if(o.isHidden){var e;o.props.attach&&(e=o.parent)!=null&&e.object?iy(o.parent,o):Aa(o.object)&&o.props.visible!==!1&&(o.object.visible=!0),o.isHidden=!1,nd(o)}}function QS(o,e,t){const i=e.root.getState();if(!(!o.parent&&o.object!==i.scene)){if(!e.object){var a,u;const f=Zh[Xy(e.type)];e.object=(a=e.props.object)!=null?a:new f(...(u=e.props.args)!=null?u:[]),e.object.__r3f=e}if(Cu(e.object,e.props),e.props.attach)iy(o,e);else if(Aa(e.object)&&Aa(o.object)){const f=o.object.children.indexOf(t?.object);if(t&&f!==-1){const d=o.object.children.indexOf(e.object);if(d!==-1){o.object.children.splice(d,1);const m=d{try{o.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT<"u"?e():jx.unstable_scheduleCallback(jx.unstable_IdlePriority,e)}}function Jx(o,e,t){if(!e)return;e.parent=null;const i=o.children.indexOf(e);i!==-1&&o.children.splice(i,1),e.props.attach?sy(o,e):Aa(e.object)&&Aa(o.object)&&(o.object.remove(e.object),$I(PT(e),e.object));const a=e.props.dispose!==null&&t!==!1;for(let u=e.children.length-1;u>=0;u--){const f=e.children[u];Jx(e,f,a)}e.children.length=0,delete e.object.__r3f,a&&e.type!=="primitive"&&e.object.type!=="Scene"&&XT(e.object),t===void 0&&nd(e)}function xO(o,e){for(const t of[o,o.alternate])if(t!==null)if(typeof t.ref=="function"){t.refCleanup==null||t.refCleanup();const i=t.ref(e);typeof i=="function"&&(t.refCleanup=i)}else t.ref&&(t.ref.current=e)}const uv=[];function SO(){for(const[t]of uv){const i=t.parent;if(i){t.props.attach?sy(i,t):Aa(t.object)&&Aa(i.object)&&i.object.remove(t.object);for(const a of t.children)a.props.attach?sy(t,a):Aa(a.object)&&Aa(t.object)&&t.object.remove(a.object)}t.isHidden&>(t),t.object.__r3f&&delete t.object.__r3f,t.type!=="primitive"&&XT(t.object)}for(const[t,i,a]of uv){t.props=i;const u=t.parent;if(u){var o,e;const f=Zh[Xy(t.type)];t.object=(o=t.props.object)!=null?o:new f(...(e=t.props.args)!=null?e:[]),t.object.__r3f=t,xO(a,t.object),Cu(t.object,t.props),t.props.attach?iy(u,t):Aa(t.object)&&Aa(u.object)&&u.object.add(t.object);for(const d of t.children)d.props.attach?iy(t,d):Aa(d.object)&&Aa(t.object)&&t.object.add(d.object);nd(t)}}uv.length=0}const Tx=()=>{},U1={};let av=kT;const bO=0,MO=4,Kx=dO({isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:yO,removeChild:Jx,appendChild:Ex,appendInitialChild:Ex,insertBefore:L1,appendChildToContainer(o,e){const t=o.getState().scene.__r3f;!e||!t||Ex(t,e)},removeChildFromContainer(o,e){const t=o.getState().scene.__r3f;!e||!t||Jx(t,e)},insertInContainerBefore(o,e,t){const i=o.getState().scene.__r3f;!e||!t||!i||L1(i,e,t)},getRootHostContext:()=>U1,getChildHostContext:()=>U1,commitUpdate(o,e,t,i,a){var u,f,d;HT(e,i);let m=!1;if((o.type==="primitive"&&t.object!==i.object||((u=i.args)==null?void 0:u.length)!==((f=t.args)==null?void 0:f.length)||(d=i.args)!=null&&d.some((_,S)=>{var x;return _!==((x=t.args)==null?void 0:x[S])}))&&(m=!0),m)uv.push([o,{...i},a]);else{const _=jI(o,i);Object.keys(_).length&&(Object.assign(o.props,_),Cu(o.object,_))}(a.sibling===null||(a.flags&MO)===bO)&&SO()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:o=>o?.object,prepareForCommit:()=>null,preparePortalMount:o=>ny(o.getState().scene,o,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:_O,unhideInstance:GT,createTextInstance:Tx,hideTextInstance:Tx,unhideTextInstance:Tx,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:Vt.createContext(null),setCurrentUpdatePriority(o){av=o},getCurrentUpdatePriority(){return av},resolveUpdatePriority(){var o;if(av!==kT)return av;switch(typeof window<"u"&&((o=window.event)==null?void 0:o.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return rO;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return sO;default:return aO}},resetFormInstance(){},rendererPackageName:"@react-three/fiber",rendererVersion:oO.version,applyViewTransitionName(o,e,t){},restoreViewTransitionName(o,e){},cancelViewTransitionName(o,e,t){},cancelRootViewTransitionName(o){},restoreRootViewTransitionName(o){},InstanceMeasurement:null,measureInstance:o=>null,wasInstanceInViewport:o=>!0,hasInstanceChanged:(o,e)=>!1,hasInstanceAffectedParent:(o,e)=>!1,suspendOnActiveViewTransition(o,e){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(o){},createViewTransitionInstance:o=>null,getCurrentGestureOffset(o){throw new Error("startGestureTransition is not yet supported in react-three-fiber.")},cloneMutableInstance(o,e){return o},cloneMutableTextInstance(o){return o},cloneRootViewTransitionContainer(o){throw new Error("Not implemented.")},removeRootViewTransitionClone(o,e){throw new Error("Not implemented.")},createFragmentInstance:o=>null,updateFragmentInstanceFiber(o,e){},commitNewChildToFragmentInstance(o,e){},deleteChildFromFragmentInstance(o,e){},measureClonedInstance:o=>null,maySuspendCommitOnUpdate:(o,e,t)=>!1,maySuspendCommitInSyncRender:(o,e)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(o,e)=>null}),ef=new Map,Uh={objects:"shallow",strict:!1};function EO(o,e){if(!e&&typeof HTMLCanvasElement<"u"&&o instanceof HTMLCanvasElement&&o.parentElement){const{width:t,height:i,top:a,left:u}=o.parentElement.getBoundingClientRect();return{width:t,height:i,top:a,left:u}}else if(!e&&typeof OffscreenCanvas<"u"&&o instanceof OffscreenCanvas)return{width:o.width,height:o.height,top:0,left:0};return{width:0,height:0,top:0,left:0,...e}}function TO(o){const e=ef.get(o),t=e?.fiber,i=e?.store;e&&console.warn("R3F.createRoot should only be called once!");const a=typeof reportError=="function"?reportError:console.error,u=i||nO(tS,O1),f=t||Kx.createContainer(u,iO,null,!1,null,"",a,a,a,null);e||ef.set(o,{fiber:f,store:u});let d,m,g=!1,_=null;return{async configure(S={}){let x;_=new Promise(X=>x=X);let{gl:M,size:T,scene:D,events:w,onCreated:A,shadows:R=!1,linear:L=!1,flat:I=!1,legacy:V=!1,orthographic:z=!1,frameloop:H="always",dpr:U=[1,2],performance:P,raycaster:Q,camera:W,onPointerMissed:te}=S,$=u.getState(),ue=$.gl;if(!$.gl){const X={canvas:o,powerPreference:"high-performance",antialias:!0,alpha:!0},ee=typeof M=="function"?await M(X):M;w1(ee)?ue=ee:ue=new LT({...X,...M}),$.set({gl:ue})}let se=$.raycaster;se||$.set({raycaster:se=new MT});const{params:q,...j}=Q||{};if(yi.equ(j,se,Uh)||Cu(se,{...j}),yi.equ(q,se.params,Uh)||Cu(se,{params:{...se.params,...q}}),!$.camera||$.camera===m&&!yi.equ(m,W,Uh)){m=W;const X=W?.isCamera,ee=X?W:z?new ed(0,0,0,0,.1,1e3):new as(75,0,.1,1e3);X||(ee.position.z=5,W&&(Cu(ee,W),ee.manual||("aspect"in W||"left"in W||"right"in W||"bottom"in W||"top"in W)&&(ee.manual=!0,ee.updateProjectionMatrix())),!$.camera&&!(W!=null&&W.rotation)&&ee.lookAt(0,0,0)),$.set({camera:ee}),se.camera=ee}if(!$.scene){let X;D!=null&&D.isScene?(X=D,ny(X,u,"",{})):(X=new _S,ny(X,u,"",{}),D&&Cu(X,D)),$.set({scene:X})}w&&!$.events.handlers&&$.set({events:w(u)});const ye=EO(o,T);if(yi.equ(ye,$.size,Uh)||$.setSize(ye.width,ye.height,ye.top,ye.left),U&&$.viewport.dpr!==BT(U)&&$.setDpr(U),$.frameloop!==H&&$.setFrameloop(H),$.onPointerMissed||$.set({onPointerMissed:te}),P&&!yi.equ(P,$.performance,Uh)&&$.set(X=>({performance:{...X.performance,...P}})),!$.xr){var _e;const X=(Oe,st)=>{const ce=u.getState();ce.frameloop!=="never"&&O1(Oe,!0,ce,st)},ee=()=>{const Oe=u.getState();Oe.gl.xr.enabled=Oe.gl.xr.isPresenting,Oe.gl.xr.setAnimationLoop(Oe.gl.xr.isPresenting?X:null),Oe.gl.xr.isPresenting||tS(Oe)},Ee={connect(){const Oe=u.getState().gl;Oe.xr.addEventListener("sessionstart",ee),Oe.xr.addEventListener("sessionend",ee)},disconnect(){const Oe=u.getState().gl;Oe.xr.removeEventListener("sessionstart",ee),Oe.xr.removeEventListener("sessionend",ee)}};typeof((_e=ue.xr)==null?void 0:_e.addEventListener)=="function"&&Ee.connect(),$.set({xr:Ee})}if(ue.shadowMap){const X=ue.shadowMap.enabled,ee=ue.shadowMap.type;if(ue.shadowMap.enabled=!!R,yi.boo(R))ue.shadowMap.type=Wp;else if(yi.str(R)){var Ue;const Ee={basic:k1,percentage:Bh,soft:Wp,variance:Hc};ue.shadowMap.type=(Ue=Ee[R])!=null?Ue:Wp}else yi.obj(R)&&Object.assign(ue.shadowMap,R);(X!==ue.shadowMap.enabled||ee!==ue.shadowMap.type)&&(ue.shadowMap.needsUpdate=!0)}return xn.enabled=!V,g||(ue.outputColorSpace=L?Uu:Is,ue.toneMapping=I?gr:oy),$.legacy!==V&&$.set(()=>({legacy:V})),$.linear!==L&&$.set(()=>({linear:L})),$.flat!==I&&$.set(()=>({flat:I})),M&&!yi.fun(M)&&!w1(M)&&!yi.equ(M,ue,Uh)&&Cu(ue,M),d=A,g=!0,x(),this},render(S){return!g&&!_&&this.configure(),_.then(()=>{Kx.updateContainer(Mn.jsx(AO,{store:u,children:S,onCreated:d,rootElement:o}),f,null,()=>{})}),u},unmount(){WT(o)}}}function AO({store:o,children:e,onCreated:t,rootElement:i}){return Gy(()=>{const a=o.getState();a.set(u=>({internal:{...u.internal,active:!0}})),t&&t(a),o.getState().events.connected||a.events.connect==null||a.events.connect(i)},[]),Mn.jsx(tO.Provider,{value:o,children:e})}function WT(o,e){const t=ef.get(o),i=t?.fiber;if(i){const a=t?.store.getState();a&&(a.internal.active=!1),Kx.updateContainer(null,i,null,()=>{a&&setTimeout(()=>{try{var u,f,d,m;a.events.disconnect==null||a.events.disconnect(),(u=a.gl)==null||(f=u.renderLists)==null||f.dispose==null||f.dispose(),(d=a.gl)==null||d.forceContextLoss==null||d.forceContextLoss(),(m=a.gl)!=null&&m.xr&&a.xr.disconnect(),qI(a.scene),ef.delete(o)}catch{}},500)})}}const wO=new Set,CO=new Set,RO=new Set;function Ax(o,e){if(o.size)for(const{callback:t}of o.values())t(e)}function nm(o,e){switch(o){case"before":return Ax(wO,e);case"after":return Ax(CO,e);case"tail":return Ax(RO,e)}}let wx,Cx;function $x(o,e,t){let i=e.clock.getDelta();e.frameloop==="never"&&typeof o=="number"&&(i=o-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=o),wx=e.internal.subscribers;for(let a=0;a0)&&!((e=Ih.gl.xr)!=null&&e.isPresenting)&&(Rx+=$x(o,Ih))}if(eS=!1,nm("after",o),Rx===0)return nm("tail",o),ay=!1,cancelAnimationFrame(I1)}function tS(o,e=1){var t;if(!o)return ef.forEach(i=>tS(i.store.getState(),e));(t=o.gl.xr)!=null&&t.isPresenting||!o.internal.active||o.frameloop==="never"||(e>1?o.internal.frames=Math.min(60,o.internal.frames+e):eS?o.internal.frames=2:o.internal.frames=1,ay||(ay=!0,requestAnimationFrame(qT)))}function O1(o,e=!0,t,i){if(e&&nm("before",o),t)$x(o,t,i);else for(const a of ef.values())$x(o,a.store.getState());e&&nm("after",o)}const Dx={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 DO(o){const{handlePointer:e}=eO(o);return{priority:1,enabled:!0,compute(t,i,a){i.pointer.set(t.offsetX/i.size.width*2-1,-(t.offsetY/i.size.height)*2+1),i.raycaster.setFromCamera(i.pointer,i.camera)},connected:void 0,handlers:Object.keys(Dx).reduce((t,i)=>({...t,[i]:e(i)}),{}),update:()=>{var t;const{events:i,internal:a}=o.getState();(t=a.lastEvent)!=null&&t.current&&i.handlers&&i.handlers.onPointerMove(a.lastEvent.current)},connect:t=>{const{set:i,events:a}=o.getState();if(a.disconnect==null||a.disconnect(),i(u=>({events:{...u.events,connected:t}})),a.handlers)for(const u in a.handlers){const f=a.handlers[u],[d,m]=Dx[u];t.addEventListener(d,f,{passive:m})}},disconnect:()=>{const{set:t,events:i}=o.getState();if(i.connected){if(i.handlers)for(const a in i.handlers){const u=i.handlers[a],[f]=Dx[a];i.connected.removeEventListener(f,u)}t(a=>({events:{...a.events,connected:void 0}}))}}}}function P1(o,e){let t;return(...i)=>{window.clearTimeout(t),t=window.setTimeout(()=>o(...i),e)}}function NO({debounce:o,scroll:e,polyfill:t,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){const a=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!a)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]=Vt.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),d=Vt.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:u,orientationHandler:null}),m=o?typeof o=="number"?o:o.scroll:null,g=o?typeof o=="number"?o:o.resize:null,_=Vt.useRef(!1);Vt.useEffect(()=>(_.current=!0,()=>{_.current=!1}));const[S,x,M]=Vt.useMemo(()=>{const A=()=>{if(!d.current.element)return;const{left:R,top:L,width:I,height:V,bottom:z,right:H,x:U,y:P}=d.current.element.getBoundingClientRect(),Q={left:R,top:L,width:I,height:V,bottom:z,right:H,x:U,y:P};d.current.element instanceof HTMLElement&&i&&(Q.height=d.current.element.offsetHeight,Q.width=d.current.element.offsetWidth),Object.freeze(Q),_.current&&!OO(d.current.lastBounds,Q)&&f(d.current.lastBounds=Q)};return[A,g?P1(A,g):A,m?P1(A,m):A]},[f,i,m,g]);function T(){d.current.scrollContainers&&(d.current.scrollContainers.forEach(A=>A.removeEventListener("scroll",M,!0)),d.current.scrollContainers=null),d.current.resizeObserver&&(d.current.resizeObserver.disconnect(),d.current.resizeObserver=null),d.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",d.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",d.current.orientationHandler))}function D(){d.current.element&&(d.current.resizeObserver=new a(M),d.current.resizeObserver.observe(d.current.element),e&&d.current.scrollContainers&&d.current.scrollContainers.forEach(A=>A.addEventListener("scroll",M,{capture:!0,passive:!0})),d.current.orientationHandler=()=>{M()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",d.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",d.current.orientationHandler))}const w=A=>{!A||A===d.current.element||(T(),d.current.element=A,d.current.scrollContainers=YT(A),D())};return UO(M,!!e),LO(x),Vt.useEffect(()=>{T(),D()},[e,M,x]),Vt.useEffect(()=>T,[]),[w,u,S]}function LO(o){Vt.useEffect(()=>{const e=o;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[o])}function UO(o,e){Vt.useEffect(()=>{if(e){const t=o;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>{window.removeEventListener("scroll",t,!0)}}},[o,e])}function YT(o){const e=[];if(!o||o===document.body)return e;const{overflow:t,overflowX:i,overflowY:a}=window.getComputedStyle(o);return[t,i,a].some(u=>u==="auto"||u==="scroll")&&e.push(o),[...e,...YT(o.parentElement)]}const IO=["x","y","top","bottom","left","right","width","height"],OO=(o,e)=>IO.every(t=>o[t]===e[t]);function PO({ref:o,children:e,fallback:t,resize:i,style:a,gl:u,events:f=DO,eventSource:d,eventPrefix:m,shadows:g,linear:_,flat:S,legacy:x,orthographic:M,frameloop:T,dpr:D,performance:w,raycaster:A,camera:R,scene:L,onPointerMissed:I,onCreated:V,...z}){Vt.useMemo(()=>vO(MI),[]);const H=GI(),[U,P]=NO({scroll:!0,debounce:{scroll:50,resize:0},...i}),Q=Vt.useRef(null),W=Vt.useRef(null);Vt.useImperativeHandle(o,()=>Q.current);const te=HI(I),[$,ue]=Vt.useState(!1),[se,q]=Vt.useState(!1);if($)throw $;if(se)throw se;const j=Vt.useRef(null);Gy(()=>{const _e=Q.current;if(P.width>0&&P.height>0&&_e){j.current||(j.current=TO(_e));async function Ue(){await j.current.configure({gl:u,scene:L,events:f,shadows:g,linear:_,flat:S,legacy:x,orthographic:M,frameloop:T,dpr:D,performance:w,raycaster:A,camera:R,size:P,onPointerMissed:(...X)=>te.current==null?void 0:te.current(...X),onCreated:X=>{X.events.connect==null||X.events.connect(d?VI(d)?d.current:d:W.current),m&&X.setEvents({compute:(ee,Ee)=>{const Oe=ee[m+"X"],st=ee[m+"Y"];Ee.pointer.set(Oe/Ee.size.width*2-1,-(st/Ee.size.height)*2+1),Ee.raycaster.setFromCamera(Ee.pointer,Ee.camera)}}),V?.(X)}}),j.current.render(Mn.jsx(H,{children:Mn.jsx(WI,{set:q,children:Mn.jsx(Vt.Suspense,{fallback:Mn.jsx(XI,{set:ue}),children:e??null})})}))}Ue()}}),Vt.useEffect(()=>{const _e=Q.current;if(_e)return()=>WT(_e)},[]);const ye=d?"none":"auto";return Mn.jsx("div",{ref:W,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:ye,...a},...z,children:Mn.jsx("div",{ref:U,style:{width:"100%",height:"100%"},children:Mn.jsx("canvas",{ref:Q,style:{display:"block"},children:t})})})}function zO(o){return Mn.jsx(IT,{children:Mn.jsx(PO,{...o})})}function BO({rotation:o,scale:e}){return Mn.jsxs("mesh",{rotation:o,scale:e,children:[Mn.jsx("boxGeometry",{args:[1,1,1]}),Mn.jsx("meshStandardMaterial",{attach:"material-0",color:"#795548"}),Mn.jsx("meshStandardMaterial",{attach:"material-1",color:"#795548"}),Mn.jsx("meshStandardMaterial",{attach:"material-2",color:"#55aa55"}),Mn.jsx("meshStandardMaterial",{attach:"material-3",color:"#5d4037"}),Mn.jsx("meshStandardMaterial",{attach:"material-4",color:"#795548"}),Mn.jsx("meshStandardMaterial",{attach:"material-5",color:"#795548"})]})}function FO(){const o=Vt.useRef(null),[e,t]=Vt.useState([.4,.4,0]),[i,a]=Vt.useState(1.2),[u,f]=Vt.useState(!1);return Vt.useEffect(()=>{if(!window.Hands||!window.Camera){console.error("MediaPipe Scripts not found!");return}const d=new window.Hands({locateFile:m=>`https://cdn.jsdelivr.net/npm/@mediapipe/hands/${m}`});d.setOptions({maxNumHands:2,modelComplexity:1,minDetectionConfidence:.5,minTrackingConfidence:.5}),d.onResults(m=>{m.multiHandLandmarks&&m.multiHandLandmarks.length>0?(f(!0),m.multiHandLandmarks.forEach((g,_)=>{if(m.multiHandedness[_].label==="Right")t([g[0].y*5,-g[0].x*5,0]);else{const x=Math.hypot(g[4].x-g[8].x,g[4].y-g[8].y);a(Math.max(.3,x*8))}})):f(!1)}),o.current&&new window.Camera(o.current,{onFrame:async()=>{o.current&&await d.send({image:o.current})},width:640,height:480}).start()},[]),Mn.jsxs("div",{style:{width:"100vw",height:"100vh",background:"#111",position:"relative",overflow:"hidden"},children:[Mn.jsxs("div",{style:{position:"absolute",top:0,width:"100%",padding:"20px",zIndex:10,color:"white",pointerEvents:"none"},children:[Mn.jsx("h1",{style:{margin:0,fontSize:"24px"},children:"4. Floating Minecraft Grass Block"}),Mn.jsx("p",{style:{color:u?"#4caf50":"#ff9800",fontWeight:"bold"},children:u?"● AI ACTIVE - Show Hands":"○ SEARCHING FOR HANDS..."})]}),Mn.jsxs("div",{style:{width:"100%",height:"100%",position:"relative"},children:[Mn.jsx("video",{ref:o,style:{position:"absolute",width:"100%",height:"100%",objectFit:"cover",transform:"scaleX(-1)",opacity:.5}}),Mn.jsxs(zO,{camera:{position:[0,0,3]},alpha:!0,children:[Mn.jsx("ambientLight",{intensity:2}),Mn.jsx("pointLight",{position:[10,10,10]}),Mn.jsx(BO,{rotation:e,scale:i})]})]}),Mn.jsx("div",{style:{position:"absolute",bottom:20,width:"100%",textAlign:"center",color:"white",pointerEvents:"none"},children:Mn.jsx("p",{children:"Right Hand: Rotate | Left Hand: Pinch Scale"})})]})}PA.createRoot(document.getElementById("root")).render(Mn.jsx(Vt.StrictMode,{children:Mn.jsx(FO,{})}));