var CF=Object.create;var _g=Object.defineProperty;var PF=Object.getOwnPropertyDescriptor;var _F=Object.getOwnPropertyNames;var IF=Object.getPrototypeOf,DF=Object.prototype.hasOwnProperty;var OF=(n,t,e)=>t in n?_g(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var ea=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),RF=(n,t)=>{for(var e in t)_g(n,e,{get:t[e],enumerable:!0})},LF=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of _F(t))!DF.call(n,i)&&i!==e&&_g(n,i,{get:()=>t[i],enumerable:!(r=PF(t,i))||r.enumerable});return n};var ta=(n,t,e)=>(e=n!=null?CF(IF(n)):{},LF(t||!n||!n.__esModule?_g(e,"default",{value:n,enumerable:!0}):e,n));var uo=(n,t,e)=>(OF(n,typeof t!="symbol"?t+"":t,e),e);var iO=ea((g1,rO)=>{(function(n,t){typeof g1=="object"?rO.exports=t():typeof define=="function"&&define.amd?define(t):n.Alea=t()})(g1,function(){"use strict";return n.importState=function(e){var r=new n;return r.importState(e),r},n;function n(){return function(e){var r=0,i=0,s=0,o=1;e.length==0&&(e=[+new Date]);var a=t();r=a(" "),i=a(" "),s=a(" ");for(var l=0;l>>0,o-=e,o*=e,e=o>>>0,o-=e,e+=o*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var v1=ea((T0,aO)=>{(function(n,t){typeof T0=="object"&&typeof aO<"u"?t(T0):typeof define=="function"&&define.amd?define(["exports"],t):t((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(T0,function(n){"use strict";n.SVD=function(t,e,r,i,s){if(e=e===void 0||e,r=r===void 0||r,s=1e-64/(i=i||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var o,a,l,c,u,h,d,f,p,m,g,y,v=t[0].length,x=t.length;if(x{(function(n,t){typeof N1=="object"&&typeof F1<"u"?F1.exports=t():typeof define=="function"&&define.amd?define(t):(n=n||self,n.TinyQueue=t())})(N1,function(){"use strict";var n=function(r,i){if(r===void 0&&(r=[]),i===void 0&&(i=t),this.data=r,this.length=this.data.length,this.compare=i,this.length>0)for(var s=(this.length>>1)-1;s>=0;s--)this._down(s)};n.prototype.push=function(r){this.data.push(r),this.length++,this._up(this.length-1)},n.prototype.pop=function(){if(this.length!==0){var r=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),r}},n.prototype.peek=function(){return this.data[0]},n.prototype._up=function(r){for(var i=this,s=i.data,o=i.compare,a=s[r];r>0;){var l=r-1>>1,c=s[l];if(o(a,c)>=0)break;s[r]=c,r=l}s[r]=a},n.prototype._down=function(r){for(var i=this,s=i.data,o=i.compare,a=this.length>>1,l=s[r];r=0)break;s[r]=u,r=c}s[r]=l};function t(e,r){return er?1:0}return n})});var NO=ea((Zye,V1)=>{"use strict";var D0=LO();D0.default&&(D0=D0.default);V1.exports=BO;V1.exports.default=BO;function BO(n,t,e){t=t||1;for(var r,i,s,o,a=0;as)&&(s=l[0]),(!a||l[1]>o)&&(o=l[1])}var c=s-r,u=o-i,h=Math.min(c,u),d=h/2;if(h===0){var f=[r,i];return f.distance=0,f}for(var p=new D0(void 0,eY),m=r;my.d&&(y=v);for(var x=p.length;p.length;){var S=p.pop();S.d>y.d&&(y=S,e&&console.log("found best %d after %d probes",Math.round(1e4*S.d)/1e4,x)),!(S.max-y.d<=t)&&(d=S.h/2,p.push(new Fl(S.x-d,S.y-d,d,n)),p.push(new Fl(S.x+d,S.y-d,d,n)),p.push(new Fl(S.x-d,S.y+d,d,n)),p.push(new Fl(S.x+d,S.y+d,d,n)),x+=4)}e&&(console.log("num probes: "+x),console.log("best distance: "+y.d));var w=[y.x,y.y];return w.distance=y.d,w}function eY(n,t){return t.max-n.max}function Fl(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=tY(n,t,r),this.max=this.d+this.h*Math.SQRT2}function tY(n,t,e){for(var r=!1,i=1/0,s=0;st!=h[1]>t&&n<(h[0]-u[0])*(t-u[1])/(h[1]-u[1])+u[0]&&(r=!r),i=Math.min(i,iY(n,t,u,h))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function rY(n){for(var t=0,e=0,r=0,i=n[0],s=0,o=i.length,a=o-1;s1?(i=r[0],s=r[1]):l>0&&(i+=o*l,s+=a*l)}return o=n-i,a=t-s,o*o+a*a}});var FR=ea((ix,NR)=>{"use strict";Object.defineProperty(ix,"__esModule",{value:!0});ix.default=pX;function pX(n){if(n===null||n===!0||n===!1)return NaN;var t=Number(n);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}NR.exports=ix.default});var kR=ea((nx,VR)=>{"use strict";Object.defineProperty(nx,"__esModule",{value:!0});nx.default=mX;function mX(n){var t=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()));return t.setUTCFullYear(n.getFullYear()),n.getTime()-t.getTime()}VR.exports=nx.default});var UL=ea((NFe,kL)=>{"use strict";function mZ(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function nu(n,t,e,r){this.message=n,this.expected=t,this.found=e,this.location=r,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,nu)}mZ(nu,Error);nu.buildMessage=function(n,t){var e={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var u="",h;for(h=0;h0){for(h=1,d=1;hae&&(ae=F,ge=[]),ge.push(O))}function ye(O,R){return new nu(O,null,null,R)}function Me(O,R,X){return new nu(nu.buildMessage(O,R),O,R,X)}function je(){var O,R,X,U,ee;for(O=F,R=[],X=Et();X!==e;)R.push(X),X=Et();if(R!==e)if(X=He(),X===e&&(X=null),X!==e){for(U=[],ee=Et();ee!==e;)U.push(ee),ee=Et();U!==e?(N=O,R=s(X),O=R):(F=O,O=e)}else F=O,O=e;else F=O,O=e;return O}function He(){var O,R,X,U,ee,Pe;if(O=F,R=_t(),R!==e){for(X=[],U=F,ee=[],Pe=Et();Pe!==e;)ee.push(Pe),Pe=Et();for(ee!==e?(Pe=_t(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);U!==e;){for(X.push(U),U=F,ee=[],Pe=Et();Pe!==e;)ee.push(Pe),Pe=Et();ee!==e?(Pe=_t(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e)}X!==e?(N=O,R=o(R,X),O=R):(F=O,O=e)}else F=O,O=e;return O}function _t(){var O,R,X,U,ee,Pe;if(O=F,R=Vr(),R!==e){for(X=[],U=F,ee=[],Pe=Et();Pe!==e;)ee.push(Pe),Pe=Et();for(ee!==e?(Pe=Fr(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);U!==e;){for(X.push(U),U=F,ee=[],Pe=Et();Pe!==e;)ee.push(Pe),Pe=Et();ee!==e?(Pe=Fr(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e)}X!==e?(N=O,R=o(R,X),O=R):(F=O,O=e)}else F=O,O=e;return O}function Fr(){var O;return O=$o(),O===e&&(O=Mr(),O===e&&(O=Mn(),O===e&&(O=dS(),O===e&&(O=fS(),O===e&&(O=ce(),O===e&&(O=be(),O===e&&(O=At(),O===e&&(O=jt())))))))),O}function Vr(){var O,R,X,U,ee,Pe,mu;if(O=F,a.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(l)),R!==e){for(X=[],U=Et();U!==e;)X.push(U),U=Et();X!==e?(U=Ft(),U!==e?(ee=F,Pe=gt(),Pe===e&&(Pe=null),Pe!==e?(mu=es(),mu!==e?(Pe=[Pe,mu],ee=Pe):(F=ee,ee=e)):(F=ee,ee=e),ee===e&&(ee=null),ee!==e?(N=O,R=c(R,U,ee),O=R):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)}else F=O,O=e;return O}function $o(){var O,R;return O=F,u.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(h)),R!==e&&(N=O,R=d()),O=R,O}function Mr(){var O,R,X,U;if(O=F,f.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(p)),R!==e){for(X=[],U=Et();U!==e;)X.push(U),U=Et();X!==e?(U=es(),U!==e?(N=O,R=m(R,U),O=R):(F=O,O=e)):(F=O,O=e)}else F=O,O=e;return O}function es(){var O,R,X,U,ee,Pe;if(O=F,R=Ft(),R!==e){for(X=[],U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Ft(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);U!==e;)X.push(U),U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Ft(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);X!==e?(N=O,R=o(R,X),O=R):(F=O,O=e)}else F=O,O=e;return O}function Mn(){var O,R,X,U;if(O=F,g.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(y)),R!==e){for(X=[],U=Et();U!==e;)X.push(U),U=Et();X!==e?(U=Kf(),U!==e?(N=O,R=v(R,U),O=R):(F=O,O=e)):(F=O,O=e)}else F=O,O=e;return O}function Kf(){var O,R,X,U,ee,Pe;if(O=F,R=rn(),R!==e){for(X=[],U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=rn(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);U!==e;)X.push(U),U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=rn(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);X!==e?(N=O,R=o(R,X),O=R):(F=O,O=e)}else F=O,O=e;return O}function dS(){var O,R,X,U;if(O=F,x.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(S)),R!==e){for(X=[],U=Et();U!==e;)X.push(U),U=Et();X!==e?(U=Kf(),U!==e?(N=O,R=w(R,U),O=R):(F=O,O=e)):(F=O,O=e)}else F=O,O=e;return O}function fS(){var O,R,X,U;if(O=F,A.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(T)),R!==e){for(X=[],U=Et();U!==e;)X.push(U),U=Et();X!==e?(U=pS(),U!==e?(N=O,R=m(R,U),O=R):(F=O,O=e)):(F=O,O=e)}else F=O,O=e;return O}function pS(){var O,R,X,U,ee,Pe;if(O=F,R=z(),R!==e){for(X=[],U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=z(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);U!==e;)X.push(U),U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=z(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);X!==e?(N=O,R=o(R,X),O=R):(F=O,O=e)}else F=O,O=e;return O}function z(){var O,R,X,U,ee,Pe;return O=F,R=Ft(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(U=Ft(),U!==e?(ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Ft(),Pe!==e?(N=O,R=b(R,U,Pe),O=R):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)):(F=O,O=e),O}function ce(){var O,R,X,U;if(O=F,M.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(C)),R!==e){for(X=[],U=Et();U!==e;)X.push(U),U=Et();X!==e?(U=ve(),U!==e?(N=O,R=m(R,U),O=R):(F=O,O=e)):(F=O,O=e)}else F=O,O=e;return O}function ve(){var O,R,X,U,ee,Pe;if(O=F,R=se(),R!==e){for(X=[],U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=se(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);U!==e;)X.push(U),U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=se(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);X!==e?(N=O,R=o(R,X),O=R):(F=O,O=e)}else F=O,O=e;return O}function se(){var O,R,X,U;return O=F,R=Ft(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(U=Ft(),U!==e?(N=O,R=P(R,U),O=R):(F=O,O=e)):(F=O,O=e)):(F=O,O=e),O}function be(){var O,R,X,U;if(O=F,I.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(_)),R!==e){for(X=[],U=Et();U!==e;)X.push(U),U=Et();X!==e?(U=ct(),U!==e?(N=O,R=m(R,U),O=R):(F=O,O=e)):(F=O,O=e)}else F=O,O=e;return O}function ct(){var O,R,X,U,ee,Pe;if(O=F,R=mt(),R!==e){for(X=[],U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=mt(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);U!==e;)X.push(U),U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=mt(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);X!==e?(N=O,R=o(R,X),O=R):(F=O,O=e)}else F=O,O=e;return O}function mt(){var O,R,X,U;return O=F,R=Ft(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(U=Ft(),U!==e?(N=O,R=D(R,U),O=R):(F=O,O=e)):(F=O,O=e)):(F=O,O=e),O}function At(){var O,R,X,U;if(O=F,L.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(j)),R!==e){for(X=[],U=Et();U!==e;)X.push(U),U=Et();X!==e?(U=Ct(),U!==e?(N=O,R=m(R,U),O=R):(F=O,O=e)):(F=O,O=e)}else F=O,O=e;return O}function Ct(){var O,R,X,U,ee,Pe;if(O=F,R=Ft(),R!==e){for(X=[],U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Ft(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);U!==e;)X.push(U),U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=Ft(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);X!==e?(N=O,R=o(R,X),O=R):(F=O,O=e)}else F=O,O=e;return O}function jt(){var O,R,X,U;if(O=F,V.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(H)),R!==e){for(X=[],U=Et();U!==e;)X.push(U),U=Et();X!==e?(U=Nt(),U!==e?(N=O,R=m(R,U),O=R):(F=O,O=e)):(F=O,O=e)}else F=O,O=e;return O}function Nt(){var O,R,X,U,ee,Pe;if(O=F,R=It(),R!==e){for(X=[],U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=It(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);U!==e;)X.push(U),U=F,ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=It(),Pe!==e?(ee=[ee,Pe],U=ee):(F=U,U=e)):(F=U,U=e);X!==e?(N=O,R=o(R,X),O=R):(F=O,O=e)}else F=O,O=e;return O}function It(){var O,R,X,U,ee,Pe,mu,mS,Cg,gS,Pg,yS;return O=F,R=tn(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(U=tn(),U!==e?(ee=gt(),ee===e&&(ee=null),ee!==e?(Pe=rn(),Pe!==e?(mu=gt(),mu!==e?(mS=lo(),mS!==e?(Cg=gt(),Cg===e&&(Cg=null),Cg!==e?(gS=lo(),gS!==e?(Pg=gt(),Pg===e&&(Pg=null),Pg!==e?(yS=Ft(),yS!==e?(N=O,R=W(R,U,Pe,mS,gS,yS),O=R):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)):(F=O,O=e)):(F=O,O=e),O}function Ft(){var O,R,X,U;return O=F,R=rn(),R!==e?(X=gt(),X===e&&(X=null),X!==e?(U=rn(),U!==e?(N=O,R=q(R,U),O=R):(F=O,O=e)):(F=O,O=e)):(F=O,O=e),O}function tn(){var O,R;return O=F,R=du(),R===e&&(R=zn()),R!==e&&(N=O,R=Q(R)),O=R,O}function rn(){var O,R,X,U;return O=F,R=F,X=fu(),X===e&&(X=null),X!==e?(U=du(),U!==e?(X=[X,U],R=X):(F=R,R=e)):(F=R,R=e),R===e&&(R=F,X=fu(),X===e&&(X=null),X!==e?(U=zn(),U!==e?(X=[X,U],R=X):(F=R,R=e)):(F=R,R=e)),R!==e&&(N=O,R=G(R)),O=R,O}function lo(){var O,R;return O=F,Z.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(te)),R!==e&&(N=O,R=$(R)),O=R,O}function gt(){var O,R,X,U,ee;if(O=F,R=[],X=Et(),X!==e)for(;X!==e;)R.push(X),X=Et();else R=e;if(R!==e)if(X=Rt(),X===e&&(X=null),X!==e){for(U=[],ee=Et();ee!==e;)U.push(ee),ee=Et();U!==e?(R=[R,X,U],O=R):(F=O,O=e)}else F=O,O=e;else F=O,O=e;if(O===e){if(O=F,R=F,X=Rt(),X!==e){for(U=[],ee=Et();ee!==e;)U.push(ee),ee=Et();U!==e?(X=[X,U],R=X):(F=R,R=e)}else F=R,R=e;R!==e&&(N=O,R=Y()),O=R}return O}function Rt(){var O;return n.charCodeAt(F)===44?(O=oe,F++):(O=e,me===0&&K(ie)),O}function du(){var O,R,X,U;return O=F,R=F,X=ci(),X!==e?(U=co(),U===e&&(U=null),U!==e?(X=[X,U],R=X):(F=R,R=e)):(F=R,R=e),R===e&&(R=F,X=zn(),X!==e?(U=co(),U!==e?(X=[X,U],R=X):(F=R,R=e)):(F=R,R=e)),R!==e&&(N=O,R=re(R)),O=R,O}function ci(){var O,R,X,U,ee;return O=F,R=F,X=zn(),X===e&&(X=null),X!==e?(n.charCodeAt(F)===46?(U=J,F++):(U=e,me===0&&K(Ae)),U!==e?(ee=zn(),ee!==e?(X=[X,U,ee],R=X):(F=R,R=e)):(F=R,R=e)):(F=R,R=e),R===e&&(R=F,X=zn(),X!==e?(n.charCodeAt(F)===46?(U=J,F++):(U=e,me===0&&K(Ae)),U!==e?(X=[X,U],R=X):(F=R,R=e)):(F=R,R=e)),R!==e&&(N=O,R=re(R)),O=R,O}function co(){var O,R,X,U,ee;return O=F,R=F,xe.test(n.charAt(F))?(X=n.charAt(F),F++):(X=e,me===0&&K(de)),X!==e?(U=fu(),U===e&&(U=null),U!==e?(ee=zn(),ee!==e?(X=[X,U,ee],R=X):(F=R,R=e)):(F=R,R=e)):(F=R,R=e),R!==e&&(N=O,R=re(R)),O=R,O}function fu(){var O;return De.test(n.charAt(F))?(O=n.charAt(F),F++):(O=e,me===0&&K(Ce)),O}function zn(){var O,R,X;if(O=F,R=[],ze.test(n.charAt(F))?(X=n.charAt(F),F++):(X=e,me===0&&K(Ue)),X!==e)for(;X!==e;)R.push(X),ze.test(n.charAt(F))?(X=n.charAt(F),F++):(X=e,me===0&&K(Ue));else R=e;return R!==e&&(N=O,R=Ve(R)),O=R,O}function Et(){var O,R;return O=F,Oe.test(n.charAt(F))?(R=n.charAt(F),F++):(R=e,me===0&&K(Ye)),R!==e&&(N=O,R=Y()),O=R,O}function Si(O,R){if(!R)return[O];for(var X=[O],U=0,ee=R.length;U{var Zx=UL().parse;Zx.parseSVG=Zx;Zx.makeAbsolute=yZ;zL.exports=Zx;function yZ(n){var t,e={x:0,y:0},r={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return n.forEach(function(i){i.command==="moveto"&&(t=i),i.x0=e.x,i.y0=e.y;for(var s in r)s in i&&(i[s]+=i.relative?i[r[s]]:0);"x"in i||(i.x=e.x),"y"in i||(i.y=e.y),i.relative=!1,i.code=i.code.toUpperCase(),i.command=="closepath"&&(i.x=t.x,i.y=t.y),e=i}),n}});var EF=ea((IYe,AF)=>{AF.exports=function(t,e){for(var r=t.split("."),i=e.split("."),s=0;s<3;s++){var o=Number(r[s]),a=Number(i[s]);if(o>a)return 1;if(a>o)return-1;if(!isNaN(o)&&isNaN(a))return 1;if(isNaN(o)&&!isNaN(a))return-1}return 0}});var ha="149";var Xn={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},BF=0,CM=1,NF=2;var Ly=1,FF=2,sp=3,Hn=0,pi=1,fi=2;var $t=0,$a=1,PM=2,_M=3,IM=4,VF=5,Iu=100,kF=101,UF=102,DM=103,OM=104,zF=200,GF=201,jF=202,HF=203,sP=204,oP=205,WF=206,qF=207,YF=208,XF=209,KF=210,QF=0,ZF=1,JF=2,tw=3,$F=4,eV=5,tV=6,rV=7,aP=0,iV=1,nV=2,Os=0,sV=1,oV=2,aV=3,lV=4,cV=5,lP=300,tl=301,rl=302,rw=303,iw=304,th=306,Rs=1e3,Qt=1001,nw=1002,Vt=1003,RM=1004;var vS=1005;var rt=1006,uV=1007;var xc=1008;var _r=1009,hV=1010,dV=1011,cP=1012,fV=1013,Ds=1014,br=1015,Wn=1016,pV=1017,mV=1018,el=1020,gV=1021,qr=1023,yV=1024,vV=1025,yc=1026,il=1027,xV=1028,bV=1029,rh=1030,SV=1031,Fw=1033,xS=33776,bS=33777,SS=33778,wS=33779,LM=35840,BM=35841,NM=35842,FM=35843,wV=36196,VM=37492,kM=37496,UM=37808,zM=37809,GM=37810,jM=37811,HM=37812,WM=37813,qM=37814,YM=37815,XM=37816,KM=37817,QM=37818,ZM=37819,JM=37820,$M=37821,AS=36492,AV=36283,eC=36284,tC=36285,rC=36286,Vw=2200,kw=2201,Pp=2202,sy=2300,oy=2301,ES=2302,Du=2400,Ou=2401,ay=2402,Uw=2500,EV=2501;var mn=3e3,at=3001,Bi=3200,zw=3201,TV=0,MV=1;var ho="srgb",dp="srgb-linear";var TS=7680;var CV=519,sw=35044,uP=35048;var iC="300 es",ow=1035,pr=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(e)===-1&&r[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;let r=this._listeners;return r[t]!==void 0&&r[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;let i=this._listeners[t];if(i!==void 0){let s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;let r=this._listeners[t.type];if(r!==void 0){t.target=this;let i=r.slice(0);for(let s=0,o=i.length;s>8&255]+nn[n>>16&255]+nn[n>>24&255]+"-"+nn[t&255]+nn[t>>8&255]+"-"+nn[t>>16&15|64]+nn[t>>24&255]+"-"+nn[e&63|128]+nn[e>>8&255]+"-"+nn[e>>16&255]+nn[e>>24&255]+nn[r&255]+nn[r>>8&255]+nn[r>>16&255]+nn[r>>24&255]).toLowerCase()}function di(n,t,e){return Math.max(t,Math.min(e,n))}function Gw(n,t){return(n%t+t)%t}function PV(n,t,e,r,i){return r+(n-t)*(i-r)/(e-t)}function _V(n,t,e){return n!==t?(e-n)/(t-n):0}function lp(n,t,e){return(1-e)*n+e*t}function IV(n,t,e,r){return lp(n,t,1-Math.exp(-e*r))}function DV(n,t=1){return t-Math.abs(Gw(n,t*2)-t)}function OV(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function RV(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function LV(n,t){return n+Math.floor(Math.random()*(t-n+1))}function BV(n,t){return n+Math.random()*(t-n)}function NV(n){return n*(.5-Math.random())}function FV(n){n!==void 0&&(nC=n);let t=nC+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function VV(n){return n*ap}function kV(n){return n*fp}function aw(n){return(n&n-1)===0&&n!==0}function hP(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function ly(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function UV(n,t,e,r,i){let s=Math.cos,o=Math.sin,a=s(e/2),l=o(e/2),c=s((t+r)/2),u=o((t+r)/2),h=s((t-r)/2),d=o((t-r)/2),f=s((r-t)/2),p=o((r-t)/2);switch(i){case"XYX":n.set(a*u,l*h,l*d,a*c);break;case"YZY":n.set(l*d,a*u,l*h,a*c);break;case"ZXZ":n.set(l*h,l*d,a*u,a*c);break;case"XZX":n.set(a*u,l*p,l*f,a*c);break;case"YXY":n.set(l*f,a*u,l*p,a*c);break;case"ZYZ":n.set(l*p,l*f,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function ca(n,t){switch(t.constructor){case Float32Array:return n;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function xr(n,t){switch(t.constructor){case Float32Array:return n;case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}var we=Object.freeze({__proto__:null,DEG2RAD:ap,RAD2DEG:fp,ceilPowerOfTwo:hP,clamp:di,damp:IV,degToRad:VV,denormalize:ca,euclideanModulo:Gw,floorPowerOfTwo:ly,generateUUID:is,inverseLerp:_V,isPowerOfTwo:aw,lerp:lp,mapLinear:PV,normalize:xr,pingpong:DV,radToDeg:kV,randFloat:BV,randFloatSpread:NV,randInt:LV,seededRandom:FV,setQuaternionFromProperEuler:UV,smootherstep:RV,smoothstep:OV}),k=class{constructor(t=0,e=0){k.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,r=this.y,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6],this.y=i[1]*e+i[4]*r+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,r=this.y-t.y;return e*e+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let r=Math.cos(e),i=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*r-o*i+t.x,this.y=s*i+o*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},fr=class{constructor(){fr.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(t,e,r,i,s,o,a,l,c){let u=this.elements;return u[0]=t,u[1]=i,u[2]=a,u[3]=e,u[4]=s,u[5]=l,u[6]=r,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],u=r[4],h=r[7],d=r[2],f=r[5],p=r[8],m=i[0],g=i[3],y=i[6],v=i[1],x=i[4],S=i[7],w=i[2],A=i[5],T=i[8];return s[0]=o*m+a*v+l*w,s[3]=o*g+a*x+l*A,s[6]=o*y+a*S+l*T,s[1]=c*m+u*v+h*w,s[4]=c*g+u*x+h*A,s[7]=c*y+u*S+h*T,s[2]=d*m+f*v+p*w,s[5]=d*g+f*x+p*A,s[8]=d*y+f*S+p*T,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e*o*u-e*a*c-r*s*u+r*a*l+i*s*c-i*o*l}invert(){let t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*o-a*c,d=a*l-u*s,f=c*s-o*l,p=e*h+r*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return t[0]=h*m,t[1]=(i*c-u*r)*m,t[2]=(a*r-i*o)*m,t[3]=d*m,t[4]=(u*e-i*l)*m,t[5]=(i*s-a*e)*m,t[6]=f*m,t[7]=(r*l-c*e)*m,t[8]=(o*e-r*s)*m,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,r,i,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*o+c*a)+o+t,-i*c,i*l,-i*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(MS.makeScale(t,e)),this}rotate(t){return this.premultiply(MS.makeRotation(-t)),this}translate(t,e){return this.premultiply(MS.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,r=t.elements;for(let i=0;i<9;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){let r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return new this.constructor().fromArray(this.elements)}},MS=new fr;function dP(n){for(let t=n.length-1;t>=0;--t)if(n[t]>=65535)return!0;return!1}var zV={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ig(n,t){return new zV[n](t)}function pp(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function vc(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function ny(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var CS={[ho]:{[dp]:vc},[dp]:{[ho]:ny}},dn={legacyMode:!0,get workingColorSpace(){return dp},set workingColorSpace(n){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(n,t,e){if(this.legacyMode||t===e||!t||!e)return n;if(CS[t]&&CS[t][e]!==void 0){let r=CS[t][e];return n.r=r(n.r),n.g=r(n.g),n.b=r(n.b),n}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(n,t){return this.convert(n,this.workingColorSpace,t)},toWorkingColorSpace:function(n,t){return this.convert(n,t,this.workingColorSpace)}},fP={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},wi={r:0,g:0,b:0},Ps={h:0,s:0,l:0},Dg={h:0,s:0,l:0};function PS(n,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+(t-n)*6*e:e<1/2?t:e<2/3?n+(t-n)*6*(2/3-e):n}function Og(n,t){return t.r=n.r,t.g=n.g,t.b=n.b,t}var We=class{constructor(t,e,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,e===void 0&&r===void 0?this.set(t):this.setRGB(t,e,r)}set(t){return t&&t.isColor?this.copy(t):typeof t=="number"?this.setHex(t):typeof t=="string"&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=ho){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,dn.toWorkingColorSpace(this,e),this}setRGB(t,e,r,i=dn.workingColorSpace){return this.r=t,this.g=e,this.b=r,dn.toWorkingColorSpace(this,i),this}setHSL(t,e,r,i=dn.workingColorSpace){if(t=Gw(t,1),e=di(e,0,1),r=di(r,0,1),e===0)this.r=this.g=this.b=r;else{let s=r<=.5?r*(1+e):r+e-r*e,o=2*r-s;this.r=PS(o,s,t+1/3),this.g=PS(o,s,t),this.b=PS(o,s,t-1/3)}return dn.toWorkingColorSpace(this,i),this}setStyle(t,e=ho){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,dn.toWorkingColorSpace(this,e),r(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,dn.toWorkingColorSpace(this,e),r(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){let l=parseFloat(s[1])/360,c=parseFloat(s[2])/100,u=parseFloat(s[3])/100;return r(s[4]),this.setHSL(l,c,u,e)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let s=i[1],o=s.length;if(o===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,dn.toWorkingColorSpace(this,e),this;if(o===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,dn.toWorkingColorSpace(this,e),this}return t&&t.length>0?this.setColorName(t,e):this}setColorName(t,e=ho){let r=fP[t.toLowerCase()];return r!==void 0?this.setHex(r,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=vc(t.r),this.g=vc(t.g),this.b=vc(t.b),this}copyLinearToSRGB(t){return this.r=ny(t.r),this.g=ny(t.g),this.b=ny(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ho){return dn.fromWorkingColorSpace(Og(this,wi),t),di(wi.r*255,0,255)<<16^di(wi.g*255,0,255)<<8^di(wi.b*255,0,255)<<0}getHexString(t=ho){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=dn.workingColorSpace){dn.fromWorkingColorSpace(Og(this,wi),e);let r=wi.r,i=wi.g,s=wi.b,o=Math.max(r,i,s),a=Math.min(r,i,s),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case r:l=(i-s)/h+(i"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{gu===void 0&&(gu=pp("canvas")),gu.width=t.width,gu.height=t.height;let r=gu.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height),e=gu}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=pp("canvas");e.width=t.width,e.height=t.height;let r=e.getContext("2d");r.drawImage(t,0,0,t.width,t.height);let i=r.getImageData(0,0,t.width,t.height),s=i.data;for(let o=0;o0&&(r.userData=this.userData),e||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==lP)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Rs:t.x=t.x-Math.floor(t.x);break;case Qt:t.x=t.x<0?0:1;break;case nw:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Rs:t.y=t.y-Math.floor(t.y);break;case Qt:t.y=t.y<0?0:1;break;case nw:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}};er.DEFAULT_IMAGE=null;er.DEFAULT_MAPPING=lP;er.DEFAULT_ANISOTROPY=1;var Ze=class{constructor(t=0,e=0,r=0,i=1){Ze.prototype.isVector4=!0,this.x=t,this.y=e,this.z=r,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,r=this.y,i=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*e+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*e+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*e+o[7]*r+o[11]*i+o[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,r,i,s,l=t.elements,c=l[0],u=l[4],h=l[8],d=l[1],f=l[5],p=l[9],m=l[2],g=l[6],y=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+m)<.1&&Math.abs(p+g)<.1&&Math.abs(c+f+y-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let x=(c+1)/2,S=(f+1)/2,w=(y+1)/2,A=(u+d)/4,T=(h+m)/4,b=(p+g)/4;return x>S&&x>w?x<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(x),i=A/r,s=T/r):S>w?S<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(S),r=A/i,s=b/i):w<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(w),r=T/s,i=b/s),this.set(r,i,s,e),this}let v=Math.sqrt((g-p)*(g-p)+(h-m)*(h-m)+(d-u)*(d-u));return Math.abs(v)<.001&&(v=1),this.x=(g-p)/v,this.y=(h-m)/v,this.z=(d-u)/v,this.w=Math.acos((c+f+y-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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}},dt=class extends pr{constructor(t=1,e=1,r={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Ze(0,0,t,e),this.scissorTest=!1,this.viewport=new Ze(0,0,t,e);let i={width:t,height:e,depth:1};this.texture=new er(i,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps!==void 0?r.generateMipmaps:!1,this.texture.internalFormat=r.internalFormat!==void 0?r.internalFormat:null,this.texture.minFilter=r.minFilter!==void 0?r.minFilter:rt,this.depthBuffer=r.depthBuffer!==void 0?r.depthBuffer:!0,this.stencilBuffer=r.stencilBuffer!==void 0?r.stencilBuffer:!1,this.depthTexture=r.depthTexture!==void 0?r.depthTexture:null,this.samples=r.samples!==void 0?r.samples:0}setSize(t,e,r=1){(this.width!==t||this.height!==e||this.depth!==r)&&(this.width=t,this.height=e,this.depth=r,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new uy(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},hy=class extends er{constructor(t=null,e=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:r,depth:i},this.magFilter=Vt,this.minFilter=Vt,this.wrapR=Qt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var dy=class extends er{constructor(t=null,e=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:r,depth:i},this.magFilter=Vt,this.minFilter=Vt,this.wrapR=Qt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var fy=class extends dt{constructor(t=1,e=1,r=1,i={}){super(t,e,i),this.isWebGLMultipleRenderTargets=!0;let s=this.texture;this.texture=[];for(let o=0;o=0?1:-1,x=1-y*y;if(x>Number.EPSILON){let w=Math.sqrt(x),A=Math.atan2(w,y*v);g=Math.sin(g*A)/w,a=Math.sin(a*A)/w}let S=a*v;if(l=l*g+d*S,c=c*g+f*S,u=u*g+p*S,h=h*g+m*S,g===1-a){let w=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=w,c*=w,u*=w,h*=w}}t[e]=l,t[e+1]=c,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,r,i,s,o){let a=r[i],l=r[i+1],c=r[i+2],u=r[i+3],h=s[o],d=s[o+1],f=s[o+2],p=s[o+3];return t[e]=a*p+u*h+l*f-c*d,t[e+1]=l*p+u*d+c*h-a*f,t[e+2]=c*p+u*f+a*d-l*h,t[e+3]=u*p-a*h-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){let r=t._x,i=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(r/2),u=a(i/2),h=a(s/2),d=l(r/2),f=l(i/2),p=l(s/2);switch(o){case"XYZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"YXZ":this._x=d*u*h+c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"ZXY":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h-d*f*p;break;case"ZYX":this._x=d*u*h-c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h+d*f*p;break;case"YZX":this._x=d*u*h+c*f*p,this._y=c*f*h+d*u*p,this._z=c*u*p-d*f*h,this._w=c*u*h-d*f*p;break;case"XZY":this._x=d*u*h-c*f*p,this._y=c*f*h-d*u*p,this._z=c*u*p+d*f*h,this._w=c*u*h+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let r=e/2,i=Math.sin(r);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,r=e[0],i=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],u=e[6],h=e[10],d=r+a+h;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(s-c)*f,this._z=(o-i)*f}else if(r>a&&r>h){let f=2*Math.sqrt(1+r-a-h);this._w=(u-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+c)/f}else if(a>h){let f=2*Math.sqrt(1+a-r-h);this._w=(s-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+u)/f}else{let f=2*Math.sqrt(1+h-r-a);this._w=(o-i)/f,this._x=(s+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return rMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(di(this.dot(t),-1,1)))}rotateTowards(t,e){let r=this.angleTo(t);if(r===0)return this;let i=Math.min(1,e/r);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let r=t._x,i=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,u=e._w;return this._x=r*u+o*a+i*c-s*l,this._y=i*u+o*l+s*a-r*c,this._z=s*u+o*c+r*l-i*a,this._w=o*u-r*a-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let r=this._x,i=this._y,s=this._z,o=this._w,a=o*t._w+r*t._x+i*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let f=1-e;return this._w=f*o+e*this._w,this._x=f*r+e*this._x,this._y=f*i+e*this._y,this._z=f*s+e*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-e)*u)/c,d=Math.sin(e*u)/c;return this._w=o*h+this._w*d,this._x=r*h+this._x*d,this._y=i*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){let t=Math.random(),e=Math.sqrt(1-t),r=Math.sqrt(t),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(e*Math.cos(i),r*Math.sin(s),r*Math.cos(s),e*Math.sin(i))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},E=class{constructor(t=0,e=0,r=0){E.prototype.isVector3=!0,this.x=t,this.y=e,this.z=r}set(t,e,r){return r===void 0&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(sC.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(sC.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*r+s[6]*i,this.y=s[1]*e+s[4]*r+s[7]*i,this.z=s[2]*e+s[5]*r+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,r=this.y,i=this.z,s=t.elements,o=1/(s[3]*e+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*e+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*e+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(t){let e=this.x,r=this.y,i=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=l*e+o*i-a*r,u=l*r+a*e-s*i,h=l*i+s*r-o*e,d=-s*e-o*r-a*i;return this.x=c*l+d*-s+u*-a-h*-o,this.y=u*l+d*-o+h*-s-c*-a,this.z=h*l+d*-a+c*-o-u*-s,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*i,this.y=s[1]*e+s[5]*r+s[9]*i,this.z=s[2]*e+s[6]*r+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){let r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let r=t.x,i=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return IS.copy(this).projectOnVector(t),this.sub(IS)}reflect(t){return this.sub(IS.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let r=this.dot(t)/e;return Math.acos(di(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,r){let i=Math.sin(e)*t;return this.x=i*Math.sin(r),this.y=Math.cos(e)*t,this.z=i*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=(Math.random()-.5)*2,e=Math.random()*Math.PI*2,r=Math.sqrt(1-t**2);return this.x=r*Math.cos(e),this.y=r*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},IS=new E,sC=new Ke,Ht=class{constructor(t=new E(1/0,1/0,1/0),e=new E(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,r=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=t.length;ls&&(s=u),h>o&&(o=h),d>a&&(a=d)}return this.min.set(e,r,i),this.max.set(s,o,a),this}setFromBufferAttribute(t){let e=1/0,r=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,c=t.count;ls&&(s=u),h>o&&(o=h),d>a&&(a=d)}return this.min.set(e,r,i),this.max.set(s,o,a),this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,dc),dc.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Qf),Rg.subVectors(this.max,Qf),yu.subVectors(t.a,Qf),vu.subVectors(t.b,Qf),xu.subVectors(t.c,Qf),Xa.subVectors(vu,yu),Ka.subVectors(xu,vu),fc.subVectors(yu,xu);let e=[0,-Xa.z,Xa.y,0,-Ka.z,Ka.y,0,-fc.z,fc.y,Xa.z,0,-Xa.x,Ka.z,0,-Ka.x,fc.z,0,-fc.x,-Xa.y,Xa.x,0,-Ka.y,Ka.x,0,-fc.y,fc.x,0];return!OS(e,yu,vu,xu,Rg)||(e=[1,0,0,0,1,0,0,0,1],!OS(e,yu,vu,xu,Rg))?!1:(Lg.crossVectors(Xa,Ka),e=[Lg.x,Lg.y,Lg.z],OS(e,yu,vu,xu,Rg))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return dc.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=this.getSize(dc).length()*.5,t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(ra[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ra[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ra[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ra[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ra[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ra[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ra[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ra[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ra),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},ra=[new E,new E,new E,new E,new E,new E,new E,new E],dc=new E,DS=new Ht,yu=new E,vu=new E,xu=new E,Xa=new E,Ka=new E,fc=new E,Qf=new E,Rg=new E,Lg=new E,pc=new E;function OS(n,t,e,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){pc.fromArray(n,s);let a=i.x*Math.abs(pc.x)+i.y*Math.abs(pc.y)+i.z*Math.abs(pc.z),l=t.dot(pc),c=e.dot(pc),u=r.dot(pc);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var jV=new Ht,Zf=new E,RS=new E,Rr=class{constructor(t=new E,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let r=this.center;e!==void 0?r.copy(e):jV.setFromPoints(t).getCenter(r);let i=0;for(let s=0,o=t.length;sthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Zf.subVectors(t,this.center);let e=Zf.lengthSq();if(e>this.radius*this.radius){let r=Math.sqrt(e),i=(r-this.radius)*.5;this.center.addScaledVector(Zf,i/r),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(RS.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Zf.copy(t.center).add(RS)),this.expandByPoint(Zf.copy(t.center).sub(RS))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},ia=new E,LS=new E,Bg=new E,Qa=new E,BS=new E,Ng=new E,NS=new E,Ls=class{constructor(t=new E,e=new E(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ia)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=ia.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ia.copy(this.direction).multiplyScalar(e).add(this.origin),ia.distanceToSquared(t))}distanceSqToSegment(t,e,r,i){LS.copy(t).add(e).multiplyScalar(.5),Bg.copy(e).sub(t).normalize(),Qa.copy(this.origin).sub(LS);let s=t.distanceTo(e)*.5,o=-this.direction.dot(Bg),a=Qa.dot(this.direction),l=-Qa.dot(Bg),c=Qa.lengthSq(),u=Math.abs(1-o*o),h,d,f,p;if(u>0)if(h=o*l-a,d=o*a-l,p=s*u,h>=0)if(d>=-p)if(d<=p){let m=1/u;h*=m,d*=m,f=h*(h+o*d+2*a)+d*(o*h+d+2*l)+c}else d=s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;else d=-s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;else d<=-p?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+c):d<=p?(h=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+c);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;return r&&r.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy(Bg).multiplyScalar(d).add(LS),f}intersectSphere(t,e){ia.subVectors(t.center,this.origin);let r=ia.dot(this.direction),i=ia.dot(ia)-r*r,s=t.radius*t.radius;if(i>s)return null;let o=Math.sqrt(s-i),a=r-o,l=r+o;return a<0&&l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null}intersectPlane(t,e){let r=this.distanceToPlane(t);return r===null?null:this.at(r,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let r,i,s,o,a,l,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(r=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(r=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),u>=0?(s=(t.min.y-d.y)*u,o=(t.max.y-d.y)*u):(s=(t.max.y-d.y)*u,o=(t.min.y-d.y)*u),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o=0?(a=(t.min.z-d.z)*h,l=(t.max.z-d.z)*h):(a=(t.max.z-d.z)*h,l=(t.min.z-d.z)*h),r>l||a>i)||((a>r||r!==r)&&(r=a),(l=0?r:i,e)}intersectsBox(t){return this.intersectBox(t,ia)!==null}intersectTriangle(t,e,r,i,s){BS.subVectors(e,t),Ng.subVectors(r,t),NS.crossVectors(BS,Ng);let o=this.direction.dot(NS),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Qa.subVectors(this.origin,t);let l=a*this.direction.dot(Ng.crossVectors(Qa,Ng));if(l<0)return null;let c=a*this.direction.dot(BS.cross(Qa));if(c<0||l+c>o)return null;let u=-a*Qa.dot(NS);return u<0?null:this.at(u/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ue=class{constructor(){ue.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(t,e,r,i,s,o,a,l,c,u,h,d,f,p,m,g){let y=this.elements;return y[0]=t,y[4]=e,y[8]=r,y[12]=i,y[1]=s,y[5]=o,y[9]=a,y[13]=l,y[2]=c,y[6]=u,y[10]=h,y[14]=d,y[3]=f,y[7]=p,y[11]=m,y[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ue().fromArray(this.elements)}copy(t){let e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){let e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,r=t.elements,i=1/bu.setFromMatrixColumn(t,0).length(),s=1/bu.setFromMatrixColumn(t,1).length(),o=1/bu.setFromMatrixColumn(t,2).length();return e[0]=r[0]*i,e[1]=r[1]*i,e[2]=r[2]*i,e[3]=0,e[4]=r[4]*s,e[5]=r[5]*s,e[6]=r[6]*s,e[7]=0,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,r=t.x,i=t.y,s=t.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),c=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){let d=o*u,f=o*h,p=a*u,m=a*h;e[0]=l*u,e[4]=-l*h,e[8]=c,e[1]=f+p*c,e[5]=d-m*c,e[9]=-a*l,e[2]=m-d*c,e[6]=p+f*c,e[10]=o*l}else if(t.order==="YXZ"){let d=l*u,f=l*h,p=c*u,m=c*h;e[0]=d+m*a,e[4]=p*a-f,e[8]=o*c,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=f*a-p,e[6]=m+d*a,e[10]=o*l}else if(t.order==="ZXY"){let d=l*u,f=l*h,p=c*u,m=c*h;e[0]=d-m*a,e[4]=-o*h,e[8]=p+f*a,e[1]=f+p*a,e[5]=o*u,e[9]=m-d*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){let d=o*u,f=o*h,p=a*u,m=a*h;e[0]=l*u,e[4]=p*c-f,e[8]=d*c+m,e[1]=l*h,e[5]=m*c+d,e[9]=f*c-p,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){let d=o*l,f=o*c,p=a*l,m=a*c;e[0]=l*u,e[4]=m-d*h,e[8]=p*h+f,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-c*u,e[6]=f*h+p,e[10]=d-m*h}else if(t.order==="XZY"){let d=o*l,f=o*c,p=a*l,m=a*c;e[0]=l*u,e[4]=-h,e[8]=c*u,e[1]=d*h+m,e[5]=o*u,e[9]=f*h-p,e[2]=p*h-f,e[6]=a*u,e[10]=m*h+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(HV,t,WV)}lookAt(t,e,r){let i=this.elements;return Gn.subVectors(t,e),Gn.lengthSq()===0&&(Gn.z=1),Gn.normalize(),Za.crossVectors(r,Gn),Za.lengthSq()===0&&(Math.abs(r.z)===1?Gn.x+=1e-4:Gn.z+=1e-4,Gn.normalize(),Za.crossVectors(r,Gn)),Za.normalize(),Fg.crossVectors(Gn,Za),i[0]=Za.x,i[4]=Fg.x,i[8]=Gn.x,i[1]=Za.y,i[5]=Fg.y,i[9]=Gn.y,i[2]=Za.z,i[6]=Fg.z,i[10]=Gn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[4],l=r[8],c=r[12],u=r[1],h=r[5],d=r[9],f=r[13],p=r[2],m=r[6],g=r[10],y=r[14],v=r[3],x=r[7],S=r[11],w=r[15],A=i[0],T=i[4],b=i[8],M=i[12],C=i[1],P=i[5],I=i[9],_=i[13],D=i[2],L=i[6],j=i[10],V=i[14],H=i[3],W=i[7],q=i[11],Q=i[15];return s[0]=o*A+a*C+l*D+c*H,s[4]=o*T+a*P+l*L+c*W,s[8]=o*b+a*I+l*j+c*q,s[12]=o*M+a*_+l*V+c*Q,s[1]=u*A+h*C+d*D+f*H,s[5]=u*T+h*P+d*L+f*W,s[9]=u*b+h*I+d*j+f*q,s[13]=u*M+h*_+d*V+f*Q,s[2]=p*A+m*C+g*D+y*H,s[6]=p*T+m*P+g*L+y*W,s[10]=p*b+m*I+g*j+y*q,s[14]=p*M+m*_+g*V+y*Q,s[3]=v*A+x*C+S*D+w*H,s[7]=v*T+x*P+S*L+w*W,s[11]=v*b+x*I+S*j+w*q,s[15]=v*M+x*_+S*V+w*Q,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],r=t[4],i=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],u=t[2],h=t[6],d=t[10],f=t[14],p=t[3],m=t[7],g=t[11],y=t[15];return p*(+s*l*h-i*c*h-s*a*d+r*c*d+i*a*f-r*l*f)+m*(+e*l*f-e*c*d+s*o*d-i*o*f+i*c*u-s*l*u)+g*(+e*c*h-e*a*f-s*o*h+r*o*f+s*a*u-r*c*u)+y*(-i*a*u-e*l*h+e*a*d+i*o*h-r*o*d+r*l*u)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,r){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=r),this}invert(){let t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],y=t[15],v=h*g*c-m*d*c+m*l*f-a*g*f-h*l*y+a*d*y,x=p*d*c-u*g*c-p*l*f+o*g*f+u*l*y-o*d*y,S=u*m*c-p*h*c+p*a*f-o*m*f-u*a*y+o*h*y,w=p*h*l-u*m*l-p*a*d+o*m*d+u*a*g-o*h*g,A=e*v+r*x+i*S+s*w;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let T=1/A;return t[0]=v*T,t[1]=(m*d*s-h*g*s-m*i*f+r*g*f+h*i*y-r*d*y)*T,t[2]=(a*g*s-m*l*s+m*i*c-r*g*c-a*i*y+r*l*y)*T,t[3]=(h*l*s-a*d*s-h*i*c+r*d*c+a*i*f-r*l*f)*T,t[4]=x*T,t[5]=(u*g*s-p*d*s+p*i*f-e*g*f-u*i*y+e*d*y)*T,t[6]=(p*l*s-o*g*s-p*i*c+e*g*c+o*i*y-e*l*y)*T,t[7]=(o*d*s-u*l*s+u*i*c-e*d*c-o*i*f+e*l*f)*T,t[8]=S*T,t[9]=(p*h*s-u*m*s-p*r*f+e*m*f+u*r*y-e*h*y)*T,t[10]=(o*m*s-p*a*s+p*r*c-e*m*c-o*r*y+e*a*y)*T,t[11]=(u*a*s-o*h*s-u*r*c+e*h*c+o*r*f-e*a*f)*T,t[12]=w*T,t[13]=(u*m*i-p*h*i+p*r*d-e*m*d-u*r*g+e*h*g)*T,t[14]=(p*a*i-o*m*i-p*r*l+e*m*l+o*r*g-e*a*g)*T,t[15]=(o*h*i-u*a*i+u*r*l-e*h*l-o*r*d+e*a*d)*T,this}scale(t){let e=this.elements,r=t.x,i=t.y,s=t.z;return e[0]*=r,e[4]*=i,e[8]*=s,e[1]*=r,e[5]*=i,e[9]*=s,e[2]*=r,e[6]*=i,e[10]*=s,e[3]*=r,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,i))}makeTranslation(t,e,r){return this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let r=Math.cos(e),i=Math.sin(e),s=1-r,o=t.x,a=t.y,l=t.z,c=s*o,u=s*a;return this.set(c*o+r,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+r,u*l-i*o,0,c*l-i*a,u*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,i,s,o){return this.set(1,r,s,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,r){let i=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,u=o+o,h=a+a,d=s*c,f=s*u,p=s*h,m=o*u,g=o*h,y=a*h,v=l*c,x=l*u,S=l*h,w=r.x,A=r.y,T=r.z;return i[0]=(1-(m+y))*w,i[1]=(f+S)*w,i[2]=(p-x)*w,i[3]=0,i[4]=(f-S)*A,i[5]=(1-(d+y))*A,i[6]=(g+v)*A,i[7]=0,i[8]=(p+x)*T,i[9]=(g-v)*T,i[10]=(1-(d+m))*T,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,r){let i=this.elements,s=bu.set(i[0],i[1],i[2]).length(),o=bu.set(i[4],i[5],i[6]).length(),a=bu.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),t.x=i[12],t.y=i[13],t.z=i[14],_s.copy(this);let c=1/s,u=1/o,h=1/a;return _s.elements[0]*=c,_s.elements[1]*=c,_s.elements[2]*=c,_s.elements[4]*=u,_s.elements[5]*=u,_s.elements[6]*=u,_s.elements[8]*=h,_s.elements[9]*=h,_s.elements[10]*=h,e.setFromRotationMatrix(_s),r.x=s,r.y=o,r.z=a,this}makePerspective(t,e,r,i,s,o){let a=this.elements,l=2*s/(e-t),c=2*s/(r-i),u=(e+t)/(e-t),h=(r+i)/(r-i),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,r,i,s,o){let a=this.elements,l=1/(e-t),c=1/(r-i),u=1/(o-s),h=(e+t)*l,d=(r+i)*c,f=(o+s)*u;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*u,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){let e=this.elements,r=t.elements;for(let i=0;i<16;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){let r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}},bu=new E,_s=new ue,HV=new E(0,0,0),WV=new E(1,1,1),Za=new E,Fg=new E,Gn=new E,oC=new ue,aC=new Ke,nr=class{constructor(t=0,e=0,r=0,i=nr.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,r,i=this._order){return this._x=t,this._y=e,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,r=!0){let i=t.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],u=i[9],h=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(di(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-di(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(di(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-di(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(di(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-di(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,r===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return oC.makeRotationFromQuaternion(t),this.setFromRotationMatrix(oC,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return aC.setFromEuler(this),this.setFromQuaternion(aC,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};nr.DEFAULT_ORDER="XYZ";var mp=class{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let r=0;r0&&(r=r.concat(o))}return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Jf,t,YV),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Jf,XV,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let r=0,i=e.length;r0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(r.geometries=a),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),u.length>0&&(r.images=u),h.length>0&&(r.shapes=h),d.length>0&&(r.skeletons=d),f.length>0&&(r.animations=f),p.length>0&&(r.nodes=p)}return r.object=i,r;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let r=0;r0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,r,i,s){Is.subVectors(i,e),sa.subVectors(r,e),FS.subVectors(t,e);let o=Is.dot(Is),a=Is.dot(sa),l=Is.dot(FS),c=sa.dot(sa),u=sa.dot(FS),h=o*c-a*a;if(h===0)return s.set(-2,-1,-1);let d=1/h,f=(c*l-a*u)*d,p=(o*u-a*l)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,r,i){return this.getBarycoord(t,e,r,i,oa),oa.x>=0&&oa.y>=0&&oa.x+oa.y<=1}static getUV(t,e,r,i,s,o,a,l){return this.getBarycoord(t,e,r,i,oa),l.set(0,0),l.addScaledVector(s,oa.x),l.addScaledVector(o,oa.y),l.addScaledVector(a,oa.z),l}static isFrontFacing(t,e,r,i){return Is.subVectors(r,e),sa.subVectors(t,e),Is.cross(sa).dot(i)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,i){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,r,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Is.subVectors(this.c,this.b),sa.subVectors(this.a,this.b),Is.cross(sa).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Cr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Cr.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,r,i,s){return Cr.getUV(t,this.a,this.b,this.c,e,r,i,s)}containsPoint(t){return Cr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Cr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let r=this.a,i=this.b,s=this.c,o,a;wu.subVectors(i,r),Au.subVectors(s,r),VS.subVectors(t,r);let l=wu.dot(VS),c=Au.dot(VS);if(l<=0&&c<=0)return e.copy(r);kS.subVectors(t,i);let u=wu.dot(kS),h=Au.dot(kS);if(u>=0&&h<=u)return e.copy(i);let d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return o=l/(l-u),e.copy(r).addScaledVector(wu,o);US.subVectors(t,s);let f=wu.dot(US),p=Au.dot(US);if(p>=0&&f<=p)return e.copy(s);let m=f*c-l*p;if(m<=0&&c>=0&&p<=0)return a=c/(c-p),e.copy(r).addScaledVector(Au,a);let g=u*p-f*h;if(g<=0&&h-u>=0&&f-p>=0)return fC.subVectors(s,i),a=(h-u)/(h-u+(f-p)),e.copy(i).addScaledVector(fC,a);let y=1/(g+m+d);return o=m*y,a=d*y,e.copy(r).addScaledVector(wu,o).addScaledVector(Au,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},QV=0,bc=class extends pr{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:QV++}),this.uuid=is(),this.name="",this.type="Material",this.blending=$a,this.side=Hn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=sP,this.blendDst=oP,this.blendEquation=Iu,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=tw,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=CV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=TS,this.stencilZFail=TS,this.stencilZPass=TS,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let r=t[e];if(r===void 0){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}let i=this[e];if(i===void 0){console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.");continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[e]=r}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(t).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==$a&&(r.blending=this.blending),this.side!==Hn&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(r.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(r.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=this.flatShading),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(e){let s=i(t.textures),o=i(t.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,r=null;if(e!==null){let i=e.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=e[s].clone()}return this.clippingPlanes=r,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},on=class extends bc{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new We(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=aP,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},hi=new E,kg=new k,Xe=class{constructor(t,e,r=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=r,this.usage=sw,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this}copyAt(t,e,r){t*=this.itemSize,r*=e.itemSize;for(let i=0,s=this.itemSize;i0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let r=this.attributes;for(let l in r){let c=r[l];t.data.attributes[l]=c.toJSON(t.data)}let i={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h0&&(i[l]=u,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let r=t.index;r!==null&&this.setIndex(r.clone(e));let i=t.attributes;for(let c in i){let u=i[c];this.setAttribute(c,u.clone(e))}let s=t.morphAttributes;for(let c in s){let u=[],h=s[c];for(let d=0,f=h.length;d0){let i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;se.far?null:{distance:c,point:Hg.clone(),object:n}}function Wg(n,t,e,r,i,s,o,a,l){n.getVertexPosition(o,ep),n.getVertexPosition(a,tp),n.getVertexPosition(l,rp);let c=JV(n,t,e,r,ep,tp,rp,HS);if(c){i&&(zg.fromBufferAttribute(i,o),Gg.fromBufferAttribute(i,a),jg.fromBufferAttribute(i,l),c.uv=Cr.getUV(HS,ep,tp,rp,zg,Gg,jg,new k)),s&&(zg.fromBufferAttribute(s,o),Gg.fromBufferAttribute(s,a),jg.fromBufferAttribute(s,l),c.uv2=Cr.getUV(HS,ep,tp,rp,zg,Gg,jg,new k));let u={a:o,b:a,c:l,normal:new E,materialIndex:0};Cr.getNormal(ep,tp,rp,u.normal),c.face=u}return c}var mi=class extends _e{constructor(t=1,e=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};let a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],u=[],h=[],d=0,f=0;p("z","y","x",-1,-1,r,e,t,o,s,0),p("z","y","x",1,-1,r,e,-t,o,s,1),p("x","z","y",1,1,t,r,e,i,o,2),p("x","z","y",1,-1,t,r,-e,i,o,3),p("x","y","z",1,-1,t,e,r,i,s,4),p("x","y","z",-1,-1,t,e,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Te(c,3)),this.setAttribute("normal",new Te(u,3)),this.setAttribute("uv",new Te(h,2));function p(m,g,y,v,x,S,w,A,T,b,M){let C=S/T,P=w/b,I=S/2,_=w/2,D=A/2,L=T+1,j=b+1,V=0,H=0,W=new E;for(let q=0;q0?1:-1,u.push(W.x,W.y,W.z),h.push(G/T),h.push(1-q/b),V+=1}}for(let q=0;q0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;let r={};for(let i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(e.extensions=r),e}},qn=class extends Tt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ue,this.projectionMatrix=new ue,this.projectionMatrixInverse=new ue}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},$r=class extends qn{constructor(t=50,e=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=fp*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(ap*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return fp*2*Math.atan(Math.tan(ap*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,r,i,s,o){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(ap*.5*this.fov)/this.zoom,r=2*e,i=this.aspect*r,s=-.5*i,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*i/l,e-=o.offsetY*r/c,i*=o.width/l,r*=o.height/c}let a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,e,e-r,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},Mu=-90,Cu=1,lw=class extends Tt{constructor(t,e,r){super(),this.type="CubeCamera",this.renderTarget=r;let i=new $r(Mu,Cu,t,e);i.layers=this.layers,i.up.set(0,1,0),i.lookAt(1,0,0),this.add(i);let s=new $r(Mu,Cu,t,e);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(-1,0,0),this.add(s);let o=new $r(Mu,Cu,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(0,1,0),this.add(o);let a=new $r(Mu,Cu,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(0,-1,0),this.add(a);let l=new $r(Mu,Cu,t,e);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,1),this.add(l);let c=new $r(Mu,Cu,t,e);c.layers=this.layers,c.up.set(0,1,0),c.lookAt(0,0,-1),this.add(c)}update(t,e){this.parent===null&&this.updateMatrixWorld();let r=this.renderTarget,[i,s,o,a,l,c]=this.children,u=t.getRenderTarget(),h=t.toneMapping,d=t.xr.enabled;t.toneMapping=Os,t.xr.enabled=!1;let f=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,i),t.setRenderTarget(r,1),t.render(e,s),t.setRenderTarget(r,2),t.render(e,o),t.setRenderTarget(r,3),t.render(e,a),t.setRenderTarget(r,4),t.render(e,l),r.texture.generateMipmaps=f,t.setRenderTarget(r,5),t.render(e,c),t.setRenderTarget(u),t.toneMapping=h,t.xr.enabled=d,r.texture.needsPMREMUpdate=!0}},Fu=class extends er{constructor(t,e,r,i,s,o,a,l,c,u){t=t!==void 0?t:[],e=e!==void 0?e:tl,super(t,e,r,i,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},cw=class extends dt{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let r={width:t,height:t,depth:1},i=[r,r,r,r,r,r];this.texture=new Fu(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:rt}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let r={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 ); } `},i=new mi(5,5,5),s=new it({name:"CubemapFromEquirect",uniforms:Nu(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:pi,blending:$t});s.uniforms.tEquirect.value=e;let o=new Ut(i,s),a=e.minFilter;return e.minFilter===xc&&(e.minFilter=rt),new lw(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,r,i){let s=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,r,i);t.setRenderTarget(s)}},WS=new E,rk=new E,ik=new fr,kr=class{constructor(t=new E(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,r,i){return this.normal.set(t,e,r),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,r){let i=WS.subVectors(r,e).cross(rk.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){let r=t.delta(WS),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let s=-(t.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:e.copy(r).multiplyScalar(s).add(t.start)}intersectsLine(t){let e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let r=e||ik.getNormalMatrix(t),i=this.coplanarPoint(WS).applyMatrix4(t),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},Pu=new Rr,qg=new E,gp=class{constructor(t=new kr,e=new kr,r=new kr,i=new kr,s=new kr,o=new kr){this.planes=[t,e,r,i,s,o]}set(t,e,r,i,s,o){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(t){let e=this.planes;for(let r=0;r<6;r++)e[r].copy(t.planes[r]);return this}setFromProjectionMatrix(t){let e=this.planes,r=t.elements,i=r[0],s=r[1],o=r[2],a=r[3],l=r[4],c=r[5],u=r[6],h=r[7],d=r[8],f=r[9],p=r[10],m=r[11],g=r[12],y=r[13],v=r[14],x=r[15];return e[0].setComponents(a-i,h-l,m-d,x-g).normalize(),e[1].setComponents(a+i,h+l,m+d,x+g).normalize(),e[2].setComponents(a+s,h+c,m+f,x+y).normalize(),e[3].setComponents(a-s,h-c,m-f,x-y).normalize(),e[4].setComponents(a-o,h-u,m-p,x-v).normalize(),e[5].setComponents(a+o,h+u,m+p,x+v).normalize(),this}intersectsObject(t){let e=t.geometry;return e.boundingSphere===null&&e.computeBoundingSphere(),Pu.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(Pu)}intersectsSprite(t){return Pu.center.set(0,0,0),Pu.radius=.7071067811865476,Pu.applyMatrix4(t.matrixWorld),this.intersectsSphere(Pu)}intersectsSphere(t){let e=this.planes,r=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(r)0?t.max.x:t.min.x,qg.y=i.normal.y>0?t.max.y:t.min.y,qg.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(qg)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function mP(){let n=null,t=!1,e=null,r=null;function i(s,o){e(s,o),r=n.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(r=n.requestAnimationFrame(i),t=!0)},stop:function(){n.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){n=s}}}function nk(n,t){let e=t.isWebGL2,r=new WeakMap;function i(c,u){let h=c.array,d=c.usage,f=n.createBuffer();n.bindBuffer(u,f),n.bufferData(u,h,d),c.onUploadCallback();let p;if(h instanceof Float32Array)p=5126;else if(h instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(e)p=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else p=5123;else if(h instanceof Int16Array)p=5122;else if(h instanceof Uint32Array)p=5125;else if(h instanceof Int32Array)p=5124;else if(h instanceof Int8Array)p=5120;else if(h instanceof Uint8Array)p=5121;else if(h instanceof Uint8ClampedArray)p=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:f,type:p,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version}}function s(c,u,h){let d=u.array,f=u.updateRange;n.bindBuffer(h,c),f.count===-1?n.bufferSubData(h,0,d):(e?n.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):n.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1),u.onUploadCallback()}function o(c){return c.isInterleavedBufferAttribute&&(c=c.data),r.get(c)}function a(c){c.isInterleavedBufferAttribute&&(c=c.data);let u=r.get(c);u&&(n.deleteBuffer(u.buffer),r.delete(c))}function l(c,u){if(c.isGLBufferAttribute){let d=r.get(c);(!d||d.version 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 * transposeMat3( 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 ); } float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( specularColor, 1.0, dotVH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } #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`,pk=`#ifdef USE_IRIDESCENCE const mat3 XYZ_TO_REC709 = mat3( 3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.0415560, 1.0572252 ); vec3 Fresnel0ToIor( vec3 fresnel0 ) { vec3 sqrtF0 = sqrt( fresnel0 ); return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); } vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); } float IorToFresnel0( float transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); } vec3 evalSensitivity( float OPD, vec3 shift ) { float phase = 2.0 * PI * OPD * 1.0e-9; vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); xyz /= 1.0685e-7; vec3 rgb = XYZ_TO_REC709 * xyz; return rgb; } vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { vec3 I; float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); float cosTheta2Sq = 1.0 - sinTheta2Sq; if ( cosTheta2Sq < 0.0 ) { return vec3( 1.0 ); } float cosTheta2 = sqrt( cosTheta2Sq ); float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); float R12 = F_Schlick( R0, 1.0, cosTheta1 ); float R21 = R12; float T121 = 1.0 - R12; float phi12 = 0.0; if ( iridescenceIOR < outsideIOR ) phi12 = PI; float phi21 = PI - phi12; vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); vec3 phi23 = vec3( 0.0 ); if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; vec3 phi = vec3( phi21 ) + phi23; vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); vec3 r123 = sqrt( R123 ); vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); vec3 C0 = R12 + Rs; I = C0; vec3 Cm = Rs - T121; for ( int m = 1; m <= 2; ++ m ) { Cm *= r123; vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); I += Cm * Sm; } return max( I, vec3( 0.0 ) ); } #endif`,mk=`#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vUv ); vec2 dSTdy = dFdy( vUv ); float Hll = bumpScale * texture2D( bumpMap, vUv ).x; float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { vec3 vSigmaX = dFdx( surf_pos.xyz ); vec3 vSigmaY = dFdy( surf_pos.xyz ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`,gk=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #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`,yk=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,vk=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,xk=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,bk=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,Sk=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,wk=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,Ak=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif`,Ek=`#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; }; struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; #ifdef USE_CLEARCOAT vec3 clearcoatNormal; #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 ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } float luminance( const in vec3 rgb ) { const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); return dot( weights, rgb ); } 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 ); }`,Tk=`#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_v0 0.339 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_v1 0.276 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_v4 0.046 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_v5 0.016 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_v6 0.0038 #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`,Mk=`vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 m = mat3( instanceMatrix ); transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); transformedNormal = m * transformedNormal; #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,Ck=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,Pk=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`,_k=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,Ik=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,Dk="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ok=`vec4 LinearToLinear( in vec4 value ) { return value; } vec4 LinearTosRGB( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`,Rk=`#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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,Lk=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,Bk=`#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`,Nk=`#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`,Fk=`#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`,Vk=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,kk=`#ifdef USE_FOG varying float vFogDepth; #endif`,Uk=`#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`,zk=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,Gk=`#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 }`,jk=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,Hk=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,Wk=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,qk=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, 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`,Yk=`uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; 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 ) { #if defined ( PHYSICALLY_CORRECT_LIGHTS ) float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; #else if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); } return 1.0; #endif } 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, const in GeometricContext geometry, 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 GeometricContext geometry, out IncidentLight light ) { vec3 lVector = pointLight.position - geometry.position; 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 GeometricContext geometry, out IncidentLight light ) { vec3 lVector = spotLight.position - geometry.position; 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`,Xk=`#if defined( USE_ENVMAP ) vec3 getIBLIrradiance( const in vec3 normal ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, 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 ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #endif`,Kk=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,Qk=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, 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`,Zk=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,Jk=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, 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`,$k=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); 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 SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULARINTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; #endif #ifdef USE_SPECULARCOLORMAP specularColorFactor *= texture2D( specularColorMap, vUv ).rgb; #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 = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), 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, vUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).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_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEENCOLORMAP material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEENROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; #endif #endif`,eU=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; #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; #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 }; vec3 clearcoatSpecular = vec3( 0.0 ); vec3 sheenSpecular = vec3( 0.0 ); 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 a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); 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 vec2 fab = DFGApprox( normal, viewDir, roughness ); #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; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometry.normal; vec3 viewDir = geometry.viewDir; vec3 position = geometry.position; 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.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); #endif #ifdef USE_IRIDESCENCE reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness ); #else reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); #endif reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #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 ); }`,tU=` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef USE_CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometry.viewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); 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, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometry, 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, geometry, 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.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, 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, geometry, 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.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, 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, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,rU=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometry.normal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); #endif #endif`,iU=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,nU=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,sU=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,oU=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,aU=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #else if ( isPerspectiveMatrix( projectionMatrix ) ) { gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; gl_Position.z *= gl_Position.w; } #endif #endif`,lU=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; #endif`,cU=`#ifdef USE_MAP uniform sampler2D map; #endif`,uU=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,hU=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,dU=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`,fU=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,pU=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) 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`,mU=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #else objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif #endif`,gU=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; 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 ); } #else #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif #endif`,yU=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #else transformed += morphTarget0 * morphTargetInfluences[ 0 ]; transformed += morphTarget1 * morphTargetInfluences[ 1 ]; transformed += morphTarget2 * morphTargetInfluences[ 2 ]; transformed += morphTarget3 * morphTargetInfluences[ 3 ]; #ifndef USE_MORPHNORMALS transformed += morphTarget4 * morphTargetInfluences[ 4 ]; transformed += morphTarget5 * morphTargetInfluences[ 5 ]; transformed += morphTarget6 * morphTargetInfluences[ 6 ]; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif #endif`,vU=`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 = normal * faceDirection; #endif #ifdef USE_TANGENT vec3 tangent = normalize( vTangent ); vec3 bitangent = normalize( vBitangent ); #ifdef DOUBLE_SIDED tangent = tangent * faceDirection; bitangent = bitangent * faceDirection; #endif #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) mat3 vTBN = mat3( tangent, bitangent, normal ); #endif #endif #endif vec3 geometryNormal = normal;`,xU=`#ifdef OBJECTSPACE_NORMALMAP normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( TANGENTSPACE_NORMALMAP ) vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; #ifdef USE_TANGENT normal = normalize( vTBN * mapN ); #else normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection ); #endif #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,bU=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,SU=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,wU=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,AU=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef OBJECTSPACE_NORMALMAP uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( vUv.st ); vec2 st1 = dFdy( vUv.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 : faceDirection * inversesqrt( det ); return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); } #endif`,EU=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,TU=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; #ifdef USE_TANGENT clearcoatNormal = normalize( vTBN * clearcoatMapN ); #else clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); #endif #endif`,MU=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif`,CU=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,PU=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha + 0.1; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,_U=`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 vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); const float ShiftRight8 = 1. / 256.; vec4 packDepthToRGBA( const in float v ) { vec4 r = vec4( fract( v * PackFactors ), v ); r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors ); } vec2 packDepthToRG( in highp float v ) { return packDepthToRGBA( v ).yx; } float unpackRGToDepth( const in highp vec2 v ) { return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); } vec4 pack2HalfToRGBA( 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( 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 linearClipZ, const in float near, const in float far ) { return linearClipZ * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * invClipZ - far ); }`,IU=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,DU=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,OU=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,RU=`#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`,LU=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`,BU=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,NU=`#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 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, 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 ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); vec3 lightToPosition = shadowCoord.xyz; float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; return ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } #endif`,FU=`#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 shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { 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 shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,VU=`#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`,kU=`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.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.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 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.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,UU=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,zU=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; uniform int boneTextureSize; mat4 getBoneMatrix( const in float i ) { float j = i * 4.0; float x = mod( j, float( boneTextureSize ) ); float y = floor( j / float( boneTextureSize ) ); float dx = 1.0 / float( boneTextureSize ); float dy = 1.0 / float( boneTextureSize ); y = dy * ( y + 0.5 ); vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); mat4 bone = mat4( v1, v2, v3, v4 ); return bone; } #endif`,GU=`#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`,jU=`#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`,HU=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,WU=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,qU=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,YU=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return toneMappingExposure * color; } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 OptimizedCineonToneMapping( 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 ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,XU=`#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, vUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmission = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission ); #endif`,KU=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; 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 framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); #ifdef texture2DLodEXT return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #else return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #endif } vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return radiance; } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; } } 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 ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { 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; vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); } #endif`,QU=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`,ZU=`#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`,JU=`#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`,$U=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`,ez=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`,tz=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`,rz=`#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_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`,iz=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,nz=`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 }`,sz=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,oz=`#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; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,az=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,lz=`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 }`,cz=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,uz=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif }`,hz=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,dz=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,fz=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,pz=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,mz=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include }`,gz=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,yz=`#include #include #include #include #include #include #include #include #include #include void main() { #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 }`,vz=`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() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #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, vUv2 ); 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 }`,xz=`#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 vViewPosition = - mvPosition.xyz; #include #include #include #include }`,bz=`#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 void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); 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 #include }`,Sz=`#define MATCAP varying vec3 vViewPosition; #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 vViewPosition = - mvPosition.xyz; }`,wz=`#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 void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #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 }`,Az=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,Ez=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,Tz=`#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 vViewPosition = - mvPosition.xyz; #include #include #include #include }`,Mz=`#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 void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); 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 + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,Cz=`#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 vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,Pz=`#define STANDARD #ifdef PHYSICAL #define IOR #define SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULARINTENSITYMAP uniform sampler2D specularIntensityMap; #endif #ifdef USE_SPECULARCOLORMAP uniform sampler2D specularColorMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #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_SHEENCOLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEENROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #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 #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); 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 vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; #endif #include #include #include #include #include #include }`,_z=`#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 vViewPosition = - mvPosition.xyz; #include #include #include }`,Iz=`#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 #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); 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 vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,Dz=`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #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 }`,Oz=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,Rz=`#include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include }`,Lz=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,Bz=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); #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 }`,Nz=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,xt={alphamap_fragment:sk,alphamap_pars_fragment:ok,alphatest_fragment:ak,alphatest_pars_fragment:lk,aomap_fragment:ck,aomap_pars_fragment:uk,begin_vertex:hk,beginnormal_vertex:dk,bsdfs:fk,iridescence_fragment:pk,bumpmap_pars_fragment:mk,clipping_planes_fragment:gk,clipping_planes_pars_fragment:yk,clipping_planes_pars_vertex:vk,clipping_planes_vertex:xk,color_fragment:bk,color_pars_fragment:Sk,color_pars_vertex:wk,color_vertex:Ak,common:Ek,cube_uv_reflection_fragment:Tk,defaultnormal_vertex:Mk,displacementmap_pars_vertex:Ck,displacementmap_vertex:Pk,emissivemap_fragment:_k,emissivemap_pars_fragment:Ik,encodings_fragment:Dk,encodings_pars_fragment:Ok,envmap_fragment:Rk,envmap_common_pars_fragment:Lk,envmap_pars_fragment:Bk,envmap_pars_vertex:Nk,envmap_physical_pars_fragment:Xk,envmap_vertex:Fk,fog_vertex:Vk,fog_pars_vertex:kk,fog_fragment:Uk,fog_pars_fragment:zk,gradientmap_pars_fragment:Gk,lightmap_fragment:jk,lightmap_pars_fragment:Hk,lights_lambert_fragment:Wk,lights_lambert_pars_fragment:qk,lights_pars_begin:Yk,lights_toon_fragment:Kk,lights_toon_pars_fragment:Qk,lights_phong_fragment:Zk,lights_phong_pars_fragment:Jk,lights_physical_fragment:$k,lights_physical_pars_fragment:eU,lights_fragment_begin:tU,lights_fragment_maps:rU,lights_fragment_end:iU,logdepthbuf_fragment:nU,logdepthbuf_pars_fragment:sU,logdepthbuf_pars_vertex:oU,logdepthbuf_vertex:aU,map_fragment:lU,map_pars_fragment:cU,map_particle_fragment:uU,map_particle_pars_fragment:hU,metalnessmap_fragment:dU,metalnessmap_pars_fragment:fU,morphcolor_vertex:pU,morphnormal_vertex:mU,morphtarget_pars_vertex:gU,morphtarget_vertex:yU,normal_fragment_begin:vU,normal_fragment_maps:xU,normal_pars_fragment:bU,normal_pars_vertex:SU,normal_vertex:wU,normalmap_pars_fragment:AU,clearcoat_normal_fragment_begin:EU,clearcoat_normal_fragment_maps:TU,clearcoat_pars_fragment:MU,iridescence_pars_fragment:CU,output_fragment:PU,packing:_U,premultiplied_alpha_fragment:IU,project_vertex:DU,dithering_fragment:OU,dithering_pars_fragment:RU,roughnessmap_fragment:LU,roughnessmap_pars_fragment:BU,shadowmap_pars_fragment:NU,shadowmap_pars_vertex:FU,shadowmap_vertex:VU,shadowmask_pars_fragment:kU,skinbase_vertex:UU,skinning_pars_vertex:zU,skinning_vertex:GU,skinnormal_vertex:jU,specularmap_fragment:HU,specularmap_pars_fragment:WU,tonemapping_fragment:qU,tonemapping_pars_fragment:YU,transmission_fragment:XU,transmission_pars_fragment:KU,uv_pars_fragment:QU,uv_pars_vertex:ZU,uv_vertex:JU,uv2_pars_fragment:$U,uv2_pars_vertex:ez,uv2_vertex:tz,worldpos_vertex:rz,background_vert:iz,background_frag:nz,backgroundCube_vert:sz,backgroundCube_frag:oz,cube_vert:az,cube_frag:lz,depth_vert:cz,depth_frag:uz,distanceRGBA_vert:hz,distanceRGBA_frag:dz,equirect_vert:fz,equirect_frag:pz,linedashed_vert:mz,linedashed_frag:gz,meshbasic_vert:yz,meshbasic_frag:vz,meshlambert_vert:xz,meshlambert_frag:bz,meshmatcap_vert:Sz,meshmatcap_frag:wz,meshnormal_vert:Az,meshnormal_frag:Ez,meshphong_vert:Tz,meshphong_frag:Mz,meshphysical_vert:Cz,meshphysical_frag:Pz,meshtoon_vert:_z,meshtoon_frag:Iz,points_vert:Dz,points_frag:Oz,shadow_vert:Rz,shadow_frag:Lz,sprite_vert:Bz,sprite_frag:Nz},Ie={common:{diffuse:{value:new We(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new fr},uv2Transform:{value:new fr},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new k(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new We(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new We(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new fr}},sprite:{diffuse:{value:new We(16777215)},opacity:{value:1},center:{value:new k(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new fr}}},fo={basic:{uniforms:pn([Ie.common,Ie.specularmap,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.fog]),vertexShader:xt.meshbasic_vert,fragmentShader:xt.meshbasic_frag},lambert:{uniforms:pn([Ie.common,Ie.specularmap,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.fog,Ie.lights,{emissive:{value:new We(0)}}]),vertexShader:xt.meshlambert_vert,fragmentShader:xt.meshlambert_frag},phong:{uniforms:pn([Ie.common,Ie.specularmap,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.fog,Ie.lights,{emissive:{value:new We(0)},specular:{value:new We(1118481)},shininess:{value:30}}]),vertexShader:xt.meshphong_vert,fragmentShader:xt.meshphong_frag},standard:{uniforms:pn([Ie.common,Ie.envmap,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.roughnessmap,Ie.metalnessmap,Ie.fog,Ie.lights,{emissive:{value:new We(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:xt.meshphysical_vert,fragmentShader:xt.meshphysical_frag},toon:{uniforms:pn([Ie.common,Ie.aomap,Ie.lightmap,Ie.emissivemap,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.gradientmap,Ie.fog,Ie.lights,{emissive:{value:new We(0)}}]),vertexShader:xt.meshtoon_vert,fragmentShader:xt.meshtoon_frag},matcap:{uniforms:pn([Ie.common,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,Ie.fog,{matcap:{value:null}}]),vertexShader:xt.meshmatcap_vert,fragmentShader:xt.meshmatcap_frag},points:{uniforms:pn([Ie.points,Ie.fog]),vertexShader:xt.points_vert,fragmentShader:xt.points_frag},dashed:{uniforms:pn([Ie.common,Ie.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:xt.linedashed_vert,fragmentShader:xt.linedashed_frag},depth:{uniforms:pn([Ie.common,Ie.displacementmap]),vertexShader:xt.depth_vert,fragmentShader:xt.depth_frag},normal:{uniforms:pn([Ie.common,Ie.bumpmap,Ie.normalmap,Ie.displacementmap,{opacity:{value:1}}]),vertexShader:xt.meshnormal_vert,fragmentShader:xt.meshnormal_frag},sprite:{uniforms:pn([Ie.sprite,Ie.fog]),vertexShader:xt.sprite_vert,fragmentShader:xt.sprite_frag},background:{uniforms:{uvTransform:{value:new fr},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:xt.background_vert,fragmentShader:xt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:xt.backgroundCube_vert,fragmentShader:xt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:xt.cube_vert,fragmentShader:xt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:xt.equirect_vert,fragmentShader:xt.equirect_frag},distanceRGBA:{uniforms:pn([Ie.common,Ie.displacementmap,{referencePosition:{value:new E},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:xt.distanceRGBA_vert,fragmentShader:xt.distanceRGBA_frag},shadow:{uniforms:pn([Ie.lights,Ie.fog,{color:{value:new We(0)},opacity:{value:1}}]),vertexShader:xt.shadow_vert,fragmentShader:xt.shadow_frag}};fo.physical={uniforms:pn([fo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new k(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new We(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new k},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new We(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new We(1,1,1)},specularColorMap:{value:null}}]),vertexShader:xt.meshphysical_vert,fragmentShader:xt.meshphysical_frag};var Yg={r:0,b:0,g:0};function Fz(n,t,e,r,i,s,o){let a=new We(0),l=s===!0?0:1,c,u,h=null,d=0,f=null;function p(g,y){let v=!1,x=y.isScene===!0?y.background:null;x&&x.isTexture&&(x=(y.backgroundBlurriness>0?e:t).get(x));let S=n.xr,w=S.getSession&&S.getSession();w&&w.environmentBlendMode==="additive"&&(x=null),x===null?m(a,l):x&&x.isColor&&(m(x,1),v=!0),(n.autoClear||v)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),x&&(x.isCubeTexture||x.mapping===th)?(u===void 0&&(u=new Ut(new mi(1,1,1),new it({name:"BackgroundCubeMaterial",uniforms:Nu(fo.backgroundCube.uniforms),vertexShader:fo.backgroundCube.vertexShader,fragmentShader:fo.backgroundCube.fragmentShader,side:pi,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(A,T,b){this.matrixWorld.copyPosition(b.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=x,u.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.toneMapped=x.encoding!==at,(h!==x||d!==x.version||f!==n.toneMapping)&&(u.material.needsUpdate=!0,h=x,d=x.version,f=n.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null)):x&&x.isTexture&&(c===void 0&&(c=new Ut(new Li(2,2),new it({name:"BackgroundMaterial",uniforms:Nu(fo.background.uniforms),vertexShader:fo.background.vertexShader,fragmentShader:fo.background.fragmentShader,side:Hn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=x,c.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,c.material.toneMapped=x.encoding!==at,x.matrixAutoUpdate===!0&&x.updateMatrix(),c.material.uniforms.uvTransform.value.copy(x.matrix),(h!==x||d!==x.version||f!==n.toneMapping)&&(c.material.needsUpdate=!0,h=x,d=x.version,f=n.toneMapping),c.layers.enableAll(),g.unshift(c,c.geometry,c.material,0,0,null))}function m(g,y){g.getRGB(Yg,pP(n)),r.buffers.color.setClear(Yg.r,Yg.g,Yg.b,y,o)}return{getClearColor:function(){return a},setClearColor:function(g,y=1){a.set(g),l=y,m(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(g){l=g,m(a,l)},render:p}}function Vz(n,t,e,r){let i=n.getParameter(34921),s=r.isWebGL2?null:t.get("OES_vertex_array_object"),o=r.isWebGL2||s!==null,a={},l=g(null),c=l,u=!1;function h(D,L,j,V,H){let W=!1;if(o){let q=m(V,j,L);c!==q&&(c=q,f(c.object)),W=y(D,V,j,H),W&&v(D,V,j,H)}else{let q=L.wireframe===!0;(c.geometry!==V.id||c.program!==j.id||c.wireframe!==q)&&(c.geometry=V.id,c.program=j.id,c.wireframe=q,W=!0)}H!==null&&e.update(H,34963),(W||u)&&(u=!1,b(D,L,j,V),H!==null&&n.bindBuffer(34963,e.get(H).buffer))}function d(){return r.isWebGL2?n.createVertexArray():s.createVertexArrayOES()}function f(D){return r.isWebGL2?n.bindVertexArray(D):s.bindVertexArrayOES(D)}function p(D){return r.isWebGL2?n.deleteVertexArray(D):s.deleteVertexArrayOES(D)}function m(D,L,j){let V=j.wireframe===!0,H=a[D.id];H===void 0&&(H={},a[D.id]=H);let W=H[L.id];W===void 0&&(W={},H[L.id]=W);let q=W[V];return q===void 0&&(q=g(d()),W[V]=q),q}function g(D){let L=[],j=[],V=[];for(let H=0;H=0){let te=H[G],$=W[G];if($===void 0&&(G==="instanceMatrix"&&D.instanceMatrix&&($=D.instanceMatrix),G==="instanceColor"&&D.instanceColor&&($=D.instanceColor)),te===void 0||te.attribute!==$||$&&te.data!==$.data)return!0;q++}return c.attributesNum!==q||c.index!==V}function v(D,L,j,V){let H={},W=L.attributes,q=0,Q=j.getAttributes();for(let G in Q)if(Q[G].location>=0){let te=W[G];te===void 0&&(G==="instanceMatrix"&&D.instanceMatrix&&(te=D.instanceMatrix),G==="instanceColor"&&D.instanceColor&&(te=D.instanceColor));let $={};$.attribute=te,te&&te.data&&($.data=te.data),H[G]=$,q++}c.attributes=H,c.attributesNum=q,c.index=V}function x(){let D=c.newAttributes;for(let L=0,j=D.length;L=0){let Z=H[Q];if(Z===void 0&&(Q==="instanceMatrix"&&D.instanceMatrix&&(Z=D.instanceMatrix),Q==="instanceColor"&&D.instanceColor&&(Z=D.instanceColor)),Z!==void 0){let te=Z.normalized,$=Z.itemSize,Y=e.get(Z);if(Y===void 0)continue;let oe=Y.buffer,ie=Y.type,re=Y.bytesPerElement;if(Z.isInterleavedBufferAttribute){let J=Z.data,Ae=J.stride,xe=Z.offset;if(J.isInstancedInterleavedBuffer){for(let de=0;de0&&n.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";T="mediump"}return T==="mediump"&&n.getShaderPrecisionFormat(35633,36337).precision>0&&n.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&n instanceof WebGL2RenderingContext,a=e.precision!==void 0?e.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let c=o||t.has("WEBGL_draw_buffers"),u=e.logarithmicDepthBuffer===!0,h=n.getParameter(34930),d=n.getParameter(35660),f=n.getParameter(3379),p=n.getParameter(34076),m=n.getParameter(34921),g=n.getParameter(36347),y=n.getParameter(36348),v=n.getParameter(36349),x=d>0,S=o||t.has("OES_texture_float"),w=x&&S,A=o?n.getParameter(36183):0;return{isWebGL2:o,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:g,maxVaryings:y,maxFragmentUniforms:v,vertexTextures:x,floatFragmentTextures:S,floatVertexTextures:w,maxSamples:A}}function zz(n){let t=this,e=null,r=0,i=!1,s=!1,o=new kr,a=new fr,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){let f=h.length!==0||d||r!==0||i;return i=d,r=h.length,f},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){e=u(h,d,0)},this.setState=function(h,d,f){let p=h.clippingPlanes,m=h.clipIntersection,g=h.clipShadows,y=n.get(h);if(!i||p===null||p.length===0||s&&!g)s?u(null):c();else{let v=s?0:r,x=v*4,S=y.clippingState||null;l.value=S,S=u(p,d,x,f);for(let w=0;w!==x;++w)S[w]=e[w];y.clippingState=S,this.numIntersection=m?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(h,d,f,p){let m=h!==null?h.length:0,g=null;if(m!==0){if(g=l.value,p!==!0||g===null){let y=f+m*4,v=d.matrixWorldInverse;a.getNormalMatrix(v),(g===null||g.length0){let c=new cw(l.height/2);return c.fromEquirectangularTexture(n,o),t.set(o,c),o.addEventListener("dispose",i),e(c.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let l=t.get(a);l!==void 0&&(t.delete(a),l.dispose())}function s(){t=new WeakMap}return{get:r,dispose:s}}var nl=class extends qn{constructor(t=-1,e=1,r=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=r,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,r,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=r-t,o=r+t,a=i+e,l=i-e;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},Ru=4,mC=[.125,.215,.35,.446,.526,.582],gc=20,qS=new nl,gC=new We,YS=null,mc=(1+Math.sqrt(5))/2,_u=1/mc,yC=[new E(1,1,1),new E(-1,1,1),new E(1,1,-1),new E(-1,1,-1),new E(0,mc,_u),new E(0,mc,-_u),new E(_u,0,mc),new E(-_u,0,mc),new E(mc,_u,0),new E(-mc,_u,0)],my=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,r=.1,i=100){YS=this._renderer.getRenderTarget(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,r,i,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=bC(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=xC(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?x:0,x,x),u.setRenderTarget(i),m&&u.render(p,a),u.render(t,a)}p.geometry.dispose(),p.material.dispose(),u.toneMapping=d,u.autoClear=h,t.background=g}_textureToCubeUV(t,e){let r=this._renderer,i=t.mapping===tl||t.mapping===rl;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=bC()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=xC());let s=i?this._cubemapMaterial:this._equirectMaterial,o=new Ut(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=t;let l=this._cubeSize;Xg(e,0,0,3*l,2*l),r.setRenderTarget(e),r.render(o,qS)}_applyPMREM(t){let e=this._renderer,r=e.autoClear;e.autoClear=!1;for(let i=1;igc&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${gc}`);let y=[],v=0;for(let T=0;Tx-Ru?i-x+Ru:0),A=4*(this._cubeSize-S);Xg(e,w,A,3*S,2*S),l.setRenderTarget(e),l.render(h,qS)}};function jz(n){let t=[],e=[],r=[],i=n,s=n-Ru+1+mC.length;for(let o=0;on-Ru?l=mC[o-n+Ru-1]:o===0&&(l=0),r.push(l);let c=1/(a-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,p=6,m=3,g=2,y=1,v=new Float32Array(m*p*f),x=new Float32Array(g*p*f),S=new Float32Array(y*p*f);for(let A=0;A2?0:-1,M=[T,b,0,T+2/3,b,0,T+2/3,b+1,0,T,b,0,T+2/3,b+1,0,T,b+1,0];v.set(M,m*p*A),x.set(d,g*p*A);let C=[A,A,A,A,A,A];S.set(C,y*p*A)}let w=new _e;w.setAttribute("position",new Xe(v,m)),w.setAttribute("uv",new Xe(x,g)),w.setAttribute("faceIndex",new Xe(S,y)),t.push(w),i>Ru&&i--}return{lodPlanes:t,sizeLods:e,sigmas:r}}function vC(n,t,e){let r=new dt(n,t,e);return r.texture.mapping=th,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Xg(n,t,e,r,i){n.viewport.set(t,e,r,i),n.scissor.set(t,e,r,i)}function Hz(n,t,e){let r=new Float32Array(gc),i=new E(0,1,0);return new it({name:"SphericalGaussianBlur",defines:{n:gc,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:jw(),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:$t,depthTest:!1,depthWrite:!1})}function xC(){return new it({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:jw(),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:$t,depthTest:!1,depthWrite:!1})}function bC(){return new it({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:jw(),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:$t,depthTest:!1,depthWrite:!1})}function jw(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function Wz(n){let t=new WeakMap,e=null;function r(a){if(a&&a.isTexture){let l=a.mapping,c=l===rw||l===iw,u=l===tl||l===rl;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=t.get(a);return e===null&&(e=new my(n)),h=c?e.fromEquirectangular(a,h):e.fromCubemap(a,h),t.set(a,h),h.texture}else{if(t.has(a))return t.get(a).texture;{let h=a.image;if(c&&h&&h.height>0||u&&h&&i(h)){e===null&&(e=new my(n));let d=c?e.fromEquirectangular(a):e.fromCubemap(a);return t.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function i(a){let l=0,c=6;for(let u=0;ut.maxTextureSize&&(P=Math.ceil(C/t.maxTextureSize),C=t.maxTextureSize);let I=new Float32Array(C*P*4*m),_=new hy(I,C,P,m);_.type=br,_.needsUpdate=!0;let D=M*4;for(let j=0;j0)return n;let i=t*e,s=SC[i];if(s===void 0&&(s=new Float32Array(i),SC[i]=s),t!==0){r.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=e,n[o].toArray(s,a)}return s}function Ai(n,t){if(n.length!==t.length)return!1;for(let e=0,r=n.length;e":" "} ${a}: ${e[o]}`)}return r.join(` `)}function jG(n){switch(n){case mn:return["Linear","( value )"];case at:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",n),["Linear","( value )"]}}function PC(n,t,e){let r=n.getShaderParameter(t,35713),i=n.getShaderInfoLog(t).trim();if(r&&i==="")return"";let s=/ERROR: 0:(\d+)/.exec(i);if(s){let o=parseInt(s[1]);return e.toUpperCase()+` `+i+` `+GG(n.getShaderSource(t),o)}else return i}function HG(n,t){let e=jG(t);return"vec4 "+n+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function WG(n,t){let e;switch(t){case sV:e="Linear";break;case oV:e="Reinhard";break;case aV:e="OptimizedCineon";break;case lV:e="ACESFilmic";break;case cV:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+n+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function qG(n){return[n.extensionDerivatives||!!n.envMapCubeUVHeight||n.bumpMap||n.tangentSpaceNormalMap||n.clearcoatNormalMap||n.flatShading||n.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap||n.transmission)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(op).join(` `)}function YG(n){let t=[];for(let e in n){let r=n[e];r!==!1&&t.push("#define "+e+" "+r)}return t.join(` `)}function XG(n,t){let e={},r=n.getProgramParameter(t,35721);for(let i=0;i/gm;function fw(n){return n.replace(KG,QG)}function QG(n,t){let e=xt[t];if(e===void 0)throw new Error("Can not resolve #include <"+t+">");return fw(e)}var ZG=/#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 DC(n){return n.replace(ZG,JG)}function JG(n,t,e,r){let i="";for(let s=parseInt(t);s0&&(g+=` `),y=[f,p].filter(op).join(` `),y.length>0&&(y+=` `)):(g=[OC(e),"#define SHADER_NAME "+e.shaderName,p,e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.supportsVertexTextures?"#define VERTEX_TEXTURES":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+u:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMap&&e.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",e.normalMap&&e.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.displacementMap&&e.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",e.specularColorMap?"#define USE_SPECULARCOLORMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEENCOLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",e.vertexTangents?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUvs?"#define USE_UV":"",e.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors&&e.isWebGL2?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(op).join(` `),y=[f,OC(e),"#define SHADER_NAME "+e.shaderName,p,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+u:"",e.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMap&&e.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",e.normalMap&&e.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",e.specularColorMap?"#define USE_SPECULARCOLORMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEENCOLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.vertexTangents?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUvs?"#define USE_UV":"",e.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Os?"#define TONE_MAPPING":"",e.toneMapping!==Os?xt.tonemapping_pars_fragment:"",e.toneMapping!==Os?WG("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",xt.encodings_pars_fragment,HG("linearToOutputTexel",e.outputEncoding),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` `].filter(op).join(` `)),o=fw(o),o=_C(o,e),o=IC(o,e),a=fw(a),a=_C(a,e),a=IC(a,e),o=DC(o),a=DC(a),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(v=`#version 300 es `,g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+g,y=["#define varying in",e.glslVersion===iC?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===iC?"":"#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(` `)+` `+y);let x=v+g+o,S=v+y+a,w=CC(i,35633,x),A=CC(i,35632,S);if(i.attachShader(m,w),i.attachShader(m,A),e.index0AttributeName!==void 0?i.bindAttribLocation(m,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(m,0,"position"),i.linkProgram(m),n.debug.checkShaderErrors){let M=i.getProgramInfoLog(m).trim(),C=i.getShaderInfoLog(w).trim(),P=i.getShaderInfoLog(A).trim(),I=!0,_=!0;if(i.getProgramParameter(m,35714)===!1){I=!1;let D=PC(i,w,"vertex"),L=PC(i,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(m,35715)+` Program Info Log: `+M+` `+D+` `+L)}else M!==""?console.warn("THREE.WebGLProgram: Program Info Log:",M):(C===""||P==="")&&(_=!1);_&&(this.diagnostics={runnable:I,programLog:M,vertexShader:{log:C,prefix:g},fragmentShader:{log:P,prefix:y}})}i.deleteShader(w),i.deleteShader(A);let T;this.getUniforms=function(){return T===void 0&&(T=new Bu(i,m)),T};let b;return this.getAttributes=function(){return b===void 0&&(b=XG(i,m)),b},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.name=e.shaderName,this.id=zG++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=A,this}var s4=0,pw=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,r=t.fragmentShader,i=this._getShaderStage(e),s=this._getShaderStage(r),o=this._getShaderCacheForMaterial(t);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let r of e)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,r=e.get(t);return r===void 0&&(r=new Set,e.set(t,r)),r}_getShaderStage(t){let e=this.shaderCache,r=e.get(t);return r===void 0&&(r=new mw(t),e.set(t,r)),r}},mw=class{constructor(t){this.id=s4++,this.code=t,this.usedTimes=0}};function o4(n,t,e,r,i,s,o){let a=new mp,l=new pw,c=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,d=i.vertexTextures,f=i.precision,p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(b,M,C,P,I){let _=P.fog,D=I.geometry,L=b.isMeshStandardMaterial?P.environment:null,j=(b.isMeshStandardMaterial?e:t).get(b.envMap||L),V=!!j&&j.mapping===th?j.image.height:null,H=p[b.type];b.precision!==null&&(f=i.getMaxPrecision(b.precision),f!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",f,"instead."));let W=D.morphAttributes.position||D.morphAttributes.normal||D.morphAttributes.color,q=W!==void 0?W.length:0,Q=0;D.morphAttributes.position!==void 0&&(Q=1),D.morphAttributes.normal!==void 0&&(Q=2),D.morphAttributes.color!==void 0&&(Q=3);let G,Z,te,$;if(H){let Ae=fo[H];G=Ae.vertexShader,Z=Ae.fragmentShader}else G=b.vertexShader,Z=b.fragmentShader,l.update(b),te=l.getVertexShaderID(b),$=l.getFragmentShaderID(b);let Y=n.getRenderTarget(),oe=b.alphaTest>0,ie=b.clearcoat>0,re=b.iridescence>0;return{isWebGL2:u,shaderID:H,shaderName:b.type,vertexShader:G,fragmentShader:Z,defines:b.defines,customVertexShaderID:te,customFragmentShaderID:$,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:f,instancing:I.isInstancedMesh===!0,instancingColor:I.isInstancedMesh===!0&&I.instanceColor!==null,supportsVertexTextures:d,outputEncoding:Y===null?n.outputEncoding:Y.isXRRenderTarget===!0?Y.texture.encoding:mn,map:!!b.map,matcap:!!b.matcap,envMap:!!j,envMapMode:j&&j.mapping,envMapCubeUVHeight:V,lightMap:!!b.lightMap,aoMap:!!b.aoMap,emissiveMap:!!b.emissiveMap,bumpMap:!!b.bumpMap,normalMap:!!b.normalMap,objectSpaceNormalMap:b.normalMapType===MV,tangentSpaceNormalMap:b.normalMapType===TV,decodeVideoTexture:!!b.map&&b.map.isVideoTexture===!0&&b.map.encoding===at,clearcoat:ie,clearcoatMap:ie&&!!b.clearcoatMap,clearcoatRoughnessMap:ie&&!!b.clearcoatRoughnessMap,clearcoatNormalMap:ie&&!!b.clearcoatNormalMap,iridescence:re,iridescenceMap:re&&!!b.iridescenceMap,iridescenceThicknessMap:re&&!!b.iridescenceThicknessMap,displacementMap:!!b.displacementMap,roughnessMap:!!b.roughnessMap,metalnessMap:!!b.metalnessMap,specularMap:!!b.specularMap,specularIntensityMap:!!b.specularIntensityMap,specularColorMap:!!b.specularColorMap,opaque:b.transparent===!1&&b.blending===$a,alphaMap:!!b.alphaMap,alphaTest:oe,gradientMap:!!b.gradientMap,sheen:b.sheen>0,sheenColorMap:!!b.sheenColorMap,sheenRoughnessMap:!!b.sheenRoughnessMap,transmission:b.transmission>0,transmissionMap:!!b.transmissionMap,thicknessMap:!!b.thicknessMap,combine:b.combine,vertexTangents:!!b.normalMap&&!!D.attributes.tangent,vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!D.attributes.color&&D.attributes.color.itemSize===4,vertexUvs:!!b.map||!!b.bumpMap||!!b.normalMap||!!b.specularMap||!!b.alphaMap||!!b.emissiveMap||!!b.roughnessMap||!!b.metalnessMap||!!b.clearcoatMap||!!b.clearcoatRoughnessMap||!!b.clearcoatNormalMap||!!b.iridescenceMap||!!b.iridescenceThicknessMap||!!b.displacementMap||!!b.transmissionMap||!!b.thicknessMap||!!b.specularIntensityMap||!!b.specularColorMap||!!b.sheenColorMap||!!b.sheenRoughnessMap,uvsVertexOnly:!(!!b.map||!!b.bumpMap||!!b.normalMap||!!b.specularMap||!!b.alphaMap||!!b.emissiveMap||!!b.roughnessMap||!!b.metalnessMap||!!b.clearcoatNormalMap||!!b.iridescenceMap||!!b.iridescenceThicknessMap||b.transmission>0||!!b.transmissionMap||!!b.thicknessMap||!!b.specularIntensityMap||!!b.specularColorMap||b.sheen>0||!!b.sheenColorMap||!!b.sheenRoughnessMap)&&!!b.displacementMap,fog:!!_,useFog:b.fog===!0,fogExp2:_&&_.isFogExp2,flatShading:!!b.flatShading,sizeAttenuation:b.sizeAttenuation,logarithmicDepthBuffer:h,skinning:I.isSkinnedMesh===!0,morphTargets:D.morphAttributes.position!==void 0,morphNormals:D.morphAttributes.normal!==void 0,morphColors:D.morphAttributes.color!==void 0,morphTargetsCount:q,morphTextureStride:Q,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:b.dithering,shadowMapEnabled:n.shadowMap.enabled&&C.length>0,shadowMapType:n.shadowMap.type,toneMapping:b.toneMapped?n.toneMapping:Os,physicallyCorrectLights:n.physicallyCorrectLights,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===fi,flipSided:b.side===pi,useDepthPacking:!!b.depthPacking,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionDerivatives:b.extensions&&b.extensions.derivatives,extensionFragDepth:b.extensions&&b.extensions.fragDepth,extensionDrawBuffers:b.extensions&&b.extensions.drawBuffers,extensionShaderTextureLOD:b.extensions&&b.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),customProgramCacheKey:b.customProgramCacheKey()}}function g(b){let M=[];if(b.shaderID?M.push(b.shaderID):(M.push(b.customVertexShaderID),M.push(b.customFragmentShaderID)),b.defines!==void 0)for(let C in b.defines)M.push(C),M.push(b.defines[C]);return b.isRawShaderMaterial===!1&&(y(M,b),v(M,b),M.push(n.outputEncoding)),M.push(b.customProgramCacheKey),M.join()}function y(b,M){b.push(M.precision),b.push(M.outputEncoding),b.push(M.envMapMode),b.push(M.envMapCubeUVHeight),b.push(M.combine),b.push(M.vertexUvs),b.push(M.fogExp2),b.push(M.sizeAttenuation),b.push(M.morphTargetsCount),b.push(M.morphAttributeCount),b.push(M.numDirLights),b.push(M.numPointLights),b.push(M.numSpotLights),b.push(M.numSpotLightMaps),b.push(M.numHemiLights),b.push(M.numRectAreaLights),b.push(M.numDirLightShadows),b.push(M.numPointLightShadows),b.push(M.numSpotLightShadows),b.push(M.numSpotLightShadowsWithMaps),b.push(M.shadowMapType),b.push(M.toneMapping),b.push(M.numClippingPlanes),b.push(M.numClipIntersection),b.push(M.depthPacking)}function v(b,M){a.disableAll(),M.isWebGL2&&a.enable(0),M.supportsVertexTextures&&a.enable(1),M.instancing&&a.enable(2),M.instancingColor&&a.enable(3),M.map&&a.enable(4),M.matcap&&a.enable(5),M.envMap&&a.enable(6),M.lightMap&&a.enable(7),M.aoMap&&a.enable(8),M.emissiveMap&&a.enable(9),M.bumpMap&&a.enable(10),M.normalMap&&a.enable(11),M.objectSpaceNormalMap&&a.enable(12),M.tangentSpaceNormalMap&&a.enable(13),M.clearcoat&&a.enable(14),M.clearcoatMap&&a.enable(15),M.clearcoatRoughnessMap&&a.enable(16),M.clearcoatNormalMap&&a.enable(17),M.iridescence&&a.enable(18),M.iridescenceMap&&a.enable(19),M.iridescenceThicknessMap&&a.enable(20),M.displacementMap&&a.enable(21),M.specularMap&&a.enable(22),M.roughnessMap&&a.enable(23),M.metalnessMap&&a.enable(24),M.gradientMap&&a.enable(25),M.alphaMap&&a.enable(26),M.alphaTest&&a.enable(27),M.vertexColors&&a.enable(28),M.vertexAlphas&&a.enable(29),M.vertexUvs&&a.enable(30),M.vertexTangents&&a.enable(31),M.uvsVertexOnly&&a.enable(32),b.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.skinning&&a.enable(4),M.morphTargets&&a.enable(5),M.morphNormals&&a.enable(6),M.morphColors&&a.enable(7),M.premultipliedAlpha&&a.enable(8),M.shadowMapEnabled&&a.enable(9),M.physicallyCorrectLights&&a.enable(10),M.doubleSided&&a.enable(11),M.flipSided&&a.enable(12),M.useDepthPacking&&a.enable(13),M.dithering&&a.enable(14),M.specularIntensityMap&&a.enable(15),M.specularColorMap&&a.enable(16),M.transmission&&a.enable(17),M.transmissionMap&&a.enable(18),M.thicknessMap&&a.enable(19),M.sheen&&a.enable(20),M.sheenColorMap&&a.enable(21),M.sheenRoughnessMap&&a.enable(22),M.decodeVideoTexture&&a.enable(23),M.opaque&&a.enable(24),b.push(a.mask)}function x(b){let M=p[b.type],C;if(M){let P=fo[M];C=Ns.clone(P.uniforms)}else C=b.uniforms;return C}function S(b,M){let C;for(let P=0,I=c.length;P0?r.push(y):f.transparent===!0?i.push(y):e.push(y)}function l(h,d,f,p,m,g){let y=o(h,d,f,p,m,g);f.transmission>0?r.unshift(y):f.transparent===!0?i.unshift(y):e.unshift(y)}function c(h,d){e.length>1&&e.sort(h||l4),r.length>1&&r.sort(d||RC),i.length>1&&i.sort(d||RC)}function u(){for(let h=t,d=n.length;h=s.length?(o=new LC,s.push(o)):o=s[i],o}function e(){n=new WeakMap}return{get:t,dispose:e}}function u4(){let n={};return{get:function(t){if(n[t.id]!==void 0)return n[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new E,color:new We};break;case"SpotLight":e={position:new E,direction:new E,color:new We,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new E,color:new We,distance:0,decay:0};break;case"HemisphereLight":e={direction:new E,skyColor:new We,groundColor:new We};break;case"RectAreaLight":e={color:new We,position:new E,halfWidth:new E,halfHeight:new E};break}return n[t.id]=e,e}}}function h4(){let n={};return{get:function(t){if(n[t.id]!==void 0)return n[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new k};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new k};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new k,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[t.id]=e,e}}}var d4=0;function f4(n,t){return(t.castShadow?2:0)-(n.castShadow?2:0)+(t.map?1:0)-(n.map?1:0)}function p4(n,t){let e=new u4,r=h4(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let u=0;u<9;u++)i.probe.push(new E);let s=new E,o=new ue,a=new ue;function l(u,h){let d=0,f=0,p=0;for(let P=0;P<9;P++)i.probe[P].set(0,0,0);let m=0,g=0,y=0,v=0,x=0,S=0,w=0,A=0,T=0,b=0;u.sort(f4);let M=h!==!0?Math.PI:1;for(let P=0,I=u.length;P0&&(t.isWebGL2||n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ie.LTC_FLOAT_1,i.rectAreaLTC2=Ie.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Ie.LTC_HALF_1,i.rectAreaLTC2=Ie.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=p;let C=i.hash;(C.directionalLength!==m||C.pointLength!==g||C.spotLength!==y||C.rectAreaLength!==v||C.hemiLength!==x||C.numDirectionalShadows!==S||C.numPointShadows!==w||C.numSpotShadows!==A||C.numSpotMaps!==T)&&(i.directional.length=m,i.spot.length=y,i.rectArea.length=v,i.point.length=g,i.hemi.length=x,i.directionalShadow.length=S,i.directionalShadowMap.length=S,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=A,i.spotShadowMap.length=A,i.directionalShadowMatrix.length=S,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=A+T-b,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=b,C.directionalLength=m,C.pointLength=g,C.spotLength=y,C.rectAreaLength=v,C.hemiLength=x,C.numDirectionalShadows=S,C.numPointShadows=w,C.numSpotShadows=A,C.numSpotMaps=T,i.version=d4++)}function c(u,h){let d=0,f=0,p=0,m=0,g=0,y=h.matrixWorldInverse;for(let v=0,x=u.length;v=a.length?(l=new BC(n,t),a.push(l)):l=a[o],l}function i(){e=new WeakMap}return{get:r,dispose:i}}var yp=class extends bc{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Bi,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},gw=class extends bc{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new E,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}},g4=`void main() { gl_Position = vec4( position, 1.0 ); }`,y4=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include 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 = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function v4(n,t,e){let r=new gp,i=new k,s=new k,o=new Ze,a=new yp({depthPacking:zw}),l=new gw,c={},u=e.maxTextureSize,h={[Hn]:pi,[pi]:Hn,[fi]:fi},d=new it({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new k},radius:{value:4}},vertexShader:g4,fragmentShader:y4}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let p=new _e;p.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new Ut(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ly,this.render=function(S,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||S.length===0)return;let T=n.getRenderTarget(),b=n.getActiveCubeFace(),M=n.getActiveMipmapLevel(),C=n.state;C.setBlending($t),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let P=0,I=S.length;Pu||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/L.x),i.x=s.x*L.x,D.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/L.y),i.y=s.y*L.y,D.mapSize.y=s.y)),D.map===null){let V=this.type!==sp?{minFilter:Vt,magFilter:Vt}:{};D.map=new dt(i.x,i.y,V),D.map.texture.name=_.name+".shadowMap",D.camera.updateProjectionMatrix()}n.setRenderTarget(D.map),n.clear();let j=D.getViewportCount();for(let V=0;V0||w.map&&w.alphaTest>0){let I=C.uuid,_=w.uuid,D=c[I];D===void 0&&(D={},c[I]=D);let L=D[_];L===void 0&&(L=C.clone(),D[_]=L),C=L}return C.visible=w.visible,C.wireframe=w.wireframe,M===sp?C.side=w.shadowSide!==null?w.shadowSide:w.side:C.side=w.shadowSide!==null?w.shadowSide:h[w.side],C.alphaMap=w.alphaMap,C.alphaTest=w.alphaTest,C.map=w.map,C.clipShadows=w.clipShadows,C.clippingPlanes=w.clippingPlanes,C.clipIntersection=w.clipIntersection,C.displacementMap=w.displacementMap,C.displacementScale=w.displacementScale,C.displacementBias=w.displacementBias,C.wireframeLinewidth=w.wireframeLinewidth,C.linewidth=w.linewidth,A.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(A.matrixWorld),C.nearDistance=T,C.farDistance=b),C}function x(S,w,A,T,b){if(S.visible===!1)return;if(S.layers.test(w.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&b===sp)&&(!S.frustumCulled||r.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,S.matrixWorld);let P=t.update(S),I=S.material;if(Array.isArray(I)){let _=P.groups;for(let D=0,L=_.length;D=1):H.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),j=V>=2);let W=null,q={},Q=n.getParameter(3088),G=n.getParameter(2978),Z=new Ze().fromArray(Q),te=new Ze().fromArray(G);function $(K,ye,Me){let je=new Uint8Array(4),He=n.createTexture();n.bindTexture(K,He),n.texParameteri(K,10241,9728),n.texParameteri(K,10240,9728);for(let _t=0;_t"u"?!1:/OculusBrowser/g.test(navigator.userAgent),p=new WeakMap,m,g=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(N,B){return y?new OffscreenCanvas(N,B):pp("canvas")}function x(N,B,ae,ge){let me=1;if((N.width>ge||N.height>ge)&&(me=ge/Math.max(N.width,N.height)),me<1||B===!0)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap){let Le=B?ly:Math.floor,Ne=Le(me*N.width),Re=Le(me*N.height);m===void 0&&(m=v(Ne,Re));let pe=ae?v(Ne,Re):m;return pe.width=Ne,pe.height=Re,pe.getContext("2d").drawImage(N,0,0,Ne,Re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+N.width+"x"+N.height+") to ("+Ne+"x"+Re+")."),pe}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+N.width+"x"+N.height+")."),N;return N}function S(N){return aw(N.width)&&aw(N.height)}function w(N){return a?!1:N.wrapS!==Qt||N.wrapT!==Qt||N.minFilter!==Vt&&N.minFilter!==rt}function A(N,B){return N.generateMipmaps&&B&&N.minFilter!==Vt&&N.minFilter!==rt}function T(N){n.generateMipmap(N)}function b(N,B,ae,ge,me=!1){if(a===!1)return B;if(N!==null){if(n[N]!==void 0)return n[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let Le=B;return B===6403&&(ae===5126&&(Le=33326),ae===5131&&(Le=33325),ae===5121&&(Le=33321)),B===33319&&(ae===5126&&(Le=33328),ae===5131&&(Le=33327),ae===5121&&(Le=33323)),B===6408&&(ae===5126&&(Le=34836),ae===5131&&(Le=34842),ae===5121&&(Le=ge===at&&me===!1?35907:32856),ae===32819&&(Le=32854),ae===32820&&(Le=32855)),(Le===33325||Le===33326||Le===33327||Le===33328||Le===34842||Le===34836)&&t.get("EXT_color_buffer_float"),Le}function M(N,B,ae){return A(N,ae)===!0||N.isFramebufferTexture&&N.minFilter!==Vt&&N.minFilter!==rt?Math.log2(Math.max(B.width,B.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?B.mipmaps.length:1}function C(N){return N===Vt||N===RM||N===vS?9728:9729}function P(N){let B=N.target;B.removeEventListener("dispose",P),_(B),B.isVideoTexture&&p.delete(B)}function I(N){let B=N.target;B.removeEventListener("dispose",I),L(B)}function _(N){let B=r.get(N);if(B.__webglInit===void 0)return;let ae=N.source,ge=g.get(ae);if(ge){let me=ge[B.__cacheKey];me.usedTimes--,me.usedTimes===0&&D(N),Object.keys(ge).length===0&&g.delete(ae)}r.remove(N)}function D(N){let B=r.get(N);n.deleteTexture(B.__webglTexture);let ae=N.source,ge=g.get(ae);delete ge[B.__cacheKey],o.memory.textures--}function L(N){let B=N.texture,ae=r.get(N),ge=r.get(B);if(ge.__webglTexture!==void 0&&(n.deleteTexture(ge.__webglTexture),o.memory.textures--),N.depthTexture&&N.depthTexture.dispose(),N.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)n.deleteFramebuffer(ae.__webglFramebuffer[me]),ae.__webglDepthbuffer&&n.deleteRenderbuffer(ae.__webglDepthbuffer[me]);else{if(n.deleteFramebuffer(ae.__webglFramebuffer),ae.__webglDepthbuffer&&n.deleteRenderbuffer(ae.__webglDepthbuffer),ae.__webglMultisampledFramebuffer&&n.deleteFramebuffer(ae.__webglMultisampledFramebuffer),ae.__webglColorRenderbuffer)for(let me=0;me=l&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+l),j+=1,N}function W(N){let B=[];return B.push(N.wrapS),B.push(N.wrapT),B.push(N.wrapR||0),B.push(N.magFilter),B.push(N.minFilter),B.push(N.anisotropy),B.push(N.internalFormat),B.push(N.format),B.push(N.type),B.push(N.generateMipmaps),B.push(N.premultiplyAlpha),B.push(N.flipY),B.push(N.unpackAlignment),B.push(N.encoding),B.join()}function q(N,B){let ae=r.get(N);if(N.isVideoTexture&&Ye(N),N.isRenderTargetTexture===!1&&N.version>0&&ae.__version!==N.version){let ge=N.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(ae,N,B);return}}e.bindTexture(3553,ae.__webglTexture,33984+B)}function Q(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){ie(ae,N,B);return}e.bindTexture(35866,ae.__webglTexture,33984+B)}function G(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){ie(ae,N,B);return}e.bindTexture(32879,ae.__webglTexture,33984+B)}function Z(N,B){let ae=r.get(N);if(N.version>0&&ae.__version!==N.version){re(ae,N,B);return}e.bindTexture(34067,ae.__webglTexture,33984+B)}let te={[Rs]:10497,[Qt]:33071,[nw]:33648},$={[Vt]:9728,[RM]:9984,[vS]:9986,[rt]:9729,[uV]:9985,[xc]:9987};function Y(N,B,ae){if(ae?(n.texParameteri(N,10242,te[B.wrapS]),n.texParameteri(N,10243,te[B.wrapT]),(N===32879||N===35866)&&n.texParameteri(N,32882,te[B.wrapR]),n.texParameteri(N,10240,$[B.magFilter]),n.texParameteri(N,10241,$[B.minFilter])):(n.texParameteri(N,10242,33071),n.texParameteri(N,10243,33071),(N===32879||N===35866)&&n.texParameteri(N,32882,33071),(B.wrapS!==Qt||B.wrapT!==Qt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(N,10240,C(B.magFilter)),n.texParameteri(N,10241,C(B.minFilter)),B.minFilter!==Vt&&B.minFilter!==rt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let ge=t.get("EXT_texture_filter_anisotropic");if(B.magFilter===Vt||B.minFilter!==vS&&B.minFilter!==xc||B.type===br&&t.has("OES_texture_float_linear")===!1||a===!1&&B.type===Wn&&t.has("OES_texture_half_float_linear")===!1)return;(B.anisotropy>1||r.get(B).__currentAnisotropy)&&(n.texParameterf(N,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(B.anisotropy,i.getMaxAnisotropy())),r.get(B).__currentAnisotropy=B.anisotropy)}}function oe(N,B){let ae=!1;N.__webglInit===void 0&&(N.__webglInit=!0,B.addEventListener("dispose",P));let ge=B.source,me=g.get(ge);me===void 0&&(me={},g.set(ge,me));let Le=W(B);if(Le!==N.__cacheKey){me[Le]===void 0&&(me[Le]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,ae=!0),me[Le].usedTimes++;let Ne=me[N.__cacheKey];Ne!==void 0&&(me[N.__cacheKey].usedTimes--,Ne.usedTimes===0&&D(B)),N.__cacheKey=Le,N.__webglTexture=me[Le].texture}return ae}function ie(N,B,ae){let ge=3553;(B.isDataArrayTexture||B.isCompressedArrayTexture)&&(ge=35866),B.isData3DTexture&&(ge=32879);let me=oe(N,B),Le=B.source;e.bindTexture(ge,N.__webglTexture,33984+ae);let Ne=r.get(Le);if(Le.version!==Ne.__version||me===!0){e.activeTexture(33984+ae),n.pixelStorei(37440,B.flipY),n.pixelStorei(37441,B.premultiplyAlpha),n.pixelStorei(3317,B.unpackAlignment),n.pixelStorei(37443,0);let Re=w(B)&&S(B.image)===!1,pe=x(B.image,Re,!1,u);pe=F(B,pe);let nt=S(pe)||a,Ge=s.convert(B.format,B.encoding),Be=s.convert(B.type),et=b(B.internalFormat,Ge,Be,B.encoding,B.isVideoTexture);Y(ge,B,nt);let st,Bt=B.mipmaps,dr=a&&B.isVideoTexture!==!0,Tr=Ne.__version===void 0||me===!0,K=M(B,pe,nt);if(B.isDepthTexture)et=6402,a?B.type===br?et=36012:B.type===Ds?et=33190:B.type===el?et=35056:et=33189:B.type===br&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),B.format===yc&&et===6402&&B.type!==cP&&B.type!==Ds&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),B.type=Ds,Be=s.convert(B.type)),B.format===il&&et===6402&&(et=34041,B.type!==el&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),B.type=el,Be=s.convert(B.type))),Tr&&(dr?e.texStorage2D(3553,1,et,pe.width,pe.height):e.texImage2D(3553,0,et,pe.width,pe.height,0,Ge,Be,null));else if(B.isDataTexture)if(Bt.length>0&&nt){dr&&Tr&&e.texStorage2D(3553,K,et,Bt[0].width,Bt[0].height);for(let ye=0,Me=Bt.length;ye>=1,Me>>=1}}else if(Bt.length>0&&nt){dr&&Tr&&e.texStorage2D(3553,K,et,Bt[0].width,Bt[0].height);for(let ye=0,Me=Bt.length;ye0&&Tr++,e.texStorage2D(34067,Tr,st,pe[0].width,pe[0].height));for(let ye=0;ye<6;ye++)if(Re){Bt?e.texSubImage2D(34069+ye,0,0,0,pe[ye].width,pe[ye].height,Be,et,pe[ye].data):e.texImage2D(34069+ye,0,st,pe[ye].width,pe[ye].height,0,Be,et,pe[ye].data);for(let Me=0;Me=34069&&me<=34074)&&n.framebufferTexture2D(36160,ge,me,r.get(ae).__webglTexture,0),e.bindFramebuffer(36160,null)}function Ae(N,B,ae){if(n.bindRenderbuffer(36161,N),B.depthBuffer&&!B.stencilBuffer){let ge=33189;if(ae||Oe(B)){let me=B.depthTexture;me&&me.isDepthTexture&&(me.type===br?ge=36012:me.type===Ds&&(ge=33190));let Le=Ve(B);Oe(B)?d.renderbufferStorageMultisampleEXT(36161,Le,ge,B.width,B.height):n.renderbufferStorageMultisample(36161,Le,ge,B.width,B.height)}else n.renderbufferStorage(36161,ge,B.width,B.height);n.framebufferRenderbuffer(36160,36096,36161,N)}else if(B.depthBuffer&&B.stencilBuffer){let ge=Ve(B);ae&&Oe(B)===!1?n.renderbufferStorageMultisample(36161,ge,35056,B.width,B.height):Oe(B)?d.renderbufferStorageMultisampleEXT(36161,ge,35056,B.width,B.height):n.renderbufferStorage(36161,34041,B.width,B.height),n.framebufferRenderbuffer(36160,33306,36161,N)}else{let ge=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let me=0;me0&&Oe(N)===!1){let Re=Le?B:[B];ae.__webglMultisampledFramebuffer=n.createFramebuffer(),ae.__webglColorRenderbuffer=[],e.bindFramebuffer(36160,ae.__webglMultisampledFramebuffer);for(let pe=0;pe0&&Oe(N)===!1){let B=N.isWebGLMultipleRenderTargets?N.texture:[N.texture],ae=N.width,ge=N.height,me=16384,Le=[],Ne=N.stencilBuffer?33306:36096,Re=r.get(N),pe=N.isWebGLMultipleRenderTargets===!0;if(pe)for(let nt=0;nt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&B.__useRenderToTexture!==!1}function Ye(N){let B=o.render.frame;p.get(N)!==B&&(p.set(N,B),N.update())}function F(N,B){let ae=N.encoding,ge=N.format,me=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||N.format===ow||ae!==mn&&(ae===at?a===!1?t.has("EXT_sRGB")===!0&&ge===qr?(N.format=ow,N.minFilter=rt,N.generateMipmaps=!1):B=cy.sRGBToLinear(B):(ge!==qr||me!==_r)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ae)),B}this.allocateTextureUnit=H,this.resetTextureUnits=V,this.setTexture2D=q,this.setTexture2DArray=Q,this.setTexture3D=G,this.setTextureCube=Z,this.rebindTextures=De,this.setupRenderTarget=Ce,this.updateRenderTargetMipmap=ze,this.updateMultisampleRenderTarget=Ue,this.setupDepthRenderbuffer=de,this.setupFrameBufferTexture=J,this.useMultisampledRTT=Oe}function S4(n,t,e){let r=e.isWebGL2;function i(s,o=null){let a;if(s===_r)return 5121;if(s===pV)return 32819;if(s===mV)return 32820;if(s===hV)return 5120;if(s===dV)return 5122;if(s===cP)return 5123;if(s===fV)return 5124;if(s===Ds)return 5125;if(s===br)return 5126;if(s===Wn)return r?5131:(a=t.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===gV)return 6406;if(s===qr)return 6408;if(s===yV)return 6409;if(s===vV)return 6410;if(s===yc)return 6402;if(s===il)return 34041;if(s===ow)return a=t.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===xV)return 6403;if(s===bV)return 36244;if(s===rh)return 33319;if(s===SV)return 33320;if(s===Fw)return 36249;if(s===xS||s===bS||s===SS||s===wS)if(o===at)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===xS)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===bS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===SS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===wS)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===xS)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===bS)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===SS)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===wS)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===LM||s===BM||s===NM||s===FM)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===LM)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===BM)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===NM)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===FM)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===wV)return a=t.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===VM||s===kM)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(s===VM)return o===at?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===kM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===UM||s===zM||s===GM||s===jM||s===HM||s===WM||s===qM||s===YM||s===XM||s===KM||s===QM||s===ZM||s===JM||s===$M)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(s===UM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===zM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===GM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===jM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===HM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===WM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===qM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===YM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===XM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===KM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===QM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===ZM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===JM)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===$M)return o===at?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===AS)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(s===AS)return o===at?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(s===AV||s===eC||s===tC||s===rC)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(s===AS)return a.COMPRESSED_RED_RGTC1_EXT;if(s===eC)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===tC)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===rC)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===el?r?34042:(a=t.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:i}}var yw=class extends $r{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},sn=class extends Tt{constructor(){super(),this.isGroup=!0,this.type="Group"}},w4={type:"move"},cp=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new sn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new sn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new sn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let r of t.hand.values())this._getHandJoint(e,r)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,r){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){o=!0;for(let m of t.hand.values()){let g=e.getJointPose(m,r),y=this._getHandJoint(c,m);g!==null&&(y.matrix.fromArray(g.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.jointRadius=g.radius),y.visible=g!==null}let u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,p=.005;c.inputState.pinching&&d>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(w4)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let r=new sn;r.matrixAutoUpdate=!1,r.visible=!1,t.joints[e.jointName]=r,t.add(r)}return t.joints[e.jointName]}},ns=class extends er{constructor(t,e,r,i,s,o,a,l,c,u){if(u=u!==void 0?u:yc,u!==yc&&u!==il)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===yc&&(r=Ds),r===void 0&&u===il&&(r=el),super(null,i,s,o,a,l,u,r,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:Vt,this.minFilter=l!==void 0?l:Vt,this.flipY=!1,this.generateMipmaps=!1}},vw=class extends pr{constructor(t,e){super();let r=this,i=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,p=null,m=e.getContextAttributes(),g=null,y=null,v=[],x=[],S=new Set,w=new Map,A=new $r;A.layers.enable(1),A.viewport=new Ze;let T=new $r;T.layers.enable(2),T.viewport=new Ze;let b=[A,T],M=new yw;M.layers.enable(1),M.layers.enable(2);let C=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let Z=v[G];return Z===void 0&&(Z=new cp,v[G]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(G){let Z=v[G];return Z===void 0&&(Z=new cp,v[G]=Z),Z.getGripSpace()},this.getHand=function(G){let Z=v[G];return Z===void 0&&(Z=new cp,v[G]=Z),Z.getHandSpace()};function I(G){let Z=x.indexOf(G.inputSource);if(Z===-1)return;let te=v[Z];te!==void 0&&te.dispatchEvent({type:G.type,data:G.inputSource})}function _(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",_),i.removeEventListener("inputsourceschange",D);for(let G=0;G=0&&(x[$]=null,v[$].disconnect(te))}for(let Z=0;Z=x.length){x.push(te),$=oe;break}else if(x[oe]===null){x[oe]=te,$=oe;break}if($===-1)break}let Y=v[$];Y&&Y.connect(te)}}let L=new E,j=new E;function V(G,Z,te){L.setFromMatrixPosition(Z.matrixWorld),j.setFromMatrixPosition(te.matrixWorld);let $=L.distanceTo(j),Y=Z.projectionMatrix.elements,oe=te.projectionMatrix.elements,ie=Y[14]/(Y[10]-1),re=Y[14]/(Y[10]+1),J=(Y[9]+1)/Y[5],Ae=(Y[9]-1)/Y[5],xe=(Y[8]-1)/Y[0],de=(oe[8]+1)/oe[0],De=ie*xe,Ce=ie*de,ze=$/(-xe+de),Ue=ze*-xe;Z.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(Ue),G.translateZ(ze),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert();let Ve=ie+ze,Oe=re+ze,Ye=De-Ue,F=Ce+($-Ue),N=J*re/Oe*Ve,B=Ae*re/Oe*Ve;G.projectionMatrix.makePerspective(Ye,F,N,B,Ve,Oe)}function H(G,Z){Z===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(Z.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(i===null)return;M.near=T.near=A.near=G.near,M.far=T.far=A.far=G.far,(C!==M.near||P!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),C=M.near,P=M.far);let Z=G.parent,te=M.cameras;H(M,Z);for(let Y=0;YY&&(w.set($,$.lastChangedTime),r.dispatchEvent({type:"planechanged",data:$}))}}p=null}let Q=new mP;Q.setAnimationLoop(q),this.setAnimationLoop=function(G){W=G},this.dispose=function(){}}};function A4(n,t){function e(m,g){g.color.getRGB(m.fogColor.value,pP(n)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,y,v,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(m,g):g.isMeshToonMaterial?(i(m,g),u(m,g)):g.isMeshPhongMaterial?(i(m,g),c(m,g)):g.isMeshStandardMaterial?(i(m,g),h(m,g),g.isMeshPhysicalMaterial&&d(m,g,x)):g.isMeshMatcapMaterial?(i(m,g),f(m,g)):g.isMeshDepthMaterial?i(m,g):g.isMeshDistanceMaterial?(i(m,g),p(m,g)):g.isMeshNormalMaterial?i(m,g):g.isLineBasicMaterial?(s(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?a(m,g,y,v):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===pi&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===pi&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y=t.get(g).envMap;if(y&&(m.envMap.value=y,m.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let S=n.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*S}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let v;g.map?v=g.map:g.specularMap?v=g.specularMap:g.displacementMap?v=g.displacementMap:g.normalMap?v=g.normalMap:g.bumpMap?v=g.bumpMap:g.roughnessMap?v=g.roughnessMap:g.metalnessMap?v=g.metalnessMap:g.alphaMap?v=g.alphaMap:g.emissiveMap?v=g.emissiveMap:g.clearcoatMap?v=g.clearcoatMap:g.clearcoatNormalMap?v=g.clearcoatNormalMap:g.clearcoatRoughnessMap?v=g.clearcoatRoughnessMap:g.iridescenceMap?v=g.iridescenceMap:g.iridescenceThicknessMap?v=g.iridescenceThicknessMap:g.specularIntensityMap?v=g.specularIntensityMap:g.specularColorMap?v=g.specularColorMap:g.transmissionMap?v=g.transmissionMap:g.thicknessMap?v=g.thicknessMap:g.sheenColorMap?v=g.sheenColorMap:g.sheenRoughnessMap&&(v=g.sheenRoughnessMap),v!==void 0&&(v.isWebGLRenderTarget&&(v=v.texture),v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function s(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function a(m,g,y,v){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=v*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let y;g.map?y=g.map:g.alphaMap&&(y=g.alphaMap),y!==void 0&&(y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix))}function c(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,y){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===pi&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function p(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:e,refreshMaterialUniforms:r}}function E4(n,t,e,r){let i={},s={},o=[],a=e.isWebGL2?n.getParameter(35375):0;function l(v,x){let S=x.program;r.uniformBlockBinding(v,S)}function c(v,x){let S=i[v.id];S===void 0&&(p(v),S=u(v),i[v.id]=S,v.addEventListener("dispose",g));let w=x.program;r.updateUBOMapping(v,w);let A=t.render.frame;s[v.id]!==A&&(d(v),s[v.id]=A)}function u(v){let x=h();v.__bindingPointIndex=x;let S=n.createBuffer(),w=v.__size,A=v.usage;return n.bindBuffer(35345,S),n.bufferData(35345,w,A),n.bindBuffer(35345,null),n.bindBufferBase(35345,x,S),S}function h(){for(let v=0;v0){A=S%w;let I=w-A;A!==0&&I-C.boundary<0&&(S+=w-A,M.__offset=S)}S+=C.storage}return A=S%w,A>0&&(S+=w-A),v.__size=S,v.__cache={},this}function m(v){let x={boundary:0,storage:0};return typeof v=="number"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){let x=v.target;x.removeEventListener("dispose",g);let S=o.indexOf(x.__bindingPointIndex);o.splice(S,1),n.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function y(){for(let v in i)n.deleteBuffer(i[v]);o=[],i={},s={}}return{bind:l,update:c,dispose:y}}function T4(){let n=pp("canvas");return n.style.display="block",n}function Hw(n={}){this.isWebGLRenderer=!0;let t=n.canvas!==void 0?n.canvas:T4(),e=n.context!==void 0?n.context:null,r=n.depth!==void 0?n.depth:!0,i=n.stencil!==void 0?n.stencil:!0,s=n.antialias!==void 0?n.antialias:!1,o=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,a=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,l=n.powerPreference!==void 0?n.powerPreference:"default",c=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1,u;e!==null?u=e.getContextAttributes().alpha:u=n.alpha!==void 0?n.alpha:!1;let h=null,d=null,f=[],p=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=mn,this.physicallyCorrectLights=!1,this.toneMapping=Os,this.toneMappingExposure=1;let m=this,g=!1,y=0,v=0,x=null,S=-1,w=null,A=new Ze,T=new Ze,b=null,M=t.width,C=t.height,P=1,I=null,_=null,D=new Ze(0,0,M,C),L=new Ze(0,0,M,C),j=!1,V=new gp,H=!1,W=!1,q=null,Q=new ue,G=new k,Z=new E,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function $(){return x===null?P:1}let Y=e;function oe(z,ce){for(let ve=0;ve0?d=p[p.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function Fr(z,ce,ve,se){if(z.visible===!1)return;if(z.layers.test(ce.layers)){if(z.isGroup)ve=z.renderOrder;else if(z.isLOD)z.autoUpdate===!0&&z.update(ce);else if(z.isLight)d.pushLight(z),z.castShadow&&d.pushShadow(z);else if(z.isSprite){if(!z.frustumCulled||V.intersectsSprite(z)){se&&Z.setFromMatrixPosition(z.matrixWorld).applyMatrix4(Q);let mt=Ve.update(z),At=z.material;At.visible&&h.push(z,mt,At,ve,Z.z,null)}}else if((z.isMesh||z.isLine||z.isPoints)&&(z.isSkinnedMesh&&z.skeleton.frame!==Ae.render.frame&&(z.skeleton.update(),z.skeleton.frame=Ae.render.frame),!z.frustumCulled||V.intersectsObject(z))){se&&Z.setFromMatrixPosition(z.matrixWorld).applyMatrix4(Q);let mt=Ve.update(z),At=z.material;if(Array.isArray(At)){let Ct=mt.groups;for(let jt=0,Nt=Ct.length;jt0&&$o(be,ce,ve),se&&J.viewport(A.copy(se)),be.length>0&&Mr(be,ce,ve),ct.length>0&&Mr(ct,ce,ve),mt.length>0&&Mr(mt,ce,ve),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function $o(z,ce,ve){let se=re.isWebGL2;q===null&&(q=new dt(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?Wn:_r,minFilter:xc,samples:se&&s===!0?4:0})),m.getDrawingBufferSize(G),se?q.setSize(G.x,G.y):q.setSize(ly(G.x),ly(G.y));let be=m.getRenderTarget();m.setRenderTarget(q),m.clear();let ct=m.toneMapping;m.toneMapping=Os,Mr(z,ce,ve),m.toneMapping=ct,de.updateMultisampleRenderTarget(q),de.updateRenderTargetMipmap(q),m.setRenderTarget(be)}function Mr(z,ce,ve){let se=ce.isScene===!0?ce.overrideMaterial:null;for(let be=0,ct=z.length;be0&&de.useMultisampledRTT(z)===!1?be=xe.get(z).__webglMultisampledFramebuffer:be=Nt,A.copy(z.viewport),T.copy(z.scissor),b=z.scissorTest}else A.copy(D).multiplyScalar(P).floor(),T.copy(L).multiplyScalar(P).floor(),b=j;if(J.bindFramebuffer(36160,be)&&re.drawBuffers&&se&&J.drawBuffers(z,be),J.viewport(A),J.scissor(T),J.setScissorTest(b),ct){let Ct=xe.get(z.texture);Y.framebufferTexture2D(36160,36064,34069+ce,Ct.__webglTexture,ve)}else if(mt){let Ct=xe.get(z.texture),jt=ce||0;Y.framebufferTextureLayer(36160,36064,Ct.__webglTexture,ve||0,jt)}S=-1},this.readRenderTargetPixels=function(z,ce,ve,se,be,ct,mt){if(!(z&&z.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let At=xe.get(z).__webglFramebuffer;if(z.isWebGLCubeRenderTarget&&mt!==void 0&&(At=At[mt]),At){J.bindFramebuffer(36160,At);try{let Ct=z.texture,jt=Ct.format,Nt=Ct.type;if(jt!==qr&&Re.convert(jt)!==Y.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let It=Nt===Wn&&(ie.has("EXT_color_buffer_half_float")||re.isWebGL2&&ie.has("EXT_color_buffer_float"));if(Nt!==_r&&Re.convert(Nt)!==Y.getParameter(35738)&&!(Nt===br&&(re.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!It){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ce>=0&&ce<=z.width-se&&ve>=0&&ve<=z.height-be&&Y.readPixels(ce,ve,se,be,Re.convert(jt),Re.convert(Nt),ct)}finally{let Ct=x!==null?xe.get(x).__webglFramebuffer:null;J.bindFramebuffer(36160,Ct)}}},this.copyFramebufferToTexture=function(z,ce,ve=0){let se=Math.pow(2,-ve),be=Math.floor(ce.image.width*se),ct=Math.floor(ce.image.height*se);de.setTexture2D(ce,0),Y.copyTexSubImage2D(3553,ve,0,0,z.x,z.y,be,ct),J.unbindTexture()},this.copyTextureToTexture=function(z,ce,ve,se=0){let be=ce.image.width,ct=ce.image.height,mt=Re.convert(ve.format),At=Re.convert(ve.type);de.setTexture2D(ve,0),Y.pixelStorei(37440,ve.flipY),Y.pixelStorei(37441,ve.premultiplyAlpha),Y.pixelStorei(3317,ve.unpackAlignment),ce.isDataTexture?Y.texSubImage2D(3553,se,z.x,z.y,be,ct,mt,At,ce.image.data):ce.isCompressedTexture?Y.compressedTexSubImage2D(3553,se,z.x,z.y,ce.mipmaps[0].width,ce.mipmaps[0].height,mt,ce.mipmaps[0].data):Y.texSubImage2D(3553,se,z.x,z.y,mt,At,ce.image),se===0&&ve.generateMipmaps&&Y.generateMipmap(3553),J.unbindTexture()},this.copyTextureToTexture3D=function(z,ce,ve,se,be=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ct=z.max.x-z.min.x+1,mt=z.max.y-z.min.y+1,At=z.max.z-z.min.z+1,Ct=Re.convert(se.format),jt=Re.convert(se.type),Nt;if(se.isData3DTexture)de.setTexture3D(se,0),Nt=32879;else if(se.isDataArrayTexture)de.setTexture2DArray(se,0),Nt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Y.pixelStorei(37440,se.flipY),Y.pixelStorei(37441,se.premultiplyAlpha),Y.pixelStorei(3317,se.unpackAlignment);let It=Y.getParameter(3314),Ft=Y.getParameter(32878),tn=Y.getParameter(3316),rn=Y.getParameter(3315),lo=Y.getParameter(32877),gt=ve.isCompressedTexture?ve.mipmaps[0]:ve.image;Y.pixelStorei(3314,gt.width),Y.pixelStorei(32878,gt.height),Y.pixelStorei(3316,z.min.x),Y.pixelStorei(3315,z.min.y),Y.pixelStorei(32877,z.min.z),ve.isDataTexture||ve.isData3DTexture?Y.texSubImage3D(Nt,be,ce.x,ce.y,ce.z,ct,mt,At,Ct,jt,gt.data):ve.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Y.compressedTexSubImage3D(Nt,be,ce.x,ce.y,ce.z,ct,mt,At,Ct,gt.data)):Y.texSubImage3D(Nt,be,ce.x,ce.y,ce.z,ct,mt,At,Ct,jt,gt),Y.pixelStorei(3314,It),Y.pixelStorei(32878,Ft),Y.pixelStorei(3316,tn),Y.pixelStorei(3315,rn),Y.pixelStorei(32877,lo),be===0&&se.generateMipmaps&&Y.generateMipmap(Nt),J.unbindTexture()},this.initTexture=function(z){z.isCubeTexture?de.setTextureCube(z,0):z.isData3DTexture?de.setTexture3D(z,0):z.isDataArrayTexture||z.isCompressedArrayTexture?de.setTexture2DArray(z,0):de.setTexture2D(z,0),J.unbindTexture()},this.resetState=function(){y=0,v=0,x=null,J.reset(),pe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var xw=class extends Hw{};xw.prototype.isWebGL1Renderer=!0;var Vu=class{constructor(t,e=1,r=1e3){this.isFog=!0,this.name="",this.color=new We(t),this.near=e,this.far=r}clone(){return new Vu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},ei=class extends Tt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(t){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=t}},gy=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=sw,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=is()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,r){t*=this.stride,r*=e.stride;for(let i=0,s=this.stride;il)continue;d.applyMatrix4(this.matrixWorld);let b=t.ray.origin.distanceTo(d);bt.far||e.push({distance:b,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else{let y=Math.max(0,o.start),v=Math.min(g.count,o.start+o.count);for(let x=y,S=v-1;xl)continue;d.applyMatrix4(this.matrixWorld);let A=t.ray.origin.distanceTo(d);At.far||e.push({distance:A,point:h.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){let i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}};var xy=class extends er{constructor(t,e,r,i,s,o,a,l,c){super(t,e,r,i,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},os=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){let e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],r,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(i),e.push(s),i=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let r=this.getLengths(),i=0,s=r.length,o;e?o=e:o=t*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);let u=r[i],d=r[i+1]-u,f=(o-u)/d;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new k:new E);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){let r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e){let r=new E,i=[],s=[],o=[],a=new E,l=new ue;for(let f=0;f<=t;f++){let p=f/t;i[f]=this.getTangentAt(p,new E)}s[0]=new E,o[0]=new E;let c=Number.MAX_VALUE,u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=c&&(c=u,r.set(1,0,0)),h<=c&&(c=h,r.set(0,1,0)),d<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(di(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,p))}o[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(di(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(f=-f);for(let p=1;p<=t;p++)s[p].applyMatrix4(l.makeRotationAxis(i[p],f*p)),o[p].crossVectors(i[p],s[p])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Ac=class extends os{constructor(t=0,e=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e){let r=e||new k,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%s]:(Zg.subVectors(i[0],i[1]).add(i[0]),c=Zg);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return r.set(HC(a,l.x,c.x,u.x,h.x),HC(a,l.y,c.y,u.y,h.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e=r){let o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let r=0,i=this.curves.length;r1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e0){let h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);let u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},Uu=class extends _e{constructor(t=[new k(0,-.5),new k(.5,0),new k(0,.5)],e=12,r=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:i},e=Math.floor(e),i=di(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],c=[],u=1/e,h=new E,d=new k,f=new E,p=new E,m=new E,g=0,y=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,m.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(m.x,m.y,m.z);break;default:g=t[v+1].x-t[v].x,y=t[v+1].y-t[v].y,f.x=y*1,f.y=-g,f.z=y*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),l.push(f.x,f.y,f.z),m.copy(p)}for(let v=0;v<=e;v++){let x=r+v*u*i,S=Math.sin(x),w=Math.cos(x);for(let A=0;A<=t.length-1;A++){h.x=t[A].x*S,h.y=t[A].y,h.z=t[A].x*w,o.push(h.x,h.y,h.z),d.x=v/e,d.y=A/(t.length-1),a.push(d.x,d.y);let T=l[3*A+0]*S,b=l[3*A+1],M=l[3*A+0]*w;c.push(T,b,M)}}for(let v=0;v0&&x(!0),e>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new Te(h,3)),this.setAttribute("normal",new Te(d,3)),this.setAttribute("uv",new Te(f,2));function v(){let S=new E,w=new E,A=0,T=(e-t)/r;for(let b=0;b<=s;b++){let M=[],C=b/s,P=C*(e-t)+t;for(let I=0;I<=i;I++){let _=I/i,D=_*l+a,L=Math.sin(D),j=Math.cos(D);w.x=P*L,w.y=-C*r+g,w.z=P*j,h.push(w.x,w.y,w.z),S.set(L,T,j).normalize(),d.push(S.x,S.y,S.z),f.push(_,1-C),M.push(p++)}m.push(M)}for(let b=0;b.9&&T<.1&&(x<.2&&(o[v+0]+=1),S<.2&&(o[v+2]+=1),w<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){let S=v*3;x.x=t[S+0],x.y=t[S+1],x.z=t[S+2]}function p(){let v=new E,x=new E,S=new E,w=new E,A=new k,T=new k,b=new k;for(let M=0,C=0;M80*e){a=c=n[0],l=u=n[1];for(let p=e;pc&&(c=h),d>u&&(u=d);f=Math.max(c-a,u-l),f=f!==0?32767/f:0}return Sp(s,o,e,a,l,f,0),o}};function bP(n,t,e,r,i){let s,o;if(i===J4(n,t,e,r)>0)for(s=t;s=t;s-=r)o=WC(s,n[s],n[s+1],o);return o&&Ny(o,o.next)&&(Ap(o),o=o.next),o}function Cc(n,t){if(!n)return n;t||(t=n);let e=n,r;do if(r=!1,!e.steiner&&(Ny(e,e.next)||Ur(e.prev,e,e.next)===0)){if(Ap(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Sp(n,t,e,r,i,s,o){if(!n)return;!o&&s&&q4(n,r,i,s);let a=n,l,c;for(;n.prev!==n.next;){if(l=n.prev,c=n.next,s?V4(n,r,i,s):F4(n)){t.push(l.i/e|0),t.push(n.i/e|0),t.push(c.i/e|0),Ap(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=k4(Cc(n),t,e),Sp(n,t,e,r,i,s,2)):o===2&&U4(n,t,e,r,i,s):Sp(Cc(n),t,e,r,i,s,1);break}}}function F4(n){let t=n.prev,e=n,r=n.next;if(Ur(t,e,r)>=0)return!1;let i=t.x,s=e.x,o=r.x,a=t.y,l=e.y,c=r.y,u=is?i>o?i:o:s>o?s:o,f=a>l?a>c?a:c:l>c?l:c,p=r.next;for(;p!==t;){if(p.x>=u&&p.x<=d&&p.y>=h&&p.y<=f&&Lu(i,a,s,l,o,c,p.x,p.y)&&Ur(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function V4(n,t,e,r){let i=n.prev,s=n,o=n.next;if(Ur(i,s,o)>=0)return!1;let a=i.x,l=s.x,c=o.x,u=i.y,h=s.y,d=o.y,f=al?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,y=Aw(f,p,t,e,r),v=Aw(m,g,t,e,r),x=n.prevZ,S=n.nextZ;for(;x&&x.z>=y&&S&&S.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==o&&Lu(a,u,l,h,c,d,x.x,x.y)&&Ur(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=f&&S.x<=m&&S.y>=p&&S.y<=g&&S!==i&&S!==o&&Lu(a,u,l,h,c,d,S.x,S.y)&&Ur(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==o&&Lu(a,u,l,h,c,d,x.x,x.y)&&Ur(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=v;){if(S.x>=f&&S.x<=m&&S.y>=p&&S.y<=g&&S!==i&&S!==o&&Lu(a,u,l,h,c,d,S.x,S.y)&&Ur(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function k4(n,t,e){let r=n;do{let i=r.prev,s=r.next.next;!Ny(i,s)&&SP(i,r,r.next,s)&&wp(i,s)&&wp(s,i)&&(t.push(i.i/e|0),t.push(r.i/e|0),t.push(s.i/e|0),Ap(r),Ap(r.next),r=n=s),r=r.next}while(r!==n);return Cc(r)}function U4(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&K4(o,a)){let l=wP(o,a);o=Cc(o,o.next),l=Cc(l,l.next),Sp(o,t,e,r,i,s,0),Sp(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function z4(n,t,e,r){let i=[],s,o,a,l,c;for(s=0,o=t.length;s=e.next.y&&e.next.y!==e.y){let d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>r&&(r=d,i=e.x=e.x&&e.x>=l&&s!==e.x&&Lu(oi.x||e.x===i.x&&W4(i,e)))&&(i=e,u=h)),e=e.next;while(e!==a);return i}function W4(n,t){return Ur(n.prev,n,t.prev)<0&&Ur(t.next,n,n.next)<0}function q4(n,t,e,r){let i=n;do i.z===0&&(i.z=Aw(i.x,i.y,t,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,Y4(i)}function Y4(n){let t,e,r,i,s,o,a,l,c=1;do{for(e=n,n=null,s=null,o=0;e;){for(o++,r=e,a=0,t=0;t0||l>0&&r;)a!==0&&(l===0||!r||e.z<=r.z)?(i=e,e=e.nextZ,a--):(i=r,r=r.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;e=r}s.nextZ=null,c*=2}while(o>1);return n}function Aw(n,t,e,r,i){return n=(n-e)*i|0,t=(t-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n|t<<1}function X4(n){let t=n,e=n;do(t.x=(n-o)*(s-a)&&(n-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(r-a)}function K4(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!Q4(n,t)&&(wp(n,t)&&wp(t,n)&&Z4(n,t)&&(Ur(n.prev,n,t.prev)||Ur(n,t.prev,t))||Ny(n,t)&&Ur(n.prev,n,n.next)>0&&Ur(t.prev,t,t.next)>0)}function Ur(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function Ny(n,t){return n.x===t.x&&n.y===t.y}function SP(n,t,e,r){let i=$g(Ur(n,t,e)),s=$g(Ur(n,t,r)),o=$g(Ur(e,r,n)),a=$g(Ur(e,r,t));return!!(i!==s&&o!==a||i===0&&Jg(n,e,t)||s===0&&Jg(n,r,t)||o===0&&Jg(e,n,r)||a===0&&Jg(e,t,r))}function Jg(n,t,e){return t.x<=Math.max(n.x,e.x)&&t.x>=Math.min(n.x,e.x)&&t.y<=Math.max(n.y,e.y)&&t.y>=Math.min(n.y,e.y)}function $g(n){return n>0?1:n<0?-1:0}function Q4(n,t){let e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==t.i&&e.next.i!==t.i&&SP(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function wp(n,t){return Ur(n.prev,n,n.next)<0?Ur(n,t,n.next)>=0&&Ur(n,n.prev,t)>=0:Ur(n,t,n.prev)<0||Ur(n,n.next,t)<0}function Z4(n,t){let e=n,r=!1,i=(n.x+t.x)/2,s=(n.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==n);return r}function wP(n,t){let e=new Ew(n.i,n.x,n.y),r=new Ew(t.i,t.x,t.y),i=n.next,s=t.prev;return n.next=t,t.prev=n,e.next=i,i.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function WC(n,t,e,r){let i=new Ew(n,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Ap(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Ew(n,t,e){this.i=n,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function J4(n,t,e,r){let i=0;for(let s=t,o=e-r;s2&&n[t-1].equals(n[0])&&n.pop()}function YC(n,t){for(let e=0;e0)&&f.push(x,S,A),(y!==r-1||l=s)){let a=e[1];t=s)break t}o=r,r=0;break r}break e}for(;r>>1;te;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=Ja(r,s,o),this.values=Ja(this.values,s*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let r=this.times,i=this.values,s=r.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){let l=r[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(i!==void 0&&AP(i))for(let a=0,l=i.length;a!==l;++a){let c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=Ja(this.times),e=Ja(this.values),r=this.getValueSize(),i=this.getInterpolation()===ES,s=t.length-1,o=1;for(let a=1;a0){t[o]=t[s];for(let a=s*r,l=o*r,c=0;c!==r;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=Ja(t,0,o),this.values=Ja(e,0,o*r)):(this.times=t,this.values=e),this}clone(){let t=Ja(this.times,0),e=Ja(this.values,0),r=this.constructor,i=new r(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};as.prototype.TimeBufferType=Float32Array;as.prototype.ValueBufferType=Float32Array;as.prototype.DefaultInterpolation=oy;var ll=class extends as{};ll.prototype.ValueTypeName="bool";ll.prototype.ValueBufferType=Array;ll.prototype.DefaultInterpolation=sy;ll.prototype.InterpolantFactoryMethodLinear=void 0;ll.prototype.InterpolantFactoryMethodSmooth=void 0;var Sy=class extends as{};Sy.prototype.ValueTypeName="color";var Xu=class extends as{};Xu.prototype.ValueTypeName="number";var Cw=class extends Yu{constructor(t,e,r,i){super(t,e,r,i)}interpolate_(t,e,r,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(r-e)/(i-e),c=t*a;for(let u=c+a;c!==u;c+=4)Ke.slerpFlat(s,0,o,c-a,o,c,l);return s}},Pc=class extends as{InterpolantFactoryMethodLinear(t){return new Cw(this.times,this.values,this.getValueSize(),t)}};Pc.prototype.ValueTypeName="quaternion";Pc.prototype.DefaultInterpolation=oy;Pc.prototype.InterpolantFactoryMethodSmooth=void 0;var cl=class extends as{};cl.prototype.ValueTypeName="string";cl.prototype.ValueBufferType=Array;cl.prototype.DefaultInterpolation=sy;cl.prototype.InterpolantFactoryMethodLinear=void 0;cl.prototype.InterpolantFactoryMethodSmooth=void 0;var Ku=class extends as{};Ku.prototype.ValueTypeName="vector";var Qu=class{constructor(t,e=-1,r,i=Uw){this.name=t,this.tracks=r,this.duration=e,this.blendMode=i,this.uuid=is(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],r=t.tracks,i=1/(t.fps||1);for(let o=0,a=r.length;o!==a;++o)e.push(tj(r[o]).scale(i));let s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){let e=[],r=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=r.length;s!==o;++s)e.push(as.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(t,e,r,i){let s=e.length,o=[];for(let a=0;a1){let h=u[1],d=i[h];d||(i[h]=d=[]),d.push(c)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],e,r));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let r=function(h,d,f,p,m){if(f.length!==0){let g=[],y=[];EP(f,g,y,p),g.length!==0&&m.push(new h(d,g,y))}},i=[],s=t.name||"default",o=t.fps||30,a=t.blendMode,l=t.length||-1,c=t.hierarchy||[];for(let h=0;h{e&&e(s),this.manager.itemEnd(t)},0),s;if(aa[t]!==void 0){aa[t].push({onLoad:e,onProgress:r,onError:i});return}aa[t]=[],aa[t].push({onLoad:e,onProgress:r,onError:i});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=aa[t],h=c.body.getReader(),d=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=d?parseInt(d):0,p=f!==0,m=0,g=new ReadableStream({start(y){v();function v(){h.read().then(({done:x,value:S})=>{if(x)y.close();else{m+=S.byteLength;let w=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let A=0,T=u.length;A{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(p=>f.decode(p))}}}).then(c=>{wy.add(t,c);let u=aa[t];delete aa[t];for(let h=0,d=u.length;h{let u=aa[t];if(u===void 0)throw this.manager.itemError(t),c;delete aa[t];for(let h=0,d=u.length;h{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}};var _w=class extends ul{constructor(t){super(t)}load(t,e,r,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let s=this,o=wy.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;let a=pp("img");function l(){u(),wy.add(t,this),e&&e(this),s.manager.itemEnd(t)}function c(h){u(),i&&i(h),s.manager.itemError(t),s.manager.itemEnd(t)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}};var Ay=class extends ul{constructor(t){super(t)}load(t,e,r,i){let s=new er,o=new _w(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},r,i),s}},hl=class extends Tt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new We(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}},Ey=class extends hl{constructor(t,e,r){super(t,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new We(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},$S=new ue,KC=new E,QC=new E,Tp=class{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new k(512,512),this.map=null,this.mapPass=null,this.matrix=new ue,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new gp,this._frameExtents=new k(1,1),this._viewportCount=1,this._viewports=[new Ze(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,r=this.matrix;KC.setFromMatrixPosition(t.matrixWorld),e.position.copy(KC),QC.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(QC),e.updateMatrixWorld(),$S.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix($S),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply($S)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},Iw=class extends Tp{constructor(){super(new $r(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){let e=this.camera,r=fp*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(r!==e.fov||i!==e.aspect||s!==e.far)&&(e.fov=r,e.aspect=i,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Ty=class extends hl{constructor(t,e,r=0,i=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.distance=r,this.angle=i,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Iw}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},ZC=new ue,np=new E,ew=new E,Dw=class extends Tp{constructor(){super(new $r(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new k(4,2),this._viewportCount=6,this._viewports=[new Ze(2,1,1,1),new Ze(0,1,1,1),new Ze(3,1,1,1),new Ze(1,1,1,1),new Ze(3,0,1,1),new Ze(1,0,1,1)],this._cubeDirections=[new E(1,0,0),new E(-1,0,0),new E(0,0,1),new E(0,0,-1),new E(0,1,0),new E(0,-1,0)],this._cubeUps=[new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)]}updateMatrices(t,e=0){let r=this.camera,i=this.matrix,s=t.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),np.setFromMatrixPosition(t.matrixWorld),r.position.copy(np),ew.copy(r.position),ew.add(this._cubeDirections[e]),r.up.copy(this._cubeUps[e]),r.lookAt(ew),r.updateMatrixWorld(),i.makeTranslation(-np.x,-np.y,-np.z),ZC.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ZC)}},My=class extends hl{constructor(t,e,r=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new Dw}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},Ow=class extends Tp{constructor(){super(new nl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Cy=class extends hl{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.shadow=new Ow}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}};var Mp=class extends _e{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Ju=class extends ul{constructor(t){super(t)}load(t,e,r,i){let s=this,o=new Zu(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(t,function(a){try{e(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},r,i)}parse(t){let e={},r={};function i(f,p){if(e[p]!==void 0)return e[p];let g=f.interleavedBuffers[p],y=s(f,g.buffer),v=Ig(g.type,y),x=new gy(v,g.stride);return x.uuid=g.uuid,e[p]=x,x}function s(f,p){if(r[p]!==void 0)return r[p];let g=f.arrayBuffers[p],y=new Uint32Array(g).buffer;return r[p]=y,y}let o=t.isInstancedBufferGeometry?new Mp:new _e,a=t.data.index;if(a!==void 0){let f=Ig(a.type,a.array);o.setIndex(new Xe(f,1))}let l=t.data.attributes;for(let f in l){let p=l[f],m;if(p.isInterleavedBufferAttribute){let g=i(t.data,p.data);m=new Sc(g,p.itemSize,p.offset,p.normalized)}else{let g=Ig(p.type,p.array),y=p.isInstancedBufferAttribute?mo:Xe;m=new y(g,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),p.updateRange!==void 0&&(m.updateRange.offset=p.updateRange.offset,m.updateRange.count=p.updateRange.count),o.setAttribute(f,m)}let c=t.data.morphAttributes;if(c)for(let f in c){let p=c[f],m=[];for(let g=0,y=p.length;g"u"?Date:performance).now()}var Rw=class{constructor(t,e,r){this.binding=t,this.valueSize=r;let i,s,o;switch(e){case"quaternion":i=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(r*6),this._workIndex=5;break;case"string":case"bool":i=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(r*5);break;default:i=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(r*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let r=this.buffer,i=this.valueSize,s=t*i+i,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)r[s+a]=r[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(r,s,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,r=this.valueSize,i=r*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,r),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,r=this.buffer,i=t*e+e,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let l=e*this._origIndex;this._mixBufferRegion(r,i,l,1-s,e)}o>0&&this._mixBufferRegionAdditive(r,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(r[l]!==r[l+e]){a.setValue(r,i);break}}saveOriginalState(){let t=this.binding,e=this.buffer,r=this.valueSize,i=r*this._origIndex;t.getValue(e,i);for(let s=r,o=i;s!==o;++s)e[s]=e[i+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let r=t;r=.5)for(let o=0;o!==s;++o)t[e+o]=t[r+o]}_slerp(t,e,r,i){Ke.slerpFlat(t,e,t,e,t,r,i)}_slerpAdditive(t,e,r,i,s){let o=this._workIndex*s;Ke.multiplyQuaternionsFlat(t,o,t,e,t,r),Ke.slerpFlat(t,e,t,e,t,o,i)}_lerp(t,e,r,i,s){let o=1-i;for(let a=0;a!==s;++a){let l=e+a;t[l]=t[l]*o+t[r+a]*i}}_lerpAdditive(t,e,r,i,s){for(let o=0;o!==s;++o){let a=e+o;t[a]=t[a]+t[r+o]*i}}},qw="\\[\\]\\.:\\/",ij=new RegExp("["+qw+"]","g"),Yw="[^"+qw+"]",nj="[^"+qw.replace("\\.","")+"]",sj=/((?:WC+[\/:])*)/.source.replace("WC",Yw),oj=/(WCOD+)?/.source.replace("WCOD",nj),aj=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Yw),lj=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Yw),cj=new RegExp("^"+sj+oj+aj+lj+"$"),uj=["material","materials","bones","map"],Lw=class{constructor(t,e,r){let i=r||Jt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(t,e)}setValue(t,e){let r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}},Jt=class{constructor(t,e,r){this.path=e,this.parsedPath=r||Jt.parseTrackName(e),this.node=Jt.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,r){return t&&t.isAnimationObjectGroup?new Jt.Composite(t,e,r):new Jt(t,e,r)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ij,"")}static parseTrackName(t){let e=cj.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=r.nodeName.substring(i+1);uj.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let r=t.skeleton.getBoneByName(e);if(r!==void 0)return r}if(t.children){let r=function(s){for(let o=0;o0){let l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case EV:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Uw:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(i,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let r=this._weightInterpolant;if(r!==null){let i=r.evaluate(t)[0];e*=i,t>r.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let r=this._timeScaleInterpolant;if(r!==null){let i=r.evaluate(t)[0];e*=i,t>r.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,r=this.loop,i=this.time+t,s=this._loopCount,o=r===Pp;if(t===0)return s===-1?i:o&&(s&1)===1?e-i:i;if(r===Vw){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=e||i<0){let a=Math.floor(i/e);i-=e*a,s+=Math.abs(a);let l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){let c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(s&1)===1)return e-i}return i}_setEndings(t,e,r){let i=this._interpolantSettings;r?(i.endingStart=Ou,i.endingEnd=Ou):(t?i.endingStart=this.zeroSlopeAtStart?Ou:Du:i.endingStart=ay,e?i.endingEnd=this.zeroSlopeAtEnd?Ou:Du:i.endingEnd=ay)}_scheduleFading(t,e,r){let i=this._mixer,s=i.time,o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,l=o.sampleValues;return a[0]=s,l[0]=e,a[1]=s+t,l[1]=r,this}},hj=new Float32Array(1),_y=class extends pr{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let r=t._localRoot||this._root,i=t._clip.tracks,s=i.length,o=t._propertyBindings,a=t._interpolants,l=r.uuid,c=this._bindingsByRootAndName,u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==s;++h){let d=i[h],f=d.name,p=u[f];if(p!==void 0)++p.referenceCount,o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,l,f));continue}let m=e&&e._propertyBindings[h].binding.parsedPath;p=new Rw(Jt.create(r,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,l,f),o[h]=p}a[h].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let r=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,r)}let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let r=0,i=e.length;r!==i;++r){let s=e[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e=0;--r)t[r].stop();return this}update(t){t*=this.timeScale;let e=this._actions,r=this._nActiveActions,i=this.time+=t,s=Math.sign(t),o=this._accuIndex^=1;for(let c=0;c!==r;++c)e[c]._update(i,t,s,o);let a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(t){this.time=0;for(let e=0;ethis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return eP.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},tP=new E,ty=new E,Ti=class{constructor(t=new E,e=new E){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){tP.subVectors(t,this.start),ty.subVectors(this.end,this.start);let r=ty.dot(ty),s=ty.dot(tP)/r;return e&&(s=di(s,0,1)),s}closestPointToPoint(t,e,r){let i=this.closestPointToPointParameter(t,e);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},rP=new E,Iy=class extends Tt{constructor(t,e){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let r=new _e,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o>-c-14,r[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(r[l]=c+15<<10,r[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(r[l]=31744,r[l|256]=64512,i[l]=24,i[l|256]=24):(r[l]=31744,r[l|256]=64512,i[l]=13,i[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:t,uint32View:e,baseTable:r,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}function fj(n){Math.abs(n)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),n=di(n,-65504,65504),la.floatView[0]=n;let t=la.uint32View[0],e=t>>23&511;return la.baseTable[e]+((t&8388607)>>la.shiftTable[e])}function pj(n){let t=n>>10;return la.uint32View[0]=la.mantissaTable[la.offsetTable[t]+(n&1023)]+la.exponentTable[t],la.floatView[0]}var TP=Object.freeze({__proto__:null,fromHalfFloat:pj,toHalfFloat:fj});typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ha}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ha);var nh=".",_p=Symbol("target"),Xw=Symbol("unsubscribe");function Ip(n){return n instanceof Date||n instanceof Set||n instanceof Map||n instanceof WeakSet||n instanceof WeakMap||ArrayBuffer.isView(n)}function MP(n){return(typeof n=="object"?n===null:typeof n!="function")||n instanceof RegExp}var Kn=Array.isArray;function _c(n){return typeof n=="symbol"}var mj={after:(n,t)=>Kn(n)?n.slice(t.length):t===""?n:n.slice(t.length+1),concat:(n,t)=>Kn(n)?(n=[...n],t&&n.push(t),n):t&&t.toString!==void 0?(n!==""&&(n+=nh),_c(t)?n+t.toString():n+t):n,initial:n=>{if(Kn(n))return n.slice(0,-1);if(n==="")return n;let t=n.lastIndexOf(nh);return t===-1?"":n.slice(0,t)},last:n=>{if(Kn(n))return n[n.length-1]||"";if(n==="")return n;let t=n.lastIndexOf(nh);return t===-1?n:n.slice(t+1)},walk:(n,t)=>{if(Kn(n))for(let e of n)t(e);else if(n!==""){let e=0,r=n.indexOf(nh);if(r===-1)t(n);else for(;e{n&&(n=n[e])}),n}},gn=mj;function Kw(n){return typeof n=="object"&&typeof n.next=="function"}function Qw(n,t,e,r,i){let s=n.next;if(t.name==="entries")n.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],t,o.value[0],r),o.value[1]=i(o.value[1],t,o.value[0],r)),o};else if(t.name==="values"){let o=e[_p].keys();n.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,t,o.next().value,r)),a}}else n.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,t,o.value,r)),o};return n}function Fy(n,t,e){return n.isUnsubscribed||t.ignoreSymbols&&_c(e)||t.ignoreUnderscores&&e.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(e)}var Dp=class{constructor(t){this._equals=t,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(t){let e=this._getDescriptorCache(),r=e.get(t);return r===void 0&&(r={},e.set(t,r)),r}_getOwnPropertyDescriptor(t,e){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(t,e);let r=this._getProperties(t),i=r[e];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(t,e),r[e]=i),i}getProxy(t,e,r,i){if(this.isUnsubscribed)return t;let s=t[i],o=s||t;this._pathCache.set(o,e);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(t,r):t,this._proxyCache.set(o,a)),a}getPath(t){return this.isUnsubscribed?void 0:this._pathCache.get(t)}isDetached(t,e){return!Object.is(t,gn.get(e,this.getPath(t)))}defineProperty(t,e,r){return Reflect.defineProperty(t,e,r)?(this.isUnsubscribed||(this._getProperties(t)[e]=r),!0):!1}setProperty(t,e,r,i,s){if(!this._equals(s,r)||!(e in t)){let o=this._getOwnPropertyDescriptor(t,e);return o!==void 0&&"set"in o?Reflect.set(t,e,r,i):Reflect.set(t,e,r)}return!0}deleteProperty(t,e,r){if(Reflect.deleteProperty(t,e)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(t);i&&(delete i[e],this._pathCache.delete(r))}return!0}return!1}isSameDescriptor(t,e,r){let i=this._getOwnPropertyDescriptor(e,r);return t!==void 0&&i!==void 0&&Object.is(t.value,i.value)&&(t.writable||!1)===(i.writable||!1)&&(t.enumerable||!1)===(i.enumerable||!1)&&(t.configurable||!1)===(i.configurable||!1)&&t.get===i.get&&t.set===i.set}isGetInvariant(t,e){let r=this._getOwnPropertyDescriptor(t,e);return r!==void 0&&r.configurable!==!0&&r.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function sh(n){return toString.call(n)==="[object Object]"}function oh(){return!0}function pl(n,t){return n.length!==t.length||n.some((e,r)=>t[r]!==e)}var Vy=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var gj=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Zw={push:oh,pop:oh,shift:oh,unshift:oh,copyWithin:pl,reverse:pl,sort:pl,splice:pl,flat:pl,fill:pl},CP=new Set([...Vy,...gj,...Object.keys(Zw)]);function ah(n,t){if(n.size!==t.size)return!0;for(let e of n)if(!t.has(e))return!0;return!1}var Jw=["keys","values","entries"],$w=new Set(["has","toString"]),eA={add:ah,clear:ah,delete:ah,forEach:ah},PP=new Set([...$w,...Object.keys(eA),...Jw]);function lh(n,t){if(n.size!==t.size)return!0;let e;for(let[r,i]of n)if(e=t.get(r),e!==i||e===void 0&&!t.has(r))return!0;return!1}var yj=new Set([...$w,"get"]),tA={set:lh,clear:lh,delete:lh,forEach:lh},_P=new Set([...yj,...Object.keys(tA),...Jw]);var Ni=class{constructor(t,e,r,i){this._path=e,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=e===void 0?t:this._shallowClone(t)}static isHandledMethod(t){return Vy.has(t)}_shallowClone(t){let e=t;if(sh(t))e={...t};else if(Kn(t))e=[...t];else if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set([...t].map(r=>this._shallowClone(r)));else if(t instanceof Map){e=new Map;for(let[r,i]of t.entries())e.set(r,this._shallowClone(i))}return this._clonedCache.add(e),e}preferredThisArg(t,e,r,i){return t?(Kn(i)?this._onIsChanged=Zw[e]:i instanceof Set?this._onIsChanged=eA[e]:i instanceof Map&&(this._onIsChanged=tA[e]),i):r}update(t,e,r){let i=gn.after(t,this._path);if(e!=="length"){let s=this.clone;gn.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:e,previous:r}),s&&s[e]&&(s[e]=r)}this._isChanged=!0}undo(t){let e;for(let r=this._changes.length-1;r!==-1;r--)e=this._changes[r],gn.get(t,e.path)[e.property]=e.previous}isChanged(t){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,t)}};var ch=class extends Ni{static isHandledMethod(t){return CP.has(t)}};var Op=class extends Ni{undo(t){t.setTime(this.clone.getTime())}isChanged(t,e){return!e(this.clone.valueOf(),t.valueOf())}};var uh=class extends Ni{static isHandledMethod(t){return PP.has(t)}undo(t){for(let e of this.clone)t.add(e);for(let e of t)this.clone.has(e)||t.delete(e)}};var hh=class extends Ni{static isHandledMethod(t){return _P.has(t)}undo(t){for(let[e,r]of this.clone.entries())t.set(e,r);for(let e of t.keys())this.clone.has(e)||t.delete(e)}};var Rp=class extends Ni{constructor(t,e,r,i){super(void 0,e,r,i),this._arg1=r[0],this._weakValue=t.has(this._arg1)}isChanged(t){return this._weakValue!==t.has(this._arg1)}undo(t){this._weakValue&&!t.has(this._arg1)?t.add(this._arg1):t.delete(this._arg1)}};var Lp=class extends Ni{constructor(t,e,r,i){super(void 0,e,r,i),this._weakKey=r[0],this._weakHas=t.has(this._weakKey),this._weakValue=t.get(this._weakKey)}isChanged(t){return this._weakValue!==t.get(this._weakKey)}undo(t){let e=t.has(this._weakKey);this._weakHas&&!e?t.set(this._weakKey,this._weakValue):!this._weakHas&&e?t.delete(this._weakKey):this._weakValue!==t.get(this._weakKey)&&t.set(this._weakKey,this._weakValue)}};var Fs=class{constructor(t){this._stack=[],this._hasOnValidate=t}static isHandledType(t){return sh(t)||Kn(t)||Ip(t)}static isHandledMethod(t,e){return sh(t)?Ni.isHandledMethod(e):Kn(t)?ch.isHandledMethod(e):t instanceof Set?uh.isHandledMethod(e):t instanceof Map?hh.isHandledMethod(e):Ip(t)}get isCloning(){return this._stack.length>0}start(t,e,r){let i=Ni;Kn(t)?i=ch:t instanceof Date?i=Op:t instanceof Set?i=uh:t instanceof Map?i=hh:t instanceof WeakSet?i=Rp:t instanceof WeakMap&&(i=Lp),this._stack.push(new i(t,e,r,this._hasOnValidate))}update(t,e,r){this._stack[this._stack.length-1].update(t,e,r)}preferredThisArg(t,e,r){let{name:i}=t,s=Fs.isHandledMethod(r,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,e,r)}isChanged(t,e,r){return this._stack[this._stack.length-1].isChanged(t,e,r)}undo(t){this._previousClone!==void 0&&this._previousClone.undo(t)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var vj={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},rA=(n,t,e={})=>{e={...vj,...e};let r=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=e,l=new Dp(i),c=typeof e.onValidate=="function",u=new Fs(c),h=(v,x,S,w,A)=>!c||u.isCloning||e.onValidate(gn.concat(l.getPath(v),x),S,w,A)===!0,d=(v,x,S,w)=>{!Fy(l,e,x)&&!(o&&l.isDetached(v,n))&&f(l.getPath(v),x,S,w)},f=(v,x,S,w,A)=>{u.isCloning?u.update(v,x,w):t(gn.concat(v,x),S,w,A)},p=v=>v&&(v[r]||v),m=(v,x,S,w)=>MP(v)||S==="constructor"||s&&!Fs.isHandledMethod(x,S)||Fy(l,e,S)||l.isGetInvariant(x,S)||o&&l.isDetached(x,n)?v:(w===void 0&&(w=l.getPath(x)),l.getProxy(v,gn.concat(w,S),g,r)),g={get(v,x,S){if(_c(x)){if(x===r||x===_p)return v;if(x===Xw&&!l.isUnsubscribed&&l.getPath(v).length===0)return l.unsubscribe(),v}let w=Ip(v)?Reflect.get(v,x):Reflect.get(v,x,S);return m(w,v,x)},set(v,x,S,w){S=p(S);let A=v[r]||v,T=A[x];if(i(T,S)&&x in v)return!0;let b=h(v,x,S,T);return b&&l.setProperty(A,x,S,w,T)?(d(v,x,v[x],T),!0):!b},defineProperty(v,x,S){if(!l.isSameDescriptor(S,v,x)){let w=v[x];h(v,x,S.value,w)&&l.defineProperty(v,x,S,w)&&d(v,x,S.value,w)}return!0},deleteProperty(v,x){if(!Reflect.has(v,x))return!0;let S=Reflect.get(v,x),w=h(v,x,void 0,S);return w&&l.deleteProperty(v,x,S)?(d(v,x,void 0,S),!0):!w},apply(v,x,S){let w=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(v,w,S);if((a===!1||a!==!0&&!a.includes(v.name))&&Fs.isHandledType(w)){let A=gn.initial(l.getPath(v)),T=Fs.isHandledMethod(w,v.name);u.start(w,A,S);let b=Reflect.apply(v,u.preferredThisArg(v,x,w),T?S.map(P=>p(P)):S),M=u.isChanged(w,i),C=u.stop();if(Fs.isHandledType(b)&&T&&(x instanceof Map&&v.name==="get"&&(A=gn.concat(A,S[0])),b=l.getProxy(b,A,g)),M){let P={name:v.name,args:S,result:b},I=u.isCloning?gn.initial(A):A,_=u.isCloning?gn.last(A):"";h(gn.get(n,I),_,w,C,P)?f(I,_,w,C,P):u.undo(w)}return(x instanceof Map||x instanceof Set)&&Kw(b)?Qw(b,v,x,A,m):b}return Reflect.apply(v,x,S)}},y=l.getProxy(n,e.pathAsArray?[]:"",g);return t=t.bind(y),c&&(e.onValidate=e.onValidate.bind(y)),y};rA.target=n=>n&&n[_p]||n;rA.unsubscribe=n=>n[Xw]||n;var iA=rA;var xj=typeof global=="object"&&global&&global.Object===Object&&global,ky=xj;var bj=typeof self=="object"&&self&&self.Object===Object&&self,Sj=ky||bj||Function("return this")(),Yr=Sj;var wj=Yr.Symbol,Fi=wj;var IP=Object.prototype,Aj=IP.hasOwnProperty,Ej=IP.toString,Bp=Fi?Fi.toStringTag:void 0;function Tj(n){var t=Aj.call(n,Bp),e=n[Bp];try{n[Bp]=void 0;var r=!0}catch{}var i=Ej.call(n);return r&&(t?n[Bp]=e:delete n[Bp]),i}var DP=Tj;var Mj=Object.prototype,Cj=Mj.toString;function Pj(n){return Cj.call(n)}var OP=Pj;var _j="[object Null]",Ij="[object Undefined]",RP=Fi?Fi.toStringTag:void 0;function Dj(n){return n==null?n===void 0?Ij:_j:RP&&RP in Object(n)?DP(n):OP(n)}var Qn=Dj;function Oj(n){return n!=null&&typeof n=="object"}var Wi=Oj;var Rj="[object Symbol]";function Lj(n){return typeof n=="symbol"||Wi(n)&&Qn(n)==Rj}var go=Lj;function Bj(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e0){if(++t>=xH)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var KP=wH;function AH(n){return function(){return n}}var QP=AH;var EH=function(){try{var n=Cn(Object,"defineProperty");return n({},"",{}),n}catch{}}(),dh=EH;var TH=dh?function(n,t){return dh(n,"toString",{configurable:!0,enumerable:!1,value:QP(t),writable:!0})}:zy,ZP=TH;var MH=KP(ZP),JP=MH;function CH(n,t){for(var e=-1,r=n==null?0:n.length;++e-1&&n%1==0&&n-1&&n%1==0&&n<=VH}var gh=kH;function UH(n){return n!=null&&gh(n.length)&&!Gy(n)}var qy=UH;var zH=Object.prototype;function GH(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||zH;return n===e}var yh=GH;function jH(n,t){for(var e=-1,r=Array(n);++e-1}var E_=cW;function uW(n,t){var e=this.__data__,r=ml(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var T_=uW;function wh(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t0&&e(a)?t>1?V_(a,t-1,e,r,i):Eh(i,a):r||(i[i.length]=a)}return i}var k_=V_;function OW(n){var t=n==null?0:n.length;return t?k_(n,1):[]}var U_=OW;function RW(n){return JP(t_(n,void 0,U_),n+"")}var Zy=RW;var LW=Ky(Object.getPrototypeOf,Object),Th=LW;var BW="[object Object]",NW=Function.prototype,FW=Object.prototype,z_=NW.toString,VW=FW.hasOwnProperty,kW=z_.call(Object);function UW(n){if(!Wi(n)||Qn(n)!=BW)return!1;var t=Th(n);if(t===null)return!0;var e=VW.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&z_.call(e)==kW}var G_=UW;function zW(n,t,e){var r=-1,i=n.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var s=Array(i);++ra))return!1;var c=s.get(n),u=s.get(t);if(c&&u)return c==t&&u==n;var h=-1,d=!0,f=e&F8?new D2:void 0;for(s.set(n,t),s.set(t,n);++h=t||T<0||h&&b>=s}function y(){var A=uv();if(g(A))return v(A);a=setTimeout(y,m(A))}function v(A){return a=void 0,d&&r?f(A):(r=i=void 0,o)}function x(){a!==void 0&&clearTimeout(a),c=0,r=l=i=a=void 0}function S(){return a===void 0?o:v(uv())}function w(){var A=uv(),T=g(A);if(r=arguments,i=this,l=A,T){if(a===void 0)return p(l);if(h)return clearTimeout(a),a=setTimeout(y,t),f(l)}return a===void 0&&(a=setTimeout(y,t)),o}return w.cancel=x,w.flush=S,w}var vo=mq;function gq(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var X2=gq;function yq(n,t){return n>t}var K2=yq;function vq(n,t){return t.length<2?n:Qy(n,j_(t,0,-1))}var Q2=vq;function xq(n,t){return H2(n,t)}var Rc=xq;function bq(n,t,e){for(var r=-1,i=n.length;++r1),s}),yo(n,tv(n),e),r&&(e=ov(e,Eq|Tq|Mq,$2));for(var i=t.length;i--;)J2(e,t[i]);return e}),Dh=Cq;function Pq(n,t,e,r){if(!yi(n))return n;t=cs(t,n);for(var i=-1,s=t.length,o=s-1,a=n;a!=null&&++itypeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),Bq=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),Nq=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Oh&&"ontouchend"in document,Fq=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,Vq=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,kq=()=>{if(typeof window>"u")return!1;let n=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(n)&&/Apple Computer/.test(t)},Uq=()=>{if(typeof window>"u")return null;let t=navigator.userAgent.match(/Version\/(\d+\.\d)/);return t&&t[1]},zq=()=>{if(typeof window>"u")return;let t=new URLSearchParams(window.location.search).get("desktop-app-version");return t?(window.localStorage.setItem("desktop-app-version",t),t):window.localStorage.getItem("desktop-app-version")??"0.0.6"},dA=Lq(),rue=dA?zq():void 0,Oh=Bq(),xo=Nq(),iI=Fq(),Ci=Vq(),fA=kq(),nI=Number(Uq());function dv(n){return Array.isArray(n)?n:[n]}function fv(n,t){let e=0;for(;et[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}function Vp(n){return Oh?n.metaKey:n.ctrlKey}function sI(n){return n.wheelDeltaY===0||n.deltaY===0?Oh&&n.shiftKey&&Math.abs(n.wheelDeltaX)>=120?!1:n.wheelDeltaX?n.wheelDeltaX===-3*n.deltaX||n.wheelDeltaX===-3*window.devicePixelRatio*n.deltaX:n.deltaMode===0:n.wheelDeltaY?n.wheelDeltaY===-3*n.deltaY||n.wheelDeltaY===-3*window.devicePixelRatio*n.deltaY:n.deltaMode===0}var Je=[],mv={},kp={},pv={};function oI(n){Je.includes(n)||Je.push(n)}function Rh(n){delete mv[n.pointerId];for(let t=0;t{dI=n});var vv;function pI(){if(vv)return vv;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/navmesh-wasm@1.9.35/build",i=import("./navmesh.js"),[s,o]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(c=>c.arrayBuffer())]),a=s.default,l=await a({wasmBinary:o});dI(l)}return vv=n(),vv}var mI,gI=new Promise(n=>{mI=n});var xv;function yI(){if(xv)return xv;async function n(){let e=await import("./physics.js");await e.init(),mI(e)}return xv=n(),xv}var Qe=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let s={...r,[t]:e};return Object.setPrototypeOf(s,Qe.prototype),s}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],i;r===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:r};let{id:s,data:o}=t,a={...e,[s]:o};return Object.setPrototypeOf(a,Qe.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:r}=t,i=e[r];if(i===void 0)return null;{let s={...e};return Object.setPrototypeOf(s,Qe.prototype),delete s[r],{data:s,actual:t,reverse:{type:1,id:r,data:i}}}}return null}};function Up(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&Up(r)}return Object.freeze(n)}function vI(n,t){let e=0;for(;et[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var Lh=class extends Error{};function bv(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function bo(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let s=n;n=t,t=s}let r=[],i=1/(e+1);for(let s=0;su.id===e);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:r},this.modifyArrayBy(s,o)}}modifyArrayBy(e,r){let i=e,s=r;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let c=s.findIndex(u=>u.id===l);if(c<0)throw new Error;s=[...s],s[c]={...s[c],children:a}}Object.setPrototypeOf(s,gr.prototype);let o=s;return o.fillCaches(),o}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let i of r)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:r,fi:i,id:s,data:o,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),u={fi:i,id:s,data:o,children:a};return c=[...c,u],c.sort((d,f)=>d.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:s}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(c=>c.id===r);e.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:e,reverse:{type:7,...a,parent:i}}}}moveOp(e){let{parent:r,fi:i,id:s}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:s});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Lh("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),c=l.findIndex(f=>f.id===s);l=[...l];let u=l.splice(c,1)[0],h=this.modifyArrayBy(o,l);o=r,l=h.childrenArray(o);let d=u.fi;return u={...u,fi:i},l=[...l,u],l.sort((f,p)=>f.fi-p.fi),e.localIndex=l.indexOf(u),h=h.modifyArrayBy(o,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:s}}}previous(e,r){if(r===null){let s=this.childrenArray(e);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(e)){if(s.id===r)return i;i=s.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===e)+1;if(s0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),s=i.findIndex(o=>o.id===e)-1;return s>=0?this.traverseSortPrevious(i[s].id):r}}getAllSorted(e){let r=[];for(let i of e){let s=this.getWithSortKey(i.id);s!==void 0&&r.push({...i,...s})}r.sort((i,s)=>vI(i.sortKey,s.sortKey));for(let i of r)delete i.sortKey;return r}getWithSortKey(e){var r=e;let i=[],s=this.get(r),o=s;if(s!==void 0){for(;r;)i.splice(0,0,s.fi),r=this.parent(r),r!==null&&(s=this.get(r));return{...o,sortKey:i}}}insertBeforeHelper(e,r,i){return this.insertAfterHelper(e,this.previous(e,r),i)}insertAfterHelper(e,r,i){let s=this.childrenArray(e);if(r===null){if(s.length===0)return bo(0,i,i);{let o=s[0].fi;return bo(o-i,o,i)}}else{let o=this.get(r);if(o===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return bo(l,l+i,i)}else return bo(o.fi,a.fi,i)}}};var Nh;(t=>{function n(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let i=r.props,s={},o=[...e],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=o[c],o[c]=i[l],a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}else{let i=r.props,s={},o={...e},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let c=i[l];c===void 0?delete o[l]:o[l]=c,a=!0}return a?{data:o,actual:r,reverse:{type:0,props:s}}:null}}t.runOp=n})(Nh||(Nh={}));var ke=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ke.prototype)}deepFreeze(){let e=0;for(;ec.id===e);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:r},this.modifyArrayBy(s)}}modifyArrayBy(e){Object.setPrototypeOf(e,ke.prototype);let r=e;return xI()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:r,id:i,data:s}=e,o=this,a={fi:r,id:i,data:s};return o=[...o,a],o.sort((c,u)=>c.fi-u.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:r}=e,i=this,s=i.findIndex(l=>l.id===r);if(s===-1)return null;e.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...o}}}moveOp(e){let{fi:r,id:i}=e,s=this;s=[...s];let o=s.findIndex(u=>u.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:r};return s[o]=l,s.sort((u,h)=>u.fi-h.fi),e.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let i of this){if(i.id===e)return r;r=i.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let i=this;if(e===null){if(i.length===0)return bo(0,r,r);{let s=i[0].fi;return bo(s-r,s,r)}}else{let s=this.get(e);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return bo(a,a+r,r)}else return bo(s.fi,o.fi,r)}}};function Fh(n){return n&&typeof n=="object"&&n instanceof yr}var yr=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,i=0,s={};for(;i0;){if(Object.keys(r).length===0){let l=e[i-1];l&&(r=bv(l),delete r[t.path[i-1]])}else{let l=e[i-1];if(l){let c=bv(l);c[t.path[i-1]]=r,r=c}else{let c=new yr;c[t.path[i-1]]=r,r=c}}i-=1}let o=Object.setPrototypeOf(r,yr.prototype),a={...t,props:s};return{data:o,actual:t,reverse:a}}},So;(r=>{function n(i,s){return zp(i,s)??i}r.apply=n;function t(i,s){return mA(i,s)}r.merge=t;function e(i,s){let o=0,a=s.path,l=i;for(;o{let s=i.id,o=zp(i.data,t[s]);if(e=e||o!==void 0,o===void 0&&(o=i.dat