3946 lines
793 KiB
JavaScript
3946 lines
793 KiB
JavaScript
const __vite__fileDeps=["assets/chunks/VPLocalSearchBox.zY3w-sDv.js","assets/chunks/framework.VBE0TPts.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
|
|
import{d as ke,o as Y,c as ge,r as pe,n as yt,a as qt,t as pt,b as Xe,w as xe,e as Fe,T as eu,_ as qe,u as Ym,i as Zm,f as Km,g as tu,h as He,j as ve,k as ee,p as $t,l as Xt,m as cs,q as sc,s as Ve,v as wt,x as Li,y as Fn,z as $n,A as ef,B as Jm,C as jm,D as rn,F as xt,E as Qt,G as Dn,H as La,I as Ue,J as Xs,K as tf,L as Xr,M as ca,N as qr,O as Qm,P as nu,Q as rc,R as iu,S as nf,U as Na,V as br,W as eg,X as tg,Y as sf,Z as Sr,$ as ng,a0 as ig,a1 as sg,a2 as rf,a3 as rg,a4 as of,a5 as og,a6 as ag,a7 as lg,a8 as cg,a9 as Ma,aa as ug,ab as hg,ac as oh,ad as dg,ae as fg,af as pg}from"./framework.VBE0TPts.js";const mg=ke({__name:"VPBadge",props:{text:{},type:{default:"tip"}},setup(s){return(e,t)=>(Y(),ge("span",{class:yt(["VPBadge",e.type])},[pe(e.$slots,"default",{},()=>[qt(pt(e.text),1)])],2))}}),gg={key:0,class:"VPBackdrop"},_g=ke({__name:"VPBackdrop",props:{show:{type:Boolean}},setup(s){return(e,t)=>(Y(),Xe(eu,{name:"fade"},{default:xe(()=>[e.show?(Y(),ge("div",gg)):Fe("",!0)]),_:1}))}}),vg=qe(_g,[["__scopeId","data-v-c79a1216"]]),lt=Ym;function yg(s,e){let t,n=!1;return()=>{t&&clearTimeout(t),n?t=setTimeout(s,e):(s(),(n=!0)&&setTimeout(()=>n=!1,e))}}function oc(s){return/^\//.test(s)?s:`/${s}`}function su(s){const{pathname:e,search:t,hash:n,protocol:i}=new URL(s,"http://a.com");if(Zm(s)||s.startsWith("#")||!i.startsWith("http")||!Km(e))return s;const{site:r}=lt(),o=e.endsWith("/")||e.endsWith(".html")?s:s.replace(/(?:(^\.+)\/)?.*$/,`$1${e.replace(/(\.md)?$/,r.value.cleanUrls?"":".html")}${t}${n}`);return tu(o)}function Yr({correspondingLink:s=!1}={}){const{site:e,localeIndex:t,page:n,theme:i,hash:r}=lt(),o=He(()=>{var l,c;return{label:(l=e.value.locales[t.value])==null?void 0:l.label,link:((c=e.value.locales[t.value])==null?void 0:c.link)||(t.value==="root"?"/":`/${t.value}/`)}});return{localeLinks:He(()=>Object.entries(e.value.locales).flatMap(([l,c])=>o.value.label===c.label?[]:{text:c.label,link:xg(c.link||(l==="root"?"/":`/${l}/`),i.value.i18nRouting!==!1&&s,n.value.relativePath.slice(o.value.link.length-1),!e.value.cleanUrls)+r.value})),currentLang:o}}function xg(s,e,t,n){return e?s.replace(/\/$/,"")+oc(t.replace(/(^|\/)index\.md$/,"$1").replace(/\.md$/,n?".html":"")):s}const Mg=s=>($t("data-v-d6be1790"),s=s(),Xt(),s),bg={class:"NotFound"},Sg={class:"code"},wg={class:"title"},Ag=Mg(()=>ve("div",{class:"divider"},null,-1)),Eg={class:"quote"},Tg={class:"action"},Cg=["href","aria-label"],Pg=ke({__name:"NotFound",setup(s){const{theme:e}=lt(),{currentLang:t}=Yr();return(n,i)=>{var r,o,a,l,c;return Y(),ge("div",bg,[ve("p",Sg,pt(((r=ee(e).notFound)==null?void 0:r.code)??"404"),1),ve("h1",wg,pt(((o=ee(e).notFound)==null?void 0:o.title)??"PAGE NOT FOUND"),1),Ag,ve("blockquote",Eg,pt(((a=ee(e).notFound)==null?void 0:a.quote)??"But if you don't change your direction, and if you keep looking, you may end up where you are heading."),1),ve("div",Tg,[ve("a",{class:"link",href:ee(tu)(ee(t).link),"aria-label":((l=ee(e).notFound)==null?void 0:l.linkLabel)??"go to home"},pt(((c=ee(e).notFound)==null?void 0:c.linkText)??"Take me home"),9,Cg)])])}}}),Rg=qe(Pg,[["__scopeId","data-v-d6be1790"]]);function af(s,e){if(Array.isArray(s))return ua(s);if(s==null)return[];e=oc(e);const t=Object.keys(s).sort((i,r)=>r.split("/").length-i.split("/").length).find(i=>e.startsWith(oc(i))),n=t?s[t]:[];return Array.isArray(n)?ua(n):ua(n.items,n.base)}function Ig(s){const e=[];let t=0;for(const n in s){const i=s[n];if(i.items){t=e.push(i);continue}e[t]||e.push({items:[]}),e[t].items.push(i)}return e}function Lg(s){const e=[];function t(n){for(const i of n)i.text&&i.link&&e.push({text:i.text,link:i.link,docFooterText:i.docFooterText}),i.items&&t(i.items)}return t(s),e}function ac(s,e){return Array.isArray(e)?e.some(t=>ac(s,t)):cs(s,e.link)?!0:e.items?ac(s,e.items):!1}function ua(s,e){return[...s].map(t=>{const n={...t},i=n.base||e;return i&&n.link&&(n.link=i+n.link),n.items&&(n.items=ua(n.items,i)),n})}function di(){const{frontmatter:s,page:e,theme:t}=lt(),n=sc("(min-width: 960px)"),i=Ve(!1),r=He(()=>{const _=t.value.sidebar,p=e.value.relativePath;return _?af(_,p):[]}),o=Ve(r.value);wt(r,(_,p)=>{JSON.stringify(_)!==JSON.stringify(p)&&(o.value=r.value)});const a=He(()=>s.value.sidebar!==!1&&o.value.length>0&&s.value.layout!=="home"),l=He(()=>c?s.value.aside==null?t.value.aside==="left":s.value.aside==="left":!1),c=He(()=>s.value.layout==="home"?!1:s.value.aside!=null?!!s.value.aside:t.value.aside!==!1),u=He(()=>a.value&&n.value),h=He(()=>a.value?Ig(o.value):[]);function d(){i.value=!0}function f(){i.value=!1}function g(){i.value?f():d()}return{isOpen:i,sidebar:o,sidebarGroups:h,hasSidebar:a,hasAside:c,leftAside:l,isSidebarEnabled:u,open:d,close:f,toggle:g}}function Ng(s,e){let t;Li(()=>{t=s.value?document.activeElement:void 0}),Fn(()=>{window.addEventListener("keyup",n)}),$n(()=>{window.removeEventListener("keyup",n)});function n(i){i.key==="Escape"&&s.value&&(e(),t==null||t.focus())}}function Dg(s){const{page:e,hash:t}=lt(),n=Ve(!1),i=He(()=>s.value.collapsed!=null),r=He(()=>!!s.value.link),o=Ve(!1),a=()=>{o.value=cs(e.value.relativePath,s.value.link)};wt([e,s,t],a),Fn(a);const l=He(()=>o.value?!0:s.value.items?ac(e.value.relativePath,s.value.items):!1),c=He(()=>!!(s.value.items&&s.value.items.length));Li(()=>{n.value=!!(i.value&&s.value.collapsed)}),ef(()=>{(o.value||l.value)&&(n.value=!1)});function u(){i.value&&(n.value=!n.value)}return{collapsed:n,collapsible:i,isLink:r,isActiveLink:o,hasActiveLink:l,hasChildren:c,toggle:u}}function Ug(){const{hasSidebar:s}=di(),e=sc("(min-width: 960px)"),t=sc("(min-width: 1280px)");return{isAsideEnabled:He(()=>!t.value&&!e.value?!1:s.value?t.value:e.value)}}const lc=[];function lf(s){return typeof s.outline=="object"&&!Array.isArray(s.outline)&&s.outline.label||s.outlineTitle||"On this page"}function ru(s){const e=[...document.querySelectorAll(".VPDoc :where(h1,h2,h3,h4,h5,h6)")].filter(t=>t.id&&t.hasChildNodes()).map(t=>{const n=Number(t.tagName[1]);return{element:t,title:Og(t),link:"#"+t.id,level:n}});return Fg(e,s)}function Og(s){let e="";for(const t of s.childNodes)if(t.nodeType===1){if(t.classList.contains("VPBadge")||t.classList.contains("header-anchor")||t.classList.contains("ignore-header"))continue;e+=t.textContent}else t.nodeType===3&&(e+=t.textContent);return e.trim()}function Fg(s,e){if(e===!1)return[];const t=(typeof e=="object"&&!Array.isArray(e)?e.level:e)||2,[n,i]=typeof t=="number"?[t,t]:t==="deep"?[2,6]:t;s=s.filter(o=>o.level>=n&&o.level<=i),lc.length=0;for(const{element:o,link:a}of s)lc.push({element:o,link:a});const r=[];e:for(let o=0;o<s.length;o++){const a=s[o];if(o===0)r.push(a);else{for(let l=o-1;l>=0;l--){const c=s[l];if(c.level<a.level){(c.children||(c.children=[])).push(a);continue e}}r.push(a)}}return r}function kg(s,e){const{isAsideEnabled:t}=Ug(),n=yg(r,100);let i=null;Fn(()=>{requestAnimationFrame(r),window.addEventListener("scroll",n)}),Jm(()=>{o(location.hash)}),$n(()=>{window.removeEventListener("scroll",n)});function r(){if(!t.value)return;const a=window.scrollY,l=window.innerHeight,c=document.body.offsetHeight,u=Math.abs(a+l-c)<1,h=lc.map(({element:f,link:g})=>({link:g,top:Bg(f)})).filter(({top:f})=>!Number.isNaN(f)).sort((f,g)=>f.top-g.top);if(!h.length){o(null);return}if(a<1){o(null);return}if(u){o(h[h.length-1].link);return}let d=null;for(const{link:f,top:g}of h){if(g>a+jm()+4)break;d=f}o(d)}function o(a){i&&i.classList.remove("active"),a==null?i=null:i=s.value.querySelector(`a[href="${decodeURIComponent(a)}"]`);const l=i;l?(l.classList.add("active"),e.value.style.top=l.offsetTop+39+"px",e.value.style.opacity="1"):(e.value.style.top="33px",e.value.style.opacity="0")}}function Bg(s){let e=0;for(;s!==document.body;){if(s===null)return NaN;e+=s.offsetTop,s=s.offsetParent}return e}const zg=["href","title"],Vg=ke({__name:"VPDocOutlineItem",props:{headers:{},root:{type:Boolean}},setup(s){function e({target:t}){const n=t.href.split("#")[1],i=document.getElementById(decodeURIComponent(n));i==null||i.focus({preventScroll:!0})}return(t,n)=>{const i=rn("VPDocOutlineItem",!0);return Y(),ge("ul",{class:yt(["VPDocOutlineItem",t.root?"root":"nested"])},[(Y(!0),ge(xt,null,Qt(t.headers,({children:r,link:o,title:a})=>(Y(),ge("li",null,[ve("a",{class:"outline-link",href:o,onClick:e,title:a},pt(a),9,zg),r!=null&&r.length?(Y(),Xe(i,{key:0,headers:r},null,8,["headers"])):Fe("",!0)]))),256))],2)}}}),cf=qe(Vg,[["__scopeId","data-v-b933a997"]]),Hg={class:"content"},Gg={"aria-level":"2",class:"outline-title",id:"doc-outline-aria-label",role:"heading"},Wg=ke({__name:"VPDocAsideOutline",setup(s){const{frontmatter:e,theme:t}=lt(),n=Dn([]);La(()=>{n.value=ru(e.value.outline??t.value.outline)});const i=Ve(),r=Ve();return kg(i,r),(o,a)=>(Y(),ge("nav",{"aria-labelledby":"doc-outline-aria-label",class:yt(["VPDocAsideOutline",{"has-outline":n.value.length>0}]),ref_key:"container",ref:i},[ve("div",Hg,[ve("div",{class:"outline-marker",ref_key:"marker",ref:r},null,512),ve("div",Gg,pt(ee(lf)(ee(t))),1),Ue(cf,{headers:n.value,root:!0},null,8,["headers"])])],2))}}),$g=qe(Wg,[["__scopeId","data-v-a5bbad30"]]),Xg={class:"VPDocAsideCarbonAds"},qg=ke({__name:"VPDocAsideCarbonAds",props:{carbonAds:{}},setup(s){const e=()=>null;return(t,n)=>(Y(),ge("div",Xg,[Ue(ee(e),{"carbon-ads":t.carbonAds},null,8,["carbon-ads"])]))}}),Yg=s=>($t("data-v-3f215769"),s=s(),Xt(),s),Zg={class:"VPDocAside"},Kg=Yg(()=>ve("div",{class:"spacer"},null,-1)),Jg=ke({__name:"VPDocAside",setup(s){const{theme:e}=lt();return(t,n)=>(Y(),ge("div",Zg,[pe(t.$slots,"aside-top",{},void 0,!0),pe(t.$slots,"aside-outline-before",{},void 0,!0),Ue($g),pe(t.$slots,"aside-outline-after",{},void 0,!0),Kg,pe(t.$slots,"aside-ads-before",{},void 0,!0),ee(e).carbonAds?(Y(),Xe(qg,{key:0,"carbon-ads":ee(e).carbonAds},null,8,["carbon-ads"])):Fe("",!0),pe(t.$slots,"aside-ads-after",{},void 0,!0),pe(t.$slots,"aside-bottom",{},void 0,!0)]))}}),jg=qe(Jg,[["__scopeId","data-v-3f215769"]]);function Qg(){const{theme:s,page:e}=lt();return He(()=>{const{text:t="Edit this page",pattern:n=""}=s.value.editLink||{};let i;return typeof n=="function"?i=n(e.value):i=n.replace(/:path/g,e.value.filePath),{url:i,text:t}})}function e_(){const{page:s,theme:e,frontmatter:t}=lt();return He(()=>{var c,u,h,d,f,g,_,p;const n=af(e.value.sidebar,s.value.relativePath),i=Lg(n),r=t_(i,m=>m.link.replace(/[?#].*$/,"")),o=r.findIndex(m=>cs(s.value.relativePath,m.link)),a=((c=e.value.docFooter)==null?void 0:c.prev)===!1&&!t.value.prev||t.value.prev===!1,l=((u=e.value.docFooter)==null?void 0:u.next)===!1&&!t.value.next||t.value.next===!1;return{prev:a?void 0:{text:(typeof t.value.prev=="string"?t.value.prev:typeof t.value.prev=="object"?t.value.prev.text:void 0)??((h=r[o-1])==null?void 0:h.docFooterText)??((d=r[o-1])==null?void 0:d.text),link:(typeof t.value.prev=="object"?t.value.prev.link:void 0)??((f=r[o-1])==null?void 0:f.link)},next:l?void 0:{text:(typeof t.value.next=="string"?t.value.next:typeof t.value.next=="object"?t.value.next.text:void 0)??((g=r[o+1])==null?void 0:g.docFooterText)??((_=r[o+1])==null?void 0:_.text),link:(typeof t.value.next=="object"?t.value.next.link:void 0)??((p=r[o+1])==null?void 0:p.link)}}})}function t_(s,e){const t=new Set;return s.filter(n=>{const i=e(n);return t.has(i)?!1:t.add(i)})}const Gn=ke({__name:"VPLink",props:{tag:{},href:{},noIcon:{type:Boolean},target:{},rel:{}},setup(s){const e=s,t=He(()=>e.tag??(e.href?"a":"span")),n=He(()=>e.href&&tf.test(e.href)||e.target==="_blank");return(i,r)=>(Y(),Xe(Xs(t.value),{class:yt(["VPLink",{link:i.href,"vp-external-link-icon":n.value,"no-icon":i.noIcon}]),href:i.href?ee(su)(i.href):void 0,target:i.target??(n.value?"_blank":void 0),rel:i.rel??(n.value?"noreferrer":void 0)},{default:xe(()=>[pe(i.$slots,"default")]),_:3},8,["class","href","target","rel"]))}}),n_={class:"VPLastUpdated"},i_=["datetime"],s_=ke({__name:"VPDocFooterLastUpdated",setup(s){const{theme:e,page:t,frontmatter:n,lang:i}=lt(),r=He(()=>new Date(n.value.lastUpdated??t.value.lastUpdated)),o=He(()=>r.value.toISOString()),a=Ve("");return Fn(()=>{Li(()=>{var l,c,u;a.value=new Intl.DateTimeFormat((c=(l=e.value.lastUpdated)==null?void 0:l.formatOptions)!=null&&c.forceLocale?i.value:void 0,((u=e.value.lastUpdated)==null?void 0:u.formatOptions)??{dateStyle:"short",timeStyle:"short"}).format(r.value)})}),(l,c)=>{var u;return Y(),ge("p",n_,[qt(pt(((u=ee(e).lastUpdated)==null?void 0:u.text)||ee(e).lastUpdatedText||"Last updated")+": ",1),ve("time",{datetime:o.value},pt(a.value),9,i_)])}}}),r_=qe(s_,[["__scopeId","data-v-7e05ebdb"]]),uf=s=>($t("data-v-d4a0bba5"),s=s(),Xt(),s),o_={key:0,class:"VPDocFooter"},a_={key:0,class:"edit-info"},l_={key:0,class:"edit-link"},c_=uf(()=>ve("span",{class:"vpi-square-pen edit-link-icon"},null,-1)),u_={key:1,class:"last-updated"},h_={key:1,class:"prev-next","aria-labelledby":"doc-footer-aria-label"},d_=uf(()=>ve("span",{class:"visually-hidden",id:"doc-footer-aria-label"},"Pager",-1)),f_={class:"pager"},p_=["innerHTML"],m_=["innerHTML"],g_={class:"pager"},__=["innerHTML"],v_=["innerHTML"],y_=ke({__name:"VPDocFooter",setup(s){const{theme:e,page:t,frontmatter:n}=lt(),i=Qg(),r=e_(),o=He(()=>e.value.editLink&&n.value.editLink!==!1),a=He(()=>t.value.lastUpdated&&n.value.lastUpdated!==!1),l=He(()=>o.value||a.value||r.value.prev||r.value.next);return(c,u)=>{var h,d,f,g;return l.value?(Y(),ge("footer",o_,[pe(c.$slots,"doc-footer-before",{},void 0,!0),o.value||a.value?(Y(),ge("div",a_,[o.value?(Y(),ge("div",l_,[Ue(Gn,{class:"edit-link-button",href:ee(i).url,"no-icon":!0},{default:xe(()=>[c_,qt(" "+pt(ee(i).text),1)]),_:1},8,["href"])])):Fe("",!0),a.value?(Y(),ge("div",u_,[Ue(r_)])):Fe("",!0)])):Fe("",!0),(h=ee(r).prev)!=null&&h.link||(d=ee(r).next)!=null&&d.link?(Y(),ge("nav",h_,[d_,ve("div",f_,[(f=ee(r).prev)!=null&&f.link?(Y(),Xe(Gn,{key:0,class:"pager-link prev",href:ee(r).prev.link},{default:xe(()=>{var _;return[ve("span",{class:"desc",innerHTML:((_=ee(e).docFooter)==null?void 0:_.prev)||"Previous page"},null,8,p_),ve("span",{class:"title",innerHTML:ee(r).prev.text},null,8,m_)]}),_:1},8,["href"])):Fe("",!0)]),ve("div",g_,[(g=ee(r).next)!=null&&g.link?(Y(),Xe(Gn,{key:0,class:"pager-link next",href:ee(r).next.link},{default:xe(()=>{var _;return[ve("span",{class:"desc",innerHTML:((_=ee(e).docFooter)==null?void 0:_.next)||"Next page"},null,8,__),ve("span",{class:"title",innerHTML:ee(r).next.text},null,8,v_)]}),_:1},8,["href"])):Fe("",!0)])])):Fe("",!0)])):Fe("",!0)}}}),x_=qe(y_,[["__scopeId","data-v-d4a0bba5"]]),M_=s=>($t("data-v-39a288b8"),s=s(),Xt(),s),b_={class:"container"},S_=M_(()=>ve("div",{class:"aside-curtain"},null,-1)),w_={class:"aside-container"},A_={class:"aside-content"},E_={class:"content"},T_={class:"content-container"},C_={class:"main"},P_=ke({__name:"VPDoc",setup(s){const{theme:e}=lt(),t=Xr(),{hasSidebar:n,hasAside:i,leftAside:r}=di(),o=He(()=>t.path.replace(/[./]+/g,"_").replace(/_html$/,""));return(a,l)=>{const c=rn("Content");return Y(),ge("div",{class:yt(["VPDoc",{"has-sidebar":ee(n),"has-aside":ee(i)}])},[pe(a.$slots,"doc-top",{},void 0,!0),ve("div",b_,[ee(i)?(Y(),ge("div",{key:0,class:yt(["aside",{"left-aside":ee(r)}])},[S_,ve("div",w_,[ve("div",A_,[Ue(jg,null,{"aside-top":xe(()=>[pe(a.$slots,"aside-top",{},void 0,!0)]),"aside-bottom":xe(()=>[pe(a.$slots,"aside-bottom",{},void 0,!0)]),"aside-outline-before":xe(()=>[pe(a.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":xe(()=>[pe(a.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":xe(()=>[pe(a.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":xe(()=>[pe(a.$slots,"aside-ads-after",{},void 0,!0)]),_:3})])])],2)):Fe("",!0),ve("div",E_,[ve("div",T_,[pe(a.$slots,"doc-before",{},void 0,!0),ve("main",C_,[Ue(c,{class:yt(["vp-doc",[o.value,ee(e).externalLinkIcon&&"external-link-icon-enabled"]])},null,8,["class"])]),Ue(x_,null,{"doc-footer-before":xe(()=>[pe(a.$slots,"doc-footer-before",{},void 0,!0)]),_:3}),pe(a.$slots,"doc-after",{},void 0,!0)])])]),pe(a.$slots,"doc-bottom",{},void 0,!0)],2)}}}),R_=qe(P_,[["__scopeId","data-v-39a288b8"]]),I_=ke({__name:"VPButton",props:{tag:{},size:{default:"medium"},theme:{default:"brand"},text:{},href:{},target:{},rel:{}},setup(s){const e=s,t=He(()=>e.href&&tf.test(e.href)),n=He(()=>e.tag||e.href?"a":"button");return(i,r)=>(Y(),Xe(Xs(n.value),{class:yt(["VPButton",[i.size,i.theme]]),href:i.href?ee(su)(i.href):void 0,target:e.target??(t.value?"_blank":void 0),rel:e.rel??(t.value?"noreferrer":void 0)},{default:xe(()=>[qt(pt(i.text),1)]),_:1},8,["class","href","target","rel"]))}}),L_=qe(I_,[["__scopeId","data-v-cad61b99"]]),N_=["src","alt"],D_=ke({inheritAttrs:!1,__name:"VPImage",props:{image:{},alt:{}},setup(s){return(e,t)=>{const n=rn("VPImage",!0);return e.image?(Y(),ge(xt,{key:0},[typeof e.image=="string"||"src"in e.image?(Y(),ge("img",ca({key:0,class:"VPImage"},typeof e.image=="string"?e.$attrs:{...e.image,...e.$attrs},{src:ee(tu)(typeof e.image=="string"?e.image:e.image.src),alt:e.alt??(typeof e.image=="string"?"":e.image.alt||"")}),null,16,N_)):(Y(),ge(xt,{key:1},[Ue(n,ca({class:"dark",image:e.image.dark,alt:e.image.alt},e.$attrs),null,16,["image","alt"]),Ue(n,ca({class:"light",image:e.image.light,alt:e.image.alt},e.$attrs),null,16,["image","alt"])],64))],64)):Fe("",!0)}}}),ba=qe(D_,[["__scopeId","data-v-8426fc1a"]]),U_=s=>($t("data-v-303bb580"),s=s(),Xt(),s),O_={class:"container"},F_={class:"main"},k_={key:0,class:"name"},B_=["innerHTML"],z_=["innerHTML"],V_=["innerHTML"],H_={key:0,class:"actions"},G_={key:0,class:"image"},W_={class:"image-container"},$_=U_(()=>ve("div",{class:"image-bg"},null,-1)),X_=ke({__name:"VPHero",props:{name:{},text:{},tagline:{},image:{},actions:{}},setup(s){const e=qr("hero-image-slot-exists");return(t,n)=>(Y(),ge("div",{class:yt(["VPHero",{"has-image":t.image||ee(e)}])},[ve("div",O_,[ve("div",F_,[pe(t.$slots,"home-hero-info-before",{},void 0,!0),pe(t.$slots,"home-hero-info",{},()=>[t.name?(Y(),ge("h1",k_,[ve("span",{innerHTML:t.name,class:"clip"},null,8,B_)])):Fe("",!0),t.text?(Y(),ge("p",{key:1,innerHTML:t.text,class:"text"},null,8,z_)):Fe("",!0),t.tagline?(Y(),ge("p",{key:2,innerHTML:t.tagline,class:"tagline"},null,8,V_)):Fe("",!0)],!0),pe(t.$slots,"home-hero-info-after",{},void 0,!0),t.actions?(Y(),ge("div",H_,[(Y(!0),ge(xt,null,Qt(t.actions,i=>(Y(),ge("div",{key:i.link,class:"action"},[Ue(L_,{tag:"a",size:"medium",theme:i.theme,text:i.text,href:i.link,target:i.target,rel:i.rel},null,8,["theme","text","href","target","rel"])]))),128))])):Fe("",!0),pe(t.$slots,"home-hero-actions-after",{},void 0,!0)]),t.image||ee(e)?(Y(),ge("div",G_,[ve("div",W_,[$_,pe(t.$slots,"home-hero-image",{},()=>[t.image?(Y(),Xe(ba,{key:0,class:"image-src",image:t.image},null,8,["image"])):Fe("",!0)],!0)])])):Fe("",!0)])],2))}}),q_=qe(X_,[["__scopeId","data-v-303bb580"]]),Y_=ke({__name:"VPHomeHero",setup(s){const{frontmatter:e}=lt();return(t,n)=>ee(e).hero?(Y(),Xe(q_,{key:0,class:"VPHomeHero",name:ee(e).hero.name,text:ee(e).hero.text,tagline:ee(e).hero.tagline,image:ee(e).hero.image,actions:ee(e).hero.actions},{"home-hero-info-before":xe(()=>[pe(t.$slots,"home-hero-info-before")]),"home-hero-info":xe(()=>[pe(t.$slots,"home-hero-info")]),"home-hero-info-after":xe(()=>[pe(t.$slots,"home-hero-info-after")]),"home-hero-actions-after":xe(()=>[pe(t.$slots,"home-hero-actions-after")]),"home-hero-image":xe(()=>[pe(t.$slots,"home-hero-image")]),_:3},8,["name","text","tagline","image","actions"])):Fe("",!0)}}),Z_=s=>($t("data-v-a3976bdc"),s=s(),Xt(),s),K_={class:"box"},J_={key:0,class:"icon"},j_=["innerHTML"],Q_=["innerHTML"],ev=["innerHTML"],tv={key:4,class:"link-text"},nv={class:"link-text-value"},iv=Z_(()=>ve("span",{class:"vpi-arrow-right link-text-icon"},null,-1)),sv=ke({__name:"VPFeature",props:{icon:{},title:{},details:{},link:{},linkText:{},rel:{},target:{}},setup(s){return(e,t)=>(Y(),Xe(Gn,{class:"VPFeature",href:e.link,rel:e.rel,target:e.target,"no-icon":!0,tag:e.link?"a":"div"},{default:xe(()=>[ve("article",K_,[typeof e.icon=="object"&&e.icon.wrap?(Y(),ge("div",J_,[Ue(ba,{image:e.icon,alt:e.icon.alt,height:e.icon.height||48,width:e.icon.width||48},null,8,["image","alt","height","width"])])):typeof e.icon=="object"?(Y(),Xe(ba,{key:1,image:e.icon,alt:e.icon.alt,height:e.icon.height||48,width:e.icon.width||48},null,8,["image","alt","height","width"])):e.icon?(Y(),ge("div",{key:2,class:"icon",innerHTML:e.icon},null,8,j_)):Fe("",!0),ve("h2",{class:"title",innerHTML:e.title},null,8,Q_),e.details?(Y(),ge("p",{key:3,class:"details",innerHTML:e.details},null,8,ev)):Fe("",!0),e.linkText?(Y(),ge("div",tv,[ve("p",nv,[qt(pt(e.linkText)+" ",1),iv])])):Fe("",!0)])]),_:1},8,["href","rel","target","tag"]))}}),rv=qe(sv,[["__scopeId","data-v-a3976bdc"]]),ov={key:0,class:"VPFeatures"},av={class:"container"},lv={class:"items"},cv=ke({__name:"VPFeatures",props:{features:{}},setup(s){const e=s,t=He(()=>{const n=e.features.length;if(n){if(n===2)return"grid-2";if(n===3)return"grid-3";if(n%3===0)return"grid-6";if(n>3)return"grid-4"}else return});return(n,i)=>n.features?(Y(),ge("div",ov,[ve("div",av,[ve("div",lv,[(Y(!0),ge(xt,null,Qt(n.features,r=>(Y(),ge("div",{key:r.title,class:yt(["item",[t.value]])},[Ue(rv,{icon:r.icon,title:r.title,details:r.details,link:r.link,"link-text":r.linkText,rel:r.rel,target:r.target},null,8,["icon","title","details","link","link-text","rel","target"])],2))),128))])])])):Fe("",!0)}}),uv=qe(cv,[["__scopeId","data-v-a6181336"]]),hv=ke({__name:"VPHomeFeatures",setup(s){const{frontmatter:e}=lt();return(t,n)=>ee(e).features?(Y(),Xe(uv,{key:0,class:"VPHomeFeatures",features:ee(e).features},null,8,["features"])):Fe("",!0)}}),dv=ke({__name:"VPHomeContent",setup(s){const{width:e}=Qm({initialWidth:0,includeScrollbar:!1});return(t,n)=>(Y(),ge("div",{class:"vp-doc container",style:nu(ee(e)?{"--vp-offset":`calc(50% - ${ee(e)/2}px)`}:{})},[pe(t.$slots,"default",{},void 0,!0)],4))}}),fv=qe(dv,[["__scopeId","data-v-8e2d4988"]]),pv={class:"VPHome"},mv=ke({__name:"VPHome",setup(s){const{frontmatter:e}=lt();return(t,n)=>{const i=rn("Content");return Y(),ge("div",pv,[pe(t.$slots,"home-hero-before",{},void 0,!0),Ue(Y_,null,{"home-hero-info-before":xe(()=>[pe(t.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":xe(()=>[pe(t.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":xe(()=>[pe(t.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":xe(()=>[pe(t.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":xe(()=>[pe(t.$slots,"home-hero-image",{},void 0,!0)]),_:3}),pe(t.$slots,"home-hero-after",{},void 0,!0),pe(t.$slots,"home-features-before",{},void 0,!0),Ue(hv),pe(t.$slots,"home-features-after",{},void 0,!0),ee(e).markdownStyles!==!1?(Y(),Xe(fv,{key:0},{default:xe(()=>[Ue(i)]),_:1})):(Y(),Xe(i,{key:1}))])}}}),gv=qe(mv,[["__scopeId","data-v-686f80a6"]]),_v={},vv={class:"VPPage"};function yv(s,e){const t=rn("Content");return Y(),ge("div",vv,[pe(s.$slots,"page-top"),Ue(t),pe(s.$slots,"page-bottom")])}const xv=qe(_v,[["render",yv]]),Mv=ke({__name:"VPContent",setup(s){const{page:e,frontmatter:t}=lt(),{hasSidebar:n}=di();return(i,r)=>(Y(),ge("div",{class:yt(["VPContent",{"has-sidebar":ee(n),"is-home":ee(t).layout==="home"}]),id:"VPContent"},[ee(e).isNotFound?pe(i.$slots,"not-found",{key:0},()=>[Ue(Rg)],!0):ee(t).layout==="page"?(Y(),Xe(xv,{key:1},{"page-top":xe(()=>[pe(i.$slots,"page-top",{},void 0,!0)]),"page-bottom":xe(()=>[pe(i.$slots,"page-bottom",{},void 0,!0)]),_:3})):ee(t).layout==="home"?(Y(),Xe(gv,{key:2},{"home-hero-before":xe(()=>[pe(i.$slots,"home-hero-before",{},void 0,!0)]),"home-hero-info-before":xe(()=>[pe(i.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":xe(()=>[pe(i.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":xe(()=>[pe(i.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":xe(()=>[pe(i.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":xe(()=>[pe(i.$slots,"home-hero-image",{},void 0,!0)]),"home-hero-after":xe(()=>[pe(i.$slots,"home-hero-after",{},void 0,!0)]),"home-features-before":xe(()=>[pe(i.$slots,"home-features-before",{},void 0,!0)]),"home-features-after":xe(()=>[pe(i.$slots,"home-features-after",{},void 0,!0)]),_:3})):ee(t).layout&&ee(t).layout!=="doc"?(Y(),Xe(Xs(ee(t).layout),{key:3})):(Y(),Xe(R_,{key:4},{"doc-top":xe(()=>[pe(i.$slots,"doc-top",{},void 0,!0)]),"doc-bottom":xe(()=>[pe(i.$slots,"doc-bottom",{},void 0,!0)]),"doc-footer-before":xe(()=>[pe(i.$slots,"doc-footer-before",{},void 0,!0)]),"doc-before":xe(()=>[pe(i.$slots,"doc-before",{},void 0,!0)]),"doc-after":xe(()=>[pe(i.$slots,"doc-after",{},void 0,!0)]),"aside-top":xe(()=>[pe(i.$slots,"aside-top",{},void 0,!0)]),"aside-outline-before":xe(()=>[pe(i.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":xe(()=>[pe(i.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":xe(()=>[pe(i.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":xe(()=>[pe(i.$slots,"aside-ads-after",{},void 0,!0)]),"aside-bottom":xe(()=>[pe(i.$slots,"aside-bottom",{},void 0,!0)]),_:3}))],2))}}),bv=qe(Mv,[["__scopeId","data-v-1428d186"]]),Sv={class:"container"},wv=["innerHTML"],Av=["innerHTML"],Ev=ke({__name:"VPFooter",setup(s){const{theme:e,frontmatter:t}=lt(),{hasSidebar:n}=di();return(i,r)=>ee(e).footer&&ee(t).footer!==!1?(Y(),ge("footer",{key:0,class:yt(["VPFooter",{"has-sidebar":ee(n)}])},[ve("div",Sv,[ee(e).footer.message?(Y(),ge("p",{key:0,class:"message",innerHTML:ee(e).footer.message},null,8,wv)):Fe("",!0),ee(e).footer.copyright?(Y(),ge("p",{key:1,class:"copyright",innerHTML:ee(e).footer.copyright},null,8,Av)):Fe("",!0)])],2)):Fe("",!0)}}),Tv=qe(Ev,[["__scopeId","data-v-e315a0ad"]]);function Cv(){const{theme:s,frontmatter:e}=lt(),t=Dn([]),n=He(()=>t.value.length>0);return La(()=>{t.value=ru(e.value.outline??s.value.outline)}),{headers:t,hasLocalNav:n}}const Pv=s=>($t("data-v-17a5e62e"),s=s(),Xt(),s),Rv={class:"menu-text"},Iv=Pv(()=>ve("span",{class:"vpi-chevron-right icon"},null,-1)),Lv={class:"header"},Nv={class:"outline"},Dv=ke({__name:"VPLocalNavOutlineDropdown",props:{headers:{},navHeight:{}},setup(s){const e=s,{theme:t}=lt(),n=Ve(!1),i=Ve(0),r=Ve(),o=Ve();function a(h){var d;(d=r.value)!=null&&d.contains(h.target)||(n.value=!1)}wt(n,h=>{if(h){document.addEventListener("click",a);return}document.removeEventListener("click",a)}),rc("Escape",()=>{n.value=!1}),La(()=>{n.value=!1});function l(){n.value=!n.value,i.value=window.innerHeight+Math.min(window.scrollY-e.navHeight,0)}function c(h){h.target.classList.contains("outline-link")&&(o.value&&(o.value.style.transition="none"),iu(()=>{n.value=!1}))}function u(){n.value=!1,window.scrollTo({top:0,left:0,behavior:"smooth"})}return(h,d)=>(Y(),ge("div",{class:"VPLocalNavOutlineDropdown",style:nu({"--vp-vh":i.value+"px"}),ref_key:"main",ref:r},[h.headers.length>0?(Y(),ge("button",{key:0,onClick:l,class:yt({open:n.value})},[ve("span",Rv,pt(ee(lf)(ee(t))),1),Iv],2)):(Y(),ge("button",{key:1,onClick:u},pt(ee(t).returnToTopLabel||"Return to top"),1)),Ue(eu,{name:"flyout"},{default:xe(()=>[n.value?(Y(),ge("div",{key:0,ref_key:"items",ref:o,class:"items",onClick:c},[ve("div",Lv,[ve("a",{class:"top-link",href:"#",onClick:u},pt(ee(t).returnToTopLabel||"Return to top"),1)]),ve("div",Nv,[Ue(cf,{headers:h.headers},null,8,["headers"])])],512)):Fe("",!0)]),_:1})],4))}}),Uv=qe(Dv,[["__scopeId","data-v-17a5e62e"]]),Ov=s=>($t("data-v-a6f0e41e"),s=s(),Xt(),s),Fv={class:"container"},kv=["aria-expanded"],Bv=Ov(()=>ve("span",{class:"vpi-align-left menu-icon"},null,-1)),zv={class:"menu-text"},Vv=ke({__name:"VPLocalNav",props:{open:{type:Boolean}},emits:["open-menu"],setup(s){const{theme:e,frontmatter:t}=lt(),{hasSidebar:n}=di(),{headers:i}=Cv(),{y:r}=nf(),o=Ve(0);Fn(()=>{o.value=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--vp-nav-height"))}),La(()=>{i.value=ru(t.value.outline??e.value.outline)});const a=He(()=>i.value.length===0),l=He(()=>a.value&&!n.value),c=He(()=>({VPLocalNav:!0,"has-sidebar":n.value,empty:a.value,fixed:l.value}));return(u,h)=>ee(t).layout!=="home"&&(!l.value||ee(r)>=o.value)?(Y(),ge("div",{key:0,class:yt(c.value)},[ve("div",Fv,[ee(n)?(Y(),ge("button",{key:0,class:"menu","aria-expanded":u.open,"aria-controls":"VPSidebarNav",onClick:h[0]||(h[0]=d=>u.$emit("open-menu"))},[Bv,ve("span",zv,pt(ee(e).sidebarMenuLabel||"Menu"),1)],8,kv)):Fe("",!0),Ue(Uv,{headers:ee(i),navHeight:o.value},null,8,["headers","navHeight"])])],2)):Fe("",!0)}}),Hv=qe(Vv,[["__scopeId","data-v-a6f0e41e"]]);function Gv(){const s=Ve(!1);function e(){s.value=!0,window.addEventListener("resize",i)}function t(){s.value=!1,window.removeEventListener("resize",i)}function n(){s.value?t():e()}function i(){window.outerWidth>=768&&t()}const r=Xr();return wt(()=>r.path,t),{isScreenOpen:s,openScreen:e,closeScreen:t,toggleScreen:n}}const Wv={},$v={class:"VPSwitch",type:"button",role:"switch"},Xv={class:"check"},qv={key:0,class:"icon"};function Yv(s,e){return Y(),ge("button",$v,[ve("span",Xv,[s.$slots.default?(Y(),ge("span",qv,[pe(s.$slots,"default",{},void 0,!0)])):Fe("",!0)])])}const Zv=qe(Wv,[["render",Yv],["__scopeId","data-v-1d5665e3"]]),hf=s=>($t("data-v-d1f28634"),s=s(),Xt(),s),Kv=hf(()=>ve("span",{class:"vpi-sun sun"},null,-1)),Jv=hf(()=>ve("span",{class:"vpi-moon moon"},null,-1)),jv=ke({__name:"VPSwitchAppearance",setup(s){const{isDark:e,theme:t}=lt(),n=qr("toggle-appearance",()=>{e.value=!e.value}),i=He(()=>e.value?t.value.lightModeSwitchTitle||"Switch to light theme":t.value.darkModeSwitchTitle||"Switch to dark theme");return(r,o)=>(Y(),Xe(Zv,{title:i.value,class:"VPSwitchAppearance","aria-checked":ee(e),onClick:ee(n)},{default:xe(()=>[Kv,Jv]),_:1},8,["title","aria-checked","onClick"]))}}),ou=qe(jv,[["__scopeId","data-v-d1f28634"]]),Qv={key:0,class:"VPNavBarAppearance"},e0=ke({__name:"VPNavBarAppearance",setup(s){const{site:e}=lt();return(t,n)=>ee(e).appearance&&ee(e).appearance!=="force-dark"?(Y(),ge("div",Qv,[Ue(ou)])):Fe("",!0)}}),t0=qe(e0,[["__scopeId","data-v-e6aabb21"]]),au=Ve();let df=!1,ml=0;function n0(s){const e=Ve(!1);if(Na){!df&&i0(),ml++;const t=wt(au,n=>{var i,r,o;n===s.el.value||(i=s.el.value)!=null&&i.contains(n)?(e.value=!0,(r=s.onFocus)==null||r.call(s)):(e.value=!1,(o=s.onBlur)==null||o.call(s))});$n(()=>{t(),ml--,ml||s0()})}return br(e)}function i0(){document.addEventListener("focusin",ff),df=!0,au.value=document.activeElement}function s0(){document.removeEventListener("focusin",ff)}function ff(){au.value=document.activeElement}const r0={class:"VPMenuLink"},o0=ke({__name:"VPMenuLink",props:{item:{}},setup(s){const{page:e}=lt();return(t,n)=>(Y(),ge("div",r0,[Ue(Gn,{class:yt({active:ee(cs)(ee(e).relativePath,t.item.activeMatch||t.item.link,!!t.item.activeMatch)}),href:t.item.link,target:t.item.target,rel:t.item.rel},{default:xe(()=>[qt(pt(t.item.text),1)]),_:1},8,["class","href","target","rel"])]))}}),Da=qe(o0,[["__scopeId","data-v-43f1e123"]]),a0={class:"VPMenuGroup"},l0={key:0,class:"title"},c0=ke({__name:"VPMenuGroup",props:{text:{},items:{}},setup(s){return(e,t)=>(Y(),ge("div",a0,[e.text?(Y(),ge("p",l0,pt(e.text),1)):Fe("",!0),(Y(!0),ge(xt,null,Qt(e.items,n=>(Y(),ge(xt,null,["link"in n?(Y(),Xe(Da,{key:0,item:n},null,8,["item"])):Fe("",!0)],64))),256))]))}}),u0=qe(c0,[["__scopeId","data-v-69e747b5"]]),h0={class:"VPMenu"},d0={key:0,class:"items"},f0=ke({__name:"VPMenu",props:{items:{}},setup(s){return(e,t)=>(Y(),ge("div",h0,[e.items?(Y(),ge("div",d0,[(Y(!0),ge(xt,null,Qt(e.items,n=>(Y(),ge(xt,{key:n.text},["link"in n?(Y(),Xe(Da,{key:0,item:n},null,8,["item"])):(Y(),Xe(u0,{key:1,text:n.text,items:n.items},null,8,["text","items"]))],64))),128))])):Fe("",!0),pe(e.$slots,"default",{},void 0,!0)]))}}),p0=qe(f0,[["__scopeId","data-v-e7ea1737"]]),m0=s=>($t("data-v-b6c34ac9"),s=s(),Xt(),s),g0=["aria-expanded","aria-label"],_0={key:0,class:"text"},v0=["innerHTML"],y0=m0(()=>ve("span",{class:"vpi-chevron-down text-icon"},null,-1)),x0={key:1,class:"vpi-more-horizontal icon"},M0={class:"menu"},b0=ke({__name:"VPFlyout",props:{icon:{},button:{},label:{},items:{}},setup(s){const e=Ve(!1),t=Ve();n0({el:t,onBlur:n});function n(){e.value=!1}return(i,r)=>(Y(),ge("div",{class:"VPFlyout",ref_key:"el",ref:t,onMouseenter:r[1]||(r[1]=o=>e.value=!0),onMouseleave:r[2]||(r[2]=o=>e.value=!1)},[ve("button",{type:"button",class:"button","aria-haspopup":"true","aria-expanded":e.value,"aria-label":i.label,onClick:r[0]||(r[0]=o=>e.value=!e.value)},[i.button||i.icon?(Y(),ge("span",_0,[i.icon?(Y(),ge("span",{key:0,class:yt([i.icon,"option-icon"])},null,2)):Fe("",!0),i.button?(Y(),ge("span",{key:1,innerHTML:i.button},null,8,v0)):Fe("",!0),y0])):(Y(),ge("span",x0))],8,g0),ve("div",M0,[Ue(p0,{items:i.items},{default:xe(()=>[pe(i.$slots,"default",{},void 0,!0)]),_:3},8,["items"])])],544))}}),lu=qe(b0,[["__scopeId","data-v-b6c34ac9"]]),S0=["href","aria-label","innerHTML"],w0=ke({__name:"VPSocialLink",props:{icon:{},link:{},ariaLabel:{}},setup(s){const e=s,t=He(()=>typeof e.icon=="object"?e.icon.svg:`<span class="vpi-social-${e.icon}" />`);return(n,i)=>(Y(),ge("a",{class:"VPSocialLink no-icon",href:n.link,"aria-label":n.ariaLabel??(typeof n.icon=="string"?n.icon:""),target:"_blank",rel:"noopener",innerHTML:t.value},null,8,S0))}}),A0=qe(w0,[["__scopeId","data-v-eee4e7cb"]]),E0={class:"VPSocialLinks"},T0=ke({__name:"VPSocialLinks",props:{links:{}},setup(s){return(e,t)=>(Y(),ge("div",E0,[(Y(!0),ge(xt,null,Qt(e.links,({link:n,icon:i,ariaLabel:r})=>(Y(),Xe(A0,{key:n,icon:i,link:n,ariaLabel:r},null,8,["icon","link","ariaLabel"]))),128))]))}}),cu=qe(T0,[["__scopeId","data-v-7bc22406"]]),C0={key:0,class:"group translations"},P0={class:"trans-title"},R0={key:1,class:"group"},I0={class:"item appearance"},L0={class:"label"},N0={class:"appearance-action"},D0={key:2,class:"group"},U0={class:"item social-links"},O0=ke({__name:"VPNavBarExtra",setup(s){const{site:e,theme:t}=lt(),{localeLinks:n,currentLang:i}=Yr({correspondingLink:!0}),r=He(()=>n.value.length&&i.value.label||e.value.appearance||t.value.socialLinks);return(o,a)=>r.value?(Y(),Xe(lu,{key:0,class:"VPNavBarExtra",label:"extra navigation"},{default:xe(()=>[ee(n).length&&ee(i).label?(Y(),ge("div",C0,[ve("p",P0,pt(ee(i).label),1),(Y(!0),ge(xt,null,Qt(ee(n),l=>(Y(),Xe(Da,{key:l.link,item:l},null,8,["item"]))),128))])):Fe("",!0),ee(e).appearance&&ee(e).appearance!=="force-dark"?(Y(),ge("div",R0,[ve("div",I0,[ve("p",L0,pt(ee(t).darkModeSwitchLabel||"Appearance"),1),ve("div",N0,[Ue(ou)])])])):Fe("",!0),ee(t).socialLinks?(Y(),ge("div",D0,[ve("div",U0,[Ue(cu,{class:"social-links-list",links:ee(t).socialLinks},null,8,["links"])])])):Fe("",!0)]),_:1})):Fe("",!0)}}),F0=qe(O0,[["__scopeId","data-v-d0bd9dde"]]),k0=s=>($t("data-v-e5dd9c1c"),s=s(),Xt(),s),B0=["aria-expanded"],z0=k0(()=>ve("span",{class:"container"},[ve("span",{class:"top"}),ve("span",{class:"middle"}),ve("span",{class:"bottom"})],-1)),V0=[z0],H0=ke({__name:"VPNavBarHamburger",props:{active:{type:Boolean}},emits:["click"],setup(s){return(e,t)=>(Y(),ge("button",{type:"button",class:yt(["VPNavBarHamburger",{active:e.active}]),"aria-label":"mobile navigation","aria-expanded":e.active,"aria-controls":"VPNavScreen",onClick:t[0]||(t[0]=n=>e.$emit("click"))},V0,10,B0))}}),G0=qe(H0,[["__scopeId","data-v-e5dd9c1c"]]),W0=["innerHTML"],$0=ke({__name:"VPNavBarMenuLink",props:{item:{}},setup(s){const{page:e}=lt();return(t,n)=>(Y(),Xe(Gn,{class:yt({VPNavBarMenuLink:!0,active:ee(cs)(ee(e).relativePath,t.item.activeMatch||t.item.link,!!t.item.activeMatch)}),href:t.item.link,noIcon:t.item.noIcon,target:t.item.target,rel:t.item.rel,tabindex:"0"},{default:xe(()=>[ve("span",{innerHTML:t.item.text},null,8,W0)]),_:1},8,["class","href","noIcon","target","rel"]))}}),X0=qe($0,[["__scopeId","data-v-9c663999"]]),q0=ke({__name:"VPNavBarMenuGroup",props:{item:{}},setup(s){const e=s,{page:t}=lt(),n=r=>"link"in r?cs(t.value.relativePath,r.link,!!e.item.activeMatch):r.items.some(n),i=He(()=>n(e.item));return(r,o)=>(Y(),Xe(lu,{class:yt({VPNavBarMenuGroup:!0,active:ee(cs)(ee(t).relativePath,r.item.activeMatch,!!r.item.activeMatch)||i.value}),button:r.item.text,items:r.item.items},null,8,["class","button","items"]))}}),Y0=s=>($t("data-v-7f418b0f"),s=s(),Xt(),s),Z0={key:0,"aria-labelledby":"main-nav-aria-label",class:"VPNavBarMenu"},K0=Y0(()=>ve("span",{id:"main-nav-aria-label",class:"visually-hidden"},"Main Navigation",-1)),J0=ke({__name:"VPNavBarMenu",setup(s){const{theme:e}=lt();return(t,n)=>ee(e).nav?(Y(),ge("nav",Z0,[K0,(Y(!0),ge(xt,null,Qt(ee(e).nav,i=>(Y(),ge(xt,{key:i.text},["link"in i?(Y(),Xe(X0,{key:0,item:i},null,8,["item"])):(Y(),Xe(q0,{key:1,item:i},null,8,["item"]))],64))),128))])):Fe("",!0)}}),j0=qe(J0,[["__scopeId","data-v-7f418b0f"]]);function Q0(s){const{localeIndex:e,theme:t}=lt();function n(i){var g,_,p;const r=i.split("."),o=(g=t.value.search)==null?void 0:g.options,a=o&&typeof o=="object",l=a&&((p=(_=o.locales)==null?void 0:_[e.value])==null?void 0:p.translations)||null,c=a&&o.translations||null;let u=l,h=c,d=s;const f=r.pop();for(const m of r){let y=null;const v=d==null?void 0:d[m];v&&(y=d=v);const x=h==null?void 0:h[m];x&&(y=h=x);const E=u==null?void 0:u[m];E&&(y=u=E),v||(d=y),x||(h=y),E||(u=y)}return(u==null?void 0:u[f])??(h==null?void 0:h[f])??(d==null?void 0:d[f])??""}return n}const ey=["aria-label"],ty={class:"DocSearch-Button-Container"},ny=ve("span",{class:"vp-icon DocSearch-Search-Icon"},null,-1),iy={class:"DocSearch-Button-Placeholder"},sy=ve("span",{class:"DocSearch-Button-Keys"},[ve("kbd",{class:"DocSearch-Button-Key"}),ve("kbd",{class:"DocSearch-Button-Key"},"K")],-1),ah=ke({__name:"VPNavBarSearchButton",setup(s){const t=Q0({button:{buttonText:"Search",buttonAriaLabel:"Search"}});return(n,i)=>(Y(),ge("button",{type:"button",class:"DocSearch DocSearch-Button","aria-label":ee(t)("button.buttonAriaLabel")},[ve("span",ty,[ny,ve("span",iy,pt(ee(t)("button.buttonText")),1)]),sy],8,ey))}}),ry={class:"VPNavBarSearch"},oy={id:"local-search"},ay={key:1,id:"docsearch"},ly=ke({__name:"VPNavBarSearch",setup(s){const e=eg(()=>tg(()=>import("./VPLocalSearchBox.zY3w-sDv.js"),__vite__mapDeps([0,1]))),t=()=>null,{theme:n}=lt(),i=Ve(!1),r=Ve(!1);Fn(()=>{});function o(){i.value||(i.value=!0,setTimeout(a,16))}function a(){const h=new Event("keydown");h.key="k",h.metaKey=!0,window.dispatchEvent(h),setTimeout(()=>{document.querySelector(".DocSearch-Modal")||a()},16)}function l(h){const d=h.target,f=d.tagName;return d.isContentEditable||f==="INPUT"||f==="SELECT"||f==="TEXTAREA"}const c=Ve(!1);rc("k",h=>{(h.ctrlKey||h.metaKey)&&(h.preventDefault(),c.value=!0)}),rc("/",h=>{l(h)||(h.preventDefault(),c.value=!0)});const u="local";return(h,d)=>{var f;return Y(),ge("div",ry,[ee(u)==="local"?(Y(),ge(xt,{key:0},[c.value?(Y(),Xe(ee(e),{key:0,onClose:d[0]||(d[0]=g=>c.value=!1)})):Fe("",!0),ve("div",oy,[Ue(ah,{onClick:d[1]||(d[1]=g=>c.value=!0)})])],64)):ee(u)==="algolia"?(Y(),ge(xt,{key:1},[i.value?(Y(),Xe(ee(t),{key:0,algolia:((f=ee(n).search)==null?void 0:f.options)??ee(n).algolia,onVnodeBeforeMount:d[2]||(d[2]=g=>r.value=!0)},null,8,["algolia"])):Fe("",!0),r.value?Fe("",!0):(Y(),ge("div",ay,[Ue(ah,{onClick:o})]))],64)):Fe("",!0)])}}}),cy=ke({__name:"VPNavBarSocialLinks",setup(s){const{theme:e}=lt();return(t,n)=>ee(e).socialLinks?(Y(),Xe(cu,{key:0,class:"VPNavBarSocialLinks",links:ee(e).socialLinks},null,8,["links"])):Fe("",!0)}}),uy=qe(cy,[["__scopeId","data-v-0394ad82"]]),hy=["href","rel","target"],dy={key:1},fy={key:2},py=ke({__name:"VPNavBarTitle",setup(s){const{site:e,theme:t}=lt(),{hasSidebar:n}=di(),{currentLang:i}=Yr(),r=He(()=>{var l;return typeof t.value.logoLink=="string"?t.value.logoLink:(l=t.value.logoLink)==null?void 0:l.link}),o=He(()=>{var l;return typeof t.value.logoLink=="string"||(l=t.value.logoLink)==null?void 0:l.rel}),a=He(()=>{var l;return typeof t.value.logoLink=="string"||(l=t.value.logoLink)==null?void 0:l.target});return(l,c)=>(Y(),ge("div",{class:yt(["VPNavBarTitle",{"has-sidebar":ee(n)}])},[ve("a",{class:"title",href:r.value??ee(su)(ee(i).link),rel:o.value,target:a.value},[pe(l.$slots,"nav-bar-title-before",{},void 0,!0),ee(t).logo?(Y(),Xe(ba,{key:0,class:"logo",image:ee(t).logo},null,8,["image"])):Fe("",!0),ee(t).siteTitle?(Y(),ge("span",dy,pt(ee(t).siteTitle),1)):ee(t).siteTitle===void 0?(Y(),ge("span",fy,pt(ee(e).title),1)):Fe("",!0),pe(l.$slots,"nav-bar-title-after",{},void 0,!0)],8,hy)],2))}}),my=qe(py,[["__scopeId","data-v-ab179fa1"]]),gy={class:"items"},_y={class:"title"},vy=ke({__name:"VPNavBarTranslations",setup(s){const{theme:e}=lt(),{localeLinks:t,currentLang:n}=Yr({correspondingLink:!0});return(i,r)=>ee(t).length&&ee(n).label?(Y(),Xe(lu,{key:0,class:"VPNavBarTranslations",icon:"vpi-languages",label:ee(e).langMenuLabel||"Change language"},{default:xe(()=>[ve("div",gy,[ve("p",_y,pt(ee(n).label),1),(Y(!0),ge(xt,null,Qt(ee(t),o=>(Y(),Xe(Da,{key:o.link,item:o},null,8,["item"]))),128))])]),_:1},8,["label"])):Fe("",!0)}}),yy=qe(vy,[["__scopeId","data-v-88af2de4"]]),xy=s=>($t("data-v-ccf7ddec"),s=s(),Xt(),s),My={class:"wrapper"},by={class:"container"},Sy={class:"title"},wy={class:"content"},Ay={class:"content-body"},Ey=xy(()=>ve("div",{class:"divider"},[ve("div",{class:"divider-line"})],-1)),Ty=ke({__name:"VPNavBar",props:{isScreenOpen:{type:Boolean}},emits:["toggle-screen"],setup(s){const{y:e}=nf(),{hasSidebar:t}=di(),{frontmatter:n}=lt(),i=Ve({});return ef(()=>{i.value={"has-sidebar":t.value,home:n.value.layout==="home",top:e.value===0}}),(r,o)=>(Y(),ge("div",{class:yt(["VPNavBar",i.value])},[ve("div",My,[ve("div",by,[ve("div",Sy,[Ue(my,null,{"nav-bar-title-before":xe(()=>[pe(r.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":xe(()=>[pe(r.$slots,"nav-bar-title-after",{},void 0,!0)]),_:3})]),ve("div",wy,[ve("div",Ay,[pe(r.$slots,"nav-bar-content-before",{},void 0,!0),Ue(ly,{class:"search"}),Ue(j0,{class:"menu"}),Ue(yy,{class:"translations"}),Ue(t0,{class:"appearance"}),Ue(uy,{class:"social-links"}),Ue(F0,{class:"extra"}),pe(r.$slots,"nav-bar-content-after",{},void 0,!0),Ue(G0,{class:"hamburger",active:r.isScreenOpen,onClick:o[0]||(o[0]=a=>r.$emit("toggle-screen"))},null,8,["active"])])])])]),Ey],2))}}),Cy=qe(Ty,[["__scopeId","data-v-ccf7ddec"]]),Py={key:0,class:"VPNavScreenAppearance"},Ry={class:"text"},Iy=ke({__name:"VPNavScreenAppearance",setup(s){const{site:e,theme:t}=lt();return(n,i)=>ee(e).appearance&&ee(e).appearance!=="force-dark"?(Y(),ge("div",Py,[ve("p",Ry,pt(ee(t).darkModeSwitchLabel||"Appearance"),1),Ue(ou)])):Fe("",!0)}}),Ly=qe(Iy,[["__scopeId","data-v-2d7af913"]]),Ny=ke({__name:"VPNavScreenMenuLink",props:{item:{}},setup(s){const e=qr("close-screen");return(t,n)=>(Y(),Xe(Gn,{class:"VPNavScreenMenuLink",href:t.item.link,target:t.item.target,rel:t.item.rel,onClick:ee(e),innerHTML:t.item.text},null,8,["href","target","rel","onClick","innerHTML"]))}}),Dy=qe(Ny,[["__scopeId","data-v-7f31e1f6"]]),Uy=ke({__name:"VPNavScreenMenuGroupLink",props:{item:{}},setup(s){const e=qr("close-screen");return(t,n)=>(Y(),Xe(Gn,{class:"VPNavScreenMenuGroupLink",href:t.item.link,target:t.item.target,rel:t.item.rel,onClick:ee(e)},{default:xe(()=>[qt(pt(t.item.text),1)]),_:1},8,["href","target","rel","onClick"]))}}),pf=qe(Uy,[["__scopeId","data-v-19976ae1"]]),Oy={class:"VPNavScreenMenuGroupSection"},Fy={key:0,class:"title"},ky=ke({__name:"VPNavScreenMenuGroupSection",props:{text:{},items:{}},setup(s){return(e,t)=>(Y(),ge("div",Oy,[e.text?(Y(),ge("p",Fy,pt(e.text),1)):Fe("",!0),(Y(!0),ge(xt,null,Qt(e.items,n=>(Y(),Xe(pf,{key:n.text,item:n},null,8,["item"]))),128))]))}}),By=qe(ky,[["__scopeId","data-v-8133b170"]]),zy=s=>($t("data-v-ff6087d4"),s=s(),Xt(),s),Vy=["aria-controls","aria-expanded"],Hy=["innerHTML"],Gy=zy(()=>ve("span",{class:"vpi-plus button-icon"},null,-1)),Wy=["id"],$y={key:1,class:"group"},Xy=ke({__name:"VPNavScreenMenuGroup",props:{text:{},items:{}},setup(s){const e=s,t=Ve(!1),n=He(()=>`NavScreenGroup-${e.text.replace(" ","-").toLowerCase()}`);function i(){t.value=!t.value}return(r,o)=>(Y(),ge("div",{class:yt(["VPNavScreenMenuGroup",{open:t.value}])},[ve("button",{class:"button","aria-controls":n.value,"aria-expanded":t.value,onClick:i},[ve("span",{class:"button-text",innerHTML:r.text},null,8,Hy),Gy],8,Vy),ve("div",{id:n.value,class:"items"},[(Y(!0),ge(xt,null,Qt(r.items,a=>(Y(),ge(xt,{key:a.text},["link"in a?(Y(),ge("div",{key:a.text,class:"item"},[Ue(pf,{item:a},null,8,["item"])])):(Y(),ge("div",$y,[Ue(By,{text:a.text,items:a.items},null,8,["text","items"])]))],64))),128))],8,Wy)],2))}}),qy=qe(Xy,[["__scopeId","data-v-ff6087d4"]]),Yy={key:0,class:"VPNavScreenMenu"},Zy=ke({__name:"VPNavScreenMenu",setup(s){const{theme:e}=lt();return(t,n)=>ee(e).nav?(Y(),ge("nav",Yy,[(Y(!0),ge(xt,null,Qt(ee(e).nav,i=>(Y(),ge(xt,{key:i.text},["link"in i?(Y(),Xe(Dy,{key:0,item:i},null,8,["item"])):(Y(),Xe(qy,{key:1,text:i.text||"",items:i.items},null,8,["text","items"]))],64))),128))])):Fe("",!0)}}),Ky=ke({__name:"VPNavScreenSocialLinks",setup(s){const{theme:e}=lt();return(t,n)=>ee(e).socialLinks?(Y(),Xe(cu,{key:0,class:"VPNavScreenSocialLinks",links:ee(e).socialLinks},null,8,["links"])):Fe("",!0)}}),mf=s=>($t("data-v-858fe1a4"),s=s(),Xt(),s),Jy=mf(()=>ve("span",{class:"vpi-languages icon lang"},null,-1)),jy=mf(()=>ve("span",{class:"vpi-chevron-down icon chevron"},null,-1)),Qy={class:"list"},ex=ke({__name:"VPNavScreenTranslations",setup(s){const{localeLinks:e,currentLang:t}=Yr({correspondingLink:!0}),n=Ve(!1);function i(){n.value=!n.value}return(r,o)=>ee(e).length&&ee(t).label?(Y(),ge("div",{key:0,class:yt(["VPNavScreenTranslations",{open:n.value}])},[ve("button",{class:"title",onClick:i},[Jy,qt(" "+pt(ee(t).label)+" ",1),jy]),ve("ul",Qy,[(Y(!0),ge(xt,null,Qt(ee(e),a=>(Y(),ge("li",{key:a.link,class:"item"},[Ue(Gn,{class:"link",href:a.link},{default:xe(()=>[qt(pt(a.text),1)]),_:2},1032,["href"])]))),128))])],2)):Fe("",!0)}}),tx=qe(ex,[["__scopeId","data-v-858fe1a4"]]),nx={class:"container"},ix=ke({__name:"VPNavScreen",props:{open:{type:Boolean}},setup(s){const e=Ve(null),t=sf(Na?document.body:null);return(n,i)=>(Y(),Xe(eu,{name:"fade",onEnter:i[0]||(i[0]=r=>t.value=!0),onAfterLeave:i[1]||(i[1]=r=>t.value=!1)},{default:xe(()=>[n.open?(Y(),ge("div",{key:0,class:"VPNavScreen",ref_key:"screen",ref:e,id:"VPNavScreen"},[ve("div",nx,[pe(n.$slots,"nav-screen-content-before",{},void 0,!0),Ue(Zy,{class:"menu"}),Ue(tx,{class:"translations"}),Ue(Ly,{class:"appearance"}),Ue(Ky,{class:"social-links"}),pe(n.$slots,"nav-screen-content-after",{},void 0,!0)])],512)):Fe("",!0)]),_:3}))}}),sx=qe(ix,[["__scopeId","data-v-cc5739dd"]]),rx={key:0,class:"VPNav"},ox=ke({__name:"VPNav",setup(s){const{isScreenOpen:e,closeScreen:t,toggleScreen:n}=Gv(),{frontmatter:i}=lt(),r=He(()=>i.value.navbar!==!1);return Sr("close-screen",t),Li(()=>{Na&&document.documentElement.classList.toggle("hide-nav",!r.value)}),(o,a)=>r.value?(Y(),ge("header",rx,[Ue(Cy,{"is-screen-open":ee(e),onToggleScreen:ee(n)},{"nav-bar-title-before":xe(()=>[pe(o.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":xe(()=>[pe(o.$slots,"nav-bar-title-after",{},void 0,!0)]),"nav-bar-content-before":xe(()=>[pe(o.$slots,"nav-bar-content-before",{},void 0,!0)]),"nav-bar-content-after":xe(()=>[pe(o.$slots,"nav-bar-content-after",{},void 0,!0)]),_:3},8,["is-screen-open","onToggleScreen"]),Ue(sx,{open:ee(e)},{"nav-screen-content-before":xe(()=>[pe(o.$slots,"nav-screen-content-before",{},void 0,!0)]),"nav-screen-content-after":xe(()=>[pe(o.$slots,"nav-screen-content-after",{},void 0,!0)]),_:3},8,["open"])])):Fe("",!0)}}),ax=qe(ox,[["__scopeId","data-v-ae24b3ad"]]),gf=s=>($t("data-v-b8d55f3b"),s=s(),Xt(),s),lx=["role","tabindex"],cx=gf(()=>ve("div",{class:"indicator"},null,-1)),ux=["onKeydown"],hx=gf(()=>ve("span",{class:"vpi-chevron-right caret-icon"},null,-1)),dx=[hx],fx={key:1,class:"items"},px=ke({__name:"VPSidebarItem",props:{item:{},depth:{}},setup(s){const e=s,{collapsed:t,collapsible:n,isLink:i,isActiveLink:r,hasActiveLink:o,hasChildren:a,toggle:l}=Dg(He(()=>e.item)),c=He(()=>a.value?"section":"div"),u=He(()=>i.value?"a":"div"),h=He(()=>a.value?e.depth+2===7?"p":`h${e.depth+2}`:"p"),d=He(()=>i.value?void 0:"button"),f=He(()=>[[`level-${e.depth}`],{collapsible:n.value},{collapsed:t.value},{"is-link":i.value},{"is-active":r.value},{"has-active":o.value}]);function g(p){"key"in p&&p.key!=="Enter"||!e.item.link&&l()}function _(){e.item.link&&l()}return(p,m)=>{const y=rn("VPSidebarItem",!0);return Y(),Xe(Xs(c.value),{class:yt(["VPSidebarItem",f.value])},{default:xe(()=>[p.item.text?(Y(),ge("div",ca({key:0,class:"item",role:d.value},ig(p.item.items?{click:g,keydown:g}:{},!0),{tabindex:p.item.items&&0}),[cx,p.item.link?(Y(),Xe(Gn,{key:0,tag:u.value,class:"link",href:p.item.link,rel:p.item.rel,target:p.item.target},{default:xe(()=>[(Y(),Xe(Xs(h.value),{class:"text",innerHTML:p.item.text},null,8,["innerHTML"]))]),_:1},8,["tag","href","rel","target"])):(Y(),Xe(Xs(h.value),{key:1,class:"text",innerHTML:p.item.text},null,8,["innerHTML"])),p.item.collapsed!=null&&p.item.items&&p.item.items.length?(Y(),ge("div",{key:2,class:"caret",role:"button","aria-label":"toggle section",onClick:_,onKeydown:ng(_,["enter"]),tabindex:"0"},dx,40,ux)):Fe("",!0)],16,lx)):Fe("",!0),p.item.items&&p.item.items.length?(Y(),ge("div",fx,[p.depth<5?(Y(!0),ge(xt,{key:0},Qt(p.item.items,v=>(Y(),Xe(y,{key:v.text,item:v,depth:p.depth+1},null,8,["item","depth"]))),128)):Fe("",!0)])):Fe("",!0)]),_:1},8,["class"])}}}),mx=qe(px,[["__scopeId","data-v-b8d55f3b"]]),_f=s=>($t("data-v-575e6a36"),s=s(),Xt(),s),gx=_f(()=>ve("div",{class:"curtain"},null,-1)),_x={class:"nav",id:"VPSidebarNav","aria-labelledby":"sidebar-aria-label",tabindex:"-1"},vx=_f(()=>ve("span",{class:"visually-hidden",id:"sidebar-aria-label"}," Sidebar Navigation ",-1)),yx=ke({__name:"VPSidebar",props:{open:{type:Boolean}},setup(s){const e=s,{sidebarGroups:t,hasSidebar:n}=di(),i=Ve(null),r=sf(Na?document.body:null);return wt([e,i],()=>{var o;e.open?(r.value=!0,(o=i.value)==null||o.focus()):r.value=!1},{immediate:!0,flush:"post"}),(o,a)=>ee(n)?(Y(),ge("aside",{key:0,class:yt(["VPSidebar",{open:o.open}]),ref_key:"navEl",ref:i,onClick:a[0]||(a[0]=sg(()=>{},["stop"]))},[gx,ve("nav",_x,[vx,pe(o.$slots,"sidebar-nav-before",{},void 0,!0),(Y(!0),ge(xt,null,Qt(ee(t),l=>(Y(),ge("div",{key:l.text,class:"group"},[Ue(mx,{item:l,depth:0},null,8,["item"])]))),128)),pe(o.$slots,"sidebar-nav-after",{},void 0,!0)])],2)):Fe("",!0)}}),xx=qe(yx,[["__scopeId","data-v-575e6a36"]]),Mx=ke({__name:"VPSkipLink",setup(s){const e=Xr(),t=Ve();wt(()=>e.path,()=>t.value.focus());function n({target:i}){const r=document.getElementById(decodeURIComponent(i.hash).slice(1));if(r){const o=()=>{r.removeAttribute("tabindex"),r.removeEventListener("blur",o)};r.setAttribute("tabindex","-1"),r.addEventListener("blur",o),r.focus(),window.scrollTo(0,0)}}return(i,r)=>(Y(),ge(xt,null,[ve("span",{ref_key:"backToTop",ref:t,tabindex:"-1"},null,512),ve("a",{href:"#VPContent",class:"VPSkipLink visually-hidden",onClick:n}," Skip to content ")],64))}}),bx=qe(Mx,[["__scopeId","data-v-0f60ec36"]]),Sx=ke({__name:"Layout",setup(s){const{isOpen:e,open:t,close:n}=di(),i=Xr();wt(()=>i.path,n),Ng(e,n);const{frontmatter:r}=lt(),o=rf(),a=He(()=>!!o["home-hero-image"]);return Sr("hero-image-slot-exists",a),(l,c)=>{const u=rn("Content");return ee(r).layout!==!1?(Y(),ge("div",{key:0,class:yt(["Layout",ee(r).pageClass])},[pe(l.$slots,"layout-top",{},void 0,!0),Ue(bx),Ue(vg,{class:"backdrop",show:ee(e),onClick:ee(n)},null,8,["show","onClick"]),Ue(ax,null,{"nav-bar-title-before":xe(()=>[pe(l.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":xe(()=>[pe(l.$slots,"nav-bar-title-after",{},void 0,!0)]),"nav-bar-content-before":xe(()=>[pe(l.$slots,"nav-bar-content-before",{},void 0,!0)]),"nav-bar-content-after":xe(()=>[pe(l.$slots,"nav-bar-content-after",{},void 0,!0)]),"nav-screen-content-before":xe(()=>[pe(l.$slots,"nav-screen-content-before",{},void 0,!0)]),"nav-screen-content-after":xe(()=>[pe(l.$slots,"nav-screen-content-after",{},void 0,!0)]),_:3}),Ue(Hv,{open:ee(e),onOpenMenu:ee(t)},null,8,["open","onOpenMenu"]),Ue(xx,{open:ee(e)},{"sidebar-nav-before":xe(()=>[pe(l.$slots,"sidebar-nav-before",{},void 0,!0)]),"sidebar-nav-after":xe(()=>[pe(l.$slots,"sidebar-nav-after",{},void 0,!0)]),_:3},8,["open"]),Ue(bv,null,{"page-top":xe(()=>[pe(l.$slots,"page-top",{},void 0,!0)]),"page-bottom":xe(()=>[pe(l.$slots,"page-bottom",{},void 0,!0)]),"not-found":xe(()=>[pe(l.$slots,"not-found",{},void 0,!0)]),"home-hero-before":xe(()=>[pe(l.$slots,"home-hero-before",{},void 0,!0)]),"home-hero-info-before":xe(()=>[pe(l.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":xe(()=>[pe(l.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":xe(()=>[pe(l.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":xe(()=>[pe(l.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":xe(()=>[pe(l.$slots,"home-hero-image",{},void 0,!0)]),"home-hero-after":xe(()=>[pe(l.$slots,"home-hero-after",{},void 0,!0)]),"home-features-before":xe(()=>[pe(l.$slots,"home-features-before",{},void 0,!0)]),"home-features-after":xe(()=>[pe(l.$slots,"home-features-after",{},void 0,!0)]),"doc-footer-before":xe(()=>[pe(l.$slots,"doc-footer-before",{},void 0,!0)]),"doc-before":xe(()=>[pe(l.$slots,"doc-before",{},void 0,!0)]),"doc-after":xe(()=>[pe(l.$slots,"doc-after",{},void 0,!0)]),"doc-top":xe(()=>[pe(l.$slots,"doc-top",{},void 0,!0)]),"doc-bottom":xe(()=>[pe(l.$slots,"doc-bottom",{},void 0,!0)]),"aside-top":xe(()=>[pe(l.$slots,"aside-top",{},void 0,!0)]),"aside-bottom":xe(()=>[pe(l.$slots,"aside-bottom",{},void 0,!0)]),"aside-outline-before":xe(()=>[pe(l.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":xe(()=>[pe(l.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":xe(()=>[pe(l.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":xe(()=>[pe(l.$slots,"aside-ads-after",{},void 0,!0)]),_:3}),Ue(Tv),pe(l.$slots,"layout-bottom",{},void 0,!0)],2)):(Y(),Xe(u,{key:1}))}}}),wx=qe(Sx,[["__scopeId","data-v-5d98c3a5"]]),vf={Layout:wx,enhanceApp:({app:s})=>{s.component("Badge",mg)}},Ax=ke({__name:"HighlightTargetedHeading",setup(s){function e(){if(!window||!window.location||!window.location.hash)return;const n=decodeURIComponent(window.location.hash);if(!n)return;let i;try{i=document.querySelector(n)}catch(r){console.error(r);return}i&&(i.classList.contains("VPNolebaseHighlightTargetedHeading")||i.classList.add("VPNolebaseHighlightTargetedHeading"),i.classList.remove("VPNolebaseHighlightTargetedHeadingAnimated"),setTimeout(()=>{i&&i.classList.add("VPNolebaseHighlightTargetedHeadingAnimated")},10))}const t=Xr();return Fn(e),wt(t,async()=>{await iu(),e()}),rg("hashchange",e),(n,i)=>pe(n.$slots,"default")}});/**
|
|
* @license
|
|
* Copyright 2010-2024 Three.js Authors
|
|
* SPDX-License-Identifier: MIT
|
|
*/const Zr="165",Ji={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ji={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},yf=0,cc=1,xf=2,Ex=3,Tx=0,uu=1,hu=2,zn=3,ci=0,an=1,In=2,ai=0,os=1,Sa=2,uc=3,hc=4,Mf=5,Ti=100,bf=101,Sf=102,wf=103,Af=104,Ef=200,Tf=201,Cf=202,Pf=203,wa=204,Aa=205,Rf=206,If=207,Lf=208,Nf=209,Df=210,Uf=211,Of=212,Ff=213,kf=214,Bf=0,zf=1,Vf=2,wr=3,Hf=4,Gf=5,Wf=6,$f=7,Kr=0,Xf=1,qf=2,Wn=0,Yf=1,Zf=2,Kf=3,Ua=4,Jf=5,jf=6,Qf=7,dc="attached",ep="detached",Oa=300,ui=301,Ri=302,Ar=303,Er=304,Js=306,Tr=1e3,An=1001,Cr=1002,Wt=1003,du=1004,Cx=1004,Vs=1005,Px=1005,Bt=1006,_r=1007,Rx=1007,Vn=1008,Ix=1008,hi=1009,tp=1010,np=1011,Pr=1012,fu=1013,us=1014,xn=1015,Jr=1016,pu=1017,mu=1018,hs=1020,ip=35902,sp=1021,rp=1022,fn=1023,op=1024,ap=1025,as=1026,ds=1027,gu=1028,_u=1029,lp=1030,vu=1031,yu=1033,ha=33776,da=33777,fa=33778,pa=33779,fc=35840,pc=35841,mc=35842,gc=35843,_c=36196,vc=37492,yc=37496,xc=37808,Mc=37809,bc=37810,Sc=37811,wc=37812,Ac=37813,Ec=37814,Tc=37815,Cc=37816,Pc=37817,Rc=37818,Ic=37819,Lc=37820,Nc=37821,ma=36492,Dc=36494,Uc=36495,cp=36283,Oc=36284,Fc=36285,kc=36286,up=2200,hp=2201,dp=2202,Rr=2300,Ea=2301,ga=2302,ns=2400,is=2401,Ir=2402,Fa=2500,xu=2501,Lx=0,Nx=1,Dx=2,fp=3200,pp=3201,Ni=0,mp=1,si="",dn="srgb",fi="srgb-linear",ka="display-p3",jr="display-p3-linear",Lr="linear",Mt="srgb",Nr="rec709",Dr="p3",Ux=0,Qi=7680,Ox=7681,Fx=7682,kx=7683,Bx=34055,zx=34056,Vx=5386,Hx=512,Gx=513,Wx=514,$x=515,Xx=516,qx=517,Yx=518,Bc=519,gp=512,_p=513,vp=514,Mu=515,yp=516,xp=517,Mp=518,bp=519,Ur=35044,Zx=35048,Kx=35040,Jx=35045,jx=35049,Qx=35041,eM=35046,tM=35050,nM=35042,iM="100",zc="300 es",Hn=2e3,Or=2001;class Yn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,e);e.target=null}}}const Yt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let lh=1234567;const ls=Math.PI/180,Ys=180/Math.PI;function Mn(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Yt[s&255]+Yt[s>>8&255]+Yt[s>>16&255]+Yt[s>>24&255]+"-"+Yt[e&255]+Yt[e>>8&255]+"-"+Yt[e>>16&15|64]+Yt[e>>24&255]+"-"+Yt[t&63|128]+Yt[t>>8&255]+"-"+Yt[t>>16&255]+Yt[t>>24&255]+Yt[n&255]+Yt[n>>8&255]+Yt[n>>16&255]+Yt[n>>24&255]).toLowerCase()}function Rt(s,e,t){return Math.max(e,Math.min(t,s))}function bu(s,e){return(s%e+e)%e}function sM(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function rM(s,e,t){return s!==e?(t-s)/(e-s):0}function vr(s,e,t){return(1-t)*s+t*e}function oM(s,e,t,n){return vr(s,e,1-Math.exp(-t*n))}function aM(s,e=1){return e-Math.abs(bu(s,e*2)-e)}function lM(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function cM(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function uM(s,e){return s+Math.floor(Math.random()*(e-s+1))}function hM(s,e){return s+Math.random()*(e-s)}function dM(s){return s*(.5-Math.random())}function fM(s){s!==void 0&&(lh=s);let e=lh+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function pM(s){return s*ls}function mM(s){return s*Ys}function gM(s){return(s&s-1)===0&&s!==0}function _M(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function vM(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function yM(s,e,t,n,i){const r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+n)/2),u=o((e+n)/2),h=r((e-n)/2),d=o((e-n)/2),f=r((n-e)/2),g=o((n-e)/2);switch(i){case"XYX":s.set(a*u,l*h,l*d,a*c);break;case"YZY":s.set(l*d,a*u,l*h,a*c);break;case"ZXZ":s.set(l*h,l*d,a*u,a*c);break;case"XZX":s.set(a*u,l*g,l*f,a*c);break;case"YXY":s.set(l*f,a*u,l*g,a*c);break;case"ZYZ":s.set(l*g,l*f,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function on(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function st(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Su={DEG2RAD:ls,RAD2DEG:Ys,generateUUID:Mn,clamp:Rt,euclideanModulo:bu,mapLinear:sM,inverseLerp:rM,lerp:vr,damp:oM,pingpong:aM,smoothstep:lM,smootherstep:cM,randInt:uM,randFloat:hM,randFloatSpread:dM,seededRandom:fM,degToRad:pM,radToDeg:mM,isPowerOfTwo:gM,ceilPowerOfTwo:_M,floorPowerOfTwo:vM,setQuaternionFromProperEuler:yM,normalize:st,denormalize:on};class te{constructor(e=0,t=0){te.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Rt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class je{constructor(e,t,n,i,r,o,a,l,c){je.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,l,c)}set(e,t,n,i,r,o,a,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=r,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],h=n[7],d=n[2],f=n[5],g=n[8],_=i[0],p=i[3],m=i[6],y=i[1],v=i[4],x=i[7],E=i[2],S=i[5],C=i[8];return r[0]=o*_+a*y+l*E,r[3]=o*p+a*v+l*S,r[6]=o*m+a*x+l*C,r[1]=c*_+u*y+h*E,r[4]=c*p+u*v+h*S,r[7]=c*m+u*x+h*C,r[2]=d*_+f*y+g*E,r[5]=d*p+f*v+g*S,r[8]=d*m+f*x+g*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-n*r*u+n*a*l+i*r*c-i*o*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,d=a*l-u*r,f=c*r-o*l,g=t*h+n*d+i*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return e[0]=h*_,e[1]=(i*c-u*n)*_,e[2]=(a*n-i*o)*_,e[3]=d*_,e[4]=(u*t-i*l)*_,e[5]=(i*r-a*t)*_,e[6]=f*_,e[7]=(n*l-c*t)*_,e[8]=(o*t-n*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,o,a){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(gl.makeScale(e,t)),this}rotate(e){return this.premultiply(gl.makeRotation(-e)),this}translate(e,t){return this.premultiply(gl.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const gl=new je;function Sp(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const xM={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Hs(s,e){return new xM[s](e)}function Fr(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function wp(){const s=Fr("canvas");return s.style.display="block",s}const ch={};function wu(s){s in ch||(ch[s]=!0,console.warn(s))}function MM(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const uh=new je().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),hh=new je().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ho={[fi]:{transfer:Lr,primaries:Nr,toReference:s=>s,fromReference:s=>s},[dn]:{transfer:Mt,primaries:Nr,toReference:s=>s.convertSRGBToLinear(),fromReference:s=>s.convertLinearToSRGB()},[jr]:{transfer:Lr,primaries:Dr,toReference:s=>s.applyMatrix3(hh),fromReference:s=>s.applyMatrix3(uh)},[ka]:{transfer:Mt,primaries:Dr,toReference:s=>s.convertSRGBToLinear().applyMatrix3(hh),fromReference:s=>s.applyMatrix3(uh).convertLinearToSRGB()}},bM=new Set([fi,jr]),dt={enabled:!0,_workingColorSpace:fi,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(s){if(!bM.has(s))throw new Error(`Unsupported working color space, "${s}".`);this._workingColorSpace=s},convert:function(s,e,t){if(this.enabled===!1||e===t||!e||!t)return s;const n=ho[e].toReference,i=ho[t].fromReference;return i(n(s))},fromWorkingColorSpace:function(s,e){return this.convert(s,this._workingColorSpace,e)},toWorkingColorSpace:function(s,e){return this.convert(s,e,this._workingColorSpace)},getPrimaries:function(s){return ho[s].primaries},getTransfer:function(s){return s===si?Lr:ho[s].transfer}};function qs(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function _l(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let ys;class Ap{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{ys===void 0&&(ys=Fr("canvas")),ys.width=e.width,ys.height=e.height;const n=ys.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=ys}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Fr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=qs(r[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(qs(t[n]/255)*255):t[n]=qs(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let SM=0;class ss{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:SM++}),this.uuid=Mn(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(vl(i[o].image)):r.push(vl(i[o]))}else r=vl(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function vl(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?Ap.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let wM=0;class It extends Yn{constructor(e=It.DEFAULT_IMAGE,t=It.DEFAULT_MAPPING,n=An,i=An,r=Bt,o=Vn,a=fn,l=hi,c=It.DEFAULT_ANISOTROPY,u=si){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:wM++}),this.uuid=Mn(),this.name="",this.source=new ss(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new te(0,0),this.repeat=new te(1,1),this.center=new te(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new je,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Oa)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Tr:e.x=e.x-Math.floor(e.x);break;case An:e.x=e.x<0?0:1;break;case Cr:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Tr:e.y=e.y-Math.floor(e.y);break;case An:e.y=e.y<0?0:1;break;case Cr:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}It.DEFAULT_IMAGE=null;It.DEFAULT_MAPPING=Oa;It.DEFAULT_ANISOTROPY=1;class _t{constructor(e=0,t=0,n=0,i=1){_t.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],f=l[5],g=l[9],_=l[2],p=l[6],m=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-_)<.01&&Math.abs(g-p)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+_)<.1&&Math.abs(g+p)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(c+1)/2,x=(f+1)/2,E=(m+1)/2,S=(u+d)/4,C=(h+_)/4,L=(g+p)/4;return v>x&&v>E?v<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(v),i=S/n,r=C/n):x>E?x<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(x),n=S/i,r=L/i):E<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(E),n=C/r,i=L/r),this.set(n,i,r,t),this}let y=Math.sqrt((p-g)*(p-g)+(h-_)*(h-_)+(d-u)*(d-u));return Math.abs(y)<.001&&(y=1),this.x=(p-g)/y,this.y=(h-_)/y,this.z=(d-u)/y,this.w=Math.acos((c+f+m-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Ep extends Yn{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new _t(0,0,e,t),this.scissorTest=!1,this.viewport=new _t(0,0,e,t);const i={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Bt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new It(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,i=e.textures.length;n<i;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new ss(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Un extends Ep{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Ba extends It{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Wt,this.minFilter=Wt,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class AM extends Un{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Ba(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Au extends It{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Wt,this.minFilter=Wt,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class EM extends Un{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Au(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Jt{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,o,a){let l=n[i+0],c=n[i+1],u=n[i+2],h=n[i+3];const d=r[o+0],f=r[o+1],g=r[o+2],_=r[o+3];if(a===0){e[t+0]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=f,e[t+2]=g,e[t+3]=_;return}if(h!==_||l!==d||c!==f||u!==g){let p=1-a;const m=l*d+c*f+u*g+h*_,y=m>=0?1:-1,v=1-m*m;if(v>Number.EPSILON){const E=Math.sqrt(v),S=Math.atan2(E,m*y);p=Math.sin(p*S)/E,a=Math.sin(a*S)/E}const x=a*y;if(l=l*p+d*x,c=c*p+f*x,u=u*p+g*x,h=h*p+_*x,p===1-a){const E=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=E,c*=E,u*=E,h*=E}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,o){const a=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=r[o],d=r[o+1],f=r[o+2],g=r[o+3];return e[t]=a*g+u*h+l*f-c*d,e[t+1]=l*g+u*d+c*h-a*f,e[t+2]=c*g+u*f+a*d-l*h,e[t+3]=u*g-a*h-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(i/2),h=a(r/2),d=l(n/2),f=l(i/2),g=l(r/2);switch(o){case"XYZ":this._x=d*u*h+c*f*g,this._y=c*f*h-d*u*g,this._z=c*u*g+d*f*h,this._w=c*u*h-d*f*g;break;case"YXZ":this._x=d*u*h+c*f*g,this._y=c*f*h-d*u*g,this._z=c*u*g-d*f*h,this._w=c*u*h+d*f*g;break;case"ZXY":this._x=d*u*h-c*f*g,this._y=c*f*h+d*u*g,this._z=c*u*g+d*f*h,this._w=c*u*h-d*f*g;break;case"ZYX":this._x=d*u*h-c*f*g,this._y=c*f*h+d*u*g,this._z=c*u*g-d*f*h,this._w=c*u*h+d*f*g;break;case"YZX":this._x=d*u*h+c*f*g,this._y=c*f*h+d*u*g,this._z=c*u*g-d*f*h,this._w=c*u*h-d*f*g;break;case"XZY":this._x=d*u*h-c*f*g,this._y=c*f*h-d*u*g,this._z=c*u*g+d*f*h,this._w=c*u*h+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=n+a+h;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(o-i)*f}else if(n>a&&n>h){const f=2*Math.sqrt(1+n-a-h);this._w=(u-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(r+c)/f}else if(a>h){const f=2*Math.sqrt(1+a-n-h);this._w=(r-c)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+h-n-a);this._w=(o-i)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Rt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+i*c-r*l,this._y=i*u+o*l+r*a-n*c,this._z=r*u+o*c+n*l-i*a,this._w=o*u-n*a-i*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,r=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;const l=1-a*a;if(l<=Number.EPSILON){const f=1-t;return this._w=f*o+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*r+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),h=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=o*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class N{constructor(e=0,t=0,n=0){N.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(dh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(dh.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*i-a*n),u=2*(a*t-r*i),h=2*(r*n-o*t);return this.x=t+l*c+o*h-a*u,this.y=n+l*u+a*c-r*h,this.z=i+l*h+r*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-r*a,this.y=r*o-n*l,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return yl.copy(this).projectOnVector(e),this.sub(yl)}reflect(e){return this.sub(yl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Rt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const yl=new N,dh=new Jt;class ln{constructor(e=new N(1/0,1/0,1/0),t=new N(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(En.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(En.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=En.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,En):En.fromBufferAttribute(r,o),En.applyMatrix4(e.matrixWorld),this.expandByPoint(En);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),fo.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),fo.copy(n.boundingBox)),fo.applyMatrix4(e.matrixWorld),this.union(fo)}const i=e.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,En),En.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(tr),po.subVectors(this.max,tr),xs.subVectors(e.a,tr),Ms.subVectors(e.b,tr),bs.subVectors(e.c,tr),vi.subVectors(Ms,xs),yi.subVectors(bs,Ms),Bi.subVectors(xs,bs);let t=[0,-vi.z,vi.y,0,-yi.z,yi.y,0,-Bi.z,Bi.y,vi.z,0,-vi.x,yi.z,0,-yi.x,Bi.z,0,-Bi.x,-vi.y,vi.x,0,-yi.y,yi.x,0,-Bi.y,Bi.x,0];return!xl(t,xs,Ms,bs,po)||(t=[1,0,0,0,1,0,0,0,1],!xl(t,xs,Ms,bs,po))?!1:(mo.crossVectors(vi,yi),t=[mo.x,mo.y,mo.z],xl(t,xs,Ms,bs,po))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,En).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(En).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Jn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Jn=[new N,new N,new N,new N,new N,new N,new N,new N],En=new N,fo=new ln,xs=new N,Ms=new N,bs=new N,vi=new N,yi=new N,Bi=new N,tr=new N,po=new N,mo=new N,zi=new N;function xl(s,e,t,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){zi.fromArray(s,r);const a=i.x*Math.abs(zi.x)+i.y*Math.abs(zi.y)+i.z*Math.abs(zi.z),l=e.dot(zi),c=t.dot(zi),u=n.dot(zi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const TM=new ln,nr=new N,Ml=new N;class jt{constructor(e=new N,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):TM.setFromPoints(e).getCenter(n);let i=0;for(let r=0,o=e.length;r<o;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;nr.subVectors(e,this.center);const t=nr.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(nr,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Ml.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(nr.copy(e.center).add(Ml)),this.expandByPoint(nr.copy(e.center).sub(Ml))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const jn=new N,bl=new N,go=new N,xi=new N,Sl=new N,_o=new N,wl=new N;class ms{constructor(e=new N,t=new N(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,jn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=jn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(jn.copy(this.origin).addScaledVector(this.direction,t),jn.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){bl.copy(e).add(t).multiplyScalar(.5),go.copy(t).sub(e).normalize(),xi.copy(this.origin).sub(bl);const r=e.distanceTo(t)*.5,o=-this.direction.dot(go),a=xi.dot(this.direction),l=-xi.dot(go),c=xi.lengthSq(),u=Math.abs(1-o*o);let h,d,f,g;if(u>0)if(h=o*l-a,d=o*a-l,g=r*u,h>=0)if(d>=-g)if(d<=g){const _=1/u;h*=_,d*=_,f=h*(h+o*d+2*a)+d*(o*h+d+2*l)+c}else d=r,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;else d=-r,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;else d<=-g?(h=Math.max(0,-(-o*r+a)),d=h>0?-r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c):d<=g?(h=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(h=Math.max(0,-(o*r+a)),d=h>0?r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c);else d=o>0?-r:r,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(bl).addScaledVector(go,d),f}intersectSphere(e,t){jn.subVectors(e.center,this.origin);const n=jn.dot(this.direction),i=jn.dot(jn)-n*n,r=e.radius*e.radius;if(i>r)return null;const o=Math.sqrt(r-i),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,o,a,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),u>=0?(r=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||r>i||((r>n||isNaN(n))&&(n=r),(o<i||isNaN(i))&&(i=o),h>=0?(a=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,jn)!==null}intersectTriangle(e,t,n,i,r){Sl.subVectors(t,e),_o.subVectors(n,e),wl.crossVectors(Sl,_o);let o=this.direction.dot(wl),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;xi.subVectors(this.origin,e);const l=a*this.direction.dot(_o.crossVectors(xi,_o));if(l<0)return null;const c=a*this.direction.dot(Sl.cross(xi));if(c<0||l+c>o)return null;const u=-a*xi.dot(wl);return u<0?null:this.at(u/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ze{constructor(e,t,n,i,r,o,a,l,c,u,h,d,f,g,_,p){Ze.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,l,c,u,h,d,f,g,_,p)}set(e,t,n,i,r,o,a,l,c,u,h,d,f,g,_,p){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=r,m[5]=o,m[9]=a,m[13]=l,m[2]=c,m[6]=u,m[10]=h,m[14]=d,m[3]=f,m[7]=g,m[11]=_,m[15]=p,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 Ze().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Ss.setFromMatrixColumn(e,0).length(),r=1/Ss.setFromMatrixColumn(e,1).length(),o=1/Ss.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const d=o*u,f=o*h,g=a*u,_=a*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=f+g*c,t[5]=d-_*c,t[9]=-a*l,t[2]=_-d*c,t[6]=g+f*c,t[10]=o*l}else if(e.order==="YXZ"){const d=l*u,f=l*h,g=c*u,_=c*h;t[0]=d+_*a,t[4]=g*a-f,t[8]=o*c,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=f*a-g,t[6]=_+d*a,t[10]=o*l}else if(e.order==="ZXY"){const d=l*u,f=l*h,g=c*u,_=c*h;t[0]=d-_*a,t[4]=-o*h,t[8]=g+f*a,t[1]=f+g*a,t[5]=o*u,t[9]=_-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const d=o*u,f=o*h,g=a*u,_=a*h;t[0]=l*u,t[4]=g*c-f,t[8]=d*c+_,t[1]=l*h,t[5]=_*c+d,t[9]=f*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const d=o*l,f=o*c,g=a*l,_=a*c;t[0]=l*u,t[4]=_-d*h,t[8]=g*h+f,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=f*h+g,t[10]=d-_*h}else if(e.order==="XZY"){const d=o*l,f=o*c,g=a*l,_=a*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+_,t[5]=o*u,t[9]=f*h-g,t[2]=g*h-f,t[6]=a*u,t[10]=_*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(CM,e,PM)}lookAt(e,t,n){const i=this.elements;return _n.subVectors(e,t),_n.lengthSq()===0&&(_n.z=1),_n.normalize(),Mi.crossVectors(n,_n),Mi.lengthSq()===0&&(Math.abs(n.z)===1?_n.x+=1e-4:_n.z+=1e-4,_n.normalize(),Mi.crossVectors(n,_n)),Mi.normalize(),vo.crossVectors(_n,Mi),i[0]=Mi.x,i[4]=vo.x,i[8]=_n.x,i[1]=Mi.y,i[5]=vo.y,i[9]=_n.y,i[2]=Mi.z,i[6]=vo.z,i[10]=_n.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],h=n[5],d=n[9],f=n[13],g=n[2],_=n[6],p=n[10],m=n[14],y=n[3],v=n[7],x=n[11],E=n[15],S=i[0],C=i[4],L=i[8],A=i[12],b=i[1],k=i[5],V=i[9],G=i[13],X=i[2],ce=i[6],Z=i[10],ae=i[14],z=i[3],Se=i[7],we=i[11],Ae=i[15];return r[0]=o*S+a*b+l*X+c*z,r[4]=o*C+a*k+l*ce+c*Se,r[8]=o*L+a*V+l*Z+c*we,r[12]=o*A+a*G+l*ae+c*Ae,r[1]=u*S+h*b+d*X+f*z,r[5]=u*C+h*k+d*ce+f*Se,r[9]=u*L+h*V+d*Z+f*we,r[13]=u*A+h*G+d*ae+f*Ae,r[2]=g*S+_*b+p*X+m*z,r[6]=g*C+_*k+p*ce+m*Se,r[10]=g*L+_*V+p*Z+m*we,r[14]=g*A+_*G+p*ae+m*Ae,r[3]=y*S+v*b+x*X+E*z,r[7]=y*C+v*k+x*ce+E*Se,r[11]=y*L+v*V+x*Z+E*we,r[15]=y*A+v*G+x*ae+E*Ae,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],f=e[14],g=e[3],_=e[7],p=e[11],m=e[15];return g*(+r*l*h-i*c*h-r*a*d+n*c*d+i*a*f-n*l*f)+_*(+t*l*f-t*c*d+r*o*d-i*o*f+i*c*u-r*l*u)+p*(+t*c*h-t*a*f-r*o*h+n*o*f+r*a*u-n*c*u)+m*(-i*a*u-t*l*h+t*a*d+i*o*h-n*o*d+n*l*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],g=e[12],_=e[13],p=e[14],m=e[15],y=h*p*c-_*d*c+_*l*f-a*p*f-h*l*m+a*d*m,v=g*d*c-u*p*c-g*l*f+o*p*f+u*l*m-o*d*m,x=u*_*c-g*h*c+g*a*f-o*_*f-u*a*m+o*h*m,E=g*h*l-u*_*l-g*a*d+o*_*d+u*a*p-o*h*p,S=t*y+n*v+i*x+r*E;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/S;return e[0]=y*C,e[1]=(_*d*r-h*p*r-_*i*f+n*p*f+h*i*m-n*d*m)*C,e[2]=(a*p*r-_*l*r+_*i*c-n*p*c-a*i*m+n*l*m)*C,e[3]=(h*l*r-a*d*r-h*i*c+n*d*c+a*i*f-n*l*f)*C,e[4]=v*C,e[5]=(u*p*r-g*d*r+g*i*f-t*p*f-u*i*m+t*d*m)*C,e[6]=(g*l*r-o*p*r-g*i*c+t*p*c+o*i*m-t*l*m)*C,e[7]=(o*d*r-u*l*r+u*i*c-t*d*c-o*i*f+t*l*f)*C,e[8]=x*C,e[9]=(g*h*r-u*_*r-g*n*f+t*_*f+u*n*m-t*h*m)*C,e[10]=(o*_*r-g*a*r+g*n*c-t*_*c-o*n*m+t*a*m)*C,e[11]=(u*a*r-o*h*r-u*n*c+t*h*c+o*n*f-t*a*f)*C,e[12]=E*C,e[13]=(u*_*i-g*h*i+g*n*d-t*_*d-u*n*p+t*h*p)*C,e[14]=(g*a*i-o*_*i-g*n*l+t*_*l+o*n*p-t*a*p)*C,e[15]=(o*h*i-u*a*i+u*n*l-t*h*l-o*n*d+t*a*d)*C,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,o=e.x,a=e.y,l=e.z,c=r*o,u=r*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+n,u*l-i*o,0,c*l-i*a,u*l+i*o,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,o){return this.set(1,n,r,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,u=o+o,h=a+a,d=r*c,f=r*u,g=r*h,_=o*u,p=o*h,m=a*h,y=l*c,v=l*u,x=l*h,E=n.x,S=n.y,C=n.z;return i[0]=(1-(_+m))*E,i[1]=(f+x)*E,i[2]=(g-v)*E,i[3]=0,i[4]=(f-x)*S,i[5]=(1-(d+m))*S,i[6]=(p+y)*S,i[7]=0,i[8]=(g+v)*C,i[9]=(p-y)*C,i[10]=(1-(d+_))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Ss.set(i[0],i[1],i[2]).length();const o=Ss.set(i[4],i[5],i[6]).length(),a=Ss.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Tn.copy(this);const c=1/r,u=1/o,h=1/a;return Tn.elements[0]*=c,Tn.elements[1]*=c,Tn.elements[2]*=c,Tn.elements[4]*=u,Tn.elements[5]*=u,Tn.elements[6]*=u,Tn.elements[8]*=h,Tn.elements[9]*=h,Tn.elements[10]*=h,t.setFromRotationMatrix(Tn),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,o,a=Hn){const l=this.elements,c=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i);let f,g;if(a===Hn)f=-(o+r)/(o-r),g=-2*o*r/(o-r);else if(a===Or)f=-o/(o-r),g=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,r,o,a=Hn){const l=this.elements,c=1/(t-e),u=1/(n-i),h=1/(o-r),d=(t+e)*c,f=(n+i)*u;let g,_;if(a===Hn)g=(o+r)*h,_=-2*h;else if(a===Or)g=r*h,_=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=_,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ss=new N,Tn=new Ze,CM=new N(0,0,0),PM=new N(1,1,1),Mi=new N,vo=new N,_n=new N,fh=new Ze,ph=new Jt;class bn{constructor(e=0,t=0,n=0,i=bn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=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(t){case"XYZ":this._y=Math.asin(Rt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Rt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(Rt(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,r));break;case"ZYX":this._y=Math.asin(-Rt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Rt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Rt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-u,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return fh.makeRotationFromQuaternion(e),this.setFromRotationMatrix(fh,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ph.setFromEuler(this),this.setFromQuaternion(ph,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}bn.DEFAULT_ORDER="XYZ";class za{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let RM=0;const mh=new N,ws=new Jt,Qn=new Ze,yo=new N,ir=new N,IM=new N,LM=new Jt,gh=new N(1,0,0),_h=new N(0,1,0),vh=new N(0,0,1),yh={type:"added"},NM={type:"removed"},As={type:"childadded",child:null},Al={type:"childremoved",child:null};class ut extends Yn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:RM++}),this.uuid=Mn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ut.DEFAULT_UP.clone();const e=new N,t=new bn,n=new Jt,i=new N(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ze},normalMatrix:{value:new je}}),this.matrix=new Ze,this.matrixWorld=new Ze,this.matrixAutoUpdate=ut.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new za,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ws.setFromAxisAngle(e,t),this.quaternion.multiply(ws),this}rotateOnWorldAxis(e,t){return ws.setFromAxisAngle(e,t),this.quaternion.premultiply(ws),this}rotateX(e){return this.rotateOnAxis(gh,e)}rotateY(e){return this.rotateOnAxis(_h,e)}rotateZ(e){return this.rotateOnAxis(vh,e)}translateOnAxis(e,t){return mh.copy(e).applyQuaternion(this.quaternion),this.position.add(mh.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(gh,e)}translateY(e){return this.translateOnAxis(_h,e)}translateZ(e){return this.translateOnAxis(vh,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Qn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?yo.copy(e):yo.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),ir.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Qn.lookAt(ir,yo,this.up):Qn.lookAt(yo,ir,this.up),this.quaternion.setFromRotationMatrix(Qn),i&&(Qn.extractRotation(i.matrixWorld),ws.setFromRotationMatrix(Qn),this.quaternion.premultiply(ws.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(yh),As.child=e,this.dispatchEvent(As),As.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(NM),Al.child=e,this.dispatchEvent(Al),Al.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Qn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Qn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Qn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(yh),As.child=e,this.dispatchEvent(As),As.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ir,e,IM),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ir,LM,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){const r=t[n];(r.matrixWorldAutoUpdate===!0||e===!0)&&r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const i=this.children;for(let r=0,o=i.length;r<o;r++){const a=i[r];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];r(e.shapes,h)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));i.material=a}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(r(e.animations,l))}}if(t){const a=o(e.geometries),l=o(e.materials),c=o(e.textures),u=o(e.images),h=o(e.shapes),d=o(e.skeletons),f=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=i,n;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}ut.DEFAULT_UP=new N(0,1,0);ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Cn=new N,ei=new N,El=new N,ti=new N,Es=new N,Ts=new N,xh=new N,Tl=new N,Cl=new N,Pl=new N;class yn{constructor(e=new N,t=new N,n=new N){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Cn.subVectors(e,t),i.cross(Cn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Cn.subVectors(i,t),ei.subVectors(n,t),El.subVectors(e,t);const o=Cn.dot(Cn),a=Cn.dot(ei),l=Cn.dot(El),c=ei.dot(ei),u=ei.dot(El),h=o*c-a*a;if(h===0)return r.set(0,0,0),null;const d=1/h,f=(c*l-a*u)*d,g=(o*u-a*l)*d;return r.set(1-f-g,g,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,ti)===null?!1:ti.x>=0&&ti.y>=0&&ti.x+ti.y<=1}static getInterpolation(e,t,n,i,r,o,a,l){return this.getBarycoord(e,t,n,i,ti)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,ti.x),l.addScaledVector(o,ti.y),l.addScaledVector(a,ti.z),l)}static isFrontFacing(e,t,n,i){return Cn.subVectors(n,t),ei.subVectors(e,t),Cn.cross(ei).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Cn.subVectors(this.c,this.b),ei.subVectors(this.a,this.b),Cn.cross(ei).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return yn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return yn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return yn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return yn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let o,a;Es.subVectors(i,n),Ts.subVectors(r,n),Tl.subVectors(e,n);const l=Es.dot(Tl),c=Ts.dot(Tl);if(l<=0&&c<=0)return t.copy(n);Cl.subVectors(e,i);const u=Es.dot(Cl),h=Ts.dot(Cl);if(u>=0&&h<=u)return t.copy(i);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(Es,o);Pl.subVectors(e,r);const f=Es.dot(Pl),g=Ts.dot(Pl);if(g>=0&&f<=g)return t.copy(r);const _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(n).addScaledVector(Ts,a);const p=u*g-f*h;if(p<=0&&h-u>=0&&f-g>=0)return xh.subVectors(r,i),a=(h-u)/(h-u+(f-g)),t.copy(i).addScaledVector(xh,a);const m=1/(p+_+d);return o=_*m,a=d*m,t.copy(n).addScaledVector(Es,o).addScaledVector(Ts,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Tp={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},bi={h:0,s:0,l:0},xo={h:0,s:0,l:0};function Rl(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Ie{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=dn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,dt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=dt.workingColorSpace){return this.r=e,this.g=t,this.b=n,dt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=dt.workingColorSpace){if(e=bu(e,1),t=Rt(t,0,1),n=Rt(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=Rl(o,r,e+1/3),this.g=Rl(o,r,e),this.b=Rl(o,r,e-1/3)}return dt.toWorkingColorSpace(this,i),this}setStyle(e,t=dn){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=dn){const n=Tp[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=qs(e.r),this.g=qs(e.g),this.b=qs(e.b),this}copyLinearToSRGB(e){return this.r=_l(e.r),this.g=_l(e.g),this.b=_l(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=dn){return dt.fromWorkingColorSpace(Zt.copy(this),e),Math.round(Rt(Zt.r*255,0,255))*65536+Math.round(Rt(Zt.g*255,0,255))*256+Math.round(Rt(Zt.b*255,0,255))}getHexString(e=dn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=dt.workingColorSpace){dt.fromWorkingColorSpace(Zt.copy(this),t);const n=Zt.r,i=Zt.g,r=Zt.b,o=Math.max(n,i,r),a=Math.min(n,i,r);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case n:l=(i-r)/h+(i<r?6:0);break;case i:l=(r-n)/h+2;break;case r:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=dt.workingColorSpace){return dt.fromWorkingColorSpace(Zt.copy(this),t),e.r=Zt.r,e.g=Zt.g,e.b=Zt.b,e}getStyle(e=dn){dt.fromWorkingColorSpace(Zt.copy(this),e);const t=Zt.r,n=Zt.g,i=Zt.b;return e!==dn?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(bi),this.setHSL(bi.h+e,bi.s+t,bi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(bi),e.getHSL(xo);const n=vr(bi.h,xo.h,t),i=vr(bi.s,xo.s,t),r=vr(bi.l,xo.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Zt=new Ie;Ie.NAMES=Tp;let DM=0;class en extends Yn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:DM++}),this.uuid=Mn(),this.name="",this.type="Material",this.blending=os,this.side=ci,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=wa,this.blendDst=Aa,this.blendEquation=Ti,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ie(0,0,0),this.blendAlpha=0,this.depthFunc=wr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Bc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qi,this.stencilZFail=Qi,this.stencilZPass=Qi,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==os&&(n.blending=this.blending),this.side!==ci&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==wa&&(n.blendSrc=this.blendSrc),this.blendDst!==Aa&&(n.blendDst=this.blendDst),this.blendEquation!==Ti&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==wr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Bc&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Qi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Qi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Qi&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const o=[];for(const a in r){const l=r[a];delete l.metadata,o.push(l)}return o}if(t){const r=i(e.textures),o=i(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class pi extends en{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ie(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new bn,this.combine=Kr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ri=UM();function UM(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const r=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);)c<<=1,u-=8388608;c&=-8388609,u+=947912704,r[l]=c|u}for(let l=1024;l<2048;++l)r[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:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:o,offsetTable:a}}function hn(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=Rt(s,-65504,65504),ri.floatView[0]=s;const e=ri.uint32View[0],t=e>>23&511;return ri.baseTable[t]+((e&8388607)>>ri.shiftTable[t])}function mr(s){const e=s>>10;return ri.uint32View[0]=ri.mantissaTable[ri.offsetTable[e]+(s&1023)]+ri.exponentTable[e],ri.floatView[0]}const OM={toHalfFloat:hn,fromHalfFloat:mr},Ft=new N,Mo=new te;class mt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ur,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=xn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return wu("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Mo.fromBufferAttribute(this,t),Mo.applyMatrix3(e),this.setXY(t,Mo.x,Mo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Ft.fromBufferAttribute(this,t),Ft.applyMatrix3(e),this.setXYZ(t,Ft.x,Ft.y,Ft.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Ft.fromBufferAttribute(this,t),Ft.applyMatrix4(e),this.setXYZ(t,Ft.x,Ft.y,Ft.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ft.fromBufferAttribute(this,t),Ft.applyNormalMatrix(e),this.setXYZ(t,Ft.x,Ft.y,Ft.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ft.fromBufferAttribute(this,t),Ft.transformDirection(e),this.setXYZ(t,Ft.x,Ft.y,Ft.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=on(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=on(t,this.array)),t}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=on(t,this.array)),t}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=on(t,this.array)),t}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=on(t,this.array)),t}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array),r=st(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ur&&(e.usage=this.usage),e}}class FM extends mt{constructor(e,t,n){super(new Int8Array(e),t,n)}}class kM extends mt{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class BM extends mt{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class zM extends mt{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Eu extends mt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class VM extends mt{constructor(e,t,n){super(new Int32Array(e),t,n)}}class Tu extends mt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class HM extends mt{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=mr(this.array[e*this.itemSize]);return this.normalized&&(t=on(t,this.array)),t}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize]=hn(t),this}getY(e){let t=mr(this.array[e*this.itemSize+1]);return this.normalized&&(t=on(t,this.array)),t}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+1]=hn(t),this}getZ(e){let t=mr(this.array[e*this.itemSize+2]);return this.normalized&&(t=on(t,this.array)),t}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+2]=hn(t),this}getW(e){let t=mr(this.array[e*this.itemSize+3]);return this.normalized&&(t=on(t,this.array)),t}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.array[e*this.itemSize+3]=hn(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.array[e+0]=hn(t),this.array[e+1]=hn(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array)),this.array[e+0]=hn(t),this.array[e+1]=hn(n),this.array[e+2]=hn(i),this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array),r=st(r,this.array)),this.array[e+0]=hn(t),this.array[e+1]=hn(n),this.array[e+2]=hn(i),this.array[e+3]=hn(r),this}}class Oe extends mt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let GM=0;const wn=new Ze,Il=new ut,Cs=new N,vn=new ln,sr=new ln,Gt=new N;class at extends Yn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:GM++}),this.uuid=Mn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Sp(e)?Tu:Eu)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new je().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return wn.makeRotationFromQuaternion(e),this.applyMatrix4(wn),this}rotateX(e){return wn.makeRotationX(e),this.applyMatrix4(wn),this}rotateY(e){return wn.makeRotationY(e),this.applyMatrix4(wn),this}rotateZ(e){return wn.makeRotationZ(e),this.applyMatrix4(wn),this}translate(e,t,n){return wn.makeTranslation(e,t,n),this.applyMatrix4(wn),this}scale(e,t,n){return wn.makeScale(e,t,n),this.applyMatrix4(wn),this}lookAt(e){return Il.lookAt(e),Il.updateMatrix(),this.applyMatrix4(Il.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cs).negate(),this.translate(Cs.x,Cs.y,Cs.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Oe(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ln);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];vn.setFromBufferAttribute(r),this.morphTargetsRelative?(Gt.addVectors(this.boundingBox.min,vn.min),this.boundingBox.expandByPoint(Gt),Gt.addVectors(this.boundingBox.max,vn.max),this.boundingBox.expandByPoint(Gt)):(this.boundingBox.expandByPoint(vn.min),this.boundingBox.expandByPoint(vn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new jt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(e){const n=this.boundingSphere.center;if(vn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const a=t[r];sr.setFromBufferAttribute(a),this.morphTargetsRelative?(Gt.addVectors(vn.min,sr.min),vn.expandByPoint(Gt),Gt.addVectors(vn.max,sr.max),vn.expandByPoint(Gt)):(vn.expandByPoint(sr.min),vn.expandByPoint(sr.max))}vn.getCenter(n);let i=0;for(let r=0,o=e.count;r<o;r++)Gt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Gt));if(t)for(let r=0,o=t.length;r<o;r++){const a=t[r],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)Gt.fromBufferAttribute(a,c),l&&(Cs.fromBufferAttribute(e,c),Gt.add(Cs)),i=Math.max(i,n.distanceToSquared(Gt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new mt(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let L=0;L<n.count;L++)a[L]=new N,l[L]=new N;const c=new N,u=new N,h=new N,d=new te,f=new te,g=new te,_=new N,p=new N;function m(L,A,b){c.fromBufferAttribute(n,L),u.fromBufferAttribute(n,A),h.fromBufferAttribute(n,b),d.fromBufferAttribute(r,L),f.fromBufferAttribute(r,A),g.fromBufferAttribute(r,b),u.sub(c),h.sub(c),f.sub(d),g.sub(d);const k=1/(f.x*g.y-g.x*f.y);isFinite(k)&&(_.copy(u).multiplyScalar(g.y).addScaledVector(h,-f.y).multiplyScalar(k),p.copy(h).multiplyScalar(f.x).addScaledVector(u,-g.x).multiplyScalar(k),a[L].add(_),a[A].add(_),a[b].add(_),l[L].add(p),l[A].add(p),l[b].add(p))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let L=0,A=y.length;L<A;++L){const b=y[L],k=b.start,V=b.count;for(let G=k,X=k+V;G<X;G+=3)m(e.getX(G+0),e.getX(G+1),e.getX(G+2))}const v=new N,x=new N,E=new N,S=new N;function C(L){E.fromBufferAttribute(i,L),S.copy(E);const A=a[L];v.copy(A),v.sub(E.multiplyScalar(E.dot(A))).normalize(),x.crossVectors(S,A);const k=x.dot(l[L])<0?-1:1;o.setXYZW(L,v.x,v.y,v.z,k)}for(let L=0,A=y.length;L<A;++L){const b=y[L],k=b.start,V=b.count;for(let G=k,X=k+V;G<X;G+=3)C(e.getX(G+0)),C(e.getX(G+1)),C(e.getX(G+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new mt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new N,r=new N,o=new N,a=new N,l=new N,c=new N,u=new N,h=new N;if(e)for(let d=0,f=e.count;d<f;d+=3){const g=e.getX(d+0),_=e.getX(d+1),p=e.getX(d+2);i.fromBufferAttribute(t,g),r.fromBufferAttribute(t,_),o.fromBufferAttribute(t,p),u.subVectors(o,r),h.subVectors(i,r),u.cross(h),a.fromBufferAttribute(n,g),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,p),a.add(u),l.add(u),c.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),u.subVectors(o,r),h.subVectors(i,r),u.cross(h),n.setXYZ(d+0,u.x,u.y,u.z),n.setXYZ(d+1,u.x,u.y,u.z),n.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gt.fromBufferAttribute(e,t),Gt.normalize(),e.setXYZ(t,Gt.x,Gt.y,Gt.z)}toNonIndexed(){function e(a,l){const c=a.array,u=a.itemSize,h=a.normalized,d=new c.constructor(l.length*u);let f=0,g=0;for(let _=0,p=l.length;_<p;_++){a.isInterleavedBufferAttribute?f=l[_]*a.data.stride+a.offset:f=l[_]*u;for(let m=0;m<u;m++)d[g++]=c[f++]}return new mt(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new at,n=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=e(l,n);t.setAttribute(a,c)}const r=this.morphAttributes;for(const a in r){const l=[],c=r[a];for(let u=0,h=c.length;u<h;u++){const d=c[u],f=e(d,n);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const f=c[h];u.push(f.toJSON(e.data))}u.length>0&&(i[l]=u,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],h=r[c];for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let c=0,u=o.length;c<u;c++){const h=o[c];this.addGroup(h.start,h.count,h.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Mh=new Ze,Vi=new ms,bo=new jt,bh=new N,Ps=new N,Rs=new N,Is=new N,Ll=new N,So=new N,wo=new te,Ao=new te,Eo=new te,Sh=new N,wh=new N,Ah=new N,To=new N,Co=new N;class Nt extends ut{constructor(e=new at,t=new pi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(r&&a){So.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const u=a[l],h=r[l];u!==0&&(Ll.fromBufferAttribute(h,e),o?So.addScaledVector(Ll,u):So.addScaledVector(Ll.sub(t),u))}t.add(So)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),bo.copy(n.boundingSphere),bo.applyMatrix4(r),Vi.copy(e.ray).recast(e.near),!(bo.containsPoint(Vi.origin)===!1&&(Vi.intersectSphere(bo,bh)===null||Vi.origin.distanceToSquared(bh)>(e.far-e.near)**2))&&(Mh.copy(r).invert(),Vi.copy(e.ray).applyMatrix4(Mh),!(n.boundingBox!==null&&Vi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Vi)))}_computeIntersections(e,t,n){let i;const r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,d=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,_=d.length;g<_;g++){const p=d[g],m=o[p.materialIndex],y=Math.max(p.start,f.start),v=Math.min(a.count,Math.min(p.start+p.count,f.start+f.count));for(let x=y,E=v;x<E;x+=3){const S=a.getX(x),C=a.getX(x+1),L=a.getX(x+2);i=Po(this,m,e,n,c,u,h,S,C,L),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),_=Math.min(a.count,f.start+f.count);for(let p=g,m=_;p<m;p+=3){const y=a.getX(p),v=a.getX(p+1),x=a.getX(p+2);i=Po(this,o,e,n,c,u,h,y,v,x),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let g=0,_=d.length;g<_;g++){const p=d[g],m=o[p.materialIndex],y=Math.max(p.start,f.start),v=Math.min(l.count,Math.min(p.start+p.count,f.start+f.count));for(let x=y,E=v;x<E;x+=3){const S=x,C=x+1,L=x+2;i=Po(this,m,e,n,c,u,h,S,C,L),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=p.materialIndex,t.push(i))}}else{const g=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let p=g,m=_;p<m;p+=3){const y=p,v=p+1,x=p+2;i=Po(this,o,e,n,c,u,h,y,v,x),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}}}}function WM(s,e,t,n,i,r,o,a){let l;if(e.side===an?l=n.intersectTriangle(o,r,i,!0,a):l=n.intersectTriangle(i,r,o,e.side===ci,a),l===null)return null;Co.copy(a),Co.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo(Co);return c<t.near||c>t.far?null:{distance:c,point:Co.clone(),object:s}}function Po(s,e,t,n,i,r,o,a,l,c){s.getVertexPosition(a,Ps),s.getVertexPosition(l,Rs),s.getVertexPosition(c,Is);const u=WM(s,e,t,n,Ps,Rs,Is,To);if(u){i&&(wo.fromBufferAttribute(i,a),Ao.fromBufferAttribute(i,l),Eo.fromBufferAttribute(i,c),u.uv=yn.getInterpolation(To,Ps,Rs,Is,wo,Ao,Eo,new te)),r&&(wo.fromBufferAttribute(r,a),Ao.fromBufferAttribute(r,l),Eo.fromBufferAttribute(r,c),u.uv1=yn.getInterpolation(To,Ps,Rs,Is,wo,Ao,Eo,new te)),o&&(Sh.fromBufferAttribute(o,a),wh.fromBufferAttribute(o,l),Ah.fromBufferAttribute(o,c),u.normal=yn.getInterpolation(To,Ps,Rs,Is,Sh,wh,Ah,new N),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const h={a,b:l,c,normal:new N,materialIndex:0};yn.getNormal(Ps,Rs,Is,h.normal),u.face=h}return u}class gs extends at{constructor(e=1,t=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};const a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);const l=[],c=[],u=[],h=[];let d=0,f=0;g("z","y","x",-1,-1,n,t,e,o,r,0),g("z","y","x",1,-1,n,t,-e,o,r,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,r,4),g("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(l),this.setAttribute("position",new Oe(c,3)),this.setAttribute("normal",new Oe(u,3)),this.setAttribute("uv",new Oe(h,2));function g(_,p,m,y,v,x,E,S,C,L,A){const b=x/C,k=E/L,V=x/2,G=E/2,X=S/2,ce=C+1,Z=L+1;let ae=0,z=0;const Se=new N;for(let we=0;we<Z;we++){const Ae=we*k-G;for(let _e=0;_e<ce;_e++){const De=_e*b-V;Se[_]=De*y,Se[p]=Ae*v,Se[m]=X,c.push(Se.x,Se.y,Se.z),Se[_]=0,Se[p]=0,Se[m]=S>0?1:-1,u.push(Se.x,Se.y,Se.z),h.push(_e/C),h.push(1-we/L),ae+=1}}for(let we=0;we<L;we++)for(let Ae=0;Ae<C;Ae++){const _e=d+Ae+ce*we,De=d+Ae+ce*(we+1),F=d+(Ae+1)+ce*(we+1),U=d+(Ae+1)+ce*we;l.push(_e,De,U),l.push(De,F,U),z+=6}a.addGroup(f,z,A),f+=z,d+=ae}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gs(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Zs(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function sn(s){const e={};for(let t=0;t<s.length;t++){const n=Zs(s[t]);for(const i in n)e[i]=n[i]}return e}function $M(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function Cp(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:dt.workingColorSpace}const Pp={clone:Zs,merge:sn};var XM=`void main() {
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,qM=`void main() {
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
}`;class On extends en{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=XM,this.fragmentShader=qM,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Zs(e.uniforms),this.uniformsGroups=$M(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Qr extends ut{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ze,this.projectionMatrix=new Ze,this.projectionMatrixInverse=new Ze,this.coordinateSystem=Hn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Si=new N,Eh=new te,Th=new te;class kt extends Qr{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Ys*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ls*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ys*2*Math.atan(Math.tan(ls*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Si.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Si.x,Si.y).multiplyScalar(-e/Si.z),Si.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Si.x,Si.y).multiplyScalar(-e/Si.z)}getViewSize(e,t){return this.getViewBounds(e,Eh,Th),t.subVectors(Th,Eh)}setViewOffset(e,t,n,i,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ls*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*i/l,t-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Ls=-90,Ns=1;class Rp extends ut{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new kt(Ls,Ns,e,t);i.layers=this.layers,this.add(i);const r=new kt(Ls,Ns,e,t);r.layers=this.layers,this.add(r);const o=new kt(Ls,Ns,e,t);o.layers=this.layers,this.add(o);const a=new kt(Ls,Ns,e,t);a.layers=this.layers,this.add(a);const l=new kt(Ls,Ns,e,t);l.layers=this.layers,this.add(l);const c=new kt(Ls,Ns,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,o,a,l]=t;for(const c of t)this.remove(c);if(e===Hn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Or)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,o,a,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=_,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(h,d,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class eo extends It{constructor(e,t,n,i,r,o,a,l,c,u){e=e!==void 0?e:[],t=t!==void 0?t:ui,super(e,t,n,i,r,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ip extends Un{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new eo(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Bt}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
|
|
}
|
|
`,fragmentShader:`
|
|
|
|
uniform sampler2D tEquirect;
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 direction = normalize( vWorldDirection );
|
|
|
|
vec2 sampleUV = equirectUv( direction );
|
|
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
|
|
}
|
|
`},i=new gs(5,5,5),r=new On({name:"CubemapFromEquirect",uniforms:Zs(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:an,blending:ai});r.uniforms.tEquirect.value=t;const o=new Nt(i,r),a=t.minFilter;return t.minFilter===Vn&&(t.minFilter=Bt),new Rp(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(r)}}const Nl=new N,YM=new N,ZM=new je;class ii{constructor(e=new N(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Nl.subVectors(n,t).cross(YM.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Nl),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||ZM.getNormalMatrix(e),i=this.coplanarPoint(Nl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Hi=new jt,Ro=new N;class to{constructor(e=new ii,t=new ii,n=new ii,i=new ii,r=new ii,o=new ii){this.planes=[e,t,n,i,r,o]}set(e,t,n,i,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Hn){const n=this.planes,i=e.elements,r=i[0],o=i[1],a=i[2],l=i[3],c=i[4],u=i[5],h=i[6],d=i[7],f=i[8],g=i[9],_=i[10],p=i[11],m=i[12],y=i[13],v=i[14],x=i[15];if(n[0].setComponents(l-r,d-c,p-f,x-m).normalize(),n[1].setComponents(l+r,d+c,p+f,x+m).normalize(),n[2].setComponents(l+o,d+u,p+g,x+y).normalize(),n[3].setComponents(l-o,d-u,p-g,x-y).normalize(),n[4].setComponents(l-a,d-h,p-_,x-v).normalize(),t===Hn)n[5].setComponents(l+a,d+h,p+_,x+v).normalize();else if(t===Or)n[5].setComponents(a,h,_,v).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Hi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Hi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hi)}intersectsSprite(e){return Hi.center.set(0,0,0),Hi.radius=.7071067811865476,Hi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(Ro.x=i.normal.x>0?e.max.x:e.min.x,Ro.y=i.normal.y>0?e.max.y:e.min.y,Ro.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ro)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Lp(){let s=null,e=!1,t=null,n=null;function i(r,o){t(r,o),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function KM(s){const e=new WeakMap;function t(a,l){const c=a.array,u=a.usage,h=c.byteLength,d=s.createBuffer();s.bindBuffer(l,d),s.bufferData(l,c,u),a.onUploadCallback();let f;if(c instanceof Float32Array)f=s.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?f=s.HALF_FLOAT:f=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=s.SHORT;else if(c instanceof Uint32Array)f=s.UNSIGNED_INT;else if(c instanceof Int32Array)f=s.INT;else if(c instanceof Int8Array)f=s.BYTE;else if(c instanceof Uint8Array)f=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,l,c){const u=l.array,h=l._updateRange,d=l.updateRanges;if(s.bindBuffer(c,a),h.count===-1&&d.length===0&&s.bufferSubData(c,0,u),d.length!==0){for(let f=0,g=d.length;f<g;f++){const _=d[f];s.bufferSubData(c,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.count)}l.clearUpdateRanges()}h.count!==-1&&(s.bufferSubData(c,h.offset*u.BYTES_PER_ELEMENT,u,h.offset,h.count),h.count=-1),l.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);const l=e.get(a);l&&(s.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isGLBufferAttribute){const u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}a.isInterleavedBufferAttribute&&(a=a.data);const c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,a,l),c.version=a.version}}return{get:i,remove:r,update:o}}class js extends at{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,o=t/2,a=Math.floor(n),l=Math.floor(i),c=a+1,u=l+1,h=e/a,d=t/l,f=[],g=[],_=[],p=[];for(let m=0;m<u;m++){const y=m*d-o;for(let v=0;v<c;v++){const x=v*h-r;g.push(x,-y,0),_.push(0,0,1),p.push(v/a),p.push(1-m/l)}}for(let m=0;m<l;m++)for(let y=0;y<a;y++){const v=y+c*m,x=y+c*(m+1),E=y+1+c*(m+1),S=y+1+c*m;f.push(v,x,S),f.push(x,E,S)}this.setIndex(f),this.setAttribute("position",new Oe(g,3)),this.setAttribute("normal",new Oe(_,3)),this.setAttribute("uv",new Oe(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new js(e.width,e.height,e.widthSegments,e.heightSegments)}}var JM=`#ifdef USE_ALPHAHASH
|
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
#endif`,jM=`#ifdef USE_ALPHAHASH
|
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
float hash2D( vec2 value ) {
|
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
}
|
|
float hash3D( vec3 value ) {
|
|
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|
}
|
|
float getAlphaHashThreshold( vec3 position ) {
|
|
float maxDeriv = max(
|
|
length( dFdx( position.xyz ) ),
|
|
length( dFdy( position.xyz ) )
|
|
);
|
|
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|
vec2 pixScales = vec2(
|
|
exp2( floor( log2( pixScale ) ) ),
|
|
exp2( ceil( log2( pixScale ) ) )
|
|
);
|
|
vec2 alpha = vec2(
|
|
hash3D( floor( pixScales.x * position.xyz ) ),
|
|
hash3D( floor( pixScales.y * position.xyz ) )
|
|
);
|
|
float lerpFactor = fract( log2( pixScale ) );
|
|
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|
vec3 cases = vec3(
|
|
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|
( x - 0.5 * a ) / ( 1.0 - a ),
|
|
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|
);
|
|
float threshold = ( x < ( 1.0 - a ) )
|
|
? ( ( x < a ) ? cases.x : cases.y )
|
|
: cases.z;
|
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
}
|
|
#endif`,QM=`#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
#endif`,eb=`#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,tb=`#ifdef USE_ALPHATEST
|
|
#ifdef ALPHA_TO_COVERAGE
|
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
#else
|
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
#endif
|
|
#endif`,nb=`#ifdef USE_ALPHATEST
|
|
uniform float alphaTest;
|
|
#endif`,ib=`#ifdef USE_AOMAP
|
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
#if defined( USE_CLEARCOAT )
|
|
clearcoatSpecularIndirect *= ambientOcclusion;
|
|
#endif
|
|
#if defined( USE_SHEEN )
|
|
sheenSpecularIndirect *= ambientOcclusion;
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
#endif
|
|
#endif`,sb=`#ifdef USE_AOMAP
|
|
uniform sampler2D aoMap;
|
|
uniform float aoMapIntensity;
|
|
#endif`,rb=`#ifdef USE_BATCHING
|
|
attribute float batchId;
|
|
uniform highp sampler2D batchingTexture;
|
|
mat4 getBatchingMatrix( const in float i ) {
|
|
int size = textureSize( batchingTexture, 0 ).x;
|
|
int j = int( i ) * 4;
|
|
int x = j % size;
|
|
int y = j / size;
|
|
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|
return mat4( v1, v2, v3, v4 );
|
|
}
|
|
#endif
|
|
#ifdef USE_BATCHING_COLOR
|
|
uniform sampler2D batchingColorTexture;
|
|
vec3 getBatchingColor( const in float i ) {
|
|
int size = textureSize( batchingColorTexture, 0 ).x;
|
|
int j = int( i );
|
|
int x = j % size;
|
|
int y = j / size;
|
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
|
|
}
|
|
#endif`,ob=`#ifdef USE_BATCHING
|
|
mat4 batchingMatrix = getBatchingMatrix( batchId );
|
|
#endif`,ab=`vec3 transformed = vec3( position );
|
|
#ifdef USE_ALPHAHASH
|
|
vPosition = vec3( position );
|
|
#endif`,lb=`vec3 objectNormal = vec3( normal );
|
|
#ifdef USE_TANGENT
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
#endif`,cb=`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 );
|
|
} // validated`,ub=`#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 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`,hb=`#ifdef USE_BUMPMAP
|
|
uniform sampler2D bumpMap;
|
|
uniform float bumpScale;
|
|
vec2 dHdxy_fwd() {
|
|
vec2 dSTdx = dFdx( vBumpMapUv );
|
|
vec2 dSTdy = dFdy( vBumpMapUv );
|
|
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
|
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
|
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
|
return vec2( dBx, dBy );
|
|
}
|
|
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
|
|
vec3 vSigmaY = normalize( 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`,db=`#if NUM_CLIPPING_PLANES > 0
|
|
vec4 plane;
|
|
#ifdef ALPHA_TO_COVERAGE
|
|
float distanceToPlane, distanceGradient;
|
|
float clipOpacity = 1.0;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
if ( clipOpacity == 0.0 ) discard;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
float unionClipOpacity = 1.0;
|
|
#pragma unroll_loop_start
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
}
|
|
#pragma unroll_loop_end
|
|
clipOpacity *= 1.0 - unionClipOpacity;
|
|
#endif
|
|
diffuseColor.a *= clipOpacity;
|
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
#else
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
bool clipped = true;
|
|
#pragma unroll_loop_start
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
|
}
|
|
#pragma unroll_loop_end
|
|
if ( clipped ) discard;
|
|
#endif
|
|
#endif
|
|
#endif`,fb=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
#endif`,pb=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
#endif`,mb=`#if NUM_CLIPPING_PLANES > 0
|
|
vClipPosition = - mvPosition.xyz;
|
|
#endif`,gb=`#if defined( USE_COLOR_ALPHA )
|
|
diffuseColor *= vColor;
|
|
#elif defined( USE_COLOR )
|
|
diffuseColor.rgb *= vColor;
|
|
#endif`,_b=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,vb=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,yb=`#if defined( USE_COLOR_ALPHA )
|
|
vColor = vec4( 1.0 );
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
vColor = vec3( 1.0 );
|
|
#endif
|
|
#ifdef USE_COLOR
|
|
vColor *= color;
|
|
#endif
|
|
#ifdef USE_INSTANCING_COLOR
|
|
vColor.xyz *= instanceColor.xyz;
|
|
#endif
|
|
#ifdef USE_BATCHING_COLOR
|
|
vec3 batchingColor = getBatchingColor( batchId );
|
|
vColor.xyz *= batchingColor.xyz;
|
|
#endif`,xb=`#define PI 3.141592653589793
|
|
#define PI2 6.283185307179586
|
|
#define PI_HALF 1.5707963267948966
|
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
#define RECIPROCAL_PI2 0.15915494309189535
|
|
#define EPSILON 1e-6
|
|
#ifndef saturate
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
#endif
|
|
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
|
float pow2( const in float x ) { return x*x; }
|
|
vec3 pow2( const in vec3 x ) { return x*x; }
|
|
float pow3( const in float x ) { return x*x*x; }
|
|
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
|
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
|
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
|
highp float rand( const in vec2 uv ) {
|
|
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
|
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
|
return fract( sin( sn ) * c );
|
|
}
|
|
#ifdef HIGH_PRECISION
|
|
float precisionSafeLength( vec3 v ) { return length( v ); }
|
|
#else
|
|
float precisionSafeLength( vec3 v ) {
|
|
float maxComponent = max3( abs( v ) );
|
|
return length( v / maxComponent ) * maxComponent;
|
|
}
|
|
#endif
|
|
struct IncidentLight {
|
|
vec3 color;
|
|
vec3 direction;
|
|
bool visible;
|
|
};
|
|
struct ReflectedLight {
|
|
vec3 directDiffuse;
|
|
vec3 directSpecular;
|
|
vec3 indirectDiffuse;
|
|
vec3 indirectSpecular;
|
|
};
|
|
#ifdef USE_ALPHAHASH
|
|
varying vec3 vPosition;
|
|
#endif
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
}
|
|
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
}
|
|
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 );
|
|
}
|
|
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
|
return RECIPROCAL_PI * diffuseColor;
|
|
}
|
|
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
}
|
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
} // validated`,Mb=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
#define cubeUV_minMipLevel 4.0
|
|
#define cubeUV_minTileSize 16.0
|
|
float getFace( vec3 direction ) {
|
|
vec3 absDirection = abs( direction );
|
|
float face = - 1.0;
|
|
if ( absDirection.x > absDirection.z ) {
|
|
if ( absDirection.x > absDirection.y )
|
|
face = direction.x > 0.0 ? 0.0 : 3.0;
|
|
else
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
} else {
|
|
if ( absDirection.z > absDirection.y )
|
|
face = direction.z > 0.0 ? 2.0 : 5.0;
|
|
else
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
}
|
|
return face;
|
|
}
|
|
vec2 getUV( vec3 direction, float face ) {
|
|
vec2 uv;
|
|
if ( face == 0.0 ) {
|
|
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
|
} else if ( face == 1.0 ) {
|
|
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
|
} else if ( face == 2.0 ) {
|
|
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
|
} else if ( face == 3.0 ) {
|
|
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
|
} else if ( face == 4.0 ) {
|
|
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
|
} else {
|
|
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
|
}
|
|
return 0.5 * ( uv + 1.0 );
|
|
}
|
|
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
|
float face = getFace( direction );
|
|
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
|
mipInt = max( mipInt, cubeUV_minMipLevel );
|
|
float faceSize = exp2( mipInt );
|
|
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
|
if ( face > 2.0 ) {
|
|
uv.y += faceSize;
|
|
face -= 3.0;
|
|
}
|
|
uv.x += face * faceSize;
|
|
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
|
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
|
uv.x *= CUBEUV_TEXEL_WIDTH;
|
|
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
|
#ifdef texture2DGradEXT
|
|
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
|
#else
|
|
return texture2D( envMap, uv ).rgb;
|
|
#endif
|
|
}
|
|
#define cubeUV_r0 1.0
|
|
#define cubeUV_m0 - 2.0
|
|
#define cubeUV_r1 0.8
|
|
#define cubeUV_m1 - 1.0
|
|
#define cubeUV_r4 0.4
|
|
#define cubeUV_m4 2.0
|
|
#define cubeUV_r5 0.305
|
|
#define cubeUV_m5 3.0
|
|
#define cubeUV_r6 0.21
|
|
#define cubeUV_m6 4.0
|
|
float roughnessToMip( float roughness ) {
|
|
float mip = 0.0;
|
|
if ( roughness >= cubeUV_r1 ) {
|
|
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
|
} else if ( roughness >= cubeUV_r4 ) {
|
|
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
|
} else if ( roughness >= cubeUV_r5 ) {
|
|
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
|
} else if ( roughness >= cubeUV_r6 ) {
|
|
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
|
} else {
|
|
mip = - 2.0 * log2( 1.16 * roughness ); }
|
|
return mip;
|
|
}
|
|
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|
float mipF = fract( mip );
|
|
float mipInt = floor( mip );
|
|
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
|
if ( mipF == 0.0 ) {
|
|
return vec4( color0, 1.0 );
|
|
} else {
|
|
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
}
|
|
}
|
|
#endif`,bb=`vec3 transformedNormal = objectNormal;
|
|
#ifdef USE_TANGENT
|
|
vec3 transformedTangent = objectTangent;
|
|
#endif
|
|
#ifdef USE_BATCHING
|
|
mat3 bm = mat3( batchingMatrix );
|
|
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
|
transformedNormal = bm * transformedNormal;
|
|
#ifdef USE_TANGENT
|
|
transformedTangent = bm * transformedTangent;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_INSTANCING
|
|
mat3 im = mat3( instanceMatrix );
|
|
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
|
transformedNormal = im * transformedNormal;
|
|
#ifdef USE_TANGENT
|
|
transformedTangent = im * transformedTangent;
|
|
#endif
|
|
#endif
|
|
transformedNormal = normalMatrix * transformedNormal;
|
|
#ifdef FLIP_SIDED
|
|
transformedNormal = - transformedNormal;
|
|
#endif
|
|
#ifdef USE_TANGENT
|
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
#ifdef FLIP_SIDED
|
|
transformedTangent = - transformedTangent;
|
|
#endif
|
|
#endif`,Sb=`#ifdef USE_DISPLACEMENTMAP
|
|
uniform sampler2D displacementMap;
|
|
uniform float displacementScale;
|
|
uniform float displacementBias;
|
|
#endif`,wb=`#ifdef USE_DISPLACEMENTMAP
|
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
#endif`,Ab=`#ifdef USE_EMISSIVEMAP
|
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
#endif`,Eb=`#ifdef USE_EMISSIVEMAP
|
|
uniform sampler2D emissiveMap;
|
|
#endif`,Tb="gl_FragColor = linearToOutputTexel( gl_FragColor );",Cb=`
|
|
const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
|
|
vec3( 0.8224621, 0.177538, 0.0 ),
|
|
vec3( 0.0331941, 0.9668058, 0.0 ),
|
|
vec3( 0.0170827, 0.0723974, 0.9105199 )
|
|
);
|
|
const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
|
|
vec3( 1.2249401, - 0.2249404, 0.0 ),
|
|
vec3( - 0.0420569, 1.0420571, 0.0 ),
|
|
vec3( - 0.0196376, - 0.0786361, 1.0982735 )
|
|
);
|
|
vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
|
|
return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
|
|
}
|
|
vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
|
|
return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
|
|
}
|
|
vec4 LinearTransferOETF( in vec4 value ) {
|
|
return value;
|
|
}
|
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
|
}
|
|
vec4 LinearToLinear( in vec4 value ) {
|
|
return value;
|
|
}
|
|
vec4 LinearTosRGB( in vec4 value ) {
|
|
return sRGBTransferOETF( value );
|
|
}`,Pb=`#ifdef USE_ENVMAP
|
|
#ifdef ENV_WORLDPOS
|
|
vec3 cameraToFrag;
|
|
if ( isOrthographic ) {
|
|
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
} else {
|
|
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
|
}
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
|
#else
|
|
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
|
#endif
|
|
#else
|
|
vec3 reflectVec = vReflect;
|
|
#endif
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
|
#else
|
|
vec4 envColor = vec4( 0.0 );
|
|
#endif
|
|
#ifdef ENVMAP_BLENDING_MULTIPLY
|
|
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
|
#elif defined( ENVMAP_BLENDING_MIX )
|
|
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
|
#elif defined( ENVMAP_BLENDING_ADD )
|
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
#endif
|
|
#endif`,Rb=`#ifdef USE_ENVMAP
|
|
uniform float envMapIntensity;
|
|
uniform float flipEnvMap;
|
|
uniform mat3 envMapRotation;
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#else
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
|
|
#endif`,Ib=`#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`,Lb=`#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`,Nb=`#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`,Db=`#ifdef USE_FOG
|
|
vFogDepth = - mvPosition.z;
|
|
#endif`,Ub=`#ifdef USE_FOG
|
|
varying float vFogDepth;
|
|
#endif`,Ob=`#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`,Fb=`#ifdef USE_FOG
|
|
uniform vec3 fogColor;
|
|
varying float vFogDepth;
|
|
#ifdef FOG_EXP2
|
|
uniform float fogDensity;
|
|
#else
|
|
uniform float fogNear;
|
|
uniform float fogFar;
|
|
#endif
|
|
#endif`,kb=`#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
|
|
}`,Bb=`#ifdef USE_LIGHTMAP
|
|
uniform sampler2D lightMap;
|
|
uniform float lightMapIntensity;
|
|
#endif`,zb=`LambertMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularStrength = specularStrength;`,Vb=`varying vec3 vViewPosition;
|
|
struct LambertMaterial {
|
|
vec3 diffuseColor;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_Lambert
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Hb=`uniform bool receiveShadow;
|
|
uniform vec3 ambientLightColor;
|
|
#if defined( USE_LIGHT_PROBES )
|
|
uniform vec3 lightProbe[ 9 ];
|
|
#endif
|
|
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|
float x = normal.x, y = normal.y, z = normal.z;
|
|
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|
return result;
|
|
}
|
|
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
|
return irradiance;
|
|
}
|
|
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
|
vec3 irradiance = ambientLightColor;
|
|
return irradiance;
|
|
}
|
|
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
|
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|
if ( cutoffDistance > 0.0 ) {
|
|
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|
}
|
|
return distanceFalloff;
|
|
}
|
|
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
|
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
|
}
|
|
#if NUM_DIR_LIGHTS > 0
|
|
struct DirectionalLight {
|
|
vec3 direction;
|
|
vec3 color;
|
|
};
|
|
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
|
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
|
|
light.color = directionalLight.color;
|
|
light.direction = directionalLight.direction;
|
|
light.visible = true;
|
|
}
|
|
#endif
|
|
#if NUM_POINT_LIGHTS > 0
|
|
struct PointLight {
|
|
vec3 position;
|
|
vec3 color;
|
|
float distance;
|
|
float decay;
|
|
};
|
|
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
|
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
vec3 lVector = pointLight.position - geometryPosition;
|
|
light.direction = normalize( lVector );
|
|
float lightDistance = length( lVector );
|
|
light.color = pointLight.color;
|
|
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|
}
|
|
#endif
|
|
#if NUM_SPOT_LIGHTS > 0
|
|
struct SpotLight {
|
|
vec3 position;
|
|
vec3 direction;
|
|
vec3 color;
|
|
float distance;
|
|
float decay;
|
|
float coneCos;
|
|
float penumbraCos;
|
|
};
|
|
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
|
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
vec3 lVector = spotLight.position - geometryPosition;
|
|
light.direction = normalize( lVector );
|
|
float angleCos = dot( light.direction, spotLight.direction );
|
|
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
|
if ( spotAttenuation > 0.0 ) {
|
|
float lightDistance = length( lVector );
|
|
light.color = spotLight.color * spotAttenuation;
|
|
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|
} else {
|
|
light.color = vec3( 0.0 );
|
|
light.visible = false;
|
|
}
|
|
}
|
|
#endif
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
struct RectAreaLight {
|
|
vec3 color;
|
|
vec3 position;
|
|
vec3 halfWidth;
|
|
vec3 halfHeight;
|
|
};
|
|
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
|
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
|
#endif
|
|
#if NUM_HEMI_LIGHTS > 0
|
|
struct HemisphereLight {
|
|
vec3 direction;
|
|
vec3 skyColor;
|
|
vec3 groundColor;
|
|
};
|
|
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
|
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
|
float dotNL = dot( normal, hemiLight.direction );
|
|
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
|
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|
return irradiance;
|
|
}
|
|
#endif`,Gb=`#ifdef USE_ENVMAP
|
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
|
|
return PI * envMapColor.rgb * envMapIntensity;
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 reflectVec = reflect( - viewDir, normal );
|
|
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
|
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
|
|
return envMapColor.rgb * envMapIntensity;
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
#ifdef USE_ANISOTROPY
|
|
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 bentNormal = cross( bitangent, viewDir );
|
|
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|
return getIBLRadiance( viewDir, bentNormal, roughness );
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
#endif
|
|
#endif`,Wb=`ToonMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;`,$b=`varying vec3 vViewPosition;
|
|
struct ToonMaterial {
|
|
vec3 diffuseColor;
|
|
};
|
|
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_Toon
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Xb=`BlinnPhongMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularColor = specular;
|
|
material.specularShininess = shininess;
|
|
material.specularStrength = specularStrength;`,qb=`varying vec3 vViewPosition;
|
|
struct BlinnPhongMaterial {
|
|
vec3 diffuseColor;
|
|
vec3 specularColor;
|
|
float specularShininess;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
}
|
|
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Yb=`PhysicalMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
|
material.roughness = min( material.roughness, 1.0 );
|
|
#ifdef IOR
|
|
material.ior = ior;
|
|
#ifdef USE_SPECULAR
|
|
float specularIntensityFactor = specularIntensity;
|
|
vec3 specularColorFactor = specularColor;
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
|
#endif
|
|
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
|
#else
|
|
float specularIntensityFactor = 1.0;
|
|
vec3 specularColorFactor = vec3( 1.0 );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
material.specularColor = 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, vClearcoatMapUv ).x;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
|
#endif
|
|
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
|
material.clearcoatRoughness += geometryRoughness;
|
|
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
#endif
|
|
#ifdef USE_DISPERSION
|
|
material.dispersion = dispersion;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
material.iridescence = iridescence;
|
|
material.iridescenceIOR = iridescenceIOR;
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
|
#else
|
|
material.iridescenceThickness = iridescenceThicknessMaximum;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
material.sheenColor = sheenColor;
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
|
#endif
|
|
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
#ifdef USE_ANISOTROPYMAP
|
|
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
|
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
|
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
|
#else
|
|
vec2 anisotropyV = anisotropyVector;
|
|
#endif
|
|
material.anisotropy = length( anisotropyV );
|
|
if( material.anisotropy == 0.0 ) {
|
|
anisotropyV = vec2( 1.0, 0.0 );
|
|
} else {
|
|
anisotropyV /= material.anisotropy;
|
|
material.anisotropy = saturate( material.anisotropy );
|
|
}
|
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
#endif`,Zb=`struct PhysicalMaterial {
|
|
vec3 diffuseColor;
|
|
float roughness;
|
|
vec3 specularColor;
|
|
float specularF90;
|
|
float dispersion;
|
|
#ifdef USE_CLEARCOAT
|
|
float clearcoat;
|
|
float clearcoatRoughness;
|
|
vec3 clearcoatF0;
|
|
float clearcoatF90;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float iridescence;
|
|
float iridescenceIOR;
|
|
float iridescenceThickness;
|
|
vec3 iridescenceFresnel;
|
|
vec3 iridescenceF0;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
vec3 sheenColor;
|
|
float sheenRoughness;
|
|
#endif
|
|
#ifdef IOR
|
|
float ior;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
float transmission;
|
|
float transmissionAlpha;
|
|
float thickness;
|
|
float attenuationDistance;
|
|
vec3 attenuationColor;
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
float anisotropy;
|
|
float alphaT;
|
|
vec3 anisotropyT;
|
|
vec3 anisotropyB;
|
|
#endif
|
|
};
|
|
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
|
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|
vec3 sheenSpecularIndirect = vec3(0.0 );
|
|
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|
float x2 = x * x;
|
|
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
|
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
|
}
|
|
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|
float a2 = pow2( alpha );
|
|
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
|
return 0.5 / max( gv + gl, EPSILON );
|
|
}
|
|
float D_GGX( const in float alpha, const in float dotNH ) {
|
|
float a2 = pow2( alpha );
|
|
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
|
return RECIPROCAL_PI * a2 / pow2( denom );
|
|
}
|
|
#ifdef USE_ANISOTROPY
|
|
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
|
|
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|
float v = 0.5 / ( gv + gl );
|
|
return saturate(v);
|
|
}
|
|
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
|
float a2 = alphaT * alphaB;
|
|
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
|
highp float v2 = dot( v, v );
|
|
float w2 = a2 / v2;
|
|
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
|
}
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
|
vec3 f0 = material.clearcoatF0;
|
|
float f90 = material.clearcoatF90;
|
|
float roughness = material.clearcoatRoughness;
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
return F * ( V * D );
|
|
}
|
|
#endif
|
|
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
vec3 f0 = material.specularColor;
|
|
float f90 = material.specularF90;
|
|
float roughness = material.roughness;
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
#ifdef USE_IRIDESCENCE
|
|
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
float dotTL = dot( material.anisotropyT, lightDir );
|
|
float dotTV = dot( material.anisotropyT, viewDir );
|
|
float dotTH = dot( material.anisotropyT, halfDir );
|
|
float dotBL = dot( material.anisotropyB, lightDir );
|
|
float dotBV = dot( material.anisotropyB, viewDir );
|
|
float dotBH = dot( material.anisotropyB, halfDir );
|
|
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
|
#else
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
#endif
|
|
return F * ( V * D );
|
|
}
|
|
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
|
const float LUT_SIZE = 64.0;
|
|
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
|
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
|
float dotNV = saturate( dot( N, V ) );
|
|
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
|
uv = uv * LUT_SCALE + LUT_BIAS;
|
|
return uv;
|
|
}
|
|
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
|
float l = length( f );
|
|
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
|
}
|
|
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
|
float x = dot( v1, v2 );
|
|
float y = abs( x );
|
|
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
|
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
|
float v = a / b;
|
|
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
|
return cross( v1, v2 ) * theta_sintheta;
|
|
}
|
|
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
|
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
|
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
|
vec3 lightNormal = cross( v1, v2 );
|
|
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
|
vec3 T1, T2;
|
|
T1 = normalize( V - N * dot( V, N ) );
|
|
T2 = - cross( N, T1 );
|
|
mat3 mat = mInv * 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 );
|
|
}
|
|
#if defined( USE_SHEEN )
|
|
float D_Charlie( float roughness, float dotNH ) {
|
|
float alpha = pow2( roughness );
|
|
float invAlpha = 1.0 / alpha;
|
|
float cos2h = dotNH * dotNH;
|
|
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
|
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
|
}
|
|
float V_Neubelt( float dotNV, float dotNL ) {
|
|
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
|
}
|
|
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float D = D_Charlie( sheenRoughness, dotNH );
|
|
float V = V_Neubelt( dotNV, dotNL );
|
|
return sheenColor * ( D * V );
|
|
}
|
|
#endif
|
|
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float r2 = roughness * roughness;
|
|
float 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 normal = geometryNormal;
|
|
vec3 viewDir = geometryViewDir;
|
|
vec3 position = geometryPosition;
|
|
vec3 lightPos = rectAreaLight.position;
|
|
vec3 halfWidth = rectAreaLight.halfWidth;
|
|
vec3 halfHeight = rectAreaLight.halfHeight;
|
|
vec3 lightColor = rectAreaLight.color;
|
|
float roughness = material.roughness;
|
|
vec3 rectCoords[ 4 ];
|
|
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
|
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
|
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
|
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
|
vec4 t1 = texture2D( ltc_1, uv );
|
|
vec4 t2 = texture2D( ltc_2, uv );
|
|
mat3 mInv = mat3(
|
|
vec3( t1.x, 0, t1.y ),
|
|
vec3( 0, 1, 0 ),
|
|
vec3( t1.z, 0, t1.w )
|
|
);
|
|
vec3 fresnel = ( material.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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
#endif
|
|
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
#endif
|
|
vec3 singleScattering = vec3( 0.0 );
|
|
vec3 multiScattering = vec3( 0.0 );
|
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
#ifdef USE_IRIDESCENCE
|
|
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|
#else
|
|
computeMultiscattering( geometryNormal, geometryViewDir, 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 );
|
|
}`,Kb=`
|
|
vec3 geometryPosition = - vViewPosition;
|
|
vec3 geometryNormal = normal;
|
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
|
#ifdef USE_CLEARCOAT
|
|
geometryClearcoatNormal = clearcoatNormal;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
|
if ( material.iridescenceThickness == 0.0 ) {
|
|
material.iridescence = 0.0;
|
|
} else {
|
|
material.iridescence = saturate( material.iridescence );
|
|
}
|
|
if ( material.iridescence > 0.0 ) {
|
|
material.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, geometryPosition, 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, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
SpotLight spotLight;
|
|
vec4 spotColor;
|
|
vec3 spotLightCoord;
|
|
bool inSpotLightMap;
|
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
spotLight = spotLights[ i ];
|
|
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
|
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
#else
|
|
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
#endif
|
|
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
#endif
|
|
#undef SPOT_LIGHT_MAP_INDEX
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
spotLightShadow = spotLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
|
DirectionalLight directionalLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
directionalLight = directionalLights[ i ];
|
|
getDirectionalLightInfo( directionalLight, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
directionalLightShadow = directionalLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
|
RectAreaLight rectAreaLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|
rectAreaLight = rectAreaLights[ i ];
|
|
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if defined( RE_IndirectDiffuse )
|
|
vec3 iblIrradiance = vec3( 0.0 );
|
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
#if defined( USE_LIGHT_PROBES )
|
|
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
#endif
|
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
vec3 radiance = vec3( 0.0 );
|
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
#endif`,Jb=`#if defined( RE_IndirectDiffuse )
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
irradiance += lightMapIrradiance;
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|
iblIrradiance += getIBLIrradiance( geometryNormal );
|
|
#endif
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
#ifdef USE_ANISOTROPY
|
|
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
#else
|
|
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
#endif
|
|
#endif`,jb=`#if defined( RE_IndirectDiffuse )
|
|
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
#endif`,Qb=`#if defined( USE_LOGDEPTHBUF )
|
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
#endif`,eS=`#if defined( USE_LOGDEPTHBUF )
|
|
uniform float logDepthBufFC;
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#endif`,tS=`#ifdef USE_LOGDEPTHBUF
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#endif`,nS=`#ifdef USE_LOGDEPTHBUF
|
|
vFragDepth = 1.0 + gl_Position.w;
|
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
#endif`,iS=`#ifdef USE_MAP
|
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
|
|
|
|
#endif
|
|
diffuseColor *= sampledDiffuseColor;
|
|
#endif`,sS=`#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif`,rS=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
#if defined( USE_POINTS_UV )
|
|
vec2 uv = vUv;
|
|
#else
|
|
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_MAP
|
|
diffuseColor *= texture2D( map, uv );
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
#endif`,oS=`#if defined( USE_POINTS_UV )
|
|
varying vec2 vUv;
|
|
#else
|
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,aS=`float metalnessFactor = metalness;
|
|
#ifdef USE_METALNESSMAP
|
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
metalnessFactor *= texelMetalness.b;
|
|
#endif`,lS=`#ifdef USE_METALNESSMAP
|
|
uniform sampler2D metalnessMap;
|
|
#endif`,cS=`#ifdef USE_INSTANCING_MORPH
|
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
}
|
|
#endif`,uS=`#if defined( USE_MORPHCOLORS )
|
|
vColor *= morphTargetBaseInfluence;
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
#if defined( USE_COLOR_ALPHA )
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
|
#elif defined( USE_COLOR )
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
#endif
|
|
}
|
|
#endif`,hS=`#ifdef USE_MORPHNORMALS
|
|
objectNormal *= morphTargetBaseInfluence;
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
}
|
|
#endif`,dS=`#ifdef USE_MORPHTARGETS
|
|
#ifndef USE_INSTANCING_MORPH
|
|
uniform float morphTargetBaseInfluence;
|
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
#endif
|
|
uniform sampler2DArray morphTargetsTexture;
|
|
uniform ivec2 morphTargetsTextureSize;
|
|
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
|
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
|
int y = texelIndex / morphTargetsTextureSize.x;
|
|
int x = texelIndex - y * morphTargetsTextureSize.x;
|
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
}
|
|
#endif`,fS=`#ifdef USE_MORPHTARGETS
|
|
transformed *= morphTargetBaseInfluence;
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
}
|
|
#endif`,pS=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
#ifdef FLAT_SHADED
|
|
vec3 fdx = dFdx( vViewPosition );
|
|
vec3 fdy = dFdy( vViewPosition );
|
|
vec3 normal = normalize( cross( fdx, fdy ) );
|
|
#else
|
|
vec3 normal = normalize( vNormal );
|
|
#ifdef DOUBLE_SIDED
|
|
normal *= faceDirection;
|
|
#endif
|
|
#endif
|
|
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
|
|
#ifdef USE_TANGENT
|
|
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
#else
|
|
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
|
#if defined( USE_NORMALMAP )
|
|
vNormalMapUv
|
|
#elif defined( USE_CLEARCOAT_NORMALMAP )
|
|
vClearcoatNormalMapUv
|
|
#else
|
|
vUv
|
|
#endif
|
|
);
|
|
#endif
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
tbn[0] *= faceDirection;
|
|
tbn[1] *= faceDirection;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
#ifdef USE_TANGENT
|
|
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
#else
|
|
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
|
|
#endif
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
tbn2[0] *= faceDirection;
|
|
tbn2[1] *= faceDirection;
|
|
#endif
|
|
#endif
|
|
vec3 nonPerturbedNormal = normal;`,mS=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
#ifdef FLIP_SIDED
|
|
normal = - normal;
|
|
#endif
|
|
#ifdef DOUBLE_SIDED
|
|
normal = normal * faceDirection;
|
|
#endif
|
|
normal = normalize( normalMatrix * normal );
|
|
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
mapN.xy *= normalScale;
|
|
normal = normalize( tbn * mapN );
|
|
#elif defined( USE_BUMPMAP )
|
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
#endif`,gS=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,_S=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,vS=`#ifndef FLAT_SHADED
|
|
vNormal = normalize( transformedNormal );
|
|
#ifdef USE_TANGENT
|
|
vTangent = normalize( transformedTangent );
|
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
#endif
|
|
#endif`,yS=`#ifdef USE_NORMALMAP
|
|
uniform sampler2D normalMap;
|
|
uniform vec2 normalScale;
|
|
#endif
|
|
#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
uniform mat3 normalMatrix;
|
|
#endif
|
|
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
|
|
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
|
|
vec3 q0 = dFdx( eye_pos.xyz );
|
|
vec3 q1 = dFdy( eye_pos.xyz );
|
|
vec2 st0 = dFdx( uv.st );
|
|
vec2 st1 = dFdy( uv.st );
|
|
vec3 N = surf_norm;
|
|
vec3 q1perp = cross( q1, N );
|
|
vec3 q0perp = cross( N, q0 );
|
|
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
|
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
|
float det = max( dot( T, T ), dot( B, B ) );
|
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
return mat3( T * scale, B * scale, N );
|
|
}
|
|
#endif`,xS=`#ifdef USE_CLEARCOAT
|
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
#endif`,MS=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
#endif`,bS=`#ifdef USE_CLEARCOATMAP
|
|
uniform sampler2D clearcoatMap;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
uniform sampler2D clearcoatNormalMap;
|
|
uniform vec2 clearcoatNormalScale;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
uniform sampler2D clearcoatRoughnessMap;
|
|
#endif`,SS=`#ifdef USE_IRIDESCENCEMAP
|
|
uniform sampler2D iridescenceMap;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
uniform sampler2D iridescenceThicknessMap;
|
|
#endif`,wS=`#ifdef OPAQUE
|
|
diffuseColor.a = 1.0;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
diffuseColor.a *= material.transmissionAlpha;
|
|
#endif
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,AS=`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 depth, const in float near, const in float far ) {
|
|
return depth * ( near - far ) - near;
|
|
}
|
|
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
|
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
|
}
|
|
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
}`,ES=`#ifdef PREMULTIPLIED_ALPHA
|
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
#endif`,TS=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_BATCHING
|
|
mvPosition = batchingMatrix * mvPosition;
|
|
#endif
|
|
#ifdef USE_INSTANCING
|
|
mvPosition = instanceMatrix * mvPosition;
|
|
#endif
|
|
mvPosition = modelViewMatrix * mvPosition;
|
|
gl_Position = projectionMatrix * mvPosition;`,CS=`#ifdef DITHERING
|
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
#endif`,PS=`#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`,RS=`float roughnessFactor = roughness;
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
roughnessFactor *= texelRoughness.g;
|
|
#endif`,IS=`#ifdef USE_ROUGHNESSMAP
|
|
uniform sampler2D roughnessMap;
|
|
#endif`,LS=`#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 ) {
|
|
float shadow = 1.0;
|
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
|
|
float lightToPositionLength = length( lightToPosition );
|
|
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
|
|
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|
vec3 bd3D = normalize( lightToPosition );
|
|
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
shadow = (
|
|
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
|
|
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
#endif
|
|
}
|
|
return shadow;
|
|
}
|
|
#endif`,NS=`#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`,DS=`#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`,US=`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;
|
|
}`,OS=`#ifdef USE_SKINNING
|
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
#endif`,FS=`#ifdef USE_SKINNING
|
|
uniform mat4 bindMatrix;
|
|
uniform mat4 bindMatrixInverse;
|
|
uniform highp sampler2D boneTexture;
|
|
mat4 getBoneMatrix( const in float i ) {
|
|
int size = textureSize( boneTexture, 0 ).x;
|
|
int j = int( i ) * 4;
|
|
int x = j % size;
|
|
int y = j / size;
|
|
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
|
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
|
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
return mat4( v1, v2, v3, v4 );
|
|
}
|
|
#endif`,kS=`#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`,BS=`#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`,zS=`float specularStrength;
|
|
#ifdef USE_SPECULARMAP
|
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
specularStrength = texelSpecular.r;
|
|
#else
|
|
specularStrength = 1.0;
|
|
#endif`,VS=`#ifdef USE_SPECULARMAP
|
|
uniform sampler2D specularMap;
|
|
#endif`,HS=`#if defined( TONE_MAPPING )
|
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
#endif`,GS=`#ifndef saturate
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
#endif
|
|
uniform float toneMappingExposure;
|
|
vec3 LinearToneMapping( vec3 color ) {
|
|
return saturate( toneMappingExposure * color );
|
|
}
|
|
vec3 ReinhardToneMapping( vec3 color ) {
|
|
color *= toneMappingExposure;
|
|
return saturate( color / ( vec3( 1.0 ) + color ) );
|
|
}
|
|
vec3 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 );
|
|
}
|
|
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
|
|
vec3( 1.6605, - 0.1246, - 0.0182 ),
|
|
vec3( - 0.5876, 1.1329, - 0.1006 ),
|
|
vec3( - 0.0728, - 0.0083, 1.1187 )
|
|
);
|
|
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
|
|
vec3( 0.6274, 0.0691, 0.0164 ),
|
|
vec3( 0.3293, 0.9195, 0.0880 ),
|
|
vec3( 0.0433, 0.0113, 0.8956 )
|
|
);
|
|
vec3 agxDefaultContrastApprox( vec3 x ) {
|
|
vec3 x2 = x * x;
|
|
vec3 x4 = x2 * x2;
|
|
return + 15.5 * x4 * x2
|
|
- 40.14 * x4 * x
|
|
+ 31.96 * x4
|
|
- 6.868 * x2 * x
|
|
+ 0.4298 * x2
|
|
+ 0.1191 * x
|
|
- 0.00232;
|
|
}
|
|
vec3 AgXToneMapping( vec3 color ) {
|
|
const mat3 AgXInsetMatrix = mat3(
|
|
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
|
|
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
|
|
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
|
|
);
|
|
const mat3 AgXOutsetMatrix = mat3(
|
|
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
|
|
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
|
|
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
|
|
);
|
|
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
|
|
color *= toneMappingExposure;
|
|
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
|
|
color = AgXInsetMatrix * color;
|
|
color = max( color, 1e-10 ); color = log2( color );
|
|
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
|
|
color = clamp( color, 0.0, 1.0 );
|
|
color = agxDefaultContrastApprox( color );
|
|
color = AgXOutsetMatrix * color;
|
|
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
|
|
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
|
|
color = clamp( color, 0.0, 1.0 );
|
|
return color;
|
|
}
|
|
vec3 NeutralToneMapping( vec3 color ) {
|
|
const float StartCompression = 0.8 - 0.04;
|
|
const float Desaturation = 0.15;
|
|
color *= toneMappingExposure;
|
|
float x = min( color.r, min( color.g, color.b ) );
|
|
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
|
|
color -= offset;
|
|
float peak = max( color.r, max( color.g, color.b ) );
|
|
if ( peak < StartCompression ) return color;
|
|
float d = 1. - StartCompression;
|
|
float newPeak = 1. - d * d / ( peak + d - StartCompression );
|
|
color *= newPeak / peak;
|
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
return mix( color, vec3( newPeak ), g );
|
|
}
|
|
vec3 CustomToneMapping( vec3 color ) { return color; }`,WS=`#ifdef USE_TRANSMISSION
|
|
material.transmission = transmission;
|
|
material.transmissionAlpha = 1.0;
|
|
material.thickness = thickness;
|
|
material.attenuationDistance = attenuationDistance;
|
|
material.attenuationColor = attenuationColor;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
|
#endif
|
|
vec3 pos = vWorldPosition;
|
|
vec3 v = normalize( cameraPosition - pos );
|
|
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 transmitted = getIBLVolumeRefraction(
|
|
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
|
material.attenuationColor, material.attenuationDistance );
|
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
#endif`,$S=`#ifdef USE_TRANSMISSION
|
|
uniform float transmission;
|
|
uniform float thickness;
|
|
uniform float attenuationDistance;
|
|
uniform vec3 attenuationColor;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform sampler2D transmissionMap;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform sampler2D thicknessMap;
|
|
#endif
|
|
uniform vec2 transmissionSamplerSize;
|
|
uniform sampler2D transmissionSamplerMap;
|
|
uniform mat4 modelMatrix;
|
|
uniform mat4 projectionMatrix;
|
|
varying vec3 vWorldPosition;
|
|
float w0( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
|
}
|
|
float w1( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
|
|
}
|
|
float w2( float a ){
|
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
|
|
}
|
|
float w3( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * a * a );
|
|
}
|
|
float g0( float a ) {
|
|
return w0( a ) + w1( a );
|
|
}
|
|
float g1( float a ) {
|
|
return w2( a ) + w3( a );
|
|
}
|
|
float h0( float a ) {
|
|
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
|
|
}
|
|
float h1( float a ) {
|
|
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
|
|
}
|
|
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
|
|
uv = uv * texelSize.zw + 0.5;
|
|
vec2 iuv = floor( uv );
|
|
vec2 fuv = fract( uv );
|
|
float g0x = g0( fuv.x );
|
|
float g1x = g1( fuv.x );
|
|
float h0x = h0( fuv.x );
|
|
float h1x = h1( fuv.x );
|
|
float h0y = h0( fuv.y );
|
|
float h1y = h1( fuv.y );
|
|
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
|
|
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
|
|
}
|
|
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
|
|
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
|
|
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
|
|
vec2 fLodSizeInv = 1.0 / fLodSize;
|
|
vec2 cLodSizeInv = 1.0 / cLodSize;
|
|
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
|
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
|
return mix( fSample, cSample, fract( lod ) );
|
|
}
|
|
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
|
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
|
vec3 modelScale;
|
|
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
|
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
|
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
|
return normalize( refractionVector ) * thickness * modelScale;
|
|
}
|
|
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
|
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|
}
|
|
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
|
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
|
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
|
|
}
|
|
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
if ( isinf( attenuationDistance ) ) {
|
|
return vec3( 1.0 );
|
|
} else {
|
|
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
|
|
}
|
|
}
|
|
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
|
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
|
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
|
|
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
vec4 transmittedLight;
|
|
vec3 transmittance;
|
|
#ifdef USE_DISPERSION
|
|
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
|
|
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
|
|
for ( int i = 0; i < 3; i ++ ) {
|
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
|
|
vec3 refractedRayExit = position + transmissionRay;
|
|
|
|
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
refractionCoords += 1.0;
|
|
refractionCoords /= 2.0;
|
|
|
|
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
|
|
transmittedLight[ i ] = transmissionSample[ i ];
|
|
transmittedLight.a += transmissionSample.a;
|
|
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
|
|
}
|
|
transmittedLight.a /= 3.0;
|
|
|
|
#else
|
|
|
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
vec3 refractedRayExit = position + transmissionRay;
|
|
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
refractionCoords += 1.0;
|
|
refractionCoords /= 2.0;
|
|
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
|
|
#endif
|
|
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
|
|
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
}
|
|
#endif`,XS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
varying vec2 vUv;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
varying vec2 vMapUv;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
varying vec2 vAlphaMapUv;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
varying vec2 vLightMapUv;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
varying vec2 vAoMapUv;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
varying vec2 vBumpMapUv;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
varying vec2 vNormalMapUv;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
varying vec2 vEmissiveMapUv;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
varying vec2 vMetalnessMapUv;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
varying vec2 vRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
varying vec2 vAnisotropyMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
varying vec2 vClearcoatMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
varying vec2 vClearcoatNormalMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
varying vec2 vClearcoatRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
varying vec2 vIridescenceMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
varying vec2 vIridescenceThicknessMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
varying vec2 vSheenColorMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
varying vec2 vSheenRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
varying vec2 vSpecularMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
varying vec2 vSpecularColorMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
varying vec2 vSpecularIntensityMapUv;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform mat3 transmissionMapTransform;
|
|
varying vec2 vTransmissionMapUv;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform mat3 thicknessMapTransform;
|
|
varying vec2 vThicknessMapUv;
|
|
#endif`,qS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
varying vec2 vUv;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
uniform mat3 mapTransform;
|
|
varying vec2 vMapUv;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
uniform mat3 alphaMapTransform;
|
|
varying vec2 vAlphaMapUv;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
uniform mat3 lightMapTransform;
|
|
varying vec2 vLightMapUv;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
uniform mat3 aoMapTransform;
|
|
varying vec2 vAoMapUv;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
uniform mat3 bumpMapTransform;
|
|
varying vec2 vBumpMapUv;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
uniform mat3 normalMapTransform;
|
|
varying vec2 vNormalMapUv;
|
|
#endif
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
uniform mat3 displacementMapTransform;
|
|
varying vec2 vDisplacementMapUv;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
uniform mat3 emissiveMapTransform;
|
|
varying vec2 vEmissiveMapUv;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
uniform mat3 metalnessMapTransform;
|
|
varying vec2 vMetalnessMapUv;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
uniform mat3 roughnessMapTransform;
|
|
varying vec2 vRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
uniform mat3 anisotropyMapTransform;
|
|
varying vec2 vAnisotropyMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
uniform mat3 clearcoatMapTransform;
|
|
varying vec2 vClearcoatMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
uniform mat3 clearcoatNormalMapTransform;
|
|
varying vec2 vClearcoatNormalMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
uniform mat3 clearcoatRoughnessMapTransform;
|
|
varying vec2 vClearcoatRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
uniform mat3 sheenColorMapTransform;
|
|
varying vec2 vSheenColorMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
uniform mat3 sheenRoughnessMapTransform;
|
|
varying vec2 vSheenRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
uniform mat3 iridescenceMapTransform;
|
|
varying vec2 vIridescenceMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
uniform mat3 iridescenceThicknessMapTransform;
|
|
varying vec2 vIridescenceThicknessMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
uniform mat3 specularMapTransform;
|
|
varying vec2 vSpecularMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
uniform mat3 specularColorMapTransform;
|
|
varying vec2 vSpecularColorMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
uniform mat3 specularIntensityMapTransform;
|
|
varying vec2 vSpecularIntensityMapUv;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform mat3 transmissionMapTransform;
|
|
varying vec2 vTransmissionMapUv;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform mat3 thicknessMapTransform;
|
|
varying vec2 vThicknessMapUv;
|
|
#endif`,YS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
vUv = vec3( uv, 1 ).xy;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
#endif`,ZS=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_BATCHING
|
|
worldPosition = batchingMatrix * worldPosition;
|
|
#endif
|
|
#ifdef USE_INSTANCING
|
|
worldPosition = instanceMatrix * worldPosition;
|
|
#endif
|
|
worldPosition = modelMatrix * worldPosition;
|
|
#endif`;const KS=`varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
void main() {
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
}`,JS=`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 <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,jS=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,QS=`#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
uniform float flipEnvMap;
|
|
uniform float backgroundBlurriness;
|
|
uniform float backgroundIntensity;
|
|
uniform mat3 backgroundRotation;
|
|
varying vec3 vWorldDirection;
|
|
#include <cube_uv_reflection_fragment>
|
|
void main() {
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
|
#else
|
|
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
#endif
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,ew=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,tw=`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 <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,nw=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <morphinstance_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vHighPrecisionZW = gl_Position.zw;
|
|
}`,iw=`#if DEPTH_PACKING == 3200
|
|
uniform float opacity;
|
|
#endif
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <clipping_planes_fragment>
|
|
#if DEPTH_PACKING == 3200
|
|
diffuseColor.a = opacity;
|
|
#endif
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
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
|
|
}`,sw=`#define DISTANCE
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <morphinstance_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vWorldPosition = worldPosition.xyz;
|
|
}`,rw=`#define DISTANCE
|
|
uniform vec3 referencePosition;
|
|
uniform float nearDistance;
|
|
uniform float farDistance;
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main () {
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <clipping_planes_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
float dist = length( vWorldPosition - referencePosition );
|
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
dist = saturate( dist );
|
|
gl_FragColor = packDepthToRGBA( dist );
|
|
}`,ow=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
}`,aw=`uniform sampler2D tEquirect;
|
|
varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vec3 direction = normalize( vWorldDirection );
|
|
vec2 sampleUV = equirectUv( direction );
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,lw=`uniform float scale;
|
|
attribute float lineDistance;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
vLineDistance = scale * lineDistance;
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,cw=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform float dashSize;
|
|
uniform float totalSize;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
discard;
|
|
}
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,uw=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,hw=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#endif
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
|
#else
|
|
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|
#endif
|
|
#include <aomap_fragment>
|
|
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,dw=`#define LAMBERT
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,fw=`#define LAMBERT
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_lambert_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_lambert_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,pw=`#define MATCAP
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
}`,mw=`#define MATCAP
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform sampler2D matcap;
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
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 <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,gw=`#define NORMAL
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vViewPosition = - mvPosition.xyz;
|
|
#endif
|
|
}`,_w=`#define NORMAL
|
|
uniform float opacity;
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
|
|
#ifdef OPAQUE
|
|
gl_FragColor.a = 1.0;
|
|
#endif
|
|
}`,vw=`#define PHONG
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,yw=`#define PHONG
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform vec3 specular;
|
|
uniform float shininess;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_phong_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_phong_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,xw=`#define STANDARD
|
|
varying vec3 vViewPosition;
|
|
#ifdef USE_TRANSMISSION
|
|
varying vec3 vWorldPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
#ifdef USE_TRANSMISSION
|
|
vWorldPosition = worldPosition.xyz;
|
|
#endif
|
|
}`,Mw=`#define STANDARD
|
|
#ifdef PHYSICAL
|
|
#define IOR
|
|
#define USE_SPECULAR
|
|
#endif
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float roughness;
|
|
uniform float metalness;
|
|
uniform float opacity;
|
|
#ifdef IOR
|
|
uniform float ior;
|
|
#endif
|
|
#ifdef USE_SPECULAR
|
|
uniform float specularIntensity;
|
|
uniform vec3 specularColor;
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
uniform sampler2D specularColorMap;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
uniform sampler2D specularIntensityMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
uniform float clearcoat;
|
|
uniform float clearcoatRoughness;
|
|
#endif
|
|
#ifdef USE_DISPERSION
|
|
uniform float dispersion;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
uniform float iridescence;
|
|
uniform float iridescenceIOR;
|
|
uniform float iridescenceThicknessMinimum;
|
|
uniform float iridescenceThicknessMaximum;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
uniform vec3 sheenColor;
|
|
uniform float sheenRoughness;
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
uniform sampler2D sheenColorMap;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
uniform sampler2D sheenRoughnessMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
uniform vec2 anisotropyVector;
|
|
#ifdef USE_ANISOTROPYMAP
|
|
uniform sampler2D anisotropyMap;
|
|
#endif
|
|
#endif
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <iridescence_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_physical_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_physical_pars_fragment>
|
|
#include <transmission_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <clearcoat_pars_fragment>
|
|
#include <iridescence_pars_fragment>
|
|
#include <roughnessmap_pars_fragment>
|
|
#include <metalnessmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <roughnessmap_fragment>
|
|
#include <metalnessmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <clearcoat_normal_fragment_begin>
|
|
#include <clearcoat_normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_physical_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
#include <transmission_fragment>
|
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
#ifdef USE_SHEEN
|
|
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
#endif
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,bw=`#define TOON
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Sw=`#define TOON
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <gradientmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_toon_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_toon_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,ww=`uniform float size;
|
|
uniform float scale;
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
#ifdef USE_POINTS_UV
|
|
varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
void main() {
|
|
#ifdef USE_POINTS_UV
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
#endif
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
gl_PointSize = size;
|
|
#ifdef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
#endif
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <fog_vertex>
|
|
}`,Aw=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <map_particle_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_particle_fragment>
|
|
#include <color_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,Ew=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
void main() {
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Tw=`uniform vec3 color;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <shadowmask_pars_fragment>
|
|
void main() {
|
|
#include <logdepthbuf_fragment>
|
|
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,Cw=`uniform float rotation;
|
|
uniform vec2 center;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
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 <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,Pw=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,ot={alphahash_fragment:JM,alphahash_pars_fragment:jM,alphamap_fragment:QM,alphamap_pars_fragment:eb,alphatest_fragment:tb,alphatest_pars_fragment:nb,aomap_fragment:ib,aomap_pars_fragment:sb,batching_pars_vertex:rb,batching_vertex:ob,begin_vertex:ab,beginnormal_vertex:lb,bsdfs:cb,iridescence_fragment:ub,bumpmap_pars_fragment:hb,clipping_planes_fragment:db,clipping_planes_pars_fragment:fb,clipping_planes_pars_vertex:pb,clipping_planes_vertex:mb,color_fragment:gb,color_pars_fragment:_b,color_pars_vertex:vb,color_vertex:yb,common:xb,cube_uv_reflection_fragment:Mb,defaultnormal_vertex:bb,displacementmap_pars_vertex:Sb,displacementmap_vertex:wb,emissivemap_fragment:Ab,emissivemap_pars_fragment:Eb,colorspace_fragment:Tb,colorspace_pars_fragment:Cb,envmap_fragment:Pb,envmap_common_pars_fragment:Rb,envmap_pars_fragment:Ib,envmap_pars_vertex:Lb,envmap_physical_pars_fragment:Gb,envmap_vertex:Nb,fog_vertex:Db,fog_pars_vertex:Ub,fog_fragment:Ob,fog_pars_fragment:Fb,gradientmap_pars_fragment:kb,lightmap_pars_fragment:Bb,lights_lambert_fragment:zb,lights_lambert_pars_fragment:Vb,lights_pars_begin:Hb,lights_toon_fragment:Wb,lights_toon_pars_fragment:$b,lights_phong_fragment:Xb,lights_phong_pars_fragment:qb,lights_physical_fragment:Yb,lights_physical_pars_fragment:Zb,lights_fragment_begin:Kb,lights_fragment_maps:Jb,lights_fragment_end:jb,logdepthbuf_fragment:Qb,logdepthbuf_pars_fragment:eS,logdepthbuf_pars_vertex:tS,logdepthbuf_vertex:nS,map_fragment:iS,map_pars_fragment:sS,map_particle_fragment:rS,map_particle_pars_fragment:oS,metalnessmap_fragment:aS,metalnessmap_pars_fragment:lS,morphinstance_vertex:cS,morphcolor_vertex:uS,morphnormal_vertex:hS,morphtarget_pars_vertex:dS,morphtarget_vertex:fS,normal_fragment_begin:pS,normal_fragment_maps:mS,normal_pars_fragment:gS,normal_pars_vertex:_S,normal_vertex:vS,normalmap_pars_fragment:yS,clearcoat_normal_fragment_begin:xS,clearcoat_normal_fragment_maps:MS,clearcoat_pars_fragment:bS,iridescence_pars_fragment:SS,opaque_fragment:wS,packing:AS,premultiplied_alpha_fragment:ES,project_vertex:TS,dithering_fragment:CS,dithering_pars_fragment:PS,roughnessmap_fragment:RS,roughnessmap_pars_fragment:IS,shadowmap_pars_fragment:LS,shadowmap_pars_vertex:NS,shadowmap_vertex:DS,shadowmask_pars_fragment:US,skinbase_vertex:OS,skinning_pars_vertex:FS,skinning_vertex:kS,skinnormal_vertex:BS,specularmap_fragment:zS,specularmap_pars_fragment:VS,tonemapping_fragment:HS,tonemapping_pars_fragment:GS,transmission_fragment:WS,transmission_pars_fragment:$S,uv_pars_fragment:XS,uv_pars_vertex:qS,uv_vertex:YS,worldpos_vertex:ZS,background_vert:KS,background_frag:JS,backgroundCube_vert:jS,backgroundCube_frag:QS,cube_vert:ew,cube_frag:tw,depth_vert:nw,depth_frag:iw,distanceRGBA_vert:sw,distanceRGBA_frag:rw,equirect_vert:ow,equirect_frag:aw,linedashed_vert:lw,linedashed_frag:cw,meshbasic_vert:uw,meshbasic_frag:hw,meshlambert_vert:dw,meshlambert_frag:fw,meshmatcap_vert:pw,meshmatcap_frag:mw,meshnormal_vert:gw,meshnormal_frag:_w,meshphong_vert:vw,meshphong_frag:yw,meshphysical_vert:xw,meshphysical_frag:Mw,meshtoon_vert:bw,meshtoon_frag:Sw,points_vert:ww,points_frag:Aw,shadow_vert:Ew,shadow_frag:Tw,sprite_vert:Cw,sprite_frag:Pw},Pe={common:{diffuse:{value:new Ie(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new je},alphaMap:{value:null},alphaMapTransform:{value:new je},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new je}},envmap:{envMap:{value:null},envMapRotation:{value:new je},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new je}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new je}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new je},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new je},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new je},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new je}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new je}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new je}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ie(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 Ie(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new je},alphaTest:{value:0},uvTransform:{value:new je}},sprite:{diffuse:{value:new Ie(16777215)},opacity:{value:1},center:{value:new te(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new je},alphaMap:{value:null},alphaMapTransform:{value:new je},alphaTest:{value:0}}},Rn={basic:{uniforms:sn([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.fog]),vertexShader:ot.meshbasic_vert,fragmentShader:ot.meshbasic_frag},lambert:{uniforms:sn([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,Pe.lights,{emissive:{value:new Ie(0)}}]),vertexShader:ot.meshlambert_vert,fragmentShader:ot.meshlambert_frag},phong:{uniforms:sn([Pe.common,Pe.specularmap,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,Pe.lights,{emissive:{value:new Ie(0)},specular:{value:new Ie(1118481)},shininess:{value:30}}]),vertexShader:ot.meshphong_vert,fragmentShader:ot.meshphong_frag},standard:{uniforms:sn([Pe.common,Pe.envmap,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.roughnessmap,Pe.metalnessmap,Pe.fog,Pe.lights,{emissive:{value:new Ie(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ot.meshphysical_vert,fragmentShader:ot.meshphysical_frag},toon:{uniforms:sn([Pe.common,Pe.aomap,Pe.lightmap,Pe.emissivemap,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.gradientmap,Pe.fog,Pe.lights,{emissive:{value:new Ie(0)}}]),vertexShader:ot.meshtoon_vert,fragmentShader:ot.meshtoon_frag},matcap:{uniforms:sn([Pe.common,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,Pe.fog,{matcap:{value:null}}]),vertexShader:ot.meshmatcap_vert,fragmentShader:ot.meshmatcap_frag},points:{uniforms:sn([Pe.points,Pe.fog]),vertexShader:ot.points_vert,fragmentShader:ot.points_frag},dashed:{uniforms:sn([Pe.common,Pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ot.linedashed_vert,fragmentShader:ot.linedashed_frag},depth:{uniforms:sn([Pe.common,Pe.displacementmap]),vertexShader:ot.depth_vert,fragmentShader:ot.depth_frag},normal:{uniforms:sn([Pe.common,Pe.bumpmap,Pe.normalmap,Pe.displacementmap,{opacity:{value:1}}]),vertexShader:ot.meshnormal_vert,fragmentShader:ot.meshnormal_frag},sprite:{uniforms:sn([Pe.sprite,Pe.fog]),vertexShader:ot.sprite_vert,fragmentShader:ot.sprite_frag},background:{uniforms:{uvTransform:{value:new je},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ot.background_vert,fragmentShader:ot.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new je}},vertexShader:ot.backgroundCube_vert,fragmentShader:ot.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ot.cube_vert,fragmentShader:ot.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ot.equirect_vert,fragmentShader:ot.equirect_frag},distanceRGBA:{uniforms:sn([Pe.common,Pe.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ot.distanceRGBA_vert,fragmentShader:ot.distanceRGBA_frag},shadow:{uniforms:sn([Pe.lights,Pe.fog,{color:{value:new Ie(0)},opacity:{value:1}}]),vertexShader:ot.shadow_vert,fragmentShader:ot.shadow_frag}};Rn.physical={uniforms:sn([Rn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new je},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new je},clearcoatNormalScale:{value:new te(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new je},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new je},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new je},sheen:{value:0},sheenColor:{value:new Ie(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new je},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new je},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new je},transmissionSamplerSize:{value:new te},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new je},attenuationDistance:{value:0},attenuationColor:{value:new Ie(0)},specularColor:{value:new Ie(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new je},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new je},anisotropyVector:{value:new te},anisotropyMap:{value:null},anisotropyMapTransform:{value:new je}}]),vertexShader:ot.meshphysical_vert,fragmentShader:ot.meshphysical_frag};const Io={r:0,b:0,g:0},Gi=new bn,Rw=new Ze;function Iw(s,e,t,n,i,r,o){const a=new Ie(0);let l=r===!0?0:1,c,u,h=null,d=0,f=null;function g(y){let v=y.isScene===!0?y.background:null;return v&&v.isTexture&&(v=(y.backgroundBlurriness>0?t:e).get(v)),v}function _(y){let v=!1;const x=g(y);x===null?m(a,l):x&&x.isColor&&(m(x,1),v=!0);const E=s.xr.getEnvironmentBlendMode();E==="additive"?n.buffers.color.setClear(0,0,0,1,o):E==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(s.autoClear||v)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function p(y,v){const x=g(v);x&&(x.isCubeTexture||x.mapping===Js)?(u===void 0&&(u=new Nt(new gs(1,1,1),new On({name:"BackgroundCubeMaterial",uniforms:Zs(Rn.backgroundCube.uniforms),vertexShader:Rn.backgroundCube.vertexShader,fragmentShader:Rn.backgroundCube.fragmentShader,side:an,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(E,S,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Gi.copy(v.backgroundRotation),Gi.x*=-1,Gi.y*=-1,Gi.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(Gi.y*=-1,Gi.z*=-1),u.material.uniforms.envMap.value=x,u.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Rw.makeRotationFromEuler(Gi)),u.material.toneMapped=dt.getTransfer(x.colorSpace)!==Mt,(h!==x||d!==x.version||f!==s.toneMapping)&&(u.material.needsUpdate=!0,h=x,d=x.version,f=s.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null)):x&&x.isTexture&&(c===void 0&&(c=new Nt(new js(2,2),new On({name:"BackgroundMaterial",uniforms:Zs(Rn.background.uniforms),vertexShader:Rn.background.vertexShader,fragmentShader:Rn.background.fragmentShader,side:ci,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=v.backgroundIntensity,c.material.toneMapped=dt.getTransfer(x.colorSpace)!==Mt,x.matrixAutoUpdate===!0&&x.updateMatrix(),c.material.uniforms.uvTransform.value.copy(x.matrix),(h!==x||d!==x.version||f!==s.toneMapping)&&(c.material.needsUpdate=!0,h=x,d=x.version,f=s.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function m(y,v){y.getRGB(Io,Cp(s)),n.buffers.color.setClear(Io.r,Io.g,Io.b,v,o)}return{getClearColor:function(){return a},setClearColor:function(y,v=1){a.set(y),l=v,m(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,m(a,l)},render:_,addToRenderList:p}}function Lw(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,o=!1;function a(b,k,V,G,X){let ce=!1;const Z=h(G,V,k);r!==Z&&(r=Z,c(r.object)),ce=f(b,G,V,X),ce&&g(b,G,V,X),X!==null&&e.update(X,s.ELEMENT_ARRAY_BUFFER),(ce||o)&&(o=!1,x(b,k,V,G),X!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(X).buffer))}function l(){return s.createVertexArray()}function c(b){return s.bindVertexArray(b)}function u(b){return s.deleteVertexArray(b)}function h(b,k,V){const G=V.wireframe===!0;let X=n[b.id];X===void 0&&(X={},n[b.id]=X);let ce=X[k.id];ce===void 0&&(ce={},X[k.id]=ce);let Z=ce[G];return Z===void 0&&(Z=d(l()),ce[G]=Z),Z}function d(b){const k=[],V=[],G=[];for(let X=0;X<t;X++)k[X]=0,V[X]=0,G[X]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:k,enabledAttributes:V,attributeDivisors:G,object:b,attributes:{},index:null}}function f(b,k,V,G){const X=r.attributes,ce=k.attributes;let Z=0;const ae=V.getAttributes();for(const z in ae)if(ae[z].location>=0){const we=X[z];let Ae=ce[z];if(Ae===void 0&&(z==="instanceMatrix"&&b.instanceMatrix&&(Ae=b.instanceMatrix),z==="instanceColor"&&b.instanceColor&&(Ae=b.instanceColor)),we===void 0||we.attribute!==Ae||Ae&&we.data!==Ae.data)return!0;Z++}return r.attributesNum!==Z||r.index!==G}function g(b,k,V,G){const X={},ce=k.attributes;let Z=0;const ae=V.getAttributes();for(const z in ae)if(ae[z].location>=0){let we=ce[z];we===void 0&&(z==="instanceMatrix"&&b.instanceMatrix&&(we=b.instanceMatrix),z==="instanceColor"&&b.instanceColor&&(we=b.instanceColor));const Ae={};Ae.attribute=we,we&&we.data&&(Ae.data=we.data),X[z]=Ae,Z++}r.attributes=X,r.attributesNum=Z,r.index=G}function _(){const b=r.newAttributes;for(let k=0,V=b.length;k<V;k++)b[k]=0}function p(b){m(b,0)}function m(b,k){const V=r.newAttributes,G=r.enabledAttributes,X=r.attributeDivisors;V[b]=1,G[b]===0&&(s.enableVertexAttribArray(b),G[b]=1),X[b]!==k&&(s.vertexAttribDivisor(b,k),X[b]=k)}function y(){const b=r.newAttributes,k=r.enabledAttributes;for(let V=0,G=k.length;V<G;V++)k[V]!==b[V]&&(s.disableVertexAttribArray(V),k[V]=0)}function v(b,k,V,G,X,ce,Z){Z===!0?s.vertexAttribIPointer(b,k,V,X,ce):s.vertexAttribPointer(b,k,V,G,X,ce)}function x(b,k,V,G){_();const X=G.attributes,ce=V.getAttributes(),Z=k.defaultAttributeValues;for(const ae in ce){const z=ce[ae];if(z.location>=0){let Se=X[ae];if(Se===void 0&&(ae==="instanceMatrix"&&b.instanceMatrix&&(Se=b.instanceMatrix),ae==="instanceColor"&&b.instanceColor&&(Se=b.instanceColor)),Se!==void 0){const we=Se.normalized,Ae=Se.itemSize,_e=e.get(Se);if(_e===void 0)continue;const De=_e.buffer,F=_e.type,U=_e.bytesPerElement,I=F===s.INT||F===s.UNSIGNED_INT||Se.gpuType===fu;if(Se.isInterleavedBufferAttribute){const T=Se.data,se=T.stride,fe=Se.offset;if(T.isInstancedInterleavedBuffer){for(let K=0;K<z.locationSize;K++)m(z.location+K,T.meshPerAttribute);b.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=T.meshPerAttribute*T.count)}else for(let K=0;K<z.locationSize;K++)p(z.location+K);s.bindBuffer(s.ARRAY_BUFFER,De);for(let K=0;K<z.locationSize;K++)v(z.location+K,Ae/z.locationSize,F,we,se*U,(fe+Ae/z.locationSize*K)*U,I)}else{if(Se.isInstancedBufferAttribute){for(let T=0;T<z.locationSize;T++)m(z.location+T,Se.meshPerAttribute);b.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=Se.meshPerAttribute*Se.count)}else for(let T=0;T<z.locationSize;T++)p(z.location+T);s.bindBuffer(s.ARRAY_BUFFER,De);for(let T=0;T<z.locationSize;T++)v(z.location+T,Ae/z.locationSize,F,we,Ae*U,Ae/z.locationSize*T*U,I)}}else if(Z!==void 0){const we=Z[ae];if(we!==void 0)switch(we.length){case 2:s.vertexAttrib2fv(z.location,we);break;case 3:s.vertexAttrib3fv(z.location,we);break;case 4:s.vertexAttrib4fv(z.location,we);break;default:s.vertexAttrib1fv(z.location,we)}}}}y()}function E(){L();for(const b in n){const k=n[b];for(const V in k){const G=k[V];for(const X in G)u(G[X].object),delete G[X];delete k[V]}delete n[b]}}function S(b){if(n[b.id]===void 0)return;const k=n[b.id];for(const V in k){const G=k[V];for(const X in G)u(G[X].object),delete G[X];delete k[V]}delete n[b.id]}function C(b){for(const k in n){const V=n[k];if(V[b.id]===void 0)continue;const G=V[b.id];for(const X in G)u(G[X].object),delete G[X];delete V[b.id]}}function L(){A(),o=!0,r!==i&&(r=i,c(r.object))}function A(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:L,resetDefaultState:A,dispose:E,releaseStatesOfGeometry:S,releaseStatesOfProgram:C,initAttributes:_,enableAttribute:p,disableUnusedAttributes:y}}function Nw(s,e,t){let n;function i(c){n=c}function r(c,u){s.drawArrays(n,c,u),t.update(u,n,1)}function o(c,u,h){h!==0&&(s.drawArraysInstanced(n,c,u,h),t.update(u,n,h))}function a(c,u,h){if(h===0)return;const d=e.get("WEBGL_multi_draw");if(d===null)for(let f=0;f<h;f++)this.render(c[f],u[f]);else{d.multiDrawArraysWEBGL(n,c,0,u,0,h);let f=0;for(let g=0;g<h;g++)f+=u[g];t.update(f,n,1)}}function l(c,u,h,d){if(h===0)return;const f=e.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<c.length;g++)o(c[g],u[g],d[g]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,u,0,d,0,h);let g=0;for(let _=0;_<h;_++)g+=u[_];for(let _=0;_<d.length;_++)t.update(g,n,d[_])}}this.setMode=i,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function Dw(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const S=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(S.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(S){return!(S!==fn&&n.convert(S)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(S){const C=S===Jr&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(S!==hi&&n.convert(S)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&S!==xn&&!C)}function l(S){if(S==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";S="mediump"}return S==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),f=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_TEXTURE_SIZE),_=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),p=s.getParameter(s.MAX_VERTEX_ATTRIBS),m=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),y=s.getParameter(s.MAX_VARYING_VECTORS),v=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),x=f>0,E=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:h,maxTextures:d,maxVertexTextures:f,maxTextureSize:g,maxCubemapSize:_,maxAttributes:p,maxVertexUniforms:m,maxVaryings:y,maxFragmentUniforms:v,vertexTextures:x,maxSamples:E}}function Uw(s){const e=this;let t=null,n=0,i=!1,r=!1;const o=new ii,a=new je,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const f=h.length!==0||d||n!==0||i;return i=d,n=h.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,f){const g=h.clippingPlanes,_=h.clipIntersection,p=h.clipShadows,m=s.get(h);if(!i||g===null||g.length===0||r&&!p)r?u(null):c();else{const y=r?0:n,v=y*4;let x=m.clippingState||null;l.value=x,x=u(g,d,v,f);for(let E=0;E!==v;++E)x[E]=t[E];m.clippingState=x,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,d,f,g){const _=h!==null?h.length:0;let p=null;if(_!==0){if(p=l.value,g!==!0||p===null){const m=f+_*4,y=d.matrixWorldInverse;a.getNormalMatrix(y),(p===null||p.length<m)&&(p=new Float32Array(m));for(let v=0,x=f;v!==_;++v,x+=4)o.copy(h[v]).applyMatrix4(y,a),o.normal.toArray(p,x),p[x+3]=o.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,p}}function Ow(s){let e=new WeakMap;function t(o,a){return a===Ar?o.mapping=ui:a===Er&&(o.mapping=Ri),o}function n(o){if(o&&o.isTexture){const a=o.mapping;if(a===Ar||a===Er)if(e.has(o)){const l=e.get(o).texture;return t(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new Ip(l.height);return c.fromEquirectangularTexture(s,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}class Va extends Qr{constructor(e=-1,t=1,n=1,i=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Gs=4,Ch=[.125,.215,.35,.446,.526,.582],ts=20,Dl=new Va,Ph=new Ie;let Ul=null,Ol=0,Fl=0,kl=!1;const es=(1+Math.sqrt(5))/2,Ds=1/es,Rh=[new N(-es,Ds,0),new N(es,Ds,0),new N(-Ds,0,es),new N(Ds,0,es),new N(0,es,-Ds),new N(0,es,Ds),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)];class Vc{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Ul=this._renderer.getRenderTarget(),Ol=this._renderer.getActiveCubeFace(),Fl=this._renderer.getActiveMipmapLevel(),kl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Nh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Lh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Ul,Ol,Fl),this._renderer.xr.enabled=kl,e.scissorTest=!1,Lo(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ui||e.mapping===Ri?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ul=this._renderer.getRenderTarget(),Ol=this._renderer.getActiveCubeFace(),Fl=this._renderer.getActiveMipmapLevel(),kl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Bt,minFilter:Bt,generateMipmaps:!1,type:Jr,format:fn,colorSpace:fi,depthBuffer:!1},i=Ih(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ih(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Fw(r)),this._blurMaterial=kw(r,e,t)}return i}_compileMaterial(e){const t=new Nt(this._lodPlanes[0],e);this._renderer.compile(t,Dl)}_sceneToCubeUV(e,t,n,i){const a=new kt(90,1,t,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,d=u.toneMapping;u.getClearColor(Ph),u.toneMapping=Wn,u.autoClear=!1;const f=new pi({name:"PMREM.Background",side:an,depthWrite:!1,depthTest:!1}),g=new Nt(new gs,f);let _=!1;const p=e.background;p?p.isColor&&(f.color.copy(p),e.background=null,_=!0):(f.color.copy(Ph),_=!0);for(let m=0;m<6;m++){const y=m%3;y===0?(a.up.set(0,l[m],0),a.lookAt(c[m],0,0)):y===1?(a.up.set(0,0,l[m]),a.lookAt(0,c[m],0)):(a.up.set(0,l[m],0),a.lookAt(0,0,c[m]));const v=this._cubeSize;Lo(i,y*v,m>2?v:0,v,v),u.setRenderTarget(i),_&&u.render(g,a),u.render(e,a)}g.geometry.dispose(),g.material.dispose(),u.toneMapping=d,u.autoClear=h,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===ui||e.mapping===Ri;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Nh()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Lh());const r=i?this._cubemapMaterial:this._equirectMaterial,o=new Nt(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const l=this._cubeSize;Lo(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Dl)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=Rh[(i-r-1)%Rh.length];this._blur(e,r-1,r,o,a)}t.autoClear=n}_blur(e,t,n,i,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",r),this._halfBlur(o,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new Nt(this._lodPlanes[i],c),d=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*ts-1),_=r/g,p=isFinite(r)?1+Math.floor(u*_):ts;p>ts&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${ts}`);const m=[];let y=0;for(let C=0;C<ts;++C){const L=C/_,A=Math.exp(-L*L/2);m.push(A),C===0?y+=A:C<p&&(y+=2*A)}for(let C=0;C<m.length;C++)m[C]=m[C]/y;d.envMap.value=e.texture,d.samples.value=p,d.weights.value=m,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:v}=this;d.dTheta.value=g,d.mipInt.value=v-n;const x=this._sizeLods[i],E=3*x*(i>v-Gs?i-v+Gs:0),S=4*(this._cubeSize-x);Lo(t,E,S,3*x,2*x),l.setRenderTarget(t),l.render(h,Dl)}}function Fw(s){const e=[],t=[],n=[];let i=s;const r=s-Gs+1+Ch.length;for(let o=0;o<r;o++){const a=Math.pow(2,i);t.push(a);let l=1/a;o>s-Gs?l=Ch[o-s+Gs-1]:o===0&&(l=0),n.push(l);const c=1/(a-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,g=6,_=3,p=2,m=1,y=new Float32Array(_*g*f),v=new Float32Array(p*g*f),x=new Float32Array(m*g*f);for(let S=0;S<f;S++){const C=S%3*2/3-1,L=S>2?0:-1,A=[C,L,0,C+2/3,L,0,C+2/3,L+1,0,C,L,0,C+2/3,L+1,0,C,L+1,0];y.set(A,_*g*S),v.set(d,p*g*S);const b=[S,S,S,S,S,S];x.set(b,m*g*S)}const E=new at;E.setAttribute("position",new mt(y,_)),E.setAttribute("uv",new mt(v,p)),E.setAttribute("faceIndex",new mt(x,m)),e.push(E),i>Gs&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Ih(s,e,t){const n=new Un(s,e,t);return n.texture.mapping=Js,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Lo(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function kw(s,e,t){const n=new Float32Array(ts),i=new N(0,1,0);return new On({name:"SphericalGaussianBlur",defines:{n:ts,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Cu(),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 <cube_uv_reflection_fragment>
|
|
|
|
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:ai,depthTest:!1,depthWrite:!1})}function Lh(){return new On({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cu(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 outputDirection = normalize( vOutputDirection );
|
|
vec2 uv = equirectUv( outputDirection );
|
|
|
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
|
|
}
|
|
`,blending:ai,depthTest:!1,depthWrite:!1})}function Nh(){return new On({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cu(),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:ai,depthTest:!1,depthWrite:!1})}function Cu(){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 Bw(s){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const l=a.mapping,c=l===Ar||l===Er,u=l===ui||l===Ri;if(c||u){let h=e.get(a);const d=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new Vc(s)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{const f=a.image;return c&&f&&f.height>0||u&&f&&i(f)?(t===null&&(t=new Vc(s)),h=c?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",r),h.texture):null}}}return a}function i(a){let l=0;const c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function r(a){const l=a.target;l.removeEventListener("dispose",r);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function zw(s){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const i=t(n);return i===null&&wu("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function Vw(s,e,t,n){const i={},r=new WeakMap;function o(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);for(const g in d.morphAttributes){const _=d.morphAttributes[g];for(let p=0,m=_.length;p<m;p++)e.remove(_[p])}d.removeEventListener("dispose",o),delete i[d.id];const f=r.get(d);f&&(e.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const g in d)e.update(d[g],s.ARRAY_BUFFER);const f=h.morphAttributes;for(const g in f){const _=f[g];for(let p=0,m=_.length;p<m;p++)e.update(_[p],s.ARRAY_BUFFER)}}function c(h){const d=[],f=h.index,g=h.attributes.position;let _=0;if(f!==null){const y=f.array;_=f.version;for(let v=0,x=y.length;v<x;v+=3){const E=y[v+0],S=y[v+1],C=y[v+2];d.push(E,S,S,C,C,E)}}else if(g!==void 0){const y=g.array;_=g.version;for(let v=0,x=y.length/3-1;v<x;v+=3){const E=v+0,S=v+1,C=v+2;d.push(E,S,S,C,C,E)}}else return;const p=new(Sp(d)?Tu:Eu)(d,1);p.version=_;const m=r.get(h);m&&e.remove(m),r.set(h,p)}function u(h){const d=r.get(h);if(d){const f=h.index;f!==null&&d.version<f.version&&c(h)}else c(h);return r.get(h)}return{get:a,update:l,getWireframeAttribute:u}}function Hw(s,e,t){let n;function i(d){n=d}let r,o;function a(d){r=d.type,o=d.bytesPerElement}function l(d,f){s.drawElements(n,f,r,d*o),t.update(f,n,1)}function c(d,f,g){g!==0&&(s.drawElementsInstanced(n,f,r,d*o,g),t.update(f,n,g))}function u(d,f,g){if(g===0)return;const _=e.get("WEBGL_multi_draw");if(_===null)for(let p=0;p<g;p++)this.render(d[p]/o,f[p]);else{_.multiDrawElementsWEBGL(n,f,0,r,d,0,g);let p=0;for(let m=0;m<g;m++)p+=f[m];t.update(p,n,1)}}function h(d,f,g,_){if(g===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<d.length;m++)c(d[m]/o,f[m],_[m]);else{p.multiDrawElementsInstancedWEBGL(n,f,0,r,d,0,_,0,g);let m=0;for(let y=0;y<g;y++)m+=f[y];for(let y=0;y<_.length;y++)t.update(m,n,_[y])}}this.setMode=i,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function Gw(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case s.TRIANGLES:t.triangles+=a*(r/3);break;case s.LINES:t.lines+=a*(r/2);break;case s.LINE_STRIP:t.lines+=a*(r-1);break;case s.LINE_LOOP:t.lines+=a*r;break;case s.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function Ww(s,e,t){const n=new WeakMap,i=new _t;function r(o,a,l){const c=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0;let d=n.get(a);if(d===void 0||d.count!==h){let A=function(){C.dispose(),n.delete(a),a.removeEventListener("dispose",A)};d!==void 0&&d.texture.dispose();const f=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,p=a.morphAttributes.position||[],m=a.morphAttributes.normal||[],y=a.morphAttributes.color||[];let v=0;f===!0&&(v=1),g===!0&&(v=2),_===!0&&(v=3);let x=a.attributes.position.count*v,E=1;x>e.maxTextureSize&&(E=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);const S=new Float32Array(x*E*4*h),C=new Ba(S,x,E,h);C.type=xn,C.needsUpdate=!0;const L=v*4;for(let b=0;b<h;b++){const k=p[b],V=m[b],G=y[b],X=x*E*4*b;for(let ce=0;ce<k.count;ce++){const Z=ce*L;f===!0&&(i.fromBufferAttribute(k,ce),S[X+Z+0]=i.x,S[X+Z+1]=i.y,S[X+Z+2]=i.z,S[X+Z+3]=0),g===!0&&(i.fromBufferAttribute(V,ce),S[X+Z+4]=i.x,S[X+Z+5]=i.y,S[X+Z+6]=i.z,S[X+Z+7]=0),_===!0&&(i.fromBufferAttribute(G,ce),S[X+Z+8]=i.x,S[X+Z+9]=i.y,S[X+Z+10]=i.z,S[X+Z+11]=G.itemSize===4?i.w:1)}}d={count:h,texture:C,size:new te(x,E)},n.set(a,d),a.addEventListener("dispose",A)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",o.morphTexture,t);else{let f=0;for(let _=0;_<c.length;_++)f+=c[_];const g=a.morphTargetsRelative?1:1-f;l.getUniforms().setValue(s,"morphTargetBaseInfluence",g),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function $w(s,e,t,n){let i=new WeakMap;function r(l){const c=n.render.frame,u=l.geometry,h=e.get(l,u);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),i.get(l)!==c&&(t.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,s.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;i.get(d)!==c&&(d.update(),i.set(d,c))}return h}function o(){i=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:r,dispose:o}}class Pu extends It{constructor(e,t,n,i,r,o,a,l,c,u=as){if(u!==as&&u!==ds)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===as&&(n=us),n===void 0&&u===ds&&(n=hs),super(null,i,r,o,a,l,u,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Wt,this.minFilter=l!==void 0?l:Wt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const Np=new It,Dp=new Pu(1,1);Dp.compareFunction=Mu;const Up=new Ba,Op=new Au,Fp=new eo,Dh=[],Uh=[],Oh=new Float32Array(16),Fh=new Float32Array(9),kh=new Float32Array(4);function Qs(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=Dh[i];if(r===void 0&&(r=new Float32Array(i),Dh[i]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,s[o].toArray(r,a)}return r}function zt(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function Vt(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function Ha(s,e){let t=Uh[e];t===void 0&&(t=new Int32Array(e),Uh[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function Xw(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function qw(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(zt(t,e))return;s.uniform2fv(this.addr,e),Vt(t,e)}}function Yw(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(zt(t,e))return;s.uniform3fv(this.addr,e),Vt(t,e)}}function Zw(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(zt(t,e))return;s.uniform4fv(this.addr,e),Vt(t,e)}}function Kw(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(zt(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),Vt(t,e)}else{if(zt(t,n))return;kh.set(n),s.uniformMatrix2fv(this.addr,!1,kh),Vt(t,n)}}function Jw(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(zt(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),Vt(t,e)}else{if(zt(t,n))return;Fh.set(n),s.uniformMatrix3fv(this.addr,!1,Fh),Vt(t,n)}}function jw(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(zt(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),Vt(t,e)}else{if(zt(t,n))return;Oh.set(n),s.uniformMatrix4fv(this.addr,!1,Oh),Vt(t,n)}}function Qw(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function e1(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(zt(t,e))return;s.uniform2iv(this.addr,e),Vt(t,e)}}function t1(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(zt(t,e))return;s.uniform3iv(this.addr,e),Vt(t,e)}}function n1(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(zt(t,e))return;s.uniform4iv(this.addr,e),Vt(t,e)}}function i1(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function s1(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(zt(t,e))return;s.uniform2uiv(this.addr,e),Vt(t,e)}}function r1(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(zt(t,e))return;s.uniform3uiv(this.addr,e),Vt(t,e)}}function o1(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(zt(t,e))return;s.uniform4uiv(this.addr,e),Vt(t,e)}}function a1(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);const r=this.type===s.SAMPLER_2D_SHADOW?Dp:Np;t.setTexture2D(e||r,i)}function l1(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Op,i)}function c1(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Fp,i)}function u1(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Up,i)}function h1(s){switch(s){case 5126:return Xw;case 35664:return qw;case 35665:return Yw;case 35666:return Zw;case 35674:return Kw;case 35675:return Jw;case 35676:return jw;case 5124:case 35670:return Qw;case 35667:case 35671:return e1;case 35668:case 35672:return t1;case 35669:case 35673:return n1;case 5125:return i1;case 36294:return s1;case 36295:return r1;case 36296:return o1;case 35678:case 36198:case 36298:case 36306:case 35682:return a1;case 35679:case 36299:case 36307:return l1;case 35680:case 36300:case 36308:case 36293:return c1;case 36289:case 36303:case 36311:case 36292:return u1}}function d1(s,e){s.uniform1fv(this.addr,e)}function f1(s,e){const t=Qs(e,this.size,2);s.uniform2fv(this.addr,t)}function p1(s,e){const t=Qs(e,this.size,3);s.uniform3fv(this.addr,t)}function m1(s,e){const t=Qs(e,this.size,4);s.uniform4fv(this.addr,t)}function g1(s,e){const t=Qs(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function _1(s,e){const t=Qs(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function v1(s,e){const t=Qs(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function y1(s,e){s.uniform1iv(this.addr,e)}function x1(s,e){s.uniform2iv(this.addr,e)}function M1(s,e){s.uniform3iv(this.addr,e)}function b1(s,e){s.uniform4iv(this.addr,e)}function S1(s,e){s.uniform1uiv(this.addr,e)}function w1(s,e){s.uniform2uiv(this.addr,e)}function A1(s,e){s.uniform3uiv(this.addr,e)}function E1(s,e){s.uniform4uiv(this.addr,e)}function T1(s,e,t){const n=this.cache,i=e.length,r=Ha(t,i);zt(n,r)||(s.uniform1iv(this.addr,r),Vt(n,r));for(let o=0;o!==i;++o)t.setTexture2D(e[o]||Np,r[o])}function C1(s,e,t){const n=this.cache,i=e.length,r=Ha(t,i);zt(n,r)||(s.uniform1iv(this.addr,r),Vt(n,r));for(let o=0;o!==i;++o)t.setTexture3D(e[o]||Op,r[o])}function P1(s,e,t){const n=this.cache,i=e.length,r=Ha(t,i);zt(n,r)||(s.uniform1iv(this.addr,r),Vt(n,r));for(let o=0;o!==i;++o)t.setTextureCube(e[o]||Fp,r[o])}function R1(s,e,t){const n=this.cache,i=e.length,r=Ha(t,i);zt(n,r)||(s.uniform1iv(this.addr,r),Vt(n,r));for(let o=0;o!==i;++o)t.setTexture2DArray(e[o]||Up,r[o])}function I1(s){switch(s){case 5126:return d1;case 35664:return f1;case 35665:return p1;case 35666:return m1;case 35674:return g1;case 35675:return _1;case 35676:return v1;case 5124:case 35670:return y1;case 35667:case 35671:return x1;case 35668:case 35672:return M1;case 35669:case 35673:return b1;case 5125:return S1;case 36294:return w1;case 36295:return A1;case 36296:return E1;case 35678:case 36198:case 36298:case 36306:case 35682:return T1;case 35679:case 36299:case 36307:return C1;case 35680:case 36300:case 36308:case 36293:return P1;case 36289:case 36303:case 36311:case 36292:return R1}}class L1{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=h1(t.type)}}class N1{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=I1(t.type)}}class D1{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,o=i.length;r!==o;++r){const a=i[r];a.setValue(e,t[a.id],n)}}}const Bl=/(\w+)(\])?(\[|\.)?/g;function Bh(s,e){s.seq.push(e),s.map[e.id]=e}function U1(s,e,t){const n=s.name,i=n.length;for(Bl.lastIndex=0;;){const r=Bl.exec(n),o=Bl.lastIndex;let a=r[1];const l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===i){Bh(t,c===void 0?new L1(a,s,e):new N1(a,s,e));break}else{let h=t.map[a];h===void 0&&(h=new D1(a),Bh(t,h)),t=h}}}class _a{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const r=e.getActiveUniform(t,i),o=e.getUniformLocation(t,r.name);U1(r,o,this)}}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,o=t.length;r!==o;++r){const a=t[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const o=e[i];o.id in t&&n.push(o)}return n}}function zh(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const O1=37297;let F1=0;function k1(s,e){const t=s.split(`
|
|
`),n=[],i=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=i;o<r;o++){const a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
|
|
`)}function B1(s){const e=dt.getPrimaries(dt.workingColorSpace),t=dt.getPrimaries(s);let n;switch(e===t?n="":e===Dr&&t===Nr?n="LinearDisplayP3ToLinearSRGB":e===Nr&&t===Dr&&(n="LinearSRGBToLinearDisplayP3"),s){case fi:case jr:return[n,"LinearTransferOETF"];case dn:case ka:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",s),[n,"LinearTransferOETF"]}}function Vh(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),i=s.getShaderInfoLog(e).trim();if(n&&i==="")return"";const r=/ERROR: 0:(\d+)/.exec(i);if(r){const o=parseInt(r[1]);return t.toUpperCase()+`
|
|
|
|
`+i+`
|
|
|
|
`+k1(s.getShaderSource(e),o)}else return i}function z1(s,e){const t=B1(e);return`vec4 ${s}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function V1(s,e){let t;switch(e){case Yf:t="Linear";break;case Zf:t="Reinhard";break;case Kf:t="OptimizedCineon";break;case Ua:t="ACESFilmic";break;case jf:t="AgX";break;case Qf:t="Neutral";break;case Jf:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function H1(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(gr).join(`
|
|
`)}function G1(s){const e=[];for(const t in s){const n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
`)}function W1(s,e){const t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const r=s.getActiveAttrib(e,i),o=r.name;let a=1;r.type===s.FLOAT_MAT2&&(a=2),r.type===s.FLOAT_MAT3&&(a=3),r.type===s.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:s.getAttribLocation(e,o),locationSize:a}}return t}function gr(s){return s!==""}function Hh(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Gh(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const $1=/^[ \t]*#include +<([\w\d./]+)>/gm;function Hc(s){return s.replace($1,q1)}const X1=new Map;function q1(s,e){let t=ot[e];if(t===void 0){const n=X1.get(e);if(n!==void 0)t=ot[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Hc(t)}const Y1=/#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 Wh(s){return s.replace(Y1,Z1)}function Z1(s,e,t,n){let i="";for(let r=parseInt(e);r<parseInt(t);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function $h(s){let e=`precision ${s.precision} float;
|
|
precision ${s.precision} int;
|
|
precision ${s.precision} sampler2D;
|
|
precision ${s.precision} samplerCube;
|
|
precision ${s.precision} sampler3D;
|
|
precision ${s.precision} sampler2DArray;
|
|
precision ${s.precision} sampler2DShadow;
|
|
precision ${s.precision} samplerCubeShadow;
|
|
precision ${s.precision} sampler2DArrayShadow;
|
|
precision ${s.precision} isampler2D;
|
|
precision ${s.precision} isampler3D;
|
|
precision ${s.precision} isamplerCube;
|
|
precision ${s.precision} isampler2DArray;
|
|
precision ${s.precision} usampler2D;
|
|
precision ${s.precision} usampler3D;
|
|
precision ${s.precision} usamplerCube;
|
|
precision ${s.precision} usampler2DArray;
|
|
`;return s.precision==="highp"?e+=`
|
|
#define HIGH_PRECISION`:s.precision==="mediump"?e+=`
|
|
#define MEDIUM_PRECISION`:s.precision==="lowp"&&(e+=`
|
|
#define LOW_PRECISION`),e}function K1(s){let e="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===uu?e="SHADOWMAP_TYPE_PCF":s.shadowMapType===hu?e="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===zn&&(e="SHADOWMAP_TYPE_VSM"),e}function J1(s){let e="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case ui:case Ri:e="ENVMAP_TYPE_CUBE";break;case Js:e="ENVMAP_TYPE_CUBE_UV";break}return e}function j1(s){let e="ENVMAP_MODE_REFLECTION";if(s.envMap)switch(s.envMapMode){case Ri:e="ENVMAP_MODE_REFRACTION";break}return e}function Q1(s){let e="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case Kr:e="ENVMAP_BLENDING_MULTIPLY";break;case Xf:e="ENVMAP_BLENDING_MIX";break;case qf:e="ENVMAP_BLENDING_ADD";break}return e}function eA(s){const e=s.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function tA(s,e,t,n){const i=s.getContext(),r=t.defines;let o=t.vertexShader,a=t.fragmentShader;const l=K1(t),c=J1(t),u=j1(t),h=Q1(t),d=eA(t),f=H1(t),g=G1(r),_=i.createProgram();let p,m,y=t.glslVersion?"#version "+t.glslVersion+`
|
|
`:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(gr).join(`
|
|
`),p.length>0&&(p+=`
|
|
`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(gr).join(`
|
|
`),m.length>0&&(m+=`
|
|
`)):(p=[$h(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
`].filter(gr).join(`
|
|
`),m=[$h(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.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":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Wn?"#define TONE_MAPPING":"",t.toneMapping!==Wn?ot.tonemapping_pars_fragment:"",t.toneMapping!==Wn?V1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ot.colorspace_pars_fragment,z1("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
`].filter(gr).join(`
|
|
`)),o=Hc(o),o=Hh(o,t),o=Gh(o,t),a=Hc(a),a=Hh(a,t),a=Gh(a,t),o=Wh(o),a=Wh(a),t.isRawShaderMaterial!==!0&&(y=`#version 300 es
|
|
`,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
`)+`
|
|
`+p,m=["#define varying in",t.glslVersion===zc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===zc?"":"#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(`
|
|
`)+`
|
|
`+m);const v=y+p+o,x=y+m+a,E=zh(i,i.VERTEX_SHADER,v),S=zh(i,i.FRAGMENT_SHADER,x);i.attachShader(_,E),i.attachShader(_,S),t.index0AttributeName!==void 0?i.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function C(k){if(s.debug.checkShaderErrors){const V=i.getProgramInfoLog(_).trim(),G=i.getShaderInfoLog(E).trim(),X=i.getShaderInfoLog(S).trim();let ce=!0,Z=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(ce=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,_,E,S);else{const ae=Vh(i,E,"vertex"),z=Vh(i,S,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+`
|
|
|
|
Material Name: `+k.name+`
|
|
Material Type: `+k.type+`
|
|
|
|
Program Info Log: `+V+`
|
|
`+ae+`
|
|
`+z)}else V!==""?console.warn("THREE.WebGLProgram: Program Info Log:",V):(G===""||X==="")&&(Z=!1);Z&&(k.diagnostics={runnable:ce,programLog:V,vertexShader:{log:G,prefix:p},fragmentShader:{log:X,prefix:m}})}i.deleteShader(E),i.deleteShader(S),L=new _a(i,_),A=W1(i,_)}let L;this.getUniforms=function(){return L===void 0&&C(this),L};let A;this.getAttributes=function(){return A===void 0&&C(this),A};let b=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return b===!1&&(b=i.getProgramParameter(_,O1)),b},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=F1++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=E,this.fragmentShader=S,this}let nA=0;class iA{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new sA(e),t.set(e,n)),n}}class sA{constructor(e){this.id=nA++,this.code=e,this.usedTimes=0}}function rA(s,e,t,n,i,r,o){const a=new za,l=new iA,c=new Set,u=[],h=i.logarithmicDepthBuffer,d=i.vertexTextures;let f=i.precision;const g={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 _(A){return c.add(A),A===0?"uv":`uv${A}`}function p(A,b,k,V,G){const X=V.fog,ce=G.geometry,Z=A.isMeshStandardMaterial?V.environment:null,ae=(A.isMeshStandardMaterial?t:e).get(A.envMap||Z),z=ae&&ae.mapping===Js?ae.image.height:null,Se=g[A.type];A.precision!==null&&(f=i.getMaxPrecision(A.precision),f!==A.precision&&console.warn("THREE.WebGLProgram.getParameters:",A.precision,"not supported, using",f,"instead."));const we=ce.morphAttributes.position||ce.morphAttributes.normal||ce.morphAttributes.color,Ae=we!==void 0?we.length:0;let _e=0;ce.morphAttributes.position!==void 0&&(_e=1),ce.morphAttributes.normal!==void 0&&(_e=2),ce.morphAttributes.color!==void 0&&(_e=3);let De,F,U,I;if(Se){const ht=Rn[Se];De=ht.vertexShader,F=ht.fragmentShader}else De=A.vertexShader,F=A.fragmentShader,l.update(A),U=l.getVertexShaderID(A),I=l.getFragmentShaderID(A);const T=s.getRenderTarget(),se=G.isInstancedMesh===!0,fe=G.isBatchedMesh===!0,K=!!A.map,D=!!A.matcap,q=!!ae,J=!!A.aoMap,H=!!A.lightMap,W=!!A.bumpMap,ie=!!A.normalMap,he=!!A.displacementMap,B=!!A.emissiveMap,O=!!A.metalnessMap,R=!!A.roughnessMap,w=A.anisotropy>0,Q=A.clearcoat>0,me=A.dispersion>0,de=A.iridescence>0,ye=A.sheen>0,Be=A.transmission>0,Ce=w&&!!A.anisotropyMap,Ee=Q&&!!A.clearcoatMap,Je=Q&&!!A.clearcoatNormalMap,be=Q&&!!A.clearcoatRoughnessMap,Ne=de&&!!A.iridescenceMap,rt=de&&!!A.iridescenceThicknessMap,Ke=ye&&!!A.sheenColorMap,Re=ye&&!!A.sheenRoughnessMap,nt=!!A.specularMap,it=!!A.specularColorMap,At=!!A.specularIntensityMap,M=Be&&!!A.transmissionMap,le=Be&&!!A.thicknessMap,ne=!!A.gradientMap,ue=!!A.alphaMap,Me=A.alphaTest>0,We=!!A.alphaHash,tt=!!A.extensions;let Et=Wn;A.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(Et=s.toneMapping);const Dt={shaderID:Se,shaderType:A.type,shaderName:A.name,vertexShader:De,fragmentShader:F,defines:A.defines,customVertexShaderID:U,customFragmentShaderID:I,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:f,batching:fe,batchingColor:fe&&G._colorsTexture!==null,instancing:se,instancingColor:se&&G.instanceColor!==null,instancingMorph:se&&G.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:T===null?s.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:fi,alphaToCoverage:!!A.alphaToCoverage,map:K,matcap:D,envMap:q,envMapMode:q&&ae.mapping,envMapCubeUVHeight:z,aoMap:J,lightMap:H,bumpMap:W,normalMap:ie,displacementMap:d&&he,emissiveMap:B,normalMapObjectSpace:ie&&A.normalMapType===mp,normalMapTangentSpace:ie&&A.normalMapType===Ni,metalnessMap:O,roughnessMap:R,anisotropy:w,anisotropyMap:Ce,clearcoat:Q,clearcoatMap:Ee,clearcoatNormalMap:Je,clearcoatRoughnessMap:be,dispersion:me,iridescence:de,iridescenceMap:Ne,iridescenceThicknessMap:rt,sheen:ye,sheenColorMap:Ke,sheenRoughnessMap:Re,specularMap:nt,specularColorMap:it,specularIntensityMap:At,transmission:Be,transmissionMap:M,thicknessMap:le,gradientMap:ne,opaque:A.transparent===!1&&A.blending===os&&A.alphaToCoverage===!1,alphaMap:ue,alphaTest:Me,alphaHash:We,combine:A.combine,mapUv:K&&_(A.map.channel),aoMapUv:J&&_(A.aoMap.channel),lightMapUv:H&&_(A.lightMap.channel),bumpMapUv:W&&_(A.bumpMap.channel),normalMapUv:ie&&_(A.normalMap.channel),displacementMapUv:he&&_(A.displacementMap.channel),emissiveMapUv:B&&_(A.emissiveMap.channel),metalnessMapUv:O&&_(A.metalnessMap.channel),roughnessMapUv:R&&_(A.roughnessMap.channel),anisotropyMapUv:Ce&&_(A.anisotropyMap.channel),clearcoatMapUv:Ee&&_(A.clearcoatMap.channel),clearcoatNormalMapUv:Je&&_(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:be&&_(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Ne&&_(A.iridescenceMap.channel),iridescenceThicknessMapUv:rt&&_(A.iridescenceThicknessMap.channel),sheenColorMapUv:Ke&&_(A.sheenColorMap.channel),sheenRoughnessMapUv:Re&&_(A.sheenRoughnessMap.channel),specularMapUv:nt&&_(A.specularMap.channel),specularColorMapUv:it&&_(A.specularColorMap.channel),specularIntensityMapUv:At&&_(A.specularIntensityMap.channel),transmissionMapUv:M&&_(A.transmissionMap.channel),thicknessMapUv:le&&_(A.thicknessMap.channel),alphaMapUv:ue&&_(A.alphaMap.channel),vertexTangents:!!ce.attributes.tangent&&(ie||w),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!ce.attributes.color&&ce.attributes.color.itemSize===4,pointsUvs:G.isPoints===!0&&!!ce.attributes.uv&&(K||ue),fog:!!X,useFog:A.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:A.flatShading===!0,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:G.isSkinnedMesh===!0,morphTargets:ce.morphAttributes.position!==void 0,morphNormals:ce.morphAttributes.normal!==void 0,morphColors:ce.morphAttributes.color!==void 0,morphTargetsCount:Ae,morphTextureStride:_e,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:s.shadowMap.enabled&&k.length>0,shadowMapType:s.shadowMap.type,toneMapping:Et,decodeVideoTexture:K&&A.map.isVideoTexture===!0&&dt.getTransfer(A.map.colorSpace)===Mt,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===In,flipSided:A.side===an,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:tt&&A.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:tt&&A.extensions.multiDraw===!0&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return Dt.vertexUv1s=c.has(1),Dt.vertexUv2s=c.has(2),Dt.vertexUv3s=c.has(3),c.clear(),Dt}function m(A){const b=[];if(A.shaderID?b.push(A.shaderID):(b.push(A.customVertexShaderID),b.push(A.customFragmentShaderID)),A.defines!==void 0)for(const k in A.defines)b.push(k),b.push(A.defines[k]);return A.isRawShaderMaterial===!1&&(y(b,A),v(b,A),b.push(s.outputColorSpace)),b.push(A.customProgramCacheKey),b.join()}function y(A,b){A.push(b.precision),A.push(b.outputColorSpace),A.push(b.envMapMode),A.push(b.envMapCubeUVHeight),A.push(b.mapUv),A.push(b.alphaMapUv),A.push(b.lightMapUv),A.push(b.aoMapUv),A.push(b.bumpMapUv),A.push(b.normalMapUv),A.push(b.displacementMapUv),A.push(b.emissiveMapUv),A.push(b.metalnessMapUv),A.push(b.roughnessMapUv),A.push(b.anisotropyMapUv),A.push(b.clearcoatMapUv),A.push(b.clearcoatNormalMapUv),A.push(b.clearcoatRoughnessMapUv),A.push(b.iridescenceMapUv),A.push(b.iridescenceThicknessMapUv),A.push(b.sheenColorMapUv),A.push(b.sheenRoughnessMapUv),A.push(b.specularMapUv),A.push(b.specularColorMapUv),A.push(b.specularIntensityMapUv),A.push(b.transmissionMapUv),A.push(b.thicknessMapUv),A.push(b.combine),A.push(b.fogExp2),A.push(b.sizeAttenuation),A.push(b.morphTargetsCount),A.push(b.morphAttributeCount),A.push(b.numDirLights),A.push(b.numPointLights),A.push(b.numSpotLights),A.push(b.numSpotLightMaps),A.push(b.numHemiLights),A.push(b.numRectAreaLights),A.push(b.numDirLightShadows),A.push(b.numPointLightShadows),A.push(b.numSpotLightShadows),A.push(b.numSpotLightShadowsWithMaps),A.push(b.numLightProbes),A.push(b.shadowMapType),A.push(b.toneMapping),A.push(b.numClippingPlanes),A.push(b.numClipIntersection),A.push(b.depthPacking)}function v(A,b){a.disableAll(),b.supportsVertexTextures&&a.enable(0),b.instancing&&a.enable(1),b.instancingColor&&a.enable(2),b.instancingMorph&&a.enable(3),b.matcap&&a.enable(4),b.envMap&&a.enable(5),b.normalMapObjectSpace&&a.enable(6),b.normalMapTangentSpace&&a.enable(7),b.clearcoat&&a.enable(8),b.iridescence&&a.enable(9),b.alphaTest&&a.enable(10),b.vertexColors&&a.enable(11),b.vertexAlphas&&a.enable(12),b.vertexUv1s&&a.enable(13),b.vertexUv2s&&a.enable(14),b.vertexUv3s&&a.enable(15),b.vertexTangents&&a.enable(16),b.anisotropy&&a.enable(17),b.alphaHash&&a.enable(18),b.batching&&a.enable(19),b.dispersion&&a.enable(20),b.batchingColor&&a.enable(21),A.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.skinning&&a.enable(4),b.morphTargets&&a.enable(5),b.morphNormals&&a.enable(6),b.morphColors&&a.enable(7),b.premultipliedAlpha&&a.enable(8),b.shadowMapEnabled&&a.enable(9),b.doubleSided&&a.enable(10),b.flipSided&&a.enable(11),b.useDepthPacking&&a.enable(12),b.dithering&&a.enable(13),b.transmission&&a.enable(14),b.sheen&&a.enable(15),b.opaque&&a.enable(16),b.pointsUvs&&a.enable(17),b.decodeVideoTexture&&a.enable(18),b.alphaToCoverage&&a.enable(19),A.push(a.mask)}function x(A){const b=g[A.type];let k;if(b){const V=Rn[b];k=Pp.clone(V.uniforms)}else k=A.uniforms;return k}function E(A,b){let k;for(let V=0,G=u.length;V<G;V++){const X=u[V];if(X.cacheKey===b){k=X,++k.usedTimes;break}}return k===void 0&&(k=new tA(s,b,A,r),u.push(k)),k}function S(A){if(--A.usedTimes===0){const b=u.indexOf(A);u[b]=u[u.length-1],u.pop(),A.destroy()}}function C(A){l.remove(A)}function L(){l.dispose()}return{getParameters:p,getProgramCacheKey:m,getUniforms:x,acquireProgram:E,releaseProgram:S,releaseShaderCache:C,programs:u,dispose:L}}function oA(){let s=new WeakMap;function e(r){let o=s.get(r);return o===void 0&&(o={},s.set(r,o)),o}function t(r){s.delete(r)}function n(r,o,a){s.get(r)[o]=a}function i(){s=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function aA(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.z!==e.z?s.z-e.z:s.id-e.id}function Xh(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function qh(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function o(h,d,f,g,_,p){let m=s[e];return m===void 0?(m={id:h.id,object:h,geometry:d,material:f,groupOrder:g,renderOrder:h.renderOrder,z:_,group:p},s[e]=m):(m.id=h.id,m.object=h,m.geometry=d,m.material=f,m.groupOrder=g,m.renderOrder=h.renderOrder,m.z=_,m.group=p),e++,m}function a(h,d,f,g,_,p){const m=o(h,d,f,g,_,p);f.transmission>0?n.push(m):f.transparent===!0?i.push(m):t.push(m)}function l(h,d,f,g,_,p){const m=o(h,d,f,g,_,p);f.transmission>0?n.unshift(m):f.transparent===!0?i.unshift(m):t.unshift(m)}function c(h,d){t.length>1&&t.sort(h||aA),n.length>1&&n.sort(d||Xh),i.length>1&&i.sort(d||Xh)}function u(){for(let h=e,d=s.length;h<d;h++){const f=s[h];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:a,unshift:l,finish:u,sort:c}}function lA(){let s=new WeakMap;function e(n,i){const r=s.get(n);let o;return r===void 0?(o=new qh,s.set(n,[o])):i>=r.length?(o=new qh,r.push(o)):o=r[i],o}function t(){s=new WeakMap}return{get:e,dispose:t}}function cA(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new N,color:new Ie};break;case"SpotLight":t={position:new N,direction:new N,color:new Ie,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new Ie,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new Ie,groundColor:new Ie};break;case"RectAreaLight":t={color:new Ie,position:new N,halfWidth:new N,halfHeight:new N};break}return s[e.id]=t,t}}}function uA(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new te,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let hA=0;function dA(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function fA(s){const e=new cA,t=uA(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new N);const i=new N,r=new Ze,o=new Ze;function a(c){let u=0,h=0,d=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,g=0,_=0,p=0,m=0,y=0,v=0,x=0,E=0,S=0,C=0;c.sort(dA);for(let A=0,b=c.length;A<b;A++){const k=c[A],V=k.color,G=k.intensity,X=k.distance,ce=k.shadow&&k.shadow.map?k.shadow.map.texture:null;if(k.isAmbientLight)u+=V.r*G,h+=V.g*G,d+=V.b*G;else if(k.isLightProbe){for(let Z=0;Z<9;Z++)n.probe[Z].addScaledVector(k.sh.coefficients[Z],G);C++}else if(k.isDirectionalLight){const Z=e.get(k);if(Z.color.copy(k.color).multiplyScalar(k.intensity),k.castShadow){const ae=k.shadow,z=t.get(k);z.shadowBias=ae.bias,z.shadowNormalBias=ae.normalBias,z.shadowRadius=ae.radius,z.shadowMapSize=ae.mapSize,n.directionalShadow[f]=z,n.directionalShadowMap[f]=ce,n.directionalShadowMatrix[f]=k.shadow.matrix,y++}n.directional[f]=Z,f++}else if(k.isSpotLight){const Z=e.get(k);Z.position.setFromMatrixPosition(k.matrixWorld),Z.color.copy(V).multiplyScalar(G),Z.distance=X,Z.coneCos=Math.cos(k.angle),Z.penumbraCos=Math.cos(k.angle*(1-k.penumbra)),Z.decay=k.decay,n.spot[_]=Z;const ae=k.shadow;if(k.map&&(n.spotLightMap[E]=k.map,E++,ae.updateMatrices(k),k.castShadow&&S++),n.spotLightMatrix[_]=ae.matrix,k.castShadow){const z=t.get(k);z.shadowBias=ae.bias,z.shadowNormalBias=ae.normalBias,z.shadowRadius=ae.radius,z.shadowMapSize=ae.mapSize,n.spotShadow[_]=z,n.spotShadowMap[_]=ce,x++}_++}else if(k.isRectAreaLight){const Z=e.get(k);Z.color.copy(V).multiplyScalar(G),Z.halfWidth.set(k.width*.5,0,0),Z.halfHeight.set(0,k.height*.5,0),n.rectArea[p]=Z,p++}else if(k.isPointLight){const Z=e.get(k);if(Z.color.copy(k.color).multiplyScalar(k.intensity),Z.distance=k.distance,Z.decay=k.decay,k.castShadow){const ae=k.shadow,z=t.get(k);z.shadowBias=ae.bias,z.shadowNormalBias=ae.normalBias,z.shadowRadius=ae.radius,z.shadowMapSize=ae.mapSize,z.shadowCameraNear=ae.camera.near,z.shadowCameraFar=ae.camera.far,n.pointShadow[g]=z,n.pointShadowMap[g]=ce,n.pointShadowMatrix[g]=k.shadow.matrix,v++}n.point[g]=Z,g++}else if(k.isHemisphereLight){const Z=e.get(k);Z.skyColor.copy(k.color).multiplyScalar(G),Z.groundColor.copy(k.groundColor).multiplyScalar(G),n.hemi[m]=Z,m++}}p>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Pe.LTC_FLOAT_1,n.rectAreaLTC2=Pe.LTC_FLOAT_2):(n.rectAreaLTC1=Pe.LTC_HALF_1,n.rectAreaLTC2=Pe.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=d;const L=n.hash;(L.directionalLength!==f||L.pointLength!==g||L.spotLength!==_||L.rectAreaLength!==p||L.hemiLength!==m||L.numDirectionalShadows!==y||L.numPointShadows!==v||L.numSpotShadows!==x||L.numSpotMaps!==E||L.numLightProbes!==C)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=p,n.point.length=g,n.hemi.length=m,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=v,n.pointShadowMap.length=v,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=v,n.spotLightMatrix.length=x+E-S,n.spotLightMap.length=E,n.numSpotLightShadowsWithMaps=S,n.numLightProbes=C,L.directionalLength=f,L.pointLength=g,L.spotLength=_,L.rectAreaLength=p,L.hemiLength=m,L.numDirectionalShadows=y,L.numPointShadows=v,L.numSpotShadows=x,L.numSpotMaps=E,L.numLightProbes=C,n.version=hA++)}function l(c,u){let h=0,d=0,f=0,g=0,_=0;const p=u.matrixWorldInverse;for(let m=0,y=c.length;m<y;m++){const v=c[m];if(v.isDirectionalLight){const x=n.directional[h];x.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(p),h++}else if(v.isSpotLight){const x=n.spot[f];x.position.setFromMatrixPosition(v.matrixWorld),x.position.applyMatrix4(p),x.direction.setFromMatrixPosition(v.matrixWorld),i.setFromMatrixPosition(v.target.matrixWorld),x.direction.sub(i),x.direction.transformDirection(p),f++}else if(v.isRectAreaLight){const x=n.rectArea[g];x.position.setFromMatrixPosition(v.matrixWorld),x.position.applyMatrix4(p),o.identity(),r.copy(v.matrixWorld),r.premultiply(p),o.extractRotation(r),x.halfWidth.set(v.width*.5,0,0),x.halfHeight.set(0,v.height*.5,0),x.halfWidth.applyMatrix4(o),x.halfHeight.applyMatrix4(o),g++}else if(v.isPointLight){const x=n.point[d];x.position.setFromMatrixPosition(v.matrixWorld),x.position.applyMatrix4(p),d++}else if(v.isHemisphereLight){const x=n.hemi[_];x.direction.setFromMatrixPosition(v.matrixWorld),x.direction.transformDirection(p),_++}}}return{setup:a,setupView:l,state:n}}function Yh(s){const e=new fA(s),t=[],n=[];function i(u){c.camera=u,t.length=0,n.length=0}function r(u){t.push(u)}function o(u){n.push(u)}function a(){e.setup(t)}function l(u){e.setupView(t,u)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:a,setupLightsView:l,pushLight:r,pushShadow:o}}function pA(s){let e=new WeakMap;function t(i,r=0){const o=e.get(i);let a;return o===void 0?(a=new Yh(s),e.set(i,[a])):r>=o.length?(a=new Yh(s),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}class Ru extends en{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=fp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Iu extends en{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const mA=`void main() {
|
|
gl_Position = vec4( position, 1.0 );
|
|
}`,gA=`uniform sampler2D shadow_pass;
|
|
uniform vec2 resolution;
|
|
uniform float radius;
|
|
#include <packing>
|
|
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 _A(s,e,t){let n=new to;const i=new te,r=new te,o=new _t,a=new Ru({depthPacking:pp}),l=new Iu,c={},u=t.maxTextureSize,h={[ci]:an,[an]:ci,[In]:In},d=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new te},radius:{value:4}},vertexShader:mA,fragmentShader:gA}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new at;g.setAttribute("position",new mt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Nt(g,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=uu;let m=this.type;this.render=function(S,C,L){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||S.length===0)return;const A=s.getRenderTarget(),b=s.getActiveCubeFace(),k=s.getActiveMipmapLevel(),V=s.state;V.setBlending(ai),V.buffers.color.setClear(1,1,1,1),V.buffers.depth.setTest(!0),V.setScissorTest(!1);const G=m!==zn&&this.type===zn,X=m===zn&&this.type!==zn;for(let ce=0,Z=S.length;ce<Z;ce++){const ae=S[ce],z=ae.shadow;if(z===void 0){console.warn("THREE.WebGLShadowMap:",ae,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;i.copy(z.mapSize);const Se=z.getFrameExtents();if(i.multiply(Se),r.copy(z.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(r.x=Math.floor(u/Se.x),i.x=r.x*Se.x,z.mapSize.x=r.x),i.y>u&&(r.y=Math.floor(u/Se.y),i.y=r.y*Se.y,z.mapSize.y=r.y)),z.map===null||G===!0||X===!0){const Ae=this.type!==zn?{minFilter:Wt,magFilter:Wt}:{};z.map!==null&&z.map.dispose(),z.map=new Un(i.x,i.y,Ae),z.map.texture.name=ae.name+".shadowMap",z.camera.updateProjectionMatrix()}s.setRenderTarget(z.map),s.clear();const we=z.getViewportCount();for(let Ae=0;Ae<we;Ae++){const _e=z.getViewport(Ae);o.set(r.x*_e.x,r.y*_e.y,r.x*_e.z,r.y*_e.w),V.viewport(o),z.updateMatrices(ae,Ae),n=z.getFrustum(),x(C,L,z.camera,ae,this.type)}z.isPointLightShadow!==!0&&this.type===zn&&y(z,L),z.needsUpdate=!1}m=this.type,p.needsUpdate=!1,s.setRenderTarget(A,b,k)};function y(S,C){const L=e.update(_);d.defines.VSM_SAMPLES!==S.blurSamples&&(d.defines.VSM_SAMPLES=S.blurSamples,f.defines.VSM_SAMPLES=S.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new Un(i.x,i.y)),d.uniforms.shadow_pass.value=S.map.texture,d.uniforms.resolution.value=S.mapSize,d.uniforms.radius.value=S.radius,s.setRenderTarget(S.mapPass),s.clear(),s.renderBufferDirect(C,null,L,d,_,null),f.uniforms.shadow_pass.value=S.mapPass.texture,f.uniforms.resolution.value=S.mapSize,f.uniforms.radius.value=S.radius,s.setRenderTarget(S.map),s.clear(),s.renderBufferDirect(C,null,L,f,_,null)}function v(S,C,L,A){let b=null;const k=L.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(k!==void 0)b=k;else if(b=L.isPointLight===!0?l:a,s.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const V=b.uuid,G=C.uuid;let X=c[V];X===void 0&&(X={},c[V]=X);let ce=X[G];ce===void 0&&(ce=b.clone(),X[G]=ce,C.addEventListener("dispose",E)),b=ce}if(b.visible=C.visible,b.wireframe=C.wireframe,A===zn?b.side=C.shadowSide!==null?C.shadowSide:C.side:b.side=C.shadowSide!==null?C.shadowSide:h[C.side],b.alphaMap=C.alphaMap,b.alphaTest=C.alphaTest,b.map=C.map,b.clipShadows=C.clipShadows,b.clippingPlanes=C.clippingPlanes,b.clipIntersection=C.clipIntersection,b.displacementMap=C.displacementMap,b.displacementScale=C.displacementScale,b.displacementBias=C.displacementBias,b.wireframeLinewidth=C.wireframeLinewidth,b.linewidth=C.linewidth,L.isPointLight===!0&&b.isMeshDistanceMaterial===!0){const V=s.properties.get(b);V.light=L}return b}function x(S,C,L,A,b){if(S.visible===!1)return;if(S.layers.test(C.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&b===zn)&&(!S.frustumCulled||n.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(L.matrixWorldInverse,S.matrixWorld);const G=e.update(S),X=S.material;if(Array.isArray(X)){const ce=G.groups;for(let Z=0,ae=ce.length;Z<ae;Z++){const z=ce[Z],Se=X[z.materialIndex];if(Se&&Se.visible){const we=v(S,Se,A,b);S.onBeforeShadow(s,S,C,L,G,we,z),s.renderBufferDirect(L,null,G,we,S,z),S.onAfterShadow(s,S,C,L,G,we,z)}}}else if(X.visible){const ce=v(S,X,A,b);S.onBeforeShadow(s,S,C,L,G,ce,null),s.renderBufferDirect(L,null,G,ce,S,null),S.onAfterShadow(s,S,C,L,G,ce,null)}}const V=S.children;for(let G=0,X=V.length;G<X;G++)x(V[G],C,L,A,b)}function E(S){S.target.removeEventListener("dispose",E);for(const L in c){const A=c[L],b=S.target.uuid;b in A&&(A[b].dispose(),delete A[b])}}}function vA(s){function e(){let M=!1;const le=new _t;let ne=null;const ue=new _t(0,0,0,0);return{setMask:function(Me){ne!==Me&&!M&&(s.colorMask(Me,Me,Me,Me),ne=Me)},setLocked:function(Me){M=Me},setClear:function(Me,We,tt,Et,Dt){Dt===!0&&(Me*=Et,We*=Et,tt*=Et),le.set(Me,We,tt,Et),ue.equals(le)===!1&&(s.clearColor(Me,We,tt,Et),ue.copy(le))},reset:function(){M=!1,ne=null,ue.set(-1,0,0,0)}}}function t(){let M=!1,le=null,ne=null,ue=null;return{setTest:function(Me){Me?I(s.DEPTH_TEST):T(s.DEPTH_TEST)},setMask:function(Me){le!==Me&&!M&&(s.depthMask(Me),le=Me)},setFunc:function(Me){if(ne!==Me){switch(Me){case Bf:s.depthFunc(s.NEVER);break;case zf:s.depthFunc(s.ALWAYS);break;case Vf:s.depthFunc(s.LESS);break;case wr:s.depthFunc(s.LEQUAL);break;case Hf:s.depthFunc(s.EQUAL);break;case Gf:s.depthFunc(s.GEQUAL);break;case Wf:s.depthFunc(s.GREATER);break;case $f:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}ne=Me}},setLocked:function(Me){M=Me},setClear:function(Me){ue!==Me&&(s.clearDepth(Me),ue=Me)},reset:function(){M=!1,le=null,ne=null,ue=null}}}function n(){let M=!1,le=null,ne=null,ue=null,Me=null,We=null,tt=null,Et=null,Dt=null;return{setTest:function(ht){M||(ht?I(s.STENCIL_TEST):T(s.STENCIL_TEST))},setMask:function(ht){le!==ht&&!M&&(s.stencilMask(ht),le=ht)},setFunc:function(ht,Ut,Ot){(ne!==ht||ue!==Ut||Me!==Ot)&&(s.stencilFunc(ht,Ut,Ot),ne=ht,ue=Ut,Me=Ot)},setOp:function(ht,Ut,Ot){(We!==ht||tt!==Ut||Et!==Ot)&&(s.stencilOp(ht,Ut,Ot),We=ht,tt=Ut,Et=Ot)},setLocked:function(ht){M=ht},setClear:function(ht){Dt!==ht&&(s.clearStencil(ht),Dt=ht)},reset:function(){M=!1,le=null,ne=null,ue=null,Me=null,We=null,tt=null,Et=null,Dt=null}}}const i=new e,r=new t,o=new n,a=new WeakMap,l=new WeakMap;let c={},u={},h=new WeakMap,d=[],f=null,g=!1,_=null,p=null,m=null,y=null,v=null,x=null,E=null,S=new Ie(0,0,0),C=0,L=!1,A=null,b=null,k=null,V=null,G=null;const X=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let ce=!1,Z=0;const ae=s.getParameter(s.VERSION);ae.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(ae)[1]),ce=Z>=1):ae.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(ae)[1]),ce=Z>=2);let z=null,Se={};const we=s.getParameter(s.SCISSOR_BOX),Ae=s.getParameter(s.VIEWPORT),_e=new _t().fromArray(we),De=new _t().fromArray(Ae);function F(M,le,ne,ue){const Me=new Uint8Array(4),We=s.createTexture();s.bindTexture(M,We),s.texParameteri(M,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(M,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let tt=0;tt<ne;tt++)M===s.TEXTURE_3D||M===s.TEXTURE_2D_ARRAY?s.texImage3D(le,0,s.RGBA,1,1,ue,0,s.RGBA,s.UNSIGNED_BYTE,Me):s.texImage2D(le+tt,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,Me);return We}const U={};U[s.TEXTURE_2D]=F(s.TEXTURE_2D,s.TEXTURE_2D,1),U[s.TEXTURE_CUBE_MAP]=F(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),U[s.TEXTURE_2D_ARRAY]=F(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),U[s.TEXTURE_3D]=F(s.TEXTURE_3D,s.TEXTURE_3D,1,1),i.setClear(0,0,0,1),r.setClear(1),o.setClear(0),I(s.DEPTH_TEST),r.setFunc(wr),W(!1),ie(cc),I(s.CULL_FACE),J(ai);function I(M){c[M]!==!0&&(s.enable(M),c[M]=!0)}function T(M){c[M]!==!1&&(s.disable(M),c[M]=!1)}function se(M,le){return u[M]!==le?(s.bindFramebuffer(M,le),u[M]=le,M===s.DRAW_FRAMEBUFFER&&(u[s.FRAMEBUFFER]=le),M===s.FRAMEBUFFER&&(u[s.DRAW_FRAMEBUFFER]=le),!0):!1}function fe(M,le){let ne=d,ue=!1;if(M){ne=h.get(le),ne===void 0&&(ne=[],h.set(le,ne));const Me=M.textures;if(ne.length!==Me.length||ne[0]!==s.COLOR_ATTACHMENT0){for(let We=0,tt=Me.length;We<tt;We++)ne[We]=s.COLOR_ATTACHMENT0+We;ne.length=Me.length,ue=!0}}else ne[0]!==s.BACK&&(ne[0]=s.BACK,ue=!0);ue&&s.drawBuffers(ne)}function K(M){return f!==M?(s.useProgram(M),f=M,!0):!1}const D={[Ti]:s.FUNC_ADD,[bf]:s.FUNC_SUBTRACT,[Sf]:s.FUNC_REVERSE_SUBTRACT};D[wf]=s.MIN,D[Af]=s.MAX;const q={[Ef]:s.ZERO,[Tf]:s.ONE,[Cf]:s.SRC_COLOR,[wa]:s.SRC_ALPHA,[Df]:s.SRC_ALPHA_SATURATE,[Lf]:s.DST_COLOR,[Rf]:s.DST_ALPHA,[Pf]:s.ONE_MINUS_SRC_COLOR,[Aa]:s.ONE_MINUS_SRC_ALPHA,[Nf]:s.ONE_MINUS_DST_COLOR,[If]:s.ONE_MINUS_DST_ALPHA,[Uf]:s.CONSTANT_COLOR,[Of]:s.ONE_MINUS_CONSTANT_COLOR,[Ff]:s.CONSTANT_ALPHA,[kf]:s.ONE_MINUS_CONSTANT_ALPHA};function J(M,le,ne,ue,Me,We,tt,Et,Dt,ht){if(M===ai){g===!0&&(T(s.BLEND),g=!1);return}if(g===!1&&(I(s.BLEND),g=!0),M!==Mf){if(M!==_||ht!==L){if((p!==Ti||v!==Ti)&&(s.blendEquation(s.FUNC_ADD),p=Ti,v=Ti),ht)switch(M){case os:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Sa:s.blendFunc(s.ONE,s.ONE);break;case uc:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case hc:s.blendFuncSeparate(s.ZERO,s.SRC_COLOR,s.ZERO,s.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",M);break}else switch(M){case os:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Sa:s.blendFunc(s.SRC_ALPHA,s.ONE);break;case uc:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case hc:s.blendFunc(s.ZERO,s.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",M);break}m=null,y=null,x=null,E=null,S.set(0,0,0),C=0,_=M,L=ht}return}Me=Me||le,We=We||ne,tt=tt||ue,(le!==p||Me!==v)&&(s.blendEquationSeparate(D[le],D[Me]),p=le,v=Me),(ne!==m||ue!==y||We!==x||tt!==E)&&(s.blendFuncSeparate(q[ne],q[ue],q[We],q[tt]),m=ne,y=ue,x=We,E=tt),(Et.equals(S)===!1||Dt!==C)&&(s.blendColor(Et.r,Et.g,Et.b,Dt),S.copy(Et),C=Dt),_=M,L=!1}function H(M,le){M.side===In?T(s.CULL_FACE):I(s.CULL_FACE);let ne=M.side===an;le&&(ne=!ne),W(ne),M.blending===os&&M.transparent===!1?J(ai):J(M.blending,M.blendEquation,M.blendSrc,M.blendDst,M.blendEquationAlpha,M.blendSrcAlpha,M.blendDstAlpha,M.blendColor,M.blendAlpha,M.premultipliedAlpha),r.setFunc(M.depthFunc),r.setTest(M.depthTest),r.setMask(M.depthWrite),i.setMask(M.colorWrite);const ue=M.stencilWrite;o.setTest(ue),ue&&(o.setMask(M.stencilWriteMask),o.setFunc(M.stencilFunc,M.stencilRef,M.stencilFuncMask),o.setOp(M.stencilFail,M.stencilZFail,M.stencilZPass)),B(M.polygonOffset,M.polygonOffsetFactor,M.polygonOffsetUnits),M.alphaToCoverage===!0?I(s.SAMPLE_ALPHA_TO_COVERAGE):T(s.SAMPLE_ALPHA_TO_COVERAGE)}function W(M){A!==M&&(M?s.frontFace(s.CW):s.frontFace(s.CCW),A=M)}function ie(M){M!==yf?(I(s.CULL_FACE),M!==b&&(M===cc?s.cullFace(s.BACK):M===xf?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):T(s.CULL_FACE),b=M}function he(M){M!==k&&(ce&&s.lineWidth(M),k=M)}function B(M,le,ne){M?(I(s.POLYGON_OFFSET_FILL),(V!==le||G!==ne)&&(s.polygonOffset(le,ne),V=le,G=ne)):T(s.POLYGON_OFFSET_FILL)}function O(M){M?I(s.SCISSOR_TEST):T(s.SCISSOR_TEST)}function R(M){M===void 0&&(M=s.TEXTURE0+X-1),z!==M&&(s.activeTexture(M),z=M)}function w(M,le,ne){ne===void 0&&(z===null?ne=s.TEXTURE0+X-1:ne=z);let ue=Se[ne];ue===void 0&&(ue={type:void 0,texture:void 0},Se[ne]=ue),(ue.type!==M||ue.texture!==le)&&(z!==ne&&(s.activeTexture(ne),z=ne),s.bindTexture(M,le||U[M]),ue.type=M,ue.texture=le)}function Q(){const M=Se[z];M!==void 0&&M.type!==void 0&&(s.bindTexture(M.type,null),M.type=void 0,M.texture=void 0)}function me(){try{s.compressedTexImage2D.apply(s,arguments)}catch(M){console.error("THREE.WebGLState:",M)}}function de(){try{s.compressedTexImage3D.apply(s,arguments)}catch(M){console.error("THREE.WebGLState:",M)}}function ye(){try{s.texSubImage2D.apply(s,arguments)}catch(M){console.error("THREE.WebGLState:",M)}}function Be(){try{s.texSubImage3D.apply(s,arguments)}catch(M){console.error("THREE.WebGLState:",M)}}function Ce(){try{s.compressedTexSubImage2D.apply(s,arguments)}catch(M){console.error("THREE.WebGLState:",M)}}function Ee(){try{s.compressedTexSubImage3D.apply(s,arguments)}catch(M){console.error("THREE.WebGLState:",M)}}function Je(){try{s.texStorage2D.apply(s,arguments)}catch(M){console.error("THREE.WebGLState:",M)}}function be(){try{s.texStorage3D.apply(s,arguments)}catch(M){console.error("THREE.WebGLState:",M)}}function Ne(){try{s.texImage2D.apply(s,arguments)}catch(M){console.error("THREE.WebGLState:",M)}}function rt(){try{s.texImage3D.apply(s,arguments)}catch(M){console.error("THREE.WebGLState:",M)}}function Ke(M){_e.equals(M)===!1&&(s.scissor(M.x,M.y,M.z,M.w),_e.copy(M))}function Re(M){De.equals(M)===!1&&(s.viewport(M.x,M.y,M.z,M.w),De.copy(M))}function nt(M,le){let ne=l.get(le);ne===void 0&&(ne=new WeakMap,l.set(le,ne));let ue=ne.get(M);ue===void 0&&(ue=s.getUniformBlockIndex(le,M.name),ne.set(M,ue))}function it(M,le){const ue=l.get(le).get(M);a.get(le)!==ue&&(s.uniformBlockBinding(le,ue,M.__bindingPointIndex),a.set(le,ue))}function At(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),c={},z=null,Se={},u={},h=new WeakMap,d=[],f=null,g=!1,_=null,p=null,m=null,y=null,v=null,x=null,E=null,S=new Ie(0,0,0),C=0,L=!1,A=null,b=null,k=null,V=null,G=null,_e.set(0,0,s.canvas.width,s.canvas.height),De.set(0,0,s.canvas.width,s.canvas.height),i.reset(),r.reset(),o.reset()}return{buffers:{color:i,depth:r,stencil:o},enable:I,disable:T,bindFramebuffer:se,drawBuffers:fe,useProgram:K,setBlending:J,setMaterial:H,setFlipSided:W,setCullFace:ie,setLineWidth:he,setPolygonOffset:B,setScissorTest:O,activeTexture:R,bindTexture:w,unbindTexture:Q,compressedTexImage2D:me,compressedTexImage3D:de,texImage2D:Ne,texImage3D:rt,updateUBOMapping:nt,uniformBlockBinding:it,texStorage2D:Je,texStorage3D:be,texSubImage2D:ye,texSubImage3D:Be,compressedTexSubImage2D:Ce,compressedTexSubImage3D:Ee,scissor:Ke,viewport:Re,reset:At}}function yA(s,e,t,n,i,r,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new te,u=new WeakMap;let h;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(R,w){return f?new OffscreenCanvas(R,w):Fr("canvas")}function _(R,w,Q){let me=1;const de=O(R);if((de.width>Q||de.height>Q)&&(me=Q/Math.max(de.width,de.height)),me<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const ye=Math.floor(me*de.width),Be=Math.floor(me*de.height);h===void 0&&(h=g(ye,Be));const Ce=w?g(ye,Be):h;return Ce.width=ye,Ce.height=Be,Ce.getContext("2d").drawImage(R,0,0,ye,Be),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+de.width+"x"+de.height+") to ("+ye+"x"+Be+")."),Ce}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+de.width+"x"+de.height+")."),R;return R}function p(R){return R.generateMipmaps&&R.minFilter!==Wt&&R.minFilter!==Bt}function m(R){s.generateMipmap(R)}function y(R,w,Q,me,de=!1){if(R!==null){if(s[R]!==void 0)return s[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let ye=w;if(w===s.RED&&(Q===s.FLOAT&&(ye=s.R32F),Q===s.HALF_FLOAT&&(ye=s.R16F),Q===s.UNSIGNED_BYTE&&(ye=s.R8)),w===s.RED_INTEGER&&(Q===s.UNSIGNED_BYTE&&(ye=s.R8UI),Q===s.UNSIGNED_SHORT&&(ye=s.R16UI),Q===s.UNSIGNED_INT&&(ye=s.R32UI),Q===s.BYTE&&(ye=s.R8I),Q===s.SHORT&&(ye=s.R16I),Q===s.INT&&(ye=s.R32I)),w===s.RG&&(Q===s.FLOAT&&(ye=s.RG32F),Q===s.HALF_FLOAT&&(ye=s.RG16F),Q===s.UNSIGNED_BYTE&&(ye=s.RG8)),w===s.RG_INTEGER&&(Q===s.UNSIGNED_BYTE&&(ye=s.RG8UI),Q===s.UNSIGNED_SHORT&&(ye=s.RG16UI),Q===s.UNSIGNED_INT&&(ye=s.RG32UI),Q===s.BYTE&&(ye=s.RG8I),Q===s.SHORT&&(ye=s.RG16I),Q===s.INT&&(ye=s.RG32I)),w===s.RGB&&Q===s.UNSIGNED_INT_5_9_9_9_REV&&(ye=s.RGB9_E5),w===s.RGBA){const Be=de?Lr:dt.getTransfer(me);Q===s.FLOAT&&(ye=s.RGBA32F),Q===s.HALF_FLOAT&&(ye=s.RGBA16F),Q===s.UNSIGNED_BYTE&&(ye=Be===Mt?s.SRGB8_ALPHA8:s.RGBA8),Q===s.UNSIGNED_SHORT_4_4_4_4&&(ye=s.RGBA4),Q===s.UNSIGNED_SHORT_5_5_5_1&&(ye=s.RGB5_A1)}return(ye===s.R16F||ye===s.R32F||ye===s.RG16F||ye===s.RG32F||ye===s.RGBA16F||ye===s.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function v(R,w){let Q;return R?w===null||w===us||w===hs?Q=s.DEPTH24_STENCIL8:w===xn?Q=s.DEPTH32F_STENCIL8:w===Pr&&(Q=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):w===null||w===us||w===hs?Q=s.DEPTH_COMPONENT24:w===xn?Q=s.DEPTH_COMPONENT32F:w===Pr&&(Q=s.DEPTH_COMPONENT16),Q}function x(R,w){return p(R)===!0||R.isFramebufferTexture&&R.minFilter!==Wt&&R.minFilter!==Bt?Math.log2(Math.max(w.width,w.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?w.mipmaps.length:1}function E(R){const w=R.target;w.removeEventListener("dispose",E),C(w),w.isVideoTexture&&u.delete(w)}function S(R){const w=R.target;w.removeEventListener("dispose",S),A(w)}function C(R){const w=n.get(R);if(w.__webglInit===void 0)return;const Q=R.source,me=d.get(Q);if(me){const de=me[w.__cacheKey];de.usedTimes--,de.usedTimes===0&&L(R),Object.keys(me).length===0&&d.delete(Q)}n.remove(R)}function L(R){const w=n.get(R);s.deleteTexture(w.__webglTexture);const Q=R.source,me=d.get(Q);delete me[w.__cacheKey],o.memory.textures--}function A(R){const w=n.get(R);if(R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let me=0;me<6;me++){if(Array.isArray(w.__webglFramebuffer[me]))for(let de=0;de<w.__webglFramebuffer[me].length;de++)s.deleteFramebuffer(w.__webglFramebuffer[me][de]);else s.deleteFramebuffer(w.__webglFramebuffer[me]);w.__webglDepthbuffer&&s.deleteRenderbuffer(w.__webglDepthbuffer[me])}else{if(Array.isArray(w.__webglFramebuffer))for(let me=0;me<w.__webglFramebuffer.length;me++)s.deleteFramebuffer(w.__webglFramebuffer[me]);else s.deleteFramebuffer(w.__webglFramebuffer);if(w.__webglDepthbuffer&&s.deleteRenderbuffer(w.__webglDepthbuffer),w.__webglMultisampledFramebuffer&&s.deleteFramebuffer(w.__webglMultisampledFramebuffer),w.__webglColorRenderbuffer)for(let me=0;me<w.__webglColorRenderbuffer.length;me++)w.__webglColorRenderbuffer[me]&&s.deleteRenderbuffer(w.__webglColorRenderbuffer[me]);w.__webglDepthRenderbuffer&&s.deleteRenderbuffer(w.__webglDepthRenderbuffer)}const Q=R.textures;for(let me=0,de=Q.length;me<de;me++){const ye=n.get(Q[me]);ye.__webglTexture&&(s.deleteTexture(ye.__webglTexture),o.memory.textures--),n.remove(Q[me])}n.remove(R)}let b=0;function k(){b=0}function V(){const R=b;return R>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+i.maxTextures),b+=1,R}function G(R){const w=[];return w.push(R.wrapS),w.push(R.wrapT),w.push(R.wrapR||0),w.push(R.magFilter),w.push(R.minFilter),w.push(R.anisotropy),w.push(R.internalFormat),w.push(R.format),w.push(R.type),w.push(R.generateMipmaps),w.push(R.premultiplyAlpha),w.push(R.flipY),w.push(R.unpackAlignment),w.push(R.colorSpace),w.join()}function X(R,w){const Q=n.get(R);if(R.isVideoTexture&&he(R),R.isRenderTargetTexture===!1&&R.version>0&&Q.__version!==R.version){const me=R.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{De(Q,R,w);return}}t.bindTexture(s.TEXTURE_2D,Q.__webglTexture,s.TEXTURE0+w)}function ce(R,w){const Q=n.get(R);if(R.version>0&&Q.__version!==R.version){De(Q,R,w);return}t.bindTexture(s.TEXTURE_2D_ARRAY,Q.__webglTexture,s.TEXTURE0+w)}function Z(R,w){const Q=n.get(R);if(R.version>0&&Q.__version!==R.version){De(Q,R,w);return}t.bindTexture(s.TEXTURE_3D,Q.__webglTexture,s.TEXTURE0+w)}function ae(R,w){const Q=n.get(R);if(R.version>0&&Q.__version!==R.version){F(Q,R,w);return}t.bindTexture(s.TEXTURE_CUBE_MAP,Q.__webglTexture,s.TEXTURE0+w)}const z={[Tr]:s.REPEAT,[An]:s.CLAMP_TO_EDGE,[Cr]:s.MIRRORED_REPEAT},Se={[Wt]:s.NEAREST,[du]:s.NEAREST_MIPMAP_NEAREST,[Vs]:s.NEAREST_MIPMAP_LINEAR,[Bt]:s.LINEAR,[_r]:s.LINEAR_MIPMAP_NEAREST,[Vn]:s.LINEAR_MIPMAP_LINEAR},we={[gp]:s.NEVER,[bp]:s.ALWAYS,[_p]:s.LESS,[Mu]:s.LEQUAL,[vp]:s.EQUAL,[Mp]:s.GEQUAL,[yp]:s.GREATER,[xp]:s.NOTEQUAL};function Ae(R,w){if(w.type===xn&&e.has("OES_texture_float_linear")===!1&&(w.magFilter===Bt||w.magFilter===_r||w.magFilter===Vs||w.magFilter===Vn||w.minFilter===Bt||w.minFilter===_r||w.minFilter===Vs||w.minFilter===Vn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(R,s.TEXTURE_WRAP_S,z[w.wrapS]),s.texParameteri(R,s.TEXTURE_WRAP_T,z[w.wrapT]),(R===s.TEXTURE_3D||R===s.TEXTURE_2D_ARRAY)&&s.texParameteri(R,s.TEXTURE_WRAP_R,z[w.wrapR]),s.texParameteri(R,s.TEXTURE_MAG_FILTER,Se[w.magFilter]),s.texParameteri(R,s.TEXTURE_MIN_FILTER,Se[w.minFilter]),w.compareFunction&&(s.texParameteri(R,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(R,s.TEXTURE_COMPARE_FUNC,we[w.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(w.magFilter===Wt||w.minFilter!==Vs&&w.minFilter!==Vn||w.type===xn&&e.has("OES_texture_float_linear")===!1)return;if(w.anisotropy>1||n.get(w).__currentAnisotropy){const Q=e.get("EXT_texture_filter_anisotropic");s.texParameterf(R,Q.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,i.getMaxAnisotropy())),n.get(w).__currentAnisotropy=w.anisotropy}}}function _e(R,w){let Q=!1;R.__webglInit===void 0&&(R.__webglInit=!0,w.addEventListener("dispose",E));const me=w.source;let de=d.get(me);de===void 0&&(de={},d.set(me,de));const ye=G(w);if(ye!==R.__cacheKey){de[ye]===void 0&&(de[ye]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,Q=!0),de[ye].usedTimes++;const Be=de[R.__cacheKey];Be!==void 0&&(de[R.__cacheKey].usedTimes--,Be.usedTimes===0&&L(w)),R.__cacheKey=ye,R.__webglTexture=de[ye].texture}return Q}function De(R,w,Q){let me=s.TEXTURE_2D;(w.isDataArrayTexture||w.isCompressedArrayTexture)&&(me=s.TEXTURE_2D_ARRAY),w.isData3DTexture&&(me=s.TEXTURE_3D);const de=_e(R,w),ye=w.source;t.bindTexture(me,R.__webglTexture,s.TEXTURE0+Q);const Be=n.get(ye);if(ye.version!==Be.__version||de===!0){t.activeTexture(s.TEXTURE0+Q);const Ce=dt.getPrimaries(dt.workingColorSpace),Ee=w.colorSpace===si?null:dt.getPrimaries(w.colorSpace),Je=w.colorSpace===si||Ce===Ee?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,w.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,w.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Je);let be=_(w.image,!1,i.maxTextureSize);be=B(w,be);const Ne=r.convert(w.format,w.colorSpace),rt=r.convert(w.type);let Ke=y(w.internalFormat,Ne,rt,w.colorSpace,w.isVideoTexture);Ae(me,w);let Re;const nt=w.mipmaps,it=w.isVideoTexture!==!0,At=Be.__version===void 0||de===!0,M=ye.dataReady,le=x(w,be);if(w.isDepthTexture)Ke=v(w.format===ds,w.type),At&&(it?t.texStorage2D(s.TEXTURE_2D,1,Ke,be.width,be.height):t.texImage2D(s.TEXTURE_2D,0,Ke,be.width,be.height,0,Ne,rt,null));else if(w.isDataTexture)if(nt.length>0){it&&At&&t.texStorage2D(s.TEXTURE_2D,le,Ke,nt[0].width,nt[0].height);for(let ne=0,ue=nt.length;ne<ue;ne++)Re=nt[ne],it?M&&t.texSubImage2D(s.TEXTURE_2D,ne,0,0,Re.width,Re.height,Ne,rt,Re.data):t.texImage2D(s.TEXTURE_2D,ne,Ke,Re.width,Re.height,0,Ne,rt,Re.data);w.generateMipmaps=!1}else it?(At&&t.texStorage2D(s.TEXTURE_2D,le,Ke,be.width,be.height),M&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,be.width,be.height,Ne,rt,be.data)):t.texImage2D(s.TEXTURE_2D,0,Ke,be.width,be.height,0,Ne,rt,be.data);else if(w.isCompressedTexture)if(w.isCompressedArrayTexture){it&&At&&t.texStorage3D(s.TEXTURE_2D_ARRAY,le,Ke,nt[0].width,nt[0].height,be.depth);for(let ne=0,ue=nt.length;ne<ue;ne++)if(Re=nt[ne],w.format!==fn)if(Ne!==null)if(it){if(M)if(w.layerUpdates.size>0){for(const Me of w.layerUpdates){const We=Re.width*Re.height;t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ne,0,0,Me,Re.width,Re.height,1,Ne,Re.data.slice(We*Me,We*(Me+1)),0,0)}w.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ne,0,0,0,Re.width,Re.height,be.depth,Ne,Re.data,0,0)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,ne,Ke,Re.width,Re.height,be.depth,0,Re.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else it?M&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,ne,0,0,0,Re.width,Re.height,be.depth,Ne,rt,Re.data):t.texImage3D(s.TEXTURE_2D_ARRAY,ne,Ke,Re.width,Re.height,be.depth,0,Ne,rt,Re.data)}else{it&&At&&t.texStorage2D(s.TEXTURE_2D,le,Ke,nt[0].width,nt[0].height);for(let ne=0,ue=nt.length;ne<ue;ne++)Re=nt[ne],w.format!==fn?Ne!==null?it?M&&t.compressedTexSubImage2D(s.TEXTURE_2D,ne,0,0,Re.width,Re.height,Ne,Re.data):t.compressedTexImage2D(s.TEXTURE_2D,ne,Ke,Re.width,Re.height,0,Re.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):it?M&&t.texSubImage2D(s.TEXTURE_2D,ne,0,0,Re.width,Re.height,Ne,rt,Re.data):t.texImage2D(s.TEXTURE_2D,ne,Ke,Re.width,Re.height,0,Ne,rt,Re.data)}else if(w.isDataArrayTexture)if(it){if(At&&t.texStorage3D(s.TEXTURE_2D_ARRAY,le,Ke,be.width,be.height,be.depth),M)if(w.layerUpdates.size>0){let ne;switch(rt){case s.UNSIGNED_BYTE:switch(Ne){case s.ALPHA:ne=1;break;case s.LUMINANCE:ne=1;break;case s.LUMINANCE_ALPHA:ne=2;break;case s.RGB:ne=3;break;case s.RGBA:ne=4;break;default:throw new Error(`Unknown texel size for format ${Ne}.`)}break;case s.UNSIGNED_SHORT_4_4_4_4:case s.UNSIGNED_SHORT_5_5_5_1:case s.UNSIGNED_SHORT_5_6_5:ne=1;break;default:throw new Error(`Unknown texel size for type ${rt}.`)}const ue=be.width*be.height*ne;for(const Me of w.layerUpdates)t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,Me,be.width,be.height,1,Ne,rt,be.data.slice(ue*Me,ue*(Me+1)));w.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,be.width,be.height,be.depth,Ne,rt,be.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,Ke,be.width,be.height,be.depth,0,Ne,rt,be.data);else if(w.isData3DTexture)it?(At&&t.texStorage3D(s.TEXTURE_3D,le,Ke,be.width,be.height,be.depth),M&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,be.width,be.height,be.depth,Ne,rt,be.data)):t.texImage3D(s.TEXTURE_3D,0,Ke,be.width,be.height,be.depth,0,Ne,rt,be.data);else if(w.isFramebufferTexture){if(At)if(it)t.texStorage2D(s.TEXTURE_2D,le,Ke,be.width,be.height);else{let ne=be.width,ue=be.height;for(let Me=0;Me<le;Me++)t.texImage2D(s.TEXTURE_2D,Me,Ke,ne,ue,0,Ne,rt,null),ne>>=1,ue>>=1}}else if(nt.length>0){if(it&&At){const ne=O(nt[0]);t.texStorage2D(s.TEXTURE_2D,le,Ke,ne.width,ne.height)}for(let ne=0,ue=nt.length;ne<ue;ne++)Re=nt[ne],it?M&&t.texSubImage2D(s.TEXTURE_2D,ne,0,0,Ne,rt,Re):t.texImage2D(s.TEXTURE_2D,ne,Ke,Ne,rt,Re);w.generateMipmaps=!1}else if(it){if(At){const ne=O(be);t.texStorage2D(s.TEXTURE_2D,le,Ke,ne.width,ne.height)}M&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,Ne,rt,be)}else t.texImage2D(s.TEXTURE_2D,0,Ke,Ne,rt,be);p(w)&&m(me),Be.__version=ye.version,w.onUpdate&&w.onUpdate(w)}R.__version=w.version}function F(R,w,Q){if(w.image.length!==6)return;const me=_e(R,w),de=w.source;t.bindTexture(s.TEXTURE_CUBE_MAP,R.__webglTexture,s.TEXTURE0+Q);const ye=n.get(de);if(de.version!==ye.__version||me===!0){t.activeTexture(s.TEXTURE0+Q);const Be=dt.getPrimaries(dt.workingColorSpace),Ce=w.colorSpace===si?null:dt.getPrimaries(w.colorSpace),Ee=w.colorSpace===si||Be===Ce?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,w.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,w.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ee);const Je=w.isCompressedTexture||w.image[0].isCompressedTexture,be=w.image[0]&&w.image[0].isDataTexture,Ne=[];for(let ue=0;ue<6;ue++)!Je&&!be?Ne[ue]=_(w.image[ue],!0,i.maxCubemapSize):Ne[ue]=be?w.image[ue].image:w.image[ue],Ne[ue]=B(w,Ne[ue]);const rt=Ne[0],Ke=r.convert(w.format,w.colorSpace),Re=r.convert(w.type),nt=y(w.internalFormat,Ke,Re,w.colorSpace),it=w.isVideoTexture!==!0,At=ye.__version===void 0||me===!0,M=de.dataReady;let le=x(w,rt);Ae(s.TEXTURE_CUBE_MAP,w);let ne;if(Je){it&&At&&t.texStorage2D(s.TEXTURE_CUBE_MAP,le,nt,rt.width,rt.height);for(let ue=0;ue<6;ue++){ne=Ne[ue].mipmaps;for(let Me=0;Me<ne.length;Me++){const We=ne[Me];w.format!==fn?Ke!==null?it?M&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,Me,0,0,We.width,We.height,Ke,We.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,Me,nt,We.width,We.height,0,We.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):it?M&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,Me,0,0,We.width,We.height,Ke,Re,We.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,Me,nt,We.width,We.height,0,Ke,Re,We.data)}}}else{if(ne=w.mipmaps,it&&At){ne.length>0&&le++;const ue=O(Ne[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,le,nt,ue.width,ue.height)}for(let ue=0;ue<6;ue++)if(be){it?M&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0,0,0,Ne[ue].width,Ne[ue].height,Ke,Re,Ne[ue].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0,nt,Ne[ue].width,Ne[ue].height,0,Ke,Re,Ne[ue].data);for(let Me=0;Me<ne.length;Me++){const tt=ne[Me].image[ue].image;it?M&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,Me+1,0,0,tt.width,tt.height,Ke,Re,tt.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,Me+1,nt,tt.width,tt.height,0,Ke,Re,tt.data)}}else{it?M&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0,0,0,Ke,Re,Ne[ue]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0,nt,Ke,Re,Ne[ue]);for(let Me=0;Me<ne.length;Me++){const We=ne[Me];it?M&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,Me+1,0,0,Ke,Re,We.image[ue]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,Me+1,nt,Ke,Re,We.image[ue])}}}p(w)&&m(s.TEXTURE_CUBE_MAP),ye.__version=de.version,w.onUpdate&&w.onUpdate(w)}R.__version=w.version}function U(R,w,Q,me,de,ye){const Be=r.convert(Q.format,Q.colorSpace),Ce=r.convert(Q.type),Ee=y(Q.internalFormat,Be,Ce,Q.colorSpace);if(!n.get(w).__hasExternalTextures){const be=Math.max(1,w.width>>ye),Ne=Math.max(1,w.height>>ye);de===s.TEXTURE_3D||de===s.TEXTURE_2D_ARRAY?t.texImage3D(de,ye,Ee,be,Ne,w.depth,0,Be,Ce,null):t.texImage2D(de,ye,Ee,be,Ne,0,Be,Ce,null)}t.bindFramebuffer(s.FRAMEBUFFER,R),ie(w)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,me,de,n.get(Q).__webglTexture,0,W(w)):(de===s.TEXTURE_2D||de>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&de<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,me,de,n.get(Q).__webglTexture,ye),t.bindFramebuffer(s.FRAMEBUFFER,null)}function I(R,w,Q){if(s.bindRenderbuffer(s.RENDERBUFFER,R),w.depthBuffer){const me=w.depthTexture,de=me&&me.isDepthTexture?me.type:null,ye=v(w.stencilBuffer,de),Be=w.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Ce=W(w);ie(w)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ce,ye,w.width,w.height):Q?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ce,ye,w.width,w.height):s.renderbufferStorage(s.RENDERBUFFER,ye,w.width,w.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,Be,s.RENDERBUFFER,R)}else{const me=w.textures;for(let de=0;de<me.length;de++){const ye=me[de],Be=r.convert(ye.format,ye.colorSpace),Ce=r.convert(ye.type),Ee=y(ye.internalFormat,Be,Ce,ye.colorSpace),Je=W(w);Q&&ie(w)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,Je,Ee,w.width,w.height):ie(w)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Je,Ee,w.width,w.height):s.renderbufferStorage(s.RENDERBUFFER,Ee,w.width,w.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function T(R,w){if(w&&w.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,R),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(w.depthTexture).__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)&&(w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0),X(w.depthTexture,0);const me=n.get(w.depthTexture).__webglTexture,de=W(w);if(w.depthTexture.format===as)ie(w)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,me,0,de):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,me,0);else if(w.depthTexture.format===ds)ie(w)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,me,0,de):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,me,0);else throw new Error("Unknown depthTexture format")}function se(R){const w=n.get(R),Q=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!w.__autoAllocateDepthBuffer){if(Q)throw new Error("target.depthTexture not supported in Cube render targets");T(w.__webglFramebuffer,R)}else if(Q){w.__webglDepthbuffer=[];for(let me=0;me<6;me++)t.bindFramebuffer(s.FRAMEBUFFER,w.__webglFramebuffer[me]),w.__webglDepthbuffer[me]=s.createRenderbuffer(),I(w.__webglDepthbuffer[me],R,!1)}else t.bindFramebuffer(s.FRAMEBUFFER,w.__webglFramebuffer),w.__webglDepthbuffer=s.createRenderbuffer(),I(w.__webglDepthbuffer,R,!1);t.bindFramebuffer(s.FRAMEBUFFER,null)}function fe(R,w,Q){const me=n.get(R);w!==void 0&&U(me.__webglFramebuffer,R,R.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),Q!==void 0&&se(R)}function K(R){const w=R.texture,Q=n.get(R),me=n.get(w);R.addEventListener("dispose",S);const de=R.textures,ye=R.isWebGLCubeRenderTarget===!0,Be=de.length>1;if(Be||(me.__webglTexture===void 0&&(me.__webglTexture=s.createTexture()),me.__version=w.version,o.memory.textures++),ye){Q.__webglFramebuffer=[];for(let Ce=0;Ce<6;Ce++)if(w.mipmaps&&w.mipmaps.length>0){Q.__webglFramebuffer[Ce]=[];for(let Ee=0;Ee<w.mipmaps.length;Ee++)Q.__webglFramebuffer[Ce][Ee]=s.createFramebuffer()}else Q.__webglFramebuffer[Ce]=s.createFramebuffer()}else{if(w.mipmaps&&w.mipmaps.length>0){Q.__webglFramebuffer=[];for(let Ce=0;Ce<w.mipmaps.length;Ce++)Q.__webglFramebuffer[Ce]=s.createFramebuffer()}else Q.__webglFramebuffer=s.createFramebuffer();if(Be)for(let Ce=0,Ee=de.length;Ce<Ee;Ce++){const Je=n.get(de[Ce]);Je.__webglTexture===void 0&&(Je.__webglTexture=s.createTexture(),o.memory.textures++)}if(R.samples>0&&ie(R)===!1){Q.__webglMultisampledFramebuffer=s.createFramebuffer(),Q.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,Q.__webglMultisampledFramebuffer);for(let Ce=0;Ce<de.length;Ce++){const Ee=de[Ce];Q.__webglColorRenderbuffer[Ce]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,Q.__webglColorRenderbuffer[Ce]);const Je=r.convert(Ee.format,Ee.colorSpace),be=r.convert(Ee.type),Ne=y(Ee.internalFormat,Je,be,Ee.colorSpace,R.isXRRenderTarget===!0),rt=W(R);s.renderbufferStorageMultisample(s.RENDERBUFFER,rt,Ne,R.width,R.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ce,s.RENDERBUFFER,Q.__webglColorRenderbuffer[Ce])}s.bindRenderbuffer(s.RENDERBUFFER,null),R.depthBuffer&&(Q.__webglDepthRenderbuffer=s.createRenderbuffer(),I(Q.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(ye){t.bindTexture(s.TEXTURE_CUBE_MAP,me.__webglTexture),Ae(s.TEXTURE_CUBE_MAP,w);for(let Ce=0;Ce<6;Ce++)if(w.mipmaps&&w.mipmaps.length>0)for(let Ee=0;Ee<w.mipmaps.length;Ee++)U(Q.__webglFramebuffer[Ce][Ee],R,w,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Ee);else U(Q.__webglFramebuffer[Ce],R,w,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0);p(w)&&m(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Be){for(let Ce=0,Ee=de.length;Ce<Ee;Ce++){const Je=de[Ce],be=n.get(Je);t.bindTexture(s.TEXTURE_2D,be.__webglTexture),Ae(s.TEXTURE_2D,Je),U(Q.__webglFramebuffer,R,Je,s.COLOR_ATTACHMENT0+Ce,s.TEXTURE_2D,0),p(Je)&&m(s.TEXTURE_2D)}t.unbindTexture()}else{let Ce=s.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Ce=R.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(Ce,me.__webglTexture),Ae(Ce,w),w.mipmaps&&w.mipmaps.length>0)for(let Ee=0;Ee<w.mipmaps.length;Ee++)U(Q.__webglFramebuffer[Ee],R,w,s.COLOR_ATTACHMENT0,Ce,Ee);else U(Q.__webglFramebuffer,R,w,s.COLOR_ATTACHMENT0,Ce,0);p(w)&&m(Ce),t.unbindTexture()}R.depthBuffer&&se(R)}function D(R){const w=R.textures;for(let Q=0,me=w.length;Q<me;Q++){const de=w[Q];if(p(de)){const ye=R.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D,Be=n.get(de).__webglTexture;t.bindTexture(ye,Be),m(ye),t.unbindTexture()}}}const q=[],J=[];function H(R){if(R.samples>0){if(ie(R)===!1){const w=R.textures,Q=R.width,me=R.height;let de=s.COLOR_BUFFER_BIT;const ye=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Be=n.get(R),Ce=w.length>1;if(Ce)for(let Ee=0;Ee<w.length;Ee++)t.bindFramebuffer(s.FRAMEBUFFER,Be.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ee,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,Be.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ee,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,Be.__webglMultisampledFramebuffer),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Be.__webglFramebuffer);for(let Ee=0;Ee<w.length;Ee++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(de|=s.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(de|=s.STENCIL_BUFFER_BIT)),Ce){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,Be.__webglColorRenderbuffer[Ee]);const Je=n.get(w[Ee]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,Je,0)}s.blitFramebuffer(0,0,Q,me,0,0,Q,me,de,s.NEAREST),l===!0&&(q.length=0,J.length=0,q.push(s.COLOR_ATTACHMENT0+Ee),R.depthBuffer&&R.resolveDepthBuffer===!1&&(q.push(ye),J.push(ye),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,J)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,q))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),Ce)for(let Ee=0;Ee<w.length;Ee++){t.bindFramebuffer(s.FRAMEBUFFER,Be.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ee,s.RENDERBUFFER,Be.__webglColorRenderbuffer[Ee]);const Je=n.get(w[Ee]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,Be.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ee,s.TEXTURE_2D,Je,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Be.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&l){const w=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[w])}}}function W(R){return Math.min(i.maxSamples,R.samples)}function ie(R){const w=n.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function he(R){const w=o.render.frame;u.get(R)!==w&&(u.set(R,w),R.update())}function B(R,w){const Q=R.colorSpace,me=R.format,de=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||Q!==fi&&Q!==si&&(dt.getTransfer(Q)===Mt?(me!==fn||de!==hi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Q)),w}function O(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=V,this.resetTextureUnits=k,this.setTexture2D=X,this.setTexture2DArray=ce,this.setTexture3D=Z,this.setTextureCube=ae,this.rebindTextures=fe,this.setupRenderTarget=K,this.updateRenderTargetMipmap=D,this.updateMultisampleRenderTarget=H,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=U,this.useMultisampledRTT=ie}function kp(s,e){function t(n,i=si){let r;const o=dt.getTransfer(i);if(n===hi)return s.UNSIGNED_BYTE;if(n===pu)return s.UNSIGNED_SHORT_4_4_4_4;if(n===mu)return s.UNSIGNED_SHORT_5_5_5_1;if(n===ip)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===tp)return s.BYTE;if(n===np)return s.SHORT;if(n===Pr)return s.UNSIGNED_SHORT;if(n===fu)return s.INT;if(n===us)return s.UNSIGNED_INT;if(n===xn)return s.FLOAT;if(n===Jr)return s.HALF_FLOAT;if(n===sp)return s.ALPHA;if(n===rp)return s.RGB;if(n===fn)return s.RGBA;if(n===op)return s.LUMINANCE;if(n===ap)return s.LUMINANCE_ALPHA;if(n===as)return s.DEPTH_COMPONENT;if(n===ds)return s.DEPTH_STENCIL;if(n===gu)return s.RED;if(n===_u)return s.RED_INTEGER;if(n===lp)return s.RG;if(n===vu)return s.RG_INTEGER;if(n===yu)return s.RGBA_INTEGER;if(n===ha||n===da||n===fa||n===pa)if(o===Mt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===ha)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===da)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===pa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===ha)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===da)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===fa)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===pa)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===fc||n===pc||n===mc||n===gc)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===fc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===pc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===mc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===gc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===_c||n===vc||n===yc)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===_c||n===vc)return o===Mt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===yc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===xc||n===Mc||n===bc||n===Sc||n===wc||n===Ac||n===Ec||n===Tc||n===Cc||n===Pc||n===Rc||n===Ic||n===Lc||n===Nc)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===xc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Mc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===bc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Sc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===wc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ac)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ec)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Tc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Cc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Pc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Rc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ic)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Lc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Nc)return o===Mt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ma||n===Dc||n===Uc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===ma)return o===Mt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Dc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Uc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===cp||n===Oc||n===Fc||n===kc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===ma)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Oc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Fc)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===kc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===hs?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}class Bp extends kt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Ws extends ut{constructor(){super(),this.isGroup=!0,this.type="Group"}}const xA={type:"move"};class zl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ws,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 Ws,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ws,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const _ of e.hand.values()){const p=t.getJointPose(_,n),m=this._getHandJoint(c,_);p!==null&&(m.matrix.fromArray(p.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=p.radius),m.visible=p!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(xA)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Ws;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const MA=`
|
|
void main() {
|
|
|
|
gl_Position = vec4( position, 1.0 );
|
|
|
|
}`,bA=`
|
|
uniform sampler2DArray depthColor;
|
|
uniform float depthWidth;
|
|
uniform float depthHeight;
|
|
|
|
void main() {
|
|
|
|
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
|
|
|
|
if ( coord.x >= 1.0 ) {
|
|
|
|
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
|
|
|
|
} else {
|
|
|
|
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
|
|
|
|
}
|
|
|
|
}`;class SA{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const i=new It,r=e.properties.get(i);r.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new On({vertexShader:MA,fragmentShader:bA,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Nt(new js(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}}class wA extends Yn{constructor(e,t){super();const n=this;let i=null,r=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,g=null;const _=new SA,p=t.getContextAttributes();let m=null,y=null;const v=[],x=[],E=new te;let S=null;const C=new kt;C.layers.enable(1),C.viewport=new _t;const L=new kt;L.layers.enable(2),L.viewport=new _t;const A=[C,L],b=new Bp;b.layers.enable(1),b.layers.enable(2);let k=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(F){let U=v[F];return U===void 0&&(U=new zl,v[F]=U),U.getTargetRaySpace()},this.getControllerGrip=function(F){let U=v[F];return U===void 0&&(U=new zl,v[F]=U),U.getGripSpace()},this.getHand=function(F){let U=v[F];return U===void 0&&(U=new zl,v[F]=U),U.getHandSpace()};function G(F){const U=x.indexOf(F.inputSource);if(U===-1)return;const I=v[U];I!==void 0&&(I.update(F.inputSource,F.frame,c||o),I.dispatchEvent({type:F.type,data:F.inputSource}))}function X(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",ce);for(let F=0;F<v.length;F++){const U=x[F];U!==null&&(x[F]=null,v[F].disconnect(U))}k=null,V=null,_.reset(),e.setRenderTarget(m),f=null,d=null,h=null,i=null,y=null,De.stop(),n.isPresenting=!1,e.setPixelRatio(S),e.setSize(E.width,E.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(F){r=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(F){a=F,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(F){c=F},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(F){if(i=F,i!==null){if(m=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",X),i.addEventListener("inputsourceschange",ce),p.xrCompatible!==!0&&await t.makeXRCompatible(),S=e.getPixelRatio(),e.getSize(E),i.renderState.layers===void 0){const U={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,U),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new Un(f.framebufferWidth,f.framebufferHeight,{format:fn,type:hi,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil})}else{let U=null,I=null,T=null;p.depth&&(T=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,U=p.stencil?ds:as,I=p.stencil?hs:us);const se={colorFormat:t.RGBA8,depthFormat:T,scaleFactor:r};h=new XRWebGLBinding(i,t),d=h.createProjectionLayer(se),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new Un(d.textureWidth,d.textureHeight,{format:fn,type:hi,depthTexture:new Pu(d.textureWidth,d.textureHeight,I,void 0,void 0,void 0,void 0,void 0,void 0,U),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await i.requestReferenceSpace(a),De.setContext(i),De.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function ce(F){for(let U=0;U<F.removed.length;U++){const I=F.removed[U],T=x.indexOf(I);T>=0&&(x[T]=null,v[T].disconnect(I))}for(let U=0;U<F.added.length;U++){const I=F.added[U];let T=x.indexOf(I);if(T===-1){for(let fe=0;fe<v.length;fe++)if(fe>=x.length){x.push(I),T=fe;break}else if(x[fe]===null){x[fe]=I,T=fe;break}if(T===-1)break}const se=v[T];se&&se.connect(I)}}const Z=new N,ae=new N;function z(F,U,I){Z.setFromMatrixPosition(U.matrixWorld),ae.setFromMatrixPosition(I.matrixWorld);const T=Z.distanceTo(ae),se=U.projectionMatrix.elements,fe=I.projectionMatrix.elements,K=se[14]/(se[10]-1),D=se[14]/(se[10]+1),q=(se[9]+1)/se[5],J=(se[9]-1)/se[5],H=(se[8]-1)/se[0],W=(fe[8]+1)/fe[0],ie=K*H,he=K*W,B=T/(-H+W),O=B*-H;U.matrixWorld.decompose(F.position,F.quaternion,F.scale),F.translateX(O),F.translateZ(B),F.matrixWorld.compose(F.position,F.quaternion,F.scale),F.matrixWorldInverse.copy(F.matrixWorld).invert();const R=K+B,w=D+B,Q=ie-O,me=he+(T-O),de=q*D/w*R,ye=J*D/w*R;F.projectionMatrix.makePerspective(Q,me,de,ye,R,w),F.projectionMatrixInverse.copy(F.projectionMatrix).invert()}function Se(F,U){U===null?F.matrixWorld.copy(F.matrix):F.matrixWorld.multiplyMatrices(U.matrixWorld,F.matrix),F.matrixWorldInverse.copy(F.matrixWorld).invert()}this.updateCamera=function(F){if(i===null)return;_.texture!==null&&(F.near=_.depthNear,F.far=_.depthFar),b.near=L.near=C.near=F.near,b.far=L.far=C.far=F.far,(k!==b.near||V!==b.far)&&(i.updateRenderState({depthNear:b.near,depthFar:b.far}),k=b.near,V=b.far,C.near=k,C.far=V,L.near=k,L.far=V,C.updateProjectionMatrix(),L.updateProjectionMatrix(),F.updateProjectionMatrix());const U=F.parent,I=b.cameras;Se(b,U);for(let T=0;T<I.length;T++)Se(I[T],U);I.length===2?z(b,C,L):b.projectionMatrix.copy(C.projectionMatrix),we(F,b,U)};function we(F,U,I){I===null?F.matrix.copy(U.matrixWorld):(F.matrix.copy(I.matrixWorld),F.matrix.invert(),F.matrix.multiply(U.matrixWorld)),F.matrix.decompose(F.position,F.quaternion,F.scale),F.updateMatrixWorld(!0),F.projectionMatrix.copy(U.projectionMatrix),F.projectionMatrixInverse.copy(U.projectionMatrixInverse),F.isPerspectiveCamera&&(F.fov=Ys*2*Math.atan(1/F.projectionMatrix.elements[5]),F.zoom=1)}this.getCamera=function(){return b},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(F){l=F,d!==null&&(d.fixedFoveation=F),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=F)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(b)};let Ae=null;function _e(F,U){if(u=U.getViewerPose(c||o),g=U,u!==null){const I=u.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let T=!1;I.length!==b.cameras.length&&(b.cameras.length=0,T=!0);for(let fe=0;fe<I.length;fe++){const K=I[fe];let D=null;if(f!==null)D=f.getViewport(K);else{const J=h.getViewSubImage(d,K);D=J.viewport,fe===0&&(e.setRenderTargetTextures(y,J.colorTexture,d.ignoreDepthValues?void 0:J.depthStencilTexture),e.setRenderTarget(y))}let q=A[fe];q===void 0&&(q=new kt,q.layers.enable(fe),q.viewport=new _t,A[fe]=q),q.matrix.fromArray(K.transform.matrix),q.matrix.decompose(q.position,q.quaternion,q.scale),q.projectionMatrix.fromArray(K.projectionMatrix),q.projectionMatrixInverse.copy(q.projectionMatrix).invert(),q.viewport.set(D.x,D.y,D.width,D.height),fe===0&&(b.matrix.copy(q.matrix),b.matrix.decompose(b.position,b.quaternion,b.scale)),T===!0&&b.cameras.push(q)}const se=i.enabledFeatures;if(se&&se.includes("depth-sensing")){const fe=h.getDepthInformation(I[0]);fe&&fe.isValid&&fe.texture&&_.init(e,fe,i.renderState)}}for(let I=0;I<v.length;I++){const T=x[I],se=v[I];T!==null&&se!==void 0&&se.update(T,U,c||o)}Ae&&Ae(F,U),U.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:U}),g=null}const De=new Lp;De.setAnimationLoop(_e),this.setAnimationLoop=function(F){Ae=F},this.dispose=function(){}}}const Wi=new bn,AA=new Ze;function EA(s,e){function t(p,m){p.matrixAutoUpdate===!0&&p.updateMatrix(),m.value.copy(p.matrix)}function n(p,m){m.color.getRGB(p.fogColor.value,Cp(s)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function i(p,m,y,v,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?r(p,m):m.isMeshToonMaterial?(r(p,m),h(p,m)):m.isMeshPhongMaterial?(r(p,m),u(p,m)):m.isMeshStandardMaterial?(r(p,m),d(p,m),m.isMeshPhysicalMaterial&&f(p,m,x)):m.isMeshMatcapMaterial?(r(p,m),g(p,m)):m.isMeshDepthMaterial?r(p,m):m.isMeshDistanceMaterial?(r(p,m),_(p,m)):m.isMeshNormalMaterial?r(p,m):m.isLineBasicMaterial?(o(p,m),m.isLineDashedMaterial&&a(p,m)):m.isPointsMaterial?l(p,m,y,v):m.isSpriteMaterial?c(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function r(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map,t(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.bumpMap&&(p.bumpMap.value=m.bumpMap,t(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===an&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,t(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===an&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,t(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,p.emissiveMapTransform)),m.specularMap&&(p.specularMap.value=m.specularMap,t(m.specularMap,p.specularMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);const y=e.get(m),v=y.envMap,x=y.envMapRotation;v&&(p.envMap.value=v,Wi.copy(x),Wi.x*=-1,Wi.y*=-1,Wi.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(Wi.y*=-1,Wi.z*=-1),p.envMapRotation.value.setFromMatrix4(AA.makeRotationFromEuler(Wi)),p.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,p.aoMapTransform))}function o(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,t(m.map,p.mapTransform))}function a(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function l(p,m,y,v){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*y,p.scale.value=v*.5,m.map&&(p.map.value=m.map,t(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function c(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,t(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,t(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function u(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function h(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function d(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,y){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===an&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,m){m.matcap&&(p.matcap.value=m.matcap)}function _(p,m){const y=e.get(m).light;p.referencePosition.value.setFromMatrixPosition(y.matrixWorld),p.nearDistance.value=y.shadow.camera.near,p.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function TA(s,e,t,n){let i={},r={},o=[];const a=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,v){const x=v.program;n.uniformBlockBinding(y,x)}function c(y,v){let x=i[y.id];x===void 0&&(g(y),x=u(y),i[y.id]=x,y.addEventListener("dispose",p));const E=v.program;n.updateUBOMapping(y,E);const S=e.render.frame;r[y.id]!==S&&(d(y),r[y.id]=S)}function u(y){const v=h();y.__bindingPointIndex=v;const x=s.createBuffer(),E=y.__size,S=y.usage;return s.bindBuffer(s.UNIFORM_BUFFER,x),s.bufferData(s.UNIFORM_BUFFER,E,S),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,v,x),x}function h(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const v=i[y.id],x=y.uniforms,E=y.__cache;s.bindBuffer(s.UNIFORM_BUFFER,v);for(let S=0,C=x.length;S<C;S++){const L=Array.isArray(x[S])?x[S]:[x[S]];for(let A=0,b=L.length;A<b;A++){const k=L[A];if(f(k,S,A,E)===!0){const V=k.__offset,G=Array.isArray(k.value)?k.value:[k.value];let X=0;for(let ce=0;ce<G.length;ce++){const Z=G[ce],ae=_(Z);typeof Z=="number"||typeof Z=="boolean"?(k.__data[0]=Z,s.bufferSubData(s.UNIFORM_BUFFER,V+X,k.__data)):Z.isMatrix3?(k.__data[0]=Z.elements[0],k.__data[1]=Z.elements[1],k.__data[2]=Z.elements[2],k.__data[3]=0,k.__data[4]=Z.elements[3],k.__data[5]=Z.elements[4],k.__data[6]=Z.elements[5],k.__data[7]=0,k.__data[8]=Z.elements[6],k.__data[9]=Z.elements[7],k.__data[10]=Z.elements[8],k.__data[11]=0):(Z.toArray(k.__data,X),X+=ae.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,V,k.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(y,v,x,E){const S=y.value,C=v+"_"+x;if(E[C]===void 0)return typeof S=="number"||typeof S=="boolean"?E[C]=S:E[C]=S.clone(),!0;{const L=E[C];if(typeof S=="number"||typeof S=="boolean"){if(L!==S)return E[C]=S,!0}else if(L.equals(S)===!1)return L.copy(S),!0}return!1}function g(y){const v=y.uniforms;let x=0;const E=16;for(let C=0,L=v.length;C<L;C++){const A=Array.isArray(v[C])?v[C]:[v[C]];for(let b=0,k=A.length;b<k;b++){const V=A[b],G=Array.isArray(V.value)?V.value:[V.value];for(let X=0,ce=G.length;X<ce;X++){const Z=G[X],ae=_(Z),z=x%E;z!==0&&E-z<ae.boundary&&(x+=E-z),V.__data=new Float32Array(ae.storage/Float32Array.BYTES_PER_ELEMENT),V.__offset=x,x+=ae.storage}}}const S=x%E;return S>0&&(x+=E-S),y.__size=x,y.__cache={},this}function _(y){const v={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(v.boundary=4,v.storage=4):y.isVector2?(v.boundary=8,v.storage=8):y.isVector3||y.isColor?(v.boundary=16,v.storage=12):y.isVector4?(v.boundary=16,v.storage=16):y.isMatrix3?(v.boundary=48,v.storage=48):y.isMatrix4?(v.boundary=64,v.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),v}function p(y){const v=y.target;v.removeEventListener("dispose",p);const x=o.indexOf(v.__bindingPointIndex);o.splice(x,1),s.deleteBuffer(i[v.id]),delete i[v.id],delete r[v.id]}function m(){for(const y in i)s.deleteBuffer(i[y]);o=[],i={},r={}}return{bind:l,update:c,dispose:m}}class va{constructor(e={}){const{canvas:t=wp(),context:n=null,depth:i=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=o;const f=new Uint32Array(4),g=new Int32Array(4);let _=null,p=null;const m=[],y=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=dn,this.toneMapping=Wn,this.toneMappingExposure=1;const v=this;let x=!1,E=0,S=0,C=null,L=-1,A=null;const b=new _t,k=new _t;let V=null;const G=new Ie(0);let X=0,ce=t.width,Z=t.height,ae=1,z=null,Se=null;const we=new _t(0,0,ce,Z),Ae=new _t(0,0,ce,Z);let _e=!1;const De=new to;let F=!1,U=!1;const I=new Ze,T=new N,se={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let fe=!1;function K(){return C===null?ae:1}let D=n;function q(P,$){return t.getContext(P,$)}try{const P={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Zr}`),t.addEventListener("webglcontextlost",le,!1),t.addEventListener("webglcontextrestored",ne,!1),t.addEventListener("webglcontextcreationerror",ue,!1),D===null){const $="webgl2";if(D=q($,P),D===null)throw q($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(P){throw console.error("THREE.WebGLRenderer: "+P.message),P}let J,H,W,ie,he,B,O,R,w,Q,me,de,ye,Be,Ce,Ee,Je,be,Ne,rt,Ke,Re,nt,it;function At(){J=new zw(D),J.init(),Re=new kp(D,J),H=new Dw(D,J,e,Re),W=new vA(D),ie=new Gw(D),he=new oA,B=new yA(D,J,W,he,H,Re,ie),O=new Ow(v),R=new Bw(v),w=new KM(D),nt=new Lw(D,w),Q=new Vw(D,w,ie,nt),me=new $w(D,Q,w,ie),Ne=new Ww(D,H,B),Ee=new Uw(he),de=new rA(v,O,R,J,H,nt,Ee),ye=new EA(v,he),Be=new lA,Ce=new pA(J),be=new Iw(v,O,R,W,me,d,l),Je=new _A(v,me,H),it=new TA(D,ie,H,W),rt=new Nw(D,J,ie),Ke=new Hw(D,J,ie),ie.programs=de.programs,v.capabilities=H,v.extensions=J,v.properties=he,v.renderLists=Be,v.shadowMap=Je,v.state=W,v.info=ie}At();const M=new wA(v,D);this.xr=M,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const P=J.get("WEBGL_lose_context");P&&P.loseContext()},this.forceContextRestore=function(){const P=J.get("WEBGL_lose_context");P&&P.restoreContext()},this.getPixelRatio=function(){return ae},this.setPixelRatio=function(P){P!==void 0&&(ae=P,this.setSize(ce,Z,!1))},this.getSize=function(P){return P.set(ce,Z)},this.setSize=function(P,$,re=!0){if(M.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ce=P,Z=$,t.width=Math.floor(P*ae),t.height=Math.floor($*ae),re===!0&&(t.style.width=P+"px",t.style.height=$+"px"),this.setViewport(0,0,P,$)},this.getDrawingBufferSize=function(P){return P.set(ce*ae,Z*ae).floor()},this.setDrawingBufferSize=function(P,$,re){ce=P,Z=$,ae=re,t.width=Math.floor(P*re),t.height=Math.floor($*re),this.setViewport(0,0,P,$)},this.getCurrentViewport=function(P){return P.copy(b)},this.getViewport=function(P){return P.copy(we)},this.setViewport=function(P,$,re,oe){P.isVector4?we.set(P.x,P.y,P.z,P.w):we.set(P,$,re,oe),W.viewport(b.copy(we).multiplyScalar(ae).round())},this.getScissor=function(P){return P.copy(Ae)},this.setScissor=function(P,$,re,oe){P.isVector4?Ae.set(P.x,P.y,P.z,P.w):Ae.set(P,$,re,oe),W.scissor(k.copy(Ae).multiplyScalar(ae).round())},this.getScissorTest=function(){return _e},this.setScissorTest=function(P){W.setScissorTest(_e=P)},this.setOpaqueSort=function(P){z=P},this.setTransparentSort=function(P){Se=P},this.getClearColor=function(P){return P.copy(be.getClearColor())},this.setClearColor=function(){be.setClearColor.apply(be,arguments)},this.getClearAlpha=function(){return be.getClearAlpha()},this.setClearAlpha=function(){be.setClearAlpha.apply(be,arguments)},this.clear=function(P=!0,$=!0,re=!0){let oe=0;if(P){let j=!1;if(C!==null){const Te=C.texture.format;j=Te===yu||Te===vu||Te===_u}if(j){const Te=C.texture.type,Le=Te===hi||Te===us||Te===Pr||Te===hs||Te===pu||Te===mu,ze=be.getClearColor(),Ge=be.getClearAlpha(),Qe=ze.r,et=ze.g,Ye=ze.b;Le?(f[0]=Qe,f[1]=et,f[2]=Ye,f[3]=Ge,D.clearBufferuiv(D.COLOR,0,f)):(g[0]=Qe,g[1]=et,g[2]=Ye,g[3]=Ge,D.clearBufferiv(D.COLOR,0,g))}else oe|=D.COLOR_BUFFER_BIT}$&&(oe|=D.DEPTH_BUFFER_BIT),re&&(oe|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),D.clear(oe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",le,!1),t.removeEventListener("webglcontextrestored",ne,!1),t.removeEventListener("webglcontextcreationerror",ue,!1),Be.dispose(),Ce.dispose(),he.dispose(),O.dispose(),R.dispose(),me.dispose(),nt.dispose(),it.dispose(),de.dispose(),M.dispose(),M.removeEventListener("sessionstart",Ut),M.removeEventListener("sessionend",Ot),pn.stop()};function le(P){P.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function ne(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;const P=ie.autoReset,$=Je.enabled,re=Je.autoUpdate,oe=Je.needsUpdate,j=Je.type;At(),ie.autoReset=P,Je.enabled=$,Je.autoUpdate=re,Je.needsUpdate=oe,Je.type=j}function ue(P){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",P.statusMessage)}function Me(P){const $=P.target;$.removeEventListener("dispose",Me),We($)}function We(P){tt(P),he.remove(P)}function tt(P){const $=he.get(P).programs;$!==void 0&&($.forEach(function(re){de.releaseProgram(re)}),P.isShaderMaterial&&de.releaseShaderCache(P))}this.renderBufferDirect=function(P,$,re,oe,j,Te){$===null&&($=se);const Le=j.isMesh&&j.matrixWorld.determinant()<0,ze=Wm(P,$,re,oe,j);W.setMaterial(oe,Le);let Ge=re.index,Qe=1;if(oe.wireframe===!0){if(Ge=Q.getWireframeAttribute(re),Ge===void 0)return;Qe=2}const et=re.drawRange,Ye=re.attributes.position;let ft=et.start*Qe,Tt=(et.start+et.count)*Qe;Te!==null&&(ft=Math.max(ft,Te.start*Qe),Tt=Math.min(Tt,(Te.start+Te.count)*Qe)),Ge!==null?(ft=Math.max(ft,0),Tt=Math.min(Tt,Ge.count)):Ye!=null&&(ft=Math.max(ft,0),Tt=Math.min(Tt,Ye.count));const Ct=Tt-ft;if(Ct<0||Ct===1/0)return;nt.setup(j,oe,ze,re,Ge);let gn,gt=rt;if(Ge!==null&&(gn=w.get(Ge),gt=Ke,gt.setIndex(gn)),j.isMesh)oe.wireframe===!0?(W.setLineWidth(oe.wireframeLinewidth*K()),gt.setMode(D.LINES)):gt.setMode(D.TRIANGLES);else if(j.isLine){let $e=oe.linewidth;$e===void 0&&($e=1),W.setLineWidth($e*K()),j.isLineSegments?gt.setMode(D.LINES):j.isLineLoop?gt.setMode(D.LINE_LOOP):gt.setMode(D.LINE_STRIP)}else j.isPoints?gt.setMode(D.POINTS):j.isSprite&>.setMode(D.TRIANGLES);if(j.isBatchedMesh)j._multiDrawInstances!==null?gt.renderMultiDrawInstances(j._multiDrawStarts,j._multiDrawCounts,j._multiDrawCount,j._multiDrawInstances):gt.renderMultiDraw(j._multiDrawStarts,j._multiDrawCounts,j._multiDrawCount);else if(j.isInstancedMesh)gt.renderInstances(ft,Ct,j.count);else if(re.isInstancedBufferGeometry){const $e=re._maxInstanceCount!==void 0?re._maxInstanceCount:1/0,tn=Math.min(re.instanceCount,$e);gt.renderInstances(ft,Ct,tn)}else gt.render(ft,Ct)};function Et(P,$,re){P.transparent===!0&&P.side===In&&P.forceSinglePass===!1?(P.side=an,P.needsUpdate=!0,co(P,$,re),P.side=ci,P.needsUpdate=!0,co(P,$,re),P.side=In):co(P,$,re)}this.compile=function(P,$,re=null){re===null&&(re=P),p=Ce.get(re),p.init($),y.push(p),re.traverseVisible(function(j){j.isLight&&j.layers.test($.layers)&&(p.pushLight(j),j.castShadow&&p.pushShadow(j))}),P!==re&&P.traverseVisible(function(j){j.isLight&&j.layers.test($.layers)&&(p.pushLight(j),j.castShadow&&p.pushShadow(j))}),p.setupLights();const oe=new Set;return P.traverse(function(j){const Te=j.material;if(Te)if(Array.isArray(Te))for(let Le=0;Le<Te.length;Le++){const ze=Te[Le];Et(ze,re,j),oe.add(ze)}else Et(Te,re,j),oe.add(Te)}),y.pop(),p=null,oe},this.compileAsync=function(P,$,re=null){const oe=this.compile(P,$,re);return new Promise(j=>{function Te(){if(oe.forEach(function(Le){he.get(Le).currentProgram.isReady()&&oe.delete(Le)}),oe.size===0){j(P);return}setTimeout(Te,10)}J.get("KHR_parallel_shader_compile")!==null?Te():setTimeout(Te,10)})};let Dt=null;function ht(P){Dt&&Dt(P)}function Ut(){pn.stop()}function Ot(){pn.start()}const pn=new Lp;pn.setAnimationLoop(ht),typeof self<"u"&&pn.setContext(self),this.setAnimationLoop=function(P){Dt=P,M.setAnimationLoop(P),P===null?pn.stop():pn.start()},M.addEventListener("sessionstart",Ut),M.addEventListener("sessionend",Ot),this.render=function(P,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(x===!0)return;if(P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),$.parent===null&&$.matrixWorldAutoUpdate===!0&&$.updateMatrixWorld(),M.enabled===!0&&M.isPresenting===!0&&(M.cameraAutoUpdate===!0&&M.updateCamera($),$=M.getCamera()),P.isScene===!0&&P.onBeforeRender(v,P,$,C),p=Ce.get(P,y.length),p.init($),y.push(p),I.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),De.setFromProjectionMatrix(I),U=this.localClippingEnabled,F=Ee.init(this.clippingPlanes,U),_=Be.get(P,m.length),_.init(),m.push(_),M.enabled===!0&&M.isPresenting===!0){const Te=v.xr.getDepthSensingMesh();Te!==null&&mn(Te,$,-1/0,v.sortObjects)}mn(P,$,0,v.sortObjects),_.finish(),v.sortObjects===!0&&_.sort(z,Se),fe=M.enabled===!1||M.isPresenting===!1||M.hasDepthSensing()===!1,fe&&be.addToRenderList(_,P),this.info.render.frame++,F===!0&&Ee.beginShadows();const re=p.state.shadowsArray;Je.render(re,P,$),F===!0&&Ee.endShadows(),this.info.autoReset===!0&&this.info.reset();const oe=_.opaque,j=_.transmissive;if(p.setupLights(),$.isArrayCamera){const Te=$.cameras;if(j.length>0)for(let Le=0,ze=Te.length;Le<ze;Le++){const Ge=Te[Le];Oi(oe,j,P,Ge)}fe&&be.render(P);for(let Le=0,ze=Te.length;Le<ze;Le++){const Ge=Te[Le];gi(_,P,Ge,Ge.viewport)}}else j.length>0&&Oi(oe,j,P,$),fe&&be.render(P),gi(_,P,$);C!==null&&(B.updateMultisampleRenderTarget(C),B.updateRenderTargetMipmap(C)),P.isScene===!0&&P.onAfterRender(v,P,$),nt.resetDefaultState(),L=-1,A=null,y.pop(),y.length>0?(p=y[y.length-1],F===!0&&Ee.setGlobalState(v.clippingPlanes,p.state.camera)):p=null,m.pop(),m.length>0?_=m[m.length-1]:_=null};function mn(P,$,re,oe){if(P.visible===!1)return;if(P.layers.test($.layers)){if(P.isGroup)re=P.renderOrder;else if(P.isLOD)P.autoUpdate===!0&&P.update($);else if(P.isLight)p.pushLight(P),P.castShadow&&p.pushShadow(P);else if(P.isSprite){if(!P.frustumCulled||De.intersectsSprite(P)){oe&&T.setFromMatrixPosition(P.matrixWorld).applyMatrix4(I);const Le=me.update(P),ze=P.material;ze.visible&&_.push(P,Le,ze,re,T.z,null)}}else if((P.isMesh||P.isLine||P.isPoints)&&(!P.frustumCulled||De.intersectsObject(P))){const Le=me.update(P),ze=P.material;if(oe&&(P.boundingSphere!==void 0?(P.boundingSphere===null&&P.computeBoundingSphere(),T.copy(P.boundingSphere.center)):(Le.boundingSphere===null&&Le.computeBoundingSphere(),T.copy(Le.boundingSphere.center)),T.applyMatrix4(P.matrixWorld).applyMatrix4(I)),Array.isArray(ze)){const Ge=Le.groups;for(let Qe=0,et=Ge.length;Qe<et;Qe++){const Ye=Ge[Qe],ft=ze[Ye.materialIndex];ft&&ft.visible&&_.push(P,Le,ft,re,T.z,Ye)}}else ze.visible&&_.push(P,Le,ze,re,T.z,null)}}const Te=P.children;for(let Le=0,ze=Te.length;Le<ze;Le++)mn(Te[Le],$,re,oe)}function gi(P,$,re,oe){const j=P.opaque,Te=P.transmissive,Le=P.transparent;p.setupLightsView(re),F===!0&&Ee.setGlobalState(v.clippingPlanes,re),oe&&W.viewport(b.copy(oe)),j.length>0&&Fi(j,$,re),Te.length>0&&Fi(Te,$,re),Le.length>0&&Fi(Le,$,re),W.buffers.depth.setTest(!0),W.buffers.depth.setMask(!0),W.buffers.color.setMask(!0),W.setPolygonOffset(!1)}function Oi(P,$,re,oe){if((re.isScene===!0?re.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[oe.id]===void 0&&(p.state.transmissionRenderTarget[oe.id]=new Un(1,1,{generateMipmaps:!0,type:J.has("EXT_color_buffer_half_float")||J.has("EXT_color_buffer_float")?Jr:hi,minFilter:Vn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:dt.workingColorSpace}));const Te=p.state.transmissionRenderTarget[oe.id],Le=oe.viewport||b;Te.setSize(Le.z,Le.w);const ze=v.getRenderTarget();v.setRenderTarget(Te),v.getClearColor(G),X=v.getClearAlpha(),X<1&&v.setClearColor(16777215,.5),fe?be.render(re):v.clear();const Ge=v.toneMapping;v.toneMapping=Wn;const Qe=oe.viewport;if(oe.viewport!==void 0&&(oe.viewport=void 0),p.setupLightsView(oe),F===!0&&Ee.setGlobalState(v.clippingPlanes,oe),Fi(P,re,oe),B.updateMultisampleRenderTarget(Te),B.updateRenderTargetMipmap(Te),J.has("WEBGL_multisampled_render_to_texture")===!1){let et=!1;for(let Ye=0,ft=$.length;Ye<ft;Ye++){const Tt=$[Ye],Ct=Tt.object,gn=Tt.geometry,gt=Tt.material,$e=Tt.group;if(gt.side===In&&Ct.layers.test(oe.layers)){const tn=gt.side;gt.side=an,gt.needsUpdate=!0,nh(Ct,re,oe,gn,gt,$e),gt.side=tn,gt.needsUpdate=!0,et=!0}}et===!0&&(B.updateMultisampleRenderTarget(Te),B.updateRenderTargetMipmap(Te))}v.setRenderTarget(ze),v.setClearColor(G,X),Qe!==void 0&&(oe.viewport=Qe),v.toneMapping=Ge}function Fi(P,$,re){const oe=$.isScene===!0?$.overrideMaterial:null;for(let j=0,Te=P.length;j<Te;j++){const Le=P[j],ze=Le.object,Ge=Le.geometry,Qe=oe===null?Le.material:oe,et=Le.group;ze.layers.test(re.layers)&&nh(ze,$,re,Ge,Qe,et)}}function nh(P,$,re,oe,j,Te){P.onBeforeRender(v,$,re,oe,j,Te),P.modelViewMatrix.multiplyMatrices(re.matrixWorldInverse,P.matrixWorld),P.normalMatrix.getNormalMatrix(P.modelViewMatrix),j.onBeforeRender(v,$,re,oe,P,Te),j.transparent===!0&&j.side===In&&j.forceSinglePass===!1?(j.side=an,j.needsUpdate=!0,v.renderBufferDirect(re,$,oe,j,P,Te),j.side=ci,j.needsUpdate=!0,v.renderBufferDirect(re,$,oe,j,P,Te),j.side=In):v.renderBufferDirect(re,$,oe,j,P,Te),P.onAfterRender(v,$,re,oe,j,Te)}function co(P,$,re){$.isScene!==!0&&($=se);const oe=he.get(P),j=p.state.lights,Te=p.state.shadowsArray,Le=j.state.version,ze=de.getParameters(P,j.state,Te,$,re),Ge=de.getProgramCacheKey(ze);let Qe=oe.programs;oe.environment=P.isMeshStandardMaterial?$.environment:null,oe.fog=$.fog,oe.envMap=(P.isMeshStandardMaterial?R:O).get(P.envMap||oe.environment),oe.envMapRotation=oe.environment!==null&&P.envMap===null?$.environmentRotation:P.envMapRotation,Qe===void 0&&(P.addEventListener("dispose",Me),Qe=new Map,oe.programs=Qe);let et=Qe.get(Ge);if(et!==void 0){if(oe.currentProgram===et&&oe.lightsStateVersion===Le)return sh(P,ze),et}else ze.uniforms=de.getUniforms(P),P.onBuild(re,ze,v),P.onBeforeCompile(ze,v),et=de.acquireProgram(ze,Ge),Qe.set(Ge,et),oe.uniforms=ze.uniforms;const Ye=oe.uniforms;return(!P.isShaderMaterial&&!P.isRawShaderMaterial||P.clipping===!0)&&(Ye.clippingPlanes=Ee.uniform),sh(P,ze),oe.needsLights=Xm(P),oe.lightsStateVersion=Le,oe.needsLights&&(Ye.ambientLightColor.value=j.state.ambient,Ye.lightProbe.value=j.state.probe,Ye.directionalLights.value=j.state.directional,Ye.directionalLightShadows.value=j.state.directionalShadow,Ye.spotLights.value=j.state.spot,Ye.spotLightShadows.value=j.state.spotShadow,Ye.rectAreaLights.value=j.state.rectArea,Ye.ltc_1.value=j.state.rectAreaLTC1,Ye.ltc_2.value=j.state.rectAreaLTC2,Ye.pointLights.value=j.state.point,Ye.pointLightShadows.value=j.state.pointShadow,Ye.hemisphereLights.value=j.state.hemi,Ye.directionalShadowMap.value=j.state.directionalShadowMap,Ye.directionalShadowMatrix.value=j.state.directionalShadowMatrix,Ye.spotShadowMap.value=j.state.spotShadowMap,Ye.spotLightMatrix.value=j.state.spotLightMatrix,Ye.spotLightMap.value=j.state.spotLightMap,Ye.pointShadowMap.value=j.state.pointShadowMap,Ye.pointShadowMatrix.value=j.state.pointShadowMatrix),oe.currentProgram=et,oe.uniformsList=null,et}function ih(P){if(P.uniformsList===null){const $=P.currentProgram.getUniforms();P.uniformsList=_a.seqWithValue($.seq,P.uniforms)}return P.uniformsList}function sh(P,$){const re=he.get(P);re.outputColorSpace=$.outputColorSpace,re.batching=$.batching,re.batchingColor=$.batchingColor,re.instancing=$.instancing,re.instancingColor=$.instancingColor,re.instancingMorph=$.instancingMorph,re.skinning=$.skinning,re.morphTargets=$.morphTargets,re.morphNormals=$.morphNormals,re.morphColors=$.morphColors,re.morphTargetsCount=$.morphTargetsCount,re.numClippingPlanes=$.numClippingPlanes,re.numIntersection=$.numClipIntersection,re.vertexAlphas=$.vertexAlphas,re.vertexTangents=$.vertexTangents,re.toneMapping=$.toneMapping}function Wm(P,$,re,oe,j){$.isScene!==!0&&($=se),B.resetTextureUnits();const Te=$.fog,Le=oe.isMeshStandardMaterial?$.environment:null,ze=C===null?v.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:fi,Ge=(oe.isMeshStandardMaterial?R:O).get(oe.envMap||Le),Qe=oe.vertexColors===!0&&!!re.attributes.color&&re.attributes.color.itemSize===4,et=!!re.attributes.tangent&&(!!oe.normalMap||oe.anisotropy>0),Ye=!!re.morphAttributes.position,ft=!!re.morphAttributes.normal,Tt=!!re.morphAttributes.color;let Ct=Wn;oe.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(Ct=v.toneMapping);const gn=re.morphAttributes.position||re.morphAttributes.normal||re.morphAttributes.color,gt=gn!==void 0?gn.length:0,$e=he.get(oe),tn=p.state.lights;if(F===!0&&(U===!0||P!==A)){const Sn=P===A&&oe.id===L;Ee.setState(oe,P,Sn)}let vt=!1;oe.version===$e.__version?($e.needsLights&&$e.lightsStateVersion!==tn.state.version||$e.outputColorSpace!==ze||j.isBatchedMesh&&$e.batching===!1||!j.isBatchedMesh&&$e.batching===!0||j.isBatchedMesh&&$e.batchingColor===!0&&j.colorTexture===null||j.isBatchedMesh&&$e.batchingColor===!1&&j.colorTexture!==null||j.isInstancedMesh&&$e.instancing===!1||!j.isInstancedMesh&&$e.instancing===!0||j.isSkinnedMesh&&$e.skinning===!1||!j.isSkinnedMesh&&$e.skinning===!0||j.isInstancedMesh&&$e.instancingColor===!0&&j.instanceColor===null||j.isInstancedMesh&&$e.instancingColor===!1&&j.instanceColor!==null||j.isInstancedMesh&&$e.instancingMorph===!0&&j.morphTexture===null||j.isInstancedMesh&&$e.instancingMorph===!1&&j.morphTexture!==null||$e.envMap!==Ge||oe.fog===!0&&$e.fog!==Te||$e.numClippingPlanes!==void 0&&($e.numClippingPlanes!==Ee.numPlanes||$e.numIntersection!==Ee.numIntersection)||$e.vertexAlphas!==Qe||$e.vertexTangents!==et||$e.morphTargets!==Ye||$e.morphNormals!==ft||$e.morphColors!==Tt||$e.toneMapping!==Ct||$e.morphTargetsCount!==gt)&&(vt=!0):(vt=!0,$e.__version=oe.version);let Kn=$e.currentProgram;vt===!0&&(Kn=co(oe,$,j));let uo=!1,ki=!1,dl=!1;const Ht=Kn.getUniforms(),_i=$e.uniforms;if(W.useProgram(Kn.program)&&(uo=!0,ki=!0,dl=!0),oe.id!==L&&(L=oe.id,ki=!0),uo||A!==P){Ht.setValue(D,"projectionMatrix",P.projectionMatrix),Ht.setValue(D,"viewMatrix",P.matrixWorldInverse);const Sn=Ht.map.cameraPosition;Sn!==void 0&&Sn.setValue(D,T.setFromMatrixPosition(P.matrixWorld)),H.logarithmicDepthBuffer&&Ht.setValue(D,"logDepthBufFC",2/(Math.log(P.far+1)/Math.LN2)),(oe.isMeshPhongMaterial||oe.isMeshToonMaterial||oe.isMeshLambertMaterial||oe.isMeshBasicMaterial||oe.isMeshStandardMaterial||oe.isShaderMaterial)&&Ht.setValue(D,"isOrthographic",P.isOrthographicCamera===!0),A!==P&&(A=P,ki=!0,dl=!0)}if(j.isSkinnedMesh){Ht.setOptional(D,j,"bindMatrix"),Ht.setOptional(D,j,"bindMatrixInverse");const Sn=j.skeleton;Sn&&(Sn.boneTexture===null&&Sn.computeBoneTexture(),Ht.setValue(D,"boneTexture",Sn.boneTexture,B))}j.isBatchedMesh&&(Ht.setOptional(D,j,"batchingTexture"),Ht.setValue(D,"batchingTexture",j._matricesTexture,B),Ht.setOptional(D,j,"batchingColorTexture"),j._colorsTexture!==null&&Ht.setValue(D,"batchingColorTexture",j._colorsTexture,B));const fl=re.morphAttributes;if((fl.position!==void 0||fl.normal!==void 0||fl.color!==void 0)&&Ne.update(j,re,Kn),(ki||$e.receiveShadow!==j.receiveShadow)&&($e.receiveShadow=j.receiveShadow,Ht.setValue(D,"receiveShadow",j.receiveShadow)),oe.isMeshGouraudMaterial&&oe.envMap!==null&&(_i.envMap.value=Ge,_i.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),oe.isMeshStandardMaterial&&oe.envMap===null&&$.environment!==null&&(_i.envMapIntensity.value=$.environmentIntensity),ki&&(Ht.setValue(D,"toneMappingExposure",v.toneMappingExposure),$e.needsLights&&$m(_i,dl),Te&&oe.fog===!0&&ye.refreshFogUniforms(_i,Te),ye.refreshMaterialUniforms(_i,oe,ae,Z,p.state.transmissionRenderTarget[P.id]),_a.upload(D,ih($e),_i,B)),oe.isShaderMaterial&&oe.uniformsNeedUpdate===!0&&(_a.upload(D,ih($e),_i,B),oe.uniformsNeedUpdate=!1),oe.isSpriteMaterial&&Ht.setValue(D,"center",j.center),Ht.setValue(D,"modelViewMatrix",j.modelViewMatrix),Ht.setValue(D,"normalMatrix",j.normalMatrix),Ht.setValue(D,"modelMatrix",j.matrixWorld),oe.isShaderMaterial||oe.isRawShaderMaterial){const Sn=oe.uniformsGroups;for(let pl=0,qm=Sn.length;pl<qm;pl++){const rh=Sn[pl];it.update(rh,Kn),it.bind(rh,Kn)}}return Kn}function $m(P,$){P.ambientLightColor.needsUpdate=$,P.lightProbe.needsUpdate=$,P.directionalLights.needsUpdate=$,P.directionalLightShadows.needsUpdate=$,P.pointLights.needsUpdate=$,P.pointLightShadows.needsUpdate=$,P.spotLights.needsUpdate=$,P.spotLightShadows.needsUpdate=$,P.rectAreaLights.needsUpdate=$,P.hemisphereLights.needsUpdate=$}function Xm(P){return P.isMeshLambertMaterial||P.isMeshToonMaterial||P.isMeshPhongMaterial||P.isMeshStandardMaterial||P.isShadowMaterial||P.isShaderMaterial&&P.lights===!0}this.getActiveCubeFace=function(){return E},this.getActiveMipmapLevel=function(){return S},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(P,$,re){he.get(P.texture).__webglTexture=$,he.get(P.depthTexture).__webglTexture=re;const oe=he.get(P);oe.__hasExternalTextures=!0,oe.__autoAllocateDepthBuffer=re===void 0,oe.__autoAllocateDepthBuffer||J.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),oe.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(P,$){const re=he.get(P);re.__webglFramebuffer=$,re.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(P,$=0,re=0){C=P,E=$,S=re;let oe=!0,j=null,Te=!1,Le=!1;if(P){const Ge=he.get(P);Ge.__useDefaultFramebuffer!==void 0?(W.bindFramebuffer(D.FRAMEBUFFER,null),oe=!1):Ge.__webglFramebuffer===void 0?B.setupRenderTarget(P):Ge.__hasExternalTextures&&B.rebindTextures(P,he.get(P.texture).__webglTexture,he.get(P.depthTexture).__webglTexture);const Qe=P.texture;(Qe.isData3DTexture||Qe.isDataArrayTexture||Qe.isCompressedArrayTexture)&&(Le=!0);const et=he.get(P).__webglFramebuffer;P.isWebGLCubeRenderTarget?(Array.isArray(et[$])?j=et[$][re]:j=et[$],Te=!0):P.samples>0&&B.useMultisampledRTT(P)===!1?j=he.get(P).__webglMultisampledFramebuffer:Array.isArray(et)?j=et[re]:j=et,b.copy(P.viewport),k.copy(P.scissor),V=P.scissorTest}else b.copy(we).multiplyScalar(ae).floor(),k.copy(Ae).multiplyScalar(ae).floor(),V=_e;if(W.bindFramebuffer(D.FRAMEBUFFER,j)&&oe&&W.drawBuffers(P,j),W.viewport(b),W.scissor(k),W.setScissorTest(V),Te){const Ge=he.get(P.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+$,Ge.__webglTexture,re)}else if(Le){const Ge=he.get(P.texture),Qe=$||0;D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ge.__webglTexture,re||0,Qe)}L=-1},this.readRenderTargetPixels=function(P,$,re,oe,j,Te,Le){if(!(P&&P.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ze=he.get(P).__webglFramebuffer;if(P.isWebGLCubeRenderTarget&&Le!==void 0&&(ze=ze[Le]),ze){W.bindFramebuffer(D.FRAMEBUFFER,ze);try{const Ge=P.texture,Qe=Ge.format,et=Ge.type;if(!H.textureFormatReadable(Qe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!H.textureTypeReadable(et)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=P.width-oe&&re>=0&&re<=P.height-j&&D.readPixels($,re,oe,j,Re.convert(Qe),Re.convert(et),Te)}finally{const Ge=C!==null?he.get(C).__webglFramebuffer:null;W.bindFramebuffer(D.FRAMEBUFFER,Ge)}}},this.readRenderTargetPixelsAsync=async function(P,$,re,oe,j,Te,Le){if(!(P&&P.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ze=he.get(P).__webglFramebuffer;if(P.isWebGLCubeRenderTarget&&Le!==void 0&&(ze=ze[Le]),ze){W.bindFramebuffer(D.FRAMEBUFFER,ze);try{const Ge=P.texture,Qe=Ge.format,et=Ge.type;if(!H.textureFormatReadable(Qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!H.textureTypeReadable(et))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if($>=0&&$<=P.width-oe&&re>=0&&re<=P.height-j){const Ye=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,Ye),D.bufferData(D.PIXEL_PACK_BUFFER,Te.byteLength,D.STREAM_READ),D.readPixels($,re,oe,j,Re.convert(Qe),Re.convert(et),0),D.flush();const ft=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);await MM(D,ft,4);try{D.bindBuffer(D.PIXEL_PACK_BUFFER,Ye),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,Te)}finally{D.deleteBuffer(Ye),D.deleteSync(ft)}return Te}}finally{const Ge=C!==null?he.get(C).__webglFramebuffer:null;W.bindFramebuffer(D.FRAMEBUFFER,Ge)}}},this.copyFramebufferToTexture=function(P,$=null,re=0){P.isTexture!==!0&&(console.warn("WebGLRenderer: copyFramebufferToTexture function signature has changed."),$=arguments[0]||null,P=arguments[1]);const oe=Math.pow(2,-re),j=Math.floor(P.image.width*oe),Te=Math.floor(P.image.height*oe),Le=$!==null?$.x:0,ze=$!==null?$.y:0;B.setTexture2D(P,0),D.copyTexSubImage2D(D.TEXTURE_2D,re,0,0,Le,ze,j,Te),W.unbindTexture()},this.copyTextureToTexture=function(P,$,re=null,oe=null,j=0){P.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture function signature has changed."),oe=arguments[0]||null,P=arguments[1],$=arguments[2],j=arguments[3]||0,re=null);let Te,Le,ze,Ge,Qe,et;re!==null?(Te=re.max.x-re.min.x,Le=re.max.y-re.min.y,ze=re.min.x,Ge=re.min.y):(Te=P.image.width,Le=P.image.height,ze=0,Ge=0),oe!==null?(Qe=oe.x,et=oe.y):(Qe=0,et=0);const Ye=Re.convert($.format),ft=Re.convert($.type);B.setTexture2D($,0),D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,$.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,$.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,$.unpackAlignment);const Tt=D.getParameter(D.UNPACK_ROW_LENGTH),Ct=D.getParameter(D.UNPACK_IMAGE_HEIGHT),gn=D.getParameter(D.UNPACK_SKIP_PIXELS),gt=D.getParameter(D.UNPACK_SKIP_ROWS),$e=D.getParameter(D.UNPACK_SKIP_IMAGES),tn=P.isCompressedTexture?P.mipmaps[j]:P.image;D.pixelStorei(D.UNPACK_ROW_LENGTH,tn.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,tn.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,ze),D.pixelStorei(D.UNPACK_SKIP_ROWS,Ge),P.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,j,Qe,et,Te,Le,Ye,ft,tn.data):P.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,j,Qe,et,tn.width,tn.height,Ye,tn.data):D.texSubImage2D(D.TEXTURE_2D,j,Qe,et,Ye,ft,tn),D.pixelStorei(D.UNPACK_ROW_LENGTH,Tt),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Ct),D.pixelStorei(D.UNPACK_SKIP_PIXELS,gn),D.pixelStorei(D.UNPACK_SKIP_ROWS,gt),D.pixelStorei(D.UNPACK_SKIP_IMAGES,$e),j===0&&$.generateMipmaps&&D.generateMipmap(D.TEXTURE_2D),W.unbindTexture()},this.copyTextureToTexture3D=function(P,$,re=null,oe=null,j=0){P.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture3D function signature has changed."),re=arguments[0]||null,oe=arguments[1]||null,P=arguments[2],$=arguments[3],j=arguments[4]||0);let Te,Le,ze,Ge,Qe,et,Ye,ft,Tt;const Ct=P.isCompressedTexture?P.mipmaps[j]:P.image;re!==null?(Te=re.max.x-re.min.x,Le=re.max.y-re.min.y,ze=re.max.z-re.min.z,Ge=re.min.x,Qe=re.min.y,et=re.min.z):(Te=Ct.width,Le=Ct.height,ze=Ct.depth,Ge=0,Qe=0,et=0),oe!==null?(Ye=oe.x,ft=oe.y,Tt=oe.z):(Ye=0,ft=0,Tt=0);const gn=Re.convert($.format),gt=Re.convert($.type);let $e;if($.isData3DTexture)B.setTexture3D($,0),$e=D.TEXTURE_3D;else if($.isDataArrayTexture||$.isCompressedArrayTexture)B.setTexture2DArray($,0),$e=D.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,$.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,$.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,$.unpackAlignment);const tn=D.getParameter(D.UNPACK_ROW_LENGTH),vt=D.getParameter(D.UNPACK_IMAGE_HEIGHT),Kn=D.getParameter(D.UNPACK_SKIP_PIXELS),uo=D.getParameter(D.UNPACK_SKIP_ROWS),ki=D.getParameter(D.UNPACK_SKIP_IMAGES);D.pixelStorei(D.UNPACK_ROW_LENGTH,Ct.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Ct.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,Ge),D.pixelStorei(D.UNPACK_SKIP_ROWS,Qe),D.pixelStorei(D.UNPACK_SKIP_IMAGES,et),P.isDataTexture||P.isData3DTexture?D.texSubImage3D($e,j,Ye,ft,Tt,Te,Le,ze,gn,gt,Ct.data):$.isCompressedArrayTexture?D.compressedTexSubImage3D($e,j,Ye,ft,Tt,Te,Le,ze,gn,Ct.data):D.texSubImage3D($e,j,Ye,ft,Tt,Te,Le,ze,gn,gt,Ct),D.pixelStorei(D.UNPACK_ROW_LENGTH,tn),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,vt),D.pixelStorei(D.UNPACK_SKIP_PIXELS,Kn),D.pixelStorei(D.UNPACK_SKIP_ROWS,uo),D.pixelStorei(D.UNPACK_SKIP_IMAGES,ki),j===0&&$.generateMipmaps&&D.generateMipmap($e),W.unbindTexture()},this.initRenderTarget=function(P){he.get(P).__webglFramebuffer===void 0&&B.setupRenderTarget(P)},this.initTexture=function(P){P.isCubeTexture?B.setTextureCube(P,0):P.isData3DTexture?B.setTexture3D(P,0):P.isDataArrayTexture||P.isCompressedArrayTexture?B.setTexture2DArray(P,0):B.setTexture2D(P,0),W.unbindTexture()},this.resetState=function(){E=0,S=0,C=null,W.reset(),nt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Hn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===ka?"display-p3":"srgb",t.unpackColorSpace=dt.workingColorSpace===jr?"display-p3":"srgb"}}class Ga{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ie(e),this.density=t}clone(){return new Ga(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Wa{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ie(e),this.near=t,this.far=n}clone(){return new Wa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class $a extends ut{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new bn,this.environmentIntensity=1,this.environmentRotation=new bn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Xa{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ur,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Mn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return wu("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const nn=new N;class fs{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)nn.fromBufferAttribute(this,t),nn.applyMatrix4(e),this.setXYZ(t,nn.x,nn.y,nn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)nn.fromBufferAttribute(this,t),nn.applyNormalMatrix(e),this.setXYZ(t,nn.x,nn.y,nn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)nn.fromBufferAttribute(this,t),nn.transformDirection(e),this.setXYZ(t,nn.x,nn.y,nn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=on(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=st(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=st(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=on(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=on(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=on(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=on(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=st(t,this.array),n=st(n,this.array),i=st(i,this.array),r=st(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new mt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new fs(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Lu extends en{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ie(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Us;const rr=new N,Os=new N,Fs=new N,ks=new te,or=new te,zp=new Ze,No=new N,ar=new N,Do=new N,Zh=new te,Vl=new te,Kh=new te;class Vp extends ut{constructor(e=new Lu){if(super(),this.isSprite=!0,this.type="Sprite",Us===void 0){Us=new at;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Xa(t,5);Us.setIndex([0,1,2,0,2,3]),Us.setAttribute("position",new fs(n,3,0,!1)),Us.setAttribute("uv",new fs(n,2,3,!1))}this.geometry=Us,this.material=e,this.center=new te(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Os.setFromMatrixScale(this.matrixWorld),zp.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Fs.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Os.multiplyScalar(-Fs.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const o=this.center;Uo(No.set(-.5,-.5,0),Fs,o,Os,i,r),Uo(ar.set(.5,-.5,0),Fs,o,Os,i,r),Uo(Do.set(.5,.5,0),Fs,o,Os,i,r),Zh.set(0,0),Vl.set(1,0),Kh.set(1,1);let a=e.ray.intersectTriangle(No,ar,Do,!1,rr);if(a===null&&(Uo(ar.set(-.5,.5,0),Fs,o,Os,i,r),Vl.set(0,1),a=e.ray.intersectTriangle(No,Do,ar,!1,rr),a===null))return;const l=e.ray.origin.distanceTo(rr);l<e.near||l>e.far||t.push({distance:l,point:rr.clone(),uv:yn.getInterpolation(rr,No,ar,Do,Zh,Vl,Kh,new te),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Uo(s,e,t,n,i,r){ks.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(or.x=r*ks.x-i*ks.y,or.y=i*ks.x+r*ks.y):or.copy(ks),s.copy(e),s.x+=or.x,s.y+=or.y,s.applyMatrix4(zp)}const Oo=new N,Jh=new N;class Hp extends ut{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const r=t[n];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let r;for(r=0;r<i.length&&!(t<i[r].distance);r++);return i.splice(r,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Oo.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Oo);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Oo.setFromMatrixPosition(e.matrixWorld),Jh.setFromMatrixPosition(this.matrixWorld);const n=Oo.distanceTo(Jh)/e.zoom;t[0].object.visible=!0;let i,r;for(i=1,r=t.length;i<r;i++){let o=t[i].distance;if(t[i].object.visible&&(o-=o*t[i].hysteresis),n>=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<r;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let i=0,r=n.length;i<r;i++){const o=n[i];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}}const jh=new N,Qh=new _t,ed=new _t,CA=new N,td=new Ze,Fo=new N,Hl=new jt,nd=new Ze,Gl=new ms;class Gp extends Nt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=dc,this.bindMatrix=new Ze,this.bindMatrixInverse=new Ze,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ln),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Fo),this.boundingBox.expandByPoint(Fo)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new jt),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Fo),this.boundingSphere.expandByPoint(Fo)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Hl.copy(this.boundingSphere),Hl.applyMatrix4(i),e.ray.intersectsSphere(Hl)!==!1&&(nd.copy(i).invert(),Gl.copy(e.ray).applyMatrix4(nd),!(this.boundingBox!==null&&Gl.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Gl)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new _t,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===dc?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===ep?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;Qh.fromBufferAttribute(i.attributes.skinIndex,e),ed.fromBufferAttribute(i.attributes.skinWeight,e),jh.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const o=ed.getComponent(r);if(o!==0){const a=Qh.getComponent(r);td.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(CA.copy(jh).applyMatrix4(td),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Nu extends ut{constructor(){super(),this.isBone=!0,this.type="Bone"}}class li extends It{constructor(e=null,t=1,n=1,i,r,o,a,l,c=Wt,u=Wt,h,d){super(null,o,a,l,c,u,i,r,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const id=new Ze,PA=new Ze;class qa{constructor(e=[],t=[]){this.uuid=Mn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ze)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Ze;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,o=e.length;r<o;r++){const a=e[r]?e[r].matrixWorld:PA;id.multiplyMatrices(a,t[r]),id.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new qa(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new li(t,e,e,fn,xn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new Nu),this.bones.push(o),this.boneInverses.push(new Ze().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const o=t[i];e.bones.push(o.uuid);const a=n[i];e.boneInverses.push(a.toArray())}return e}}class Ks extends mt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Bs=new Ze,sd=new Ze,ko=[],rd=new ln,RA=new Ze,lr=new Nt,cr=new jt;class Wp extends Nt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ks(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,RA)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ln),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Bs),rd.copy(e.boundingBox).applyMatrix4(Bs),this.boundingBox.union(rd)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new jt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Bs),cr.copy(e.boundingSphere).applyMatrix4(Bs),this.boundingSphere.union(cr)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,o=e*r+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(lr.geometry=this.geometry,lr.material=this.material,lr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),cr.copy(this.boundingSphere),cr.applyMatrix4(n),e.ray.intersectsSphere(cr)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,Bs),sd.multiplyMatrices(n,Bs),lr.matrixWorld=sd,lr.raycast(e,ko);for(let o=0,a=ko.length;o<a;o++){const l=ko[o];l.instanceId=r,l.object=this,t.push(l)}ko.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ks(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new li(new Float32Array(i*this.count),i,this.count,gu,xn));const r=this.morphTexture.source.data.data;let o=0;for(let c=0;c<n.length;c++)o+=n[c];const a=this.geometry.morphTargetsRelative?1:1-o,l=i*e;r[l]=a,r.set(n,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function IA(s,e){return s.z-e.z}function LA(s,e){return e.z-s.z}class NA{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){const n=this.pool,i=this.list;this.index>=n.length&&n.push({start:-1,count:-1,z:-1});const r=n[this.index];i.push(r),this.index++,r.start=e.start,r.count=e.count,r.z=t}reset(){this.list.length=0,this.index=0}}const zs="batchId",wi=new Ze,Wl=new Ze,DA=new Ze,UA=new Ie(1,1,1),od=new Ze,$l=new to,Bo=new ln,$i=new jt,ur=new N,ad=new N,OA=new N,Xl=new NA,Kt=new Nt,zo=[];function FA(s,e,t=0){const n=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const i=s.count;for(let r=0;r<i;r++)for(let o=0;o<n;o++)e.setComponent(r+t,o,s.getComponent(r,o))}else e.array.set(s.array,t*n);e.needsUpdate=!0}class $p extends Nt{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,n=t*2,i){super(new at,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture(),this._colorsTexture=null}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new li(t,e,e,fn,xn);this._matricesTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxGeometryCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new li(t,e,e,fn,xn);n.colorSpace=dt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,i=this._maxGeometryCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const a in e.attributes){const l=e.getAttribute(a),{array:c,itemSize:u,normalized:h}=l,d=new c.constructor(n*u),f=new mt(d,u,h);t.setAttribute(a,f)}if(e.getIndex()!==null){const a=n>65536?new Uint32Array(r):new Uint16Array(r);t.setIndex(new mt(a,1))}const o=i>65536?new Uint32Array(n):new Uint16Array(n);t.setAttribute(zs,new mt(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(zs))throw new Error(`BatchedMesh: Geometry cannot use attribute "${zs}"`);const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(n===zs)continue;if(!e.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ln);const e=this._geometryCount,t=this.boundingBox,n=this._active;t.makeEmpty();for(let i=0;i<e;i++)n[i]!==!1&&(this.getMatrixAt(i,wi),this.getBoundingBoxAt(i,Bo).applyMatrix4(wi),t.union(Bo))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new jt);const e=this._geometryCount,t=this.boundingSphere,n=this._active;t.makeEmpty();for(let i=0;i<e;i++)n[i]!==!1&&(this.getMatrixAt(i,wi),this.getBoundingSphereAt(i,$i).applyMatrix4(wi),t.union($i))}addGeometry(e,t=-1,n=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let r=null;const o=this._reservedRanges,a=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(r=o[o.length-1]),t===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=t,r===null?i.vertexStart=0:i.vertexStart=r.vertexStart+r.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(n===-1?i.indexCount=c.count:i.indexCount=n,r===null?i.indexStart=0:i.indexStart=r.indexStart+r.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._visibility,d=this._active,f=this._matricesTexture,g=this._matricesTexture.image.data,_=this._colorsTexture;h.push(!0),d.push(!0);const p=this._geometryCount;this._geometryCount++,DA.toArray(g,p*16),f.needsUpdate=!0,_!==null&&(UA.toArray(_.image.data,p*4),_.needsUpdate=!0),o.push(i),a.push({start:u?i.indexStart:i.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new ln,sphereInitialized:!1,sphere:new jt});const m=this.geometry.getAttribute(zs);for(let y=0;y<i.vertexCount;y++)m.setX(i.vertexStart+y,p);return m.needsUpdate=!0,this.setGeometryAt(p,e),p}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(i&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=a.vertexStart,c=a.vertexCount;for(const f in n.attributes){if(f===zs)continue;const g=t.getAttribute(f),_=n.getAttribute(f);FA(g,_,l);const p=g.itemSize;for(let m=g.count,y=c;m<y;m++){const v=l+m;for(let x=0;x<p;x++)_.setComponent(v,x,0)}_.needsUpdate=!0,_.addUpdateRange(l*p,c*p)}if(i){const f=a.indexStart;for(let g=0;g<o.count;g++)r.setX(f+g,l+o.getX(g));for(let g=o.count,_=a.indexCount;g<_;g++)r.setX(f+g,l);r.needsUpdate=!0,r.addUpdateRange(f,a.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],d=t.getAttribute("position");return h.count=i?o.count:d.count,this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getInstanceCountAt(e){return this._multiDrawInstances===null?null:this._multiDrawInstances[e]}setInstanceCountAt(e,t){return this._multiDrawInstances===null&&(this._multiDrawInstances=new Int32Array(this._maxGeometryCount).fill(1)),this._multiDrawInstances[e]=t,e}getBoundingBoxAt(e,t){if(this._active[e]===!1)return null;const i=this._bounds[e],r=i.box,o=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();const a=o.index,l=o.attributes.position,c=this._drawRanges[e];for(let u=c.start,h=c.start+c.count;u<h;u++){let d=u;a&&(d=a.getX(d)),r.expandByPoint(ur.fromBufferAttribute(l,d))}i.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return null;const i=this._bounds[e],r=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,Bo),Bo.getCenter(r.center);const a=o.index,l=o.attributes.position,c=this._drawRanges[e];let u=0;for(let h=c.start,d=c.start+c.count;h<d;h++){let f=h;a&&(f=a.getX(f)),ur.fromBufferAttribute(l,f),u=Math.max(u,r.center.distanceToSquared(ur))}r.radius=Math.sqrt(u),i.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const n=this._active,i=this._matricesTexture,r=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||n[e]===!1?this:(t.toArray(r,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,t){const n=this._active,i=this._matricesTexture.image.data,r=this._geometryCount;return e>=r||n[e]===!1?null:t.fromArray(i,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const n=this._active,i=this._colorsTexture,r=this._colorsTexture.image.data,o=this._geometryCount;return e>=o||n[e]===!1?this:(t.toArray(r,e*4),i.needsUpdate=!0,this)}getColorAt(e,t){const n=this._active,i=this._colorsTexture.image.data,r=this._geometryCount;return e>=r||n[e]===!1?null:t.fromArray(i,e*4)}setVisibleAt(e,t){const n=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1||n[e]===t?this:(n[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._visibility,n=this._active,i=this._geometryCount;return e>=i||n[e]===!1?!1:t[e]}raycast(e,t){const n=this._visibility,i=this._active,r=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,l=this.geometry;Kt.material=this.material,Kt.geometry.index=l.index,Kt.geometry.attributes=l.attributes,Kt.geometry.boundingBox===null&&(Kt.geometry.boundingBox=new ln),Kt.geometry.boundingSphere===null&&(Kt.geometry.boundingSphere=new jt);for(let c=0;c<o;c++){if(!n[c]||!i[c])continue;const u=r[c];Kt.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,Kt.matrixWorld).premultiply(a),this.getBoundingBoxAt(c,Kt.geometry.boundingBox),this.getBoundingSphereAt(c,Kt.geometry.boundingSphere),Kt.raycast(e,zo);for(let h=0,d=zo.length;h<d;h++){const f=zo[h];f.object=this,f.batchId=c,t.push(f)}zo.length=0}Kt.material=null,Kt.geometry.index=null,Kt.geometry.attributes={},Kt.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,l=this._active,c=this._visibility,u=this._multiDrawStarts,h=this._multiDrawCounts,d=this._drawRanges,f=this.perObjectFrustumCulled;f&&(od.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),$l.setFromProjectionMatrix(od,e.coordinateSystem));let g=0;if(this.sortObjects){Wl.copy(this.matrixWorld).invert(),ur.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Wl),ad.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Wl);for(let m=0,y=c.length;m<y;m++)if(c[m]&&l[m]){this.getMatrixAt(m,wi),this.getBoundingSphereAt(m,$i).applyMatrix4(wi);let v=!1;if(f&&(v=!$l.intersectsSphere($i)),!v){const x=OA.subVectors($i.center,ur).dot(ad);Xl.push(d[m],x)}}const _=Xl.list,p=this.customSort;p===null?_.sort(r.transparent?LA:IA):p.call(this,_,n);for(let m=0,y=_.length;m<y;m++){const v=_[m];u[g]=v.start*a,h[g]=v.count,g++}Xl.reset()}else for(let _=0,p=c.length;_<p;_++)if(c[_]&&l[_]){let m=!1;if(f&&(this.getMatrixAt(_,wi),this.getBoundingSphereAt(_,$i).applyMatrix4(wi),m=!$l.intersectsSphere($i)),!m){const y=d[_];u[g]=y.start*a,h[g]=y.count,g++}}this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,r,o){this.onBeforeRender(e,null,i,r,o)}}class cn extends en{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ie(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Ta=new N,Ca=new N,ld=new Ze,hr=new ms,Vo=new jt,ql=new N,cd=new N;class Ii extends ut{constructor(e=new at,t=new cn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Ta.fromBufferAttribute(t,i-1),Ca.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Ta.distanceTo(Ca);e.setAttribute("lineDistance",new Oe(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Vo.copy(n.boundingSphere),Vo.applyMatrix4(i),Vo.radius+=r,e.ray.intersectsSphere(Vo)===!1)return;ld.copy(i).invert(),hr.copy(e.ray).applyMatrix4(ld);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){const f=Math.max(0,o.start),g=Math.min(u.count,o.start+o.count);for(let _=f,p=g-1;_<p;_+=c){const m=u.getX(_),y=u.getX(_+1),v=Ho(this,e,hr,l,m,y);v&&t.push(v)}if(this.isLineLoop){const _=u.getX(g-1),p=u.getX(f),m=Ho(this,e,hr,l,_,p);m&&t.push(m)}}else{const f=Math.max(0,o.start),g=Math.min(d.count,o.start+o.count);for(let _=f,p=g-1;_<p;_+=c){const m=Ho(this,e,hr,l,_,_+1);m&&t.push(m)}if(this.isLineLoop){const _=Ho(this,e,hr,l,g-1,f);_&&t.push(_)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Ho(s,e,t,n,i,r){const o=s.geometry.attributes.position;if(Ta.fromBufferAttribute(o,i),Ca.fromBufferAttribute(o,r),t.distanceSqToSegment(Ta,Ca,ql,cd)>n)return;ql.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(ql);if(!(l<e.near||l>e.far))return{distance:l,point:cd.clone().applyMatrix4(s.matrixWorld),index:i,face:null,faceIndex:null,object:s}}const ud=new N,hd=new N;class Zn extends Ii{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)ud.fromBufferAttribute(t,i),hd.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+ud.distanceTo(hd);e.setAttribute("lineDistance",new Oe(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Xp extends Ii{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Du extends en{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ie(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const dd=new Ze,Gc=new ms,Go=new jt,Wo=new N;class qp extends ut{constructor(e=new at,t=new Du){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Go.copy(n.boundingSphere),Go.applyMatrix4(i),Go.radius+=r,e.ray.intersectsSphere(Go)===!1)return;dd.copy(i).invert(),Gc.copy(e.ray).applyMatrix4(dd);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,h=n.attributes.position;if(c!==null){const d=Math.max(0,o.start),f=Math.min(c.count,o.start+o.count);for(let g=d,_=f;g<_;g++){const p=c.getX(g);Wo.fromBufferAttribute(h,p),fd(Wo,p,l,i,e,t,this)}}else{const d=Math.max(0,o.start),f=Math.min(h.count,o.start+o.count);for(let g=d,_=f;g<_;g++)Wo.fromBufferAttribute(h,g),fd(Wo,g,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function fd(s,e,t,n,i,r,o){const a=Gc.distanceSqToPoint(s);if(a<t){const l=new N;Gc.closestPointToPoint(s,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class kA extends It{constructor(e,t,n,i,r,o,a,l,c){super(e,t,n,i,r,o,a,l,c),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Bt,this.magFilter=r!==void 0?r:Bt,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class BA extends It{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Wt,this.minFilter=Wt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ya extends It{constructor(e,t,n,i,r,o,a,l,c,u,h,d){super(null,o,a,l,c,u,i,r,h,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class zA extends Ya{constructor(e,t,n,i,r,o){super(e,t,n,r,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=An,this.layerUpdates=new Set}addLayerUpdates(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class VA extends Ya{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,ui),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class HA extends It{constructor(e,t,n,i,r,o,a,l,c){super(e,t,n,i,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class kn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let o;t?o=t:o=e*n[r-1];let a=0,l=r-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(r-1);const u=n[i],d=n[i+1]-u,f=(o-u)/d;return(i+f)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const o=this.getPoint(i),a=this.getPoint(r),l=t||(o.isVector2?new te:new N);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new N,i=[],r=[],o=[],a=new N,l=new Ze;for(let f=0;f<=e;f++){const g=f/e;i[f]=this.getTangentAt(g,new N)}r[0]=new N,o[0]=new N;let c=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=c&&(c=u,n.set(1,0,0)),h<=c&&(c=h,n.set(0,1,0)),d<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();const g=Math.acos(Rt(i[f-1].dot(i[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(a,g))}o[f].crossVectors(i[f],r[f])}if(t===!0){let f=Math.acos(Rt(r[0].dot(r[e]),-1,1));f/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(f=-f);for(let g=1;g<=e;g++)r[g].applyMatrix4(l.makeRotationAxis(i[g],f*g)),o[g].crossVectors(i[g],r[g])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Za extends kn{constructor(e=0,t=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new te){const n=t,i=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(o?r=0:r=i),this.aClockwise===!0&&!o&&(r===i?r=-i:r=r-i);const a=this.aStartAngle+e*r;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*u-f*h+this.aX,c=d*h+f*u+this.aY}return n.set(l,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Yp extends Za{constructor(e,t,n,i,r,o){super(e,t,n,n,i,r,o),this.isArcCurve=!0,this.type="ArcCurve"}}function Uu(){let s=0,e=0,t=0,n=0;function i(r,o,a,l){s=r,e=a,t=-3*r+3*o-2*a-l,n=2*r-2*o+a+l}return{initCatmullRom:function(r,o,a,l,c){i(o,a,c*(a-r),c*(l-o))},initNonuniformCatmullRom:function(r,o,a,l,c,u,h){let d=(o-r)/c-(a-r)/(c+u)+(a-o)/u,f=(a-o)/u-(l-o)/(u+h)+(l-a)/h;d*=u,f*=u,i(o,a,d,f)},calc:function(r){const o=r*r,a=o*r;return s+e*r+t*o+n*a}}}const $o=new N,Yl=new Uu,Zl=new Uu,Kl=new Uu;class Zp extends kn{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new N){const n=t,i=this.points,r=i.length,o=(r-(this.closed?0:1))*e;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:l===0&&a===r-1&&(a=r-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%r]:($o.subVectors(i[0],i[1]).add(i[0]),c=$o);const h=i[a%r],d=i[(a+1)%r];if(this.closed||a+2<r?u=i[(a+2)%r]:($o.subVectors(i[r-1],i[r-2]).add(i[r-1]),u=$o),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(h),f),_=Math.pow(h.distanceToSquared(d),f),p=Math.pow(d.distanceToSquared(u),f);_<1e-4&&(_=1),g<1e-4&&(g=_),p<1e-4&&(p=_),Yl.initNonuniformCatmullRom(c.x,h.x,d.x,u.x,g,_,p),Zl.initNonuniformCatmullRom(c.y,h.y,d.y,u.y,g,_,p),Kl.initNonuniformCatmullRom(c.z,h.z,d.z,u.z,g,_,p)}else this.curveType==="catmullrom"&&(Yl.initCatmullRom(c.x,h.x,d.x,u.x,this.tension),Zl.initCatmullRom(c.y,h.y,d.y,u.y,this.tension),Kl.initCatmullRom(c.z,h.z,d.z,u.z,this.tension));return n.set(Yl.calc(l),Zl.calc(l),Kl.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new N().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function pd(s,e,t,n,i){const r=(n-e)*.5,o=(i-t)*.5,a=s*s,l=s*a;return(2*t-2*n+r+o)*l+(-3*t+3*n-2*r-o)*a+r*s+t}function GA(s,e){const t=1-s;return t*t*e}function WA(s,e){return 2*(1-s)*s*e}function $A(s,e){return s*s*e}function yr(s,e,t,n){return GA(s,e)+WA(s,t)+$A(s,n)}function XA(s,e){const t=1-s;return t*t*t*e}function qA(s,e){const t=1-s;return 3*t*t*s*e}function YA(s,e){return 3*(1-s)*s*s*e}function ZA(s,e){return s*s*s*e}function xr(s,e,t,n,i){return XA(s,e)+qA(s,t)+YA(s,n)+ZA(s,i)}class Ou extends kn{constructor(e=new te,t=new te,n=new te,i=new te){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new te){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(xr(e,i.x,r.x,o.x,a.x),xr(e,i.y,r.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Kp extends kn{constructor(e=new N,t=new N,n=new N,i=new N){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new N){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(xr(e,i.x,r.x,o.x,a.x),xr(e,i.y,r.y,o.y,a.y),xr(e,i.z,r.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Fu extends kn{constructor(e=new te,t=new te){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new te){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new te){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Jp extends kn{constructor(e=new N,t=new N){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new N){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new N){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class ku extends kn{constructor(e=new te,t=new te,n=new te){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new te){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(yr(e,i.x,r.x,o.x),yr(e,i.y,r.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Bu extends kn{constructor(e=new N,t=new N,n=new N){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new N){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(yr(e,i.x,r.x,o.x),yr(e,i.y,r.y,o.y),yr(e,i.z,r.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class zu extends kn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new te){const n=t,i=this.points,r=(i.length-1)*e,o=Math.floor(r),a=r-o,l=i[o===0?o:o-1],c=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(pd(a,l.x,c.x,u.x,h.x),pd(a,l.y,c.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new te().fromArray(i))}return this}}var Pa=Object.freeze({__proto__:null,ArcCurve:Yp,CatmullRomCurve3:Zp,CubicBezierCurve:Ou,CubicBezierCurve3:Kp,EllipseCurve:Za,LineCurve:Fu,LineCurve3:Jp,QuadraticBezierCurve:ku,QuadraticBezierCurve3:Bu,SplineCurve:zu});class jp extends kn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Pa[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const o=i[r]-n,a=this.curves[r],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const o=r[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let c=0;c<l.length;c++){const u=l[c];n&&n.equals(u)||(t.push(u),n=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new Pa[i.type]().fromJSON(i))}return this}}class Ci extends jp{constructor(e){super(),this.type="Path",this.currentPoint=new te,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Fu(this.currentPoint.clone(),new te(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const r=new ku(this.currentPoint.clone(),new te(e,t),new te(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,o){const a=new Ou(this.currentPoint.clone(),new te(e,t),new te(n,i),new te(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new zu(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,r,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,r,o),this}absarc(e,t,n,i,r,o){return this.absellipse(e,t,n,n,i,r,o),this}ellipse(e,t,n,i,r,o,a,l){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+c,t+u,n,i,r,o,a,l),this}absellipse(e,t,n,i,r,o,a,l){const c=new Za(e,t,n,i,r,o,a,l);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class no extends at{constructor(e=[new te(0,-.5),new te(.5,0),new te(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Rt(i,0,Math.PI*2);const r=[],o=[],a=[],l=[],c=[],u=1/t,h=new N,d=new te,f=new N,g=new N,_=new N;let p=0,m=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:p=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,f.x=m*1,f.y=-p,f.z=m*0,_.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(_.x,_.y,_.z);break;default:p=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,f.x=m*1,f.y=-p,f.z=m*0,g.copy(f),f.x+=_.x,f.y+=_.y,f.z+=_.z,f.normalize(),l.push(f.x,f.y,f.z),_.copy(g)}for(let y=0;y<=t;y++){const v=n+y*u*i,x=Math.sin(v),E=Math.cos(v);for(let S=0;S<=e.length-1;S++){h.x=e[S].x*x,h.y=e[S].y,h.z=e[S].x*E,o.push(h.x,h.y,h.z),d.x=y/t,d.y=S/(e.length-1),a.push(d.x,d.y);const C=l[3*S+0]*x,L=l[3*S+1],A=l[3*S+0]*E;c.push(C,L,A)}}for(let y=0;y<t;y++)for(let v=0;v<e.length-1;v++){const x=v+y*e.length,E=x,S=x+e.length,C=x+e.length+1,L=x+1;r.push(E,S,L),r.push(C,L,S)}this.setIndex(r),this.setAttribute("position",new Oe(o,3)),this.setAttribute("uv",new Oe(a,2)),this.setAttribute("normal",new Oe(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new no(e.points,e.segments,e.phiStart,e.phiLength)}}class Ka extends no{constructor(e=1,t=1,n=4,i=8){const r=new Ci;r.absarc(0,-t/2,e,Math.PI*1.5,0),r.absarc(0,t/2,e,0,Math.PI*.5),super(r.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new Ka(e.radius,e.length,e.capSegments,e.radialSegments)}}class Ja extends at{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],o=[],a=[],l=[],c=new N,u=new te;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const f=n+h/t*i;c.x=e*Math.cos(f),c.y=e*Math.sin(f),o.push(c.x,c.y,c.z),a.push(0,0,1),u.x=(o[d]/e+1)/2,u.y=(o[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)r.push(h,h+1,0);this.setIndex(r),this.setAttribute("position",new Oe(o,3)),this.setAttribute("normal",new Oe(a,3)),this.setAttribute("uv",new Oe(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ja(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class er extends at{constructor(e=1,t=1,n=1,i=32,r=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:l};const c=this;i=Math.floor(i),r=Math.floor(r);const u=[],h=[],d=[],f=[];let g=0;const _=[],p=n/2;let m=0;y(),o===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new Oe(h,3)),this.setAttribute("normal",new Oe(d,3)),this.setAttribute("uv",new Oe(f,2));function y(){const x=new N,E=new N;let S=0;const C=(t-e)/n;for(let L=0;L<=r;L++){const A=[],b=L/r,k=b*(t-e)+e;for(let V=0;V<=i;V++){const G=V/i,X=G*l+a,ce=Math.sin(X),Z=Math.cos(X);E.x=k*ce,E.y=-b*n+p,E.z=k*Z,h.push(E.x,E.y,E.z),x.set(ce,C,Z).normalize(),d.push(x.x,x.y,x.z),f.push(G,1-b),A.push(g++)}_.push(A)}for(let L=0;L<i;L++)for(let A=0;A<r;A++){const b=_[A][L],k=_[A+1][L],V=_[A+1][L+1],G=_[A][L+1];u.push(b,k,G),u.push(k,V,G),S+=6}c.addGroup(m,S,0),m+=S}function v(x){const E=g,S=new te,C=new N;let L=0;const A=x===!0?e:t,b=x===!0?1:-1;for(let V=1;V<=i;V++)h.push(0,p*b,0),d.push(0,b,0),f.push(.5,.5),g++;const k=g;for(let V=0;V<=i;V++){const X=V/i*l+a,ce=Math.cos(X),Z=Math.sin(X);C.x=A*Z,C.y=p*b,C.z=A*ce,h.push(C.x,C.y,C.z),d.push(0,b,0),S.x=ce*.5+.5,S.y=Z*.5*b+.5,f.push(S.x,S.y),g++}for(let V=0;V<i;V++){const G=E+V,X=k+V;x===!0?u.push(X,X+1,G):u.push(X+1,X,G),L+=3}c.addGroup(m,L,x===!0?1:2),m+=L}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new er(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ja extends er{constructor(e=1,t=1,n=32,i=1,r=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,r,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}static fromJSON(e){return new ja(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Di extends at{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],o=[];a(i),c(n),u(),this.setAttribute("position",new Oe(r,3)),this.setAttribute("normal",new Oe(r.slice(),3)),this.setAttribute("uv",new Oe(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(y){const v=new N,x=new N,E=new N;for(let S=0;S<t.length;S+=3)f(t[S+0],v),f(t[S+1],x),f(t[S+2],E),l(v,x,E,y)}function l(y,v,x,E){const S=E+1,C=[];for(let L=0;L<=S;L++){C[L]=[];const A=y.clone().lerp(x,L/S),b=v.clone().lerp(x,L/S),k=S-L;for(let V=0;V<=k;V++)V===0&&L===S?C[L][V]=A:C[L][V]=A.clone().lerp(b,V/k)}for(let L=0;L<S;L++)for(let A=0;A<2*(S-L)-1;A++){const b=Math.floor(A/2);A%2===0?(d(C[L][b+1]),d(C[L+1][b]),d(C[L][b])):(d(C[L][b+1]),d(C[L+1][b+1]),d(C[L+1][b]))}}function c(y){const v=new N;for(let x=0;x<r.length;x+=3)v.x=r[x+0],v.y=r[x+1],v.z=r[x+2],v.normalize().multiplyScalar(y),r[x+0]=v.x,r[x+1]=v.y,r[x+2]=v.z}function u(){const y=new N;for(let v=0;v<r.length;v+=3){y.x=r[v+0],y.y=r[v+1],y.z=r[v+2];const x=p(y)/2/Math.PI+.5,E=m(y)/Math.PI+.5;o.push(x,1-E)}g(),h()}function h(){for(let y=0;y<o.length;y+=6){const v=o[y+0],x=o[y+2],E=o[y+4],S=Math.max(v,x,E),C=Math.min(v,x,E);S>.9&&C<.1&&(v<.2&&(o[y+0]+=1),x<.2&&(o[y+2]+=1),E<.2&&(o[y+4]+=1))}}function d(y){r.push(y.x,y.y,y.z)}function f(y,v){const x=y*3;v.x=e[x+0],v.y=e[x+1],v.z=e[x+2]}function g(){const y=new N,v=new N,x=new N,E=new N,S=new te,C=new te,L=new te;for(let A=0,b=0;A<r.length;A+=9,b+=6){y.set(r[A+0],r[A+1],r[A+2]),v.set(r[A+3],r[A+4],r[A+5]),x.set(r[A+6],r[A+7],r[A+8]),S.set(o[b+0],o[b+1]),C.set(o[b+2],o[b+3]),L.set(o[b+4],o[b+5]),E.copy(y).add(v).add(x).divideScalar(3);const k=p(E);_(S,b+0,y,k),_(C,b+2,v,k),_(L,b+4,x,k)}}function _(y,v,x,E){E<0&&y.x===1&&(o[v]=y.x-1),x.x===0&&x.z===0&&(o[v]=E/2/Math.PI+.5)}function p(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Di(e.vertices,e.indices,e.radius,e.details)}}class Qa extends Di{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(r,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Qa(e.radius,e.detail)}}const Xo=new N,qo=new N,Jl=new N,Yo=new yn;class Qp extends at{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),r=Math.cos(ls*t),o=e.getIndex(),a=e.getAttribute("position"),l=o?o.count:a.count,c=[0,0,0],u=["a","b","c"],h=new Array(3),d={},f=[];for(let g=0;g<l;g+=3){o?(c[0]=o.getX(g),c[1]=o.getX(g+1),c[2]=o.getX(g+2)):(c[0]=g,c[1]=g+1,c[2]=g+2);const{a:_,b:p,c:m}=Yo;if(_.fromBufferAttribute(a,c[0]),p.fromBufferAttribute(a,c[1]),m.fromBufferAttribute(a,c[2]),Yo.getNormal(Jl),h[0]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,h[1]=`${Math.round(p.x*i)},${Math.round(p.y*i)},${Math.round(p.z*i)}`,h[2]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let y=0;y<3;y++){const v=(y+1)%3,x=h[y],E=h[v],S=Yo[u[y]],C=Yo[u[v]],L=`${x}_${E}`,A=`${E}_${x}`;A in d&&d[A]?(Jl.dot(d[A].normal)<=r&&(f.push(S.x,S.y,S.z),f.push(C.x,C.y,C.z)),d[A]=null):L in d||(d[L]={index0:c[y],index1:c[v],normal:Jl.clone()})}}for(const g in d)if(d[g]){const{index0:_,index1:p}=d[g];Xo.fromBufferAttribute(a,_),qo.fromBufferAttribute(a,p),f.push(Xo.x,Xo.y,Xo.z),f.push(qo.x,qo.y,qo.z)}this.setAttribute("position",new Oe(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Pi extends Ci{constructor(e){super(e),this.uuid=Mn(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new Ci().fromJSON(i))}return this}}const KA={triangulate:function(s,e,t=2){const n=e&&e.length,i=n?e[0]*t:s.length;let r=em(s,0,i,t,!0);const o=[];if(!r||r.next===r.prev)return o;let a,l,c,u,h,d,f;if(n&&(r=tE(s,e,r,t)),s.length>80*t){a=c=s[0],l=u=s[1];for(let g=t;g<i;g+=t)h=s[g],d=s[g+1],h<a&&(a=h),d<l&&(l=d),h>c&&(c=h),d>u&&(u=d);f=Math.max(c-a,u-l),f=f!==0?32767/f:0}return kr(r,o,t,a,l,f,0),o}};function em(s,e,t,n,i){let r,o;if(i===dE(s,e,t,n)>0)for(r=e;r<t;r+=n)o=md(r,s[r],s[r+1],o);else for(r=t-n;r>=e;r-=n)o=md(r,s[r],s[r+1],o);return o&&el(o,o.next)&&(zr(o),o=o.next),o}function ps(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(el(t,t.next)||St(t.prev,t,t.next)===0)){if(zr(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function kr(s,e,t,n,i,r,o){if(!s)return;!o&&r&&oE(s,n,i,r);let a=s,l,c;for(;s.prev!==s.next;){if(l=s.prev,c=s.next,r?jA(s,n,i,r):JA(s)){e.push(l.i/t|0),e.push(s.i/t|0),e.push(c.i/t|0),zr(s),s=c.next,a=c.next;continue}if(s=c,s===a){o?o===1?(s=QA(ps(s),e,t),kr(s,e,t,n,i,r,2)):o===2&&eE(s,e,t,n,i,r):kr(ps(s),e,t,n,i,r,1);break}}}function JA(s){const e=s.prev,t=s,n=s.next;if(St(e,t,n)>=0)return!1;const i=e.x,r=t.x,o=n.x,a=e.y,l=t.y,c=n.y,u=i<r?i<o?i:o:r<o?r:o,h=a<l?a<c?a:c:l<c?l:c,d=i>r?i>o?i:o:r>o?r:o,f=a>l?a>c?a:c:l>c?l:c;let g=n.next;for(;g!==e;){if(g.x>=u&&g.x<=d&&g.y>=h&&g.y<=f&&$s(i,a,r,l,o,c,g.x,g.y)&&St(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function jA(s,e,t,n){const i=s.prev,r=s,o=s.next;if(St(i,r,o)>=0)return!1;const a=i.x,l=r.x,c=o.x,u=i.y,h=r.y,d=o.y,f=a<l?a<c?a:c:l<c?l:c,g=u<h?u<d?u:d:h<d?h:d,_=a>l?a>c?a:c:l>c?l:c,p=u>h?u>d?u:d:h>d?h:d,m=Wc(f,g,e,t,n),y=Wc(_,p,e,t,n);let v=s.prevZ,x=s.nextZ;for(;v&&v.z>=m&&x&&x.z<=y;){if(v.x>=f&&v.x<=_&&v.y>=g&&v.y<=p&&v!==i&&v!==o&&$s(a,u,l,h,c,d,v.x,v.y)&&St(v.prev,v,v.next)>=0||(v=v.prevZ,x.x>=f&&x.x<=_&&x.y>=g&&x.y<=p&&x!==i&&x!==o&&$s(a,u,l,h,c,d,x.x,x.y)&&St(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;v&&v.z>=m;){if(v.x>=f&&v.x<=_&&v.y>=g&&v.y<=p&&v!==i&&v!==o&&$s(a,u,l,h,c,d,v.x,v.y)&&St(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=_&&x.y>=g&&x.y<=p&&x!==i&&x!==o&&$s(a,u,l,h,c,d,x.x,x.y)&&St(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function QA(s,e,t){let n=s;do{const i=n.prev,r=n.next.next;!el(i,r)&&tm(i,n,n.next,r)&&Br(i,r)&&Br(r,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(r.i/t|0),zr(n),zr(n.next),n=s=r),n=n.next}while(n!==s);return ps(n)}function eE(s,e,t,n,i,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&cE(o,a)){let l=nm(o,a);o=ps(o,o.next),l=ps(l,l.next),kr(o,e,t,n,i,r,0),kr(l,e,t,n,i,r,0);return}a=a.next}o=o.next}while(o!==s)}function tE(s,e,t,n){const i=[];let r,o,a,l,c;for(r=0,o=e.length;r<o;r++)a=e[r]*n,l=r<o-1?e[r+1]*n:s.length,c=em(s,a,l,n,!1),c===c.next&&(c.steiner=!0),i.push(lE(c));for(i.sort(nE),r=0;r<i.length;r++)t=iE(i[r],t);return t}function nE(s,e){return s.x-e.x}function iE(s,e){const t=sE(s,e);if(!t)return e;const n=nm(t,s);return ps(n,n.next),ps(t,t.next)}function sE(s,e){let t=e,n=-1/0,i;const r=s.x,o=s.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const d=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=r&&d>n&&(n=d,i=t.x<t.next.x?t:t.next,d===r))return i}t=t.next}while(t!==e);if(!i)return null;const a=i,l=i.x,c=i.y;let u=1/0,h;t=i;do r>=t.x&&t.x>=l&&r!==t.x&&$s(o<c?r:n,o,l,c,o<c?n:r,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(r-t.x),Br(t,s)&&(h<u||h===u&&(t.x>i.x||t.x===i.x&&rE(i,t)))&&(i=t,u=h)),t=t.next;while(t!==a);return i}function rE(s,e){return St(s.prev,s,e.prev)<0&&St(e.next,s,s.next)<0}function oE(s,e,t,n){let i=s;do i.z===0&&(i.z=Wc(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,aE(i)}function aE(s){let e,t,n,i,r,o,a,l,c=1;do{for(t=s,s=null,r=null,o=0;t;){for(o++,n=t,a=0,e=0;e<c&&(a++,n=n.nextZ,!!n);e++);for(l=c;a>0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;t=n}r.nextZ=null,c*=2}while(o>1);return s}function Wc(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function lE(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function $s(s,e,t,n,i,r,o,a){return(i-o)*(e-a)>=(s-o)*(r-a)&&(s-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(i-o)*(n-a)}function cE(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!uE(s,e)&&(Br(s,e)&&Br(e,s)&&hE(s,e)&&(St(s.prev,s,e.prev)||St(s,e.prev,e))||el(s,e)&&St(s.prev,s,s.next)>0&&St(e.prev,e,e.next)>0)}function St(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function el(s,e){return s.x===e.x&&s.y===e.y}function tm(s,e,t,n){const i=Ko(St(s,e,t)),r=Ko(St(s,e,n)),o=Ko(St(t,n,s)),a=Ko(St(t,n,e));return!!(i!==r&&o!==a||i===0&&Zo(s,t,e)||r===0&&Zo(s,n,e)||o===0&&Zo(t,s,n)||a===0&&Zo(t,e,n))}function Zo(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function Ko(s){return s>0?1:s<0?-1:0}function uE(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&tm(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Br(s,e){return St(s.prev,s,s.next)<0?St(s,e,s.next)>=0&&St(s,s.prev,e)>=0:St(s,e,s.prev)<0||St(s,s.next,e)<0}function hE(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&i<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function nm(s,e){const t=new $c(s.i,s.x,s.y),n=new $c(e.i,e.x,e.y),i=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function md(s,e,t,n){const i=new $c(s,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function zr(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function $c(s,e,t){this.i=s,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function dE(s,e,t,n){let i=0;for(let r=e,o=t-n;r<t;r+=n)i+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return i}class Nn{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return n*.5}static isClockWise(e){return Nn.area(e)<0}static triangulateShape(e,t){const n=[],i=[],r=[];gd(e),_d(n,e);let o=e.length;t.forEach(gd);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,_d(n,t[l]);const a=KA.triangulate(n,i);for(let l=0;l<a.length;l+=3)r.push(a.slice(l,l+3));return r}}function gd(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function _d(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class tl extends at{constructor(e=new Pi([new te(.5,.5),new te(-.5,.5),new te(-.5,-.5),new te(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],r=[];for(let a=0,l=e.length;a<l;a++){const c=e[a];o(c)}this.setAttribute("position",new Oe(i,3)),this.setAttribute("uv",new Oe(r,2)),this.computeVertexNormals();function o(a){const l=[],c=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,f=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:f-.1,_=t.bevelOffset!==void 0?t.bevelOffset:0,p=t.bevelSegments!==void 0?t.bevelSegments:3;const m=t.extrudePath,y=t.UVGenerator!==void 0?t.UVGenerator:fE;let v,x=!1,E,S,C,L;m&&(v=m.getSpacedPoints(u),x=!0,d=!1,E=m.computeFrenetFrames(u,!1),S=new N,C=new N,L=new N),d||(p=0,f=0,g=0,_=0);const A=a.extractPoints(c);let b=A.shape;const k=A.holes;if(!Nn.isClockWise(b)){b=b.reverse();for(let q=0,J=k.length;q<J;q++){const H=k[q];Nn.isClockWise(H)&&(k[q]=H.reverse())}}const G=Nn.triangulateShape(b,k),X=b;for(let q=0,J=k.length;q<J;q++){const H=k[q];b=b.concat(H)}function ce(q,J,H){return J||console.error("THREE.ExtrudeGeometry: vec does not exist"),q.clone().addScaledVector(J,H)}const Z=b.length,ae=G.length;function z(q,J,H){let W,ie,he;const B=q.x-J.x,O=q.y-J.y,R=H.x-q.x,w=H.y-q.y,Q=B*B+O*O,me=B*w-O*R;if(Math.abs(me)>Number.EPSILON){const de=Math.sqrt(Q),ye=Math.sqrt(R*R+w*w),Be=J.x-O/de,Ce=J.y+B/de,Ee=H.x-w/ye,Je=H.y+R/ye,be=((Ee-Be)*w-(Je-Ce)*R)/(B*w-O*R);W=Be+B*be-q.x,ie=Ce+O*be-q.y;const Ne=W*W+ie*ie;if(Ne<=2)return new te(W,ie);he=Math.sqrt(Ne/2)}else{let de=!1;B>Number.EPSILON?R>Number.EPSILON&&(de=!0):B<-Number.EPSILON?R<-Number.EPSILON&&(de=!0):Math.sign(O)===Math.sign(w)&&(de=!0),de?(W=-O,ie=B,he=Math.sqrt(Q)):(W=B,ie=O,he=Math.sqrt(Q/2))}return new te(W/he,ie/he)}const Se=[];for(let q=0,J=X.length,H=J-1,W=q+1;q<J;q++,H++,W++)H===J&&(H=0),W===J&&(W=0),Se[q]=z(X[q],X[H],X[W]);const we=[];let Ae,_e=Se.concat();for(let q=0,J=k.length;q<J;q++){const H=k[q];Ae=[];for(let W=0,ie=H.length,he=ie-1,B=W+1;W<ie;W++,he++,B++)he===ie&&(he=0),B===ie&&(B=0),Ae[W]=z(H[W],H[he],H[B]);we.push(Ae),_e=_e.concat(Ae)}for(let q=0;q<p;q++){const J=q/p,H=f*Math.cos(J*Math.PI/2),W=g*Math.sin(J*Math.PI/2)+_;for(let ie=0,he=X.length;ie<he;ie++){const B=ce(X[ie],Se[ie],W);T(B.x,B.y,-H)}for(let ie=0,he=k.length;ie<he;ie++){const B=k[ie];Ae=we[ie];for(let O=0,R=B.length;O<R;O++){const w=ce(B[O],Ae[O],W);T(w.x,w.y,-H)}}}const De=g+_;for(let q=0;q<Z;q++){const J=d?ce(b[q],_e[q],De):b[q];x?(C.copy(E.normals[0]).multiplyScalar(J.x),S.copy(E.binormals[0]).multiplyScalar(J.y),L.copy(v[0]).add(C).add(S),T(L.x,L.y,L.z)):T(J.x,J.y,0)}for(let q=1;q<=u;q++)for(let J=0;J<Z;J++){const H=d?ce(b[J],_e[J],De):b[J];x?(C.copy(E.normals[q]).multiplyScalar(H.x),S.copy(E.binormals[q]).multiplyScalar(H.y),L.copy(v[q]).add(C).add(S),T(L.x,L.y,L.z)):T(H.x,H.y,h/u*q)}for(let q=p-1;q>=0;q--){const J=q/p,H=f*Math.cos(J*Math.PI/2),W=g*Math.sin(J*Math.PI/2)+_;for(let ie=0,he=X.length;ie<he;ie++){const B=ce(X[ie],Se[ie],W);T(B.x,B.y,h+H)}for(let ie=0,he=k.length;ie<he;ie++){const B=k[ie];Ae=we[ie];for(let O=0,R=B.length;O<R;O++){const w=ce(B[O],Ae[O],W);x?T(w.x,w.y+v[u-1].y,v[u-1].x+H):T(w.x,w.y,h+H)}}}F(),U();function F(){const q=i.length/3;if(d){let J=0,H=Z*J;for(let W=0;W<ae;W++){const ie=G[W];se(ie[2]+H,ie[1]+H,ie[0]+H)}J=u+p*2,H=Z*J;for(let W=0;W<ae;W++){const ie=G[W];se(ie[0]+H,ie[1]+H,ie[2]+H)}}else{for(let J=0;J<ae;J++){const H=G[J];se(H[2],H[1],H[0])}for(let J=0;J<ae;J++){const H=G[J];se(H[0]+Z*u,H[1]+Z*u,H[2]+Z*u)}}n.addGroup(q,i.length/3-q,0)}function U(){const q=i.length/3;let J=0;I(X,J),J+=X.length;for(let H=0,W=k.length;H<W;H++){const ie=k[H];I(ie,J),J+=ie.length}n.addGroup(q,i.length/3-q,1)}function I(q,J){let H=q.length;for(;--H>=0;){const W=H;let ie=H-1;ie<0&&(ie=q.length-1);for(let he=0,B=u+p*2;he<B;he++){const O=Z*he,R=Z*(he+1),w=J+W+O,Q=J+ie+O,me=J+ie+R,de=J+W+R;fe(w,Q,me,de)}}}function T(q,J,H){l.push(q),l.push(J),l.push(H)}function se(q,J,H){K(q),K(J),K(H);const W=i.length/3,ie=y.generateTopUV(n,i,W-3,W-2,W-1);D(ie[0]),D(ie[1]),D(ie[2])}function fe(q,J,H,W){K(q),K(J),K(W),K(J),K(H),K(W);const ie=i.length/3,he=y.generateSideWallUV(n,i,ie-6,ie-3,ie-2,ie-1);D(he[0]),D(he[1]),D(he[3]),D(he[1]),D(he[2]),D(he[3])}function K(q){i.push(l[q*3+0]),i.push(l[q*3+1]),i.push(l[q*3+2])}function D(q){r.push(q.x),r.push(q.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return pE(t,n,e)}static fromJSON(e,t){const n=[];for(let r=0,o=e.shapes.length;r<o;r++){const a=t[e.shapes[r]];n.push(a)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new Pa[i.type]().fromJSON(i)),new tl(n,e.options)}}const fE={generateTopUV:function(s,e,t,n,i){const r=e[t*3],o=e[t*3+1],a=e[n*3],l=e[n*3+1],c=e[i*3],u=e[i*3+1];return[new te(r,o),new te(a,l),new te(c,u)]},generateSideWallUV:function(s,e,t,n,i,r){const o=e[t*3],a=e[t*3+1],l=e[t*3+2],c=e[n*3],u=e[n*3+1],h=e[n*3+2],d=e[i*3],f=e[i*3+1],g=e[i*3+2],_=e[r*3],p=e[r*3+1],m=e[r*3+2];return Math.abs(a-u)<Math.abs(o-c)?[new te(o,1-l),new te(c,1-h),new te(d,1-g),new te(_,1-m)]:[new te(a,1-l),new te(u,1-h),new te(f,1-g),new te(p,1-m)]}};function pE(s,e,t){if(t.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){const r=s[n];t.shapes.push(r.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class nl extends Di{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new nl(e.radius,e.detail)}}class io extends Di{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new io(e.radius,e.detail)}}class il extends at{constructor(e=.5,t=1,n=32,i=1,r=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);const a=[],l=[],c=[],u=[];let h=e;const d=(t-e)/i,f=new N,g=new te;for(let _=0;_<=i;_++){for(let p=0;p<=n;p++){const m=r+p/n*o;f.x=h*Math.cos(m),f.y=h*Math.sin(m),l.push(f.x,f.y,f.z),c.push(0,0,1),g.x=(f.x/t+1)/2,g.y=(f.y/t+1)/2,u.push(g.x,g.y)}h+=d}for(let _=0;_<i;_++){const p=_*(n+1);for(let m=0;m<n;m++){const y=m+p,v=y,x=y+n+1,E=y+n+2,S=y+1;a.push(v,x,S),a.push(x,E,S)}}this.setIndex(a),this.setAttribute("position",new Oe(l,3)),this.setAttribute("normal",new Oe(c,3)),this.setAttribute("uv",new Oe(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new il(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class sl extends at{constructor(e=new Pi([new te(0,.5),new te(-.5,-.5),new te(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],r=[],o=[];let a=0,l=0;if(Array.isArray(e)===!1)c(e);else for(let u=0;u<e.length;u++)c(e[u]),this.addGroup(a,l,u),a+=l,l=0;this.setIndex(n),this.setAttribute("position",new Oe(i,3)),this.setAttribute("normal",new Oe(r,3)),this.setAttribute("uv",new Oe(o,2));function c(u){const h=i.length/3,d=u.extractPoints(t);let f=d.shape;const g=d.holes;Nn.isClockWise(f)===!1&&(f=f.reverse());for(let p=0,m=g.length;p<m;p++){const y=g[p];Nn.isClockWise(y)===!0&&(g[p]=y.reverse())}const _=Nn.triangulateShape(f,g);for(let p=0,m=g.length;p<m;p++){const y=g[p];f=f.concat(y)}for(let p=0,m=f.length;p<m;p++){const y=f[p];i.push(y.x,y.y,0),r.push(0,0,1),o.push(y.x,y.y)}for(let p=0,m=_.length;p<m;p++){const y=_[p],v=y[0]+h,x=y[1]+h,E=y[2]+h;n.push(v,x,E),l+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return mE(t,e)}static fromJSON(e,t){const n=[];for(let i=0,r=e.shapes.length;i<r;i++){const o=t[e.shapes[i]];n.push(o)}return new sl(n,e.curveSegments)}}function mE(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,n=s.length;t<n;t++){const i=s[t];e.shapes.push(i.uuid)}else e.shapes.push(s.uuid);return e}class so extends at{constructor(e=1,t=32,n=16,i=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(o+a,Math.PI);let c=0;const u=[],h=new N,d=new N,f=[],g=[],_=[],p=[];for(let m=0;m<=n;m++){const y=[],v=m/n;let x=0;m===0&&o===0?x=.5/t:m===n&&l===Math.PI&&(x=-.5/t);for(let E=0;E<=t;E++){const S=E/t;h.x=-e*Math.cos(i+S*r)*Math.sin(o+v*a),h.y=e*Math.cos(o+v*a),h.z=e*Math.sin(i+S*r)*Math.sin(o+v*a),g.push(h.x,h.y,h.z),d.copy(h).normalize(),_.push(d.x,d.y,d.z),p.push(S+x,1-v),y.push(c++)}u.push(y)}for(let m=0;m<n;m++)for(let y=0;y<t;y++){const v=u[m][y+1],x=u[m][y],E=u[m+1][y],S=u[m+1][y+1];(m!==0||o>0)&&f.push(v,x,S),(m!==n-1||l<Math.PI)&&f.push(x,E,S)}this.setIndex(f),this.setAttribute("position",new Oe(g,3)),this.setAttribute("normal",new Oe(_,3)),this.setAttribute("uv",new Oe(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new so(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class rl extends Di{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new rl(e.radius,e.detail)}}class ol extends at{constructor(e=1,t=.4,n=12,i=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const o=[],a=[],l=[],c=[],u=new N,h=new N,d=new N;for(let f=0;f<=n;f++)for(let g=0;g<=i;g++){const _=g/i*r,p=f/n*Math.PI*2;h.x=(e+t*Math.cos(p))*Math.cos(_),h.y=(e+t*Math.cos(p))*Math.sin(_),h.z=t*Math.sin(p),a.push(h.x,h.y,h.z),u.x=e*Math.cos(_),u.y=e*Math.sin(_),d.subVectors(h,u).normalize(),l.push(d.x,d.y,d.z),c.push(g/i),c.push(f/n)}for(let f=1;f<=n;f++)for(let g=1;g<=i;g++){const _=(i+1)*f+g-1,p=(i+1)*(f-1)+g-1,m=(i+1)*(f-1)+g,y=(i+1)*f+g;o.push(_,p,y),o.push(p,m,y)}this.setIndex(o),this.setAttribute("position",new Oe(a,3)),this.setAttribute("normal",new Oe(l,3)),this.setAttribute("uv",new Oe(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ol(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class al extends at{constructor(e=1,t=.4,n=64,i=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:r,q:o},n=Math.floor(n),i=Math.floor(i);const a=[],l=[],c=[],u=[],h=new N,d=new N,f=new N,g=new N,_=new N,p=new N,m=new N;for(let v=0;v<=n;++v){const x=v/n*r*Math.PI*2;y(x,r,o,e,f),y(x+.01,r,o,e,g),p.subVectors(g,f),m.addVectors(g,f),_.crossVectors(p,m),m.crossVectors(_,p),_.normalize(),m.normalize();for(let E=0;E<=i;++E){const S=E/i*Math.PI*2,C=-t*Math.cos(S),L=t*Math.sin(S);h.x=f.x+(C*m.x+L*_.x),h.y=f.y+(C*m.y+L*_.y),h.z=f.z+(C*m.z+L*_.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),c.push(d.x,d.y,d.z),u.push(v/n),u.push(E/i)}}for(let v=1;v<=n;v++)for(let x=1;x<=i;x++){const E=(i+1)*(v-1)+(x-1),S=(i+1)*v+(x-1),C=(i+1)*v+x,L=(i+1)*(v-1)+x;a.push(E,S,L),a.push(S,C,L)}this.setIndex(a),this.setAttribute("position",new Oe(l,3)),this.setAttribute("normal",new Oe(c,3)),this.setAttribute("uv",new Oe(u,2));function y(v,x,E,S,C){const L=Math.cos(v),A=Math.sin(v),b=E/x*v,k=Math.cos(b);C.x=S*(2+k)*.5*L,C.y=S*(2+k)*A*.5,C.z=S*Math.sin(b)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new al(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class ll extends at{constructor(e=new Bu(new N(-1,-1,0),new N(-1,1,0),new N(1,1,0)),t=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r};const o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new N,l=new N,c=new te;let u=new N;const h=[],d=[],f=[],g=[];_(),this.setIndex(g),this.setAttribute("position",new Oe(h,3)),this.setAttribute("normal",new Oe(d,3)),this.setAttribute("uv",new Oe(f,2));function _(){for(let v=0;v<t;v++)p(v);p(r===!1?t:0),y(),m()}function p(v){u=e.getPointAt(v/t,u);const x=o.normals[v],E=o.binormals[v];for(let S=0;S<=i;S++){const C=S/i*Math.PI*2,L=Math.sin(C),A=-Math.cos(C);l.x=A*x.x+L*E.x,l.y=A*x.y+L*E.y,l.z=A*x.z+L*E.z,l.normalize(),d.push(l.x,l.y,l.z),a.x=u.x+n*l.x,a.y=u.y+n*l.y,a.z=u.z+n*l.z,h.push(a.x,a.y,a.z)}}function m(){for(let v=1;v<=t;v++)for(let x=1;x<=i;x++){const E=(i+1)*(v-1)+(x-1),S=(i+1)*v+(x-1),C=(i+1)*v+x,L=(i+1)*(v-1)+x;g.push(E,S,L),g.push(S,C,L)}}function y(){for(let v=0;v<=t;v++)for(let x=0;x<=i;x++)c.x=v/t,c.y=x/i,f.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new ll(new Pa[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class im extends at{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new N,r=new N;if(e.index!==null){const o=e.attributes.position,a=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],d=h.start,f=h.count;for(let g=d,_=d+f;g<_;g+=3)for(let p=0;p<3;p++){const m=a.getX(g+p),y=a.getX(g+(p+1)%3);i.fromBufferAttribute(o,m),r.fromBufferAttribute(o,y),vd(i,r,n)===!0&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}}else{const o=e.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const u=3*a+c,h=3*a+(c+1)%3;i.fromBufferAttribute(o,u),r.fromBufferAttribute(o,h),vd(i,r,n)===!0&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new Oe(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function vd(s,e,t){const n=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var yd=Object.freeze({__proto__:null,BoxGeometry:gs,CapsuleGeometry:Ka,CircleGeometry:Ja,ConeGeometry:ja,CylinderGeometry:er,DodecahedronGeometry:Qa,EdgesGeometry:Qp,ExtrudeGeometry:tl,IcosahedronGeometry:nl,LatheGeometry:no,OctahedronGeometry:io,PlaneGeometry:js,PolyhedronGeometry:Di,RingGeometry:il,ShapeGeometry:sl,SphereGeometry:so,TetrahedronGeometry:rl,TorusGeometry:ol,TorusKnotGeometry:al,TubeGeometry:ll,WireframeGeometry:im});class sm extends en{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ie(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class rm extends On{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Vu extends en{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ie(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ni,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new bn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class om extends Vu{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new te(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Rt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ie(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ie(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ie(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class am extends en{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ie(16777215),this.specular=new Ie(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ni,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new bn,this.combine=Kr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class lm extends en{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ie(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ni,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class cm extends en{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ni,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class um extends en{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ie(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ni,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new bn,this.combine=Kr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class hm extends en{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ie(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ni,this.normalScale=new te(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class dm extends cn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function rs(s,e,t){return!s||!t&&s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function fm(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function pm(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Xc(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){const a=t[r]*e;for(let l=0;l!==e;++l)i[o++]=s[a+l]}return i}function Hu(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=s[i++];while(r!==void 0)}function gE(s,e,t,n,i=30){const r=s.clone();r.name=e;const o=[];for(let l=0;l<r.tracks.length;++l){const c=r.tracks[l],u=c.getValueSize(),h=[],d=[];for(let f=0;f<c.times.length;++f){const g=c.times[f]*i;if(!(g<t||g>=n)){h.push(c.times[f]);for(let _=0;_<u;++_)d.push(c.values[f*u+_])}}h.length!==0&&(c.times=rs(h,c.times.constructor),c.values=rs(d,c.values.constructor),o.push(c))}r.tracks=o;let a=1/0;for(let l=0;l<r.tracks.length;++l)a>r.tracks[l].times[0]&&(a=r.tracks[l].times[0]);for(let l=0;l<r.tracks.length;++l)r.tracks[l].shift(-1*a);return r.resetDuration(),r}function _E(s,e=0,t=s,n=30){n<=0&&(n=30);const i=t.tracks.length,r=e/n;for(let o=0;o<i;++o){const a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;const c=s.tracks.find(function(m){return m.name===a.name&&m.ValueTypeName===l});if(c===void 0)continue;let u=0;const h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0;const f=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);const g=a.times.length-1;let _;if(r<=a.times[0]){const m=u,y=h-u;_=a.values.slice(m,y)}else if(r>=a.times[g]){const m=g*h+u,y=m+h-u;_=a.values.slice(m,y)}else{const m=a.createInterpolant(),y=u,v=h-u;m.evaluate(r),_=m.resultBuffer.slice(y,v)}l==="quaternion"&&new Jt().fromArray(_).normalize().conjugate().toArray(_);const p=c.times.length;for(let m=0;m<p;++m){const y=m*f+d;if(l==="quaternion")Jt.multiplyQuaternionsFlat(c.values,y,_,0,c.values,y);else{const v=f-d*2;for(let x=0;x<v;++x)c.values[y+x]-=_[x]}}}return s.blendMode=xu,s}const vE={convertArray:rs,isTypedArray:fm,getKeyframeOrder:pm,sortedArray:Xc,flattenJSON:Hu,subclip:gE,makeClipAdditive:_E};class ro{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=r)){const a=t[1];e<a&&(n=2,r=a);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=r,r=t[--n-1],e>=r)break t}o=n,n=0;break n}break e}for(;n<o;){const a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let o=0;o!==i;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class mm extends ro{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ns,endingEnd:ns}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,o=e+1,a=i[r],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case is:r=e,a=2*t-n;break;case Ir:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case is:o=e,l=2*n-t;break;case Ir:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}const c=(n-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=r*u,this._offsetNext=o*u}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,g=(n-t)/(i-t),_=g*g,p=_*g,m=-d*p+2*d*_-d*g,y=(1+d)*p+(-1.5-2*d)*_+(-.5+d)*g+1,v=(-1-f)*p+(1.5+f)*_+.5*g,x=f*p-f*_;for(let E=0;E!==a;++E)r[E]=m*o[u+E]+y*o[c+E]+v*o[l+E]+x*o[h+E];return r}}class Gu extends ro{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=(n-t)/(i-t),h=1-u;for(let d=0;d!==a;++d)r[d]=o[c+d]*h+o[l+d]*u;return r}}class gm extends ro{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Bn{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=rs(t,this.TimeBufferType),this.values=rs(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:rs(e.times,Array),values:rs(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new gm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Gu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new mm(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Rr:t=this.InterpolantFactoryMethodDiscrete;break;case Ea:t=this.InterpolantFactoryMethodLinear;break;case ga:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Rr;case this.InterpolantFactoryMethodLinear:return Ea;case this.InterpolantFactoryMethodSmooth:return ga}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,o=i-1;for(;r!==i&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&fm(i))for(let a=0,l=i.length;a!==l;++a){const c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===ga,r=e.length-1;let o=1;for(let a=1;a<r;++a){let l=!1;const c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(i)l=!0;else{const h=a*n,d=h-n,f=h+n;for(let g=0;g!==n;++g){const _=t[h+g];if(_!==t[d+g]||_!==t[f+g]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];const h=a*n,d=o*n;for(let f=0;f!==n;++f)t[d+f]=t[h+f]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Bn.prototype.TimeBufferType=Float32Array;Bn.prototype.ValueBufferType=Float32Array;Bn.prototype.DefaultInterpolation=Ea;class _s extends Bn{constructor(e,t,n){super(e,t,n)}}_s.prototype.ValueTypeName="bool";_s.prototype.ValueBufferType=Array;_s.prototype.DefaultInterpolation=Rr;_s.prototype.InterpolantFactoryMethodLinear=void 0;_s.prototype.InterpolantFactoryMethodSmooth=void 0;class Wu extends Bn{}Wu.prototype.ValueTypeName="color";class Vr extends Bn{}Vr.prototype.ValueTypeName="number";class _m extends ro{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t);let c=e*a;for(let u=c+a;c!==u;c+=4)Jt.slerpFlat(r,0,o,c-a,o,c,l);return r}}class oo extends Bn{InterpolantFactoryMethodLinear(e){return new _m(this.times,this.values,this.getValueSize(),e)}}oo.prototype.ValueTypeName="quaternion";oo.prototype.InterpolantFactoryMethodSmooth=void 0;class vs extends Bn{constructor(e,t,n){super(e,t,n)}}vs.prototype.ValueTypeName="string";vs.prototype.ValueBufferType=Array;vs.prototype.DefaultInterpolation=Rr;vs.prototype.InterpolantFactoryMethodLinear=void 0;vs.prototype.InterpolantFactoryMethodSmooth=void 0;class Hr extends Bn{}Hr.prototype.ValueTypeName="vector";class Gr{constructor(e="",t=-1,n=[],i=Fa){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Mn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(xE(n[o]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=n.length;r!==o;++r)t.push(Bn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,o=[];for(let a=0;a<r;a++){let l=[],c=[];l.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);const u=pm(l);l=Xc(l,1,u),c=Xc(c,1,u),!i&&l[0]===0&&(l.push(r),c.push(c[0])),o.push(new Vr(".morphTargetInfluences["+t[a].name+"]",l,c).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,l=e.length;a<l;a++){const c=e[a],u=c.name.match(r);if(u&&u.length>1){const h=u[1];let d=i[h];d||(i[h]=d=[]),d.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,d,f,g,_){if(f.length!==0){const p=[],m=[];Hu(f,p,m,g),p.length!==0&&_.push(new h(d,p,m))}},i=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const d=c[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let _=0;_<d[g].morphTargets.length;_++)f[d[g].morphTargets[_]]=-1;for(const _ in f){const p=[],m=[];for(let y=0;y!==d[g].morphTargets.length;++y){const v=d[g];p.push(v.time),m.push(v.morphTarget===_?1:0)}i.push(new Vr(".morphTargetInfluence["+_+"]",p,m))}l=f.length*o}else{const f=".bones["+t[h].name+"]";n(Hr,f+".position",d,"pos",i),n(oo,f+".quaternion",d,"rot",i),n(Hr,f+".scale",d,"scl",i)}}return i.length===0?null:new this(r,l,i,a)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function yE(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Vr;case"vector":case"vector2":case"vector3":case"vector4":return Hr;case"color":return Wu;case"quaternion":return oo;case"bool":case"boolean":return _s;case"string":return vs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function xE(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=yE(s.type);if(s.times===void 0){const t=[],n=[];Hu(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const oi={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class $u{constructor(e,t,n){const i=this;let r=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){a++,r===!1&&i.onStart!==void 0&&i.onStart(u,o,a),r=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const f=c[h],g=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return g}return null}}}const vm=new $u;class un{constructor(e){this.manager=e!==void 0?e:vm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}un.DEFAULT_MATERIAL_NAME="__DEFAULT";const ni={};class ME extends Error{constructor(e,t){super(e),this.response=t}}class Xn extends un{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=oi.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(ni[e]!==void 0){ni[e].push({onLoad:t,onProgress:n,onError:i});return}ni[e]=[],ni[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=ni[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,g=f!==0;let _=0;const p=new ReadableStream({start(m){y();function y(){h.read().then(({done:v,value:x})=>{if(v)m.close();else{_+=x.byteLength;const E=new ProgressEvent("progress",{lengthComputable:g,loaded:_,total:f});for(let S=0,C=u.length;S<C;S++){const L=u[S];L.onProgress&&L.onProgress(E)}m.enqueue(x),y()}},v=>{m.error(v)})}}});return new Response(p)}else throw new ME(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a===void 0)return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(g=>f.decode(g))}}}).then(c=>{oi.add(e,c);const u=ni[e];delete ni[e];for(let h=0,d=u.length;h<d;h++){const f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{const u=ni[e];if(u===void 0)throw this.manager.itemError(e),c;delete ni[e];for(let h=0,d=u.length;h<d;h++){const f=u[h];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class bE extends un{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new Xn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=Gr.parse(e[n]);t.push(i)}return t}}class SE extends un{constructor(e){super(e)}load(e,t,n,i){const r=this,o=[],a=new Ya,l=new Xn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(r.withCredentials);let c=0;function u(h){l.load(e[h],function(d){const f=r.parse(d,!0);o[h]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},c+=1,c===6&&(f.mipmapCount===1&&(a.minFilter=Bt),a.image=o,a.format=f.format,a.needsUpdate=!0,t&&t(a))},n,i)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else l.load(e,function(h){const d=r.parse(h,!0);if(d.isCubemap){const f=d.mipmaps.length/d.mipmapCount;for(let g=0;g<f;g++){o[g]={mipmaps:[]};for(let _=0;_<d.mipmapCount;_++)o[g].mipmaps.push(d.mipmaps[g*d.mipmapCount+_]),o[g].format=d.format,o[g].width=d.width,o[g].height=d.height}a.image=o}else a.image.width=d.width,a.image.height=d.height,a.mipmaps=d.mipmaps;d.mipmapCount===1&&(a.minFilter=Bt),a.format=d.format,a.needsUpdate=!0,t&&t(a)},n,i);return a}}class Wr extends un{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=oi.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const a=Fr("img");function l(){u(),oi.add(e,this),t&&t(this),r.manager.itemEnd(e)}function c(h){u(),i&&i(h),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class wE extends un{constructor(e){super(e)}load(e,t,n,i){const r=new eo;r.colorSpace=dn;const o=new Wr(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function l(c){o.load(e[c],function(u){r.images[c]=u,a++,a===6&&(r.needsUpdate=!0,t&&t(r))},void 0,i)}for(let c=0;c<e.length;++c)l(c);return r}}class AE extends un{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new li,a=new Xn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(e,function(l){let c;try{c=r.parse(l)}catch(u){if(i!==void 0)i(u);else{console.error(u);return}}c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:An,o.wrapT=c.wrapT!==void 0?c.wrapT:An,o.magFilter=c.magFilter!==void 0?c.magFilter:Bt,o.minFilter=c.minFilter!==void 0?c.minFilter:Bt,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.colorSpace!==void 0&&(o.colorSpace=c.colorSpace),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=Vn),c.mipmapCount===1&&(o.minFilter=Bt),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c)},n,i),o}}class EE extends un{constructor(e){super(e)}load(e,t,n,i){const r=new It,o=new Wr(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class Ui extends ut{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ie(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}class ym extends Ui{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ie(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const jl=new Ze,xd=new N,Md=new N;class Xu{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new te(512,512),this.map=null,this.mapPass=null,this.matrix=new Ze,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new to,this._frameExtents=new te(1,1),this._viewportCount=1,this._viewports=[new _t(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;xd.setFromMatrixPosition(e.matrixWorld),t.position.copy(xd),Md.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Md),t.updateMatrixWorld(),jl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(jl),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(jl)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class TE extends Xu{constructor(){super(new kt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=Ys*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class xm extends Ui{constructor(e,t,n=0,i=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new TE}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const bd=new Ze,dr=new N,Ql=new N;class CE extends Xu{constructor(){super(new kt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new te(4,2),this._viewportCount=6,this._viewports=[new _t(2,1,1,1),new _t(0,1,1,1),new _t(3,1,1,1),new _t(1,1,1,1),new _t(3,0,1,1),new _t(1,0,1,1)],this._cubeDirections=[new N(1,0,0),new N(-1,0,0),new N(0,0,1),new N(0,0,-1),new N(0,1,0),new N(0,-1,0)],this._cubeUps=[new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,1,0),new N(0,0,1),new N(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),dr.setFromMatrixPosition(e.matrixWorld),n.position.copy(dr),Ql.copy(n.position),Ql.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Ql),n.updateMatrixWorld(),i.makeTranslation(-dr.x,-dr.y,-dr.z),bd.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bd)}}class Mm extends Ui{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new CE}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class PE extends Xu{constructor(){super(new Va(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class bm extends Ui{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ut.DEFAULT_UP),this.updateMatrix(),this.target=new ut,this.shadow=new PE}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Sm extends Ui{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class wm extends Ui{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class Am{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new N)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*i),t.addScaledVector(o[2],.488603*r),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*i)),t.addScaledVector(o[5],1.092548*(i*r)),t.addScaledVector(o[6],.315392*(3*r*r-1)),t.addScaledVector(o[7],1.092548*(n*r)),t.addScaledVector(o[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*i),t.addScaledVector(o[2],2*.511664*r),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*i),t.addScaledVector(o[5],2*.429043*i*r),t.addScaledVector(o[6],.743125*r*r-.247708),t.addScaledVector(o[7],2*.429043*n*r),t.addScaledVector(o[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}class Em extends Ui{constructor(e=new Am,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class cl extends un{constructor(e){super(e),this.textures={}}load(e,t,n,i){const r=this,o=new Xn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}parse(e){const t=this.textures;function n(r){return t[r]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",r),t[r]}const i=cl.createMaterialFromType(e.type);if(e.uuid!==void 0&&(i.uuid=e.uuid),e.name!==void 0&&(i.name=e.name),e.color!==void 0&&i.color!==void 0&&i.color.setHex(e.color),e.roughness!==void 0&&(i.roughness=e.roughness),e.metalness!==void 0&&(i.metalness=e.metalness),e.sheen!==void 0&&(i.sheen=e.sheen),e.sheenColor!==void 0&&(i.sheenColor=new Ie().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(i.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(e.emissive),e.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(e.specular),e.specularIntensity!==void 0&&(i.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(i.shininess=e.shininess),e.clearcoat!==void 0&&(i.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(i.dispersion=e.dispersion),e.iridescence!==void 0&&(i.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(i.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(i.transmission=e.transmission),e.thickness!==void 0&&(i.thickness=e.thickness),e.attenuationDistance!==void 0&&(i.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(i.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(i.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(i.fog=e.fog),e.flatShading!==void 0&&(i.flatShading=e.flatShading),e.blending!==void 0&&(i.blending=e.blending),e.combine!==void 0&&(i.combine=e.combine),e.side!==void 0&&(i.side=e.side),e.shadowSide!==void 0&&(i.shadowSide=e.shadowSide),e.opacity!==void 0&&(i.opacity=e.opacity),e.transparent!==void 0&&(i.transparent=e.transparent),e.alphaTest!==void 0&&(i.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(i.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(i.depthFunc=e.depthFunc),e.depthTest!==void 0&&(i.depthTest=e.depthTest),e.depthWrite!==void 0&&(i.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(i.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(i.blendSrc=e.blendSrc),e.blendDst!==void 0&&(i.blendDst=e.blendDst),e.blendEquation!==void 0&&(i.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(i.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(i.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(i.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&i.blendColor!==void 0&&i.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(i.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(i.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(i.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(i.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(i.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(i.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(i.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(i.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(i.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(i.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(i.rotation=e.rotation),e.linewidth!==void 0&&(i.linewidth=e.linewidth),e.dashSize!==void 0&&(i.dashSize=e.dashSize),e.gapSize!==void 0&&(i.gapSize=e.gapSize),e.scale!==void 0&&(i.scale=e.scale),e.polygonOffset!==void 0&&(i.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(i.dithering=e.dithering),e.alphaToCoverage!==void 0&&(i.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(i.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(i.visible=e.visible),e.toneMapped!==void 0&&(i.toneMapped=e.toneMapped),e.userData!==void 0&&(i.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const o=e.uniforms[r];switch(i.uniforms[r]={},o.type){case"t":i.uniforms[r].value=n(o.value);break;case"c":i.uniforms[r].value=new Ie().setHex(o.value);break;case"v2":i.uniforms[r].value=new te().fromArray(o.value);break;case"v3":i.uniforms[r].value=new N().fromArray(o.value);break;case"v4":i.uniforms[r].value=new _t().fromArray(o.value);break;case"m3":i.uniforms[r].value=new je().fromArray(o.value);break;case"m4":i.uniforms[r].value=new Ze().fromArray(o.value);break;default:i.uniforms[r].value=o.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)i.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new te().fromArray(r)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapRotation!==void 0&&i.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new te().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:sm,SpriteMaterial:Lu,RawShaderMaterial:rm,ShaderMaterial:On,PointsMaterial:Du,MeshPhysicalMaterial:om,MeshStandardMaterial:Vu,MeshPhongMaterial:am,MeshToonMaterial:lm,MeshNormalMaterial:cm,MeshLambertMaterial:um,MeshDepthMaterial:Ru,MeshDistanceMaterial:Iu,MeshBasicMaterial:pi,MeshMatcapMaterial:hm,LineDashedMaterial:dm,LineBasicMaterial:cn,Material:en};return new t[e]}}class qc{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Tm extends at{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class Cm extends un{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new Xn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(f,g){if(t[g]!==void 0)return t[g];const p=f.interleavedBuffers[g],m=r(f,p.buffer),y=Hs(p.type,m),v=new Xa(y,p.stride);return v.uuid=p.uuid,t[g]=v,v}function r(f,g){if(n[g]!==void 0)return n[g];const p=f.arrayBuffers[g],m=new Uint32Array(p).buffer;return n[g]=m,m}const o=e.isInstancedBufferGeometry?new Tm:new at,a=e.data.index;if(a!==void 0){const f=Hs(a.type,a.array);o.setIndex(new mt(f,1))}const l=e.data.attributes;for(const f in l){const g=l[f];let _;if(g.isInterleavedBufferAttribute){const p=i(e.data,g.data);_=new fs(p,g.itemSize,g.offset,g.normalized)}else{const p=Hs(g.type,g.array),m=g.isInstancedBufferAttribute?Ks:mt;_=new m(p,g.itemSize,g.normalized)}g.name!==void 0&&(_.name=g.name),g.usage!==void 0&&_.setUsage(g.usage),o.setAttribute(f,_)}const c=e.data.morphAttributes;if(c)for(const f in c){const g=c[f],_=[];for(let p=0,m=g.length;p<m;p++){const y=g[p];let v;if(y.isInterleavedBufferAttribute){const x=i(e.data,y.data);v=new fs(x,y.itemSize,y.offset,y.normalized)}else{const x=Hs(y.type,y.array);v=new mt(x,y.itemSize,y.normalized)}y.name!==void 0&&(v.name=y.name),_.push(v)}o.morphAttributes[f]=_}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let f=0,g=h.length;f!==g;++f){const _=h[f];o.addGroup(_.start,_.count,_.materialIndex)}const d=e.data.boundingSphere;if(d!==void 0){const f=new N;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new jt(f,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class RE extends un{constructor(e){super(e)}load(e,t,n,i){const r=this,o=this.path===""?qc.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new Xn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){let c=null;try{c=JSON.parse(l)}catch(h){i!==void 0&&i(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}r.parse(c,t)},n,i)}async loadAsync(e,t){const n=this,i=this.path===""?qc.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const r=new Xn(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const o=await r.loadAsync(e,t),a=JSON.parse(o),l=a.metadata;if(l===void 0||l.type===void 0||l.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(a)}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),o=this.parseImages(e.images,function(){t!==void 0&&t(c)}),a=this.parseTextures(e.textures,o),l=this.parseMaterials(e.materials,a),c=this.parseObject(e.object,r,l,a,n),u=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,u),t!==void 0){let h=!1;for(const d in o)if(o[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),r=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,r),a=this.parseMaterials(e.materials,o),l=this.parseObject(e.object,i,a,o,t),c=this.parseSkeletons(e.skeletons,l);return this.bindSkeletons(l,c),l}parseShapes(e){const t={};if(e!==void 0)for(let n=0,i=e.length;n<i;n++){const r=new Pi().fromJSON(e[n]);t[r.uuid]=r}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse(function(r){r.isBone&&(i[r.uuid]=r)}),e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=new qa().fromJSON(e[r],i);n[a.uuid]=a}return n}parseGeometries(e,t){const n={};if(e!==void 0){const i=new Cm;for(let r=0,o=e.length;r<o;r++){let a;const l=e[r];switch(l.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(l);break;default:l.type in yd?a=yd[l.type].fromJSON(l,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${l.type}"`)}a.uuid=l.uuid,l.name!==void 0&&(a.name=l.name),l.userData!==void 0&&(a.userData=l.userData),n[l.uuid]=a}}return n}parseMaterials(e,t){const n={},i={};if(e!==void 0){const r=new cl;r.setTextures(t);for(let o=0,a=e.length;o<a;o++){const l=e[o];n[l.uuid]===void 0&&(n[l.uuid]=r.parse(l)),i[l.uuid]=n[l.uuid]}}return i}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const i=e[n],r=Gr.parse(i);t[r.uuid]=r}return t}parseImages(e,t){const n=this,i={};let r;function o(l){return n.manager.itemStart(l),r.load(l,function(){n.manager.itemEnd(l)},void 0,function(){n.manager.itemError(l),n.manager.itemEnd(l)})}function a(l){if(typeof l=="string"){const c=l,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:n.resourcePath+c;return o(u)}else return l.data?{data:Hs(l.type,l.data),width:l.width,height:l.height}:null}if(e!==void 0&&e.length>0){const l=new $u(t);r=new Wr(l),r.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c<u;c++){const h=e[c],d=h.url;if(Array.isArray(d)){const f=[];for(let g=0,_=d.length;g<_;g++){const p=d[g],m=a(p);m!==null&&(m instanceof HTMLImageElement?f.push(m):f.push(new li(m.data,m.width,m.height)))}i[h.uuid]=new ss(f)}else{const f=a(h.url);i[h.uuid]=new ss(f)}}}return i}async parseImagesAsync(e){const t=this,n={};let i;async function r(o){if(typeof o=="string"){const a=o,l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await i.loadAsync(l)}else return o.data?{data:Hs(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){i=new Wr(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){const l=e[o],c=l.url;if(Array.isArray(c)){const u=[];for(let h=0,d=c.length;h<d;h++){const f=c[h],g=await r(f);g!==null&&(g instanceof HTMLImageElement?u.push(g):u.push(new li(g.data,g.width,g.height)))}n[l.uuid]=new ss(u)}else{const u=await r(l.url);n[l.uuid]=new ss(u)}}}return n}parseTextures(e,t){function n(r,o){return typeof r=="number"?r:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",r),o[r])}const i={};if(e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=e[r];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const l=t[a.image],c=l.data;let u;Array.isArray(c)?(u=new eo,c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new li:u=new It,c&&(u.needsUpdate=!0)),u.source=l,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=n(a.mapping,IE)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=n(a.wrap[0],Sd),u.wrapT=n(a.wrap[1],Sd)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=n(a.minFilter,wd)),a.magFilter!==void 0&&(u.magFilter=n(a.magFilter,wd)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),i[a.uuid]=u}return i}parseObject(e,t,n,i,r){let o;function a(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function l(d){if(d!==void 0){if(Array.isArray(d)){const f=[];for(let g=0,_=d.length;g<_;g++){const p=d[g];n[p]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",p),f.push(n[p])}return f}return n[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),n[d]}}function c(d){return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),i[d]}let u,h;switch(e.type){case"Scene":o=new $a,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Ie(e.background):o.background=c(e.background)),e.environment!==void 0&&(o.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new Wa(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Ga(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new kt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new Va(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new Sm(e.color,e.intensity);break;case"DirectionalLight":o=new bm(e.color,e.intensity);break;case"PointLight":o=new Mm(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new wm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new xm(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new ym(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new Em().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),h=l(e.material),o=new Gp(u,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),h=l(e.material),o=new Nt(u,h);break;case"InstancedMesh":u=a(e.geometry),h=l(e.material);const d=e.count,f=e.instanceMatrix,g=e.instanceColor;o=new Wp(u,h,d),o.instanceMatrix=new Ks(new Float32Array(f.array),16),g!==void 0&&(o.instanceColor=new Ks(new Float32Array(g.array),g.itemSize));break;case"BatchedMesh":u=a(e.geometry),h=l(e.material),o=new $p(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,h),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(_=>{const p=new ln;p.min.fromArray(_.boxMin),p.max.fromArray(_.boxMax);const m=new jt;return m.radius=_.sphereRadius,m.center.fromArray(_.sphereCenter),{boxInitialized:_.boxInitialized,box:p,sphereInitialized:_.sphereInitialized,sphere:m}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(o._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":o=new Hp;break;case"Line":o=new Ii(a(e.geometry),l(e.material));break;case"LineLoop":o=new Xp(a(e.geometry),l(e.material));break;case"LineSegments":o=new Zn(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new qp(a(e.geometry),l(e.material));break;case"Sprite":o=new Vp(l(e.material));break;case"Group":o=new Ws;break;case"Bone":o=new Nu;break;default:o=new ut}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let f=0;f<d.length;f++)o.add(this.parseObject(d[f],t,n,i,r))}if(e.animations!==void 0){const d=e.animations;for(let f=0;f<d.length;f++){const g=d[f];o.animations.push(r[g])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const d=e.levels;for(let f=0;f<d.length;f++){const g=d[f],_=o.getObjectByProperty("uuid",g.object);_!==void 0&&o.addLevel(_,g.distance,g.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=t[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}}const IE={UVMapping:Oa,CubeReflectionMapping:ui,CubeRefractionMapping:Ri,EquirectangularReflectionMapping:Ar,EquirectangularRefractionMapping:Er,CubeUVReflectionMapping:Js},Sd={RepeatWrapping:Tr,ClampToEdgeWrapping:An,MirroredRepeatWrapping:Cr},wd={NearestFilter:Wt,NearestMipmapNearestFilter:du,NearestMipmapLinearFilter:Vs,LinearFilter:Bt,LinearMipmapNearestFilter:_r,LinearMipmapLinearFilter:Vn};class LE extends un{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=oi.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),r.manager.itemEnd(e)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return oi.add(e,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){i&&i(c),oi.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});oi.add(e,l),r.manager.itemStart(e)}}let Jo;class qu{static getContext(){return Jo===void 0&&(Jo=new(window.AudioContext||window.webkitAudioContext)),Jo}static setContext(e){Jo=e}}class NE extends un{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new Xn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const c=l.slice(0);qu.getContext().decodeAudioData(c,function(h){t(h)}).catch(a)}catch(c){a(c)}},n,i);function a(l){i?i(l):console.error(l),r.manager.itemError(e)}}}const Ad=new Ze,Ed=new Ze,Xi=new Ze;class DE{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new kt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new kt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Xi.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,o=t.near*Math.tan(ls*t.fov*.5)/t.zoom;let a,l;Ed.elements[12]=-i,Ad.elements[12]=i,a=-o*t.aspect+r,l=o*t.aspect+r,Xi.elements[0]=2*t.near/(l-a),Xi.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(Xi),a=-o*t.aspect-r,l=o*t.aspect-r,Xi.elements[0]=2*t.near/(l-a),Xi.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(Xi)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Ed),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Ad)}}class ul{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Td(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Td();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Td(){return(typeof performance>"u"?Date:performance).now()}const qi=new N,Cd=new Jt,UE=new N,Yi=new N;class OE extends ut{constructor(){super(),this.type="AudioListener",this.context=qu.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new ul}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(qi,Cd,UE),Yi.set(0,0,-1).applyQuaternion(Cd),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(qi.x,i),t.positionY.linearRampToValueAtTime(qi.y,i),t.positionZ.linearRampToValueAtTime(qi.z,i),t.forwardX.linearRampToValueAtTime(Yi.x,i),t.forwardY.linearRampToValueAtTime(Yi.y,i),t.forwardZ.linearRampToValueAtTime(Yi.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(qi.x,qi.y,qi.z),t.setOrientation(Yi.x,Yi.y,Yi.z,n.x,n.y,n.z)}}class Pm extends ut{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const Zi=new N,Pd=new Jt,FE=new N,Ki=new N;class kE extends Pm{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Zi,Pd,FE),Ki.set(0,0,1).applyQuaternion(Pd);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Zi.x,n),t.positionY.linearRampToValueAtTime(Zi.y,n),t.positionZ.linearRampToValueAtTime(Zi.z,n),t.orientationX.linearRampToValueAtTime(Ki.x,n),t.orientationY.linearRampToValueAtTime(Ki.y,n),t.orientationZ.linearRampToValueAtTime(Ki.z,n)}else t.setPosition(Zi.x,Zi.y,Zi.z),t.setOrientation(Ki.x,Ki.y,Ki.z)}}class BE{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class Rm{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,o;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,r=e*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[r+a]=n[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const l=t*this._origIndex;this._mixBufferRegion(n,i,l,1-r,t)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,o=i;r!==o;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=.5)for(let o=0;o!==r;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){Jt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const o=this._workIndex*r;Jt.multiplyQuaternionsFlat(e,o,e,t,e,n),Jt.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,r){const o=1-i;for(let a=0;a!==r;++a){const l=t+a;e[l]=e[l]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let o=0;o!==r;++o){const a=t+o;e[a]=e[a]+e[n+o]*i}}}const Yu="\\[\\]\\.:\\/",zE=new RegExp("["+Yu+"]","g"),Zu="[^"+Yu+"]",VE="[^"+Yu.replace("\\.","")+"]",HE=/((?:WC+[\/:])*)/.source.replace("WC",Zu),GE=/(WCOD+)?/.source.replace("WCOD",VE),WE=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Zu),$E=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Zu),XE=new RegExp("^"+HE+GE+WE+$E+"$"),qE=["material","materials","bones","map"];class YE{constructor(e,t,n){const i=n||ct.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ct{constructor(e,t,n){this.path=t,this.parsedPath=n||ct.parseTrackName(t),this.node=ct.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ct.Composite(e,t,n):new ct(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(zE,"")}static parseTrackName(e){const t=XE.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);qE.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let o=0;o<r.length;o++){const a=r[o];if(a.name===t||a.uuid===t)return a;const l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=ct.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const o=e[i];if(o===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ct.Composite=YE;ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ct.prototype.GetterByBindingType=[ct.prototype._getValue_direct,ct.prototype._getValue_array,ct.prototype._getValue_arrayElement,ct.prototype._getValue_toArray];ct.prototype.SetterByBindingTypeAndVersioning=[[ct.prototype._setValue_direct,ct.prototype._setValue_direct_setNeedsUpdate,ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_array,ct.prototype._setValue_array_setNeedsUpdate,ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_arrayElement,ct.prototype._setValue_arrayElement_setNeedsUpdate,ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_fromArray,ct.prototype._setValue_fromArray_setNeedsUpdate,ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ZE{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Mn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,o=r.length;let a,l=e.length,c=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const d=arguments[u],f=d.uuid;let g=t[f];if(g===void 0){g=l++,t[f]=g,e.push(d);for(let _=0,p=o;_!==p;++_)r[_].push(new ct(d,n[_],i[_]))}else if(g<c){a=e[g];const _=--c,p=e[_];t[p.uuid]=g,e[g]=p,t[f]=_,e[_]=d;for(let m=0,y=o;m!==y;++m){const v=r[m],x=v[_];let E=v[g];v[g]=x,E===void 0&&(E=new ct(d,n[m],i[m])),v[_]=E}}else e[g]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const l=arguments[o],c=l.uuid,u=t[c];if(u!==void 0&&u>=r){const h=r++,d=e[h];t[d.uuid]=u,e[u]=d,t[c]=h,e[h]=l;for(let f=0,g=i;f!==g;++f){const _=n[f],p=_[h],m=_[u];_[u]=p,_[h]=m}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],u=c.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<r){const d=--r,f=e[d],g=--o,_=e[g];t[f.uuid]=h,e[h]=f,t[_.uuid]=d,e[d]=_,e.pop();for(let p=0,m=i;p!==m;++p){const y=n[p],v=y[d],x=y[g];y[h]=v,y[d]=x,y.pop()}}else{const d=--o,f=e[d];d>0&&(t[f.uuid]=h),e[h]=f,e.pop();for(let g=0,_=i;g!==_;++g){const p=n[g];p[h]=p[d],p.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(i!==void 0)return r[i];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,h=new Array(c);i=r.length,n[e]=i,o.push(e),a.push(t),r.push(h);for(let d=u,f=l.length;d!==f;++d){const g=l[d];h[d]=new ct(g,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=n,o[n]=l,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class Im{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,o=r.length,a=new Array(o),l={endingStart:ns,endingEnd:ns};for(let c=0;c!==o;++c){const u=r[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=hp,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,r=e._clip.duration,o=r/i,a=i/r;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=r,l[1]=r+n,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const l=(e-r)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case xu:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case Fa:default:for(let u=0,h=l.length;u!==h;++u)l[u].evaluate(o),c[u].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const o=n===dp;if(e===0)return r===-1?i:o&&(r&1)===1?t-i:i;if(n===up){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;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:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);const l=this.repetitions-r;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=is,i.endingEnd=is):(e?i.endingStart=this.zeroSlopeAtStart?is:ns:i.endingStart=Ir,t?i.endingEnd=this.zeroSlopeAtEnd?is:ns:i.endingEnd=Ir)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=r,l[0]=t,a[1]=r+e,l[1]=n,this}}const KE=new Float32Array(1);class JE extends Yn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,o=e._propertyBindings,a=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let h=0;h!==r;++h){const d=i[h],f=d.name;let g=u[f];if(g!==void 0)++g.referenceCount,o[h]=g;else{if(g=o[h],g!==void 0){g._cacheIndex===null&&(++g.referenceCount,this._addInactiveBinding(g,l,f));continue}const _=t&&t._propertyBindings[h].binding.parsedPath;g=new Rm(ct.create(n,f,_),d.ValueTypeName,d.getValueSize()),++g.referenceCount,this._addInactiveBinding(g,l,f),o[h]=g}a[h].resultBuffer=g.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,r=this._actionsByClip;let o=r[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,a=o[r],l=a.knownActions,c=l[l.length-1],u=e._byClipCacheIndex;c._byClipCacheIndex=u,l[u]=c,l.pop(),e._byClipCacheIndex=null;const h=a.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],l.length===0&&delete o[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,r=this._bindings;let o=i[t];o===void 0&&(o={},i[t]=o),o[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete a[r],Object.keys(a).length===0&&delete o[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Gu(new Float32Array(2),new Float32Array(2),1,KE),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){const i=t||this._root,r=i.uuid;let o=typeof e=="string"?Gr.findByName(i,e):e;const a=o!==null?o.uuid:e,l=this._actionsByClip[a];let c=null;if(n===void 0&&(o!==null?n=o.blendMode:n=Fa),l!==void 0){const h=l.actionByRoot[r];if(h!==void 0&&h.blendMode===n)return h;c=l.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;const u=new Im(this,o,t,n);return this._bindAction(u,c),this._addInactiveAction(u,a,r),u}existingAction(e,t){const n=t||this._root,i=n.uuid,r=typeof e=="string"?Gr.findByName(n,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){const o=r.knownActions;for(let a=0,l=o.length;a!==l;++a){const c=o[a];this._deactivateAction(c);const u=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const o in n){const a=n[o].actionByRoot,l=a[t];l!==void 0&&(this._deactivateAction(l),this._removeInactiveAction(l))}const i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(const o in r){const a=r[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class Ku{constructor(e){this.value=e}clone(){return new Ku(this.value.clone===void 0?this.value:this.value.clone())}}let jE=0;class QE extends Yn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:jE++}),this.name="",this.usage=Ur,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,i=t.length;n<i;n++){const r=Array.isArray(t[n])?t[n]:[t[n]];for(let o=0;o<r.length;o++)this.uniforms.push(r[o].clone())}return this}clone(){return new this.constructor().copy(this)}}class eT extends Xa{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class tT{constructor(e,t,n,i,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=r,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const Rd=new Ze;class Lm{constructor(e,t,n=0,i=1/0){this.ray=new ms(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new za,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Rd.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Rd),this}intersectObject(e,t=!0,n=[]){return Yc(e,this,n,t),n.sort(Id),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)Yc(e[i],this,n,t);return n.sort(Id),n}}function Id(s,e){return s.distance-e.distance}function Yc(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let o=0,a=r.length;o<a;o++)Yc(r[o],e,t,!0)}}class Zc{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Rt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class nT{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}const Ld=new te;class Nm{constructor(e=new te(1/0,1/0),t=new te(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Ld.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ld).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Nd=new N,jo=new N;class iT{constructor(e=new N,t=new N){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Nd.subVectors(e,this.start),jo.subVectors(this.end,this.start);const n=jo.dot(jo);let r=jo.dot(Nd)/n;return t&&(r=Rt(r,0,1)),r}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Dd=new N;class sT extends ut{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new at,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<l;o++,a++){const c=o/l*Math.PI*2,u=a/l*Math.PI*2;i.push(Math.cos(c),Math.sin(c),1,Math.cos(u),Math.sin(u),1)}n.setAttribute("position",new Oe(i,3));const r=new cn({fog:!1,toneMapped:!1});this.cone=new Zn(n,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Dd.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Dd),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Ai=new N,Qo=new Ze,ec=new Ze;class rT extends Zn{constructor(e){const t=Dm(e),n=new at,i=[],r=[],o=new Ie(0,0,1),a=new Ie(0,1,0);for(let c=0;c<t.length;c++){const u=t[c];u.parent&&u.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(o.r,o.g,o.b),r.push(a.r,a.g,a.b))}n.setAttribute("position",new Oe(i,3)),n.setAttribute("color",new Oe(r,3));const l=new cn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,l),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");ec.copy(this.root.matrixWorld).invert();for(let r=0,o=0;r<t.length;r++){const a=t[r];a.parent&&a.parent.isBone&&(Qo.multiplyMatrices(ec,a.matrixWorld),Ai.setFromMatrixPosition(Qo),i.setXYZ(o,Ai.x,Ai.y,Ai.z),Qo.multiplyMatrices(ec,a.parent.matrixWorld),Ai.setFromMatrixPosition(Qo),i.setXYZ(o+1,Ai.x,Ai.y,Ai.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Dm(s){const e=[];s.isBone===!0&&e.push(s);for(let t=0;t<s.children.length;t++)e.push.apply(e,Dm(s.children[t]));return e}class oT extends Nt{constructor(e,t,n){const i=new so(t,4,2),r=new pi({wireframe:!0,fog:!1,toneMapped:!1});super(i,r),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const aT=new N,Ud=new Ie,Od=new Ie;class lT extends ut{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new io(t);i.rotateY(Math.PI*.5),this.material=new pi({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),o=new Float32Array(r.count*3);i.setAttribute("color",new mt(o,3)),this.add(new Nt(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Ud.copy(this.light.color),Od.copy(this.light.groundColor);for(let n=0,i=t.count;n<i;n++){const r=n<i/2?Ud:Od;t.setXYZ(n,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(aT.setFromMatrixPosition(this.light.matrixWorld).negate())}}class cT extends Zn{constructor(e=10,t=10,n=4473924,i=8947848){n=new Ie(n),i=new Ie(i);const r=t/2,o=e/t,a=e/2,l=[],c=[];for(let d=0,f=0,g=-a;d<=t;d++,g+=o){l.push(-a,0,g,a,0,g),l.push(g,0,-a,g,0,a);const _=d===r?n:i;_.toArray(c,f),f+=3,_.toArray(c,f),f+=3,_.toArray(c,f),f+=3,_.toArray(c,f),f+=3}const u=new at;u.setAttribute("position",new Oe(l,3)),u.setAttribute("color",new Oe(c,3));const h=new cn({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class uT extends Zn{constructor(e=10,t=16,n=8,i=64,r=4473924,o=8947848){r=new Ie(r),o=new Ie(o);const a=[],l=[];if(t>1)for(let h=0;h<t;h++){const d=h/t*(Math.PI*2),f=Math.sin(d)*e,g=Math.cos(d)*e;a.push(0,0,0),a.push(f,0,g);const _=h&1?r:o;l.push(_.r,_.g,_.b),l.push(_.r,_.g,_.b)}for(let h=0;h<n;h++){const d=h&1?r:o,f=e-e/n*h;for(let g=0;g<i;g++){let _=g/i*(Math.PI*2),p=Math.sin(_)*f,m=Math.cos(_)*f;a.push(p,0,m),l.push(d.r,d.g,d.b),_=(g+1)/i*(Math.PI*2),p=Math.sin(_)*f,m=Math.cos(_)*f,a.push(p,0,m),l.push(d.r,d.g,d.b)}}const c=new at;c.setAttribute("position",new Oe(a,3)),c.setAttribute("color",new Oe(l,3));const u=new cn({vertexColors:!0,toneMapped:!1});super(c,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Fd=new N,ea=new N,kd=new N;class hT extends ut{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let i=new at;i.setAttribute("position",new Oe([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new cn({fog:!1,toneMapped:!1});this.lightPlane=new Ii(i,r),this.add(this.lightPlane),i=new at,i.setAttribute("position",new Oe([0,0,0,0,0,1],3)),this.targetLine=new Ii(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Fd.setFromMatrixPosition(this.light.matrixWorld),ea.setFromMatrixPosition(this.light.target.matrixWorld),kd.subVectors(ea,Fd),this.lightPlane.lookAt(ea),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(ea),this.targetLine.scale.z=kd.length()}}const ta=new N,Pt=new Qr;class dT extends Zn{constructor(e){const t=new at,n=new cn({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(g,_){l(g),l(_)}function l(g){i.push(0,0,0),r.push(0,0,0),o[g]===void 0&&(o[g]=[]),o[g].push(i.length/3-1)}t.setAttribute("position",new Oe(i,3)),t.setAttribute("color",new Oe(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const c=new Ie(16755200),u=new Ie(16711680),h=new Ie(43775),d=new Ie(16777215),f=new Ie(3355443);this.setColors(c,u,h,d,f)}setColors(e,t,n,i,r){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,i=1;Pt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Lt("c",t,e,Pt,0,0,-1),Lt("t",t,e,Pt,0,0,1),Lt("n1",t,e,Pt,-n,-i,-1),Lt("n2",t,e,Pt,n,-i,-1),Lt("n3",t,e,Pt,-n,i,-1),Lt("n4",t,e,Pt,n,i,-1),Lt("f1",t,e,Pt,-n,-i,1),Lt("f2",t,e,Pt,n,-i,1),Lt("f3",t,e,Pt,-n,i,1),Lt("f4",t,e,Pt,n,i,1),Lt("u1",t,e,Pt,n*.7,i*1.1,-1),Lt("u2",t,e,Pt,-n*.7,i*1.1,-1),Lt("u3",t,e,Pt,0,i*2,-1),Lt("cf1",t,e,Pt,-n,0,1),Lt("cf2",t,e,Pt,n,0,1),Lt("cf3",t,e,Pt,0,-i,1),Lt("cf4",t,e,Pt,0,i,1),Lt("cn1",t,e,Pt,-n,0,-1),Lt("cn2",t,e,Pt,n,0,-1),Lt("cn3",t,e,Pt,0,-i,-1),Lt("cn4",t,e,Pt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Lt(s,e,t,n,i,r,o){ta.set(i,r,o).unproject(n);const a=e[s];if(a!==void 0){const l=t.getAttribute("position");for(let c=0,u=a.length;c<u;c++)l.setXYZ(a[c],ta.x,ta.y,ta.z)}}const na=new ln;class fT extends Zn{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(8*3),r=new at;r.setIndex(new mt(n,1)),r.setAttribute("position",new mt(i,3)),super(r,new cn({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&na.setFromObject(this.object),na.isEmpty())return;const t=na.min,n=na.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=t.x,r[4]=n.y,r[5]=n.z,r[6]=t.x,r[7]=t.y,r[8]=n.z,r[9]=n.x,r[10]=t.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=t.z,r[15]=t.x,r[16]=n.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=n.x,r[22]=t.y,r[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class pT extends Zn{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],r=new at;r.setIndex(new mt(n,1)),r.setAttribute("position",new Oe(i,3)),super(r,new cn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class mT extends Ii{constructor(e,t=1,n=16776960){const i=n,r=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new at;o.setAttribute("position",new Oe(r,3)),o.computeBoundingSphere(),super(o,new cn({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],l=new at;l.setAttribute("position",new Oe(a,3)),l.computeBoundingSphere(),this.add(new Nt(l,new pi({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Bd=new N;let ia,tc;class gT extends ut{constructor(e=new N(0,0,1),t=new N(0,0,0),n=1,i=16776960,r=n*.2,o=r*.2){super(),this.type="ArrowHelper",ia===void 0&&(ia=new at,ia.setAttribute("position",new Oe([0,0,0,0,1,0],3)),tc=new er(0,.5,1,5,1),tc.translate(0,-.5,0)),this.position.copy(t),this.line=new Ii(ia,new cn({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Nt(tc,new pi({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,r,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Bd.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Bd,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class _T extends Zn{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new at;i.setAttribute("position",new Oe(t,3)),i.setAttribute("color",new Oe(n,3));const r=new cn({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(e,t,n){const i=new Ie,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ei{constructor(){this.type="ShapePath",this.color=new Ie,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Ci,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,o){return this.currentPath.bezierCurveTo(e,t,n,i,r,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){const y=[];for(let v=0,x=m.length;v<x;v++){const E=m[v],S=new Pi;S.curves=E.curves,y.push(S)}return y}function n(m,y){const v=y.length;let x=!1;for(let E=v-1,S=0;S<v;E=S++){let C=y[E],L=y[S],A=L.x-C.x,b=L.y-C.y;if(Math.abs(b)>Number.EPSILON){if(b<0&&(C=y[S],A=-A,L=y[E],b=-b),m.y<C.y||m.y>L.y)continue;if(m.y===C.y){if(m.x===C.x)return!0}else{const k=b*(m.x-C.x)-A*(m.y-C.y);if(k===0)return!0;if(k<0)continue;x=!x}}else{if(m.y!==C.y)continue;if(L.x<=m.x&&m.x<=C.x||C.x<=m.x&&m.x<=L.x)return!0}}return x}const i=Nn.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,l;const c=[];if(r.length===1)return a=r[0],l=new Pi,l.curves=a.curves,c.push(l),c;let u=!i(r[0].getPoints());u=e?!u:u;const h=[],d=[];let f=[],g=0,_;d[g]=void 0,f[g]=[];for(let m=0,y=r.length;m<y;m++)a=r[m],_=a.getPoints(),o=i(_),o=e?!o:o,o?(!u&&d[g]&&g++,d[g]={s:new Pi,p:_},d[g].s.curves=a.curves,u&&g++,f[g]=[]):f[g].push({h:a,p:_[0]});if(!d[0])return t(r);if(d.length>1){let m=!1,y=0;for(let v=0,x=d.length;v<x;v++)h[v]=[];for(let v=0,x=d.length;v<x;v++){const E=f[v];for(let S=0;S<E.length;S++){const C=E[S];let L=!0;for(let A=0;A<d.length;A++)n(C.p,d[A].p)&&(v!==A&&y++,L?(L=!1,h[A].push(C)):m=!0);L&&h[v].push(C)}}y>0&&m===!1&&(f=h)}let p;for(let m=0,y=d.length;m<y;m++){l=d[m].s,c.push(l),p=f[m];for(let v=0,x=p.length;v<x;v++)l.holes.push(p[v].h)}return c}}class vT extends Un{constructor(e=1,t=1,n=1,i={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...i,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Zr}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Zr);const yT=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Ua,AddEquation:Ti,AddOperation:qf,AdditiveAnimationBlendMode:xu,AdditiveBlending:Sa,AgXToneMapping:jf,AlphaFormat:sp,AlwaysCompare:bp,AlwaysDepth:zf,AlwaysStencilFunc:Bc,AmbientLight:Sm,AnimationAction:Im,AnimationClip:Gr,AnimationLoader:bE,AnimationMixer:JE,AnimationObjectGroup:ZE,AnimationUtils:vE,ArcCurve:Yp,ArrayCamera:Bp,ArrowHelper:gT,AttachedBindMode:dc,Audio:Pm,AudioAnalyser:BE,AudioContext:qu,AudioListener:OE,AudioLoader:NE,AxesHelper:_T,BackSide:an,BasicDepthPacking:fp,BasicShadowMap:Tx,BatchedMesh:$p,Bone:Nu,BooleanKeyframeTrack:_s,Box2:Nm,Box3:ln,Box3Helper:pT,BoxGeometry:gs,BoxHelper:fT,BufferAttribute:mt,BufferGeometry:at,BufferGeometryLoader:Cm,ByteType:tp,Cache:oi,Camera:Qr,CameraHelper:dT,CanvasTexture:HA,CapsuleGeometry:Ka,CatmullRomCurve3:Zp,CineonToneMapping:Kf,CircleGeometry:Ja,ClampToEdgeWrapping:An,Clock:ul,Color:Ie,ColorKeyframeTrack:Wu,ColorManagement:dt,CompressedArrayTexture:zA,CompressedCubeTexture:VA,CompressedTexture:Ya,CompressedTextureLoader:SE,ConeGeometry:ja,ConstantAlphaFactor:Ff,ConstantColorFactor:Uf,CubeCamera:Rp,CubeReflectionMapping:ui,CubeRefractionMapping:Ri,CubeTexture:eo,CubeTextureLoader:wE,CubeUVReflectionMapping:Js,CubicBezierCurve:Ou,CubicBezierCurve3:Kp,CubicInterpolant:mm,CullFaceBack:cc,CullFaceFront:xf,CullFaceFrontBack:Ex,CullFaceNone:yf,Curve:kn,CurvePath:jp,CustomBlending:Mf,CustomToneMapping:Jf,CylinderGeometry:er,Cylindrical:nT,Data3DTexture:Au,DataArrayTexture:Ba,DataTexture:li,DataTextureLoader:AE,DataUtils:OM,DecrementStencilOp:kx,DecrementWrapStencilOp:zx,DefaultLoadingManager:vm,DepthFormat:as,DepthStencilFormat:ds,DepthTexture:Pu,DetachedBindMode:ep,DirectionalLight:bm,DirectionalLightHelper:hT,DiscreteInterpolant:gm,DisplayP3ColorSpace:ka,DodecahedronGeometry:Qa,DoubleSide:In,DstAlphaFactor:Rf,DstColorFactor:Lf,DynamicCopyUsage:tM,DynamicDrawUsage:Zx,DynamicReadUsage:jx,EdgesGeometry:Qp,EllipseCurve:Za,EqualCompare:vp,EqualDepth:Hf,EqualStencilFunc:Wx,EquirectangularReflectionMapping:Ar,EquirectangularRefractionMapping:Er,Euler:bn,EventDispatcher:Yn,ExtrudeGeometry:tl,FileLoader:Xn,Float16BufferAttribute:HM,Float32BufferAttribute:Oe,FloatType:xn,Fog:Wa,FogExp2:Ga,FramebufferTexture:BA,FrontSide:ci,Frustum:to,GLBufferAttribute:tT,GLSL1:iM,GLSL3:zc,GreaterCompare:yp,GreaterDepth:Wf,GreaterEqualCompare:Mp,GreaterEqualDepth:Gf,GreaterEqualStencilFunc:Yx,GreaterStencilFunc:Xx,GridHelper:cT,Group:Ws,HalfFloatType:Jr,HemisphereLight:ym,HemisphereLightHelper:lT,IcosahedronGeometry:nl,ImageBitmapLoader:LE,ImageLoader:Wr,ImageUtils:Ap,IncrementStencilOp:Fx,IncrementWrapStencilOp:Bx,InstancedBufferAttribute:Ks,InstancedBufferGeometry:Tm,InstancedInterleavedBuffer:eT,InstancedMesh:Wp,Int16BufferAttribute:zM,Int32BufferAttribute:VM,Int8BufferAttribute:FM,IntType:fu,InterleavedBuffer:Xa,InterleavedBufferAttribute:fs,Interpolant:ro,InterpolateDiscrete:Rr,InterpolateLinear:Ea,InterpolateSmooth:ga,InvertStencilOp:Vx,KeepStencilOp:Qi,KeyframeTrack:Bn,LOD:Hp,LatheGeometry:no,Layers:za,LessCompare:_p,LessDepth:Vf,LessEqualCompare:Mu,LessEqualDepth:wr,LessEqualStencilFunc:$x,LessStencilFunc:Gx,Light:Ui,LightProbe:Em,Line:Ii,Line3:iT,LineBasicMaterial:cn,LineCurve:Fu,LineCurve3:Jp,LineDashedMaterial:dm,LineLoop:Xp,LineSegments:Zn,LinearDisplayP3ColorSpace:jr,LinearFilter:Bt,LinearInterpolant:Gu,LinearMipMapLinearFilter:Ix,LinearMipMapNearestFilter:Rx,LinearMipmapLinearFilter:Vn,LinearMipmapNearestFilter:_r,LinearSRGBColorSpace:fi,LinearToneMapping:Yf,LinearTransfer:Lr,Loader:un,LoaderUtils:qc,LoadingManager:$u,LoopOnce:up,LoopPingPong:dp,LoopRepeat:hp,LuminanceAlphaFormat:ap,LuminanceFormat:op,MOUSE:Ji,Material:en,MaterialLoader:cl,MathUtils:Su,Matrix3:je,Matrix4:Ze,MaxEquation:Af,Mesh:Nt,MeshBasicMaterial:pi,MeshDepthMaterial:Ru,MeshDistanceMaterial:Iu,MeshLambertMaterial:um,MeshMatcapMaterial:hm,MeshNormalMaterial:cm,MeshPhongMaterial:am,MeshPhysicalMaterial:om,MeshStandardMaterial:Vu,MeshToonMaterial:lm,MinEquation:wf,MirroredRepeatWrapping:Cr,MixOperation:Xf,MultiplyBlending:hc,MultiplyOperation:Kr,NearestFilter:Wt,NearestMipMapLinearFilter:Px,NearestMipMapNearestFilter:Cx,NearestMipmapLinearFilter:Vs,NearestMipmapNearestFilter:du,NeutralToneMapping:Qf,NeverCompare:gp,NeverDepth:Bf,NeverStencilFunc:Hx,NoBlending:ai,NoColorSpace:si,NoToneMapping:Wn,NormalAnimationBlendMode:Fa,NormalBlending:os,NotEqualCompare:xp,NotEqualDepth:$f,NotEqualStencilFunc:qx,NumberKeyframeTrack:Vr,Object3D:ut,ObjectLoader:RE,ObjectSpaceNormalMap:mp,OctahedronGeometry:io,OneFactor:Tf,OneMinusConstantAlphaFactor:kf,OneMinusConstantColorFactor:Of,OneMinusDstAlphaFactor:If,OneMinusDstColorFactor:Nf,OneMinusSrcAlphaFactor:Aa,OneMinusSrcColorFactor:Pf,OrthographicCamera:Va,P3Primaries:Dr,PCFShadowMap:uu,PCFSoftShadowMap:hu,PMREMGenerator:Vc,Path:Ci,PerspectiveCamera:kt,Plane:ii,PlaneGeometry:js,PlaneHelper:mT,PointLight:Mm,PointLightHelper:oT,Points:qp,PointsMaterial:Du,PolarGridHelper:uT,PolyhedronGeometry:Di,PositionalAudio:kE,PropertyBinding:ct,PropertyMixer:Rm,QuadraticBezierCurve:ku,QuadraticBezierCurve3:Bu,Quaternion:Jt,QuaternionKeyframeTrack:oo,QuaternionLinearInterpolant:_m,RED_GREEN_RGTC2_Format:Fc,RED_RGTC1_Format:cp,REVISION:Zr,RGBADepthPacking:pp,RGBAFormat:fn,RGBAIntegerFormat:yu,RGBA_ASTC_10x10_Format:Ic,RGBA_ASTC_10x5_Format:Cc,RGBA_ASTC_10x6_Format:Pc,RGBA_ASTC_10x8_Format:Rc,RGBA_ASTC_12x10_Format:Lc,RGBA_ASTC_12x12_Format:Nc,RGBA_ASTC_4x4_Format:xc,RGBA_ASTC_5x4_Format:Mc,RGBA_ASTC_5x5_Format:bc,RGBA_ASTC_6x5_Format:Sc,RGBA_ASTC_6x6_Format:wc,RGBA_ASTC_8x5_Format:Ac,RGBA_ASTC_8x6_Format:Ec,RGBA_ASTC_8x8_Format:Tc,RGBA_BPTC_Format:ma,RGBA_ETC2_EAC_Format:yc,RGBA_PVRTC_2BPPV1_Format:gc,RGBA_PVRTC_4BPPV1_Format:mc,RGBA_S3TC_DXT1_Format:da,RGBA_S3TC_DXT3_Format:fa,RGBA_S3TC_DXT5_Format:pa,RGBFormat:rp,RGB_BPTC_SIGNED_Format:Dc,RGB_BPTC_UNSIGNED_Format:Uc,RGB_ETC1_Format:_c,RGB_ETC2_Format:vc,RGB_PVRTC_2BPPV1_Format:pc,RGB_PVRTC_4BPPV1_Format:fc,RGB_S3TC_DXT1_Format:ha,RGFormat:lp,RGIntegerFormat:vu,RawShaderMaterial:rm,Ray:ms,Raycaster:Lm,Rec709Primaries:Nr,RectAreaLight:wm,RedFormat:gu,RedIntegerFormat:_u,ReinhardToneMapping:Zf,RenderTarget:Ep,RepeatWrapping:Tr,ReplaceStencilOp:Ox,ReverseSubtractEquation:Sf,RingGeometry:il,SIGNED_RED_GREEN_RGTC2_Format:kc,SIGNED_RED_RGTC1_Format:Oc,SRGBColorSpace:dn,SRGBTransfer:Mt,Scene:$a,ShaderChunk:ot,ShaderLib:Rn,ShaderMaterial:On,ShadowMaterial:sm,Shape:Pi,ShapeGeometry:sl,ShapePath:Ei,ShapeUtils:Nn,ShortType:np,Skeleton:qa,SkeletonHelper:rT,SkinnedMesh:Gp,Source:ss,Sphere:jt,SphereGeometry:so,Spherical:Zc,SphericalHarmonics3:Am,SplineCurve:zu,SpotLight:xm,SpotLightHelper:sT,Sprite:Vp,SpriteMaterial:Lu,SrcAlphaFactor:wa,SrcAlphaSaturateFactor:Df,SrcColorFactor:Cf,StaticCopyUsage:eM,StaticDrawUsage:Ur,StaticReadUsage:Jx,StereoCamera:DE,StreamCopyUsage:nM,StreamDrawUsage:Kx,StreamReadUsage:Qx,StringKeyframeTrack:vs,SubtractEquation:bf,SubtractiveBlending:uc,TOUCH:ji,TangentSpaceNormalMap:Ni,TetrahedronGeometry:rl,Texture:It,TextureLoader:EE,TorusGeometry:ol,TorusKnotGeometry:al,Triangle:yn,TriangleFanDrawMode:Dx,TriangleStripDrawMode:Nx,TrianglesDrawMode:Lx,TubeGeometry:ll,UVMapping:Oa,Uint16BufferAttribute:Eu,Uint32BufferAttribute:Tu,Uint8BufferAttribute:kM,Uint8ClampedBufferAttribute:BM,Uniform:Ku,UniformsGroup:QE,UniformsLib:Pe,UniformsUtils:Pp,UnsignedByteType:hi,UnsignedInt248Type:hs,UnsignedInt5999Type:ip,UnsignedIntType:us,UnsignedShort4444Type:pu,UnsignedShort5551Type:mu,UnsignedShortType:Pr,VSMShadowMap:zn,Vector2:te,Vector3:N,Vector4:_t,VectorKeyframeTrack:Hr,VideoTexture:kA,WebGL3DRenderTarget:EM,WebGLArrayRenderTarget:AM,WebGLCoordinateSystem:Hn,WebGLCubeRenderTarget:Ip,WebGLMultipleRenderTargets:vT,WebGLRenderTarget:Un,WebGLRenderer:va,WebGLUtils:kp,WebGPUCoordinateSystem:Or,WireframeGeometry:im,WrapAroundEnding:Ir,ZeroCurvatureEnding:ns,ZeroFactor:Ef,ZeroSlopeEnding:is,ZeroStencilOp:Ux,createCanvasElement:wp},Symbol.toStringTag,{value:"Module"}));function qn(s){return og()?(ag(s),!0):!1}function Pn(){const s=new Set,e=i=>{s.delete(i)};return{on:i=>{s.add(i);const r=()=>e(i);return qn(r),{off:r}},off:e,trigger:(...i)=>Promise.all(Array.from(s).map(r=>r(...i)))}}function bt(s){return typeof s=="function"?s():ee(s)}const Kc=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const xT=s=>s!=null,MT=Object.prototype.toString,bT=s=>MT.call(s)==="[object Object]",Jc=()=>{};function ST(s,e){function t(...n){return new Promise((i,r)=>{Promise.resolve(s(()=>e.apply(this,n),{fn:e,thisArg:this,args:n})).then(i).catch(r)})}return t}function wT(s,e={}){let t,n,i=Jc;const r=a=>{clearTimeout(a),i(),i=Jc};return a=>{const l=bt(s),c=bt(e.maxWait);return t&&r(t),l<=0||c!==void 0&&c<=0?(n&&(r(n),n=null),Promise.resolve(a())):new Promise((u,h)=>{i=e.rejectOnCancel?h:u,c&&!n&&(n=setTimeout(()=>{t&&r(t),n=null,u(a())},c)),t=setTimeout(()=>{n&&r(n),n=null,u(a())},l)})}}function AT(s,e,t=!1){return e.reduce((n,i)=>(i in s&&(!t||s[i]!==void 0)&&(n[i]=s[i]),n),{})}function ET(s){return Ma()}function TT(s,e=200,t={}){return ST(wT(e,t),s)}function zd(s,e=200,t={}){const n=Ve(s.value),i=TT(()=>{n.value=s.value},e,t);return wt(s,()=>i()),n}function CT(s,e={}){if(!of(s))return lg(s);const t=Array.isArray(s.value)?Array.from({length:s.value.length}):{};for(const n in s.value)t[n]=cg(()=>({get(){return s.value[n]},set(i){var r;if((r=bt(e.replaceRef))!=null?r:!0)if(Array.isArray(s.value)){const a=[...s.value];a[n]=i,s.value=a}else{const a={...s.value,[n]:i};Object.setPrototypeOf(a,Object.getPrototypeOf(s.value)),s.value=a}else s.value[n]=i}}));return t}function Ju(s,e=!0,t){ET()?Fn(s,t):e?s():iu(s)}function PT(s,e=1e3,t={}){const{immediate:n=!0,immediateCallback:i=!1}=t;let r=null;const o=Ve(!1);function a(){r&&(clearInterval(r),r=null)}function l(){o.value=!1,a()}function c(){const u=bt(e);u<=0||(o.value=!0,i&&s(),a(),r=setInterval(s,u))}if(n&&Kc&&c(),of(e)||typeof e=="function"){const u=wt(e,()=>{o.value&&Kc&&c()});qn(u)}return qn(l),{isActive:o,pause:l,resume:c}}function Ln(s){var e;const t=bt(s);return(e=t==null?void 0:t.$el)!=null?e:t}const mi=Kc?window:void 0;function $r(...s){let e,t,n,i;if(typeof s[0]=="string"||Array.isArray(s[0])?([t,n,i]=s,e=mi):[e,t,n,i]=s,!e)return Jc;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const r=[],o=()=>{r.forEach(u=>u()),r.length=0},a=(u,h,d,f)=>(u.addEventListener(h,d,f),()=>u.removeEventListener(h,d,f)),l=wt(()=>[Ln(e),bt(i)],([u,h])=>{if(o(),!u)return;const d=bT(h)?{...h}:h;r.push(...t.flatMap(f=>n.map(g=>a(u,f,g,d))))},{immediate:!0,flush:"post"}),c=()=>{l(),o()};return qn(c),c}function RT(){const s=Ve(!1),e=Ma();return e&&Fn(()=>{s.value=!0},e),s}function hl(s){const e=RT();return He(()=>(e.value,!!s()))}function IT(s,e,t={}){const{window:n=mi,...i}=t;let r;const o=hl(()=>n&&"MutationObserver"in n),a=()=>{r&&(r.disconnect(),r=void 0)},l=He(()=>{const d=bt(s),f=(Array.isArray(d)?d:[d]).map(Ln).filter(xT);return new Set(f)}),c=wt(()=>l.value,d=>{a(),o.value&&d.size&&(r=new MutationObserver(e),d.forEach(f=>r.observe(f,i)))},{immediate:!0,flush:"post"}),u=()=>r==null?void 0:r.takeRecords(),h=()=>{a(),c()};return qn(h),{isSupported:o,stop:h,takeRecords:u}}function ju(s,e={}){const{immediate:t=!0,fpsLimit:n=void 0,window:i=mi}=e,r=Ve(!1),o=n?1e3/n:null;let a=0,l=null;function c(d){if(!r.value||!i)return;a||(a=d);const f=d-a;if(o&&f<o){l=i.requestAnimationFrame(c);return}a=d,s({delta:f,timestamp:d}),l=i.requestAnimationFrame(c)}function u(){!r.value&&i&&(r.value=!0,a=0,l=i.requestAnimationFrame(c))}function h(){r.value=!1,l!=null&&i&&(i.cancelAnimationFrame(l),l=null)}return t&&u(),qn(h),{isActive:br(r),pause:h,resume:u}}function LT(s,e={}){const{window:t=mi}=e,n=hl(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let i;const r=Ve(!1),o=c=>{r.value=c.matches},a=()=>{i&&("removeEventListener"in i?i.removeEventListener("change",o):i.removeListener(o))},l=Li(()=>{n.value&&(a(),i=t.matchMedia(bt(s)),"addEventListener"in i?i.addEventListener("change",o):i.addListener(o),r.value=i.matches)});return qn(()=>{l(),a(),i=void 0}),r}function NT(s={}){const{window:e=mi}=s,t=Ve(1);if(e){let n=function(){t.value=e.devicePixelRatio,i(),r=e.matchMedia(`(resolution: ${t.value}dppx)`),r.addEventListener("change",n,{once:!0})},i=function(){r==null||r.removeEventListener("change",n)},r;n(),qn(i)}return{pixelRatio:t}}function Um(s,e,t={}){const{window:n=mi,...i}=t;let r;const o=hl(()=>n&&"ResizeObserver"in n),a=()=>{r&&(r.disconnect(),r=void 0)},l=He(()=>Array.isArray(s)?s.map(h=>Ln(h)):[Ln(s)]),c=wt(l,h=>{if(a(),o.value&&n){r=new ResizeObserver(e);for(const d of h)d&&r.observe(d,i)}},{immediate:!0,flush:"post"}),u=()=>{a(),c()};return qn(u),{isSupported:o,stop:u}}function DT(s,e={}){const{reset:t=!0,windowResize:n=!0,windowScroll:i=!0,immediate:r=!0}=e,o=Ve(0),a=Ve(0),l=Ve(0),c=Ve(0),u=Ve(0),h=Ve(0),d=Ve(0),f=Ve(0);function g(){const _=Ln(s);if(!_){t&&(o.value=0,a.value=0,l.value=0,c.value=0,u.value=0,h.value=0,d.value=0,f.value=0);return}const p=_.getBoundingClientRect();o.value=p.height,a.value=p.bottom,l.value=p.left,c.value=p.right,u.value=p.top,h.value=p.width,d.value=p.x,f.value=p.y}return Um(s,g),wt(()=>Ln(s),_=>!_&&g()),IT(s,g,{attributeFilter:["style","class"]}),i&&$r("scroll",g,{capture:!0,passive:!0}),n&&$r("resize",g,{passive:!0}),Ju(()=>{r&&g()}),{height:o,bottom:a,left:l,right:c,top:u,width:h,x:d,y:f,update:g}}function UT(s,e={width:0,height:0},t={}){const{window:n=mi,box:i="content-box"}=t,r=He(()=>{var h,d;return(d=(h=Ln(s))==null?void 0:h.namespaceURI)==null?void 0:d.includes("svg")}),o=Ve(e.width),a=Ve(e.height),{stop:l}=Um(s,([h])=>{const d=i==="border-box"?h.borderBoxSize:i==="content-box"?h.contentBoxSize:h.devicePixelContentBoxSize;if(n&&r.value){const f=Ln(s);if(f){const g=f.getBoundingClientRect();o.value=g.width,a.value=g.height}}else if(d){const f=Array.isArray(d)?d:[d];o.value=f.reduce((g,{inlineSize:_})=>g+_,0),a.value=f.reduce((g,{blockSize:_})=>g+_,0)}else o.value=h.contentRect.width,a.value=h.contentRect.height},t);Ju(()=>{const h=Ln(s);h&&(o.value="offsetWidth"in h?h.offsetWidth:e.width,a.value="offsetHeight"in h?h.offsetHeight:e.height)});const c=wt(()=>Ln(s),h=>{o.value=h?e.width:0,a.value=h?e.height:0});function u(){l(),c()}return{width:o,height:a,stop:u}}function OT(s){var e;const t=Ve(0);if(typeof performance>"u")return t;const n=(e=s==null?void 0:s.every)!=null?e:10;let i=performance.now(),r=0;return ju(()=>{if(r+=1,r>=n){const o=performance.now(),a=o-i;t.value=Math.round(1e3/(a/r)),i=o,r=0}}),t}function FT(s={}){const e=Ve(),t=hl(()=>typeof performance<"u"&&"memory"in performance);if(t.value){const{interval:n=1e3}=s;PT(()=>{e.value=performance.memory},n,{immediate:s.immediate,immediateCallback:s.immediateCallback})}return{isSupported:t,memory:e}}const Om={x:0,y:0,pointerId:0,pressure:0,tiltX:0,tiltY:0,width:0,height:0,twist:0,pointerType:null},kT=Object.keys(Om);function BT(s={}){const{target:e=mi}=s,t=Ve(!1),n=Ve(s.initialValue||{});Object.assign(n.value,Om,n.value);const i=r=>{t.value=!0,!(s.pointerTypes&&!s.pointerTypes.includes(r.pointerType))&&(n.value=AT(r,kT,!1))};if(e){const r={passive:!0};$r(e,["pointerdown","pointermove","pointerup"],i,r),$r(e,"pointerleave",()=>t.value=!1,r)}return{...CT(n),isInside:t}}function zT(s={}){const{window:e=mi,initialWidth:t=Number.POSITIVE_INFINITY,initialHeight:n=Number.POSITIVE_INFINITY,listenOrientation:i=!0,includeScrollbar:r=!0}=s,o=Ve(t),a=Ve(n),l=()=>{e&&(r?(o.value=e.innerWidth,a.value=e.innerHeight):(o.value=e.document.documentElement.clientWidth,a.value=e.document.documentElement.clientHeight))};if(l(),Ju(l),$r("resize",l,{passive:!0}),i){const c=LT("(orientation: portrait)");wt(c,()=>l())}return{width:o,height:a}}var VT=Object.defineProperty,HT=(s,e,t)=>e in s?VT(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Vd=(s,e,t)=>(HT(s,typeof e!="symbol"?e+"":e,t),t);const GT="@tresjs/core",WT="module",$T="4.0.2",XT="pnpm@9.1.4",qT="Declarative ThreeJS using Vue Components",YT="Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",ZT="MIT",KT=["vue","3d","threejs","three","threejs-vue"],JT=!1,jT={".":{types:"./dist/index.d.ts",import:"./dist/tres.js",require:"./dist/tres.umd.cjs"},"./components":{types:"./dist/src/components/index.d.ts"},"./composables":{types:"./dist/src/composables/index.d.ts"},"./types":{types:"./dist/src/types/index.d.ts"},"./utils":{types:"./dist/src/utils/index.d.ts"},"./*":"./*"},QT="./dist/tres.js",eC="./dist/tres.js",tC="./dist/index.d.ts",nC=["*.d.ts","dist"],iC={access:"public"},sC={dev:"cd playground && npm run dev",build:"vite build",playground:"cd playground && npm run dev",test:"vitest","test:ci":"vitest run","test:ui":"vitest --ui --coverage.enabled=true",release:"release-it",coverage:"vitest run --coverage",lint:"eslint .","lint:fix":"eslint . --fix","docs:dev":"vitepress dev docs","docs:build":"vitepress build docs","docs:serve":"vitepress serve docs","docs:preview":"vitepress preview docs","docs:contributors":"esno scripts/update-contributors.ts",prepare:"node .husky/install.mjs"},rC={three:">=0.133",vue:">=3.4"},oC={"@alvarosabu/utils":"^3.2.0","@vue/devtools-api":"^6.6.2","@vueuse/core":"^10.10.0"},aC={"@release-it/conventional-changelog":"^8.0.1","@stackblitz/sdk":"^1.10.0","@tresjs/cientos":"3.9.0","@tresjs/eslint-config":"^1.1.0","@types/three":"^0.165.0","@typescript-eslint/eslint-plugin":"^7.11.0","@typescript-eslint/parser":"^7.11.0","@vitejs/plugin-vue":"^5.0.5","@vitest/coverage-c8":"^0.33.0","@vitest/coverage-v8":"^1.6.0","@vitest/ui":"^1.6.0","@vue/test-utils":"^2.4.6",eslint:"^9.4.0","eslint-plugin-vue":"^9.26.0",esno:"^4.7.0",gsap:"^3.12.5",husky:"^9.0.11",jsdom:"^24.1.0",kolorist:"^1.8.0",ohmyfetch:"^0.4.21",pathe:"^1.1.2","release-it":"^17.3.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-copy":"^3.5.0","rollup-plugin-visualizer":"^5.12.0",three:"^0.165.0",unocss:"^0.60.4",unplugin:"^1.10.1","unplugin-vue-components":"^0.27.0",vite:"^5.2.12","vite-plugin-banner":"^0.7.1","vite-plugin-dts":"3.9.1","vite-plugin-inspect":"^0.8.4","vite-plugin-require-transform":"^1.0.21","vite-svg-loader":"^5.1.0",vitepress:"1.2.2",vitest:"^1.6.0",vue:"^3.4.27","vue-demi":"^0.14.8"},lC={name:GT,type:WT,version:$T,packageManager:XT,description:qT,author:YT,license:ZT,keywords:KT,sideEffects:JT,exports:jT,main:QT,module:eC,types:tC,files:nC,publishConfig:iC,scripts:sC,peerDependencies:rC,dependencies:oC,devDependencies:aC},cC=({sizes:s})=>{const e=Ve([]),t=He(()=>e.value[0]),n=o=>{const a=o instanceof Qr?o:e.value.find(c=>c.uuid===o);if(!a)return;const l=e.value.filter(({uuid:c})=>c!==a.uuid);e.value=[a,...l]},i=(o,a=!1)=>{e.value.some(({uuid:l})=>l===o.uuid)||(a?n(o):e.value.push(o))},r=o=>{e.value=e.value.filter(({uuid:a})=>a!==o.uuid)};return Li(()=>{s.aspectRatio.value&&e.value.forEach(o=>{!o.manual&&(o instanceof kt||uC(o))&&(o instanceof kt?o.aspect=s.aspectRatio.value:(o.left=s.width.value*-.5,o.right=s.width.value*.5,o.top=s.height.value*.5,o.bottom=s.height.value*-.5),o.updateProjectionMatrix())})}),$n(()=>{e.value=[]}),{camera:t,cameras:e,registerCamera:i,deregisterCamera:r,setCameraActive:n}};function uC(s){return s.hasOwnProperty("isOrthographicCamera")&&s.isOrthographicCamera}const Fm=Pn(),km=Pn(),Qu=Pn(),Mr=new ul;let ya=0,xa=0;const{pause:hC,resume:Hd,isActive:dC}=ju(()=>{Fm.trigger({delta:ya,elapsed:xa,clock:Mr}),km.trigger({delta:ya,elapsed:xa,clock:Mr}),Qu.trigger({delta:ya,elapsed:xa,clock:Mr})},{immediate:!1});Qu.on(()=>{ya=Mr.getDelta(),xa=Mr.getElapsedTime()});let Gd=!1;const fC=()=>(Gd||(Gd=!0,Hd()),{onBeforeLoop:Fm.on,onLoop:km.on,onAfterLoop:Qu.on,pause:hC,resume:Hd,isActive:dC}),sa="[TresJS ▲ ■ ●] ";function ao(){function s(...n){typeof n[0]=="string"?n[0]=sa+n[0]:n.unshift(sa),console.error(...n)}function e(...n){typeof n[0]=="string"?n[0]=sa+n[0]:n.unshift(sa),console.warn(...n)}function t(n,i){}return{logError:s,logWarning:e,logMessage:t}}function pC(s){return s instanceof Ie?s:Array.isArray(s)?new Ie(...s):new Ie(s)}class mC extends Nt{constructor(...e){super(...e),Vd(this,"type","HightlightMesh"),Vd(this,"createTime"),this.createTime=Date.now()}onBeforeRender(){const e=(Date.now()-this.createTime)/1e3,t=1+.07*Math.sin(2.5*e);this.scale.set(t,t,t)}}const Bm=(s,e)=>{for(const t of Object.keys(e))e[t]instanceof Object&&Object.assign(e[t],Bm(s[t],e[t]));return Object.assign(s||{},e),s},gC="html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot",_C=xC(gC);function Wd(s){return s&&s.nodeType===1}function ra(s){return s.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const vC=/\B([A-Z])/g;function yC(s){return s.replace(vC,"-$1").toLowerCase()}function xC(s,e){const t=Object.create(null),n=s.split(",");for(let i=0;i<n.length;i++)t[n[i]]=!0;return i=>!!t[i]}const $d=(s,e)=>{if(!e)return;const t=Array.isArray(e)?e:e.match(/([^[.\]])+/g);return t==null?void 0:t.reduce((n,i)=>n&&n[i],s)},MC=(s,e,t)=>{const n=Array.isArray(e)?e:e.match(/([^[.\]])+/g);n&&n.reduce((i,r,o)=>(i[r]===void 0&&(i[r]={}),o===n.length-1&&(i[r]=t),i[r]),s)};function zm(s,e){if(Wd(s)&&Wd(e)){const i=s.attributes,r=e.attributes;return i.length!==r.length?!1:Array.from(i).every(({name:o,value:a})=>e.getAttribute(o)===a)}if(s===e)return!0;if(s===null||typeof s!="object"||e===null||typeof e!="object")return!1;const t=Object.keys(s),n=Object.keys(e);if(t.length!==n.length)return!1;for(const i of t)if(!n.includes(i)||!zm(s[i],e[i]))return!1;return!0}function bC(s,e){if(!Array.isArray(s)||!Array.isArray(e)||s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!zm(s[t],e[t]))return!1;return!0}function SC(s,e,t,n){const i=l=>{if(l.uuid===e)return l;for(const c of l.children){const u=i(c);if(u)return u}},r=i(s);if(!r){console.warn("Object with UUID not found in the scene.");return}let o=r;for(let l=0;l<t.length-1;l++)if(o[t[l]]!==void 0)o=o[t[l]];else{console.warn(`Property path is not valid: ${t.join(".")}`);return}const a=t[t.length-1];o[a]!==void 0?o[a]=n:console.warn(`Property path is not valid: ${t.join(".")}`)}function wC(s){const e=new pi({color:11003607,transparent:!0,opacity:.2,depthTest:!1,side:In});return new mC(s.geometry.clone(),e)}function AC(s){return"map"in s}function Xd(s){AC(s)&&s.map&&s.map.dispose(),s.dispose()}function eh(s){var e,t;if(s.parent&&((e=s.removeFromParent)==null||e.call(s)),delete s.__tres,[...s.children].forEach(n=>eh(n)),!(s instanceof $a)){const n=s;s&&((t=s.dispose)==null||t.call(s)),n.geometry&&(n.geometry.dispose(),delete n.geometry),Array.isArray(n.material)?(n.material.forEach(i=>Xd(i)),delete n.material):n.material&&(Xd(n.material),delete n.material)}}const EC=Number.parseInt(Zr.replace("dev","")),oa={realistic:{shadows:!0,physicallyCorrectLights:!0,outputColorSpace:dn,toneMapping:Ua,toneMappingExposure:3,shadowMap:{enabled:!0,type:hu}},flat:{toneMapping:Wn,toneMappingExposure:1}};function TC({canvas:s,options:e,contextParts:{sizes:t,render:n,invalidate:i,advance:r}}){const o=He(()=>({alpha:bt(e.alpha)??!0,depth:bt(e.depth),canvas:Ln(s),context:bt(e.context),stencil:bt(e.stencil),antialias:bt(e.antialias)??!0,precision:bt(e.precision),powerPreference:bt(e.powerPreference),premultipliedAlpha:bt(e.premultipliedAlpha),preserveDrawingBuffer:bt(e.preserveDrawingBuffer),logarithmicDepthBuffer:bt(e.logarithmicDepthBuffer),failIfMajorPerformanceCaveat:bt(e.failIfMajorPerformanceCaveat)})),a=Dn(new va(o.value));function l(){e.renderMode==="on-demand"&&i()}wt(o,()=>{a.value.dispose(),a.value=new va(o.value),l()}),wt([t.width,t.height],()=>{a.value.setSize(t.width.value,t.height.value),l()},{immediate:!0}),wt(()=>e.clearColor,l);const{pixelRatio:c}=NT();wt(c,()=>{a.value.setPixelRatio(c.value)});const{logError:u}=ao(),h=(()=>{const f=new va,g={shadowMap:{enabled:f.shadowMap.enabled,type:f.shadowMap.type},toneMapping:f.toneMapping,toneMappingExposure:f.toneMappingExposure,outputColorSpace:f.outputColorSpace};return f.dispose(),g})(),d=bt(e.renderMode);return d==="on-demand"&&i(),d==="manual"&&setTimeout(()=>{r()},100),Li(()=>{const f=bt(e.preset);f&&(f in oa||u(`Renderer Preset must be one of these: ${Object.keys(oa).join(", ")}`),Bm(a.value,oa[f])),d==="always"&&(n.frames.value=Math.max(1,n.frames.value));const g=(m,y)=>{const v=bt(m),x=()=>{if(f)return $d(oa[f],y)};if(v!==void 0)return v;const E=x();return E!==void 0?E:$d(h,y)},_=(m,y)=>MC(a.value,y,g(m,y));_(e.shadows,"shadowMap.enabled"),_(e.toneMapping??Ua,"toneMapping"),_(e.shadowMapType,"shadowMap.type"),EC<150&&_(!e.useLegacyLights,"physicallyCorrectLights"),_(e.outputColorSpace,"outputColorSpace"),_(e.toneMappingExposure,"toneMappingExposure");const p=g(e.clearColor,"clearColor");p&&a.value.setClearColor(p?pC(p):new Ie(0))}),$n(()=>{a.value.dispose(),a.value.forceContextLoss()}),{renderer:a}}const aa=s=>typeof s=="function",CC=s=>!!s&&s.constructor===Array;function PC(s){const e={nodes:{},materials:{}};return s&&s.traverse(t=>{t.name&&(e.nodes[t.name]=t),t.material&&!e.materials[t.material.name]&&(e.materials[t.material.name]=t.material)}),e}async function RC(s,e,t,n,i){const{logError:r}=ao(),o=new s,a=(Array.isArray(e)?e:[e]).map(l=>new Promise((c,u)=>{o.load(l,h=>{h.scene&&Object.assign(h,PC(h.scene)),c(h)},n,h=>u(r("[useLoader] - Failed to load resource",h)))}));return CC(e)?await Promise.all(a):await a[0]}const IC=(s,e)=>{const t=He(()=>e.renderer.value.domElement),n=Dn([]),{x:i,y:r}=BT({target:t}),o=He(()=>s.value.filter(_e=>{var De;return((De=_e.__tres)==null?void 0:De.eventCount)>0}));let a=0;const{width:l,height:c,top:u,left:h}=DT(t),d=({x:_e,y:De})=>{if(t.value)return{x:(_e-h.value)/l.value*2-1,y:-((De-u.value)/c.value)*2+1}},f=({x:_e,y:De})=>{if(e.camera.value)return e.raycaster.value.setFromCamera(new te(_e,De),e.camera.value),n.value=e.raycaster.value.intersectObjects(o.value,!0),n.value},g=_e=>{const De=d({x:(_e==null?void 0:_e.clientX)??i.value,y:(_e==null?void 0:_e.clientY)??r.value});return De?f(De)||[]:[]},_=Pn(),p=Pn(),m=Pn(),y=Pn(),v=Pn(),x=Pn(),E=Pn(),S=Pn();function C(_e){const De={};for(const F in _e)typeof F!="function"&&(De[F]=_e[F]);return De}const L=(_e,De)=>{var F,U,I;const T=C(De),se=new N(De==null?void 0:De.clientX,De==null?void 0:De.clientY,0).unproject((F=e.camera)==null?void 0:F.value);_e.trigger({...T,intersections:n.value,unprojectedPoint:se,ray:(U=e.raycaster)==null?void 0:U.value.ray,camera:(I=e.camera)==null?void 0:I.value,sourceEvent:De,delta:a,stopPropagating:!1})};let A;const b=_e=>{g(_e),L(m,_e),A=_e},k=()=>{A&&b(A)};let V,G,X;const ce=_e=>{var De;V=(De=n.value[0])==null?void 0:De.object,a=0,G=new te((_e==null?void 0:_e.clientX)??i.value,(_e==null?void 0:_e.clientY)??r.value),L(v,_e)};let Z,ae=!1;const z=_e=>{var De,F,U;_e instanceof PointerEvent&&(n.value.length===0&&L(x,_e),V===((De=n.value[0])==null?void 0:De.object)&&(X=new te((_e==null?void 0:_e.clientX)??i.value,(_e==null?void 0:_e.clientY)??r.value),a=G==null?void 0:G.distanceTo(X),_e.button===0?(L(_,_e),Z===((F=n.value[0])==null?void 0:F.object)?ae=!0:(Z=(U=n.value[0])==null?void 0:U.object,ae=!1)):_e.button===2&&L(E,_e)),L(y,_e))},Se=_e=>{ae&&(L(p,_e),Z=void 0,ae=!1)},we=_e=>L(m,_e),Ae=_e=>L(S,_e);return t.value.addEventListener("pointerup",z),t.value.addEventListener("pointerdown",ce),t.value.addEventListener("pointermove",b),t.value.addEventListener("pointerleave",we),t.value.addEventListener("dblclick",Se),t.value.addEventListener("wheel",Ae),$n(()=>{t!=null&&t.value&&(t.value.removeEventListener("pointerup",z),t.value.removeEventListener("pointerdown",ce),t.value.removeEventListener("pointermove",b),t.value.removeEventListener("pointerleave",we),t.value.removeEventListener("dblclick",Se),t.value.removeEventListener("wheel",Ae))}),{intersects:n,onClick:_e=>_.on(_e).off,onDblClick:_e=>p.on(_e).off,onContextMenu:_e=>E.on(_e).off,onPointerMove:_e=>m.on(_e).off,onPointerUp:_e=>y.on(_e).off,onPointerDown:_e=>v.on(_e).off,onPointerMissed:_e=>x.on(_e).off,onWheel:_e=>S.on(_e).off,forceUpdate:k}};function th(s){let e=0;return s.traverse(t=>{if(t.isMesh&&t.geometry){const n=t.geometry,i=n.attributes.position.count*3*Float32Array.BYTES_PER_ELEMENT,r=n.index?n.index.count*Uint32Array.BYTES_PER_ELEMENT:0,o=n.attributes.normal?n.attributes.normal.count*3*Float32Array.BYTES_PER_ELEMENT:0,a=n.attributes.uv?n.attributes.uv.count*2*Float32Array.BYTES_PER_ELEMENT:0,l=i+r+o+a;e+=l}}),e}function LC(s){return(s/1024).toFixed(2)}const jc=Ve({}),Ra=s=>Object.assign(jc.value,s);function NC(s,e,t=10){const n=bt(s)?zT():UT(He(()=>bt(e).parentElement)),i=br(zd(n.width,t)),r=br(zd(n.height,t)),o=He(()=>i.value/r.value);return{height:r,width:i,aspectRatio:o}}function nc(){const s=new Map,e=new Set;let t=0,n=!1;const i=()=>{const o=Array.from(s.entries()).sort((a,l)=>{const c=a[1].priority-l[1].priority;return c===0?a[1].addI-l[1].addI:c});e.clear(),o.forEach(a=>e.add(a[0]))},r=o=>{s.delete(o),e.delete(o)};return{on:(o,a=0)=>{s.set(o,{priority:a,addI:t++});const l=()=>r(o);return qn(l),n=!0,{off:l}},off:r,trigger:(...o)=>{n&&(i(),n=!1),e.forEach(a=>a(...o))},dispose:()=>{s.clear(),e.clear()},get count(){return s.size}}}function DC(){const s=new ul(!1),e=Ve(!1),t=Ve(!1);let n;const i=Su.generateUUID();let r=null;const o=nc(),a=nc(),l=nc();let c={};function u(v){c=v}function h(v,x,E=0){switch(x){case"before":return o.on(v,E);case"render":return r||(r=v),a.dispose(),a.on(v);case"after":return l.on(v,E)}}function d(){e.value||(s.start(),e.value=!0,y())}function f(){e.value&&(s.stop(),cancelAnimationFrame(n),e.value=!1)}function g(){s.stop(),e.value=!1}function _(){s.start(),e.value=!0}function p(){t.value=!0}function m(){t.value=!1}function y(){const v=s.getDelta(),x=s.getElapsedTime(),E={camera:ee(c.camera),scene:ee(c.scene),renderer:ee(c.renderer),raycaster:ee(c.raycaster),controls:ee(c.controls),invalidate:c.invalidate,advance:c.advance},S={delta:v,elapsed:x,clock:s,...E};e.value&&o.trigger(S),t.value||(a.count?a.trigger(S):r&&r(S)),e.value&&l.trigger(S),n=requestAnimationFrame(y)}return{loopId:i,register:(v,x,E)=>h(v,x,E),start:d,stop:f,pause:g,resume:_,pauseRender:p,resumeRender:m,isRenderPaused:t,isActive:e,setContext:u}}function UC({scene:s,canvas:e,windowSize:t,disableRender:n,rendererOptions:i,emit:r}){const{logWarning:o}=ao(),a=Dn(s),l=NC(t,e),{camera:c,cameras:u,registerCamera:h,deregisterCamera:d,setCameraActive:f}=cC({sizes:l,scene:s}),g={mode:Ve(i.renderMode||"always"),priority:Ve(0),frames:Ve(0),maxFrames:60,canBeInvalidated:He(()=>g.mode.value==="on-demand"&&g.frames.value===0)};function _(G=1){i.renderMode==="on-demand"?g.frames.value=Math.min(g.maxFrames,g.frames.value+G):o("`invalidate` can only be used when `renderMode` is set to `on-demand`")}function p(){i.renderMode==="manual"?g.frames.value=1:o("`advance` can only be used when `renderMode` is set to `manual`")}const{renderer:m}=TC({scene:s,canvas:e,options:i,emit:r,contextParts:{sizes:l,camera:c,render:g,invalidate:_,advance:p},disableRender:n}),y={sizes:l,scene:a,camera:c,cameras:br(u),renderer:m,raycaster:Dn(new Lm),controls:Ve(null),perf:{maxFrames:160,fps:{value:0,accumulator:[]},memory:{currentMem:0,allocatedMem:0,accumulator:[]}},render:g,advance:p,extend:Ra,invalidate:_,registerCamera:h,setCameraActive:f,deregisterCamera:d,loop:DC()};Sr("useTres",y),y.scene.value.__tres={root:y},y.loop.register(()=>{c.value&&g.frames.value>0&&(m.value.render(s,c.value),r("render",y.renderer.value)),g.priority.value=0,g.mode.value==="always"?g.frames.value=1:g.frames.value=Math.max(0,g.frames.value-1)},"render"),y.loop.start(),$n(()=>{y.loop.stop()});const v=100,x=OT({every:v}),{isSupported:E,memory:S}=FT({interval:v}),C=160;let L=performance.now();const A=({timestamp:G})=>{y.scene.value&&(y.perf.memory.allocatedMem=th(y.scene.value)),G-L>=v&&(L=G,y.perf.fps.accumulator.push(x.value),y.perf.fps.accumulator.length>C&&y.perf.fps.accumulator.shift(),y.perf.fps.value=x.value,E.value&&S.value&&(y.perf.memory.accumulator.push(S.value.usedJSHeapSize/1024/1024),y.perf.memory.accumulator.length>C&&y.perf.memory.accumulator.shift(),y.perf.memory.currentMem=y.perf.memory.accumulator.reduce((X,ce)=>X+ce,0)/y.perf.memory.accumulator.length))};let b=0;const k=1,{pause:V}=ju(({delta:G})=>{window.__TRES__DEVTOOLS__&&(A({timestamp:performance.now()}),b+=G,b>=k&&(window.__TRES__DEVTOOLS__.cb(y),b=0))},{immediate:!0});return $n(()=>{V()}),y}function OC(){const s=qr("useTres");if(!s)throw new Error("useTresContext must be used together with useTresContextProvider");return s}function FC(s,e,t){const n=Dn(),i=Dn();s&&(n.value=s),e&&(i.value=e);const r=He(()=>n.value?n.value.children:[]);function o(E,S){if(Array.isArray(E))for(const C of E)C(S);typeof E=="function"&&E(S)}function a(E,S){const C=[],L=()=>S.stopPropagating=!0;S.stopPropagation=L;for(const A of S==null?void 0:S.intersections){if(S.stopPropagating)return;S={...S,...A};const{object:b}=A;S.eventObject=b,o(b[E],S),C.push(b);let k=b.parent;for(;k!==null&&!S.stopPropagating&&!C.includes(k);)S.eventObject=k,o(k[E],S),C.push(k),k=k.parent;const V=yC(E.slice(2));t(V,{intersection:A,event:S})}}const{onClick:l,onDblClick:c,onContextMenu:u,onPointerMove:h,onPointerDown:d,onPointerUp:f,onPointerMissed:g,onWheel:_,forceUpdate:p}=IC(r,e);f(E=>a("onPointerUp",E)),d(E=>a("onPointerDown",E)),l(E=>a("onClick",E)),c(E=>a("onDoubleClick",E)),u(E=>a("onContextMenu",E)),_(E=>a("onWheel",E));let m=[];h(E=>{const S=E.intersections.map(({object:L})=>L),C=E.intersections;m.forEach(({object:L})=>{S.includes(L)||(E.intersections=m,a("onPointerLeave",E),a("onPointerOut",E))}),E.intersections=C,E.intersections.forEach(({object:L})=>{m.includes(L)||(a("onPointerEnter",E),a("onPointerOver",E))}),a("onPointerMove",E),m=E.intersections});const y=[];g(E=>{const S=()=>E.stopPropagating=!0;E.stopPropagation=S,y.forEach(C=>{E.stopPropagating||(E.eventObject=C,o(C.onPointerMissed,E))}),t("pointer-missed",{event:E})});function v(E){y.push(E)}function x(E){const S=y.indexOf(E);S>-1&&y.splice(S,1)}return e.eventManager={forceUpdate:p,registerPointerMissedObject:v,deregisterPointerMissedObject:x},{forceUpdate:p,registerPointerMissedObject:v,deregisterPointerMissedObject:x}}const{logError:qd}=ao(),Yd=["onClick","onContextMenu","onPointerMove","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onDoubleClick","onPointerDown","onPointerUp","onPointerCancel","onPointerMissed","onLostPointerCapture","onWheel"];function Zd(s){var e;const t=(e=s==null?void 0:s.__tres)==null?void 0:e.root;t&&t.render&&t.render.canBeInvalidated.value&&t.invalidate()}const kC=()=>{let s=null;function e(l,c,u,h){if(h||(h={}),h.args||(h.args=[]),l==="template"||_C(l))return null;let d=l.replace("Tres",""),f;if(l==="primitive"){(h==null?void 0:h.object)===void 0&&qd("Tres primitives need a prop 'object'");const g=h.object;d=g.type,f=Object.assign(g.clone(),{type:d})}else{const g=jc.value[d];g||qd(`${d} is not defined on the THREE namespace. Use extend to add it to the catalog.`),f=new g(...h.args)}return f?(f.isCamera&&(h!=null&&h.position||f.position.set(3,3,3),h!=null&&h.lookAt||f.lookAt(0,0,0)),(h==null?void 0:h.attach)===void 0&&(f.isMaterial?f.attach="material":f.isBufferGeometry&&(f.attach="geometry")),f.__tres={...f.__tres,type:d,memoizedProps:h,eventCount:0,disposable:!0,primitive:l==="primitive"},f.isObject3D&&f.__tres&&(h!=null&&h.material||h!=null&&h.geometry)&&(f.__tres.disposable=!1),f):null}function t(l,c){var u,h,d,f,g;if(!l)return;c&&c.isScene&&(s=c),s&&l.__tres&&(l.__tres.root=s.__tres.root);const _=c||s;if(l!=null&&l.isObject3D){const{registerCamera:p}=(u=l==null?void 0:l.__tres)==null?void 0:u.root;l!=null&&l.isCamera&&p(l),l.onPointerMissed&&(h=l==null?void 0:l.__tres)!=null&&h.root&&((g=(f=(d=l==null?void 0:l.__tres)==null?void 0:d.root)==null?void 0:f.eventManager)==null||g.registerPointerMissedObject(l))}l!=null&&l.isObject3D&&_!=null&&_.isObject3D?(_.add(l),l.dispatchEvent({type:"added"})):l!=null&&l.isFog?_.fog=l:typeof(l==null?void 0:l.attach)=="string"&&(l.__previousAttach=l[_==null?void 0:_.attach],_&&(_[l.attach]=l))}function n(l){var c,u,h,d;if(!l)return;const f=l.__tres;if(l.parent=l.parent||s,l.isObject3D){const g=_=>{var p,m;const y=(m=(p=l==null?void 0:l.__tres)==null?void 0:p.root)==null?void 0:m.deregisterCamera;_.isCamera&&(y==null||y(_))};(c=l.removeFromParent)==null||c.call(l),l.traverse(_=>{var p,m;g(_),_.onPointerMissed&&((m=(p=f==null?void 0:f.root)==null?void 0:p.eventManager)==null||m.deregisterPointerMissedObject(_))}),g(l),Zd(l),!((u=l.__tres)!=null&&u.primitive)&&(h=l.__tres)!=null&&h.disposable&&eh(l),(d=l.dispose)==null||d.call(l)}}function i(l,c,u,h){var d,f;if(l){let g=l,_=c;if((d=l==null?void 0:l.__tres)!=null&&d.primitive&&_==="object"&&u!==null){const v=e("primitive",void 0,void 0,{object:h});for(const x in v){if(x==="uuid")continue;const E=l[x],S=v[x];!(E!=null&&E.set)&&!aa(E)?l[x]=S:E.constructor===S.constructor&&E!=null&&E.copy?E==null||E.copy(S):Array.isArray(S)?E.set(...S):!E.isColor&&E.setScalar?E.setScalar(S):E.set(S)}v!=null&&v.__tres&&(v.__tres.root=s==null?void 0:s.__tres.root),v!=null&&v.isGroup?(l.geometry=void 0,l.material=void 0):delete l.isGroup}if(l!=null&&l.isObject3D&&_==="blocks-pointer-events"){h||h===""?l[_]=h:delete l[_];return}Yd.includes(c)&&(l.__tres.eventCount+=1);let p=ra(_),m=g==null?void 0:g[p];if(_==="args"){const v=l,x=u??[],E=h??[],S=((f=l==null?void 0:l.__tres)==null?void 0:f.type)||l.type;S&&x.length&&!bC(x,E)&&(g=Object.assign(v,new jc.value[S](...h)));return}if(g.type==="BufferGeometry"){if(_==="args")return;g.setAttribute(ra(_),new mt(...h));return}if(_.includes("-")&&m===void 0){const v=_.split("-");m=v.reduce((x,E)=>x[ra(E)],g),_=v.pop(),p=_,m!=null&&m.set||(g=v.reduce((x,E)=>x[ra(E)],g))}let y=h;if(y===""&&(y=!0),aa(m)){Yd.includes(c)||(Array.isArray(y)?l[p](...y):l[p](y)),p.startsWith("on")&&aa(y)&&(g[p]=y);return}!(m!=null&&m.set)&&!aa(m)?g[p]=y:m.constructor===y.constructor&&m!=null&&m.copy?m==null||m.copy(y):Array.isArray(y)?m.set(...y):!m.isColor&&m.setScalar?m.setScalar(y):m.set(y),Zd(l)}}function r(l){return(l==null?void 0:l.parent)||null}function o(l){const c=new ut;return c.name=l,c.__tres={type:"Comment"},c.__tres.root=s==null?void 0:s.__tres.root,c}function a(l){if(!l)return null;const c=l.parent||s,u=c.children.indexOf(l);return c.children[u+1]||null}return{insert:t,remove:n,createElement:e,patchProp:i,parentNode:r,createText:()=>{},createComment:o,setText:()=>{},setElementText:()=>{},nextSibling:a,querySelector:()=>{},setScopeId:()=>{},cloneNode:()=>{},insertStaticContent:()=>{}}};function BC(){return Vm().__VUE_DEVTOOLS_GLOBAL_HOOK__}function Vm(){return typeof navigator<"u"&&typeof window<"u"?window:typeof globalThis<"u"?globalThis:{}}const zC=typeof Proxy=="function",VC="devtools-plugin:setup",HC="plugin:settings:set";let fr,Qc;function GC(){var s;return fr!==void 0||(typeof window<"u"&&window.performance?(fr=!0,Qc=window.performance):typeof globalThis<"u"&&!((s=globalThis.perf_hooks)===null||s===void 0)&&s.performance?(fr=!0,Qc=globalThis.perf_hooks.performance):fr=!1),fr}function WC(){return GC()?Qc.now():Date.now()}class $C{constructor(e,t){this.target=null,this.targetQueue=[],this.onQueue=[],this.plugin=e,this.hook=t;const n={};if(e.settings)for(const o in e.settings){const a=e.settings[o];n[o]=a.defaultValue}const i=`__vue-devtools-plugin-settings__${e.id}`;let r=Object.assign({},n);try{const o=localStorage.getItem(i),a=JSON.parse(o);Object.assign(r,a)}catch{}this.fallbacks={getSettings(){return r},setSettings(o){try{localStorage.setItem(i,JSON.stringify(o))}catch{}r=o},now(){return WC()}},t&&t.on(HC,(o,a)=>{o===this.plugin.id&&this.fallbacks.setSettings(a)}),this.proxiedOn=new Proxy({},{get:(o,a)=>this.target?this.target.on[a]:(...l)=>{this.onQueue.push({method:a,args:l})}}),this.proxiedTarget=new Proxy({},{get:(o,a)=>this.target?this.target[a]:a==="on"?this.proxiedOn:Object.keys(this.fallbacks).includes(a)?(...l)=>(this.targetQueue.push({method:a,args:l,resolve:()=>{}}),this.fallbacks[a](...l)):(...l)=>new Promise(c=>{this.targetQueue.push({method:a,args:l,resolve:c})})})}async setRealTarget(e){this.target=e;for(const t of this.onQueue)this.target.on[t.method](...t.args);for(const t of this.targetQueue)t.resolve(await this.target[t.method](...t.args))}}function XC(s,e){const t=s,n=Vm(),i=BC(),r=zC&&t.enableEarlyProxy;if(i&&(n.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__||!r))i.emit(VC,s,e);else{const o=r?new $C(t,i):null;(n.__VUE_DEVTOOLS_PLUGINS__=n.__VUE_DEVTOOLS_PLUGINS__||[]).push({pluginDescriptor:t,setupFn:e,proxy:o}),o&&e(o.proxiedTarget)}}function qC(s,e){const t=`▲ ■ ●${s}`;typeof Kd=="function"?Kd(t,e):console.log(t)}function Kd(s,e){throw new Error(s+e)}const Hm=s=>{const e={id:s.uuid,label:s.type,children:[],tags:[]};s.name!==""&&e.tags.push({label:s.name,textColor:5750629,backgroundColor:15793395});const t=th(s);return t>0&&e.tags.push({label:`${LC(t)} KB`,textColor:15707189,backgroundColor:16775644,tooltip:"Memory usage"}),s.type.includes("Light")&&(e.tags.push({label:`${s.intensity}`,textColor:9738662,backgroundColor:16316922,tooltip:"Intensity"}),e.tags.push({label:`#${s.color.getHexString()}`,textColor:9738662,backgroundColor:16316922,tooltip:"Color"})),s.type.includes("Camera")&&(e.tags.push({label:`${s.fov}°`,textColor:9738662,backgroundColor:16316922,tooltip:"Field of view"}),e.tags.push({label:`x: ${Math.round(s.position.x)} y: ${Math.round(s.position.y)} z: ${Math.round(s.position.z)}`,textColor:9738662,backgroundColor:16316922,tooltip:"Position"})),e};function Gm(s,e,t=""){s.children.forEach(n=>{if(n.type==="HightlightMesh"||t&&!n.type.includes(t)&&!n.name.includes(t))return;const i=Hm(n);e.children.push(i),Gm(n,i,t)})}const YC=[],pr="tres:inspector",ZC=ug({sceneGraph:null});function KC(s,e){XC({id:"dev.esm.tres",label:"TresJS 🪐",logo:"https://raw.githubusercontent.com/Tresjs/tres/main/public/favicon.svg",packageName:"tresjs",homepage:"https://tresjs.org",componentStateTypes:YC,app:s},t=>{typeof t.now!="function"&&qC("You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html."),t.addInspector({id:pr,label:"TresJS 🪐",icon:"account_tree",treeFilterPlaceholder:"Search instances"}),setInterval(()=>{t.sendInspectorTree(pr)},1e3),setInterval(()=>{t.notifyComponentUpdate()},5e3),t.on.getInspectorTree(r=>{if(r.inspectorId===pr){const o=Hm(e.scene.value);Gm(e.scene.value,o,r.filter),ZC.sceneGraph=o,r.rootNodes=[o]}});let n=null,i=null;t.on.getInspectorState(r=>{var o;if(r.inspectorId===pr){const[a]=e.scene.value.getObjectsByProperty("uuid",r.nodeId);if(!a)return;if(i&&n&&n.parent&&i.remove(n),a.isMesh){const l=wC(a);a.add(l),n=l,i=a}r.state={object:[{key:"uuid",editable:!0,value:a.uuid},{key:"name",editable:!0,value:a.name},{key:"type",editable:!0,value:a.type},{key:"position",editable:!0,value:a.position},{key:"rotation",editable:!0,value:a.rotation},{key:"scale",editable:!0,value:a.scale},{key:"geometry",value:a.geometry},{key:"material",value:a.material},{key:"color",editable:!0,value:a.color},{key:"intensity",editable:!0,value:a.intensity},{key:"castShadow",editable:!0,value:a.castShadow},{key:"receiveShadow",editable:!0,value:a.receiveShadow},{key:"frustumCulled",editable:!0,value:a.frustumCulled},{key:"matrixAutoUpdate",editable:!0,value:a.matrixAutoUpdate},{key:"matrixWorldNeedsUpdate",editable:!0,value:a.matrixWorldNeedsUpdate},{key:"matrixWorld",value:a.matrixWorld},{key:"visible",editable:!0,value:a.visible}]},a.isScene&&(r.state.info={memory:th(a),objects:a.children.length,calls:e.renderer.value.info.render.calls,triangles:e.renderer.value.info.render.triangles,points:e.renderer.value.info.render.points,lines:e.renderer.value.info.render.lines},r.state.programs=((o=e.renderer.value.info.programs)==null?void 0:o.map(l=>({key:l.name,value:{...l,vertexShader:l.vertexShader,attributes:l.getAttributes(),uniforms:l.getUniforms()}})))||[])}}),t.on.editInspectorState(r=>{r.inspectorId===pr&&SC(e.scene.value,r.nodeId,r.path,r.state.value)})})}const JC=["data-scene","data-tres"],jC=ke({__name:"TresCanvas",props:{shadows:{type:Boolean,default:void 0},clearColor:{},toneMapping:{},shadowMapType:{},useLegacyLights:{type:Boolean,default:void 0},outputColorSpace:{},toneMappingExposure:{},renderMode:{default:"always"},camera:{},preset:{},windowSize:{type:Boolean,default:void 0},disableRender:{type:Boolean,default:void 0},context:{},precision:{},alpha:{type:Boolean,default:void 0},premultipliedAlpha:{type:Boolean},antialias:{type:Boolean,default:void 0},stencil:{type:Boolean,default:void 0},preserveDrawingBuffer:{type:Boolean,default:void 0},powerPreference:{},depth:{type:Boolean,default:void 0},logarithmicDepthBuffer:{type:Boolean,default:void 0},failIfMajorPerformanceCaveat:{type:Boolean,default:void 0}},emits:["render","click","double-click","context-menu","pointer-move","pointer-up","pointer-down","pointer-enter","pointer-leave","pointer-over","pointer-out","pointer-missed","wheel"],setup(s,{expose:e,emit:t}){var n;const i=s,r=t,o=rf(),{logWarning:a}=ao(),l=Ve(),c=Dn(new $a),u=(n=Ma())==null?void 0:n.appContext.app;Ra(yT);const h=p=>ke({setup(){var m;const y=(m=Ma())==null?void 0:m.appContext;return y&&(y.app=u),Sr("useTres",p),Sr("extend",Ra),typeof window<"u"&&KC(y==null?void 0:y.app,p),()=>oh(xt,null,o!=null&&o.default?o.default():[])}}),d=p=>{const m=h(p),{render:y}=hg(kC());y(oh(m),c.value)},f=(p,m=!1)=>{eh(p.scene.value),m&&(p.renderer.value.dispose(),p.renderer.value.renderLists.dispose(),p.renderer.value.forceContextLoss()),c.value.__tres={root:p},d(p)},g=He(()=>i.disableRender),_=Dn(null);return e({context:_,dispose:()=>f(_.value,!0)}),Fn(()=>{const p=l;_.value=UC({scene:c.value,canvas:p,windowSize:i.windowSize??!1,disableRender:g.value??!1,rendererOptions:i,emit:r}),FC(c.value,_.value,r);const{registerCamera:m,camera:y,cameras:v,deregisterCamera:x}=_.value;d(_.value);const E=()=>{const S=new kt(45,window.innerWidth/window.innerHeight,.1,1e3);S.position.set(3,3,3),S.lookAt(0,0,0),m(S);const C=Li(()=>{v.value.length>=2&&(S.removeFromParent(),x(S),C==null||C())})};wt(()=>i.camera,(S,C)=>{S&&m(S),C&&(C.removeFromParent(),x(C))},{immediate:!0}),y.value||(a("No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."),E())}),$n(()=>{f(_.value)}),(p,m)=>(Y(),ge("canvas",{ref_key:"canvas",ref:l,"data-scene":c.value.uuid,class:yt(p.$attrs.class),"data-tres":`tresjs ${ee(lC).version}`,style:nu({display:"block",width:"100%",height:"100%",position:p.windowSize?"fixed":"relative",top:0,left:0,pointerEvents:"auto",touchAction:"none",...p.$attrs.style})},null,14,JC))}}),QC=dn;class Ia extends un{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,i){const r=this,o=new Xn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(a))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}parse(e){const t=this;function n(F,U){if(F.nodeType!==1)return;const I=x(F);let T=!1,se=null;switch(F.nodeName){case"svg":U=g(F,U);break;case"style":r(F);break;case"g":U=g(F,U);break;case"path":U=g(F,U),F.hasAttribute("d")&&(se=i(F));break;case"rect":U=g(F,U),se=l(F);break;case"polygon":U=g(F,U),se=c(F);break;case"polyline":U=g(F,U),se=u(F);break;case"circle":U=g(F,U),se=h(F);break;case"ellipse":U=g(F,U),se=d(F);break;case"line":U=g(F,U),se=f(F);break;case"defs":T=!0;break;case"use":U=g(F,U);const D=(F.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),q=F.viewportElement.getElementById(D);q?n(q,U):console.warn("SVGLoader: 'use node' references non-existent node id: "+D);break}se&&(U.fill!==void 0&&U.fill!=="none"&&se.color.setStyle(U.fill,QC),S(se,Ae),V.push(se),se.userData={node:F,style:U});const fe=F.childNodes;for(let K=0;K<fe.length;K++){const D=fe[K];T&&D.nodeName!=="style"&&D.nodeName!=="defs"||n(D,U)}I&&(X.pop(),X.length>0?Ae.copy(X[X.length-1]):Ae.identity())}function i(F){const U=new Ei,I=new te,T=new te,se=new te;let fe=!0,K=!1;const D=F.getAttribute("d");if(D===""||D==="none")return null;const q=D.match(/[a-df-z][^a-df-z]*/ig);for(let J=0,H=q.length;J<H;J++){const W=q[J],ie=W.charAt(0),he=W.slice(1).trim();fe===!0&&(K=!0,fe=!1);let B;switch(ie){case"M":B=p(he);for(let O=0,R=B.length;O<R;O+=2)I.x=B[O+0],I.y=B[O+1],T.x=I.x,T.y=I.y,O===0?U.moveTo(I.x,I.y):U.lineTo(I.x,I.y),O===0&&se.copy(I);break;case"H":B=p(he);for(let O=0,R=B.length;O<R;O++)I.x=B[O],T.x=I.x,T.y=I.y,U.lineTo(I.x,I.y),O===0&&K===!0&&se.copy(I);break;case"V":B=p(he);for(let O=0,R=B.length;O<R;O++)I.y=B[O],T.x=I.x,T.y=I.y,U.lineTo(I.x,I.y),O===0&&K===!0&&se.copy(I);break;case"L":B=p(he);for(let O=0,R=B.length;O<R;O+=2)I.x=B[O+0],I.y=B[O+1],T.x=I.x,T.y=I.y,U.lineTo(I.x,I.y),O===0&&K===!0&&se.copy(I);break;case"C":B=p(he);for(let O=0,R=B.length;O<R;O+=6)U.bezierCurveTo(B[O+0],B[O+1],B[O+2],B[O+3],B[O+4],B[O+5]),T.x=B[O+2],T.y=B[O+3],I.x=B[O+4],I.y=B[O+5],O===0&&K===!0&&se.copy(I);break;case"S":B=p(he);for(let O=0,R=B.length;O<R;O+=4)U.bezierCurveTo(_(I.x,T.x),_(I.y,T.y),B[O+0],B[O+1],B[O+2],B[O+3]),T.x=B[O+0],T.y=B[O+1],I.x=B[O+2],I.y=B[O+3],O===0&&K===!0&&se.copy(I);break;case"Q":B=p(he);for(let O=0,R=B.length;O<R;O+=4)U.quadraticCurveTo(B[O+0],B[O+1],B[O+2],B[O+3]),T.x=B[O+0],T.y=B[O+1],I.x=B[O+2],I.y=B[O+3],O===0&&K===!0&&se.copy(I);break;case"T":B=p(he);for(let O=0,R=B.length;O<R;O+=2){const w=_(I.x,T.x),Q=_(I.y,T.y);U.quadraticCurveTo(w,Q,B[O+0],B[O+1]),T.x=w,T.y=Q,I.x=B[O+0],I.y=B[O+1],O===0&&K===!0&&se.copy(I)}break;case"A":B=p(he,[3,4],7);for(let O=0,R=B.length;O<R;O+=7){if(B[O+5]==I.x&&B[O+6]==I.y)continue;const w=I.clone();I.x=B[O+5],I.y=B[O+6],T.x=I.x,T.y=I.y,o(U,B[O],B[O+1],B[O+2],B[O+3],B[O+4],w,I),O===0&&K===!0&&se.copy(I)}break;case"m":B=p(he);for(let O=0,R=B.length;O<R;O+=2)I.x+=B[O+0],I.y+=B[O+1],T.x=I.x,T.y=I.y,O===0?U.moveTo(I.x,I.y):U.lineTo(I.x,I.y),O===0&&se.copy(I);break;case"h":B=p(he);for(let O=0,R=B.length;O<R;O++)I.x+=B[O],T.x=I.x,T.y=I.y,U.lineTo(I.x,I.y),O===0&&K===!0&&se.copy(I);break;case"v":B=p(he);for(let O=0,R=B.length;O<R;O++)I.y+=B[O],T.x=I.x,T.y=I.y,U.lineTo(I.x,I.y),O===0&&K===!0&&se.copy(I);break;case"l":B=p(he);for(let O=0,R=B.length;O<R;O+=2)I.x+=B[O+0],I.y+=B[O+1],T.x=I.x,T.y=I.y,U.lineTo(I.x,I.y),O===0&&K===!0&&se.copy(I);break;case"c":B=p(he);for(let O=0,R=B.length;O<R;O+=6)U.bezierCurveTo(I.x+B[O+0],I.y+B[O+1],I.x+B[O+2],I.y+B[O+3],I.x+B[O+4],I.y+B[O+5]),T.x=I.x+B[O+2],T.y=I.y+B[O+3],I.x+=B[O+4],I.y+=B[O+5],O===0&&K===!0&&se.copy(I);break;case"s":B=p(he);for(let O=0,R=B.length;O<R;O+=4)U.bezierCurveTo(_(I.x,T.x),_(I.y,T.y),I.x+B[O+0],I.y+B[O+1],I.x+B[O+2],I.y+B[O+3]),T.x=I.x+B[O+0],T.y=I.y+B[O+1],I.x+=B[O+2],I.y+=B[O+3],O===0&&K===!0&&se.copy(I);break;case"q":B=p(he);for(let O=0,R=B.length;O<R;O+=4)U.quadraticCurveTo(I.x+B[O+0],I.y+B[O+1],I.x+B[O+2],I.y+B[O+3]),T.x=I.x+B[O+0],T.y=I.y+B[O+1],I.x+=B[O+2],I.y+=B[O+3],O===0&&K===!0&&se.copy(I);break;case"t":B=p(he);for(let O=0,R=B.length;O<R;O+=2){const w=_(I.x,T.x),Q=_(I.y,T.y);U.quadraticCurveTo(w,Q,I.x+B[O+0],I.y+B[O+1]),T.x=w,T.y=Q,I.x=I.x+B[O+0],I.y=I.y+B[O+1],O===0&&K===!0&&se.copy(I)}break;case"a":B=p(he,[3,4],7);for(let O=0,R=B.length;O<R;O+=7){if(B[O+5]==0&&B[O+6]==0)continue;const w=I.clone();I.x+=B[O+5],I.y+=B[O+6],T.x=I.x,T.y=I.y,o(U,B[O],B[O+1],B[O+2],B[O+3],B[O+4],w,I),O===0&&K===!0&&se.copy(I)}break;case"Z":case"z":U.currentPath.autoClose=!0,U.currentPath.curves.length>0&&(I.copy(se),U.currentPath.currentPoint.copy(I),fe=!0);break;default:console.warn(W)}K=!1}return U}function r(F){if(!(!F.sheet||!F.sheet.cssRules||!F.sheet.cssRules.length))for(let U=0;U<F.sheet.cssRules.length;U++){const I=F.sheet.cssRules[U];if(I.type!==1)continue;const T=I.selectorText.split(/,/gm).filter(Boolean).map(se=>se.trim());for(let se=0;se<T.length;se++){const fe=Object.fromEntries(Object.entries(I.style).filter(([,K])=>K!==""));G[T[se]]=Object.assign(G[T[se]]||{},fe)}}}function o(F,U,I,T,se,fe,K,D){if(U==0||I==0){F.lineTo(D.x,D.y);return}T=T*Math.PI/180,U=Math.abs(U),I=Math.abs(I);const q=(K.x-D.x)/2,J=(K.y-D.y)/2,H=Math.cos(T)*q+Math.sin(T)*J,W=-Math.sin(T)*q+Math.cos(T)*J;let ie=U*U,he=I*I;const B=H*H,O=W*W,R=B/ie+O/he;if(R>1){const be=Math.sqrt(R);U=be*U,I=be*I,ie=U*U,he=I*I}const w=ie*O+he*B,Q=(ie*he-w)/w;let me=Math.sqrt(Math.max(0,Q));se===fe&&(me=-me);const de=me*U*W/I,ye=-me*I*H/U,Be=Math.cos(T)*de-Math.sin(T)*ye+(K.x+D.x)/2,Ce=Math.sin(T)*de+Math.cos(T)*ye+(K.y+D.y)/2,Ee=a(1,0,(H-de)/U,(W-ye)/I),Je=a((H-de)/U,(W-ye)/I,(-H-de)/U,(-W-ye)/I)%(Math.PI*2);F.currentPath.absellipse(Be,Ce,U,I,Ee,Ee+Je,fe===0,T)}function a(F,U,I,T){const se=F*I+U*T,fe=Math.sqrt(F*F+U*U)*Math.sqrt(I*I+T*T);let K=Math.acos(Math.max(-1,Math.min(1,se/fe)));return F*T-U*I<0&&(K=-K),K}function l(F){const U=v(F.getAttribute("x")||0),I=v(F.getAttribute("y")||0),T=v(F.getAttribute("rx")||F.getAttribute("ry")||0),se=v(F.getAttribute("ry")||F.getAttribute("rx")||0),fe=v(F.getAttribute("width")),K=v(F.getAttribute("height")),D=1-.551915024494,q=new Ei;return q.moveTo(U+T,I),q.lineTo(U+fe-T,I),(T!==0||se!==0)&&q.bezierCurveTo(U+fe-T*D,I,U+fe,I+se*D,U+fe,I+se),q.lineTo(U+fe,I+K-se),(T!==0||se!==0)&&q.bezierCurveTo(U+fe,I+K-se*D,U+fe-T*D,I+K,U+fe-T,I+K),q.lineTo(U+T,I+K),(T!==0||se!==0)&&q.bezierCurveTo(U+T*D,I+K,U,I+K-se*D,U,I+K-se),q.lineTo(U,I+se),(T!==0||se!==0)&&q.bezierCurveTo(U,I+se*D,U+T*D,I,U+T,I),q}function c(F){function U(fe,K,D){const q=v(K),J=v(D);se===0?T.moveTo(q,J):T.lineTo(q,J),se++}const I=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,T=new Ei;let se=0;return F.getAttribute("points").replace(I,U),T.currentPath.autoClose=!0,T}function u(F){function U(fe,K,D){const q=v(K),J=v(D);se===0?T.moveTo(q,J):T.lineTo(q,J),se++}const I=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,T=new Ei;let se=0;return F.getAttribute("points").replace(I,U),T.currentPath.autoClose=!1,T}function h(F){const U=v(F.getAttribute("cx")||0),I=v(F.getAttribute("cy")||0),T=v(F.getAttribute("r")||0),se=new Ci;se.absarc(U,I,T,0,Math.PI*2);const fe=new Ei;return fe.subPaths.push(se),fe}function d(F){const U=v(F.getAttribute("cx")||0),I=v(F.getAttribute("cy")||0),T=v(F.getAttribute("rx")||0),se=v(F.getAttribute("ry")||0),fe=new Ci;fe.absellipse(U,I,T,se,0,Math.PI*2);const K=new Ei;return K.subPaths.push(fe),K}function f(F){const U=v(F.getAttribute("x1")||0),I=v(F.getAttribute("y1")||0),T=v(F.getAttribute("x2")||0),se=v(F.getAttribute("y2")||0),fe=new Ei;return fe.moveTo(U,I),fe.lineTo(T,se),fe.currentPath.autoClose=!1,fe}function g(F,U){U=Object.assign({},U);let I={};if(F.hasAttribute("class")){const K=F.getAttribute("class").split(/\s/).filter(Boolean).map(D=>D.trim());for(let D=0;D<K.length;D++)I=Object.assign(I,G["."+K[D]])}F.hasAttribute("id")&&(I=Object.assign(I,G["#"+F.getAttribute("id")]));function T(K,D,q){q===void 0&&(q=function(H){return H.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),H}),F.hasAttribute(K)&&(U[D]=q(F.getAttribute(K))),I[K]&&(U[D]=q(I[K])),F.style&&F.style[K]!==""&&(U[D]=q(F.style[K]))}function se(K){return Math.max(0,Math.min(1,v(K)))}function fe(K){return Math.max(0,v(K))}return T("fill","fill"),T("fill-opacity","fillOpacity",se),T("fill-rule","fillRule"),T("opacity","opacity",se),T("stroke","stroke"),T("stroke-opacity","strokeOpacity",se),T("stroke-width","strokeWidth",fe),T("stroke-linejoin","strokeLineJoin"),T("stroke-linecap","strokeLineCap"),T("stroke-miterlimit","strokeMiterLimit",fe),T("visibility","visibility"),U}function _(F,U){return F-(U-F)}function p(F,U,I){if(typeof F!="string")throw new TypeError("Invalid input: "+typeof F);const T={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},se=0,fe=1,K=2,D=3;let q=se,J=!0,H="",W="";const ie=[];function he(w,Q,me){const de=new SyntaxError('Unexpected character "'+w+'" at index '+Q+".");throw de.partial=me,de}function B(){H!==""&&(W===""?ie.push(Number(H)):ie.push(Number(H)*Math.pow(10,Number(W)))),H="",W=""}let O;const R=F.length;for(let w=0;w<R;w++){if(O=F[w],Array.isArray(U)&&U.includes(ie.length%I)&&T.FLAGS.test(O)){q=fe,H=O,B();continue}if(q===se){if(T.WHITESPACE.test(O))continue;if(T.DIGIT.test(O)||T.SIGN.test(O)){q=fe,H=O;continue}if(T.POINT.test(O)){q=K,H=O;continue}T.COMMA.test(O)&&(J&&he(O,w,ie),J=!0)}if(q===fe){if(T.DIGIT.test(O)){H+=O;continue}if(T.POINT.test(O)){H+=O,q=K;continue}if(T.EXP.test(O)){q=D;continue}T.SIGN.test(O)&&H.length===1&&T.SIGN.test(H[0])&&he(O,w,ie)}if(q===K){if(T.DIGIT.test(O)){H+=O;continue}if(T.EXP.test(O)){q=D;continue}T.POINT.test(O)&&H[H.length-1]==="."&&he(O,w,ie)}if(q===D){if(T.DIGIT.test(O)){W+=O;continue}if(T.SIGN.test(O)){if(W===""){W+=O;continue}W.length===1&&T.SIGN.test(W)&&he(O,w,ie)}}T.WHITESPACE.test(O)?(B(),q=se,J=!1):T.COMMA.test(O)?(B(),q=se,J=!0):T.SIGN.test(O)?(B(),q=fe,H=O):T.POINT.test(O)?(B(),q=K,H=O):he(O,w,ie)}return B(),ie}const m=["mm","cm","in","pt","pc","px"],y={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function v(F){let U="px";if(typeof F=="string"||F instanceof String)for(let T=0,se=m.length;T<se;T++){const fe=m[T];if(F.endsWith(fe)){U=fe,F=F.substring(0,F.length-fe.length);break}}let I;return U==="px"&&t.defaultUnit!=="px"?I=y.in[t.defaultUnit]/t.defaultDPI:(I=y[U][t.defaultUnit],I<0&&(I=y[U].in*t.defaultDPI)),I*parseFloat(F)}function x(F){if(!(F.hasAttribute("transform")||F.nodeName==="use"&&(F.hasAttribute("x")||F.hasAttribute("y"))))return null;const U=E(F);return X.length>0&&U.premultiply(X[X.length-1]),Ae.copy(U),X.push(U),U}function E(F){const U=new je,I=ce;if(F.nodeName==="use"&&(F.hasAttribute("x")||F.hasAttribute("y"))){const T=v(F.getAttribute("x")),se=v(F.getAttribute("y"));U.translate(T,se)}if(F.hasAttribute("transform")){const T=F.getAttribute("transform").split(")");for(let se=T.length-1;se>=0;se--){const fe=T[se].trim();if(fe==="")continue;const K=fe.indexOf("("),D=fe.length;if(K>0&&K<D){const q=fe.slice(0,K),J=p(fe.slice(K+1));switch(I.identity(),q){case"translate":if(J.length>=1){const H=J[0];let W=0;J.length>=2&&(W=J[1]),I.translate(H,W)}break;case"rotate":if(J.length>=1){let H=0,W=0,ie=0;H=J[0]*Math.PI/180,J.length>=3&&(W=J[1],ie=J[2]),Z.makeTranslation(-W,-ie),ae.makeRotation(H),z.multiplyMatrices(ae,Z),Z.makeTranslation(W,ie),I.multiplyMatrices(Z,z)}break;case"scale":if(J.length>=1){const H=J[0];let W=H;J.length>=2&&(W=J[1]),I.scale(H,W)}break;case"skewX":J.length===1&&I.set(1,Math.tan(J[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":J.length===1&&I.set(1,0,0,Math.tan(J[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":J.length===6&&I.set(J[0],J[2],J[4],J[1],J[3],J[5],0,0,1);break}}U.premultiply(I)}}return U}function S(F,U){function I(K){we.set(K.x,K.y,1).applyMatrix3(U),K.set(we.x,we.y)}function T(K){const D=K.xRadius,q=K.yRadius,J=Math.cos(K.aRotation),H=Math.sin(K.aRotation),W=new N(D*J,D*H,0),ie=new N(-q*H,q*J,0),he=W.applyMatrix3(U),B=ie.applyMatrix3(U),O=ce.set(he.x,B.x,0,he.y,B.y,0,0,0,1),R=Z.copy(O).invert(),me=ae.copy(R).transpose().multiply(R).elements,de=k(me[0],me[1],me[4]),ye=Math.sqrt(de.rt1),Be=Math.sqrt(de.rt2);if(K.xRadius=1/ye,K.yRadius=1/Be,K.aRotation=Math.atan2(de.sn,de.cs),!((K.aEndAngle-K.aStartAngle)%(2*Math.PI)<Number.EPSILON)){const Ee=Z.set(ye,0,0,0,Be,0,0,0,1),Je=ae.set(de.cs,de.sn,0,-de.sn,de.cs,0,0,0,1),be=Ee.multiply(Je).multiply(O),Ne=rt=>{const{x:Ke,y:Re}=new N(Math.cos(rt),Math.sin(rt),0).applyMatrix3(be);return Math.atan2(Re,Ke)};K.aStartAngle=Ne(K.aStartAngle),K.aEndAngle=Ne(K.aEndAngle),C(U)&&(K.aClockwise=!K.aClockwise)}}function se(K){const D=A(U),q=b(U);K.xRadius*=D,K.yRadius*=q;const J=D>Number.EPSILON?Math.atan2(U.elements[1],U.elements[0]):Math.atan2(-U.elements[3],U.elements[4]);K.aRotation+=J,C(U)&&(K.aStartAngle*=-1,K.aEndAngle*=-1,K.aClockwise=!K.aClockwise)}const fe=F.subPaths;for(let K=0,D=fe.length;K<D;K++){const J=fe[K].curves;for(let H=0;H<J.length;H++){const W=J[H];W.isLineCurve?(I(W.v1),I(W.v2)):W.isCubicBezierCurve?(I(W.v0),I(W.v1),I(W.v2),I(W.v3)):W.isQuadraticBezierCurve?(I(W.v0),I(W.v1),I(W.v2)):W.isEllipseCurve&&(Se.set(W.aX,W.aY),I(Se),W.aX=Se.x,W.aY=Se.y,L(U)?T(W):se(W))}}}function C(F){const U=F.elements;return U[0]*U[4]-U[1]*U[3]<0}function L(F){const U=F.elements,I=U[0]*U[3]+U[1]*U[4];if(I===0)return!1;const T=A(F),se=b(F);return Math.abs(I/(T*se))>Number.EPSILON}function A(F){const U=F.elements;return Math.sqrt(U[0]*U[0]+U[1]*U[1])}function b(F){const U=F.elements;return Math.sqrt(U[3]*U[3]+U[4]*U[4])}function k(F,U,I){let T,se,fe,K,D;const q=F+I,J=F-I,H=Math.sqrt(J*J+4*U*U);return q>0?(T=.5*(q+H),D=1/T,se=F*D*I-U*D*U):q<0?se=.5*(q-H):(T=.5*H,se=-.5*H),J>0?fe=J+H:fe=J-H,Math.abs(fe)>2*Math.abs(U)?(D=-2*U/fe,K=1/Math.sqrt(1+D*D),fe=D*K):Math.abs(U)===0?(fe=1,K=0):(D=-.5*fe/U,fe=1/Math.sqrt(1+D*D),K=D*fe),J>0&&(D=fe,fe=-K,K=D),{rt1:T,rt2:se,cs:fe,sn:K}}const V=[],G={},X=[],ce=new je,Z=new je,ae=new je,z=new je,Se=new te,we=new N,Ae=new je,_e=new DOMParser().parseFromString(e,"image/svg+xml");return n(_e.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:V,xml:_e.documentElement}}static createShapes(e){const n={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},i={loc:n.ORIGIN,t:0};function r(_,p,m,y){const v=_.x,x=p.x,E=m.x,S=y.x,C=_.y,L=p.y,A=m.y,b=y.y,k=(S-E)*(C-A)-(b-A)*(v-E),V=(x-v)*(C-A)-(L-C)*(v-E),G=(b-A)*(x-v)-(S-E)*(L-C),X=k/G,ce=V/G;if(G===0&&k!==0||X<=0||X>=1||ce<0||ce>1)return null;if(k===0&&G===0){for(let Z=0;Z<2;Z++)if(o(Z===0?m:y,_,p),i.loc==n.ORIGIN){const ae=Z===0?m:y;return{x:ae.x,y:ae.y,t:i.t}}else if(i.loc==n.BETWEEN){const ae=+(v+i.t*(x-v)).toPrecision(10),z=+(C+i.t*(L-C)).toPrecision(10);return{x:ae,y:z,t:i.t}}return null}else{for(let z=0;z<2;z++)if(o(z===0?m:y,_,p),i.loc==n.ORIGIN){const Se=z===0?m:y;return{x:Se.x,y:Se.y,t:i.t}}const Z=+(v+X*(x-v)).toPrecision(10),ae=+(C+X*(L-C)).toPrecision(10);return{x:Z,y:ae,t:X}}}function o(_,p,m){const y=m.x-p.x,v=m.y-p.y,x=_.x-p.x,E=_.y-p.y,S=y*E-x*v;if(_.x===p.x&&_.y===p.y){i.loc=n.ORIGIN,i.t=0;return}if(_.x===m.x&&_.y===m.y){i.loc=n.DESTINATION,i.t=1;return}if(S<-Number.EPSILON){i.loc=n.LEFT;return}if(S>Number.EPSILON){i.loc=n.RIGHT;return}if(y*x<0||v*E<0){i.loc=n.BEHIND;return}if(Math.sqrt(y*y+v*v)<Math.sqrt(x*x+E*E)){i.loc=n.BEYOND;return}let C;y!==0?C=x/y:C=E/v,i.loc=n.BETWEEN,i.t=C}function a(_,p){const m=[],y=[];for(let v=1;v<_.length;v++){const x=_[v-1],E=_[v];for(let S=1;S<p.length;S++){const C=p[S-1],L=p[S],A=r(x,E,C,L);A!==null&&m.find(b=>b.t<=A.t+Number.EPSILON&&b.t>=A.t-Number.EPSILON)===void 0&&(m.push(A),y.push(new te(A.x,A.y)))}}return y}function l(_,p,m){const y=new te;p.getCenter(y);const v=[];return m.forEach(x=>{x.boundingBox.containsPoint(y)&&a(_,x.points).forEach(S=>{v.push({identifier:x.identifier,isCW:x.isCW,point:S})})}),v.sort((x,E)=>x.point.x-E.point.x),v}function c(_,p,m,y,v){(v==null||v==="")&&(v="nonzero");const x=new te;_.boundingBox.getCenter(x);const E=[new te(m,x.y),new te(y,x.y)],S=l(E,_.boundingBox,p);S.sort((V,G)=>V.point.x-G.point.x);const C=[],L=[];S.forEach(V=>{V.identifier===_.identifier?C.push(V):L.push(V)});const A=C[0].point.x,b=[];let k=0;for(;k<L.length&&L[k].point.x<A;)b.length>0&&b[b.length-1]===L[k].identifier?b.pop():b.push(L[k].identifier),k++;if(b.push(_.identifier),v==="evenodd"){const V=b.length%2===0,G=b[b.length-2];return{identifier:_.identifier,isHole:V,for:G}}else if(v==="nonzero"){let V=!0,G=null,X=null;for(let ce=0;ce<b.length;ce++){const Z=b[ce];V?(X=p[Z].isCW,V=!1,G=Z):X!==p[Z].isCW&&(X=p[Z].isCW,V=!0)}return{identifier:_.identifier,isHole:V,for:G}}else console.warn('fill-rule: "'+v+'" is currently not implemented.')}let u=999999999,h=-999999999,d=e.subPaths.map(_=>{const p=_.getPoints();let m=-999999999,y=999999999,v=-999999999,x=999999999;for(let E=0;E<p.length;E++){const S=p[E];S.y>m&&(m=S.y),S.y<y&&(y=S.y),S.x>v&&(v=S.x),S.x<x&&(x=S.x)}return h<=v&&(h=v+1),u>=x&&(u=x-1),{curves:_.curves,points:p,isCW:Nn.isClockWise(p),identifier:-1,boundingBox:new Nm(new te(x,y),new te(v,m))}});d=d.filter(_=>_.points.length>1);for(let _=0;_<d.length;_++)d[_].identifier=_;const f=d.map(_=>c(_,d,u,h,e.userData?e.userData.style.fillRule:void 0)),g=[];return d.forEach(_=>{if(!f[_.identifier].isHole){const m=new Pi;m.curves=_.curves,f.filter(v=>v.isHole&&v.for===_.identifier).forEach(v=>{const x=d[v.identifier],E=new Ci;E.curves=x.curves,m.holes.push(E)}),g.push(m)}}),g}static getStrokeStyle(e,t,n,i,r){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",n=n!==void 0?n:"miter",i=i!==void 0?i:"butt",r=r!==void 0?r:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:i,strokeMiterLimit:r}}static pointsToStroke(e,t,n,i){const r=[],o=[],a=[];if(Ia.pointsToStrokeWithBuffers(e,t,n,i,r,o,a)===0)return null;const l=new at;return l.setAttribute("position",new Oe(r,3)),l.setAttribute("normal",new Oe(o,3)),l.setAttribute("uv",new Oe(a,2)),l}static pointsToStrokeWithBuffers(e,t,n,i,r,o,a,l){const c=new te,u=new te,h=new te,d=new te,f=new te,g=new te,_=new te,p=new te,m=new te,y=new te,v=new te,x=new te,E=new te,S=new te,C=new te,L=new te,A=new te;n=n!==void 0?n:12,i=i!==void 0?i:.001,l=l!==void 0?l:0,e=J(e);const b=e.length;if(b<2)return 0;const k=e[0].equals(e[b-1]);let V,G=e[0],X;const ce=t.strokeWidth/2,Z=1/(b-1);let ae=0,z,Se,we,Ae,_e=!1,De=0,F=l*3,U=l*2;I(e[0],e[1],c).multiplyScalar(ce),p.copy(e[0]).sub(c),m.copy(e[0]).add(c),y.copy(p),v.copy(m);for(let H=1;H<b;H++){V=e[H],H===b-1?k?X=e[1]:X=void 0:X=e[H+1];const W=c;if(I(G,V,W),h.copy(W).multiplyScalar(ce),x.copy(V).sub(h),E.copy(V).add(h),z=ae+Z,Se=!1,X!==void 0){I(V,X,u),h.copy(u).multiplyScalar(ce),S.copy(V).sub(h),C.copy(V).add(h),we=!0,h.subVectors(X,G),W.dot(h)<0&&(we=!1),H===1&&(_e=we),h.subVectors(X,V),h.normalize();const ie=Math.abs(W.dot(h));if(ie>Number.EPSILON){const he=ce/ie;h.multiplyScalar(-he),d.subVectors(V,G),f.copy(d).setLength(he).add(h),L.copy(f).negate();const B=f.length(),O=d.length();d.divideScalar(O),g.subVectors(X,V);const R=g.length();switch(g.divideScalar(R),d.dot(L)<O&&g.dot(L)<R&&(Se=!0),A.copy(f).add(V),L.add(V),Ae=!1,Se?we?(C.copy(L),E.copy(L)):(S.copy(L),x.copy(L)):fe(),t.strokeLineJoin){case"bevel":K(we,Se,z);break;case"round":D(we,Se),we?se(V,x,S,z,0):se(V,C,E,z,1);break;case"miter":case"miter-clip":default:const w=ce*t.strokeMiterLimit/B;if(w<1)if(t.strokeLineJoin!=="miter-clip"){K(we,Se,z);break}else D(we,Se),we?(g.subVectors(A,x).multiplyScalar(w).add(x),_.subVectors(A,S).multiplyScalar(w).add(S),T(x,z,0),T(g,z,0),T(V,z,.5),T(V,z,.5),T(g,z,0),T(_,z,0),T(V,z,.5),T(_,z,0),T(S,z,0)):(g.subVectors(A,E).multiplyScalar(w).add(E),_.subVectors(A,C).multiplyScalar(w).add(C),T(E,z,1),T(g,z,1),T(V,z,.5),T(V,z,.5),T(g,z,1),T(_,z,1),T(V,z,.5),T(_,z,1),T(C,z,1));else Se?(we?(T(m,ae,1),T(p,ae,0),T(A,z,0),T(m,ae,1),T(A,z,0),T(L,z,1)):(T(m,ae,1),T(p,ae,0),T(A,z,1),T(p,ae,0),T(L,z,0),T(A,z,1)),we?S.copy(A):C.copy(A)):we?(T(x,z,0),T(A,z,0),T(V,z,.5),T(V,z,.5),T(A,z,0),T(S,z,0)):(T(E,z,1),T(A,z,1),T(V,z,.5),T(V,z,.5),T(A,z,1),T(C,z,1)),Ae=!0;break}}else fe()}else fe();!k&&H===b-1&&q(e[0],y,v,we,!0,ae),ae=z,G=V,p.copy(S),m.copy(C)}if(!k)q(V,x,E,we,!1,z);else if(Se&&r){let H=A,W=L;_e!==we&&(H=L,W=A),we?(Ae||_e)&&(W.toArray(r,0*3),W.toArray(r,3*3),Ae&&H.toArray(r,1*3)):(Ae||!_e)&&(W.toArray(r,1*3),W.toArray(r,3*3),Ae&&H.toArray(r,0*3))}return De;function I(H,W,ie){return ie.subVectors(W,H),ie.set(-ie.y,ie.x).normalize()}function T(H,W,ie){r&&(r[F]=H.x,r[F+1]=H.y,r[F+2]=0,o&&(o[F]=0,o[F+1]=0,o[F+2]=1),F+=3,a&&(a[U]=W,a[U+1]=ie,U+=2)),De+=3}function se(H,W,ie,he,B){c.copy(W).sub(H).normalize(),u.copy(ie).sub(H).normalize();let O=Math.PI;const R=c.dot(u);Math.abs(R)<1&&(O=Math.abs(Math.acos(R))),O/=n,h.copy(W);for(let w=0,Q=n-1;w<Q;w++)d.copy(h).rotateAround(H,O),T(h,he,B),T(d,he,B),T(H,he,.5),h.copy(d);T(d,he,B),T(ie,he,B),T(H,he,.5)}function fe(){T(m,ae,1),T(p,ae,0),T(x,z,0),T(m,ae,1),T(x,z,0),T(E,z,1)}function K(H,W,ie){W?H?(T(m,ae,1),T(p,ae,0),T(x,z,0),T(m,ae,1),T(x,z,0),T(L,z,1),T(x,ie,0),T(S,ie,0),T(L,ie,.5)):(T(m,ae,1),T(p,ae,0),T(E,z,1),T(p,ae,0),T(L,z,0),T(E,z,1),T(E,ie,1),T(L,ie,0),T(C,ie,1)):H?(T(x,ie,0),T(S,ie,0),T(V,ie,.5)):(T(E,ie,1),T(C,ie,0),T(V,ie,.5))}function D(H,W){W&&(H?(T(m,ae,1),T(p,ae,0),T(x,z,0),T(m,ae,1),T(x,z,0),T(L,z,1),T(x,ae,0),T(V,z,.5),T(L,z,1),T(V,z,.5),T(S,ae,0),T(L,z,1)):(T(m,ae,1),T(p,ae,0),T(E,z,1),T(p,ae,0),T(L,z,0),T(E,z,1),T(E,ae,1),T(L,z,0),T(V,z,.5),T(V,z,.5),T(L,z,0),T(C,ae,1)))}function q(H,W,ie,he,B,O){switch(t.strokeLineCap){case"round":B?se(H,ie,W,O,.5):se(H,W,ie,O,.5);break;case"square":if(B)c.subVectors(W,H),u.set(c.y,-c.x),h.addVectors(c,u).add(H),d.subVectors(u,c).add(H),he?(h.toArray(r,1*3),d.toArray(r,0*3),d.toArray(r,3*3)):(h.toArray(r,1*3),a[3*2+1]===1?d.toArray(r,3*3):h.toArray(r,3*3),d.toArray(r,0*3));else{c.subVectors(ie,H),u.set(c.y,-c.x),h.addVectors(c,u).add(H),d.subVectors(u,c).add(H);const R=r.length;he?(h.toArray(r,R-1*3),d.toArray(r,R-2*3),d.toArray(r,R-4*3)):(d.toArray(r,R-2*3),h.toArray(r,R-1*3),d.toArray(r,R-4*3))}break}}function J(H){let W=!1;for(let he=1,B=H.length-1;he<B;he++)if(H[he].distanceTo(H[he+1])<i){W=!0;break}if(!W)return H;const ie=[];ie.push(H[0]);for(let he=1,B=H.length-1;he<B;he++)H[he].distanceTo(H[he+1])>=i&&ie.push(H[he]);return ie.push(H[H.length-1]),ie}}}const Jd={type:"change"},ic={type:"start"},jd={type:"end"},la=new ms,Qd=new ii,eP=Math.cos(70*Su.DEG2RAD);let tP=class extends Yn{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new N,this.cursor=new N,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Ji.ROTATE,MIDDLE:Ji.DOLLY,RIGHT:Ji.PAN},this.touches={ONE:ji.ROTATE,TWO:ji.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return a.phi},this.getAzimuthalAngle=function(){return a.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(M){M.addEventListener("keydown",Ee),this._domElementKeyEvents=M},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ee),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(Jd),n.update(),r=i.NONE},this.update=function(){const M=new N,le=new Jt().setFromUnitVectors(e.up,new N(0,1,0)),ne=le.clone().invert(),ue=new N,Me=new Jt,We=new N,tt=2*Math.PI;return function(Dt=null){const ht=n.object.position;M.copy(ht).sub(n.target),M.applyQuaternion(le),a.setFromVector3(M),n.autoRotate&&r===i.NONE&&V(b(Dt)),n.enableDamping?(a.theta+=l.theta*n.dampingFactor,a.phi+=l.phi*n.dampingFactor):(a.theta+=l.theta,a.phi+=l.phi);let Ut=n.minAzimuthAngle,Ot=n.maxAzimuthAngle;isFinite(Ut)&&isFinite(Ot)&&(Ut<-Math.PI?Ut+=tt:Ut>Math.PI&&(Ut-=tt),Ot<-Math.PI?Ot+=tt:Ot>Math.PI&&(Ot-=tt),Ut<=Ot?a.theta=Math.max(Ut,Math.min(Ot,a.theta)):a.theta=a.theta>(Ut+Ot)/2?Math.max(Ut,a.theta):Math.min(Ot,a.theta)),a.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,a.phi)),a.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(u,n.dampingFactor):n.target.add(u),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor);let pn=!1;if(n.zoomToCursor&&S||n.object.isOrthographicCamera)a.radius=we(a.radius);else{const mn=a.radius;a.radius=we(a.radius*c),pn=mn!=a.radius}if(M.setFromSpherical(a),M.applyQuaternion(ne),ht.copy(n.target).add(M),n.object.lookAt(n.target),n.enableDamping===!0?(l.theta*=1-n.dampingFactor,l.phi*=1-n.dampingFactor,u.multiplyScalar(1-n.dampingFactor)):(l.set(0,0,0),u.set(0,0,0)),n.zoomToCursor&&S){let mn=null;if(n.object.isPerspectiveCamera){const gi=M.length();mn=we(gi*c);const Oi=gi-mn;n.object.position.addScaledVector(x,Oi),n.object.updateMatrixWorld(),pn=!!Oi}else if(n.object.isOrthographicCamera){const gi=new N(E.x,E.y,0);gi.unproject(n.object);const Oi=n.object.zoom;n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/c)),n.object.updateProjectionMatrix(),pn=Oi!==n.object.zoom;const Fi=new N(E.x,E.y,0);Fi.unproject(n.object),n.object.position.sub(Fi).add(gi),n.object.updateMatrixWorld(),mn=M.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;mn!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(mn).add(n.object.position):(la.origin.copy(n.object.position),la.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(la.direction))<eP?e.lookAt(n.target):(Qd.setFromNormalAndCoplanarPoint(n.object.up,n.target),la.intersectPlane(Qd,n.target))))}else if(n.object.isOrthographicCamera){const mn=n.object.zoom;n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/c)),mn!==n.object.zoom&&(n.object.updateProjectionMatrix(),pn=!0)}return c=1,S=!1,pn||ue.distanceToSquared(n.object.position)>o||8*(1-Me.dot(n.object.quaternion))>o||We.distanceToSquared(n.target)>o?(n.dispatchEvent(Jd),ue.copy(n.object.position),Me.copy(n.object.quaternion),We.copy(n.target),!0):!1}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",Ne),n.domElement.removeEventListener("pointerdown",O),n.domElement.removeEventListener("pointercancel",w),n.domElement.removeEventListener("wheel",de),n.domElement.removeEventListener("pointermove",R),n.domElement.removeEventListener("pointerup",w),n.domElement.getRootNode().removeEventListener("keydown",Be,{capture:!0}),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener("keydown",Ee),n._domElementKeyEvents=null)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let r=i.NONE;const o=1e-6,a=new Zc,l=new Zc;let c=1;const u=new N,h=new te,d=new te,f=new te,g=new te,_=new te,p=new te,m=new te,y=new te,v=new te,x=new N,E=new te;let S=!1;const C=[],L={};let A=!1;function b(M){return M!==null?2*Math.PI/60*n.autoRotateSpeed*M:2*Math.PI/60/60*n.autoRotateSpeed}function k(M){const le=Math.abs(M*.01);return Math.pow(.95,n.zoomSpeed*le)}function V(M){l.theta-=M}function G(M){l.phi-=M}const X=function(){const M=new N;return function(ne,ue){M.setFromMatrixColumn(ue,0),M.multiplyScalar(-ne),u.add(M)}}(),ce=function(){const M=new N;return function(ne,ue){n.screenSpacePanning===!0?M.setFromMatrixColumn(ue,1):(M.setFromMatrixColumn(ue,0),M.crossVectors(n.object.up,M)),M.multiplyScalar(ne),u.add(M)}}(),Z=function(){const M=new N;return function(ne,ue){const Me=n.domElement;if(n.object.isPerspectiveCamera){const We=n.object.position;M.copy(We).sub(n.target);let tt=M.length();tt*=Math.tan(n.object.fov/2*Math.PI/180),X(2*ne*tt/Me.clientHeight,n.object.matrix),ce(2*ue*tt/Me.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(X(ne*(n.object.right-n.object.left)/n.object.zoom/Me.clientWidth,n.object.matrix),ce(ue*(n.object.top-n.object.bottom)/n.object.zoom/Me.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function ae(M){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c/=M:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function z(M){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c*=M:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function Se(M,le){if(!n.zoomToCursor)return;S=!0;const ne=n.domElement.getBoundingClientRect(),ue=M-ne.left,Me=le-ne.top,We=ne.width,tt=ne.height;E.x=ue/We*2-1,E.y=-(Me/tt)*2+1,x.set(E.x,E.y,1).unproject(n.object).sub(n.object.position).normalize()}function we(M){return Math.max(n.minDistance,Math.min(n.maxDistance,M))}function Ae(M){h.set(M.clientX,M.clientY)}function _e(M){Se(M.clientX,M.clientX),m.set(M.clientX,M.clientY)}function De(M){g.set(M.clientX,M.clientY)}function F(M){d.set(M.clientX,M.clientY),f.subVectors(d,h).multiplyScalar(n.rotateSpeed);const le=n.domElement;V(2*Math.PI*f.x/le.clientHeight),G(2*Math.PI*f.y/le.clientHeight),h.copy(d),n.update()}function U(M){y.set(M.clientX,M.clientY),v.subVectors(y,m),v.y>0?ae(k(v.y)):v.y<0&&z(k(v.y)),m.copy(y),n.update()}function I(M){_.set(M.clientX,M.clientY),p.subVectors(_,g).multiplyScalar(n.panSpeed),Z(p.x,p.y),g.copy(_),n.update()}function T(M){Se(M.clientX,M.clientY),M.deltaY<0?z(k(M.deltaY)):M.deltaY>0&&ae(k(M.deltaY)),n.update()}function se(M){let le=!1;switch(M.code){case n.keys.UP:M.ctrlKey||M.metaKey||M.shiftKey?G(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):Z(0,n.keyPanSpeed),le=!0;break;case n.keys.BOTTOM:M.ctrlKey||M.metaKey||M.shiftKey?G(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):Z(0,-n.keyPanSpeed),le=!0;break;case n.keys.LEFT:M.ctrlKey||M.metaKey||M.shiftKey?V(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):Z(n.keyPanSpeed,0),le=!0;break;case n.keys.RIGHT:M.ctrlKey||M.metaKey||M.shiftKey?V(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):Z(-n.keyPanSpeed,0),le=!0;break}le&&(M.preventDefault(),n.update())}function fe(M){if(C.length===1)h.set(M.pageX,M.pageY);else{const le=it(M),ne=.5*(M.pageX+le.x),ue=.5*(M.pageY+le.y);h.set(ne,ue)}}function K(M){if(C.length===1)g.set(M.pageX,M.pageY);else{const le=it(M),ne=.5*(M.pageX+le.x),ue=.5*(M.pageY+le.y);g.set(ne,ue)}}function D(M){const le=it(M),ne=M.pageX-le.x,ue=M.pageY-le.y,Me=Math.sqrt(ne*ne+ue*ue);m.set(0,Me)}function q(M){n.enableZoom&&D(M),n.enablePan&&K(M)}function J(M){n.enableZoom&&D(M),n.enableRotate&&fe(M)}function H(M){if(C.length==1)d.set(M.pageX,M.pageY);else{const ne=it(M),ue=.5*(M.pageX+ne.x),Me=.5*(M.pageY+ne.y);d.set(ue,Me)}f.subVectors(d,h).multiplyScalar(n.rotateSpeed);const le=n.domElement;V(2*Math.PI*f.x/le.clientHeight),G(2*Math.PI*f.y/le.clientHeight),h.copy(d)}function W(M){if(C.length===1)_.set(M.pageX,M.pageY);else{const le=it(M),ne=.5*(M.pageX+le.x),ue=.5*(M.pageY+le.y);_.set(ne,ue)}p.subVectors(_,g).multiplyScalar(n.panSpeed),Z(p.x,p.y),g.copy(_)}function ie(M){const le=it(M),ne=M.pageX-le.x,ue=M.pageY-le.y,Me=Math.sqrt(ne*ne+ue*ue);y.set(0,Me),v.set(0,Math.pow(y.y/m.y,n.zoomSpeed)),ae(v.y),m.copy(y);const We=(M.pageX+le.x)*.5,tt=(M.pageY+le.y)*.5;Se(We,tt)}function he(M){n.enableZoom&&ie(M),n.enablePan&&W(M)}function B(M){n.enableZoom&&ie(M),n.enableRotate&&H(M)}function O(M){n.enabled!==!1&&(C.length===0&&(n.domElement.setPointerCapture(M.pointerId),n.domElement.addEventListener("pointermove",R),n.domElement.addEventListener("pointerup",w)),!Re(M)&&(rt(M),M.pointerType==="touch"?Je(M):Q(M)))}function R(M){n.enabled!==!1&&(M.pointerType==="touch"?be(M):me(M))}function w(M){switch(Ke(M),C.length){case 0:n.domElement.releasePointerCapture(M.pointerId),n.domElement.removeEventListener("pointermove",R),n.domElement.removeEventListener("pointerup",w),n.dispatchEvent(jd),r=i.NONE;break;case 1:const le=C[0],ne=L[le];Je({pointerId:le,pageX:ne.x,pageY:ne.y});break}}function Q(M){let le;switch(M.button){case 0:le=n.mouseButtons.LEFT;break;case 1:le=n.mouseButtons.MIDDLE;break;case 2:le=n.mouseButtons.RIGHT;break;default:le=-1}switch(le){case Ji.DOLLY:if(n.enableZoom===!1)return;_e(M),r=i.DOLLY;break;case Ji.ROTATE:if(M.ctrlKey||M.metaKey||M.shiftKey){if(n.enablePan===!1)return;De(M),r=i.PAN}else{if(n.enableRotate===!1)return;Ae(M),r=i.ROTATE}break;case Ji.PAN:if(M.ctrlKey||M.metaKey||M.shiftKey){if(n.enableRotate===!1)return;Ae(M),r=i.ROTATE}else{if(n.enablePan===!1)return;De(M),r=i.PAN}break;default:r=i.NONE}r!==i.NONE&&n.dispatchEvent(ic)}function me(M){switch(r){case i.ROTATE:if(n.enableRotate===!1)return;F(M);break;case i.DOLLY:if(n.enableZoom===!1)return;U(M);break;case i.PAN:if(n.enablePan===!1)return;I(M);break}}function de(M){n.enabled===!1||n.enableZoom===!1||r!==i.NONE||(M.preventDefault(),n.dispatchEvent(ic),T(ye(M)),n.dispatchEvent(jd))}function ye(M){const le=M.deltaMode,ne={clientX:M.clientX,clientY:M.clientY,deltaY:M.deltaY};switch(le){case 1:ne.deltaY*=16;break;case 2:ne.deltaY*=100;break}return M.ctrlKey&&!A&&(ne.deltaY*=10),ne}function Be(M){M.key==="Control"&&(A=!0,n.domElement.getRootNode().addEventListener("keyup",Ce,{passive:!0,capture:!0}))}function Ce(M){M.key==="Control"&&(A=!1,n.domElement.getRootNode().removeEventListener("keyup",Ce,{passive:!0,capture:!0}))}function Ee(M){n.enabled===!1||n.enablePan===!1||se(M)}function Je(M){switch(nt(M),C.length){case 1:switch(n.touches.ONE){case ji.ROTATE:if(n.enableRotate===!1)return;fe(M),r=i.TOUCH_ROTATE;break;case ji.PAN:if(n.enablePan===!1)return;K(M),r=i.TOUCH_PAN;break;default:r=i.NONE}break;case 2:switch(n.touches.TWO){case ji.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;q(M),r=i.TOUCH_DOLLY_PAN;break;case ji.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;J(M),r=i.TOUCH_DOLLY_ROTATE;break;default:r=i.NONE}break;default:r=i.NONE}r!==i.NONE&&n.dispatchEvent(ic)}function be(M){switch(nt(M),r){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;H(M),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;W(M),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;he(M),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;B(M),n.update();break;default:r=i.NONE}}function Ne(M){n.enabled!==!1&&M.preventDefault()}function rt(M){C.push(M.pointerId)}function Ke(M){delete L[M.pointerId];for(let le=0;le<C.length;le++)if(C[le]==M.pointerId){C.splice(le,1);return}}function Re(M){for(let le=0;le<C.length;le++)if(C[le]==M.pointerId)return!0;return!1}function nt(M){let le=L[M.pointerId];le===void 0&&(le=new te,L[M.pointerId]=le),le.set(M.pageX,M.pageY)}function it(M){const le=M.pointerId===C[0]?C[1]:C[0];return L[le]}n.domElement.addEventListener("contextmenu",Ne),n.domElement.addEventListener("pointerdown",O),n.domElement.addEventListener("pointercancel",w),n.domElement.addEventListener("wheel",de,{passive:!1}),n.domElement.getRootNode().addEventListener("keydown",Be,{passive:!0,capture:!0}),this.update()}};const nP=ke({__name:"OrbitControls",setup(s){Ra({OrbitControls:tP});const{camera:e,renderer:t}=OC();return(n,i)=>{var o;const r=rn("TresOrbitControls");return ee(t)?(Y(),Xe(r,{key:0,args:[ee(e),(o=ee(t))==null?void 0:o.domElement]},null,8,["args"])):Fe("",!0)}}}),iP=qe(nP,[["__scopeId","data-v-50048212"]]),sP=`//
|
|
// Description : Array and textureless GLSL 2D/3D/4D simplex
|
|
// noise functions.
|
|
// Author : Ian McEwan, Ashima Arts.
|
|
// Maintainer : stegu
|
|
// Lastmod : 20201014 (stegu)
|
|
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
|
|
// Distributed under the MIT License. See LICENSE file.
|
|
// https://github.com/ashima/webgl-noise
|
|
// https://github.com/stegu/webgl-noise
|
|
//
|
|
|
|
vec3 mod289(vec3 x) {
|
|
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
|
}
|
|
|
|
vec4 mod289(vec4 x) {
|
|
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
|
}
|
|
|
|
vec4 permute(vec4 x) {
|
|
return mod289(((x*34.0)+10.0)*x);
|
|
}
|
|
|
|
vec4 taylorInvSqrt(vec4 r)
|
|
{
|
|
return 1.79284291400159 - 0.85373472095314 * r;
|
|
}
|
|
|
|
float snoise(vec3 v)
|
|
{
|
|
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
|
|
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
|
|
|
|
// First corner
|
|
vec3 i = floor(v + dot(v, C.yyy) );
|
|
vec3 x0 = v - i + dot(i, C.xxx) ;
|
|
|
|
// Other corners
|
|
vec3 g = step(x0.yzx, x0.xyz);
|
|
vec3 l = 1.0 - g;
|
|
vec3 i1 = min( g.xyz, l.zxy );
|
|
vec3 i2 = max( g.xyz, l.zxy );
|
|
|
|
// x0 = x0 - 0.0 + 0.0 * C.xxx;
|
|
// x1 = x0 - i1 + 1.0 * C.xxx;
|
|
// x2 = x0 - i2 + 2.0 * C.xxx;
|
|
// x3 = x0 - 1.0 + 3.0 * C.xxx;
|
|
vec3 x1 = x0 - i1 + C.xxx;
|
|
vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
|
|
vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y
|
|
|
|
// Permutations
|
|
i = mod289(i);
|
|
vec4 p = permute( permute( permute(
|
|
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
|
|
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
|
|
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
|
|
|
|
// Gradients: 7x7 points over a square, mapped onto an octahedron.
|
|
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
|
|
float n_ = 0.142857142857; // 1.0/7.0
|
|
vec3 ns = n_ * D.wyz - D.xzx;
|
|
|
|
vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)
|
|
|
|
vec4 x_ = floor(j * ns.z);
|
|
vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
|
|
|
|
vec4 x = x_ *ns.x + ns.yyyy;
|
|
vec4 y = y_ *ns.x + ns.yyyy;
|
|
vec4 h = 1.0 - abs(x) - abs(y);
|
|
|
|
vec4 b0 = vec4( x.xy, y.xy );
|
|
vec4 b1 = vec4( x.zw, y.zw );
|
|
|
|
//vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
|
|
//vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
|
|
vec4 s0 = floor(b0)*2.0 + 1.0;
|
|
vec4 s1 = floor(b1)*2.0 + 1.0;
|
|
vec4 sh = -step(h, vec4(0.0));
|
|
|
|
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
|
|
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
|
|
|
|
vec3 p0 = vec3(a0.xy,h.x);
|
|
vec3 p1 = vec3(a0.zw,h.y);
|
|
vec3 p2 = vec3(a1.xy,h.z);
|
|
vec3 p3 = vec3(a1.zw,h.w);
|
|
|
|
//Normalise gradients
|
|
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
|
|
p0 *= norm.x;
|
|
p1 *= norm.y;
|
|
p2 *= norm.z;
|
|
p3 *= norm.w;
|
|
|
|
// Mix final noise value
|
|
vec4 m = max(0.5 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
|
|
m = m * m;
|
|
return 105.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
|
|
dot(p2,x2), dot(p3,x3) ) );
|
|
}
|
|
|
|
// demo code:
|
|
// float color(vec2 xy) { return 0.7 * snoise(vec3(xy, 0.3*iTime)); }
|
|
// void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
// vec2 p = (fragCoord.xy/iResolution.y) * 2.0 - 1.0;
|
|
|
|
// vec3 xyz = vec3(p, 0);
|
|
|
|
// vec2 step = vec2(1.3, 1.7);
|
|
// float n = color(xyz.xy);
|
|
// n += 0.5 * color(xyz.xy * 2.0 - step);
|
|
// n += 0.25 * color(xyz.xy * 4.0 - 2.0 * step);
|
|
// n += 0.125 * color(xyz.xy * 8.0 - 3.0 * step);
|
|
// n += 0.0625 * color(xyz.xy * 16.0 - 4.0 * step);
|
|
// n += 0.03125 * color(xyz.xy * 32.0 - 5.0 * step);
|
|
|
|
// fragColor.xyz = vec3(0.5 + 0.5 * vec3(n, n, n));
|
|
|
|
// }
|
|
`,rP={class:"background"},oP=`
|
|
varying vec2 vUv;
|
|
|
|
void main() {
|
|
vec4 modelPosition = modelMatrix * vec4(position, 1.0);
|
|
vec4 viewPosition = viewMatrix * modelPosition;
|
|
gl_Position = projectionMatrix * viewPosition;
|
|
vUv = uv;
|
|
}
|
|
`,aP=ke({__name:"Background",async setup(s){let e,t;const n=Ve(),{paths:i}=([e,t]=dg(()=>RC(Ia,"/circuit-board.svg")),e=await e,t(),e),r=i.map(y=>Ia.createShapes(y)).reduce((y,v)=>[...y,...v]),o=Ve(window.innerWidth),a=Ve(window.innerHeight),l=He(()=>Math.ceil(a.value/304)),c=He(()=>Math.ceil(o.value/304));function u(){o.value=window.innerWidth,a.value=window.innerHeight}wt([o,a,n],([y,v,x])=>{x&&(x.left=0,x.bottom=0,x.right=y,x.top=v,x.updateProjectionMatrix())});const h=Ve(new te(1/0,1/0));function d(y){h.value=new te(y.screenX,window.screen.availHeight-y.screenY),g.value&&g.value.children.forEach(v=>{v.material.uniforms.uMouse.value=h.value})}function f(y){y.relatedTarget||(h.value=new te(1/0,1/0),g.value&&g.value.children.forEach(v=>{v.material.uniforms.uMouse.value=h.value}))}Fn(()=>{window.addEventListener("resize",u),window.addEventListener("mousemove",d),window.addEventListener("mouseout",f)}),$n(()=>{window.removeEventListener("resize",u),window.removeEventListener("mousemove",d),window.removeEventListener("mouseout",f)});const g=Dn(null),_={uTime:{value:0},uMouse:{value:new te(1/0,1/0)}},p=sP+`
|
|
precision mediump float;
|
|
uniform float uTime;
|
|
uniform vec2 uMouse;
|
|
varying vec2 vUv;
|
|
|
|
void main() {
|
|
float dist = distance(gl_FragCoord.xy, uMouse);
|
|
float alpha = max(0., 1. - dist / 304.);
|
|
alpha += max(0., snoise(vec3(gl_FragCoord.xy / 304., uTime / 4.)));
|
|
gl_FragColor = vec4(0, 0, 0, alpha);
|
|
}
|
|
`,{onLoop:m}=fC();return m(({elapsed:y})=>{g.value&&g.value.children.forEach(v=>{v.material.uniforms.uTime.value=y})}),(y,v)=>{const x=rn("TresOrthographicCamera"),E=rn("TresShapeGeometry"),S=rn("TresShaderMaterial"),C=rn("TresMesh"),L=rn("TresGroup"),A=rn("TresAmbientLight");return Y(),ge("div",rP,[Ue(ee(jC),null,{default:xe(()=>[Ue(x,{ref_key:"camera",ref:n,position:[0,0,10]},null,512),Ue(L,{ref_key:"blobRef",ref:g},{default:xe(()=>[(Y(!0),ge(xt,null,Qt(l.value*c.value,b=>(Y(),Xe(C,{position:[(b%c.value-c.value/2)*304,(Math.floor((b-1)/c.value)-l.value/2)*304,0]},{default:xe(()=>[Ue(E,{args:[ee(r)]},null,8,["args"]),Ue(S,{vertexShader:oP,fragmentShader:p,uniforms:_,blending:ee(Sa)},null,8,["blending"])]),_:2},1032,["position"]))),256))]),_:1},512),Ue(A,{intensity:1}),Ue(iP)]),_:1})])}}}),lP=qe(aP,[["__scopeId","data-v-cef58a07"]]),lo=s=>($t("data-v-4638965c"),s=s(),Xt(),s),cP={class:"vp-doc"},uP=lo(()=>ve("a",{class:"h-card",rel:"me",href:"/about"},[ve("img",{src:pg,alt:""}),qt("The Paper Pilot")],-1)),hP=lo(()=>ve("a",{rel:"license",href:"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"CC BY-NC-SA 4.0",-1)),dP=lo(()=>ve("div",null,"Any and all opinions listed here are my own and not representative of my employers; future, past and present.",-1)),fP=lo(()=>ve("div",null,[ve("a",{href:"https://resume.incremental.social/thepaperpilot/thepaperpilot"},"Resume"),qt(" (not actively seeking new opportunities).")],-1)),pP=lo(()=>ve("div",null,[qt("Site built from "),ve("a",{href:"https://code.incremental.social/thepaperpilot/pages/commit/a4e47f244fde2f8726efac7d0dfb0b32c7b45465"},"this commit"),qt(" on "),ve("time",null,"Thursday, June 20, 2024 at 06:27:48"),qt(".")],-1)),mP=ke({__name:"Layout",setup(s){return(e,t)=>{const n=rn("ClientOnly");return Y(),Xe(ee(vf).Layout,null,{"layout-top":xe(()=>[Ue(ee(Ax)),Ue(n,null,{default:xe(()=>[(Y(),Xe(fg,null,{default:xe(()=>[Ue(lP)]),_:1}))]),_:1})]),"layout-bottom":xe(()=>[ve("footer",cP,[ve("div",null,[qt("CC "+pt(new Date().getFullYear())+" ",1),uP,qt(". "),hP,qt(".")]),dP,fP,pP])]),_:1})}}}),gP=qe(mP,[["__scopeId","data-v-4638965c"]]),yP={...vf,Layout:gP};export{yP as R,Q0 as c,lt as u};
|